Hand-apply 63b62aa703c2628b27b577114081b265f237dadb from master;
[dcpomatic.git] / src / lib / util.cc
index 728e7d048199f08652329b078e214039e244bbc1..bf4c7424417e92dde0de6a1127415a72fe061ee5 100644 (file)
@@ -156,10 +156,10 @@ seconds_to_approximate_hms (int s)
 
        if (hours) {
                if (m > 30 && !minutes) {
-                       /* TRANSLATORS: h here is an abbreviation for hours */
+                       /// TRANSLATORS: h here is an abbreviation for hours
                        ap << (h + 1) << _("h");
                } else {
-                       /* TRANSLATORS: h here is an abbreviation for hours */
+                       /// TRANSLATORS: h here is an abbreviation for hours
                        ap << h << _("h");
                }
 
@@ -171,10 +171,10 @@ seconds_to_approximate_hms (int s)
        if (minutes) {
                /* Minutes */
                if (s > 30 && !seconds) {
-                       /* TRANSLATORS: m here is an abbreviation for minutes */
+                       /// TRANSLATORS: m here is an abbreviation for minutes
                        ap << (m + 1) << _("m");
                } else {
-                       /* TRANSLATORS: m here is an abbreviation for minutes */
+                       /// TRANSLATORS: m here is an abbreviation for minutes
                        ap << m << _("m");
                }
 
@@ -185,7 +185,7 @@ seconds_to_approximate_hms (int s)
 
        if (seconds) {
                /* Seconds */
-               /* TRANSLATORS: s here is an abbreviation for seconds */
+               /// TRANSLATORS: s here is an abbreviation for seconds
                ap << s << _("s");
        }
 
@@ -282,6 +282,12 @@ LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *)
 }
 #endif
 
+void
+set_backtrace_file (boost::filesystem::path p)
+{
+       backtrace_file = p;
+}
+
 /* From http://stackoverflow.com/questions/2443135/how-do-i-find-where-an-exception-was-thrown-in-c */
 void
 terminate ()
@@ -317,8 +323,9 @@ void
 dcpomatic_setup ()
 {
 #ifdef DCPOMATIC_WINDOWS
-       backtrace_file /= g_get_user_config_dir ();
-       backtrace_file /= "backtrace.txt";
+       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
@@ -760,10 +767,9 @@ audio_channel_name (int c)
 {
        assert (MAX_DCP_AUDIO_CHANNELS == 12);
 
-       /* TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency
-          enhancement channel (sub-woofer).  HI is the hearing-impaired audio track and
-          VI is the visually-impaired audio track (audio describe).
-       */
+       /// TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency
+       /// enhancement channel (sub-woofer).  HI is the hearing-impaired audio track and
+       /// VI is the visually-impaired audio track (audio describe).
        string const channels[] = {
                _("Left"),
                _("Right"),
@@ -787,7 +793,19 @@ valid_image_file (boost::filesystem::path f)
 {
        string ext = f.extension().string();
        transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-       return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" || ext == ".tga" || ext == ".dpx");
+       return (
+               ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" ||
+               ext == ".png" || ext == ".bmp" || ext == ".tga" || ext == ".dpx" ||
+               ext == ".j2c" || ext == ".j2k"
+               );
+}
+
+bool
+valid_j2k_file (boost::filesystem::path f)
+{
+       string ext = f.extension().string();
+       transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
+       return (ext == ".j2k" || ext == ".j2c");
 }
 
 string