[FFmpeg-devel] [PATCH] avcodec/cuvidddec: Guess pixel format based on probed bit depth

Timo Rothenpieler timo at rothenpieler.org
Thu Aug 1 21:14:22 EEST 2024


On 01.08.2024 15:54, Roman Arzumanyan wrote:
> Hello world,
> 
> This patch adds a pixel format guess based on probed bit depth.
> With current FFMpeg ToT, when the cuvid codec is opened, input sw_pix_fmt
> is AV_PIX_FMT_NV12 until the first frame is decoded. Even if input has 10
> or 12 bit depth, the format will be NV12 for some time.
> 
> What's the need for this patch ?
> Applications that rely on libavcodec will have a chance to calculate the
> proper amount of vRAM required to store a reconstructed video frame before
> decoding begins.

The 12 bit format should be AV_PIX_FMT_P016.
Also, might as well take probe_desc->log2_chroma_w/log2_chroma_h into 
account.
If they're 0, it's 444, and the formats change to AV_PIX_FMT_YUV444P(16).
Akin to the switch() on format->bit_depth_luma_minus8 in the probe function.

Patch looks fine on first glance, though relying on a rather arbitrary 
second field there does not seem like a good idea to me.
Why can't the application simply also look at the probed format?


More information about the ffmpeg-devel mailing list