#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"
, _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);
}
/* XXX: is this right? Especially for more than 5.1? */
- vector<double> channel_corrections(film->audio_channels(), 1);
+ vector<double> channel_corrections(static_cast<size_t>(film->audio_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
channel_corrections,
850, // suggested by leqm_nrt CLI source
64, // suggested by leqm_nrt CLI source
- boost::thread::hardware_concurrency()
+ static_cast<int>(boost::thread::hardware_concurrency())
));
}
void
AnalyseAudioJob::run ()
{
+ LOG_DEBUG_AUDIO_ANALYSIS_NC("AnalyseAudioJob::run");
+
shared_ptr<Player> player (new Player(_film, _playlist));
player->set_ignore_video ();
player->set_ignore_text ();
}
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 (
_analysis->set_leqm (_leqm->leq_m());
_analysis->write (_path);
+ LOG_DEBUG_AUDIO_ANALYSIS_NC("Job finished");
set_progress (1);
set_state (FINISHED_OK);
}
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
}
#endif
- int const frames = b->frames ();
- int const channels = b->channels ();
- vector<double> interleaved(frames * channels);
+ DCPOMATIC_ASSERT (b->frames());
+ DCPOMATIC_ASSERT (b->channels());
+
+ vector<double> interleaved(static_cast<size_t>(b->frames() * b->channels()));
- for (int j = 0; j < channels; ++j) {
+ for (int j = 0; j < b->channels(); ++j) {
float* data = b->data(j);
- for (int i = 0; i < frames; ++i) {
- float s = data[i];
+ for (Frame i = 0; i < b->frames(); ++i) {
+ float s = data[static_cast<size_t>(i)];
- interleaved[i * channels + j] = s;
+ interleaved[static_cast<size_t>(i * b->channels() + j)] = s;
float as = fabsf (s);
if (as < 10e-7) {
_leqm->add(interleaved);
- _done += frames;
+ _done += b->frames();
DCPTime const length = _playlist->length (_film);
set_progress ((time.seconds() - _start.seconds()) / (length.seconds() - _start.seconds()));
+ LOG_DEBUG_AUDIO_ANALYSIS_NC("Frames processed");
}