summaryrefslogtreecommitdiff
path: root/src/lib/encoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-09-28 23:09:15 +0100
committerCarl Hetherington <cth@carlh.net>2012-09-28 23:09:15 +0100
commitc0ed407fb02891f0dd364e78b6192f0e6dbe1d8d (patch)
treecfa1abb09f891f220f15886b4cad2d1562f4a79c /src/lib/encoder.cc
parentd50fe6707c973d4a1397aa40b67ae753744ce748 (diff)
parentc252cb33a3ca8088fbe091af903a77ad8a098969 (diff)
Merge branch 'master' of /home/carl/git/dvdomatic
Diffstat (limited to 'src/lib/encoder.cc')
-rw-r--r--src/lib/encoder.cc36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index c8eb24c80..62ba922da 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -36,6 +36,8 @@ Encoder::Encoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Lo
: _fs (s)
, _opt (o)
, _log (l)
+ , _just_skipped (false)
+ , _last_frame (0)
{
}
@@ -58,10 +60,32 @@ Encoder::current_frames_per_second () const
return _history_size / (seconds (now) - seconds (_time_history.back ()));
}
+/** @return true if the last frame to be processed was skipped as it already existed */
+bool
+Encoder::skipping () const
+{
+ boost::mutex::scoped_lock (_history_mutex);
+ return _just_skipped;
+}
+
+/** @return Index of last frame to be successfully encoded */
+int
+Encoder::last_frame () const
+{
+ boost::mutex::scoped_lock (_history_mutex);
+ return _last_frame;
+}
+
+/** Should be called when a frame has been encoded successfully.
+ * @param n Frame index.
+ */
void
-Encoder::frame_done ()
+Encoder::frame_done (int n)
{
boost::mutex::scoped_lock lock (_history_mutex);
+ _just_skipped = false;
+ _last_frame = n;
+
struct timeval tv;
gettimeofday (&tv, 0);
_time_history.push_front (tv);
@@ -69,3 +93,13 @@ Encoder::frame_done ()
_time_history.pop_back ();
}
}
+
+/** Called by a subclass when it has just skipped the processing
+ of a frame because it has already been done.
+*/
+void
+Encoder::frame_skipped ()
+{
+ boost::mutex::scoped_lock lock (_history_mutex);
+ _just_skipped = true;
+}