+ for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
+ H264SEIUnregistered *unreg = &h->sei.unregistered;
+
+ if (unreg->buf_ref[i]) {
+ AVFrameSideData *sd = av_frame_new_side_data_from_buf(out,
+ AV_FRAME_DATA_SEI_UNREGISTERED,
+ unreg->buf_ref[i]);
+ if (!sd)
+ av_buffer_unref(&unreg->buf_ref[i]);
+ unreg->buf_ref[i] = NULL;
+ }
+ }
+ h->sei.unregistered.nb_buf_ref = 0;
+
+ if (h->sei.picture_timing.timecode_cnt > 0) {
+ 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);
+
+ 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);
+ }
+ h->sei.picture_timing.timecode_cnt = 0;