Loading...
Searching...
No Matches
v4l2_pixelformat.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
* Copyright (C) 2020, Raspberry Pi Ltd
*
* V4L2 Pixel Format
*/
#pragma once
#include <functional>
#include <ostream>
#include <stdint.h>
#include <string>
#include <vector>
#include <linux/videodev2.h>
#include <libcamera/pixel_format.h>
namespace libcamera {
class V4L2PixelFormat
{
public:
struct Info {
PixelFormat format;
const char *description;
};
V4L2PixelFormat()
: fourcc_(0)
{
}
explicit V4L2PixelFormat(uint32_t fourcc)
: fourcc_(fourcc)
{
}
bool isValid() const { return fourcc_ != 0; }
uint32_t fourcc() const { return fourcc_; }
operator uint32_t() const { return fourcc_; }
std::string toString() const;
const char *description() const;
PixelFormat toPixelFormat(bool warn = true) const;
static const std::vector<V4L2PixelFormat> &
fromPixelFormat(const PixelFormat &pixelFormat);
bool isGenericLineBasedMetadata() const;
private:
uint32_t fourcc_;
};
std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f);
} /* namespace libcamera */
namespace std {
template<>
struct hash<libcamera::V4L2PixelFormat> {
size_t operator()(libcamera::V4L2PixelFormat const &format) const noexcept
{
return format.fourcc();
}
};
} /* namespace std */
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::V4L2PixelFormat::toString
std::string toString() const
Assemble and return a string describing the pixel format.
Definition v4l2_pixelformat.cpp:286
libcamera::V4L2PixelFormat::isGenericLineBasedMetadata
bool isGenericLineBasedMetadata() const
Test if a V4L2PixelFormat is one of the line based generic metadata formats.
Definition v4l2_pixelformat.cpp:393
libcamera::V4L2PixelFormat::V4L2PixelFormat
V4L2PixelFormat(uint32_t fourcc)
Construct a V4L2PixelFormat from a FourCC value.
Definition v4l2_pixelformat.h:36
libcamera::V4L2PixelFormat::fourcc
uint32_t fourcc() const
Retrieve the pixel format FourCC numerical value.
Definition v4l2_pixelformat.h:42
libcamera::V4L2PixelFormat::fromPixelFormat
static const std::vector< V4L2PixelFormat > & fromPixelFormat(const PixelFormat &pixelFormat)
Retrieve the list of V4L2PixelFormat associated with pixelFormat.
Definition v4l2_pixelformat.cpp:364
libcamera::V4L2PixelFormat::description
const char * description() const
Retrieve the V4L2 description for the format.
Definition v4l2_pixelformat.cpp:316
libcamera::V4L2PixelFormat::V4L2PixelFormat
V4L2PixelFormat()
Construct a V4L2PixelFormat with an invalid format.
Definition v4l2_pixelformat.h:31
libcamera::V4L2PixelFormat::isValid
bool isValid() const
Check if the pixel format is valid.
Definition v4l2_pixelformat.h:41
libcamera::V4L2PixelFormat::toPixelFormat
PixelFormat toPixelFormat(bool warn=true) const
Convert the V4L2 pixel format to the corresponding PixelFormat.
Definition v4l2_pixelformat.cpp:341
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::operator<<
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition geometry.cpp:91
pixel_format.h
libcamera pixel format
libcamera::V4L2PixelFormat::Info
Information about a V4L2 pixel format.
Definition v4l2_pixelformat.h:26
libcamera::V4L2PixelFormat::Info::description
const char * description
The human-readable description of the V4L2 pixel format.
Definition v4l2_pixelformat.h:28
libcamera::V4L2PixelFormat::Info::format
PixelFormat format
The corresponding libcamera PixelFormat.
Definition v4l2_pixelformat.h:27