}
};
- 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
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,
#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) {
Frame _samples_per_point = 1;
boost::scoped_ptr<leqm_nrt::Calculator> _leqm;
+ int _leqm_channels = 0;
Frame _done = 0;
std::vector<float> _sample_peak;
std::vector<Frame> _sample_peak_frame;
#include "lib/audio_analysis.h"
#include "lib/audio_content.h"
#include "lib/content_factory.h"
+#include "lib/dcp_content.h"
#include "lib/dcp_content_type.h"
#include "lib/ffmpeg_content.h"
#include "lib/ffmpeg_content.h"
}
+BOOST_AUTO_TEST_CASE(analyse_audio_leqm_same_with_empty_channels)
+{
+ auto dcp = make_shared<DCPContent>(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV");
+ auto film = new_test_film2("analyse_audio_leqm_test2", { dcp });
+ film->set_audio_channels(8);
+
+ auto analyse = [film, dcp](int channels) {
+ film->set_audio_channels(channels);
+ auto playlist = make_shared<Playlist>();
+ playlist->add(film, dcp);
+ boost::signals2::connection c;
+ JobManager::instance()->analyse_audio(film, playlist, false, c, [](Job::Result) {});
+ BOOST_CHECK(!wait_for_jobs());
+ AudioAnalysis analysis(film->audio_analysis_path(playlist));
+ return analysis.leqm().get_value_or(0);
+ };
+
+ BOOST_CHECK_CLOSE(analyse( 6), 84.51411, 0.001);
+ BOOST_CHECK_CLOSE(analyse( 8), 84.51411, 0.001);
+ BOOST_CHECK_CLOSE(analyse(16), 84.51411, 0.001);
+}
+
+
/** Bug #2364; a file with a lot of silent video at the end (about 50s worth)
* crashed the audio analysis with an OOM on Windows.
*/