[{"id":36992,"web_url":"https://patchwork.libcamera.org/comment/36992/","msgid":"<9cc27216-a76b-44d9-a8d7-46473d991b68@ideasonboard.com>","date":"2025-11-21T13:56:50","subject":"Re: [PATCH v4 11/23] libcamera: software_isp: debayer_egl: Add an\n\teGL debayer class","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 11. 21. 0:33 keltezéssel, Bryan O'Donoghue írta:\n> Add a class to run the existing glsl debayer shaders on a GBM surface.\n> \n> Signed-off-by: Robert Mader <robert.mader@collabora.com>\n> Co-developed-by: Robert Mader <robert.mader@collabora.com>\n> [bod took scaling and buffer size fixes from Robert]\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>   src/libcamera/software_isp/debayer_egl.cpp | 668 +++++++++++++++++++++\n>   src/libcamera/software_isp/debayer_egl.h   | 177 ++++++\n>   src/libcamera/software_isp/meson.build     |   8 +\n>   3 files changed, 853 insertions(+)\n>   create mode 100644 src/libcamera/software_isp/debayer_egl.cpp\n>   create mode 100644 src/libcamera/software_isp/debayer_egl.h\n> \n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> new file mode 100644\n> index 000000000..cf40478fa\n> --- /dev/null\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -0,0 +1,668 @@\n> [...]\n> +DebayerEGL::~DebayerEGL()\n> +{\n> +\tif (eglImageBlueLookup_)\n> +\t\tdelete eglImageBlueLookup_;\n> +\n> +\tif (eglImageGreenLookup_)\n> +\t\tdelete eglImageGreenLookup_;\n> +\n> +\tif (eglImageRedLookup_)\n> +\t\tdelete eglImageRedLookup_;\n> +\n> +\tif (eglImageBayerOut_)\n> +\t\tdelete eglImageBayerOut_;\n> +\n> +\tif (eglImageBayerIn_)\n> +\t\tdelete eglImageBayerIn_;\n\nLet's please use `std::unique_ptr` instead for these.\n\n\n> +}\n> [...]\n> +int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n> +\t\t\t  const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,\n> +\t\t\t  bool ccmEnabled)\n> +{\n> [...]\n> +\n> +\t// Raw bayer input as texture\n> +\teglImageBayerIn_ = new eGLImage(width_, height_, 32, inputCfg.stride, GL_TEXTURE0, 0);\n> +\tif (!eglImageBayerIn_)\n> +\t\treturn -ENOMEM;\n\nA `new` expression like that never returns nullptr. So checking that\nis unnecessary. Let's just use `std::make_unique()` after converting\nthe member variables to `std::unique_ptr`. (Same applies to all other\n`new eGLImage`.)\n\n\nRegards,\nBarnabás Pőcze\n\n> +\n> +\t// Only do the RGB lookup table textures if CCM is disabled\n> +\tif (!ccmEnabled_) {\n> +\n> +\t\t/// RGB correction tables as 2d textures\n> +\t\t// eGL doesn't support glTexImage1D so we do a little hack with 2D to compensate\n> +\t\teglImageRedLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE1, 1);\n> +\t\tif (!eglImageRedLookup_)\n> +\t\t\treturn -ENOMEM;\n> +\n> +\t\teglImageGreenLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE2, 2);\n> +\t\tif (!eglImageGreenLookup_)\n> +\t\t\treturn -ENOMEM;\n> +\n> +\t\teglImageBlueLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE3, 3);\n> +\t\tif (!eglImageBlueLookup_)\n> +\t\t\treturn -ENOMEM;\n> +\t}\n> +\n> +\teglImageBayerOut_ = new eGLImage(outputCfg.size.width, outputCfg.size.height, 32, outputCfg.stride, GL_TEXTURE4, 4);\n> +\tif (!eglImageBayerOut_)\n> +\t\treturn -ENOMEM;\n> +\n> +\tif (initBayerShaders(inputCfg.pixelFormat, outputCfg.pixelFormat))\n> +\t\treturn -EINVAL;\n> +\n> +\treturn 0;\n> +}\n> [...]","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 4DF31C3330\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Nov 2025 13:56:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC61560A81;\n\tFri, 21 Nov 2025 14:56:55 +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 9E92B609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Nov 2025 14:56:54 +0100 (CET)","from [192.168.33.39] (185.221.143.100.nat.pool.zt.hu\n\t[185.221.143.100])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3CB8B66B;\n\tFri, 21 Nov 2025 14:54:48 +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=\"WjDeali6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763733288;\n\tbh=0033r/mp3UPMWkjg37HzmpeFcYcCznD+fNlZssluRR4=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=WjDeali6TBtUeFX17VLLzFkxu6mihJ4Mg1L0iK8LSXRaYa/SQ4NDFbIN1/CiKIjCU\n\tefVqiuXktN3dfYow/rOiBBYmWu8p0E573O/KUYGsryc+NLsErrrZe4Slc+vfQ0sDEy\n\tBa0P6svVYwPwXL/l940YHw4b9qYzbyypyetEWhwk=","Message-ID":"<9cc27216-a76b-44d9-a8d7-46473d991b68@ideasonboard.com>","Date":"Fri, 21 Nov 2025 14:56:50 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4 11/23] libcamera: software_isp: debayer_egl: Add an\n\teGL debayer class","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"pavel@ucw.cz, Robert Mader <robert.mader@collabora.com>","References":"<20251120233347.5046-1-bryan.odonoghue@linaro.org>\n\t<mQtLg288GMRtwAUjJSdi3oLW62GaabKRNEuI9RowUMVZ2bKrDV9ihxHVM7TzsfAFQ3YIlArk4ygNnidwa3t0og==@protonmail.internalid>\n\t<20251120233347.5046-12-bryan.odonoghue@linaro.org>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20251120233347.5046-12-bryan.odonoghue@linaro.org>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]