[{"id":29600,"web_url":"https://patchwork.libcamera.org/comment/29600/","msgid":"<171641891134.2920551.8422827089846754298@ping.linuxembedded.co.uk>","date":"2024-05-22T23:01:51","subject":"Re: [PATCH v2 3/4] ipa: rkisp1: Fix algorithm controls vanish after\n\tconfigure","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-05-22 15:54:37)\n> std::map::merge(source) has the side effect of actually moving items from\n> source to target. In this case the controls where removed from the source maps\n\ns/where/were/\n\n> on the first call to updateControls() and on the second call to\n> updateControls() they where missing in the source maps and therefore also\n\ns/where/were/\n\n> removed from the camera. Fix this by using insert() instead of merge(). This is\n> most likely cheaper than copy-contructing the source map.\n\nHrm, https://libcamera.org/api-html/classlibcamera_1_1ControlList.html#afb929046d68faa5dea1b43ce4028721f\nstates that merge is a copy when working on a ControlList - but I see here\nwe're working on a ControlInfoMap ...\nhttps://en.cppreference.com/w/cpp/container/map/merge and the behaviour\nis different :-(\n\n \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/rkisp1.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 6687c91e..17474408 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -427,7 +427,7 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n>                                                               frameDurations[1],\n>                                                               frameDurations[2]);\n>  \n> -       ctrlMap.merge(context_.ctrlMap);\n> +       ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end());\n\nI was going to suggest a comment above the .insert() due to the\nconfusion that took place, but it's hard to think of something suitable\nso maybe it's not helfpul.\n\nIf this fixes a bug/issue - please add a fixes tag so I can highlight it\nin the next release notes.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n>         *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);\n>  }\n>  \n> -- \n> 2.40.1\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 E3028BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 May 2024 23:01:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F31F563499;\n\tThu, 23 May 2024 01:01:56 +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 A719D61A55\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2024 01:01:54 +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 6BD547E1;\n\tThu, 23 May 2024 01:01:41 +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=\"X9KO0G7t\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716418901;\n\tbh=UTgmQP8bA4rjNCyDrESI+JvLzAmXbhCV7szNkBd3c1g=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=X9KO0G7tms6ILDdpgg+24CPDCMFiL+qgCUfeORns4oCVJxlMgjvxSKyp0sKtCFEI+\n\tG6f06pk3lctp3TGsxT/Uoz8V/PMA3+gq0uP9Nt7kJ6XdZklhBM+22DbvPWsIGIiyld\n\tnAB2Up851oFPcGOyKyQGRUvRYPyfuQquKzl8vE4M=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240522145438.436688-4-stefan.klug@ideasonboard.com>","References":"<20240522145438.436688-1-stefan.klug@ideasonboard.com>\n\t<20240522145438.436688-4-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 3/4] ipa: rkisp1: Fix algorithm controls vanish after\n\tconfigure","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 23 May 2024 00:01:51 +0100","Message-ID":"<171641891134.2920551.8422827089846754298@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>"}},{"id":29606,"web_url":"https://patchwork.libcamera.org/comment/29606/","msgid":"<ft6lfqopotjp3beenw3svdkk73clsgov3aso6nj36xsbvlzanp@h4hqtch2ee7r>","date":"2024-05-23T08:07:56","subject":"Re: [PATCH v2 3/4] ipa: rkisp1: Fix algorithm controls vanish after\n\tconfigure","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Stefan\n\nOn Thu, May 23, 2024 at 12:01:51AM GMT, Kieran Bingham wrote:\n> Quoting Stefan Klug (2024-05-22 15:54:37)\n> > std::map::merge(source) has the side effect of actually moving items from\n\nIt's actually an unordered_map which is the ControlInfoMap base class,\nthe behaviour is not different though.\n\n> > source to target. In this case the controls where removed from the source maps\n>\n> s/where/were/\n>\n> > on the first call to updateControls() and on the second call to\n> > updateControls() they where missing in the source maps and therefore also\n>\n> s/where/were/\n>\n> > removed from the camera. Fix this by using insert() instead of merge(). This is\n> > most likely cheaper than copy-contructing the source map.\n>\n> Hrm, https://libcamera.org/api-html/classlibcamera_1_1ControlList.html#afb929046d68faa5dea1b43ce4028721f\n> states that merge is a copy when working on a ControlList - but I see here\n> we're working on a ControlInfoMap ...\n> https://en.cppreference.com/w/cpp/container/map/merge and the behaviour\n> is different :-(\n>\n>\n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/ipa/rkisp1/rkisp1.cpp | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> > index 6687c91e..17474408 100644\n> > --- a/src/ipa/rkisp1/rkisp1.cpp\n> > +++ b/src/ipa/rkisp1/rkisp1.cpp\n> > @@ -427,7 +427,7 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n> >                                                               frameDurations[1],\n> >                                                               frameDurations[2]);\n> >\n> > -       ctrlMap.merge(context_.ctrlMap);\n> > +       ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end());\n>\n> I was going to suggest a comment above the .insert() due to the\n> confusion that took place, but it's hard to think of something suitable\n> so maybe it's not helfpul.\n>\n> If this fixes a bug/issue - please add a fixes tag so I can highlight it\n> in the next release notes.\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nThere's one thing that puzzles me\n\nControlInfoMap privately inherits from unordered_map\n\n        class ControlInfoMap : private std::unordered_map<const ControlId *, ControlInfo>\n\nand we don't expose Map::merge as we do for the iterators and a few\nmore functions.\n\nShouldn't std::unordered_map::merge be unaccessible for users of\nControlInfoMap ?\n\n>\n>\n> >         *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);\n> >  }\n> >\n> > --\n> > 2.40.1\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 6C4A2BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 May 2024 08:08:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E06363499;\n\tThu, 23 May 2024 10:08:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8AC9063482\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2024 10:07:59 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2001:b07:5d2e:52c9:cc1e:e404:491f:e6ea])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1773F475;\n\tThu, 23 May 2024 10:07: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=\"uymrbhNx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716451666;\n\tbh=5vi6i+7QzA+PspTv5GQUts6jTpsJTkotzyy3UuCEKUU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uymrbhNxKRj16iiddmvwSjcMWm61e1l4BrWdTkIdAkG1EXSkhC0TqUSMpHSrp420s\n\tvO5gpHA6abCF05zfwEwBy4+LemlH2sESp3jsWuDB2wMdzl3/bR2JM6bT+/omc+lkkc\n\tegUWBX41MBrUdkyn5UgqkrQtXg0JV8ioK92zKaK0=","Date":"Thu, 23 May 2024 10:07:56 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 3/4] ipa: rkisp1: Fix algorithm controls vanish after\n\tconfigure","Message-ID":"<ft6lfqopotjp3beenw3svdkk73clsgov3aso6nj36xsbvlzanp@h4hqtch2ee7r>","References":"<20240522145438.436688-1-stefan.klug@ideasonboard.com>\n\t<20240522145438.436688-4-stefan.klug@ideasonboard.com>\n\t<171641891134.2920551.8422827089846754298@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<171641891134.2920551.8422827089846754298@ping.linuxembedded.co.uk>","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>"}},{"id":29607,"web_url":"https://patchwork.libcamera.org/comment/29607/","msgid":"<20240523081942.m2wa62dqil7lbxrg@jasper>","date":"2024-05-23T08:19:42","subject":"Re: [PATCH v2 3/4] ipa: rkisp1: Fix algorithm controls vanish after\n\tconfigure","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Jacopo,\n\nthanks for the review.\n\nOn Thu, May 23, 2024 at 10:07:56AM +0200, Jacopo Mondi wrote:\n> Hi Stefan\n> \n> On Thu, May 23, 2024 at 12:01:51AM GMT, Kieran Bingham wrote:\n> > Quoting Stefan Klug (2024-05-22 15:54:37)\n> > > std::map::merge(source) has the side effect of actually moving items from\n> \n> It's actually an unordered_map which is the ControlInfoMap base class,\n> the behaviour is not different though.\n> \n> > > source to target. In this case the controls where removed from the source maps\n> >\n> > s/where/were/\n> >\n> > > on the first call to updateControls() and on the second call to\n> > > updateControls() they where missing in the source maps and therefore also\n> >\n> > s/where/were/\n> >\n> > > removed from the camera. Fix this by using insert() instead of merge(). This is\n> > > most likely cheaper than copy-contructing the source map.\n> >\n> > Hrm, https://libcamera.org/api-html/classlibcamera_1_1ControlList.html#afb929046d68faa5dea1b43ce4028721f\n> > states that merge is a copy when working on a ControlList - but I see here\n> > we're working on a ControlInfoMap ...\n> > https://en.cppreference.com/w/cpp/container/map/merge and the behaviour\n> > is different :-(\n> >\n> >\n> > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > > ---\n> > >  src/ipa/rkisp1/rkisp1.cpp | 2 +-\n> > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > >\n> > > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> > > index 6687c91e..17474408 100644\n> > > --- a/src/ipa/rkisp1/rkisp1.cpp\n> > > +++ b/src/ipa/rkisp1/rkisp1.cpp\n> > > @@ -427,7 +427,7 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,\n> > >                                                               frameDurations[1],\n> > >                                                               frameDurations[2]);\n> > >\n> > > -       ctrlMap.merge(context_.ctrlMap);\n> > > +       ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end());\n> >\n> > I was going to suggest a comment above the .insert() due to the\n> > confusion that took place, but it's hard to think of something suitable\n> > so maybe it's not helfpul.\n> >\n> > If this fixes a bug/issue - please add a fixes tag so I can highlight it\n> > in the next release notes.\n> >\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> There's one thing that puzzles me\n> \n> ControlInfoMap privately inherits from unordered_map\n> \n>         class ControlInfoMap : private std::unordered_map<const ControlId *, ControlInfo>\n> \n> and we don't expose Map::merge as we do for the iterators and a few\n> more functions.\n> \n> Shouldn't std::unordered_map::merge be unaccessible for users of\n> ControlInfoMap ?\n\nctrlMap is of type ControlInfoMap::Map, so the underlying unordered_map\nis used directly. \n\nCheers,\nStefan\n\n> \n> >\n> >\n> > >         *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);\n> > >  }\n> > >\n> > > --\n> > > 2.40.1\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 09DBDBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 May 2024 08:19:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1DA563499;\n\tThu, 23 May 2024 10:19:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 643CD63482\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2024 10:19:45 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:6e2:db60:9aa4:f6ee])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DC865475;\n\tThu, 23 May 2024 10:19:31 +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=\"dQhw+Ix9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716452372;\n\tbh=4fkPlaevQjNyT8tKpIQP5aTCiRtK9OtuadxxaN4cmqg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dQhw+Ix9fCFPUu3Y6QLaD49162X2XrgWEFHa8IVeYKknpWP6CAZ3yeOUxDCbisIQQ\n\t4DAJFg/FmmqjpKRQyp9rsR1usV7AwKN2ieZy2suBA/WAOLTMPDixsrGhZ3ND2wF6U7\n\tS8OO3sOJdlRcuhvQd9ag8s3T+ktUSRFw+vh4AZwU=","Date":"Thu, 23 May 2024 10:19:42 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 3/4] ipa: rkisp1: Fix algorithm controls vanish after\n\tconfigure","Message-ID":"<20240523081942.m2wa62dqil7lbxrg@jasper>","References":"<20240522145438.436688-1-stefan.klug@ideasonboard.com>\n\t<20240522145438.436688-4-stefan.klug@ideasonboard.com>\n\t<171641891134.2920551.8422827089846754298@ping.linuxembedded.co.uk>\n\t<ft6lfqopotjp3beenw3svdkk73clsgov3aso6nj36xsbvlzanp@h4hqtch2ee7r>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<ft6lfqopotjp3beenw3svdkk73clsgov3aso6nj36xsbvlzanp@h4hqtch2ee7r>","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>"}}]