summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-11-30 21:17:22 +0100
committerCarl Hetherington <cth@carlh.net>2019-11-30 21:17:22 +0100
commitb62cc4a8ced62d0d23da5a66494236be2822be79 (patch)
treef3fe5f9c364fb4a22b682c243c075ba19e76ec22
parent7c839a2530c910f062f3da8a02b7c70603c1f31b (diff)
Don't say we're encoding at 0fps when we're waiting for the timing history to stablise.
-rw-r--r--src/lib/event_history.cc8
-rw-r--r--src/lib/event_history.h5
-rw-r--r--src/lib/j2k_encoder.cc4
-rw-r--r--src/lib/j2k_encoder.h2
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 <cth@carlh.net>
+ Copyright (C) 2017-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -22,18 +22,20 @@
#include "util.h"
#include <boost/thread/mutex.hpp>
+using boost::optional;
+
EventHistory::EventHistory (int size)
: _size (size)
{
}
-float
+optional<float>
EventHistory::rate () const
{
boost::mutex::scoped_lock lock (_mutex);
if (int (_history.size()) < _size) {
- return 0;
+ return optional<float>();
}
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 <cth@carlh.net>
+ Copyright (C) 2017-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -22,6 +22,7 @@
#define DCPOMATIC_EVENT_HISTORY_H
#include <boost/thread/mutex.hpp>
+#include <boost/optional.hpp>
#include <list>
class EventHistory
@@ -29,7 +30,7 @@ class EventHistory
public:
explicit EventHistory (int size);
- float rate () const;
+ boost::optional<float> 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<float>
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<float> current_encoding_rate () const;
int video_frames_enqueued () const;
void servers_list_changed ();