Loading...
Searching...
No Matches
bayer_format.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
* Bayer Pixel Format
*/
#pragma once
#include <ostream>
#include <stdint.h>
#include <string>
#include <libcamera/pixel_format.h>
#include "libcamera/internal/v4l2_pixelformat.h"
namespace libcamera {
enum class Transform;
class BayerFormat
{
public:
enum Order : uint8_t {
BGGR = 0,
GBRG = 1,
GRBG = 2,
RGGB = 3,
MONO = 4
};
enum class Packing : uint16_t {
None = 0,
CSI2 = 1,
IPU3 = 2,
PISP1 = 3,
PISP2 = 4,
};
constexpr BayerFormat()
: order(Order::BGGR), bitDepth(0), packing(Packing::None)
{
}
constexpr BayerFormat(Order o, uint8_t b, Packing p)
: order(o), bitDepth(b), packing(p)
{
}
static const BayerFormat &fromMbusCode(unsigned int mbusCode);
bool isValid() const { return bitDepth != 0; }
std::string toString() const;
V4L2PixelFormat toV4L2PixelFormat() const;
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);
PixelFormat toPixelFormat() const;
static BayerFormat fromPixelFormat(PixelFormat format);
BayerFormat transform(Transform t) const;
Order order;
uint8_t bitDepth;
Packing packing;
};
bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
{
return !(lhs == rhs);
}
std::ostream &operator<<(std::ostream &out, const BayerFormat &f);
} /* namespace libcamera */
libcamera::BayerFormat
Class to represent a raw image Bayer format.
Definition bayer_format.h:23
libcamera::BayerFormat::fromV4L2PixelFormat
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
Convert v4l2Format to the corresponding BayerFormat.
Definition bayer_format.cpp:359
libcamera::BayerFormat::Packing
Packing
Different types of packing that can be applied to a BayerFormat.
Definition bayer_format.h:33
libcamera::BayerFormat::Packing::PISP1
@ PISP1
Format uses PISP mode 1 compression.
Definition bayer_format.h:37
libcamera::BayerFormat::Packing::PISP2
@ PISP2
Format uses PISP mode 2 compression.
Definition bayer_format.h:38
libcamera::BayerFormat::Packing::CSI2
@ CSI2
Format uses MIPI CSI-2 style packing.
Definition bayer_format.h:35
libcamera::BayerFormat::Packing::None
@ None
No packing.
Definition bayer_format.h:34
libcamera::BayerFormat::Packing::IPU3
@ IPU3
Format uses IPU3 style packing.
Definition bayer_format.h:36
libcamera::BayerFormat::bitDepth
uint8_t bitDepth
The bit depth of the samples in the Bayer pattern.
Definition bayer_format.h:63
libcamera::BayerFormat::packing
Packing packing
Any packing scheme applied to this BayerFormat.
Definition bayer_format.h:65
libcamera::BayerFormat::order
Order order
The order of the colour channels in the Bayer pattern.
Definition bayer_format.h:62
libcamera::BayerFormat::isValid
bool isValid() const
Return whether a BayerFormat is valid.
Definition bayer_format.h:52
libcamera::BayerFormat::Order
Order
The order of the colour channels in the Bayer pattern.
Definition bayer_format.h:25
libcamera::BayerFormat::BGGR
@ BGGR
B then G on the first row, G then R on the second row.
Definition bayer_format.h:26
libcamera::BayerFormat::GRBG
@ GRBG
G then R on the first row, B then G on the second row.
Definition bayer_format.h:28
libcamera::BayerFormat::GBRG
@ GBRG
G then B on the first row, R then G on the second row.
Definition bayer_format.h:27
libcamera::BayerFormat::RGGB
@ RGGB
R then G on the first row, G then B on the second row.
Definition bayer_format.h:29
libcamera::BayerFormat::MONO
@ MONO
Monochrome image data, there is no colour filter array.
Definition bayer_format.h:30
libcamera::BayerFormat::toV4L2PixelFormat
V4L2PixelFormat toV4L2PixelFormat() const
Convert a BayerFormat into the corresponding V4L2PixelFormat.
Definition bayer_format.cpp:345
libcamera::BayerFormat::fromMbusCode
static const BayerFormat & fromMbusCode(unsigned int mbusCode)
Retrieve the BayerFormat associated with a media bus code.
Definition bayer_format.cpp:259
libcamera::BayerFormat::toPixelFormat
PixelFormat toPixelFormat() const
Convert a BayerFormat into the corresponding PixelFormat.
Definition bayer_format.cpp:375
libcamera::BayerFormat::BayerFormat
constexpr BayerFormat(Order o, uint8_t b, Packing p)
Construct a BayerFormat from explicit values.
Definition bayer_format.h:46
libcamera::BayerFormat::toString
std::string toString() const
Assemble and return a readable string representation of the BayerFormat.
Definition bayer_format.cpp:280
libcamera::BayerFormat::transform
BayerFormat transform(Transform t) const
Apply a transform to this BayerFormat.
Definition bayer_format.cpp:417
libcamera::BayerFormat::fromPixelFormat
static BayerFormat fromPixelFormat(PixelFormat format)
Convert a PixelFormat into the corresponding BayerFormat.
Definition bayer_format.cpp:388
libcamera::BayerFormat::BayerFormat
constexpr BayerFormat()
Construct an empty (and invalid) BayerFormat.
Definition bayer_format.h:41
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::V4L2PixelFormat
V4L2 pixel format FourCC wrapper.
Definition v4l2_pixelformat.h:24
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::Transform
Transform
Enum to represent a 2D plane transform.
Definition transform.h:14
libcamera::operator<<
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition geometry.cpp:91
pixel_format.h
libcamera pixel format
v4l2_pixelformat.h
V4L2 Pixel Format.