- _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, _playlist->content ()) {
+ if (c->audio) {
+ has_any_audio = true;
+ }
+ }
+
+ if (has_any_audio) {
+ _done = 0;
+ DCPTime const block = DCPTime::from_seconds (1.0 / 8);
+ for (DCPTime t = start; t < length; t += block) {
+ shared_ptr<const AudioBuffers> audio = player->get_audio (t, block, false);
+#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
+ if (Config::instance()->analyse_ebur128 ()) {
+ _ebur128->process (audio);
+ }
+#endif
+ analyse (audio);
+ set_progress ((t.seconds() - start.seconds()) / (length.seconds() - start.seconds()));
+ }
+ }
+
+ _analysis->set_sample_peak (_sample_peak, DCPTime::from_frames (_sample_peak_frame, _film->audio_frame_rate ()));
+
+#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
+ if (Config::instance()->analyse_ebur128 ()) {
+ void* eb = _ebur128->get("Parsed_ebur128_0")->priv;
+ double true_peak = 0;
+ for (int i = 0; i < _film->audio_channels(); ++i) {
+ true_peak = max (true_peak, av_ebur128_get_true_peaks(eb)[i]);
+ }
+ _analysis->set_true_peak (true_peak);
+ _analysis->set_integrated_loudness (av_ebur128_get_integrated_loudness(eb));
+ _analysis->set_loudness_range (av_ebur128_get_loudness_range(eb));
+ }
+#endif
+
+ if (_playlist->content().size() == 1) {
+ /* If there was only one piece of content in this analysis we may later need to know what its
+ gain was when we analysed it.
+ */
+ shared_ptr<const AudioContent> ac = _playlist->content().front()->audio;
+ DCPOMATIC_ASSERT (ac);
+ _analysis->set_analysis_gain (ac->gain ());