avcodec/wcmv: Avoid copying frames if they are unchanged
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 19 Feb 2019 18:05:10 +0000 (19:05 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 25 Feb 2019 17:03:24 +0000 (18:03 +0100)
Improves speed of the testcase by about a factor of 10

Fixes: Timeout
Fixes: 13132/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664190616829952

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/wcmv.c

index f03761b..2988c15 100644 (file)
@@ -56,11 +56,13 @@ static int decode_frame(AVCodecContext *avctx,
     }
 
     bytestream2_init(&gb, avpkt->data, avpkt->size);
+    blocks = bytestream2_get_le16(&gb);
+    if (!blocks)
+        return avpkt->size;
 
     if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
         return ret;
 
-    blocks = bytestream2_get_le16(&gb);
     if (blocks > 5) {
         GetByteContext bgb;
         int x = 0, size;