{"id":26095,"url":"https://patchwork.libcamera.org/api/1.1/patches/26095/?format=json","web_url":"https://patchwork.libcamera.org/patch/26095/","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":"<20260205102156.2591211-1-barnabas.pocze@ideasonboard.com>","date":"2026-02-05T10:21:56","name":"[v2] libcamera: software_isp: debayer: Take `DebayerParams` by ref","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"46ac5cbec4c4100462392db90cb214d35e9147a3","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26095/mbox/","series":[{"id":5773,"url":"https://patchwork.libcamera.org/api/1.1/series/5773/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5773","date":"2026-02-05T10:21:56","name":"[v2] libcamera: software_isp: debayer: Take `DebayerParams` by ref","version":2,"mbox":"https://patchwork.libcamera.org/series/5773/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26095/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26095/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 BACBABD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Feb 2026 10:22:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9F3626204A;\n\tThu,  5 Feb 2026 11:22:00 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 924D361F84\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Feb 2026 11:21:59 +0100 (CET)","from pb-laptop.local (185.221.141.206.nat.pool.zt.hu\n\t[185.221.141.206])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 997DD227;\n\tThu,  5 Feb 2026 11:21:16 +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=\"Ajg4tIBU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770286876;\n\tbh=GmACjKMWOcU7DXqghEumcezcd6/Hz8hixTfyzHOU79g=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Ajg4tIBUARE3wq5kby6qY8D5FYdXjKDo80iw68hl8KkOwNejeL3qIK3DWRlNp8z1J\n\tYZkt+oxFPYGJqialJthykwgC3J2OB8vbaOtbPbNh/Gg+Vl43ieW0JyFAw7GokbqvjQ\n\tGBsNWp7mLIQ/4QTBvf807AdqeSfGF71ItxEbU9Lc=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>","Subject":"[PATCH v2] libcamera: software_isp: debayer: Take `DebayerParams` by\n\tref","Date":"Thu,  5 Feb 2026 11:21:56 +0100","Message-ID":"<20260205102156.2591211-1-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.53.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 times:\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\nWhile compilers might avoid one or two of the above copies, this is still\nnot ideal. By making `Debayer::process()` take the parameter object by\nconst lvalue reference, only the copy in the `BoundMethodArgs` constructor\nremains. So do that.\n\nBefore:\n\t[0:12:51.133836595] [12424] DEBUG SoftwareIsp software_isp.cpp:399 params=0x7d0a691f57d0\n\tcopy from 0x7d0a691f57d0 into 0x7baa65f2bf30\n\tcopy from 0x7baa65f2bf30 into 0x7c6a69209758\n\tcopy from 0x7c6a69209758 into 0x7baa63223930\n\tcopy from 0x7baa63223930 into 0x7baa63223a70\n\t[0:12:51.134559602] [12426] DEBUG eGL debayer_egl.cpp:538 params=0x7baa63223a70\n\t771.099877 (30.06 fps) cam0-stream0 seq: 000031 bytesused: 8666112\n\nAfter:\n\t[0:13:42.861691943] [12543] DEBUG SoftwareIsp software_isp.cpp:399 params=0x7cfaad5f57d0\n\tcopy from 0x7cfaad5f57d0 into 0x7c5aad609758\n\t[0:13:42.862453917] [12545] DEBUG eGL debayer_egl.cpp:538 params=0x7c5aad609758\n\t822.827388 (30.02 fps) cam0-stream0 seq: 000031 bytesused: 8666112\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\nchanges in v2:\n  * rebase\n  * reword and extend commit message\n\nv1: https://patchwork.libcamera.org/patch/25898/\n---\n src/libcamera/software_isp/debayer.h       | 2 +-\n src/libcamera/software_isp/debayer_cpu.cpp | 6 +++---\n src/libcamera/software_isp/debayer_cpu.h   | 6 +++---\n src/libcamera/software_isp/debayer_egl.cpp | 6 +++---\n src/libcamera/software_isp/debayer_egl.h   | 6 +++---\n 5 files changed, 13 insertions(+), 13 deletions(-)\n\n--\n2.53.0","diff":"diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nindex 652cff4cc..ce9350b7b 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\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex af7af0a8d..d09883577 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -750,7 +750,7 @@ void DebayerCpu::process4(uint32_t frame, const uint8_t *src, uint8_t *dst)\n \t}\n }\n\n-void DebayerCpu::updateGammaTable(DebayerParams &params)\n+void DebayerCpu::updateGammaTable(const DebayerParams &params)\n {\n \tconst RGB<float> blackLevel = params.blackLevel;\n \t/* Take let's say the green channel black level */\n@@ -780,7 +780,7 @@ void DebayerCpu::updateGammaTable(DebayerParams &params)\n \t\t  gammaTable_[blackIndex]);\n }\n\n-void DebayerCpu::updateLookupTables(DebayerParams &params)\n+void DebayerCpu::updateLookupTables(const DebayerParams &params)\n {\n \tconst bool gammaUpdateNeeded =\n \t\tparams.gamma != params_.gamma ||\n@@ -842,7 +842,7 @@ void DebayerCpu::updateLookupTables(DebayerParams &params)\n \tparams_ = params;\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 b5cbb5bd2..7a6517462 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -39,7 +39,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\n@@ -110,8 +110,8 @@ private:\n \tvoid memcpyNextLine(const uint8_t *linePointers[]);\n \tvoid process2(uint32_t frame, const uint8_t *src, uint8_t *dst);\n \tvoid process4(uint32_t frame, const uint8_t *src, uint8_t *dst);\n-\tvoid updateGammaTable(DebayerParams &params);\n-\tvoid updateLookupTables(DebayerParams &params);\n+\tvoid updateGammaTable(const DebayerParams &params);\n+\tvoid updateLookupTables(const DebayerParams &params);\n\n \t/* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */\n \tstatic constexpr unsigned int kMaxLineBuffers = 5;\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 4d0caa6ef..93f7c6946 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -383,7 +383,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@@ -506,7 +506,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@@ -533,7 +533,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 cfbaf8e9d..59aebcc81 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":["v2"]}