X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;fp=src%2Flib%2Futil.cc;h=7089ef2a5d2f1ea74c0a0c8aeac660616e519408;hb=1629bd7df2150156109afbc7a16677cb29e82adf;hp=f604cd10a7830c0e9b0ff69540530233bf2ea926;hpb=f0738a22fc7555c306d49bcd1c356ce210e2c0e2;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index f604cd10a..7089ef2a5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -48,10 +48,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include extern "C" { #include #include @@ -101,7 +102,7 @@ using boost::shared_ptr; using boost::thread; using boost::lexical_cast; using boost::optional; -using libdcp::Size; +using dcp::Size; static boost::thread::id ui_thread; static boost::filesystem::path backtrace_file; @@ -251,7 +252,7 @@ dependency_version_summary () << N_("libswscale ") << ffmpeg_version_to_string (swscale_version()) << N_(", ") << MagickVersion << N_(", ") << N_("libssh ") << ssh_version (0) << N_(", ") - << N_("libdcp ") << libdcp::version << N_(" git ") << libdcp::git_commit; + << N_("libdcp ") << dcp::version << N_(" git ") << dcp::git_commit; return s.str (); } @@ -342,7 +343,8 @@ dcpomatic_setup () set_terminate (terminate); - libdcp::init (); + Pango::init (); + dcp::init (); Ratio::setup_ratios (); DCPContentType::setup_dcp_content_types (); @@ -782,7 +784,7 @@ ensure_ui_thread () * @return Equivalent number of audio frames for `v'. */ int64_t -video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, float frames_per_second) +video_frames_to_audio_frames (VideoFrame v, float audio_sample_rate, float frames_per_second) { return ((int64_t) v * audio_sample_rate / frames_per_second); } @@ -810,7 +812,7 @@ audio_channel_name (int c) return channels[c]; } -FrameRateConversion::FrameRateConversion (float source, int dcp) +FrameRateChange::FrameRateChange (float source, int dcp) : skip (false) , repeat (1) , change_speed (false) @@ -828,7 +830,8 @@ FrameRateConversion::FrameRateConversion (float source, int dcp) repeat = round (dcp / source); } - change_speed = !about_equal (source * factor(), dcp); + speed_up = dcp / (source * factor()); + change_speed = !about_equal (speed_up, 1.0); if (!skip && repeat == 1 && !change_speed) { description = _("Content and DCP have the same rate.\n"); @@ -890,7 +893,7 @@ tidy_for_filename (string f) return t; } -shared_ptr +shared_ptr make_signer () { boost::filesystem::path const sd = Config::instance()->signer_chain_directory (); @@ -910,37 +913,37 @@ make_signer () if (!boost::filesystem::exists (p)) { boost::filesystem::remove_all (sd); boost::filesystem::create_directories (sd); - libdcp::make_signer_chain (sd, openssl_path ()); + dcp::make_signer_chain (sd, openssl_path ()); break; } ++i; } - libdcp::CertificateChain chain; + dcp::CertificateChain chain; { boost::filesystem::path p (sd); p /= "ca.self-signed.pem"; - chain.add (shared_ptr (new libdcp::Certificate (p))); + chain.add (shared_ptr (new dcp::Certificate (p))); } { boost::filesystem::path p (sd); p /= "intermediate.signed.pem"; - chain.add (shared_ptr (new libdcp::Certificate (p))); + chain.add (shared_ptr (new dcp::Certificate (p))); } { boost::filesystem::path p (sd); p /= "leaf.signed.pem"; - chain.add (shared_ptr (new libdcp::Certificate (p))); + chain.add (shared_ptr (new dcp::Certificate (p))); } boost::filesystem::path signer_key (sd); signer_key /= "leaf.key"; - return shared_ptr (new libdcp::Signer (chain, signer_key)); + return shared_ptr (new dcp::Signer (chain, signer_key)); } map @@ -989,14 +992,21 @@ split_get_request (string url) return r; } -libdcp::Size -fit_ratio_within (float ratio, libdcp::Size full_frame) +dcp::Size +fit_ratio_within (float ratio, dcp::Size full_frame) { if (ratio < full_frame.ratio ()) { - return libdcp::Size (rint (full_frame.height * ratio), full_frame.height); + return dcp::Size (rint (full_frame.height * ratio), full_frame.height); } - return libdcp::Size (full_frame.width, rint (full_frame.width / ratio)); + return dcp::Size (full_frame.width, rint (full_frame.width / ratio)); +} + +DCPTime +time_round_up (DCPTime t, DCPTime nearest) +{ + DCPTime const a = t + nearest - 1; + return a - (a % nearest); } void *