From patchwork Thu Apr 1 10:13:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11810 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 6F655C0DA4 for ; Thu, 1 Apr 2021 10:14:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 24DC268786; Thu, 1 Apr 2021 12:14:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cZ26l7mh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42C7668782 for ; Thu, 1 Apr 2021 12:14:01 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CF39CF7; Thu, 1 Apr 2021 12:13:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272041; bh=mDh8j51KePPsrpsOwTeVl4thnj9CV52Rc1z67ivFfBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZ26l7mhg0/KO6juZjD0olTwnP+wttS7/D8cAl2ea2262giHo7P2BJRd/mlFgwon/ J7CuQXWatV1uTqHNRwDIFwbtCPQRCSkRLexsiVbNOv6TVnWhxjhEGclUbcQKCmGomy hxDIJL3qDdC0UQp0mqcBpbaFXx8cQdTOF4IPRYmU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:36 +0900 Message-Id: <20210401101340.160590-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/8] android: camera_device: Set proper frame duration 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" CTS tests that the frame duration is for every frame (after the first 6) are within an the frame duration ranges that we provide in the static metadata. One way it can do this, which it was doing previously, is to calculate it based on the timestamps that we report for each capture result. Another option is that we can report the frame duration ourselves. The frame durations that we report can be more "correct", so use this method to appease CTS. This is part of the fix to allow the following CTS test to pass: - android.hardware.camera2.cts.CaptureRequestTest#testNoiseReductionModeControl Signed-off-by: Paul Elder --- This probably isn't the right solution, but I can't seem to figure out what the correct route is. CTS checks if the frame duration that we report is within the frame duration range. The frame duration range comes from CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES (where the frame duration is less than or equal to 1e9/30). The frame duration for the current frame is either calculated by CTS by subtracting the SENSOR_TIMESTAMP of the current frame from the one of the last frame (which is what we did previously) or from what we report in SENSOR_FRAME_DURATION. The issue is that the frame duration calculated by CTS is less than the minimum available frame duration that we report. So should we lower that? Or report a different SENSOR_FRAME DURATION, if at all? --- src/android/camera_device.cpp | 13 +++++++++++-- src/android/camera_device.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ded57649..0dcfc880 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -311,7 +311,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor() = default; CameraDevice::CameraDevice(unsigned int id, std::shared_ptr camera) : id_(id), running_(false), camera_(std::move(camera)), - facing_(CAMERA_FACING_FRONT), orientation_(0) + facing_(CAMERA_FACING_FRONT), orientation_(0), lastResultTimestamp_(0) { camera_->requestCompleted.connect(this, &CameraDevice::requestComplete); @@ -1339,6 +1339,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() ANDROID_REQUEST_PIPELINE_DEPTH, ANDROID_SCALER_CROP_REGION, ANDROID_SENSOR_EXPOSURE_TIME, + ANDROID_SENSOR_FRAME_DURATION, ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, ANDROID_SENSOR_TEST_PATTERN_MODE, ANDROID_SENSOR_TIMESTAMP, @@ -1944,6 +1945,7 @@ void CameraDevice::requestComplete(Request *request) */ uint64_t timestamp = buffers.begin()->second->metadata().timestamp; resultMetadata = getResultMetadata(*descriptor, timestamp); + lastResultTimestamp_ = timestamp; /* Handle any JPEG compression. */ for (camera3_stream_buffer_t &buffer : descriptor->buffers_) { @@ -2074,7 +2076,7 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor, * Total bytes for JPEG metadata: 82 */ std::unique_ptr resultMetadata = - std::make_unique(44, 166); + std::make_unique(45, 174); if (!resultMetadata->isValid()) { LOG(HAL, Error) << "Failed to allocate result metadata"; return nullptr; @@ -2197,6 +2199,13 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor, value = ANDROID_NOISE_REDUCTION_MODE_OFF; resultMetadata->addEntry(ANDROID_NOISE_REDUCTION_MODE, &value, 1); + /* + * \todo Use sliding window average + * int64_t value64 = timestamp - lastResultTimestamp_; + */ + int64_t value64 = 33333333; + resultMetadata->addEntry(ANDROID_SENSOR_FRAME_DURATION, &value64, 1); + /* 33.3 msec */ const int64_t rolling_shutter_skew = 33300000; resultMetadata->addEntry(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 388acf51..dc03a038 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -131,6 +131,8 @@ private: unsigned int maxJpegBufferSize_; + int64_t lastResultTimestamp_; + CameraMetadata lastSettings_; };