21#include "libcamera/internal/global_configuration.h"
22#include "libcamera/internal/software_isp/debayer_params.h"
23#include "libcamera/internal/software_isp/swstats_cpu.h"
36 const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
40 std::tuple<unsigned int, unsigned int>
75 using debayerFn = void (
DebayerCpu::*)(uint8_t *dst, const uint8_t *src[]);
78 template<
bool addAlphaByte,
bool ccmEnabled>
79 void debayer8_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
80 template<
bool addAlphaByte,
bool ccmEnabled>
81 void debayer8_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
83 template<
bool addAlphaByte,
bool ccmEnabled>
84 void debayer10_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
85 template<
bool addAlphaByte,
bool ccmEnabled>
86 void debayer10_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
88 template<
bool addAlphaByte,
bool ccmEnabled>
89 void debayer12_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
90 template<
bool addAlphaByte,
bool ccmEnabled>
91 void debayer12_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
93 template<
bool addAlphaByte,
bool ccmEnabled>
94 void debayer10P_BGBG_BGR888(uint8_t *dst,
const uint8_t *src[]);
95 template<
bool addAlphaByte,
bool ccmEnabled>
96 void debayer10P_GRGR_BGR888(uint8_t *dst,
const uint8_t *src[]);
97 template<
bool addAlphaByte,
bool ccmEnabled>
98 void debayer10P_GBGB_BGR888(uint8_t *dst,
const uint8_t *src[]);
99 template<
bool addAlphaByte,
bool ccmEnabled>
100 void debayer10P_RGRG_BGR888(uint8_t *dst,
const uint8_t *src[]);
102 static int getInputConfig(
PixelFormat inputFormat, DebayerInputConfig &config);
103 static int getOutputConfig(
PixelFormat outputFormat, DebayerOutputConfig &config);
108 void setupInputMemcpy(
const uint8_t *linePointers[]);
109 void shiftLinePointers(
const uint8_t *linePointers[],
const uint8_t *src);
110 void memcpyNextLine(
const uint8_t *linePointers[]);
111 void process2(uint32_t frame,
const uint8_t *src, uint8_t *dst);
112 void process4(uint32_t frame,
const uint8_t *src, uint8_t *dst);
117 static constexpr unsigned int kMaxLineBuffers = 5;
119 static constexpr unsigned int kRGBLookupSize = 256;
120 static constexpr unsigned int kGammaLookupSize = 1024;
126 using LookupTable = std::array<uint8_t, kRGBLookupSize>;
127 using CcmLookupTable = std::array<CcmColumn, kRGBLookupSize>;
131 CcmLookupTable redCcm_;
132 CcmLookupTable greenCcm_;
133 CcmLookupTable blueCcm_;
134 std::array<double, kGammaLookupSize> gammaTable_;
135 LookupTable gammaLut_;
137 DebayerParams params_;
144 std::unique_ptr<SwStatsCpu> stats_;
145 std::vector<uint8_t> lineBuffers_[kMaxLineBuffers];
146 unsigned int lineBufferLength_;
147 unsigned int lineBufferPadding_;
148 unsigned int lineBufferIndex_;
149 unsigned int xShift_;
150 bool enableInputMemcpy_;
Class for debayering on the CPU.
Definition debayer_cpu.h:30
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)
Process the bayer data into the requested format.
Definition debayer_cpu.cpp:845
Size patternSize(PixelFormat inputFormat)
Get the width and height at which the bayer pattern repeats.
Definition debayer_cpu.cpp:569
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize)
Get the supported output sizes for the given input format and size.
Definition debayer_cpu.cpp:893
int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfgs, bool ccmEnabled)
Configure the debayer object according to the passed in parameters.
Definition debayer_cpu.cpp:481
std::vector< PixelFormat > formats(PixelFormat input)
Get the supported output formats.
Definition debayer_cpu.cpp:579
std::tuple< unsigned int, unsigned int > strideAndFrameSize(const PixelFormat &outputFormat, const Size &size)
Get the stride and the frame size.
Definition debayer_cpu.cpp:590
const SharedFD & getStatsFD()
Get the file descriptor for the statistics.
Definition debayer_cpu.h:44
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
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