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,
40 bool ccmEnabled)
override;
43 std::tuple<unsigned int, unsigned int>
82 using debayerFn = void (
DebayerCpu::*)(uint8_t *dst, const uint8_t *src[]);
84 void debayer0(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer0_)(dst, src); }
85 void debayer1(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer1_)(dst, src); }
86 void debayer2(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer2_)(dst, src); }
87 void debayer3(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer3_)(dst, src); }
90 template<
bool addAlphaByte,
bool ccmEnabled>
91 void debayer8_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
92 template<
bool addAlphaByte,
bool ccmEnabled>
93 void debayer8_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
95 template<
bool addAlphaByte,
bool ccmEnabled>
96 void debayer10_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
97 template<
bool addAlphaByte,
bool ccmEnabled>
98 void debayer10_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
100 template<
bool addAlphaByte,
bool ccmEnabled>
101 void debayer12_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
102 template<
bool addAlphaByte,
bool ccmEnabled>
103 void debayer12_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
105 template<
bool addAlphaByte,
bool ccmEnabled>
106 void debayer10P_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
107 template<
bool addAlphaByte,
bool ccmEnabled>
108 void debayer10P_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
109 template<
bool addAlphaByte,
bool ccmEnabled>
110 void debayer10P_GBGB_BGR888(uint8_t *dst,
const uint8_t *src[]);
111 template<
bool addAlphaByte,
bool ccmEnabled>
112 void debayer10P_RGRG_BGR888(uint8_t *dst,
const uint8_t *src[]);
114 template<
bool addAlphaByte,
bool ccmEnabled>
115 void debayer12P_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
116 template<
bool addAlphaByte,
bool ccmEnabled>
117 void debayer12P_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
118 template<
bool addAlphaByte,
bool ccmEnabled>
119 void debayer12P_GBGB_BGR888(uint8_t *dst,
const uint8_t *src[]);
120 template<
bool addAlphaByte,
bool ccmEnabled>
121 void debayer12P_RGRG_BGR888(uint8_t *dst,
const uint8_t *src[]);
123 static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config);
124 static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &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:39
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:1148
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:777
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:1072
Size patternSize(PixelFormat inputFormat) override
Get the width and height at which the bayer pattern repeats.
Definition debayer_cpu.cpp:756
int start() override
Execute a start signal in the debayer object from workerthread context.
Definition debayer_cpu.cpp:1131
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< const StreamConfiguration > > &outputCfgs, bool ccmEnabled) override
Configure the debayer object according to the passed in parameters.
Definition debayer_cpu.cpp:642
const SharedFD & getStatsFD() override
Get the file descriptor for the statistics.
Definition debayer_cpu.h:49
std::vector< PixelFormat > formats(PixelFormat input) override
Get the supported output formats.
Definition debayer_cpu.cpp:766
void stop() override
Stop the debayering process and perform cleanup.
Definition debayer_cpu.cpp:1139
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:20
Configuration parameters for a stream.
Definition stream.h:40