OSDN Git Service

MacGui: Remove Target Size as a rate control option as it doesn't really work correct...
[handbrake-jp/handbrake-jp-git.git] / gtk / src / presets.c
index 40329de..2e231bf 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
  * presets.c
- * Copyright (C) John Stebbins 2008 <stebbins@stebbins>
+ * Copyright (C) John Stebbins 2008-2011 <stebbins@stebbins>
  * 
  * presets.c is free software.
  * 
@@ -1999,7 +1999,8 @@ static value_map_t acodec_xlat[] =
 {
        {"AAC (faac)", "faac"},
        {"AAC (CoreAudio)", "faac"},
-       {"AC3 Passthru", "ac3"},
+       {"AC3 Passthru", "ac3pass"},
+       {"DTS Passthru", "dtspass"},
        {"MP3 (lame)", "lame"},
        {"Vorbis (vorbis)", "vorbis"},
        {NULL,NULL}
@@ -2642,21 +2643,18 @@ import_xlat_preset(GValue *dict)
        } break;
        }
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
+       // *note: target is no longer used
        switch (vqtype)
        {
        case 0:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(TRUE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
-                                               ghb_boolean_value_new(FALSE));
+                                               ghb_boolean_value_new(TRUE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
                                                ghb_boolean_value_new(FALSE));
        } break;
        case 1:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
                                                ghb_boolean_value_new(TRUE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
@@ -2664,8 +2662,6 @@ import_xlat_preset(GValue *dict)
        } break;
        case 2:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
                                                ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
@@ -2673,16 +2669,87 @@ import_xlat_preset(GValue *dict)
        } break;
        default:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
                                                ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
                                                ghb_boolean_value_new(TRUE));
        } break;
        }
+
        import_value_xlat(dict);
 
+       GValue *mode = ghb_dict_lookup(dict, "VideoFramerateMode");
+       if (mode == NULL)
+       {
+               GValue *fr = ghb_dict_lookup(dict, "VideoFramerate");
+               if (fr)
+               {
+                       gchar *str;
+                       gboolean pfr = FALSE;
+                       GValue *pfr_val = ghb_dict_lookup(dict, "VideoFrameratePFR");
+                       if (pfr_val)
+                       {
+                               pfr = ghb_value_boolean(pfr_val);
+                       }
+                       str = ghb_value_string(fr);
+                       if (strcmp(str, "source") == 0)
+                       {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                       }
+                       else if (!pfr)
+                       {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                       }
+                       else
+                       {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                       }
+            g_free(str);
+               }
+       }
+       else
+       {
+               gchar *str;
+               str = ghb_value_string(mode);
+               if (strcmp(str, "cfr") == 0)
+               {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                               ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+               }
+               else if (strcmp(str, "pfr") == 0)
+               {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+               }
+               else
+               {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+               }
+               g_free(str);
+       }
+
        gdouble vquality;
        const GValue *gval;
 
@@ -2751,12 +2818,10 @@ import_xlat_presets(GValue *presets)
 static void
 export_xlat_preset(GValue *dict)
 {
-       gboolean autoscale, target, br, constant;
+       gboolean autoscale, br, constant;
 
        g_debug("export_xlat_prest ()");
        autoscale = ghb_value_boolean(preset_dict_get_value(dict, "autoscale"));
-       target = ghb_value_boolean(
-                               preset_dict_get_value(dict, "vquality_type_target"));
        br = ghb_value_boolean(
                                preset_dict_get_value(dict, "vquality_type_bitrate"));
        constant = ghb_value_boolean(
@@ -2770,12 +2835,8 @@ export_xlat_preset(GValue *dict)
                                                ghb_int_value_new(1));
 
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
-       if (target)
-       {
-               ghb_dict_insert(dict, g_strdup("VideoQualityType"), 
-                                               ghb_int_value_new(0));
-       }
-       else if (br)
+       // *note: target is no longer used
+       if (br)
        {
                ghb_dict_insert(dict, g_strdup("VideoQualityType"), 
                                                ghb_int_value_new(1));
@@ -2786,6 +2847,22 @@ export_xlat_preset(GValue *dict)
                                                ghb_int_value_new(2));
        }
 
+       if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFramerateCFR")))
+       {
+               ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), 
+                                               ghb_string_value_new("cfr"));
+       }
+       else if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFrameratePFR")))
+       {
+               ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), 
+                                               ghb_string_value_new("pfr"));
+       }
+       else
+       {
+               ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), 
+                                               ghb_string_value_new("vfr"));
+       }
+
        GValue *alist, *adict;
        gint count, ii;
 
