24#include "libcamera/internal/software_isp/debayer_params.h"
25#include "libcamera/internal/software_isp/swstats_cpu.h"
31class DebayerCpuThread;
39 const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
41 bool lscEnabled)
override;
44 std::tuple<unsigned int, unsigned int>
83 using debayerFn = void (
DebayerCpu::*)(uint8_t *dst, const uint8_t *src[]);
85 void debayer0(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer0_)(dst, src); }
86 void debayer1(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer1_)(dst, src); }
87 void debayer2(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer2_)(dst, src); }
88 void debayer3(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer3_)(dst, src); }
91 template<
bool addAlphaByte,
bool ccmEnabled>
92 void debayer8_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
93 template<
bool addAlphaByte,
bool ccmEnabled>
94 void debayer8_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
96 template<
bool addAlphaByte,
bool ccmEnabled>
97 void debayer10_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
98 template<
bool addAlphaByte,
bool ccmEnabled>
99 void debayer10_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
101 template<
bool addAlphaByte,
bool ccmEnabled>
102 void debayer12_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
103 template<
bool addAlphaByte,
bool ccmEnabled>
104 void debayer12_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
106 template<
bool addAlphaByte,
bool ccmEnabled>
107 void debayer10P_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
108 template<
bool addAlphaByte,
bool ccmEnabled>
109 void debayer10P_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
110 template<
bool addAlphaByte,
bool ccmEnabled>
111 void debayer10P_GBGB_BGR888(uint8_t *dst,
const uint8_t *src[]);
112 template<
bool addAlphaByte,
bool ccmEnabled>
113 void debayer10P_RGRG_BGR888(uint8_t *dst,
const uint8_t *src[]);
115 template<
bool addAlphaByte,
bool ccmEnabled>
116 void debayer12P_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
117 template<
bool addAlphaByte,
bool ccmEnabled>
118 void debayer12P_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
119 template<
bool addAlphaByte,
bool ccmEnabled>
120 void debayer12P_GBGB_BGR888(uint8_t *dst,
const uint8_t *src[]);
121 template<
bool addAlphaByte,
bool ccmEnabled>
122 void debayer12P_RGRG_BGR888(uint8_t *dst,
const uint8_t *src[]);
124 static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config);
126 int setDebayerFunctions(PixelFormat inputFormat,
127 PixelFormat outputFormat,
129 void updateGammaTable(
const DebayerParams ¶ms);
130 void updateLookupTables(
const DebayerParams ¶ms);
132 static constexpr unsigned int kRGBLookupSize = 256;
133 static constexpr unsigned int kGammaLookupSize = 1024;
139 using LookupTable = std::array<uint8_t, kRGBLookupSize>;
140 using CcmLookupTable = std::array<CcmColumn, kRGBLookupSize>;
144 CcmLookupTable redCcm_;
145 CcmLookupTable greenCcm_;
146 CcmLookupTable blueCcm_;
147 std::array<double, kGammaLookupSize> gammaTable_;
148 LookupTable gammaLut_;
150 DebayerParams params_;
157 std::unique_ptr<SwStatsCpu> stats_;
158 unsigned int xShift_;
160 static constexpr unsigned int kMinThreads = 1;
161 static constexpr unsigned int kMaxThreads = 8;
162 static constexpr unsigned int kDefaultThreads = 2;
164 unsigned int workPending_ LIBCAMERA_TSA_GUARDED_BY(workPendingMutex_);
165 Mutex workPendingMutex_;
166 ConditionVariable workPendingCv_;
167 std::vector<std::unique_ptr<DebayerCpuThread>> threads_;
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
Class representing one CPU debayering thread.
Definition debayer_cpu.cpp:40
Class for debayering on the CPU.
Definition debayer_cpu.h:33
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override
Get the supported output sizes for the given input format and size.
Definition debayer_cpu.cpp:1125
std::tuple< unsigned int, unsigned int > strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) override
Get the stride and the frame size.
Definition debayer_cpu.cpp:764
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) override
Process the bayer data into the requested format.
Definition debayer_cpu.cpp:1049
Size patternSize(PixelFormat inputFormat) override
Get the width and height at which the bayer pattern repeats.
Definition debayer_cpu.cpp:743
int start() override
Execute a start signal in the debayer object from workerthread context.
Definition debayer_cpu.cpp:1108
const SharedFD & getStatsFD() override
Get the file descriptor for the statistics.
Definition debayer_cpu.h:50
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< const StreamConfiguration > > &outputCfgs, bool ccmEnabled, bool lscEnabled) override
Configure the debayer object according to the passed in parameters.
Definition debayer_cpu.cpp:625
std::vector< PixelFormat > formats(PixelFormat input) override
Get the supported output formats.
Definition debayer_cpu.cpp:753
void stop() override
Stop the debayering process and perform cleanup.
Definition debayer_cpu.cpp:1116
Base debayering class.
Definition debayer.h:36
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
RAII-style wrapper for file descriptors.
Definition shared_fd.h:17
Describe a range of sizes.
Definition geometry.h:205
Describe a two-dimensional size.
Definition geometry.h:51
Mutex classes with clang thread safety annotation.
Top-level libcamera namespace.
Definition backtrace.h:17
Base object to support automatic signal disconnection.
Struct to hold the debayer parameters.
Definition debayer_params.h:21
Configuration parameters for a stream.
Definition stream.h:40