[{"id":32982,"web_url":"https://patchwork.libcamera.org/comment/32982/","msgid":"<173644184742.2992722.7569480409514422733@ping.linuxembedded.co.uk>","date":"2025-01-09T16:57:27","subject":"Re: [PATCH v3 4/9] libcamera: software_isp: Use common code to store\n\tdebayered pixels","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2024-12-10 15:34:34)\n> The debayering macros use the same pattern, let's extract it to a common\n> macro.  This reduces code duplication a bit now and it'll make changes\n> of debayering easier when color correction matrix is introduced.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n\nI'm fine with this - it looks correct to me - but I'm probably keen on\nhearing what Hans or others think.\n\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/software_isp/debayer_cpu.cpp | 56 +++++++++++-----------\n>  1 file changed, 28 insertions(+), 28 deletions(-)\n> \n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index 31ab96ab..0eabced2 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -62,57 +62,57 @@ DebayerCpu::~DebayerCpu() = default;\n>         const pixel_t *curr = (const pixel_t *)src[1] + xShift_; \\\n>         const pixel_t *next = (const pixel_t *)src[2] + xShift_;\n>  \n> +#define STORE_PIXEL(b, g, r)        \\\n> +       *dst++ = blue_[b];          \\\n> +       *dst++ = green_[g];         \\\n> +       *dst++ = red_[r];           \\\n> +       if constexpr (addAlphaByte) \\\n> +               *dst++ = 255;       \\\n> +       x++;\n> +\n>  /*\n>   * RGR\n>   * GBG\n>   * RGR\n>   */\n> -#define BGGR_BGR888(p, n, div)                                                                \\\n> -       *dst++ = blue_[curr[x] / (div)];                                                      \\\n> -       *dst++ = green_[(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div))];       \\\n> -       *dst++ = red_[(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div))]; \\\n> -       if constexpr (addAlphaByte)                                                           \\\n> -               *dst++ = 255;                                                                 \\\n> -       x++;\n> +#define BGGR_BGR888(p, n, div)                                                 \\\n> +       STORE_PIXEL(                                                           \\\n> +               curr[x] / (div),                                               \\\n> +               (prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div)), \\\n> +               (prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div)))\n>  \n>  /*\n>   * GBG\n>   * RGR\n>   * GBG\n>   */\n> -#define GRBG_BGR888(p, n, div)                                    \\\n> -       *dst++ = blue_[(prev[x] + next[x]) / (2 * (div))];        \\\n> -       *dst++ = green_[curr[x] / (div)];                         \\\n> -       *dst++ = red_[(curr[x - p] + curr[x + n]) / (2 * (div))]; \\\n> -       if constexpr (addAlphaByte)                               \\\n> -               *dst++ = 255;                                     \\\n> -       x++;\n> +#define GRBG_BGR888(p, n, div)                     \\\n> +       STORE_PIXEL(                               \\\n> +               (prev[x] + next[x]) / (2 * (div)), \\\n> +               curr[x] / (div),                   \\\n> +               (curr[x - p] + curr[x + n]) / (2 * (div)))\n>  \n>  /*\n>   * GRG\n>   * BGB\n>   * GRG\n>   */\n> -#define GBRG_BGR888(p, n, div)                                     \\\n> -       *dst++ = blue_[(curr[x - p] + curr[x + n]) / (2 * (div))]; \\\n> -       *dst++ = green_[curr[x] / (div)];                          \\\n> -       *dst++ = red_[(prev[x] + next[x]) / (2 * (div))];          \\\n> -       if constexpr (addAlphaByte)                                \\\n> -               *dst++ = 255;                                      \\\n> -       x++;\n> +#define GBRG_BGR888(p, n, div)                             \\\n> +       STORE_PIXEL(                                       \\\n> +               (curr[x - p] + curr[x + n]) / (2 * (div)), \\\n> +               curr[x] / (div),                           \\\n> +               (prev[x] + next[x]) / (2 * (div)))\n>  \n>  /*\n>   * BGB\n>   * GRG\n>   * BGB\n>   */\n> -#define RGGB_BGR888(p, n, div)                                                                 \\\n> -       *dst++ = blue_[(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div))]; \\\n> -       *dst++ = green_[(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div))];        \\\n> -       *dst++ = red_[curr[x] / (div)];                                                        \\\n> -       if constexpr (addAlphaByte)                                                            \\\n> -               *dst++ = 255;                                                                  \\\n> -       x++;\n> +#define RGGB_BGR888(p, n, div)                                                         \\\n> +       STORE_PIXEL(                                                                   \\\n> +               (prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div)), \\\n> +               (prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div)),         \\\n> +               curr[x] / (div))\n>  \n>  template<bool addAlphaByte>\n>  void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])\n> -- \n> 2.44.2\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 EB2DBC32EF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jan 2025 16:57:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1BC5F68500;\n\tThu,  9 Jan 2025 17:57:31 +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 65AB061880\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jan 2025 17:57:30 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82F2C110F;\n\tThu,  9 Jan 2025 17:56:36 +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=\"TTwEkmk0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1736441796;\n\tbh=jcDO/8wem9dwTA7k75yxSOj2oRgMnu1FYWezOZcHus8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=TTwEkmk0WAHUWUN7+PRqN/RZxqDMxgR24bx7gacT0ojhiLuXo4P8nkrynS/kYSH3Y\n\tLrSZz/QnPQFFzCCGSOE46y+c1TWT9ZBVsCtx2D1octlxBqf7B+N4+vg38eL6VTqKAh\n\tgPKTGeIZGQQ3sYMl6x2Ka2daNh0AFnOXhdmZwKrU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241210153440.1007470-5-mzamazal@redhat.com>","References":"<20241210153440.1007470-1-mzamazal@redhat.com>\n\t<20241210153440.1007470-5-mzamazal@redhat.com>","Subject":"Re: [PATCH v3 4/9] libcamera: software_isp: Use common code to store\n\tdebayered pixels","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tRobert Mader <robert.mader@collabora.com>,\n\tHans de Goede <hdegoede@redhat.com>, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Thu, 09 Jan 2025 16:57:27 +0000","Message-ID":"<173644184742.2992722.7569480409514422733@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]