[{"id":22503,"web_url":"https://patchwork.libcamera.org/comment/22503/","msgid":"<f0e90958-57e4-33cb-f4ab-a521292dc39e@ideasonboard.com>","date":"2022-03-29T05:56:26","subject":"Re: [libcamera-devel] [PATCH v3 3/5] ipa: ipu3: af: Remove\n\tredundant memcpy","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Kieran,\n\nThanks for the patch !\n\nOn 25/03/2022 10:25, Kieran Bingham wrote:\n> The af statistics can be accessed directly from the mapped buffer.\n> Remove the redundant memcpy, and simplify the call to\n> afEstimateVariance().\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\n> \n> ---\n>   - Fix ASSERT\n> \n>   src/ipa/ipu3/algorithms/af.cpp | 12 ++++--------\n>   src/ipa/ipu3/algorithms/af.h   |  2 +-\n>   2 files changed, 5 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\n> index 4476857fa772..6893a15fdc07 100644\n> --- a/src/ipa/ipu3/algorithms/af.cpp\n> +++ b/src/ipa/ipu3/algorithms/af.cpp\n> @@ -335,7 +335,7 @@ void Af::afIgnoreFrameReset()\n>    *\n>    * \\return The variance of the values in the data set \\a y_item selected by \\a isY1\n>    */\n> -double Af::afEstimateVariance(y_table_item_t *y_item, uint32_t len,\n> +double Af::afEstimateVariance(const y_table_item_t *y_item, uint32_t len,\n>   \t\t\t      bool isY1)\n>   {\n>   \tuint32_t z = 0;\n> @@ -405,25 +405,21 @@ bool Af::afIsOutOfFocus(IPAContext context)\n>    */\n>   void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>   {\n> -\ty_table_item_t y_item[IPU3_UAPI_AF_Y_TABLE_MAX_SIZE / sizeof(y_table_item_t)];\n> +\tconst y_table_item_t *y_item = reinterpret_cast<const y_table_item_t *>(&stats->af_raw_buffer.y_table);\n>   \tuint32_t afRawBufferLen;\n>   \n>   \t/* Evaluate the AF buffer length */\n>   \tafRawBufferLen = context.configuration.af.afGrid.width *\n>   \t\t\t context.configuration.af.afGrid.height;\n>   \n> -\tmemcpy(y_item, stats->af_raw_buffer.y_table,\n> -\t       afRawBufferLen * sizeof(y_table_item_t));\n> +\tASSERT(afRawBufferLen < IPU3_UAPI_AF_Y_TABLE_MAX_SIZE);\n>   \n>   \t/*\n>   \t * Calculate the mean and the variance of AF statistics for a given grid.\n>   \t * For coarse: y1 are used.\n>   \t * For fine: y2 results are used.\n>   \t */\n> -\tif (coarseCompleted_)\n> -\t\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, false);\n> -\telse\n> -\t\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, true);\n> +\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, !coarseCompleted_);\n>   \n>   \tif (!context.frameContext.af.stable) {\n>   \t\tafCoarseScan(context);\n> diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h\n> index 906f2843dd49..3b5758e868ea 100644\n> --- a/src/ipa/ipu3/algorithms/af.h\n> +++ b/src/ipa/ipu3/algorithms/af.h\n> @@ -41,7 +41,7 @@ private:\n>   \tvoid afReset(IPAContext &context);\n>   \tbool afNeedIgnoreFrame();\n>   \tvoid afIgnoreFrameReset();\n> -\tdouble afEstimateVariance(y_table_item_t *y_item, uint32_t len,\n> +\tdouble afEstimateVariance(const y_table_item_t *y_item, uint32_t len,\n>   \t\t\t\t  bool isY1);\n>   \tbool afIsOutOfFocus(IPAContext context);\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7778FC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Mar 2022 05:56:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 30A2B65636;\n\tTue, 29 Mar 2022 07:56:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 44623604BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Mar 2022 07:56:29 +0200 (CEST)","from [IPV6:2a01:e0a:169:7140:46c7:900e:3d98:76e7] (unknown\n\t[IPv6:2a01:e0a:169:7140:46c7:900e:3d98:76e7])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 01BBB888;\n\tTue, 29 Mar 2022 07:56:28 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648533390;\n\tbh=s1vcsBRgxc1hsILYm+2Sy3X6qhZJvht2Sl4uRAFXROI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=UN4uWvzb9wmqmBzOyNOI/X7JTD0hb1rcu9YQuPLPDPFodGZFqq/p70ZqLguW4YAJg\n\tpnBUdC9ZiWo0fulZEXPnIQYlpJQs/RnBGrpxVCkYeETna1RRFAaE6W70mpQ+sj5/vz\n\tuPwMJVyXEl7EKN8EsJpQiJCGlvZEVE8YdnQMfwwtiI+zOsZf1OGBnfwqgfOjGeIFbB\n\tSwTpvPpdt2odbO71/dEHiBXMCfiY1SCoBCVvKogpOqIHakjBohgqSygREAItjW8SZ0\n\tr73u5keBdYBseGNwKfl3kreuQoPmdZfVcmE/8Prv+cjFbUBKHXA05lnw4D0vqP/aaN\n\tJYBt9MAlXuPjQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648533389;\n\tbh=s1vcsBRgxc1hsILYm+2Sy3X6qhZJvht2Sl4uRAFXROI=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=DmlLtYNrR6WnwhS8rFzA/kL8bCFMXFaDyn3GVuHkNdVTfVj+LuIPI5na/AkWfSjoM\n\tB8DiYRLI8HbE7hPp50TVhHsnSFUZITJ629FE9xTFgCQD6Jd9gEqOo9A+D4LEZAiP5J\n\tExslu//1Qn2xp5W/YNOhNfnCOdBtl0sT9e/CbVFk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DmlLtYNr\"; dkim-atps=neutral","Message-ID":"<f0e90958-57e4-33cb-f4ab-a521292dc39e@ideasonboard.com>","Date":"Tue, 29 Mar 2022 07:56:26 +0200","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.7.0","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>,\n\tKate Hsuan <hpa@redhat.com>","References":"<20220325092555.1799897-1-kieran.bingham@ideasonboard.com>\n\t<20220325092555.1799897-4-kieran.bingham@ideasonboard.com>","In-Reply-To":"<20220325092555.1799897-4-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 3/5] ipa: ipu3: af: Remove\n\tredundant memcpy","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]