libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
debayer.h
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2023, Linaro Ltd
4 * Copyright (C) 2023, Red Hat Inc.
5 *
6 * Authors:
7 * Hans de Goede <hdegoede@redhat.com>
8 *
9 * debayering base class
10 */
11
12#pragma once
13
14#include <stdint.h>
15
16#include <libcamera/base/log.h>
17#include <libcamera/base/object.h>
18#include <libcamera/base/signal.h>
19
20#include <libcamera/geometry.h>
21#include <libcamera/stream.h>
22
23#include "libcamera/internal/bayer_format.h"
24#include "libcamera/internal/dma_buf_allocator.h"
25#include "libcamera/internal/software_isp/benchmark.h"
26#include "libcamera/internal/software_isp/debayer_params.h"
27
28 namespace libcamera {
29
30 class CameraManager;
31 class FrameBuffer;
32
33 LOG_DECLARE_CATEGORY(Debayer)
34
35class Debayer : public Object
36{
37 public:
38 Debayer(const CameraManager &cm);
39 virtual ~Debayer() = 0;
40
41 virtual int configure(const StreamConfiguration &inputCfg,
42 const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
43 bool ccmEnabled) = 0;
44
45 virtual std::vector<PixelFormat> formats(PixelFormat inputFormat) = 0;
46
47 virtual std::tuple<unsigned int, unsigned int>
48 strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;
49 virtual uint32_t preferredInputStride([[maybe_unused]] const PixelFormat &inputFormat, [[maybe_unused]] const Size &size) { return 0; }
50
51 virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params) = 0;
52 virtual int start() { return 0; }
53 virtual void stop() {}
54
55 virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;
56
57 virtual const SharedFD &getStatsFD() = 0;
58
59 unsigned int frameSize() { return outputConfig_.frameSize; }
60
61 Signal<FrameBuffer *> inputBufferReady;
62 Signal<FrameBuffer *> outputBufferReady;
63
64 struct DebayerInputConfig {
65 Size patternSize;
66 unsigned int bpp;
67 unsigned int stride;
68 std::vector<PixelFormat> outputFormats;
69 };
70
71 struct DebayerOutputConfig {
72 unsigned int bpp;
73 unsigned int stride;
74 unsigned int frameSize;
75 };
76
77 DebayerInputConfig inputConfig_;
78 DebayerOutputConfig outputConfig_;
79 Size outputSize_;
80 PixelFormat inputPixelFormat_;
81 PixelFormat outputPixelFormat_;
82 bool swapRedBlueGains_;
83 Benchmark bench_;
84
85 private:
86 virtual Size patternSize(PixelFormat inputFormat) = 0;
87
88 protected:
89 void dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);
90 static bool isStandardBayerOrder(BayerFormat::Order order);
91};
92
93} /* namespace libcamera */
bayer_format.h
Class to represent Bayer formats and manipulate them.
libcamera::BayerFormat::Order
Order
The order of the colour channels in the Bayer pattern.
Definition bayer_format.h:25
libcamera::Benchmark
Simple builtin benchmark.
Definition benchmark.h:22
libcamera::CameraManager
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
libcamera::Debayer
Base debayering class.
Definition debayer.h:36
libcamera::Debayer::outputPixelFormat_
PixelFormat outputPixelFormat_
The output pixel format.
Definition debayer.h:81
libcamera::Debayer::outputConfig_
DebayerOutputConfig outputConfig_
Output configuration data for the debayered frame.
Definition debayer.h:78
libcamera::Debayer::preferredInputStride
virtual uint32_t preferredInputStride(const PixelFormat &inputFormat, const Size &size)
Definition debayer.h:49
libcamera::Debayer::Debayer
Debayer(const CameraManager &cm)
Construct a Debayer object.
Definition debayer.cpp:59
libcamera::Debayer::frameSize
unsigned int frameSize()
Get the output frame size.
Definition debayer.h:59
libcamera::Debayer::sizes
virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize)=0
Get the supported output sizes for the given input format and size.
libcamera::Debayer::strideAndFrameSize
virtual std::tuple< unsigned int, unsigned int > strideAndFrameSize(const PixelFormat &outputFormat, const Size &size)=0
Get the stride and the frame size.
libcamera::Debayer::stop
virtual void stop()
Stop the debayering process and perform cleanup.
Definition debayer.h:53
libcamera::Debayer::swapRedBlueGains_
bool swapRedBlueGains_
Flag indicating whether red and blue channel gains should be swapped.
Definition debayer.h:82
libcamera::Debayer::formats
virtual std::vector< PixelFormat > formats(PixelFormat inputFormat)=0
Get the supported output formats.
libcamera::Debayer::inputConfig_
DebayerInputConfig inputConfig_
Input configuration parameters for the current debayer operation.
Definition debayer.h:77
libcamera::Debayer::isStandardBayerOrder
static bool isStandardBayerOrder(BayerFormat::Order order)
Common method to validate standard 2x2 Bayer pattern of 2 Green, 1 Blue, 1 Red pixels.
Definition debayer.cpp:297
libcamera::Debayer::inputPixelFormat_
PixelFormat inputPixelFormat_
The incoming pixel format.
Definition debayer.h:80
libcamera::Debayer::start
virtual int start()
Execute a start signal in the debayer object from workerthread context.
Definition debayer.h:52
libcamera::Debayer::outputSize_
Size outputSize_
Output size object.
Definition debayer.h:79
libcamera::Debayer::process
virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params)=0
Process the bayer data into the requested format.
libcamera::Debayer::outputBufferReady
Signal< FrameBuffer * > outputBufferReady
Signals when the output buffer is ready.
Definition debayer.h:62
libcamera::Debayer::dmaSyncBegin
void dmaSyncBegin(std::vector< DmaSyncer > &dmaSyncers, FrameBuffer *input, FrameBuffer *output)
Common CPU/GPU Dma Sync Buffer begin.
Definition debayer.cpp:282
libcamera::Debayer::configure
virtual int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< const StreamConfiguration > > &outputCfgs, bool ccmEnabled)=0
Configure the debayer object according to the passed in parameters.
libcamera::Debayer::inputBufferReady
Signal< FrameBuffer * > inputBufferReady
Signals when the input buffer is ready.
Definition debayer.h:61
libcamera::Debayer::bench_
Benchmark bench_
Benchmarking utility instance for performance measurements.
Definition debayer.h:83
libcamera::Debayer::getStatsFD
virtual const SharedFD & getStatsFD()=0
Get the file descriptor for the statistics.
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
libcamera::Object::Object
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::SharedFD
RAII-style wrapper for file descriptors.
Definition shared_fd.h:17
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera::SizeRange
Describe a range of sizes.
Definition geometry.h:205
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:51
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:51
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
object.h
Base object to support automatic signal disconnection.
signal.h
Signal & slot implementation.
stream.h
Video stream for a Camera.
libcamera::DebayerParams
Struct to hold the debayer parameters.
Definition debayer_params.h:20
libcamera::Debayer::DebayerInputConfig
Structure describing the incoming Bayer parameters.
Definition debayer.h:64
libcamera::Debayer::DebayerInputConfig::outputFormats
std::vector< PixelFormat > outputFormats
Definition debayer.h:68
libcamera::Debayer::DebayerInputConfig::bpp
unsigned int bpp
Definition debayer.h:66
libcamera::Debayer::DebayerInputConfig::patternSize
Size patternSize
Definition debayer.h:65
libcamera::Debayer::DebayerInputConfig::stride
unsigned int stride
Definition debayer.h:67
libcamera::Debayer::DebayerOutputConfig
Structure describing the output frame configuration.
Definition debayer.h:71
libcamera::Debayer::DebayerOutputConfig::bpp
unsigned int bpp
Definition debayer.h:72
libcamera::Debayer::DebayerOutputConfig::stride
unsigned int stride
Definition debayer.h:73
libcamera::Debayer::DebayerOutputConfig::frameSize
unsigned int frameSize
Definition debayer.h:74
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition stream.h:40