[FFmpeg-devel] [PATCH] eatgq: raise error on unsupported macroblock mode

Peter Ross pross at xvid.org
Sun Oct 14 13:11:42 CEST 2012


---
Updated patch. 
Yes, should we encounter an unknown MB mode, the remainder of the frame is going to be trashed.
Thanks Paul. 

 libavcodec/eatgq.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index 5114b20..4791262 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -141,7 +141,10 @@ static void tgq_idct_put_mb_dconly(TgqContext *s, int mb_x, int mb_y, const int8
     }
 }
 
-static void tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){
+/**
+ * @return <0 on error
+ */
+static int tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){
     int mode;
     int i;
     int8_t dc[6];
@@ -168,9 +171,11 @@ static void tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){
             }
         }else{
             av_log(s->avctx, AV_LOG_ERROR, "unsupported mb mode %i\n", mode);
+            return -1;
         }
         tgq_idct_put_mb_dconly(s, mb_x, mb_y, dc);
     }
+    return 0;
 }
 
 static void tgq_calculate_qtable(TgqContext *s, int quant){
@@ -224,7 +229,8 @@ static int tgq_decode_frame(AVCodecContext *avctx,
 
     for (y = 0; y < FFALIGN(avctx->height, 16) >> 4; y++)
         for (x = 0; x < FFALIGN(avctx->width, 16) >> 4; x++)
-            tgq_decode_mb(s, y, x);
+            if (tgq_decode_mb(s, y, x) < 0)
+                return AVERROR_INVALIDDATA;
 
     *data_size = sizeof(AVFrame);
     *(AVFrame*)data = s->frame;
-- 
1.7.10.4

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121014/1111a48e/attachment.asc>


More information about the ffmpeg-devel mailing list