[{"id":33186,"web_url":"https://patchwork.libcamera.org/comment/33186/","msgid":"<20250126231058.GI1133@pendragon.ideasonboard.com>","date":"2025-01-26T23:10:58","subject":"Re: [PATCH v4 5/9] libcamera: software_isp: Use a macro to assign\n\tdebayering methods","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Milan,\n\nThank you for the patch.\n\nOn Mon, Jan 13, 2025 at 02:51:02PM +0100, Milan Zamazal wrote:\n> Assignments of the debayering methods to be used is a repetitive pattern\n> that can be (arguably) better expressed by using a macro.  This removes\n> some duplication and also makes easier to introduce more complex\n> assignment patterns.  This will be useful once color correction matrix\n> support is added.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/software_isp/debayer_cpu.cpp | 25 ++++++++++------------\n>  1 file changed, 11 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index 0eabced2..01cfb36b 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -368,6 +368,10 @@ int DebayerCpu::setupStandardBayerOrder(BayerFormat::Order order)\n>  \treturn 0;\n>  }\n>  \n> +#define SET_DEBAYER_METHODS(method0, method1)                                                \\\n> +\tdebayer0_ = addAlphaByte ? &DebayerCpu::method0<true> : &DebayerCpu::method0<false>; \\\n> +\tdebayer1_ = addAlphaByte ? &DebayerCpu::method1<true> : &DebayerCpu::method1<false>;\n> +\n>  int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat)\n>  {\n>  \tBayerFormat bayerFormat =\n> @@ -423,16 +427,13 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputF\n>  \t    isStandardBayerOrder(bayerFormat.order)) {\n>  \t\tswitch (bayerFormat.bitDepth) {\n>  \t\tcase 8:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer8_BGBG_BGR888<true> : &DebayerCpu::debayer8_BGBG_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer8_GRGR_BGR888<true> : &DebayerCpu::debayer8_GRGR_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer8_BGBG_BGR888, debayer8_GRGR_BGR888)\n>  \t\t\tbreak;\n>  \t\tcase 10:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer10_BGBG_BGR888<true> : &DebayerCpu::debayer10_BGBG_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer10_GRGR_BGR888<true> : &DebayerCpu::debayer10_GRGR_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer10_BGBG_BGR888, debayer10_GRGR_BGR888)\n>  \t\t\tbreak;\n>  \t\tcase 12:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer12_BGBG_BGR888<true> : &DebayerCpu::debayer12_BGBG_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer12_GRGR_BGR888<true> : &DebayerCpu::debayer12_GRGR_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer12_BGBG_BGR888, debayer12_GRGR_BGR888)\n>  \t\t\tbreak;\n>  \t\t}\n>  \t\tsetupStandardBayerOrder(bayerFormat.order);\n> @@ -443,20 +444,16 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputF\n>  \t    bayerFormat.packing == BayerFormat::Packing::CSI2) {\n>  \t\tswitch (bayerFormat.order) {\n>  \t\tcase BayerFormat::BGGR:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer10P_BGBG_BGR888<true> : &DebayerCpu::debayer10P_BGBG_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer10P_GRGR_BGR888<true> : &DebayerCpu::debayer10P_GRGR_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer10P_BGBG_BGR888, debayer10P_GRGR_BGR888)\n>  \t\t\treturn 0;\n>  \t\tcase BayerFormat::GBRG:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer10P_GBGB_BGR888<true> : &DebayerCpu::debayer10P_GBGB_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer10P_RGRG_BGR888<true> : &DebayerCpu::debayer10P_RGRG_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer10P_GBGB_BGR888, debayer10P_RGRG_BGR888)\n>  \t\t\treturn 0;\n>  \t\tcase BayerFormat::GRBG:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer10P_GRGR_BGR888<true> : &DebayerCpu::debayer10P_GRGR_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer10P_BGBG_BGR888<true> : &DebayerCpu::debayer10P_BGBG_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer10P_GRGR_BGR888, debayer10P_BGBG_BGR888)\n>  \t\t\treturn 0;\n>  \t\tcase BayerFormat::RGGB:\n> -\t\t\tdebayer0_ = addAlphaByte ? &DebayerCpu::debayer10P_RGRG_BGR888<true> : &DebayerCpu::debayer10P_RGRG_BGR888<false>;\n> -\t\t\tdebayer1_ = addAlphaByte ? &DebayerCpu::debayer10P_GBGB_BGR888<true> : &DebayerCpu::debayer10P_GBGB_BGR888<false>;\n> +\t\t\tSET_DEBAYER_METHODS(debayer10P_RGRG_BGR888, debayer10P_GBGB_BGR888)\n>  \t\t\treturn 0;\n>  \t\tdefault:\n>  \t\t\tbreak;","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 1D30EBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Jan 2025 23:11:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F274F6855E;\n\tMon, 27 Jan 2025 00:11:11 +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 28B1368557\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Jan 2025 00:11:10 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F28746DF;\n\tMon, 27 Jan 2025 00:10:03 +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=\"VhCyDU+K\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737933004;\n\tbh=VvS8hEJ27QMcSPeMbwLjfTQaTF5fH//XA7VkhsSXoR0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VhCyDU+KFMnyKIJTdq+I8iiXqstWi5wGYyE0mTvrcGsNwF6Nlz3qFd4+NOxoY3p9w\n\t6umvnTleOGXhnVQpqCV3HBXzAYsLmE2VDfZMvkxpWlFtX938OepcAMCHdm98agPNgP\n\trmukuwbhXQlESPPqqjd0soMb8ER4bu5njtozAH2s=","Date":"Mon, 27 Jan 2025 01:10:58 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tRobert Mader <robert.mader@collabora.com>,\n\tHans de Goede <hdegoede@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v4 5/9] libcamera: software_isp: Use a macro to assign\n\tdebayering methods","Message-ID":"<20250126231058.GI1133@pendragon.ideasonboard.com>","References":"<20250113135108.13924-1-mzamazal@redhat.com>\n\t<20250113135108.13924-6-mzamazal@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250113135108.13924-6-mzamazal@redhat.com>","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>"}}]