Commit 796027f2 authored by Timothy Gu's avatar Timothy Gu

Merge commit 'd1d76780'

* commit 'd1d76780':
  h264: fix the check for mixed IDR/non-IDR slices

Conflicts:
	libavcodec/h264_slice.c
	libavcodec/h264dec.c
Merged-by: 's avatarTimothy Gu <timothygu99@gmail.com>
parents bca30ed2 d1d76780
...@@ -1497,6 +1497,8 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, ...@@ -1497,6 +1497,8 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
h->nb_mmco = sl->nb_mmco; h->nb_mmco = sl->nb_mmco;
h->explicit_ref_marking = sl->explicit_ref_marking; 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 /* 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 * field coded frames, since some SEI information is present for each field
* and is merged by the SEI parsing code. */ * and is merged by the SEI parsing code. */
...@@ -1829,6 +1831,11 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, ...@@ -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); av_assert1(h->mb_num == h->mb_width * h->mb_height);
if (sl->first_mb_addr << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num || if (sl->first_mb_addr << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
sl->first_mb_addr >= h->mb_num) { sl->first_mb_addr >= h->mb_num) {
......
...@@ -783,12 +783,6 @@ again: ...@@ -783,12 +783,6 @@ again:
ret = -1; ret = -1;
goto end; 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(!idr_cleared) {
if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) { 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"); av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
......
...@@ -384,6 +384,11 @@ typedef struct H264Context { ...@@ -384,6 +384,11 @@ typedef struct H264Context {
*/ */
int postpone_filter; int postpone_filter;
/*
* Set to 1 when the current picture is IDR, 0 otherwise.
*/
int picture_idr;
int8_t(*intra4x4_pred_mode); int8_t(*intra4x4_pred_mode);
H264PredContext hpc; H264PredContext hpc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment