From patchwork Wed Jun 29 08:57: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: 16425 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 2F346BD808 for ; Wed, 29 Jun 2022 08:57:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DF1C65643; Wed, 29 Jun 2022 10:57:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656493054; bh=LKM41LkvdfqwKIuygN7sVv3WXuRUOjTdLGZvjQ9+rkk=; 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=2OleYZV3aDeSC7OFBOfhHsp1jjZqALrXq4fmQdbHq7oZ77UW5vkplU1hH1dvMVAc5 Q55hr1EnPAcBWE1RBxFPSmqqMuK6ezkRfv9jQRRRh+7tNuwD9YXVIFsI+QWZbZ2oCh xSvDybw0Yith7Z4z2QsjDfUZMSjubTj68k1FI94Ps1eWn6bq0cJ/Ze+/uytITj3/lP PaMJbE82fpR/m56erDX4IxXnR9ci3RtrBs8Oz0SWQPjUpJTDk6iB7A41sQeQnYxvhl gVB2cL7lGCcXfhggawAChqgnp2gkwdTnqAMDHTs3Tg8dh9a/NUs/7HyZr52ejKEWrq cg2kPCy2fDemg== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B9EA6563B for ; Wed, 29 Jun 2022 10:57:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AE/0aNZc"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id i25so15854515wrc.13 for ; Wed, 29 Jun 2022 01:57:31 -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=in89XHK+OhJp/bEi8fRq7qH5ZAnliJIX3PqoxwQ/GOA=; b=AE/0aNZc/P3Jtq+BKPFdeTGC82KaHbeC7FVKdz25WHbKkScg7SaTo6jcfyNbO1JiSH w0j0fBicMpS9wkwAwwYaINrAvZvbqW7GC53o8oCGiRvp3PVOJC18iIyfTvNArXPYWCyP bNLfrWwOhCgyLT8pQ4J1HzsWUpiFtkbJ+QjsxGIjIVWUWrqpZrNNqwUcxZt7su+DDHCc mA9qRDRUiJas7BxOXyHCaVbGahj6XkNvYMvgTObaY6y/hL631ne6qYsAr+An1P1Tykfo E7zPHzTA2rVKN8av2NA1indQmh6yCg20EUfUqiSnVrhktXkqIEu+sC1+vS/3ykukm94K lAJg== 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=in89XHK+OhJp/bEi8fRq7qH5ZAnliJIX3PqoxwQ/GOA=; b=Ztgh3o5ukdpKowkbpMH3s3BfO6zc6TNHE9p9jqsWP1ykY41uHIoyk05G8m8f3UH1OR TklcocYjcc8Y+VSZVAPy1vZlROxlu8G66ptsOVBPbGimNZhsaRSW6pqOv10nvD3QLskL WlRQTcu7CbIqbzGjGhFWSlqIwVwLngtx7qgyTvzhu15whkGC5Cesp2rn9YyP35z9lQ/K lUhty2P5OvgcLNNAKaPnhxxDVSuIZ7aehi8KznPNi0jl7bvX5UOaISROdFa1XuPHUXtK EcJr71TYr6TPcsa5GByT04OxaTbshKs3YG6ZASy55utlubYI2v2U/UwzMlg5BGkfBkhf RROw== X-Gm-Message-State: AJIora/jU4E+w9bB+N/qEBlZLbJc2Wa+JU2+1N4MU9XKmNcAg+zGHbYp OJUjNK6edPN/Ytq44JJeLeI5kYn/VIwlOLB2 X-Google-Smtp-Source: AGRyM1uuKMLm9/ZuS+pq3HAbj1XobfnXtQu6NHUzGTiXwI8EKG24ORz68EiIy6tjpFSldkwxGtdn8Q== X-Received: by 2002:adf:e8c7:0:b0:21d:1c7a:a45f with SMTP id k7-20020adfe8c7000000b0021d1c7aa45fmr1952696wrn.168.1656493050395; Wed, 29 Jun 2022 01:57:30 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b003a032c88877sm2897102wmg.15.2022.06.29.01.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 01:57:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 09:57:22 +0100 Message-Id: <20220629085722.11786-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629085722.11786-1-naush@raspberrypi.com> References: <20220629085722.11786-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/4] ipa: raspberrypi: Use std::optional in DeviceStatus 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" Switch the aperture, lens_position, and flash_intensity fields in the DeviceStatus structure to use std::optional instead of using invalid default values. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/device_status.cpp | 14 ++++++++++---- src/ipa/raspberrypi/controller/device_status.h | 9 ++++----- src/ipa/raspberrypi/controller/rpi/lux.cpp | 4 +--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/ipa/raspberrypi/controller/device_status.cpp b/src/ipa/raspberrypi/controller/device_status.cpp index 05897fc15b50..a389c40dafed 100644 --- a/src/ipa/raspberrypi/controller/device_status.cpp +++ b/src/ipa/raspberrypi/controller/device_status.cpp @@ -12,10 +12,16 @@ std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) { out << "Exposure: " << d.shutter_speed << " Frame length: " << d.frame_length - << " Gain: " << d.analogue_gain - << " Aperture: " << d.aperture - << " Lens: " << d.lens_position - << " Flash: " << d.flash_intensity; + << " Gain: " << d.analogue_gain; + + if (d.aperture) + out << " Aperture: " << *d.aperture; + + if (d.lens_position) + out << " Lens: " << *d.lens_position; + + if (d.flash_intensity) + out << " Flash: " << *d.flash_intensity; if (d.sensor_temperature) out << " Temperature: " << *d.sensor_temperature; diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index eca3bf4b042e..b33f0d093ff3 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -19,8 +19,7 @@ struct DeviceStatus { DeviceStatus() : shutter_speed(std::chrono::seconds(0)), frame_length(0), - analogue_gain(0.0), lens_position(0.0), aperture(0.0), - flash_intensity(0.0) + analogue_gain(0.0) { } @@ -32,11 +31,11 @@ struct DeviceStatus { uint32_t frame_length; double analogue_gain; /* 1.0/distance-in-metres, or 0 if unknown */ - double lens_position; + std::optional lens_position; /* 1/f so that brightness quadruples when this doubles, or 0 if unknown */ - double aperture; + std::optional aperture; /* proportional to brightness with 0 = no flash, 1 = maximum flash */ - double flash_intensity; + std::optional flash_intensity; /* Sensor reported temperature value (in degrees) */ std::optional sensor_temperature; }; diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index f77e9140ac10..4d145b6ff0e9 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -63,9 +63,7 @@ void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) DeviceStatus device_status; if (image_metadata->Get("device.status", device_status) == 0) { double current_gain = device_status.analogue_gain; - double current_aperture = device_status.aperture; - if (current_aperture == 0) - current_aperture = current_aperture_; + double current_aperture = device_status.aperture.value_or(current_aperture_); uint64_t sum = 0; uint32_t num = 0; uint32_t *bin = stats->hist[0].g_hist;