[{"id":21638,"web_url":"https://patchwork.libcamera.org/comment/21638/","msgid":"<87260b77-2e48-49d9-c6f0-372f8935be98@ideasonboard.com>","date":"2021-12-07T13:56:22","subject":"Re: [libcamera-devel] [PATCH 4/8] cam: Use Sensor sequence numbers\n\tand detect frame drop","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Kieran,\n\nOn 12/7/21 5:09 AM, Kieran Bingham wrote:\n> The stream buffer sequence numbers might produce sequential\n> monotonic sequence numbers from an ISP producing a frame for every\n> input.\n>\n> This however, doesn't capture pipeline stalls that cause us to miss or\n> drop frames from the sensor.\n>\n> Use the SensorSequence metadata to report sequence information, and add\n> a warning to the summary line if a frame drop is detected.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>   src/cam/camera_session.cpp | 17 +++++++++++++++--\n>   src/cam/camera_session.h   |  1 +\n>   2 files changed, 16 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\n> index 50170723c30f..f9495f7f7e42 100644\n> --- a/src/cam/camera_session.cpp\n> +++ b/src/cam/camera_session.cpp\n> @@ -29,8 +29,8 @@ CameraSession::CameraSession(CameraManager *cm,\n>   \t\t\t     unsigned int cameraIndex,\n>   \t\t\t     const OptionsParser::Options &options)\n>   \t: options_(options), cameraIndex_(cameraIndex), last_(0),\n> -\t  queueCount_(0), captureCount_(0), captureLimit_(0),\n> -\t  printMetadata_(false)\n> +\t  sequence_(0), queueCount_(0), captureCount_(0),\n> +\t  captureLimit_(0), printMetadata_(false)\n>   {\n>   \tchar *endptr;\n>   \tunsigned long index = strtoul(cameraId.c_str(), &endptr, 10);\n> @@ -375,6 +375,11 @@ void CameraSession::processRequest(Request *request)\n>   \t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n>   \t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n>   \n> +\tuint64_t sequence = request->metadata().get(controls::SensorSequence);\n> +\t// Report capture sequence number\n\n\nno checkstyle complain here?\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> +\tinfo << \" [\" << std::setw(6) << std::setfill('0')\n> +\t     << sequence << \"]\";\n> +\n>   \tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n>   \t\tconst Stream *stream = it->first;\n>   \t\tFrameBuffer *buffer = it->second;\n> @@ -398,6 +403,14 @@ void CameraSession::processRequest(Request *request)\n>   \t\t\trequeue = false;\n>   \t}\n>   \n> +\t/* Handle basic frame drop detection and reporting. */\n> +\tif (sequence_ == 0)\n> +\t\tsequence_ = sequence - 1;\n> +\tunsigned int drops = sequence - sequence_ - 1;\n> +\tif (drops)\n> +\t\tinfo << \" *\" << drops << \" frame drops detected* \";\n> +\tsequence_ = sequence;\n> +\n>   \tstd::cout << info.str() << std::endl;\n>   \n>   \tif (printMetadata_) {\n> diff --git a/src/cam/camera_session.h b/src/cam/camera_session.h\n> index bf966bd15ab0..14dc1421da4d 100644\n> --- a/src/cam/camera_session.h\n> +++ b/src/cam/camera_session.h\n> @@ -65,6 +65,7 @@ private:\n>   \tunsigned int cameraIndex_;\n>   \n>   \tuint64_t last_;\n> +\tuint64_t sequence_;\n>   \n>   \tunsigned int queueCount_;\n>   \tunsigned int captureCount_;","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 79E74BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Dec 2021 13:56:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C290D6086A;\n\tTue,  7 Dec 2021 14:56:34 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 08F2E60592\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Dec 2021 14:56:33 +0100 (CET)","from [IPv6:2401:4900:1f3e:16f1:4e1b:f869:54d4:8c0c] (unknown\n\t[IPv6:2401:4900:1f3e:16f1:4e1b:f869:54d4:8c0c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0AD2A556;\n\tTue,  7 Dec 2021 14:56:30 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tpbmPHbk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638885392;\n\tbh=bQ9LHcCwQNovjUx9XMfXspz9IDhnkhVnRECWOohfpDY=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=tpbmPHbkYn1gJkPLL0HVTXIBLef+InCB3pCdLRIz62xiV8vOaxM3UURpBNqD1KOE4\n\tiGBmiqXkpK3S1GXBW9MyyoMdKS30ckfpocHR8wufIeax7/xXW5GglgBh0m8DvmyXwR\n\tWqxeAdqZgvrCRM4kT5CoyyQB2vSDph9MYiRgpInY=","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","References":"<20211206233948.1351206-1-kieran.bingham@ideasonboard.com>\n\t<20211206233948.1351206-5-kieran.bingham@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<87260b77-2e48-49d9-c6f0-372f8935be98@ideasonboard.com>","Date":"Tue, 7 Dec 2021 19:26:22 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20211206233948.1351206-5-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 4/8] cam: Use Sensor sequence numbers\n\tand detect 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>"}}]