[{"id":30206,"web_url":"https://patchwork.libcamera.org/comment/30206/","msgid":"<ZoPctaKqLiyjbYz6@pyrite.rasen.tech>","date":"2024-07-02T10:55:49","subject":"Re: [PATCH v4 1/4] converter: converter_v4l2_m2m: Rectify streams\n\tsanity check","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Mon, Jun 24, 2024 at 07:18:56PM +0530, Umang Jain wrote:\n> The streams sanity check tries to determine if all the stream indexes\n> passed in outputs std::map<> are unique. However, since the data\n> container is std::map<>, all its keys (stream indexes in this case),\n> are already unique.\n> \n> Instead, rectify the sanity check to ensure all the framebuffers passed\n> in the outputs std::map<> are unique to each index. Hence, no two stream\n> indexes should have same framebuffer. Update the comment to reflect\n> the change.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/converter/converter_v4l2_m2m.cpp | 11 ++++++-----\n>  1 file changed, 6 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp\n> index 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> -- \n> 2.44.0\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 8C478BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Jul 2024 10:55:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F9A562E24;\n\tTue,  2 Jul 2024 12:55:57 +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 ED93D62C96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jul 2024 12:55:55 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 626F15A4;\n\tTue,  2 Jul 2024 12:55:27 +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=\"MsKO2MEN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719917728;\n\tbh=ezocy/v/APqffYL2sHSnGgpGELi6bD/7D0BlHgj04Nw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MsKO2MENvprPYtIQsg0yoX5Vzd0dqJJfuF38Z9OrxHHyZCPVxzl7oFs3jPtP0z9IO\n\tH+2WfWpNgc2yQcpx3Y9rsX9OYl3KAX8ciOi8omA7pcNvvKAj/g1J7SAe6CuL+XFW3G\n\tmNxhTMgK4qSRD9WAHw8MEPbICaoZTh74QrwZuL0o=","Date":"Tue, 2 Jul 2024 19:55:49 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v4 1/4] converter: converter_v4l2_m2m: Rectify streams\n\tsanity check","Message-ID":"<ZoPctaKqLiyjbYz6@pyrite.rasen.tech>","References":"<20240624134859.171969-1-umang.jain@ideasonboard.com>\n\t<20240624134859.171969-2-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240624134859.171969-2-umang.jain@ideasonboard.com>","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>"}}]