{"id":22312,"url":"https://patchwork.libcamera.org/api/patches/22312/?format=json","web_url":"https://patchwork.libcamera.org/patch/22312/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20241213094551.74584-3-stefan.klug@ideasonboard.com>","date":"2024-12-13T09:26:05","name":"[v3.1] fixup! libcamera: converter_v4l2_m2m: Improve crop bounds support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a0f507947e805e4f89856a49fc6964e3c5c09ba5","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22312/mbox/","series":[{"id":4882,"url":"https://patchwork.libcamera.org/api/series/4882/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4882","date":"2024-12-13T09:26:05","name":"[v3.1] fixup! libcamera: converter_v4l2_m2m: Improve crop bounds support","version":1,"mbox":"https://patchwork.libcamera.org/series/4882/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22312/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22312/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 DC4E2C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Dec 2024 09:48:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7553367EE6;\n\tFri, 13 Dec 2024 10:48:10 +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 88114618AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Dec 2024 10:48:08 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:4f4b:687b:9f5f:1d0d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 32114520;\n\tFri, 13 Dec 2024 10:47:34 +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=\"lyVMKkw1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734083254;\n\tbh=0+bmhJNxQFPVdA7EFrxpol2cl/jo5rQKnmKaDbHRyYQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lyVMKkw15LcxZfww0vKIKa+nKRjQSwJZakw572oDf5LXxcdYP7xXV1JCdTtaqzA0F\n\tPF5sN0R/xSOAL5v4QCz1+xN4uRgOhLsRpOOhHEgAGta8gIPL+kPCWesgibZvDAb3/N\n\t+VnIWftivJsIb/WsceFtI/r71AKde3YYXCcn5Hsc=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v3.1] fixup! libcamera: converter_v4l2_m2m: Improve crop\n\tbounds support","Date":"Fri, 13 Dec 2024 10:26:05 +0100","Message-ID":"<20241213094551.74584-3-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<ngyxzkzfv4ozhepcfe74pdinudgruelldfolfs4hdz7stetil3@d5t2cfqkbemv>","References":"<ngyxzkzfv4ozhepcfe74pdinudgruelldfolfs4hdz7stetil3@d5t2cfqkbemv>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"Changes semantics of inputCropBounds to return null bounds if an\nunconfigured stream is provided. Return the device crop bounds if a\nnullptr is provided.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n\nHi Jacopo,\n\nI forgot to handle your comment in the v3. Sorry for that. This is my\nproposal. It is somewhere in the middle of your suggestions, but I think\nit makes the intent clearer.\n\nI would like to keep the getCropBound() a static function as we\ndiscussed before.\n\nThe commit message will also be updated for v4.\n\nIs this change ok for you?\n\nBest regards,\nStefan\n\n include/libcamera/internal/converter.h        |  4 +++-\n .../internal/converter/converter_v4l2_m2m.h   |  1 +\n src/libcamera/converter.cpp                   | 12 +++++++++++-\n .../converter/converter_v4l2_m2m.cpp          | 19 ++++++++++++++++---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  6 +++++-\n 5 files changed, 36 insertions(+), 6 deletions(-)","diff":"diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h\nindex 9213ae5b9c33..465b0b0596d9 100644\n--- a/include/libcamera/internal/converter.h\n+++ b/include/libcamera/internal/converter.h\n@@ -73,6 +73,7 @@ public:\n \n \tvirtual int configure(const StreamConfiguration &inputCfg,\n \t\t\t      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;\n+\tvirtual bool isConfigured(const Stream *stream) const = 0;\n \tvirtual int exportBuffers(const Stream *stream, unsigned int count,\n \t\t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n \n@@ -83,7 +84,8 @@ public:\n \t\t\t\t const std::map<const Stream *, FrameBuffer *> &outputs) = 0;\n \n \tvirtual int setInputCrop(const Stream *stream, Rectangle *rect) = 0;\n-\tvirtual std::pair<Rectangle, Rectangle> inputCropBounds(const Stream *stream) = 0;\n+\tvirtual std::pair<Rectangle, Rectangle> inputCropBounds(\n+\t\t\t\tconst Stream *stream = nullptr) = 0;\n \n \tSignal<FrameBuffer *> inputBufferReady;\n \tSignal<FrameBuffer *> outputBufferReady;\ndiff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h\nindex 89bd2878b190..175f0e1109a6 100644\n--- a/include/libcamera/internal/converter/converter_v4l2_m2m.h\n+++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h\n@@ -54,6 +54,7 @@ public:\n \n \tint configure(const StreamConfiguration &inputCfg,\n \t\t      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfg);\n+\tbool isConfigured(const Stream *stream) const override;\n \tint exportBuffers(const Stream *stream, unsigned int count,\n \t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \ndiff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp\nindex c3da162b7de7..74cea46cc709 100644\n--- a/src/libcamera/converter.cpp\n+++ b/src/libcamera/converter.cpp\n@@ -169,6 +169,13 @@ Converter::~Converter()\n  * \\return 0 on success or a negative error code otherwise\n  */\n \n+/**\n+ * \\fn Converter::isConfigured()\n+ * \\brief Check if a given stream is configured\n+ * \\param[in] stream The output stream\n+ * \\return True if the \\a stream is configured or false otherwise\n+ */\n+\n /**\n  * \\fn Converter::exportBuffers()\n  * \\brief Export buffers from the converter device\n@@ -238,9 +245,12 @@ Converter::~Converter()\n  * this function should be called after the \\a stream has been configured using\n  * configure().\n  *\n- * When called with an invalid \\a stream, the function returns the default crop\n+ * When called with nullptr \\a stream this function returns the default crop\n  * bounds of the converter.\n  *\n+ * When called with an invalid \\a stream, this function returns a pair of null\n+ * rectangles\n+ *\n  * \\return A pair containing the minimum and maximum crop bound in that order\n  */\n \ndiff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp\nindex 6857472b29f2..4df253749feb 100644\n--- a/src/libcamera/converter/converter_v4l2_m2m.cpp\n+++ b/src/libcamera/converter/converter_v4l2_m2m.cpp\n@@ -559,6 +559,14 @@ int V4L2M2MConverter::configure(const StreamConfiguration &inputCfg,\n \treturn 0;\n }\n \n+/**\n+ * \\copydoc libcamera::Converter::isConfigured\n+ */\n+bool V4L2M2MConverter::isConfigured(const Stream *stream) const\n+{\n+\treturn streams_.find(stream) != streams_.end();\n+}\n+\n /**\n  * \\copydoc libcamera::Converter::exportBuffers\n  */\n@@ -595,11 +603,16 @@ int V4L2M2MConverter::setInputCrop(const Stream *stream, Rectangle *rect)\n std::pair<Rectangle, Rectangle>\n V4L2M2MConverter::inputCropBounds(const Stream *stream)\n {\n+\tif (stream == nullptr)\n+\t\treturn inputCropBounds_;\n+\n \tauto iter = streams_.find(stream);\n-\tif (iter != streams_.end())\n-\t\treturn iter->second->inputCropBounds();\n+\tif (iter == streams_.end()) {\n+\t\tLOG(Converter, Error) << \"Invalid output stream\";\n+\t\treturn {};\n+\t}\n \n-\treturn inputCropBounds_;\n+\treturn iter->second->inputCropBounds();\n }\n \n /**\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 4dcc5a4fa6a1..ad162164df1a 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -1281,8 +1281,12 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data)\n \tControlInfoMap::Map controls;\n \n \tif (dewarper_) {\n+\t\tconst Stream *stream = nullptr;\n+\t\tif (dewarper_->isConfigured(&data->mainPathStream_))\n+\t\t\tstream = &data->mainPathStream_;\n+\n \t\tstd::pair<Rectangle, Rectangle> cropLimits =\n-\t\t\tdewarper_->inputCropBounds(&data->mainPathStream_);\n+\t\t\tdewarper_->inputCropBounds(stream);\n \n \t\t/*\n \t\t * ScalerCrop is specified to be in Sensor coordinates.\n","prefixes":["v3.1"]}