libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01: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>
16 #include <libcamera/pixel_format.h>
17 
19 
20 namespace libcamera {
21 
23 {
24  unsigned int bytesPerGroup;
25  unsigned int verticalSubSampling;
26 };
27 
29 {
30 public:
35  };
36 
37  bool isValid() const { return format.isValid(); }
38 
39  static const PixelFormatInfo &info(const PixelFormat &format);
40  static const PixelFormatInfo &info(const V4L2PixelFormat &format);
41  static const PixelFormatInfo &info(const std::string &name);
42 
43  unsigned int stride(unsigned int width, unsigned int plane,
44  unsigned int align = 1) const;
45  unsigned int frameSize(const Size &size, unsigned int align = 1) const;
46  unsigned int frameSize(const Size &size,
47  const std::array<unsigned int, 3> &strides) const;
48 
49  unsigned int numPlanes() const;
50 
51  /* \todo Add support for non-contiguous memory planes */
52  const char *name;
55  unsigned int bitsPerPixel;
56  enum ColourEncoding colourEncoding;
57  bool packed;
58 
59  unsigned int pixelsPerGroup;
60 
61  std::array<PixelFormatPlaneInfo, 3> planes;
62 };
63 
64 } /* namespace libcamera */
65 
66 #endif /* __LIBCAMERA_INTERNAL_FORMATS_H__ */
libcamera image pixel format
Definition: pixel_format.h:16
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:20
RGB colour encoding.
Definition: formats.h:32
const char * name
The format name as a human-readable string, used as the test representation of the PixelFormat...
Definition: formats.h:52
std::array< PixelFormatPlaneInfo, 3 > planes
Information about pixels for each plane.
Definition: formats.h:61
Top-level libcamera namespace.
Definition: bound_method.h:15
unsigned int verticalSubSampling
Vertical subsampling multiplier.
Definition: formats.h:25
PixelFormat format
The PixelFormat described by this instance.
Definition: formats.h:53
Information about a single plane of a pixel format.
Definition: formats.h:22
unsigned int pixelsPerGroup
The number of pixels in a pixel group.
Definition: formats.h:59
RAW colour encoding.
Definition: formats.h:34
Describe a two-dimensional size.
Definition: geometry.h:50
V4L2 Pixel Format.
ColourEncoding
The colour encoding type.
Definition: formats.h:31
Information about pixel formats.
Definition: formats.h:28
unsigned int bytesPerGroup
The number of bytes that a pixel group consumes.
Definition: formats.h:24
V4L2PixelFormat v4l2Format
The V4L2 pixel format corresponding to the PixelFormat.
Definition: formats.h:54
unsigned int bitsPerPixel
The average number of bits per pixel.
Definition: formats.h:55
bool packed
Tell if multiple pixels are packed in the same bytes.
Definition: formats.h:57
YUV colour encoding.
Definition: formats.h:33
Data structures related to geometric objects.
bool isValid() const
Check if the pixel format info is valid.
Definition: formats.h:37
libcamera pixel format