summaryrefslogtreecommitdiff
path: root/src/lib/trimmer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/trimmer.cc')
-rw-r--r--src/lib/trimmer.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/lib/trimmer.cc b/src/lib/trimmer.cc
index 68364e50a..b7afc9299 100644
--- a/src/lib/trimmer.cc
+++ b/src/lib/trimmer.cc
@@ -28,7 +28,8 @@ using boost::shared_ptr;
Trimmer::Trimmer (
shared_ptr<Log> log,
int video_trim_start,
- int video_trim_end, int video_length,
+ int video_trim_end,
+ int video_length,
int audio_sample_rate,
float frames_per_second,
int dcp_frames_per_second
@@ -53,12 +54,19 @@ Trimmer::Trimmer (
_audio_start = video_frames_to_audio_frames (_video_start, audio_sample_rate, frames_per_second);
_audio_end = video_frames_to_audio_frames (_video_end, audio_sample_rate, frames_per_second);
}
+
+ /* XXX: this is a hack; this flag means that no trim is happening at the end of the film, and I'm
+ using that to prevent audio trim being rounded to video trim, which breaks the current set
+ of regression tests. This could be removed if a) the regression tests are regenerated and b)
+ I can work out what DCP length should be.
+ */
+ _no_trim = (_video_start == 0) && (_video_end == (video_length - video_trim_end));
}
void
-Trimmer::process_video (shared_ptr<Image> image, bool same, shared_ptr<Subtitle> sub)
+Trimmer::process_video (shared_ptr<const Image> image, bool same, shared_ptr<Subtitle> sub)
{
- if (_video_in >= _video_start && _video_in <= _video_end) {
+ if (_no_trim || (_video_in >= _video_start && _video_in <= _video_end)) {
Video (image, same, sub);
}
@@ -66,8 +74,13 @@ Trimmer::process_video (shared_ptr<Image> image, bool same, shared_ptr<Subtitle>
}
void
-Trimmer::process_audio (shared_ptr<AudioBuffers> audio)
+Trimmer::process_audio (shared_ptr<const AudioBuffers> audio)
{
+ if (_no_trim) {
+ Audio (audio);
+ return;
+ }
+
int64_t offset = _audio_start - _audio_in;
if (offset > audio->frames()) {
_audio_in += audio->frames ();
@@ -91,8 +104,10 @@ Trimmer::process_audio (shared_ptr<AudioBuffers> audio)
_audio_in += audio->frames ();
if (offset != 0 || length != audio->frames ()) {
- audio->move (offset, 0, length);
- audio->set_frames (length);
+ shared_ptr<AudioBuffers> copy (new AudioBuffers (audio));
+ copy->move (offset, 0, length);
+ copy->set_frames (length);
+ audio = copy;
}
Audio (audio);