diff mbox series

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

Message ID 1594615577-32485-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit a54b367c781f7735c321e6ac08a5deebeb9796a9
Headers show
Series None | expand

Commit Message

Limin Wang July 13, 2020, 4:46 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavdevice/decklink_dec.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Limin Wang July 14, 2020, 10:59 a.m. UTC | #1
On Mon, Jul 13, 2020 at 12:46:17PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Reviewed-by: Marton Balint <cus@passwd.hu>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavdevice/decklink_dec.cpp | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
> index a499972..dde68ff 100644
> --- a/libavdevice/decklink_dec.cpp
> +++ b/libavdevice/decklink_dec.cpp
> @@ -42,6 +42,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"
> @@ -882,6 +883,19 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
>                          AVDictionary* metadata_dict = NULL;
>                          int metadata_len;
>                          uint8_t* packed_metadata;
> +                        AVTimecode tcr;
> +
> +                        if (av_timecode_init_from_string(&tcr, ctx->video_st->r_frame_rate, tc, ctx) >= 0) {
> +                            uint32_t tc_data = av_timecode_get_smpte_from_framenum(&tcr, 0);
> +                            int size = sizeof(uint32_t) * 4;
> +                            uint32_t *sd = (uint32_t *)av_packet_new_side_data(&pkt, AV_PKT_DATA_S12M_TIMECODE, size);
> +
> +                            if (sd) {
> +                                *sd       = 1;       // one TC
> +                                *(sd + 1) = 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);
> -- 
> 1.8.3.1
> 

will apply the patchset tomorrow if no more comments.  I have other change to support > 30FPS
and plan to submit them in separate patch later.
diff mbox series

Patch

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index a499972..dde68ff 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -42,6 +42,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"
@@ -882,6 +883,19 @@  HRESULT decklink_input_callback::VideoInputFrameArrived(
                         AVDictionary* metadata_dict = NULL;
                         int metadata_len;
                         uint8_t* packed_metadata;
+                        AVTimecode tcr;
+
+                        if (av_timecode_init_from_string(&tcr, ctx->video_st->r_frame_rate, tc, ctx) >= 0) {
+                            uint32_t tc_data = av_timecode_get_smpte_from_framenum(&tcr, 0);
+                            int size = sizeof(uint32_t) * 4;
+                            uint32_t *sd = (uint32_t *)av_packet_new_side_data(&pkt, AV_PKT_DATA_S12M_TIMECODE, size);
+
+                            if (sd) {
+                                *sd       = 1;       // one TC
+                                *(sd + 1) = 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);