Add configure option to disable EBUR128 analysis of audio.
authorCarl Hetherington <cth@carlh.net>
Wed, 2 Mar 2016 10:48:13 +0000 (10:48 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 2 Mar 2016 10:48:13 +0000 (10:48 +0000)
ChangeLog
src/lib/analyse_audio_job.cc
src/lib/config.cc
src/lib/config.h
src/wx/config_dialog.cc

index 5c038c2e2992bcc87027d663640f57587a588242..c3a3072a9619595ac89a64592537d4d1a6a98ed4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-03-02  c.hetherington  <cth@carlh.net>
+
+       * Add configurable option to disable EBUR128
+       analysis.
+
 2016-03-01  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.6.30 released.
index d17c4c30bfb06b51b43594064b4e392b3c8a7a0e..d81f25caca7118d18e1254f08b3b78e714553ac1 100644 (file)
@@ -27,6 +27,7 @@
 #include "playlist.h"
 #include "filter.h"
 #include "audio_filter_graph.h"
+#include "config.h"
 extern "C" {
 #include <libavutil/channel_layout.h>
 #ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
@@ -116,7 +117,9 @@ AnalyseAudioJob::run ()
                for (DCPTime t = start; t < length; t += block) {
                        shared_ptr<const AudioBuffers> audio = player->get_audio (t, block, false);
 #ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
-                       _ebur128->process (audio);
+                       if (Config::instance()->analyse_ebur128 ()) {
+                               _ebur128->process (audio);
+                       }
 #endif
                        analyse (audio);
                        set_progress ((t.seconds() - start.seconds()) / (length.seconds() - start.seconds()));
@@ -126,14 +129,16 @@ AnalyseAudioJob::run ()
        _analysis->set_sample_peak (_sample_peak, DCPTime::from_frames (_sample_peak_frame, _film->audio_frame_rate ()));
 
 #ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
-       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]);
+       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));
        }
-       _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) {
index 8370be7d1d169fae247a6a75af1ed4857590e925..ba285fd2ce3e9fe1129bd05a667f95396f314587 100644 (file)
@@ -98,6 +98,7 @@ Config::set_defaults ()
        _check_for_test_updates = false;
        _maximum_j2k_bandwidth = 250000000;
        _log_types = LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR;
+       _analyse_ebur128 = true;
        _automatic_audio_analysis = false;
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = false;
@@ -247,6 +248,7 @@ Config::read ()
        _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate").get_value_or (false);
 
        _log_types = f.optional_number_child<int> ("LogTypes").get_value_or (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR);
+       _analyse_ebur128 = f.optional_bool_child("AnalyseEBUR128").get_value_or (true);
        _automatic_audio_analysis = f.optional_bool_child ("AutomaticAudioAnalysis").get_value_or (false);
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = f.optional_bool_child ("Win32Console").get_value_or (false);
@@ -411,6 +413,7 @@ Config::write_config_xml () const
        root->add_child("MaximumJ2KBandwidth")->add_child_text (raw_convert<string> (_maximum_j2k_bandwidth));
        root->add_child("AllowAnyDCPFrameRate")->add_child_text (_allow_any_dcp_frame_rate ? "1" : "0");
        root->add_child("LogTypes")->add_child_text (raw_convert<string> (_log_types));
+       root->add_child("AnalyseEBUR128")->add_child_text (_analyse_ebur128 ? "1" : "0");
        root->add_child("AutomaticAudioAnalysis")->add_child_text (_automatic_audio_analysis ? "1" : "0");
 #ifdef DCPOMATIC_WINDOWS
        root->add_child("Win32Console")->add_child_text (_win32_console ? "1" : "0");
index 109f7b603790bcd43f47a8d10ed6bb62de2679af..e5795d2c300db8ac02b02cb4c6f97369d713900d 100644 (file)
@@ -231,6 +231,10 @@ public:
                return _log_types;
        }
 
+       bool analyse_ebur128 () const {
+               return _analyse_ebur128;
+       }
+
        bool automatic_audio_analysis () const {
                return _automatic_audio_analysis;
        }
@@ -431,6 +435,10 @@ public:
                maybe_set (_log_types, t);
        }
 
+       void set_analyse_ebur128 (bool a) {
+               maybe_set (_analyse_ebur128, a);
+       }
+
        void set_automatic_audio_analysis (bool a) {
                maybe_set (_automatic_audio_analysis, a);
        }
@@ -546,6 +554,7 @@ private:
        /** maximum allowed J2K bandwidth in bits per second */
        int _maximum_j2k_bandwidth;
        int _log_types;
+       bool _analyse_ebur128;
        bool _automatic_audio_analysis;
 #ifdef DCPOMATIC_WINDOWS
        bool _win32_console;
index de0ac8176af488e1ac648a1959c624ae93ebaa0b..c0121b8fe4a908d57d866ef21a9b113ff391ed7e 100644 (file)
@@ -194,6 +194,12 @@ private:
                table->Add (_cinemas_file, wxGBPosition (r, 1));
                ++r;
 
+#ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
+               _analyse_ebur128 = new wxCheckBox (_panel, wxID_ANY, _("Find integrated loudness, true peak and loudness range when analysing audio"));
+               table->Add (_analyse_ebur128, wxGBPosition (r, 0), wxGBSpan (1, 2));
+               ++r;
+#endif
+
                _automatic_audio_analysis = new wxCheckBox (_panel, wxID_ANY, _("Automatically analyse content audio"));
                table->Add (_automatic_audio_analysis, wxGBPosition (r, 0), wxGBSpan (1, 2));
                ++r;
@@ -227,6 +233,9 @@ private:
                _num_local_encoding_threads->SetRange (1, 128);
                _num_local_encoding_threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&GeneralPage::num_local_encoding_threads_changed, this));
 
+#ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
+               _analyse_ebur128->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::analyse_ebur128_changed, this));
+#endif
                _automatic_audio_analysis->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::automatic_audio_analysis_changed, this));
                _check_for_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_updates_changed, this));
                _check_for_test_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_test_updates_changed, this));
@@ -270,6 +279,9 @@ private:
                }
 
                checked_set (_num_local_encoding_threads, config->num_local_encoding_threads ());
+#ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
+               checked_set (_analyse_ebur128, config->analyse_ebur128 ());
+#endif
                checked_set (_automatic_audio_analysis, config->automatic_audio_analysis ());
                checked_set (_check_for_updates, config->check_for_updates ());
                checked_set (_check_for_test_updates, config->check_for_test_updates ());
@@ -341,6 +353,13 @@ private:
                }
        }
 
+#ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
+       void analyse_ebur128_changed ()
+       {
+               Config::instance()->set_analyse_ebur128 (_analyse_ebur128->GetValue ());
+       }
+#endif
+
        void automatic_audio_analysis_changed ()
        {
                Config::instance()->set_automatic_audio_analysis (_automatic_audio_analysis->GetValue ());
@@ -380,6 +399,9 @@ private:
        wxChoice* _language;
        wxSpinCtrl* _num_local_encoding_threads;
        FilePickerCtrl* _cinemas_file;
+#ifdef DCPOMATIC_HAVE_PATCHED_FFMPEG
+       wxCheckBox* _analyse_ebur128;
+#endif
        wxCheckBox* _automatic_audio_analysis;
        wxCheckBox* _check_for_updates;
        wxCheckBox* _check_for_test_updates;