From patchwork Fri Jun 10 12:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16190 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 6897CBD161 for ; Fri, 10 Jun 2022 12:03:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F34FD65637; Fri, 10 Jun 2022 14:03:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654862625; bh=fRGUgvmQGO76HOY3krgWf1oDNTOur3O3Ovg2e8u7pyo=; 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=A7TMZVWsErvH7Em2CSzxUb0QYRaGblur44WwVkbGqq9PupFAwtGqLTp/q5Z1hfH/V CmkyAZfqEv19h8FoUlbvnZYjpuNoLLVBhZuXDVQMFfMk2aAqgEBWdAkhnmP1Q16LZ6 pRoQByD/c68prHeOj4/cxshzvKifLK2x3QrWwW75VHCnhRrghhRis3M/2oCIeUf0Qd h7ZEaxwDYhldv+LVBK7MLmf3WC5eiqdtHEn35NNz0HXeU3Os1+mZAg+66IMCRP92T/ 6/2eNOAmGCxa+ccGWzBG+Ha4J6XC69Ou8UoOOPnByCJDtJ5jfbyKk3HyooEE3kiZfE 42EgYe1nFS2Og== Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5CB2633A6 for ; Fri, 10 Jun 2022 14:03:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="TAE3ksq4"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654862621; bh=fRGUgvmQGO76HOY3krgWf1oDNTOur3O3Ovg2e8u7pyo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=TAE3ksq4HYTQq2WEisDYPsOoU8mt5gMG1G9zWxSOKrhVgM4FWRFLud26P4FMs2VwJ /w3gOjqinQ8HniB7XY6Mk2wSP5anHWC6K/N+CVkAsyDFJnWrQBPhkIGocxa/M90srV pwQBBJIh/D8jZJ4ojBs4HG/LHFk/yVJ3dILX3GDM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mg6Zq-1nXiWh0cCU-00hbgC; Fri, 10 Jun 2022 14:03:41 +0200 To: libcamera-devel@lists.libcamera.org Date: Fri, 10 Jun 2022 13:03:35 +0100 Message-Id: <20220610120338.96883-2-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610120338.96883-1-Rauch.Christian@gmx.de> References: <20220610120338.96883-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:YQN5a60gpNvmQ9mqZuotMDm9uLw4/kHnr/zTpFE4X0gG11ejSIz C7A4x8PCVO0MZ1G4wQIlD9G+8j0MZXKr9OcEgmC0Q4KGiJzTOFd7QF+b+DveN1Mb5/F7geW MHG9mZacx61oi9dJFQE5KusWYx6hoEJK/zDoB8Bgk+9AkW3wf3YdIiqMKtl361Kt7bbqX64 Jozw0RNXtB/Lsfa8V8pew== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:i1/RDNKq96w=:q2d9HxAiK0oXGstXZJr+Ul EyhzmIqPn++SHb7JerDwaO7K01Zo3WgKksH7kRbr45LAijxNImzduFrGRNgAhNb5w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47YH3LO0qxBG0Q== Subject: [libcamera-devel] [PATCH v8 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 Reviewed-by: Laurent Pinchart --- 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/ipa/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 9 ++++---- .../pipeline/raspberrypi/raspberrypi.cpp | 9 ++++---- src/qcam/dng_writer.cpp | 22 +++++++++---------- 9 files changed, 43 insertions(+), 43 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 8e804d4d..ec117101 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -305,7 +305,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; @@ -355,7 +355,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) { @@ -1094,7 +1094,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 " @@ -1473,29 +1474,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), @@ -1504,8 +1504,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/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 3b126bb5..f65a0680 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -939,7 +939,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 adc397e8..a62afdd4 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -365,7 +365,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) @@ -1706,7 +1706,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{ @@ -2041,7 +2042,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 }; @@ -2079,7 +2080,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 Fri Jun 10 12:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16191 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 54F4CC326B for ; Fri, 10 Jun 2022 12:03:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2BE276563B; Fri, 10 Jun 2022 14:03:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654862626; bh=zcOLN4jTQsCp6vUKu3Yx2tGvQEPJLyoWBisxOznYHvg=; 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=nmC9e4PLAmJiyuniKZ2ZT8kncwiWH7ecqLjrJLF7gAkmNiZWsgiFcLam2BCufh9Da jR0lnjZvrO//bxRgmySmcL/pGJR2q7cwqwstsFfYfl6yZ276TrAbtkXgFkOFIgsGqd nhdmGNcjcRuSfOxQ+Nmcntew4qz1rqFvuEg2rkwJ2tgi594houqER+9PdsStqY/8Uf DKLLFzYqpf4B6utPg6z1ghhHx7uAz8W5sng5FPWLCcRmkTDrooFfT0cdcEoudvLsFo 4SCTjXo64Bde/vfJjLKIErCWkjzBgqg4m0p9rXAJhbXlaGLtNf8MZLDsweipjfZ+0Y mHQ6zfyAQI5Vw== Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DBFCB65632 for ; Fri, 10 Jun 2022 14:03:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="atWD5Nvb"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654862621; bh=zcOLN4jTQsCp6vUKu3Yx2tGvQEPJLyoWBisxOznYHvg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=atWD5NvbidgeUtwzQai6saR/TvhrWHOhrm0Xf7XJFRh7HZ9gO9iklsUCyyhtAx0Mj asBIVbL+ZHrX6eUYlI6sIr05qaUe7CvlXl6ldI4+9aI5wHY+TF77EBbnjrXAiCAuLK 5HzKuq3Zop/TY4NRy0Xu3aqgVmkhhr6R84srql9U= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mt79F-1nkAsO1xrF-00tTl5; Fri, 10 Jun 2022 14:03:41 +0200 To: libcamera-devel@lists.libcamera.org Date: Fri, 10 Jun 2022 13:03:36 +0100 Message-Id: <20220610120338.96883-3-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610120338.96883-1-Rauch.Christian@gmx.de> References: <20220610120338.96883-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:5Q9EiJMeovbCTLOllPCNYlEJP2qYODZv5BbidjX7d6nFxlhu80c 0hak95PcJuW//3kiNjpndyIs5V+4e/LIBPbSS3eSGstQvyIEyskACi2PCsrc+TwnlHxtIDH xgh8lwamWvUaruoFgg3fb6KP3VZFK6GZpm96KCGr5UJpn2zI5rMn8CuYDGgH7f8X8s5kVjt V7/4PV7BsBT8VJ2BZsrXQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DA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yoGYjmKF8w9eis8+nUvsH2xGxIn1ejmTFi08eaDfo 0UlwVaNPG3+3fmMoqBBTCCGsP27rQUYD19un1j7dDp+8gCoqF0HjKHqRQ== Subject: [libcamera-devel] [PATCH v8 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 cd1d4512..f707c1f5 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 @@ -515,7 +515,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 Fri Jun 10 12:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16192 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 15633BD161 for ; Fri, 10 Jun 2022 12:03:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF5B16563E; Fri, 10 Jun 2022 14:03:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654862626; 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=dXeJayueG2dOtv9W0Xq54FHYZm1W1BSnDPLAaHiMffBdNid4p3TU5BXu+oRcMLxkr 5IzeJR6P6bHdkA+5fzcvTJhZdbpYsfBgUX5SOFhGkmGCPlSlnLQp7CXH9Us4lI1aZN OFiBqiNJNZLoDz+sUlfCQp8HFD7I6KvfyvA4uNbBGwsggcqWpVBQkunQfo3oIFMhyI hLGh97U7b+xiX6NOB/LuxcHZZk/cVrL4AtKCcvo8wsm/Q20fxub0ImrxhF6pXT07yC XGN71FumkWE89OHq3mxZa72VhTZuiMF1Vh5XHi/8kYzSuKms0nqJ17pPyVg6B61/Ey 5XThRgmxX2JYg== Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D54565635 for ; Fri, 10 Jun 2022 14:03:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="YeRheBFe"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654862622; bh=UqwmX7+yMaOqSyR96KduBQpxFaCTOfHvdMO6MxtFX8g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=YeRheBFekjIUDYppK2setFQbTgYj1n4uFZyzPI5yJzvnSB3kF06nyzb/Jv+D4jpwK 5br2J1fOcdlvThohRf8XpogMVxchX74QUBWcAyqQBaXsXgH6aCDwADwY/DIUq1nif1 wT3F9HsM1vze77Livmjgcashl1OoCruHYPOznW5E= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M1Ygt-1o10wI3Azr-0031az; Fri, 10 Jun 2022 14:03:41 +0200 To: libcamera-devel@lists.libcamera.org Date: Fri, 10 Jun 2022 13:03:37 +0100 Message-Id: <20220610120338.96883-4-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610120338.96883-1-Rauch.Christian@gmx.de> References: <20220610120338.96883-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:BTulCx1S+bFhonHqBTaBanSOVXgY3fdkv7aDzDlABF7hSnZjF2F IlGlrouEh3yCj7oetaqcNal9MCYgxfzGEunTICCLoqBssxaIT4CRXo5pTdpk/uZPe0OPjdP ubTKsfJjwyHv9N1mZfPyhx2A4D2HpTWEUaH1g0z5EYqSIz6hH9+OekcJBAwjXaRIzo+PtR7 2N2of5Zd/I2uVZpk+vCTQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Hjhxtm99Vo8=:qgNSD+dI6AJhhwbyQOHi2t bG6fw4TG7pmCOevStFAcG7oXMDkssr3ED921JY0VgRf+29fXGjQK76J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skNOQeJhPkPq3C7jtX0Cz/4G6Q== Subject: [libcamera-devel] [PATCH v8 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 Fri Jun 10 12:03:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16193 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 4D8F6C3273 for ; Fri, 10 Jun 2022 12:03:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2635D65647; Fri, 10 Jun 2022 14:03:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654862627; bh=57RCMCH2ddS8uCZM3E90CIxLhQ7NCr8PSdJyCaYE2pE=; 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=Oaxcok5no9SXRsAkspXowejSgoTjBfXOBaESpgAQ+QA9mKkj6B5TCIkIzHq7nASLZ OU5NReTemVCtQOI7jGcnA+dDluDsDjARLBy5QdMMY3Kpd+qxq9UHtLPibS3mxaZKT2 WVJIRG3HC+gONjLuNJbDBRzeHAq4zGu2fpmLFH08rYyst0kC56MZQB6qUG0EUdlvlH tf3HS7Ribh5GzG/qHuNxl5910w85TX4WKexrC5i/Dz2PZbLXd8vcPFtBNC8Fq/lljS DWWRzudtV/YxZXZ70NurY1KmxTOpBuVfJzBt1HqGFwPLHJlCHOsgbLOL2TiFanMYZv o8RJ06Q42jybA== Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 63FF7633A4 for ; Fri, 10 Jun 2022 14:03:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="LZXdxKSn"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654862622; bh=57RCMCH2ddS8uCZM3E90CIxLhQ7NCr8PSdJyCaYE2pE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=LZXdxKSnqSyPzY6o2rHi84acQGDHIDzIqQg9icUZXsQxKwbFII0z631OzKYB5yT/o Wb3HdloWxWtfzLJuOE/7TZolZpyDJpwxYWPKtyHhAshov8Gw3eM5CnC7giBrX9c/Kz amE9guz6XVEWs9MlkE2yQOUjaKE9tb0BtehoT8Uc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mbir8-1nTKoS03lW-00dBpM; Fri, 10 Jun 2022 14:03:42 +0200 To: libcamera-devel@lists.libcamera.org Date: Fri, 10 Jun 2022 13:03:38 +0100 Message-Id: <20220610120338.96883-5-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610120338.96883-1-Rauch.Christian@gmx.de> References: <20220610120338.96883-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:u1QfUdIYSEIwFXXbWte/JkcleX0EwVKw52hlNkvbKSySgbepGX9 qKd5GjPqKoxedRx4KFKOLj+ReDy3dnfe0AqXTTBrkGBL5JC/yw4VX+NNZzoKZ4qjechdZbE st3onm5ypLlMLHfBXryk2WsuSoPk65E/HghWlwsJPQ7lK3RfEUj0IrHY2d3lI3LaOb/7sqZ U1JxeSvG7LnVCckSx+CNQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:UHlmoPPN5p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8U3lJaCsq1G9hPVAJdEZ04yXYOrE0 eSW94Coek/mkf7fKFJjPCuEVTvOUzUgMjKCsSxw+ywb+jM7VBLmPGRT9Q== Subject: [libcamera-devel] [PATCH v8 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 f65a0680..203ae613 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -505,18 +505,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) { @@ -821,7 +822,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; } @@ -1105,8 +1106,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 a62afdd4..6efe7c3c 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1706,7 +1706,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); /*