From patchwork Mon Jul 25 13:46:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16767 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 957A9C3275 for ; Mon, 25 Jul 2022 13:47:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6055163326; Mon, 25 Jul 2022 15:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658756824; bh=coyL7A+RDv/0GmHd5bO9x3qwbpcjqNLg3YfYdCPB1PE=; 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=aSKjGoZJHUQXgQ6hJhOwPbmwGPosFBI0ndyHzdOhEeg+sBind32y127dV2DgrVOG9 /ocnI6XRmf2Z3r2rHavcgPBfX4TkmLmVTMfpjpECXj35roJ2pFo7tqfW312NzXD/6M GRrloVQKlD/jhKEXLGcFsNe3I1BTlZFgR46cMQJPH5t52VCvagimDqIVICij8tUc1x lbVuyhJusHelBeaJVVO+VTf8eTbalE1vTvaNQW/Ce7wtvMMaQelbezWtuPeV83/CC2 gZk0qGyd+wZhhzDBgK6dhd9CqBjQdhpbOAIEZ0syfS8rLYqBQQJnN4HgDTkqVyAT62 8drwsBjqJgC+A== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8A5263323 for ; Mon, 25 Jul 2022 15:46:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="m9wMmZJW"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id d8so15976123wrp.6 for ; Mon, 25 Jul 2022 06:46:55 -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=rMnW7KSk/HdaD7cYFcdYBQQ2FVAxVpWZvjnKr699LO4=; b=m9wMmZJWuZOECPZpfzFdFpMVbU7Fxyz+B3C48P11owORq3zfhnpaqbZKZgWxzj6+fB MkMkma/+yk5Yi6HJ/oBFsaDpoYuexFkipnXeFNkCuIwVJsK12hoEnrtVEtyMhvpU8+ub fteOSwNI8KAB/6URig/rFNdU43ZYjegtQH0hq68vaZ/aLzUlpVck75yH0LSkom+xtN/d q3Gv8gTkTq2cNftGnxn6UuuKJTtlmKwyycbavMYor5Id/G4bVMwGugAia4qaCGhM73q6 vrbvtckK/VFt7hgt8z2nXVtA1ZMZujjMhpzScMKk/+UOHHqexmUUe009g2bjLw+024DS ozzQ== 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=rMnW7KSk/HdaD7cYFcdYBQQ2FVAxVpWZvjnKr699LO4=; b=W7MVb2KeoV68CJ6Ix1i0dKlP5KJagq3uxLmh9AuV50H1EspEPw6vaJjZWv6h8MuubN efo0T90jlf3VYxqQyVnWYKhRYPnpqcuNO0Sm5Cv/jzm5JFswQUGTe6xNM9KY9CbGVx3U /8kc8Z2og1FoUHiUTzv3rZLzJFv+TdDbE/z72CHzV8rBELQWo/wdI76FvgFcXqx9PFb7 7B3/SaNlq0Plf2trQOgIgedBOxhWRv9VabpWkhB1WSZtyCRbiescrzqvFAPlRoZTSL19 EDiX9Wc7empET8ObgwQqUJqBE8jRpypRikQu8wIoNinbxwG+6n9fpVkoVaBIGzjKkh1d cONw== X-Gm-Message-State: AJIora9jGUoUB3daVxHbCRdJZHIPflsNQqcEDIffSWu6DtQ9mFcPXxZd DjxFayXrZk3ft0eBLIzpWLKOk/2lTU0UsA== X-Google-Smtp-Source: AGRyM1sIdbtzopEhrSQis4CVcTApKSVUoySwLGFnXw4+V+16kVfBEpdktXYwxCw64yeGMNhfb+tOJg== X-Received: by 2002:a05:6000:23b:b0:21e:6dae:f046 with SMTP id l27-20020a056000023b00b0021e6daef046mr7401793wrz.661.1658756815062; Mon, 25 Jul 2022 06:46:55 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id a20-20020a05600c225400b003a32167b8d4sm18054320wmm.13.2022.07.25.06.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 06:46:54 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jul 2022 14:46:39 +0100 Message-Id: <20220725134639.4572-16-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220725134639.4572-1-naush@raspberrypi.com> References: <20220725134639.4572-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 15/15] 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 2c7928bbac4d..0f44ceb3feda 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_.constraint_mode, sizeof(status_.constraint_mode)); @@ -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 7dd35aef10c4..f2111a7f63ec 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 5f601290ce72..aabfec6bd672 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")); }