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
bayer_format.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
4  *
5  * bayer_format.h - Bayer Pixel Format
6  */
7 #ifndef __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__
8 #define __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__
9 
10 #include <stdint.h>
11 #include <string>
12 
14 
15 namespace libcamera {
16 
17 enum class Transform;
18 
20 {
21 public:
22  enum Order : uint8_t {
23  BGGR = 0,
24  GBRG = 1,
25  GRBG = 2,
26  RGGB = 3
27  };
28 
29  enum Packing : uint16_t {
30  None = 0,
33  };
34 
35  constexpr BayerFormat()
37  {
38  }
39 
40  constexpr BayerFormat(Order o, uint8_t b, Packing p)
41  : order(o), bitDepth(b), packing(p)
42  {
43  }
44 
45  static const BayerFormat &fromMbusCode(unsigned int mbusCode);
46  bool isValid() const { return bitDepth != 0; }
47 
48  std::string toString() const;
49 
53 
55  uint8_t bitDepth;
56 
58 };
59 
60 bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
61 static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
62 {
63  return !(lhs == rhs);
64 }
65 
66 } /* namespace libcamera */
67 
68 #endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */
Order order
The order of the colour channels in the Bayer pattern.
Definition: bayer_format.h:54
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:20
bool isValid() const
Return whether a BayerFormat is valid.
Definition: bayer_format.h:46
B then G on the first row, G then R on the second row.
Definition: bayer_format.h:23
Top-level libcamera namespace.
Definition: bound_method.h:15
Format uses IPU3 style packing.
Definition: bayer_format.h:32
Transform
Enum to represent a 2D plane transform.
Definition: transform.h:15
Packing packing
Any packing scheme applied to this BayerFormat.
Definition: bayer_format.h:57
V4L2 Pixel Format.
constexpr BayerFormat(Order o, uint8_t b, Packing p)
Construct a BayerFormat from explicit values.
Definition: bayer_format.h:40
No packing.
Definition: bayer_format.h:30
std::string toString() const
Assemble and return a readable string representation of the BayerFormat.
Definition: bayer_format.cpp:193
BayerFormat transform(Transform t) const
Apply a transform to this BayerFormat.
Definition: bayer_format.cpp:279
G then R on the first row, B then G on the second row.
Definition: bayer_format.h:25
Packing
Different types of packing that can be applied to a BayerFormat.
Definition: bayer_format.h:29
Format uses MIPI CSI-2 style packing.
Definition: bayer_format.h:31
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
Convert v4l2Format to the corresponding BayerFormat.
Definition: bayer_format.cpp:253
R then G on the first row, G then B on the second row.
Definition: bayer_format.h:26
V4L2PixelFormat toV4L2PixelFormat() const
Convert a BayerFormat into the corresponding V4L2PixelFormat.
Definition: bayer_format.cpp:239
static const BayerFormat & fromMbusCode(unsigned int mbusCode)
Retrieve the BayerFormat associated with a media bus code.
Definition: bayer_format.cpp:172
G then B on the first row, R then G on the second row.
Definition: bayer_format.h:24
uint8_t bitDepth
The bit depth of the samples in the Bayer pattern.
Definition: bayer_format.h:55
bool operator==(const Point &lhs, const Point &rhs)
Compare points for equality.
Definition: geometry.cpp:75
constexpr BayerFormat()
Construct an empty (and invalid) BayerFormat.
Definition: bayer_format.h:35
Order
The order of the colour channels in the Bayer pattern.
Definition: bayer_format.h:22
Class to represent a raw image Bayer format.
Definition: bayer_format.h:19