libcamera v0.3.2
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
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 * libcamera image formats
6 */
7
8#pragma once
9
10#include <array>
11#include <vector>
12
13#include <libcamera/geometry.h>
15
17
18namespace libcamera {
19
21{
22public:
28
29 struct Plane {
30 unsigned int bytesPerGroup;
31 unsigned int verticalSubSampling;
32 };
33
34 bool isValid() const { return format.isValid(); }
35
36 static const PixelFormatInfo &info(const PixelFormat &format);
37 static const PixelFormatInfo &info(const V4L2PixelFormat &format);
38 static const PixelFormatInfo &info(const std::string &name);
39
40 unsigned int stride(unsigned int width, unsigned int plane,
41 unsigned int align = 1) const;
42 unsigned int planeSize(const Size &size, unsigned int plane,
43 unsigned int align = 1) const;
44 unsigned int planeSize(unsigned int height, unsigned int plane,
45 unsigned int stride) const;
46 unsigned int frameSize(const Size &size, unsigned int align = 1) const;
47 unsigned int frameSize(const Size &size,
48 const std::array<unsigned int, 3> &strides) const;
49
50 unsigned int numPlanes() const;
51
52 /* \todo Add support for non-contiguous memory planes */
53 const char *name;
55 std::vector<V4L2PixelFormat> v4l2Formats;
56 unsigned int bitsPerPixel;
58 bool packed;
59
60 unsigned int pixelsPerGroup;
61
62 std::array<Plane, 3> planes;
63};
64
65} /* namespace libcamera */
Information about pixel formats.
Definition formats.h:21
ColourEncoding
The colour encoding type.
Definition formats.h:23
@ ColourEncodingRGB
RGB colour encoding.
Definition formats.h:24
@ ColourEncodingRAW
RAW colour encoding.
Definition formats.h:26
@ ColourEncodingYUV
YUV colour encoding.
Definition formats.h:25
unsigned int stride(unsigned int width, unsigned int plane, unsigned int align=1) const
Compute the stride.
Definition formats.cpp:1070
unsigned int numPlanes() const
Retrieve the number of planes represented by the format.
Definition formats.cpp:1204
PixelFormat format
The PixelFormat described by this instance.
Definition formats.h:54
unsigned int bitsPerPixel
The average number of bits per pixel.
Definition formats.h:56
std::array< Plane, 3 > planes
Information about pixels for each plane.
Definition formats.h:62
bool packed
Tell if multiple pixels are packed in the same bytes.
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:1157
const char * name
The format name as a human-readable string, used as the text representation of the PixelFormat.
Definition formats.h:53
static const PixelFormatInfo & info(const PixelFormat &format)
Retrieve information about a pixel format.
Definition formats.cpp:1002
unsigned int pixelsPerGroup
The number of pixels in a pixel group.
Definition formats.h:60
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
bool isValid() const
Check if the pixel format info is valid.
Definition formats.h:34
enum ColourEncoding colourEncoding
The colour encoding type.
Definition formats.h:57
std::vector< V4L2PixelFormat > v4l2Formats
The V4L2 pixel formats corresponding to the PixelFormat.
Definition formats.h:55
libcamera image pixel format
Definition pixel_format.h:17
constexpr bool isValid() const
Check if the pixel format is valid.
Definition pixel_format.h:33
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:29
unsigned int verticalSubSampling
Vertical subsampling multiplier.
Definition formats.h:31
unsigned int bytesPerGroup
The number of bytes that a pixel group consumes.
Definition formats.h:30
V4L2 Pixel Format.