Add an assert.
[dcpomatic.git] / src / lib / audio_analyser.cc
index 5f8f88c5adfaa96cb63088819bd31549b82f92e0..df76932dedb36ebad107754c6baf3f2a1fa4cd39 100644 (file)
@@ -65,7 +65,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"));
+       _filters.push_back({"ebur128", "ebur128", "audio", "ebur128=peak=true"});
        _ebur128.setup(_filters);
 #endif
 
@@ -86,10 +86,18 @@ AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Play
                }
        };
 
-       _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 = 0;
+               for (auto channel: content[0]->audio->mapping().mapped_output_channels()) {
+                       /* This means that if, for example, a file only maps C we will
+                        * calculate LEQ(m) for L, R and C.  I'm not sure if this is
+                        * right or not.
+                        */
+                       _leqm_channels = std::min(film->audio_channels(), channel + 1);
+               }
+       } else {
+               _leqm_channels = film->audio_channels();
        }
 
        /* XXX: is this right?  Especially for more than 5.1? */
@@ -124,14 +132,6 @@ AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Play
 }
 
 
-AudioAnalyser::~AudioAnalyser ()
-{
-       for (auto i: _filters) {
-               delete const_cast<Filter*> (i);
-       }
-}
-
-
 void
 AudioAnalyser::analyse (shared_ptr<AudioBuffers> b, DCPTime time)
 {