From patchwork Wed Mar 23 13:56:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15521 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 046BAC3265 for ; Wed, 23 Mar 2022 13:56:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ACE1A632E5; Wed, 23 Mar 2022 14:56:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648043785; bh=A1g4kuQaYiTSdeq7im294Vu8hMz13VzXpGOkDfCbC/4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Ho1AYEp+lf3NFms67ZDwiD04PYTaWTZ1KAcf6cVwoFFeeVD7R8g0B93oH75W0YGM5 W0+W0ZzbIONWhzHrkowfurHPjpDY2MivgcVtRlXXf+X8oJ5HJePFoUCJ/1x4oDBA7R 5cSJqCeatwuBrdPQdvRBZlYOVtFjAxAs/LVvUYF4dBwK3N2nyuoDOoz19j5bL8r7pj bepvlMGANajbTSp5DEPmip0eD+x1tFe49sR/TTEQfl/WJHZDDM/HxrOToBtOrElGrR db3CqyVENyAJcZEtdZc66zWE4URUYUmYwVIeDCjq9XS/C+T8k7wayavKkVz25qHI3U Iirrmi7YOAi8g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 347F9604C6 for ; Wed, 23 Mar 2022 14:56:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="deuwMcak"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D8C1F9DE; Wed, 23 Mar 2022 14:56:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648043781; bh=A1g4kuQaYiTSdeq7im294Vu8hMz13VzXpGOkDfCbC/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=deuwMcakgvVcudhenUGDSt0mhe1rM40nWIgxmH0BI4zfM7RsCxX3cLtKMsIJhver7 dZVBf3C2nSA1CdwGoUC3NU5ExyXNqd2Cyu0AtbwSrMYhHAEZyrjRVyMAEXfGvwsRY7 ZXo3WmAdb8bQuFiXlbzo1JXkrfGCOLDpyQlQnmtM= To: libcamera devel Date: Wed, 23 Mar 2022 13:56:12 +0000 Message-Id: <20220323135614.865252-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220323135614.865252-1-kieran.bingham@ideasonboard.com> References: <20220323135614.865252-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] ipa: ipu3: af: Remove redundant memcpy 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The af statistics can be accessed directly from the mapped buffer. Remove the redundant memcpy, and simplify the call to afEstimateVariance(). Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- v2: - Fix ASSERT src/ipa/ipu3/algorithms/af.cpp | 12 ++++-------- src/ipa/ipu3/algorithms/af.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index f5a489412a9e..68e100fdc504 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -336,7 +336,7 @@ void Af::afIgnoreFrameReset() * * \return The variance of the values in the data set \a y_item selected by \a isY1 */ -double Af::afEstimateVariance(y_table_item_t *y_item, uint32_t len, +double Af::afEstimateVariance(const y_table_item_t *y_item, uint32_t len, bool isY1) { uint32_t z = 0; @@ -406,25 +406,21 @@ bool Af::afIsOutOfFocus(IPAContext context) */ void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats) { - y_table_item_t y_item[IPU3_UAPI_AF_Y_TABLE_MAX_SIZE / sizeof(y_table_item_t)]; + const y_table_item_t *y_item = reinterpret_cast(&stats->af_raw_buffer.y_table); uint32_t afRawBufferLen; /* Evaluate the AF buffer length */ afRawBufferLen = context.configuration.af.afGrid.width * context.configuration.af.afGrid.height; - memcpy(y_item, stats->af_raw_buffer.y_table, - afRawBufferLen * sizeof(y_table_item_t)); + ASSERT(afRawBufferLen < IPU3_UAPI_AF_Y_TABLE_MAX_SIZE); /* * Calculate the mean and the variance of AF statistics for a given grid. * For coarse: y1 are used. * For fine: y2 results are used. */ - if (coarseCompleted_) - currentVariance_ = afEstimateVariance(y_item, afRawBufferLen, false); - else - currentVariance_ = afEstimateVariance(y_item, afRawBufferLen, true); + currentVariance_ = afEstimateVariance(y_item, afRawBufferLen, !coarseCompleted_); if (!context.frameContext.af.stable) { afCoarseScan(context); diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h index 906f2843dd49..3b5758e868ea 100644 --- a/src/ipa/ipu3/algorithms/af.h +++ b/src/ipa/ipu3/algorithms/af.h @@ -41,7 +41,7 @@ private: void afReset(IPAContext &context); bool afNeedIgnoreFrame(); void afIgnoreFrameReset(); - double afEstimateVariance(y_table_item_t *y_item, uint32_t len, + double afEstimateVariance(const y_table_item_t *y_item, uint32_t len, bool isY1); bool afIsOutOfFocus(IPAContext context);