[FFmpeg-devel] [PATCH v3] avdevice/decklink_dec: map the raw_format instead of hardcode
Marton Balint
cus at passwd.hu
Thu Nov 19 22:39:14 EET 2020
On Thu, 19 Nov 2020, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
>
> The patch will change the numerical values for the string constants so bump
> micro version.
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavdevice/decklink_common.h | 9 +++++++++
> libavdevice/decklink_dec.cpp | 3 ++-
> libavdevice/decklink_dec_c.c | 14 +++++++-------
> libavdevice/version.h | 2 +-
> 4 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
> index f35bd9a..05380ef 100644
> --- a/libavdevice/decklink_common.h
> +++ b/libavdevice/decklink_common.h
> @@ -162,6 +162,15 @@ IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
> typedef uint32_t buffercount_type;
> #endif
>
> +static const BMDPixelFormat decklink_raw_format_map[] = {
> + (BMDPixelFormat)0,
> + bmdFormat8BitYUV,
> + bmdFormat10BitYUV,
> + bmdFormat8BitARGB,
> + bmdFormat8BitBGRA,
> + bmdFormat10BitRGB,
> +};
> +
> static const BMDAudioConnection decklink_audio_connection_map[] = {
> (BMDAudioConnection)0,
> bmdAudioConnectionEmbedded,
> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
> index 6517b9d..049e133 100644
> --- a/libavdevice/decklink_dec.cpp
> +++ b/libavdevice/decklink_dec.cpp
> @@ -1152,7 +1152,8 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
> ctx->video_pts_source = cctx->video_pts_source;
> ctx->draw_bars = cctx->draw_bars;
> ctx->audio_depth = cctx->audio_depth;
> - ctx->raw_format = (BMDPixelFormat)cctx->raw_format;
> + if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < FF_ARRAY_ELEMS(decklink_raw_format_map))
> + ctx->raw_format = decklink_raw_format_map[cctx->raw_format];
> cctx->ctx = ctx;
>
> /* Check audio channel option for valid values: 2, 8 or 16 */
> diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
> index f3fdcd3..59044fe 100644
> --- a/libavdevice/decklink_dec_c.c
> +++ b/libavdevice/decklink_dec_c.c
> @@ -33,13 +33,13 @@ static const AVOption options[] = {
> { "list_devices", "list available devices" , OFFSET(list_devices), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
> { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
> { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
> - { "raw_format", "pixel format to be returned by the card when capturing" , OFFSET(raw_format), AV_OPT_TYPE_INT, { .i64 = 0}, 0, UINT_MAX, DEC, "raw_format" },
> - { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, DEC, "raw_format"},
> - { "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"},
> - { "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"},
> - { "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 32 }, 0, 0, DEC, "raw_format"},
> - { "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('B','G','R','A') }, 0, 0, DEC, "raw_format"},
> - { "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('r','2','1','0') }, 0, 0, DEC, "raw_format"},
> + { "raw_format", "pixel format to be returned by the card when capturing" , OFFSET(raw_format), AV_OPT_TYPE_INT, { .i64 = 0}, 0, 6, DEC, "raw_format" },
Why 6? 5 is the maximum as far as I see.
Thanks,
Marton
> + { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, DEC, "raw_format"},
> + { "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, DEC, "raw_format"},
> + { "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, DEC, "raw_format"},
> + { "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, 0, 0, DEC, "raw_format"},
> + { "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, 0, 0, DEC, "raw_format"},
> + { "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 5 }, 0, 0, DEC, "raw_format"},
> { "enable_klv", "output klv if present in vanc", OFFSET(enable_klv), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
> { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},
> { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},
> diff --git a/libavdevice/version.h b/libavdevice/version.h
> index e3aca9e..7022fdb 100644
> --- a/libavdevice/version.h
> +++ b/libavdevice/version.h
> @@ -29,7 +29,7 @@
>
> #define LIBAVDEVICE_VERSION_MAJOR 58
> #define LIBAVDEVICE_VERSION_MINOR 11
> -#define LIBAVDEVICE_VERSION_MICRO 102
> +#define LIBAVDEVICE_VERSION_MICRO 103
>
> #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
> LIBAVDEVICE_VERSION_MINOR, \
> --
> 1.8.3.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list