ffmpeg | branch: master | Anton Khirnov <an...@khirnov.net> | Fri May 20 11:04:55 2016 +0200| [d1d7678040cd60148f97b372cb4291bcc45b2e22] | committer: Anton Khirnov
h264: fix the check for mixed IDR/non-IDR slices > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1d7678040cd60148f97b372cb4291bcc45b2e22 --- 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 3218022..244640f 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1333,6 +1333,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. */ @@ -1599,6 +1601,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; + } + assert(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 cc5bdca..c99f6e6 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -694,12 +694,6 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) err = 0; switch (nal->type) { case H264_NAL_IDR_SLICE: - 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; - } idr(h); // FIXME ensure we don't lose some frames if there is reordering case H264_NAL_SLICE: sl->gb = nal->gb; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index e422871..6f3c437 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -366,6 +366,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; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog