]> git.sesse.net Git - ffmpeg/commitdiff
parsers: initialize MpegEncContext.slice_context_count to 1
authorJanne Grunau <janne-libav@jannau.net>
Thu, 5 Jan 2012 23:17:37 +0000 (00:17 +0100)
committerJanne Grunau <janne-libav@jannau.net>
Fri, 6 Jan 2012 00:47:45 +0000 (01:47 +0100)
The mpeg4 video, H264 and VC-1 parser hold (directly or indirectly)
a MpegEncContext in their private context. Since they do not call the
common mpegvideo init function slice_context_count has explicitly set
to 1.
Prevents a null pointer dereference in the h264 parser and fixes
bug 193.

libavcodec/h264_parser.c
libavcodec/mpeg4video_parser.c
libavcodec/vc1_parser.c

index 826c17a0f1e415d23add71bfa17b8e2ce69d1521..bcaa04a11585f064352a5a61a417accff6ff7c26 100644 (file)
@@ -330,6 +330,7 @@ static int init(AVCodecParserContext *s)
 {
     H264Context *h = s->priv_data;
     h->thread_context[0] = h;
+    h->s.slice_context_count = 1;
     return 0;
 }
 
index 162bc1d03e58b409267f4592ba86c00cd53ef264..89bbf3465d9e60c92b9b14459569ec75de3a7578 100644 (file)
@@ -99,6 +99,7 @@ static av_cold int mpeg4video_parse_init(AVCodecParserContext *s)
     if (!pc->enc)
         return -1;
     pc->first_picture = 1;
+    pc->enc->slice_context_count = 1;
     return 0;
 }
 
index e6243d9ac00bff85268ef86b79fcdd0651fbb959..0cc5ea0fa81dfcb9a9b7b4adea61c42c3f85bb82 100644 (file)
@@ -184,9 +184,17 @@ static int vc1_split(AVCodecContext *avctx,
     return 0;
 }
 
+static int vc1_parse_init(AVCodecParserContext *s)
+{
+    VC1ParseContext *vpc = s->priv_data;
+    vpc->v.s.slice_context_count = 1;
+    return 0;
+}
+
 AVCodecParser ff_vc1_parser = {
     .codec_ids      = { CODEC_ID_VC1 },
     .priv_data_size = sizeof(VC1ParseContext),
+    .parser_init    = vc1_parse_init,
     .parser_parse   = vc1_parse,
     .parser_close   = ff_parse1_close,
     .split          = vc1_split,