Content can be added and previewed.
authorCarl Hetherington <cth@carlh.net>
Sun, 31 Mar 2013 15:04:10 +0000 (16:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 31 Mar 2013 15:04:10 +0000 (16:04 +0100)
35 files changed:
src/lib/ab_transcode_job.cc
src/lib/ab_transcode_job.h
src/lib/ab_transcoder.cc
src/lib/ab_transcoder.h
src/lib/analyse_audio_job.cc
src/lib/audio_decoder.cc
src/lib/audio_decoder.h
src/lib/dcp_video_frame.cc
src/lib/decoder.cc
src/lib/decoder.h
src/lib/decoder_factory.cc
src/lib/decoder_factory.h
src/lib/encoder.cc
src/lib/examine_content_job.cc
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_decoder.h
src/lib/film.cc
src/lib/imagemagick_decoder.cc
src/lib/imagemagick_decoder.h
src/lib/options.h [deleted file]
src/lib/playlist.cc
src/lib/playlist.h
src/lib/sndfile_decoder.cc
src/lib/sndfile_decoder.h
src/lib/transcode_job.cc
src/lib/transcode_job.h
src/lib/transcoder.cc
src/lib/transcoder.h
src/lib/video_decoder.cc
src/lib/video_decoder.h
src/tools/servomatictest.cc
src/wx/film_editor.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h

index f17d439164be63e37f54a89951acffd273865304..2bdff47de684827ab0e0ec15664737cb624609ed 100644 (file)
@@ -32,11 +32,9 @@ using std::string;
 using boost::shared_ptr;
 
 /** @param f Film to compare.
- *  @param o Decode options.
  */
-ABTranscodeJob::ABTranscodeJob (shared_ptr<Film> f, DecodeOptions o)
+ABTranscodeJob::ABTranscodeJob (shared_ptr<Film> f)
        : Job (f)
-       , _decode_opt (o)
 {
        _film_b.reset (new Film (*_film));
        _film_b->set_scaler (Config::instance()->reference_scaler ());
@@ -54,7 +52,7 @@ ABTranscodeJob::run ()
 {
        try {
                /* _film_b is the one with reference filters */
-               ABTranscoder w (_film_b, _film, _decode_opt, shared_from_this ());
+               ABTranscoder w (_film_b, _film, shared_from_this ());
                w.go ();
                set_progress (1);
                set_state (FINISHED_OK);
index 5d029a18bd1fb8887a31332a3739acda54fffb7b..cd82d4247ffdf7dfc49095993466792b618c1f0f 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <boost/shared_ptr.hpp>
 #include "job.h"
-#include "options.h"
 
 class Film;
 
@@ -38,8 +37,7 @@ class ABTranscodeJob : public Job
 {
 public:
        ABTranscodeJob (
-               boost::shared_ptr<Film> f,
-               DecodeOptions o
+               boost::shared_ptr<Film> f
                );
 
        std::string name () const;
@@ -48,5 +46,4 @@ public:
 private:
        /** Copy of our Film using the reference filters and scaler */
        boost::shared_ptr<Film> _film_b;
-       DecodeOptions _decode_opt;
 };
index 0c687008d91f18546fd2871a788b7b33905f9663..6fc438ee8cc04b7d6093d7f9a80e322ce1364a1e 100644 (file)
@@ -23,7 +23,6 @@
 #include "film.h"
 #include "encoder.h"
 #include "job.h"
-#include "options.h"
 #include "image.h"
 #include "playlist.h"
 #include "matcher.h"
@@ -47,7 +46,7 @@ using boost::dynamic_pointer_cast;
  *  @param e Encoder to use.
  */
 
-ABTranscoder::ABTranscoder (shared_ptr<Film> a, shared_ptr<Film> b, DecodeOptions o, shared_ptr<Job> j)
+ABTranscoder::ABTranscoder (shared_ptr<Film> a, shared_ptr<Film> b, shared_ptr<Job> j)
        : _film_a (a)
        , _film_b (b)
        , _playlist_a (_film_a->playlist ())
index 14277c562cbae07eb3efb525fd39acf4f0083fd8..090c26fb7e6b0e7b5693ee9266a3e012feef7816 100644 (file)
@@ -48,7 +48,6 @@ public:
        ABTranscoder (
                boost::shared_ptr<Film> a,
                boost::shared_ptr<Film> b,
-               DecodeOptions o,
                boost::shared_ptr<Job> j
                );
        
index 74491943b2eb8d0d3ebbc27a49f37e36b8b45937..6e6dda88634891449b2897be29aa18633583d693 100644 (file)
@@ -21,7 +21,6 @@
 #include "analyse_audio_job.h"
 #include "compose.hpp"
 #include "film.h"
-#include "options.h"
 #include "playlist.h"
 
 #include "i18n.h"
index a72cf11bbf86514ef6e482d3d4b28c926693c53d..e2006a795d9c31e650f99c64cb3634f18047ca67 100644 (file)
@@ -22,8 +22,8 @@
 using boost::optional;
 using boost::shared_ptr;
 
-AudioDecoder::AudioDecoder (shared_ptr<const Film> f, shared_ptr<AudioContent> c, DecodeOptions o)
-       : Decoder (f, o)
+AudioDecoder::AudioDecoder (shared_ptr<const Film> f, shared_ptr<AudioContent> c)
+       : Decoder (f)
 {
 
 }
index 7d2a2bb62b3e05a2ad5377a33f1e799a982dfff5..cbb84b52d29df63198cf744f0a324767caf6044d 100644 (file)
@@ -35,7 +35,7 @@ class AudioContent;
 class AudioDecoder : public AudioSource, public virtual Decoder
 {
 public:
-       AudioDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>, DecodeOptions);
+       AudioDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>);
 };
 
 #endif
index d674393a98023e2e02459c1bc6b8ec6c966d2a42..e9499871ab240877958c8e1484269a8811f1590c 100644 (file)
@@ -47,7 +47,6 @@
 #include "dcp_video_frame.h"
 #include "lut.h"
 #include "config.h"
-#include "options.h"
 #include "exceptions.h"
 #include "server.h"
 #include "util.h"
index 2fe265c145a6a863088a39eb2ee597cef164130a..c4044691943334d2cefb575b50f5a23e6716fb5c 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <iostream>
 #include "film.h"
-#include "options.h"
 #include "exceptions.h"
 #include "util.h"
 #include "decoder.h"
@@ -36,9 +35,8 @@ using boost::shared_ptr;
 /** @param f Film.
  *  @param o Decode options.
  */
-Decoder::Decoder (shared_ptr<const Film> f, DecodeOptions o)
+Decoder::Decoder (shared_ptr<const Film> f)
        : _film (f)
-       , _opt (o)
 {
        _film_connection = f->Changed.connect (bind (&Decoder::film_changed, this, _1));
 }
index 50aa16dba3c0e1d0d419a46551d22ce1c4d12002..4ccdc046fcbb19f7da54e43ca0cba1fd4b5305cd 100644 (file)
@@ -33,7 +33,6 @@
 #include "video_source.h"
 #include "audio_source.h"
 #include "film.h"
-#include "options.h"
 
 class Image;
 class Log;
@@ -52,7 +51,7 @@ class FilterGraph;
 class Decoder
 {
 public:
-       Decoder (boost::shared_ptr<const Film>, DecodeOptions);
+       Decoder (boost::shared_ptr<const Film>);
        virtual ~Decoder () {}
 
        virtual bool pass () = 0;
@@ -63,8 +62,6 @@ public:
 
 protected:
        boost::shared_ptr<const Film> _film;
-       /** our decode options */
-       DecodeOptions _opt;
 
 private:
        virtual void film_changed (Film::Property) {}
index feaa1c7ef2f64a51667fcd69c8565b2275277fbc..7940edc2ea257466cd15285ec851d74a1368f526 100644 (file)
@@ -36,7 +36,7 @@ using boost::dynamic_pointer_cast;
 
 Decoders
 decoder_factory (
-       shared_ptr<Film> f, DecodeOptions o
+       shared_ptr<Film> f
        )
 {
        return Decoders ();
index 8076b01c7e68875434ad971d4da2b199458713a7..3fd91f8760fa6ffb205a411d0248fa96b6f5801f 100644 (file)
@@ -24,8 +24,6 @@
  *  @brief A method to create appropriate decoders for some content.
  */
 
-#include "options.h"
-
 class Film;
 class VideoDecoder;
 class AudioDecoder;
@@ -43,7 +41,7 @@ struct Decoders {
 };
 
 extern Decoders decoder_factory (
-       boost::shared_ptr<Film>, DecodeOptions
+       boost::shared_ptr<Film>
        );
 
 #endif
index 9702137930e8008bdfe0fa38cfe9ae410e2fdb66..00807f863808e3c952fc52a99ab6cc1833153058 100644 (file)
@@ -27,7 +27,6 @@
 #include <libdcp/picture_asset.h>
 #include "encoder.h"
 #include "util.h"
-#include "options.h"
 #include "film.h"
 #include "log.h"
 #include "exceptions.h"
index c600132c31369ed496b9119bd093b73b04e3149b..aad7f265e8e9f1465fd58d7ed22b35cdb4cbccdc 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <boost/filesystem.hpp>
 #include "examine_content_job.h"
-#include "options.h"
 #include "log.h"
 #include "content.h"
 
index 25efb1ebf580cf64232fdc0472766f91a50697d2..6109b72126af904a4a8909e52bb4061ac221c545 100644 (file)
@@ -1,6 +1,5 @@
 #include "ffmpeg_content.h"
 #include "ffmpeg_decoder.h"
-#include "options.h"
 #include "compose.hpp"
 #include "job.h"
 #include "util.h"
@@ -33,9 +32,7 @@ FFmpegContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
 
        job->set_progress_unknown ();
 
-       DecodeOptions o;
-       o.decode_audio = false;
-       shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), o));
+       shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), true, false, false, true));
 
        ContentVideoFrame video_length = 0;
        if (quick) {
index c8e46776f2b90db7782e56b237c357c96df5f3f6..7b56a59712641cd9de903746f1b9b1a590cf1cea 100644 (file)
@@ -41,7 +41,6 @@ extern "C" {
 #include "transcoder.h"
 #include "job.h"
 #include "filter.h"
-#include "options.h"
 #include "exceptions.h"
 #include "image.h"
 #include "util.h"
@@ -62,10 +61,10 @@ using boost::optional;
 using boost::dynamic_pointer_cast;
 using libdcp::Size;
 
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<FFmpegContent> c, DecodeOptions o)
-       : Decoder (f, o)
-       , VideoDecoder (f, c, o)
-       , AudioDecoder (f, c, o)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<FFmpegContent> c, bool video, bool audio, bool subtitles, bool video_sync)
+       : Decoder (f)
+       , VideoDecoder (f, c)
+       , AudioDecoder (f, c)
        , _ffmpeg_content (c)
        , _format_context (0)
        , _video_stream (-1)
