{"id":20113,"url":"https://patchwork.libcamera.org/api/patches/20113/?format=json","web_url":"https://patchwork.libcamera.org/patch/20113/","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":"<20240529070248.12186-2-umang.jain@ideasonboard.com>","date":"2024-05-29T07:02:45","name":"[v2,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/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20113/mbox/","series":[{"id":4331,"url":"https://patchwork.libcamera.org/api/series/4331/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4331","date":"2024-05-29T07:02:44","name":"libcamera: converter: Replace usage of stream index by Stream pointer","version":2,"mbox":"https://patchwork.libcamera.org/series/4331/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20113/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20113/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 228E2C32C8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 May 2024 07:03:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9813F634BA;\n\tWed, 29 May 2024 09:03:02 +0200 (CEST)","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 7C8C0634AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 09:03:00 +0200 (CEST)","from fedora.local (unknown\n\t[IPv6:2409:4055:4e99:4251:f523:b915:4362:f847])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 17E679CA;\n\tWed, 29 May 2024 09:02:54 +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=\"LP/6rDv5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716966176;\n\tbh=GC99GjfrGOhwcxJunZtbPRcrQLC5zB+LHdEY4NV6QyQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=LP/6rDv5YNilvQzXlA4YdE/fOSFyWbHBaTlNNmYNEEpJp46vXR0baYdrJANFGXnV/\n\t77scIGdMGDUMVuDXPgwpL19lrYj/54A9BLVTwZy1Bi5qwVN8IATCKbbUgm0juwhcAL\n\tQzGj55kbt/9OeeXRJq7WqXHBBcR26VcJ3theZnmk=","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>","Subject":"[PATCH v2 1/4] converter: converter_v4l2_m2m: Rectify streams sanity\n\tcheck","Date":"Wed, 29 May 2024 12:32:45 +0530","Message-ID":"<20240529070248.12186-2-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.44.0","In-Reply-To":"<20240529070248.12186-1-umang.jain@ideasonboard.com>","References":"<20240529070248.12186-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>\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":["v2","1/4"]}