Logging improvements to allow prettier displays in the server GUI.
[dcpomatic.git] / src / lib / util.cc
index dad094b6ee750e76d6697dd7663f865572f1b0d3..77d66d07763f967cc436bb14883604f9dd4b2621 100644 (file)
 #include "md5_digester.h"
 #include "audio_processor.h"
 #include "safe_stringstream.h"
+#include "compose.hpp"
 #include <dcp/util.h>
-#include <dcp/signer.h>
 #include <dcp/picture_asset.h>
 #include <dcp/sound_asset.h>
 #include <dcp/subtitle_asset.h>
+extern "C" {
+#include <libavfilter/avfilter.h>
+#include <libavcodec/avcodec.h>
+}
 #include <curl/curl.h>
 #include <glib.h>
 #include <pangomm/init.h>
 #include <boost/algorithm/string.hpp>
-#include <boost/bind.hpp>
-#include <boost/lambda/lambda.hpp>
 #include <boost/thread.hpp>
 #include <boost/filesystem.hpp>
 #ifdef DCPOMATIC_WINDOWS
@@ -281,18 +283,10 @@ terminate ()
        abort();
 }
 
-/** Call the required functions to set up DCP-o-matic's static arrays, etc.
- *  Must be called from the UI thread, if there is one.
- */
 void
-dcpomatic_setup ()
+dcpomatic_setup_path_encoding ()
 {
 #ifdef DCPOMATIC_WINDOWS
-       boost::filesystem::path p = g_get_user_config_dir ();
-       p /= "backtrace.txt";
-       set_backtrace_file (p);
-       SetUnhandledExceptionFilter(exception_handler);
-
        /* Dark voodoo which, I think, gets boost::filesystem::path to
           correctly convert UTF-8 strings to paths, and also paths
           back to UTF-8 strings (on path::string()).
@@ -308,6 +302,20 @@ dcpomatic_setup ()
        std::locale::global (boost::locale::generator().generate (""));
        boost::filesystem::path::imbue (std::locale ());
 #endif
+}
+
+/** Call the required functions to set up DCP-o-matic's static arrays, etc.
+ *  Must be called from the UI thread, if there is one.
+ */
+void
+dcpomatic_setup ()
+{
+#ifdef DCPOMATIC_WINDOWS
+       boost::filesystem::path p = g_get_user_config_dir ();
+       p /= "backtrace.txt";
+       set_backtrace_file (p);
+       SetUnhandledExceptionFilter(exception_handler);
+#endif
 
        avfilter_register_all ();
 
@@ -532,10 +540,10 @@ dcp::Size
 fit_ratio_within (float ratio, dcp::Size full_frame)
 {
        if (ratio < full_frame.ratio ()) {
-               return dcp::Size (rint (full_frame.height * ratio), full_frame.height);
+               return dcp::Size (lrintf (full_frame.height * ratio), full_frame.height);
        }
 
-       return dcp::Size (full_frame.width, rint (full_frame.width / ratio));
+       return dcp::Size (full_frame.width, lrintf (full_frame.width / ratio));
 }
 
 void *
@@ -548,22 +556,6 @@ wrapped_av_malloc (size_t s)
        return p;
 }
 
-FFmpegSubtitlePeriod
-subtitle_period (AVSubtitle const & sub)
-{
-       ContentTime const packet_time = ContentTime::from_seconds (static_cast<double> (sub.pts) / AV_TIME_BASE);
-
-       if (sub.end_display_time == static_cast<uint32_t> (-1)) {
-               /* End time is not known */
-               return FFmpegSubtitlePeriod (packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3));
-       }
-
-       return FFmpegSubtitlePeriod (
-               packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3),
-               packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3)
-               );
-}
-
 map<string, string>
 split_get_request (string url)
 {