libcamera v0.0.0+1-ab0bf965
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
15namespace libcamera {
16
17enum class Transform;
18
20{
21public:
22 enum Order : uint8_t {
23 BGGR = 0,
24 GBRG = 1,
25 GRBG = 2,
26 RGGB = 3,
27 MONO = 4
28 };
29
30 enum Packing : uint16_t {
31 None = 0,
34 };
35
36 constexpr BayerFormat()
38 {
39 }
40
41 constexpr BayerFormat(Order o, uint8_t b, Packing p)
42 : order(o), bitDepth(b), packing(p)
43 {
44 }
45
46 static const BayerFormat &fromMbusCode(unsigned int mbusCode);
47 bool isValid() const { return bitDepth != 0; }
48
49 std::string toString() const;
50
54
56 uint8_t bitDepth;
57
59};
60
61bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
62static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
63{
64 return !(lhs == rhs);
65}
66
67} /* namespace libcamera */
68
69#endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */
Class to represent a raw image Bayer format.
Definition: bayer_format.h:20
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
Convert v4l2Format to the corresponding BayerFormat.
Definition: bayer_format.cpp:260
constexpr BayerFormat()
Construct an empty (and invalid) BayerFormat.
Definition: bayer_format.h:36
Packing
Different types of packing that can be applied to a BayerFormat.
Definition: bayer_format.h:30
@ CSI2Packed
Format uses MIPI CSI-2 style packing.
Definition: bayer_format.h:32
@ None
No packing.
Definition: bayer_format.h:31
@ IPU3Packed
Format uses IPU3 style packing.
Definition: bayer_format.h:33
uint8_t bitDepth
The bit depth of the samples in the Bayer pattern.
Definition: bayer_format.h:56
Order
The order of the colour channels in the Bayer pattern.
Definition: bayer_format.h:22
@ GBRG
G then B on the first row, R then G on the second row.
Definition: bayer_format.h:24
@ GRBG
G then R on the first row, B then G on the second row.
Definition: bayer_format.h:25
@ RGGB
R then G on the first row, G then B on the second row.
Definition: bayer_format.h:26
@ MONO
Monochrome image data, there is no colour filter array.
Definition: bayer_format.h:27
@ BGGR
B then G on the first row, G then R on the second row.
Definition: bayer_format.h:23
Packing packing
Any packing scheme applied to this BayerFormat.
Definition: bayer_format.h:58
V4L2PixelFormat toV4L2PixelFormat() const
Convert a BayerFormat into the corresponding V4L2PixelFormat.
Definition: bayer_format.cpp:246
static const BayerFormat & fromMbusCode(unsigned int mbusCode)
Retrieve the BayerFormat associated with a media bus code.
Definition: bayer_format.cpp:178
Order order
The order of the colour channels in the Bayer pattern.
Definition: bayer_format.h:55
std::string toString() const
Assemble and return a readable string representation of the BayerFormat.
Definition: bayer_format.cpp:199
BayerFormat transform(Transform t) const
Apply a transform to this BayerFormat.
Definition: bayer_format.cpp:286
constexpr BayerFormat(Order o, uint8_t b, Packing p)
Construct a BayerFormat from explicit values.
Definition: bayer_format.h:41
bool isValid() const
Return whether a BayerFormat is valid.
Definition: bayer_format.h:47
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:21
Top-level libcamera namespace.
Definition: bound_method.h:15
Transform
Enum to represent a 2D plane transform.
Definition: transform.h:15
bool operator==(const Point &lhs, const Point &rhs)
Compare points for equality.
Definition: geometry.cpp:75
V4L2 Pixel Format.