summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-10 16:38:55 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-10 16:38:55 +0100
commit93a7ccee1d8d6a89fa90b15893f48c0aaf1d7c9d (patch)
tree0507c9146594af723340b2f56f5d860520799c27
parent148cc238cfba25ebfab198d7ba3134fc2ea37647 (diff)
Skip audio analysis when there is no audio content (#596).
-rw-r--r--ChangeLog4
-rw-r--r--src/lib/analyse_audio_job.cc21
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 <cth@carlh.net>
+
+ * Skip audio analysis when there is no audio content (#596).
+
2015-06-09 Carl Hetherington <cth@carlh.net>
* 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 <boost/foreach.hpp>
#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<Content> c, _film->content ()) {
+ if (dynamic_pointer_cast<AudioContent> (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 ()));