OSDN Git Service

mjpegb: don't return 0 at the end of frame decoding.
authorRonald S. Bultje <rsbultje@gmail.com>
Sat, 18 Feb 2012 00:27:36 +0000 (16:27 -0800)
committerRonald S. Bultje <rsbultje@gmail.com>
Sat, 18 Feb 2012 16:41:45 +0000 (08:41 -0800)
Return 0 indicates "please return the same data again", i.e. it causes
an infinite loop. Instead, return that we consumed the buffer if we
finished decoding succesfully, or return an error if an error occurred.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
libavcodec/mjpegbdec.c

index c89a5bd..10c5add 100644 (file)
@@ -69,7 +69,7 @@ read_header:
     if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
     {
         av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
-        return 0;
+        return AVERROR_INVALIDDATA;
     }
 
     field_size = get_bits_long(&hgb, 32); /* field size */
@@ -149,7 +149,7 @@ read_header:
         picture->quality*= FF_QP2LAMBDA;
     }
 
-    return buf_ptr - buf;
+    return buf_size;
 }
 
 AVCodec ff_mjpegb_decoder = {