[{"id":36716,"web_url":"https://patchwork.libcamera.org/comment/36716/","msgid":"<176236124597.2116251.6394227944258115697@neptunite.rasen.tech>","date":"2025-11-05T16:47:25","subject":"Re: [PATCH v2 15/35] libcamera: rkisp1: Scale down in dewarper\n\tinstead of resizer","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-10-23 23:48:16)\n> In order to allow digital zooming, scale down in the dewarper instead of\n> the resizer. That means forwarding the full sensor size data to the\n> dewarper. The ScalerCrop rectangle will also be applied at the dewarper.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nLooks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 43 +++++++++++++++++++-----\n>  1 file changed, 35 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 241c83f4125b..46bc81f2483c 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -888,16 +888,31 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>         /*\n>          * On devices without DUAL_CROP (like the imx8mp) cropping needs to be\n>          * done on the ISP/IS output.\n> +        *\n> +        * If the dewarper is used, the cropping shall be done by the dewarper.\n>          */\n>         if (media_->hwRevision() == RKISP1_V_IMX8MP) {\n>                 /* imx8mp has only a single path. */\n>                 const auto &cfg = config->at(0);\n> -               Size ispCrop = format.size.boundedToAspectRatio(cfg.size);\n> +               /*\n> +                * If the dewarper is used, all cropping including aspect ratio\n> +                * preservation shall be done there. To ensure that the output\n> +                * format provided by the ISP is supported by the dewarper, a\n> +                * minimal crop still needs to be applied on the ISP output.\n> +                *\n> +                * \\todo It might be possible to allocate bigger buffers\n> +                * (aligned to 8 pixels) with a stride matching format.size for\n> +                * the ISP. The not-filled border could later be ignored by the\n> +                * dewarper. This way we could skip the minimal crop here and\n> +                * the MaximumScalerCrop would always match the isp output.\n> +                */\n> +               Size ispCrop;\n>                 if (data->usesDewarper_)\n>                         ispCrop = dewarper_->adjustInputSize(cfg.pixelFormat,\n> -                                                            ispCrop);\n> +                                                            format.size);\n>                 else\n> -                       ispCrop.alignUpTo(2, 2);\n> +                       ispCrop = format.size.boundedToAspectRatio(cfg.size)\n> +                                         .alignedUpTo(2, 2);\n>  \n>                 outputCrop = ispCrop.centeredTo(Rectangle(format.size).center());\n>                 format.size = ispCrop;\n> @@ -930,13 +945,21 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>  \n>         for (const StreamConfiguration &cfg : *config) {\n>                 if (cfg.stream() == &data->mainPathStream_) {\n> -                       ret = mainPath_.configure(cfg, format);\n> -                       streamConfig[0] = IPAStream(cfg.pixelFormat,\n> -                                                   cfg.size);\n> -                       /* Configure dewarp */\n> +                       /*\n> +                        * To allow for digital zoom, scaling down should happen\n> +                        * in the dewarper, instead of the resizer. Configure\n> +                        * the isp output to the same size as the sensor output.\n> +                        */\n> +                       StreamConfiguration ispCfg = cfg;\n>                         if (data->usesDewarper_) {\n>                                 outputCfgs.push_back(const_cast<StreamConfiguration &>(cfg));\n> -                               ret = dewarper_->configure(cfg, outputCfgs);\n> +\n> +                               ispCfg.size = format.size;\n> +                               ispCfg.stride =\n> +                                       PixelFormatInfo::info(ispCfg.pixelFormat)\n> +                                               .stride(ispCfg.size.width, 0);\n> +\n> +                               ret = dewarper_->configure(ispCfg, outputCfgs);\n>                                 if (ret)\n>                                         return ret;\n>  \n> @@ -949,6 +972,10 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>                                         outputCrop.transformedBetween(inputCrop,\n>                                                                       sensorInfo.analogCrop);\n>                         }\n> +\n> +                       ret = mainPath_.configure(ispCfg, format);\n> +                       streamConfig[0] = IPAStream(cfg.pixelFormat,\n> +                                                   cfg.size);\n>                 } else if (hasSelfPath_) {\n>                         ret = selfPath_.configure(cfg, format);\n>                         streamConfig[1] = IPAStream(cfg.pixelFormat,\n> -- \n> 2.48.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 A2ED7C3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Nov 2025 16:47:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D78860AAB;\n\tWed,  5 Nov 2025 17:47:33 +0100 (CET)","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 E48CD60A86\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Nov 2025 17:47:31 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:d4d0:27ea:7a74:8a9e])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 095251733; \n\tWed,  5 Nov 2025 17:45:36 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"jj0mkmr/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762361137;\n\tbh=oFkWvqp3fQuPlNUCLk2IW0u5y0uAeUPIBbWTVzxdP0c=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=jj0mkmr/qSi9fiu1ITNhW7YeKaTp3aJMKXX2v3SM/Dw1ALlpZfzn2nfgv9Z5O7RLC\n\t+6MZKrfwJ5umSmDa5ynCU0N/WA/KjpcgKddwLy+3YLtk/Kx5W45InpIGcz2/XjdsZ3\n\tLy66Qu8fJOTbLtwKjL6WNFguPwt9FqpXRxzXI+zo=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251023144841.403689-16-stefan.klug@ideasonboard.com>","References":"<20251023144841.403689-1-stefan.klug@ideasonboard.com>\n\t<20251023144841.403689-16-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 15/35] libcamera: rkisp1: Scale down in dewarper\n\tinstead of resizer","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 06 Nov 2025 01:47:25 +0900","Message-ID":"<176236124597.2116251.6394227944258115697@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]