{"id":25898,"url":"https://patchwork.libcamera.org/api/patches/25898/?format=json","web_url":"https://patchwork.libcamera.org/patch/25898/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20260120170701.400944-1-barnabas.pocze@ideasonboard.com>","date":"2026-01-20T17:07:01","name":"[RFC,v1] libcamera: software_isp: debayer: Take `DebayerParams` by ref","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"279f011c0baea8326aca6670c6daadeceb036aae","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25898/mbox/","series":[{"id":5726,"url":"https://patchwork.libcamera.org/api/series/5726/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5726","date":"2026-01-20T17:07:01","name":"[RFC,v1] libcamera: software_isp: debayer: Take `DebayerParams` by ref","version":1,"mbox":"https://patchwork.libcamera.org/series/5726/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25898/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25898/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 CDE37C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Jan 2026 17:07:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 04E5C61FC9;\n\tTue, 20 Jan 2026 18:07:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02E9461A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jan 2026 18:07:04 +0100 (CET)","from pb-laptop.local (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6B428177D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jan 2026 18:06:33 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ucFe0gfV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768928793;\n\tbh=RqkbJEnCgL0GbNM4dRDPdtWkLQoRdsRsHXKgYHqni+g=;\n\th=From:To:Subject:Date:From;\n\tb=ucFe0gfVRRvhEhW92BR2xqPi4DjagdrDUYOq5AkGv5hseJBEnz3dNOE5DES0CMhdS\n\tJzF1c9tnheINK27VMBlV5n/PzQzPJEX0crOdAafs3ZKGRg/bLaKYV13JcfCHq+9+0Y\n\tBdgGObcPOxlaadBnpzxEjKb8a5x8uWpcTBU3dpcA=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[RFC PATCH v1] libcamera: software_isp: debayer: Take\n\t`DebayerParams` by ref","Date":"Tue, 20 Jan 2026 18:07:01 +0100","Message-ID":"<20260120170701.400944-1-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.52.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","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":"When calling `Debayer::process()` from `SoftwareIsp::process()`, the\n`DebayerParams` object is copied multiple time:\n\n  (1) call of `BoundMethodMember<...>::activate()`\n      inside `Object::invokeMethod()`\n  (2) constructor of `BoundMethodArgs<...>`\n      inside `BoundMethodMember<...>::activate()`\n  (3) call of `BoundMethodMember<...>::invoke()`\n      inside `BoundMethodArgs::invokePack()`\n  (4) call of the actual pointer to member function\n      inside `BoundMethodMember::invoke()`\n\nGiven that the type has a size of 5696 bytes at the moment on x86-64,\nwhile the size is expected to shrink considerably and compilers might\navoid one or two of the above copies, this is still not ideal. By making\n`Debayer::process()` take the parameter object by const lvalue reference,\nonly the copy in the `BoundMethodArgs` constructor remains. So do that.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/software_isp/debayer.cpp     | 2 +-\n src/libcamera/software_isp/debayer.h       | 4 ++--\n src/libcamera/software_isp/debayer_cpu.cpp | 2 +-\n src/libcamera/software_isp/debayer_cpu.h   | 2 +-\n src/libcamera/software_isp/debayer_egl.cpp | 6 +++---\n src/libcamera/software_isp/debayer_egl.h   | 6 +++---\n 6 files changed, 11 insertions(+), 11 deletions(-)","diff":"diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex 65a1762dd..3e7702525 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -401,7 +401,7 @@ Debayer::~Debayer()\n  * \\brief Select the bayer params to use for the next frame debayer\n  * \\param[in] params The parameters to be used in debayering\n  */\n-void Debayer::setParams(DebayerParams &params)\n+void Debayer::setParams(const DebayerParams &params)\n {\n \tgreen_ = params.green;\n \tgreenCcm_ = params.greenCcm;\ndiff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nindex cd2db9930..99e22ed85 100644\n--- a/src/libcamera/software_isp/debayer.h\n+++ b/src/libcamera/software_isp/debayer.h\n@@ -47,7 +47,7 @@ public:\n \tvirtual std::tuple<unsigned int, unsigned int>\n \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;\n \n-\tvirtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n+\tvirtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params) = 0;\n \tvirtual int start() { return 0; }\n \tvirtual void stop() {}\n \n@@ -92,7 +92,7 @@ private:\n \tvirtual Size patternSize(PixelFormat inputFormat) = 0;\n \n protected:\n-\tvoid setParams(DebayerParams &params);\n+\tvoid setParams(const DebayerParams &params);\n \tvoid dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);\n \tstatic bool isStandardBayerOrder(BayerFormat::Order order);\n };\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 00738c56b..b52f4d5c7 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -740,7 +740,7 @@ void DebayerCpu::process4(uint32_t frame, const uint8_t *src, uint8_t *dst)\n \t}\n }\n \n-void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n+void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params)\n {\n \tbench_.startFrame();\n \ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 67df2b93a..27eff021d 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -37,7 +37,7 @@ public:\n \tstd::vector<PixelFormat> formats(PixelFormat input);\n \tstd::tuple<unsigned int, unsigned int>\n \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n-\tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n+\tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params);\n \tSizeRange sizes(PixelFormat inputFormat, const Size &inputSize);\n \tconst SharedFD &getStatsFD() { return stats_->getStatsFD(); }\n \ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 9693d7252..1ac162427 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -386,7 +386,7 @@ DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size\n \treturn std::make_tuple(stride, stride * size.height);\n }\n \n-void DebayerEGL::setShaderVariableValues(DebayerParams &params)\n+void DebayerEGL::setShaderVariableValues(const DebayerParams &params)\n {\n \t/*\n \t * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats\n@@ -509,7 +509,7 @@ void DebayerEGL::setShaderVariableValues(DebayerParams &params)\n \treturn;\n }\n \n-int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams &params)\n+int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams &params)\n {\n \t/* eGL context switch */\n \tegl_.makeCurrent();\n@@ -536,7 +536,7 @@ int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams &par\n \treturn 0;\n }\n \n-void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n+void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params)\n {\n \tbench_.startFrame();\n \ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex a5033bc63..790348249 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -50,7 +50,7 @@ public:\n \tstd::vector<PixelFormat> formats(PixelFormat input);\n \tstd::tuple<unsigned int, unsigned int> strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n \n-\tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n+\tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params);\n \tint start();\n \tvoid stop();\n \n@@ -72,9 +72,9 @@ private:\n \t\t\t\t std::vector<std::string> shaderEnv);\n \tint linkShaderProgram(void);\n \tint getShaderVariableLocations();\n-\tvoid setShaderVariableValues(DebayerParams &params);\n+\tvoid setShaderVariableValues(const DebayerParams &params);\n \tvoid configureTexture(GLuint &texture);\n-\tint debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams &params);\n+\tint debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams &params);\n \n \t/* Shader program identifiers */\n \tGLuint vertexShaderId_ = 0;\n","prefixes":["RFC","v1"]}