X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=64550556b39bd3d27104468a1573f7ab8b7fd6a7;hb=a2111c9816c9597e6f121010e6f4f34797abb0c7;hp=6b3625d9e727d34faec4effa67da7304aa1d832f;hpb=3828baf56467224f5d44049bf1e7a7ed11f43a05;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index 6b3625d9e..64550556b 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -42,7 +42,7 @@ #include "environment_info.h" #include "raw_convert.h" #include "audio_processor.h" -#include "md5_digester.h" +#include "digester.h" #include "compose.hpp" #include "screen.h" #include "audio_content.h" @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -108,8 +109,13 @@ using boost::is_any_of; * * 32 -> 33 * Changed to in FFmpegSubtitleStream + * 33 -> 34 + * Content only contains audio/subtitle-related tags if those things + * are present. + * 34 -> 35 + * VideoFrameType in VideoContent is a string rather than an integer. */ -int const Film::current_state_version = 33; +int const Film::current_state_version = 35; /** Construct a Film object in a given directory. * @@ -244,7 +250,7 @@ Film::audio_analysis_path (shared_ptr playlist) const { boost::filesystem::path p = dir ("analysis"); - MD5Digester digester; + Digester digester; BOOST_FOREACH (shared_ptr i, playlist->content ()) { if (!i->audio) { continue; @@ -1287,18 +1293,44 @@ Film::subtitle_language () const /** Change the gains of the supplied AudioMapping to make it a default * for this film. The defaults are guessed based on what processor (if any) - * is in use and the number of input channels. + * is in use, the number of input channels and any filename supplied. */ void -Film::make_audio_mapping_default (AudioMapping& mapping) const +Film::make_audio_mapping_default (AudioMapping& mapping, optional filename) const { + static string const regex[] = { + ".*[\\._-]L[\\._-].*", + ".*[\\._-]R[\\._-].*", + ".*[\\._-]C[\\._-].*", + ".*[\\._-]Lfe[\\._-].*", + ".*[\\._-]Ls[\\._-].*", + ".*[\\._-]Rs[\\._-].*" + }; + + static int const regexes = sizeof(regex) / sizeof(*regex); + if (audio_processor ()) { audio_processor()->make_audio_mapping_default (mapping); } else { mapping.make_zero (); if (mapping.input_channels() == 1) { - /* Mono -> Centre */ - mapping.set (0, static_cast (dcp::CENTRE), 1); + bool guessed = false; + + /* See if we can guess where this stream should go */ + if (filename) { + for (int i = 0; i < regexes; ++i) { + boost::regex e (regex[i], boost::regex::icase); + if (boost::regex_match (filename->string(), e) && i < mapping.output_channels()) { + mapping.set (0, i, 1); + guessed = true; + } + } + } + + if (!guessed) { + /* If we have no idea, just put it on centre */ + mapping.set (0, static_cast (dcp::CENTRE), 1); + } } else { /* 1:1 mapping */ for (int i = 0; i < min (mapping.input_channels(), mapping.output_channels()); ++i) {