Move transcode progress updating.
authorCarl Hetherington <cth@carlh.net>
Sat, 28 May 2016 23:58:36 +0000 (00:58 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 28 May 2016 23:59:58 +0000 (00:59 +0100)
Do this in the transcoder rather than the writer so that it updates
even if video is being referenced.

src/lib/transcoder.cc
src/lib/transcoder.h
src/lib/writer.cc

index eb787dee82c52ca3795cb5a145170710e6d1cd85..8afd647092512c2d802d9541e1ef5680cac86752 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -40,6 +40,8 @@
 #include <boost/foreach.hpp>
 #include <iostream>
 
+#include "i18n.h"
+
 using std::string;
 using std::cout;
 using std::list;
@@ -53,6 +55,7 @@ using boost::dynamic_pointer_cast;
  */
 Transcoder::Transcoder (shared_ptr<const Film> film, shared_ptr<Job> j)
        : _film (film)
+       , _job (j)
        , _player (new Player (film, film->playlist ()))
        , _writer (new Writer (film, j))
        , _encoder (new Encoder (film, _writer))
@@ -67,6 +70,8 @@ Transcoder::go ()
        _writer->start ();
        _encoder->begin ();
 
+       _job->sub (_("Encoding picture and sound"));
+
        DCPTime const frame = DCPTime::from_frames (1, _film->video_frame_rate ());
        DCPTime const length = _film->length ();
 
@@ -93,6 +98,8 @@ Transcoder::go ()
                if (non_burnt_subtitles) {
                        _writer->write (_player->get_subtitles (t, frame, true, false, true));
                }
+
+               _job->set_progress (float(t.get()) / length.get());
        }
 
        BOOST_FOREACH (ReferencedReelAsset i, _player->get_reel_assets ()) {
index 01446dccda49f1c08a9e35d0e64bbb40b7a34f00..a01b6a64ad4048d336e6c9b871a80e6517644755 100644 (file)
@@ -44,6 +44,7 @@ public:
 
 private:
        boost::shared_ptr<const Film> _film;
+       boost::shared_ptr<Job> _job;
        boost::shared_ptr<Player> _player;
        boost::shared_ptr<Writer> _writer;
        boost::shared_ptr<Encoder> _encoder;
index 8c01afe7c03f91a686dbb20682c1a2d0c2da9b25..4a99b079306f6c226ce3cc1b886852ded75e7e95 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -96,8 +96,6 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
        if (_film->is_signed() && !Config::instance()->signer_chain()->valid ()) {
                throw InvalidSignerError ();
        }
-
-       job->sub (_("Encoding image data"));
 }
 
 void
@@ -360,19 +358,6 @@ try
                        }
 
                        lock.lock ();
-
-                       shared_ptr<Job> job = _job.lock ();
-                       DCPOMATIC_ASSERT (job);
-                       int64_t total = _film->length().frames_round (_film->video_frame_rate ());
-                       if (_film->three_d ()) {
-                               /* _full_written and so on are incremented for each eye, so we need to double the total
-                                  frames to get the correct progress.
-                               */
-                               total *= 2;
-                       }
-                       if (total) {
-                               job->set_progress (float (_full_written + _fake_written + _repeat_written) / total);
-                       }
                }
 
                while (_queued_full_in_memory > _maximum_frames_in_memory) {