From patchwork Sun Oct 9 04:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17562 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F1D4FBD16B for ; Sun, 9 Oct 2022 04:44:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B5A8D62D52; Sun, 9 Oct 2022 06:44:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665290691; bh=mboVyrXr+3MIU/mUf+w7XxCKHp0dSH6gPDbX4nn2D/M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=l+H/+t1AnE8V7ll4xC0Yy0edYLS1wdvPW9JI17KCE7zuD2cA9fFbuBCXcEIup67dB chGCaLkCX7zbLB9SuNCUcQSb1VVOAaXK0mG9H+iOAxPQx9YYIUMkV2bBkYYrS1X+9V pTUEB4SgCoZibSmpDp2ogccBDwbASifWwMD4Ug/Gfi1l8MSMg0i0BKcGvmCIMpZTmy kQ9Xr82lONYYeKJ/ppFmYEdXFRwsBSUf7GKpHkHXMuczKJpndfQCmD1RRENJKuhXmc ZA7Bk/oHS3qYG2oarZkuORIFkNthxEIVz8jTJ4AMgN0/woykF0+HKEuQg6daxrqMNE fqvAdhjFM4EXQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5758462D49 for ; Sun, 9 Oct 2022 06:44:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tkf/MLA3"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AF3F79C4 for ; Sun, 9 Oct 2022 06:44:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665290687; bh=mboVyrXr+3MIU/mUf+w7XxCKHp0dSH6gPDbX4nn2D/M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tkf/MLA3+gKOw4YYHOaRf+v1vf7rz7Whg/eI/AlaRIyyEGKhEAafieMiuXW+Q2fmF vrVeu7POOCQvHiwLCs7fS9McnugQnw2JyBomEdovZ7WgT90QoPTZAOa96oDiXPtBQP i8CaEcvCesxxrberpse4dfqWe+T6+DgdtU3JkuT4= To: libcamera-devel@lists.libcamera.org Date: Sun, 9 Oct 2022 07:44:39 +0300 Message-Id: <20221009044440.21499-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009044440.21499-1-laurent.pinchart@ideasonboard.com> References: <20221009044440.21499-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] ipa: rkisp1: Drop use of utils::defopt X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" utils::defopt causes compilation issues on gcc 8.0.0 to gcc 8.3.0, likely due to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 that was fixed in gcc 8.4.0. gcc 8.3.0 may be considered old (libcamera requires gcc-8 or newer), but it is shipped by Debian 10 that has LTS support until mid-2024. As no workaround has been found to fix compilation on gcc 8.3.0 while still retaining the functionality of utils::defopt, stop using it in the RkISP1 IPA module. Signed-off-by: Laurent Pinchart --- src/ipa/rkisp1/algorithms/dpf.cpp | 6 +++--- src/ipa/rkisp1/algorithms/gsl.cpp | 8 ++++---- src/ipa/rkisp1/algorithms/lsc.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp index 82d4f7fecc67..5bd7e59f651c 100644 --- a/src/ipa/rkisp1/algorithms/dpf.cpp +++ b/src/ipa/rkisp1/algorithms/dpf.cpp @@ -70,7 +70,7 @@ int Dpf::init([[maybe_unused]] IPAContext &context, * +---------|--------> X * -4....-1 0 1 2 3 4 */ - values = dFObject["g"].getList().value_or(utils::defopt); + values = dFObject["g"].getList().value_or(std::vector{}); if (values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS) { LOG(RkISP1Dpf, Error) << "Invalid 'DomainFilter:g': expected " @@ -106,7 +106,7 @@ int Dpf::init([[maybe_unused]] IPAContext &context, * For a 9x9 kernel, columns -6 and 6 are dropped, so coefficient * number 6 is not used. */ - values = dFObject["rb"].getList().value_or(utils::defopt); + values = dFObject["rb"].getList().value_or(std::vector{}); if (values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS && values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1) { LOG(RkISP1Dpf, Error) @@ -135,7 +135,7 @@ int Dpf::init([[maybe_unused]] IPAContext &context, const YamlObject &rFObject = tuningData["NoiseLevelFunction"]; std::vector nllValues; - nllValues = rFObject["coeff"].getList().value_or(utils::defopt); + nllValues = rFObject["coeff"].getList().value_or(std::vector{}); if (nllValues.size() != RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS) { LOG(RkISP1Dpf, Error) << "Invalid 'RangeFilter:coeff': expected " diff --git a/src/ipa/rkisp1/algorithms/gsl.cpp b/src/ipa/rkisp1/algorithms/gsl.cpp index a80fed589bb2..b9f879124633 100644 --- a/src/ipa/rkisp1/algorithms/gsl.cpp +++ b/src/ipa/rkisp1/algorithms/gsl.cpp @@ -59,7 +59,7 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) { std::vector xIntervals = - tuningData["x-intervals"].getList().value_or(utils::defopt); + tuningData["x-intervals"].getList().value_or(std::vector{}); if (xIntervals.size() != kDegammaXIntervals) { LOG(RkISP1Gsl, Error) << "Invalid 'x' coordinates: expected " @@ -83,7 +83,7 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context, return -EINVAL; } - curveYr_ = yObject["red"].getList().value_or(utils::defopt); + curveYr_ = yObject["red"].getList().value_or(std::vector{}); if (curveYr_.size() != RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE) { LOG(RkISP1Gsl, Error) << "Invalid 'y:red' coordinates: expected " @@ -92,7 +92,7 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context, return -EINVAL; } - curveYg_ = yObject["green"].getList().value_or(utils::defopt); + curveYg_ = yObject["green"].getList().value_or(std::vector{}); if (curveYg_.size() != RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE) { LOG(RkISP1Gsl, Error) << "Invalid 'y:green' coordinates: expected " @@ -101,7 +101,7 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context, return -EINVAL; } - curveYb_ = yObject["blue"].getList().value_or(utils::defopt); + curveYb_ = yObject["blue"].getList().value_or(std::vector{}); if (curveYb_.size() != RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE) { LOG(RkISP1Gsl, Error) << "Invalid 'y:blue' coordinates: expected " diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index 102535bd11a4..de2de0139747 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -43,7 +43,7 @@ static std::vector parseSizes(const YamlObject &tuningData, const char *prop) { std::vector sizes = - tuningData[prop].getList().value_or(utils::defopt); + tuningData[prop].getList().value_or(std::vector{}); if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) { LOG(RkISP1Lsc, Error) << "Invalid '" << prop << "' values: expected " @@ -76,7 +76,7 @@ static std::vector parseTable(const YamlObject &tuningData, RKISP1_CIF_ISP_LSC_SAMPLES_MAX * RKISP1_CIF_ISP_LSC_SAMPLES_MAX; std::vector table = - tuningData[prop].getList().value_or(utils::defopt); + tuningData[prop].getList().value_or(std::vector{}); if (table.size() != kLscNumSamples) { LOG(RkISP1Lsc, Error) << "Invalid '" << prop << "' values: expected " From patchwork Sun Oct 9 04:44:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17563 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DC8A2C327C for ; Sun, 9 Oct 2022 04:44:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34F1162D50; Sun, 9 Oct 2022 06:44:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665290692; bh=Y1wygcPwghVzW4K6saB4YoVPipBJTeHDFj0IBQZn83k=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cM4u3TBxnQlY9p/SpQ81XqDR9aenbBVl+u/svCSeFt6dyCLm2PaYtvcPVZb+A/3r2 KKBqKy2lJgur8Eh95lsU0jy4SyAdP/QzGTjkEpaKzmDyxfkSueGPGx5q9UvJn6FMoo yxX4fltqUQ0CgDbbNJLQfwW222/rbC71iMsbVDu5dktCY7hTO6KgkMbB2PMNjdiU4U VFdZx+UGDXpzpegb2UGt/fUvux0lXhfJCzq5+fqsfb40JsiEVl/tA7c51k6t+MK+rU IxInzuDKxD7qgtjyhVPAObduz5D4HH9sKz5cpmjugYpB8ZS4bTCtqEIeGojf732Vgl KnDTqAbFERfyQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E19CA62D49 for ; Sun, 9 Oct 2022 06:44:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mcZUYp9z"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 48D499C4 for ; Sun, 9 Oct 2022 06:44:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665290689; bh=Y1wygcPwghVzW4K6saB4YoVPipBJTeHDFj0IBQZn83k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mcZUYp9zUgq0VPFcdakQ0kTb3EsIrjiv3TVqgT+aAgyFdSoY3souTrS7M59sIGRAQ yQGOZnkEf5iP8Sm0eEkkchvwD6PrOBKOQWd4ln/uVmzUAX0O1fVPi4FakgDLWcQNhR 0kNQdz62RNYgEyxAKFch0xjGp9X5RKwfR9WINBAw= To: libcamera-devel@lists.libcamera.org Date: Sun, 9 Oct 2022 07:44:40 +0300 Message-Id: <20221009044440.21499-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009044440.21499-1-laurent.pinchart@ideasonboard.com> References: <20221009044440.21499-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: base: utils: Drop defopt X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" utils::defopt causes compilation issues on gcc 8.0.0 to gcc 8.3.0, likely due to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 that was fixed in gcc 8.4.0. gcc 8.3.0 may be considered old (libcamera requires gcc-8 or newer), but it is shipped by Debian 10 that has LTS support until mid-2024. As no workaround has been found to fix compilation on gcc 8.3.0 while still retaining the functionality of utils::defopt, remove it from the libcamera base library. This change could be reverted once support for gcc-8 will be dropped. Signed-off-by: Laurent Pinchart --- include/libcamera/base/utils.h | 14 --------- src/libcamera/base/utils.cpp | 21 -------------- test/utils.cpp | 53 ---------------------------------- 3 files changed, 88 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index ed88b7163770..eb7bcdf4c173 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -367,20 +367,6 @@ decltype(auto) abs_diff(const T &a, const T &b) return a - b; } -namespace details { - -struct defopt_t { - template - operator T() const - { - return T{}; - } -}; - -} /* namespace details */ - -constexpr details::defopt_t defopt; - } /* namespace utils */ #ifndef __DOXYGEN__ diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 9cd6cb197243..6a307940448e 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -463,27 +463,6 @@ std::string toAscii(const std::string &str) * \a b */ -/** - * \var defopt - * \brief Constant used with std::optional::value_or() to create a - * default-constructed object - * - * The std::optional::value_or(U &&default_value) function returns the - * contained value if available, or \a default_value if the std::optional has no - * value. If the desired default value is a default-constructed T, the obvious - * option is to call std::optional::value_or(T{}). This approach has two - * drawbacks: - * - * * The \a default_value T{} is constructed even if the std::optional instance - * has a value, which impacts efficiency. - * * The T{} default constructor needs to be spelled out explicitly in the - * value_or() call, leading to long lines if the type is complex. - * - * The defopt variable solves these issues by providing a value that can be - * passed to std::optional::value_or() and get implicitly converted to a - * default-constructed T. - */ - } /* namespace utils */ #ifndef __DOXYGEN__ diff --git a/test/utils.cpp b/test/utils.cpp index 58b5a59dd17d..fc56e14ee734 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -170,55 +170,6 @@ protected: return TestPass; } - int testDefopt() - { - static bool defaultConstructed = false; - - struct ValueType { - ValueType() - : value_(-1) - { - defaultConstructed = true; - } - - ValueType(int value) - : value_(value) - { - } - - int value_; - }; - - /* - * Test that utils::defopt doesn't cause default-construction - * of a ValueType instance when value_or(utils::defopt) is - * called on a std::optional that has a value. - */ - std::optional opt = ValueType(0); - ValueType value = opt.value_or(utils::defopt); - - if (defaultConstructed || value.value_ != 0) { - std::cerr << "utils::defopt didn't prevent default construction" - << std::endl; - return TestFail; - } - - /* - * Then test that the ValueType is correctly default-constructed - * when the std::optional has no value. - */ - opt = std::nullopt; - value = opt.value_or(utils::defopt); - - if (!defaultConstructed || value.value_ != -1) { - std::cerr << "utils::defopt didn't cause default construction" - << std::endl; - return TestFail; - } - - return TestPass; - } - int run() { /* utils::hex() test. */ @@ -339,10 +290,6 @@ protected: if (testDuration() != TestPass) return TestFail; - /* utils::defopt test. */ - if (testDefopt() != TestPass) - return TestFail; - return TestPass; } };