Patch Detail
Show a patch.
GET /api/1.1/patches/16143/?format=api
{ "id": 16143, "url": "https://patchwork.libcamera.org/api/1.1/patches/16143/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16143/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220603220712.73673-2-Rauch.Christian@gmx.de>", "date": "2022-06-03T22:07:08", "name": "[libcamera-devel,v6,1/5] libcamera: controls: Use std::optional to handle invalid control values", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3f9d6ea520fb692efcb64370df8486b284725fd8", "submitter": { "id": 111, "url": "https://patchwork.libcamera.org/api/1.1/people/111/?format=api", "name": "Christian Rauch", "email": "Rauch.Christian@gmx.de" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16143/mbox/", "series": [ { "id": 3158, "url": "https://patchwork.libcamera.org/api/1.1/series/3158/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3158", "date": "2022-06-03T22:07:07", "name": "generate and use fixed-sized Span Control types", "version": 6, "mbox": "https://patchwork.libcamera.org/series/3158/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16143/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16143/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AA342C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 3 Jun 2022 22:07:21 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 89C4765638;\n\tSat, 4 Jun 2022 00:07:19 +0200 (CEST)", "from mout.gmx.net (mout.gmx.net [212.227.15.15])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 49B5D633A4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 4 Jun 2022 00:07:16 +0200 (CEST)", "from localhost.localdomain ([92.18.80.244]) by mail.gmx.net\n\t(mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id\n\t1MEm6L-1nzESW3M43-00GLFX; Sat, 04 Jun 2022 00:07:15 +0200" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654294039;\n\tbh=i5YbH2fpAbEvT30PjxeDlgk5SUPAfgOejLuBK9CAmfc=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=gRXNCBknTQZ/G6cVdgrAQVroqgSTMBHzdVlc280Q9cCk9INixvsixTvVBEY+Eprc7\n\tDc2r3A7pFaL+4/3HajxFI5CzGulq69E8oFp05wH6KCYu4agvRi6KuxotsftfswXCRs\n\tXaKSANZfZM+gLS/waxfBQZ3K1xr0zx0ZhJ2biaTmVWnBZf3QVWgd8xYLbNrDFhIP2C\n\ttrGZCd7KRrcL59HEQvjHKtETp3tuWvwW63Sd95uTERS25QaTP148dGYZe2/mnxalMJ\n\tEE+HVh4yHOPWoS8wZ+F7Se0SP0FpA0O8XfQCupYg11iDlUdrC610xzLUtOBG4/XWBJ\n\tle87/3TCxElFw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1654294036;\n\tbh=i5YbH2fpAbEvT30PjxeDlgk5SUPAfgOejLuBK9CAmfc=;\n\th=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=F+RBslza6N/vHfnTkdIRSGq5MGnog96VY9dTuaxFY+CUPqyMb+cLPwHdWclc1KCoe\n\tipKPTaoxgIL2w6fDJiToEEc9cbwMjBJ0xmvu7LGLPjum69RautlcmndredQunX0DOE\n\tS9pt+flS/tqao4tcIW5aGmAUeJynoNY3T/JjA8BQ=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"F+RBslza\"; dkim-atps=neutral", "X-UI-Sender-Class": "01bb95c1-4bf8-414a-932a-4f6e2808ef9c", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 3 Jun 2022 23:07:08 +0100", "Message-Id": "<20220603220712.73673-2-Rauch.Christian@gmx.de>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220603220712.73673-1-Rauch.Christian@gmx.de>", "References": "<20220603220712.73673-1-Rauch.Christian@gmx.de>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "quoted-printable", "X-Provags-ID": "V03:K1:4Wku12GC9+AMxLF+f5FJG+YH+beersrCBNw59KD+9RkGftuOFkz\n\tiLBYjH4M3Pz3w1Yb9tEPeIpsdxEcsq/z45qFEsSBk9662U8vtICiQXfHW5YY+OxvYIWMaXx\n\tXOjQ/CV2DtiJKXxufYPGGSizdfw1ZqUTlL8Kh9BLZeoUynv8NYCmJMrtqWyrT86H5dfu+0C\n\tFQZD5GWb/HAPQDWWhL5iA==", "X-Spam-Flag": "NO", "X-UI-Out-Filterresults": "notjunk:1; V03:K0:4pf/dJkHfOs=:bN4fWdSFf2PKDkQZGp0btM\n\tD6XAcVsuBVuHO9UeKfDj7FMGTDgMhYVfoC2UCbSUTu+7Kl1631LEtXoBTbaKKQhxKMZBfMXNa\n\ttHDXZsr8Mj0aJ2kLojeDu4/4oxCrSUSb5wOD8jnOg4N92OB6bBA+p1yUHshoFtDncdwPaPoZn\n\tsZWD2ZbbxDP5Z3tnt1Y+MWkB+Q332qzbzKNmCwX9WNbHu5V6F0dMJW4/7AHnQ3IAR4WeOjOqY\n\ts2AqQQ/Vr1M2pmpvQ/RG6ZNeA7WdJ0DRb6uI2b3PoKXTOMbRphOU/dmEQuqNRVYl0p/t1Hn+a\n\tmZKdo1cLgFThJ7WraQ3aaz96LxZMR1B6osK/tL276rbqYfjYksMK5yyDMt3Ko/YKzKPFwjHLY\n\t81g6a0ZDjG7EVQeilOtCaZk962ggdHmIeeF+7P80LWh52oJbtELTVaj6rt/gnXpwtG5GU9wiH\n\tXREZlTuwv3/LRScZyBxLQBiuVUn1aWmzLLCkvWBekxVihBwZs2SGAwbnjgUGCTuOIJTyqvhrE\n\tA9dy+1ZDK0D2vTQI8oBhgKKuMwvCCc8C064BdXlQQ66bMzOiG2Lq9kb7NIT4puFvTsOYmRIwR\n\tkjP9tIaajKUPHOykGGgUiyjD2p+4TSWu2vxXCrEyEjIHKGOIMt6DKHGMYmYRUNM3f1MOp42Ub\n\tJLn4ghdGXuEyYeOYiFcI7uf+lLsy16B9YyjTWOPSKRAjKPAMxvrJ227vWvZ/T9Or5/MrwsltH\n\tmlIbWvsFpXHALEO7VH4xxXdqGOWeg1cv7rMpD9EPvHTCfbUwyPpX6XAPZ3DB+PP8kf0Gr8yPl\n\taBsw5oVFPoIC4JCxidvtY5X3moXZ7Fn9I9xAN264vVfG8cMzISr56XNkosB3LzM18tnE4T6gH\n\tt9f1QOsAixVeeSj0C8gI4DAgTg3N2M+Vz48RQZf22oCJNs8UQySheHPUsW1b/58Tjt4k4EWWb\n\tcxH78vjq0p3A4S2WINKg+YNP46wr7FEkadx8Dys6xkEypimKZTaHfL1EVyIugZi5RxWX3PQHF\n\tmoPz3ci08DBXpm+ZIT0Ch74ti+y3ZN/bIhzvz2PKg0MSVGr8MDfgKG+X7BsK2ZY8Z6JPe5MAH\n\tWJNRl+dCTK5j0PLZrJUrFmT6M3NZU1edW5VepC7Z1UyyHtUvo3ZlKa+7Q==", "Subject": "[libcamera-devel] [PATCH v6 1/5] libcamera: controls: Use\n\tstd::optional to handle invalid control values", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Christian Rauch via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Christian Rauch <Rauch.Christian@gmx.de>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Previously, ControlList::get<T>() would use default constructed objects to\nindicate that a ControlList does not have the requested Control. This has\nseveral disadvantages: 1) It requires types to be default constructible,\n2) it does not differentiate between a default constructed object and an\nobject that happens to have the same state as a default constructed object.\n\nstd::optional<T> additionally stores the information if the object is valid\nor not, and therefore is more expressive than a default constructed object.\n\nSigned-off-by: Christian Rauch <Rauch.Christian@gmx.de>\n---\n include/libcamera/controls.h | 5 +++--\n src/android/camera_capabilities.cpp | 8 +++----\n src/android/camera_device.cpp | 21 +++++++++----------\n src/android/camera_hal_manager.cpp | 2 +-\n src/cam/main.cpp | 4 ++--\n src/ipa/raspberrypi/raspberrypi.cpp | 2 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 9 ++++----\n .../pipeline/raspberrypi/raspberrypi.cpp | 9 ++++----\n src/qcam/dng_writer.cpp | 15 +++++++------\n 9 files changed, 39 insertions(+), 36 deletions(-)\n\n--\n2.34.1", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 665bcac1..192be784 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -8,6 +8,7 @@\n #pragma once\n\n #include <assert.h>\n+#include <optional>\n #include <set>\n #include <stdint.h>\n #include <string>\n@@ -373,11 +374,11 @@ public:\n \tbool contains(unsigned int id) const;\n\n \ttemplate<typename T>\n-\tT get(const Control<T> &ctrl) const\n+\tstd::optional<T> get(const Control<T> &ctrl) const\n \t{\n \t\tconst ControlValue *val = find(ctrl.id());\n \t\tif (!val)\n-\t\t\treturn T{};\n+\t\t\treturn std::nullopt;\n\n \t\treturn val->get<T>();\n \t}\ndiff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\nindex 6f197eb8..892bbc2b 100644\n--- a/src/android/camera_capabilities.cpp\n+++ b/src/android/camera_capabilities.cpp\n@@ -1042,7 +1042,7 @@ int CameraCapabilities::initializeStaticMetadata()\n \t/* Sensor static metadata. */\n \tstd::array<int32_t, 2> pixelArraySize;\n \t{\n-\t\tconst Size &size = properties.get(properties::PixelArraySize);\n+\t\tconst Size &size = properties.get(properties::PixelArraySize).value_or(Size{});\n \t\tpixelArraySize[0] = size.width;\n \t\tpixelArraySize[1] = size.height;\n \t\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,\n@@ -1050,7 +1050,7 @@ int CameraCapabilities::initializeStaticMetadata()\n \t}\n\n \tif (properties.contains(properties::UnitCellSize)) {\n-\t\tconst Size &cellSize = properties.get<Size>(properties::UnitCellSize);\n+\t\tconst Size &cellSize = *properties.get<Size>(properties::UnitCellSize);\n \t\tstd::array<float, 2> physicalSize{\n \t\t\tcellSize.width * pixelArraySize[0] / 1e6f,\n \t\t\tcellSize.height * pixelArraySize[1] / 1e6f\n@@ -1061,7 +1061,7 @@ int CameraCapabilities::initializeStaticMetadata()\n\n \t{\n \t\tconst Span<const Rectangle> &rects =\n-\t\t\tproperties.get(properties::PixelArrayActiveAreas);\n+\t\t\tproperties.get(properties::PixelArrayActiveAreas).value_or(Span<const Rectangle>{});\n \t\tstd::vector<int32_t> data{\n \t\t\tstatic_cast<int32_t>(rects[0].x),\n \t\t\tstatic_cast<int32_t>(rects[0].y),\n@@ -1080,7 +1080,7 @@ int CameraCapabilities::initializeStaticMetadata()\n\n \t/* Report the color filter arrangement if the camera reports it. */\n \tif (properties.contains(properties::draft::ColorFilterArrangement)) {\n-\t\tuint8_t filterArr = properties.get(properties::draft::ColorFilterArrangement);\n+\t\tuint8_t filterArr = *properties.get(properties::draft::ColorFilterArrangement);\n \t\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT,\n \t\t\t\t\t filterArr);\n \t}\ndiff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 8e804d4d..ec117101 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -305,7 +305,7 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData)\n \tconst ControlList &properties = camera_->properties();\n\n \tif (properties.contains(properties::Location)) {\n-\t\tint32_t location = properties.get(properties::Location);\n+\t\tint32_t location = *properties.get(properties::Location);\n \t\tswitch (location) {\n \t\tcase properties::CameraLocationFront:\n \t\t\tfacing_ = CAMERA_FACING_FRONT;\n@@ -355,7 +355,7 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData)\n \t * metadata.\n \t */\n \tif (properties.contains(properties::Rotation)) {\n-\t\tint rotation = properties.get(properties::Rotation);\n+\t\tint rotation = *properties.get(properties::Rotation);\n \t\torientation_ = (360 - rotation) % 360;\n \t\tif (cameraConfigData && cameraConfigData->rotation != -1 &&\n \t\t orientation_ != cameraConfigData->rotation) {\n@@ -1094,7 +1094,8 @@ void CameraDevice::requestComplete(Request *request)\n \t * as soon as possible, earlier than request completion time.\n \t */\n \tuint64_t sensorTimestamp = static_cast<uint64_t>(request->metadata()\n-\t\t\t\t\t\t\t .get(controls::SensorTimestamp));\n+\t\t\t\t\t\t\t\t .get(controls::SensorTimestamp)\n+\t\t\t\t\t\t\t\t .value_or(0));\n \tnotifyShutter(descriptor->frameNumber_, sensorTimestamp);\n\n \tLOG(HAL, Debug) << \"Request \" << request->cookie() << \" completed with \"\n@@ -1473,29 +1474,28 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons\n \t\t\t\t rolling_shutter_skew);\n\n \t/* Add metadata tags reported by libcamera. */\n-\tconst int64_t timestamp = metadata.get(controls::SensorTimestamp);\n+\tconst int64_t timestamp = metadata.get(controls::SensorTimestamp).value_or(0);\n \tresultMetadata->addEntry(ANDROID_SENSOR_TIMESTAMP, timestamp);\n\n \tif (metadata.contains(controls::draft::PipelineDepth)) {\n-\t\tuint8_t pipeline_depth =\n-\t\t\tmetadata.get<int32_t>(controls::draft::PipelineDepth);\n+\t\tuint8_t pipeline_depth = *metadata.get<int32_t>(controls::draft::PipelineDepth);\n \t\tresultMetadata->addEntry(ANDROID_REQUEST_PIPELINE_DEPTH,\n \t\t\t\t\t pipeline_depth);\n \t}\n\n \tif (metadata.contains(controls::ExposureTime)) {\n-\t\tint64_t exposure = metadata.get(controls::ExposureTime) * 1000ULL;\n+\t\tint64_t exposure = *metadata.get(controls::ExposureTime) * 1000ULL;\n \t\tresultMetadata->addEntry(ANDROID_SENSOR_EXPOSURE_TIME, exposure);\n \t}\n\n \tif (metadata.contains(controls::FrameDuration)) {\n-\t\tint64_t duration = metadata.get(controls::FrameDuration) * 1000;\n+\t\tint64_t duration = *metadata.get(controls::FrameDuration) * 1000;\n \t\tresultMetadata->addEntry(ANDROID_SENSOR_FRAME_DURATION,\n \t\t\t\t\t duration);\n \t}\n\n \tif (metadata.contains(controls::ScalerCrop)) {\n-\t\tRectangle crop = metadata.get(controls::ScalerCrop);\n+\t\tRectangle crop = *metadata.get(controls::ScalerCrop);\n \t\tint32_t cropRect[] = {\n \t\t\tcrop.x, crop.y, static_cast<int32_t>(crop.width),\n \t\t\tstatic_cast<int32_t>(crop.height),\n@@ -1504,8 +1504,7 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons\n \t}\n\n \tif (metadata.contains(controls::draft::TestPatternMode)) {\n-\t\tconst int32_t testPatternMode =\n-\t\t\tmetadata.get(controls::draft::TestPatternMode);\n+\t\tconst int32_t testPatternMode = *metadata.get(controls::draft::TestPatternMode);\n \t\tresultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE,\n \t\t\t\t\t testPatternMode);\n \t}\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex 5f7bfe26..0b23397a 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -232,7 +232,7 @@ int32_t CameraHalManager::cameraLocation(const Camera *cam)\n \tif (!properties.contains(properties::Location))\n \t\treturn -1;\n\n-\treturn properties.get(properties::Location);\n+\treturn properties.get(properties::Location).value_or(0);\n }\n\n CameraDevice *CameraHalManager::cameraDeviceFromHalId(unsigned int id)\ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 79875ed7..d8115cd8 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -301,7 +301,7 @@ std::string CamApp::cameraName(const Camera *camera)\n \t * is only used if the location isn't present or is set to External.\n \t */\n \tif (props.contains(properties::Location)) {\n-\t\tswitch (props.get(properties::Location)) {\n+\t\tswitch (*props.get(properties::Location)) {\n \t\tcase properties::CameraLocationFront:\n \t\t\taddModel = false;\n \t\t\tname = \"Internal front camera \";\n@@ -321,7 +321,7 @@ std::string CamApp::cameraName(const Camera *camera)\n \t\t * If the camera location is not availble use the camera model\n \t\t * to build the camera name.\n \t\t */\n-\t\tname = \"'\" + props.get(properties::Model) + \"' \";\n+\t\tname = \"'\" + *props.get(properties::Model) + \"' \";\n \t}\n\n \tname += \"(\" + camera->id() + \")\";\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 3b126bb5..f65a0680 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -939,7 +939,7 @@ void IPARPi::returnEmbeddedBuffer(unsigned int bufferId)\n\n void IPARPi::prepareISP(const ISPConfig &data)\n {\n-\tint64_t frameTimestamp = data.controls.get(controls::SensorTimestamp);\n+\tint64_t frameTimestamp = data.controls.get(controls::SensorTimestamp).value_or(0);\n \tRPiController::Metadata lastMetadata;\n \tSpan<uint8_t> embeddedBuffer;\n\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex fd989e61..53332826 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1145,7 +1145,7 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Convert the sensor rotation to a transformation */\n \t\tint32_t rotation = 0;\n \t\tif (data->properties_.contains(properties::Rotation))\n-\t\t\trotation = data->properties_.get(properties::Rotation);\n+\t\t\trotation = *(data->properties_.get(properties::Rotation));\n \t\telse\n \t\t\tLOG(IPU3, Warning) << \"Rotation control not exposed by \"\n \t\t\t\t\t << cio2->sensor()->id()\n@@ -1331,7 +1331,7 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer)\n \trequest->metadata().set(controls::draft::PipelineDepth, 3);\n \t/* \\todo Actually apply the scaler crop region to the ImgU. */\n \tif (request->controls().contains(controls::ScalerCrop))\n-\t\tcropRegion_ = request->controls().get(controls::ScalerCrop);\n+\t\tcropRegion_ = *(request->controls().get(controls::ScalerCrop));\n \trequest->metadata().set(controls::ScalerCrop, cropRegion_);\n\n \tif (frameInfos_.tryComplete(info))\n@@ -1424,7 +1424,7 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer)\n \t\treturn;\n \t}\n\n-\tipa_->processStatsBuffer(info->id, request->metadata().get(controls::SensorTimestamp),\n+\tipa_->processStatsBuffer(info->id, request->metadata().get(controls::SensorTimestamp).value_or(0),\n \t\t\t\t info->statBuffer->cookie(), info->effectiveSensorControls);\n }\n\n@@ -1458,8 +1458,7 @@ void IPU3CameraData::frameStart(uint32_t sequence)\n \tif (!request->controls().contains(controls::draft::TestPatternMode))\n \t\treturn;\n\n-\tconst int32_t testPatternMode = request->controls().get(\n-\t\tcontrols::draft::TestPatternMode);\n+\tconst int32_t testPatternMode = request->controls().get(controls::draft::TestPatternMode).value_or(0);\n\n \tint ret = cio2_.sensor()->setTestPatternMode(\n \t\tstatic_cast<controls::draft::TestPatternModeEnum>(testPatternMode));\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex adc397e8..a62afdd4 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -365,7 +365,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t * error means the platform can never run. Let's just print a warning\n \t * and continue regardless; the rotation is effectively set to zero.\n \t */\n-\tint32_t rotation = data_->sensor_->properties().get(properties::Rotation);\n+\tint32_t rotation = data_->sensor_->properties().get(properties::Rotation).value_or(0);\n \tbool success;\n \tTransform rotationTransform = transformFromRotation(rotation, &success);\n \tif (!success)\n@@ -1706,7 +1706,8 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n \t * V4L2_CID_NOTIFY_GAINS control (which means notifyGainsUnity_ is set).\n \t */\n \tif (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) {\n-\t\tlibcamera::Span<const float> colourGains = controls.get(libcamera::controls::ColourGains);\n+\t\tlibcamera::Span<const float> colourGains =\n+\t\t\t*controls.get(libcamera::controls::ColourGains);\n \t\t/* The control wants linear gains in the order B, Gb, Gr, R. */\n \t\tControlList ctrls(sensor_->controls());\n \t\tstd::array<int32_t, 4> gains{\n@@ -2041,7 +2042,7 @@ Rectangle RPiCameraData::scaleIspCrop(const Rectangle &ispCrop) const\n void RPiCameraData::applyScalerCrop(const ControlList &controls)\n {\n \tif (controls.contains(controls::ScalerCrop)) {\n-\t\tRectangle nativeCrop = controls.get<Rectangle>(controls::ScalerCrop);\n+\t\tRectangle nativeCrop = *controls.get<Rectangle>(controls::ScalerCrop);\n\n \t\tif (!nativeCrop.width || !nativeCrop.height)\n \t\t\tnativeCrop = { 0, 0, 1, 1 };\n@@ -2079,7 +2080,7 @@ void RPiCameraData::fillRequestMetadata(const ControlList &bufferControls,\n \t\t\t\t\tRequest *request)\n {\n \trequest->metadata().set(controls::SensorTimestamp,\n-\t\t\t\tbufferControls.get(controls::SensorTimestamp));\n+\t\t\t\tbufferControls.get(controls::SensorTimestamp).value_or(0));\n\n \trequest->metadata().set(controls::ScalerCrop, scalerCrop_);\n }\ndiff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp\nindex 34c8df5a..780f58f7 100644\n--- a/src/qcam/dng_writer.cpp\n+++ b/src/qcam/dng_writer.cpp\n@@ -392,7 +392,7 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \tTIFFSetField(tif, TIFFTAG_MAKE, \"libcamera\");\n\n \tif (cameraProperties.contains(properties::Model)) {\n-\t\tstd::string model = cameraProperties.get(properties::Model);\n+\t\tstd::string model = *cameraProperties.get(properties::Model);\n \t\tTIFFSetField(tif, TIFFTAG_MODEL, model.c_str());\n \t\t/* \\todo set TIFFTAG_UNIQUECAMERAMODEL. */\n \t}\n@@ -438,7 +438,8 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \tconst double eps = 1e-2;\n\n \tif (metadata.contains(controls::ColourGains)) {\n-\t\tSpan<const float> const &colourGains = metadata.get(controls::ColourGains);\n+\t\tSpan<const float> const &colourGains =\n+\t\t\t*metadata.get(controls::ColourGains);\n \t\tif (colourGains[0] > eps && colourGains[1] > eps) {\n \t\t\twbGain = Matrix3d::diag(colourGains[0], 1, colourGains[1]);\n \t\t\tneutral[0] = 1.0 / colourGains[0]; /* red */\n@@ -446,7 +447,8 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \t\t}\n \t}\n \tif (metadata.contains(controls::ColourCorrectionMatrix)) {\n-\t\tSpan<const float> const &coeffs = metadata.get(controls::ColourCorrectionMatrix);\n+\t\tSpan<const float> const &coeffs =\n+\t\t\t*metadata.get(controls::ColourCorrectionMatrix);\n \t\tMatrix3d ccmSupplied(coeffs);\n \t\tif (ccmSupplied.determinant() > eps)\n \t\t\tccm = ccmSupplied;\n@@ -515,7 +517,8 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \tuint32_t whiteLevel = (1 << info->bitsPerSample) - 1;\n\n \tif (metadata.contains(controls::SensorBlackLevels)) {\n-\t\tSpan<const int32_t> levels = metadata.get(controls::SensorBlackLevels);\n+\t\tSpan<const int32_t> levels =\n+\t\t\t*metadata.get(controls::SensorBlackLevels);\n\n \t\t/*\n \t\t * The black levels control is specified in R, Gr, Gb, B order.\n@@ -593,13 +596,13 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \tTIFFSetField(tif, EXIFTAG_DATETIMEDIGITIZED, strTime);\n\n \tif (metadata.contains(controls::AnalogueGain)) {\n-\t\tfloat gain = metadata.get(controls::AnalogueGain);\n+\t\tfloat gain = *metadata.get(controls::AnalogueGain);\n \t\tuint16_t iso = std::min(std::max(gain * 100, 0.0f), 65535.0f);\n \t\tTIFFSetField(tif, EXIFTAG_ISOSPEEDRATINGS, 1, &iso);\n \t}\n\n \tif (metadata.contains(controls::ExposureTime)) {\n-\t\tfloat exposureTime = metadata.get(controls::ExposureTime) / 1e6;\n+\t\tfloat exposureTime = *metadata.get(controls::ExposureTime) / 1e6;\n \t\tTIFFSetField(tif, EXIFTAG_EXPOSURETIME, exposureTime);\n \t}\n\n", "prefixes": [ "libcamera-devel", "v6", "1/5" ] }