[{"id":22380,"web_url":"https://patchwork.libcamera.org/comment/22380/","msgid":"<Yjp2ZObTIWGd2XDj@pendragon.ideasonboard.com>","date":"2022-03-23T01:22:44","subject":"Re: [libcamera-devel] [PATCH 2/3] ipa: ipu3: af: Use geometry\n\tclasses to perform grid centering","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Tue, Mar 15, 2022 at 05:53:44PM +0000, Kieran Bingham via libcamera-devel wrote:\n> Use our geometry classes for Rectangle, Size and Point to identify\n> the region of interest for the autofocus, and center it on the BDS output.\n> \n> This will facilitate custom ROI being passed in through controls at a later\n> time.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/af.cpp | 24 ++++++++++++++++--------\n>  1 file changed, 16 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\n> index 3cedf8cbd687..469762a29937 100644\n> --- a/src/ipa/ipu3/algorithms/af.cpp\n> +++ b/src/ipa/ipu3/algorithms/af.cpp\n> @@ -141,16 +141,24 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>  \tgrid.block_height_log2 = kAfMinGridBlockHeight;\n>  \tgrid.height_per_slice = kAfDefaultHeightPerSlice;\n>  \n> -\t/* x_start and y start are default to BDS center */\n> -\tgrid.x_start = (configInfo.bdsOutputSize.width / 2) -\n> -\t\t       (((grid.width << grid.block_width_log2) / 2));\n> -\tgrid.y_start = (configInfo.bdsOutputSize.height / 2) -\n> -\t\t       (((grid.height << grid.block_height_log2) / 2));\n> +\t/* Position the AF grid in the center of the BDS output. */\n> +\tRectangle bds(configInfo.bdsOutputSize);\n> +\tSize gridSize(grid.width << grid.block_width_log2,\n> +\t\t      grid.height << grid.block_height_log2);\n> +\n> +\t/*\n> +\t * \\todo - Support request metadata\n> +\t * - Set the ROI based on any input controls in the request\n> +\t * - Return the AF ROI as metadata in the Request\n> +\t * - Provide an alignedTo on a point, or Rectangle x,y position\n> +\t */\n> +\tRectangle roi = gridSize.centeredTo(bds.center());\n> +\tPoint start = roi.topLeft();\n>  \n>  \t/* x_start and y_start should be even */\n> -\tgrid.x_start = (grid.x_start / 2) * 2;\n> -\tgrid.y_start = (grid.y_start / 2) * 2;\n> -\tgrid.y_start = grid.y_start | IPU3_UAPI_GRID_Y_START_EN;\n> +\tgrid.x_start = (start.x / 2) * 2;\n> +\tgrid.y_start = (start.y / 2) * 2;\n\nYou could use\n\n\tgrid.x_start = utils::alignDown(start.x, 2);\n\tgrid.y_start = utils::alignDown(start.y, 2);\n\nor possibly even\n\n\tgrid.x_start = start.x & ~1;\n\tgrid.y_start = start.y & ~1;\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\tgrid.y_start |= IPU3_UAPI_GRID_Y_START_EN;\n>  \n>  \t/* Initial max focus step */\n>  \tmaxStep_ = kMaxFocusSteps;","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 8893BC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 01:23:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E56E0604C7;\n\tWed, 23 Mar 2022 02:23:03 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13615604C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 02:23:02 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 861289DE;\n\tWed, 23 Mar 2022 02:23:01 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647998583;\n\tbh=Kt2n7spUrWvewO0MG5+7cdFCqGqS+EDlokt1yMRWn+8=;\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:Cc:\n\tFrom;\n\tb=ksvEAnfaRZvl6BtQKreGg7tEgjD7wJguAHjGUyVVcCmBBzUPoOvV1/1++nVhII3MH\n\tVFX2SbS50hEzkl0NZsZIl114vSQ0koStGO3NtzekDJgS+h7ZBVS1KypbfbNhGuhrRv\n\tp7wbV6jS6ZePF+5CnoscnjigA0rdr32/Ia0a4RIVhB1jX6m9RB6j1NEdBsVakdXjhL\n\tTwX0GHBS/Lk7I1DNIROus9PovYLnTpxc6xNf0m9Loatr7ETchHheKET7L3ls96RUt9\n\tC7IOhluSSvCq5w1kXarJxkbyrV5Kg+zKqBM+SX356VkZAoP21HIUHcEnAhYJpNCSXX\n\tx27Rk9YXw8ZJA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647998581;\n\tbh=Kt2n7spUrWvewO0MG5+7cdFCqGqS+EDlokt1yMRWn+8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=CgFTInV+jaOBZk3D4nLuyae50X14tv1ap3THcpAj1/8h20Hl8Q7hcTaNn4SB2Bb4A\n\tj9l5CHBFK6EznRIq0DrZJS3y8HoeW2kygaAFeHhnrjfgR/nLfMPr2G0jaGWn4QANpQ\n\tU8mPiM4X1dAZIF7QY7l9098T2kueEfVOR4jnb6RM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CgFTInV+\"; dkim-atps=neutral","Date":"Wed, 23 Mar 2022 03:22:44 +0200","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Yjp2ZObTIWGd2XDj@pendragon.ideasonboard.com>","References":"<20220315175345.479951-1-kieran.bingham@ideasonboard.com>\n\t<20220315175345.479951-3-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220315175345.479951-3-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/3] ipa: ipu3: af: Use geometry\n\tclasses to perform grid centering","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22389,"web_url":"https://patchwork.libcamera.org/comment/22389/","msgid":"<164802801429.2130830.15027086079725874418@Monstersaurus>","date":"2022-03-23T09:33:34","subject":"Re: [libcamera-devel] [PATCH 2/3] ipa: ipu3: af: Use geometry\n\tclasses to perform grid centering","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2022-03-23 01:22:44)\n> Hi Kieran,\n> \n> Thank you for the patch.\n> \n> On Tue, Mar 15, 2022 at 05:53:44PM +0000, Kieran Bingham via libcamera-devel wrote:\n> > Use our geometry classes for Rectangle, Size and Point to identify\n> > the region of interest for the autofocus, and center it on the BDS output.\n> > \n> > This will facilitate custom ROI being passed in through controls at a later\n> > time.\n> > \n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > ---\n> >  src/ipa/ipu3/algorithms/af.cpp | 24 ++++++++++++++++--------\n> >  1 file changed, 16 insertions(+), 8 deletions(-)\n> > \n> > diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\n> > index 3cedf8cbd687..469762a29937 100644\n> > --- a/src/ipa/ipu3/algorithms/af.cpp\n> > +++ b/src/ipa/ipu3/algorithms/af.cpp\n> > @@ -141,16 +141,24 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n> >       grid.block_height_log2 = kAfMinGridBlockHeight;\n> >       grid.height_per_slice = kAfDefaultHeightPerSlice;\n> >  \n> > -     /* x_start and y start are default to BDS center */\n> > -     grid.x_start = (configInfo.bdsOutputSize.width / 2) -\n> > -                    (((grid.width << grid.block_width_log2) / 2));\n> > -     grid.y_start = (configInfo.bdsOutputSize.height / 2) -\n> > -                    (((grid.height << grid.block_height_log2) / 2));\n> > +     /* Position the AF grid in the center of the BDS output. */\n> > +     Rectangle bds(configInfo.bdsOutputSize);\n> > +     Size gridSize(grid.width << grid.block_width_log2,\n> > +                   grid.height << grid.block_height_log2);\n> > +\n> > +     /*\n> > +      * \\todo - Support request metadata\n> > +      * - Set the ROI based on any input controls in the request\n> > +      * - Return the AF ROI as metadata in the Request\n> > +      * - Provide an alignedTo on a point, or Rectangle x,y position\n> > +      */\n> > +     Rectangle roi = gridSize.centeredTo(bds.center());\n> > +     Point start = roi.topLeft();\n> >  \n> >       /* x_start and y_start should be even */\n> > -     grid.x_start = (grid.x_start / 2) * 2;\n> > -     grid.y_start = (grid.y_start / 2) * 2;\n> > -     grid.y_start = grid.y_start | IPU3_UAPI_GRID_Y_START_EN;\n> > +     grid.x_start = (start.x / 2) * 2;\n> > +     grid.y_start = (start.y / 2) * 2;\n> \n> You could use\n> \n>         grid.x_start = utils::alignDown(start.x, 2);\n>         grid.y_start = utils::alignDown(start.y, 2);\n\nThanks, that's what I want. I was looking for a way to align a Point (or\nRectangle x,y) to a specific value in geometry, didn't think to look for\nit in utils.\n\n> \n> or possibly even\n> \n>         grid.x_start = start.x & ~1;\n>         grid.y_start = start.y & ~1;\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +     grid.y_start |= IPU3_UAPI_GRID_Y_START_EN;\n> >  \n> >       /* Initial max focus step */\n> >       maxStep_ = kMaxFocusSteps;\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 AB923BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 09:33:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 019DB604D5;\n\tWed, 23 Mar 2022 10:33:39 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 457F6601F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 10:33:37 +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 CFAD39DE;\n\tWed, 23 Mar 2022 10:33:36 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648028019;\n\tbh=5HHmcPK/tJMMF2Heh2WDr/Isg/BzUIo4/+0cU9clWRc=;\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:Cc:\n\tFrom;\n\tb=EsZmSQVgLj61M/ydx+CUuIzqgh0yJQNWiOUBLDZqnDqw+MAeR/I3arAa+Nqa1z/Hl\n\tBE7xKVFLnmFIpYC4OAoVZoltCxPCM+CUJGthAlYX6wr3qw5g/1U3KUUjYkiFuS1UqL\n\tIwk8Zq5VO0B6Moh7AAKxbk4w7yKL+eLqe5gdZOvh9yX+/1mjeAQBG6Jc7cvtoaE7Qw\n\tGoNmbZ6yBKZbFi8SheRdfNgjyUZVe5aRiEWEcDLaR67CbrMdmbgglewiwzDkVD9qjm\n\t0JKyXxCk93BkgILMsf7LzJj2P0yJLDPYBShvfZUkJQdIelOAgeUxwACiTQgOZewGpN\n\tc/DI9FYyRXbZA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648028016;\n\tbh=5HHmcPK/tJMMF2Heh2WDr/Isg/BzUIo4/+0cU9clWRc=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=iaQYNP012CJgxxQvN3gPH3D4wIJnxTPGxIPWTDT+mzTGp0cIdn7stHLOtYbJvVh45\n\tZrftkyU4pM/Ws28unxWfK0GkIKsAoLMKYVSUKYBmiLh3BHv+Urc0w44an/Pb7Rij7W\n\tiTn4/NSO2hWOzX6tQMFPreXbRsOU3479EpLc6ebU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"iaQYNP01\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<Yjp2ZObTIWGd2XDj@pendragon.ideasonboard.com>","References":"<20220315175345.479951-1-kieran.bingham@ideasonboard.com>\n\t<20220315175345.479951-3-kieran.bingham@ideasonboard.com>\n\t<Yjp2ZObTIWGd2XDj@pendragon.ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Wed, 23 Mar 2022 09:33:34 +0000","Message-ID":"<164802801429.2130830.15027086079725874418@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH 2/3] ipa: ipu3: af: Use geometry\n\tclasses to perform grid centering","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]