From patchwork Thu Jul 4 14:59:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1616 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3731561570 for ; Thu, 4 Jul 2019 16:59:47 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B41A2F7B; Thu, 4 Jul 2019 16:59:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562252386; bh=hpAdJ1Frx97sr3AhhePfmNLQau/b6lCTcUYGLPg0jKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vKV1akXsYnXDqv49yDyLmy2DLYTshPLONztt7FWYnMfI5ilAH3D3hVepcHrO9KaXz cEY92MEo9S9mjngK1y1TMdTuOHu+2x8FDG0EgGCZnouy3EGtksS8YCAFQSyPTqbowe BIKXZpYv4i0Eq0GeCGGFfSmnlD8IHXwVGiFh3x7A= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 15:59:39 +0100 Message-Id: <20190704145942.17879-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> References: <20190704145942.17879-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/6] qcam: Move static timestamp to MainWindow X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jul 2019 14:59:47 -0000 The 'last' buffer timestamp is stored as a static. Rename the variable to a more descritive 'lastBufferTime' and move it to the class instance. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/qcam/main_window.cpp | 10 +++++----- src/qcam/main_window.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 16b123132dd9..0f737d852960 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -144,6 +144,8 @@ int MainWindow::startCapture() requests.push_back(request); } + lastBufferTime_ = 0; + ret = camera_->start(); if (ret) { std::cout << "Failed to start capture" << std::endl; @@ -187,16 +189,14 @@ void MainWindow::stopCapture() void MainWindow::requestComplete(Request *request, const std::map &buffers) { - static uint64_t last = 0; - if (request->status() == Request::RequestCancelled) return; Buffer *buffer = buffers.begin()->second; - double fps = buffer->timestamp() - last; - fps = last && fps ? 1000000000.0 / fps : 0.0; - last = buffer->timestamp(); + double fps = buffer->timestamp() - lastBufferTime_; + fps = lastBufferTime_ && fps ? 1000000000.0 / fps : 0.0; + lastBufferTime_ = buffer->timestamp(); std::cout << "seq: " << std::setw(6) << std::setfill('0') << buffer->sequence() << " buf: " << buffer->index() diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index fe565cbcb460..345bdaaed354 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -48,6 +48,8 @@ private: bool isCapturing_; std::unique_ptr config_; + uint64_t lastBufferTime_; + ViewFinder *viewfinder_; };