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

@@@ -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");
@@@ -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