]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'd1d7678040cd60148f97b372cb4291bcc45b2e22'
authorTimothy Gu <timothygu99@gmail.com>
Wed, 3 Aug 2016 22:59:51 +0000 (15:59 -0700)
committerTimothy Gu <timothygu99@gmail.com>
Wed, 3 Aug 2016 22:59:51 +0000 (15:59 -0700)
* commit 'd1d7678040cd60148f97b372cb4291bcc45b2e22':
  h264: fix the check for mixed IDR/non-IDR slices

Conflicts:
libavcodec/h264_slice.c
libavcodec/h264dec.c

Merged-by: Timothy Gu <timothygu99@gmail.com>
1  2 
libavcodec/h264_slice.c
libavcodec/h264dec.c
libavcodec/h264dec.h

index f32a74aea0f72ec039ce5345b8e8eec72c98062b,244640fa59c9ecaf7f720864b0b90b51c59943e3..ade41f5d35269bb1e1c0767def45f8b6fd412e1f
@@@ -1829,7 -1601,12 +1831,12 @@@ int ff_h264_decode_slice_header(H264Con
          }
      }
  
 -    assert(h->mb_num == h->mb_width * h->mb_height);
+     if (h->picture_idr && nal->type != H264_NAL_IDR_SLICE) {
+         av_log(h->avctx, AV_LOG_ERROR, "Invalid mix of IDR and non-IDR slices\n");
+         return AVERROR_INVALIDDATA;
+     }
 +    av_assert1(h->mb_num == h->mb_width * h->mb_height);
      if (sl->first_mb_addr << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
          sl->first_mb_addr >= h->mb_num) {
          av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
index 323639dc19bfa1f7d4d2b750c2a0bf3a73e7a35f,c99f6e6ec7f65640517e798f093772d43efc3aa0..977977431e692b1b3751449927af6954ed04ecb5
@@@ -777,28 -694,7 +777,22 @@@ again
          err = 0;
          switch (nal->type) {
          case H264_NAL_IDR_SLICE:
 -            idr(h); // FIXME ensure we don't lose some frames if there is reordering
 +            if ((nal->data[1] & 0xFC) == 0x98) {
 +                av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
 +                h->next_outputed_poc = INT_MIN;
 +                ret = -1;
 +                goto end;
 +            }
-             if (nal->type != H264_NAL_IDR_SLICE) {
-                 av_log(h->avctx, AV_LOG_ERROR,
-                        "Invalid mix of idr and non-idr slices\n");
-                 ret = -1;
-                 goto end;
-             }
 +            if(!idr_cleared) {
 +                if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
 +                    av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
 +                    ret = AVERROR_INVALIDDATA;
 +                    goto end;
 +                }
 +                idr(h); // FIXME ensure we don't lose some frames if there is reordering
 +            }
 +            idr_cleared = 1;
 +            h->has_recovery_point = 1;
          case H264_NAL_SLICE:
              sl->gb = nal->gb;
  
Simple merge