From patchwork Thu Jun 18 12:22:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 26935 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D951CC3301 for ; Thu, 18 Jun 2026 12:23:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71CCD62C6D; Thu, 18 Jun 2026 14:23:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HDZAXm9Y"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 11EFB629A8 for ; Thu, 18 Jun 2026 14:22:59 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-490be29c1c5so7263125e9.2 for ; Thu, 18 Jun 2026 05:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781785379; x=1782390179; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lU+S6rm4EDKAJ6Icy3YR22fQP98Ke30bgUg2epSurEg=; b=HDZAXm9YutX0ACE/VQGOvCpu95OMz9EgRwU3zqLuyTKITmfJSw+mG591hk9R3Lru0u Snn5pYqg7u7Tk7aSseGMX5Y8Ym7zckesYsTtXWohlGJ0MfAAHXjKvVoKRpVCkU2VKRk+ aQzugDTolewHK/vh6IN6eNfxBZp4xvLg7xHlgxXLqrncSKHGCz2fP7T+d/1rlIGBDYTd 1Y34SN2yJbblSMme6/Aqg2sIGHWeU0Yt7hG38QhO9vviXtC7tCjKVMGhBtNA+heTgLO0 GNbhDNg7a7u6C8W9mOr8Wg99uOXXYEiCXkRDTJcPpWZuXW9t3Vn20B4XPf1tMJva651x YtZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781785379; x=1782390179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lU+S6rm4EDKAJ6Icy3YR22fQP98Ke30bgUg2epSurEg=; b=lX0DgDSbOIUI3UAHntCgqybekDCQ72Soj6be7xdj18EnS4C7prFCg5SGNl9FIPsU02 hw/jIUsSqJrXbuVkJ7kGIuK+nh3Hyfxb1iFpl1nQ2GLhda/sfhlh+yb5BwZaN5CnFvDL imsnRjPQC5uxYMfPEZ6xGbt5dUJKLO10S0kj22+lCo/l7/X539ivMhpnvk5sHSxPY8NL O48/qvusDe2VfKKxW/SOUh2GOD7IrRcFbp2HR7CxmmJdzq5jiVeTZDhIMEO2q1JbjlgD SGjnZr89zut3PnYq033/Tr5QlZNUQqCxOFpObq1JDi9Of2F3E3GaiZNdRuCyTb7Xv0oE AIKQ== X-Gm-Message-State: AOJu0YxxYWr1OeE+mY8bJxY/9Jywa3x66DV5wqCNacerpZlROGLQDWLp RDQXfktdDqbUkZ9T/5RNL+RIX/96vyzhzNqmwc8qK/0FpIC7EOd1I1NhOTHX9ks4L7n0J2Pv2fu fj2+aa4A= X-Gm-Gg: AfdE7cnBvsSLPrFcrsSO5PZVcgDnD9Vj6NhJGmMoj+PMSpSkPz4bJJsNe95paT3COTg 9aIfHXaJkWLBfaWQkw/JNEv0A8YgDNXSXIJdnuUVLlhmndhkOnv0SU9rt+mGdYLObEIVff+oRss 8gAIA0yEhcDNEc+ChdxWLCOhLW5aTs3JKONiZLgx4PU3kei0ixjXwTS1JdQQ1aTlflJHFA1SwN5 dPaVzjfZl2aqGeLYuHeAJ6rM0N5wCyjhFcvnd7T9Biv3u5g+2TIRluVSE6Zi8KykzoJWkRxsAPg enMj0xG+LFNzNdqYlEBgtU6TKOOLVFt95Iei+3e4mGKO2hyAVxVqgB3pguYsm3GvtrI8yWvGx6q neCZWBXIIzGOBckQDxYNBurguGB5DgwwpvIC1QXF+e9H5ce7S8aSMVeNMStwhbqTEKStYejihSQ ggRHC5CwPBpfMdtwr+xpgh1mlcIcaW X-Received: by 2002:a05:600c:a114:b0:490:e243:4806 with SMTP id 5b1f17b1804b1-492333bf4ebmr114850085e9.9.1781785377832; Thu, 18 Jun 2026 05:22:57 -0700 (PDT) Received: from inspiron14p-linux ([109.76.144.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a4easm275198015e9.3.2026.06.18.05.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 05:22:57 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: bryan.odonoghue@linaro.org, pavel@ucw.cz Subject: [PATCH 01/30] libcamera: software_isp: Rename Bayer classes to SoftwareIspPipeline Date: Thu, 18 Jun 2026 13:22:14 +0100 Message-ID: <20260618122245.946138-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618122245.946138-1-bryan.odonoghue@linaro.org> References: <20260618122245.946138-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The GPUISP multi-pass really wants to run a series of shaders inside of its process() block. Looking at the classes we have now the Debayer class really implements high level logic for the ISP that just so happens to be centered around Bayer operations. We have already done alot of work to make softisp mesa/thread safe so the logical step to take is to start adding in support for more shaders to our existing EGL implementation. It feels lazy sticking to the debayer_-> object and naming convention and moreover it won't be accurate in later patches. Its a little less satisfying for the DebayerCpu to rename it to SoftwareIspPipelineCpu but it also isn't a lie. SoftIsp itself doesn't especially need to know what is happening inside of the invokeMethod(process) signal save that "sutff" happens and data is returned. For obvious reasons we started with a base class of type Debayer but, now that we are expanding the capabilities of SoftIsp to go beyond things that happen in the demosiac phase - we also need to outgrow the constraining name Bayer - no disrespect to Bruce Bayer himself intended. Signed-off-by: Bryan O'Donoghue --- .../internal/software_isp/software_isp.h | 4 +- src/libcamera/software_isp/meson.build | 6 +- src/libcamera/software_isp/software_isp.cpp | 60 +++---- ...{debayer.cpp => software_isp_pipeline.cpp} | 77 +++++---- .../{debayer.h => software_isp_pipeline.h} | 8 +- ..._cpu.cpp => software_isp_pipeline_cpu.cpp} | 160 +++++++++--------- ...ayer_cpu.h => software_isp_pipeline_cpu.h} | 10 +- ..._egl.cpp => software_isp_pipeline_gpu.cpp} | 51 +++--- ...ayer_egl.h => software_isp_pipeline_gpu.h} | 8 +- 9 files changed, 192 insertions(+), 192 deletions(-) rename src/libcamera/software_isp/{debayer.cpp => software_isp_pipeline.cpp} (73%) rename src/libcamera/software_isp/{debayer.h => software_isp_pipeline.h} (93%) rename src/libcamera/software_isp/{debayer_cpu.cpp => software_isp_pipeline_cpu.cpp} (84%) rename src/libcamera/software_isp/{debayer_cpu.h => software_isp_pipeline_cpu.h} (95%) rename src/libcamera/software_isp/{debayer_egl.cpp => software_isp_pipeline_gpu.cpp} (90%) rename src/libcamera/software_isp/{debayer_egl.h => software_isp_pipeline_gpu.h} (93%) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 86cb8f8de..f29e478a5 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -36,9 +36,9 @@ namespace libcamera { -class Debayer; class FrameBuffer; class PixelFormat; +class SoftwareIspPipeline; class Stream; struct StreamConfiguration; @@ -93,7 +93,7 @@ private: void statsReady(uint32_t frame, uint32_t bufferId); void inputReady(FrameBuffer *input); void outputReady(FrameBuffer *output); - std::unique_ptr debayer_; + std::unique_ptr pipeline_; Thread ispWorkerThread_; SharedMemObject sharedParams_; DebayerParams debayerParams_; diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index 15f9e4032..51cc6ac3e 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -21,8 +21,8 @@ summary({'SoftISP GPU acceleration' : mesa_works}, libcamera_internal_sources += files([ 'benchmark.cpp', - 'debayer.cpp', - 'debayer_cpu.cpp', + 'software_isp_pipeline.cpp', + 'software_isp_pipeline_cpu.cpp', 'software_isp.cpp', 'swstats_cpu.cpp', ]) @@ -31,7 +31,7 @@ if mesa_works config_h.set('HAVE_DEBAYER_EGL', 1) libcamera_internal_sources += files([ '../egl.cpp', - 'debayer_egl.cpp', + 'software_isp_pipeline_gpu.cpp', ]) libcamera_deps += [ libegl, diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 781cf02f8..c99d8654c 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -27,9 +27,9 @@ #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/software_isp/debayer_params.h" -#include "debayer_cpu.h" +#include "software_isp_pipeline_cpu.h" #if HAVE_DEBAYER_EGL -#include "debayer_egl.h" +#include "software_isp_pipeline_gpu.h" #endif /** @@ -120,20 +120,20 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, } if (!softISPMode || softISPMode == "gpu") - debayer_ = std::make_unique(std::move(stats), cm); + pipeline_ = std::make_unique(std::move(stats), cm); #endif - if (!debayer_) - debayer_ = std::make_unique(std::move(stats), cm); + if (!pipeline_) + pipeline_ = std::make_unique(std::move(stats), cm); - debayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady); - debayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady); + pipeline_->inputBufferReady.connect(this, &SoftwareIsp::inputReady); + pipeline_->outputBufferReady.connect(this, &SoftwareIsp::outputReady); ipa_ = pipe->createIPA(0, 0); if (!ipa_) { LOG(SoftwareIsp, Error) << "Creating IPA for software ISP failed"; - debayer_.reset(); + pipeline_.reset(); return; } @@ -152,7 +152,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, } ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, - debayer_->getStatsFD(), + pipeline_->getStatsFD(), sharedParams_.fd(), sensorInfo, sensor->controls(), @@ -160,7 +160,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, &ccmEnabled_); if (ret) { LOG(SoftwareIsp, Error) << "IPA init failed"; - debayer_.reset(); + pipeline_.reset(); return; } @@ -171,13 +171,13 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, }); ipa_->setSensorControls.connect(this, &SoftwareIsp::setSensorCtrls); - debayer_->moveToThread(&ispWorkerThread_); + pipeline_->moveToThread(&ispWorkerThread_); } SoftwareIsp::~SoftwareIsp() { - /* make sure to destroy the DebayerCpu before the ispWorkerThread_ is gone */ - debayer_.reset(); + /* make sure to destroy the SoftwareIspPipeline before the ispWorkerThread_ is gone */ + pipeline_.reset(); } /** @@ -212,7 +212,7 @@ void SoftwareIsp::processStats(const uint32_t frame, const uint32_t bufferId, */ bool SoftwareIsp::isValid() const { - return !!debayer_; + return !!pipeline_; } /** @@ -222,9 +222,9 @@ bool SoftwareIsp::isValid() const */ std::vector SoftwareIsp::formats(PixelFormat inputFormat) { - ASSERT(debayer_); + ASSERT(pipeline_); - return debayer_->formats(inputFormat); + return pipeline_->formats(inputFormat); } /** @@ -235,9 +235,9 @@ std::vector SoftwareIsp::formats(PixelFormat inputFormat) */ SizeRange SoftwareIsp::sizes(PixelFormat inputFormat, const Size &inputSize) { - ASSERT(debayer_); + ASSERT(pipeline_); - return debayer_->sizes(inputFormat, inputSize); + return pipeline_->sizes(inputFormat, inputSize); } /** @@ -250,9 +250,9 @@ SizeRange SoftwareIsp::sizes(PixelFormat inputFormat, const Size &inputSize) std::tuple SoftwareIsp::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) { - ASSERT(debayer_); + ASSERT(pipeline_); - return debayer_->strideAndFrameSize(outputFormat, size); + return pipeline_->strideAndFrameSize(outputFormat, size); } /** @@ -267,13 +267,13 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, const ipa::soft::IPAConfigInfo &configInfo) { - ASSERT(ipa_ && debayer_); + ASSERT(ipa_ && pipeline_); int ret = ipa_->configure(configInfo); if (ret < 0) return ret; - ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_); + ret = pipeline_->configure(inputCfg, outputCfgs, ccmEnabled_); if (ret < 0) return ret; @@ -296,13 +296,13 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count, std::vector> *buffers) { - ASSERT(debayer_ != nullptr); + ASSERT(pipeline_ != nullptr); /* single output for now */ if (stream == nullptr) return -EINVAL; - return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); + return dmaHeap_.exportBuffers(count, { pipeline_->frameSize() }, buffers); } /** @@ -364,8 +364,8 @@ int SoftwareIsp::start() ispWorkerThread_.start(); - return debayer_->invokeMethod(&Debayer::start, - ConnectionTypeBlocking); + return pipeline_->invokeMethod(&SoftwareIspPipeline::start, + ConnectionTypeBlocking); } /** @@ -376,8 +376,8 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { - debayer_->invokeMethod(&Debayer::stop, - ConnectionTypeBlocking); + pipeline_->invokeMethod(&SoftwareIspPipeline::stop, + ConnectionTypeBlocking); ispWorkerThread_.exit(); ispWorkerThread_.wait(); @@ -410,8 +410,8 @@ void SoftwareIsp::stop() void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output) { ipa_->computeParams(frame); - debayer_->invokeMethod(&Debayer::process, - ConnectionTypeQueued, frame, input, output, debayerParams_); + pipeline_->invokeMethod(&SoftwareIspPipeline::process, + ConnectionTypeQueued, frame, input, output, debayerParams_); } void SoftwareIsp::saveIspParams() diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/software_isp_pipeline.cpp similarity index 73% rename from src/libcamera/software_isp/debayer.cpp rename to src/libcamera/software_isp/software_isp_pipeline.cpp index 2d7abfb83..85fd4b120 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/software_isp_pipeline.cpp @@ -6,10 +6,10 @@ * Authors: * Hans de Goede * - * debayer base class + * SoftwareIspPipeline base class */ -#include "debayer.h" +#include "software_isp_pipeline.h" namespace libcamera { @@ -44,7 +44,7 @@ namespace libcamera { */ /** - * \class Debayer + * \class SoftwareIspPipeline * \brief Base debayering class * * Base class that provides functions for setting up the debayering process. @@ -56,17 +56,16 @@ LOG_DEFINE_CATEGORY(Debayer) * \brief Construct a Debayer object * \param[in] cm The camera manager */ -Debayer::Debayer(const CameraManager &cm) +SoftwareIspPipeline::SoftwareIspPipeline(const CameraManager &cm) : bench_(cm, "Debayer") { } - -Debayer::~Debayer() +SoftwareIspPipeline::~SoftwareIspPipeline() { } /** - * \fn int Debayer::configure() + * \fn int SoftwareIspPipeline::configure() * \brief Configure the debayer object according to the passed in parameters * \param[in] inputCfg The input configuration * \param[in] outputCfgs The output configurations @@ -76,7 +75,7 @@ Debayer::~Debayer() */ /** - * \fn Size Debayer::patternSize(PixelFormat inputFormat) + * \fn Size SoftwareIspPipeline::patternSize(PixelFormat inputFormat) * \brief Get the width and height at which the bayer pattern repeats * \param[in] inputFormat The input format * @@ -86,7 +85,7 @@ Debayer::~Debayer() */ /** - * \fn std::vector Debayer::formats(PixelFormat inputFormat) + * \fn std::vector SoftwareIspPipeline::formats(PixelFormat inputFormat) * \brief Get the supported output formats * \param[in] inputFormat The input format * @@ -94,7 +93,7 @@ Debayer::~Debayer() */ /** - * \fn std::tuple Debayer::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) + * \fn std::tuple SoftwareIspPipeline::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) * \brief Get the stride and the frame size * \param[in] outputFormat The output format * \param[in] size The output size @@ -104,7 +103,7 @@ Debayer::~Debayer() */ /** - * \fn void Debayer::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) + * \fn void SoftwareIspPipeline::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) * \brief Process the bayer data into the requested format * \param[in] frame The frame number * \param[in] input The input buffer @@ -116,7 +115,7 @@ Debayer::~Debayer() */ /** - * \fn virtual SizeRange Debayer::sizes(PixelFormat inputFormat, const Size &inputSize) + * \fn virtual SizeRange SoftwareIspPipeline::sizes(PixelFormat inputFormat, const Size &inputSize) * \brief Get the supported output sizes for the given input format and size * \param[in] inputFormat The input format * \param[in] inputSize The input size @@ -125,7 +124,7 @@ Debayer::~Debayer() */ /** - * \fn const SharedFD &Debayer::getStatsFD() + * \fn const SharedFD &SoftwareIspPipeline::getStatsFD() * \brief Get the file descriptor for the statistics * * This file descriptor provides access to the output statistics buffer @@ -135,7 +134,7 @@ Debayer::~Debayer() */ /** - * \fn unsigned int Debayer::frameSize() + * \fn unsigned int SoftwareIspPipeline::frameSize() * \brief Get the output frame size * * \return The total output frame size in bytes as configured for the @@ -143,17 +142,17 @@ Debayer::~Debayer() */ /** - * \var Signal Debayer::inputBufferReady + * \var Signal SoftwareIspPipeline::inputBufferReady * \brief Signals when the input buffer is ready */ /** - * \var Signal Debayer::outputBufferReady + * \var Signal SoftwareIspPipeline::outputBufferReady * \brief Signals when the output buffer is ready */ /** - * \struct Debayer::DebayerInputConfig + * \struct SoftwareIspPipeline::DebayerInputConfig * \brief Structure describing the incoming Bayer parameters * * The DebayerInputConfig structure defines the characteristics of the raw @@ -162,40 +161,40 @@ Debayer::~Debayer() * - Memory layout parameters such as stride and bytes per pixel (\ref bpp) * - A list of supported output pixel formats. * - * \var Debayer::DebayerInputConfig::patternSize + * \var SoftwareIspPipeline::DebayerInputConfig::patternSize * Size of the Bayer pattern in pixels. For standard Bayer formats such as * BGGR, GRBG, GBRG, and RGGB, this is typically 2×2 pixels. * - * \var Debayer::DebayerInputConfig::bpp + * \var SoftwareIspPipeline::DebayerInputConfig::bpp * Number of bytes used per pixel in memory. This reflects storage size, * not precision. * - * \var Debayer::DebayerInputConfig::stride + * \var SoftwareIspPipeline::DebayerInputConfig::stride * Line stride in bytes for the Bayer input frame. * - * \var Debayer::DebayerInputConfig::outputFormats + * \var SoftwareIspPipeline::DebayerInputConfig::outputFormats * List of pixel formats supported as output for this input configuration. */ /** - * \struct Debayer::DebayerOutputConfig + * \struct SoftwareIspPipeline::DebayerOutputConfig * \brief Structure describing the output frame configuration * * Defines how the output of the debayer process is laid out in memory. * It includes per-pixel size, stride, and total frame size. * - * \var Debayer::DebayerOutputConfig::bpp + * \var SoftwareIspPipeline::DebayerOutputConfig::bpp * Bytes used per pixel in the output format. * - * \var Debayer::DebayerOutputConfig::stride + * \var SoftwareIspPipeline::DebayerOutputConfig::stride * Line stride in bytes for the output frame. * - * \var Debayer::DebayerOutputConfig::frameSize + * \var SoftwareIspPipeline::DebayerOutputConfig::frameSize * Total frame size in bytes for the output buffer. */ /** - * \var Debayer::inputConfig_ + * \var SoftwareIspPipeline::inputConfig_ * \brief Input configuration parameters for the current debayer operation * * Holds metadata describing the incoming Bayer image layout, including @@ -204,7 +203,7 @@ Debayer::~Debayer() */ /** - * \var Debayer::outputConfig_ + * \var SoftwareIspPipeline::outputConfig_ * \brief Output configuration data for the debayered frame * * Contains bytes per pixel, stride, and total frame size for the @@ -212,22 +211,22 @@ Debayer::~Debayer() */ /** - * \var Debayer::inputPixelFormat_ + * \var SoftwareIspPipeline::inputPixelFormat_ * \brief The incoming pixel format */ /** - * \var Debayer::outputPixelFormat_ + * \var SoftwareIspPipeline::outputPixelFormat_ * \brief The output pixel format */ /** - * \var Debayer::outputSize_ + * \var SoftwareIspPipeline::outputSize_ * \brief Output size object */ /** - * \var Debayer::swapRedBlueGains_ + * \var SoftwareIspPipeline::swapRedBlueGains_ * \brief Flag indicating whether red and blue channel gains should be swapped * * Used when the Bayer pattern order indicates that red/blue color channels are @@ -235,7 +234,7 @@ Debayer::~Debayer() */ /** - * \var Debayer::bench_ + * \var SoftwareIspPipeline::bench_ * \brief Benchmarking utility instance for performance measurements * * Used internally to track timing and performance metrics during @@ -243,7 +242,7 @@ Debayer::~Debayer() */ /** - * \fn int Debayer::start() + * \fn int SoftwareIspPipeline::start() * \brief Execute a start signal in the debayer object from workerthread context * * The start() method is invoked so that a Debayer object can initialise @@ -255,11 +254,11 @@ Debayer::~Debayer() */ /** - * \fn void Debayer::stop() + * \fn void SoftwareIspPipeline::stop() * \brief Stop the debayering process and perform cleanup * * The stop() method is invoked as the logically corollary of start(). - * Debayer::stop() will be called by software_isp::stop() allowing for any + * SoftwareIspPipeline::stop() will be called by software_isp::stop() allowing for any * cleanup which should happend with stop(). * * The stop method similar to start() is useful for DebayerEGL as it allows @@ -268,10 +267,10 @@ Debayer::~Debayer() */ /** - * \fn void Debayer::dmaSyncBegin(DebayerParams ¶ms) + * \fn void SoftwareIspPipeline::dmaSyncBegin(DebayerParams ¶ms) * \brief Common CPU/GPU Dma Sync Buffer begin */ -void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output) +void SoftwareIspPipeline::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output) { for (const FrameBuffer::Plane &plane : input->planes()) dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); @@ -283,10 +282,10 @@ void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *inpu } /** - * \fn void Debayer::isStandardBayerOrder(BayerFormat::Order order) + * \fn void SoftwareIspPipeline::isStandardBayerOrder(BayerFormat::Order order) * \brief Common method to validate standard 2x2 Bayer pattern of 2 Green, 1 Blue, 1 Red pixels */ -bool Debayer::isStandardBayerOrder(BayerFormat::Order order) +bool SoftwareIspPipeline::isStandardBayerOrder(BayerFormat::Order order) { return order == BayerFormat::BGGR || order == BayerFormat::GBRG || order == BayerFormat::GRBG || order == BayerFormat::RGGB; diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/software_isp_pipeline.h similarity index 93% rename from src/libcamera/software_isp/debayer.h rename to src/libcamera/software_isp/software_isp_pipeline.h index a2a17ec18..63b7dddd7 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/software_isp_pipeline.h @@ -6,7 +6,7 @@ * Authors: * Hans de Goede * - * debayering base class + * SoftwareIspPipeline base class */ #pragma once @@ -32,11 +32,11 @@ class FrameBuffer; LOG_DECLARE_CATEGORY(Debayer) -class Debayer : public Object +class SoftwareIspPipeline : public Object { public: - Debayer(const CameraManager &cm); - virtual ~Debayer() = 0; + SoftwareIspPipeline(const CameraManager &cm); + virtual ~SoftwareIspPipeline() = 0; virtual int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/software_isp_pipeline_cpu.cpp similarity index 84% rename from src/libcamera/software_isp/debayer_cpu.cpp rename to src/libcamera/software_isp/software_isp_pipeline_cpu.cpp index d2596d32b..affe4f180 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/software_isp_pipeline_cpu.cpp @@ -9,7 +9,7 @@ * CPU based debayering class */ -#include "debayer_cpu.h" +#include "software_isp_pipeline_cpu.h" #include #include @@ -38,7 +38,7 @@ namespace libcamera { class DebayerCpuThread : public Thread, public Object { public: - DebayerCpuThread(DebayerCpu *debayer, unsigned int threadIndex, + DebayerCpuThread(SoftwareIspPipelineCpu *pipeline, unsigned int threadIndex, bool enableInputMemcpy); void configure(unsigned int yStart, unsigned int yEnd); @@ -54,7 +54,7 @@ private: /* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */ static constexpr unsigned int kMaxLineBuffers = 5; - DebayerCpu *debayer_; + SoftwareIspPipelineCpu *pipeline_; unsigned int threadIndex_; unsigned int yStart_; unsigned int yEnd_; @@ -67,33 +67,33 @@ private: /** * \brief Construct a DebayerCpuThread object - * \param[in] debayer pointer back to the DebayerCpuObject this thread belongs to + * \param[in] debayer pointer back to the SoftwareIspPipelineCpu this thread belongs to * \param[in] threadIndex 0 .. n thread-index value for the thread * \param[in] enableInputMemcpy when set copy input data to a heap buffer before use */ -DebayerCpuThread::DebayerCpuThread(DebayerCpu *debayer, unsigned int threadIndex, +DebayerCpuThread::DebayerCpuThread(SoftwareIspPipelineCpu *pipeline, unsigned int threadIndex, bool enableInputMemcpy) : Thread("DebayerCpu:" + std::to_string(threadIndex)), - debayer_(debayer), threadIndex_(threadIndex), + pipeline_(pipeline), threadIndex_(threadIndex), enableInputMemcpy_(enableInputMemcpy) { moveToThread(this); } /** - * \class DebayerCpu + * \class SoftwareIspPipelineCpu * \brief Class for debayering on the CPU * * Implementation for CPU based debayering */ /** - * \brief Constructs a DebayerCpu object + * \brief Constructs a SoftwareIspPipelineCpu object * \param[in] stats Pointer to the stats object to use * \param[in] cm The camera manager */ -DebayerCpu::DebayerCpu(std::unique_ptr stats, const CameraManager &cm) - : Debayer(cm), stats_(std::move(stats)) +SoftwareIspPipelineCpu::SoftwareIspPipelineCpu(std::unique_ptr stats, const CameraManager &cm) + : SoftwareIspPipeline(cm), stats_(std::move(stats)) { /* * Reading from uncached buffers may be very slow. @@ -121,7 +121,7 @@ DebayerCpu::DebayerCpu(std::unique_ptr stats, const CameraManager &c LOG(Debayer, Debug) << "Thread count " << threadCount; } -DebayerCpu::~DebayerCpu() = default; +SoftwareIspPipelineCpu::~SoftwareIspPipelineCpu() = default; #define DECLARE_SRC_POINTERS(pixel_t) \ const pixel_t *prev = (const pixel_t *)src[0] + xShift_; \ @@ -193,7 +193,7 @@ DebayerCpu::~DebayerCpu() = default; curr[x] / (div)) template -void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) { DECLARE_SRC_POINTERS(uint8_t) @@ -204,7 +204,7 @@ void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer8_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer8_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) { DECLARE_SRC_POINTERS(uint8_t) @@ -215,7 +215,7 @@ void DebayerCpu::debayer8_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer10_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer10_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) { DECLARE_SRC_POINTERS(uint16_t) @@ -227,7 +227,7 @@ void DebayerCpu::debayer10_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer10_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer10_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) { DECLARE_SRC_POINTERS(uint16_t) @@ -239,7 +239,7 @@ void DebayerCpu::debayer10_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer12_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer12_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) { DECLARE_SRC_POINTERS(uint16_t) @@ -251,7 +251,7 @@ void DebayerCpu::debayer12_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer12_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer12_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) { DECLARE_SRC_POINTERS(uint16_t) @@ -263,7 +263,7 @@ void DebayerCpu::debayer12_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 5 / 4; const uint8_t *prev = src[0]; @@ -289,7 +289,7 @@ void DebayerCpu::debayer10P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer10P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer10P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 5 / 4; const uint8_t *prev = src[0]; @@ -310,7 +310,7 @@ void DebayerCpu::debayer10P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer10P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer10P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 5 / 4; const uint8_t *prev = src[0]; @@ -331,7 +331,7 @@ void DebayerCpu::debayer10P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 5 / 4; const uint8_t *prev = src[0]; @@ -352,7 +352,7 @@ void DebayerCpu::debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer12P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer12P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 3 / 2; const uint8_t *prev = src[0]; @@ -370,7 +370,7 @@ void DebayerCpu::debayer12P_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer12P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer12P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 3 / 2; const uint8_t *prev = src[0]; @@ -388,7 +388,7 @@ void DebayerCpu::debayer12P_GRGR_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer12P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer12P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 3 / 2; const uint8_t *prev = src[0]; @@ -406,7 +406,7 @@ void DebayerCpu::debayer12P_GBGB_BGR888(uint8_t *dst, const uint8_t *src[]) } template -void DebayerCpu::debayer12P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) +void SoftwareIspPipelineCpu::debayer12P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) { const int widthInBytes = window_.width * 3 / 2; const uint8_t *prev = src[0]; @@ -428,7 +428,7 @@ void DebayerCpu::debayer12P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) * Return 0 on success, a negative errno value on failure * (unsupported parameters). */ -int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) +int SoftwareIspPipelineCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) { BayerFormat bayerFormat = BayerFormat::fromPixelFormat(inputFormat); @@ -474,7 +474,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf return -EINVAL; } -int DebayerCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config) +int SoftwareIspPipelineCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config) { if (outputFormat == formats::RGB888 || outputFormat == formats::BGR888) { config.bpp = 24; @@ -496,7 +496,7 @@ int DebayerCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &c * Check for standard Bayer orders and set xShift_ and swap debayer0/1, so that * a single pair of BGGR debayer functions can be used for all 4 standard orders. */ -int DebayerCpu::setupStandardBayerOrder(BayerFormat::Order order) +int SoftwareIspPipelineCpu::setupStandardBayerOrder(BayerFormat::Order order) { switch (order) { case BayerFormat::BGGR: @@ -520,13 +520,13 @@ int DebayerCpu::setupStandardBayerOrder(BayerFormat::Order order) #define SET_DEBAYER_METHODS(method0, method1) \ debayer0_ = addAlphaByte \ - ? (ccmEnabled ? &DebayerCpu::method0 : &DebayerCpu::method0) \ - : (ccmEnabled ? &DebayerCpu::method0 : &DebayerCpu::method0); \ + ? (ccmEnabled ? &SoftwareIspPipelineCpu::method0 : &SoftwareIspPipelineCpu::method0) \ + : (ccmEnabled ? &SoftwareIspPipelineCpu::method0 : &SoftwareIspPipelineCpu::method0); \ debayer1_ = addAlphaByte \ - ? (ccmEnabled ? &DebayerCpu::method1 : &DebayerCpu::method1) \ - : (ccmEnabled ? &DebayerCpu::method1 : &DebayerCpu::method1); + ? (ccmEnabled ? &SoftwareIspPipelineCpu::method1 : &SoftwareIspPipelineCpu::method1) \ + : (ccmEnabled ? &SoftwareIspPipelineCpu::method1 : &SoftwareIspPipelineCpu::method1); -int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, +int SoftwareIspPipelineCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat, bool ccmEnabled) { @@ -639,9 +639,9 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, return invalidFmt(); } -int DebayerCpu::configure(const StreamConfiguration &inputCfg, - const std::vector> &outputCfgs, - bool ccmEnabled) +int SoftwareIspPipelineCpu::configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs, + bool ccmEnabled) { if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) return -EINVAL; @@ -733,14 +733,14 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg, */ void DebayerCpuThread::configure(unsigned int yStart, unsigned int yEnd) { - Debayer::DebayerInputConfig &inputConfig = debayer_->inputConfig_; + SoftwareIspPipelineCpu::DebayerInputConfig &inputConfig = pipeline_->inputConfig_; yStart_ = yStart; yEnd_ = yEnd; /* pad with patternSize.Width on both left and right side */ lineBufferPadding_ = inputConfig.patternSize.width * inputConfig.bpp / 8; - lineBufferLength_ = debayer_->window_.width * inputConfig.bpp / 8 + + lineBufferLength_ = pipeline_->window_.width * inputConfig.bpp / 8 + 2 * lineBufferPadding_; if (enableInputMemcpy_) { @@ -753,9 +753,9 @@ void DebayerCpuThread::configure(unsigned int yStart, unsigned int yEnd) * Get width and height at which the bayer-pattern repeats. * Return pattern-size or an empty Size for an unsupported inputFormat. */ -Size DebayerCpu::patternSize(PixelFormat inputFormat) +Size SoftwareIspPipelineCpu::patternSize(PixelFormat inputFormat) { - DebayerCpu::DebayerInputConfig config; + SoftwareIspPipelineCpu::DebayerInputConfig config; if (getInputConfig(inputFormat, config) != 0) return {}; @@ -763,9 +763,9 @@ Size DebayerCpu::patternSize(PixelFormat inputFormat) return config.patternSize; } -std::vector DebayerCpu::formats(PixelFormat inputFormat) +std::vector SoftwareIspPipelineCpu::formats(PixelFormat inputFormat) { - DebayerCpu::DebayerInputConfig config; + SoftwareIspPipelineCpu::DebayerInputConfig config; if (getInputConfig(inputFormat, config) != 0) return std::vector(); @@ -774,9 +774,9 @@ std::vector DebayerCpu::formats(PixelFormat inputFormat) } std::tuple -DebayerCpu::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) +SoftwareIspPipelineCpu::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) { - DebayerCpu::DebayerOutputConfig config; + SoftwareIspPipelineCpu::DebayerOutputConfig config; if (getOutputConfig(outputFormat, config) != 0) return std::make_tuple(0, 0); @@ -789,7 +789,7 @@ DebayerCpu::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size void DebayerCpuThread::setupInputMemcpy(const uint8_t *linePointers[]) { - const unsigned int patternHeight = debayer_->inputConfig_.patternSize.height; + const unsigned int patternHeight = pipeline_->inputConfig_.patternSize.height; if (!enableInputMemcpy_) return; @@ -807,18 +807,18 @@ void DebayerCpuThread::setupInputMemcpy(const uint8_t *linePointers[]) void DebayerCpuThread::shiftLinePointers(const uint8_t *linePointers[], const uint8_t *src) { - const unsigned int patternHeight = debayer_->inputConfig_.patternSize.height; + const unsigned int patternHeight = pipeline_->inputConfig_.patternSize.height; for (unsigned int i = 0; i < patternHeight; i++) linePointers[i] = linePointers[i + 1]; linePointers[patternHeight] = - src + (patternHeight / 2) * (int)debayer_->inputConfig_.stride; + src + (patternHeight / 2) * (int)pipeline_->inputConfig_.stride; } void DebayerCpuThread::memcpyNextLine(const uint8_t *linePointers[]) { - const unsigned int patternHeight = debayer_->inputConfig_.patternSize.height; + const unsigned int patternHeight = pipeline_->inputConfig_.patternSize.height; if (!enableInputMemcpy_) return; @@ -839,30 +839,30 @@ void DebayerCpuThread::memcpyNextLine(const uint8_t *linePointers[]) */ void DebayerCpuThread::process(uint32_t frame, const uint8_t *src, uint8_t *dst) { - Rectangle &window = debayer_->window_; + Rectangle &window = pipeline_->window_; /* Adjust src to top left corner of the window */ - src += (window.y + yStart_) * debayer_->inputConfig_.stride + - window.x * debayer_->inputConfig_.bpp / 8; + src += (window.y + yStart_) * pipeline_->inputConfig_.stride + + window.x * pipeline_->inputConfig_.bpp / 8; /* Adjust dst for yStart_ */ - dst += yStart_ * debayer_->outputConfig_.stride; + dst += yStart_ * pipeline_->outputConfig_.stride; - if (debayer_->inputConfig_.patternSize.height == 2) + if (pipeline_->inputConfig_.patternSize.height == 2) process2(frame, src, dst); else process4(frame, src, dst); - debayer_->workPendingMutex_.lock(); - debayer_->workPending_ &= ~(1 << threadIndex_); - debayer_->workPendingMutex_.unlock(); - debayer_->workPendingCv_.notify_one(); + pipeline_->workPendingMutex_.lock(); + pipeline_->workPending_ &= ~(1 << threadIndex_); + pipeline_->workPendingMutex_.unlock(); + pipeline_->workPendingCv_.notify_one(); } void DebayerCpuThread::process2(uint32_t frame, const uint8_t *src, uint8_t *dst) { - unsigned int outputStride = debayer_->outputConfig_.stride; - unsigned int inputStride = debayer_->inputConfig_.stride; - Rectangle &window = debayer_->window_; + unsigned int outputStride = pipeline_->outputConfig_.stride; + unsigned int inputStride = pipeline_->inputConfig_.stride; + Rectangle &window = pipeline_->window_; unsigned int yEnd = yEnd_; /* Holds [0] previous- [1] current- [2] next-line */ const uint8_t *linePointers[3]; @@ -895,14 +895,14 @@ void DebayerCpuThread::process2(uint32_t frame, const uint8_t *src, uint8_t *dst for (unsigned int y = yStart_; y < yEnd; y += 2) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->stats_->processLine0(frame, y, linePointers, threadIndex_); - debayer_->debayer0(dst, linePointers); + pipeline_->stats_->processLine0(frame, y, linePointers, threadIndex_); + pipeline_->debayer0(dst, linePointers); src += inputStride; dst += outputStride; shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->debayer1(dst, linePointers); + pipeline_->debayer1(dst, linePointers); src += inputStride; dst += outputStride; } @@ -910,15 +910,15 @@ void DebayerCpuThread::process2(uint32_t frame, const uint8_t *src, uint8_t *dst if (window.y == 0 && yEnd_ == window.height) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->stats_->processLine0(frame, yEnd, linePointers, threadIndex_); - debayer_->debayer0(dst, linePointers); + pipeline_->stats_->processLine0(frame, yEnd, linePointers, threadIndex_); + pipeline_->debayer0(dst, linePointers); src += inputStride; dst += outputStride; shiftLinePointers(linePointers, src); /* next line may point outside of src, use prev. */ linePointers[2] = linePointers[0]; - debayer_->debayer1(dst, linePointers); + pipeline_->debayer1(dst, linePointers); src += inputStride; dst += outputStride; } @@ -926,8 +926,8 @@ void DebayerCpuThread::process2(uint32_t frame, const uint8_t *src, uint8_t *dst void DebayerCpuThread::process4(uint32_t frame, const uint8_t *src, uint8_t *dst) { - unsigned int outputStride = debayer_->outputConfig_.stride; - unsigned int inputStride = debayer_->inputConfig_.stride; + unsigned int outputStride = pipeline_->outputConfig_.stride; + unsigned int inputStride = pipeline_->inputConfig_.stride; /* * This holds pointers to [0] 2-lines-up [1] 1-line-up [2] current-line @@ -951,33 +951,33 @@ void DebayerCpuThread::process4(uint32_t frame, const uint8_t *src, uint8_t *dst for (unsigned int y = yStart_; y < yEnd_; y += 4) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->stats_->processLine0(frame, y, linePointers, threadIndex_); - debayer_->debayer0(dst, linePointers); + pipeline_->stats_->processLine0(frame, y, linePointers, threadIndex_); + pipeline_->debayer0(dst, linePointers); src += inputStride; dst += outputStride; shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->debayer1(dst, linePointers); + pipeline_->debayer1(dst, linePointers); src += inputStride; dst += outputStride; shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->stats_->processLine2(frame, y, linePointers, threadIndex_); - debayer_->debayer2(dst, linePointers); + pipeline_->stats_->processLine2(frame, y, linePointers, threadIndex_); + pipeline_->debayer2(dst, linePointers); src += inputStride; dst += outputStride; shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); - debayer_->debayer3(dst, linePointers); + pipeline_->debayer3(dst, linePointers); src += inputStride; dst += outputStride; } } -void DebayerCpu::updateGammaTable(const DebayerParams ¶ms) +void SoftwareIspPipelineCpu::updateGammaTable(const DebayerParams ¶ms) { const RGB blackLevel = params.blackLevel; /* Take let's say the green channel black level */ @@ -1007,7 +1007,7 @@ void DebayerCpu::updateGammaTable(const DebayerParams ¶ms) gammaTable_[blackIndex]); } -void DebayerCpu::updateLookupTables(const DebayerParams ¶ms) +void SoftwareIspPipelineCpu::updateLookupTables(const DebayerParams ¶ms) { const bool gammaUpdateNeeded = params.gamma != params_.gamma || @@ -1069,7 +1069,7 @@ void DebayerCpu::updateLookupTables(const DebayerParams ¶ms) params_ = params; } -void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) +void SoftwareIspPipelineCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) { bench_.startFrame(); @@ -1128,7 +1128,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output inputBufferReady.emit(input); } -int DebayerCpu::start() +int SoftwareIspPipelineCpu::start() { for (auto &thread : threads_) thread->start(); @@ -1136,7 +1136,7 @@ int DebayerCpu::start() return 0; } -void DebayerCpu::stop() +void SoftwareIspPipelineCpu::stop() { for (auto &thread : threads_) thread->exit(); @@ -1145,7 +1145,7 @@ void DebayerCpu::stop() thread->wait(); } -SizeRange DebayerCpu::sizes(PixelFormat inputFormat, const Size &inputSize) +SizeRange SoftwareIspPipelineCpu::sizes(PixelFormat inputFormat, const Size &inputSize) { Size patternSize = this->patternSize(inputFormat); unsigned int borderHeight = patternSize.height; diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/software_isp_pipeline_cpu.h similarity index 95% rename from src/libcamera/software_isp/debayer_cpu.h rename to src/libcamera/software_isp/software_isp_pipeline_cpu.h index 5281c65cb..fee1c979f 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/software_isp_pipeline_cpu.h @@ -24,16 +24,16 @@ #include "libcamera/internal/software_isp/debayer_params.h" #include "libcamera/internal/software_isp/swstats_cpu.h" -#include "debayer.h" +#include "software_isp_pipeline.h" namespace libcamera { class DebayerCpuThread; -class DebayerCpu : public Debayer +class SoftwareIspPipelineCpu : public SoftwareIspPipeline { public: - DebayerCpu(std::unique_ptr stats, const CameraManager &cm); - ~DebayerCpu(); + SoftwareIspPipelineCpu(std::unique_ptr stats, const CameraManager &cm); + ~SoftwareIspPipelineCpu(); int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, @@ -79,7 +79,7 @@ private: * pointers are passed holding: src[0] = 2-lines-up, src[1] = 1-line-up * src[2] = current-line, src[3] = 1-line-down, src[4] = 2-lines-down. */ - using debayerFn = void (DebayerCpu::*)(uint8_t *dst, const uint8_t *src[]); + using debayerFn = void (SoftwareIspPipelineCpu::*)(uint8_t *dst, const uint8_t *src[]); void debayer0(uint8_t *dst, const uint8_t *src[]) { (this->*debayer0_)(dst, src); } void debayer1(uint8_t *dst, const uint8_t *src[]) { (this->*debayer1_)(dst, src); } diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/software_isp_pipeline_gpu.cpp similarity index 90% rename from src/libcamera/software_isp/debayer_egl.cpp rename to src/libcamera/software_isp/software_isp_pipeline_gpu.cpp index 8e52b45ae..53bb5e61f 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/software_isp_pipeline_gpu.cpp @@ -7,7 +7,7 @@ * */ -#include "debayer_egl.h" +#include "software_isp_pipeline_gpu.h" #include #include @@ -28,27 +28,28 @@ namespace libcamera { /** - * \class DebayerEGL + * \class SoftwareIspPipelineGpu * \brief Class for debayering using an EGL Shader * * Implements an EGL shader based debayering solution. */ /** - * \brief Construct a DebayerEGL object + * \fn SoftwareIspPipelineGpu::SoftwareIspPipelineGpu(std::unique_ptr stats, const CameraManager &cm) + * \brief Construct a SoftwareIspPipelineGpu object * \param[in] stats Statistics processing object * \param[in] cm The camera manager */ -DebayerEGL::DebayerEGL(std::unique_ptr stats, const CameraManager &cm) - : Debayer(cm), stats_(std::move(stats)) +SoftwareIspPipelineGpu::SoftwareIspPipelineGpu(std::unique_ptr stats, const CameraManager &cm) + : SoftwareIspPipeline(cm), stats_(std::move(stats)) { } -DebayerEGL::~DebayerEGL() +SoftwareIspPipelineGpu::~SoftwareIspPipelineGpu() { } -int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) +int SoftwareIspPipelineGpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) { BayerFormat bayerFormat = BayerFormat::fromPixelFormat(inputFormat); @@ -94,7 +95,7 @@ int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf return -EINVAL; } -int DebayerEGL::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config) +int SoftwareIspPipelineGpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config) { if (outputFormat == formats::XRGB8888 || outputFormat == formats::ARGB8888 || outputFormat == formats::XBGR8888 || outputFormat == formats::ABGR8888) { @@ -108,7 +109,7 @@ int DebayerEGL::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &c return -EINVAL; } -int DebayerEGL::getShaderVariableLocations(void) +int SoftwareIspPipelineGpu::getShaderVariableLocations(void) { attributeVertex_ = glGetAttribLocation(programId_, "vertexIn"); attributeTexture_ = glGetAttribLocation(programId_, "textureIn"); @@ -139,7 +140,7 @@ int DebayerEGL::getShaderVariableLocations(void) return 0; } -int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat) +int SoftwareIspPipelineGpu::initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat) { std::vector shaderEnv; unsigned int fragmentShaderDataLen = 0; @@ -290,9 +291,9 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm return getShaderVariableLocations(); } -int DebayerEGL::configure(const StreamConfiguration &inputCfg, - const std::vector> &outputCfgs, - [[maybe_unused]] bool ccmEnabled) +int SoftwareIspPipelineGpu::configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs, + [[maybe_unused]] bool ccmEnabled) { if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) return -EINVAL; @@ -353,9 +354,9 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, return 0; } -Size DebayerEGL::patternSize(PixelFormat inputFormat) +Size SoftwareIspPipelineGpu::patternSize(PixelFormat inputFormat) { - DebayerEGL::DebayerInputConfig config; + SoftwareIspPipelineGpu::DebayerInputConfig config; if (getInputConfig(inputFormat, config) != 0) return {}; @@ -363,9 +364,9 @@ Size DebayerEGL::patternSize(PixelFormat inputFormat) return config.patternSize; } -std::vector DebayerEGL::formats(PixelFormat inputFormat) +std::vector SoftwareIspPipelineGpu::formats(PixelFormat inputFormat) { - DebayerEGL::DebayerInputConfig config; + SoftwareIspPipelineGpu::DebayerInputConfig config; if (getInputConfig(inputFormat, config) != 0) return std::vector(); @@ -374,9 +375,9 @@ std::vector DebayerEGL::formats(PixelFormat inputFormat) } std::tuple -DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) +SoftwareIspPipelineGpu::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) { - DebayerEGL::DebayerOutputConfig config; + SoftwareIspPipelineGpu::DebayerOutputConfig config; if (getOutputConfig(outputFormat, config) != 0) return std::make_tuple(0, 0); @@ -387,7 +388,7 @@ DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size return std::make_tuple(stride, stride * size.height); } -void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms) +void SoftwareIspPipelineGpu::setShaderVariableValues(const DebayerParams ¶ms) { /* * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats @@ -510,7 +511,7 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms) return; } -int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms, std::optional *inMapped, std::optional *inDmaSyncer) +int SoftwareIspPipelineGpu::debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms, std::optional *inMapped, std::optional *inDmaSyncer) { bool dmabuf_import_succeeded = false; @@ -555,7 +556,7 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye return 0; } -void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) +void SoftwareIspPipelineGpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) { bench_.startFrame(); @@ -607,7 +608,7 @@ error: return; } -int DebayerEGL::start() +int SoftwareIspPipelineGpu::start() { GLint maxTextureImageUnits; @@ -630,7 +631,7 @@ int DebayerEGL::start() return 0; } -void DebayerEGL::stop() +void SoftwareIspPipelineGpu::stop() { eglImageBayerOut_.reset(); eglImageBayerIn_.reset(); @@ -639,7 +640,7 @@ void DebayerEGL::stop() glDeleteProgram(programId_); } -SizeRange DebayerEGL::sizes(PixelFormat inputFormat, const Size &inputSize) +SizeRange SoftwareIspPipelineGpu::sizes(PixelFormat inputFormat, const Size &inputSize) { Size patternSize = this->patternSize(inputFormat); unsigned int borderHeight = patternSize.height; diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/software_isp_pipeline_gpu.h similarity index 93% rename from src/libcamera/software_isp/debayer_egl.h rename to src/libcamera/software_isp/software_isp_pipeline_gpu.h index 875e7cfc5..eb365d198 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/software_isp_pipeline_gpu.h @@ -27,7 +27,7 @@ #include #include -#include "debayer.h" +#include "software_isp_pipeline.h" namespace libcamera { @@ -36,11 +36,11 @@ namespace libcamera { class CameraManager; -class DebayerEGL : public Debayer +class SoftwareIspPipelineGpu : public SoftwareIspPipeline { public: - DebayerEGL(std::unique_ptr stats, const CameraManager &cm); - ~DebayerEGL(); + SoftwareIspPipelineGpu(std::unique_ptr stats, const CameraManager &cm); + ~SoftwareIspPipelineGpu(); int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs,