summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-08-29 14:25:31 +0100
committerCarl Hetherington <cth@carlh.net>2013-08-29 14:25:31 +0100
commit9e124e8ce2eb7a9faeb91b33169ab1ae4912afb0 (patch)
treedce175e929d64c6562b60a43138d41dfdd3da6d1 /src/lib
parent86880ddcedaf39522a92a3a63d2a5df48fdf2284 (diff)
Better progress reporting during MXF hashing (#184).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/encoder.cc12
-rw-r--r--src/lib/encoder.h15
-rw-r--r--src/lib/transcode_job.cc7
-rw-r--r--src/lib/transcoder.cc6
-rw-r--r--src/lib/transcoder.h14
-rw-r--r--src/lib/writer.cc14
6 files changed, 51 insertions, 17 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index ea175f1f4..35ebfb52e 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -52,6 +52,7 @@ Encoder::Encoder (shared_ptr<const Film> f, shared_ptr<Job> j)
: _film (f)
, _job (j)
, _video_frames_out (0)
+ , _state (TRANSCODING)
, _terminate (false)
{
_have_a_real_frame[EYES_BOTH] = false;
@@ -125,6 +126,11 @@ Encoder::process_end ()
}
}
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _state = HASHING;
+ }
+
_writer->finish ();
_writer.reset ();
}
@@ -135,7 +141,7 @@ Encoder::process_end ()
float
Encoder::current_encoding_rate () const
{
- boost::mutex::scoped_lock lock (_history_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
if (int (_time_history.size()) < _history_size) {
return 0;
}
@@ -150,7 +156,7 @@ Encoder::current_encoding_rate () const
int
Encoder::video_frames_out () const
{
- boost::mutex::scoped_lock (_history_mutex);
+ boost::mutex::scoped_lock (_state_mutex);
return _video_frames_out;
}
@@ -160,7 +166,7 @@ Encoder::video_frames_out () const
void
Encoder::frame_done ()
{
- boost::mutex::scoped_lock lock (_history_mutex);
+ boost::mutex::scoped_lock lock (_state_mutex);
struct timeval tv;
gettimeofday (&tv, 0);
diff --git a/src/lib/encoder.h b/src/lib/encoder.h
index 44134e568..e9b30df9e 100644
--- a/src/lib/encoder.h
+++ b/src/lib/encoder.h
@@ -77,6 +77,16 @@ public:
float current_encoding_rate () const;
int video_frames_out () const;
+ enum State {
+ TRANSCODING,
+ HASHING
+ };
+
+ State state () const {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _state;
+ }
+
private:
void frame_done ();
@@ -88,8 +98,8 @@ private:
boost::shared_ptr<const Film> _film;
boost::shared_ptr<Job> _job;
- /** Mutex for _time_history and _last_frame */
- mutable boost::mutex _history_mutex;
+ /** Mutex for _time_history, _last_frame and _state */
+ mutable boost::mutex _state_mutex;
/** List of the times of completion of the last _history_size frames;
first is the most recently completed.
*/
@@ -99,6 +109,7 @@ private:
/** Number of video frames written for the DCP so far */
int _video_frames_out;
+ State _state;
bool _have_a_real_frame[EYES_COUNT];
bool _terminate;
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index 6d5edd7c0..c9ec2053d 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -91,7 +91,12 @@ TranscodeJob::status () const
s << Job::status ();
if (!finished ()) {
- s << N_("; ") << fixed << setprecision (1) << fps << N_(" ") << _("frames per second");
+ if (_transcoder->state() == Encoder::TRANSCODING) {
+ s << "; " << fixed << setprecision (1) << fps << N_(" ") << _("frames per second");
+ } else {
+ /* TRANSLATORS: this means `computing a hash' as in a digest of a block of data */
+ s << "; " << _("hashing");
+ }
}
return s.str ();
diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc
index 715a158db..63ba77939 100644
--- a/src/lib/transcoder.cc
+++ b/src/lib/transcoder.cc
@@ -90,3 +90,9 @@ Transcoder::video_frames_out () const
{
return _encoder->video_frames_out ();
}
+
+Encoder::State
+Transcoder::state () const
+{
+ return _encoder->state ();
+}
diff --git a/src/lib/transcoder.h b/src/lib/transcoder.h
index 007065b65..7bf214a88 100644
--- a/src/lib/transcoder.h
+++ b/src/lib/transcoder.h
@@ -18,12 +18,7 @@
*/
#include "types.h"
-
-/** @file src/transcoder.h
- *
- * A decoder is selected according to the content type, and the encoder can be specified
- * as a parameter to the constructor.
- */
+#include "encoder.h"
class Film;
class Job;
@@ -31,11 +26,7 @@ class Encoder;
class VideoFilter;
class Player;
-/** @class Transcoder
- *
- * A decoder is selected according to the content type, and the encoder can be specified
- * as a parameter to the constructor.
- */
+/** @class Transcoder */
class Transcoder : public boost::noncopyable
{
public:
@@ -47,6 +38,7 @@ public:
void go ();
float current_encoding_rate () const;
+ Encoder::State state () const;
int video_frames_out () const;
private:
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 2e0ffd833..5f94d5d6b 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -110,6 +110,8 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
_sound_asset_writer = _sound_asset->start_write (_film->interop ());
_thread = new boost::thread (boost::bind (&Writer::thread, this));
+
+ _job->descend (0.9);
}
void
@@ -389,6 +391,18 @@ Writer::finish ()
)
));
+ /* Compute the digests for the assets now so that we can keep track of progress.
+ We did _job->descend (0.9) in our constructor */
+ _job->ascend ();
+
+ _job->descend (0.1);
+ _picture_asset->compute_digest (boost::bind (&Job::set_progress, _job.get(), _1));
+ _job->ascend ();
+
+ _job->descend (0.1);
+ _sound_asset->compute_digest (boost::bind (&Job::set_progress, _job.get(), _1));
+ _job->ascend ();
+
libdcp::XMLMetadata meta = Config::instance()->dcp_metadata ();
meta.set_issue_date_now ();
dcp.write_xml (_film->interop (), meta);