summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-11-04 23:56:53 +0000
committerCarl Hetherington <cth@carlh.net>2012-11-04 23:56:53 +0000
commit10a001a0c7cf33d384d9613168d80c0c5a07426c (patch)
tree0b610fb22917e2bd339067981ccc69bd33d493e8 /src/lib
parentfa1ac8629ae03c152ee85c0a82ed979557e4be00 (diff)
Various fixes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/decoder.cc22
-rw-r--r--src/lib/j2k_wav_encoder.cc4
-rw-r--r--src/lib/job.cc2
-rw-r--r--src/lib/transcode_job.cc2
4 files changed, 21 insertions, 9 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index e25a106d2..617d57ff6 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -116,6 +116,11 @@ Decoder::process_end ()
black->make_black ();
for (int i = 0; i < black_video_frames; ++i) {
emit_video (black, shared_ptr<Subtitle> ());
+
+ /* This is a bit of a hack, but you can sort-of justify it if you squint at it right.
+ It's important because the encoder will probably use this to name its output frame.
+ */
+ ++_video_frames_in;
}
/* Now recompute our check value */
@@ -232,6 +237,8 @@ Decoder::process_audio (uint8_t* data, int size)
_delay_line->feed (audio);
+ int const in_frames = audio->frames ();
+
if (_opt->decode_range) {
/* Decode range in audio frames */
pair<int64_t, int64_t> required_range (
@@ -244,10 +251,13 @@ Decoder::process_audio (uint8_t* data, int size)
_audio_frames_in,
_audio_frames_in + audio->frames()
);
-
- if (required_range.first >= this_range.first && required_range.first < this_range.second) {
+
+ if (this_range.second < required_range.first || required_range.second < this_range.first) {
+ /* No part of this audio is within the required range */
+ audio->set_frames (0);
+ } else if (required_range.first >= this_range.first && required_range.first < this_range.second) {
/* Trim start */
- int64_t const shift = this_range.first - required_range.first;
+ int64_t const shift = required_range.first - this_range.first;
audio->move (shift, 0, audio->frames() - shift);
audio->set_frames (audio->frames() - shift);
} else if (required_range.second >= this_range.first && required_range.second < this_range.second) {
@@ -259,6 +269,8 @@ Decoder::process_audio (uint8_t* data, int size)
if (audio->frames()) {
emit_audio (audio);
}
+
+ _audio_frames_in += in_frames;
}
void
@@ -317,9 +329,8 @@ Decoder::process_video (AVFrame* frame)
}
emit_video (*i, sub);
+ ++_video_frames_in;
}
-
- ++_video_frames_in;
}
void
@@ -331,6 +342,7 @@ Decoder::repeat_last_video ()
}
emit_video (_last_image, _last_subtitle);
+ ++_video_frames_in;
}
void
diff --git a/src/lib/j2k_wav_encoder.cc b/src/lib/j2k_wav_encoder.cc
index 38078efb1..09e877579 100644
--- a/src/lib/j2k_wav_encoder.cc
+++ b/src/lib/j2k_wav_encoder.cc
@@ -163,7 +163,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
TIMING ("encoder thread %1 wakes with queue of %2", boost::this_thread::get_id(), _queue.size());
boost::shared_ptr<DCPVideoFrame> vf = _queue.front ();
- _film->log()->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame()));
+ _film->log()->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame()), Log::VERBOSE);
_queue.pop_front ();
lock.unlock ();
@@ -278,7 +278,7 @@ J2KWAVEncoder::process_end ()
/* Keep waking workers until the queue is empty */
while (!_queue.empty ()) {
- _film->log()->log ("Waking with " + lexical_cast<string> (_queue.size ()));
+ _film->log()->log ("Waking with " + lexical_cast<string> (_queue.size ()), Log::VERBOSE);
_worker_condition.notify_all ();
_worker_condition.wait (lock);
}
diff --git a/src/lib/job.cc b/src/lib/job.cc
index c5a254a2a..3309fe16c 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -236,7 +236,7 @@ Job::status () const
float const p = overall_progress ();
int const t = elapsed_time ();
int const r = remaining_time ();
-
+
stringstream s;
if (!finished () && p >= 0 && t > 10 && r > 0) {
s << rint (p * 100) << "%; " << seconds_to_approximate_hms (r) << " remaining";
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index 2690d8ed1..db4fb86e1 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -111,6 +111,6 @@ TranscodeJob::remaining_time () const
}
/* We assume that dcp_length() is valid */
- SourceFrame const left = _film->dcp_length().get() - _encoder->last_frame() - _film->dcp_trim_start();
+ SourceFrame const left = _film->dcp_trim_start() + _film->dcp_length().get() - _encoder->last_frame();
return left / fps;
}