{"id":12252,"url":"https://patchwork.libcamera.org/api/1.1/patches/12252/?format=json","web_url":"https://patchwork.libcamera.org/patch/12252/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210512084744.1499469-2-naush@raspberrypi.com>","date":"2021-05-12T08:47:44","name":"[libcamera-devel,2/2] pipeline raspberrypi: Move adding of ScalerCrop to the Request metadata","commit_ref":"d832e9622e69f88986c2b5a3ea836238b860e0f7","pull_url":null,"state":"accepted","archived":false,"hash":"258d72bd35397b2274e1ecf5bc7fb78833a7a25a","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12252/mbox/","series":[{"id":2019,"url":"https://patchwork.libcamera.org/api/1.1/series/2019/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2019","date":"2021-05-12T08:47:43","name":"[libcamera-devel,1/2] pipeline: raspberrypi: Store timestamp in the correct Request metadata","version":1,"mbox":"https://patchwork.libcamera.org/series/2019/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12252/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12252/checks/","tags":{},"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 5425AC31E5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 12 May 2021 08:47:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7C9786891A;\n\tWed, 12 May 2021 10:47:51 +0200 (CEST)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39A7F688E4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 May 2021 10:47:50 +0200 (CEST)","by mail-wm1-x32c.google.com with SMTP id\n\tn17-20020a7bc5d10000b0290169edfadac9so2071988wmk.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 May 2021 01:47:50 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:d29a:cbe2:1c54:7a47])\n\tby smtp.gmail.com with ESMTPSA id\n\td3sm16370759wrs.41.2021.05.12.01.47.49\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 12 May 2021 01:47:49 -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=\"Ew0OSv96\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=5g00rQh09hp0CWGm/UKrsjSeTYX4ad+gKpUJXc2JwTg=;\n\tb=Ew0OSv96vkD49OuMk7NUuzeMMlQVIUy+GhLiLZKwI0ygWoa0NcdkBbMpT+GrON7JaX\n\tXA90hOwX4OqT+8Tv+5/v9Jt7ItNgk4zpcmoW1tpjeNmXB5Uacey5ZYziLSz3aQumHgYs\n\tA7MShhGhztpsIOMg5sbqSBosokoG2mi3upv4fEhbUJ/zkYVs5OEpiAZ2zUEVeuaGYT9P\n\t+GtNBw5vh4jDIdGEdPswVY4YgrZxdN1/xuo99kQdyxlWnbuqraTk1eYZi3iNcgyapO2f\n\tXglpJcqOgM4nNjsS3u14qljpowsh201EazrwC5Vu2WfS9/X5zXMjWtUWY0FG40bO8/JB\n\t5oPQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=5g00rQh09hp0CWGm/UKrsjSeTYX4ad+gKpUJXc2JwTg=;\n\tb=eAh/dPra+nZMOeEP7+Ktc57Lcf8amNSWB8AuL6DeElqgJiIbnpJOefnf0o3lulvoGs\n\t2PtrXPc2qkn+v+Um37Jbimh1UcOsF3mAAfuhlllL3XCsGwPYP2+q8EPQ7VgKj844pxC0\n\tFYQClBsuKh1CP9Jy39XwaD+8vX5tWRbCz9GQNATbmrQGr93eV7nOa8MTpwaKEwh1myGM\n\tPzhp5Fk1A2aVV4KqdYJCp6JD03kVZ014N7x4Y0a7WyxYolt3o+o1LogsgX/XCOjULU0j\n\tNFv+knJKO2rqj1FU62KyCG7EELhcVZkFwc+HWgjk6WtFL4pxbpA8btsMHfFf1Ps5ALsH\n\tzZQg==","X-Gm-Message-State":"AOAM530E7SjEBagXKsxsmqi48Kr83ySC5MsHLy0JKVBSkIlh/Q9/9Y//\n\tu0p7FRrE7z4Wf6r6KZs0MEh1kvjn0/JszA==","X-Google-Smtp-Source":"ABdhPJwCFVEZD9K/rmL8YV7O+ENd1EzlGU6NCl97ArUM80FzW8HMSjPzIALXlF8xVuPJLJsCVpnBTQ==","X-Received":"by 2002:a1c:750b:: with SMTP id\n\to11mr10357862wmc.188.1620809269709; \n\tWed, 12 May 2021 01:47:49 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 12 May 2021 09:47:44 +0100","Message-Id":"<20210512084744.1499469-2-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210512084744.1499469-1-naush@raspberrypi.com>","References":"<20210512084744.1499469-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 2/2] pipeline raspberrypi: Move adding of\n\tScalerCrop 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>","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>"},"content":"With the recent change to merge existing Request metadata with the\nControlList provided by the IPA in commit fcfb1dc02a6b (\"libcamera:\nraspberry: Report sensor timestamp\"), we can now write the\ncontrols::ScalerCrop value at the start of the pipeline instead of at\nthe end.\n\nThis change simplifies the logic slightly, and allows us to write all\nmetadata items to the Request in one place.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 32 +++++++------------\n 1 file changed, 12 insertions(+), 20 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 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","prefixes":["libcamera-devel","2/2"]}