On 10/12/11 13:08, Janne Grunau wrote:
I'm not sure if it might be better to return an error but if it's
caused by incorrectly splitted frames an error should be return
if the rest of the frame is passed to decode() and doesn't start
with a frame header.
The main intention was to fix the warning/error.
Janne
---8<---
Return the whole packet as consumed in this case and not the size the
packet should have had. Move the insufficient data check into the for
condition to fix a ISO C90 error on bigendian.
---
libavcodec/ptx.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c
index eee0d58..75b42d5 100644
--- a/libavcodec/ptx.c
+++ b/libavcodec/ptx.c
@@ -84,9 +84,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void
*data, int *data_size,
ptr = p->data[0];
stride = p->linesize[0];
- for (y=0; y<h; y++) {
- if (buf_end - buf< w * bytes_per_pixel)
- break;
+ for (y = 0; y< h&& buf_end - buf< w * bytes_per_pixel; y++) {
not sure if the long for line might be nice split per element.
#if HAVE_BIGENDIAN
unsigned int x;
for (x=0; x<w*bytes_per_pixel; x+=bytes_per_pixel)
@@ -101,6 +99,11 @@ static int ptx_decode_frame(AVCodecContext *avctx, void
*data, int *data_size,
*picture = s->picture;
*data_size = sizeof(AVPicture);
+ if (y< h) {
+ av_log(avctx, AV_LOG_WARNING, "incomplete packet\n");
+ return avpkt->size;
+ }
+
return offset + w*h*bytes_per_pixel;
}
Beside that look ok.
lu
--
Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel