ffmpeg | branch: master | Timothy Gu <timothyg...@gmail.com> | Wed Aug 3 15:59:51 2016 -0700| [796027f22154c799e0063e2457b31e0cfd1dddae] | committer: Timothy Gu
Merge commit 'd1d7678040cd60148f97b372cb4291bcc45b2e22' * commit 'd1d7678040cd60148f97b372cb4291bcc45b2e22': h264: fix the check for mixed IDR/non-IDR slices Conflicts: libavcodec/h264_slice.c libavcodec/h264dec.c Merged-by: Timothy Gu <timothyg...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=796027f22154c799e0063e2457b31e0cfd1dddae --- libavcodec/h264_slice.c | 7 +++++++ libavcodec/h264dec.c | 6 ------ libavcodec/h264dec.h | 5 +++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index f32a74a..ade41f5 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1497,6 +1497,8 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, h->nb_mmco = sl->nb_mmco; h->explicit_ref_marking = sl->explicit_ref_marking; + h->picture_idr = nal->type == H264_NAL_IDR_SLICE; + /* Set the frame properties/side data. Only done for the second field in * field coded frames, since some SEI information is present for each field * and is merged by the SEI parsing code. */ @@ -1829,6 +1831,11 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, } } + 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) { diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 323639d..9779774 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -783,12 +783,6 @@ again: 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"); diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 9483efb..3034a93 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -384,6 +384,11 @@ typedef struct H264Context { */ int postpone_filter; + /* + * Set to 1 when the current picture is IDR, 0 otherwise. + */ + int picture_idr; + int8_t(*intra4x4_pred_mode); H264PredContext hpc; ====================================================================== diff --cc libavcodec/h264_slice.c index f32a74a,244640f..ade41f5 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@@ -1829,7 -1601,12 +1831,12 @@@ int ff_h264_decode_slice_header(H264Con } } + 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; + } + - assert(h->mb_num == h->mb_width * h->mb_height); + 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"); diff --cc libavcodec/h264dec.c index 323639d,c99f6e6..9779774 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@@ -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; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog