From patchwork Thu Jul 4 13:03:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1609 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1EB8761572 for ; Thu, 4 Jul 2019 15:03:54 +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 BFD0324B; Thu, 4 Jul 2019 15:03:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562245433; bh=tLQfOxhemAu9JAK8sxda3d2pwJLGMUqfMc+UnIfl/7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/8xBV7j4NYd+f0TKDDdPSLfjZdsWUUdK1d88lapsdC3eHQ5BO5AM/6A3Q20ciKrv xgekJGQiCJgqsebxr+kMNwDyrqVdtWzA9cVZ/uB4whZ4Bz1/nYgUHWoQTzfPIjl0BH 6izyFe08mtXc0/2kM+OmuKT/LzIiiSz+I/jO+aFk= From: Kieran Bingham To: LibCamera Devel Date: Thu, 4 Jul 2019 14:03:45 +0100 Message-Id: <20190704130347.9372-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190704130347.9372-1-kieran.bingham@ideasonboard.com> References: <20190704130347.9372-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] 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 13:03:55 -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. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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_; };