libcamera
v0.3.2+116-83c5ad0f
Supporting cameras in Linux since 2019
|
V4L2 pixel format FourCC wrapper. More...
Classes | |
struct | Info |
Information about a V4L2 pixel format. 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... | |
const char * | description () const |
Retrieve the V4L2 description for the format. More... | |
PixelFormat | toPixelFormat (bool warn=true) const |
Convert the V4L2 pixel format to the corresponding PixelFormat. More... | |
Static Public Member Functions | |
static const std::vector< V4L2PixelFormat > & | fromPixelFormat (const PixelFormat &pixelFormat) |
Retrieve the list of V4L2PixelFormat associated with pixelFormat. More... | |
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.
|
inline |
Construct a V4L2PixelFormat with an invalid format.
V4L2PixelFormat instances constructed with the default constructor are invalid, calling the isValid() function returns false.
|
inlineexplicit |
Construct a V4L2PixelFormat from a FourCC value.
[in] | fourcc | The pixel format FourCC numerical value |
const char * libcamera::V4L2PixelFormat::description | ( | ) | const |
Retrieve the V4L2 description for the format.
The description matches the value used by the kernel, as would be reported by the VIDIOC_ENUM_FMT ioctl.
|
inline |
Retrieve the pixel format FourCC numerical value.
|
static |
Retrieve the list of V4L2PixelFormat associated with pixelFormat.
[in] | pixelFormat | The PixelFormat to convert |
Multiple V4L2 formats may exist for one PixelFormat as V4L2 defines separate 4CCs for contiguous and non-contiguous versions of the same image format.
|
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.
|
inline |
Convert to the pixel format FourCC numerical value.
PixelFormat libcamera::V4L2PixelFormat::toPixelFormat | ( | bool | warn = true | ) | const |
Convert the V4L2 pixel format to the corresponding PixelFormat.
[in] | warn | When true, log a warning message if the V4L2 pixel format isn't known |
Users of this function might try to convert a V4L2PixelFormat to a PixelFormat just to check if the format is supported or not. In that case, they can suppress the warning message by setting the warn argument to false to not pollute the log with unnecessary messages.
std::string libcamera::V4L2PixelFormat::toString | ( | ) | const |
Assemble and return a string describing the pixel format.