From b62cc4a8ced62d0d23da5a66494236be2822be79 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 30 Nov 2019 21:17:22 +0100 Subject: [PATCH] Don't say we're encoding at 0fps when we're waiting for the timing history to stablise. --- src/lib/event_history.cc | 8 +++++--- src/lib/event_history.h | 5 +++-- src/lib/j2k_encoder.cc | 4 ++-- src/lib/j2k_encoder.h | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/event_history.cc b/src/lib/event_history.cc index eb3438aab..efe80b243 100644 --- a/src/lib/event_history.cc +++ b/src/lib/event_history.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -22,18 +22,20 @@ #include "util.h" #include +using boost::optional; + EventHistory::EventHistory (int size) : _size (size) { } -float +optional EventHistory::rate () const { boost::mutex::scoped_lock lock (_mutex); if (int (_history.size()) < _size) { - return 0; + return optional(); } struct timeval now; diff --git a/src/lib/event_history.h b/src/lib/event_history.h index e194f6333..4670e7bfe 100644 --- a/src/lib/event_history.h +++ b/src/lib/event_history.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -22,6 +22,7 @@ #define DCPOMATIC_EVENT_HISTORY_H #include +#include #include class EventHistory @@ -29,7 +30,7 @@ class EventHistory public: explicit EventHistory (int size); - float rate () const; + boost::optional rate () const; void event (); private: diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 431a47e65..e5f127100 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -142,9 +142,9 @@ J2KEncoder::end () } /** @return an estimate of the current number of frames we are encoding per second, - * or 0 if not known. + * if known. */ -float +optional J2KEncoder::current_encoding_rate () const { return _history.rate (); diff --git a/src/lib/j2k_encoder.h b/src/lib/j2k_encoder.h index 01cf0605e..b723ca88f 100644 --- a/src/lib/j2k_encoder.h +++ b/src/lib/j2k_encoder.h @@ -68,7 +68,7 @@ public: /** Called when a processing run has finished */ void end (); - float current_encoding_rate () const; + boost::optional current_encoding_rate () const; int video_frames_enqueued () const; void servers_list_changed (); -- 2.30.2