From patchwork Fri Jun 24 07:35:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16366 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 DD513BD808 for ; Fri, 24 Jun 2022 07:35:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 498F46563F; Fri, 24 Jun 2022 09:35:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656056138; bh=sDyI8g97X48JdfiwaxJIL/+wnmJROB56cMLoq2m57ds=; 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=DpZ1oidmrhBCPWdH2Q+1rc4PEdmAXrCrR2jSmXj9P4Mv1i7udGouDfQDIiQwkyG21 fPbdhWStAy+GwDhCDCuV4xfMFaUv4KXba7HXEPtawi3pziIx9DPpFaan/IvtdAd9RP pnZmiMC6LriwerP7LqpjFTPANxE7cp/wucKxt514NxFA2bQo2Lxr6tKp+OGmzO4Zlr ouT5/Sf9XbuHWqfA8NGwuLLMLsjma+NJJ/sRZG4xvjIxfdd8FGLb5xpWwCrYzAFaVX WLT7WM5C6KL8A9m7nNQoLGaI+R+d2YGBzWe/CqpIFGVBnaaavYVPoVMh8XcBu1zHIX mgNkIrx4BGqVQ== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D72D6563D for ; Fri, 24 Jun 2022 09:35:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iHnBBxLR"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id u12-20020a05600c210c00b003a02b16d2b8so1013970wml.2 for ; Fri, 24 Jun 2022 00:35:34 -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=HNrdXmmfeCNlElA1aGia+hElBRScKTSJx9yNux7DNGw=; b=iHnBBxLRDTDcx+Nj9dfk5oD7jql3ZS+1SjBYVVw7C/AL4hCYYWxZwnhQjDrR2QdeGC pEphLKW6b30wwsMuAk8GvYy2kShx85ZJ+22adeQbzyuyHv3TXecqlbLhlMNhw1IVPud6 2xOcCDOjAHPRuAsBZdlDHXZUoGdeNSL66RLTFGXZOhcnRSIcg80hLnzIH8Erd6xFZO/7 YXSFaak/WgN4E92wQqxI9fAcHyIKZMbPOxDPv4XqgL1mjS+IrE1knSx9pxEzDltR/EK/ WUpRhDdK/Npr8eOhmiEJhbcNrJP7/QBx7TFhKrw6L3VGuYs+ePx9JZE4D0E+i+V6IW6c Z75g== 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=HNrdXmmfeCNlElA1aGia+hElBRScKTSJx9yNux7DNGw=; b=ZvTE0+WESr9dmy5Q7ezyqd/TJ+mikjBodh2yDxY+xxhXK2rMRalnPp4KKskZ3oj1Gw r9TaUjKbDYxNyoPqzuZcw0qc5MKF3sAqpQ/kxuRGIvMqTRV0Sgl1ewgwcFywscOXqdeT ln0xxGmNS3n+RQIdPLhKboa8bHoqnkvkhIZ45SvfuO/le5uUqMLAW/lIAMnPbKEkiUdK +DV7avPMI40Wdx2rSepNerHB11cQ4dOx/NqygA0V4WPZaJLDo5xY3nSLs2MHsA2kKN3H sNXV5hpbDrTgA8ssGmUT4e2QsMaz0XYLR81sDLvT1h9wsCTn96ONBCXxnmfJRDP0gePm tDOw== X-Gm-Message-State: AJIora+S0gB8JSyfUNwXLhgHq1VuMgMJNZRoo3u+eT5SWHYZYYpWtiTs dGJY6En2247eF+0d3mFhbWf0wT4DdOljeOPu X-Google-Smtp-Source: AGRyM1u8StVfx0AuyD9UNyTj7SgaNC1zzyd1nXOaHk6TLdTNoteHBMgr3sOYHsU4TqQ+N0LZ9FkjGA== X-Received: by 2002:a05:600c:4fd4:b0:3a0:334e:241e with SMTP id o20-20020a05600c4fd400b003a0334e241emr2237363wmq.73.1656056133542; Fri, 24 Jun 2022 00:35:33 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b0039ee391a024sm6695195wmg.14.2022.06.24.00.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 00:35:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Jun 2022 08:35:28 +0100 Message-Id: <20220624073528.26670-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624073528.26670-1-naush@raspberrypi.com> References: <20220624073528.26670-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 5 ++--- 3 files changed, 16 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..643fb8fbaac6 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -63,9 +63,8 @@ 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 ? *device_status.aperture + : current_aperture_; uint64_t sum = 0; uint32_t num = 0; uint32_t *bin = stats->hist[0].g_hist;