From patchwork Thu Nov 20 23:20:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25110 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 BE658C3330 for ; Thu, 20 Nov 2025 23:20:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 84B6360AA4; Fri, 21 Nov 2025 00:20:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="KbhNMKhe"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C8D4960A8A for ; Fri, 21 Nov 2025 00:20:41 +0100 (CET) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4779aa4f928so13841125e9.1 for ; Thu, 20 Nov 2025 15:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763680841; x=1764285641; 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=zVktTW+jzDGHUXwiqWUbvZQ5i5MyV+LhWJh64BRRBbI=; b=KbhNMKheKWOS8YNlA3ie0gGEE5a+GY6EaU8q0i0Osj+T7vgkgyHN9+biOaIkB7XV8h BzAbqBeIy0RWxoHDlvYXzqUgrMo6J00A7Bi3XSdDJLp9MGnMLgXVcluinwdJDOT52liL mjQ7cD8P3113TWqjdjgObRcFmHX4/3RcSroLGwn/bxbz/UBRuMmGJQPgzMUKM+H7nbXQ W6VwJetPm2WKW55l0QDRpaREIm5By3pZgDWdg1Sq2aVpTg571dCKECLsj+fflCBseR3Y oXxUlu/sVW3WLHYXld58HFybFoAJ8gkeyp4ZXJ181MxAwPcaQ7Rbeu3hFM3tkPwbYTeI 9/Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763680841; x=1764285641; 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=zVktTW+jzDGHUXwiqWUbvZQ5i5MyV+LhWJh64BRRBbI=; b=Mx0a3CsbCQhx0QjdaNnY7FD9SnApEbwOwBf9sX1qeK6Pr9wKJn2lrM/qOCXqwDXpUv ZdAGgMkdBMEygqIg2liHRrPidnysCZ48Y/2ljGjeDRBkKBNGjCVBgHKnGgu8Q7ySUiGU V+e5tVR1kUq5gWcjkdUr6R3kJIID5f6kRomYEYQD/w5SK/pGSJhEEAVso7LyOzeBGDew Qr4yUiXgfnhJ4HIwfc9r/ixefITGWW6oqDC/5eGOAzoQoLc3HCpZz3b1CVXlPnsBpRlc 9KUk9nPrG717Az2U71XX751qn66vHo5lNRfnSnFJHVlf8eMttpEO4C45b/TA1wBBOi0d ZOSQ== X-Gm-Message-State: AOJu0YwXjppbbSAgjvNgkK02Qk2xoQGQCJlDQKBGyk8aTw/HKead23Io inwjUD8e5qrtBWKKE/ByJ7+7VA30Ejgj0UFkdWue1KR9X0EDj7pkEuuPbrV8vTVGQT78YxJpICF U2RGziuE= X-Gm-Gg: ASbGnct2cQuU/gfy50RyE1c7zKTpAF8YFsS2wHsQDuA57lq71H1+EPhsHepe97jsZnH In6XEG8Y51UJQKbZNOyG3L5oPyvqjS0zSBMlJThOzQwiaCDv0zwvoizCOlIH1CkHkbb+RiWJOFm iAH1mZsY3WonDqSlXbHD+uHd+0NB0+xl0vxbpvdcJN2jOJFi9T2GH0btdhhtkt8cTkMCca7qX3h d0T8cK7UGRxhanfFeynYMTD0H+mY9xZ8ijfMtKGWhWCDXupd8yEv6cRSPmqsG25/znqIcz33Aah VRkK5u3LDNcY9X8mZfMeunqV1kZekqtH+y375gGo9amMRDmEv/RnOv7vIRqu1eWn8Dzv3v3+3Vm zkvnVAJuWFdLAa5Vvstd/cRC+tTn7uxSJGPAYpoe8oThU28TcMIy2i5D/XHLhuUNIwl8u9D1P7y rvOdmSPnBwE5G7zPG6C1FLdzGXEDFsre3JfyiHEbV6t+ORqjzIvITwBOOGcISSBYCTnNg= X-Google-Smtp-Source: AGHT+IHDoTRBAw7aA/ZWbvn7gmFKfGi8Gm18/KuuM3RcDheV12Og51BP3pcBnN+V8+QJ3Woe4aROeA== X-Received: by 2002:a05:600c:470d:b0:475:dd7f:f6cd with SMTP id 5b1f17b1804b1-477c01f751cmr3262485e9.35.1763680840954; Thu, 20 Nov 2025 15:20:40 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477bf3af0ecsm11618415e9.9.2025.11.20.15.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 15:20:39 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham Subject: [PATCH 09/22] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Thu, 20 Nov 2025 23:20:06 +0000 Message-ID: <20251120232019.3590-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251120232019.3590-1-bryan.odonoghue@linaro.org> References: <20251120232019.3590-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 DebayerCpu class has a number of variables, embedded structures and methods which are useful to DebayerGpu implementation. Move relevant variables and methods to base class. Since we want to call setParams() from the GPUISP and reuse the code in the existing CPUISP as a first step, we need to move all of the dependent variables in DebayerCPU to the Debayer base class including LookupTable and redCcm_. The DebayerEGL class will ultimately be able to consume both the CCM and non-CCM data. Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 6 +++ src/libcamera/software_isp/debayer.h | 63 +++++++++++++++++++++- src/libcamera/software_isp/debayer_cpu.cpp | 2 +- src/libcamera/software_isp/debayer_cpu.h | 41 +------------- 4 files changed, 70 insertions(+), 42 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index e9e18c488..e9130df1e 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -18,6 +18,12 @@ namespace libcamera { * \brief Struct to hold the debayer parameters. */ +/** + * \fn Debayer::Debayer(const GlobalConfiguration &configuration) + * \brief Construct a Debayer object + * \param[in] configuration Global configuration reference + */ + /** * \var DebayerParams::kRGBLookupSize * \brief Size of a color lookup table diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ba033d440..578535b20 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -14,11 +14,14 @@ #include #include +#include #include #include #include +#include "libcamera/internal/global_configuration.h" +#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" namespace libcamera { @@ -27,9 +30,10 @@ class FrameBuffer; LOG_DECLARE_CATEGORY(Debayer) -class Debayer +class Debayer : public Object { public: + Debayer (const GlobalConfiguration &configuration) : bench_(configuration) {}; virtual ~Debayer() = 0; virtual int configure(const StreamConfiguration &inputCfg, @@ -45,10 +49,67 @@ public: virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; + /** + * \brief Get the file descriptor for the statistics + * + * \return the file descriptor pointing to the statistics + */ + virtual const SharedFD &getStatsFD() = 0; + + /** + * \brief Get the output frame size + * + * \return The output frame size + */ + unsigned int frameSize() { return outputConfig_.frameSize; } + Signal inputBufferReady; Signal outputBufferReady; + /** + * struct DebayerInputConfig + * + * Structure to describe the incoming Bayer parameters. + */ + struct DebayerInputConfig { + Size patternSize; /**< patternSize size of the Bayer pattern in pixels */ + unsigned int bpp; /**< bpp Memory used per pixel, not precision */ + unsigned int stride; /**< stride Line stride in bytes */ + std::vector outputFormats; /**< outputFormats List of supported output pixel formats */ + }; + + /** + * struct DebayerOutputConfig + * + * Structure to describe the output pattern requested to the Debayer logic. + */ + struct DebayerOutputConfig { + unsigned int bpp; /**< bpp Memory used per pixel, not precision */ + unsigned int stride; /**< stride Line stride in bytes */ + unsigned int frameSize; /**< framesize Total frame size in bytes */ + }; + + DebayerInputConfig inputConfig_; /**< inputConfig_ debayer input config params */ + DebayerOutputConfig outputConfig_; /**< outputConfig_ debayer output config data */ + DebayerParams::LookupTable red_; /**< red_ DebayerParams red_ lookup table */ + DebayerParams::LookupTable green_; /**< green_ DebayerParams green_ lookup table */ + DebayerParams::LookupTable blue_; /**< blue_ DebayerParams blue_ lookup table */ + DebayerParams::CcmLookupTable redCcm_; /**< redCcm_ Red Colour Correction matrix lookup table */ + DebayerParams::CcmLookupTable greenCcm_; /**< greenCcm_ Green Colour Correction matrix lookup table */ + DebayerParams::CcmLookupTable blueCcm_; /**< blueCcm_ Blue Colour Correction matrix lookup table */ + DebayerParams::LookupTable gammaLut_; /**< gammaLut_ Gamma Lut lookup table */ + bool swapRedBlueGains_; /**< swapRedBlueGains_ bool to indicate swapping of red/blue gains */ + Benchmark bench_; /**< bench_ an instance of the Benchmark class */ + private: + /** + * \fn patternSize(PixelFormat inputFormat) + * \var DebayerInputConfig::patternSize + * \brief Size of the Bayer pattern in pixels + * + * The width and height of the Bayer color filter array pattern. For standard + * Bayer formats (BGGR, GRBG, GBRG, RGGB) this is typically 2x2 pixels. + */ virtual Size patternSize(PixelFormat inputFormat) = 0; }; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index b92c6a904..e55599f09 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -42,7 +42,7 @@ namespace libcamera { * \param[in] configuration The global configuration */ DebayerCpu::DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration) - : stats_(std::move(stats)), bench_(configuration) + : Debayer(configuration), stats_(std::move(stats)) { /* * Reading from uncached buffers may be very slow. diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index aff32491e..ecc4f9dd0 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -17,16 +17,14 @@ #include -#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/bayer_format.h" -#include "libcamera/internal/global_configuration.h" #include "libcamera/internal/software_isp/swstats_cpu.h" #include "debayer.h" namespace libcamera { -class DebayerCpu : public Debayer, public Object +class DebayerCpu : public Debayer { public: DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration); @@ -41,21 +39,8 @@ public: strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); - - /** - * \brief Get the file descriptor for the statistics - * - * \return the file descriptor pointing to the statistics - */ const SharedFD &getStatsFD() { return stats_->getStatsFD(); } - /** - * \brief Get the output frame size - * - * \return The output frame size - */ - unsigned int frameSize() { return outputConfig_.frameSize; } - private: /** * \brief Called to debayer 1 line of Bayer input data to output format @@ -112,19 +97,6 @@ private: template void debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); - struct DebayerInputConfig { - Size patternSize; - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - std::vector outputFormats; - }; - - struct DebayerOutputConfig { - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - unsigned int frameSize; - }; - int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); int setupStandardBayerOrder(BayerFormat::Order order); @@ -140,20 +112,11 @@ private: /* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */ static constexpr unsigned int kMaxLineBuffers = 5; - DebayerParams::LookupTable red_; - DebayerParams::LookupTable green_; - DebayerParams::LookupTable blue_; - DebayerParams::CcmLookupTable redCcm_; - DebayerParams::CcmLookupTable greenCcm_; - DebayerParams::CcmLookupTable blueCcm_; - DebayerParams::LookupTable gammaLut_; debayerFn debayer0_; debayerFn debayer1_; debayerFn debayer2_; debayerFn debayer3_; Rectangle window_; - DebayerInputConfig inputConfig_; - DebayerOutputConfig outputConfig_; std::unique_ptr stats_; std::vector lineBuffers_[kMaxLineBuffers]; unsigned int lineBufferLength_; @@ -161,8 +124,6 @@ private: unsigned int lineBufferIndex_; unsigned int xShift_; /* Offset of 0/1 applied to window_.x */ bool enableInputMemcpy_; - bool swapRedBlueGains_; - Benchmark bench_; }; } /* namespace libcamera */