libcamera v0.2.0+3-70b69666-nvm
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
software_isp.h
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2023, Linaro Ltd
4 *
5 * software_isp.h - Interface for a software implementation of an ISP
6 */
7
8#pragma once
9
10#include <functional>
11#include <initializer_list>
12#include <map>
13#include <memory>
14#include <string>
15#include <tuple>
16#include <vector>
17
19#include <libcamera/base/log.h>
21
22#include <libcamera/geometry.h>
23
25
26namespace libcamera {
27
28class FrameBuffer;
29class PixelFormat;
30struct StreamConfiguration;
31
32LOG_DECLARE_CATEGORY(SoftwareIsp)
33
34
40{
41public:
47 SoftwareIsp(PipelineHandler *pipe, const ControlInfoMap &sensorControls);
48 virtual ~SoftwareIsp();
49
56 virtual int loadConfiguration(const std::string &filename) = 0;
57
63 virtual bool isValid() const = 0;
64
71 virtual std::vector<PixelFormat> formats(PixelFormat input) = 0;
72
80 virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;
81
89 virtual std::tuple<unsigned int, unsigned int>
90 strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;
91
100 virtual int configure(const StreamConfiguration &inputCfg,
101 const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
102 const ControlInfoMap &sensorControls) = 0;
103
112 virtual int exportBuffers(unsigned int output, unsigned int count,
113 std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;
114
120 virtual int start() = 0;
121
125 virtual void stop() = 0;
126
134 virtual int queueBuffers(FrameBuffer *input,
135 const std::map<unsigned int, FrameBuffer *> &outputs) = 0;
136
141 virtual void processStats(const ControlList &sensorControls) = 0; // rather merge with queueBuffers()?
142
149
158
165};
166
173{
174public:
176 virtual ~SoftwareIspFactoryBase() = default;
177
185 static std::unique_ptr<SoftwareIsp> create(PipelineHandler *pipe,
186 const ControlInfoMap &sensorControls);
193
194private:
196
197 static void registerType(SoftwareIspFactoryBase *factory);
198 virtual std::unique_ptr<SoftwareIsp> createInstance(PipelineHandler *pipe,
199 const ControlInfoMap &sensorControls) const = 0;
200};
201
205template<typename _SoftwareIsp>
207{
208public:
211 {
212 }
213
221 std::unique_ptr<SoftwareIsp> createInstance(PipelineHandler *pipe,
222 const ControlInfoMap &sensorControls) const override
223 {
224 return std::make_unique<_SoftwareIsp>(pipe, sensorControls);
225 }
226};
227
228#define REGISTER_SOFTWAREISP(softwareIsp) \
229 static SoftwareIspFactory<softwareIsp> global_##softwareIsp##Factory;
230
231} /* namespace libcamera */
Utilities to help constructing class interfaces.
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Definition class.h:29
A map of ControlId to ControlInfo.
Definition controls.h:306
Associate a list of ControlId with their values for an object.
Definition controls.h:350
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
Create and manage cameras based on a set of media devices.
Definition pipeline_handler.h:39
libcamera image pixel format
Definition pixel_format.h:18
Generic signal and slot communication mechanism.
Definition signal.h:39
Describe a range of sizes.
Definition geometry.h:201
Describe a two-dimensional size.
Definition geometry.h:53
Base class for the Software ISP Factory.
Definition software_isp.h:173
static std::unique_ptr< SoftwareIsp > create(PipelineHandler *pipe, const ControlInfoMap &sensorControls)
Creates a SoftwareIsp object.
Definition software_isp.cpp:48
static SoftwareIspFactoryBase *& factory()
Gives back a pointer to the factory.
Definition software_isp.cpp:41
Implementation for the Software ISP Factory.
Definition software_isp.h:207
std::unique_ptr< SoftwareIsp > createInstance(PipelineHandler *pipe, const ControlInfoMap &sensorControls) const override
Creates an instance of a SoftwareIsp object.
Definition software_isp.h:221
Base class for the Software ISP.
Definition software_isp.h:40
virtual int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfgs, const ControlInfoMap &sensorControls)=0
Configure the SwIspSimple object according to the passed in parameters.
virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize)=0
Get the supported output sizes for the given input format and size.
virtual int loadConfiguration(const std::string &filename)=0
Load a configuration from a file.
virtual int start()=0
Starts the Software ISP worker.
virtual int queueBuffers(FrameBuffer *input, const std::map< unsigned int, FrameBuffer * > &outputs)=0
Queues buffers for processing.
Signal< FrameBuffer * > inputBufferReady
Signals that the input buffer is ready.
Definition software_isp.h:153
virtual void stop()=0
Stops the Software ISP worker.
virtual int exportBuffers(unsigned int output, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers)=0
Exports the buffers for use in processing.
virtual Signal< const ControlList & > & getSignalSetSensorControls()=0
Get the signal for when the sensor controls are set.
virtual void processStats(const ControlList &sensorControls)=0
Process the statistics gathered.
virtual std::tuple< unsigned int, unsigned int > strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size)=0
Get the stride and the frame size.
virtual bool isValid() const =0
Gets if there is a valid debayer object.
Signal< int > ispStatsReady
Signals that the ISP stats are ready.
Definition software_isp.h:164
Signal< FrameBuffer * > outputBufferReady
Signals that the output buffer is ready.
Definition software_isp.h:157
virtual std::vector< PixelFormat > formats(PixelFormat input)=0
Get the supported output formats.
Data structures related to geometric objects.
Logging infrastructure.
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:47
Top-level libcamera namespace.
Definition backtrace.h:17
Create pipelines and cameras from a set of media devices.
Signal & slot implementation.
Configuration parameters for a stream.
Definition stream.h:41