summaryrefslogtreecommitdiff
path: root/src/lib/decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-11-04 20:33:43 +0000
committerCarl Hetherington <cth@carlh.net>2012-11-04 20:33:43 +0000
commit555b4068ff0e1726519d720b055a9faaca01a1a1 (patch)
treeb999d604061de8fd1dedbe4c4631f86db8015dbe /src/lib/decoder.cc
parentb7466a9653345bc51db4cb1d7e960bfc4c12721f (diff)
Various range fixes.
Diffstat (limited to 'src/lib/decoder.cc')
-rw-r--r--src/lib/decoder.cc61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index 1f93c6c60..5860f339e 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -232,30 +232,32 @@ Decoder::process_audio (uint8_t* data, int size)
_delay_line->feed (audio);
- /* Decode range in audio frames */
- pair<int64_t, int64_t> required_range (
- video_frames_to_audio_frames (_film->dcp_trim_start()),
- video_frames_to_audio_frames (_film->dcp_trim_start() + _film->dcp_length().get())
- );
-
- /* Range of this block of data */
- pair<int64_t, int64_t> this_range (
- _audio_frames_in,
- _audio_frames_in + audio->frames()
- );
-
- /* Trim start */
- if (required_range.first >= this_range.first && required_range.first < this_range.second) {
- int64_t const shift = this_range.first - required_range.first;
- audio->move (shift, 0, audio->frames() - shift);
- audio->set_frames (audio->frames() - shift);
- }
-
- /* Trim end */
- if (required_range.second >= this_range.first && required_range.second < this_range.second) {
- audio->set_frames (this_range.first - required_range.second);
+ if (_opt->decode_range) {
+ /* Decode range in audio frames */
+ pair<int64_t, int64_t> required_range (
+ video_frames_to_audio_frames (_opt->decode_range.get().first),
+ video_frames_to_audio_frames (_opt->decode_range.get().second)
+ );
+
+ /* Range of this block of data */
+ pair<int64_t, int64_t> this_range (
+ _audio_frames_in,
+ _audio_frames_in + audio->frames()
+ );
+
+ /* Trim start */
+ if (required_range.first >= this_range.first && required_range.first < this_range.second) {
+ int64_t const shift = this_range.first - required_range.first;
+ audio->move (shift, 0, audio->frames() - shift);
+ audio->set_frames (audio->frames() - shift);
+ }
+
+ /* Trim end */
+ if (required_range.second >= this_range.first && required_range.second < this_range.second) {
+ audio->set_frames (this_range.first - required_range.second);
+ }
}
-
+
if (audio->frames()) {
emit_audio (audio);
}
@@ -275,23 +277,22 @@ Decoder::emit_audio (shared_ptr<AudioBuffers> audio)
void
Decoder::process_video (AVFrame* frame)
{
- assert (_film->length());
-
if (_minimal) {
++_video_frames_in;
return;
}
- /* Use Film::length here as our one may be wrong */
-
if (_opt->decode_video_skip != 0 && (_video_frames_in % _opt->decode_video_skip) != 0) {
++_video_frames_in;
return;
}
- if (_video_frames_in < _film->dcp_trim_start() || _video_frames_in > (_film->dcp_trim_start() + _film->length().get())) {
- ++_video_frames_in;
- return;
+ if (_opt->decode_range) {
+ pair<SourceFrame, SourceFrame> r = _opt->decode_range.get();
+ if (_video_frames_in < r.first || _video_frames_in >= r.second) {
+ ++_video_frames_in;
+ return;
+ }
}
shared_ptr<FilterGraph> graph;