[{"id":16921,"web_url":"https://patchwork.libcamera.org/comment/16921/","msgid":"<CAHW6GYJu808XHF9i=sUdsfn9ZN3i2pvkUwfJf8pNJbDtSgz5Dg@mail.gmail.com>","date":"2021-05-12T16:07:13","subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline raspberrypi: Move adding\n\tof ScalerCrop to the Request metadata","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for this patch too. I have no particular comments - it seems\nlike a sensible little tidy-up.\n\nOn Wed, 12 May 2021 at 09:47, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\n> With the recent change to merge existing Request metadata with the\n> ControlList provided by the IPA in commit fcfb1dc02a6b (\"libcamera:\n> raspberry: Report sensor timestamp\"), we can now write the\n> controls::ScalerCrop value at the start of the pipeline instead of at\n> the end.\n>\n> This change simplifies the logic slightly, and allows us to write all\n> metadata items to the Request in one place.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nI've been testing this patch too along with the previous one, so:\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 32 +++++++------------\n>  1 file changed, 12 insertions(+), 20 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index eb6d31670567..0a71325ad7c0 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -140,7 +140,7 @@ public:\n>         RPiCameraData(PipelineHandler *pipe)\n>                 : CameraData(pipe), state_(State::Stopped),\n>                   supportsFlips_(false), flipsAlterBayerOrder_(false),\n> -                 updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0)\n> +                 dropFrameCount_(0), ispOutputCount_(0)\n>         {\n>         }\n>\n> @@ -214,7 +214,6 @@ public:\n>         CameraSensorInfo sensorInfo_;\n>         Rectangle ispCrop_; /* crop in ISP (camera mode) pixels */\n>         Rectangle scalerCrop_; /* crop in sensor native pixels */\n> -       bool updateScalerCrop_;\n>         Size ispMinCropSize_;\n>\n>         unsigned int dropFrameCount_;\n> @@ -1325,23 +1324,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n>         Request *request = requestQueue_.front();\n>         request->metadata().merge(controls);\n>\n> -       /*\n> -        * Also update the ScalerCrop in the metadata with what we actually\n> -        * used. But we must first rescale that from ISP (camera mode) pixels\n> -        * back into sensor native pixels.\n> -        *\n> -        * Sending this information on every frame may be helpful.\n> -        */\n> -       if (updateScalerCrop_) {\n> -               updateScalerCrop_ = false;\n> -               scalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),\n> -                                               sensorInfo_.outputSize);\n> -               scalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());\n> -       }\n> -       request->metadata().set(controls::ScalerCrop, scalerCrop_);\n> -\n>         state_ = State::IpaComplete;\n> -\n>         handleState();\n>  }\n>\n> @@ -1673,8 +1656,15 @@ void RPiCameraData::applyScalerCrop(const ControlList &controls)\n>                 if (ispCrop != ispCrop_) {\n>                         isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &ispCrop);\n>                         ispCrop_ = ispCrop;\n> -                       /* queueFrameAction will have to update its scalerCrop_ */\n> -                       updateScalerCrop_ = true;\n> +\n> +                       /*\n> +                        * Also update the ScalerCrop in the metadata with what we actually\n> +                        * used. But we must first rescale that from ISP (camera mode) pixels\n> +                        * back into sensor native pixels.\n> +                        */\n> +                       scalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),\n> +                                                       sensorInfo_.outputSize);\n> +                       scalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());\n>                 }\n>         }\n>  }\n> @@ -1684,6 +1674,8 @@ void RPiCameraData::fillRequestMetadata(const ControlList &bufferControls,\n>  {\n>         request->metadata().set(controls::SensorTimestamp,\n>                                 bufferControls.get(controls::SensorTimestamp));\n> +\n> +       request->metadata().set(controls::ScalerCrop, scalerCrop_);\n>  }\n>\n>  void RPiCameraData::tryRunPipeline()\n> --\n> 2.25.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 5D2D3C31E6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 12 May 2021 16:07:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CC5DE61538;\n\tWed, 12 May 2021 18:07:27 +0200 (CEST)","from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EC4D602B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 May 2021 18:07:26 +0200 (CEST)","by mail-wm1-x32f.google.com with SMTP id\n\tu5-20020a7bc0450000b02901480e40338bso3100918wmc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 May 2021 09:07:26 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Z2yzVaGX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=5t5MSHbKqSXZam9V7pJzJ1XnU65dhyEeW8Vfk29XRuI=;\n\tb=Z2yzVaGXmnohTHM94LhzqyZzEazqkTIzitDCLvbtkLIupqvYq4jMth/s4lIGvBPqtq\n\t7trnmQAjz0k0NFuwWb+6ohIlBuOuid0Ob510JGBWqAfMvHBF12v/xAa7Nt5EI1SasGmz\n\tc9/QHV88wSMq8nsKEf/O7WQBh9iV8Y2mTJUzDpn++ykCyYdnrjLvI5cqFztgoUU118kz\n\taQ5b+Wz62iv1AfnX/SCVGFo1+ftljVOnrhlDjQtpzlt3VLjvMEJ8opoL07ynh1AN6aen\n\t01lmv1qAzrn8uwNtsKkPPJXPpRps7JpJd1aziqGtcE7mdsqrt8XpD1VY06zAUEItluuA\n\tgHiQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=5t5MSHbKqSXZam9V7pJzJ1XnU65dhyEeW8Vfk29XRuI=;\n\tb=FSaJR+jkY8iSHigMzw5nFTD12Zzdzat8d6U3NInBq/4MMY8flbY6WUaIrvVQ1pammn\n\tgwjgbQVsu4nZ0ktCfsDTNO0A2MPXzgV4V+6E+4By+DVoiA0wg+P6PUnOnEs/S6kyBBIT\n\tjvm/Fl6HgJubhaKCrYRYyZ20XIMyZ6d/lU9qxSeAGHbuHIyG8cl07aZ/aayFbGtJslcY\n\t9t1t7y6Tw3YtWmYR5tZKqKeNd7NTX9ap8MFxjn3VyOMDEIafVWAnSZO0JTMfqZQtJcn+\n\tU0U83RiaI6KXbLhLHHfLFoKhRvvFXooKew+Osl0YT5Sx8ARxHNWDDJ/rbk2ba+nkIo7u\n\tA5+w==","X-Gm-Message-State":"AOAM53166fi9BSRfY6zHtR5WJD45ODYXggADAi0QKEL05a3oVizpOXAe\n\tOn+MlXp07c+/IRHyKD/2e47jDJgMyC6posf1mFqM5g==","X-Google-Smtp-Source":"ABdhPJz4PM7gAEu+jkzkcktLiJXFrtTwK9sYEkIISfj/1QOykG0jmRd4HZseuEoEdyMpUkI7zV5UeMHKma86/JOBi+M=","X-Received":"by 2002:a1c:a507:: with SMTP id\n\to7mr12514595wme.130.1620835645980; \n\tWed, 12 May 2021 09:07:25 -0700 (PDT)","MIME-Version":"1.0","References":"<20210512084744.1499469-1-naush@raspberrypi.com>\n\t<20210512084744.1499469-2-naush@raspberrypi.com>","In-Reply-To":"<20210512084744.1499469-2-naush@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Wed, 12 May 2021 17:07:13 +0100","Message-ID":"<CAHW6GYJu808XHF9i=sUdsfn9ZN3i2pvkUwfJf8pNJbDtSgz5Dg@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline raspberrypi: Move adding\n\tof ScalerCrop to the Request metadata","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16992,"web_url":"https://patchwork.libcamera.org/comment/16992/","msgid":"<f5386dfd-b4a0-0a0c-9780-0371e7817c95@ideasonboard.com>","date":"2021-05-17T12:43:14","subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline raspberrypi: Move adding\n\tof ScalerCrop to the Request metadata","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nOn 12/05/2021 09:47, Naushir Patuck wrote:\n> With the recent change to merge existing Request metadata with the\n> ControlList provided by the IPA in commit fcfb1dc02a6b (\"libcamera:\n> raspberry: Report sensor timestamp\"), we can now write the\n> controls::ScalerCrop value at the start of the pipeline instead of at\n> the end.\n> \n> This change simplifies the logic slightly, and allows us to write all\n> metadata items to the Request in one place.\n\nThat sounds nicer!\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 32 +++++++------------\n>  1 file changed, 12 insertions(+), 20 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index eb6d31670567..0a71325ad7c0 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -140,7 +140,7 @@ public:\n>  \tRPiCameraData(PipelineHandler *pipe)\n>  \t\t: CameraData(pipe), state_(State::Stopped),\n>  \t\t  supportsFlips_(false), flipsAlterBayerOrder_(false),\n> -\t\t  updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0)\n> +\t\t  dropFrameCount_(0), ispOutputCount_(0)\n>  \t{\n>  \t}\n>  \n> @@ -214,7 +214,6 @@ public:\n>  \tCameraSensorInfo sensorInfo_;\n>  \tRectangle ispCrop_; /* crop in ISP (camera mode) pixels */\n>  \tRectangle scalerCrop_; /* crop in sensor native pixels */\n> -\tbool updateScalerCrop_;\n>  \tSize ispMinCropSize_;\n>  \n>  \tunsigned int dropFrameCount_;\n> @@ -1325,23 +1324,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n>  \tRequest *request = requestQueue_.front();\n>  \trequest->metadata().merge(controls);\n>  \n> -\t/*\n> -\t * Also update the ScalerCrop in the metadata with what we actually\n> -\t * used. But we must first rescale that from ISP (camera mode) pixels\n> -\t * back into sensor native pixels.\n> -\t *\n> -\t * Sending this information on every frame may be helpful.\n> -\t */\n> -\tif (updateScalerCrop_) {\n> -\t\tupdateScalerCrop_ = false;\n> -\t\tscalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),\n> -\t\t\t\t\t\tsensorInfo_.outputSize);\n> -\t\tscalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());\n> -\t}\n> -\trequest->metadata().set(controls::ScalerCrop, scalerCrop_);\n> -\n>  \tstate_ = State::IpaComplete;\n> -\n>  \thandleState();\n>  }\n>  \n> @@ -1673,8 +1656,15 @@ void RPiCameraData::applyScalerCrop(const ControlList &controls)\n>  \t\tif (ispCrop != ispCrop_) {\n>  \t\t\tisp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &ispCrop);\n>  \t\t\tispCrop_ = ispCrop;\n> -\t\t\t/* queueFrameAction will have to update its scalerCrop_ */\n> -\t\t\tupdateScalerCrop_ = true;\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_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),\n> +\t\t\t\t\t\t\tsensorInfo_.outputSize);\n> +\t\t\tscalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());\n>  \t\t}\n>  \t}\n>  }\n> @@ -1684,6 +1674,8 @@ void RPiCameraData::fillRequestMetadata(const ControlList &bufferControls,\n>  {\n>  \trequest->metadata().set(controls::SensorTimestamp,\n>  \t\t\t\tbufferControls.get(controls::SensorTimestamp));\n> +\n> +\trequest->metadata().set(controls::ScalerCrop, scalerCrop_);\n>  }\n>  \n>  void RPiCameraData::tryRunPipeline()\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 66A0CC31FB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 May 2021 12:43:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D587B68918;\n\tMon, 17 May 2021 14:43:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D36A602C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 May 2021 14:43:18 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C03EE88F;\n\tMon, 17 May 2021 14:43:17 +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=\"vC7q9S80\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621255398;\n\tbh=sDqFAnzkWeYIT3qJOsWVVfErOFucbJE4E+kf9dHIiRY=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=vC7q9S80tMMhNScJWK725z93uclvRRB0qW09f+yi/9uSkdlEmImWZXMR/tyWg5s4S\n\tuEr7EbPbE3M/2iQmH3lzNoS6PnpmDHAcuTiNyoGF1fR+sWQMuxQ+0dayhyiVcb6Qw+\n\t0qSwK4vts3pKEpcQ5iXVECz/qh6ukNYr4doZxXfw=","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210512084744.1499469-1-naush@raspberrypi.com>\n\t<20210512084744.1499469-2-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Organization":"Ideas on Board","Message-ID":"<f5386dfd-b4a0-0a0c-9780-0371e7817c95@ideasonboard.com>","Date":"Mon, 17 May 2021 13:43:14 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.7.1","MIME-Version":"1.0","In-Reply-To":"<20210512084744.1499469-2-naush@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline raspberrypi: Move adding\n\tof ScalerCrop to the Request metadata","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>","Reply-To":"kieran.bingham@ideasonboard.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]