@@ -76,13 +75,17 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<FFmpegContent
        , _audio_codec (0)
        , _subtitle_codec_context (0)
        , _subtitle_codec (0)
+       , _decode_video (video)
+       , _decode_audio (audio)
+       , _decode_subtitles (subtitles)
+       , _video_sync (video_sync)
 {
        setup_general ();
        setup_video ();
        setup_audio ();
        setup_subtitle ();
 
-       if (!o.video_sync) {
+       if (!video_sync) {
                _first_video = 0;
        }
 }
@@ -230,13 +233,13 @@ FFmpegDecoder::pass ()
 
                int frame_finished;
 
-               if (_opt.decode_video) {
+               if (_decode_video) {
                        while (avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) {
                                filter_and_emit_video (_frame);
                        }
                }
 
-               if (_ffmpeg_content->audio_stream() && _opt.decode_audio) {
+               if (_ffmpeg_content->audio_stream() && _decode_audio) {
                        decode_audio_packet ();
                }
 
@@ -245,7 +248,7 @@ FFmpegDecoder::pass ()
 
        avcodec_get_frame_defaults (_frame);
 
-       if (_packet.stream_index == _video_stream && _opt.decode_video) {
+       if (_packet.stream_index == _video_stream && _decode_video) {
 
                int frame_finished;
                int const r = avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet);
@@ -255,16 +258,16 @@ FFmpegDecoder::pass ()
                                _film->log()->log (String::compose (N_("Used only %1 bytes of %2 in packet"), r, _packet.size));
                        }
 
-                       if (_opt.video_sync) {
+                       if (_video_sync) {
                                out_with_sync ();
                        } else {
                                filter_and_emit_video (_frame);
                        }
                }
 
-       } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _opt.decode_audio) {
+       } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _decode_audio) {
                decode_audio_packet ();
-       } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _opt.decode_subtitles && _first_video) {
+       } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _decode_subtitles && _first_video) {
 
                int got_subtitle;
                AVSubtitle sub;
@@ -633,9 +636,9 @@ FFmpegDecoder::decode_audio_packet ()
                           was before this packet.  Until then audio is thrown away.
                        */
                        
-                       if ((_first_video && _first_video.get() <= source_pts_seconds) || !_opt.decode_video) {
+                       if ((_first_video && _first_video.get() <= source_pts_seconds) || !_decode_video) {
                                
-                               if (!_first_audio && _opt.decode_video) {
+                               if (!_first_audio && _decode_video) {
                                        _first_audio = source_pts_seconds;
                                        
                                        /* This is our first audio frame, and if we've arrived here we must have had our
index a0900d89f8a9a413e9cb7d3f009c439ddcfc5adc..ef66f09d9d55acfdcc1d1485bac67c5f6cd40d38 100644 (file)
@@ -57,7 +57,7 @@ class Log;
 class FFmpegDecoder : public VideoDecoder, public AudioDecoder
 {
 public:
-       FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>, DecodeOptions);
+       FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>, bool video, bool audio, bool subtitles, bool video_sync);
        ~FFmpegDecoder ();
 
        float frames_per_second () const;
@@ -129,4 +129,9 @@ private:
 
         std::vector<FFmpegSubtitleStream> _subtitle_streams;
         std::vector<FFmpegAudioStream> _audio_streams;
+
+       bool _decode_video;
+       bool _decode_audio;
+       bool _decode_subtitles;
+       bool _video_sync;
 };
index f69f63fd84169a37b5ef72d7a6479dc9ee1b4299..0e57cf8ebf40dc96e9916ad9888e809cdd2edf07 100644 (file)
@@ -40,7 +40,6 @@
 #include "transcode_job.h"
 #include "scp_dcp_job.h"
 #include "log.h"
-#include "options.h"
 #include "exceptions.h"
 #include "examine_content_job.h"
 #include "scaler.h"
@@ -296,15 +295,12 @@ Film::make_dcp ()
                throw MissingSettingError (_("name"));
        }
 
-       DecodeOptions od;
-       od.decode_subtitles = with_subtitles ();
-
        shared_ptr<Job> r;
 
        if (dcp_ab()) {
-               r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), od)));
+               r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this())));
        } else {
-               r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), od)));
+               r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this())));
        }
 }
 
index aa3c64f931f7e4e48d241cab70ef1ec01b1ec872..c3723f6106cda578ca24df7ddc75e15c9fd1bc57 100644 (file)
@@ -32,10 +32,9 @@ using std::cout;
 using boost::shared_ptr;
 using libdcp::Size;
 
-ImageMagickDecoder::ImageMagickDecoder (
-       shared_ptr<const Film> f, shared_ptr<ImageMagickContent> c, DecodeOptions o)
-       : Decoder (f, o)
-       , VideoDecoder (f, c, o)
+ImageMagickDecoder::ImageMagickDecoder (shared_ptr<const Film> f, shared_ptr<ImageMagickContent> c)
+       : Decoder (f)
+       , VideoDecoder (f, c)
        , _imagemagick_content (c)
        , _position (0)
 {
index b04bd88b10bba16d893769e0991656331b1c5da8..a26e283c09b92e453f576a282094b78c4e064b68 100644 (file)
@@ -28,7 +28,7 @@ class ImageMagickContent;
 class ImageMagickDecoder : public VideoDecoder
 {
 public:
-       ImageMagickDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<ImageMagickContent>, DecodeOptions);
+       ImageMagickDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<ImageMagickContent>);
 
        float frames_per_second () const {
                /* We don't know */
diff --git a/src/lib/options.h b/src/lib/options.h
deleted file mode 100644 (file)
index 0d2c07f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef DVDOMATIC_OPTIONS_H
-#define DVDOMATIC_OPTIONS_H
-
-/** @file src/options.h
- *  @brief Options for a decoding operation.
- */
-
-class DecodeOptions
-{
-public:
-       DecodeOptions ()
-               : decode_video (true)
-               , decode_audio (true)
-               , decode_subtitles (false)
-               , video_sync (true)
-       {}
-
-       bool decode_video;
-       bool decode_audio;
-       bool decode_subtitles;
-       bool video_sync;
-};
-
-#endif
index 17ecd2f373ddb8874b070965f7cb46beba7f355e..fc9edac48c3ec8d3bdb5ec158ca56153f6631798 100644 (file)
@@ -31,9 +31,12 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 
 Playlist::Playlist (shared_ptr<const Film> f, list<shared_ptr<Content> > c)
-       : _video_from (VIDEO_NONE)
+       : _film (f)
+       , _video_from (VIDEO_NONE)
        , _audio_from (AUDIO_NONE)
+       , _have_setup_decoders (false)
        , _ffmpeg_decoder_done (false)
+       , _video_sync (true)
 {
        for (list<shared_ptr<Content> >::const_iterator i = c.begin(); i != c.end(); ++i) {
                shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i);
@@ -60,42 +63,6 @@ Playlist::Playlist (shared_ptr<const Film> f, list<shared_ptr<Content> > c)
                        _audio_from = AUDIO_SNDFILE;
                }
        }
-
-       if (_video_from == VIDEO_FFMPEG || _audio_from == AUDIO_FFMPEG) {
-               DecodeOptions o;
-               /* XXX: decodeoptions */
-               _ffmpeg_decoder.reset (new FFmpegDecoder (f, _ffmpeg, o));
-       }
-       
-       if (_video_from == VIDEO_FFMPEG) {
-               _ffmpeg_decoder->connect_video (shared_from_this ());
-       }
-
-       if (_audio_from == AUDIO_FFMPEG) {
-               _ffmpeg_decoder->connect_audio (shared_from_this ());
-       }
-
-       if (_video_from == VIDEO_IMAGEMAGICK) {
-               for (list<shared_ptr<ImageMagickContent> >::iterator i = _imagemagick.begin(); i != _imagemagick.end(); ++i) {
-                       DecodeOptions o;
-                       /* XXX: decodeoptions */
-                       shared_ptr<ImageMagickDecoder> d (new ImageMagickDecoder (f, *i, o));
-                       _imagemagick_decoders.push_back (d);
-                       d->connect_video (shared_from_this ());
-               }
-
-               _imagemagick_decoder = _imagemagick_decoders.begin ();
-       }
-
-       if (_audio_from == AUDIO_SNDFILE) {
-               for (list<shared_ptr<SndfileContent> >::iterator i = _sndfile.begin(); i != _sndfile.end(); ++i) {
-                       DecodeOptions o;
-                       /* XXX: decodeoptions */
-                       shared_ptr<SndfileDecoder> d (new SndfileDecoder (f, *i, o));
-                       _sndfile_decoders.push_back (d);
-                       d->connect_audio (shared_from_this ());
-               }
-       }
 }
 
 ContentAudioFrame
@@ -202,6 +169,27 @@ Playlist::video_size () const
        return libdcp::Size ();
 }
 
+ContentVideoFrame
+Playlist::video_length () const
+{
+       switch (_video_from) {
+       case VIDEO_NONE:
+               return 0;
+       case VIDEO_FFMPEG:
+               return _ffmpeg->video_length ();
+       case VIDEO_IMAGEMAGICK:
+       {
+               ContentVideoFrame l = 0;
+               for (list<shared_ptr<ImageMagickContent> >::const_iterator i = _imagemagick.begin(); i != _imagemagick.end(); ++i) {
+                       l += (*i)->video_length ();
+               }
+               return l;
+       }
+       }
+
+       return 0;
+}
+
 bool
 Playlist::has_audio () const
 {
@@ -214,9 +202,26 @@ Playlist::disable_video ()
        _video_from = VIDEO_NONE;
 }
 
+void
+Playlist::disable_audio ()
+{
+       _audio_from = AUDIO_NONE;
+}
+
+void
+Playlist::disable_subtitles ()
+{
+       /* XXX */
+}
+
 bool
 Playlist::pass ()
 {
+       if (!_have_setup_decoders) {
+               setup_decoders ();
+               _have_setup_decoders = true;
+       }
+       
        bool done = true;
        
        if (_video_from == VIDEO_FFMPEG || _audio_from == AUDIO_FFMPEG) {
@@ -264,3 +269,96 @@ Playlist::process_audio (shared_ptr<AudioBuffers> b)
        Audio (b);
 }
 
+bool
+Playlist::seek (double t)
+{
+       bool r = false;
+       
+       switch (_video_from) {
+       case VIDEO_NONE:
+               break;
+       case VIDEO_FFMPEG:
+               if (_ffmpeg_decoder->seek (t)) {
+                       r = true;
+               }
+               break;
+       case VIDEO_IMAGEMAGICK:
+               if ((*_imagemagick_decoder)->seek (t)) {
+                       r = true;
+               }
+               break;
+       }
+
+       /* XXX: don't seek audio because we don't need to... */
+
+       return r;
+}
+
+bool
+Playlist::seek_to_last ()
+{
+       bool r = false;
+       
+       switch (_video_from) {
+       case VIDEO_NONE:
+               break;
+       case VIDEO_FFMPEG:
+               if (_ffmpeg_decoder->seek_to_last ()) {
+                       r = true;
+               }
+               break;
+       case VIDEO_IMAGEMAGICK:
+               if ((*_imagemagick_decoder)->seek_to_last ()) {
+                       r = true;
+               }
+               break;
+       }
+
+       /* XXX: don't seek audio because we don't need to... */
+
+       return r;
+}
+
+void
+Playlist::setup_decoders ()
+{
+       if (_video_from == VIDEO_FFMPEG || _audio_from == AUDIO_FFMPEG) {
+               _ffmpeg_decoder.reset (
+                       new FFmpegDecoder (
+                               _film, _ffmpeg, _video_from == VIDEO_FFMPEG, _audio_from == AUDIO_FFMPEG, _film->with_subtitles(), _video_sync
+                               )
+                       );
+       }
+       
+       if (_video_from == VIDEO_FFMPEG) {
+               _ffmpeg_decoder->connect_video (shared_from_this ());
+       }
+
+       if (_audio_from == AUDIO_FFMPEG) {
+               _ffmpeg_decoder->connect_audio (shared_from_this ());
+       }
+
+       if (_video_from == VIDEO_IMAGEMAGICK) {
+               for (list<shared_ptr<ImageMagickContent> >::iterator i = _imagemagick.begin(); i != _imagemagick.end(); ++i) {
+                       shared_ptr<ImageMagickDecoder> d (new ImageMagickDecoder (_film, *i));
+                       _imagemagick_decoders.push_back (d);
+                       d->connect_video (shared_from_this ());
+               }
+
+               _imagemagick_decoder = _imagemagick_decoders.begin ();
+       }
+
+       if (_audio_from == AUDIO_SNDFILE) {
+               for (list<shared_ptr<SndfileContent> >::iterator i = _sndfile.begin(); i != _sndfile.end(); ++i) {
+                       shared_ptr<SndfileDecoder> d (new SndfileDecoder (_film, *i));
+                       _sndfile_decoders.push_back (d);
+                       d->connect_audio (shared_from_this ());
+               }
+       }
+}
+
+void
+Playlist::disable_video_sync ()
+{
+       _video_sync = false;
+}
index b42d46036bb9e37b2c5679c8bd4c503549d6f9b0..d374dc98c8ec131df3aadaa68c4fe03b1f5f00b1 100644 (file)
@@ -48,16 +48,25 @@ public:
        
        float video_frame_rate () const;
        libdcp::Size video_size () const;
+       ContentVideoFrame video_length () const;
 
        void disable_video ();
+       void disable_audio ();
+       void disable_subtitles ();
+       void disable_video_sync ();
 
        bool pass ();
        void set_progress (boost::shared_ptr<Job>);
+       bool seek (double);
+       bool seek_to_last ();
 
 private:
        void process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s);
        void process_audio (boost::shared_ptr<AudioBuffers>);
+       void setup_decoders ();
        
+       boost::shared_ptr<const Film> _film;
+
        enum {
                VIDEO_NONE,
                VIDEO_FFMPEG,
@@ -74,9 +83,12 @@ private:
        std::list<boost::shared_ptr<ImageMagickContent> > _imagemagick;
        std::list<boost::shared_ptr<SndfileContent> > _sndfile;
 
+       bool _have_setup_decoders;
        boost::shared_ptr<FFmpegDecoder> _ffmpeg_decoder;
        bool _ffmpeg_decoder_done;
        std::list<boost::shared_ptr<ImageMagickDecoder> > _imagemagick_decoders;
        std::list<boost::shared_ptr<ImageMagickDecoder> >::iterator _imagemagick_decoder;
        std::list<boost::shared_ptr<SndfileDecoder> > _sndfile_decoders;
+
+       bool _video_sync;
 };
index 8848ff4f8a195fef29e3c268782e719322647387..daa363c5e8aaef9b8ecfebac5dbe1e1b0e563b53 100644 (file)
@@ -36,9 +36,9 @@ using boost::optional;
 
 /* XXX */
 
-SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<SndfileContent> c, DecodeOptions o)
-       : Decoder (f, o)
-       , AudioDecoder (f, c, o)
+SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<SndfileContent> c)
+       : Decoder (f)
+       , AudioDecoder (f, c)
 {
        sf_count_t frames;
        SNDFILE* sf = open_file (frames);
index c06b97a609aae1d73ff5ed4557d5d22104345de5..9a3ef49b017a3983f698a57c89218089d7e3bfa2 100644 (file)
@@ -26,7 +26,7 @@ class SndfileContent;
 class SndfileDecoder : public AudioDecoder
 {
 public:
-       SndfileDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<SndfileContent>, DecodeOptions);
+       SndfileDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<SndfileContent>);
 
        bool pass ();
 
