]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vp9_parser.c
avcodec: Constify all the AVCodecParsers
[ffmpeg] / libavcodec / vp9_parser.c
index 9531f34a32531dc1a4d86428e1314a21e187e18e..ffcb93505f24d5f621a38b2a9d292d99844761ce 100644 (file)
@@ -36,12 +36,16 @@ static int parse(AVCodecParserContext *ctx,
     *out_data = data;
     *out_size = size;
 
-    if ((res = init_get_bits8(&gb, data, size)) < 0)
+    if (!size || (res = init_get_bits8(&gb, data, size)) < 0)
         return size; // parsers can't return errors
     get_bits(&gb, 2); // frame marker
     profile  = get_bits1(&gb);
     profile |= get_bits1(&gb) << 1;
     if (profile == 3) profile += get_bits1(&gb);
+    if (profile > 3)
+        return size;
+
+    avctx->profile = profile;
 
     if (get_bits1(&gb)) {
         keyframe = 0;
@@ -60,7 +64,7 @@ static int parse(AVCodecParserContext *ctx,
     return size;
 }
 
-AVCodecParser ff_vp9_parser = {
+const AVCodecParser ff_vp9_parser = {
     .codec_ids      = { AV_CODEC_ID_VP9 },
     .parser_parse   = parse,
 };