Various work on range setting.
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Nov 2012 15:58:22 +0000 (15:58 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Nov 2012 15:58:22 +0000 (15:58 +0000)
24 files changed:
src/lib/ab_transcoder.cc
src/lib/ab_transcoder.h
src/lib/check_hashes_job.cc
src/lib/dcp_video_frame.cc
src/lib/dcp_video_frame.h
src/lib/decoder.cc
src/lib/decoder.h
src/lib/encoder.cc
src/lib/encoder.h
src/lib/examine_content_job.cc
src/lib/film.cc
src/lib/film.h
src/lib/imagemagick_encoder.cc
src/lib/imagemagick_encoder.h
src/lib/j2k_still_encoder.cc
src/lib/j2k_still_encoder.h
src/lib/j2k_wav_encoder.cc
src/lib/j2k_wav_encoder.h
src/lib/make_dcp_job.cc
src/lib/options.h
src/lib/transcode_job.cc
src/lib/util.h
src/wx/dcp_range_dialog.cc
test/test.cc

index beedd478ffac18235d9d21e2e662dbad8133e799..0579aa4ff228fe7422f0401cd9eafb4179d817dc 100644 (file)
@@ -66,7 +66,7 @@ ABTranscoder::~ABTranscoder ()
 }
 
 void
-ABTranscoder::process_video (shared_ptr<Image> yuv, int frame, shared_ptr<Subtitle> sub, int index)
+ABTranscoder::process_video (shared_ptr<Image> yuv, SourceFrame frame, shared_ptr<Subtitle> sub, int index)
 {
        if (index == 0) {
                /* Keep this image around until we get the other half */
index 7bf5dd4a1fe412e3eafc9f460014de043a8a393f..a136fd27091462a7a4d2735d45f4b898b4b7514f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <boost/shared_ptr.hpp>
 #include <stdint.h>
+#include "util.h"
 
 class Job;
 class Encoder;
@@ -54,7 +55,7 @@ public:
        void go ();
 
 private:
-       void process_video (boost::shared_ptr<Image>, int, boost::shared_ptr<Subtitle>, int);
+       void process_video (boost::shared_ptr<Image>, SourceFrame, boost::shared_ptr<Subtitle>, int);
        
        boost::shared_ptr<Film> _film_a;
        boost::shared_ptr<Film> _film_b;
@@ -63,6 +64,6 @@ private:
        boost::shared_ptr<Encoder> _encoder;
        boost::shared_ptr<Decoder> _da;
        boost::shared_ptr<Decoder> _db;
-       int _last_frame;
+       SourceFrame _last_frame;
        boost::shared_ptr<Image> _image;
 };
index d1483933d3e0172707cf20772f3defe9781855dc..3967d0d704e4c46b8e43db6f6fbd3022a98f5db8 100644 (file)
@@ -57,10 +57,10 @@ CheckHashesJob::run ()
                throw EncodeError ("cannot check hashes of a DCP with unknown length");
        }
        
-       int const N = _film->dcp_length().get();
+       SourceFrame const N = _film->dcp_trim_start() + _film->dcp_length().get();
        DCPFrameRate const dfr = dcp_frame_rate (_film->frames_per_second ());
        
