1 /*****************************************************************************
2 * x264_gtk_mb.c: h264 gtk encoder frontend
3 *****************************************************************************
4 * Copyright (C) 2006 Vincent Torri
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
19 *****************************************************************************/
23 #include "x264_gtk_i18n.h"
24 #include "x264_gtk_private.h"
28 static void x264_mb_bframe_pyramid (GtkToggleButton *button,
30 static void x264_mb_inter_search_8 (GtkToggleButton *button,
32 static void x264_mb_transform_8x8 (GtkToggleButton *button,
37 x264_mb_page (X264_Gui_Config *config)
45 GtkTooltips *tooltips;
47 tooltips = gtk_tooltips_new ();
49 vbox = gtk_vbox_new (FALSE, 0);
50 gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
53 frame = gtk_frame_new (_("Partitions"));
54 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
55 gtk_widget_show (frame);
57 vbox2 = gtk_vbox_new (FALSE, 6);
58 gtk_container_set_border_width (GTK_CONTAINER (vbox2), 6);
59 gtk_container_add (GTK_CONTAINER (frame), vbox2);
60 gtk_widget_show (vbox2);
62 config->mb.partitions.transform_8x8 = gtk_check_button_new_with_label (_("8x8 Transform"));
63 gtk_tooltips_set_tip (tooltips, config->mb.partitions.transform_8x8,
64 _("8x8 Transform - description"),
66 g_signal_connect (G_OBJECT (config->mb.partitions.transform_8x8),
68 G_CALLBACK (x264_mb_transform_8x8), config);
69 gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.transform_8x8, FALSE, TRUE, 0);
70 gtk_widget_show (config->mb.partitions.transform_8x8);
72 config->mb.partitions.pframe_search_8 = gtk_check_button_new_with_label (_("8x16, 16x8 and 8x8 P-frame search"));
73 gtk_tooltips_set_tip (tooltips, config->mb.partitions.pframe_search_8,
74 _("8x16, 16x8 and 8x8 P-frame search - description"),
76 gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.pframe_search_8, FALSE, TRUE, 0);
77 gtk_widget_show (config->mb.partitions.pframe_search_8);
79 config->mb.partitions.bframe_search_8 = gtk_check_button_new_with_label (_("8x16, 16x8 and 8x8 B-frame search"));
80 gtk_tooltips_set_tip (tooltips, config->mb.partitions.bframe_search_8,
81 _("8x16, 16x8 and 8x8 B-frame search - description"),
83 gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.bframe_search_8, FALSE, TRUE, 0);
84 gtk_widget_show (config->mb.partitions.bframe_search_8);
86 config->mb.partitions.pframe_search_4 = gtk_check_button_new_with_label (_("4x8, 8x4 and 4x4 P-frame search"));
87 gtk_tooltips_set_tip (tooltips, config->mb.partitions.pframe_search_4,
88 _("4x8, 8x4 and 4x4 P-frame search - description"),
90 gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.pframe_search_4, FALSE, TRUE, 0);
91 gtk_widget_show (config->mb.partitions.pframe_search_4);
93 config->mb.partitions.inter_search_8 = gtk_check_button_new_with_label (_("8x8 Intra search"));
94 gtk_tooltips_set_tip (tooltips, config->mb.partitions.inter_search_8,
95 _("8x8 Intra search - description"),
97 g_signal_connect (G_OBJECT (config->mb.partitions.inter_search_8),
99 G_CALLBACK (x264_mb_inter_search_8), config);
100 gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.inter_search_8, FALSE, TRUE, 0);
101 gtk_widget_show (config->mb.partitions.inter_search_8);
103 config->mb.partitions.inter_search_4 = gtk_check_button_new_with_label (_("4x4 Intra search"));
104 gtk_tooltips_set_tip (tooltips, config->mb.partitions.inter_search_4,
105 _("4x4 Intra search - description"),
107 gtk_box_pack_start (GTK_BOX (vbox2), config->mb.partitions.inter_search_4, FALSE, TRUE, 0);
108 gtk_widget_show (config->mb.partitions.inter_search_4);
111 frame = gtk_frame_new (_("B-Frames"));
112 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
113 gtk_widget_show (frame);
115 table = gtk_table_new (5, 2, TRUE);
116 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
117 gtk_container_set_border_width (GTK_CONTAINER (table), 6);
118 gtk_container_add (GTK_CONTAINER (frame), table);
119 gtk_widget_show (table);
121 eb = gtk_event_box_new ();
122 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
123 gtk_tooltips_set_tip (tooltips, eb,
124 _("Max consecutive - description"),
126 gtk_table_attach_defaults (GTK_TABLE (table), eb,
128 gtk_widget_show (eb);
130 label = gtk_label_new (_("Max consecutive"));
131 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
132 gtk_container_add (GTK_CONTAINER (eb), label);
133 gtk_widget_show (label);
135 config->mb.bframes.bframe = gtk_entry_new_with_max_length (3);
136 gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe,
138 gtk_widget_show (config->mb.bframes.bframe);
140 eb = gtk_event_box_new ();
141 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
142 gtk_tooltips_set_tip (tooltips, eb,
143 _("Bias - description"),
145 gtk_table_attach_defaults (GTK_TABLE (table), eb,
147 gtk_widget_show (eb);
149 label = gtk_label_new (_("Bias"));
150 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
151 gtk_container_add (GTK_CONTAINER (eb), label);
152 gtk_widget_show (label);
154 config->mb.bframes.bframe_bias = gtk_hscale_new_with_range (-100.0, 100.0, 1.0);
155 gtk_scale_set_digits (GTK_SCALE (config->mb.bframes.bframe_bias), 0);
156 gtk_scale_set_value_pos (GTK_SCALE (config->mb.bframes.bframe_bias), GTK_POS_RIGHT);
157 gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe_bias,
159 gtk_widget_show (config->mb.bframes.bframe_bias);
161 config->mb.bframes.bframe_pyramid = gtk_check_button_new_with_label (_("Use as references"));
162 gtk_tooltips_set_tip (tooltips, config->mb.bframes.bframe_pyramid,
163 _("Use as references - description"),
165 g_signal_connect (G_OBJECT (config->mb.bframes.bframe_pyramid),
167 G_CALLBACK (x264_mb_bframe_pyramid), config);
168 gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe_pyramid,
170 gtk_widget_show (config->mb.bframes.bframe_pyramid);
172 config->mb.bframes.bidir_me = gtk_check_button_new_with_label (_("Bidirectional ME"));
173 gtk_tooltips_set_tip (tooltips, config->mb.bframes.bidir_me,
174 _("Bidirectional ME - description"),
176 gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bidir_me,
178 gtk_widget_show (config->mb.bframes.bidir_me);
180 config->mb.bframes.bframe_adaptive = gtk_check_button_new_with_label (_("Adaptive"));
181 gtk_tooltips_set_tip (tooltips, config->mb.bframes.bframe_adaptive,
182 _("Adaptive - description"),
184 gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.bframe_adaptive,
186 gtk_widget_show (config->mb.bframes.bframe_adaptive);
188 config->mb.bframes.weighted_bipred = gtk_check_button_new_with_label (_("Weighted biprediction"));
189 gtk_tooltips_set_tip (tooltips, config->mb.bframes.weighted_bipred,
190 _("Weighted biprediction - description"),
192 gtk_table_attach_defaults (GTK_TABLE (table), config->mb.bframes.weighted_bipred,
194 gtk_widget_show (config->mb.bframes.weighted_bipred);
196 eb = gtk_event_box_new ();
197 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
198 gtk_tooltips_set_tip (tooltips, eb,
199 _("Direct mode - description"),
201 gtk_table_attach_defaults (GTK_TABLE (table), eb,
203 gtk_widget_show (eb);
205 label = gtk_label_new (_("Direct mode"));
206 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
207 gtk_container_add (GTK_CONTAINER (eb), label);
208 gtk_widget_show (label);
210 config->mb.bframes.direct_mode = gtk_combo_box_new_text ();
211 gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
213 gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
215 gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
217 gtk_combo_box_append_text (GTK_COMBO_BOX (config->mb.bframes.direct_mode),
219 gtk_table_attach_defaults (GTK_TABLE (table),
220 config->mb.bframes.direct_mode,
222 gtk_widget_show (config->mb.bframes.direct_mode);
228 x264_mb_bframe_pyramid (GtkToggleButton *button,
231 X264_Gui_Config *config;
233 config = (X264_Gui_Config *)user_data;
235 if (gtk_toggle_button_get_active (button)) {
239 text = gtk_entry_get_text (GTK_ENTRY (config->mb.bframes.bframe));
240 val = (gint)g_ascii_strtoull (text, NULL, 10);
242 gtk_entry_set_text (GTK_ENTRY (config->mb.bframes.bframe), "2");
247 x264_mb_inter_search_8 (GtkToggleButton *button,
250 X264_Gui_Config *config;
252 config = (X264_Gui_Config *)user_data;
254 if (gtk_toggle_button_get_active (button)) {
255 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config->mb.partitions.transform_8x8), TRUE);
260 x264_mb_transform_8x8 (GtkToggleButton *button,
263 X264_Gui_Config *config;
265 config = (X264_Gui_Config *)user_data;
267 if (!gtk_toggle_button_get_active (button)) {
268 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config->mb.partitions.inter_search_8), FALSE);