[{"id":22281,"web_url":"https://patchwork.libcamera.org/comment/22281/","msgid":"<164735584274.123014.13080050169802797326@Monstersaurus>","date":"2022-03-15T14:50:42","subject":"Re: [libcamera-devel] [PATCH] SQUASH: ipa: ipu3: af: Auto focus for\n\tdw9719 Surface Go2 VCM","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Quoting Kieran Bingham (2022-03-15 14:13:18)\n> These changes are expected to be squashed into the AF implementation.\n> \n> The changes here include:\n> - Correct alignment of documentation *'s\n> - Normalise return value documentation\n> - Fix spelling of /afEstemateVariance/afEstimateVariance/\n> - Expand documentation of Af::afEstimateVariance\n> \n> With these, for Kate's patch:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> I have a few more potential changes, but they can be handled as patches\n> on top and reviewed independently.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/af.cpp | 76 +++++++++++++++++++++++-----------\n>  1 file changed, 52 insertions(+), 24 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\n> index 17055c043200..541b200bcc61 100644\n> --- a/src/ipa/ipu3/algorithms/af.cpp\n> +++ b/src/ipa/ipu3/algorithms/af.cpp\n> @@ -33,25 +33,25 @@\n>   * \\var kAfMinGridWidth\n>   * \\brief the minimum width of AF grid.\n>   * The minimum grid horizontal dimensions.\n> -*/\n> + */\n>  \n>  /**\n>   * \\var kAfMinGridHeight\n>   * \\brief the minimum height of AF grid.\n>   * The minimum grid vertical dimensions.\n> -*/\n> + */\n>  \n>  /**\n>   * \\var kAfMaxGridWidth\n>   * \\brief the maximum width of AF grid.\n>   * The maximum grid horizontal dimensions.\n> -*/\n> + */\n>  \n>  /**\n>   * \\var kAfMaxGridHeight\n>   * \\brief The maximum height of AF grid.\n>   * The maximum grid vertical dimensions.\n> -*/\n> + */\n>  \n>  /**\n>   * \\var kAfMinGridBlockWidth\n> @@ -127,6 +127,7 @@ static struct ipu3_uapi_af_filter_config afFilterConfigDefault = {\n>  /**\n>   * \\class Af\n>   * \\brief An auto-focus algorithm based on IPU3 statistics\n> + *\n>   * This algorithm is used to determine the position of the lens to make a\n>   * focused image. The IPU3 AF processing block computes the statistics that\n>   * are composed by two types of filtered value and stores in a AF buffer.\n> @@ -158,7 +159,7 @@ void Af::prepare(IPAContext &context, ipu3_uapi_params *params)\n>   * \\brief Configure the Af given a configInfo\n>   * \\param[in] context The shared IPA context\n>   * \\param[in] configInfo The IPA configuration data\n> - * \\return 0\n> + * \\return 0 on success, a negative error code otherwise\n>   */\n>  int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>  {\n> @@ -195,7 +196,9 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>  \n>  /**\n>   * \\brief AF coarse scan\n> + *\n>   * Find a near focused image using a coarse step. The step is determined by coarseSearchStep.\n> + *\n>   * \\param[in] context The shared IPA context\n>   */\n>  void Af::afCoarseScan(IPAContext &context)\n> @@ -220,7 +223,9 @@ void Af::afCoarseScan(IPAContext &context)\n>  \n>  /**\n>   * \\brief AF fine scan\n> + *\n>   * Find an optimum lens position with moving 1 step for each search.\n> + *\n>   * \\param[in] context The shared IPA context\n>   */\n>  void Af::afFineScan(IPAContext &context)\n> @@ -239,7 +244,9 @@ void Af::afFineScan(IPAContext &context)\n>  \n>  /**\n>   * \\brief AF reset\n> + *\n>   * Reset all the parameters to start over the AF process.\n> + *\n>   * \\param[in] context The shared IPA context\n>   */\n>  void Af::afReset(IPAContext &context)\n> @@ -260,11 +267,13 @@ void Af::afReset(IPAContext &context)\n>  \n>  /**\n>   * \\brief AF variance comparison.\n> - * It always picks the largest variance to replace the previous one. The image\n> - * with a larger variance also indicates it is a clearer image than previous\n> - * one. If it finds the negative sign of derivative, it returns immediately.\n>   * \\param[in] context The IPA context\n>   * \\param min_step The VCM movement step.\n> + *\n> + * We always pick the largest variance to replace the previous one. The image\n> + * with a larger variance also indicates it is a clearer image than previous\n> + * one. If we find a negative derivative, we return immediately.\n> + *\n>   * \\return True, if it finds a AF value.\n>   */\n>  bool Af::afScan(IPAContext &context, int min_step)\n> @@ -278,7 +287,7 @@ bool Af::afScan(IPAContext &context, int min_step)\n>                  * Find the maximum of the variance by estimating its\n>                  * derivative. If the direction changes, it means we have\n>                  * passed a maximum one step before.\n> -               */\n> +                */\n>                 if ((currentVariance_ - context.frameContext.af.maxVariance) >=\n>                     -(context.frameContext.af.maxVariance * 0.1)) {\n>                         /*\n> @@ -313,8 +322,7 @@ bool Af::afScan(IPAContext &context, int min_step)\n>  \n>  /**\n>   * \\brief Determine the frame to be ignored.\n> - * \\return Return true the frame is ignored.\n> - * \\return Return false the frame should be processed.\n> + * \\return Return True if the frame should be ignored, false otherwise\n>   */\n>  bool Af::afNeedIgnoreFrame()\n>  {\n> @@ -334,9 +342,22 @@ void Af::afIgnoreFrameReset()\n>  }\n>  \n>  /**\n> - * \\brief Estemate variance\n> + * \\brief Estimate variance\n> + * \\param y_item The AF filter data set from the IPU3 statistics buffer\n> + * \\param len The quantity of table item entries which are valid to process\n> + * \\param isY1 Selects between filter Y1 or Y2 to calculate the variance\n> + *\n> + * Calculate the mean of the data set provided by \\a y_item, and then calculate\n> + * the variance of that data set from the mean.\n> + *\n> + * The operation can work on one of two sets of values contained within the\n> + * y_item data set supplied by the IPU3. The two data sets are the results of\n> + * both the Y1 and Y2 filters which are used to support coarse (Y1) and fine\n> + * (Y2) calculations of the contrast.\n> + *\n> + * \\return The variance of the values in the data set \\a y_item selected by \\a isY1\n>   */\n> -double Af::afEstemateVariance(y_table_item_t *y_item, uint32_t len,\n> +double Af::afEstimateVariance(y_table_item_t *y_item, uint32_t len,\n\nOf course, there is also the corresponding update to the class\ndefinition in the header for this change.\n--\nKieran\n\n>                               bool isY1)\n>  {\n>         uint32_t z = 0;\n> @@ -363,21 +384,25 @@ double Af::afEstemateVariance(y_table_item_t *y_item, uint32_t len,\n>  \n>  /**\n>   * \\brief Determine out-of-focus situation.\n> + * \\param context The IPA context.\n> + *\n>   * Out-of-focus means that the variance change rate for a focused and a new\n>   * variance is greater than a threshold.\n> - * \\param context The IPA context.\n> - * \\return If it is out-of-focus, return true.\n> - * \\return If is is focused, return false.\n> + *\n> + * \\return True if the variance threshold is crossed indicating lost focus,\n> + *         false otherwise.\n>   */\n>  bool Af::afIsOutOfFocus(IPAContext context)\n>  {\n>         const uint32_t diff_var = std::abs(currentVariance_ -\n>                                            context.frameContext.af.maxVariance);\n>         const double var_ratio = diff_var / context.frameContext.af.maxVariance;\n> +\n>         LOG(IPU3Af, Debug) << \"Variance change rate: \"\n>                            << var_ratio\n>                            << \" Current VCM step: \"\n>                            << context.frameContext.af.focus;\n> +\n>         if (var_ratio > kMaxChange)\n>                 return true;\n>         else\n> @@ -386,16 +411,19 @@ bool Af::afIsOutOfFocus(IPAContext context)\n>  \n>  /**\n>   * \\brief Determine the max contrast image and lens position.\n> - * Ideally, a clear image also has a raletively higher contrast. So, every\n> - * images for each focus step should be tested to find a optimal focus step.\n> + * \\param[in] context The IPA context.\n> + * \\param[in] stats The statistic buffer of IPU3.\n> + *\n> + * Ideally, a clear image also has a relatively higher contrast. So, every\n> + * image for each focus step should be tested to find an optimal focus step.\n> + *\n>   * The Hill Climbing Algorithm[1] is used to find the maximum variance of the\n> - * AF statistic which is the AF output of IPU3. The focus step is increased\n> + * AF statistics which is the AF output of IPU3. The focus step is increased\n>   * then the variance of the AF statistic is estimated. If it finds the negative\n> - * derivative which means we just passed the peak, the best focus is found.\n> + * derivative we have just passed the peak, and we infer that the best focus is\n> + * found.\n>   *\n>   * [1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing\n> - * \\param[in] context The IPA context.\n> - * \\param[in] stats The statistic buffer of IPU3.\n>   */\n>  void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  {\n> @@ -415,9 +443,9 @@ void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>          * For fine: y2 results are used.\n>          */\n>         if (coarseCompleted_)\n> -               currentVariance_ = afEstemateVariance(y_item, afRawBufferLen, false);\n> +               currentVariance_ = afEstimateVariance(y_item, afRawBufferLen, false);\n>         else\n> -               currentVariance_ = afEstemateVariance(y_item, afRawBufferLen, true);\n> +               currentVariance_ = afEstimateVariance(y_item, afRawBufferLen, true);\n>  \n>         if (!context.frameContext.af.stable) {\n>                 afCoarseScan(context);\n> -- \n> 2.32.0\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 C99ADBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Mar 2022 14:50:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1618E604DA;\n\tTue, 15 Mar 2022 15:50:47 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00580604DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Mar 2022 15:50:45 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9589210DD;\n\tTue, 15 Mar 2022 15:50:45 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647355847;\n\tbh=PJtqVlEzOKIG7pOous+ccy4gSjL7bdJJOMbfd1rCzrY=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=qaaqxG9S+5y04HheyxHWOSmf51OEx6CY0eACcRUtDI7FdHrA2m+AOF/37qnXx90rc\n\tlCKlLrcNhkzJ/mXlR6DseKw1srlIWS4gA6o1up9DT6v8GAAALBq0pRbIlpvaEK6fsb\n\tNyqsY7iVciODtyGJ4Aa6ZwgR5hT8L6GzQwoRF1x8HcG/Z2Eca725JNJV9deToNbm34\n\t4gPz6HKOufSbs/qoG27IHVSBl8fZPW0Jbgm5I3GPvFIuC1mmcC3+70bGvWg1e9tMC/\n\tHWNXWrA7PM6I/1ioSAkm1bHOBh1m2OjCo48rRBHVYyEjxXiJ+6LNf07h3k5ZTymMfJ\n\tslwZDWgB5jK/Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647355845;\n\tbh=PJtqVlEzOKIG7pOous+ccy4gSjL7bdJJOMbfd1rCzrY=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ofDhxqay7OlAyUh9VOVm1QQUUD36gxynZGYvpWQiwRJGch0u1Ej/U3TmucliR6L+m\n\thkr5jK+QokfG68M/Wc3PeCZQCgxlXmPrwxDy5J3/OLxxc0oh0SbLyvRyKNIdWPRwBf\n\twUMyxAO3Xb/CynPOGFe6TfyR+f6nEXYIu7Gl1GWc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ofDhxqay\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220315141318.329309-1-kieran.bingham@ideasonboard.com>","References":"<20220214095136.25425-1-hpa@redhat.com>\n\t<20220315141318.329309-1-kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tKate Hsuan <hpa@redhat.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 15 Mar 2022 14:50:42 +0000","Message-ID":"<164735584274.123014.13080050169802797326@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] SQUASH: ipa: ipu3: af: Auto focus for\n\tdw9719 Surface Go2 VCM","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22282,"web_url":"https://patchwork.libcamera.org/comment/22282/","msgid":"<62982184-fe30-c45c-05ae-2f416223e790@ideasonboard.com>","date":"2022-03-15T15:45:54","subject":"Re: [libcamera-devel] [PATCH] SQUASH: ipa: ipu3: af: Auto focus for\n\tdw9719 Surface Go2 VCM","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Kieran,\n\nOn 15/03/2022 15:13, Kieran Bingham wrote:\n> These changes are expected to be squashed into the AF implementation.\n> \n> The changes here include:\n> - Correct alignment of documentation *'s\n> - Normalise return value documentation\n> - Fix spelling of /afEstemateVariance/afEstimateVariance/\n> - Expand documentation of Af::afEstimateVariance\n\nThanks for the improvements !\n\n> \n> With these, for Kate's patch:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> I have a few more potential changes, but they can be handled as patches\n> on top and reviewed independently.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>   src/ipa/ipu3/algorithms/af.cpp | 76 +++++++++++++++++++++++-----------\n>   1 file changed, 52 insertions(+), 24 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\n> index 17055c043200..541b200bcc61 100644\n> --- a/src/ipa/ipu3/algorithms/af.cpp\n> +++ b/src/ipa/ipu3/algorithms/af.cpp\n> @@ -33,25 +33,25 @@\n>    * \\var kAfMinGridWidth\n>    * \\brief the minimum width of AF grid.\n>    * The minimum grid horizontal dimensions.\n> -*/\n> + */\n>   \n>   /**\n>    * \\var kAfMinGridHeight\n>    * \\brief the minimum height of AF grid.\n>    * The minimum grid vertical dimensions.\n> -*/\n> + */\n>   \n>   /**\n>    * \\var kAfMaxGridWidth\n>    * \\brief the maximum width of AF grid.\n>    * The maximum grid horizontal dimensions.\n> -*/\n> + */\n>   \n>   /**\n>    * \\var kAfMaxGridHeight\n>    * \\brief The maximum height of AF grid.\n>    * The maximum grid vertical dimensions.\n> -*/\n> + */\n>   \n>   /**\n>    * \\var kAfMinGridBlockWidth\n> @@ -127,6 +127,7 @@ static struct ipu3_uapi_af_filter_config afFilterConfigDefault = {\n>   /**\n>    * \\class Af\n>    * \\brief An auto-focus algorithm based on IPU3 statistics\n> + *\n>    * This algorithm is used to determine the position of the lens to make a\n>    * focused image. The IPU3 AF processing block computes the statistics that\n>    * are composed by two types of filtered value and stores in a AF buffer.\n> @@ -158,7 +159,7 @@ void Af::prepare(IPAContext &context, ipu3_uapi_params *params)\n>    * \\brief Configure the Af given a configInfo\n>    * \\param[in] context The shared IPA context\n>    * \\param[in] configInfo The IPA configuration data\n> - * \\return 0\n> + * \\return 0 on success, a negative error code otherwise\n>    */\n>   int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>   {\n> @@ -195,7 +196,9 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>   \n>   /**\n>    * \\brief AF coarse scan\n> + *\n>    * Find a near focused image using a coarse step. The step is determined by coarseSearchStep.\n> + *\n>    * \\param[in] context The shared IPA context\n>    */\n>   void Af::afCoarseScan(IPAContext &context)\n> @@ -220,7 +223,9 @@ void Af::afCoarseScan(IPAContext &context)\n>   \n>   /**\n>    * \\brief AF fine scan\n> + *\n>    * Find an optimum lens position with moving 1 step for each search.\n> + *\n>    * \\param[in] context The shared IPA context\n>    */\n>   void Af::afFineScan(IPAContext &context)\n> @@ -239,7 +244,9 @@ void Af::afFineScan(IPAContext &context)\n>   \n>   /**\n>    * \\brief AF reset\n> + *\n>    * Reset all the parameters to start over the AF process.\n> + *\n>    * \\param[in] context The shared IPA context\n>    */\n>   void Af::afReset(IPAContext &context)\n> @@ -260,11 +267,13 @@ void Af::afReset(IPAContext &context)\n>   \n>   /**\n>    * \\brief AF variance comparison.\n> - * It always picks the largest variance to replace the previous one. The image\n> - * with a larger variance also indicates it is a clearer image than previous\n> - * one. If it finds the negative sign of derivative, it returns immediately.\n>    * \\param[in] context The IPA context\n>    * \\param min_step The VCM movement step.\n> + *\n> + * We always pick the largest variance to replace the previous one. The image\n> + * with a larger variance also indicates it is a clearer image than previous\n> + * one. If we find a negative derivative, we return immediately.\n> + *\n>    * \\return True, if it finds a AF value.\n>    */\n>   bool Af::afScan(IPAContext &context, int min_step)\n> @@ -278,7 +287,7 @@ bool Af::afScan(IPAContext &context, int min_step)\n>   \t\t * Find the maximum of the variance by estimating its\n>   \t\t * derivative. If the direction changes, it means we have\n>   \t\t * passed a maximum one step before.\n> -\t\t*/\n> +\t\t */\n>   \t\tif ((currentVariance_ - context.frameContext.af.maxVariance) >=\n>   \t\t    -(context.frameContext.af.maxVariance * 0.1)) {\n>   \t\t\t/*\n> @@ -313,8 +322,7 @@ bool Af::afScan(IPAContext &context, int min_step)\n>   \n>   /**\n>    * \\brief Determine the frame to be ignored.\n> - * \\return Return true the frame is ignored.\n> - * \\return Return false the frame should be processed.\n> + * \\return Return True if the frame should be ignored, false otherwise\n>    */\n>   bool Af::afNeedIgnoreFrame()\n>   {\n> @@ -334,9 +342,22 @@ void Af::afIgnoreFrameReset()\n>   }\n>   \n>   /**\n> - * \\brief Estemate variance\n> + * \\brief Estimate variance\n\nNice typo catch !\n\n> + * \\param y_item The AF filter data set from the IPU3 statistics buffer\n> + * \\param len The quantity of table item entries which are valid to process\n> + * \\param isY1 Selects between filter Y1 or Y2 to calculate the variance\n> + *\n> + * Calculate the mean of the data set provided by \\a y_item, and then calculate\n> + * the variance of that data set from the mean.\n> + *\n> + * The operation can work on one of two sets of values contained within the\n> + * y_item data set supplied by the IPU3. The two data sets are the results of\n> + * both the Y1 and Y2 filters which are used to support coarse (Y1) and fine\n\ns/fine/finer maybe ?\n\n> + * (Y2) calculations of the contrast.\n> + *\n> + * \\return The variance of the values in the data set \\a y_item selected by \\a isY1\n>    */\n> -double Af::afEstemateVariance(y_table_item_t *y_item, uint32_t len,\n> +double Af::afEstimateVariance(y_table_item_t *y_item, uint32_t len,\n>   \t\t\t      bool isY1)\n>   {\n>   \tuint32_t z = 0;\n> @@ -363,21 +384,25 @@ double Af::afEstemateVariance(y_table_item_t *y_item, uint32_t len,\n>   \n>   /**\n>    * \\brief Determine out-of-focus situation.\n> + * \\param context The IPA context.\n> + *\n>    * Out-of-focus means that the variance change rate for a focused and a new\n>    * variance is greater than a threshold.\n> - * \\param context The IPA context.\n> - * \\return If it is out-of-focus, return true.\n> - * \\return If is is focused, return false.\n> + *\n> + * \\return True if the variance threshold is crossed indicating lost focus,\n> + *         false otherwise.\n>    */\n>   bool Af::afIsOutOfFocus(IPAContext context)\n>   {\n>   \tconst uint32_t diff_var = std::abs(currentVariance_ -\n>   \t\t\t\t\t   context.frameContext.af.maxVariance);\n>   \tconst double var_ratio = diff_var / context.frameContext.af.maxVariance;\n> +\n>   \tLOG(IPU3Af, Debug) << \"Variance change rate: \"\n>   \t\t\t   << var_ratio\n>   \t\t\t   << \" Current VCM step: \"\n>   \t\t\t   << context.frameContext.af.focus;\n> +\n>   \tif (var_ratio > kMaxChange)\n>   \t\treturn true;\n>   \telse\n> @@ -386,16 +411,19 @@ bool Af::afIsOutOfFocus(IPAContext context)\n>   \n>   /**\n>    * \\brief Determine the max contrast image and lens position.\n> - * Ideally, a clear image also has a raletively higher contrast. So, every\n> - * images for each focus step should be tested to find a optimal focus step.\n> + * \\param[in] context The IPA context.\n> + * \\param[in] stats The statistic buffer of IPU3.\n\ns/statistic/statistics\n\n> + *\n> + * Ideally, a clear image also has a relatively higher contrast. So, every\n> + * image for each focus step should be tested to find an optimal focus step.\n> + *\n>    * The Hill Climbing Algorithm[1] is used to find the maximum variance of the\n> - * AF statistic which is the AF output of IPU3. The focus step is increased\n> + * AF statistics which is the AF output of IPU3. The focus step is increased\n>    * then the variance of the AF statistic is estimated. If it finds the negative\n> - * derivative which means we just passed the peak, the best focus is found.\n> + * derivative we have just passed the peak, and we infer that the best focus is\n> + * found.\n>    *\n>    * [1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing\n> - * \\param[in] context The IPA context.\n> - * \\param[in] stats The statistic buffer of IPU3.\n>    */\n>   void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>   {\n> @@ -415,9 +443,9 @@ void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>   \t * For fine: y2 results are used.\n>   \t */\n>   \tif (coarseCompleted_)\n> -\t\tcurrentVariance_ = afEstemateVariance(y_item, afRawBufferLen, false);\n> +\t\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, false);\n>   \telse\n> -\t\tcurrentVariance_ = afEstemateVariance(y_item, afRawBufferLen, true);\n> +\t\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, true);\n>   \n>   \tif (!context.frameContext.af.stable) {\n>   \t\tafCoarseScan(context);\n\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","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 17693BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Mar 2022 15:46:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6EB60610F8;\n\tTue, 15 Mar 2022 16:45:59 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 99AC1604DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Mar 2022 16:45:57 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:e38:1788:50cc:d433] (unknown\n\t[IPv6:2a01:e0a:169:7140:e38:1788:50cc:d433])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 30FBC1BBB;\n\tTue, 15 Mar 2022 16:45:57 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647359159;\n\tbh=llyGWsPFNfj1n4pvqxQfA0Gbc9SIXfPlCvRuDT5Yx+w=;\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=dPz3MiKP42jixTuWkoHIYiKXjqi8dIw2kuMvVv0J0LvU4mOKgh1sTmk/qTM+Gn91f\n\t1zR5SMurtXkr3cssPi6lOeV+Cdf4OpDsGqNmHk9jMCPcoXR96Gy4A727bKtZuizyKh\n\t73RdYzJPkV5in2nkT+xByhEndG4IQurVFKyHvBMEpcduTZ3IgHFclq5PaJV5seFnpb\n\tuPVOg8T5PuJgCI/ijiIDuT8fEv3+QHK4XCaLcW3xho+twumH1dT4fZt8n5QSdwHjY/\n\tyv12ocrcbrN+G/uOBIwMq8R63k4FvNL27YH1YS6Ay1ixBxr0CIGVi7jb2GiA9diQRV\n\t0BMzVyG2QoSog==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647359157;\n\tbh=llyGWsPFNfj1n4pvqxQfA0Gbc9SIXfPlCvRuDT5Yx+w=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=XC+uIEivKcA6b2UmSCUnRtGpjQ6vZL78dm2VShA78Eeiml6FKkRn2mNLROWCHH+8T\n\tMOUmHy2hUxaXrEuJR9N8Zq+tF6PY0w4HtSss8U4y8sEhcvrEMsziwhntBuVaxvkgZN\n\tcK2OvqFFyxzZU+aVkQzV5lRxQVmd4fmo1jTMep+o="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XC+uIEiv\"; dkim-atps=neutral","Message-ID":"<62982184-fe30-c45c-05ae-2f416223e790@ideasonboard.com>","Date":"Tue, 15 Mar 2022 16:45:54 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.5.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":"<20220214095136.25425-1-hpa@redhat.com>\n\t<20220315141318.329309-1-kieran.bingham@ideasonboard.com>","In-Reply-To":"<20220315141318.329309-1-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH] SQUASH: ipa: ipu3: af: Auto focus for\n\tdw9719 Surface Go2 VCM","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>"}}]