X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264.c;h=933c58234157174995cb46a19577139ac6200243;hb=68f48406069e9aff0c01c96671f7c58de166e1f8;hp=11f1055882535f78e714b75e89f3d1127600c7a2;hpb=4b7356ce8f2c7902a9b97645f86e0ae09bc2676c;p=ffmpeg diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 11f10558825..933c5823415 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -619,8 +619,6 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) h->bit_depth_luma = 8; h->chroma_format_idc = 1; - h->cur_chroma_format_idc = 1; - ff_h264dsp_init(&h->h264dsp, 8, 1); av_assert0(h->sps.bit_depth_chroma == 0); ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma); @@ -632,6 +630,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) /* needed so that IDCT permutation is known early */ ff_videodsp_init(&h->vdsp, 8); + h->cur_chroma_format_idc = -1; memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t)); memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t)); @@ -705,7 +704,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) if (h->enable_er < 0 && (avctx->active_thread_type & FF_THREAD_SLICE)) h->enable_er = 0; - if (h->enable_er) { + if (h->enable_er && (avctx->active_thread_type & FF_THREAD_SLICE)) { av_log(avctx, AV_LOG_WARNING, "Error resilience with slice threads is enabled. It is unsafe and unsupported and may crash. " "Use it at your own risk\n"); @@ -1548,8 +1547,14 @@ again: ret = -1; goto end; } - if(!idr_cleared) + 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 NAL_SLICE: @@ -1598,7 +1603,7 @@ again: if (h->avctx->hwaccel && (ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0) - return ret; + goto end; if (CONFIG_H264_VDPAU_DECODER && h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_h264_picture_start(h); @@ -1610,7 +1615,7 @@ again: &buf[buf_index - consumed], consumed); if (ret < 0) - return ret; + goto end; } else if (CONFIG_H264_VDPAU_DECODER && h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) { ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],