formats.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* formats.h - libcamera image formats
*/
#ifndef __LIBCAMERA_INTERNAL_FORMATS_H__
#define __LIBCAMERA_INTERNAL_FORMATS_H__
#include <map>
#include <vector>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
#include "libcamera/internal/v4l2_pixelformat.h"
namespace libcamera {
class ImageFormats
{
public:
int addFormat(unsigned int format, const std::vector<SizeRange> &sizes);
bool isEmpty() const;
std::vector<unsigned int> formats() const;
const std::vector<SizeRange> &sizes(unsigned int format) const;
const std::map<unsigned int, std::vector<SizeRange>> &data() const;
private:
std::map<unsigned int, std::vector<SizeRange>> data_;
};
class PixelFormatInfo
{
public:
enum ColourEncoding {
ColourEncodingRGB,
ColourEncodingYUV,
ColourEncodingRAW,
};
bool isValid() const { return format.isValid(); }
static const PixelFormatInfo &info(const PixelFormat &format);
/* \todo Add support for non-contiguous memory planes */
const char *name;
PixelFormat format;
V4L2PixelFormat v4l2Format;
unsigned int bitsPerPixel;
enum ColourEncoding colourEncoding;
bool packed;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_FORMATS_H__ */
libcamera::ImageFormats
Describe V4L2Device and V4L2SubDevice image formats.
Definition: formats.h:22
libcamera::ImageFormats::addFormat
int addFormat(unsigned int format, const std::vector< SizeRange > &sizes)
Add a format and corresponding sizes to the description.
Definition: formats.cpp:48
libcamera::ImageFormats::isEmpty
bool isEmpty() const
Check if the list of devices supported formats is empty.
Definition: formats.cpp:62
libcamera::ImageFormats::data
const std::map< unsigned int, std::vector< SizeRange > > & data() const
Retrieve the map that associates formats to image sizes.
Definition: formats.cpp:108
libcamera::ImageFormats::formats
std::vector< unsigned int > formats() const
Retrieve a list of all supported image formats.
Definition: formats.cpp:71
libcamera::ImageFormats::sizes
const std::vector< SizeRange > & sizes(unsigned int format) const
Retrieve all sizes for a specific format.
Definition: formats.cpp:93
libcamera::PixelFormatInfo
Information about pixel formats.
Definition: formats.h:36
libcamera::PixelFormatInfo::ColourEncoding
ColourEncoding
The colour encoding type.
Definition: formats.h:38
libcamera::PixelFormatInfo::ColourEncodingRGB
@ ColourEncodingRGB
RGB colour encoding.
Definition: formats.h:39
libcamera::PixelFormatInfo::ColourEncodingYUV
@ ColourEncodingYUV
YUV colour encoding.
Definition: formats.h:40
libcamera::PixelFormatInfo::ColourEncodingRAW
@ ColourEncodingRAW
RAW colour encoding.
Definition: formats.h:41
libcamera::PixelFormatInfo::name
const char * name
The format name as a human-readable string, used as the test representation of the PixelFormat.
Definition: formats.h:49
libcamera::PixelFormatInfo::v4l2Format
V4L2PixelFormat v4l2Format
The V4L2 pixel format corresponding to the PixelFormat.
Definition: formats.h:51
libcamera::PixelFormatInfo::format
PixelFormat format
The PixelFormat described by this instance.
Definition: formats.h:50
libcamera::PixelFormatInfo::colourEncoding
enum ColourEncoding colourEncoding
The colour encoding type.
Definition: formats.h:53
libcamera::PixelFormatInfo::info
static const PixelFormatInfo & info(const PixelFormat &format)
Retrieve information about a pixel format.
Definition: formats.cpp:537
libcamera::PixelFormatInfo::isValid
bool isValid() const
Check if the pixel format info is valid.
Definition: formats.h:44
libcamera::PixelFormatInfo::bitsPerPixel
unsigned int bitsPerPixel
The average number of bits per pixel.
Definition: formats.h:52
libcamera::PixelFormatInfo::packed
bool packed
Tell if multiple pixels are packed in the same bytes.
Definition: formats.h:54
libcamera::PixelFormat
libcamera image pixel format
Definition: pixel_format.h:17
libcamera::PixelFormat::isValid
constexpr bool isValid() const
Check if the pixel format is valid.
Definition: pixel_format.h:33
libcamera::V4L2PixelFormat
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:21
geometry.h
Data structures related to geometric objects.
pixel_format.h
libcamera pixel format
v4l2_pixelformat.h
V4L2 Pixel Format.