-       for (int i = 0; i < N; i += dfr.skip) {
+       for (SourceFrame i = _film->dcp_trim_start(); i < N; i += dfr.skip) {
                string const j2k_file = _opt->frame_out_path (i, false);
                string const hash_file = j2k_file + ".md5";
 
index 1dcc81f0de980a6954c7add6394e0f4f001be6d2..c185de0f4d74ffeef5b6df6cdec2299874db6c3f 100644 (file)
@@ -76,7 +76,7 @@ using boost::shared_ptr;
 DCPVideoFrame::DCPVideoFrame (
        shared_ptr<const Image> yuv, shared_ptr<Subtitle> sub,
        Size out, int p, int subtitle_offset, float subtitle_scale,
-       Scaler const * s, int f, float fps, string pp, int clut, int bw, Log* l
+       Scaler const * s, SourceFrame f, float fps, string pp, int clut, int bw, Log* l
        )
        : _input (yuv)
        , _subtitle (sub)
@@ -376,7 +376,7 @@ DCPVideoFrame::encode_remotely (ServerDescription const * serv)
  *  @param frame Frame index.
  */
 void
-EncodedData::write (shared_ptr<const Options> opt, int frame)
+EncodedData::write (shared_ptr<const Options> opt, SourceFrame frame)
 {
        string const tmp_j2k = opt->frame_out_path (frame, true);
 
index 0ff29f7bfd1d803e885fb7f28daa5b6e470f813d..5ae53f1e8743b3ce711521502c192ef0ba67e9ca 100644 (file)
@@ -50,7 +50,7 @@ public:
        virtual ~EncodedData () {}
 
        void send (boost::shared_ptr<Socket> socket);
-       void write (boost::shared_ptr<const Options>, int);
+       void write (boost::shared_ptr<const Options>, SourceFrame);
 
        /** @return data */
        uint8_t* data () const {
@@ -106,13 +106,17 @@ public:
 class DCPVideoFrame
 {
 public:
-       DCPVideoFrame (boost::shared_ptr<const Image>, boost::shared_ptr<Subtitle>, Size, int, int, float, Scaler const *, int, float, std::string, int, int, Log *);
+       DCPVideoFrame (
+               boost::shared_ptr<const Image>, boost::shared_ptr<Subtitle>, Size,
+               int, int, float, Scaler const *, SourceFrame, float, std::string, int, int, Log *
+               );
+       
        virtual ~DCPVideoFrame ();
 
        boost::shared_ptr<EncodedData> encode_locally ();
        boost::shared_ptr<EncodedData> encode_remotely (ServerDescription const *);
 
-       int frame () const {
+       SourceFrame frame () const {
                return _frame;
        }
        
@@ -127,7 +131,7 @@ private:
        int _subtitle_offset;
        float _subtitle_scale;
        Scaler const * _scaler;          ///< scaler to use
-       int _frame;                      ///< frame index within the Film
+       SourceFrame _frame;              ///< frame index within the Film's source
        int _frames_per_second;          ///< Frames per second that we will use for the DCP (rounded)
        std::string _post_process;       ///< FFmpeg post-processing string to use
        int _colour_lut_index;           ///< Colour look-up table to use (see Config::colour_lut_index ())
index a8da1ae67be6b9b5758703e30aafa403451bdd74..3e210c9ccb63feb9ab417aebafcadbd87277d1d6 100644 (file)
@@ -140,7 +140,8 @@ Decoder::go ()
 
        while (pass () == false) {
                if (_job && _film->dcp_length()) {
-                       _job->set_progress (float ((_video_frame_index - _film->dcp_trim_start())) / _film->dcp_length().get());
+                       SourceFrame const p = _video_frame_index - _film->dcp_trim_start();
+                       _job->set_progress (float (p) / _film->dcp_length().get());
                }
        }
 
index e8e73cc9f851688b720a7539ff577db5d2d29a94..0741c4f54e4578d6f6069ef6e1de7b7c9be044c9 100644 (file)
@@ -81,7 +81,7 @@ public:
        void go ();
 
        /** @return the index of the last video frame to be processed */
-       int video_frame_index () const {
+       SourceFrame video_frame_index () const {
                return _video_frame_index;
        }
 
@@ -94,11 +94,11 @@ public:
        }
 
        /** Emitted when a video frame is ready.
-        *  First parameter is the frame.
+        *  First parameter is the frame within the source.
         *  Second parameter is its index within the content.
         *  Third parameter is either 0 or a subtitle that should be on this frame.
         */
-       boost::signals2::signal<void (boost::shared_ptr<Image>, int, boost::shared_ptr<Subtitle>)> Video;
+       boost::signals2::signal<void (boost::shared_ptr<Image>, SourceFrame, boost::shared_ptr<Subtitle>)> Video;
 
        /** Emitted when some audio data is ready */
        boost::signals2::signal<void (boost::shared_ptr<AudioBuffers>)> Audio;
@@ -133,7 +133,7 @@ private:
        void emit_audio (uint8_t* data, int size);
        
        /** last video frame to be processed */
-       int _video_frame_index;
+       SourceFrame _video_frame_index;
 
        std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
 
index 7352dcfb126c60f654af4a62f8217c253b1aae4e..bb23c9e5922b34a6d82a96d4b449b280a1112a81 100644 (file)
@@ -67,7 +67,7 @@ Encoder::skipping () const
 }
 
 /** @return Index of last frame to be successfully encoded */
-int
+SourceFrame
 Encoder::last_frame () const
 {
        boost::mutex::scoped_lock (_history_mutex);
@@ -75,10 +75,10 @@ Encoder::last_frame () const
 }
 
 /** Should be called when a frame has been encoded successfully.
- *  @param n Frame index.
+ *  @param n Source frame index.
  */
 void
-Encoder::frame_done (int n)
+Encoder::frame_done (SourceFrame n)
 {
        boost::mutex::scoped_lock lock (_history_mutex);
        _just_skipped = false;
index 590b8aaa9a25e8189102d5105fbefc6a599507bc..704b55e46f5777798d12eeeea16121872eaa13ad 100644 (file)
@@ -31,6 +31,7 @@
 extern "C" {
 #include <libavutil/samplefmt.h>
 }
+#include "util.h"
 
 class Options;
 class Image;
@@ -58,10 +59,10 @@ public:
 
        /** Called with a frame of video.
         *  @param i Video frame image.
-        *  @param f Frame number within the film.
+        *  @param f Frame number within the film's source.
         *  @param s A subtitle that should be on this frame, or 0.
         */
-       virtual void process_video (boost::shared_ptr<const Image> i, int f, boost::shared_ptr<Subtitle> s) = 0;
+       virtual void process_video (boost::shared_ptr<const Image> i, SourceFrame f, boost::shared_ptr<Subtitle> s) = 0;
 
        /** Called with some audio data.
         *  @param d Array of pointers to floating point sample data for each channel.
@@ -74,10 +75,10 @@ public:
 
        float current_frames_per_second () const;
        bool skipping () const;
-       int last_frame () const;
+       SourceFrame last_frame () const;
 
 protected:
-       void frame_done (int n);
+       void frame_done (SourceFrame n);
        void frame_skipped ();
        
        /** Film that we are encoding */
@@ -95,8 +96,8 @@ protected:
        static int const _history_size;
        /** true if the last frame we processed was skipped (because it was already done) */
        bool _just_skipped;
-       /** Index of the last frame to be processed */
-       int _last_frame;
+       /** Source index of the last frame to be processed */
+       SourceFrame _last_frame;
 };
 
 #endif
index 6d1233a8cdd70133e2856d1de0d22326d0bec843..58b9282b85e5cb97cba26702cf6fdf2562d7d296 100644 (file)
@@ -105,7 +105,7 @@ ExamineContentJob::run ()
        }
 
        string const tdir = _film->dir ("thumbs");
-       vector<int> thumbs;
+       vector<SourceFrame> thumbs;
 
        for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (tdir); i != boost::filesystem::directory_iterator(); ++i) {
 
index da664a5a59e6a21a78cdabadce40f0fe4ac4a314..cacd307643363657b180ef348c0b37bc9a7b0682 100644 (file)
@@ -282,7 +282,7 @@ Film::examine_content ()
                return;
        }
 
-       set_thumbs (vector<int> ());
+       set_thumbs (vector<SourceFrame> ());
        boost::filesystem::remove_all (dir ("thumbs"));
 
        /* This call will recreate the directory */
@@ -428,7 +428,7 @@ Film::write_metadata () const
        /* Cached stuff; this is information about our content; we could
           look it up each time, but that's slow.
        */
-       for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
+       for (vector<SourceFrame>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
                f << "thumb " << *i << "\n";
        }
        f << "width " << _size.width << "\n";
@@ -567,17 +567,19 @@ Film::thumb_file (int n) const
        return thumb_file_for_frame (thumb_frame (n));
 }
 
-/** @param n A frame index within the Film.
+/** @param n A frame index within the Film's source.
  *  @return The path to the thumb's image file for this frame;
  *  we assume that it exists.
  */
 string
-Film::thumb_file_for_frame (int n) const
+Film::thumb_file_for_frame (SourceFrame n) const
 {
        return thumb_base_for_frame(n) + ".png";
 }
 
-/** Must not be called with the _state_mutex locked */
+/** @param n Thumb index.
+ *  Must not be called with the _state_mutex locked.
+ */
 string
 Film::thumb_base (int n) const
 {
@@ -585,7 +587,7 @@ Film::thumb_base (int n) const
 }
 
 string
-Film::thumb_base_for_frame (int n) const
+Film::thumb_base_for_frame (SourceFrame n) const
 {
        stringstream s;
        s.width (8);
@@ -599,11 +601,11 @@ Film::thumb_base_for_frame (int n) const
 }
 
 /** @param n A thumb index.
- *  @return The frame within the Film that it is for.
+ *  @return The frame within the Film's source that it is for.
  *
  *  Must not be called with the _state_mutex locked.
  */
-int
+SourceFrame
 Film::thumb_frame (int n) const
 {
        boost::mutex::scoped_lock lm (_state_mutex);
@@ -698,11 +700,11 @@ Film::target_audio_sample_rate () const
        return rint (t);
 }
 
-boost::optional<int>
+boost::optional<SourceFrame>
 Film::dcp_length () const
 {
        if (!length()) {
-               return boost::optional<int> ();
+               return boost::optional<SourceFrame> ();
        }
 
        return length().get() - dcp_trim_start() - dcp_trim_end();
@@ -1194,7 +1196,7 @@ Film::set_package_type (string p)
 }
 
 void
-Film::set_thumbs (vector<int> t)
+Film::set_thumbs (vector<SourceFrame> t)
 {
        {
                boost::mutex::scoped_lock lm (_state_mutex);
@@ -1214,7 +1216,7 @@ Film::set_size (Size s)
 }
 
 void
-Film::set_length (int l)
+Film::set_length (SourceFrame l)
 {
        {
                boost::mutex::scoped_lock lm (_state_mutex);
index eeaae2acdaba9b3dab123a22381f723349826559..06ebba3ce7545a6cac8939e8b547dd0c2b9bd69c 100644 (file)
@@ -87,7 +87,7 @@ public:
 
        std::string thumb_file (int) const;
        std::string thumb_base (int) const;
-       int thumb_frame (int) const;
+       SourceFrame thumb_frame (int) const;
 
        int target_audio_sample_rate () const;
        
@@ -95,7 +95,7 @@ public:
        void read_metadata ();
 
        Size cropped_size (Size) const;
-       boost::optional<int> dcp_length () const;
+       boost::optional<SourceFrame> dcp_length () const;
        std::string dci_name () const;
        std::string dcp_name () const;
 
@@ -187,12 +187,12 @@ public:
                return _scaler;
        }
 
-       int dcp_trim_start () const {
+       SourceFrame dcp_trim_start () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _dcp_trim_start;
        }
 
-       int dcp_trim_end () const {
+       SourceFrame dcp_trim_end () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _dcp_trim_end;
        }
@@ -289,7 +289,7 @@ public:
                return _package_type;
        }
 
-       std::vector<int> thumbs () const {
+       std::vector<SourceFrame> thumbs () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _thumbs;
        }
@@ -299,7 +299,7 @@ public:
                return _size;
        }
 
-       boost::optional<int> length () const {
+       boost::optional<SourceFrame> length () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _length;
        }
@@ -368,9 +368,9 @@ public:
        void set_studio (std::string);
        void set_facility (std::string);
        void set_package_type (std::string);
-       void set_thumbs (std::vector<int>);
+       void set_thumbs (std::vector<SourceFrame>);
        void set_size (Size);
-       void set_length (int);
+       void set_length (SourceFrame);
        void unset_length ();
        void set_audio_sample_rate (int);
        void set_content_digest (std::string);
@@ -392,8 +392,8 @@ private:
 
        boost::gregorian::date _dci_date;
 
-       std::string thumb_file_for_frame (int) const;
-       std::string thumb_base_for_frame (int) const;
+       std::string thumb_file_for_frame (SourceFrame) const;
+       std::string thumb_base_for_frame (SourceFrame) const;
        void signal_changed (Property);
        void examine_content_finished ();
        
@@ -422,8 +422,8 @@ private:
        std::vector<Filter const *> _filters;
        /** Scaler algorithm to use */
        Scaler const * _scaler;
-       int _dcp_trim_start;
-       int _dcp_trim_end;
+       SourceFrame _dcp_trim_start;
+       SourceFrame _dcp_trim_end;
        /** true to create an A/B comparison DCP, where the left half of the image
            is the video without any filters or post-processing, and the right half
            has the specified filters and post-processing.
@@ -460,11 +460,11 @@ private:
        /* Data which are cached to speed things up */
 
        /** Vector of frame indices for each of our `thumbnails' */
-       std::vector<int> _thumbs;
+       std::vector<SourceFrame> _thumbs;
        /** Size, in pixels, of the source (ignoring cropping) */
        Size _size;
        /** Actual length of the source (in video frames) from examining it */
-       boost::optional<int> _length;
+       boost::optional<SourceFrame> _length;
        /** Sample rate of the source audio, in Hz */
        int _audio_sample_rate;
        /** MD5 digest of our content file */
index e8b060997fb3dd71ee5ab84419be186b70185d9b..e0e2d1cdcdbce1f4d8e86b1bc84a8ac61f7a6858 100644 (file)
@@ -50,7 +50,7 @@ ImageMagickEncoder::ImageMagickEncoder (shared_ptr<const Film> f, shared_ptr<con
 }
 
 void
-ImageMagickEncoder::process_video (shared_ptr<const Image> image, int frame, shared_ptr<Subtitle> sub)
+ImageMagickEncoder::process_video (shared_ptr<const Image> image, SourceFrame frame, shared_ptr<Subtitle> sub)
 {
        shared_ptr<Image> scaled = image->scale_and_convert_to_rgb (_opt->out_size, _opt->padding, _film->scaler());
        shared_ptr<Image> compact (new CompactImage (scaled));
index c112300e3e5488d73ca2f5e901451ad818fd3e4f..3d8edd25ed82c80ec60720438a0df7cc815bec08 100644 (file)
@@ -37,7 +37,7 @@ public:
        ImageMagickEncoder (boost::shared_ptr<const Film> f, boost::shared_ptr<const Options> o);
 
        void process_begin (int64_t audio_channel_layout) {}
-       void process_video (boost::shared_ptr<const Image>, int, boost::shared_ptr<Subtitle>);
+       void process_video (boost::shared_ptr<const Image>, SourceFrame, boost::shared_ptr<Subtitle>);
        void process_audio (boost::shared_ptr<const AudioBuffers>) {}
        void process_end () {}
 };
index edcf0de898e0765c8683ab85594ea80999bfb799..aab686417ba6de0fb14920afa8e43a1deea51d92 100644 (file)
@@ -49,7 +49,7 @@ J2KStillEncoder::J2KStillEncoder (shared_ptr<const Film> f, shared_ptr<const Opt
 }
 
 void
-J2KStillEncoder::process_video (shared_ptr<const Image> yuv, int frame, shared_ptr<Subtitle> sub)
+J2KStillEncoder::process_video (shared_ptr<const Image> yuv, SourceFrame frame, shared_ptr<Subtitle> sub)
 {
        pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
        DCPVideoFrame* f = new DCPVideoFrame (
index 86bebc0d27a2f0b18e5eb1a7795bc6aebf6af2b6..89222ce18f1f696d2032dcfc3227136e828e26cc 100644 (file)
@@ -37,7 +37,7 @@ public:
        J2KStillEncoder (boost::shared_ptr<const Film>, boost::shared_ptr<const Options>);
 
        void process_begin (int64_t audio_channel_layout) {}
-       void process_video (boost::shared_ptr<const Image>, int, boost::shared_ptr<Subtitle>);
+       void process_video (boost::shared_ptr<const Image>, SourceFrame, boost::shared_ptr<Subtitle>);
        void process_audio (boost::shared_ptr<const AudioBuffers>) {}
        void process_end () {}
 };
index bac7d5f35c63e17d2f66d285c3453bde8e56c652..f93fd9460352fe37f5e0983adae7faf10b4521b4 100644 (file)
@@ -106,7 +106,7 @@ J2KWAVEncoder::close_sound_files ()
 }      
 
 void
-J2KWAVEncoder::process_video (shared_ptr<const Image> yuv, int frame, shared_ptr<Subtitle> sub)
+J2KWAVEncoder::process_video (shared_ptr<const Image> yuv, SourceFrame frame, shared_ptr<Subtitle> sub)
 {
        boost::mutex::scoped_lock lock (_worker_mutex);
 
index 99924829d2c8207f4454728e8dc4fe2158f85f8a..2272d7f4967d94337951475e3904495ede58a123 100644 (file)
@@ -51,7 +51,7 @@ public:
        ~J2KWAVEncoder ();
 
        void process_begin (int64_t audio_channel_layout);
-       void process_video (boost::shared_ptr<const Image>, int, boost::shared_ptr<Subtitle>);
+       void process_video (boost::shared_ptr<const Image>, SourceFrame, boost::shared_ptr<Subtitle>);
        void process_audio (boost::shared_ptr<const AudioBuffers>);
        void process_end ();
 
index 4102f838401d9f5f35fc8aa977ab9355694dfeba..a1ffd967236b45f736691995ed24e211362dc76f 100644 (file)
@@ -55,10 +55,12 @@ MakeDCPJob::name () const
        return String::compose ("Make DCP for %1", _film->name());
 }
 
+/** @param f DCP frame index */
 string
 MakeDCPJob::j2c_path (int f) const
 {
-       return _opt->frame_out_path (f * dcp_frame_rate(_film->frames_per_second()).skip, false);
+       SourceFrame const s = (f * dcp_frame_rate(_film->frames_per_second()).skip) + _film->dcp_trim_start();
+       return _opt->frame_out_path (s, false);
 }
 
 string
@@ -84,6 +86,7 @@ MakeDCPJob::run ()
        int frames = 0;
        switch (_film->content_type ()) {
        case VIDEO:
+               /* Source frames -> DCP frames */
                frames = _film->dcp_length().get() / dfr.skip;
                break;
        case STILL:
index aef9ca112a5c9bc175f679d9567beb89930bad53..043e3692f476ee1e23d711a91be753cf29e51798 100644 (file)
@@ -52,11 +52,11 @@ public:
                return _frame_out_path;
        }
 
-       /** @param f Frame index.
+       /** @param f Source frame index.
         *  @param t true to return a temporary file path, otherwise a permanent one.
         *  @return The path to write this video frame to.
         */
-       std::string frame_out_path (int f, bool t, std::string e = "") const {
+       std::string frame_out_path (SourceFrame f, bool t, std::string e = "") const {
                if (e.empty ()) {
                        e = _frame_out_extension;
                }
@@ -96,8 +96,10 @@ public:
        float ratio;                ///< ratio of the wanted output image (not considering padding)
        int padding;                ///< number of pixels of padding (in terms of the output size) each side of the image
        bool apply_crop;            ///< true to apply cropping
-       int decode_video_skip;      ///< skip frames such that we don't decode any frame where (index % decode_video_skip) != 0; e.g.
-                                   ///< 1 for every frame, 2 for every other frame, etc.
+       /** Skip frames such that we don't decode any frame where (index % decode_video_skip) != 0; e.g.
+        *  1 for every frame, 2 for every other frame, etc.
+        */
+       SourceFrame decode_video_skip; 
        bool decode_audio;          ///< true to decode audio, otherwise false
        bool decode_subtitles;
 
index 877214316eb75dcd1e2c352d61bc71019927b852..31808c10317b12c986e048ad6f28a15a906dc316 100644 (file)
@@ -110,5 +110,6 @@ TranscodeJob::remaining_time () const
        }
 
        /* We assume that dcp_length() is valid */
-       return ((_film->dcp_length().get() - _encoder->last_frame()) / fps);
+       SourceFrame const left = _film->dcp_length().get() - _encoder->last_frame() - _film->dcp_trim_start();
+       return left / fps;
 }
index 26c6ed9faba6d940e32b279474435d4cd69d0aa3..f87328dba5b382ac5953fa0e25399b1e91755396 100644 (file)
@@ -54,6 +54,8 @@ extern std::string md5_digest (std::string);
 extern std::string md5_digest (void const *, int);
 extern void ensure_ui_thread ();
 
+typedef int SourceFrame;
+
 struct DCPFrameRate
 {
        int frames_per_second;
index e249f6fc6f88346e95093965433ea0e022d99ea2..9eced92d67cf60ebf76af0acf3387118f0982ec9 100644 (file)
@@ -39,6 +39,11 @@ DCPRangeDialog::DCPRangeDialog (wxWindow* p, shared_ptr<Film> f)
        table->Add (_trim_end, 1);
        add_label_to_sizer (table, this, "frames");
 
+       if (_film->length()) {
+               _trim_start->SetRange (0, _film->length().get());
+               _trim_end->SetRange (0, _film->length().get());
+       }
+
        _trim_start->SetValue (_film->dcp_trim_start());
        _trim_end->SetValue (_film->dcp_trim_end());
 
index 742a522fbf58287270794c717ba7a86fd9e8b06c..a1a8c9cf3a8aafe866c14bea80484b607392363d 100644 (file)
@@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE (paths_test)
 {
        shared_ptr<Film> f = new_test_film ("paths_test");
        f->set_directory ("build/test/a/b/c/d/e");
-       vector<int> thumbs;
+       vector<SourceFrame> thumbs;
        thumbs.push_back (42);
        f->set_thumbs (thumbs);
        BOOST_CHECK_EQUAL (f->thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.png");