{"id":23853,"url":"https://patchwork.libcamera.org/api/patches/23853/?format=json","web_url":"https://patchwork.libcamera.org/patch/23853/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20250718144444.58573-1-mzamazal@redhat.com>","date":"2025-07-18T14:44:44","name":"libcamera: software_isp: Remove type casts in statistics computation","commit_ref":"cc137b1c6d5dbfc5365f2eae4e53dab9ca134224","pull_url":null,"state":"accepted","archived":false,"hash":"c3f68c9d75f48d84e8391af7f24fb59d5e06991b","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23853/mbox/","series":[{"id":5300,"url":"https://patchwork.libcamera.org/api/series/5300/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5300","date":"2025-07-18T14:44:44","name":"libcamera: software_isp: Remove type casts in statistics computation","version":1,"mbox":"https://patchwork.libcamera.org/series/5300/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23853/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23853/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 436AFBE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jul 2025 14:44:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 217FC68FA9;\n\tFri, 18 Jul 2025 16:44:53 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F7A06150F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jul 2025 16:44:52 +0200 (CEST)","from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-173-S02w5UaWPnyzr4lHy9PFRg-1;\n\tFri, 18 Jul 2025 10:44:49 -0400","from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.15])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid D748B18002A0 for <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jul 2025 14:44:48 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.221])\n\tby mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id DCF5419560AB; Fri, 18 Jul 2025 14:44:47 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"L2gJQroK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1752849891;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=mSTPzEkaczNV3L2TyOBX9ujudAQIOgSd8OAd/7F8PN0=;\n\tb=L2gJQroKZ6J7U/+xmWxIGkZCyVyPdvOzgniTetyMLKYRNz1BWXOCf7ZVFdqBB+Zd4LwfAu\n\tJueJ4g4fPeyUP4vIWU825lEyj5caRJiFGz+KrgfdVeL7t03DwP4iNzTBhJ+66r9H4FDtmu\n\ttWhuuyIc6q695uwY+9/3BhzX4WTXgZI=","X-MC-Unique":"S02w5UaWPnyzr4lHy9PFRg-1","X-Mimecast-MFC-AGG-ID":"S02w5UaWPnyzr4lHy9PFRg_1752849888","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>","Subject":"[PATCH] libcamera: software_isp: Remove type casts in statistics\n\tcomputation","Date":"Fri, 18 Jul 2025 16:44:44 +0200","Message-ID":"<20250718144444.58573-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.15","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"qUbuI5mZ_MRMxe837H7Yd2OaJJiQaTf0MeRhH___kXc_1752849888","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","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":"Type casting from unsigned int to int performed in stats computation is\nunnecessary, window_.width is unsigned and the array index is always\nnon-negative.  Let's simply use unsigned int in all the\nSwStatsCpu:stats* methods.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/libcamera/software_isp/swstats_cpu.cpp | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)","diff":"diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex c520c806e..4b77b3600 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -175,7 +175,7 @@ void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[])\n \t\tstd::swap(src0, src1);\n \n \t/* x += 4 sample every other 2x2 block */\n-\tfor (int x = 0; x < (int)window_.width; x += 4) {\n+\tfor (unsigned int x = 0; x < window_.width; x += 4) {\n \t\tb = src0[x];\n \t\tg = src0[x + 1];\n \t\tg2 = src1[x];\n@@ -200,7 +200,7 @@ void SwStatsCpu::statsBGGR10Line0(const uint8_t *src[])\n \t\tstd::swap(src0, src1);\n \n \t/* x += 4 sample every other 2x2 block */\n-\tfor (int x = 0; x < (int)window_.width; x += 4) {\n+\tfor (unsigned int x = 0; x < window_.width; x += 4) {\n \t\tb = src0[x];\n \t\tg = src0[x + 1];\n \t\tg2 = src1[x];\n@@ -226,7 +226,7 @@ void SwStatsCpu::statsBGGR12Line0(const uint8_t *src[])\n \t\tstd::swap(src0, src1);\n \n \t/* x += 4 sample every other 2x2 block */\n-\tfor (int x = 0; x < (int)window_.width; x += 4) {\n+\tfor (unsigned int x = 0; x < window_.width; x += 4) {\n \t\tb = src0[x];\n \t\tg = src0[x + 1];\n \t\tg2 = src1[x];\n@@ -245,7 +245,7 @@ void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[])\n {\n \tconst uint8_t *src0 = src[1] + window_.x * 5 / 4;\n \tconst uint8_t *src1 = src[2] + window_.x * 5 / 4;\n-\tconst int widthInBytes = window_.width * 5 / 4;\n+\tconst unsigned int widthInBytes = window_.width * 5 / 4;\n \n \tif (swapLines_)\n \t\tstd::swap(src0, src1);\n@@ -253,7 +253,7 @@ void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[])\n \tSWSTATS_START_LINE_STATS(uint8_t)\n \n \t/* x += 5 sample every other 2x2 block */\n-\tfor (int x = 0; x < widthInBytes; x += 5) {\n+\tfor (unsigned int x = 0; x < widthInBytes; x += 5) {\n \t\t/* BGGR */\n \t\tb = src0[x];\n \t\tg = src0[x + 1];\n@@ -271,7 +271,7 @@ void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[])\n {\n \tconst uint8_t *src0 = src[1] + window_.x * 5 / 4;\n \tconst uint8_t *src1 = src[2] + window_.x * 5 / 4;\n-\tconst int widthInBytes = window_.width * 5 / 4;\n+\tconst unsigned int widthInBytes = window_.width * 5 / 4;\n \n \tif (swapLines_)\n \t\tstd::swap(src0, src1);\n@@ -279,7 +279,7 @@ void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[])\n \tSWSTATS_START_LINE_STATS(uint8_t)\n \n \t/* x += 5 sample every other 2x2 block */\n-\tfor (int x = 0; x < widthInBytes; x += 5) {\n+\tfor (unsigned int x = 0; x < widthInBytes; x += 5) {\n \t\t/* GBRG */\n \t\tg = src0[x];\n \t\tb = src0[x + 1];\n","prefixes":[]}