diff mbox series

[FFmpeg-devel,3/4] avdevice/decklink: add levelA configure

Message ID 1628037188-8826-3-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/4] avdevice/decklink: add link configuration
Related show

Checks

Context Check Description
andriy/configure warning Failed to apply patch
andriy/configure warning Failed to apply patch

Commit Message

Limin Wang Aug. 4, 2021, 12:33 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 doc/outdevs.texi                |  4 ++++
 libavdevice/decklink_common.cpp | 17 +++++++++++++++++
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_enc_c.c    |  1 +
 4 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index 488b1e4..ba52df7 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -214,6 +214,10 @@  Defaults to @samp{unset}.
 If set to @option{true},  Quad-link SDI is output in Square Division Quad Split mode.
 Defaults to @option{false}.
 
+@item levelA
+If set to @option{true}, SMPTE Level A is enable on the used output.
+Defaults to @option{false}.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index bb69a54..46e9768 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -234,6 +234,23 @@  int ff_decklink_set_configs(AVFormatContext *avctx,
         }
     }
 
+    if (direction == DIRECTION_OUT && cctx->levelA) {
+        DECKLINK_BOOL levelA_supported = false;
+
+        if (ctx->attr->GetFlag(BMDDeckLinkSupportsSMPTELevelAOutput, &levelA_supported) != S_OK)
+            levelA_supported = false;
+
+        if (levelA_supported) {
+            res = ctx->cfg->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, cctx->levelA);
+            if (res != S_OK)
+                av_log(avctx, AV_LOG_WARNING, "Setting SMPTE levelA failed.\n");
+            else
+                av_log(avctx, AV_LOG_VERBOSE, "Successfully set SMPTE levelA.\n");
+        } else {
+            av_log(avctx, AV_LOG_WARNING, "Unable to set SMPTE levelA mode, because it is not supported.\n");
+        }
+    }
+
     return 0;
 }
 
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index fdaa1f9..d855311 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -50,6 +50,7 @@  struct decklink_cctx {
     int duplex_mode;
     int link;
     int sqd;
+    int levelA;
     DecklinkPtsSource audio_pts_source;
     DecklinkPtsSource video_pts_source;
     int audio_input;
diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
index b26c93b..614a84a 100644
--- a/libavdevice/decklink_enc_c.c
+++ b/libavdevice/decklink_enc_c.c
@@ -40,6 +40,7 @@  static const AVOption options[] = {
     { "single"      ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "link"},
     { "dual"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "link"},
     { "quad"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 3   }, 0, 0, ENC, "link"},
+    { "levelA"      , "set SMPTE LevelA"        , OFFSET(levelA)      , AV_OPT_TYPE_BOOL,   { .i64 = 0   }, 0, 1, ENC },
     { "sqd"         , "set Square Division"     , OFFSET(sqd)         , AV_OPT_TYPE_BOOL,   { .i64 = 0   }, 0, 1, ENC },
     { "timing_offset", "genlock timing pixel offset", OFFSET(timing_offset), AV_OPT_TYPE_INT,   { .i64 = INT_MIN }, INT_MIN, INT_MAX, ENC, "timing_offset"},
     { "unset"       ,  NULL                     , 0                        , AV_OPT_TYPE_CONST, { .i64 = INT_MIN },       0,       0, ENC, "timing_offset"},