void
dvdomatic_setup ()
{
- bindtextdomain ("libdvdomatic", LOCALE_PREFIX);
- setlocale (LC_ALL, "");
-
avfilter_register_all ();
Format::setup_formats ();
ui_thread = this_thread::get_id ();
}
+#ifdef DVDOMATIC_WINDOWS
+boost::filesystem::path
+mo_path ()
+{
+ wchar_t buffer[512];
+ GetModuleFileName (0, buffer, 512 * sizeof(wchar_t));
+ boost::filesystem::path p (buffer);
+ p = p.parent_path ();
+ p = p.parent_path ();
+ p /= "locale";
+ return p;
+}
+#endif
+
+void
+dvdomatic_setup_i18n (string lang)
+{
+ setlocale (LC_ALL, "");
+ textdomain ("libdvdomatic");
+
+#ifdef DVDOMATIC_WINDOWS
+ string const e = "LANGUAGE=" + lang;
+ putenv (e.c_str());
+
+ bindtextdomain ("libdvdomatic", mo_path().string().c_str());
+#else
+ /* Hack to silence warning */
+ lang.clear ();
+#endif
+
+#ifdef DVDOMATIC_POSIX
+ bindtextdomain ("libdvdomatic", POSIX_LOCALE_PREFIX);
+#endif
+}
+
/** @param start Start position for the crop within the image.
* @param size Size of the cropped area.
* @return FFmpeg crop filter string.
, dcp (dcp_)
{}
- bool skip () const {
- return !about_equal (source, dcp) && source > dcp;
- }
-
- bool repeat () const {
- return !about_equal (source, dcp) && source < dcp;
- }
-
float source;
int dcp;
};
-/** @param fps Arbitrary source frames-per-second value */
-/** XXX: this could be slow-ish */
-DCPFrameRate::DCPFrameRate (float source_fps)
+int
+best_dcp_frame_rate (float source_fps)
{
list<int> const allowed_dcp_frame_rates = Config::instance()->allowed_dcp_frame_rates ();
++i;
}
- if (!best) {
- throw EncodeError (_("cannot find a suitable DCP frame rate for this source"));
- }
-
- frames_per_second = best->dcp;
- skip = best->skip ();
- repeat = best->repeat ();
- change_speed = !about_equal (source_fps * factor(), frames_per_second);
+ assert (best);
+ return best->dcp;
}
/** @param An arbitrary sampling rate.
return _source_channels;
}
+
+FrameRateConversion::FrameRateConversion (float source, int dcp)
+ : skip (false)
+ , repeat (false)
+ , change_speed (false)
+{
+ if (fabs (source / 2.0 - dcp) < (fabs (source - dcp))) {
+ skip = true;
+ } else if (fabs (source * 2 - dcp) < fabs (source - dcp)) {
+ repeat = true;
+ }
+
+ change_speed = !about_equal (source * factor(), dcp);
+
+ if (!skip && !repeat && !change_speed) {
+ description = _("DCP and source have the same rate.\n");
+ } else {
+ if (skip) {
+ description = _("DCP will use every other frame of the source.\n");
+ } else if (repeat) {
+ description = _("Each source frame will be doubled in the DCP.\n");
+ }
+
+ if (change_speed) {
+ float const pc = dcp * 100 / (source * factor());
+ description += String::compose (_("DCP will run at %1%% of the source speed."), pc);
+ }
+ }
+}