@@ -33,6 +33,7 @@
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/shared_mem_object.h"
#include "libcamera/internal/software_isp/debayer_params.h"
+#include "libcamera/internal/software_isp/swstats_cpu.h"
namespace libcamera {
@@ -102,6 +103,7 @@ private:
DmaBufAllocator dmaHeap_;
bool ccmEnabled_;
bool lscEnabled_;
+ std::shared_ptr<SwStatsCpu> stats_;
std::unique_ptr<ipa::softisp::IPAProxySoftIsp> ipa_;
std::deque<FrameBuffer *> queuedInputBuffers_;
@@ -174,16 +174,6 @@ Debayer::~Debayer()
* \return The valid size ranges or an empty range if there are none
*/
-/**
- * \fn const SharedFD &Debayer::getStatsFD()
- * \brief Get the file descriptor for the statistics
- *
- * This file descriptor provides access to the output statistics buffer
- * associated with the current debayering process.
- *
- * \return The file descriptor pointing to the statistics data
- */
-
/**
* \fn unsigned int Debayer::frameSize()
* \brief Get the output frame size
@@ -55,8 +55,6 @@ public:
virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;
- virtual const SharedFD &getStatsFD() = 0;
-
unsigned int frameSize() { return outputConfig_.frameSize; }
Signal<FrameBuffer *> inputBufferReady;
@@ -93,7 +93,7 @@ DebayerCpuThread::DebayerCpuThread(DebayerCpu *debayer, unsigned int threadIndex
* \param[in] stats Pointer to the stats object to use
* \param[in] cm The camera manager
*/
-DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats, const CameraManager &cm)
+DebayerCpu::DebayerCpu(std::shared_ptr<SwStatsCpu> stats, const CameraManager &cm)
: Debayer(cm), stats_(std::move(stats))
{
/*
@@ -32,7 +32,7 @@ class DebayerCpuThread;
class DebayerCpu : public Debayer
{
public:
- DebayerCpu(std::unique_ptr<SwStatsCpu> stats, const CameraManager &cm);
+ DebayerCpu(std::shared_ptr<SwStatsCpu> stats, const CameraManager &cm);
~DebayerCpu();
int configure(const StreamConfiguration &inputCfg,
@@ -47,7 +47,6 @@ public:
int start() override;
void stop() override;
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override;
- const SharedFD &getStatsFD() override { return stats_->getStatsFD(); }
private:
friend class DebayerCpuThread;
@@ -154,7 +153,7 @@ private:
debayerFn debayer2_;
debayerFn debayer3_;
Rectangle window_;
- std::unique_ptr<SwStatsCpu> stats_;
+ std::shared_ptr<SwStatsCpu> stats_;
unsigned int xShift_; /* Offset of 0/1 applied to window_.x */
static constexpr unsigned int kMinThreads = 1;
@@ -42,7 +42,7 @@ namespace libcamera {
* \param[in] cm The camera manager
* \param[in] display The EGL display to use
*/
-DebayerEGL::DebayerEGL(std::unique_ptr<SwStatsCpu> stats, const CameraManager &cm, EGLDisplay display)
+DebayerEGL::DebayerEGL(std::shared_ptr<SwStatsCpu> stats, const CameraManager &cm, EGLDisplay display)
: Debayer(cm), stats_(std::move(stats)), egl_(display)
{
}
@@ -40,7 +40,7 @@ class CameraManager;
class DebayerEGL : public Debayer
{
public:
- DebayerEGL(std::unique_ptr<SwStatsCpu> stats, const CameraManager &cm, EGLDisplay display);
+ DebayerEGL(std::shared_ptr<SwStatsCpu> stats, const CameraManager &cm, EGLDisplay display);
~DebayerEGL();
int configure(const StreamConfiguration &inputCfg,
@@ -58,8 +58,6 @@ public:
int start() override;
void stop() override;
- const SharedFD &getStatsFD() override { return stats_->getStatsFD(); }
-
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override;
private:
@@ -121,7 +119,7 @@ private:
Size nativeOutputSize_;
Rectangle window_;
- std::unique_ptr<SwStatsCpu> stats_;
+ std::shared_ptr<SwStatsCpu> stats_;
eGL egl_;
uint32_t width_;
uint32_t height_;
@@ -98,12 +98,12 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
const CameraManager &cm = *pipe->cameraManager();
- auto stats = std::make_unique<SwStatsCpu>(cm);
- if (!stats->isValid()) {
+ stats_ = std::make_shared<SwStatsCpu>(cm);
+ if (!stats_->isValid()) {
LOG(SoftwareIsp, Error) << "Failed to create SwStatsCpu object";
return;
}
- stats->statsReady.connect(this, &SoftwareIsp::statsReady);
+ stats_->statsReady.connect(this, &SoftwareIsp::statsReady);
#if HAVE_DEBAYER_EGL
const GlobalConfiguration &configuration = cm._d()->configuration();
@@ -121,7 +121,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
if (!softISPMode || softISPMode == "gpu") {
auto display = eGL::probeDisplay();
if (display != EGL_NO_DISPLAY) {
- debayer_ = std::make_unique<DebayerEGL>(std::move(stats), cm, display);
+ debayer_ = std::make_unique<DebayerEGL>(stats_, cm, display);
} else {
LOG(SoftwareIsp, Info)
<< "EGL not available, falling back to CPU debayer";
@@ -130,7 +130,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
#endif
if (!debayer_)
- debayer_ = std::make_unique<DebayerCpu>(std::move(stats), cm);
+ debayer_ = std::make_unique<DebayerCpu>(stats_, cm);
debayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady);
debayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady);
@@ -158,7 +158,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
}
ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() },
- debayer_->getStatsFD(),
+ stats_->getStatsFD(),
sharedParams_.fd(),
sensorInfo,
sensor->controls(),