From patchwork Wed Oct 21 07:59:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 28538 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 8ABD9C324C for ; Wed, 21 Oct 2026 08:00:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 17DC768F22; Wed, 21 Oct 2026 10:00:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="OYVAiHZZ"; 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 0DB7A68F1A for ; Wed, 21 Oct 2026 10:00:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792569612; 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=6iWimVyt+3nE7xfuM1PdwgaO/Oiom//J1hc+c0GTt/8=; b=OYVAiHZZ45FHGXwilsA2eJOW+WBDRoqbO6c5/ah8pKryxJxpWSgCYWa2JCGBlYSvdsGtN1 CFZoj/zk66QpWySfHcB/cdMVICol/fI546wRarTwRrsHM99tBjUXdpXWPyvrGufpSXaIDg BUj9qR3JLNqHe+GXQy2g/Dmn3nIya6E= 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-635-3-3nUm5mM9yGDulUvZ0PSQ-1; Wed, 21 Oct 2026 08:00:11 +0000 X-MC-Unique: 3-3nUm5mM9yGDulUvZ0PSQ-1 X-Mimecast-MFC-AGG-ID: 3-3nUm5mM9yGDulUvZ0PSQ_1792569610 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 8DA191800361 for ; Wed, 21 Oct 2026 08:00:10 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.43.17.75]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 054E21800444; Wed, 21 Oct 2026 08:00:08 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH 3/7] libcamera: software_isp: Add variance to stats Date: Wed, 21 Oct 2026 09:59:43 +0200 Message-ID: <20261021080000.16624-4-mzamazal@redhat.com> In-Reply-To: <20261021080000.16624-1-mzamazal@redhat.com> References: <20261021080000.16624-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qNkIEouh9_Dk4LoGGbPvPGU6v2wxBUL7pCcf_689SKA_1792569610 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 libipa Af algorithm requests variance value as its input. Let's add the corresponding member to SwIspStats and initialise it. This commit is preparatory and doesn't implement computation of the variance nor introduces other changes to the stats like when to update them for autofocus. Signed-off-by: Milan Zamazal --- include/libcamera/internal/software_isp/swisp_stats.h | 4 ++++ src/libcamera/software_isp/swstats_cpu.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/libcamera/internal/software_isp/swisp_stats.h b/include/libcamera/internal/software_isp/swisp_stats.h index d9d0d9be8..43ca85b26 100644 --- a/include/libcamera/internal/software_isp/swisp_stats.h +++ b/include/libcamera/internal/software_isp/swisp_stats.h @@ -43,6 +43,10 @@ struct SwIspStats { * \brief A histogram of luminance values of all the sampled pixels */ Histogram yHistogram; + /** + * \brief A variance value for the autofocus algorithm + */ + double variance; }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 362fb6a86..0d2bbd686 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -391,6 +391,7 @@ void SwStatsCpu::startFrame(uint32_t frame) for (auto &s : stats_) { s.sum_ = RGB({ 0, 0, 0 }); + s.variance = 0.0; s.yHistogram.fill(0); } } @@ -408,9 +409,11 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId) if (valid) { sharedStats_->sum_ = RGB({ 0, 0, 0 }); + sharedStats_->variance = 0.0; sharedStats_->yHistogram.fill(0); for (const auto &s : stats_) { sharedStats_->sum_ += s.sum_; + sharedStats_->variance += s.variance; for (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++) sharedStats_->yHistogram[j] += s.yHistogram[j]; }