index f8810975b1995712848aba6478540f3d4078e3a7..8b74f776630a2346455160b50751bb8445fea4c0 100644 (file)
@@ -39,11 +39,9 @@ using std::setprecision;
 using boost::shared_ptr;
 
 /** @param s Film to use.
- *  @param o Decode options.
  */
-TranscodeJob::TranscodeJob (shared_ptr<Film> f, DecodeOptions o)
+TranscodeJob::TranscodeJob (shared_ptr<Film> f)
        : Job (f)
-       , _decode_opt (o)
 {
        
 }
@@ -62,7 +60,7 @@ TranscodeJob::run ()
                _film->log()->log (N_("Transcode job starting"));
                _film->log()->log (String::compose (N_("Audio delay is %1ms"), _film->audio_delay()));
 
-               Transcoder w (_film, _decode_opt, shared_from_this ());
+               Transcoder w (_film, shared_from_this ());
                w.go ();
                set_progress (1);
                set_state (FINISHED_OK);
index a409ec97e4050d1cdaeffb23dcab22399e8680af..def545958f4ff0c52a0626e2ae5b1a2106ccdf6f 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <boost/shared_ptr.hpp>
 #include "job.h"
-#include "options.h"
 
 class Encoder;
 
@@ -33,7 +32,7 @@ class Encoder;
 class TranscodeJob : public Job
 {
 public:
-       TranscodeJob (boost::shared_ptr<Film> f, DecodeOptions od);
+       TranscodeJob (boost::shared_ptr<Film> f);
        
        std::string name () const;
        void run ();
@@ -41,7 +40,4 @@ public:
 
 protected:
        int remaining_time () const;
-
-private:
-       DecodeOptions _decode_opt;
 };
