From a9172427858ec747ed5ff6ff4c2ab6eba1613135 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Mar 2013 20:04:05 +0000 Subject: Disable show audio button when there is no audio (#73). --- src/lib/film.cc | 18 ++++++++++++++++++ src/lib/film.h | 2 +- src/wx/film_editor.cc | 12 ++++++++++++ src/wx/film_editor.h | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index 8f545952b..20e08c037 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1434,3 +1434,21 @@ Film::have_dcp () const return true; } + +bool +Film::has_audio () const +{ + if (use_content_audio()) { + return audio_stream(); + } + + vector const e = external_audio (); + for (vector::const_iterator i = e.begin(); i != e.end(); ++i) { + if (!i->empty ()) { + return true; + } + } + + return false; +} + diff --git a/src/lib/film.h b/src/lib/film.h index 9921acbb4..88f6fbcd7 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -327,7 +327,7 @@ public: } boost::shared_ptr audio_stream () const; - + bool has_audio () const; /* SET */ diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index b9a4012e3..dcd18c97f 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -617,6 +617,7 @@ FilmEditor::film_changed (Film::Property p) setup_formats (); setup_subtitle_control_sensitivity (); setup_streams (); + setup_show_audio_sensitivity (); break; case Film::TRUST_CONTENT_HEADER: checked_set (_trust_content_header, _film->trust_content_header ()); @@ -627,6 +628,7 @@ FilmEditor::film_changed (Film::Property p) break; case Film::CONTENT_AUDIO_STREAMS: setup_streams (); + setup_show_audio_sensitivity (); break; case Film::FORMAT: { @@ -754,6 +756,7 @@ FilmEditor::film_changed (Film::Property p) setup_dcp_name (); setup_audio_details (); setup_audio_control_sensitivity (); + setup_show_audio_sensitivity (); break; case Film::USE_CONTENT_AUDIO: checked_set (_use_content_audio, _film->use_content_audio()); @@ -761,6 +764,7 @@ FilmEditor::film_changed (Film::Property p) setup_dcp_name (); setup_audio_details (); setup_audio_control_sensitivity (); + setup_show_audio_sensitivity (); break; case Film::SUBTITLE_STREAM: if (_film->subtitle_stream()) { @@ -774,6 +778,7 @@ FilmEditor::film_changed (Film::Property p) checked_set (_external_audio[i], a[i]); } setup_audio_details (); + setup_show_audio_sensitivity (); break; } case Film::DCP_FRAME_RATE: @@ -915,6 +920,7 @@ FilmEditor::set_things_sensitive (bool s) setup_subtitle_control_sensitivity (); setup_audio_control_sensitivity (); + setup_show_audio_sensitivity (); } /** Called when the `Edit filters' button has been clicked */ @@ -1289,3 +1295,9 @@ FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &) _film->set_dcp_frame_rate (best_dcp_frame_rate (_film->source_frame_rate ())); } + +void +FilmEditor::setup_show_audio_sensitivity () +{ + _show_audio->Enable (_film && _film->has_audio ()); +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 29b453b8b..e5b619886 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -98,6 +98,7 @@ private: void setup_streams (); void setup_audio_details (); void setup_dcp_name (); + void setup_show_audio_sensitivity (); wxControl* video_control (wxControl *); wxControl* still_control (wxControl *); -- cgit v1.2.3 From 6ab3bf8add89cf16fd9d7f644527a2ca8207e83e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Mar 2013 20:11:32 +0000 Subject: Disable content audio selector if there is none (#41). --- src/wx/film_editor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index dcd18c97f..82c8a76a8 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -1129,7 +1129,7 @@ FilmEditor::setup_subtitle_control_sensitivity () void FilmEditor::setup_audio_control_sensitivity () { - _use_content_audio->Enable (_generally_sensitive); + _use_content_audio->Enable (_generally_sensitive && _film && !_film->content_audio_streams().empty()); _use_external_audio->Enable (_generally_sensitive); bool const source = _generally_sensitive && _use_content_audio->GetValue(); @@ -1224,7 +1224,7 @@ FilmEditor::subtitle_stream_changed (wxCommandEvent &) void FilmEditor::setup_audio_details () { - if (!_film->audio_stream()) { + if (!_film->content_audio_stream()) { _audio->SetLabel (wxT ("")); } else { stringstream s; -- cgit v1.2.3 From bb95f333f15ace7c032bb5b5761b512b6fe2e84e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Mar 2013 21:03:28 +0000 Subject: Numerous fixes to A/B mode so that at least it doesn't crash (#72). --- src/lib/ab_transcoder.cc | 17 +++++++++++++---- src/lib/combiner.cc | 2 +- src/lib/combiner.h | 2 +- src/lib/dcp_video_frame.cc | 2 +- src/lib/dcp_video_frame.h | 4 ++-- src/lib/delay_line.cc | 2 +- src/lib/delay_line.h | 2 +- src/lib/film.cc | 9 +++++---- src/lib/film.h | 4 ++-- src/lib/gain.cc | 2 +- src/lib/gain.h | 2 +- src/lib/matcher.cc | 2 +- src/lib/matcher.h | 2 +- src/lib/processor.h | 10 +++++----- src/lib/server.cc | 2 +- src/lib/server.h | 4 ++-- src/lib/transcoder.cc | 1 - src/tools/dvdomatic.cc | 10 +++++++--- src/tools/servomatic_cli.cc | 9 ++++++--- src/tools/servomatic_gui.cc | 13 ++++++++----- src/tools/servomatictest.cc | 6 +++--- test/test.cc | 14 +++++++------- 22 files changed, 70 insertions(+), 51 deletions(-) (limited to 'src') 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 (_da.audio) != dynamic_pointer_cast (_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) : 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); void process_video (boost::shared_ptr i, bool, boost::shared_ptr s); void process_video_b (boost::shared_ptr i, bool, boost::shared_ptr 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 yuv, shared_ptr 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 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, boost::shared_ptr, 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 ); 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 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, 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, int channels, int frames); void process_audio (boost::shared_ptr); 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 (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 () const { return _log; } @@ -382,7 +382,7 @@ public: private: /** Log to write to */ - Log* _log; + boost::shared_ptr _log; /** Any running ExamineContentJob, or 0 */ boost::shared_ptr _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, 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, float gain); void process_audio (boost::shared_ptr); 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, 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, int sample_rate, float frames_per_second); void process_video (boost::shared_ptr i, bool, boost::shared_ptr s); void process_audio (boost::shared_ptr); 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) {} @@ -50,7 +50,7 @@ public: virtual void process_end () {} protected: - Log* _log; ///< log to write to + boost::shared_ptr _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) : Processor (log) {} }; @@ -76,7 +76,7 @@ public: /** Construct an AudioProcessor. * @param log Log to write to. */ - AudioProcessor (Log* log) + AudioProcessor (boost::shared_ptr 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) : 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) { 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); void run (int num_threads); @@ -88,5 +88,5 @@ private: std::list > _queue; boost::mutex _worker_mutex; boost::condition _worker_condition; - Log* _log; + boost::shared_ptr _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 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 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 log_ (new FileLog ("servomatictest.log")); static int frame = 0; void @@ -53,14 +53,14 @@ process_video (shared_ptr image, bool, shared_ptr 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 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 << ": "; diff --git a/test/test.cc b/test/test.cc index 15c34ca78..448168f24 100644 --- a/test/test.cc +++ b/test/test.cc @@ -254,9 +254,9 @@ public: void do_positive_delay_line_test (int delay_length, int data_length) { - NullLog log; + shared_ptr log (new NullLog); - DelayLine d (&log, 6, delay_length); + DelayLine d (log, 6, delay_length); shared_ptr data (new AudioBuffers (6, data_length)); int in = 0; @@ -297,9 +297,9 @@ do_positive_delay_line_test (int delay_length, int data_length) void do_negative_delay_line_test (int delay_length, int data_length) { - NullLog log; + shared_ptr log (new NullLog); - DelayLine d (&log, 6, delay_length); + DelayLine d (log, 6, delay_length); shared_ptr data (new AudioBuffers (6, data_length)); int in = 0; @@ -406,7 +406,7 @@ BOOST_AUTO_TEST_CASE (client_server_test) shared_ptr subtitle (new Subtitle (Position (50, 60), sub_image)); - FileLog log ("build/test/client_server_test.log"); + shared_ptr log (new FileLog ("build/test/client_server_test.log")); shared_ptr frame ( new DCPVideoFrame ( @@ -422,14 +422,14 @@ BOOST_AUTO_TEST_CASE (client_server_test) "", 0, 200000000, - &log + log ) ); shared_ptr locally_encoded = frame->encode_locally (); BOOST_ASSERT (locally_encoded); - Server* server = new Server (&log); + Server* server = new Server (log); new thread (boost::bind (&Server::run, server, 2)); -- cgit v1.2.3 From 7339bd0457584dc8996a472ee7264a59a779c68e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Mar 2013 21:27:01 +0000 Subject: Fix crash on analysing audio when we think the film is zero length. --- src/lib/analyse_audio_job.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 41f918f34..de2632b0a 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -67,7 +67,7 @@ AnalyseAudioJob::run () decoders.audio->Audio.connect (bind (&AnalyseAudioJob::audio, this, _1)); int64_t total_audio_frames = video_frames_to_audio_frames (_film->length().get(), _film->audio_stream()->sample_rate(), _film->source_frame_rate()); - _samples_per_point = total_audio_frames / _num_points; + _samples_per_point = min (1, total_audio_frames / _num_points); _current.resize (_film->audio_stream()->channels ()); _analysis.reset (new AudioAnalysis (_film->audio_stream()->channels())); -- cgit v1.2.3 From 031a4066190454b1a4d933b74e86a053673a5e43 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Mar 2013 22:51:39 +0000 Subject: Stop infinite loop if audio analysis fails. --- src/lib/analyse_audio_job.cc | 3 ++- src/lib/film.cc | 7 +++++-- src/lib/film.h | 2 +- src/wx/audio_dialog.cc | 4 ++-- src/wx/audio_dialog.h | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index de2632b0a..92c3cdd4e 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -29,6 +29,7 @@ using std::string; using std::max; +using std::min; using std::cout; using boost::shared_ptr; @@ -67,7 +68,7 @@ AnalyseAudioJob::run () decoders.audio->Audio.connect (bind (&AnalyseAudioJob::audio, this, _1)); int64_t total_audio_frames = video_frames_to_audio_frames (_film->length().get(), _film->audio_stream()->sample_rate(), _film->source_frame_rate()); - _samples_per_point = min (1, total_audio_frames / _num_points); + _samples_per_point = max (1L, total_audio_frames / _num_points); _current.resize (_film->audio_stream()->channels ()); _analysis.reset (new AudioAnalysis (_film->audio_stream()->channels())); diff --git a/src/lib/film.cc b/src/lib/film.cc index 8028f40ef..46b48f511 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -351,9 +351,12 @@ void Film::analyse_audio_finished () { ensure_ui_thread (); - _analyse_audio_job.reset (); - AudioAnalysisFinished (); + if (_analyse_audio_job->finished_ok ()) { + AudioAnalysisSucceeded (); + } + + _analyse_audio_job.reset (); } void diff --git a/src/lib/film.h b/src/lib/film.h index 2ab4a9450..150e384bc 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -374,7 +374,7 @@ public: /** Emitted when some property has changed */ mutable boost::signals2::signal Changed; - boost::signals2::signal AudioAnalysisFinished; + boost::signals2::signal AudioAnalysisSucceeded; /** Current version number of the state file */ static int const state_version; diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 5bac8eabe..ba7ddd8f7 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -87,7 +87,7 @@ void AudioDialog::set_film (boost::shared_ptr f) { _film_changed_connection.disconnect (); - _film_audio_analysis_finished_connection.disconnect (); + _film_audio_analysis_succeeded_connection.disconnect (); _film = f; @@ -96,7 +96,7 @@ AudioDialog::set_film (boost::shared_ptr f) _plot->set_gain (_film->audio_gain ()); _film_changed_connection = _film->Changed.connect (bind (&AudioDialog::film_changed, this, _1)); - _film_audio_analysis_finished_connection = _film->AudioAnalysisFinished.connect (bind (&AudioDialog::try_to_load_analysis, this)); + _film_audio_analysis_succeeded_connection = _film->AudioAnalysisSucceeded.connect (bind (&AudioDialog::try_to_load_analysis, this)); SetTitle (std_to_wx (String::compose (wx_to_std (_("DVD-o-matic audio - %1")), _film->name()))); } diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index 16cb356fe..514faeea0 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -47,5 +47,5 @@ private: wxCheckBox* _type_checkbox[AudioPoint::COUNT]; wxSlider* _smoothing; boost::signals2::scoped_connection _film_changed_connection; - boost::signals2::scoped_connection _film_audio_analysis_finished_connection; + boost::signals2::scoped_connection _film_audio_analysis_succeeded_connection; }; -- cgit v1.2.3 From 2bde54c29e6b36c75948ca1d3efcda0535d148d7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Mar 2013 23:13:23 +0000 Subject: Remove un-read intrinsic_duration. --- src/lib/dcp_video_frame.cc | 2 +- src/lib/film.cc | 17 ----------------- src/lib/film.h | 7 ------- src/lib/transcode_job.cc | 3 --- src/lib/writer.cc | 2 -- src/wx/film_editor.cc | 2 -- 6 files changed, 1 insertion(+), 32 deletions(-) (limited to 'src') diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index d735122b5..d674393a9 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -70,7 +70,7 @@ using libdcp::Size; * @param out Required size of output, in pixels (including any padding). * @param s Scaler to use. * @param p Number of pixels of padding either side of the image. - * @param f Index of the frame within the DCP's intrinsic duration. + * @param f Index of the frame within the DCP. * @param fps Frames per second of the Film's source. * @param pp FFmpeg post-processing string to use. * @param clut Colour look-up table to use (see Config::colour_lut_index ()) diff --git a/src/lib/film.cc b/src/lib/film.cc index 46b48f511..77f9828cd 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -181,7 +181,6 @@ Film::Film (Film const & o) , _dcp_frame_rate (o._dcp_frame_rate) , _size (o._size) , _length (o._length) - , _dcp_intrinsic_duration (o._dcp_intrinsic_duration) , _content_digest (o._content_digest) , _content_audio_streams (o._content_audio_streams) , _external_audio_stream (o._external_audio_stream) @@ -454,7 +453,6 @@ Film::write_metadata () const f << "width " << _size.width << endl; f << "height " << _size.height << endl; f << "length " << _length.get_value_or(0) << endl; - f << "dcp_intrinsic_duration " << _dcp_intrinsic_duration.get_value_or(0) << endl; f << "content_digest " << _content_digest << endl; for (vector >::const_iterator i = _content_audio_streams.begin(); i != _content_audio_streams.end(); ++i) { @@ -595,11 +593,6 @@ Film::read_metadata () if (vv) { _length = vv; } - } else if (k == "dcp_intrinsic_duration") { - int const vv = atoi (v.c_str ()); - if (vv) { - _dcp_intrinsic_duration = vv; - } } else if (k == "content_digest") { _content_digest = v; } else if (k == "content_audio_stream" || (!version && k == "audio_stream")) { @@ -1294,16 +1287,6 @@ Film::unset_length () signal_changed (LENGTH); } -void -Film::set_dcp_intrinsic_duration (int d) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _dcp_intrinsic_duration = d; - } - signal_changed (DCP_INTRINSIC_DURATION); -} - void Film::set_content_digest (string d) { diff --git a/src/lib/film.h b/src/lib/film.h index 150e384bc..698e7ef46 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -98,10 +98,6 @@ public: std::string dci_name (bool if_created_now) const; std::string dcp_name (bool if_created_now = false) const; - boost::optional dcp_intrinsic_duration () const { - return _dcp_intrinsic_duration; - } - /** @return true if our state has changed since we last saved it */ bool dirty () const { return _dirty; @@ -145,7 +141,6 @@ public: DCI_METADATA, SIZE, LENGTH, - DCP_INTRINSIC_DURATION, CONTENT_AUDIO_STREAMS, SUBTITLE_STREAMS, SOURCE_FRAME_RATE, @@ -365,7 +360,6 @@ public: void set_size (libdcp::Size); void set_length (SourceFrame); void unset_length (); - void set_dcp_intrinsic_duration (int); void set_content_digest (std::string); void set_content_audio_streams (std::vector >); void set_subtitle_streams (std::vector >); @@ -477,7 +471,6 @@ private: libdcp::Size _size; /** The length of the source, in video frames (as far as we know) */ boost::optional _length; - boost::optional _dcp_intrinsic_duration; /** MD5 digest of our content file */ std::string _content_digest; /** The audio streams in our content */ diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index f7cc500fe..234ebe051 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -68,10 +68,7 @@ TranscodeJob::run () set_progress (1); set_state (FINISHED_OK); - _film->set_dcp_intrinsic_duration (_encoder->video_frames_out ()); - _film->log()->log (N_("Transcode job completed successfully")); - _film->log()->log (String::compose (N_("DCP intrinsic duration is %1"), _encoder->video_frames_out())); } catch (std::exception& e) { diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 5a2f7c9a9..06acaa1f6 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -261,8 +261,6 @@ Writer::finish () int const frames = _last_written_frame + 1; int const duration = frames - _film->trim_start() - _film->trim_end(); - _film->set_dcp_intrinsic_duration (frames); - _picture_asset->set_entry_point (_film->trim_start ()); _picture_asset->set_duration (duration); diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 82c8a76a8..20dbc88ef 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -698,8 +698,6 @@ FilmEditor::film_changed (Film::Property p) _trim_end->SetRange (0, _film->length().get()); } break; - case Film::DCP_INTRINSIC_DURATION: - break; case Film::DCP_CONTENT_TYPE: checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ())); setup_dcp_name (); -- cgit v1.2.3 From 0a7004ab20d6bc3d20c1956df355384fa7f2da30 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Mar 2013 22:15:36 +0000 Subject: Try to copy instead of hard linking if the hard-link fails (#77). --- src/lib/writer.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 06acaa1f6..6ca56ec4e 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -273,8 +273,12 @@ Writer::finish () boost::filesystem::path to; to /= _film->dir (_film->dcp_name()); to /= N_("video.mxf"); - - boost::filesystem::create_hard_link (from, to); + + boost::system::error_code ec; + if (boost::filesystem::create_hard_link (from, to, ec)) { + /* hard link failed; copy instead */ + boost::filesystem::copy_file (from, to); + } /* And update the asset */ -- cgit v1.2.3 From 72234d49c16bad30d66256dd6e82d1359f4f830b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Mar 2013 22:18:00 +0000 Subject: Fix previous. --- src/lib/writer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 6ca56ec4e..33f574f56 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -275,7 +275,8 @@ Writer::finish () to /= N_("video.mxf"); boost::system::error_code ec; - if (boost::filesystem::create_hard_link (from, to, ec)) { + boost::filesystem::create_hard_link (from, to, ec); + if (ec) { /* hard link failed; copy instead */ boost::filesystem::copy_file (from, to); } -- cgit v1.2.3 From 7d262f9be3a4c5d8da07dce42f7e2da708f6c7f4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Mar 2013 22:19:13 +0000 Subject: Log failure to hard-link. --- src/lib/writer.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 33f574f56..2d7ee9ba3 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -279,6 +279,7 @@ Writer::finish () if (ec) { /* hard link failed; copy instead */ boost::filesystem::copy_file (from, to); + _film->log()->log ("Hard-link failed; fell back to copying"); } /* And update the asset */ -- cgit v1.2.3