[{"id":31475,"web_url":"https://patchwork.libcamera.org/comment/31475/","msgid":"<yubm5kdmygg2odmvg2pjs76z2vztrxvkvnwxggonjcetwdszpo@rryzjzcm52gi>","date":"2024-10-01T06:14:10","subject":"Re: [PATCH v2 2/7] pipeline: rpi: Remove CameraData::scalerCrop_","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Mon, Sep 30, 2024 at 03:14:10PM GMT, Naushir Patuck wrote:\n> Do not cache the scalerCrop_ parameter. The cached value is used to\n> update the request metadata, but since this is not an expensive\n> operation (and can only occur once per frame), caching it is of limited\n> value.\n>\n> This will simplify logic in a future commit where we can specify a\n> crop per-output stream.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n> ---\n>  .../pipeline/rpi/common/pipeline_base.cpp      | 18 +++---------------\n>  .../pipeline/rpi/common/pipeline_base.h        |  1 -\n>  2 files changed, 3 insertions(+), 16 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> index 3041fd1ed9fd..11f1bfd4a5da 100644\n> --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> @@ -544,12 +544,6 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n>  \t\treturn ret;\n>  \t}\n>\n> -\t/*\n> -\t * Set the scaler crop to the value we are using (scaled to native sensor\n> -\t * coordinates).\n> -\t */\n> -\tdata->scalerCrop_ = data->scaleIspCrop(data->ispCrop_);\n> -\n>  \t/*\n>  \t * Update the ScalerCropMaximum to the correct value for this camera mode.\n>  \t * For us, it's the same as the \"analogue crop\".\n> @@ -569,7 +563,8 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n>\n>  \t/* Add the ScalerCrop control limits based on the current mode. */\n>  \tRectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->ispMinCropSize_));\n> -\tctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, data->scalerCrop_);\n> +\tctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop,\n> +\t\t\t\t\t\t     data->scaleIspCrop(data->ispCrop_));\n>\n>  \tdata->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap());\n>\n> @@ -1320,13 +1315,6 @@ void CameraData::applyScalerCrop(const ControlList &controls)\n>  \t\tif (ispCrop != ispCrop_) {\n>  \t\t\tispCrop_ = ispCrop;\n>  \t\t\tplatformSetIspCrop();\n> -\n> -\t\t\t/*\n> -\t\t\t * Also update the ScalerCrop in the metadata with what we actually\n> -\t\t\t * used. But we must first rescale that from ISP (camera mode) pixels\n> -\t\t\t * back into sensor native pixels.\n> -\t\t\t */\n> -\t\t\tscalerCrop_ = scaleIspCrop(ispCrop_);\n>  \t\t}\n>  \t}\n>  }\n> @@ -1483,7 +1471,7 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request\n>  \trequest->metadata().set(controls::SensorTimestamp,\n>  \t\t\t\tbufferControls.get(controls::SensorTimestamp).value_or(0));\n>\n> -\trequest->metadata().set(controls::ScalerCrop, scalerCrop_);\n> +\trequest->metadata().set(controls::ScalerCrop, scaleIspCrop(ispCrop_));\n>  }\n>\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h\n> index f9cecf70f179..5161c16e518f 100644\n> --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h\n> +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h\n> @@ -134,7 +134,6 @@ public:\n>  \t/* For handling digital zoom. */\n>  \tIPACameraSensorInfo sensorInfo_;\n>  \tRectangle ispCrop_; /* crop in ISP (camera mode) pixels */\n> -\tRectangle scalerCrop_; /* crop in sensor native pixels */\n>  \tSize ispMinCropSize_;\n>\n>  \tunsigned int dropFrameCount_;\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 F271EBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Oct 2024 06:14:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F7626350E;\n\tTue,  1 Oct 2024 08:14:16 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A0E7E62C91\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Oct 2024 08:14:14 +0200 (CEST)","from ideasonboard.com (unknown [5.179.150.95])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C770A2E3;\n\tTue,  1 Oct 2024 08:12:42 +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=\"gFyBxdWV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727763163;\n\tbh=BdPXBnzTvbbJBe4o5lUAwX4lLeJpFlOkiVlJHZ0Z3bU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gFyBxdWVlU/O2W7h6x+3EJZzjInTY32VNv2wqMflBXRuzOe36OXvgeWtCUD414eFu\n\tRamDdl7ezN5vugy96aNHKqwdpI8J2YPUCPUBnvJYyOL0X/DV+EgrCYUykox5dsQFYs\n\tqWIGWn/Mmzhxh0sHogb8yiw+8sLeNloOLAjtYoHs=","Date":"Tue, 1 Oct 2024 08:14:10 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH v2 2/7] pipeline: rpi: Remove CameraData::scalerCrop_","Message-ID":"<yubm5kdmygg2odmvg2pjs76z2vztrxvkvnwxggonjcetwdszpo@rryzjzcm52gi>","References":"<20240930141415.8857-1-naush@raspberrypi.com>\n\t<20240930141415.8857-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240930141415.8857-3-naush@raspberrypi.com>","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>"}}]