Loading...
Searching...
No Matches
debayer.h
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2023, Linaro Ltd
* Copyright (C) 2023, Red Hat Inc.
*
* Authors:
* Hans de Goede <hdegoede@redhat.com>
*
* debayering base class
*/
#pragma once
#include <stdint.h>
#include <libcamera/base/log.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
#include <libcamera/geometry.h>
#include <libcamera/stream.h>
#include "libcamera/internal/bayer_format.h"
#include "libcamera/internal/dma_buf_allocator.h"
#include "libcamera/internal/global_configuration.h"
#include "libcamera/internal/software_isp/benchmark.h"
#include "libcamera/internal/software_isp/debayer_params.h"
namespace libcamera {
class FrameBuffer;
LOG_DECLARE_CATEGORY(Debayer)
class Debayer : public Object
{
public:
Debayer(const GlobalConfiguration &configuration);
virtual ~Debayer() = 0;
virtual int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
bool ccmEnabled) = 0;
virtual std::vector<PixelFormat> formats(PixelFormat inputFormat) = 0;
virtual std::tuple<unsigned int, unsigned int>
strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;
virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;
virtual int start() { return 0; }
virtual void stop() {}
virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;
virtual const SharedFD &getStatsFD() = 0;
unsigned int frameSize() { return outputConfig_.frameSize; }
Signal<FrameBuffer *> inputBufferReady;
Signal<FrameBuffer *> outputBufferReady;
struct DebayerInputConfig {
Size patternSize;
unsigned int bpp;
unsigned int stride;
std::vector<PixelFormat> outputFormats;
};
struct DebayerOutputConfig {
unsigned int bpp;
unsigned int stride;
unsigned int frameSize;
};
DebayerInputConfig inputConfig_;
DebayerOutputConfig outputConfig_;
Size outputSize_;
PixelFormat inputPixelFormat_;
PixelFormat outputPixelFormat_;
bool swapRedBlueGains_;
Benchmark bench_;
private:
virtual Size patternSize(PixelFormat inputFormat) = 0;
protected:
void dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);
static bool isStandardBayerOrder(BayerFormat::Order order);
};
} /* 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:21
libcamera::Debayer
Base debayering class.
Definition debayer.h:36
libcamera::Debayer::configure
virtual int configure(const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfgs, bool ccmEnabled)=0
Configure the debayer object according to the passed in parameters.
libcamera::Debayer::outputPixelFormat_
PixelFormat outputPixelFormat_
The output pixel format.
Definition debayer.h:80
libcamera::Debayer::outputConfig_
DebayerOutputConfig outputConfig_
Output configuration data for the debayered frame.
Definition debayer.h:77
libcamera::Debayer::frameSize
unsigned int frameSize()
Get the output frame size.
Definition debayer.h:58
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::process
virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)=0
Process the bayer data into the requested format.
libcamera::Debayer::stop
virtual void stop()
Stop the debayering process and perform cleanup.
Definition debayer.h:52
libcamera::Debayer::swapRedBlueGains_
bool swapRedBlueGains_
Flag indicating whether red and blue channel gains should be swapped.
Definition debayer.h:81
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:76
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:290
libcamera::Debayer::inputPixelFormat_
PixelFormat inputPixelFormat_
The incoming pixel format.
Definition debayer.h:79
libcamera::Debayer::start
virtual int start()
Execute a start signal in the debayer object from workerthread context.
Definition debayer.h:51
libcamera::Debayer::outputSize_
Size outputSize_
Output size object.
Definition debayer.h:78
libcamera::Debayer::outputBufferReady
Signal< FrameBuffer * > outputBufferReady
Signals when the output buffer is ready.
Definition debayer.h:61
libcamera::Debayer::dmaSyncBegin
void dmaSyncBegin(std::vector< DmaSyncer > &dmaSyncers, FrameBuffer *input, FrameBuffer *output)
Common CPU/GPU Dma Sync Buffer begin.
Definition debayer.cpp:275
libcamera::Debayer::inputBufferReady
Signal< FrameBuffer * > inputBufferReady
Signals when the input buffer is ready.
Definition debayer.h:60
libcamera::Debayer::bench_
Benchmark bench_
Benchmarking utility instance for performance measurements.
Definition debayer.h:82
libcamera::Debayer::getStatsFD
virtual const SharedFD & getStatsFD()=0
Get the file descriptor for the statistics.
libcamera::Debayer::Debayer
Debayer(const GlobalConfiguration &configuration)
Construct a Debayer object.
Definition debayer.cpp:61
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
libcamera::GlobalConfiguration
Support for global libcamera configuration.
Definition global_configuration.h:22
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:63
libcamera::Debayer::DebayerInputConfig::outputFormats
std::vector< PixelFormat > outputFormats
Definition debayer.h:67
libcamera::Debayer::DebayerInputConfig::bpp
unsigned int bpp
Definition debayer.h:65
libcamera::Debayer::DebayerInputConfig::patternSize
Size patternSize
Definition debayer.h:64
libcamera::Debayer::DebayerInputConfig::stride
unsigned int stride
Definition debayer.h:66
libcamera::Debayer::DebayerOutputConfig
Structure describing the output frame configuration.
Definition debayer.h:70
libcamera::Debayer::DebayerOutputConfig::bpp
unsigned int bpp
Definition debayer.h:71
libcamera::Debayer::DebayerOutputConfig::stride
unsigned int stride
Definition debayer.h:72
libcamera::Debayer::DebayerOutputConfig::frameSize
unsigned int frameSize
Definition debayer.h:73
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition stream.h:40