OSDN Git Service

LinGui: first cut at anamorphic picture settings enhancements
[handbrake-jp/handbrake-jp-git.git] / gtk / src / presets.c
index aafff05..fb4bfc2 100644 (file)
@@ -43,6 +43,7 @@ static gboolean prefs_modified = FALSE;
 static const GValue* preset_dict_get_value(GValue *dict, const gchar *key);
 static void store_plist(GValue *plist, const gchar *name);
 static void store_presets(void);
+static void store_prefs(void);
 
 // This only handle limited depth
 GtkTreePath*
@@ -1196,7 +1197,7 @@ ghb_prefs_save(GValue *settings)
                        ghb_dict_insert(pref_dict, g_strdup(key), ghb_value_dup(value));
            }
        }
-    store_plist(prefsPlist, "preferences");
+       store_prefs();
        prefs_modified = FALSE;
 }
 
@@ -1216,7 +1217,7 @@ ghb_pref_set(GValue *settings, const gchar *key)
                if (ghb_value_cmp(value, value2) != 0)
                {
                        ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
-                       store_plist(prefsPlist, "preferences");
+                       store_prefs();
                        prefs_modified = TRUE;
                }
        }
@@ -1238,7 +1239,7 @@ ghb_pref_save(GValue *settings, const gchar *key)
                if (ghb_value_cmp(value, value2) != 0)
                {
                        ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
-                       store_plist(prefsPlist, "preferences");
+                       store_prefs();
                        prefs_modified = FALSE;
                }
        }
@@ -1249,7 +1250,7 @@ ghb_prefs_store(void)
 {
        if (prefs_modified)
        {
-               store_plist(prefsPlist, "preferences");
+               store_prefs();
                prefs_modified = FALSE;
        }
 }
@@ -1350,7 +1351,7 @@ ghb_prefs_load(signal_user_data_t *ud)
                }
                ghb_dict_insert(dict, 
                        g_strdup("destination_dir"), ghb_value_dup(ghb_string_value(dir)));
-               store_plist(prefsPlist, "preferences");
+               store_prefs();
     }
        // Read legacy default_preset preference and update accordingly
        path = ghb_dict_lookup(dict, "default_preset");
@@ -1376,7 +1377,7 @@ ghb_prefs_load(signal_user_data_t *ud)
                        g_free(indices);
                }
                ghb_dict_remove(dict, "default_preset");
-               store_plist(prefsPlist, "preferences");
+               store_prefs();
        }
 }
 
@@ -1690,7 +1691,7 @@ typedef struct
 static value_map_t vcodec_xlat[] =
 {
        {"MPEG-4 (FFmpeg)", "ffmpeg"},
-       {"MPEG-4 (XviD)", "xvid"},
+       {"MPEG-4 (XviD)", "ffmpeg"},
        {"H.264 (x264)", "x264"},
        {"VP3 (Theora)", "theora"},
        {NULL,NULL}
@@ -1710,8 +1711,8 @@ value_map_t container_xlat[] =
        {"MP4 file", "mp4"},
        {"M4V file", "m4v"},
        {"MKV file", "mkv"},
-       {"AVI file", "avi"},
-       {"OGM file", "ogm"},
+       {"AVI file", "mkv"},
+       {"OGM file", "mkv"},
        {NULL, NULL}
 };
 
@@ -2202,32 +2203,26 @@ import_xlat_preset(GValue *dict)
        {
        case 0:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(FALSE));
-               if (ghb_dict_lookup(dict, "ModDimensions") == NULL)
-                       ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                                       ghb_boolean_value_new(TRUE));
+               if (ghb_dict_lookup(dict, "PictureAlignment") == NULL)
+                       ghb_dict_insert(dict, g_strdup("PictureAlignment"), 
+                                                       ghb_int_value_new(16));
        } break;
        case 1:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(TRUE));
-               ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                               ghb_boolean_value_new(FALSE));
+               ghb_dict_insert(dict, g_strdup("PictureAlignment"), 
+                                               ghb_int_value_new(1));
        } break;
        case 2:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(TRUE));