index 19d06714996d442d18f2fd5b30da0475bf134d3b..07025800822cd6f5860cfc6e097de9abcce60434 100644 (file)
@@ -32,7 +32,6 @@
 #include "film.h"
 #include "matcher.h"
 #include "delay_line.h"
-#include "options.h"
 #include "gain.h"
 #include "video_decoder.h"
 #include "audio_decoder.h"
@@ -44,11 +43,10 @@ using boost::dynamic_pointer_cast;
 
 /** Construct a transcoder using a Decoder that we create and a supplied Encoder.
  *  @param f Film that we are transcoding.
- *  @param o Decode options.
  *  @param j Job that we are running under, or 0.
  *  @param e Encoder to use.
  */
-Transcoder::Transcoder (shared_ptr<Film> f, DecodeOptions o, shared_ptr<Job> j)
+Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<Job> j)
        : _job (j)
        , _playlist (f->playlist ())
        , _encoder (new Encoder (f, _playlist))
index 8d34af9481ebc8fc34b72c71000026dcbe5abf59..3c47b0c7ea421f61067d5e06b3a8af4b5fb0534b 100644 (file)
@@ -18,7 +18,6 @@
 */
 
 /** @file  src/transcoder.h
- *  @brief A class which takes a Film and some Options, then uses those to transcode the film.
  *
  *  A decoder is selected according to the content type, and the encoder can be specified
  *  as a parameter to the constructor.
@@ -36,7 +35,6 @@ class DelayLine;
 class Playlist;
 
 /** @class Transcoder
- *  @brief A class which takes a Film and some Options, then uses those to transcode the film.
  *
  *  A decoder is selected according to the content type, and the encoder can be specified
  *  as a parameter to the constructor.
@@ -46,7 +44,6 @@ class Transcoder
 public:
        Transcoder (
                boost::shared_ptr<Film> f,
-               DecodeOptions o,
                boost::shared_ptr<Job> j
                );
 
index ca1e7ab568df884e6708a7da77d3dabcf9022211..33dd433eac8e1a6d3484a6ca6be954924727850b 100644 (file)
@@ -22,7 +22,6 @@
 #include "film.h"
 #include "image.h"
 #include "log.h"
-#include "options.h"
 #include "job.h"
 
 #include "i18n.h"
@@ -30,8 +29,8 @@
 using boost::shared_ptr;
 using boost::optional;
 
-VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<VideoContent> c, DecodeOptions o)
-       : Decoder (f, o)
+VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<VideoContent> c)
+       : Decoder (f)
        , _video_frame (0)
        , _last_source_time (0)
 {
index a52e5448a74ddda42327de7f1f6e8500543bc872..03dc4777a6a93a069ae533ecbaf99c787bc14b2c 100644 (file)
@@ -28,7 +28,7 @@ class VideoContent;
 class VideoDecoder : public VideoSource, public virtual Decoder
 {
 public:
-       VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<VideoContent>, DecodeOptions);
+       VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<VideoContent>);
 
        /** @return video frames per second, or 0 if unknown */
        virtual float frames_per_second () const = 0;
