From patchwork Fri Jul 18 14:44:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 23853 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 436AFBE175 for ; Fri, 18 Jul 2025 14:44:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 217FC68FA9; Fri, 18 Jul 2025 16:44:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="L2gJQroK"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F7A06150F for ; Fri, 18 Jul 2025 16:44:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752849891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mSTPzEkaczNV3L2TyOBX9ujudAQIOgSd8OAd/7F8PN0=; b=L2gJQroKZ6J7U/+xmWxIGkZCyVyPdvOzgniTetyMLKYRNz1BWXOCf7ZVFdqBB+Zd4LwfAu JueJ4g4fPeyUP4vIWU825lEyj5caRJiFGz+KrgfdVeL7t03DwP4iNzTBhJ+66r9H4FDtmu tWhuuyIc6q695uwY+9/3BhzX4WTXgZI= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-S02w5UaWPnyzr4lHy9PFRg-1; Fri, 18 Jul 2025 10:44:49 -0400 X-MC-Unique: S02w5UaWPnyzr4lHy9PFRg-1 X-Mimecast-MFC-AGG-ID: S02w5UaWPnyzr4lHy9PFRg_1752849888 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D748B18002A0 for ; Fri, 18 Jul 2025 14:44:48 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.221]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DCF5419560AB; Fri, 18 Jul 2025 14:44:47 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH] libcamera: software_isp: Remove type casts in statistics computation 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-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Type casting from unsigned int to int performed in stats computation is unnecessary, window_.width is unsigned and the array index is always non-negative. Let's simply use unsigned int in all the SwStatsCpu:stats* methods. Signed-off-by: Milan Zamazal --- src/libcamera/software_isp/swstats_cpu.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index c520c806e..4b77b3600 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -175,7 +175,7 @@ void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[]) std::swap(src0, src1); /* x += 4 sample every other 2x2 block */ - for (int x = 0; x < (int)window_.width; x += 4) { + for (unsigned int x = 0; x < window_.width; x += 4) { b = src0[x]; g = src0[x + 1]; g2 = src1[x]; @@ -200,7 +200,7 @@ void SwStatsCpu::statsBGGR10Line0(const uint8_t *src[]) std::swap(src0, src1); /* x += 4 sample every other 2x2 block */ - for (int x = 0; x < (int)window_.width; x += 4) { + for (unsigned int x = 0; x < window_.width; x += 4) { b = src0[x]; g = src0[x + 1]; g2 = src1[x]; @@ -226,7 +226,7 @@ void SwStatsCpu::statsBGGR12Line0(const uint8_t *src[]) std::swap(src0, src1); /* x += 4 sample every other 2x2 block */ - for (int x = 0; x < (int)window_.width; x += 4) { + for (unsigned int x = 0; x < window_.width; x += 4) { b = src0[x]; g = src0[x + 1]; g2 = src1[x]; @@ -245,7 +245,7 @@ void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[]) { const uint8_t *src0 = src[1] + window_.x * 5 / 4; const uint8_t *src1 = src[2] + window_.x * 5 / 4; - const int widthInBytes = window_.width * 5 / 4; + const unsigned int widthInBytes = window_.width * 5 / 4; if (swapLines_) std::swap(src0, src1); @@ -253,7 +253,7 @@ void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[]) SWSTATS_START_LINE_STATS(uint8_t) /* x += 5 sample every other 2x2 block */ - for (int x = 0; x < widthInBytes; x += 5) { + for (unsigned int x = 0; x < widthInBytes; x += 5) { /* BGGR */ b = src0[x]; g = src0[x + 1]; @@ -271,7 +271,7 @@ void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[]) { const uint8_t *src0 = src[1] + window_.x * 5 / 4; const uint8_t *src1 = src[2] + window_.x * 5 / 4; - const int widthInBytes = window_.width * 5 / 4; + const unsigned int widthInBytes = window_.width * 5 / 4; if (swapLines_) std::swap(src0, src1); @@ -279,7 +279,7 @@ void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[]) SWSTATS_START_LINE_STATS(uint8_t) /* x += 5 sample every other 2x2 block */ - for (int x = 0; x < widthInBytes; x += 5) { + for (unsigned int x = 0; x < widthInBytes; x += 5) { /* GBRG */ g = src0[x]; b = src0[x + 1];