From patchwork Mon Jul 4 23:32:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16538 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 C568BBE173 for ; Mon, 4 Jul 2022 23:32:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6067863316; Tue, 5 Jul 2022 01:32:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656977556; bh=lomK59UIRO1RSrhj65aOgU6BLhhyBHgMUnHMJP4IstE=; 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=t6+73Z+83bLJB6GkSaE5+M0SMjB00n0ast6N9565NA45m/YN9TI7KU3eztuNDnL8t AOv0uGuZST5LYbPZdpyb67kZcOmFkv4ORp8nosvMlTxnXMQoScYk9SjBsiwUPT0NB8 Z7ypIhz1Zg4L8tvr40fuP4JPGZsDaBMyV7uHHIC9VWjyON/K6sySH/v2XEfe8ZLhMA odHLX8bYq/K+Jk9Ga3oi3S5ng+qdkGu2dyd5ekcba8lXdSh5trqdDiz+4DN9lYlQXb n8cRgmd65uT0KgohFHQz+LsgJJ84SPhy9s9bU/z2Ki35axAhWO03L3/+wyfjbfWjuL wMKbbLZndevgQ== Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D45F06330C for ; Tue, 5 Jul 2022 01:32:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="jJawJd0k"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656977553; bh=lomK59UIRO1RSrhj65aOgU6BLhhyBHgMUnHMJP4IstE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jJawJd0khKGZwxNweUE5l9nt5ElGqfDqiYVjIdAyiwyVxcxiwHTFZuEPQUgl+5xA2 xIlAt5GXrRnnuQ+tp3kOTtub9qmZEA5vZrLbMCAWh/LB8UX5pTSUy1FcU9IbrVErsq 5M8IIGs77GjdAljLqwOxuWhEjq80bCFLkd9CxsjU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5fIW-1oEXAB12s6-0079eW; Tue, 05 Jul 2022 01:32:33 +0200 To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jul 2022 00:32:14 +0100 Message-Id: <20220704233217.54769-2-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704233217.54769-1-Rauch.Christian@gmx.de> References: <20220704233217.54769-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:vitDZqXKu2ihk0iPRAL/UxAhkgXEjiJVIbbnEsWGNdESSxflOSL xqWH4X555Vw/3czXUA7eWKMdmpVcn5vTGzx0p6lo7+EOUcQOqKaxsVQFZ8zh3bGouS8Hp9q Np25hoR+T6kl1rss2CPGDnMowf4p7gdz/SjNwL15EjMcl/HosHqKVYKFLomoMqIFuoABWQw oh4Y/96Oind2qjfDdlK8Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:AvK+Xr+RPqM=:uTCUxUm5WCtVojhqbVp/O5 EpAx/tGI0maJ0sBTiUV5L37Jw9tGSPzqCwpXW4jnQIcpI4wTKwikcCRu/lTUfKzD7jQEhVw2K o/4PgRYV2KEJhtLsqyCamUr3wxiRsIekAdtI8BRKJwR+xvhOyIYHJ+MthtwDpVO+ZXhjTR2JB yMYu/ow4m/HInp5u0tLBncBmZhZc4Xgdisw9FmmviWFSqn26rqHxCtzOvRwWOwpDx/h7RDgy3 Hrnrwwwp0ZMcSqvDPfP0Hc4qfGzTYXQdGrdrDylyYiG7HvYk7SRNKS+QQCNJ4U74mtaNwR1Mn 41VpoXHp/UrWLTVZPBkimPPmQ+c58CrPwDs/CWJBJpc75/zDEkHuhI08HntrfUC3J/GWvRP7f f+SNAOFS5Alij4M7lmuXmfgfKzeSnXXf04gEhM/fKuWepVrSDFTfVLuwGTIWsZ7x78m2VTH71 UiRD9TSUi65UbmE4aW0W/MFZeQwGhjuGG4Mv9mfzdSTzh7iV7d6Uevm8t3QSq2C6z25omvi5k FoCMxGTzsJXsBf9tAvLrMLi49KiGkft9YkrqBF+HeQXrjcfnchekAXk6zL7cDu+UFzYb9kMXC Qo+OzZs798O4EdN8/pun1W/1/U5h5beh9lW2db9R1QtsM84t5mIR2JAW5N5CuK4YITw4PKt/j J8xBZFWv5j97yv9J2b0zbOTiJzYheYwaNraXWBN1CK8jTUTTCUfMlRfhV79p8geC3m5gx4bry 6pIkwk/b2dANmLOoaOgeHS0Ay+Xwpbf7zpzLguAIXHoK9KiRk4WuNL9BYojR1LeLsCsMa55W3 bMM9KW5S+5OFs1Cxuc95MYsZAdQb6Mz3mI5s04G12MTehzbj9COxE/CJiVDuDhwaElxmLDBd5 5oNtgsjZq6AA9IamGHwf1LLCBnZr/EtDwYTXZJ7hA+K6MpTuh+QQVIRtRbvpyGYvasNOOW/0C L/RnU2Ci067b4rlQ4Rb2MXKL4V/8+vdDuK5uQxKn6mJYtTqvwpr53m3pxnc+XgdqJyxBdPFXo GIYyIElOjsCUcdAjESpZqp5MwmD8dwrgRuHnjMDVsTRWCeDb7oxRQRZiitP5X+12wpjzSvV9h e/v8Zwn/oI7pP9CQQd2r7f59gsPlp1b/7Pu/lhU+8uoXcwnEAvayOlCdA== Subject: [libcamera-devel] [PATCH v9 1/4] libcamera: controls: Use std::optional to handle invalid control values 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: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Previously, ControlList::get() would use default constructed objects to indicate that a ControlList does not have the requested Control. This has several disadvantages: 1) It requires types to be default constructible, 2) it does not differentiate between a default constructed object and an object that happens to have the same state as a default constructed object. std::optional additionally stores the information if the object is valid or not, and therefore is more expressive than a default constructed object. Signed-off-by: Christian Rauch Reviewed-by: Jacopo Mondi --- include/libcamera/controls.h | 5 +++-- src/android/camera_capabilities.cpp | 12 +++++----- src/android/camera_device.cpp | 21 +++++++++--------- src/android/camera_hal_manager.cpp | 2 +- src/cam/main.cpp | 4 ++-- src/gstreamer/gstlibcamerasrc.cpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 9 ++++---- .../pipeline/raspberrypi/raspberrypi.cpp | 9 ++++---- src/qcam/dng_writer.cpp | 22 +++++++++---------- 10 files changed, 44 insertions(+), 44 deletions(-) -- 2.34.1 diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 665bcac1..192be784 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -373,11 +374,11 @@ public: bool contains(unsigned int id) const; template - T get(const Control &ctrl) const + std::optional get(const Control &ctrl) const { const ControlValue *val = find(ctrl.id()); if (!val) - return T{}; + return std::nullopt; return val->get(); } diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6f197eb8..5304b2da 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1042,7 +1042,7 @@ int CameraCapabilities::initializeStaticMetadata() /* Sensor static metadata. */ std::array pixelArraySize; { - const Size &size = properties.get(properties::PixelArraySize); + const Size &size = properties.get(properties::PixelArraySize).value_or(Size{}); pixelArraySize[0] = size.width; pixelArraySize[1] = size.height; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, @@ -1050,10 +1050,10 @@ int CameraCapabilities::initializeStaticMetadata() } if (properties.contains(properties::UnitCellSize)) { - const Size &cellSize = properties.get(properties::UnitCellSize); + const auto &cellSize = properties.get(properties::UnitCellSize); std::array physicalSize{ - cellSize.width * pixelArraySize[0] / 1e6f, - cellSize.height * pixelArraySize[1] / 1e6f + cellSize->width * pixelArraySize[0] / 1e6f, + cellSize->height * pixelArraySize[1] / 1e6f }; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, physicalSize); @@ -1061,7 +1061,7 @@ int CameraCapabilities::initializeStaticMetadata() { const Span &rects = - properties.get(properties::PixelArrayActiveAreas); + properties.get(properties::PixelArrayActiveAreas).value_or(Span{}); std::vector data{ static_cast(rects[0].x), static_cast(rects[0].y), @@ -1080,7 +1080,7 @@ int CameraCapabilities::initializeStaticMetadata() /* Report the color filter arrangement if the camera reports it. */ if (properties.contains(properties::draft::ColorFilterArrangement)) { - uint8_t filterArr = properties.get(properties::draft::ColorFilterArrangement); + uint8_t filterArr = *properties.get(properties::draft::ColorFilterArrangement); staticMetadata_->addEntry(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, filterArr); } diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 8c039fb9..46621232 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -306,7 +306,7 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData) const ControlList &properties = camera_->properties(); if (properties.contains(properties::Location)) { - int32_t location = properties.get(properties::Location); + int32_t location = *properties.get(properties::Location); switch (location) { case properties::CameraLocationFront: facing_ = CAMERA_FACING_FRONT; @@ -356,7 +356,7 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData) * metadata. */ if (properties.contains(properties::Rotation)) { - int rotation = properties.get(properties::Rotation); + int rotation = *properties.get(properties::Rotation); orientation_ = (360 - rotation) % 360; if (cameraConfigData && cameraConfigData->rotation != -1 && orientation_ != cameraConfigData->rotation) { @@ -1181,7 +1181,8 @@ void CameraDevice::requestComplete(Request *request) * as soon as possible, earlier than request completion time. */ uint64_t sensorTimestamp = static_cast(request->metadata() - .get(controls::SensorTimestamp)); + .get(controls::SensorTimestamp) + .value_or(0)); notifyShutter(descriptor->frameNumber_, sensorTimestamp); LOG(HAL, Debug) << "Request " << request->cookie() << " completed with " @@ -1560,29 +1561,28 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons rolling_shutter_skew); /* Add metadata tags reported by libcamera. */ - const int64_t timestamp = metadata.get(controls::SensorTimestamp); + const int64_t timestamp = metadata.get(controls::SensorTimestamp).value_or(0); resultMetadata->addEntry(ANDROID_SENSOR_TIMESTAMP, timestamp); if (metadata.contains(controls::draft::PipelineDepth)) { - uint8_t pipeline_depth = - metadata.get(controls::draft::PipelineDepth); + uint8_t pipeline_depth = *metadata.get(controls::draft::PipelineDepth); resultMetadata->addEntry(ANDROID_REQUEST_PIPELINE_DEPTH, pipeline_depth); } if (metadata.contains(controls::ExposureTime)) { - int64_t exposure = metadata.get(controls::ExposureTime) * 1000ULL; + int64_t exposure = *metadata.get(controls::ExposureTime) * 1000ULL; resultMetadata->addEntry(ANDROID_SENSOR_EXPOSURE_TIME, exposure); } if (metadata.contains(controls::FrameDuration)) { - int64_t duration = metadata.get(controls::FrameDuration) * 1000; + int64_t duration = *metadata.get(controls::FrameDuration) * 1000; resultMetadata->addEntry(ANDROID_SENSOR_FRAME_DURATION, duration); } if (metadata.contains(controls::ScalerCrop)) { - Rectangle crop = metadata.get(controls::ScalerCrop); + Rectangle crop = *metadata.get(controls::ScalerCrop); int32_t cropRect[] = { crop.x, crop.y, static_cast(crop.width), static_cast(crop.height), @@ -1591,8 +1591,7 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons } if (metadata.contains(controls::draft::TestPatternMode)) { - const int32_t testPatternMode = - metadata.get(controls::draft::TestPatternMode); + const int32_t testPatternMode = *metadata.get(controls::draft::TestPatternMode); resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, testPatternMode); } diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index 5f7bfe26..0bffe96f 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -232,7 +232,7 @@ int32_t CameraHalManager::cameraLocation(const Camera *cam) if (!properties.contains(properties::Location)) return -1; - return properties.get(properties::Location); + return *properties.get(properties::Location); } CameraDevice *CameraHalManager::cameraDeviceFromHalId(unsigned int id) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 79875ed7..d8115cd8 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -301,7 +301,7 @@ std::string CamApp::cameraName(const Camera *camera) * is only used if the location isn't present or is set to External. */ if (props.contains(properties::Location)) { - switch (props.get(properties::Location)) { + switch (*props.get(properties::Location)) { case properties::CameraLocationFront: addModel = false; name = "Internal front camera "; @@ -321,7 +321,7 @@ std::string CamApp::cameraName(const Camera *camera) * If the camera location is not availble use the camera model * to build the camera name. */ - name = "'" + props.get(properties::Model) + "' "; + name = "'" + *props.get(properties::Model) + "' "; } name += "(" + camera->id() + ")"; diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a7a0c440..3d3efc0c 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -234,7 +234,7 @@ GstLibcameraSrcState::requestCompleted(Request *request) } if (GST_ELEMENT_CLOCK(src_)) { - int64_t timestamp = request->metadata().get(controls::SensorTimestamp); + int64_t timestamp = request->metadata().get(controls::SensorTimestamp).value_or(0); GstClockTime gst_base_time = GST_ELEMENT(src_)->base_time; GstClockTime gst_now = gst_clock_get_time(GST_ELEMENT_CLOCK(src_)); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index f8d37b87..c7492a77 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -993,7 +993,7 @@ void IPARPi::returnEmbeddedBuffer(unsigned int bufferId) void IPARPi::prepareISP(const ISPConfig &data) { - int64_t frameTimestamp = data.controls.get(controls::SensorTimestamp); + int64_t frameTimestamp = data.controls.get(controls::SensorTimestamp).value_or(0); RPiController::Metadata lastMetadata; Span embeddedBuffer; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index b7dda282..43db7b68 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1145,7 +1145,7 @@ int PipelineHandlerIPU3::registerCameras() /* Convert the sensor rotation to a transformation */ int32_t rotation = 0; if (data->properties_.contains(properties::Rotation)) - rotation = data->properties_.get(properties::Rotation); + rotation = *(data->properties_.get(properties::Rotation)); else LOG(IPU3, Warning) << "Rotation control not exposed by " << cio2->sensor()->id() @@ -1331,7 +1331,7 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer) request->metadata().set(controls::draft::PipelineDepth, 3); /* \todo Actually apply the scaler crop region to the ImgU. */ if (request->controls().contains(controls::ScalerCrop)) - cropRegion_ = request->controls().get(controls::ScalerCrop); + cropRegion_ = *(request->controls().get(controls::ScalerCrop)); request->metadata().set(controls::ScalerCrop, cropRegion_); if (frameInfos_.tryComplete(info)) @@ -1424,7 +1424,7 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) return; } - ipa_->processStatsBuffer(info->id, request->metadata().get(controls::SensorTimestamp), + ipa_->processStatsBuffer(info->id, request->metadata().get(controls::SensorTimestamp).value_or(0), info->statBuffer->cookie(), info->effectiveSensorControls); } @@ -1458,8 +1458,7 @@ void IPU3CameraData::frameStart(uint32_t sequence) if (!request->controls().contains(controls::draft::TestPatternMode)) return; - const int32_t testPatternMode = request->controls().get( - controls::draft::TestPatternMode); + const int32_t testPatternMode = *(request->controls().get(controls::draft::TestPatternMode)); int ret = cio2_.sensor()->setTestPatternMode( static_cast(testPatternMode)); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 66a84b1d..28f054cb 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -364,7 +364,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * error means the platform can never run. Let's just print a warning * and continue regardless; the rotation is effectively set to zero. */ - int32_t rotation = data_->sensor_->properties().get(properties::Rotation); + int32_t rotation = data_->sensor_->properties().get(properties::Rotation).value_or(0); bool success; Transform rotationTransform = transformFromRotation(rotation, &success); if (!success) @@ -1717,7 +1717,8 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & * V4L2_CID_NOTIFY_GAINS control (which means notifyGainsUnity_ is set). */ if (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) { - libcamera::Span colourGains = controls.get(libcamera::controls::ColourGains); + libcamera::Span colourGains = + *controls.get(libcamera::controls::ColourGains); /* The control wants linear gains in the order B, Gb, Gr, R. */ ControlList ctrls(sensor_->controls()); std::array gains{ @@ -2052,7 +2053,7 @@ Rectangle RPiCameraData::scaleIspCrop(const Rectangle &ispCrop) const void RPiCameraData::applyScalerCrop(const ControlList &controls) { if (controls.contains(controls::ScalerCrop)) { - Rectangle nativeCrop = controls.get(controls::ScalerCrop); + Rectangle nativeCrop = *controls.get(controls::ScalerCrop); if (!nativeCrop.width || !nativeCrop.height) nativeCrop = { 0, 0, 1, 1 }; @@ -2090,7 +2091,7 @@ void RPiCameraData::fillRequestMetadata(const ControlList &bufferControls, Request *request) { request->metadata().set(controls::SensorTimestamp, - bufferControls.get(controls::SensorTimestamp)); + bufferControls.get(controls::SensorTimestamp).value_or(0)); request->metadata().set(controls::ScalerCrop, scalerCrop_); } diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 34c8df5a..4b5d8276 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -392,7 +392,7 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, TIFFTAG_MAKE, "libcamera"); if (cameraProperties.contains(properties::Model)) { - std::string model = cameraProperties.get(properties::Model); + std::string model = *cameraProperties.get(properties::Model); TIFFSetField(tif, TIFFTAG_MODEL, model.c_str()); /* \todo set TIFFTAG_UNIQUECAMERAMODEL. */ } @@ -438,16 +438,15 @@ int DNGWriter::write(const char *filename, const Camera *camera, const double eps = 1e-2; if (metadata.contains(controls::ColourGains)) { - Span const &colourGains = metadata.get(controls::ColourGains); - if (colourGains[0] > eps && colourGains[1] > eps) { - wbGain = Matrix3d::diag(colourGains[0], 1, colourGains[1]); - neutral[0] = 1.0 / colourGains[0]; /* red */ - neutral[2] = 1.0 / colourGains[1]; /* blue */ + const auto &colourGains = metadata.get(controls::ColourGains); + if ((*colourGains)[0] > eps && (*colourGains)[1] > eps) { + wbGain = Matrix3d::diag((*colourGains)[0], 1, (*colourGains)[1]); + neutral[0] = 1.0 / (*colourGains)[0]; /* red */ + neutral[2] = 1.0 / (*colourGains)[1]; /* blue */ } } if (metadata.contains(controls::ColourCorrectionMatrix)) { - Span const &coeffs = metadata.get(controls::ColourCorrectionMatrix); - Matrix3d ccmSupplied(coeffs); + Matrix3d ccmSupplied(*metadata.get(controls::ColourCorrectionMatrix)); if (ccmSupplied.determinant() > eps) ccm = ccmSupplied; } @@ -515,7 +514,8 @@ int DNGWriter::write(const char *filename, const Camera *camera, uint32_t whiteLevel = (1 << info->bitsPerSample) - 1; if (metadata.contains(controls::SensorBlackLevels)) { - Span levels = metadata.get(controls::SensorBlackLevels); + Span levels = + *metadata.get(controls::SensorBlackLevels); /* * The black levels control is specified in R, Gr, Gb, B order. @@ -593,13 +593,13 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, EXIFTAG_DATETIMEDIGITIZED, strTime); if (metadata.contains(controls::AnalogueGain)) { - float gain = metadata.get(controls::AnalogueGain); + float gain = *metadata.get(controls::AnalogueGain); uint16_t iso = std::min(std::max(gain * 100, 0.0f), 65535.0f); TIFFSetField(tif, EXIFTAG_ISOSPEEDRATINGS, 1, &iso); } if (metadata.contains(controls::ExposureTime)) { - float exposureTime = metadata.get(controls::ExposureTime) / 1e6; + float exposureTime = *metadata.get(controls::ExposureTime) / 1e6; TIFFSetField(tif, EXIFTAG_EXPOSURETIME, exposureTime); } From patchwork Mon Jul 4 23:32:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16539 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 A6C0DBE173 for ; Mon, 4 Jul 2022 23:32:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1CBA263318; Tue, 5 Jul 2022 01:32:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656977557; bh=/16NRmqVAVwDPoEee56Lymj5hfeWnsuaNzk+/jfYIM4=; 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=eTC4OYnqtGhahdcUaNS5pcDqIu4BE+KrBnR5T/G5WwOtve+FnEBnkgqaswe2H2gml azrQzxuCBftr9O6bJJykFv9wnbUpYyaYc4BONz6mnBo8gEb3R111qYOVZOaEIpdy8u yGQo0Sxx6ciREM04RArJt6JtVes8gpO1MbZ3yrOOinvIRsB6WR1jb+N6KVepucaan/ OUmRRCt0eV7JhfhrVMGCNbSzVZ4tzMvQaGz/ylXvk8NzTkUzkXltl241nCxTg4ysq0 NKdM8+4/h/KReWTezTM2TaxYR+BsrP8xLv768THQDjN7hP3+F+1t2vxUkSI5vDqEWn uL1fqaWiYdswQ== Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C3946330E for ; Tue, 5 Jul 2022 01:32:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="a1aygOr9"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656977553; bh=/16NRmqVAVwDPoEee56Lymj5hfeWnsuaNzk+/jfYIM4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=a1aygOr9ON1onlLPVB40B6w9/thWIS36ec9754wvCXJ15JR9CzMMQns05wYqWZnyV dti4TGuvn2iWvZCV3cq9WpVcTIh2kZr1qeYTT076+c0lL0+L68YXjFQSrrtgvzoYXr bcVVRLxe6LD5fgt8cIYUkNciV5KO9idwXY4Onkb0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MuDc7-1nKnka2PIT-00ub2R; Tue, 05 Jul 2022 01:32:33 +0200 To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jul 2022 00:32:15 +0100 Message-Id: <20220704233217.54769-3-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704233217.54769-1-Rauch.Christian@gmx.de> References: <20220704233217.54769-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/2oK35LtBlWFHPeYeZOs3cTRQzzu5SgZ6QNVE5eJwsLoO1CHLIY Dw5EyIt9DCyEK0TLp4JfXuKKg2qk534NwHGJix/ZpGTmV+SqC4huPD8uV30kwyJ07eKhORq 6YMplxoYTzCAhy+R4Yunl07HOh1Jup/0wGAhp6CuiIS4BG40tNyjii0glnSMrQUwPNeCkNm Exyg7frAN8K7Xm89qcUlA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:nv1wakTSGek=:4P4G1Oe66wajjOpP0TNs53 K0QqAUzlMcUtmwsJvJ8DPPDSEQHygIxiZMAm+iZrsKKggPfmZ9Bt8fUvF0/NS9BKjqZL7OiCm 6czCfik9aiIKdcsOberq0eC0HYBdHk6efL4PzxOCR2OYx9MMmdOVcvtHBmihNm7Qi2vvzVsQo V0W1uQvvOm9T0tq4DkXum2cMXnabYEVcl06gGEWMyYuGZ5pG4GnwJ4XKXwQhuHwTcxVPbfz0H nkvkWm7k1yU4xeRO2Kp6hTpua5sk8q04bAdKPG4AG725fQMAIU+tI3lIC8wdPxPCKIhiOgDtB XZATrKoF/czyaFDRKosEXmsRGHuvloDpknLbOGTsZPr14rur2fnQBxmvREJL6KDTSRfVsIvp1 KgMN4ufnkJCuoN96ITK06Qxfa5vq5wpuY/kp9TZmqNH55yv8bIkDriApZ/zGVd9HYNwcQHVzY vjeIVr4yS/tzJYSaoA2HrokMOQM1YyarC3VjxXL//NfY2JqQlZLlicgsJwOfEgOPt8Eia6nUX yEtga40i3KVyhHNOrcJpQVvQH7y25x2qAM4v4Ng8vrQnxfFCWF0BumsSLGjU/fnjMbQEWf5St t5B5hLtbrX57ksmV+frlR6Mhc8Kd7n6r9P1njq5PfcGKA04Cda3ZiG1xz9sIIyy3k+c2qogNU VWjGD9bb2BtsfHaM36Um4XSU7JduDmMjrmjHzVfv8qdr06AfQQsFDrSeBmaKlFnrUnwYX8u7C 5d116gdwJWRk3ONgLKXpMbO1xvFgKse873oEdKMhrTWJwWfCSsTgHzpVAQgcNX4r6u1uJYO4D sVn7mi0BW6Bx4pob0g31RUKJGS0D6eS7vn84Q28IFhG5Dazmi3FRUlme7fX1tsdmV6UroNqZv eAFSywMoLslS/BLhDnX6Ae4VXFWuU+XRdIyThbNnWFNmCoTl1qi+MM2Cu2+xcZ00BDVBrNo5l fYlKzDtf7wWfpAVAZELRmp1D1/RRX1w83jIBBPT8CVE12kuBsW7GAaWgOfDbWu9l2mjLWpOuF FJArbXajvoyujTGb9gzaP4sUxmW6eKaRsdday0GWkW/ZjNCv/TDvYQRwCPzPzL4RGZvdrG9cp x/zmoRSyJwl7JOkyw28q6iEfpqYDboywL/ElGRTqwjh2qt4Xn3gQECRCw== Subject: [libcamera-devel] [PATCH v9 2/4] libcamera: controls: Define size of array controls as a shape vector 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: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This follows the convention in other Tensor APIs. Since all tensors are represented as a Span with a single dimension, values provided in 'size' are interpreted as fixed-size Spans, while an empty array ("[]") will be interpreted as variable-sized Span. Signed-off-by: Christian Rauch Reviewed-by: Jacopo Mondi --- src/libcamera/control_ids.yaml | 4 ++-- src/libcamera/property_ids.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.34.1 diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index ecab3ae9..5fa168c6 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -291,7 +291,7 @@ controls: transformation. The 3x3 matrix is stored in conventional reading order in an array of 9 floating point values. - size: [3x3] + size: [3,3] - ScalerCrop: type: Rectangle @@ -525,7 +525,7 @@ controls: the window where the focal distance for the objects shown in that part of the image are closest to the camera. - size: [n] + size: [] - AfTrigger: type: int32_t diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 11b7ebdc..a87485d7 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -497,7 +497,7 @@ controls: - PixelArrayOpticalBlackRectangles: type: Rectangle - size: [n] + size: [] description: | The pixel array region(s) which contain optical black pixels considered valid for calibration purposes. @@ -592,7 +592,7 @@ controls: - PixelArrayActiveAreas: type: Rectangle - size: [n] + size: [] description: | The PixelArrayActiveAreas property defines the (possibly multiple and overlapping) portions of the camera sensor readable pixel matrix From patchwork Mon Jul 4 23:32:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16540 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 4F7C5BE173 for ; Mon, 4 Jul 2022 23:32:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEC7863313; Tue, 5 Jul 2022 01:32:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656977558; bh=UqwmX7+yMaOqSyR96KduBQpxFaCTOfHvdMO6MxtFX8g=; 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=j/5/Ay9DMIMPDKqIYF82sj5wp7/+83u7f/qDN4KVtpSjVpfMuxg1k4VzazkvthQop vkXQF7A2bgu0xNRSvTwtSqF9rDjD2tEEFZiS3kprZ8qjop8WNP5JEBE1JVU9WJ59bL l5rk3KEue3X55my7/L6l35LCut3OaFNWLLQFQY53A7poAibjqhZiR0nZ24CFb19YMs umr1XnL7rSGW//tpK02l7s6NxHPldDRjjXboT237uhNdPH4VpEhls24ClxG710djFw nSxgULanotBuuvBxo30Ki/bcmphOMHM2GTmzmt0+8bAK4egx8yXvV7YS8P/Ae+2WlK l7T4SgOfWFJ9w== Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58ED36042E for ; Tue, 5 Jul 2022 01:32:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="IBGXHTri"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656977554; bh=UqwmX7+yMaOqSyR96KduBQpxFaCTOfHvdMO6MxtFX8g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=IBGXHTrizAYQflxUJXHl32cJijLfpSiuGjPic9up9ypsZZlBCFbDI/ZkLnUbjVmHH m4NN00Cu997VaFWLu+O36BXsi1eFwnUAdFaH2sX/4HRYGt99zl5cVKJtAv5dcAnNVq oMmsUcpeprE8PFgqfRCVPzq7s49Xgoim3QAZ2wpA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5QJD-1o9L2C3i1l-001P19; Tue, 05 Jul 2022 01:32:34 +0200 To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jul 2022 00:32:16 +0100 Message-Id: <20220704233217.54769-4-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704233217.54769-1-Rauch.Christian@gmx.de> References: <20220704233217.54769-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:w5qMBf2rLPmRmaGHONqhxzM+PR2cqmKzyuaorhqo6JhWh+COwX3 2T9FOXVDtvhte+XyFk15yqSjSBNHvg8NF4+Ucb7GeNwyapGVHNfVndM5Vko89JPMVkCYdUz 4aYs+fggbgqC8+ZG4rHeEfypRQ8EL9/gJZiOMZDl4XGdvTpMQGRvLZU5jBQy8ocR7tbqAkH Tj5mZYgfIihINtGfbmBug== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DXLRsWq7lck=:Uc3EziPeJ2Q093N92i6l/p pkA3MukjmKGL7eYwLznzSbAXGJLhyjDgak75lXVzpyr3kqNZEIEQ/075WyMBlmOUqwlZX9yq+ HgGYMwMdXPsBdpDu7aGNDl9b/ln3+RUIvJeXQTHakaCC5yzVqfdeiMxKy9C22oBkeYVIkpDZP 4zHi70eFoTcZ8b+v5fZQrcJJxrzzPi/0HArQCrNTrl8JKK6s8aVkWnSpH3pi8yVD5xNdIdzug QpzPus4vSyKWJnp18VyoyRqEFxKNxdzyVOTU/i/IdIJR9XP1mUNqWKfTpT9cSRWC7fjlGbIV+ 6UQtCYeZCoAK53XanBjdlBEtb6f6gSE8vJHgX1iAhuL1sqwH9FczUHqHg0yXPrWVe33yDnc92 WjOtybfqNYSdF5k0aM0Hr5pMxhmKAEST9T18SabFsAO+t8jCgsuwfFIsRoIgX2dBv6EwsHCAQ n6NZXh2VsK8A1ONZjapxVylH4quBr2+SUTlMaRcSQWDmo1iReMn5bKraZB6B7p1yIrcdOmYCl c4CF+VKsqU4Bd91CFsj9n7xVTLu5SByM4ot1pYLDrtEOnnZzgIhvJukc8PZivO9Rv/WExHG1i CK4QrsyQ5rfADlEJ99uroIrZiqFHejNMfi+YIgFK7Vs4Gj0qHqRfho5UHDqRhavJrvCWFvaum Cv1fSOin39DqXoM2YzixdkslAJ9SQU31JDZI+WdrAiggIQQKQJZ2eePURK8dhZCzt9ED/Cvrz GKQ4RqcdJYzBtfkD/jsyhYPWeqhGlppZ1VVcYyaNBmk4MCrCneRbHdB3wkkkJo4h/Pee3IxFI cwXw/8EACICZ86UMW1/xSmpCVM1wcbk6vqz5xn70BHxKZ05hcIAAvtyDH/W0jXYdBJLRw4IwR Anyh0MLb5Rkeks/Hc3l41QJDyoRmu/9G/rhSxoC/SOxX7KoIvH29d5c38GTheT1MylGcQYxyC RHVP1KtUwlCWupgf7IaeS64w//Azh/UVBksghq7MJ9+YiBj+M47Btl+aNE3FPAJ2AW/CTutEz vlF2m95zuciSW9HAJxrP1l1e/RtZMn801Scy30beNmcGmukKYlVUAW3xOSQLP81d0dC7vl07x pC5+uZ2n5qpW8c8GuK0P3IMa/6CHwy7rIq+4BZdqN8Bt5Zyc10pXOf/YQ== Subject: [libcamera-devel] [PATCH v9 3/4] libcamera: controls: Generate fixed- and variable-sized Span Controls 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: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This defines Controls with a 'size' as either variable-sized Span or as fixed-sized Span. Signed-off-by: Christian Rauch Reviewed-by: Jacopo Mondi --- utils/gen-controls.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) -- 2.34.1 diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 3f99b5e2..46ba4394 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -7,6 +7,8 @@ # gen-controls.py - Generate control definitions from YAML import argparse +from functools import reduce +import operator import string import sys import yaml @@ -22,6 +24,24 @@ def format_description(description): return '\n'.join([(line and ' * ' or ' *') + line for line in description]) +def get_ctrl_type(ctrl): + ctrl_type = ctrl['type'] + ctrl_size_arr = ctrl.get('size') + + if ctrl_type == 'string': + return 'std::string' + elif ctrl_size_arr is not None: + if len(ctrl_size_arr) > 0: + # fixed-sized Span + ctrl_span_size = reduce(operator.mul, ctrl_size_arr) + return f"Span" + else: + # variable-sized Span + return f"Span" + else: + return ctrl_type + + def generate_cpp(controls): enum_doc_start_template = string.Template('''/** * \\enum ${name}Enum @@ -50,11 +70,7 @@ ${description} name, ctrl = ctrl.popitem() id_name = snake_case(name).upper() - ctrl_type = ctrl['type'] - if ctrl_type == 'string': - ctrl_type = 'std::string' - elif ctrl.get('size'): - ctrl_type = 'Span' % ctrl_type + ctrl_type = get_ctrl_type(ctrl) info = { 'name': name, @@ -135,11 +151,7 @@ def generate_h(controls): ids.append('\t' + id_name + ' = ' + str(id_value) + ',') - ctrl_type = ctrl['type'] - if ctrl_type == 'string': - ctrl_type = 'std::string' - elif ctrl.get('size'): - ctrl_type = 'Span' % ctrl_type + ctrl_type = get_ctrl_type(ctrl) info = { 'name': name, From patchwork Mon Jul 4 23:32:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16541 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 AAE00C3273 for ; Mon, 4 Jul 2022 23:32:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5534F63312; Tue, 5 Jul 2022 01:32:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656977558; bh=qdkppGAt8GGAkIW4ikxxbmnaUy8g9qZLK3Flsvri9Po=; 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=SjuAQFDMBvvTOEUHnN0Su196RLfw4MF1V5PO3MBywyl+oHyZpcwG3A7iiTxok5NzQ zTadlgQ4Ng5rSNdOrW+YwBavPesfZNHUxh6aZSL3tYPLDvDatvRYxrrBU2Ybl3k7FQ kerv3N4BlI2pL7Rb4/mIhSePUXPCjsLK/iN5JArjynjL7h4TKRDssZKsVszomzvvBH fGdNBA0ge67VAQKVgBt6IH4z+V05iJqTVQ/CG1gkUFHca1Oyc0swfQ+G8bMI7OhimS LY7S98T+/HkOz/EBZFXTzP+H5iw4VskwoZGf0jkOaWyKJgicHcCD2b4yby02aOeInA OEIyIFgPl5D/w== Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 998296330C for ; Tue, 5 Jul 2022 01:32:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="DNs4v97k"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656977554; bh=qdkppGAt8GGAkIW4ikxxbmnaUy8g9qZLK3Flsvri9Po=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=DNs4v97kzwUqiDBiw4luqv60XYDYkD7VU7XXLfvt3T+vwWTDM+/bqKvR8HAN0WbZW 5Ao1hCISkDLqu9NiRmXVUK6HXRR42ADQPRZJ1NiOCGrwmL4VP5Vh3Non7miWTl9JZe y5vKgmRY7ZsphaHAg/bpa8ERWZL0cJFjWqKD0rFw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N1Obh-1nRulV0ckl-012slJ; Tue, 05 Jul 2022 01:32:34 +0200 To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jul 2022 00:32:17 +0100 Message-Id: <20220704233217.54769-5-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704233217.54769-1-Rauch.Christian@gmx.de> References: <20220704233217.54769-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:7iGohiHwf4goJ8QSBa2b5vs3GqQZLSC43gEm+OFgl7eE1EZVs3w iPMBIVCPoAeE38cq1GjUnKzPNZe0kvYtukYa6mvCdTP4s9K8xoOyTvB82zyiOaRuxpLpz8a iBvL+MEWoy8UTpmlIbzO2kNmO3LYp8MeUmjsY70V0ddnRtoQJetermTenq5eyT4fQ9v/aFs W13c+x2NdWSGYvJk+DNjg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:lR1VDFReXY8=:5KFSP0n3LU1Etao7ho9RLe DPlvTI7xDogeILMtxOmW//0vpslnaZKz4HHrdSO2n73H/I2U+qv+PJB0cSGUNzIiCdc5bYbhO IKsxOC6ph3SJ8hr9JnRNXPEN/sF6duntDIqoCK9rWrACeksdARCl9j2itXiCvVbXiSCebws4K ntyd8xRtagS5bUzZlnS431IECsC0PtoQRDlwn7iBC34cT0N4/RjUsVgiVM9qjXkQpuaSRrOs6 F6wviacNEbuimCA4tgge6sCTd9yzUJC282D7CpiMk+90QzsiyfmR2LxkAEXhCmavBeYQoiEok Cvi4jVOrUbxJ2TxjcmpJKRUNi8iD8IBWPUl6D71sPsuin1UppF41qGM9hNL4LKho0Q6mXp3Tw xx7JZp697fM8g5Dc2xQzus3MzfryhyinWm/w5Pw6U3JbQmZaKvqbCMKCaoxoTqy3GKQFnYgm8 Rl5DwWhl3XJUxVlo4sDKE5dYQ0xmq/ITwySiYg0MmXA5gop5nOy+LCh9uL24grZiXSZXBsfq2 PZZxVUGW42yDYjJoZUcpkFhO3xdDBzbMGttRbYCNscIewBp5pC5USM12oA7VCR9wba1ZgG4Zl M+LzUMm9XIbgEQw9vzbkJKwPosz+FV85JJ9gPpXAdGVDYFZsRLqpqJSTgqtTKULPV2iZsgXId eLudvWOmKGdgAJqAp0ysA7x73rzxvylRV07IKIRkmuVo7JbtOhqZenAHrD3pivolo4QhOkeeI TvnI3Hmu0O+EH4NiwkWcSwuxvw6uTkyuKGNPZBPNavuFowlc+kJYgugmKy2DtTtcz3aXTeOqT Zsupd4xPoFMLMub9KHdZHwB1RT5qxO1oRyhvcOqigRaKjiv+hoiMvDIao4RBGvDHtp4CCPB1r tPwGxsCtkprOzFbgscBn50o2kNCPxKT158CkCXJc2KXrwvzrSdrgfpXWDFrt4QD3Sm/UP0xYs kMTJPPm9vISyB5Xkhhq1G79Logx0QgjHA141lc+gKayEhFDKlRCILUJxXBQCvvwbfDTxYtC1S g9rVajQ0P7XfT0hxm/GragqNi4QoNxw/YrodgaAOeOFmoydA3V7BrVyp7PReSQD7lPzqF82bK 4LMe86IPVDE/rxp3ljegxISSCL9LrsVLFU2FbBgnvyPMAVxTC4RhLbPqA== Subject: [libcamera-devel] [PATCH v9 4/4] libcamera: controls: Apply explicit fixed-sized Span type casts 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: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The change of types of some Controls from variable- to fixed-sized requires explicit casting of FrameDurationLimits, ColourGains and SensorBlackLevels. Signed-off-by: Christian Rauch --- include/libcamera/controls.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 19 ++++++++++--------- .../pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/qcam/dng_writer.cpp | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) -- 2.34.1 diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 192be784..a19f1845 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -168,7 +168,7 @@ public: using V = typename T::value_type; const V *value = reinterpret_cast(data().data()); - return { value, numElements_ }; + return T{ value, numElements_ }; } #ifndef __DOXYGEN__ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index c7492a77..baaa1e08 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -559,18 +559,19 @@ void IPARPi::reportMetadata() AwbStatus *awbStatus = rpiMetadata_.GetLocked("awb.status"); if (awbStatus) { - libcameraMetadata_.set(controls::ColourGains, { static_cast(awbStatus->gain_r), - static_cast(awbStatus->gain_b) }); + libcameraMetadata_.set(controls::ColourGains, + Span({ static_cast(awbStatus->gain_r), + static_cast(awbStatus->gain_b) })); libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperature_K); } BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked("black_level.status"); if (blackLevelStatus) libcameraMetadata_.set(controls::SensorBlackLevels, - { static_cast(blackLevelStatus->black_level_r), - static_cast(blackLevelStatus->black_level_g), - static_cast(blackLevelStatus->black_level_g), - static_cast(blackLevelStatus->black_level_b) }); + Span({ blackLevelStatus->black_level_r, + blackLevelStatus->black_level_g, + blackLevelStatus->black_level_g, + blackLevelStatus->black_level_b })); FocusStatus *focusStatus = rpiMetadata_.GetLocked("focus.status"); if (focusStatus && focusStatus->num == 12) { @@ -875,7 +876,7 @@ void IPARPi::queueRequest(const ControlList &controls) if (gains[0] != 0.0f && gains[1] != 0.0f) /* A gain of 0.0f will switch back to auto mode. */ libcameraMetadata_.set(controls::ColourGains, - { gains[0], gains[1] }); + Span({ gains[0], gains[1] })); break; } @@ -1159,8 +1160,8 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur /* Return the validated limits via metadata. */ libcameraMetadata_.set(controls::FrameDurationLimits, - { static_cast(minFrameDuration_.get()), - static_cast(maxFrameDuration_.get()) }); + Span({ static_cast(minFrameDuration_.get()), + static_cast(maxFrameDuration_.get()) })); /* * Calculate the maximum exposure time possible for the AGC to use. diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 28f054cb..d88aa256 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1717,7 +1717,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & * V4L2_CID_NOTIFY_GAINS control (which means notifyGainsUnity_ is set). */ if (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) { - libcamera::Span colourGains = + libcamera::Span colourGains = *controls.get(libcamera::controls::ColourGains); /* The control wants linear gains in the order B, Gb, Gr, R. */ ControlList ctrls(sensor_->controls()); diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 4b5d8276..23612be0 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -514,7 +514,7 @@ int DNGWriter::write(const char *filename, const Camera *camera, uint32_t whiteLevel = (1 << info->bitsPerSample) - 1; if (metadata.contains(controls::SensorBlackLevels)) { - Span levels = + Span levels = *metadata.get(controls::SensorBlackLevels); /*