[{"id":28264,"web_url":"https://patchwork.libcamera.org/comment/28264/","msgid":"<CAHW6GY+jiRxP25X6pCjdbkV=hA4AnP+nu=oE1kmm-6-3V-3RVw@mail.gmail.com>","date":"2023-12-06T19:42:32","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: Allow the mean of an empty\n\thistogram interval","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Nick\n\nThanks for the patch. Looks good to me!\n\nOn Wed, 6 Dec 2023 at 17:27, Nick Hollinghurst via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Don't assert when taking the weighted mean of a zero-width or\n> zero-weight interval; return its upper bound. That is certainly\n> correct in the zero-width case, and plausible otherwise.\n>\n> Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\n> ---\n>  src/ipa/rpi/controller/histogram.cpp | 10 ++++++++--\n>  1 file changed, 8 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/ipa/rpi/controller/histogram.cpp b/src/ipa/rpi/controller/histogram.cpp\n> index 0a27ba2c..78116141 100644\n> --- a/src/ipa/rpi/controller/histogram.cpp\n> +++ b/src/ipa/rpi/controller/histogram.cpp\n> @@ -47,7 +47,7 @@ double Histogram::quantile(double q, int first, int last) const\n>\n>  double Histogram::interBinMean(double binLo, double binHi) const\n>  {\n> -       assert(binHi > binLo);\n> +       assert(binHi >= binLo);\n>         double sumBinFreq = 0, cumulFreq = 0;\n>         for (double binNext = floor(binLo) + 1.0; binNext <= ceil(binHi);\n>              binLo = binNext, binNext += 1.0) {\n> @@ -57,13 +57,19 @@ double Histogram::interBinMean(double binLo, double binHi) const\n>                 sumBinFreq += bin * freq;\n>                 cumulFreq += freq;\n>         }\n> +\n> +       if (cumulFreq == 0) {\n> +               /* interval had zero width or contained no weight? */\n> +               return binHi;\n> +       }\n> +\n>         /* add 0.5 to give an average for bin mid-points */\n>         return sumBinFreq / cumulFreq + 0.5;\n>  }\n>\n>  double Histogram::interQuantileMean(double qLo, double qHi) const\n>  {\n> -       assert(qHi > qLo);\n> +       assert(qHi >= qLo);\n>         double pLo = quantile(qLo);\n>         double pHi = quantile(qHi, (int)pLo);\n>         return interBinMean(pLo, pHi);\n> --\n> 2.39.2\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 D76F9C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Dec 2023 19:42:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 441E7629CE;\n\tWed,  6 Dec 2023 20:42:47 +0100 (CET)","from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com\n\t[IPv6:2607:f8b0:4864:20::f30])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E374261D9E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Dec 2023 20:42:44 +0100 (CET)","by mail-qv1-xf30.google.com with SMTP id\n\t6a1803df08f44-67abd1879c0so999406d6.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 Dec 2023 11:42:44 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701891767;\n\tbh=k2EJ8QFV9F9SmhVD4wTa35+mDnjkBoWlIxvMt58qmEw=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=wPX77RBlUHf9c7Q+ajRd45uKLyHNwU5vG4oyjJ5CAHmDxjJtYmpKcj6AJcDTNxLla\n\toA3c8rvG92Kvy03QJ38KvquCxMsmzHdVPA+OJ5m+2BA/qZG57ONwNfwiLZkb9+HTOI\n\teterywpq/6HiLyI5TWBp6rFwFbtUyyWCV+/mn06BB5t+LnRiZXfz86byj2oJqv2DN2\n\tvoUrC7y5du0BaAaa/Nfm+znhMs+SoiU6g41dD/KCtsolwP1OwneDAPcICO/iz0uKOB\n\t2oVA/9AeZGnm7DdssspL2Q8hwJV2+nyNVF1S3FhO4eu01oah40ETjTBYy4+dL6Qtbt\n\twuj1Z6Fkhnvew==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1701891764; x=1702496564;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=vGPqvHODgfP24a33OPoB70yoFyBkZHEeW5twmPiuSgM=;\n\tb=NzD2h/Q89TGfIxwwNpYagYn7rfpdkcxK/hqeV/xlcPBVAAPfkes0UEfeZTkjniMsjv\n\tCzZSDvJCOfajRstx2I32nWT1B9cHtzJ0oyC83U4Lt1pVhskUSa4HVn/FWLC9X6pDl/p1\n\tnli9FSAKxfGiGSXSuh1C+TgTD5st4WTcRr2X5uj/1UHmYO1q7IyezSiCu/mZlSfYDMQo\n\t3CMbelxl3/GpXjbGPytTDWSmsiSkcTbgO2A6jD4cNIa4TReSyTpOn3/HZRiOGeB7caK3\n\tuvBXUvw7Z8hbbYCi2HX/jVLEpgdvJ0k0d5agFfI9EMAxmnIQdKJZP+8VSzQriUx3pAxG\n\tQrYw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"NzD2h/Q8\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1701891764; x=1702496564;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=vGPqvHODgfP24a33OPoB70yoFyBkZHEeW5twmPiuSgM=;\n\tb=pbc6uwnJfEJY/9IyzOealqReZrn0ajQ2qBtyP5skZpAHMLjCxrK0mCy0OJzjc7+fSs\n\tZ8X9K/KCuR4C+Bbig4a9ni1QAzJd6AAtObrWIrp5siypuPGfeiqsLwqOEv3Y5shwbLP6\n\tx/45LG27ycxlLcDlcB976QP7xnVyMuxIBDVY2dGE/em4HGkT7KlL3UMJmMc3Mkxoskto\n\tRITL1iXfU423Boe9tHiehpwNbN8Lday/cGb0SyesMtU1Q+7qlfRFXxbetmVYmfLYCyeF\n\tjtrHd/p5xMRGqE9rkcsrluzHvytXm9D9EkjK0TYaSuM2OL6SPjk/EDXWddqg4o4q0KyG\n\t7Mvw==","X-Gm-Message-State":"AOJu0YziSrUc9ckLdBXqwFtb+NmfoEa66AM9vMdCt3bbI3FKXd1Ig1yH\n\tVr5vKdI5rkSAKMz1podabF0WkBqWo5Nkptl6odJT2NECzqPzGdYQ","X-Google-Smtp-Source":"AGHT+IG9FcU3KZgI6im+j5QuHytgpz2mImu3NJQ3cvW9w2xKMnKuCFzNRF9Xie02shrBKdtbMMUR2TFdkJue1qW/eJY=","X-Received":"by 2002:a05:6214:2a3:b0:67a:ae69:2ff5 with SMTP id\n\tm3-20020a05621402a300b0067aae692ff5mr1415976qvv.27.1701891763800;\n\tWed, 06 Dec 2023 11:42:43 -0800 (PST)","MIME-Version":"1.0","References":"<20231206172743.13355-1-nick.hollinghurst@raspberrypi.com>\n\t<20231206172743.13355-2-nick.hollinghurst@raspberrypi.com>","In-Reply-To":"<20231206172743.13355-2-nick.hollinghurst@raspberrypi.com>","Date":"Wed, 6 Dec 2023 19:42:32 +0000","Message-ID":"<CAHW6GY+jiRxP25X6pCjdbkV=hA4AnP+nu=oE1kmm-6-3V-3RVw@mail.gmail.com>","To":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: Allow the mean of an empty\n\thistogram interval","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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28272,"web_url":"https://patchwork.libcamera.org/comment/28272/","msgid":"<CAEmqJPoSYj9QrABF5EV_UTo7c4e4YGoHF_5OAhtL1HFisA=rAg@mail.gmail.com>","date":"2023-12-07T09:59:30","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: Allow the mean of an empty\n\thistogram interval","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Nick,\n\nThanks for the patch.\n\nOn Wed, 6 Dec 2023 at 17:27, Nick Hollinghurst via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Don't assert when taking the weighted mean of a zero-width or\n> zero-weight interval; return its upper bound. That is certainly\n> correct in the zero-width case, and plausible otherwise.\n>\n> Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n> ---\n>  src/ipa/rpi/controller/histogram.cpp | 10 ++++++++--\n>  1 file changed, 8 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/ipa/rpi/controller/histogram.cpp b/src/ipa/rpi/controller/histogram.cpp\n> index 0a27ba2c..78116141 100644\n> --- a/src/ipa/rpi/controller/histogram.cpp\n> +++ b/src/ipa/rpi/controller/histogram.cpp\n> @@ -47,7 +47,7 @@ double Histogram::quantile(double q, int first, int last) const\n>\n>  double Histogram::interBinMean(double binLo, double binHi) const\n>  {\n> -       assert(binHi > binLo);\n> +       assert(binHi >= binLo);\n>         double sumBinFreq = 0, cumulFreq = 0;\n>         for (double binNext = floor(binLo) + 1.0; binNext <= ceil(binHi);\n>              binLo = binNext, binNext += 1.0) {\n> @@ -57,13 +57,19 @@ double Histogram::interBinMean(double binLo, double binHi) const\n>                 sumBinFreq += bin * freq;\n>                 cumulFreq += freq;\n>         }\n> +\n> +       if (cumulFreq == 0) {\n> +               /* interval had zero width or contained no weight? */\n> +               return binHi;\n> +       }\n> +\n>         /* add 0.5 to give an average for bin mid-points */\n>         return sumBinFreq / cumulFreq + 0.5;\n>  }\n>\n>  double Histogram::interQuantileMean(double qLo, double qHi) const\n>  {\n> -       assert(qHi > qLo);\n> +       assert(qHi >= qLo);\n>         double pLo = quantile(qLo);\n>         double pHi = quantile(qHi, (int)pLo);\n>         return interBinMean(pLo, pHi);\n> --\n> 2.39.2\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 E57AEC322E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Dec 2023 10:00:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E37FA629E3;\n\tThu,  7 Dec 2023 11:00:09 +0100 (CET)","from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com\n\t[IPv6:2607:f8b0:4864:20::b2c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 033BB629CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Dec 2023 11:00:07 +0100 (CET)","by mail-yb1-xb2c.google.com with SMTP id\n\t3f1490d57ef6-db544987c79so775559276.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Dec 2023 02:00:07 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701943209;\n\tbh=56N/Ro96kmcIt2xJRv9dv669iicQoZK4ZOe9AbcDXzk=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=1KG7+QMX+CKfwFm9UdjqPwOAUy7MMFXC1VlwhRCXaj79L5gcipeLgYkWi07Ycj4uT\n\tHa/fuPu103S3YjhUEnZxO2o5WqgeUuo8MWhL9Ju4htkUk31UluK/ZK8rOztqB8AiFI\n\tlNpYJj6ArVNxaL+nN5UaDMRH4H3h51BCqr+y9/O30r52qxbbF4Jyo9Te7YR/w8a27R\n\tRsgwvgIJn/sMlvDVrrrBmMySfRzVq11YXwTZKzEVRsGwEri5ePMPdnMuTQuxyyxiiK\n\ts6VkqKOdw4T9VO8ksjStKaG5SFKRBtCQfOFPjGXnWe4o2n4YdTN6MI1v12792dwCcb\n\tT6NiQPF6b0MSg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1701943206; x=1702548006;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=Lu3skI8ac7W8UUJ3fGsgB7yIA0t22e2wt9tJHDMQNjc=;\n\tb=ehyoqPD38uJvgEWGJwir9R+FzVmBb576rcAVExrV6pQfflxvCBUrDOZsZSdMoBFhmZ\n\tZ2Xb/UdKF+CSaalvzi7yFlKeVT/ypcXPWgToJW5W0v4/h9ayXBKX0nRfv613ALbUZmZl\n\tNKsAHvFXTYAg+sBfN6qfU8Tr3m37vtOGTSsr+gZYfje4riG4JE8zIm3NtXjs6dHmxqbC\n\tNJJdYaImDrE9vM0i71cnpqQSDvDuUNJFh2K06u0AeCRRblHv2BoMV6+Dy9O0SDSfaftr\n\t+BqQFB4yUf/4BzydIIkRfz2i05xeHXjqDPAxvH7ck4QhvcqF263NiEmuGsVAiz4rvRWW\n\t40Qg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"ehyoqPD3\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1701943206; x=1702548006;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=Lu3skI8ac7W8UUJ3fGsgB7yIA0t22e2wt9tJHDMQNjc=;\n\tb=wupya11GXVei7f21islLLuGy8r1N8nAWrh1vINWwpqdYsSC6D3mFONhi/tXH0xI8Nf\n\trT9Mio0QeLP/7QW94WLA0nHzJ5vdS8xbv/wLxKxdXjib3kFxYCgdliPwaitKzWVPZ5lW\n\tPyg/K7rY7Wq7AFziEG76UouApkqkH56hbwQqelp4tlnNbFGK7EWrZMqtIVEHwQLXO49h\n\t4n55z175T3iIAMBAPR4Oq8PVTwCFO5hlF+FdzBKl0V+aaSeAQoZOuJkuK2lZK2VY91mN\n\tMgFLe888yFCDfi2ZfERU7+Hr2VuXH69bokrhn8qvN9QDCusb7k5KEgWRjbqpBj4tAhRU\n\tak6g==","X-Gm-Message-State":"AOJu0Yzjw7//vDBLNb4DCw/6qLozfWk1M4bsBy/vA8+GVwfpE0cO0mX8\n\tKKePtnrcCJrJQbRdef0HYoRnHrbyXqSvp5ONnXg8rgVc+GW6b+PvOb4=","X-Google-Smtp-Source":"AGHT+IEVd3t0pusi6pKfDQF3uB4SKdPz9+eyn2UkIseU1n6zxQzPFd24rB5H1oqUi+nI1+l46FhSPACLqVQDgcBEoV4=","X-Received":"by 2002:a25:344e:0:b0:db7:d0da:4f8 with SMTP id\n\tb75-20020a25344e000000b00db7d0da04f8mr1915901yba.30.1701943206539;\n\tThu, 07 Dec 2023 02:00:06 -0800 (PST)","MIME-Version":"1.0","References":"<20231206172743.13355-1-nick.hollinghurst@raspberrypi.com>\n\t<20231206172743.13355-2-nick.hollinghurst@raspberrypi.com>","In-Reply-To":"<20231206172743.13355-2-nick.hollinghurst@raspberrypi.com>","Date":"Thu, 7 Dec 2023 09:59:30 +0000","Message-ID":"<CAEmqJPoSYj9QrABF5EV_UTo7c4e4YGoHF_5OAhtL1HFisA=rAg@mail.gmail.com>","To":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: Allow the mean of an empty\n\thistogram interval","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]