libcamera  v0.0.0
Supporting cameras in Linux since 2019
Public Member Functions | Static Public Member Functions | List of all members
libcamera::V4L2PixelFormat Class Reference

V4L2 pixel format FourCC wrapper. More...

Public Member Functions

 V4L2PixelFormat ()
 Construct a V4L2PixelFormat with an invalid format. More...
 
 V4L2PixelFormat (uint32_t fourcc)
 Construct a V4L2PixelFormat from a FourCC value. More...
 
bool isValid () const
 Check if the pixel format is valid. More...
 
uint32_t fourcc () const
 Retrieve the pixel format FourCC numerical value. More...
 
 operator uint32_t () const
 Convert to the pixel format FourCC numerical value. More...
 
std::string toString () const
 Assemble and return a string describing the pixel format. More...
 
PixelFormat toPixelFormat () const
 Convert the V4L2 pixel format to the corresponding PixelFormat. More...
 

Static Public Member Functions

static V4L2PixelFormat fromPixelFormat (const PixelFormat &pixelFormat, bool multiplanar)
 Convert pixelFormat to its corresponding V4L2PixelFormat. More...
 

Detailed Description

V4L2 pixel format FourCC wrapper.

The V4L2PixelFormat class describes the pixel format of a V4L2 buffer. It wraps the V4L2 numerical FourCC, and shall be used in all APIs that deal with V4L2 pixel formats. Its purpose is to prevent unintentional confusion of V4L2 and DRM FourCCs in code by catching implicit conversion attempts at compile time.

To achieve this goal, construction of a V4L2PixelFormat from an integer value is explicit. To retrieve the integer value of a V4L2PixelFormat, both the explicit value() and implicit uint32_t conversion operators may be used.

Constructor & Destructor Documentation

◆ V4L2PixelFormat() [1/2]

libcamera::V4L2PixelFormat::V4L2PixelFormat ( )
inline

Construct a V4L2PixelFormat with an invalid format.

V4L2PixelFormat instances constructed with the default constructor are invalid, calling the isValid() function returns false.

◆ V4L2PixelFormat() [2/2]

libcamera::V4L2PixelFormat::V4L2PixelFormat ( uint32_t  fourcc)
inlineexplicit

Construct a V4L2PixelFormat from a FourCC value.

Parameters
[in]fourccThe pixel format FourCC numerical value

Member Function Documentation

◆ fourcc()

uint32_t libcamera::V4L2PixelFormat::fourcc ( ) const
inline

Retrieve the pixel format FourCC numerical value.

Returns
The pixel format FourCC numerical value

◆ fromPixelFormat()

V4L2PixelFormat libcamera::V4L2PixelFormat::fromPixelFormat ( const PixelFormat pixelFormat,
bool  multiplanar 
)
static

Convert pixelFormat to its corresponding V4L2PixelFormat.

Parameters
[in]pixelFormatThe PixelFormat to convert
[in]multiplanarV4L2 Multiplanar API support flag

Multiple V4L2 formats may exist for one PixelFormat when the format uses multiple planes, as V4L2 defines separate 4CCs for contiguous and separate planes formats. Set the multiplanar parameter to false to select a format with contiguous planes, or to true to select a format with non-contiguous planes.

Returns
The V4L2PixelFormat corresponding to pixelFormat

◆ isValid()

bool libcamera::V4L2PixelFormat::isValid ( ) const
inline

Check if the pixel format is valid.

V4L2PixelFormat instances constructed with the default constructor are invalid. Instances constructed with a FourCC defined in the V4L2 API are valid. The behaviour is undefined otherwise.

Returns
True if the pixel format is valid, false otherwise

◆ operator uint32_t()

libcamera::V4L2PixelFormat::operator uint32_t ( ) const
inline

Convert to the pixel format FourCC numerical value.

Returns
The pixel format FourCC numerical value

◆ toPixelFormat()

PixelFormat libcamera::V4L2PixelFormat::toPixelFormat ( ) const

Convert the V4L2 pixel format to the corresponding PixelFormat.

Returns
The PixelFormat corresponding to the V4L2 pixel format

◆ toString()

std::string libcamera::V4L2PixelFormat::toString ( ) const

Assemble and return a string describing the pixel format.

Returns
A string describing the pixel format

The documentation for this class was generated from the following files: