[FFmpeg-cvslog] avcodec/hevcdec: sync SEI derived AVCodecContext fields across threads
James Almer
git at videolan.org
Wed Sep 23 16:23:52 EEST 2020
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Sep 16 21:17:45 2020 -0300| [bd4ef145c0c1a1f699fd4d9939dba4d7a338a2cf] | committer: James Almer
avcodec/hevcdec: sync SEI derived AVCodecContext fields across threads
Fixes ticket #8610.
Found-by: Pavel Koshevoy <pkoshevoy at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bd4ef145c0c1a1f699fd4d9939dba4d7a338a2cf
---
libavcodec/hevcdec.c | 25 +++++++++++++++++++++++--
1 file 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
More information about the ffmpeg-cvslog
mailing list