libcamera v0.1.0+127-8e215127-dirty (2023-12-02T01:06:12+00:00)
Supporting cameras in Linux since 2019
formats.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2019, Google Inc.
4 *
5 * formats.h - libcamera image formats
6 */
7
8#pragma once
9
10#include <array>
11#include <map>
12#include <vector>
13
14#include <libcamera/geometry.h>
16
18
19namespace libcamera {
20
22{
23public:
28 };
29
30 struct Plane {
31 unsigned int bytesPerGroup;
32 unsigned int verticalSubSampling;
33 };
34
35 bool isValid() const { return format.isValid(); }
36
37 static const PixelFormatInfo &info(const PixelFormat &format);
38 static const PixelFormatInfo &info(const V4L2PixelFormat &format);
39 static const PixelFormatInfo &info(const std::string &name);
40
41 unsigned int stride(unsigned int width, unsigned int plane,
42 unsigned int align = 1) const;
43 unsigned int planeSize(const Size &size, unsigned int plane,
44 unsigned int align = 1) const;
45 unsigned int planeSize(unsigned int height, unsigned int plane,
46 unsigned int stride) const;
47 unsigned int frameSize(const Size &size, unsigned int align = 1) const;
48 unsigned int frameSize(const Size &size,
49 const std::array<unsigned int, 3> &strides) const;
50
51 unsigned int numPlanes() const;
52
53 /* \todo Add support for non-contiguous memory planes */
54 const char *name;
56 std::vector<V4L2PixelFormat> v4l2Formats;
57 unsigned int bitsPerPixel;
59 bool packed;
60
61 unsigned int pixelsPerGroup;
62
63 std::array<Plane, 3> planes;
64};
65
66} /* namespace libcamera */
Information about pixel formats.
Definition: formats.h:22
ColourEncoding
The colour encoding type.
Definition: formats.h:24
@ ColourEncodingRGB
RGB colour encoding.
Definition: formats.h:25
@ ColourEncodingYUV
YUV colour encoding.
Definition: formats.h:26
@ ColourEncodingRAW
RAW colour encoding.
Definition: formats.h:27
const char * name
The format name as a human-readable string, used as the test representation of the PixelFormat.
Definition: formats.h:54
PixelFormat format
The PixelFormat described by this instance.
Definition: formats.h:55
unsigned int stride(unsigned int width, unsigned int plane, unsigned int align=1) const
Compute the stride.
Definition: formats.cpp:982
std::vector< V4L2PixelFormat > v4l2Formats
The V4L2 pixel formats corresponding to the PixelFormat.
Definition: formats.h:56
unsigned int numPlanes() const
Retrieve the number of planes represented by the format.
Definition: formats.cpp:1116
enum ColourEncoding colourEncoding
The colour encoding type.
Definition: formats.h:58
unsigned int frameSize(const Size &size, unsigned int align=1) const
Compute the number of bytes necessary to store a frame.
Definition: formats.cpp:1069
static const PixelFormatInfo & info(const PixelFormat &format)
Retrieve information about a pixel format.
Definition: formats.cpp:914
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:1019
bool isValid() const
Check if the pixel format info is valid.
Definition: formats.h:35
unsigned int pixelsPerGroup
The number of pixels in a pixel group.
Definition: formats.h:61
std::array< Plane, 3 > planes
Information about pixels for each plane.
Definition: formats.h:63
unsigned int bitsPerPixel
The average number of bits per pixel.
Definition: formats.h:57
bool packed
Tell if multiple pixels are packed in the same bytes.
Definition: formats.h:59
libcamera image pixel format
Definition: pixel_format.h:18
constexpr bool isValid() const
Check if the pixel format is valid.
Definition: pixel_format.h:34
Describe a two-dimensional size.
Definition: geometry.h:53
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:24
Data structures related to geometric objects.
Top-level libcamera namespace.
Definition: backtrace.h:17
libcamera pixel format
Information about a single plane of a pixel format.
Definition: formats.h:30
unsigned int verticalSubSampling
Vertical subsampling multiplier.
Definition: formats.h:32
unsigned int bytesPerGroup
The number of bytes that a pixel group consumes.
Definition: formats.h:31
V4L2 Pixel Format.