From 93a7ccee1d8d6a89fa90b15893f48c0aaf1d7c9d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 10 Jun 2015 16:38:55 +0100 Subject: Skip audio analysis when there is no audio content (#596). --- ChangeLog | 4 ++++ src/lib/analyse_audio_job.cc | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47678af18..9db166734 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-06-10 c.hetherington + + * Skip audio analysis when there is no audio content (#596). + 2015-06-09 Carl Hetherington * Version 2.0.49 released. diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 31b9dccae..b17dd07dc 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -23,6 +23,7 @@ #include "compose.hpp" #include "film.h" #include "player.h" +#include #include "i18n.h" @@ -31,6 +32,7 @@ using std::max; using std::min; using std::cout; using boost::shared_ptr; +using boost::dynamic_pointer_cast; int const AnalyseAudioJob::_num_points = 1024; @@ -69,11 +71,20 @@ AnalyseAudioJob::run () _current.resize (_film->audio_channels ()); _analysis.reset (new AudioAnalysis (_film->audio_channels ())); - _done = 0; - DCPTime const block = DCPTime::from_seconds (1.0 / 8); - for (DCPTime t; t < _film->length(); t += block) { - analyse (player->get_audio (t, block, false)); - set_progress (t.seconds() / _film->length().seconds()); + bool has_any_audio = false; + BOOST_FOREACH (shared_ptr c, _film->content ()) { + if (dynamic_pointer_cast (c)) { + has_any_audio = true; + } + } + + if (has_any_audio) { + _done = 0; + DCPTime const block = DCPTime::from_seconds (1.0 / 8); + for (DCPTime t; t < _film->length(); t += block) { + analyse (player->get_audio (t, block, false)); + set_progress (t.seconds() / _film->length().seconds()); + } } _analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ())); -- cgit v1.2.3