Loading...
Searching...
No Matches
formats.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* libcamera image formats
*/
#pragma once
#include <array>
#include <vector>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
#include "libcamera/internal/v4l2_pixelformat.h"
namespace libcamera {
class PixelFormatInfo
{
public:
enum ColourEncoding {
ColourEncodingRGB,
ColourEncodingYUV,
ColourEncodingRAW,
};
struct Plane {
unsigned int bytesPerGroup;
unsigned int verticalSubSampling;
};
bool isValid() const { return format.isValid(); }
static const PixelFormatInfo &info(const PixelFormat &format);
static const PixelFormatInfo &info(const V4L2PixelFormat &format);
static const PixelFormatInfo &info(const std::string &name);
unsigned int stride(unsigned int width, unsigned int plane,
unsigned int align = 1) const;
unsigned int planeSize(const Size &size, unsigned int plane,
unsigned int align = 1) const;
unsigned int planeSize(unsigned int height, unsigned int plane,
unsigned int stride) const;
unsigned int frameSize(const Size &size, unsigned int align = 1) const;
unsigned int frameSize(const Size &size,
const std::array<unsigned int, 3> &strides) const;
unsigned int numPlanes() const;
/* \todo Add support for non-contiguous memory planes */
const char *name;
PixelFormat format;
std::vector<V4L2PixelFormat> v4l2Formats;
unsigned int bitsPerPixel;
enum ColourEncoding colourEncoding;
bool packed;
unsigned int pixelsPerGroup;
std::array<Plane, 3> planes;
};
} /* namespace libcamera */
libcamera::PixelFormatInfo
Information about pixel formats.
Definition formats.h:21
libcamera::PixelFormatInfo::ColourEncoding
ColourEncoding
The colour encoding type.
Definition formats.h:23
libcamera::PixelFormatInfo::ColourEncodingRGB
@ ColourEncodingRGB
RGB colour encoding.
Definition formats.h:24
libcamera::PixelFormatInfo::ColourEncodingRAW
@ ColourEncodingRAW
RAW colour encoding.
Definition formats.h:26
libcamera::PixelFormatInfo::ColourEncodingYUV
@ ColourEncodingYUV
YUV colour encoding.
Definition formats.h:25
libcamera::PixelFormatInfo::stride
unsigned int stride(unsigned int width, unsigned int plane, unsigned int align=1) const
Compute the stride.
Definition formats.cpp:1070
libcamera::PixelFormatInfo::numPlanes
unsigned int numPlanes() const
Retrieve the number of planes represented by the format.
Definition formats.cpp:1204
libcamera::PixelFormatInfo::format
PixelFormat format
The PixelFormat described by this instance.
Definition formats.h:54
libcamera::PixelFormatInfo::bitsPerPixel
unsigned int bitsPerPixel
The average number of bits per pixel.
Definition formats.h:56
libcamera::PixelFormatInfo::planes
std::array< Plane, 3 > planes
Information about pixels for each plane.
Definition formats.h:62
libcamera::PixelFormatInfo::packed
bool packed
Tell if multiple pixels are packed in the same bytes.
Definition formats.h:58
libcamera::PixelFormatInfo::frameSize
unsigned int frameSize(const Size &size, unsigned int align=1) const
Compute the number of bytes necessary to store a frame.
Definition formats.cpp:1157
libcamera::PixelFormatInfo::name
const char * name
The format name as a human-readable string, used as the text representation of the PixelFormat.
Definition formats.h:53
libcamera::PixelFormatInfo::info
static const PixelFormatInfo & info(const PixelFormat &format)
Retrieve information about a pixel format.
Definition formats.cpp:1002
libcamera::PixelFormatInfo::pixelsPerGroup
unsigned int pixelsPerGroup
The number of pixels in a pixel group.
Definition formats.h:60
libcamera::PixelFormatInfo::planeSize
unsigned int planeSize(const Size &size, unsigned int plane, unsigned int align=1) const
Compute the number of bytes necessary to store a plane of a frame.
Definition formats.cpp:1107
libcamera::PixelFormatInfo::isValid
bool isValid() const
Check if the pixel format info is valid.
Definition formats.h:34
libcamera::PixelFormatInfo::colourEncoding
enum ColourEncoding colourEncoding
The colour encoding type.
Definition formats.h:57
libcamera::PixelFormatInfo::v4l2Formats
std::vector< V4L2PixelFormat > v4l2Formats
The V4L2 pixel formats corresponding to the PixelFormat.
Definition formats.h:55
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:51
libcamera::V4L2PixelFormat
V4L2 pixel format FourCC wrapper.
Definition v4l2_pixelformat.h:24
geometry.h
Data structures related to geometric objects.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
pixel_format.h
libcamera pixel format
libcamera::PixelFormatInfo::Plane
Information about a single plane of a pixel format.
Definition formats.h:29
libcamera::PixelFormatInfo::Plane::verticalSubSampling
unsigned int verticalSubSampling
Vertical subsampling multiplier.
Definition formats.h:31
libcamera::PixelFormatInfo::Plane::bytesPerGroup
unsigned int bytesPerGroup
The number of bytes that a pixel group consumes.
Definition formats.h:30
v4l2_pixelformat.h
V4L2 Pixel Format.