1 /*****************************************************************************
2 * x264_gtk_more.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_more_deblocking_filter (GtkToggleButton *button,
30 static void x264_more_cabac (GtkToggleButton *button,
32 static void x264_more_mixed_ref (GtkToggleButton *button,
37 x264_more_page (X264_Gui_Config *config)
51 GtkTooltips *tooltips;
53 tooltips = gtk_tooltips_new ();
55 label = gtk_entry_new_with_max_length (3);
56 gtk_widget_size_request (label, &size);
57 gtk_widget_destroy (GTK_WIDGET (label));
59 label = gtk_check_button_new_with_label (_("Deblocking Filter"));
60 gtk_widget_size_request (label, &size2);
61 gtk_widget_destroy (GTK_WIDGET (label));
63 label = gtk_label_new (_("Partition decision"));
64 gtk_widget_size_request (label, &size3);
65 gtk_widget_destroy (GTK_WIDGET (label));
67 label = gtk_label_new (_("Threshold"));
68 gtk_widget_size_request (label, &size5);
69 gtk_widget_destroy (GTK_WIDGET (label));
71 vbox = gtk_vbox_new (FALSE, 0);
72 gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
74 /* Motion Estimation */
75 frame = gtk_frame_new (_("Motion Estimation"));
76 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
77 gtk_widget_show (frame);
79 table = gtk_table_new (5, 3, TRUE);
80 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
81 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
82 gtk_container_set_border_width (GTK_CONTAINER (table), 6);
83 gtk_container_add (GTK_CONTAINER (frame), table);
84 gtk_widget_show (table);
86 eb = gtk_event_box_new ();
87 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
88 gtk_tooltips_set_tip (tooltips, eb,
89 _("Partition decision - description"),
91 gtk_table_attach_defaults (GTK_TABLE (table), eb,
95 label = gtk_label_new (_("Partition decision"));
96 gtk_widget_set_size_request (label, size2.width, size3.height);
97 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
98 gtk_container_add (GTK_CONTAINER (eb), label);
99 gtk_widget_show (label);
101 config->more.motion_estimation.partition_decision = gtk_combo_box_new_text ();
102 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
104 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
106 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
108 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
110 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
111 _("5 (High quality)"));
112 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
114 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.partition_decision),
115 _("6b (RDO on B frames)"));
116 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.partition_decision,
118 gtk_widget_show (config->more.motion_estimation.partition_decision);
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 _("Method - description"),
125 gtk_table_attach_defaults (GTK_TABLE (table), eb,
127 gtk_widget_show (eb);
129 label = gtk_label_new (_("Method"));
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);
134 config->more.motion_estimation.method = gtk_combo_box_new_text ();
135 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.method),
136 _("Diamond Search"));
137 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.method),
138 _("Hexagonal Search"));
139 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.method),
140 _("Uneven Multi-Hexagon"));
141 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.motion_estimation.method),
142 _("Exhaustive search"));
143 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.method,
145 gtk_widget_show (config->more.motion_estimation.method);
147 eb = gtk_event_box_new ();
148 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
149 gtk_tooltips_set_tip (tooltips, eb,
150 _("Range - description"),
152 gtk_table_attach_defaults (GTK_TABLE (table), eb,
154 gtk_widget_show (eb);
156 label = gtk_label_new (_("Range"));
157 gtk_widget_size_request (label, &size4);
158 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
159 gtk_container_add (GTK_CONTAINER (eb), label);
160 gtk_widget_show (label);
162 config->more.motion_estimation.range = gtk_entry_new_with_max_length (3);
163 gtk_widget_set_size_request (config->more.motion_estimation.range,
165 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.range,
167 gtk_widget_show (config->more.motion_estimation.range);
169 config->more.motion_estimation.chroma_me = gtk_check_button_new_with_label (_("Chroma ME"));
170 gtk_tooltips_set_tip (tooltips, config->more.motion_estimation.chroma_me,
171 _("Chroma ME - description"),
173 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.chroma_me,
175 gtk_widget_show (config->more.motion_estimation.chroma_me);
177 eb = gtk_event_box_new ();
178 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
179 gtk_tooltips_set_tip (tooltips, eb,
180 _("Max Ref. frames - description"),
182 gtk_table_attach_defaults (GTK_TABLE (table), eb,
184 gtk_widget_show (eb);
186 label = gtk_label_new (_("Max Ref. frames"));
187 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
188 gtk_container_add (GTK_CONTAINER (eb), label);
189 gtk_widget_show (label);
191 config->more.motion_estimation.max_ref_frames = gtk_entry_new_with_max_length (3);
192 gtk_widget_set_size_request (config->more.motion_estimation.max_ref_frames,
194 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.max_ref_frames,
196 gtk_widget_show (config->more.motion_estimation.max_ref_frames);
198 config->more.motion_estimation.mixed_refs = gtk_check_button_new_with_label (_("Mixed Refs"));
199 gtk_tooltips_set_tip (tooltips, config->more.motion_estimation.mixed_refs,
200 _("Mixed Refs - description"),
202 g_signal_connect (G_OBJECT (config->more.motion_estimation.mixed_refs),
204 G_CALLBACK (x264_more_mixed_ref), config);
205 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.mixed_refs,
207 gtk_widget_show (config->more.motion_estimation.mixed_refs);
209 config->more.motion_estimation.fast_pskip = gtk_check_button_new_with_label (_("Fast P skip"));
210 gtk_tooltips_set_tip (tooltips, config->more.motion_estimation.fast_pskip,
211 _("Fast P skip - description"),
213 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.fast_pskip,
215 gtk_widget_show (config->more.motion_estimation.fast_pskip);
217 config->more.motion_estimation.dct_decimate = gtk_check_button_new_with_label (_("DCT decimate"));
218 gtk_tooltips_set_tip (tooltips, config->more.motion_estimation.dct_decimate,
219 _("DCT decimate - description"),
221 gtk_table_attach_defaults (GTK_TABLE (table), config->more.motion_estimation.dct_decimate,
223 gtk_widget_show (config->more.motion_estimation.dct_decimate);
226 frame = gtk_frame_new (_("Misc. Options"));
227 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
228 gtk_widget_show (frame);
230 table = gtk_table_new (5, 4, FALSE);
231 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
232 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
233 gtk_container_set_border_width (GTK_CONTAINER (table), 6);
234 gtk_container_add (GTK_CONTAINER (frame), table);
235 gtk_widget_show (table);
237 eb = gtk_event_box_new ();
238 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
239 gtk_tooltips_set_tip (tooltips, eb,
240 _("Sample Aspect Ratio - description"),
242 gtk_table_attach_defaults (GTK_TABLE (table), eb,
244 gtk_widget_show (eb);
246 label = gtk_label_new (_("Sample Aspect Ratio"));
247 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
248 gtk_container_add (GTK_CONTAINER (eb), label);
249 gtk_widget_show (label);
251 hbox = gtk_hbox_new (TRUE, 6);
252 gtk_table_attach_defaults (GTK_TABLE (table), hbox,
254 gtk_widget_show (hbox);
256 config->more.misc.sample_ar_x = gtk_entry_new_with_max_length (3);
257 gtk_widget_set_size_request (config->more.misc.sample_ar_x, 25, size.height);
258 gtk_box_pack_start (GTK_BOX (hbox), config->more.misc.sample_ar_x, FALSE, TRUE, 0);
259 gtk_widget_show (config->more.misc.sample_ar_x);
261 config->more.misc.sample_ar_y = gtk_entry_new_with_max_length (3);
262 gtk_widget_set_size_request (config->more.misc.sample_ar_y, 25, size.height);
263 gtk_box_pack_start (GTK_BOX (hbox), config->more.misc.sample_ar_y, FALSE, TRUE, 0);
264 gtk_widget_show (config->more.misc.sample_ar_y);
266 eb = gtk_event_box_new ();
267 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
268 gtk_tooltips_set_tip (tooltips, eb,
269 _("Threads - description"),
271 gtk_table_attach_defaults (GTK_TABLE (table), eb,
273 gtk_widget_show (eb);
275 label = gtk_label_new (_("Threads"));
276 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
277 gtk_container_add (GTK_CONTAINER (eb), label);
278 gtk_widget_show (label);
280 adj = gtk_adjustment_new (1.0, 1.0, 4.0, 1.0, 1.0, 1.0);
281 config->more.misc.threads = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1.0, 0);
283 gtk_widget_set_size_request (config->more.misc.threads, size5.width, size.height);
284 gtk_table_attach_defaults (GTK_TABLE (table),
285 config->more.misc.threads,
287 gtk_widget_show (config->more.misc.threads);
289 config->more.misc.cabac = gtk_check_button_new_with_label (_("CABAC"));
290 gtk_widget_set_size_request (config->more.misc.cabac, size5.width, size.height);
291 gtk_tooltips_set_tip (tooltips, config->more.misc.cabac,
292 _("CABAC - description"),
294 g_signal_connect (G_OBJECT (config->more.misc.cabac),
296 G_CALLBACK (x264_more_cabac), config);
297 gtk_table_attach_defaults (GTK_TABLE (table), config->more.misc.cabac,
299 gtk_widget_show (config->more.misc.cabac);
301 eb = gtk_event_box_new ();
302 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
303 gtk_tooltips_set_tip (tooltips, eb,
304 _("Trellis - description"),
306 gtk_table_attach_defaults (GTK_TABLE (table), eb,
308 gtk_widget_show (eb);
310 label = gtk_label_new (_("Trellis"));
311 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
312 gtk_container_add (GTK_CONTAINER (eb), label);
313 gtk_widget_show (label);
315 config->more.misc.trellis = gtk_combo_box_new_text ();
316 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.misc.trellis),
318 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.misc.trellis),
319 _("Enabled (once)"));
320 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.misc.trellis),
321 _("Enabled (mode decision)"));
322 gtk_table_attach_defaults (GTK_TABLE (table), config->more.misc.trellis,
324 gtk_widget_show (config->more.misc.trellis);
326 eb = gtk_event_box_new ();
327 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
328 gtk_tooltips_set_tip (tooltips, eb,
329 _("Noise reduction - description"),
331 gtk_table_attach_defaults (GTK_TABLE (table), eb,
333 gtk_widget_show (eb);
335 label = gtk_label_new (_("Noise reduction"));
336 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
337 gtk_container_add (GTK_CONTAINER (eb), label);
338 gtk_widget_show (label);
340 config->more.misc.noise_reduction = gtk_entry_new_with_max_length (3);
341 gtk_widget_set_size_request (config->more.misc.noise_reduction, size5.width, size.height);
342 gtk_table_attach_defaults (GTK_TABLE (table), config->more.misc.noise_reduction,
344 gtk_widget_show (config->more.misc.noise_reduction);
346 config->more.misc.df.deblocking_filter = gtk_check_button_new_with_label (_("Deblocking Filter"));
347 gtk_tooltips_set_tip (tooltips, config->more.misc.df.deblocking_filter,
348 _("Deblocking Filter - description"),
350 g_signal_connect (G_OBJECT (config->more.misc.df.deblocking_filter),
352 G_CALLBACK (x264_more_deblocking_filter), config);
353 gtk_table_attach_defaults (GTK_TABLE (table), config->more.misc.df.deblocking_filter,
355 gtk_widget_show (config->more.misc.df.deblocking_filter);
357 eb = gtk_event_box_new ();
358 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
359 gtk_tooltips_set_tip (tooltips, eb,
360 _("Strength - description"),
362 gtk_table_attach_defaults (GTK_TABLE (table), eb,
364 gtk_widget_show (eb);
366 label = gtk_label_new (_("Strength"));
367 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
368 gtk_widget_set_size_request (label, size5.width, size4.height);
369 gtk_container_add (GTK_CONTAINER (eb), label);
370 gtk_widget_show (label);
372 config->more.misc.df.strength = gtk_hscale_new_with_range (-6.0, 6.0, 1.0);
373 gtk_widget_size_request (config->more.misc.df.strength, &size4);
374 gtk_scale_set_digits (GTK_SCALE (config->more.misc.df.strength), 0);
375 gtk_scale_set_value_pos (GTK_SCALE (config->more.misc.df.strength), GTK_POS_RIGHT);
376 // gtk_widget_set_size_request (config->more.misc.df.strength, size5.width, size4.height);
377 gtk_table_attach_defaults (GTK_TABLE (table), config->more.misc.df.strength,
379 gtk_widget_show (config->more.misc.df.strength);
381 eb = gtk_event_box_new ();
382 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
383 gtk_tooltips_set_tip (tooltips, eb,
384 _("Threshold - description"),
386 gtk_table_attach_defaults (GTK_TABLE (table), eb,
388 gtk_widget_show (eb);
390 label = gtk_label_new (_("Threshold"));
391 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
392 gtk_widget_set_size_request (label, size5.width, size4.height);
393 gtk_container_add (GTK_CONTAINER (eb), label);
394 gtk_widget_show (label);
396 config->more.misc.df.threshold = gtk_hscale_new_with_range (-6.0, 6.0, 1.0);
397 gtk_scale_set_digits (GTK_SCALE (config->more.misc.df.threshold), 0);
398 gtk_scale_set_value_pos (GTK_SCALE (config->more.misc.df.threshold), GTK_POS_RIGHT);
399 gtk_table_attach_defaults (GTK_TABLE (table), config->more.misc.df.threshold,
401 gtk_widget_show (config->more.misc.df.threshold);
404 frame = gtk_frame_new (_("Debug"));
405 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 6);
406 gtk_widget_show (frame);
408 table = gtk_table_new (2, 2, TRUE);
409 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
410 gtk_container_set_border_width (GTK_CONTAINER (table), 6);
411 gtk_container_add (GTK_CONTAINER (frame), table);
412 gtk_widget_show (table);
414 eb = gtk_event_box_new ();
415 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
416 gtk_tooltips_set_tip (tooltips, eb,
417 _("Log level - description"),
419 gtk_table_attach_defaults (GTK_TABLE (table), eb,
421 gtk_widget_show (eb);
423 label = gtk_label_new (_("Log level"));
424 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
425 gtk_container_add (GTK_CONTAINER (eb), label);
426 gtk_widget_show (label);
428 config->more.debug.log_level = gtk_combo_box_new_text ();
429 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.debug.log_level),
431 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.debug.log_level),
433 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.debug.log_level),
435 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.debug.log_level),
437 gtk_combo_box_append_text (GTK_COMBO_BOX (config->more.debug.log_level),
439 gtk_table_attach_defaults (GTK_TABLE (table), config->more.debug.log_level,
441 gtk_widget_show (config->more.debug.log_level);
443 eb = gtk_event_box_new ();
444 gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE);
445 gtk_tooltips_set_tip (tooltips, eb,
446 _("FourCC - description"),
448 gtk_table_attach_defaults (GTK_TABLE (table), eb,
450 gtk_widget_show (eb);
452 label = gtk_label_new ("FourCC");
453 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
454 gtk_container_add (GTK_CONTAINER (eb), label);
455 gtk_widget_show (label);
457 config->more.debug.fourcc = gtk_entry_new_with_max_length (4);
458 gtk_table_attach_defaults (GTK_TABLE (table),
459 config->more.debug.fourcc,
461 gtk_widget_set_sensitive (config->more.debug.fourcc, FALSE);
462 gtk_widget_show (config->more.debug.fourcc);
471 x264_more_deblocking_filter (GtkToggleButton *button,
474 X264_Gui_Config *config;
476 config = (X264_Gui_Config *)user_data;
478 if (gtk_toggle_button_get_active (button)) {
479 gtk_widget_set_sensitive (config->more.misc.df.strength, TRUE);
480 gtk_widget_set_sensitive (config->more.misc.df.threshold, TRUE);
483 gtk_widget_set_sensitive (config->more.misc.df.strength, FALSE);
484 gtk_widget_set_sensitive (config->more.misc.df.threshold, FALSE);
489 x264_more_cabac (GtkToggleButton *button,
492 X264_Gui_Config *config;
494 config = (X264_Gui_Config *)user_data;
496 if (gtk_toggle_button_get_active (button))
497 gtk_widget_set_sensitive (config->more.misc.trellis, TRUE);
499 gtk_widget_set_sensitive (config->more.misc.trellis, FALSE);
503 x264_more_mixed_ref (GtkToggleButton *button,
506 X264_Gui_Config *config;
508 config = (X264_Gui_Config *)user_data;
510 if (gtk_toggle_button_get_active (button)) {
514 text = gtk_entry_get_text (GTK_ENTRY (config->more.motion_estimation.max_ref_frames));
515 val = (gint)g_ascii_strtoull (text, NULL, 10);
517 gtk_entry_set_text (GTK_ENTRY (config->more.motion_estimation.max_ref_frames), "2");