Don't say we're encoding at 0fps when we're waiting for the timing history to stablise.
authorCarl Hetherington <cth@carlh.net>
Sat, 30 Nov 2019 20:17:22 +0000 (21:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 30 Nov 2019 20:17:22 +0000 (21:17 +0100)
src/lib/event_history.cc
src/lib/event_history.h
src/lib/j2k_encoder.cc
src/lib/j2k_encoder.h

index eb3438aaba1397b747554b31b25d21e4b92c8c4e..efe80b243ce53f328609b1d8be2af1975a725b79 100644 (file)
@@ -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.
 
 
     This file is part of DCP-o-matic.
 
 #include "util.h"
 #include <boost/thread/mutex.hpp>
 
 #include "util.h"
 #include <boost/thread/mutex.hpp>
 
+using boost::optional;
+
 EventHistory::EventHistory (int size)
        : _size (size)
 {
 
 }
 
 EventHistory::EventHistory (int size)
        : _size (size)
 {
 
 }
 
-float
+optional<float>
 EventHistory::rate () const
 {
        boost::mutex::scoped_lock lock (_mutex);
        if (int (_history.size()) < _size) {
 EventHistory::rate () const
 {
        boost::mutex::scoped_lock lock (_mutex);
        if (int (_history.size()) < _size) {
-               return 0;
+               return optional<float>();
        }
 
        struct timeval now;
        }
 
        struct timeval now;
index e194f633335f0c3e0850a4db3c101d54aadabfef..4670e7bfe8069b215448d09c62f545af909c7d1c 100644 (file)
@@ -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.
 
 
     This file is part of DCP-o-matic.
 
@@ -22,6 +22,7 @@
 #define DCPOMATIC_EVENT_HISTORY_H
 
 #include <boost/thread/mutex.hpp>
 #define DCPOMATIC_EVENT_HISTORY_H
 
 #include <boost/thread/mutex.hpp>
+#include <boost/optional.hpp>
 #include <list>
 
 class EventHistory
 #include <list>
 
 class EventHistory
@@ -29,7 +30,7 @@ class EventHistory
 public:
        explicit EventHistory (int size);
 
 public:
        explicit EventHistory (int size);
 
-       float rate () const;
+       boost::optional<float> rate () const;
        void event ();
 
 private:
        void event ();
 
 private:
index 431a47e6530e8277961ebc1f5ca0a6b7f24c32c2..e5f1271006b81953979f903b1ca86ae3413c5a47 100644 (file)
@@ -142,9 +142,9 @@ J2KEncoder::end ()
 }
 
 /** @return an estimate of the current number of frames we are encoding per second,
 }
 
 /** @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 ();
 J2KEncoder::current_encoding_rate () const
 {
        return _history.rate ();
index 01cf0605e0c1692e113d07fc8fef59c952f840ef..b723ca88f7afe2211364f25b817360ec639d4872 100644 (file)
@@ -68,7 +68,7 @@ public:
        /** Called when a processing run has finished */
        void end ();
 
        /** 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 ();
        int video_frames_enqueued () const;
 
        void servers_list_changed ();