{"id":25110,"url":"https://patchwork.libcamera.org/api/1.1/patches/25110/?format=json","web_url":"https://patchwork.libcamera.org/patch/25110/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20251120232019.3590-10-bryan.odonoghue@linaro.org>","date":"2025-11-20T23:20:06","name":"[09/22] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"303366c4a36b4cfd02f334b7a34624d00a11f59a","submitter":{"id":175,"url":"https://patchwork.libcamera.org/api/1.1/people/175/?format=json","name":"Bryan O'Donoghue","email":"bryan.odonoghue@linaro.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25110/mbox/","series":[{"id":5599,"url":"https://patchwork.libcamera.org/api/1.1/series/5599/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5599","date":"2025-11-20T23:19:57","name":"GPUISP precursor series","version":1,"mbox":"https://patchwork.libcamera.org/series/5599/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25110/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25110/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BE658C3330\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Nov 2025 23:20:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 84B6360AA4;\n\tFri, 21 Nov 2025 00:20:44 +0100 (CET)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C8D4960A8A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Nov 2025 00:20:41 +0100 (CET)","by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-4779aa4f928so13841125e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Nov 2025 15:20:41 -0800 (PST)","from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie.\n\t[188.141.3.146]) by smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-477bf3af0ecsm11618415e9.9.2025.11.20.15.20.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 20 Nov 2025 15:20:39 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"KbhNMKhe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1763680841; x=1764285641;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=zVktTW+jzDGHUXwiqWUbvZQ5i5MyV+LhWJh64BRRBbI=;\n\tb=KbhNMKheKWOS8YNlA3ie0gGEE5a+GY6EaU8q0i0Osj+T7vgkgyHN9+biOaIkB7XV8h\n\tBzAbqBeIy0RWxoHDlvYXzqUgrMo6J00A7Bi3XSdDJLp9MGnMLgXVcluinwdJDOT52liL\n\tmjQ7cD8P3113TWqjdjgObRcFmHX4/3RcSroLGwn/bxbz/UBRuMmGJQPgzMUKM+H7nbXQ\n\tW6VwJetPm2WKW55l0QDRpaREIm5By3pZgDWdg1Sq2aVpTg571dCKECLsj+fflCBseR3Y\n\toXxUlu/sVW3WLHYXld58HFybFoAJ8gkeyp4ZXJ181MxAwPcaQ7Rbeu3hFM3tkPwbYTeI\n\t9/Uw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1763680841; x=1764285641;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=zVktTW+jzDGHUXwiqWUbvZQ5i5MyV+LhWJh64BRRBbI=;\n\tb=Mx0a3CsbCQhx0QjdaNnY7FD9SnApEbwOwBf9sX1qeK6Pr9wKJn2lrM/qOCXqwDXpUv\n\tZdAGgMkdBMEygqIg2liHRrPidnysCZ48Y/2ljGjeDRBkKBNGjCVBgHKnGgu8Q7ySUiGU\n\tV+e5tVR1kUq5gWcjkdUr6R3kJIID5f6kRomYEYQD/w5SK/pGSJhEEAVso7LyOzeBGDew\n\tQr4yUiXgfnhJ4HIwfc9r/ixefITGWW6oqDC/5eGOAzoQoLc3HCpZz3b1CVXlPnsBpRlc\n\t9KUk9nPrG717Az2U71XX751qn66vHo5lNRfnSnFJHVlf8eMttpEO4C45b/TA1wBBOi0d\n\tZOSQ==","X-Gm-Message-State":"AOJu0YwXjppbbSAgjvNgkK02Qk2xoQGQCJlDQKBGyk8aTw/HKead23Io\n\tinwjUD8e5qrtBWKKE/ByJ7+7VA30Ejgj0UFkdWue1KR9X0EDj7pkEuuPbrV8vTVGQT78YxJpICF\n\tU2RGziuE=","X-Gm-Gg":"ASbGnct2cQuU/gfy50RyE1c7zKTpAF8YFsS2wHsQDuA57lq71H1+EPhsHepe97jsZnH\n\tIn6XEG8Y51UJQKbZNOyG3L5oPyvqjS0zSBMlJThOzQwiaCDv0zwvoizCOlIH1CkHkbb+RiWJOFm\n\tiAH1mZsY3WonDqSlXbHD+uHd+0NB0+xl0vxbpvdcJN2jOJFi9T2GH0btdhhtkt8cTkMCca7qX3h\n\td0T8cK7UGRxhanfFeynYMTD0H+mY9xZ8ijfMtKGWhWCDXupd8yEv6cRSPmqsG25/znqIcz33Aah\n\tVRkK5u3LDNcY9X8mZfMeunqV1kZekqtH+y375gGo9amMRDmEv/RnOv7vIRqu1eWn8Dzv3v3+3Vm\n\tzkvnVAJuWFdLAa5Vvstd/cRC+tTn7uxSJGPAYpoe8oThU28TcMIy2i5D/XHLhuUNIwl8u9D1P7y\n\trvOdmSPnBwE5G7zPG6C1FLdzGXEDFsre3JfyiHEbV6t+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\n\t5b1f17b1804b1-477c01f751cmr3262485e9.35.1763680840954; \n\tThu, 20 Nov 2025 15:20:40 -0800 (PST)","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"pavel@ucw.cz, Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH 09/22] libcamera: software_isp: Move useful items from\n\tDebayerCpu 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","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The DebayerCpu class has a number of variables, embedded structures and\nmethods which are useful to DebayerGpu implementation.\n\nMove relevant variables and methods to base class.\n\nSince we want to call setParams() from the GPUISP and reuse the code in\nthe existing CPUISP as a first step, we need to move all of the\ndependent variables in DebayerCPU to the Debayer base class including\nLookupTable and redCcm_.\n\nThe DebayerEGL class will ultimately be able to consume both the CCM and\nnon-CCM data.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n src/libcamera/software_isp/debayer.cpp     |  6 +++\n src/libcamera/software_isp/debayer.h       | 63 +++++++++++++++++++++-\n src/libcamera/software_isp/debayer_cpu.cpp |  2 +-\n src/libcamera/software_isp/debayer_cpu.h   | 41 +-------------\n 4 files changed, 70 insertions(+), 42 deletions(-)","diff":"diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex e9e18c488..e9130df1e 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -18,6 +18,12 @@ namespace libcamera {\n  * \\brief Struct to hold the debayer parameters.\n  */\n \n+/**\n+ * \\fn Debayer::Debayer(const GlobalConfiguration &configuration)\n+ * \\brief Construct a Debayer object\n+ * \\param[in] configuration Global configuration reference\n+ */\n+\n /**\n  * \\var DebayerParams::kRGBLookupSize\n  * \\brief Size of a color lookup table\ndiff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nindex ba033d440..578535b20 100644\n--- a/src/libcamera/software_isp/debayer.h\n+++ b/src/libcamera/software_isp/debayer.h\n@@ -14,11 +14,14 @@\n #include <stdint.h>\n \n #include <libcamera/base/log.h>\n+#include <libcamera/base/object.h>\n #include <libcamera/base/signal.h>\n \n #include <libcamera/geometry.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/global_configuration.h\"\n+#include \"libcamera/internal/software_isp/benchmark.h\"\n #include \"libcamera/internal/software_isp/debayer_params.h\"\n \n namespace libcamera {\n@@ -27,9 +30,10 @@ class FrameBuffer;\n \n LOG_DECLARE_CATEGORY(Debayer)\n \n-class Debayer\n+class Debayer : public Object\n {\n public:\n+\tDebayer (const GlobalConfiguration &configuration) : bench_(configuration) {};\n \tvirtual ~Debayer() = 0;\n \n \tvirtual int configure(const StreamConfiguration &inputCfg,\n@@ -45,10 +49,67 @@ public:\n \n \tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n \n+\t/**\n+\t * \\brief Get the file descriptor for the statistics\n+\t *\n+\t * \\return the file descriptor pointing to the statistics\n+\t */\n+\tvirtual const SharedFD &getStatsFD() = 0;\n+\n+\t/**\n+\t * \\brief Get the output frame size\n+\t *\n+\t * \\return The output frame size\n+\t */\n+\tunsigned int frameSize() { return outputConfig_.frameSize; }\n+\n \tSignal<FrameBuffer *> inputBufferReady;\n \tSignal<FrameBuffer *> outputBufferReady;\n \n+\t/**\n+\t * struct DebayerInputConfig\n+\t *\n+\t * Structure to describe the incoming Bayer parameters.\n+\t */\n+\tstruct DebayerInputConfig {\n+\t\tSize patternSize;\t\t\t/**< patternSize size of the Bayer pattern in pixels */\n+\t\tunsigned int bpp;\t\t\t/**< bpp Memory used per pixel, not precision */\n+\t\tunsigned int stride;\t\t\t/**< stride Line stride in bytes */\n+\t\tstd::vector<PixelFormat> outputFormats;\t/**< outputFormats List of supported output pixel formats */\n+\t};\n+\n+\t/**\n+\t * struct DebayerOutputConfig\n+\t *\n+\t * Structure to describe the output pattern requested to the Debayer logic.\n+\t */\n+\tstruct DebayerOutputConfig {\n+\t\tunsigned int bpp;\t\t\t/**< bpp Memory used per pixel, not precision */\n+\t\tunsigned int stride;\t\t\t/**< stride Line stride in bytes */\n+\t\tunsigned int frameSize;\t\t\t/**< framesize Total frame size in bytes */\n+\t};\n+\n+\tDebayerInputConfig inputConfig_;\t\t/**< inputConfig_ debayer input config params */\n+\tDebayerOutputConfig outputConfig_;\t\t/**< outputConfig_ debayer output config data */\n+\tDebayerParams::LookupTable red_;\t\t/**< red_ DebayerParams red_ lookup table */\n+\tDebayerParams::LookupTable green_;\t\t/**< green_ DebayerParams green_ lookup table */\n+\tDebayerParams::LookupTable blue_;\t\t/**< blue_ DebayerParams blue_ lookup table */\n+\tDebayerParams::CcmLookupTable redCcm_;\t\t/**< redCcm_ Red Colour Correction matrix lookup table */\n+\tDebayerParams::CcmLookupTable greenCcm_;\t/**< greenCcm_ Green Colour Correction matrix lookup table */\n+\tDebayerParams::CcmLookupTable blueCcm_;\t\t/**< blueCcm_ Blue Colour Correction matrix lookup table */\n+\tDebayerParams::LookupTable gammaLut_;\t\t/**< gammaLut_ Gamma Lut lookup table */\n+\tbool swapRedBlueGains_;\t\t\t\t/**< swapRedBlueGains_ bool to indicate swapping of red/blue gains */\n+\tBenchmark bench_;\t\t\t\t/**< bench_ an instance of the Benchmark class */\n+\n private:\n+\t/**\n+\t * \\fn patternSize(PixelFormat inputFormat)\n+\t * \\var DebayerInputConfig::patternSize\n+\t * \\brief Size of the Bayer pattern in pixels\n+\t *\n+\t * The width and height of the Bayer color filter array pattern. For standard\n+\t * Bayer formats (BGGR, GRBG, GBRG, RGGB) this is typically 2x2 pixels.\n+\t */\n \tvirtual Size patternSize(PixelFormat inputFormat) = 0;\n };\n \ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex b92c6a904..e55599f09 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -42,7 +42,7 @@ namespace libcamera {\n  * \\param[in] configuration The global configuration\n  */\n DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats, const GlobalConfiguration &configuration)\n-\t: stats_(std::move(stats)), bench_(configuration)\n+\t: Debayer(configuration), stats_(std::move(stats))\n {\n \t/*\n \t * Reading from uncached buffers may be very slow.\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex aff32491e..ecc4f9dd0 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -17,16 +17,14 @@\n \n #include <libcamera/base/object.h>\n \n-#include \"libcamera/internal/software_isp/benchmark.h\"\n #include \"libcamera/internal/bayer_format.h\"\n-#include \"libcamera/internal/global_configuration.h\"\n #include \"libcamera/internal/software_isp/swstats_cpu.h\"\n \n #include \"debayer.h\"\n \n namespace libcamera {\n \n-class DebayerCpu : public Debayer, public Object\n+class DebayerCpu : public Debayer\n {\n public:\n \tDebayerCpu(std::unique_ptr<SwStatsCpu> stats, const GlobalConfiguration &configuration);\n@@ -41,21 +39,8 @@ public:\n \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n \tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n \tSizeRange sizes(PixelFormat inputFormat, const Size &inputSize);\n-\n-\t/**\n-\t * \\brief Get the file descriptor for the statistics\n-\t *\n-\t * \\return the file descriptor pointing to the statistics\n-\t */\n \tconst SharedFD &getStatsFD() { return stats_->getStatsFD(); }\n \n-\t/**\n-\t * \\brief Get the output frame size\n-\t *\n-\t * \\return The output frame size\n-\t */\n-\tunsigned int frameSize() { return outputConfig_.frameSize; }\n-\n private:\n \t/**\n \t * \\brief Called to debayer 1 line of Bayer input data to output format\n@@ -112,19 +97,6 @@ private:\n \ttemplate<bool addAlphaByte, bool ccmEnabled>\n \tvoid debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]);\n \n-\tstruct DebayerInputConfig {\n-\t\tSize patternSize;\n-\t\tunsigned int bpp; /* Memory used per pixel, not precision */\n-\t\tunsigned int stride;\n-\t\tstd::vector<PixelFormat> outputFormats;\n-\t};\n-\n-\tstruct DebayerOutputConfig {\n-\t\tunsigned int bpp; /* Memory used per pixel, not precision */\n-\t\tunsigned int stride;\n-\t\tunsigned int frameSize;\n-\t};\n-\n \tint getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config);\n \tint getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config);\n \tint setupStandardBayerOrder(BayerFormat::Order order);\n@@ -140,20 +112,11 @@ private:\n \t/* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */\n \tstatic constexpr unsigned int kMaxLineBuffers = 5;\n \n-\tDebayerParams::LookupTable red_;\n-\tDebayerParams::LookupTable green_;\n-\tDebayerParams::LookupTable blue_;\n-\tDebayerParams::CcmLookupTable redCcm_;\n-\tDebayerParams::CcmLookupTable greenCcm_;\n-\tDebayerParams::CcmLookupTable blueCcm_;\n-\tDebayerParams::LookupTable gammaLut_;\n \tdebayerFn debayer0_;\n \tdebayerFn debayer1_;\n \tdebayerFn debayer2_;\n \tdebayerFn debayer3_;\n \tRectangle window_;\n-\tDebayerInputConfig inputConfig_;\n-\tDebayerOutputConfig outputConfig_;\n \tstd::unique_ptr<SwStatsCpu> stats_;\n \tstd::vector<uint8_t> lineBuffers_[kMaxLineBuffers];\n \tunsigned int lineBufferLength_;\n@@ -161,8 +124,6 @@ private:\n \tunsigned int lineBufferIndex_;\n \tunsigned int xShift_; /* Offset of 0/1 applied to window_.x */\n \tbool enableInputMemcpy_;\n-\tbool swapRedBlueGains_;\n-\tBenchmark bench_;\n };\n \n } /* namespace libcamera */\n","prefixes":["09/22"]}