OSDN Git Service

LinGui: Make preset key/values mostly align with macui presets.
[handbrake-jp/handbrake-jp-git.git] / gtk / src / makedeps.c
1 #include <glib.h>
2 #include <glib-object.h>
3 #include <glib/gstdio.h>
4 #include <string.h>
5 #include "values.h"
6 #include "plist.h"
7
8 typedef struct
9 {
10         const gchar *widget_name;
11         const gchar *dep_name;
12         const gchar *enable_value;
13         const gboolean disable_if_equal;
14 } dependency_t;
15
16 static dependency_t dep_map[] =
17 {
18         {"title", "queue_add", "none", TRUE},
19         {"title", "queue_add_menu", "none", TRUE},
20         {"title", "preview_button", "none", TRUE},
21         {"title", "show_preview_menu", "none", TRUE},
22         {"title", "preview_frame", "none", TRUE},
23         {"title", "picture_label", "none", TRUE},
24         {"title", "picture_tab", "none", TRUE},
25         {"title", "chapters_label", "none", TRUE},
26         {"title", "chapters_tab", "none", TRUE},
27         {"title", "title", "none", TRUE},
28         {"title", "start_chapter", "none", TRUE},
29         {"title", "end_chapter", "none", TRUE},
30         {"vquality_type_bitrate", "VideoAvgBitrate", "TRUE", FALSE},
31         {"vquality_type_target", "VideoTargetSize", "TRUE", FALSE},
32         {"vquality_type_constant", "VideoQualitySlider", "TRUE", FALSE},
33         {"vquality_type_constant", "constant_rate_factor", "TRUE", FALSE},
34         {"vquality_type_constant", "VideoTwoPass", "TRUE", TRUE},
35         {"vquality_type_constant", "VideoTurboTwoPass", "TRUE", TRUE},
36         {"VideoTwoPass", "VideoTurboTwoPass", "TRUE", FALSE},
37         {"FileFormat", "Mp4LargeFile", "mp4|m4v", FALSE},
38         {"FileFormat", "Mp4HttpOptimize", "mp4|m4v", FALSE},
39         {"FileFormat", "Mp4iPodCompatible", "mp4|m4v", FALSE},
40         {"PictureDecomb", "PictureDeinterlace", "TRUE", TRUE},
41         {"PictureDecomb", "tweak_PictureDeinterlace", "TRUE", TRUE},
42         {"PictureAutoCrop", "PictureTopCrop", "FALSE", FALSE},
43         {"PictureAutoCrop", "PictureBottomCrop", "FALSE", FALSE},
44         {"PictureAutoCrop", "PictureLeftCrop", "FALSE", FALSE},
45         {"PictureAutoCrop", "PictureRightCrop", "FALSE", FALSE},
46         {"autoscale", "scale_width", "FALSE", FALSE},
47         {"autoscale", "scale_height", "FALSE", FALSE},
48         {"anamorphic", "PictureKeepRatio", "FALSE", FALSE},
49         {"anamorphic", "scale_height", "FALSE", FALSE},
50         {"PictureKeepRatio", "scale_height", "FALSE", FALSE},
51         {"VideoEncoder", "x264_tab", "x264", FALSE},
52         {"VideoEncoder", "x264_tab_label", "x264", FALSE},
53         {"VideoEncoder", "Mp4iPodCompatible", "x264", FALSE},
54         {"VideoEncoder", "directqp", "x264|ffmpeg", FALSE},
55         {"AudioEncoder", "AudioBitrate", "ac3", TRUE},
56         {"AudioEncoder", "AudioSamplerate", "ac3", TRUE},
57         {"AudioEncoder", "AudioMixdown", "ac3", TRUE},
58         {"AudioEncoder", "AudioTrackDRCSlider", "ac3", TRUE},
59         {"x264_bframes", "x264_weighted_bframes", "0", TRUE},
60         {"x264_bframes", "x264_bpyramid", "<2", TRUE},
61         {"x264_bframes", "x264_direct", "0", TRUE},
62         {"x264_refs", "x264_mixed_refs", "<2", TRUE},
63         {"x264_cabac", "x264_trellis", "TRUE", FALSE},
64         {"x264_me", "x264_merange", "umh|esa", FALSE},
65         {"ChapterMarkers", "chapters_list", "TRUE", FALSE},
66         {"use_source_name", "chapters_in_destination", "TRUE", FALSE},
67 };
68
69 int
70 main(gint argc, gchar *argv[])
71 {
72         gint ii, jj;
73         GValue *top;
74         gint count = sizeof(dep_map) / sizeof(dependency_t);
75
76         g_type_init();
77
78         top = ghb_dict_value_new();
79         for (ii = 0; ii < count; ii++)
80         {
81                 const gchar *name;
82                 GValue *array;
83
84                 name = dep_map[ii].widget_name;
85                 if (ghb_dict_lookup(top, name))
86                         continue;
87                 array = ghb_array_value_new(8);
88                 for (jj = 0; jj < count; jj++)
89                 {
90                         if (strcmp(name, dep_map[jj].widget_name) == 0)
91                         {
92                                 ghb_array_append(array,
93                                         ghb_value_dup(ghb_string_value(dep_map[jj].dep_name)));
94                         }
95                 }
96                 ghb_dict_insert(top, g_strdup(name), array);
97         }
98         ghb_plist_write_file("widget_deps", top);
99
100         // reverse map
101         top = ghb_dict_value_new();
102         for (ii = 0; ii < count; ii++)
103         {
104                 const gchar *name;
105                 GValue *array;
106
107                 name = dep_map[ii].dep_name;
108                 if (ghb_dict_lookup(top, name))
109                         continue;
110                 array = ghb_array_value_new(8);
111                 for (jj = 0; jj < count; jj++)
112                 {
113                         if (strcmp(name, dep_map[jj].dep_name) == 0)
114                         {
115                                 GValue *data;
116                                 data = ghb_array_value_new(3);
117                                 ghb_array_append(data, ghb_value_dup(
118                                         ghb_string_value(dep_map[jj].widget_name)));
119                                 ghb_array_append(data, ghb_value_dup(
120                                         ghb_string_value(dep_map[jj].enable_value)));
121                                 ghb_array_append(data, ghb_value_dup(
122                                         ghb_boolean_value(dep_map[jj].disable_if_equal)));
123                                 ghb_array_append(array, data);
124                         }
125                 }
126                 ghb_dict_insert(top, g_strdup(name), array);
127         }
128         ghb_plist_write_file("widget_reverse_deps", top);
129         return 0;
130 }
131