[FFmpeg-devel] [PATCH v3 1/4] avdevice/decklink: add link configuration

Marton Balint cus at passwd.hu
Thu Aug 12 22:43:07 EEST 2021



On Tue, 10 Aug 2021, lance.lmwang at gmail.com wrote:

> From: Limin Wang <lance.lmwang at gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> doc/outdevs.texi                | 6 ++++++
> libavdevice/decklink_common.cpp | 9 +++++++++
> libavdevice/decklink_common.h   | 8 ++++++++
> libavdevice/decklink_common_c.h | 1 +
> libavdevice/decklink_enc.cpp    | 2 ++
> libavdevice/decklink_enc_c.c    | 5 +++++
> 6 files changed, 31 insertions(+)
>
> diff --git a/doc/outdevs.texi b/doc/outdevs.texi
> index aaf2479..f046b23 100644
> --- a/doc/outdevs.texi
> +++ b/doc/outdevs.texi
> @@ -205,6 +205,12 @@ Defaults to @samp{unset}.
> Sets the genlock timing pixel offset on the used output.
> Defaults to @samp{unset}.
>
> + at item link
> +Sets the SDI video link configuration on the used output. Must be
> + at samp{unset}, @samp{single} link SDI, @samp{dual} link SDI or @samp{quad} link
> +SDI.
> +Defaults to @samp{unset}.
> +
> @end table
>
> @subsection Examples
> diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
> index 24aa9b1..4e0df04 100644
> --- a/libavdevice/decklink_common.cpp
> +++ b/libavdevice/decklink_common.cpp
> @@ -214,6 +214,15 @@ int ff_decklink_set_configs(AVFormatContext *avctx,
>         if (res != S_OK)
>             av_log(avctx, AV_LOG_WARNING, "Setting timing offset failed.\n");
>     }
> +
> +    if (direction == DIRECTION_OUT && ctx->link > 0) {
> +        res = ctx->cfg->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, ctx->link);
> +        if (res != S_OK)
> +            av_log(avctx, AV_LOG_WARNING, "Setting link configuration failed.\n");
> +        else
> +            av_log(avctx, AV_LOG_VERBOSE, "Successfully set link configuration: 0x%x.\n", ctx->link);
> +    }
> +
>     return 0;
> }
>
> diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
> index 6e03295..ad8b33c 100644
> --- a/libavdevice/decklink_common.h
> +++ b/libavdevice/decklink_common.h
> @@ -131,6 +131,7 @@ struct decklink_ctx {
>     int64_t teletext_lines;
>     double preroll;
>     int duplex_mode;
> +    BMDLinkConfiguration link;
>     DecklinkPtsSource audio_pts_source;
>     DecklinkPtsSource video_pts_source;
>     int draw_bars;
> @@ -200,6 +201,13 @@ static const BMDTimecodeFormat decklink_timecode_format_map[] = {
> #endif
> };
>
> +static const BMDLinkConfiguration decklink_link_conf_map[] = {
> +    (BMDLinkConfiguration)0,
> +    bmdLinkConfigurationSingleLink,
> +    bmdLinkConfigurationDualLink,
> +    bmdLinkConfigurationQuadLink
> +};
> +
> int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction);
> int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t direction = DIRECTION_OUT);
> int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction);
> diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
> index 68978fa..f37e0c0 100644
> --- a/libavdevice/decklink_common_c.h
> +++ b/libavdevice/decklink_common_c.h
> @@ -48,6 +48,7 @@ struct decklink_cctx {
>     int audio_channels;
>     int audio_depth;
>     int duplex_mode;
> +    int link;
>     DecklinkPtsSource audio_pts_source;
>     DecklinkPtsSource video_pts_source;
>     int audio_input;
> diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
> index 4c1eb05..6dec5f3 100644
> --- a/libavdevice/decklink_enc.cpp
> +++ b/libavdevice/decklink_enc.cpp
> @@ -559,6 +559,8 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
>     ctx->list_formats = cctx->list_formats;
>     ctx->preroll      = cctx->preroll;
>     ctx->duplex_mode  = cctx->duplex_mode;
> +    if (cctx->link > 0 && (unsigned int)cctx->link < FF_ARRAY_ELEMS(decklink_link_conf_map))
> +        ctx->link = decklink_link_conf_map[cctx->link];
>     cctx->ctx = ctx;
> #if CONFIG_LIBKLVANC
>     if (klvanc_context_create(&ctx->vanc_ctx) < 0) {
> diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
> index 828cf5d..4d191d8 100644
> --- a/libavdevice/decklink_enc_c.c
> +++ b/libavdevice/decklink_enc_c.c
> @@ -35,6 +35,11 @@ static const AVOption options[] = {
>     { "unset"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "duplex_mode"},
>     { "half"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "duplex_mode"},
>     { "full"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "duplex_mode"},
> +    { "link" ,         "single/dual/quad SDI link configuration", OFFSET(link), AV_OPT_TYPE_INT, { .i64 = 0   }, 0, 3, ENC, "link"},
> +    { "unset"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "link"},
> +    { "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"},
>     { "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"},
>     { NULL },
> -- 
> 1.8.3.1

Bump libavdevice micro version for the new option. Otherwise LGTM, thanks.

Marton


More information about the ffmpeg-devel mailing list