libcamera: include/libcamera/internal/software_isp/software_isp.h Source File

libcamera v0.3.2 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 * Simple software ISP implementation
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
18#include <libcamera/base/class.h>
19#include <libcamera/base/log.h>
20#include <libcamera/base/signal.h>
21#include <libcamera/base/thread.h>
22
23#include <libcamera/geometry.h>
24#include <libcamera/pixel_format.h>
25
26#include <libcamera/ipa/soft_ipa_interface.h>
27#include <libcamera/ipa/soft_ipa_proxy.h>
28
29#include "libcamera/internal/camera_sensor.h"
30#include "libcamera/internal/dma_buf_allocator.h"
31#include "libcamera/internal/pipeline_handler.h"
32#include "libcamera/internal/shared_mem_object.h"
33#include "libcamera/internal/software_isp/debayer_params.h"
34
35namespace libcamera {
36
37class DebayerCpu;
38class FrameBuffer;
39class PixelFormat;
40class Stream;
41struct StreamConfiguration;
42
43 LOG_DECLARE_CATEGORY(SoftwareIsp)
44
45class SoftwareIsp
46{
47public:
48 SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor);
49 ~SoftwareIsp();
50
51 int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }
52
53 bool isValid() const;
54
55 std::vector<PixelFormat> formats(PixelFormat input);
56
57 SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);
58
59 std::tuple<unsigned int, unsigned int>
60 strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
61
62 int configure(const StreamConfiguration &inputCfg,
63 const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
64 const ControlInfoMap &sensorControls);
65
66 int exportBuffers(const Stream *stream, unsigned int count,
67 std::vector<std::unique_ptr<FrameBuffer>> *buffers);
68
69 void processStats(const ControlList &sensorControls);
70
71 int start();
72 void stop();
73
74 int queueBuffers(FrameBuffer *input,
75 const std::map<const Stream *, FrameBuffer *> &outputs);
76
77 void process(FrameBuffer *input, FrameBuffer *output);
78
79 Signal<FrameBuffer *> inputBufferReady;
80 Signal<FrameBuffer *> outputBufferReady;
81 Signal<> ispStatsReady;
82 Signal<const ControlList &> setSensorControls;
83
84private:
85 void saveIspParams();
86 void setSensorCtrls(const ControlList &sensorControls);
87 void statsReady();
88 void inputReady(FrameBuffer *input);
89 void outputReady(FrameBuffer *output);
90
91 std::unique_ptr<DebayerCpu> debayer_;
92 Thread ispWorkerThread_;
93 SharedMemObject<DebayerParams> sharedParams_;
94 DebayerParams debayerParams_;
95 DmaBufAllocator dmaHeap_;
96
97 std::unique_ptr<ipa::soft::IPAProxySoft> ipa_;
98};
99
100} /* namespace libcamera */
camera_sensor.h
A camera sensor.
class.h
Utilities to help constructing class interfaces.
libcamera::CameraSensor
A camera sensor based on V4L2 subdevices.
Definition camera_sensor.h:39
libcamera::ControlInfoMap
A map of ControlId to ControlInfo.
Definition controls.h:306
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:350
libcamera::DmaBufAllocator
Helper class for dma-buf allocations.
Definition dma_buf_allocator.h:16
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:49
libcamera::PipelineHandler
Create and manage cameras based on a set of media devices.
Definition pipeline_handler.h:35
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::SharedMemObject
Helper class to allocate an object in shareable memory.
Definition shared_mem_object.h:60
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera::SizeRange
Describe a range of sizes.
Definition geometry.h:201
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:53
libcamera::SoftwareIsp
Class for the Software ISP.
Definition software_isp.h:46
libcamera::SoftwareIsp::ispStatsReady
Signal ispStatsReady
A signal emitted when the statistics for IPA are ready.
Definition software_isp.h:81
libcamera::SoftwareIsp::loadConfiguration
int loadConfiguration(const std::string &filename)
Load a configuration from a file.
Definition software_isp.h:51
libcamera::SoftwareIsp::inputBufferReady
Signal< FrameBuffer * > inputBufferReady
A signal emitted when the input frame buffer completes.
Definition software_isp.h:79
libcamera::SoftwareIsp::setSensorControls
Signal< const ControlList & > setSensorControls
A signal emitted when the values to write to the sensor controls are ready.
Definition software_isp.h:82
libcamera::SoftwareIsp::outputBufferReady
Signal< FrameBuffer * > outputBufferReady
A signal emitted when the output frame buffer completes.
Definition software_isp.h:80
libcamera::Stream
Video stream for a camera.
Definition stream.h:74
libcamera::Thread
A thread of execution.
Definition thread.h:29
geometry.h
Data structures related to geometric objects.
log.h
Logging infrastructure.
LOG_DECLARE_CATEGORY
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:46
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
pipeline_handler.h
Create pipelines and cameras from a set of media devices.
pixel_format.h
libcamera pixel format
signal.h
Signal & slot implementation.
libcamera::DebayerParams
Struct to hold the debayer parameters.
Definition debayer_params.h:18
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition stream.h:40
thread.h
Thread support.