OSDN Git Service

26bf0fbec074fb6011f4a5bb2d07da0d0e37b1d7
[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         const gboolean hide;
15 } dependency_t;
16
17 static dependency_t dep_map[] =
18 {
19         {"title", "queue_add", "none", TRUE, FALSE},
20         {"title", "queue_add_menu", "none", TRUE, FALSE},
21         {"title", "show_picture", "none", TRUE, FALSE},
22         {"title", "show_preview_menu", "none", TRUE, FALSE},
23         {"title", "preview_frame", "none", TRUE, FALSE},
24         {"title", "picture_label", "none", TRUE, FALSE},
25         {"title", "picture_tab", "none", TRUE, FALSE},
26         {"title", "chapters_label", "none", TRUE, FALSE},
27         {"title", "chapters_tab", "none", TRUE, FALSE},
28         {"title", "start_chapter", "none", TRUE, FALSE},
29         {"title", "end_chapter", "none", TRUE, FALSE},
30         {"vquality_type_bitrate", "VideoAvgBitrate", "TRUE", FALSE, FALSE},
31         {"vquality_type_target", "VideoTargetSize", "TRUE", FALSE, FALSE},
32         {"vquality_type_constant", "VideoQualitySlider", "TRUE", FALSE, FALSE},
33         {"vquality_type_constant", "constant_rate_factor", "TRUE", FALSE, FALSE},
34         {"vquality_type_constant", "VideoTwoPass", "TRUE", TRUE, FALSE},
35         {"vquality_type_constant", "VideoTurboTwoPass", "TRUE", TRUE, FALSE},
36         {"VideoTwoPass", "VideoTurboTwoPass", "TRUE", FALSE, FALSE},
37         {"FileFormat", "Mp4LargeFile", "mp4|m4v", FALSE, TRUE},
38         {"FileFormat", "Mp4HttpOptimize", "mp4|m4v", FALSE, TRUE},
39         {"FileFormat", "Mp4iPodCompatible", "mp4|m4v", FALSE, TRUE},
40         {"PictureDecomb", "PictureDeinterlace", "none", FALSE, FALSE},
41         {"PictureDecomb", "PictureDeinterlaceCustom", "none", FALSE, TRUE},
42         {"PictureDeinterlace", "PictureDeinterlaceCustom", "custom", FALSE, TRUE},
43         {"PictureDenoise", "PictureDenoiseCustom", "custom", FALSE, TRUE},
44         {"PictureDecomb", "PictureDecombCustom", "custom", FALSE, TRUE},
45         {"PictureDetelecine", "PictureDetelecineCustom", "custom", FALSE, TRUE},
46         {"PictureAutoCrop", "PictureTopCrop", "FALSE", FALSE, FALSE},
47         {"PictureAutoCrop", "PictureBottomCrop", "FALSE", FALSE, FALSE},
48         {"PictureAutoCrop", "PictureLeftCrop", "FALSE", FALSE, FALSE},
49         {"PictureAutoCrop", "PictureRightCrop", "FALSE", FALSE, FALSE},
50         {"VideoEncoder", "x264_tab", "x264", FALSE, FALSE},
51         {"VideoEncoder", "x264_tab_label", "x264", FALSE, FALSE},
52         {"VideoEncoder", "Mp4iPodCompatible", "x264", FALSE, FALSE},
53         {"AudioEncoder", "AudioBitrate", "ac3|dts", TRUE, FALSE},
54         {"AudioEncoder", "AudioSamplerate", "ac3|dts", TRUE, FALSE},
55         {"AudioEncoder", "AudioMixdown", "ac3|dts", TRUE, FALSE},
56         {"AudioEncoder", "AudioTrackDRCSlider", "ac3|dts", TRUE, FALSE},
57         {"x264_bframes", "x264_weighted_bframes", "0", TRUE, FALSE},
58         {"x264_bframes", "x264_bpyramid", "<2", TRUE, FALSE},
59         {"x264_bframes", "x264_direct", "0", TRUE, FALSE},
60         {"x264_bframes", "x264_b_adapt", "0", TRUE, FALSE},
61         {"x264_refs", "x264_mixed_refs", "<2", TRUE, FALSE},
62         {"x264_cabac", "x264_trellis", "TRUE", FALSE, FALSE},
63         {"x264_subme", "x264_psy_rd", "<6", TRUE, FALSE},
64         {"x264_subme", "x264_psy_trell", "<6", TRUE, FALSE},
65         {"x264_cabac", "x264_psy_trell", "TRUE", FALSE, FALSE},
66         {"x264_trellis", "x264_psy_trell", "0", TRUE, FALSE},
67         {"ChapterMarkers", "chapters_list", "TRUE", FALSE, FALSE},
68         {"use_source_name", "chapters_in_destination", "TRUE", FALSE, FALSE},
69         {"use_source_name", "title_no_in_destination", "TRUE", FALSE, FALSE},
70 };
71
72 int
73 main(gint argc, gchar *argv[])
74 {
75         gint ii, jj;
76         GValue *top;
77         gint count = sizeof(dep_map) / sizeof(dependency_t);
78
79         g_type_init();
80
81         top = ghb_dict_value_new();
82         for (ii = 0; ii < count; ii++)
83         {
84                 const gchar *name;
85                 GValue *array;
86
87                 name = dep_map[ii].widget_name;
88                 if (ghb_dict_lookup(top, name))
89                         continue;
90                 array = ghb_array_value_new(8);
91                 for (jj = 0; jj < count; jj++)
92                 {
93                         if (strcmp(name, dep_map[jj].widget_name) == 0)
94                         {
95                                 ghb_array_append(array,
96                                         ghb_value_dup(ghb_string_value(dep_map[jj].dep_name)));
97                         }
98                 }
99                 ghb_dict_insert(top, g_strdup(name), array);
100         }
101         ghb_plist_write_file("widget.deps", top);
102
103         // reverse map
104         top = ghb_dict_value_new();
105         for (ii = 0; ii < count; ii++)
106         {
107                 const gchar *name;
108                 GValue *array;
109
110                 name = dep_map[ii].dep_name;
111                 if (ghb_dict_lookup(top, name))
112                         continue;
113                 array = ghb_array_value_new(8);
114                 for (jj = 0; jj < count; jj++)
115                 {
116                         if (strcmp(name, dep_map[jj].dep_name) == 0)
117                         {
118                                 GValue *data;
119                                 data = ghb_array_value_new(3);
120                                 ghb_array_append(data, ghb_value_dup(
121                                         ghb_string_value(dep_map[jj].widget_name)));
122                                 ghb_array_append(data, ghb_value_dup(
123                                         ghb_string_value(dep_map[jj].enable_value)));
124                                 ghb_array_append(data, ghb_value_dup(
125                                         ghb_boolean_value(dep_map[jj].disable_if_equal)));
126                                 ghb_array_append(data, ghb_value_dup(
127                                         ghb_boolean_value(dep_map[jj].hide)));
128                                 ghb_array_append(array, data);
129                         }
130                 }
131                 ghb_dict_insert(top, g_strdup(name), array);
132         }
133         ghb_plist_write_file("widget_reverse.deps", top);
134         return 0;
135 }
136