[{"id":12104,"web_url":"https://patchwork.libcamera.org/comment/12104/","msgid":"<a493d010-4465-633a-00f0-9132a8c23420@ideasonboard.com>","date":"2020-08-24T09:29:56","subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 22/08/2020 14:35, Laurent Pinchart wrote:\n> Print the timestamp of the captured buffer in addition to the frame\n> rate, as this is more precise information that can help debugging issue.\n> While at it, compute the frame rate on the buffer timestamps instead of\n> sampling the clock in the request completion handler.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/cam/capture.cpp | 18 +++++++++++-------\n>  src/cam/capture.h   |  4 ++--\n>  2 files changed, 13 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> index af9029b743de..5510c009ca57 100644\n> --- a/src/cam/capture.cpp\n> +++ b/src/cam/capture.cpp\n> @@ -5,7 +5,6 @@\n>   * capture.cpp - Cam capture\n>   */\n>  \n> -#include <chrono>\n>  #include <iomanip>\n>  #include <iostream>\n>  #include <limits.h>\n> @@ -159,14 +158,19 @@ void Capture::requestComplete(Request *request)\n>  \n>  \tconst Request::BufferMap &buffers = request->buffers();\n>  \n> -\tstd::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();\n> -\tdouble fps = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_).count();\n> -\tfps = last_ != std::chrono::steady_clock::time_point() && fps\n> -\t    ? 1000.0 / fps : 0.0;\n> -\tlast_ = now;\n> +\t/*\n> +\t * Compute the frame rate. The timestamp is arbitrarily retrieved from\n> +\t * the first buffer, as all buffers should have matching timestamps.\n> +\t */\n> +\tuint64_t ts = buffers.begin()->second->metadata().timestamp;\n\nhow many seconds does this add? (Sorry I /reallly/ hate std::pair\nnomenclature... and using it like this in the context of a timestamp too\n... :-S)\n\nOther than that,\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +\tdouble fps = ts - last_;\n> +\tfps = last_ != 0 && fps ? 1000000000.0 / fps : 0.0;\n> +\tlast_ = ts;\n>  \n>  \tstd::stringstream info;\n> -\tinfo << \"fps: \" << std::fixed << std::setprecision(2) << fps;\n> +\tinfo << ts / 1000000000 << \".\"\n> +\t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n> +\t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n>  \n>  \tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n>  \t\tconst Stream *stream = it->first;\n> diff --git a/src/cam/capture.h b/src/cam/capture.h\n> index b4e39d51fdfa..0aebdac944cf 100644\n> --- a/src/cam/capture.h\n> +++ b/src/cam/capture.h\n> @@ -7,8 +7,8 @@\n>  #ifndef __CAM_CAPTURE_H__\n>  #define __CAM_CAPTURE_H__\n>  \n> -#include <chrono>\n>  #include <memory>\n> +#include <stdint.h>\n>  \n>  #include <libcamera/buffer.h>\n>  #include <libcamera/camera.h>\n> @@ -38,7 +38,7 @@ private:\n>  \n>  \tstd::map<const libcamera::Stream *, std::string> streamName_;\n>  \tBufferWriter *writer_;\n> -\tstd::chrono::steady_clock::time_point last_;\n> +\tuint64_t last_;\n>  \n>  \tEventLoop *loop_;\n>  \tunsigned int captureCount_;\n>","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 1F287BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 09:30:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 75A5962818;\n\tMon, 24 Aug 2020 11:30:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 15AF860387\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 11:30:04 +0200 (CEST)","from [192.168.0.20]\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 8DF9A279;\n\tMon, 24 Aug 2020 11:29:58 +0200 (CEST)"],"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=\"lNZSqaIO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598261398;\n\tbh=03hxufsrem78hqsO/lvQwzooLzxAEb2+va+e4EQxkns=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=lNZSqaIOjM276ClZcqlLCDLHXecxwDcDHrLHgQ3xT+JfyRtIfD02g3C6k3okuW6tr\n\tCwrk0DvBei7yHoCySOJ237TzYvgtHHhqpmea5ltMGcdN/Ue5k1UiVjx/ZUXpRttLFt\n\tfaski7GA9DQXJsnTUA3ow0vW73ZaVDY8WDy9q0DQ=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20200822133542.15612-1-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/S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0h6qWNpGwJ0/tYIgQJZh6bqkvBrDogAvuhf60Sogw+mH8b+PBlx1L\n\toeTK396wc+4c3BfiC6pNtUS5GpsPMMjYMk7kVvEAEQEAAYkCPAQYAQoAJgIbDBYhBJAt15g/\n\tvSj943LUeqEeRnIQpGH9BQJdizzIBQkLSKZiAAoJEKEeRnIQpGH9eYgQAJpjaWNgqNOnMTmD\n\tMJggbwjIotypzIXfhHNCeTkG7+qCDlSaBPclcPGYrTwCt0YWPU2TgGgJrVhYT20ierN8LUvj\n\t6qOPTd+Uk7NFzL65qkh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz\n\tPZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<a493d010-4465-633a-00f0-9132a8c23420@ideasonboard.com>","Date":"Mon, 24 Aug 2020 10:29:56 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20200822133542.15612-1-laurent.pinchart@ideasonboard.com>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","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>","Reply-To":"kieran.bingham@ideasonboard.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12132,"web_url":"https://patchwork.libcamera.org/comment/12132/","msgid":"<20200824215610.GH594558@oden.dyn.berto.se>","date":"2020-08-24T21:56:10","subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-08-22 16:35:42 +0300, Laurent Pinchart wrote:\n> Print the timestamp of the captured buffer in addition to the frame\n> rate, as this is more precise information that can help debugging issue.\n> While at it, compute the frame rate on the buffer timestamps instead of\n> sampling the clock in the request completion handler.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nIt would be nice to capture the before and after output of the tool in \nthe commit message. This is a nit so with and without it added,\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/cam/capture.cpp | 18 +++++++++++-------\n>  src/cam/capture.h   |  4 ++--\n>  2 files changed, 13 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> index af9029b743de..5510c009ca57 100644\n> --- a/src/cam/capture.cpp\n> +++ b/src/cam/capture.cpp\n> @@ -5,7 +5,6 @@\n>   * capture.cpp - Cam capture\n>   */\n>  \n> -#include <chrono>\n>  #include <iomanip>\n>  #include <iostream>\n>  #include <limits.h>\n> @@ -159,14 +158,19 @@ void Capture::requestComplete(Request *request)\n>  \n>  \tconst Request::BufferMap &buffers = request->buffers();\n>  \n> -\tstd::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();\n> -\tdouble fps = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_).count();\n> -\tfps = last_ != std::chrono::steady_clock::time_point() && fps\n> -\t    ? 1000.0 / fps : 0.0;\n> -\tlast_ = now;\n> +\t/*\n> +\t * Compute the frame rate. The timestamp is arbitrarily retrieved from\n> +\t * the first buffer, as all buffers should have matching timestamps.\n> +\t */\n> +\tuint64_t ts = buffers.begin()->second->metadata().timestamp;\n> +\tdouble fps = ts - last_;\n> +\tfps = last_ != 0 && fps ? 1000000000.0 / fps : 0.0;\n> +\tlast_ = ts;\n>  \n>  \tstd::stringstream info;\n> -\tinfo << \"fps: \" << std::fixed << std::setprecision(2) << fps;\n> +\tinfo << ts / 1000000000 << \".\"\n> +\t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n> +\t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n>  \n>  \tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n>  \t\tconst Stream *stream = it->first;\n> diff --git a/src/cam/capture.h b/src/cam/capture.h\n> index b4e39d51fdfa..0aebdac944cf 100644\n> --- a/src/cam/capture.h\n> +++ b/src/cam/capture.h\n> @@ -7,8 +7,8 @@\n>  #ifndef __CAM_CAPTURE_H__\n>  #define __CAM_CAPTURE_H__\n>  \n> -#include <chrono>\n>  #include <memory>\n> +#include <stdint.h>\n>  \n>  #include <libcamera/buffer.h>\n>  #include <libcamera/camera.h>\n> @@ -38,7 +38,7 @@ private:\n>  \n>  \tstd::map<const libcamera::Stream *, std::string> streamName_;\n>  \tBufferWriter *writer_;\n> -\tstd::chrono::steady_clock::time_point last_;\n> +\tuint64_t last_;\n>  \n>  \tEventLoop *loop_;\n>  \tunsigned int captureCount_;\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 8C00CBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 21:56:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 23004616B1;\n\tMon, 24 Aug 2020 23:56:13 +0200 (CEST)","from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 05A42616B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 23:56:11 +0200 (CEST)","by mail-lf1-x143.google.com with SMTP id x64so4357214lff.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 14:56:11 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tn24sm2392993lfe.38.2020.08.24.14.56.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 24 Aug 2020 14:56:10 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"w8gX4r8L\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=rW/TOi3km2DLlYcu/HYmg+JwKMtV9n2v5+R5jm8aivw=;\n\tb=w8gX4r8LTR0AYOAvs5vx3Cap4Hj3cSGhIyP7KAQwtS1jS2KrE3RWJJTHeem8QaWkmw\n\tCET5oLTsf3KqTWgbpa/wBECw9WzeF/zy1VwG4a1wB5Eg+5npI4Es35NPaxUFPu2ScGAt\n\tyEGUjMap79nF1fBf/oAyunWySaoa8Wr4mIj0hPDOqoONs1uG4bbZOgPrZ+eKD+emLHDY\n\tMTh4aAdh0kTlgpDLpHUYwIsdzk7xdyZy7LLzVTfabDsqQNROL/U5sd0h7m+NkHRZ3ZJU\n\tFtmPLCUsGvLCv/dkz39Jq1QFQio5UoU2zx6gyiy06zOuIeNTXp1pdf82uduzeQL9lqBS\n\t7tZA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=rW/TOi3km2DLlYcu/HYmg+JwKMtV9n2v5+R5jm8aivw=;\n\tb=gVO3XJmU+Y45plnIaFRiQ2joyA3BW0TWWO0poK2hEA4YSDxjNjVAuVebznOE3Om6UB\n\t9xkMV9y0SiUvGUhur10Tv9XqNNbRELohqH1GP4XfnDFN6PNjxhRhdbOe08RJElp7g5JX\n\tfZIW9CAngaSbzeD9viJgnZwBmCCjfK7Z3dWkfNvb1Y6nXR/VHBvIXboTjCCQOSCoay0g\n\tF+L2znTJYCNMEKOeDq8+XLiW7ZBBnL6a1WjLb/W1OdThJ+2OMSWmQRvZvR5w6P91SJwf\n\tpbzZFsfYN/Z+v4eFzOP8hFTmSEDamoORowJq3IVvJrurI8gSiSw8bZY368tbYNENZEdN\n\tqx/g==","X-Gm-Message-State":"AOAM533N2e45VrlRpdz5u6iGa9JdSd2RAgCWdcxb3wpzfyUxG+726r4a\n\tyDbzR4kVmSfLq+CPBYByAKO7Gw==","X-Google-Smtp-Source":"ABdhPJxxn3lhItEA3910vfZrEl/gxqeO0K3XVEYCa4Ob8V3yc+LTT0/C+KobkRUFntvVz7rMBH43sA==","X-Received":"by 2002:ac2:4ec4:: with SMTP id p4mr3588207lfr.176.1598306171271;\n\tMon, 24 Aug 2020 14:56:11 -0700 (PDT)","Date":"Mon, 24 Aug 2020 23:56:10 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200824215610.GH594558@oden.dyn.berto.se>","References":"<20200822133542.15612-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200822133542.15612-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12135,"web_url":"https://patchwork.libcamera.org/comment/12135/","msgid":"<20200824225012.GL6002@pendragon.ideasonboard.com>","date":"2020-08-24T22:50:12","subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nOn Mon, Aug 24, 2020 at 11:56:10PM +0200, Niklas Söderlund wrote:\n> On 2020-08-22 16:35:42 +0300, Laurent Pinchart wrote:\n> > Print the timestamp of the captured buffer in addition to the frame\n> > rate, as this is more precise information that can help debugging issue.\n> > While at it, compute the frame rate on the buffer timestamps instead of\n> > sampling the clock in the request completion handler.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> It would be nice to capture the before and after output of the tool in \n> the commit message. This is a nit so with and without it added,\n\nI'll add\n\nThe log changes from\n\nUsing camera \\_SB_.PCI0.XHC_.RHUB.HS05-5:1.0-0bda:58f4\nCapture until user interrupts by SIGINT\nfps: 0.00 stream0 seq: 000000 bytesused: 169968\nfps: 28.57 stream0 seq: 000002 bytesused: 170352\nfps: 31.25 stream0 seq: 000003 bytesused: 170428\nfps: 32.26 stream0 seq: 000004 bytesused: 170672\nfps: 27.78 stream0 seq: 000005 bytesused: 170568\n\nto\n\nUsing camera \\_SB_.PCI0.XHC_.RHUB.HS05-5:1.0-0bda:58f4\nCapture until user interrupts by SIGINT\n93473.942525 (0.00 fps) stream0 seq: 000000 bytesused: 183940\n93474.006528 (15.62 fps) stream0 seq: 000002 bytesused: 183512\n93474.038525 (31.25 fps) stream0 seq: 000003 bytesused: 183760\n93474.074530 (27.77 fps) stream0 seq: 000004 bytesused: 182704\n93474.106581 (31.20 fps) stream0 seq: 000005 bytesused: 182768\n\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> > ---\n> >  src/cam/capture.cpp | 18 +++++++++++-------\n> >  src/cam/capture.h   |  4 ++--\n> >  2 files changed, 13 insertions(+), 9 deletions(-)\n> > \n> > diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> > index af9029b743de..5510c009ca57 100644\n> > --- a/src/cam/capture.cpp\n> > +++ b/src/cam/capture.cpp\n> > @@ -5,7 +5,6 @@\n> >   * capture.cpp - Cam capture\n> >   */\n> >  \n> > -#include <chrono>\n> >  #include <iomanip>\n> >  #include <iostream>\n> >  #include <limits.h>\n> > @@ -159,14 +158,19 @@ void Capture::requestComplete(Request *request)\n> >  \n> >  \tconst Request::BufferMap &buffers = request->buffers();\n> >  \n> > -\tstd::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();\n> > -\tdouble fps = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_).count();\n> > -\tfps = last_ != std::chrono::steady_clock::time_point() && fps\n> > -\t    ? 1000.0 / fps : 0.0;\n> > -\tlast_ = now;\n> > +\t/*\n> > +\t * Compute the frame rate. The timestamp is arbitrarily retrieved from\n> > +\t * the first buffer, as all buffers should have matching timestamps.\n> > +\t */\n> > +\tuint64_t ts = buffers.begin()->second->metadata().timestamp;\n> > +\tdouble fps = ts - last_;\n> > +\tfps = last_ != 0 && fps ? 1000000000.0 / fps : 0.0;\n> > +\tlast_ = ts;\n> >  \n> >  \tstd::stringstream info;\n> > -\tinfo << \"fps: \" << std::fixed << std::setprecision(2) << fps;\n> > +\tinfo << ts / 1000000000 << \".\"\n> > +\t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n> > +\t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n> >  \n> >  \tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n> >  \t\tconst Stream *stream = it->first;\n> > diff --git a/src/cam/capture.h b/src/cam/capture.h\n> > index b4e39d51fdfa..0aebdac944cf 100644\n> > --- a/src/cam/capture.h\n> > +++ b/src/cam/capture.h\n> > @@ -7,8 +7,8 @@\n> >  #ifndef __CAM_CAPTURE_H__\n> >  #define __CAM_CAPTURE_H__\n> >  \n> > -#include <chrono>\n> >  #include <memory>\n> > +#include <stdint.h>\n> >  \n> >  #include <libcamera/buffer.h>\n> >  #include <libcamera/camera.h>\n> > @@ -38,7 +38,7 @@ private:\n> >  \n> >  \tstd::map<const libcamera::Stream *, std::string> streamName_;\n> >  \tBufferWriter *writer_;\n> > -\tstd::chrono::steady_clock::time_point last_;\n> > +\tuint64_t last_;\n> >  \n> >  \tEventLoop *loop_;\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 57C44BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 22:50:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E3E1C6037F;\n\tTue, 25 Aug 2020 00:50:33 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 73D676037F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Aug 2020 00:50:32 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E402B9CE;\n\tTue, 25 Aug 2020 00:50:31 +0200 (CEST)"],"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=\"nmyh6t9C\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598309432;\n\tbh=3mabz/SrxwJTF7kd2sUmH0SZuSOCdgOrfmCg5ZPcC8k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nmyh6t9C3b94OYcLJS7SJ2/1Q2mcooMwS2GyejoXdzlj8hXQ2Hf+qTgGgh0dtDczV\n\td0ME/aSRrpoOWfXq5PbDNt5d5t2geQxZpbOmaxXNsB2FnuEN/U4GnNn4ran2m7OKgu\n\t2UotT/Mf46JFm+pnU3NRXogDEMooBVDOghYOcJE4=","Date":"Tue, 25 Aug 2020 01:50:12 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200824225012.GL6002@pendragon.ideasonboard.com>","References":"<20200822133542.15612-1-laurent.pinchart@ideasonboard.com>\n\t<20200824215610.GH594558@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200824215610.GH594558@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12138,"web_url":"https://patchwork.libcamera.org/comment/12138/","msgid":"<20200824230218.GO6002@pendragon.ideasonboard.com>","date":"2020-08-24T23:02:18","subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Mon, Aug 24, 2020 at 10:29:56AM +0100, Kieran Bingham wrote:\n> On 22/08/2020 14:35, Laurent Pinchart wrote:\n> > Print the timestamp of the captured buffer in addition to the frame\n> > rate, as this is more precise information that can help debugging issue.\n> > While at it, compute the frame rate on the buffer timestamps instead of\n> > sampling the clock in the request completion handler.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/cam/capture.cpp | 18 +++++++++++-------\n> >  src/cam/capture.h   |  4 ++--\n> >  2 files changed, 13 insertions(+), 9 deletions(-)\n> > \n> > diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> > index af9029b743de..5510c009ca57 100644\n> > --- a/src/cam/capture.cpp\n> > +++ b/src/cam/capture.cpp\n> > @@ -5,7 +5,6 @@\n> >   * capture.cpp - Cam capture\n> >   */\n> >  \n> > -#include <chrono>\n> >  #include <iomanip>\n> >  #include <iostream>\n> >  #include <limits.h>\n> > @@ -159,14 +158,19 @@ void Capture::requestComplete(Request *request)\n> >  \n> >  \tconst Request::BufferMap &buffers = request->buffers();\n> >  \n> > -\tstd::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();\n> > -\tdouble fps = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_).count();\n> > -\tfps = last_ != std::chrono::steady_clock::time_point() && fps\n> > -\t    ? 1000.0 / fps : 0.0;\n> > -\tlast_ = now;\n> > +\t/*\n> > +\t * Compute the frame rate. The timestamp is arbitrarily retrieved from\n> > +\t * the first buffer, as all buffers should have matching timestamps.\n> > +\t */\n> > +\tuint64_t ts = buffers.begin()->second->metadata().timestamp;\n> \n> how many seconds does this add? (Sorry I /reallly/ hate std::pair\n> nomenclature... and using it like this in the context of a timestamp too\n> ... :-S)\n\nI'm not a big fan either. The good news is that this will go away as\nsoon as we add a timestamp to the request :-)\n\n> Other than that,\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> \n> > +\tdouble fps = ts - last_;\n> > +\tfps = last_ != 0 && fps ? 1000000000.0 / fps : 0.0;\n> > +\tlast_ = ts;\n> >  \n> >  \tstd::stringstream info;\n> > -\tinfo << \"fps: \" << std::fixed << std::setprecision(2) << fps;\n> > +\tinfo << ts / 1000000000 << \".\"\n> > +\t     << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000\n> > +\t     << \" (\" << std::fixed << std::setprecision(2) << fps << \" fps)\";\n> >  \n> >  \tfor (auto it = buffers.begin(); it != buffers.end(); ++it) {\n> >  \t\tconst Stream *stream = it->first;\n> > diff --git a/src/cam/capture.h b/src/cam/capture.h\n> > index b4e39d51fdfa..0aebdac944cf 100644\n> > --- a/src/cam/capture.h\n> > +++ b/src/cam/capture.h\n> > @@ -7,8 +7,8 @@\n> >  #ifndef __CAM_CAPTURE_H__\n> >  #define __CAM_CAPTURE_H__\n> >  \n> > -#include <chrono>\n> >  #include <memory>\n> > +#include <stdint.h>\n> >  \n> >  #include <libcamera/buffer.h>\n> >  #include <libcamera/camera.h>\n> > @@ -38,7 +38,7 @@ private:\n> >  \n> >  \tstd::map<const libcamera::Stream *, std::string> streamName_;\n> >  \tBufferWriter *writer_;\n> > -\tstd::chrono::steady_clock::time_point last_;\n> > +\tuint64_t last_;\n> >  \n> >  \tEventLoop *loop_;\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 668F5BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 23:02:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 012CF62818;\n\tTue, 25 Aug 2020 01:02:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 28B0A6037F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Aug 2020 01:02:40 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3507D9CE;\n\tTue, 25 Aug 2020 01:02:38 +0200 (CEST)"],"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=\"rALPoBep\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598310158;\n\tbh=XE45fWdj184atZ37lC6Rzzxzqw+a4wsuc/pX+4QqMgk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rALPoBep01pwOyW+i58l+f2rcegrJJmPcB4YACijt99HhuvOJLAqF1EyGjZTXvy5g\n\t8CSrSwCJZ2t0riBj62d0ZsoKFwEul9cCMYLXoLHVuWDJPgojP5+O+zxX+SEZmK8D64\n\tcOfr8ochrxsbTFKU3co0KSCbsIvuXc11+23dYEO0=","Date":"Tue, 25 Aug 2020 02:02:18 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20200824230218.GO6002@pendragon.ideasonboard.com>","References":"<20200822133542.15612-1-laurent.pinchart@ideasonboard.com>\n\t<a493d010-4465-633a-00f0-9132a8c23420@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<a493d010-4465-633a-00f0-9132a8c23420@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] cam: Print timestamp of captured\n\tbuffers","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]