[{"id":15289,"web_url":"https://patchwork.libcamera.org/comment/15289/","msgid":"<YDOxcjusQJHulZwG@oden.dyn.berto.se>","date":"2021-02-22T13:28:18","subject":"Re: [libcamera-devel] [PATCH/WIP] libcamera: controls: Add a\n\tfunction to merge two control lists","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2021-02-22 15:21:21 +0200, Laurent Pinchart wrote:\n> Add a new ControlList::merge() function to merge two control lists. The\n> semantics is identical to std::unordered_map::merge(). This can be used\n> by pipeline handlers to merge metadata they populate with metadata\n> received from an IPA.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/controls.h |  2 ++\n>  src/libcamera/controls.cpp   | 20 ++++++++++++++++++++\n>  2 files changed, 22 insertions(+)\n> \n> Hello,\n> \n> This may come handy for the IPU3 IPA. The patch hasn't been tested yet,\n> I'm in particular not entirely sure of the idmap_ check. I've opted for\n> an ASSERT() to be restrictive and catch potential issues, we may decide\n> to relax the requirement (or handle it differently) if the assertion is\n> triggered and the analysis of the problem shows that a different\n> approach is required.\n\nI think it make sens to have an ASSERT() check for this.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 1a5690a5ccbe..16726ce9b1ed 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -363,7 +363,9 @@ public:\n>  \n>  \tbool empty() const { return controls_.empty(); }\n>  \tstd::size_t size() const { return controls_.size(); }\n> +\n>  \tvoid clear() { controls_.clear(); }\n> +\tvoid merge(ControlList &source);\n>  \n>  \tbool contains(const ControlId &id) const;\n>  \tbool contains(unsigned int id) const;\n> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> index c58ed3946f3b..58555ea64c95 100644\n> --- a/src/libcamera/controls.cpp\n> +++ b/src/libcamera/controls.cpp\n> @@ -874,6 +874,26 @@ ControlList::ControlList(const ControlInfoMap &infoMap, ControlValidator *valida\n>   * \\brief Removes all controls from the list\n>   */\n>  \n> +/**\n> + * \\brief Merge the \\a source into the ControlList\n> + * \\param[in] source The ControlList to merge into this object\n> + *\n> + * Merging two control lists extracts elements from the \\a source and insert\n> + * them in *this. If the \\a source contains elements whose key is already\n> + * present in *this, then those elements are not extracted. The semantics is\n> + * identical to std::unordered_map::merge() in that only internal pointers to\n> + * nodes are updated, without copying or moving the elements.\n> + *\n> + * Only control lists created from the same ControlIdMap or ControlInfoMap may\n> + * be merged. Attempting to do otherwise results in undefined behaviour.\n> + */\n> +void ControlList::merge(ControlList &source)\n> +{\n> +\tASSERT(idmap_ == source.idmap_);\n> +\n> +\tcontrols_.merge(source.controls_);\n> +}\n> +\n>  /**\n>   * \\brief Check if the list contains a control with the specified \\a id\n>   * \\param[in] id The control ID\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 05A94BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Feb 2021 13:28:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7678568A1C;\n\tMon, 22 Feb 2021 14:28:21 +0100 (CET)","from mail-lj1-x230.google.com (mail-lj1-x230.google.com\n\t[IPv6:2a00:1450:4864:20::230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5714468A07\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Feb 2021 14:28:20 +0100 (CET)","by mail-lj1-x230.google.com with SMTP id c8so57832476ljd.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Feb 2021 05:28:20 -0800 (PST)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tm12sm1119804lji.80.2021.02.22.05.28.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 22 Feb 2021 05:28:19 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"IFs77X/Q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=EZP631jd53HZ1ih+E1cMptKsfIpWeTtl8OdNjs1fz0U=;\n\tb=IFs77X/Q0+jxIHCodsGs7JjYW7AL1s4UMs8KI2/AYUhJw0yoo4dXQdMyZIP+8DgEme\n\t+sE8pE6VpXurXJbRtGUxJJRbllW0eKr+udPxiW2qr78pcKrNU7BZ8cy5WRfCQ1uicatQ\n\t1ebKYDdREAQEBIBwFYgbc5EJ6vx+kwSPu4GoCA4mPhcf7P6dDcZR8Uv4eSIqQcclnGOL\n\twAEhnaiJYhYGMekRPanNVBlOCNoWPiZIruop2TU9mF5Lyjrqb/FkWRrRg/gQShO6KHKa\n\tfhY2QKJbonDM1ZEvr1+WtNhgW4t6zeHf8O2+VyG4URBNnIqVU5UY+hj0qC2p116xW/lp\n\tFBZA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=EZP631jd53HZ1ih+E1cMptKsfIpWeTtl8OdNjs1fz0U=;\n\tb=rEuRb4FhEi6V3hpo5LEJ7yZv94W2DBk2lRwiht2Yqc5xqHmgIGT9Yf6S2veL70pGkx\n\tlYbOldyHnHlahqO+NmuKG+ZD4kKTNLISr/y51lRO+TRmryRmBtbTMpCMg5iUlUthEJWM\n\tLD3ci0ejMWi6N8ZTrQIfyZh4OgzVgw7+1ca/a4C6i27JyO3D3SJ4GZAykeVtMqf0FssH\n\tmOFll5Ema7YhirlvnC4PWfu+u2zn1qq3PKYDjcVZyIvqelzsAkS9W2LW0uHvtexm7v9m\n\tw2dj/T5pyFuL9XdN9JjoKZc4re0pOsTUnX1gh2msUtq+oct95HD4CF8q7fr3b/TZoUW/\n\tG63A==","X-Gm-Message-State":"AOAM5303pluxlFZxu5pWOSd646wKf9LJI6i618IusB+BWKUZP5XuJBql\n\tq8DfzVzV2JtIFeBqwO2457r6ObVmsaUb7A==","X-Google-Smtp-Source":"ABdhPJyqz/R0KQrcXQIL2OQa7EzWArLT7MvciBE7k7E/NCyB0Hf85VjSFqdtwB7q31ZqPw53IpE/Vw==","X-Received":"by 2002:a2e:a0d8:: with SMTP id\n\tf24mr5937625ljm.180.1614000499800; \n\tMon, 22 Feb 2021 05:28:19 -0800 (PST)","Date":"Mon, 22 Feb 2021 14:28:18 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<YDOxcjusQJHulZwG@oden.dyn.berto.se>","References":"<20210222132121.6728-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210222132121.6728-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH/WIP] libcamera: controls: Add a\n\tfunction to merge two control lists","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]