diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-03-08 21:03:28 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-03-08 21:03:28 +0000 |
| commit | bb95f333f15ace7c032bb5b5761b512b6fe2e84e (patch) | |
| tree | d9486a34d1980804ceb9b2203e46de1bdf3bf9d8 /src | |
| parent | 8af3fc82eb7d5955b09d94e1cc142f6a3adcf370 (diff) | |
Numerous fixes to A/B mode so that at least it doesn't crash (#72).
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/ab_transcoder.cc | 17 | ||||
| -rw-r--r-- | src/lib/combiner.cc | 2 | ||||
| -rw-r--r-- | src/lib/combiner.h | 2 | ||||
| -rw-r--r-- | src/lib/dcp_video_frame.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcp_video_frame.h | 4 | ||||
| -rw-r--r-- | src/lib/delay_line.cc | 2 | ||||
| -rw-r--r-- | src/lib/delay_line.h | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 9 | ||||
| -rw-r--r-- | src/lib/film.h | 4 | ||||
| -rw-r--r-- | src/lib/gain.cc | 2 | ||||
| -rw-r--r-- | src/lib/gain.h | 2 | ||||
| -rw-r--r-- | src/lib/matcher.cc | 2 | ||||
| -rw-r--r-- | src/lib/matcher.h | 2 | ||||
| -rw-r--r-- | src/lib/processor.h | 10 | ||||
| -rw-r--r-- | src/lib/server.cc | 2 | ||||
| -rw-r--r-- | src/lib/server.h | 4 | ||||
| -rw-r--r-- | src/lib/transcoder.cc | 1 | ||||
| -rw-r--r-- | src/tools/dvdomatic.cc | 10 | ||||
| -rw-r--r-- | src/tools/servomatic_cli.cc | 9 | ||||
| -rw-r--r-- | src/tools/servomatic_gui.cc | 13 | ||||
| -rw-r--r-- | src/tools/servomatictest.cc | 6 |
21 files changed, 63 insertions, 44 deletions
diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc index 4ed5d02ca..3a1cd83d7 100644 --- a/src/lib/ab_transcoder.cc +++ b/src/lib/ab_transcoder.cc @@ -40,6 +40,7 @@ using std::string; using boost::shared_ptr; +using boost::dynamic_pointer_cast; /** @param a Film to use for the left half of the screen. * @param b Film to use for the right half of the screen. @@ -54,6 +55,7 @@ ABTranscoder::ABTranscoder ( , _film_b (b) , _job (j) , _encoder (e) + , _combiner (new Combiner (a->log())) { _da = decoder_factory (_film_a, o); _db = decoder_factory (_film_b, o); @@ -92,17 +94,24 @@ void ABTranscoder::go () { _encoder->process_begin (); + + bool done[3] = { false, false, false }; while (1) { - bool const va = _da.video->pass (); - bool const vb = _db.video->pass (); - bool const a = _da.audio->pass (); + done[0] = _da.video->pass (); + done[1] = _db.video->pass (); + + if (!done[2] && _da.audio && dynamic_pointer_cast<Decoder> (_da.audio) != dynamic_pointer_cast<Decoder> (_da.video)) { + done[2] = _da.audio->pass (); + } else { + done[2] = true; + } if (_job) { _da.video->set_progress (_job); } - if (va && vb && a) { + if (done[0] && done[1] && done[2]) { break; } } diff --git a/src/lib/combiner.cc b/src/lib/combiner.cc index 68aafd2a2..12ce4a96e 100644 --- a/src/lib/combiner.cc +++ b/src/lib/combiner.cc @@ -22,7 +22,7 @@ using boost::shared_ptr; -Combiner::Combiner (Log* log) +Combiner::Combiner (shared_ptr<Log> log) : VideoProcessor (log) { diff --git a/src/lib/combiner.h b/src/lib/combiner.h index 7fad1aeae..68026eaff 100644 --- a/src/lib/combiner.h +++ b/src/lib/combiner.h @@ -31,7 +31,7 @@ class Combiner : public VideoProcessor { public: - Combiner (Log* log); + Combiner (boost::shared_ptr<Log> log); void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s); void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s); diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 67617c63c..d735122b5 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -80,7 +80,7 @@ using libdcp::Size; 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, int dcp_fps, string pp, int clut, int bw, Log* l + Scaler const * s, int f, int dcp_fps, string pp, int clut, int bw, shared_ptr<Log> l ) : _input (yuv) , _subtitle (sub) diff --git a/src/lib/dcp_video_frame.h b/src/lib/dcp_video_frame.h index 6794765ac..4ceb07d26 100644 --- a/src/lib/dcp_video_frame.h +++ b/src/lib/dcp_video_frame.h @@ -107,7 +107,7 @@ class DCPVideoFrame public: DCPVideoFrame ( boost::shared_ptr<const Image>, boost::shared_ptr<Subtitle>, libdcp::Size, - int, int, float, Scaler const *, int, int, std::string, int, int, Log * + int, int, float, Scaler const *, int, int, std::string, int, int, boost::shared_ptr<Log> ); virtual ~DCPVideoFrame (); @@ -135,7 +135,7 @@ private: int _colour_lut; ///< Colour look-up table to use int _j2k_bandwidth; ///< J2K bandwidth to use - Log* _log; ///< log + boost::shared_ptr<Log> _log; ///< log opj_image_cmptparm_t _cmptparm[3]; ///< libopenjpeg's opj_image_cmptparm_t opj_image* _image; ///< libopenjpeg's image container diff --git a/src/lib/delay_line.cc b/src/lib/delay_line.cc index 4ad172781..53da9a412 100644 --- a/src/lib/delay_line.cc +++ b/src/lib/delay_line.cc @@ -30,7 +30,7 @@ using boost::shared_ptr; /** @param channels Number of channels of audio. * @param frames Delay in frames, +ve to move audio later. */ -DelayLine::DelayLine (Log* log, int channels, int frames) +DelayLine::DelayLine (shared_ptr<Log> log, int channels, int frames) : AudioProcessor (log) , _negative_delay_remaining (0) , _frames (frames) diff --git a/src/lib/delay_line.h b/src/lib/delay_line.h index 4d6f1313b..c51784f35 100644 --- a/src/lib/delay_line.h +++ b/src/lib/delay_line.h @@ -26,7 +26,7 @@ class AudioBuffers; class DelayLine : public AudioProcessor { public: - DelayLine (Log* log, int channels, int frames); + DelayLine (boost::shared_ptr<Log> log, int channels, int frames); void process_audio (boost::shared_ptr<AudioBuffers>); diff --git a/src/lib/film.cc b/src/lib/film.cc index 20e08c037..8028f40ef 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -144,12 +144,13 @@ Film::Film (string d, bool must_exist) read_metadata (); } - _log = new FileLog (file ("log")); + _log.reset (new FileLog (file ("log"))); } Film::Film (Film const & o) : boost::enable_shared_from_this<Film> (o) - , _log (0) + /* note: the copied film shares the original's log */ + , _log (o._log) , _directory (o._directory) , _name (o._name) , _use_dci_name (o._use_dci_name) @@ -188,12 +189,12 @@ Film::Film (Film const & o) , _source_frame_rate (o._source_frame_rate) , _dirty (o._dirty) { - + } Film::~Film () { - delete _log; + } string diff --git a/src/lib/film.h b/src/lib/film.h index 88f6fbcd7..2ab4a9450 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -77,7 +77,7 @@ public: /** @return Logger. * It is safe to call this from any thread. */ - Log* log () const { + boost::shared_ptr<Log> log () const { return _log; } @@ -382,7 +382,7 @@ public: private: /** Log to write to */ - Log* _log; + boost::shared_ptr<Log> _log; /** Any running ExamineContentJob, or 0 */ boost::shared_ptr<ExamineContentJob> _examine_content_job; diff --git a/src/lib/gain.cc b/src/lib/gain.cc index cec3b3c62..df7011d2e 100644 --- a/src/lib/gain.cc +++ b/src/lib/gain.cc @@ -22,7 +22,7 @@ using boost::shared_ptr; /** @param gain gain in dB */ -Gain::Gain (Log* log, float gain) +Gain::Gain (shared_ptr<Log> log, float gain) : AudioProcessor (log) , _gain (gain) { diff --git a/src/lib/gain.h b/src/lib/gain.h index 716ee9b51..d462e5aee 100644 --- a/src/lib/gain.h +++ b/src/lib/gain.h @@ -22,7 +22,7 @@ class Gain : public AudioProcessor { public: - Gain (Log* log, float gain); + Gain (boost::shared_ptr<Log> log, float gain); void process_audio (boost::shared_ptr<AudioBuffers>); diff --git a/src/lib/matcher.cc b/src/lib/matcher.cc index 4cd264338..48f6ed912 100644 --- a/src/lib/matcher.cc +++ b/src/lib/matcher.cc @@ -26,7 +26,7 @@ using std::min; using boost::shared_ptr; -Matcher::Matcher (Log* log, int sample_rate, float frames_per_second) +Matcher::Matcher (shared_ptr<Log> log, int sample_rate, float frames_per_second) : AudioVideoProcessor (log) , _sample_rate (sample_rate) , _frames_per_second (frames_per_second) diff --git a/src/lib/matcher.h b/src/lib/matcher.h index 60bb87432..b1680e131 100644 --- a/src/lib/matcher.h +++ b/src/lib/matcher.h @@ -24,7 +24,7 @@ class Matcher : public AudioVideoProcessor { public: - Matcher (Log* log, int sample_rate, float frames_per_second); + Matcher (boost::shared_ptr<Log> log, int sample_rate, float frames_per_second); void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s); void process_audio (boost::shared_ptr<AudioBuffers>); void process_end (); diff --git a/src/lib/processor.h b/src/lib/processor.h index 19d7c4b0c..1ba396f2f 100644 --- a/src/lib/processor.h +++ b/src/lib/processor.h @@ -40,7 +40,7 @@ public: /** Construct a Processor. * @param log Log to use. */ - Processor (Log* log) + Processor (boost::shared_ptr<Log> log) : _log (log) {} @@ -50,7 +50,7 @@ public: virtual void process_end () {} protected: - Log* _log; ///< log to write to + boost::shared_ptr<Log> _log; ///< log to write to }; /** @class AudioVideoProcessor @@ -62,7 +62,7 @@ public: /** Construct an AudioVideoProcessor. * @param log Log to write to. */ - AudioVideoProcessor (Log* log) + AudioVideoProcessor (boost::shared_ptr<Log> log) : Processor (log) {} }; @@ -76,7 +76,7 @@ public: /** Construct an AudioProcessor. * @param log Log to write to. */ - AudioProcessor (Log* log) + AudioProcessor (boost::shared_ptr<Log> log) : Processor (log) {} }; @@ -90,7 +90,7 @@ public: /** Construct an VideoProcessor. * @param log Log to write to. */ - VideoProcessor (Log* log) + VideoProcessor (boost::shared_ptr<Log> log) : Processor (log) {} }; diff --git a/src/lib/server.cc b/src/lib/server.cc index 76a25bfbb..9c5a77f68 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -77,7 +77,7 @@ ServerDescription::as_metadata () const return s.str (); } -Server::Server (Log* log) +Server::Server (shared_ptr<Log> log) : _log (log) { diff --git a/src/lib/server.h b/src/lib/server.h index 32ba8dc4b..89aeca626 100644 --- a/src/lib/server.h +++ b/src/lib/server.h @@ -76,7 +76,7 @@ private: class Server { public: - Server (Log* log); + Server (boost::shared_ptr<Log> log); void run (int num_threads); @@ -88,5 +88,5 @@ private: std::list<boost::shared_ptr<Socket> > _queue; boost::mutex _worker_mutex; boost::condition _worker_condition; - Log* _log; + boost::shared_ptr<Log> _log; }; diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index 9720ca56a..e0f3a03a2 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -38,7 +38,6 @@ #include "audio_decoder.h" using std::string; -using std::cout; using boost::shared_ptr; using boost::dynamic_pointer_cast; diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index 4874e6ef8..230e02c88 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -482,12 +482,16 @@ class App : public wxApp #ifdef DVDOMATIC_POSIX unsetenv ("UBUNTU_MENUPROXY"); #endif - + + /* This needs to be before setup_i18n, as setup_i18n() will + create a Config object, which needs Scalers to have + been created. + */ + dvdomatic_setup (); + wxInitAllImageHandlers (); setup_i18n (); - dvdomatic_setup (); - if (!film_to_load.empty() && boost::filesystem::is_directory (film_to_load)) { try { film.reset (new Film (film_to_load)); diff --git a/src/tools/servomatic_cli.cc b/src/tools/servomatic_cli.cc index f8e713193..6626d45b9 100644 --- a/src/tools/servomatic_cli.cc +++ b/src/tools/servomatic_cli.cc @@ -42,7 +42,10 @@ #include "log.h" #include "version.h" -using namespace std; +using std::cerr; +using std::string; +using std::cout; +using boost::shared_ptr; static void help (string n) @@ -87,8 +90,8 @@ main (int argc, char* argv[]) } Scaler::setup_scalers (); - FileLog log ("servomatic.log"); - Server server (&log); + shared_ptr<FileLog> log (new FileLog ("servomatic.log")); + Server server (log); server.run (num_threads); return 0; } diff --git a/src/tools/servomatic_gui.cc b/src/tools/servomatic_gui.cc index 610ba8005..dd169725f 100644 --- a/src/tools/servomatic_gui.cc +++ b/src/tools/servomatic_gui.cc @@ -25,8 +25,11 @@ #include "lib/server.h" #include "lib/config.h" -using namespace std; -using namespace boost; +using std::cout; +using std::string; +using boost::shared_ptr; +using boost::thread; +using boost::bind; enum { ID_status = 1, @@ -52,7 +55,7 @@ private: string _log; }; -static MemoryLog memory_log; +static shared_ptr<MemoryLog> memory_log (new MemoryLog); class StatusDialog : public wxDialog { @@ -77,7 +80,7 @@ public: private: void update (wxTimerEvent &) { - _text->ChangeValue (std_to_wx (memory_log.get ())); + _text->ChangeValue (std_to_wx (memory_log->get ())); _sizer->Layout (); } @@ -141,7 +144,7 @@ private: void main_thread () { - Server server (&memory_log); + Server server (memory_log); server.run (Config::instance()->num_local_encoding_threads ()); } diff --git a/src/tools/servomatictest.cc b/src/tools/servomatictest.cc index 91ad02120..f5756c693 100644 --- a/src/tools/servomatictest.cc +++ b/src/tools/servomatictest.cc @@ -43,7 +43,7 @@ using std::pair; using boost::shared_ptr; static ServerDescription* server; -static FileLog log_ ("servomatictest.log"); +static shared_ptr<FileLog> log_ (new FileLog ("servomatictest.log")); static int frame = 0; void @@ -53,14 +53,14 @@ process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub) new DCPVideoFrame ( image, sub, libdcp::Size (1024, 1024), 0, 0, 0, - Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_) + Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, log_) ); shared_ptr<DCPVideoFrame> remote ( new DCPVideoFrame ( image, sub, libdcp::Size (1024, 1024), 0, 0, 0, - Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_) + Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, log_) ); cout << "Frame " << frame << ": "; |
