From patchwork Thu Aug 21 13:41:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 24171 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 A7B80C32BB for ; Thu, 21 Aug 2025 13:42:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 30D6C692E9; Thu, 21 Aug 2025 15:42:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="NjYLAApA"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4955D692E0 for ; Thu, 21 Aug 2025 15:42:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755783719; 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: in-reply-to:in-reply-to:references:references; bh=Wl/TK3kHRaw+6lpLzuqpLesDlPkIT1iVxCiZboXG6BA=; b=NjYLAApAzwEJUCVplDZK4Q8DW037xpnH2IRCkQKmTc1/hIrV8UGOTBnmoF0XdP1twmdzc3 A37h3baKvGxjUvQK/tulT8hTQyTxherJNcbs6yuNRLAKWM5hkqWIMZEbjCruD2nd15W2Te AGGCCMNGa2WKrZTmm2ueLi1bHRm5w7I= 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-264-Fa297o7iORi3XLbtTfdlCA-1; Thu, 21 Aug 2025 09:41:55 -0400 X-MC-Unique: Fa297o7iORi3XLbtTfdlCA-1 X-Mimecast-MFC-AGG-ID: Fa297o7iORi3XLbtTfdlCA_1755783714 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 A0E631800289; Thu, 21 Aug 2025 13:41:54 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.162]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 17C37180047F; Thu, 21 Aug 2025 13:41:52 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , pobrn@protonmail.com, mail@maciej.szmigiero.name Subject: [PATCH 2/5] libcamera: software_isp: Pass correct y-coordinate to stats Date: Thu, 21 Aug 2025 15:41:38 +0200 Message-ID: <20250821134141.83236-3-mzamazal@redhat.com> In-Reply-To: <20250821134141.83236-1-mzamazal@redhat.com> References: <20250821134141.83236-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ocbqjK1QPtZ5YhI563zNfkQRzlb2reJybkLQY39U7BI_1755783714 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" The window set by SwStatsCpu::setWindow is relative to the processed image area. But debayering passes the processed line y-coordinate to the stats relative to the whole image area. This can result in gathering stats from a wrong image area or in not gathering stats at all. Let's pass the correct y-coordinate to the stats processing methods. Bug: https://bugs.libcamera.org/show_bug.cgi?id=280 Co-developed-by: Maciej S. Szmigiero Signed-off-by: Milan Zamazal Signed-off-by: Maciej S. Szmigiero --- src/libcamera/software_isp/debayer_cpu.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index bcc847ae6..185edd814 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -648,7 +648,7 @@ void DebayerCpu::memcpyNextLine(const uint8_t *linePointers[]) void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) { - unsigned int yEnd = window_.y + window_.height; + unsigned int yEnd = window_.height; /* Holds [0] previous- [1] current- [2] next-line */ const uint8_t *linePointers[3]; @@ -664,12 +664,12 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) linePointers[1] = src + inputConfig_.stride; linePointers[2] = src; /* Last 2 lines also need special handling */ - yEnd -= 2; + yEnd = (yEnd > 2 ? yEnd - 2 : 0); } setupInputMemcpy(linePointers); - for (unsigned int y = window_.y; y < yEnd; y += 2) { + for (unsigned int y = 0; y < yEnd; y += 2) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); stats_->processLine0(y, linePointers); @@ -703,7 +703,7 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) { - const unsigned int yEnd = window_.y + window_.height; + const unsigned int yEnd = window_.height; /* * This holds pointers to [0] 2-lines-up [1] 1-line-up [2] current-line * [3] 1-line-down [4] 2-lines-down. @@ -721,7 +721,7 @@ void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) setupInputMemcpy(linePointers); - for (unsigned int y = window_.y; y < yEnd; y += 4) { + for (unsigned int y = 0; y < yEnd; y += 4) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); stats_->processLine0(y, linePointers);