[FFmpeg-devel] [PATCH 3/4] avdevice/decklink_dec: add support for rgb/yuv pixel format autodetection

Marton Balint cus at passwd.hu
Mon Sep 14 22:21:37 EEST 2020



On Mon, 14 Sep 2020, Gyan Doshi wrote:

>
> Building with Decklink is broken, apparently due to f1b908d20a8
>
> Error is
>
> ----
>
> src/libavdevice/decklink_dec.cpp: In function 'int 
> ff_decklink_read_header(AVFormatContext*)':
>
> src/libavdevice/decklink_dec.cpp:1235:28: error: 'bmdFormatUnspecified' 
> was not declared in this scope
>
> 1235 | if (ctx->raw_format == bmdFormatUnspecified)
>
> | ^~~~~~~~~~~~~~~~~~~~
>
> make: *** [/build/ffmpeg-git/ffbuild/common.mak:70: 
> libavdevice/decklink_dec.o] Error 1

Shoot, I missed that the unspecified format also needs a newer SDK. Will 
send a patch shortly which should fix this.

Thanks,
Marton

>
> ----
>
> Regards,
> Gyan
>
> On 08-09-2020 11:22 pm, Marton Balint wrote:
>> Signed-off-by: Marton Balint <cus at passwd.hu>
>> ---
>>   doc/indevs.texi              | 15 +++++++++++++++
>>   libavdevice/decklink_dec.cpp |  8 +++++++-
>>   libavdevice/decklink_dec_c.c |  3 ++-
>>   3 files changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/indevs.texi b/doc/indevs.texi
>> index 4d2312e201..7748232b26 100644
>> --- a/doc/indevs.texi
>> +++ b/doc/indevs.texi
>> @@ -296,16 +296,31 @@ supports it.
>>   Set the pixel format of the captured video.
>>   Available values are:
>>   @table @samp
>> + at item auto
>> +
>> +This is the default which means 8-bit YUV 422 or 8-bit ARGB if format
>> +autodetection is used, 8-bit YUV 422 otherwise.
>> +
>>   @item uyvy422
>> 
>> +8-bit YUV 422.
>> +
>>   @item yuv422p10
>> 
>> +10-bit YUV 422.
>> +
>>   @item argb
>> 
>> +8-bit RGB.
>> +
>>   @item bgra
>> 
>> +8-bit RGB.
>> +
>>   @item rgb10
>> 
>> +10-bit RGB.
>> +
>>   @end table
>>
>>   @item teletext_lines
>> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
>> index af0ef04c56..92b8feed14 100644
>> --- a/libavdevice/decklink_dec.cpp
>> +++ b/libavdevice/decklink_dec.cpp
>> @@ -1044,9 +1044,13 @@ HRESULT 
> decklink_input_callback::VideoInputFrameArrived(
>>
>>   HRESULT decklink_input_callback::VideoInputFormatChanged(
>>       BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode,
>> -    BMDDetectedVideoInputFormatFlags)
>> +    BMDDetectedVideoInputFormatFlags formatFlags)
>>   {
>> +    struct decklink_cctx *cctx = (struct decklink_cctx *) 
> avctx->priv_data;
>>       ctx->bmd_mode = mode->GetDisplayMode();
>> +    // check the C context member to make sure we set both raw_format and 
> bmd_mode with data from the same format change callback
>> +    if (!cctx->raw_format)
>> +        ctx->raw_format = (formatFlags & bmdDetectedVideoInputRGB444) ? 
> bmdFormat8BitARGB : bmdFormat8BitYUV;
>>       return S_OK;
>>   }
>> 
>> @@ -1228,6 +1232,8 @@ av_cold int ff_decklink_read_header(AVFormatContext 
> *avctx)
>>           }
>>           av_log(avctx, AV_LOG_INFO, "Autodetected the input mode\n");
>>       }
>> +    if (ctx->raw_format == bmdFormatUnspecified)
>> +        ctx->raw_format = bmdFormat8BitYUV;
>>       if (ff_decklink_set_format(avctx, DIRECTION_IN) < 0) {
>>           av_log(avctx, AV_LOG_ERROR, "Could not set format code %s for 
> %s\n",
>>               cctx->format_code ? cctx->format_code : "(unset)", 
> avctx->url);
>> diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
>> index 9f4b32088c..54cd681710 100644
>> --- a/libavdevice/decklink_dec_c.c
>> +++ b/libavdevice/decklink_dec_c.c
>> @@ -33,7 +33,8 @@ 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 = 
> MKBETAG('2','v','u','y')}, 0, UINT_MAX, 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, 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"},
>
> _______________________________________________
> 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