From patchwork Mon Sep 29 20:19:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 24491 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 9591DC324C for ; Mon, 29 Sep 2025 20:19:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4602D6B626; Mon, 29 Sep 2025 22:19:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="DtmugV5S"; 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 BA5F26B60F for ; Mon, 29 Sep 2025 22:19:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759177185; 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=Y3EvnC9xVYMjL2+fsG65hSpjsgf/MkaX0weBsZfpdfg=; b=DtmugV5Sve5W/zSC0R1qXfH9p9nBBREn/DzSqzZ+UjRe4lIFhTQ21Io6ongwx4WyBl8uKY q7+GjW8Vpbe4s4jISULZFObrWDCJTULwJpciFtNNrt4wDyMgPFtnOt6BzEl3AKZTYrWGIX rZbe16RBxW6bLRDo30oVbxDZsvmyGbw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-676-i4pJqKgxNQ2UYJ08fmtccQ-1; Mon, 29 Sep 2025 16:19:42 -0400 X-MC-Unique: i4pJqKgxNQ2UYJ08fmtccQ-1 X-Mimecast-MFC-AGG-ID: i4pJqKgxNQ2UYJ08fmtccQ_1759177181 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 33781195E916; Mon, 29 Sep 2025 20:19:41 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.35]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6AB9319560B4; Mon, 29 Sep 2025 20:19:39 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , pobrn@protonmail.com, mail@maciej.szmigiero.name, hansg@kernel.org Subject: [PATCH v5 3/7] libcamera: software_isp: Pass correct y-coordinate to stats Date: Mon, 29 Sep 2025 22:19:20 +0200 Message-ID: <20250929201924.45019-4-mzamazal@redhat.com> In-Reply-To: <20250929201924.45019-1-mzamazal@redhat.com> References: <20250929201924.45019-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: NY2qL20W9YJEm1mAOdQXuMMO9PkRIrS5JrfJfvyhsy0_1759177181 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 Signed-off-by: Maciej S. Szmigiero Signed-off-by: Milan Zamazal Reviewed-by: Hans de Goede Reviewed-by: Barnabás Pőcze --- src/libcamera/software_isp/debayer_cpu.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index bcaaa5dee..09d171d6b 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -661,7 +661,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]; @@ -676,13 +676,16 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) /* window_.y == 0, use the next line as prev line */ linePointers[1] = src + inputConfig_.stride; linePointers[2] = src; - /* Last 2 lines also need special handling */ + /* + * Last 2 lines also need special handling. + * (And configure() ensures that yEnd >= 2.) + */ yEnd -= 2; } 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); @@ -716,7 +719,6 @@ 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; /* * This holds pointers to [0] 2-lines-up [1] 1-line-up [2] current-line * [3] 1-line-down [4] 2-lines-down. @@ -734,7 +736,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 < window_.height; y += 4) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); stats_->processLine0(y, linePointers);