1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/hevcdec: sync SEI derived AVCodecContext fields across threads

Fixes ticket #8610.

Found-by: Pavel Koshevoy <pkoshevoy@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2020-09-16 21:17:45 -03:00
parent 003b5c800f
commit bd4ef145c0

View File

@ -369,12 +369,22 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
if (num != 0 && den != 0)
av_reduce(&avctx->framerate.den, &avctx->framerate.num,
num, den, 1 << 30);
}
static int export_stream_params_from_sei(HEVCContext *s)
{
AVCodecContext *avctx = s->avctx;
if (s->sei.a53_caption.buf_ref)
s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
if (s->sei.alternative_transfer.present &&
av_color_transfer_name(s->sei.alternative_transfer.preferred_transfer_characteristics) &&
s->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
avctx->color_trc = s->sei.alternative_transfer.preferred_transfer_characteristics;
}
return 0;
}
static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
@ -582,6 +592,10 @@ static int hls_slice_header(HEVCContext *s)
s->max_ra = INT_MAX;
}
ret = export_stream_params_from_sei(s);
if (ret < 0)
return ret;
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
@ -2806,8 +2820,6 @@ static int set_side_data(HEVCContext *s)
if (!sd)
av_buffer_unref(&a53->buf_ref);
a53->buf_ref = NULL;
s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
}
for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) {
@ -3250,6 +3262,11 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int f
}
}
/* export stream parameters from SEI */
ret = export_stream_params_from_sei(s);
if (ret < 0)
return ret;
return 0;
}
@ -3537,6 +3554,10 @@ static int hevc_update_thread_context(AVCodecContext *dst,
s->sei.content_light = s0->sei.content_light;
s->sei.alternative_transfer = s0->sei.alternative_transfer;
ret = export_stream_params_from_sei(s);
if (ret < 0)
return ret;
return 0;
}
#endif