[FFmpeg-devel] libavdevice/decklink trivial patch for SDI input/output

Baldur Gislason turbobaldur at gmail.com
Thu Sep 6 17:07:01 EEST 2018


Sending this again as the mime type was wrong for the patch on the last message.
I have prepared a patch that adds two things.
On the Decklink input side, it adds a parameter called 'passthrough'
which makes it possible to change from the default behaviour on cards
that can handle both inputs and outputs. The default behaviour on such
cards depends on the model but many of them will pass through the
input signal if the application generating the output stops. This is
not always desirable so the Decklink API provides a method of changing
it.

On the output side, it adds a parameter called 'sdi_link' which is
crucial when working with SDI output cards that support 3G SDI or
faster. The default behaviour for 1080p60 for example is to use two
HD-SDI links and the default for 2160p29.97 is to use four HD-SDI
links. This option makes it possible to specify how many SDI links are
to be used to make use of 3G, 6G or 12G SDI capabilities of newer
cards which can output those configurations over a single cable.

Baldur Gislason
-------------- next part --------------
From 4620016823015757c647662cf2815b7d9cbb69cb Mon Sep 17 00:00:00 2001
From: Baldur Gislason <baldur at foo.is>
Date: Thu, 6 Sep 2018 13:27:01 +0000
Subject: [PATCH] Adding options to disable Decklink passthrough on capture as
 well as control the output link configuration.

---
 libavdevice/decklink_common.cpp | 12 ++++++++++++
 libavdevice/decklink_common_c.h |  2 ++
 libavdevice/decklink_dec_c.c    |  4 ++++
 libavdevice/decklink_enc.cpp    | 13 +++++++++++++
 libavdevice/decklink_enc_c.c    |  1 +
 5 files changed, 32 insertions(+)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index aab9d85b94..35d9aa636b 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -352,6 +352,18 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
 
     if (direction == DIRECTION_IN) {
         int ret;
+        switch(cctx->passthrough) {
+            case 0:
+            ctx->cfg->SetInt(bmdDeckLinkConfigCapturePassThroughMode, bmdDeckLinkCapturePassthroughModeDirect);
+            break;
+            case 1:
+            ctx->cfg->SetInt(bmdDeckLinkConfigCapturePassThroughMode, bmdDeckLinkCapturePassthroughModeCleanSwitch);
+            break;
+            case 2:
+            ctx->cfg->SetInt(bmdDeckLinkConfigCapturePassThroughMode, bmdDeckLinkCapturePassthroughModeDisabled);
+            break;
+        }
+
         ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection);
         if (ret < 0)
             return ret;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 32a5d70ee1..0e30ec44b9 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -53,6 +53,8 @@ struct decklink_cctx {
     int tc_format;
     int draw_bars;
     char *format_code;
+    int sdi_link;
+    int passthrough;
     int raw_format;
     int64_t queue_size;
     int copyts;
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 6ab3819375..e9f202b0ad 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -84,6 +84,10 @@ static const AVOption options[] = {
     { "queue_size",    "input queue buffer size",   OFFSET(queue_size),   AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
     { "audio_depth",   "audio bitdepth (16 or 32)", OFFSET(audio_depth),  AV_OPT_TYPE_INT,   { .i64 = 16}, 16, 32, DEC },
     { "decklink_copyts", "copy timestamps, do not remove the initial offset", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
+    { "passthrough",   "monitoring pass through mode", OFFSET(passthrough),  AV_OPT_TYPE_INT,{ .i64 = 0}, 0, 2, DEC, "passthrough" },
+    { "direct",        NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = 0}, 0, 0, DEC, "passthrough" },
+    { "cleanswitch",   NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = 1}, 0, 0, DEC, "passthrough" },
+    { "disabled",      NULL,                                          0,  AV_OPT_TYPE_CONST, { .i64 = 2}, 0, 0, DEC, "passthrough" },
     { NULL },
 };
 
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index ee4c962add..d98d72e847 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -150,6 +150,19 @@ static int decklink_setup_video(AVFormatContext *avctx, AVStream *st)
         return -1;
     }
 
+    switch(cctx->sdi_link) {
+        case 1:
+        ctx->cfg->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, bmdLinkConfigurationSingleLink);
+        break;
+        case 2:
+        ctx->cfg->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, bmdLinkConfigurationDualLink);
+        break;
+        case 4:
+        ctx->cfg->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, bmdLinkConfigurationQuadLink);
+        break;
+    }
+
+
     if (c->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) {
         if (c->format != AV_PIX_FMT_UYVY422) {
             av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format!"
diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
index 360535cfda..ab081a2493 100644
--- a/libavdevice/decklink_enc_c.c
+++ b/libavdevice/decklink_enc_c.c
@@ -31,6 +31,7 @@ static const AVOption options[] = {
     { "list_devices", "list available devices"  , OFFSET(list_devices), AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, ENC },
     { "list_formats", "list supported formats"  , OFFSET(list_formats), AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, ENC },
     { "preroll"     , "video preroll in seconds", OFFSET(preroll     ), AV_OPT_TYPE_DOUBLE, { .dbl = 0.5 }, 0, 5, ENC },
+    { "sdi_link"    , "SDI single(1)/dual(2)/quad(4) link configuration", OFFSET(sdi_link), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, ENC }, 
     { NULL },
 };
 
-- 
2.14.1



More information about the ffmpeg-devel mailing list