diff mbox series

[FFmpeg-devel,7/7] avdevice/decklink_enc: Add support for output of bar data as VANC

Message ID 1686169347-28987-8-git-send-email-dheitmueller@ltnglobal.com
State New
Headers show
Series Misc AFD improvements and support for Bar Data | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Devin Heitmueller June 7, 2023, 8:22 p.m. UTC
SMPTE ST2016-3 supports both AFD and bar data within the VANC message.
Extend the existing support to pass through both.

Example usage:

ffmpeg -i input.ts -vf setafd=afd=1:code=0x00:bardata=1:top=100:bottom=120 -f decklink -vcodec v210 'DeckLink Duo (4)'

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
 libavdevice/decklink_enc.cpp | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 6906cb0..5d85d6b 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -447,23 +447,39 @@  static void construct_afd(AVFormatContext *avctx, struct decklink_ctx *ctx,
     struct klvanc_packet_afd_s *afd = NULL;
     uint16_t *afd_words = NULL;
     uint16_t len;
-    size_t size;
+    size_t size, bardata_size;
     int f1_line = 12, f2_line = 0, ret;
 
     const uint8_t *data = av_packet_get_side_data(pkt, AV_PKT_DATA_AFD, &size);
-    if (!data || size == 0)
+    const AVBarData *bardata = (AVBarData *) av_packet_get_side_data(pkt, AV_PKT_DATA_BARDATA, &bardata_size);
+
+    if ((!data || size == 0) && (!bardata || bardata_size != sizeof(AVBarData)))
         return;
 
     ret = klvanc_create_AFD(&afd);
     if (ret)
         return;
 
-    ret = klvanc_set_AFD_val(afd, data[0]);
-    if (ret) {
-        av_log(avctx, AV_LOG_ERROR, "Invalid AFD value specified: %d\n",
-               data[0]);
-        klvanc_destroy_AFD(afd);
-        return;
+    if (data) {
+        ret = klvanc_set_AFD_val(afd, data[0]);
+        if (ret) {
+            av_log(avctx, AV_LOG_ERROR, "Invalid AFD value specified: %d\n",
+                   data[0]);
+            klvanc_destroy_AFD(afd);
+            return;
+        }
+    }
+
+    if (bardata) {
+        if (bardata->top_bottom) {
+            afd->barDataFlags = BARS_TOPBOTTOM;
+            afd->top = bardata->top;
+            afd->bottom = bardata->bottom;
+        } else {
+            afd->barDataFlags = BARS_LEFTRIGHT;
+            afd->left = bardata->left;
+            afd->right = bardata->right;
+        }
     }
 
     /* Compute the AR flag based on the DAR (see ST 2016-1:2009 Sec 9.1).  Note, we treat