Cleanup: remove an unnecessary shared_ptr.
[dcpomatic.git] / src / lib / audio_analyser.cc
index e4dfc6bdeeea6744adee49a3e07534f5b71c9d43..5f8f88c5adfaa96cb63088819bd31549b82f92e0 100644 (file)
@@ -30,7 +30,6 @@
 #include "film.h"
 #include "filter.h"
 #include "playlist.h"
-#include "types.h"
 #include <dcp/warnings.h>
 extern "C" {
 #include <leqm_nrt.h>
@@ -58,7 +57,7 @@ AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Play
        , _playlist (playlist)
        , _set_progress (set_progress)
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
-       , _ebur128 (new AudioFilterGraph(film->audio_frame_rate(), film->audio_channels()))
+       , _ebur128(film->audio_frame_rate(), film->audio_channels())
 #endif
        , _sample_peak (film->audio_channels())
        , _sample_peak_frame (film->audio_channels())
@@ -67,7 +66,7 @@ AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Play
 
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
        _filters.push_back (new Filter("ebur128", "ebur128", "audio", "ebur128=peak=true"));
-       _ebur128->setup (_filters);
+       _ebur128.setup(_filters);
 #endif
 
        _current = std::vector<AudioPoint>(_film->audio_channels());
@@ -87,14 +86,14 @@ AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Play
                }
        };
 
-       int leqm_channels = film->audio_channels();
+       _leqm_channels = film->audio_channels();
        auto content = _playlist->content();
        if (content.size() == 1 && content[0]->audio) {
-               leqm_channels = content[0]->audio->mapping().mapped_output_channels().size();
+               _leqm_channels = content[0]->audio->mapping().mapped_output_channels().size();
        }
 
        /* XXX: is this right?  Especially for more than 5.1? */
-       vector<double> channel_corrections(leqm_channels, 1);
+       vector<double> channel_corrections(_leqm_channels, 1);
        add_if_required (channel_corrections,  4,   -3); // Ls
        add_if_required (channel_corrections,  5,   -3); // Rs
        add_if_required (channel_corrections,  6, -144); // HI
@@ -109,7 +108,7 @@ AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Play
        add_if_required (channel_corrections, 15, -144); // Unused
 
        _leqm.reset(new leqm_nrt::Calculator(
-               leqm_channels,
+               _leqm_channels,
                film->audio_frame_rate(),
                24,
                channel_corrections,
@@ -136,7 +135,7 @@ AudioAnalyser::~AudioAnalyser ()
 void
 AudioAnalyser::analyse (shared_ptr<AudioBuffers> b, DCPTime time)
 {
-       LOG_DEBUG_AUDIO_ANALYSIS("Received %1 frames at %2", b->frames(), to_string(time));
+       LOG_DEBUG_AUDIO_ANALYSIS("AudioAnalyser received %1 frames at %2", b->frames(), to_string(time));
        DCPOMATIC_ASSERT (time >= _start);
        /* In bug #2364 we had a lot of frames arriving here (~47s worth) which
         * caused an OOM error on Windows.  Check for the number of frames being
@@ -146,20 +145,19 @@ AudioAnalyser::analyse (shared_ptr<AudioBuffers> b, DCPTime time)
 
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
        if (Config::instance()->analyse_ebur128 ()) {
-               _ebur128->process (b);
+               _ebur128.process(b);
        }
 #endif
 
        int const frames = b->frames ();
-       int const channels = b->channels ();
-       vector<double> interleaved(frames * channels);
+       vector<double> interleaved(frames * _leqm_channels);
 
-       for (int j = 0; j < channels; ++j) {
+       for (int j = 0; j < _leqm_channels; ++j) {
                float const* data = b->data(j);
                for (int i = 0; i < frames; ++i) {
                        float s = data[i];
 
-                       interleaved[i * channels + j] = s;
+                       interleaved[i * _leqm_channels + j] = s;
 
                        float as = fabsf (s);
                        if (as < 10e-7) {
@@ -206,7 +204,7 @@ AudioAnalyser::finish ()
 
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
        if (Config::instance()->analyse_ebur128 ()) {
-               void* eb = _ebur128->get("Parsed_ebur128_0")->priv;
+               void* eb = _ebur128.get("Parsed_ebur128_0")->priv;
                vector<float> true_peak;
                for (int i = 0; i < _film->audio_channels(); ++i) {
                        true_peak.push_back (av_ebur128_get_true_peaks(eb)[i]);