From patchwork Tue Jan 20 17:07:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25898 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 CDE37C3220 for ; Tue, 20 Jan 2026 17:07:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 04E5C61FC9; Tue, 20 Jan 2026 18:07:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ucFe0gfV"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 02E9461A35 for ; Tue, 20 Jan 2026 18:07:04 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6B428177D for ; Tue, 20 Jan 2026 18:06:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768928793; bh=RqkbJEnCgL0GbNM4dRDPdtWkLQoRdsRsHXKgYHqni+g=; h=From:To:Subject:Date:From; b=ucFe0gfVRRvhEhW92BR2xqPi4DjagdrDUYOq5AkGv5hseJBEnz3dNOE5DES0CMhdS JzF1c9tnheINK27VMBlV5n/PzQzPJEX0crOdAafs3ZKGRg/bLaKYV13JcfCHq+9+0Y BdgGObcPOxlaadBnpzxEjKb8a5x8uWpcTBU3dpcA= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1] libcamera: software_isp: debayer: Take `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 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" When calling `Debayer::process()` from `SoftwareIsp::process()`, the `DebayerParams` object is copied multiple time: (1) call of `BoundMethodMember<...>::activate()` inside `Object::invokeMethod()` (2) constructor of `BoundMethodArgs<...>` inside `BoundMethodMember<...>::activate()` (3) call of `BoundMethodMember<...>::invoke()` inside `BoundMethodArgs::invokePack()` (4) call of the actual pointer to member function inside `BoundMethodMember::invoke()` Given that the type has a size of 5696 bytes at the moment on x86-64, while the size is expected to shrink considerably and compilers might avoid one or two of the above copies, this is still not ideal. By making `Debayer::process()` take the parameter object by const lvalue reference, only the copy in the `BoundMethodArgs` constructor remains. So do that. Signed-off-by: Barnabás Pőcze --- src/libcamera/software_isp/debayer.cpp | 2 +- src/libcamera/software_isp/debayer.h | 4 ++-- src/libcamera/software_isp/debayer_cpu.cpp | 2 +- src/libcamera/software_isp/debayer_cpu.h | 2 +- src/libcamera/software_isp/debayer_egl.cpp | 6 +++--- src/libcamera/software_isp/debayer_egl.h | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 65a1762dd..3e7702525 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -401,7 +401,7 @@ Debayer::~Debayer() * \brief Select the bayer params to use for the next frame debayer * \param[in] params The parameters to be used in debayering */ -void Debayer::setParams(DebayerParams ¶ms) +void Debayer::setParams(const DebayerParams ¶ms) { green_ = params.green; greenCcm_ = params.greenCcm; diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index cd2db9930..99e22ed85 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -47,7 +47,7 @@ public: virtual std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0; - virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0; + virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) = 0; virtual int start() { return 0; } virtual void stop() {} @@ -92,7 +92,7 @@ private: virtual Size patternSize(PixelFormat inputFormat) = 0; protected: - void setParams(DebayerParams ¶ms); + void setParams(const DebayerParams ¶ms); void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); static bool isStandardBayerOrder(BayerFormat::Order order); }; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 00738c56b..b52f4d5c7 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -740,7 +740,7 @@ void DebayerCpu::process4(uint32_t frame, const uint8_t *src, uint8_t *dst) } } -void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) +void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) { bench_.startFrame(); diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 67df2b93a..27eff021d 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -37,7 +37,7 @@ public: std::vector formats(PixelFormat input); std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); - void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); + void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms); SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); const SharedFD &getStatsFD() { return stats_->getStatsFD(); } diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 9693d7252..1ac162427 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -386,7 +386,7 @@ DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size return std::make_tuple(stride, stride * size.height); } -void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms) +void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms) { /* * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats @@ -509,7 +509,7 @@ void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms) return; } -int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams ¶ms) +int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms) { /* eGL context switch */ egl_.makeCurrent(); @@ -536,7 +536,7 @@ int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams &par return 0; } -void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) +void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) { bench_.startFrame(); diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index a5033bc63..790348249 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -50,7 +50,7 @@ public: std::vector formats(PixelFormat input); std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); - void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); + void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms); int start(); void stop(); @@ -72,9 +72,9 @@ private: std::vector shaderEnv); int linkShaderProgram(void); int getShaderVariableLocations(); - void setShaderVariableValues(DebayerParams ¶ms); + void setShaderVariableValues(const DebayerParams ¶ms); void configureTexture(GLuint &texture); - int debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams ¶ms); + int debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms); /* Shader program identifiers */ GLuint vertexShaderId_ = 0;