Skip to main content

from_av_pixel_format

Function from_av_pixel_format 

Source
pub const fn from_av_pixel_format(raw: i32) -> PixelFormat
Expand description

Maps a raw AVFrame.format integer (i.e. the value of an AVPixelFormat enum variant) onto mediadecode::PixelFormat.

Returns PixelFormat::Unknown for raw integers we don’t have a mapping for — including hardware-frame markers (AV_PIX_FMT_VIDEOTOOLBOX / _VAAPI / _CUDA / _D3D11 / …) since those never describe CPU-side pixel data and the unified enum intentionally doesn’t carry them. Use is_hardware_pix_fmt to identify HW frames before transferring to a CPU format.

The match never constructs an AVPixelFormat from a runtime value; it compares the input against AVPixelFormat::AV_PIX_FMT_X as i32 constants. Sound regardless of which discriminant set the linked FFmpeg version exposes.