index f5756c6939e7770fc12040838fc2c7b7c0030ad3..d08fefa909ebc992c76d8f19d8fd55c8ba2cffe1 100644 (file)
@@ -28,7 +28,6 @@
 #include "scaler.h"
 #include "server.h"
 #include "dcp_video_frame.h"
-#include "options.h"
 #include "decoder.h"
 #include "exceptions.h"
 #include "scaler.h"
@@ -151,12 +150,12 @@ main (int argc, char* argv[])
        server = new ServerDescription (server_host, 1);
        shared_ptr<Film> film (new Film (film_dir, true));
 
-       DecodeOptions opt;
-       opt.decode_audio = false;
-       opt.decode_subtitles = true;
-       opt.video_sync = true;
+       /* XXX */
+//     opt.decode_audio = false;
+//     opt.decode_subtitles = true;
+//     opt.video_sync = true;
 
-       Decoders decoders = decoder_factory (film, opt);
+       Decoders decoders = decoder_factory (film);
        try {
                decoders.video->Video.connect (boost::bind (process_video, _1, _2, _3));
                bool done = false;
index ce1c1abe8bb77610c5886b4893ba40c71d7106ed..f9a91f8fac9d18d5a77bccd1e9d8743e3bf28af9 100644 (file)
@@ -347,6 +347,7 @@ FilmEditor::make_content_panel ()
                 s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
 
                 _content->InsertColumn (0, "");
+               _content->SetColumnWidth (0, 512);
 
                 wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
                 _content_add = new wxButton (_content_panel, wxID_ANY, _("Add..."));
index 1e2a74be9727328d4660810251c21723c8f585b3..42af4b3c03790334bd851ba1e515f4088932ef24 100644 (file)
 #include "lib/format.h"
 #include "lib/util.h"
 #include "lib/job_manager.h"
-#include "lib/options.h"
 #include "lib/subtitle.h"
 #include "lib/image.h"
 #include "lib/scaler.h"
 #include "lib/exceptions.h"
 #include "lib/examine_content_job.h"
 #include "lib/filter.h"
+#include "lib/playlist.h"
 #include "film_viewer.h"
 #include "wx_util.h"
 #include "video_decoder.h"
@@ -97,24 +97,13 @@ FilmViewer::film_changed (Film::Property p)
                break;
        case Film::CONTENT:
        {
-               DecodeOptions o;
-               o.decode_audio = false;
-               o.decode_subtitles = true;
-               o.video_sync = false;
-
-               try {
-                       _decoders = decoder_factory (_film, o);
-               } catch (StringError& e) {
-                       error_dialog (this, wxString::Format (_("Could not open content file (%s)"), std_to_wx(e.what()).data()));
-                       return;
-               }
-               
-               if (_decoders.video == 0) {
-                       break;
-               }
-               _decoders.video->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
-               _decoders.video->OutputChanged.connect (boost::bind (&FilmViewer::decoder_changed, this));
-//             _decoders.video->set_subtitle_stream (_film->subtitle_stream());
+               _playlist = _film->playlist ();
+               _playlist->disable_audio ();
+               _playlist->disable_subtitles ();
+               _playlist->disable_video_sync ();
+
+               _playlist->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
+//             _playlist->OutputChanged.connect (boost::bind (&FilmViewer::decoder_changed, this));
                calculate_sizes ();
                get_frame ();
                _panel->Refresh ();
@@ -129,9 +118,9 @@ FilmViewer::film_changed (Film::Property p)
                update_from_raw ();
                break;
        case Film::SUBTITLE_STREAM:
-               if (_decoders.video) {
+//             if (_decoders.video) {
 //                     _decoders.video->set_subtitle_stream (_film->subtitle_stream ());
-               }
+//             }
                break;
        default:
                break;
@@ -164,7 +153,7 @@ FilmViewer::set_film (shared_ptr<Film> f)
 void
 FilmViewer::decoder_changed ()
 {
-       if (_decoders.video == 0 || _decoders.video->seek_to_last ()) {
+       if (!_playlist == 0 || _playlist->seek_to_last ()) {
                return;
        }
 
@@ -176,7 +165,7 @@ FilmViewer::decoder_changed ()
 void
 FilmViewer::timer (wxTimerEvent &)
 {
-       if (!_film || !_decoders.video) {
+       if (!_playlist) {
                return;
        }
        
@@ -185,8 +174,8 @@ FilmViewer::timer (wxTimerEvent &)
 
        get_frame ();
 
-//     if (_film->length()) {
-//             int const new_slider_position = 4096 * _decoders.video->last_source_time() / (_film->length().get() / _film->source_frame_rate());
+//     if (_playlist->video_length()) {
+//             int const new_slider_position = 4096 * _playlist->last_source_time() / (_film->length().get() / _film->source_frame_rate());
 //             if (new_slider_position != _slider->GetValue()) {
 //                     _slider->SetValue (new_slider_position);
 //             }
@@ -231,13 +220,13 @@ FilmViewer::paint_panel (wxPaintEvent &)
 void
 FilmViewer::slider_moved (wxScrollEvent &)
 {
-//     if (!_film || !_film->length() || !_decoders.video) {
-//             return;
-//     }
+       if (!_film || !_playlist) {
+               return;
+       }
        
-//     if (_decoders.video->seek (_slider->GetValue() * _film->length().get() / (4096 * _film->source_frame_rate()))) {
-//             return;
-//     }
+       if (_playlist->seek (_slider->GetValue() * _playlist->video_length() / (4096 * _playlist->video_frame_rate()))) {
+               return;
+       }
        
        get_frame ();
        _panel->Refresh ();
@@ -319,7 +308,7 @@ FilmViewer::raw_to_display ()
 void
 FilmViewer::calculate_sizes ()
 {
-       if (!_film) {
+       if (!_film || !_playlist) {
                return;
        }
 
@@ -342,9 +331,9 @@ FilmViewer::calculate_sizes ()
           of our _display_frame.
        */
        _display_frame_x = 0;
-//     if (format) {
-//             _display_frame_x = static_cast<float> (format->dcp_padding (_film)) * _out_size.width / format->dcp_size().width;
-//     }
+       if (format) {
+               _display_frame_x = static_cast<float> (format->dcp_padding (_playlist)) * _out_size.width / format->dcp_size().width;
+       }
 
        _film_size = _out_size;
        _film_size.width -= _display_frame_x * 2;
@@ -392,7 +381,7 @@ FilmViewer::get_frame ()
        /* Clear our raw frame in case we don't get a new one */
        _raw_frame.reset ();
 
-       if (_decoders.video == 0) {
+       if (!_playlist) {
                _display_frame.reset ();
                return;
        }
@@ -400,7 +389,7 @@ FilmViewer::get_frame ()
        try {
                _got_frame = false;
                while (!_got_frame) {
-                       if (_decoders.video->pass ()) {
+                       if (_playlist->pass ()) {
                                /* We didn't get a frame before the decoder gave up,
                                   so clear our display frame.
                                */
index 456301eb4e0744d9162e60781e7034bf2ad90c4b..b552a3dbc6c6d6be1e8d546799fda72ba7ef3899 100644 (file)
@@ -58,6 +58,7 @@ private:
        void active_jobs_changed (bool);
 
        boost::shared_ptr<Film> _film;
+       boost::shared_ptr<Playlist> _playlist;
 
        wxSizer* _v_sizer;
        wxPanel* _panel;
@@ -65,7 +66,6 @@ private:
        wxToggleButton* _play_button;
        wxTimer _timer;
 
-       Decoders _decoders;
        boost::shared_ptr<Image> _raw_frame;
        boost::shared_ptr<Subtitle> _raw_sub;
        boost::shared_ptr<Image> _display_frame;