-               ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                               ghb_boolean_value_new(TRUE));
+               if (ghb_dict_lookup(dict, "PictureAlignment") == NULL)
+                       ghb_dict_insert(dict, g_strdup("PictureAlignment"), 
+                                                       ghb_int_value_new(16));
        } break;
        default:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(TRUE));
-               ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                               ghb_boolean_value_new(TRUE));
+               if (ghb_dict_lookup(dict, "PictureAlignment") == NULL)
+                       ghb_dict_insert(dict, g_strdup("PictureAlignment"), 
+                                                       ghb_int_value_new(16));
        } break;
        }
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
@@ -2341,12 +2336,10 @@ import_xlat_presets(GValue *presets)
 static void
 export_xlat_preset(GValue *dict)
 {
-       gboolean ana, round, autoscale, target, br, constant;
+       gboolean autoscale, target, br, constant;
 
        g_debug("export_xlat_prest ()");
        autoscale = ghb_value_boolean(preset_dict_get_value(dict, "autoscale"));
-       ana = ghb_value_boolean(preset_dict_get_value(dict, "anamorphic"));
-       round = ghb_value_boolean(preset_dict_get_value(dict, "ModDimensions"));
        target = ghb_value_boolean(
                                preset_dict_get_value(dict, "vquality_type_target"));
        br = ghb_value_boolean(
@@ -2361,20 +2354,6 @@ export_xlat_preset(GValue *dict)
                ghb_dict_insert(dict, g_strdup("UsesPictureSettings"), 
                                                ghb_int_value_new(1));
 
-       if (ana)
-       {
-               if (round)
-                       ghb_dict_insert(dict, g_strdup("PicturePAR"), 
-                                               ghb_int_value_new(2));
-               else
-                       ghb_dict_insert(dict, g_strdup("PicturePAR"), 
-                                               ghb_int_value_new(1));
-       }
-       else
-       {
-               ghb_dict_insert(dict, g_strdup("PicturePAR"), 
-                                               ghb_int_value_new(0));
-       }
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
        if (target)
        {
@@ -2393,7 +2372,6 @@ export_xlat_preset(GValue *dict)
        }
        ghb_dict_remove(dict, "UsesMaxPictureSettings");
        ghb_dict_remove(dict, "autoscale");
-       ghb_dict_remove(dict, "anamorphic");
        ghb_dict_remove(dict, "vquality_type_target");
        ghb_dict_remove(dict, "vquality_type_bitrate");
        ghb_dict_remove(dict, "vquality_type_constant");
@@ -2427,6 +2405,16 @@ export_xlat_presets(GValue *presets)
        }
 }
 
+static guint prefs_timeout_id = 0;
+
+static gboolean
+delayed_store_prefs(gpointer data)
+{
+       store_plist(prefsPlist, "preferences");
+       prefs_timeout_id = 0;
+       return FALSE;
+}
+
 static void
 store_presets()
 {
@@ -2438,6 +2426,22 @@ store_presets()
        ghb_value_free(export);
 }
 
+static void
+store_prefs(void)
+{
+       if (prefs_timeout_id != 0)
+       {
+               GMainContext *mc;
+               GSource *source;
+
+               mc = g_main_context_default();
+               source = g_main_context_find_source_by_id(mc, prefs_timeout_id);
+               if (source != NULL)
+                       g_source_destroy(source);
+       }
+       prefs_timeout_id = g_timeout_add_seconds(1, (GSourceFunc)delayed_store_prefs, NULL);
+}
+
 void
 ghb_presets_reload(signal_user_data_t *ud)
 {
@@ -3262,10 +3266,11 @@ preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        ghb_ui_update(ud, "scale_width", 
                        ghb_int64_value(tinfo->width - tinfo->crop[2] - tinfo->crop[3]));
        // If anamorphic or keep_aspect, the hight will be automatically calculated
-       gboolean keep_aspect, anamorphic;
+       gboolean keep_aspect;
+       gint pic_par;
        keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio");
-       anamorphic = ghb_settings_get_boolean(ud->settings, "anamorphic");
-       if (!(keep_aspect || anamorphic))
+       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
+       if (!(keep_aspect || pic_par) || pic_par == 3)
        {
                ghb_ui_update(ud, "scale_height", 
                        ghb_int64_value(tinfo->height - tinfo->crop[0] - tinfo->crop[1]));