]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/h264_parse: no need check ref list1 for P slices.
authorDecai Lin <decai.lin@intel.com>
Thu, 31 Jan 2019 07:36:56 +0000 (15:36 +0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 8 Feb 2019 11:00:59 +0000 (12:00 +0100)
This is robust for some corner case there is incorrect list1 count
in pps header, but it's a P slice and can be decoded well.

Signed-off-by: Decai Lin <decai.lin@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/h264_parse.c

index 290ab681a992d016501488e0e1b01a7c4be1e6c4..a42cc299ffbaf51286cbc7d5a9a7da33637fd62e 100644 (file)
@@ -242,7 +242,12 @@ int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
                 ref_count[1] = 1;
         }
 
-        if (ref_count[0] - 1 > max[0] || ref_count[1] - 1 > max[1]) {
+        if (slice_type_nos == AV_PICTURE_TYPE_B)
+            list_count = 2;
+        else
+            list_count = 1;
+
+        if (ref_count[0] - 1 > max[0] || (list_count == 2 && (ref_count[1] - 1 > max[1]))) {
             av_log(logctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n",
                    ref_count[0] - 1, max[0], ref_count[1] - 1, max[1]);
             ref_count[0] = ref_count[1] = 0;
@@ -250,10 +255,6 @@ int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
             goto fail;
         }
 
-        if (slice_type_nos == AV_PICTURE_TYPE_B)
-            list_count = 2;
-        else
-            list_count = 1;
     } else {
         list_count   = 0;
         ref_count[0] = ref_count[1] = 0;