{"id":15062,"url":"https://patchwork.libcamera.org/api/patches/15062/?format=json","web_url":"https://patchwork.libcamera.org/patch/15062/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211206233948.1351206-7-kieran.bingham@ideasonboard.com>","date":"2021-12-06T23:39:46","name":"[libcamera-devel,6/8] qcam: Use Sensor sequence numbers and detect frame drop","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"a9a7b840ddaef4858967fbedf3c8c02a76844484","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":{"id":11,"url":"https://patchwork.libcamera.org/api/users/11/?format=json","username":"kbingham","first_name":"Kieran","last_name":"Bingham","email":"kieran.bingham@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/15062/mbox/","series":[{"id":2822,"url":"https://patchwork.libcamera.org/api/series/2822/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2822","date":"2021-12-06T23:39:40","name":"Request metadata: SensorSequence","version":1,"mbox":"https://patchwork.libcamera.org/series/2822/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15062/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15062/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 5EEFBC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Dec 2021 23:40:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 994C36087A;\n\tTue,  7 Dec 2021 00:40:01 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE9B36086C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Dec 2021 00:39:55 +0100 (CET)","from Monstersaurus.local\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 84E1CA1A;\n\tTue,  7 Dec 2021 00:39:55 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RCzz1FBC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638833995;\n\tbh=c9W5V0c1b0I7kHfI/zzAV6kOyl6NOrnkM3mB7FO/ScA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=RCzz1FBCsrqvVykG8AImWa5CjVYoA/g+vGSCCGFOlIMwNWowdP5QYGxd5ury/HiVP\n\tOKbJiFijNtGDjjAyCqfjL/Kwx0BJxV5T/lrxHN96JVMzSLGvWA6/azxz/NWxK9BskV\n\tiCG9RQZtRUis+LsZ3JXksGV8LqM4wkyZ4MN02gtU=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 6/8] qcam: Use Sensor sequence numbers and\n\tdetect frame drop","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The stream buffer sequence numbers might produce sequential\nmonotonic sequence numbers from an ISP producing a frame for every\ninput.\n\nThis however, doesn't capture pipeline stalls that cause us to miss or\ndrop frames from the sensor.\n\nUse the SensorSequence metadata to report sequence information, and\nreport with qInfo if a frame drop is detected.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/qcam/main_window.cpp | 22 ++++++++++++++++++++++\n src/qcam/main_window.h   |  1 +\n 2 files changed, 23 insertions(+)","diff":"diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex dd0e51f55b70..8d1d5b275aed 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -12,6 +12,7 @@\n #include <string>\n \n #include <libcamera/camera_manager.h>\n+#include <libcamera/control_ids.h>\n #include <libcamera/version.h>\n \n #include <QComboBox>\n@@ -510,6 +511,7 @@ int MainWindow::startCapture()\n \tpreviousFrames_ = 0;\n \tframesCaptured_ = 0;\n \tlastBufferTime_ = 0;\n+\tsequence_ = 0;\n \n \tret = camera_->start();\n \tif (ret) {\n@@ -719,6 +721,26 @@ void MainWindow::processCapture()\n \t\trequest = doneQueue_.dequeue();\n \t}\n \n+\t/* Parse the request metadata for useful information */\n+\tfor (const auto &ctrl : request->metadata()) {\n+\t\tconst int id = ctrl.first;\n+\t\tconst ControlValue &value = ctrl.second;\n+\n+\t\tif (id == controls::SensorSequence) {\n+\t\t\t/* Handle basic frame drop detection and reporting. */\n+\t\t\tint64_t sequence = value.get<int64_t>();\n+\t\t\tif (sequence_ == 0)\n+\t\t\t\tsequence_ = sequence - 1;\n+\t\t\tunsigned int drops = sequence - sequence_ - 1;\n+\t\t\tif (drops)\n+\t\t\t\tqInfo() << \"sequence: [\" << sequence << \"] *\"\n+\t\t\t\t\t<< drops << \" frame drops detected *\";\n+\t\t\tsequence_ = sequence;\n+\t\t}\n+\n+\t\t/* \\todo Handle all/other metadata types here. */\n+\t}\n+\n \t/* Process buffers. */\n \tif (request->buffers().count(vfStream_))\n \t\tprocessViewfinder(request->buffers().at(vfStream_));\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 3fbe872c0b5b..97568d6b619d 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -120,6 +120,7 @@ private:\n \tQMutex mutex_; /* Protects freeBuffers_, doneQueue_, and freeQueue_ */\n \n \tuint64_t lastBufferTime_;\n+\tuint64_t sequence_;\n \tQElapsedTimer frameRateInterval_;\n \tuint32_t previousFrames_;\n \tuint32_t framesCaptured_;\n","prefixes":["libcamera-devel","6/8"]}