23#include "libcamera/internal/software_isp/debayer_params.h"
24#include "libcamera/internal/software_isp/swstats_cpu.h"
38 const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
39 bool ccmEnabled)
override;
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[]);
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_;
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
Class representing one CPU debayering thread.
Definition debayer_cpu.cpp:38
Class for debayering on the CPU.
Definition debayer_cpu.h:32
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override
Get the supported output sizes for the given input format and size.
Definition debayer_cpu.cpp:1049
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:678
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:973
Size patternSize(PixelFormat inputFormat) override
Get the width and height at which the bayer pattern repeats.
Definition debayer_cpu.cpp:657
DebayerCpu(std::unique_ptr< SwStatsCpu > stats, const CameraManager &cm)
Constructs a DebayerCpu object.
Definition debayer_cpu.cpp:94
int start() override
Execute a start signal in the debayer object from workerthread context.
Definition debayer_cpu.cpp:1032
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:543
const SharedFD & getStatsFD() override
Get the file descriptor for the statistics.
Definition debayer_cpu.h:48
std::vector< PixelFormat > formats(PixelFormat input) override
Get the supported output formats.
Definition debayer_cpu.cpp:667
void stop() override
Stop the debayering process and perform cleanup.
Definition debayer_cpu.cpp:1040
Debayer(const CameraManager &cm)
Construct a Debayer object.
Definition debayer.cpp:59
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
Internal camera manager support.
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
Structure describing the output frame configuration.
Definition debayer.h:70
Configuration parameters for a stream.
Definition stream.h:40