aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-02-17 21:47:50 +0100
committerAnton Khirnov <anton@khirnov.net>2024-03-08 07:37:56 +0100
commiteec01ef65faf0a42e6138f7fe7dce28a237c297e (patch)
treedf24c4edc8c5d9d8d6dca00eec43eea87b2a423c /libavcodec
parent2c2d3d5acbb46cf450cad708163a65e4831a61f4 (diff)
downloadffmpeg-eec01ef65faf0a42e6138f7fe7dce28a237c297e.tar.gz
avcodec/h264_slice: 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.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264_slice.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 14791a8181..e9a404e41b 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1252,26 +1252,27 @@ static int h264_export_frame_props(H264Context *h)
if (h->sei.picture_timing.timecode_cnt > 0) {
uint32_t *tc_sd;
char tcbuf[AV_TIMECODE_STR_SIZE];
+ AVFrameSideData *tcside;
+ ret = ff_frame_new_side_data(h->avctx, out, AV_FRAME_DATA_S12M_TIMECODE,
+ sizeof(uint32_t)*4, &tcside);
+ if (ret < 0)
+ return ret;
+
+ if (tcside) {
+ tc_sd = (uint32_t*)tcside->data;
+ tc_sd[0] = h->sei.picture_timing.timecode_cnt;
- AVFrameSideData *tcside = av_frame_new_side_data(out,
- AV_FRAME_DATA_S12M_TIMECODE,
- sizeof(uint32_t)*4);
- if (!tcside)
- return AVERROR(ENOMEM);
-
- tc_sd = (uint32_t*)tcside->data;
- tc_sd[0] = h->sei.picture_timing.timecode_cnt;
-
- for (int i = 0; i < tc_sd[0]; i++) {
- int drop = h->sei.picture_timing.timecode[i].dropframe;
- int hh = h->sei.picture_timing.timecode[i].hours;
- int mm = h->sei.picture_timing.timecode[i].minutes;
- int ss = h->sei.picture_timing.timecode[i].seconds;
- int ff = h->sei.picture_timing.timecode[i].frame;
-
- tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff);
- av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0);
- av_dict_set(&out->metadata, "timecode", tcbuf, 0);
+ for (int i = 0; i < tc_sd[0]; i++) {
+ int drop = h->sei.picture_timing.timecode[i].dropframe;
+ int hh = h->sei.picture_timing.timecode[i].hours;
+ int mm = h->sei.picture_timing.timecode[i].minutes;
+ int ss = h->sei.picture_timing.timecode[i].seconds;
+ int ff = h->sei.picture_timing.timecode[i].frame;
+
+ tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff);
+ av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0);
+ av_dict_set(&out->metadata, "timecode", tcbuf, 0);
+ }
}
h->sei.picture_timing.timecode_cnt = 0;
}