Merge master.
[dcpomatic.git] / src / lib / util.cc
index b2f8c4470e5af5ee5117489870f4899bd38367bb..418d7b3e0f6123810b2f482df524473d5abe2d55 100644 (file)
@@ -48,6 +48,7 @@
 #include <openssl/md5.h>
 #include <magick/MagickCore.h>
 #include <magick/version.h>
+#include <pangomm/init.h>
 #include <libdcp/version.h>
 #include <libdcp/util.h>
 #include <libdcp/signer_chain.h>
@@ -341,6 +342,7 @@ dcpomatic_setup ()
 
        set_terminate (terminate);
 
+       Pango::init ();
        libdcp::init ();
        
        Ratio::setup_ratios ();
@@ -781,7 +783,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);
 }
@@ -806,7 +808,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)
@@ -824,7 +826,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");
@@ -949,6 +952,13 @@ fit_ratio_within (float ratio, libdcp::Size full_frame)
        return libdcp::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 *
 wrapped_av_malloc (size_t s)
 {
@@ -958,4 +968,3 @@ wrapped_av_malloc (size_t s)
        }
        return p;
 }
-