{"id":23140,"url":"https://patchwork.libcamera.org/api/1.1/patches/23140/?format=json","web_url":"https://patchwork.libcamera.org/patch/23140/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250405025122.6960-1-laurent.pinchart@ideasonboard.com>","date":"2025-04-05T02:51:22","name":"utils: rkisp1: gen-csc-table: Support printing CCM in decimal","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1f3f2a55ad95736b937c0f467caff69136dce5f3","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23140/mbox/","series":[{"id":5115,"url":"https://patchwork.libcamera.org/api/1.1/series/5115/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5115","date":"2025-04-05T02:51:22","name":"utils: rkisp1: gen-csc-table: Support printing CCM in decimal","version":1,"mbox":"https://patchwork.libcamera.org/series/5115/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23140/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23140/checks/","tags":{},"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 4B171C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  5 Apr 2025 02:51:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 826BA689A1;\n\tSat,  5 Apr 2025 04:51:51 +0200 (CEST)","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 3D8CC62C61\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  5 Apr 2025 04:51:49 +0200 (CEST)","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 1AF09129\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  5 Apr 2025 04:49:53 +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=\"f5K9zuTZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743821394;\n\tbh=ZEZHzb9dOqQtO4GIApH2IoM2fzEaftGoJvyoPNNQMjc=;\n\th=From:To:Subject:Date:From;\n\tb=f5K9zuTZ4uXUjcg5FdvyZfpEiqwYQSULxgRrwd1hxrqalSFQx/qZKwbq6aKakUiDX\n\t90jroEqtQ62qj4r5L3IBue+tEnKX4b48dZnIipUgO4pPNLiKYXorEFLi25txuiz81O\n\tX1h7keUB8W8o1igoL2bR3l0fIFV3DLcf+7K26gzQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH] utils: rkisp1: gen-csc-table: Support printing CCM in\n\tdecimal","Date":"Sat,  5 Apr 2025 05:51:22 +0300","Message-ID":"<20250405025122.6960-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.49.0","MIME-Version":"1.0","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>"},"content":"Add an option to the gen-csc-table.py script to output the CCM matrix in\ndecimal format instead of hexadecimal. This makes no functional\ndifference, but is useful to adapt to different coding styles.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/rkisp1/gen-csc-table.py | 24 ++++++++++++++++++------\n 1 file changed, 18 insertions(+), 6 deletions(-)\n\n\nbase-commit: a2a7f4fc2d2a3fa7e5cb1b7d35b369d64f86c2ab\n--\nRegards,\n\nLaurent Pinchart","diff":"diff --git a/utils/rkisp1/gen-csc-table.py b/utils/rkisp1/gen-csc-table.py\nindex 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","prefixes":[]}