[FFmpeg-cvslog] avcodec/vp9_parser: Check the input frame sizes for being consistent

Michael Niedermayer git at videolan.org
Fri Aug 26 15:41:03 EEST 2016


ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Mon Aug  1 13:50:21 2016 +0200| [da12d544bf0b28f0af78af2b9ce00ad791218472] | committer: Michael Niedermayer

avcodec/vp9_parser: Check the input frame sizes for being consistent

Suggested-by: BBB
Fixed-by: BBB
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 77b0f3f26d33d4f46f274896e0583ad1f5936b7c)

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da12d544bf0b28f0af78af2b9ce00ad791218472
---

 libavcodec/vp9_parser.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c
index f1f7e35..2d622ac 100644
--- a/libavcodec/vp9_parser.c
+++ b/libavcodec/vp9_parser.c
@@ -28,6 +28,7 @@
 typedef struct VP9ParseContext {
     int n_frames; // 1-8
     int size[8];
+    int marker_size;
     int64_t pts;
 } VP9ParseContext;
 
@@ -89,6 +90,21 @@ static int parse(AVCodecParserContext *ctx,
     }
 
     if (s->n_frames > 0) {
+        int i;
+        int size_sum = 0;
+
+        for (i = 0; i < s->n_frames ;i++)
+            size_sum += s->size[i];
+        size_sum += s->marker_size;
+
+        if (size_sum != size) {
+            av_log(avctx, AV_LOG_ERROR, "Inconsistent input frame sizes %d %d\n",
+                   size_sum, size);
+            s->n_frames = 0;
+        }
+    }
+
+    if (s->n_frames > 0) {
         *out_data = data;
         *out_size = s->size[--s->n_frames];
         parse_frame(ctx, *out_data, *out_size);
@@ -131,6 +147,7 @@ static int parse(AVCodecParserContext *ctx,
                     data += sz; \
                     size -= sz; \
                 } \
+                s->marker_size = size; \
                 parse_frame(ctx, *out_data, *out_size); \
                 return *out_size
 



More information about the ffmpeg-cvslog mailing list