*/
-Hints::Hints (weak_ptr<const Film> film)
- : WeakConstFilm (film)
- , _writer (new Writer(film, weak_ptr<Job>(), true))
+Hints::Hints (weak_ptr<const Film> weak_film)
+ : WeakConstFilm (weak_film)
+ , _writer (new Writer(weak_film, weak_ptr<Job>(), true))
+ , _analyser (film(), film()->playlist(), true, [](float) {})
, _stop (false)
{
}
-void
+/** @return true if the loudness could be checked, false if it could not because no analysis was available */
+bool
Hints::check_loudness ()
{
auto path = film()->audio_analysis_path(film()->playlist());
- if (boost::filesystem::exists (path)) {
- try {
- auto an = make_shared<AudioAnalysis>(path);
+ if (!boost::filesystem::exists(path)) {
+ return false;
+ }
- string ch;
+ try {
+ auto an = make_shared<AudioAnalysis>(path);
- auto sample_peak = an->sample_peak ();
- auto true_peak = an->true_peak ();
+ string ch;
- for (size_t i = 0; i < sample_peak.size(); ++i) {
- float const peak = max (sample_peak[i].peak, true_peak.empty() ? 0 : true_peak[i]);
- float const peak_dB = linear_to_db(peak) + an->gain_correction(film()->playlist());
- if (peak_dB > -3) {
- ch += dcp::raw_convert<string> (short_audio_channel_name (i)) + ", ";
- }
+ auto sample_peak = an->sample_peak ();
+ auto true_peak = an->true_peak ();
+
+ for (size_t i = 0; i < sample_peak.size(); ++i) {
+ float const peak = max (sample_peak[i].peak, true_peak.empty() ? 0 : true_peak[i]);
+ float const peak_dB = linear_to_db(peak) + an->gain_correction(film()->playlist());
+ if (peak_dB > -3) {
+ ch += dcp::raw_convert<string>(short_audio_channel_name(i)) + ", ";
}
+ }
- ch = ch.substr (0, ch.length() - 2);
+ ch = ch.substr (0, ch.length() - 2);
- if (!ch.empty ()) {
- hint (String::compose (
- _("Your audio level is very high (on %1). You should reduce the gain of your audio content."),
- ch
- )
- );
- }
- } catch (OldFormatError& e) {
- /* The audio analysis is too old to load in; just skip this hint as if
- it had never been run.
- */
+ if (!ch.empty ()) {
+ hint (String::compose (
+ _("Your audio level is very high (on %1). You should reduce the gain of your audio content."),
+ ch
+ )
+ );
}
+ } catch (OldFormatError& e) {
+ /* The audio analysis is too old to load in */
+ return false;
}
+
+ return true;
}
check_speed_up ();
check_vob ();
check_3d_in_2d ();
- check_loudness ();
+ auto const check_loudness_done = check_loudness ();
check_ffec_and_ffmc_in_smpte_feature ();
check_out_of_range_markers ();
check_text_languages ();
- emit (bind(boost::ref(Progress), _("Examining subtitles and closed captions")));
+ if (check_loudness_done) {
+ emit (bind(boost::ref(Progress), _("Examining subtitles and closed captions")));
+ } else {
+ emit (bind(boost::ref(Progress), _("Examining audio, subtitles and closed captions")));
+ }
auto player = make_shared<Player>(film);
player->set_ignore_video ();
- player->set_ignore_audio ();
+ if (check_loudness_done) {
+ /* We don't need to analyse audio because we already loaded a suitable analysis */
+ player->set_ignore_audio ();
+ }
+ player->Audio.connect (bind(&Hints::audio, this, _1, _2));
player->Text.connect (bind(&Hints::text, this, _1, _2, _3, _4));
struct timeval last_pulse;
store_current ();
}
+ if (!check_loudness_done) {
+ _analyser.finish ();
+ _analyser.get().write(film->audio_analysis_path(film->playlist()));
+ check_loudness ();
+ }
+
_writer->write (player->get_subtitle_fonts());
if (_long_subtitle && !_very_long_subtitle) {
emit(bind(boost::ref(Hint), h));
}
+
+void
+Hints::audio (shared_ptr<AudioBuffers> audio, DCPTime time)
+{
+ _analyser.analyse (audio, time);
+}
+
+
void
Hints::text (PlayerText text, TextType type, optional<DCPTextTrack> track, DCPTimePeriod period)
{
*/
+#include "audio_analyser.h"
#include "signaller.h"
#include "player_text.h"
#include "types.h"
void thread ();
void hint (std::string h);
+ void audio (std::shared_ptr<AudioBuffers> audio, dcpomatic::DCPTime time);
void text (PlayerText text, TextType type, boost::optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period);
void closed_caption (PlayerText text, dcpomatic::DCPTimePeriod period);
void open_subtitle (PlayerText text, dcpomatic::DCPTimePeriod period);
void check_speed_up ();
void check_vob ();
void check_3d_in_2d ();
- void check_loudness ();
+ bool check_loudness ();
void check_ffec_and_ffmc_in_smpte_feature ();
void check_out_of_range_markers ();
void check_text_languages ();
*/
std::shared_ptr<Writer> _writer;
+ AudioAnalyser _analyser;
+
bool _long_ccap = false;
bool _overlap_ccap = false;
bool _too_many_ccap_lines = false;