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.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -1252,26 +1252,27 @@ static int h264_export_frame_props(H264Context *h) · 1251 unmodified lines | |||
| 1252 | if (h->sei.picture_timing.timecode_cnt > 0) { | 1252 | if (h->sei.picture_timing.timecode_cnt > 0) { |
| 1253 | uint32_t *tc_sd; | 1253 | uint32_t *tc_sd; |
| 1254 | char tcbuf[AV_TIMECODE_STR_SIZE]; | 1254 | char tcbuf[AV_TIMECODE_STR_SIZE]; |
| 1255 | AVFrameSideData *tcside; | ||
| 1256 | ret = ff_frame_new_side_data(h->avctx, out, AV_FRAME_DATA_S12M_TIMECODE, | ||
| 1257 | sizeof(uint32_t)*4, &tcside); | ||
| 1258 | if (ret < 0) | ||
| 1259 | return ret; | ||
| 1260 | |||
| 1261 | if (tcside) { | ||
| 1262 | tc_sd = (uint32_t*)tcside->data; | ||
| 1263 | tc_sd[0] = h->sei.picture_timing.timecode_cnt; | ||
| 1255 | 1264 | ||
| 1256 | AVFrameSideData *tcside = av_frame_new_side_data(out, | 1265 | for (int i = 0; i < tc_sd[0]; i++) { |
| 1257 | AV_FRAME_DATA_S12M_TIMECODE, | 1266 | int drop = h->sei.picture_timing.timecode[i].dropframe; |
| 1258 | sizeof(uint32_t)*4); | 1267 | int hh = h->sei.picture_timing.timecode[i].hours; |
| 1259 | if (!tcside) | 1268 | int mm = h->sei.picture_timing.timecode[i].minutes; |
| 1260 | return AVERROR(ENOMEM); | 1269 | int ss = h->sei.picture_timing.timecode[i].seconds; |
| 1261 | 1270 | int ff = h->sei.picture_timing.timecode[i].frame; | |
| 1262 | tc_sd = (uint32_t*)tcside->data; | 1271 | |
| 1263 | tc_sd[0] = h->sei.picture_timing.timecode_cnt; | 1272 | tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); |
| 1264 | 1273 | av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0); | |
| 1265 | for (int i = 0; i < tc_sd[0]; i++) { | 1274 | av_dict_set(&out->metadata, "timecode", tcbuf, 0); |
| 1266 | int drop = h->sei.picture_timing.timecode[i].dropframe; | 1275 | } |
| 1267 | int hh = h->sei.picture_timing.timecode[i].hours; | ||
| 1268 | int mm = h->sei.picture_timing.timecode[i].minutes; | ||
| 1269 | int ss = h->sei.picture_timing.timecode[i].seconds; | ||
| 1270 | int ff = h->sei.picture_timing.timecode[i].frame; | ||
| 1271 | |||
| 1272 | tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); | ||
| 1273 | av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0); | ||
| 1274 | av_dict_set(&out->metadata, "timecode", tcbuf, 0); | ||
| 1275 | } | 1276 | } |
| 1276 | h->sei.picture_timing.timecode_cnt = 0; | 1277 | h->sei.picture_timing.timecode_cnt = 0; |
| 1277 | } | 1278 | } |