libcamera v0.0.0+3240-f2a18172-dirty (2022-05-13T14:52:50+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#ifndef __LIBCAMERA_INTERNAL_FORMATS_H__
9#define __LIBCAMERA_INTERNAL_FORMATS_H__
10
11#include <array>
12#include <map>
13#include <vector>
14
15#include <libcamera/geometry.h>
17
19
20namespace libcamera {
21
23{
24public:
29 };
30
31 struct Plane {
32 unsigned int bytesPerGroup;
33 unsigned int verticalSubSampling;
34 };
35
36 bool isValid() const { return format.isValid(); }
37
38 static const PixelFormatInfo &info(const PixelFormat &format);
39 static const PixelFormatInfo &info(const V4L2PixelFormat &format);
40 static const PixelFormatInfo &info(const std::string &name);
41
42 unsigned int stride(unsigned int width, unsigned int plane,
43 unsigned int align = 1) const;
44 unsigned int planeSize(const Size &size, unsigned int plane,
45 unsigned int align = 1) const;
46 unsigned int planeSize(unsigned int height, unsigned int plane,
47 unsigned int stride) const;
48 unsigned int frameSize(const Size &size, unsigned int align = 1) const;
49 unsigned int frameSize(const Size &size,
50 const std::array<unsigned int, 3> &strides) const;
51
52 unsigned int numPlanes() const;
53
54 /* \todo Add support for non-contiguous memory planes */
55 const char *name;
57 struct {
58 V4L2PixelFormat single;
59 V4L2PixelFormat multi;
61 unsigned int bitsPerPixel;
63 bool packed;
64
65 unsigned int pixelsPerGroup;
66
67 std::array<Plane, 3> planes;
68};
69
70} /* namespace libcamera */
71
72#endif /* __LIBCAMERA_INTERNAL_FORMATS_H__ */
Information about pixel formats.
Definition: formats.h:23
ColourEncoding
The colour encoding type.
Definition: formats.h:25
@ ColourEncodingRGB
RGB colour encoding.
Definition: formats.h:26
@ ColourEncodingYUV
YUV colour encoding.
Definition: formats.h:27
@ ColourEncodingRAW
RAW colour encoding.
Definition: formats.h:28
const char * name
The format name as a human-readable string, used as the test representation of the PixelFormat.
Definition: formats.h:55
PixelFormat format
The PixelFormat described by this instance.
Definition: formats.h:56
unsigned int stride(unsigned int width, unsigned int plane, unsigned int align=1) const
Compute the stride.
Definition: formats.cpp:992
struct libcamera::PixelFormatInfo::@2 v4l2Formats
The V4L2 pixel formats corresponding to the PixelFormat.
unsigned int numPlanes() const
Retrieve the number of planes represented by the format.
Definition: formats.cpp:1126
enum ColourEncoding colourEncoding
The colour encoding type.
Definition: formats.h:62
unsigned int frameSize(const Size &size, unsigned int align=1) const
Compute the number of bytes necessary to store a frame.
Definition: formats.cpp:1079
static const PixelFormatInfo & info(const PixelFormat &format)
Retrieve information about a pixel format.
Definition: formats.cpp:924
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:1029
bool isValid() const
Check if the pixel format info is valid.
Definition: formats.h:36
unsigned int pixelsPerGroup
The number of pixels in a pixel group.
Definition: formats.h:65
std::array< Plane, 3 > planes
Information about pixels for each plane.
Definition: formats.h:67
unsigned int bitsPerPixel
The average number of bits per pixel.
Definition: formats.h:61
bool packed
Tell if multiple pixels are packed in the same bytes.
Definition: formats.h:63
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:51
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:21
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:31
unsigned int verticalSubSampling
Vertical subsampling multiplier.
Definition: formats.h:33
unsigned int bytesPerGroup
The number of bytes that a pixel group consumes.
Definition: formats.h:32
V4L2 Pixel Format.