@@ -2805,11 +2882,25 @@ export_xlat_preset(GValue *dict)
                }
        }
 
+       GValue *internal;
+       GHashTableIter iter;
+       gchar *key;
+       GValue *value;
+       internal = plist_get_dict(internalPlist, "XlatPresets");
+       ghb_dict_iter_init(&iter, internal);
+       // middle (void*) cast prevents gcc warning "defreferencing type-punned
+       // pointer will break strict-aliasing rules"
+       while (g_hash_table_iter_next(
+                       &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
+       {
+               ghb_dict_remove(dict, key);
+       }
+
+       // remove obsolete keys
        ghb_dict_remove(dict, "UsesMaxPictureSettings");
-       ghb_dict_remove(dict, "autoscale");
-       ghb_dict_remove(dict, "vquality_type_target");
-       ghb_dict_remove(dict, "vquality_type_bitrate");
-       ghb_dict_remove(dict, "vquality_type_constant");
+       ghb_dict_remove(dict, "VFR");
+       ghb_dict_remove(dict, "VideoFrameratePFR");
+
        export_value_xlat(dict);
 }
 
@@ -3157,6 +3248,20 @@ settings_save(signal_user_data_t *ud, const GValue *path)
                                                ghb_boolean_value_new(FALSE));
                presets_list_insert(ud, indices, len);
        }
+       if (!ghb_settings_get_boolean( ud->settings, "PictureWidthEnable"))
+       {
+               ghb_dict_remove(dict, "PictureWidth");
+       }
+       if (!ghb_settings_get_boolean( ud->settings, "PictureHeightEnable"))
+       {
+               ghb_dict_remove(dict, "PictureHeight");
+       }
+       ghb_dict_insert(dict, g_strdup("autoscale"), 
+               ghb_boolean_value_new(
+                       !ghb_settings_get_boolean( ud->settings, "PictureWidthEnable") &&
+                       !ghb_settings_get_boolean( ud->settings, "PictureHeightEnable")
+               )
+       );
        store_presets();
        ud->dont_clear_presets = TRUE;
        // Make the new preset the selected item
@@ -3541,7 +3646,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        const gchar *description = "";
        gint count, *indices, len;
 
-       g_debug("presets_save_clicked_cb ()");
+       g_debug("presets_new_folder_clicked_cb ()");
        preset = ghb_settings_get_value (ud->settings, "preset_selection");
 
        count = ghb_array_len(preset);
@@ -3556,12 +3661,12 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        {
                description = g_value_get_string(
                                                        ghb_dict_lookup(dict, "PresetDescription"));
-               ghb_ui_update(ud, "PresetDescription", ghb_string_value(description));
+               ghb_ui_update(ud, "FolderDescription", ghb_string_value(description));
        }
 
-       desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
-       dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
-       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
+       desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "FolderDescription"));
+       dialog = GHB_WIDGET(ud->builder, "preset_new_folder_dialog");
+       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "FolderName"));
        gtk_entry_set_text(entry, name);
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
@@ -3586,7 +3691,8 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                        }
                }
                ghb_array_append(dest, ghb_string_value_new(name));
-               ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
+               GValue *val = ghb_widget_value(GTK_WIDGET(desc));
+               ghb_settings_set_value(ud->settings, "PresetDescription", val);
                folder_save(ud, dest);
                ghb_value_free(dest);
        }
@@ -3615,6 +3721,23 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                count = 1;
 
        desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
+       int width = ghb_settings_get_int(ud->settings, "PictureWidth");
+       int height = ghb_settings_get_int(ud->settings, "PictureHeight");
+       gboolean autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
+       ghb_ui_update(ud, "PictureWidthEnable", 
+               ghb_boolean_value(width!=0&&!autoscale));
+       ghb_ui_update(ud, "PictureHeightEnable", 
+               ghb_boolean_value(height!=0&&!autoscale));
+       if (!width)
+       {
+               width = ghb_settings_get_int(ud->settings, "scale_width");
+               ghb_ui_update(ud, "PictureWidth", ghb_int_value(width));
+       }
+       if (!height)
+       {
+               height = ghb_settings_get_int(ud->settings, "scale_height");
+               ghb_ui_update(ud, "PictureHeight", ghb_int_value(height));
+       }
        dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
        entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
        gtk_entry_set_text(entry, name);