diff options
author | James Almer <jamrial@gmail.com> | 2020-09-16 21:17:45 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-09-23 10:02:47 -0300 |
commit | bd4ef145c0c1a1f699fd4d9939dba4d7a338a2cf (patch) | |
tree | 8f77eea4b75d9dab331651a80caf6367ac83ffac | |
parent | 003b5c800fef909fa84dd2fae43d66bd434d3f7e (diff) | |
download | ffmpeg-bd4ef145c0c1a1f699fd4d9939dba4d7a338a2cf.tar.gz |
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>
-rw-r--r-- | libavcodec/hevcdec.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index c1de75abe1..1f3ea54d39 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -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 |