From patchwork Mon Dec 6 23:39:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15062 X-Patchwork-Delegate: kieran.bingham@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 5EEFBC3259 for ; Mon, 6 Dec 2021 23:40:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 994C36087A; Tue, 7 Dec 2021 00:40:01 +0100 (CET) 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="RCzz1FBC"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE9B36086C for ; Tue, 7 Dec 2021 00:39:55 +0100 (CET) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 84E1CA1A; Tue, 7 Dec 2021 00:39:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638833995; bh=c9W5V0c1b0I7kHfI/zzAV6kOyl6NOrnkM3mB7FO/ScA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCzz1FBCsrqvVykG8AImWa5CjVYoA/g+vGSCCGFOlIMwNWowdP5QYGxd5ury/HiVP OKbJiFijNtGDjjAyCqfjL/Kwx0BJxV5T/lrxHN96JVMzSLGvWA6/azxz/NWxK9BskV iCG9RQZtRUis+LsZ3JXksGV8LqM4wkyZ4MN02gtU= From: Kieran Bingham To: libcamera devel Date: Mon, 6 Dec 2021 23:39:46 +0000 Message-Id: <20211206233948.1351206-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211206233948.1351206-1-kieran.bingham@ideasonboard.com> References: <20211206233948.1351206-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/8] qcam: Use Sensor sequence numbers and detect frame drop 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" The stream buffer sequence numbers might produce sequential monotonic sequence numbers from an ISP producing a frame for every input. This however, doesn't capture pipeline stalls that cause us to miss or drop frames from the sensor. Use the SensorSequence metadata to report sequence information, and report with qInfo if a frame drop is detected. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- src/qcam/main_window.cpp | 22 ++++++++++++++++++++++ src/qcam/main_window.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index dd0e51f55b70..8d1d5b275aed 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -510,6 +511,7 @@ int MainWindow::startCapture() previousFrames_ = 0; framesCaptured_ = 0; lastBufferTime_ = 0; + sequence_ = 0; ret = camera_->start(); if (ret) { @@ -719,6 +721,26 @@ void MainWindow::processCapture() request = doneQueue_.dequeue(); } + /* Parse the request metadata for useful information */ + for (const auto &ctrl : request->metadata()) { + const int id = ctrl.first; + const ControlValue &value = ctrl.second; + + if (id == controls::SensorSequence) { + /* Handle basic frame drop detection and reporting. */ + int64_t sequence = value.get(); + if (sequence_ == 0) + sequence_ = sequence - 1; + unsigned int drops = sequence - sequence_ - 1; + if (drops) + qInfo() << "sequence: [" << sequence << "] *" + << drops << " frame drops detected *"; + sequence_ = sequence; + } + + /* \todo Handle all/other metadata types here. */ + } + /* Process buffers. */ if (request->buffers().count(vfStream_)) processViewfinder(request->buffers().at(vfStream_)); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 3fbe872c0b5b..97568d6b619d 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -120,6 +120,7 @@ private: QMutex mutex_; /* Protects freeBuffers_, doneQueue_, and freeQueue_ */ uint64_t lastBufferTime_; + uint64_t sequence_; QElapsedTimer frameRateInterval_; uint32_t previousFrames_; uint32_t framesCaptured_;