diff mbox series

[FFmpeg-devel,4/6] avcodec/hevcdec: export S12M timecode side data

Message ID 1594769402-22526-4-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/6] avcodec: add AV_CODEC_EXPORT_DATA_S12M_TC flag to export S12M timecode | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Lance Wang July 14, 2020, 11:30 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/hevcdec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index b77df8d..6e24c9b 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2827,6 +2827,7 @@  static int set_side_data(HEVCContext *s)
     if (s->sei.timecode.present) {
         uint32_t *tc_sd;
         char tcbuf[AV_TIMECODE_STR_SIZE];
+        uint32_t *s12m_sd;
         AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE,
                                                          sizeof(uint32_t) * 4);
         if (!tcside)
@@ -2834,6 +2835,12 @@  static int set_side_data(HEVCContext *s)
 
         tc_sd = (uint32_t*)tcside->data;
         tc_sd[0] = s->sei.timecode.num_clock_ts;
+        if (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_S12M_TC) {
+            s12m_sd = ff_add_s12m_timecode_side_data(s->avctx);
+            if (!s12m_sd)
+                return AVERROR(ENOMEM);
+            s12m_sd[0] = tc_sd[0];
+        }
 
         for (int i = 0; i < tc_sd[0]; i++) {
             int drop = s->sei.timecode.cnt_dropped_flag[i];
@@ -2843,6 +2850,9 @@  static int set_side_data(HEVCContext *s)
             int   ff = s->sei.timecode.n_frames[i];
 
             tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff);
+            if (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_S12M_TC) {
+                s12m_sd[i + 1] = tc_sd[i + 1];
+            }
             av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0);
             av_dict_set(&out->metadata, "timecode", tcbuf, 0);
         }