From patchwork Wed Jul 27 08:55:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16842 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 558F2C3275 for ; Wed, 27 Jul 2022 08:55:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E36863327; Wed, 27 Jul 2022 10:55:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658912144; bh=acqARE09DrUQdqyFAbiuK0KCewChClXL4Yf9c2rGuQo=; 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=2OFnpuXiDmEK2aky9PFTDruTT45bvXWxzRGAyG8VgM/uMhFDztLngrIb4u3qZlsm3 X8fnrAp7sRXtFtYDT8j1+Vz2vH5Eb/YtwJPJ7AeWody8GuJUPyJfj7oz5JZ0Ieca80 k+QOYa7CbCsb/jC/yifYJr/M4UmXgqBwoj5FCA2nblBdPp49Eaj5gJtgKYrFq9yr1c A6pvxTDQ+Ii/3x+ip5t2NmByjbgd/WQPPG2Yowb4FtC9cMOR9rN17a89ZfVYIHNMGT gdH3glswAQI/CKafXORZ9qbSFDPNDOSRFC+EoP8Q8uR9FQCZY2/dSFJ8hEj/lBD/KS ZnFWa1/RYWtWg== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 780B863317 for ; Wed, 27 Jul 2022 10:55:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="akhzkcKK"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id l4so1606977wrm.13 for ; Wed, 27 Jul 2022 01:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z+Dnwt2/Z7Eh8rlty1qYrxiGTG7kl6KHrMWHejR+C5Y=; b=akhzkcKKYzJnd2BIE7O/Y2pUG2bL3DLq8Fk2QwqVvvH6+O+Jk1hdOfzR/KvbBLg+hq sEVKVpPapQTjQA7HXW3uHSe9TB+i6ETDboSFPzJIuTtaHOwdw999c8cWWfPZUmAYYBLd 5dgk22SQZnvMRae54rG4jiIn6rZm0RnnxcBUlgYt+ESSdKQxCL3CppO6z+OC07sW5VFT KtCccfPGoEh3jf+2gfpthcBSYOdOxx/QFef+xNyhOAn8twaN5/RWD7sqjCN/yLmzWIH4 U/y9jm0XavwBNJM9k93iZmi2NthuZ0mtARMT4R/2jC2YWhtjeFcig8DJhjdGaJpFNzAi IlQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z+Dnwt2/Z7Eh8rlty1qYrxiGTG7kl6KHrMWHejR+C5Y=; b=bqBpwAZPh/X8gNZVb12XAn5M4N4WpvpxlBdo6CKkNhrJ0vA0Ap/7Q5JsnWbyfSn923 kRwOOFLzpSLRRdfoN2YN7I0wgxxR5MCL0bpxIvWbV/3PY233ctzexdoK5b9pf0v7hebN Y2e3910C4HB1lKq0QWh/x7EqrA+85OO0xrjTWV07AMFoCTqVqiq5EjPyVmFAmdPQ+e7C wNkGs/uWnGDH9QLT4WIPqiLwQUQFxGBZhGc9dlyTA++EXBw3cwI8N2xS9xcPp43G79zQ 0nT/WlkTTt3I7cMEU5eOC0+85jEycaimRgTogi9vkx9o+ZET20EJ31pBPFBQN1Zs+VUN LY2Q== X-Gm-Message-State: AJIora+mpRYB3/LVQWhIUeohLWyND/aoHhvEUshglwJdpUbyO3Gruc96 kiDumVM8Ox3eJPakkyeA1dEby4344rksIQ== X-Google-Smtp-Source: AGRyM1tst/9lPjNB/mYZwHxxSYy0w9BLr6kSogbYqobG88JdayzmQcKF/KrfP8Wh1x3sREvL03yCog== X-Received: by 2002:a05:6000:186b:b0:21e:63c8:b4ad with SMTP id d11-20020a056000186b00b0021e63c8b4admr13257184wri.179.1658912136414; Wed, 27 Jul 2022 01:55:36 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id v3-20020a1cac03000000b003a0375c4f73sm1559408wme.44.2022.07.27.01.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 01:55:35 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 09:55:22 +0100 Message-Id: <20220727085524.13290-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727085524.13290-1-naush@raspberrypi.com> References: <20220727085524.13290-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/8] ipa: raspberryip: Remove all exception throw statements 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace all exception throw statements with LOG(RPi*, Fatal) error messages. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 26 +++++++++------------ src/ipa/raspberrypi/controller/rpi/alsc.cpp | 25 ++++++++------------ src/ipa/raspberrypi/controller/rpi/awb.cpp | 18 ++++++-------- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 9 ++++--- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 2 +- 6 files changed, 34 insertions(+), 48 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 000ab03e2ff7..e9a945e3a630 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -35,11 +35,11 @@ void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) int num = 0; for (auto &p : params.get_child("weights")) { if (num == AGC_STATS_SIZE) - throw std::runtime_error("AgcConfig: too many weights"); + LOG(RPiAgc, Fatal) << "AgcConfig: too many weights"; weights[num++] = p.second.get_value(); } if (num != AGC_STATS_SIZE) - throw std::runtime_error("AgcConfig: insufficient weights"); + LOG(RPiAgc, Fatal) << "AgcConfig: insufficient weights"; } static std::string @@ -78,11 +78,11 @@ void AgcExposureMode::read(boost::property_tree::ptree const ¶ms) int numShutters = readList(shutter, params.get_child("shutter")); int numAgs = readList(gain, params.get_child("gain")); if (numShutters < 2 || numAgs < 2) - throw std::runtime_error( - "AgcConfig: must have at least two entries in exposure profile"); + LOG(RPiAgc, Fatal) + << "AgcConfig: must have at least two entries in exposure profile"; if (numShutters != numAgs) - throw std::runtime_error( - "AgcConfig: expect same number of exposure and gain entries in exposure profile"); + LOG(RPiAgc, Fatal) + << "AgcConfig: expect same number of exposure and gain entries in exposure profile"; } static std::string @@ -106,8 +106,7 @@ void AgcConstraint::read(boost::property_tree::ptree const ¶ms) transform(boundString.begin(), boundString.end(), boundString.begin(), ::toupper); if (boundString != "UPPER" && boundString != "LOWER") - throw std::runtime_error( - "AGC constraint type should be UPPER or LOWER"); + LOG(RPiAgc, Fatal) << "AGC constraint type should be UPPER or LOWER"; bound = boundString == "UPPER" ? Bound::UPPER : Bound::LOWER; qLo = params.get("q_lo"); qHi = params.get("q_hi"); @@ -465,8 +464,7 @@ void Agc::housekeepConfig() if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) { auto it = config_.meteringModes.find(meteringModeName_); if (it == config_.meteringModes.end()) - throw std::runtime_error("Agc: no metering mode " + - meteringModeName_); + LOG(RPiAgc, Fatal) << "Agc: no metering mode " << meteringModeName_; meteringMode_ = &it->second; copyString(meteringModeName_, status_.meteringMode, sizeof(status_.meteringMode)); @@ -474,8 +472,7 @@ void Agc::housekeepConfig() if (strcmp(exposureModeName_.c_str(), status_.exposureMode)) { auto it = config_.exposureModes.find(exposureModeName_); if (it == config_.exposureModes.end()) - throw std::runtime_error("Agc: no exposure profile " + - exposureModeName_); + LOG(RPiAgc, Fatal) << "Agc: no exposure profile " << exposureModeName_; exposureMode_ = &it->second; copyString(exposureModeName_, status_.exposureMode, sizeof(status_.exposureMode)); @@ -484,8 +481,7 @@ void Agc::housekeepConfig() auto it = config_.constraintModes.find(constraintModeName_); if (it == config_.constraintModes.end()) - throw std::runtime_error("Agc: no constraint list " + - constraintModeName_); + LOG(RPiAgc, Fatal) << "Agc: no constraint list " << constraintModeName_; constraintMode_ = &it->second; copyString(constraintModeName_, status_.constraintMode, sizeof(status_.constraintMode)); @@ -502,7 +498,7 @@ void Agc::fetchCurrentExposure(Metadata *imageMetadata) DeviceStatus *deviceStatus = imageMetadata->getLocked("device.status"); if (!deviceStatus) - throw std::runtime_error("Agc: no device metadata"); + LOG(RPiAgc, Fatal) << "Agc: no device metadata"; current_.shutter = deviceStatus->shutterSpeed; current_.analogueGain = deviceStatus->analogueGain; AgcStatus *agcStatus = diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 35da336ebc72..7df89445711a 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -54,10 +54,10 @@ static void generateLut(double *lut, boost::property_tree::ptree const ¶ms) { double cstrength = params.get("corner_strength", 2.0); if (cstrength <= 1.0) - throw std::runtime_error("Alsc: corner_strength must be > 1.0"); + LOG(RPiAlsc, Fatal) << "Alsc: corner_strength must be > 1.0"; double asymmetry = params.get("asymmetry", 1.0); if (asymmetry < 0) - throw std::runtime_error("Alsc: asymmetry must be >= 0"); + LOG(RPiAlsc, Fatal) << "Alsc: asymmetry must be >= 0"; double f1 = cstrength - 1, f2 = 1 + sqrt(cstrength); double R2 = X * Y / 4 * (1 + asymmetry * asymmetry); int num = 0; @@ -79,12 +79,11 @@ static void readLut(double *lut, boost::property_tree::ptree const ¶ms) const int maxNum = XY; for (auto &p : params) { if (num == maxNum) - throw std::runtime_error( - "Alsc: too many entries in LSC table"); + LOG(RPiAlsc, Fatal) << "Alsc: too many entries in LSC table"; lut[num++] = p.second.get_value(); } if (num < maxNum) - throw std::runtime_error("Alsc: too few entries in LSC table"); + LOG(RPiAlsc, Fatal) << "Alsc: too few entries in LSC table"; } static void readCalibrations(std::vector &calibrations, @@ -96,9 +95,8 @@ static void readCalibrations(std::vector &calibrations, for (auto &p : params.get_child(name)) { double ct = p.second.get("ct"); if (ct <= lastCt) - throw std::runtime_error( - "Alsc: entries in " + name + - " must be in increasing ct order"); + LOG(RPiAlsc, Fatal) + << "Alsc: entries in " << name << " must be in increasing ct order"; AlscCalibration calibration; calibration.ct = lastCt = ct; boost::property_tree::ptree const &table = @@ -106,17 +104,14 @@ static void readCalibrations(std::vector &calibrations, int num = 0; for (auto it = table.begin(); it != table.end(); it++) { if (num == XY) - throw std::runtime_error( - "Alsc: too many values for ct " + - std::to_string(ct) + " in " + - name); + LOG(RPiAlsc, Fatal) + << "Alsc: too many values for ct " << ct << " in " << name; calibration.table[num++] = it->second.get_value(); } if (num != XY) - throw std::runtime_error( - "Alsc: too few values for ct " + - std::to_string(ct) + " in " + name); + LOG(RPiAlsc, Fatal) + << "Alsc: too few values for ct " << ct << " in " << name; calibrations.push_back(calibration); LOG(RPiAlsc, Debug) << "Read " << name << " calibration for ct " << ct; diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index e1dc52ac0c98..d87a8f358539 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -46,18 +46,15 @@ static void readCtCurve(Pwl &ctR, Pwl &ctB, double ct = it->second.get_value(); assert(it == params.begin() || ct != ctR.domain().end); if (++it == params.end()) - throw std::runtime_error( - "AwbConfig: incomplete CT curve entry"); + LOG(RPiAwb, Fatal) << "AwbConfig: incomplete CT curve entry"; ctR.append(ct, it->second.get_value()); if (++it == params.end()) - throw std::runtime_error( - "AwbConfig: incomplete CT curve entry"); + LOG(RPiAwb, Fatal) << "AwbConfig: incomplete CT curve entry"; ctB.append(ct, it->second.get_value()); num++; } if (num < 2) - throw std::runtime_error( - "AwbConfig: insufficient points in CT curve"); + LOG(RPiAwb, Fatal) << "AwbConfig: insufficient points in CT curve"; } void AwbConfig::read(boost::property_tree::ptree const ¶ms) @@ -74,12 +71,11 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) AwbPrior prior; prior.read(p.second); if (!priors.empty() && prior.lux <= priors.back().lux) - throw std::runtime_error("AwbConfig: Prior must be ordered in increasing lux value"); + LOG(RPiAwb, Fatal) << "AwbConfig: Prior must be ordered in increasing lux value"; priors.push_back(prior); } if (priors.empty()) - throw std::runtime_error( - "AwbConfig: no AWB priors configured"); + LOG(RPiAwb, Fatal) << "AwbConfig: no AWB priors configured"; } if (params.get_child_optional("modes")) { for (auto &p : params.get_child("modes")) { @@ -88,7 +84,7 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) defaultMode = &modes[p.first]; } if (defaultMode == nullptr) - throw std::runtime_error("AwbConfig: no AWB modes configured"); + LOG(RPiAwb, Fatal) << "AwbConfig: no AWB modes configured"; } minPixels = params.get("min_pixels", 16.0); minG = params.get("min_G", 32); @@ -98,7 +94,7 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) transversePos = params.get("transverse_pos", 0.01); transverseNeg = params.get("transverse_neg", 0.01); if (transversePos <= 0 || transverseNeg <= 0) - throw std::runtime_error("AwbConfig: transverse_pos/neg must be > 0"); + LOG(RPiAwb, Fatal) << "AwbConfig: transverse_pos/neg must be > 0"; sensitivityR = params.get("sensitivity_r", 1.0); sensitivityB = params.get("sensitivity_b", 1.0); if (bayes) { diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index 8095c42dc0c8..cf0c85d26cf9 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -45,11 +45,11 @@ void Matrix::read(boost::property_tree::ptree const ¶ms) int n = 0; for (auto it = params.begin(); it != params.end(); it++) { if (n++ == 9) - throw std::runtime_error("Ccm: too many values in CCM"); + LOG(RPiCcm, Fatal) << "Ccm: too many values in CCM"; *ptr++ = it->second.get_value(); } if (n < 9) - throw std::runtime_error("Ccm: too few values in CCM"); + LOG(RPiCcm, Fatal) << "Ccm: too few values in CCM"; } Ccm::Ccm(Controller *controller) @@ -70,12 +70,11 @@ void Ccm::read(boost::property_tree::ptree const ¶ms) ctCcm.ccm.read(p.second.get_child("ccm")); if (!config_.ccms.empty() && ctCcm.ct <= config_.ccms.back().ct) - throw std::runtime_error( - "Ccm: CCM not in increasing colour temperature order"); + LOG(RPiCcm, Fatal) << "Ccm: CCM not in increasing colour temperature order"; config_.ccms.push_back(std::move(ctCcm)); } if (config_.ccms.empty()) - throw std::runtime_error("Ccm: no CCMs specified"); + LOG(RPiCcm, Fatal) << "Ccm: no CCMs specified"; } void Ccm::setSaturation(double saturation) diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 9cd78abe28d6..d5d784e7ca64 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -35,7 +35,7 @@ void Dpc::read(boost::property_tree::ptree const ¶ms) { config_.strength = params.get("strength", 1); if (config_.strength < 0 || config_.strength > 2) - throw std::runtime_error("Dpc: bad strength value"); + LOG(RPiDpc, Fatal) << "Dpc: bad strength value"; } void Dpc::prepare(Metadata *imageMetadata) diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 4e8ed696851b..696da4aeea59 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -40,7 +40,7 @@ void Geq::read(boost::property_tree::ptree const ¶ms) config_.offset = params.get("offset", 0); config_.slope = params.get("slope", 0.0); if (config_.slope < 0.0 || config_.slope >= 1.0) - throw std::runtime_error("Geq: bad slope value"); + LOG(RPiGeq, Fatal) << "Geq: bad slope value"; if (params.get_child_optional("strength")) config_.strength.read(params.get_child("strength")); }