{"id":20159,"url":"https://patchwork.libcamera.org/api/1.1/patches/20159/?format=json","web_url":"https://patchwork.libcamera.org/patch/20159/","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":"<20240531052505.150921-2-umang.jain@ideasonboard.com>","date":"2024-05-31T05:25:02","name":"[v3,1/4] converter: converter_v4l2_m2m: Rectify streams sanity check","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5ec64924cb9eae0a03ea3daf4cdc27e8cfb2ee82","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20159/mbox/","series":[{"id":4343,"url":"https://patchwork.libcamera.org/api/1.1/series/4343/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4343","date":"2024-05-31T05:25:01","name":"libcamera: converter: Replace usage of stream index by Stream pointer","version":3,"mbox":"https://patchwork.libcamera.org/series/4343/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20159/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20159/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 081BCBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 05:25:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ACB22634BA;\n\tFri, 31 May 2024 07:25:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BAF2634AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 07:25:18 +0200 (CEST)","from fedora.local (unknown\n\t[IPv6:2409:4056:ecf:2c0c:629d:1df6:d7ca:cb53])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A0C38E22;\n\tFri, 31 May 2024 07:25:11 +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=\"JWGUl2Z9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717133113;\n\tbh=KljAcoauDhQh5SXtUaCy5unCijNv6v91D/evORqfcq8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JWGUl2Z9eTBwkfSiXtIsFsuAI92+EGe4t2zWz0k0r1RUDmdMnQc/vmydQSHbcndOG\n\tEkUAnB27uWENgcW5xrh/PNLnKJL7509uRgwy2T8klFp1Tg13en2fq9PUMh+fQhn1zZ\n\tyD5rR65vj0hnXUd9pdmnAjKKZs/osChgFvxod2XM=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH v3 1/4] converter: converter_v4l2_m2m: Rectify streams sanity\n\tcheck","Date":"Fri, 31 May 2024 10:55:02 +0530","Message-ID":"<20240531052505.150921-2-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.44.0","In-Reply-To":"<20240531052505.150921-1-umang.jain@ideasonboard.com>","References":"<20240531052505.150921-1-umang.jain@ideasonboard.com>","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":"The streams sanity check tries to determine if all the stream indexes\npassed in outputs std::map<> are unique. However, since the data\ncontainer is std::map<>, all its keys (stream indexes in this case),\nare already unique.\n\nInstead, rectify the sanity check to ensure all the framebuffers passed\nin the outputs std::map<> are unique to each index. Hence, no two stream\nindexes should have same framebuffer. Update the comment to reflect\nthe change.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/converter/converter_v4l2_m2m.cpp | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)","diff":"diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp\nindex d8929fc5..27a50e34 100644\n--- a/src/libcamera/converter/converter_v4l2_m2m.cpp\n+++ b/src/libcamera/converter/converter_v4l2_m2m.cpp\n@@ -403,13 +403,13 @@ void V4L2M2MConverter::stop()\n int V4L2M2MConverter::queueBuffers(FrameBuffer *input,\n \t\t\t\t   const std::map<unsigned int, FrameBuffer *> &outputs)\n {\n-\tunsigned int mask = 0;\n+\tstd::set<FrameBuffer *> outputBufs;\n \tint ret;\n \n \t/*\n \t * Validate the outputs as a sanity check: at least one output is\n \t * required, all outputs must reference a valid stream and no two\n-\t * outputs can reference the same stream.\n+\t * streams can reference same output framebuffers.\n \t */\n \tif (outputs.empty())\n \t\treturn -EINVAL;\n@@ -419,12 +419,13 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input,\n \t\t\treturn -EINVAL;\n \t\tif (index >= streams_.size())\n \t\t\treturn -EINVAL;\n-\t\tif (mask & (1 << index))\n-\t\t\treturn -EINVAL;\n \n-\t\tmask |= 1 << index;\n+\t\toutputBufs.insert(buffer);\n \t}\n \n+\tif (outputBufs.size() != streams_.size())\n+\t\treturn -EINVAL;\n+\n \t/* Queue the input and output buffers to all the streams. */\n \tfor (auto [index, buffer] : outputs) {\n \t\tret = streams_[index].queueBuffers(input, buffer);\n","prefixes":["v3","1/4"]}