[{"id":37053,"web_url":"https://patchwork.libcamera.org/comment/37053/","msgid":"<176409051012.567526.605859197824301198@ping.linuxembedded.co.uk>","date":"2025-11-25T17:08:30","subject":"Re: [PATCH v3 12/29] libcamera: rkisp1: Scale down in dewarper\n\tinstead of resizer","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-11-25 16:28:24)\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> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n> \n> Changes in v3:\n> - Collected tag\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 a3b92804c69f..2d89b0b41958 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -883,16 +883,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> @@ -925,13 +940,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> @@ -944,6 +967,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.51.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 6EC1DC32DE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Nov 2025 17:08:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0D3AA60A85;\n\tTue, 25 Nov 2025 18:08:34 +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 D40B5609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Nov 2025 18:08:32 +0100 (CET)","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 B7BA36AF;\n\tTue, 25 Nov 2025 18:06:23 +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=\"UtchkpZ0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764090383;\n\tbh=lD0xUmKx/E4zoUSH+JKg0zcdSxMBmW3/ipuZix8ktq8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=UtchkpZ0dMfcmafDUOPMgpyTyIsTv9gHvnwLgx6eEhFb2qk0yyDVPF/G9c6AdEWst\n\tVRMHdiv3W82X6Y6c5KhT+X+zjwnVx/RB/Au2rvZVOHofdptSVjMeFim9rIdwNw/VHi\n\t+BsE2IcJvYCPTqJDGlZBqK2F8gM6uX+1+7CT2pYs=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251125162851.2301793-13-stefan.klug@ideasonboard.com>","References":"<20251125162851.2301793-1-stefan.klug@ideasonboard.com>\n\t<20251125162851.2301793-13-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v3 12/29] libcamera: rkisp1: Scale down in dewarper\n\tinstead of resizer","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 25 Nov 2025 17:08:30 +0000","Message-ID":"<176409051012.567526.605859197824301198@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]