]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pafvideo.c
avcodec/decode: add a flags parameter to ff_reget_buffer()
[ffmpeg] / libavcodec / pafvideo.c
index 7c5861dfaf6c609cba1124b19a351bf6f5e5a307..6b4771cbce062ecfb0259a77f824c7914eab046e 100644 (file)
@@ -285,13 +285,14 @@ static int paf_video_decode(AVCodecContext *avctx, void *data,
         return AVERROR_INVALIDDATA;
     }
 
-    if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
+    if ((code & 0xF) == 0 &&
+        c->video_size / 32 - (int64_t)bytestream2_get_bytes_left(&c->gb) > c->video_size / 32 * (int64_t)avctx->discard_damaged_percentage / 100)
+        return AVERROR_INVALIDDATA;
+
+    if ((ret = ff_reget_buffer(avctx, c->pic, 0)) < 0)
         return ret;
 
     if (code & 0x20) {  // frame is keyframe
-        for (i = 0; i < 4; i++)
-            memset(c->frame[i], 0, c->frame_size);
-
         memset(c->pic->data[1], 0, AVPALETTE_SIZE);
         c->current_frame  = 0;
         c->pic->key_frame = 1;
@@ -328,6 +329,10 @@ static int paf_video_decode(AVCodecContext *avctx, void *data,
         c->pic->palette_has_changed = 1;
     }
 
+    if (code & 0x20)
+        for (i = 0; i < 4; i++)
+            memset(c->frame[i], 0, c->frame_size);
+
     switch (code & 0x0F) {
     case 0:
         /* Block-based motion compensation using 4x4 blocks with either