[libcamera-devel] [PATCH v2 3/5] qcam: Move static timestamp to MainWindow

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Jul 4 15:41:26 CEST 2019


Hi Kieran,

Thank you for the patch.

On Thu, Jul 04, 2019 at 02:03:45PM +0100, Kieran Bingham wrote:
> 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 <kieran.bingham at ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  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<Stream *, Buffer *> &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<CameraConfiguration> config_;
>  
> +	uint64_t lastBufferTime_;
> +
>  	ViewFinder *viewfinder_;
>  };
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list