22#include "libcamera/internal/global_configuration.h"
23#include "libcamera/internal/software_isp/debayer_params.h"
24#include "libcamera/internal/software_isp/swstats_cpu.h"
30class DebayerCpuThread;
38 const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
42 std::tuple<unsigned int, unsigned int>
81 using debayerFn = void (
DebayerCpu::*)(uint8_t *dst, const uint8_t *src[]);
83 void debayer0(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer0_)(dst, src); }
84 void debayer1(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer1_)(dst, src); }
85 void debayer2(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer2_)(dst, src); }
86 void debayer3(uint8_t *dst,
const uint8_t *src[]) { (this->*debayer3_)(dst, src); }
89 template<
bool addAlphaByte,
bool ccmEnabled>
90 void debayer8_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
91 template<
bool addAlphaByte,
bool ccmEnabled>
92 void debayer8_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
94 template<
bool addAlphaByte,
bool ccmEnabled>
95 void debayer10_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
96 template<
bool addAlphaByte,
bool ccmEnabled>
97 void debayer10_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
99 template<
bool addAlphaByte,
bool ccmEnabled>
100 void debayer12_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
101 template<
bool addAlphaByte,
bool ccmEnabled>
102 void debayer12_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
104 template<
bool addAlphaByte,
bool ccmEnabled>
105 void debayer10P_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
106 template<
bool addAlphaByte,
bool ccmEnabled>
107 void debayer10P_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
108 template<
bool addAlphaByte,
bool ccmEnabled>
109 void debayer10P_GBGB_BGR888(uint8_t *dst,
const uint8_t *src[]);
110 template<
bool addAlphaByte,
bool ccmEnabled>
111 void debayer10P_RGRG_BGR888(uint8_t *dst,
const uint8_t *src[]);
113 static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config);
114 static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config);
116 int setDebayerFunctions(PixelFormat inputFormat,
117 PixelFormat outputFormat,
119 void updateGammaTable(
const DebayerParams ¶ms);
120 void updateLookupTables(
const DebayerParams ¶ms);
122 static constexpr unsigned int kRGBLookupSize = 256;
123 static constexpr unsigned int kGammaLookupSize = 1024;
129 using LookupTable = std::array<uint8_t, kRGBLookupSize>;
130 using CcmLookupTable = std::array<CcmColumn, kRGBLookupSize>;
134 CcmLookupTable redCcm_;
135 CcmLookupTable greenCcm_;
136 CcmLookupTable blueCcm_;
137 std::array<double, kGammaLookupSize> gammaTable_;
138 LookupTable gammaLut_;
140 DebayerParams params_;
147 std::unique_ptr<SwStatsCpu> stats_;
148 unsigned int xShift_;
150 static constexpr unsigned int kMinThreads = 1;
151 static constexpr unsigned int kMaxThreads = 8;
152 static constexpr unsigned int kDefaultThreads = 2;
154 unsigned int workPending_ LIBCAMERA_TSA_GUARDED_BY(workPendingMutex_);
155 Mutex workPendingMutex_;
156 ConditionVariable workPendingCv_;
157 std::vector<std::unique_ptr<DebayerCpuThread>> threads_;
Class representing one CPU debayering thread.
Definition debayer_cpu.cpp:38
Class for debayering on the CPU.
Definition debayer_cpu.h:32
Size patternSize(PixelFormat inputFormat)
Get the width and height at which the bayer pattern repeats.
Definition debayer_cpu.cpp:656
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize)
Get the supported output sizes for the given input format and size.
Definition debayer_cpu.cpp:1048
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< const StreamConfiguration > > &outputCfgs, bool ccmEnabled)
Configure the debayer object according to the passed in parameters.
Definition debayer_cpu.cpp:542
void stop()
Stop the debayering process and perform cleanup.
Definition debayer_cpu.cpp:1039
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms)
Process the bayer data into the requested format.
Definition debayer_cpu.cpp:972
int start()
Execute a start signal in the debayer object from workerthread context.
Definition debayer_cpu.cpp:1031
std::vector< PixelFormat > formats(PixelFormat input)
Get the supported output formats.
Definition debayer_cpu.cpp:666
std::tuple< unsigned int, unsigned int > strideAndFrameSize(const PixelFormat &outputFormat, const Size &size)
Get the stride and the frame size.
Definition debayer_cpu.cpp:677
const SharedFD & getStatsFD()
Get the file descriptor for the statistics.
Definition debayer_cpu.h:48
Base debayering class.
Definition debayer.h:36
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
Support for global libcamera configuration.
Definition global_configuration.h:22
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