libcamera: software_isp: Move param select code to Debayer base class

Move the parameter selection code into the Debayer base class in-order to
facilitate reuse of the lookup tables in the eGL shaders.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
This commit is contained in:
Bryan O'Donoghue 2025-04-20 01:02:25 +01:00
parent 3c0a21fd30
commit c3a8493a12
3 changed files with 47 additions and 23 deletions

View file

@ -187,4 +187,44 @@ Debayer::~Debayer()
* \brief Signals when the output buffer is ready * \brief Signals when the output buffer is ready
*/ */
/**
* \fn void Debayer::setParams(DebayerParams &params)
* \brief Select the bayer params to use for the next frame debayer
* \param[in] params The parameters to be used in debayering
*/
void Debayer::setParams(DebayerParams &params)
{
green_ = params.green;
greenCcm_ = params.greenCcm;
if (swapRedBlueGains_) {
red_ = params.blue;
blue_ = params.red;
redCcm_ = params.blueCcm;
blueCcm_ = params.redCcm;
for (unsigned int i = 0; i < 256; i++) {
std::swap(redCcm_[i].r, redCcm_[i].b);
std::swap(blueCcm_[i].r, blueCcm_[i].b);
}
} else {
red_ = params.red;
blue_ = params.blue;
redCcm_ = params.redCcm;
blueCcm_ = params.blueCcm;
}
gammaLut_ = params.gammaLut;
}
/**
* \fn void Debayer::dmaSyncBegin(DebayerParams &params)
* \brief Common CPU/GPU Dma Sync Buffer begin
*/
void Debayer::dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output)
{
for (const FrameBuffer::Plane &plane : input->planes())
dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);
for (const FrameBuffer::Plane &plane : output->planes())
dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
}
} /* namespace libcamera */ } /* namespace libcamera */

View file

@ -20,6 +20,7 @@
#include <libcamera/geometry.h> #include <libcamera/geometry.h>
#include <libcamera/stream.h> #include <libcamera/stream.h>
#include "libcamera/internal/dma_buf_allocator.h"
#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/benchmark.h"
#include "libcamera/internal/software_isp/debayer_params.h" #include "libcamera/internal/software_isp/debayer_params.h"
@ -82,6 +83,10 @@ public:
private: private:
virtual Size patternSize(PixelFormat inputFormat) = 0; virtual Size patternSize(PixelFormat inputFormat) = 0;
protected:
void setParams(DebayerParams &params);
void dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);
}; };
} /* namespace libcamera */ } /* namespace libcamera */

View file

@ -22,7 +22,6 @@
#include <libcamera/formats.h> #include <libcamera/formats.h>
#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/bayer_format.h"
#include "libcamera/internal/dma_buf_allocator.h"
#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/framebuffer.h"
#include "libcamera/internal/mapped_framebuffer.h" #include "libcamera/internal/mapped_framebuffer.h"
@ -740,30 +739,10 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
bench_.startFrame(); bench_.startFrame();
std::vector<DmaSyncer> dmaSyncers; std::vector<DmaSyncer> dmaSyncers;
for (const FrameBuffer::Plane &plane : input->planes())
dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);
for (const FrameBuffer::Plane &plane : output->planes()) dmaSyncBegin(dmaSyncers, input, output);
dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
green_ = params.green; setParams(params);
greenCcm_ = params.greenCcm;
if (swapRedBlueGains_) {
red_ = params.blue;
blue_ = params.red;
redCcm_ = params.blueCcm;
blueCcm_ = params.redCcm;
for (unsigned int i = 0; i < 256; i++) {
std::swap(redCcm_[i].r, redCcm_[i].b);
std::swap(blueCcm_[i].r, blueCcm_[i].b);
}
} else {
red_ = params.red;
blue_ = params.blue;
redCcm_ = params.redCcm;
blueCcm_ = params.blueCcm;
}
gammaLut_ = params.gammaLut;
/* Copy metadata from the input buffer */ /* Copy metadata from the input buffer */
FrameMetadata &metadata = output->_d()->metadata(); FrameMetadata &metadata = output->_d()->metadata();