[{"id":31650,"web_url":"https://patchwork.libcamera.org/comment/31650/","msgid":"<172848620280.532453.3202921548946048469@ping.linuxembedded.co.uk>","date":"2024-10-09T15:03:22","subject":"Re: [PATCH v4 12/13] libcamera: mali-c55: Enable usage of scaler","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Daniel Scally (2024-07-09 15:39:12)\n> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> The Mali C55 ISP has a resizing pipeline that allows to crop and scale\n> images.\n> \n> So far the mali-c55 pipeline has only supported cropping without using\n> the scaling functionalities.\n> \n> Now that the kernel has gained support for the scaling operations, make\n> the libcamera pipeline use it by combining it with a first cropping step\n> to align the input and output images FOV ratio, and then scale to the\n> desired output size.\n> \n> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/mali-c55/mali-c55.cpp | 18 +++++++++++++++---\n>  1 file changed, 15 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> index 512a7489..f5ca2ca4 100644\n> --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> @@ -747,16 +747,28 @@ int PipelineHandlerMaliC55::configureProcessedStream(MaliC55CameraData *data,\n>         if (ret)\n>                 return ret;\n>  \n> -       /* \\todo Configure the resizer crop/compose rectangles. */\n> -       Rectangle ispCrop = { 0, 0, config.size };\n> +       /*\n> +        * Compute the scaler-in to scaler-out ratio: first center-crop to align\n> +        * the FOV to the desired resolution, then scale to the desired size.\n> +        */\n> +       Size scalerIn = subdevFormat.size.boundedToAspectRatio(config.size);\n> +       int xCrop = (subdevFormat.size.width - scalerIn.width) / 2;\n> +       int yCrop = (subdevFormat.size.height - scalerIn.height) / 2;\n\nSeeing open-coding for centering makes me think we're missing some\nhelper in geometry.h ... but it looks correct.\n\n> +       Rectangle ispCrop = { xCrop, yCrop, scalerIn };\n\nI think we should be reporting this as ScalerCrop in the metadata to\ntell applications exactly what region they are getting from the Sensor.\n\nOf course implementing ScalerCrop as a control will be good to come\nlater too ;-)\n\nDo we have a request/metadata we can access here in this function to\nreport this already?\n\nIf not - I think we can deal with it when ScalerCrop is actually\nimplemented anyway.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>         ret = pipe->resizer->setSelection(0, V4L2_SEL_TGT_CROP, &ispCrop);\n>         if (ret)\n>                 return ret;\n>  \n> -       ret = pipe->resizer->setSelection(0, V4L2_SEL_TGT_COMPOSE, &ispCrop);\n> +       Rectangle ispCompose = { 0, 0, config.size };\n> +       ret = pipe->resizer->setSelection(0, V4L2_SEL_TGT_COMPOSE, &ispCompose);\n>         if (ret)\n>                 return ret;\n>  \n> +       /*\n> +        * The source pad format size comes directly from the sink\n> +        * compose rectangle.\n> +        */\n> +       subdevFormat.size = ispCompose.size();\n>         subdevFormat.code = maliC55FmtToCode.find(config.pixelFormat)->second;\n>         return pipe->resizer->setFormat(1, &subdevFormat);\n>  }\n> -- \n> 2.34.1\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 67037C32E0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Oct 2024 15:03:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 451E16536B;\n\tWed,  9 Oct 2024 17:03:27 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 227A7618C9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2024 17:03:26 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7506F594;\n\tWed,  9 Oct 2024 17:01:48 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VMQibSea\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1728486108;\n\tbh=B544rSNtZ7XbuzwapO/4aYzXzMts5tpyJ0vvKSCVRT0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=VMQibSeaJ90ZzOg+JPBMLzd8Mn1nN6y1nJATK9qQjyd98DiJ8gkxId1fIanwMhMx9\n\txvV3GSoeJMyO9vFjAeTqpooCmsBpJEf8NAL1Yuq3ZQFZAznGw8VpxpHva87d45p571\n\tZ6g+BdW03h9JhW92LJXjDy+3VtnghmZ9MPHbpQa8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240709143913.3276983-13-dan.scally@ideasonboard.com>","References":"<20240709143913.3276983-1-dan.scally@ideasonboard.com>\n\t<20240709143913.3276983-13-dan.scally@ideasonboard.com>","Subject":"Re: [PATCH v4 12/13] libcamera: mali-c55: Enable usage of scaler","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 09 Oct 2024 16:03:22 +0100","Message-ID":"<172848620280.532453.3202921548946048469@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]