[{"id":29652,"web_url":"https://patchwork.libcamera.org/comment/29652/","msgid":"<171698050743.2248009.5665932904303622882@ping.linuxembedded.co.uk>","date":"2024-05-29T11:01:47","subject":"Re: [PATCH v2 1/4] converter: converter_v4l2_m2m: Rectify streams\n\tsanity check","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Umang Jain (2024-05-29 08:02:45)\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\nGood point ;-) So the current mask is fairly redundant...\n\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\nI was going to say surely this is just a precursor to the next patches,\nbut I do think it holds up on it's own now I realised the index is\nindeed already a std::map key...\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-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(-)\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>                                    const std::map<unsigned int, FrameBuffer *> &outputs)\n>  {\n> -       unsigned int mask = 0;\n> +       std::set<FrameBuffer *> outputBufs;\n>         int ret;\n>  \n>         /*\n>          * Validate the outputs as a sanity check: at least one output is\n>          * required, all outputs must reference a valid stream and no two\n> -        * outputs can reference the same stream.\n> +        * streams can reference same output framebuffers.\n>          */\n>         if (outputs.empty())\n>                 return -EINVAL;\n> @@ -419,12 +419,13 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input,\n>                         return -EINVAL;\n>                 if (index >= streams_.size())\n>                         return -EINVAL;\n> -               if (mask & (1 << index))\n> -                       return -EINVAL;\n>  \n> -               mask |= 1 << index;\n> +               outputBufs.insert(buffer);\n>         }\n>  \n> +       if (outputBufs.size() != streams_.size())\n> +               return -EINVAL;\n> +\n>         /* Queue the input and output buffers to all the streams. */\n>         for (auto [index, buffer] : outputs) {\n>                 ret = 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 3BF4CBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 May 2024 11:01:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 30D77634AF;\n\tWed, 29 May 2024 13:01:52 +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 8FCFA6347E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 13:01:50 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A580D4CD;\n\tWed, 29 May 2024 13:01:46 +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=\"ICO/qkha\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716980506;\n\tbh=5Csq0rJNn8GqpI5tE2ac1iMW6ob7Ntnj3WMMvOiYe+8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ICO/qkhax2s0fdn75JUUH9AtMd2p6toE4cyZ3kBk2TGZpiCbr5bjfOt5hZ15d5SmH\n\t9e8fpmgj8kwq/aeWL9Pd4S8ZwYRrdzi0lZfgiEHlivCdUE0oGIibHbXwn7lMQBYTxi\n\tK0u+tihYkJtUPpIWRV7XBq0fKAGJj0lJ4jwxOUOk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240529070248.12186-2-umang.jain@ideasonboard.com>","References":"<20240529070248.12186-1-umang.jain@ideasonboard.com>\n\t<20240529070248.12186-2-umang.jain@ideasonboard.com>","Subject":"Re: [PATCH v2 1/4] converter: converter_v4l2_m2m: Rectify streams\n\tsanity check","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>,\n\tUmang Jain <umang.jain@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 29 May 2024 12:01:47 +0100","Message-ID":"<171698050743.2248009.5665932904303622882@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]