diff mbox series

[FFmpeg-devel,4/4] avdevice/decklink_dec: export timecode with s12m side data

Message ID 1592577334-19049-4-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/4] avfilter/vf_drawtext: add option to draw timecode in S12M side data
Related show

Checks

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

Commit Message

Limin Wang June 19, 2020, 2:35 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavdevice/decklink_dec.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 82106aa..2bcdadd 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -41,6 +41,7 @@  extern "C" {
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/time.h"
+#include "libavutil/timecode.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/reverse.h"
 #include "avdevice.h"
@@ -778,6 +779,18 @@  HRESULT decklink_input_callback::VideoInputFrameArrived(
                         AVDictionary* metadata_dict = NULL;
                         int metadata_len;
                         uint8_t* packed_metadata;
+                        uint32_t tc_data;
+                        uint8_t *s12m_data;
+                        int s12m_size = sizeof(uint32_t) * 4;
+
+                        if ((tc_data = av_timecode_get_smpte_by_tc_string(tc)) > 0) {
+                            s12m_data = av_packet_new_side_data(&pkt, AV_PKT_DATA_S12M_TIMECODE, s12m_size);
+                            if (s12m_data) {
+                                AV_WL32(s12m_data, 1); // one TC ;
+                                AV_WL32(s12m_data + 4, tc_data); // TC;
+                            }
+                        }
+
                         if (av_dict_set(&metadata_dict, "timecode", tc, AV_DICT_DONT_STRDUP_VAL) >= 0) {
                             packed_metadata = av_packet_pack_dictionary(metadata_dict, &metadata_len);
                             av_dict_free(&metadata_dict);