diff options
author | Niklas Haas <git@haasn.dev> | 2024-02-17 21:48:48 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-03-08 07:37:56 +0100 |
commit | b9565db9a0a14b3fcfaf645be8363849a4583473 (patch) | |
tree | b1ceb7f1c3499d0cf01fe2b6b4df6d8d9a61f5ed | |
parent | d9f1b321cf58a85518d29c5a3d220d67b1a68b92 (diff) | |
download | ffmpeg-b9565db9a0a14b3fcfaf645be8363849a4583473.tar.gz |
avcodec/hevcdec: respect side data preference
If the time code side data is overridden by the packet level, we also
make sure not to update `out->metadata` to a mismatched timecode.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r-- | libavcodec/hevcdec.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 17c6a9212f..76aa6b4588 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2788,24 +2788,27 @@ static int set_side_data(HEVCContext *s) if (s->sei.timecode.present) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; - AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, - sizeof(uint32_t) * 4); - if (!tcside) - return AVERROR(ENOMEM); + AVFrameSideData *tcside; + ret = ff_frame_new_side_data(s->avctx, out, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t) * 4, &tcside); + if (ret < 0) + return ret; - tc_sd = (uint32_t*)tcside->data; - tc_sd[0] = s->sei.timecode.num_clock_ts; + if (tcside) { + tc_sd = (uint32_t*)tcside->data; + tc_sd[0] = s->sei.timecode.num_clock_ts; - for (int i = 0; i < tc_sd[0]; i++) { - int drop = s->sei.timecode.cnt_dropped_flag[i]; - int hh = s->sei.timecode.hours_value[i]; - int mm = s->sei.timecode.minutes_value[i]; - int ss = s->sei.timecode.seconds_value[i]; - int ff = s->sei.timecode.n_frames[i]; + for (int i = 0; i < tc_sd[0]; i++) { + int drop = s->sei.timecode.cnt_dropped_flag[i]; + int hh = s->sei.timecode.hours_value[i]; + int mm = s->sei.timecode.minutes_value[i]; + int ss = s->sei.timecode.seconds_value[i]; + int ff = s->sei.timecode.n_frames[i]; - tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); - av_timecode_make_smpte_tc_string2(tcbuf, s->avctx->framerate, tc_sd[i + 1], 0, 0); - av_dict_set(&out->metadata, "timecode", tcbuf, 0); + tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); + av_timecode_make_smpte_tc_string2(tcbuf, s->avctx->framerate, tc_sd[i + 1], 0, 0); + av_dict_set(&out->metadata, "timecode", tcbuf, 0); + } } s->sei.timecode.num_clock_ts = 0; @@ -2816,10 +2819,9 @@ static int set_side_data(HEVCContext *s) if (!info_ref) return AVERROR(ENOMEM); - if (!av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_DYNAMIC_HDR_PLUS, info_ref)) { - av_buffer_unref(&info_ref); - return AVERROR(ENOMEM); - } + ret = ff_frame_new_side_data_from_buf(s->avctx, out, AV_FRAME_DATA_DYNAMIC_HDR_PLUS, &info_ref, NULL); + if (ret < 0) + return ret; } if (s->rpu_buf) { |