BOOST_FOREACH.
[dcpomatic.git] / src / lib / analyse_audio_job.cc
index ead36bca1e031ccc1c1eb3e25db8b826d40d270f..c94e0b91ff715ebeadc6e9b162cdf29b0800a8a6 100644 (file)
@@ -23,6 +23,7 @@
 #include "analyse_audio_job.h"
 #include "audio_content.h"
 #include "compose.hpp"
+#include "dcpomatic_log.h"
 #include "film.h"
 #include "player.h"
 #include "playlist.h"
@@ -36,7 +37,6 @@ extern "C" {
 #include <libavfilter/f_ebur128.h>
 #endif
 }
-#include <boost/foreach.hpp>
 #include <iostream>
 
 #include "i18n.h"
@@ -46,9 +46,12 @@ using std::vector;
 using std::max;
 using std::min;
 using std::cout;
-using boost::shared_ptr;
-using boost::dynamic_pointer_cast;
+using std::shared_ptr;
+using std::dynamic_pointer_cast;
 using namespace dcpomatic;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 
 int const AnalyseAudioJob::_num_points = 1024;
 
@@ -74,6 +77,8 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
        , _ebur128 (new AudioFilterGraph (film->audio_frame_rate(), film->audio_channels()))
 #endif
 {
+       LOG_DEBUG_AUDIO_ANALYSIS_NC("AnalyseAudioJob::AnalyseAudioJob");
+
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
        _filters.push_back (new Filter ("ebur128", "ebur128", "audio", "ebur128=peak=true"));
        _ebur128->setup (_filters);
@@ -117,7 +122,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
 AnalyseAudioJob::~AnalyseAudioJob ()
 {
        stop_thread ();
-       BOOST_FOREACH (Filter const * i, _filters) {
+       for (auto i: _filters) {
                delete const_cast<Filter*> (i);
        }
        delete[] _current;
@@ -140,7 +145,9 @@ AnalyseAudioJob::json_name () const
 void
 AnalyseAudioJob::run ()
 {
-       shared_ptr<Player> player (new Player(_film, _playlist, _playlist->length(_film)));
+       LOG_DEBUG_AUDIO_ANALYSIS_NC("AnalyseAudioJob::run");
+
+       shared_ptr<Player> player (new Player(_film, _playlist));
        player->set_ignore_video ();
        player->set_ignore_text ();
        player->set_fast ();
@@ -157,18 +164,22 @@ AnalyseAudioJob::run ()
        _analysis.reset (new AudioAnalysis (_film->audio_channels ()));
 
        bool has_any_audio = false;
-       BOOST_FOREACH (shared_ptr<Content> c, _playlist->content ()) {
+       for (auto c: _playlist->content()) {
                if (c->audio) {
                        has_any_audio = true;
                }
        }
 
        if (has_any_audio) {
+               LOG_DEBUG_AUDIO_ANALYSIS("Seeking to %1", to_string(_start));
                player->seek (_start, true);
                _done = 0;
+               LOG_DEBUG_AUDIO_ANALYSIS("Starting loop for playlist of length %1", to_string(length));
                while (!player->pass ()) {}
        }
 
+       LOG_DEBUG_AUDIO_ANALYSIS_NC("Loop complete");
+
        vector<AudioAnalysis::PeakTime> sample_peak;
        for (int i = 0; i < _film->audio_channels(); ++i) {
                sample_peak.push_back (
@@ -205,6 +216,7 @@ AnalyseAudioJob::run ()
        _analysis->set_leqm (_leqm->leq_m());
        _analysis->write (_path);
 
+       LOG_DEBUG_AUDIO_ANALYSIS_NC("Job finished");
        set_progress (1);
        set_state (FINISHED_OK);
 }
@@ -212,6 +224,7 @@ AnalyseAudioJob::run ()
 void
 AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b, DCPTime time)
 {
+       LOG_DEBUG_AUDIO_ANALYSIS("Received %1 frames at %2", b->frames(), to_string(time));
        DCPOMATIC_ASSERT (time >= _start);
 
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
@@ -259,4 +272,5 @@ AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b, DCPTime time)
 
        DCPTime const length = _playlist->length (_film);
        set_progress ((time.seconds() - _start.seconds()) / (length.seconds() - _start.seconds()));
+       LOG_DEBUG_AUDIO_ANALYSIS_NC("Frames processed");
 }