From patchwork Fri Mar 25 09:25:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15553 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 11876BD80A for ; Fri, 25 Mar 2022 09:26:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 63DB3604DB; Fri, 25 Mar 2022 10:26:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648200364; bh=PWGZDJJWtHg1tUvVeAnqITvOLIK6XnKsFMOkDhxIta8=; 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=tuNWjt2U1HI186IwUw9h0eZ+9tSGr+xml0a2xK9gr0E1coGwUnF3LXEoOT8t89aig E+2AFRl/UtWwGonB0bX1krXpUzGS9IQ82y8AkBrVDoERwsfGCGcbfRqcBOt1LZu74j uhE0AjgFgF1wGoxDutsGnLkzblXTzbXGQWwajiTREfgoVvUX7siAzd8qsLpGiG4qXS sKVvqwTefhYz60l6YJMejQrEmrJpYNpToFnXOmcCTRjNHx6AxyKPAnJgevQX7UkkzH AyWHI8bcmrV8Dl2geRbNgzg1SagWFdNPYAL5UNA428kMdG6uD5wnFbdghkakaP46cM y8SobU+H0duWQ== 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 45317604D5 for ; Fri, 25 Mar 2022 10:26:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RU/i1nh7"; 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 D2097E0D; Fri, 25 Mar 2022 10:26:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648200361; bh=PWGZDJJWtHg1tUvVeAnqITvOLIK6XnKsFMOkDhxIta8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RU/i1nh7EvF8vqxpxXcPCBrfC1kN/Ike9MJahrKN4TqIJPMJglr/OhSLUuqpdOe/4 aRNsqoGoI05yaxlUZgBfY2URb2R200EIWQXS/gKLu4eSFgV/SxL8NdawbIPPRRcd+6 p78PK2oxcKEovFe98+6tJ6Q2zvSbgTTuLE8W4vDc= To: libcamera devel , Kate Hsuan , Jean-Michel Hautbois Date: Fri, 25 Mar 2022 09:25:53 +0000 Message-Id: <20220325092555.1799897-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220325092555.1799897-1-kieran.bingham@ideasonboard.com> References: <20220325092555.1799897-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 Reviewed-by: Jean-Michel Hautbois --- - 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 4476857fa772..6893a15fdc07 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -335,7 +335,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; @@ -405,25 +405,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);