[{"id":26217,"web_url":"https://patchwork.libcamera.org/comment/26217/","msgid":"<CAEmqJPpKRMG5oTg_VtV8RU=gBZcuMnPc3yDJ=b4=OftyX6RsEQ@mail.gmail.com>","date":"2023-01-12T11:25:56","subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Improve the\n\tvalues reported in the ScalerCrop control","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThank you for this fix!\n\nOn Thu, 12 Jan 2023 at 11:06, David Plowman via libcamera-devel <\nlibcamera-devel@lists.libcamera.org> wrote:\n\n> Previously the x,y offsets in the min/max ScalerCrop control values\n> were zero. Here we make them the same as the sensor's analogue crop\n> offset which is I think less misleading.\n>\n> With this change, it also seems reasonable to advertise the default\n> scaler crop value to be the true default that you will get. This makes\n> it possible for applications to see what that value will be without\n> having to start the camera and wait for frames.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 8569df17..809af4d2 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -905,6 +905,7 @@ int PipelineHandlerRPi::configure(Camera *camera,\n> CameraConfiguration *config)\n>         /* Adjust aspect ratio by providing crops on the input image. */\n>         Size size = unicamFormat.size.boundedToAspectRatio(maxSize);\n>         Rectangle crop =\n> size.centeredTo(Rectangle(unicamFormat.size).center());\n> +       Rectangle defaultCrop = crop;\n>         data->ispCrop_ = crop;\n>\n>         data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP,\n> &crop);\n> @@ -958,9 +959,9 @@ int PipelineHandlerRPi::configure(Camera *camera,\n> CameraConfiguration *config)\n>                 ctrlMap.emplace(c.first, c.second);\n>\n>         /* Add the ScalerCrop control limits based on the current mode. */\n> -       Rectangle ispMinCrop(data->ispMinCropSize_);\n> -       ispMinCrop.scaleBy(data->sensorInfo_.analogCrop.size(),\n> data->sensorInfo_.outputSize);\n> -       ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop,\n> Rectangle(data->sensorInfo_.analogCrop.size()));\n> +       Rectangle ispMinCrop =\n> data->scaleIspCrop(Rectangle(data->ispMinCropSize_));\n> +       defaultCrop = data->scaleIspCrop(defaultCrop);\n> +       ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop,\n> data->sensorInfo_.analogCrop, defaultCrop);\n>\n>         data->controlInfo_ = ControlInfoMap(std::move(ctrlMap),\n> result.controlInfo.idmap());\n>\n> --\n> 2.30.2\n>\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 8290BC3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Jan 2023 11:26:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D3EDD625DE;\n\tThu, 12 Jan 2023 12:26:15 +0100 (CET)","from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com\n\t[IPv6:2607:f8b0:4864:20::1131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A38A61F05\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jan 2023 12:26:14 +0100 (CET)","by mail-yw1-x1131.google.com with SMTP id\n\t00721157ae682-4a263c4ddbaso235279227b3.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jan 2023 03:26:13 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1673522775;\n\tbh=4ytxZBaDYJFfKMrqFreZ1bVfG43D8nyRKNJgyCUv5xo=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=TicO7SZzn3b826Ah1PgiDquhcSamDCkMKy+cityLS7quwxrG0ZxB9dkiLK/sxfOEH\n\tz1c0UWmSWv3dIywLn7pgsHtS/mV4ixRKa79K/QTMlqQXOBto5L+eFIiek2r8VS2Wrw\n\tgXutysp7eLCH3Kc0fDzSXHG2/z4fBdaX22Q18dfcfFz/eF5nJNqdA1VbvD9cRjErOC\n\tw7/0iVKzPmeoxZRF06sp5YUjkxDldx5MB5+m7mKjSYwkRdJM+ojHdfft1vJ6uioEcu\n\tXvnNGugRubfVsTRormHqD8m/N1XMMRdK5Y73rDNex0xbkIhiQ3omO0Tc4SjCKZ3AUY\n\thIHHkapZAMiRQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=JgU+yFZrE3ExZ812HBIh+mTpfFr8oeRgxBEjcBiVHos=;\n\tb=LXojwWzYIxuSXvxOCuSGQkpQI+PCeRYBOuXZBOo57gWV7AoP3bFjzLetTfpV3JnINl\n\t9kjeeqCEnuE1o8rtcNMnqZQnXtHUEaqqEQcvXB0K23Kdl9bgcKbsWnprSNoOOWxhzXVY\n\tH5VVlmgRdhoV2JhrciVH4ZjcxklD91D0iFw2WL1Zha8q8f55j0d7Xjx/wbNxR8HOF+ka\n\tZtwDz6zczCPW6pA4OGF0jC/czVh858KQe7Jpdq63uHy8Oj0pkIujqs6rnbCYF37wWt0m\n\tBEyFTwCcowNPUtQTj9wCMgoHQ5BxWx7h5W/Zzl0VByM0mSbppGSiWkNI4tjQDI8V4BFI\n\tFlPQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"LXojwWzY\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=JgU+yFZrE3ExZ812HBIh+mTpfFr8oeRgxBEjcBiVHos=;\n\tb=o2JIJmZ7Dh9koZTgYxM2gKqB05GiAT9Z5UK6RRueRD4qXRFZQIq2VRZH0WQB3G3gob\n\t36ngaKen7FDrhq0B9btdxFlmG46tg9NV23LBUsGdHxz79ZtE0abH229OPm1eBLmAf8Nn\n\t5jRrweARQIHUJTF6zX7sCgZu3Q0ZDu5/eBuP6hWGEor0jLyViNo8swchShqBv0awwhtI\n\txXX6KlyICavMDGKa4ZglODqZomHAVmhgTVM3RBJf8pouWmiG91rsZz3kDwKhzI90cant\n\tEtG2ntT9W7iTsoDyqILfLcTLdCKmBBMLgFO5eTXMeVoWV/wqj2zgZB1H7EEofDFd4FZA\n\tmmdA==","X-Gm-Message-State":"AFqh2kqUkkeL15R3pewQheZGxFC9GqAgOvLkEIk3uAQxoSH2CK423aWH\n\te4iPcTK2/LoN+P6lWAxnCgGxtgbCK1NybYOs91OW+kawRaOR2fZI","X-Google-Smtp-Source":"AMrXdXuQmBjJbD8G52gLqelWYfPgPwawSxDBFiIxHazsL98T6Z5686BqzNmxs6kQXoswyxG7/P5arpwkz+0zNzgD8E8=","X-Received":"by 2002:a81:8101:0:b0:38e:b5bc:e996 with SMTP id\n\tr1-20020a818101000000b0038eb5bce996mr3105583ywf.493.1673522772881;\n\tThu, 12 Jan 2023 03:26:12 -0800 (PST)","MIME-Version":"1.0","References":"<20230112110633.25329-1-david.plowman@raspberrypi.com>","In-Reply-To":"<20230112110633.25329-1-david.plowman@raspberrypi.com>","Date":"Thu, 12 Jan 2023 11:25:56 +0000","Message-ID":"<CAEmqJPpKRMG5oTg_VtV8RU=gBZcuMnPc3yDJ=b4=OftyX6RsEQ@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"00000000000066c88e05f20f624d\"","Subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Improve the\n\tvalues reported in the ScalerCrop control","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26219,"web_url":"https://patchwork.libcamera.org/comment/26219/","msgid":"<20230112160414.vpeikt5futjhnwpy@uno.localdomain>","date":"2023-01-12T16:04:14","subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Improve the\n\tvalues reported in the ScalerCrop control","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi David\n\nOn Thu, Jan 12, 2023 at 11:06:33AM +0000, David Plowman via libcamera-devel wrote:\n> Previously the x,y offsets in the min/max ScalerCrop control values\n> were zero. Here we make them the same as the sensor's analogue crop\n> offset which is I think less misleading.\n\nThis matches the definition of CameraSensorInfo::analogueCrop and\ncontrols::ScalerCrop, as they're both defined relatively to the active\narea size\n\n  - ScalerCrop:\n      type: Rectangle\n      description: |\n        Sets the image portion that will be scaled to form the whole of\n        the final output image. The (x,y) location of this rectangle is\n        relative to the PixelArrayActiveAreas that is being used. The units\n/**\n * \\var IPACameraSensorInfo::analogCrop\n * \\brief The portion of the pixel array active area which is read-out and\n * processed\n *\n * The analog crop rectangle top-left corner is defined as the displacement\n * from the top-left corner of the pixel array active area. The rectangle\n\n\n>\n> With this change, it also seems reasonable to advertise the default\n> scaler crop value to be the true default that you will get. This makes\n> it possible for applications to see what that value will be without\n> having to start the camera and wait for frames.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 8569df17..809af4d2 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -905,6 +905,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \t/* Adjust aspect ratio by providing crops on the input image. */\n>  \tSize size = unicamFormat.size.boundedToAspectRatio(maxSize);\n>  \tRectangle crop = size.centeredTo(Rectangle(unicamFormat.size).center());\n> +\tRectangle defaultCrop = crop;\n>  \tdata->ispCrop_ = crop;\n>\n>  \tdata->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop);\n> @@ -958,9 +959,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \t\tctrlMap.emplace(c.first, c.second);\n>\n>  \t/* Add the ScalerCrop control limits based on the current mode. */\n> -\tRectangle ispMinCrop(data->ispMinCropSize_);\n> -\tispMinCrop.scaleBy(data->sensorInfo_.analogCrop.size(), data->sensorInfo_.outputSize);\n> -\tctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, Rectangle(data->sensorInfo_.analogCrop.size()));\n> +\tRectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->ispMinCropSize_));\n> +\tdefaultCrop = data->scaleIspCrop(defaultCrop);\n> +\tctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, defaultCrop);\n>\n>  \tdata->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap());\n>\n> --\n> 2.30.2\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 3494CC3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Jan 2023 16:04:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A40D1625CF;\n\tThu, 12 Jan 2023 17:04:20 +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 C15DE61F05\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jan 2023 17:04:18 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 45843505;\n\tThu, 12 Jan 2023 17:04:18 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1673539460;\n\tbh=0yc36Xyb5No4DmeRg5C0DxIbZz1j014JXFJWBVJd9aU=;\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=pYwzF1bgxrA8RC/VjDgYCr09Jvx1dZu9rTEYUhLsFEZbL5OsP+JLUJKYaGcSRJ1+a\n\tz5inP0dh76BAZao7Jo1bPwL+/4AKUR+rELqC+e/M0xkk5dUYWxpzX/Iy4I1MIZcY/8\n\tNaVxX2yLiGhD5sgyINKKrTaayeXKZbBfh8vuQfoZtnuVk3ycmTcqSuyclWfuZZUTNR\n\tswFEkY2c9R8yxLmoNy6jV8jalUWpyyusaHSFtpQZsZS+lRUdMb1JM1gcyckcqr3Ctx\n\tLXpDHFffjwaaVr8o8dkXgh93n2WJQabxPVJg4LmIQRa2d5JeIMrKZ8oKgYokzVyrkM\n\t/g5VmtofWdvsw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1673539458;\n\tbh=0yc36Xyb5No4DmeRg5C0DxIbZz1j014JXFJWBVJd9aU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lIY/du3aM+lGOIaxp+/inJuCoqkatNiFyinJ3/cbq1L1JIX+idyE7LgLUgXfWk4en\n\tuf+28Fk8dF2kdD6q1Tm7ChsZIwHhqTRqiJX0WGGrTKmr18OLmrvxIBY8CiBWtZVJ1+\n\tOzoVoyXGLdGCNv3bfoH+Fx/+zqRcfIDa46Q5pvdI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lIY/du3a\"; dkim-atps=neutral","Date":"Thu, 12 Jan 2023 17:04:14 +0100","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20230112160414.vpeikt5futjhnwpy@uno.localdomain>","References":"<20230112110633.25329-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230112110633.25329-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Improve the\n\tvalues reported in the ScalerCrop control","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]