From patchwork Tue Mar 15 17:53:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15455 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 514CFC3263 for ; Tue, 15 Mar 2022 17:53:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC5A161FBC; Tue, 15 Mar 2022 18:53:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647366836; bh=CGzjh9tM+VIsTg401TThvU12GfgXHHpsOkPLGx57dn0=; 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=a8CORCX9hRIz6k7tQNxnypMspIgIuUo9uhGgdvWvKK/5vEjWUJQV4Rn7FmAPnUXPy PokMnPlr9boNMuj9mOkFLmpWMlqbCfk5q82U3gpbWlE2rEGJT10NoPjLz96X8j1z1i 27qitxtTjj08RLhOk8+2QK80gOipCQLN5+xmOzdHtUEfi0fdvMnehFfnY7Z3H/CKiz CPZ/OqIkO2VKJzTgHbA0VixSZqMX79s4YFImKtGwl+kQKuNwLksNsY1oeOyuRx0y9O 4jf4dF6nWxwXfy2eWQg8rAfTQgdRaI60kDogBYpItFU/oIqkrF8yWDt3QQBdbF3krv 6B6xiRGQGRtqA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BD776118A for ; Tue, 15 Mar 2022 18:53:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YcQVPciG"; 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 EBD0C1C6D; Tue, 15 Mar 2022 18:53:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1647366834; bh=CGzjh9tM+VIsTg401TThvU12GfgXHHpsOkPLGx57dn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YcQVPciGw4hj/YYmb60/fpygEyL1tgrUoMyYiLwRDCn6m1HEHXUjbw4bmVnp/psTC ck9kN2xMUq45bPH97rPb/9ejGH9QY6BICoXVfDePTgNttx2ZWBxE4WC24ODagRFsSF +5tDnAllUj/3K1u21OqlxdbnPo/4om8RwsXYkLr0= To: libcamera devel Date: Tue, 15 Mar 2022 17:53:45 +0000 Message-Id: <20220315175345.479951-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220315175345.479951-1-kieran.bingham@ideasonboard.com> References: <20220315175345.479951-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] 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(). Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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 469762a29937..e10cff968895 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 / sizeof(y_table_item_t) < 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);