{"id":10601,"url":"https://patchwork.libcamera.org/api/patches/10601/?format=json","web_url":"https://patchwork.libcamera.org/patch/10601/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201207180121.6374-5-david.plowman@raspberrypi.com>","date":"2020-12-07T18:01:19","name":"[libcamera-devel,v2,4/6] src: ipa: raspberrypi: Compute inverse of piecewise linear function","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"d1742d257dc2d19d78d2f451a291bc4e8d816abe","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10601/mbox/","series":[{"id":1511,"url":"https://patchwork.libcamera.org/api/series/1511/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1511","date":"2020-12-07T18:01:15","name":"Raspberry Pi AGC: initial frame drop count","version":2,"mbox":"https://patchwork.libcamera.org/series/1511/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10601/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10601/checks/","tags":{},"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 C512EBDB1F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Dec 2020 18:02:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F3C367E6B;\n\tMon,  7 Dec 2020 19:02:24 +0100 (CET)","from mail-ed1-x535.google.com (mail-ed1-x535.google.com\n\t[IPv6:2a00:1450:4864:20::535])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CC2F667E6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Dec 2020 19:02:22 +0100 (CET)","by mail-ed1-x535.google.com with SMTP id u19so14720216edx.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Dec 2020 10:02:22 -0800 (PST)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tbe6sm14657977edb.29.2020.12.07.10.02.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 07 Dec 2020 10:02:16 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"ZjDcB23c\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=QxO4QgtZgd2HaiyXhTe2SCFiVm9KpKHiGeJ8yVR92K4=;\n\tb=ZjDcB23cp0M7qGXQvW80SA3lyCjOvPJwaQ8SsN+1WdcEIznHlagGb6+9BiQmJRZywp\n\tRvluOF/OB4W302If/7bWA3sNysG4mxeRtj4dGPBNqOThmlqXyOR1VlmN7dS9X408929Z\n\ti4OUKuYl3wmmzv4V8R02Ed9dMODRDLXg8G9Extq40i+P+wVG7mtA+rgLUcZ+hFz0uFm1\n\t8j3IEltOvUgeeFhbm0oT5WJgMp89x6lHqAT32wF2QjTPhtlAAB7ZSPQQoKmKacwwu5E1\n\t3wJMhnb6i39k64cT59cI03eE8iRvlBOzBo+Mp0FdrlWbrg9hY0YZHLPwSNBU1pkovP72\n\tBOKQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=QxO4QgtZgd2HaiyXhTe2SCFiVm9KpKHiGeJ8yVR92K4=;\n\tb=uink8xEBgyGG6xGD+IdHjZTH8tjNN/T00kKOUcxUb+LxkCsxGqR48kyvXb1sWO3rTa\n\tf7I93ds46WoYvAdCfvR8bUJf2IcbApznpZFLgjyCSDpAoqDv0DclbTFUNArjn+jn4OZy\n\t+SRXVITn5qe6ciN5BdnADwZyySgM81l86czALgsMorcrD9LgBsMwEAlAiTRYn13KwE6Q\n\tD854FNOlzNsfrVlD5QZ7JGpovjVGBKj1i2cMbvVz0RT3m2FjYf6k+NTq7kdSo8xakdze\n\tL9/MA189H6sH6rC2UrBkM0Kn0d+z7igjQ6+2RnsUaXNwzzQhy+nFnQ3SRdZW+vFeNdOs\n\tH0uA==","X-Gm-Message-State":"AOAM531MrRmh6N5WKxTq7NgzzX7yzyWciAWdaAAZ+k1NhQSsiyfXhN6f\n\tmweUmmP+4JpMccTUXkr9DJ/vZ++fxsdUf65u","X-Google-Smtp-Source":"ABdhPJwi7lNf0P3p6b8180GGqt/UWHjYZQcK31xlvqeOMCX23bq/18HCvR55yhloQ3mQZqeJ3I99yg==","X-Received":"by 2002:a05:6402:21c7:: with SMTP id\n\tbi7mr21822788edb.54.1607364142004; \n\tMon, 07 Dec 2020 10:02:22 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  7 Dec 2020 18:01:19 +0000","Message-Id":"<20201207180121.6374-5-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20201207180121.6374-1-david.plowman@raspberrypi.com>","References":"<20201207180121.6374-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 4/6] src: ipa: raspberrypi: Compute\n\tinverse of piecewise linear function","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a method to the piecewise linear function (Pwl) class to compute\nthe inverse of a given Pwl. If the input function is non-monotonic we\ncan only produce a best effort \"pseudo\" inverse, and we signal this to\nthe caller.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/pwl.cpp | 27 ++++++++++++++++++++++++++\n src/ipa/raspberrypi/controller/pwl.hpp |  3 +++\n 2 files changed, 30 insertions(+)","diff":"diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp\nindex aa134a1f..70206418 100644\n--- a/src/ipa/raspberrypi/controller/pwl.cpp\n+++ b/src/ipa/raspberrypi/controller/pwl.cpp\n@@ -114,6 +114,33 @@ Pwl::PerpType Pwl::Invert(Point const &xy, Point &perp, int &span,\n \treturn PerpType::None;\n }\n \n+Pwl Pwl::Inverse(bool *true_inverse, const double eps) const\n+{\n+\tbool appended = false, prepended = false, neither = false;\n+\tPwl inverse;\n+\n+\tfor (Point const &p : points_) {\n+\t\tif (inverse.Empty())\n+\t\t\tinverse.Append(p.y, p.x, eps);\n+\t\telse if (p.y > inverse.points_.back().x - eps) {\n+\t\t\tinverse.Append(p.y, p.x, eps);\n+\t\t\tappended = true;\n+\t\t} else if (p.y < inverse.points_.front().x + eps) {\n+\t\t\tinverse.Prepend(p.y, p.x, eps);\n+\t\t\tprepended = true;\n+\t\t} else\n+\t\t\tneither = true;\n+\t}\n+\n+\t// This is not a proper inverse if we found ourselves putting points\n+\t// onto both ends of the inverse, or if there were points that couldn't\n+\t// go on either.\n+\tif (true_inverse)\n+\t\t*true_inverse = !(neither || (appended && prepended));\n+\n+\treturn inverse;\n+}\n+\n Pwl Pwl::Compose(Pwl const &other, const double eps) const\n {\n \tdouble this_x = points_[0].x, this_y = points_[0].y;\ndiff --git a/src/ipa/raspberrypi/controller/pwl.hpp b/src/ipa/raspberrypi/controller/pwl.hpp\nindex 4f168551..484672f6 100644\n--- a/src/ipa/raspberrypi/controller/pwl.hpp\n+++ b/src/ipa/raspberrypi/controller/pwl.hpp\n@@ -80,6 +80,9 @@ public:\n \t};\n \tPerpType Invert(Point const &xy, Point &perp, int &span,\n \t\t\tconst double eps = 1e-6) const;\n+\t// Compute the inverse function. Indicate if it is a proper (true)\n+\t// inverse, or only a best effort (e.g. input was non-monotonic).\n+\tPwl Inverse(bool *true_inverse = nullptr, const double eps = 1e-6) const;\n \t// Compose two Pwls together, doing \"this\" first and \"other\" after.\n \tPwl Compose(Pwl const &other, const double eps = 1e-6) const;\n \t// Apply function to (x,y) values at every control point.\n","prefixes":["libcamera-devel","v2","4/6"]}