[FFmpeg-devel] [PATCH] libavdevice/decklink: 32 bit audio support

Moritz Barsnick barsnick at gmx.net
Tue Oct 17 17:40:35 EEST 2017


On Tue, Oct 17, 2017 at 09:22:27 -0400, Dave Rice wrote:
> >> --- a/libavdevice/decklink_dec_c.c
> >> +++ b/libavdevice/decklink_dec_c.c
> >> @@ -72,6 +72,7 @@ static const AVOption options[] = {
> >>     { "wallclock",     NULL,                                          0,
> >> AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"},
> >>     { "draw_bars",     "draw bars on signal loss" , OFFSET(draw_bars),
> >> AV_OPT_TYPE_BOOL,  { .i64 = 1}, 0, 1, DEC },
> >>     { "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 },
> > 
> > Use AV_OPT_ ENUM instead.
> 
> I don't see there to be an AV_OPT_TYPE_ENUM. Could you point out how this works from an example? Alternatively since the decklink sdk only supports 2 bit depths (16 and 32), I could use a boolean here if that makes more sense.

I would guess Paul means:

enum audio_bitdepths {
    AUDIO_BITDEPTH_16,
    AUDIO_BITDEPTH_32,
    AUDIO_BITDEPTH_NB
};

    { "audio_depth",    "audio bitdepth", OFFSET(audio_depth), AV_OPT_TYPE_INT,   { .i64 = AUDIO_BITDEPTH_16 }, 0, AUDIO_BITDEPTH_NB-1, DEC, "audio_depth" },
        { "16",         "16 bits",                          0, AV_OPT_TYPE_CONST, { .i64 = AUDIO_BITDEPTH_16 }, 0, 0,                   DEC, "audio_depth" },
        { "32",         "32 bits",                          0, AV_OPT_TYPE_CONST, { .i64 = AUDIO_BITDEPTH_32 }, 0, 0,                   DEC, "audio_depth" },

I'm not sure pure digits are accepted as an option strin ("16", "32"), but, why shouldn't they.

It may seem like a bit of overkill for two values, but take into
consideration that you can skip the check "Check audio bit depth option
for valid values: 16 or 32", but need to map the enums to values
instead. Or you pre-assign the enums values (AUDIO_BITDEPTH_16 = 16,
...), but use some other trick to define the lowest possible value.[*]
And you can easily add 8 bit or 24 bit support. ;-)

Cheers,
Moritz

[*]
enum audio_bitdepths {
    AUDIO_BITDEPTH_LOWEST = 16,
    AUDIO_BITDEPTH_16     = 16,
    AUDIO_BITDEPTH_32     = 32,
    AUDIO_BITDEPTH_NB
};

    { "audio_depth",    "audio bitdepth", OFFSET(audio_depth), AV_OPT_TYPE_INT,   { .i64 = AUDIO_BITDEPTH_16 }, AUDIO_BITDEPTH_LOWEST, AUDIO_BITDEPTH_NB-1, DEC, "audio_depth" },
        { "16",         "16 bits",                          0, AV_OPT_TYPE_CONST, { .i64 = AUDIO_BITDEPTH_16 }, 0, 0, DEC, "audio_depth" },
        { "32",         "32 bits",                          0, AV_OPT_TYPE_CONST, { .i64 = AUDIO_BITDEPTH_32 }, 0, 0, DEC, "audio_depth" },


More information about the ffmpeg-devel mailing list