]> git.sesse.net Git - x264/blob - gtk/x264_gtk_mb.c
move os/compiler specific defines to their own header
[x264] / gtk / x264_gtk_mb.c
1 #include <gtk/gtk.h>
2
3 #include "x264_gtk_i18n.h"
4 #include "x264_gtk_private.h"
5
6
7 /* Callbacks */
8 static void _mb_bframe_pyramid (GtkToggleButton *button,
9                                 gpointer         user_data);
10 static void _mb_inter_search_8 (GtkToggleButton *button,
11                                 gpointer         user_data);
12 static void _mb_transform_8x8  (GtkToggleButton *button,
13                                 gpointer         user_data);
14
15
16 GtkWidget *
17 _mb_page (X264_Gui_Config *config)
18 {
19   GtkWidget   *vbox;
20   GtkWidget   *frame;
21   GtkWidget   *vbox2;
22   GtkWidget   *table;
23   GtkWidget   *eb;
24   GtkWidget   *label;
25   GtkTooltips *tooltips;
26
27   tooltips = gtk_tooltips_new ();
28
29   vbox = gtk_vbox_new (FALSE, 0);
30   gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
31
32   /* Partitions */
33   frame = gtk_frame_new (_("Partitions"));
34   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
35   gtk_widget_show (frame);
36
37   vbox2 = gtk_vbox_new (FALSE, 6);
38   gtk_container_set_border_width (GTK_CONTAINER (vbox2), 6);
39   gtk_container_add (GTK_CONTAINER (frame), vbox2);
40   gtk_widget_show (vbox2);
41
42   config->mb.partitions.transform_8x8 = gtk_check_button_new_with_label (_("8x8 Transform"));
43   gtk_tooltips_set_tip (tooltips, config->mb.partitions.transform_8x8,
44                         _("8x8 Transform - description"),
45                         "");
46   g_signal_connect (G_OBJECT (config->mb.partitions.transform_8x8),
47                     "toggled",
48                     G_CALLBACK (_mb_transform_8x8), config);
49   gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.transform_8x8, FALSE, TRUE, 0);
50   gtk_widget_show (config->mb.partitions.transform_8x8);
51
52   config->mb.partitions.pframe_search_8 = gtk_check_button_new_with_label (_("8x16, 16x8 and 8x8 P-frame search"));
53   gtk_tooltips_set_tip (tooltips, config->mb.partitions.pframe_search_8,
54                         _("8x16, 16x8 and 8x8 P-frame search - description"),
55                         "");
56   gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.pframe_search_8, FALSE, TRUE, 0);
57   gtk_widget_show (config->mb.partitions.pframe_search_8);
58
59   config->mb.partitions.bframe_search_8 = gtk_check_button_new_with_label (_("8x16, 16x8 and 8x8 B-frame search"));
60   gtk_tooltips_set_tip (tooltips, config->mb.partitions.bframe_search_8,
61                         _("8x16, 16x8 and 8x8 B-frame search - description"),
62                         "");
63   gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.bframe_search_8, FALSE, TRUE, 0);
64   gtk_widget_show (config->mb.partitions.bframe_search_8);
65
66   config->mb.partitions.pframe_search_4 = gtk_check_button_new_with_label (_("4x8, 8x4 and 4x4 P-frame search"));
67   gtk_tooltips_set_tip (tooltips, config->mb.partitions.pframe_search_4,
68                         _("4x8, 8x4 and 4x4 P-frame search - description"),
69                         "");
70   gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.pframe_search_4, FALSE, TRUE, 0);
71   gtk_widget_show (config->mb.partitions.pframe_search_4);
72
73   config->mb.partitions.inter_search_8 = gtk_check_button_new_with_label (_("8x8 Intra search"));
74   gtk_tooltips_set_tip (tooltips, config->mb.partitions.inter_search_8,
75                         _("8x8 Intra search - description"),
76                         "");
77   g_signal_connect (G_OBJECT (config->mb.partitions.inter_search_8),
78                     "toggled",
79                     G_CALLBACK (_mb_inter_search_8), config);
80   gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.inter_search_8, FALSE, TRUE, 0);
81   gtk_widget_show (config->mb.partitions.inter_search_8);
82
83   config->mb.partitions.inter_search_4 = gtk_check_button_new_with_label (_("4x4 Intra search"));
84   gtk_tooltips_set_tip (tooltips, config->mb.partitions.inter_search_4,
85                         _("4x4 Intra search - description"),
86                         "");
87   gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.inter_search_4, FALSE, TRUE, 0);
88   gtk_widget_show (config->mb.partitions.inter_search_4);
89
90   /* B-Frames */
91   frame = gtk_frame_new (_("B-Frames"));
92   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
93   gtk_widget_show (frame);
94
95   table = gtk_table_new (5, 2, TRUE);
96   gtk_table_set_row_spacings (GTK_TABLE (table), 6);
97   gtk_container_set_border_width (GTK_CONTAINER (table), 6);
98   gtk_container_add (GTK_CONTAINER (frame), table);
99   gtk_widget_show (table);
100
101   eb = gtk_event_box_new ();
102   gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
103   gtk_tooltips_set_tip (tooltips, eb,
104                         _("Max consecutive - description"),
105                         "");
106   gtk_table_attach_defaults (GTK_TABLE (table), eb,
107                              0, 1, 0, 1);
108   gtk_widget_show (eb);
109
110   label = gtk_label_new (_("Max consecutive"));
111   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
112   gtk_container_add (GTK_CONTAINER (eb), label);
113   gtk_widget_show (label);
114
115   config->mb.bframes.bframe = gtk_entry_new_with_max_length (3);
116   gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe,
117                              1, 2, 0, 1);
118   gtk_widget_show (config->mb.bframes.bframe);
119
120   eb = gtk_event_box_new ();
121   gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
122   gtk_tooltips_set_tip (tooltips, eb,
123                         _("Bias - description"),
124                         "");
125   gtk_table_attach_defaults (GTK_TABLE (table), eb,
126                              0, 1, 1, 2);
127   gtk_widget_show (eb);
128
129   label = gtk_label_new (_("Bias"));
130   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
131   gtk_container_add (GTK_CONTAINER (eb), label);
132   gtk_widget_show (label);
133
134   config->mb.bframes.bframe_bias = gtk_hscale_new_with_range (-100.0, 100.0, 1.0);
135   gtk_scale_set_digits (GTK_SCALE (config->mb.bframes.bframe_bias), 0);
136   gtk_scale_set_value_pos (GTK_SCALE (config->mb.bframes.bframe_bias), GTK_POS_RIGHT);
137   gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe_bias,
138                              1, 2, 1, 2);
139   gtk_widget_show (config->mb.bframes.bframe_bias);
140
141   config->mb.bframes.bframe_pyramid = gtk_check_button_new_with_label (_("Use as references"));
142   gtk_tooltips_set_tip (tooltips, config->mb.bframes.bframe_pyramid,
143                         _("Use as references - description"),
144                         "");
145   g_signal_connect (G_OBJECT (config->mb.bframes.bframe_pyramid),
146                     "toggled",
147                     G_CALLBACK (_mb_bframe_pyramid), config);
148   gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe_pyramid,
149                              0, 1, 2, 3);
150   gtk_widget_show (config->mb.bframes.bframe_pyramid);
151
152   config->mb.bframes.bidir_me = gtk_check_button_new_with_label (_("Bidirectional ME"));
153   gtk_tooltips_set_tip (tooltips, config->mb.bframes.bidir_me,
154                         _("Bidirectional ME - description"),
155                         "");
156   gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bidir_me,
157                              1, 2, 2, 3);
158   gtk_widget_show (config->mb.bframes.bidir_me);
159
160   config->mb.bframes.bframe_adaptive = gtk_check_button_new_with_label (_("Adaptive"));
161   gtk_tooltips_set_tip (tooltips, config->mb.bframes.bframe_adaptive,
162                         _("Adaptive - description"),
163                         "");
164   gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe_adaptive,
165                              0, 1, 3, 4);
166   gtk_widget_show (config->mb.bframes.bframe_adaptive);
167
168   config->mb.bframes.weighted_bipred = gtk_check_button_new_with_label (_("Weighted biprediction"));
169   gtk_tooltips_set_tip (tooltips, config->mb.bframes.weighted_bipred,
170                         _("Weighted biprediction - description"),
171                         "");
172   gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.weighted_bipred,
173                              1, 2, 3, 4);
174   gtk_widget_show (config->mb.bframes.weighted_bipred);
175
176   eb = gtk_event_box_new ();
177   gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
178   gtk_tooltips_set_tip (tooltips, eb,
179                         _("Direct mode - description"),
180                         "");
181   gtk_table_attach_defaults (GTK_TABLE (table), eb,
182                              0, 1, 4, 5);
183   gtk_widget_show (eb);
184
185   label = gtk_label_new (_("Direct mode"));
186   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
187   gtk_container_add (GTK_CONTAINER (eb), label);
188   gtk_widget_show (label);
189
190   config->mb.bframes.direct_mode = gtk_combo_box_new_text ();
191   gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
192                              _("None"));
193   gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
194                              _("Spatial"));
195   gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
196                              _("Temporal"));
197   gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
198                              _("Auto"));
199   gtk_table_attach_defaults (GTK_TABLE (table),
200                              config->mb.bframes.direct_mode,
201                              1, 2, 4, 5);
202   gtk_widget_show (config->mb.bframes.direct_mode);
203
204   return vbox;
205 }
206
207 static void
208 _mb_bframe_pyramid (GtkToggleButton *button,
209                     gpointer         user_data)
210 {
211   X264_Gui_Config *config;
212
213   config = (X264_Gui_Config *)user_data;
214
215   if (gtk_toggle_button_get_active (button)) {
216     const gchar *text;
217     gint         val;
218
219     text = gtk_entry_get_text (GTK_ENTRY (config->mb.bframes.bframe));
220     val = (gint)g_ascii_strtoull (text, NULL, 10);
221     if (val < 2)
222       gtk_entry_set_text (GTK_ENTRY (config->mb.bframes.bframe), "2");
223   }
224 }
225
226 static void
227 _mb_inter_search_8 (GtkToggleButton *button,
228                     gpointer         user_data)
229 {
230   X264_Gui_Config *config;
231
232   config = (X264_Gui_Config *)user_data;
233
234   if (gtk_toggle_button_get_active (button)) {
235     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config->mb.partitions.transform_8x8), TRUE);
236   }
237 }
238
239 static void
240 _mb_transform_8x8 (GtkToggleButton *button,
241                    gpointer         user_data)
242 {
243   X264_Gui_Config *config;
244
245   config = (X264_Gui_Config *)user_data;
246
247   if (!gtk_toggle_button_get_active (button)) {
248     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config->mb.partitions.inter_search_8), FALSE);
249   }
250 }