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

Devin Heitmueller devin.heitmueller at ltnglobal.com
Wed Jun 7 23:22:27 EEST 2023


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 at ltnglobal.com>
---
 libavdevice/decklink_enc.cpp | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

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
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list