[{"id":33955,"web_url":"https://patchwork.libcamera.org/comment/33955/","msgid":"<174488779445.2882969.18202787236463235965@ping.linuxembedded.co.uk>","date":"2025-04-17T11:03:14","subject":"Re: [PATCH] utils: rkisp1: gen-csc-table: Support printing CCM in\n\tdecimal","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2025-04-05 03:51:22)\n> Add an option to the gen-csc-table.py script to output the CCM matrix in\n> decimal format instead of hexadecimal. This makes no functional\n> difference, but is useful to adapt to different coding styles.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nI wonder if anyone expect you uses/would use this ;-)\n\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  utils/rkisp1/gen-csc-table.py | 24 ++++++++++++++++++------\n>  1 file changed, 18 insertions(+), 6 deletions(-)\n> \n> diff --git a/utils/rkisp1/gen-csc-table.py b/utils/rkisp1/gen-csc-table.py\n> index ffc0370acaeb..2db84feb5cd0 100755\n> --- a/utils/rkisp1/gen-csc-table.py\n> +++ b/utils/rkisp1/gen-csc-table.py\n> @@ -147,6 +147,8 @@ def main(argv):\n>          description='Generate color space conversion table coefficients with '\n>          'configurable fixed-point precision.'\n>      )\n> +    parser.add_argument('--format', '-f', choices=['dec', 'hex'], default='hex',\n> +                        help='Number format')\n>      parser.add_argument('--invert', '-i', action='store_true',\n>                          help='Invert the color space conversion (YUV -> RGB)')\n>      parser.add_argument('--precision', '-p', default='Q1.7',\n> @@ -190,19 +192,29 @@ def main(argv):\n>          else:\n>              line = round_array(line)\n> \n> -        # Convert coefficients to the number of bits selected by the precision.\n> -        # Negative values will be turned into positive integers using 2's\n> -        # complement.\n> -        line = [coeff & ((1 << precision.total) - 1) for coeff in line]\n> +        if args.format == 'hex':\n> +            # Convert coefficients to the number of bits selected by the precision.\n> +            # Negative values will be turned into positive integers using 2's\n> +            # complement.\n> +            line = [coeff & ((1 << precision.total) - 1) for coeff in line]\n> +\n>          rounded_coeffs.append(line)\n> \n>      # Print the result as C code.\n>      nbits = 1 << (precision.total - 1).bit_length()\n>      nbytes = nbits // 4\n> -    print(f'static const u{nbits} {\"yuv2rgb\" if args.invert else \"rgb2yuv\"}_{args.encoding}_{quantization.name.lower()}_coeffs[] = {{')\n> +\n> +    if args.format == 'hex':\n> +        coeff_fmt = '0x{0:0' + str(nbytes) + 'x}'\n> +        sign = 'u'\n> +    else:\n> +        coeff_fmt = '{0}'\n> +        sign = 's'\n> +\n> +    print(f'static const {sign}{nbits} {\"yuv2rgb\" if args.invert else \"rgb2yuv\"}_{args.encoding}_{quantization.name.lower()}_coeffs[] = {{')\n> \n>      for line in rounded_coeffs:\n> -        line = [f'0x{coeff:0{nbytes}x}' for coeff in line]\n> +        line = [coeff_fmt.format(coeff) for coeff in line]\n> \n>          print(f'\\t{\", \".join(line)},')\n> \n> \n> base-commit: a2a7f4fc2d2a3fa7e5cb1b7d35b369d64f86c2ab\n> --\n> Regards,\n> \n> Laurent Pinchart\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 1B836C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Apr 2025 11:03:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E11668AC2;\n\tThu, 17 Apr 2025 13:03:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 65B5F617E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Apr 2025 13:03:17 +0200 (CEST)","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 A6A3755;\n\tThu, 17 Apr 2025 13:01:13 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OB9FUMT6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1744887673;\n\tbh=u4YI2On1i8Qk+Gn7lE4eRFFG8P4rRHgNYFjbJkimVCg=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=OB9FUMT6W6PHEX73HL4ltDq0fiVdcyulzeNSCljuh+RJ1lAgRqZol8xfdlk0uGoMt\n\t5V/fSsXB/DgFoVnAI2z1CLf4Pi28T0+ZckBrErEy3SkT1Fzq2ce+GQkp6N7SCzAGuk\n\tg+d3+egggnkyS5F0F6/8RBE+SXeYYvVi/exghsMs=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250405025122.6960-1-laurent.pinchart@ideasonboard.com>","References":"<20250405025122.6960-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH] utils: rkisp1: gen-csc-table: Support printing CCM in\n\tdecimal","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 17 Apr 2025 12:03:14 +0100","Message-ID":"<174488779445.2882969.18202787236463235965@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>"}}]