Hopefully fix problems with end-trim not working.
authorCarl Hetherington <cth@carlh.net>
Wed, 26 Jun 2013 23:24:56 +0000 (00:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 26 Jun 2013 23:24:56 +0000 (00:24 +0100)
ChangeLog
src/lib/trimmer.cc
src/lib/trimmer.h
wscript

index e0a8f4bbebbcef4395f16fe61b5decec61fde906..238ad8604f38ada725ecd75e077f94217e2b0d58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-27  Carl Hetherington  <cth@carlh.net>
+
+       * Hopefully fix problems with end-trim not working.
+
 2013-06-24  Carl Hetherington  <cth@carlh.net>
 
        * Version 0.103 released.
index b7afc9299452708e6a3f4d96e44a6dc070199225..1ec9e2a5b70c6571b9646859cf5c937ff390a085 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <boost/shared_ptr.hpp>
+#include <stdint.h>
 #include "trimmer.h"
 
 using std::cout;
@@ -55,18 +56,22 @@ Trimmer::Trimmer (
                _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.
+       /* XXX: this is a hack; if there is no trim at the end, set
+          the audio end point to infinity so that
+          shorter-video-than-audio does not trim audio (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));
+       if (video_trim_end == 0) {
+               _audio_end = INT64_MAX;
+       }
 }
 
 void
 Trimmer::process_video (shared_ptr<const Image> image, bool same, shared_ptr<Subtitle> sub)
 {
-       if (_no_trim || (_video_in >= _video_start && _video_in <= _video_end)) {
+       if (_video_in >= _video_start && _video_in < _video_end) {
                Video (image, same, sub);
        }
        
@@ -76,13 +81,9 @@ Trimmer::process_video (shared_ptr<const Image> image, bool same, shared_ptr<Sub
 void
 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()) {
+               /* we haven't reached the start of the untrimmed section yet */
                _audio_in += audio->frames ();
                return;
        }
index 98a118fb27abe784366efecb64bf59b4204dda23..45b3f149a3ed770840043e422c08179c1bc97db9 100644 (file)
@@ -36,5 +36,4 @@ private:
        int64_t _audio_start;
        int64_t _audio_end;
        int64_t _audio_in;
-       bool _no_trim;
 };
diff --git a/wscript b/wscript
index e04cea069c07ec57cb90deb0bbd9c2a59a2b7070..a4d08d416f17092209df5768ca4364a2a2b220ac 100644 (file)
--- a/wscript
+++ b/wscript
@@ -28,7 +28,7 @@ def configure(conf):
     conf.env.TARGET_OSX = sys.platform == 'darwin'
     conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
 
-    conf.env.append_value('CXXFLAGS', ['-D__STDC_CONSTANT_MACROS', '-msse', '-mfpmath=sse', '-ffast-math', '-fno-strict-aliasing',
+    conf.env.append_value('CXXFLAGS', ['-D__STDC_CONSTANT_MACROS', '-D__STDC_LIMIT_MACROS', '-msse', '-mfpmath=sse', '-ffast-math', '-fno-strict-aliasing',
                                        '-Wall', '-Wno-attributes', '-Wextra'])
 
     if conf.env.TARGET_WINDOWS: