[cvs] / vfw / src / config.c Repository:
ViewVC logotype

Annotation of /vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20.2.7 - (view) (download)

1 : Isibaar 1.1 /**************************************************************************
2 :     *
3 :     * XVID VFW FRONTEND
4 :     * config
5 :     *
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.
10 :     *
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.
15 :     *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 :     *
20 :     *************************************************************************/
21 :    
22 :     /**************************************************************************
23 :     *
24 :     * History:
25 :     *
26 : suxen_drol 1.11 * 15.06.2002 added bframes options
27 : h 1.10 * 21.04.2002 fixed custom matrix support, tried to get dll size down
28 : h 1.9 * 17.04.2002 re-enabled lumi masking in 1st pass
29 : h 1.8 * 15.04.2002 updated cbr support
30 : h 1.7 * 07.04.2002 min keyframe interval checkbox
31 :     * 2-pass max bitrate and overflow customization
32 : h 1.6 * 04.04.2002 interlacing support
33 :     * hinted ME support
34 : h 1.5 * 24.03.2002 daniel smith <danielsmith@astroboymail.com>
35 :     * added Foxer's new CBR engine
36 :     * - cbr_buffer is being used as reaction delay (quick hack)
37 : h 1.4 * 23.03.2002 daniel smith <danielsmith@astroboymail.com>
38 :     * added load defaults button
39 :     * merged foxer's alternative 2-pass code (2-pass alt tab)
40 :     * added proper tooltips
41 :     * moved registry data into reg_ints/reg_strs arrays
42 :     * added DEBUGERR output on errors instead of returning
43 : h 1.3 * 16.03.2002 daniel smith <danielsmith@astroboymail.com>
44 :     * rewrote/restructured most of file
45 :     * added tooltips (kind of - dirty message hook method)
46 :     * split tabs into a main dialog / advanced prop sheet
47 :     * advanced controls are now enabled/disabled by mode
48 :     * added modulated quantization, DX50 fourcc
49 :     * 11.03.2002 Min Chen <chenm001@163.com>
50 :     * now get Core Version use xvid_init()
51 :     * 05.03.2002 Min Chen <chenm001@163.com>
52 :     * Add Core version display to about box
53 : h 1.20.2.1 * 01.12.2001 inital version; (c)2001 peter ross <pross@xvid.org>
54 : Isibaar 1.1 *
55 :     *************************************************************************/
56 :    
57 :    
58 :     #include <windows.h>
59 : h 1.3 #include <commctrl.h>
60 : Isibaar 1.1 #include <shlobj.h>
61 :     #include <prsht.h>
62 : suxen_drol 1.13 #ifdef _SMP
63 :     #include <pthread.h>
64 :     #endif
65 : Isibaar 1.1
66 : Isibaar 1.20 #include <xvid.h> // XviD API
67 :    
68 : Isibaar 1.1 #include "codec.h"
69 :     #include "config.h"
70 :     #include "resource.h"
71 : h 1.3
72 : Isibaar 1.1
73 : suxen_drol 1.13
74 : h 1.4 /* registry info structs */
75 :    
76 :     CONFIG reg;
77 :    
78 :     REG_INT const reg_ints[] = {
79 :     {"mode", &reg.mode, DLG_MODE_CBR},
80 :     {"quality", &reg.quality, 85},
81 :     {"quant", &reg.quant, 5},
82 : h 1.8 {"rc_bitrate", &reg.rc_bitrate, 900000},
83 :     {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor, 16},
84 :     {"rc_averaging_period", &reg.rc_averaging_period, 100},
85 :     {"rc_buffer", &reg.rc_buffer, 100},
86 : h 1.4
87 : syskin 1.20.2.5 {"motion_search", &reg.motion_search, 6},
88 : h 1.4 {"quant_type", &reg.quant_type, 0},
89 :     {"fourcc_used", &reg.fourcc_used, 0},
90 : syskin 1.20.2.7 {"vhq_mode", &reg.vhq_mode, 0},
91 : h 1.4 {"max_key_interval", &reg.max_key_interval, 300},
92 : h 1.7 {"min_key_interval", &reg.min_key_interval, 1},
93 : h 1.4 {"lum_masking", &reg.lum_masking, 0},
94 : h 1.6 {"interlacing", &reg.interlacing, 0},
95 : suxen_drol 1.20.2.2 {"qpel", &reg.qpel, 0},
96 :     {"gmc", &reg.gmc, 0},
97 :     {"chromame", &reg.chromame, 0},
98 : Foxer 1.18 //added by koepi for gruel's greyscale_mode
99 :     {"greyscale", &reg.greyscale, 0},
100 :     // end of koepi's additions
101 : suxen_drol 1.12 {"max_bframes", &reg.max_bframes, -1},
102 : suxen_drol 1.20.2.2 {"bquant_ratio", &reg.bquant_ratio, 150},
103 :     {"bquant_offset", &reg.bquant_offset, 100},
104 : suxen_drol 1.12 {"packed", &reg.packed, 0},
105 : syskin 1.20.2.5 {"dx50bvop", &reg.dx50bvop, 1},
106 : suxen_drol 1.12 {"debug", &reg.debug, 0},
107 : suxen_drol 1.20.2.6 {"reduced_resolution", &reg.reduced_resolution, 0},
108 : suxen_drol 1.14 {"frame_drop_ratio", &reg.frame_drop_ratio, 0},
109 : h 1.4
110 : suxen_drol 1.19 {"min_iquant", &reg.min_iquant, 2},
111 : h 1.4 {"max_iquant", &reg.max_iquant, 31},
112 : suxen_drol 1.19 {"min_pquant", &reg.min_pquant, 2},
113 : h 1.4 {"max_pquant", &reg.max_pquant, 31},
114 :    
115 :     {"desired_size", &reg.desired_size, 570000},
116 : suxen_drol 1.19 {"keyframe_boost", &reg.keyframe_boost, 0},
117 : h 1.4 {"discard1pass", &reg.discard1pass, 1},
118 :     {"dummy2pass", &reg.dummy2pass, 0},
119 : Foxer 1.15 // added by koepi for new two-pass curve treatment
120 :     {"kftreshold", &reg.kftreshold, 10},
121 : syskin 1.20.2.5 {"kfreduction", &reg.kfreduction, 20},
122 : Foxer 1.15 // end of koepi's additions
123 : syskin 1.20.2.5 {"curve_compression_high", &reg.curve_compression_high, 0},
124 :     {"curve_compression_low", &reg.curve_compression_low, 0},
125 :     {"use_alt_curve", &reg.use_alt_curve, 0},
126 : h 1.4 {"alt_curve_use_auto", &reg.alt_curve_use_auto, 1},
127 : suxen_drol 1.19 {"alt_curve_auto_str", &reg.alt_curve_auto_str, 30},
128 : h 1.4 {"alt_curve_use_auto_bonus_bias", &reg.alt_curve_use_auto_bonus_bias, 1},
129 :     {"alt_curve_bonus_bias", &reg.alt_curve_bonus_bias, 50},
130 :     {"alt_curve_type", &reg.alt_curve_type, 1},
131 : suxen_drol 1.19 {"alt_curve_high_dist", &reg.alt_curve_high_dist, 500},
132 :     {"alt_curve_low_dist", &reg.alt_curve_low_dist, 90},
133 : h 1.4 {"alt_curve_min_rel_qual", &reg.alt_curve_min_rel_qual, 50},
134 : suxen_drol 1.19 {"bitrate_payback_delay", &reg.bitrate_payback_delay, 250},
135 : h 1.4 {"bitrate_payback_method", &reg.bitrate_payback_method, 0},
136 : h 1.7 {"twopass_max_bitrate", &reg.twopass_max_bitrate, 10000 * CONFIG_KBPS},
137 :     {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 60},
138 :     {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 60},
139 : h 1.6 {"hinted_me", &reg.hinted_me, 0},
140 : h 1.4
141 :     {"credits_start", &reg.credits_start, 0},
142 :     {"credits_start_begin", &reg.credits_start_begin, 0},
143 :     {"credits_start_end", &reg.credits_start_end, 0},
144 :     {"credits_end", &reg.credits_end, 0},
145 :     {"credits_end_begin", &reg.credits_end_begin, 0},
146 :     {"credits_end_end", &reg.credits_end_end, 0},
147 :    
148 : Foxer 1.18 // added by koepi for greyscale credits
149 :     {"credits_greyscale", &reg.credits_greyscale, 0},
150 :     // end of koepi's addition
151 : h 1.4 {"credits_mode", &reg.credits_mode, 0},
152 :     {"credits_rate", &reg.credits_rate, 20},
153 :     {"credits_quant_i", &reg.credits_quant_i, 20},
154 :     {"credits_quant_p", &reg.credits_quant_p, 20},
155 :     {"credits_start_size", &reg.credits_start_size, 10000},
156 : suxen_drol 1.20.2.6 {"credits_end_size", &reg.credits_end_size, 10000},
157 :    
158 :     /* decoder */
159 :     {"deblock_y", &reg.deblock_y, 0},
160 :     {"deblock_uv", &reg.deblock_uv, 0}
161 : h 1.4 };
162 :    
163 :     REG_STR const reg_strs[] = {
164 : h 1.6 {"hintfile", reg.hintfile, CONFIG_HINTFILE},
165 : h 1.4 {"stats1", reg.stats1, CONFIG_2PASS_1_FILE},
166 :     {"stats2", reg.stats2, CONFIG_2PASS_2_FILE}
167 :     // {"build", reg.build, XVID_BUILD}
168 :     };
169 :    
170 : Isibaar 1.1 /* get config settings from registry */
171 :    
172 :     #define REG_GET_B(X, Y, Z) size=sizeof((Z));if(RegQueryValueEx(hKey, X, 0, 0, Y, &size) != ERROR_SUCCESS) {memcpy(Y, Z, sizeof((Z)));}
173 :    
174 :     void config_reg_get(CONFIG * config)
175 :     {
176 :     HKEY hKey;
177 :     DWORD size;
178 :     XVID_INIT_PARAM init_param;
179 : h 1.4 int i;
180 : Isibaar 1.1
181 : suxen_drol 1.12 init_param.cpu_flags = XVID_CPU_CHKONLY;
182 : Isibaar 1.1 xvid_init(0, 0, &init_param, NULL);
183 : suxen_drol 1.12 reg.cpu = init_param.cpu_flags;
184 : Isibaar 1.1
185 : suxen_drol 1.13 #ifdef _SMP
186 :     reg.num_threads = pthread_num_processors_np();
187 :     #endif
188 :    
189 : h 1.3 RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey);
190 : Isibaar 1.1
191 : h 1.4 for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
192 :     {
193 :     size = sizeof(int);
194 :    
195 :     if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS)
196 :     {
197 :     *reg_ints[i].config_int = reg_ints[i].def;
198 :     }
199 :     }
200 :    
201 :     for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
202 :     {
203 :     size = MAX_PATH;
204 :    
205 :     if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS)
206 :     {
207 :     memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
208 :     }
209 :     }
210 : Isibaar 1.1
211 :     {
212 :     BYTE default_qmatrix_intra[] = {
213 :     8, 17,18,19,21,23,25,27,
214 :     17,18,19,21,23,25,27,28,
215 :     20,21,22,23,24,26,28,30,
216 :     21,22,23,24,26,28,30,32,
217 :     22,23,24,26,28,30,32,35,
218 :     23,24,26,28,30,32,35,38,
219 :     25,26,28,30,32,35,38,41,
220 :     27,28,30,32,35,38,41,45
221 :     };
222 :    
223 :     BYTE default_qmatrix_inter[] = {
224 :     16,17,18,19,20,21,22,23,
225 :     17,18,19,20,21,22,23,24,
226 :     18,19,20,21,22,23,24,25,
227 :     19,20,21,22,23,24,26,27,
228 :     20,21,22,23,25,26,27,28,
229 :     21,22,23,24,26,27,28,30,
230 :     22,23,24,26,27,28,30,31,
231 :     23,24,25,27,28,30,31,33
232 :     };
233 :    
234 : h 1.4 REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra);
235 :     REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter);
236 : Isibaar 1.1 }
237 :    
238 : h 1.4 memcpy(config, &reg, sizeof(CONFIG));
239 :    
240 : Isibaar 1.1 RegCloseKey(hKey);
241 :     }
242 :    
243 :    
244 :     /* put config settings in registry */
245 :    
246 :     #define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y)))
247 :    
248 :     void config_reg_set(CONFIG * config)
249 :     {
250 :     HKEY hKey;
251 :     DWORD dispo;
252 : h 1.4 int i;
253 : Isibaar 1.1
254 :     if (RegCreateKeyEx(
255 :     XVID_REG_KEY,
256 : h 1.3 XVID_REG_PARENT "\\" XVID_REG_CHILD,
257 : Isibaar 1.1 0,
258 :     XVID_REG_CLASS,
259 :     REG_OPTION_NON_VOLATILE,
260 :     KEY_WRITE,
261 :     0,
262 :     &hKey,
263 :     &dispo) != ERROR_SUCCESS)
264 :     {
265 :     DEBUG1("Couldn't create XVID_REG_SUBKEY - ", GetLastError());
266 :     return;
267 :     }
268 :    
269 : h 1.4 memcpy(&reg, config, sizeof(CONFIG));
270 :    
271 :     for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
272 :     {
273 :     RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int));
274 :     }
275 :    
276 :     for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
277 :     {
278 :     RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1);
279 :     }
280 :    
281 :     REG_SET_B("qmatrix_intra", reg.qmatrix_intra);
282 :     REG_SET_B("qmatrix_inter", reg.qmatrix_inter);
283 : Isibaar 1.1
284 :     RegCloseKey(hKey);
285 :     }
286 :    
287 :    
288 : h 1.3 /* clear XviD registry key, load defaults */
289 : Isibaar 1.1
290 : h 1.3 void config_reg_default(CONFIG * config)
291 : Isibaar 1.1 {
292 : h 1.3 HKEY hKey;
293 : Isibaar 1.1
294 : h 1.3 if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey))
295 : Isibaar 1.1 {
296 : h 1.3 DEBUG1("Couldn't open registry key for deletion - ", GetLastError());
297 :     return;
298 : Isibaar 1.1 }
299 : h 1.3
300 : h 1.4 if (RegDeleteKey(hKey, XVID_REG_CHILD))
301 : Isibaar 1.1 {
302 : h 1.3 DEBUG1("Couldn't delete registry key - ", GetLastError());
303 :     return;
304 : Isibaar 1.1 }
305 :    
306 : h 1.4 RegCloseKey(hKey);
307 : h 1.3 config_reg_get(config);
308 : h 1.4 config_reg_set(config);
309 : h 1.3 }
310 :    
311 : Isibaar 1.1
312 : h 1.3 /* leaves current config value if dialog item is empty */
313 : Isibaar 1.1
314 : suxen_drol 1.11 int config_get_int(HWND hDlg, INT item, int config)
315 :     {
316 :     BOOL success = FALSE;
317 :    
318 :     int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);
319 :    
320 :     return (success) ? tmp : config;
321 :     }
322 :    
323 :    
324 :     int config_get_uint(HWND hDlg, UINT item, int config)
325 : h 1.3 {
326 :     BOOL success = FALSE;
327 : Isibaar 1.1
328 : h 1.3 int tmp = GetDlgItemInt(hDlg, item, &success, FALSE);
329 : Isibaar 1.1
330 : h 1.3 return (success) ? tmp : config;
331 : Isibaar 1.1 }
332 :    
333 :    
334 : h 1.3 /* downloads data from main dialog */
335 : Isibaar 1.1
336 : h 1.3 void main_download(HWND hDlg, CONFIG * config)
337 : Isibaar 1.1 {
338 : h 1.3 switch(config->mode)
339 : Isibaar 1.1 {
340 : h 1.3 default :
341 :     case DLG_MODE_CBR :
342 : suxen_drol 1.11 config->rc_bitrate = config_get_uint(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS;
343 : Isibaar 1.1 break;
344 :    
345 : h 1.3 case DLG_MODE_VBR_QUAL :
346 : suxen_drol 1.11 config->quality = config_get_uint(hDlg, IDC_VALUE, config->quality);
347 : Isibaar 1.1 break;
348 :    
349 : h 1.3 case DLG_MODE_VBR_QUANT :
350 : suxen_drol 1.11 config->quant = config_get_uint(hDlg, IDC_VALUE, config->quant);
351 : Isibaar 1.1 break;
352 :    
353 : h 1.3 case DLG_MODE_2PASS_2_INT :
354 : suxen_drol 1.11 config->desired_size = config_get_uint(hDlg, IDC_VALUE, config->desired_size);
355 : Isibaar 1.1 break;
356 :     }
357 : h 1.3
358 :     config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
359 : Isibaar 1.1 }
360 :    
361 :    
362 : h 1.3 /* updates the edit box */
363 : Isibaar 1.1
364 : h 1.3 void main_value(HWND hDlg, CONFIG* config)
365 : Isibaar 1.1 {
366 : h 1.3 char* text;
367 : Isibaar 1.1 int value;
368 : h 1.3 int enabled = TRUE;
369 : Isibaar 1.1
370 : h 1.3 switch (config->mode)
371 : Isibaar 1.1 {
372 : h 1.3 default :
373 :     enabled = FALSE;
374 : Isibaar 1.1
375 : h 1.3 case DLG_MODE_CBR :
376 :     text = "Bitrate (Kbps):";
377 : h 1.8 value = config->rc_bitrate / CONFIG_KBPS;
378 : Isibaar 1.1 break;
379 :    
380 : h 1.3 case DLG_MODE_VBR_QUAL :
381 :     text = "Quality:";
382 :     value = config->quality;
383 : Isibaar 1.1 break;
384 :    
385 : h 1.3 case DLG_MODE_VBR_QUANT :
386 :     text = "Quantizer:";
387 :     value = config->quant;
388 : Isibaar 1.1 break;
389 :    
390 : h 1.3 case DLG_MODE_2PASS_2_INT :
391 :     text = "Desired size (Kbtyes):";
392 :     value = config->desired_size;
393 : Isibaar 1.1 break;
394 :     }
395 : h 1.3
396 :     SetDlgItemText(hDlg, IDC_VALUE_STATIC, text);
397 :     SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE);
398 :    
399 :     EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);
400 :     EnableWindow(GetDlgItem(hDlg, IDC_VALUE), enabled);
401 : Isibaar 1.1 }
402 :    
403 :    
404 :     /* updates the slider */
405 :    
406 : h 1.3 void main_slider(HWND hDlg, CONFIG * config)
407 : Isibaar 1.1 {
408 :     char* text;
409 :     long range;
410 :     int pos;
411 : h 1.3 int enabled = TRUE;
412 : Isibaar 1.1
413 :     switch (config->mode)
414 :     {
415 :     default :
416 : h 1.3 enabled = FALSE;
417 :    
418 : Isibaar 1.1 case DLG_MODE_CBR :
419 :     text = "Bitrate (Kbps):";
420 :     range = MAKELONG(0,10000);
421 : h 1.8 pos = config->rc_bitrate / CONFIG_KBPS;
422 : Isibaar 1.1 break;
423 :    
424 :     case DLG_MODE_VBR_QUAL :
425 :     text = "Quality:";
426 :     range = MAKELONG(0,100);
427 :     pos = config->quality;
428 :     break;
429 :    
430 :     case DLG_MODE_VBR_QUANT :
431 :     text = "Quantizer:";
432 :     range = MAKELONG(1,31);
433 :     pos = config->quant;
434 :     break;
435 :     }
436 :    
437 :     SetDlgItemText(hDlg, IDC_SLIDER_STATIC, text);
438 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, range);
439 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, pos);
440 : h 1.3
441 :     EnableWindow(GetDlgItem(hDlg, IDC_SLIDER_STATIC), enabled);
442 :     EnableWindow(GetDlgItem(hDlg, IDC_SLIDER), enabled);
443 : Isibaar 1.1 }
444 :    
445 :    
446 : h 1.3 /* load advanced options property sheet */
447 : Isibaar 1.1
448 : h 1.3 void adv_dialog(HWND hParent, CONFIG * config)
449 : Isibaar 1.1 {
450 : h 1.3 PROPSHEETINFO psi[DLG_COUNT];
451 :     PROPSHEETPAGE psp[DLG_COUNT];
452 :     PROPSHEETHEADER psh;
453 :     CONFIG temp;
454 :     int i;
455 :    
456 :     config->save = FALSE;
457 :     memcpy(&temp, config, sizeof(CONFIG));
458 : Isibaar 1.1
459 : h 1.3 for (i=0 ; i<DLG_COUNT ; ++i)
460 : Isibaar 1.1 {
461 : h 1.3 psp[i].dwSize = sizeof(PROPSHEETPAGE);
462 :     psp[i].dwFlags = 0;
463 :     psp[i].hInstance = hInst;
464 :     psp[i].pfnDlgProc = adv_proc;
465 :     psp[i].lParam = (LPARAM)&psi[i];
466 :     psp[i].pfnCallback = NULL;
467 :    
468 :     psi[i].page = i;
469 :     psi[i].config = &temp;
470 :     }
471 :    
472 :     psp[DLG_GLOBAL].pszTemplate = MAKEINTRESOURCE(IDD_GLOBAL);
473 :     psp[DLG_QUANT].pszTemplate = MAKEINTRESOURCE(IDD_QUANT);
474 :     psp[DLG_2PASS].pszTemplate = MAKEINTRESOURCE(IDD_2PASS);
475 : h 1.4 psp[DLG_2PASSALT].pszTemplate = MAKEINTRESOURCE(IDD_2PASSALT);
476 : h 1.3 psp[DLG_CREDITS].pszTemplate = MAKEINTRESOURCE(IDD_CREDITS);
477 :     psp[DLG_CPU].pszTemplate = MAKEINTRESOURCE(IDD_CPU);
478 :    
479 :     psh.dwSize = sizeof(PROPSHEETHEADER);
480 :     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
481 :     psh.hwndParent = hParent;
482 :     psh.hInstance = hInst;
483 :     psh.pszCaption = (LPSTR) "XviD Configuration";
484 :     psh.nPages = DLG_COUNT;
485 :     psh.nStartPage = DLG_GLOBAL;
486 :     psh.ppsp = (LPCPROPSHEETPAGE)&psp;
487 :     psh.pfnCallback = NULL;
488 : Isibaar 1.1
489 : h 1.3 PropertySheet(&psh);
490 : Isibaar 1.1
491 : h 1.3 if (temp.save)
492 :     {
493 :     memcpy(config, &temp, sizeof(CONFIG));
494 : Isibaar 1.1 }
495 : h 1.3 }
496 : Isibaar 1.1
497 :    
498 : h 1.3 /* enable/disable advanced controls based on encoder mode */
499 : Isibaar 1.1
500 : h 1.3 #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))
501 :     #define ISDLGSET(X) (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)
502 : Isibaar 1.1
503 : h 1.4 #define MOD_CBR
504 :    
505 : h 1.3 void adv_mode(HWND hDlg, int mode)
506 : Isibaar 1.1 {
507 : h 1.3 // create arrays of controls to be disabled for each mode
508 : h 1.10 const short twopass_disable[] = {
509 :     IDC_KFBOOST, IDC_DUMMY2PASS, IDC_USEALT,
510 : Foxer 1.15 // added by koepi for new curve treatment
511 :     IDC_KFTRESHOLD, IDC_KFREDUCTION,
512 :     //end of koepi's additions
513 : h 1.3 IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,
514 : h 1.10 IDC_STATS2, IDC_STATS2_BROWSE,
515 :     };
516 :    
517 :     const short cbr_disable[] = {
518 :     IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
519 : h 1.3 IDC_CREDITS_START, IDC_CREDITS_END, IDC_CREDITS_START_BEGIN, IDC_CREDITS_START_END,
520 :     IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO,
521 :     IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO,
522 : chl 1.17 IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,
523 : Foxer 1.18 IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE, IDC_CREDITS_GREYSCALE, IDC_HINTFILE
524 : h 1.3 };
525 :    
526 : h 1.10 const short qual_disable[] = {
527 :     IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
528 : h 1.8 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
529 : Foxer 1.18 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,
530 :     IDC_HINTFILE
531 : h 1.3 };
532 :    
533 : h 1.10 const short quant_disable[] = {
534 :     IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
535 : h 1.8 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
536 : h 1.3 IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,
537 : Foxer 1.18 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,
538 :     IDC_HINTFILE
539 : h 1.3 };
540 :    
541 : h 1.10 const short twopass1_disable[] = {
542 : h 1.8 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
543 : h 1.9 IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,
544 : h 1.3 IDC_CREDITS_RATE_RADIO, IDC_CREDITS_RATE, IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC,
545 :     IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
546 :     };
547 :    
548 : h 1.10 const short twopass2_ext_disable[] = {
549 : h 1.8 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
550 : suxen_drol 1.20.2.2 IDC_CREDITS_RATE_RADIO,
551 : h 1.3 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,
552 : suxen_drol 1.20.2.2 IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
553 : h 1.3 };
554 :    
555 : h 1.10 const short twopass2_int_disable[] = {
556 : h 1.8 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
557 : h 1.3 IDC_STATS2, IDC_STATS2_BROWSE
558 :     };
559 :    
560 :     // store pointers in order so we can lookup using config->mode
561 : h 1.10 const short* modes[] = {
562 : h 1.3 cbr_disable, qual_disable, quant_disable,
563 :     twopass1_disable, twopass2_ext_disable, twopass2_int_disable
564 :     };
565 :    
566 :     // ditto modes[]
567 :     const int lengths[] = {
568 : h 1.10 sizeof(cbr_disable)/sizeof(short), sizeof(qual_disable)/sizeof(short),
569 :     sizeof(quant_disable)/sizeof(short), sizeof(twopass1_disable)/sizeof(short),
570 :     sizeof(twopass2_ext_disable)/sizeof(short), sizeof(twopass2_int_disable)/sizeof(short), 0
571 : h 1.3 };
572 :    
573 :     int i;
574 : h 1.10 int hinted_me, use_alt, use_alt_auto, use_alt_auto_bonus;
575 :     int credits_start, credits_end, credits_rate, credits_quant, credits_size;
576 :     int cpu_force;
577 : Isibaar 1.1
578 : h 1.3 // first perform checkbox-based enable/disable
579 : h 1.10 hinted_me = ISDLGSET(IDC_HINTEDME);
580 :     CONTROLDLG(IDC_HINTFILE, hinted_me);
581 :     CONTROLDLG(IDC_HINT_BROWSE, hinted_me);
582 :    
583 :     use_alt = ISDLGSET(IDC_USEALT) && (mode == DLG_MODE_2PASS_2_EXT || mode == DLG_MODE_2PASS_2_INT);
584 :     use_alt_auto = ISDLGSET(IDC_USEAUTO);
585 :     use_alt_auto_bonus = ISDLGSET(IDC_USEAUTOBONUS);
586 :     CONTROLDLG(IDC_USEAUTO, use_alt);
587 :     CONTROLDLG(IDC_AUTOSTR, use_alt && use_alt_auto);
588 :     CONTROLDLG(IDC_USEAUTOBONUS, use_alt);
589 :     CONTROLDLG(IDC_BONUSBIAS, use_alt && !use_alt_auto_bonus);
590 :     CONTROLDLG(IDC_CURVETYPE, use_alt);
591 :     CONTROLDLG(IDC_ALTCURVEHIGH, use_alt);
592 :     CONTROLDLG(IDC_ALTCURVELOW, use_alt);
593 :     CONTROLDLG(IDC_MINQUAL, use_alt && !use_alt_auto);
594 :    
595 :     credits_start = ISDLGSET(IDC_CREDITS_START);
596 :     CONTROLDLG(IDC_CREDITS_START_BEGIN, credits_start);
597 :     CONTROLDLG(IDC_CREDITS_START_END, credits_start);
598 :    
599 :     credits_end = ISDLGSET(IDC_CREDITS_END);
600 :     CONTROLDLG(IDC_CREDITS_END_BEGIN, credits_end);
601 :     CONTROLDLG(IDC_CREDITS_END_END, credits_end);
602 :    
603 :     credits_rate = ISDLGSET(IDC_CREDITS_RATE_RADIO);
604 :     credits_quant = ISDLGSET(IDC_CREDITS_QUANT_RADIO);
605 :     credits_size = ISDLGSET(IDC_CREDITS_SIZE_RADIO);
606 :     CONTROLDLG(IDC_CREDITS_RATE, credits_rate);
607 :     CONTROLDLG(IDC_CREDITS_QUANTI, credits_quant);
608 :     CONTROLDLG(IDC_CREDITS_QUANTP, credits_quant);
609 :     CONTROLDLG(IDC_CREDITS_START_SIZE, credits_size);
610 :     CONTROLDLG(IDC_CREDITS_END_SIZE, credits_size);
611 :    
612 :     cpu_force = ISDLGSET(IDC_CPU_FORCE);
613 :     CONTROLDLG(IDC_CPU_MMX, cpu_force);
614 :     CONTROLDLG(IDC_CPU_MMXEXT, cpu_force);
615 :     CONTROLDLG(IDC_CPU_SSE, cpu_force);
616 :     CONTROLDLG(IDC_CPU_SSE2, cpu_force);
617 :     CONTROLDLG(IDC_CPU_3DNOW, cpu_force);
618 :     CONTROLDLG(IDC_CPU_3DNOWEXT, cpu_force);
619 : Isibaar 1.1
620 : h 1.3 // now perform codec mode enable/disable
621 :     for (i=0 ; i<lengths[mode] ; ++i)
622 :     {
623 :     EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE);
624 : Isibaar 1.1 }
625 : h 1.10
626 :     if (mode != DLG_MODE_2PASS_2_EXT && mode != DLG_MODE_2PASS_2_INT)
627 :     {
628 :     for (i=0 ; i<sizeof(twopass_disable)/sizeof(short) ; ++i)
629 :     {
630 :     EnableWindow(GetDlgItem(hDlg, twopass_disable[i]), FALSE);
631 :     }
632 :     }
633 : Isibaar 1.1 }
634 :    
635 :    
636 : h 1.3 /* upload config data into dialog */
637 : Isibaar 1.1
638 : h 1.3 void adv_upload(HWND hDlg, int page, CONFIG * config)
639 : Isibaar 1.1 {
640 : h 1.3 switch (page)
641 :     {
642 :     case DLG_GLOBAL :
643 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0);
644 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);
645 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
646 : syskin 1.20.2.7 SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0);
647 : h 1.3 SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
648 : h 1.7 SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);
649 : h 1.3 CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);
650 : Foxer 1.18 CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED);
651 : suxen_drol 1.20.2.2
652 :     CheckDlgButton(hDlg, IDC_QPEL, config->qpel ? BST_CHECKED : BST_UNCHECKED);
653 :     CheckDlgButton(hDlg, IDC_GMC, config->gmc ? BST_CHECKED : BST_UNCHECKED);
654 :     CheckDlgButton(hDlg, IDC_CHROMAME, config->chromame ? BST_CHECKED : BST_UNCHECKED);
655 : chl 1.16 // added by koepi for gruel's greyscale_mode
656 : Foxer 1.18 CheckDlgButton(hDlg, IDC_GREYSCALE, config->greyscale ? BST_CHECKED : BST_UNCHECKED);
657 :     // end of koepi's addition
658 : suxen_drol 1.11 SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, TRUE);
659 :     SetDlgItemInt(hDlg, IDC_BQUANTRATIO, config->bquant_ratio, FALSE);
660 : suxen_drol 1.20.2.2 SetDlgItemInt(hDlg, IDC_BQUANTOFFSET, config->bquant_offset, FALSE);
661 : suxen_drol 1.11 CheckDlgButton(hDlg, IDC_PACKED, config->packed ? BST_CHECKED : BST_UNCHECKED);
662 : suxen_drol 1.12 CheckDlgButton(hDlg, IDC_DX50BVOP, config->dx50bvop ? BST_CHECKED : BST_UNCHECKED);
663 :     CheckDlgButton(hDlg, IDC_DEBUG, config->debug ? BST_CHECKED : BST_UNCHECKED);
664 : suxen_drol 1.20.2.6
665 :     CheckDlgButton(hDlg, IDC_REDUCED, config->reduced_resolution ? BST_CHECKED : BST_UNCHECKED);
666 : h 1.3 break;
667 : Isibaar 1.1
668 : h 1.3 case DLG_QUANT :
669 :     SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE);
670 :     SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE);
671 :     SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE);
672 :     SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE);
673 :     break;
674 : Isibaar 1.1
675 : h 1.3 case DLG_2PASS :
676 :     SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);
677 :     CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);
678 :     CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED);
679 : Foxer 1.15 // added by koepi for new 2pass curve treatment
680 :     SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE);
681 :     SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);
682 :     // end of koepi's additions
683 : h 1.3 SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);
684 :     SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);
685 :     SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);
686 :     CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));
687 :     CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));
688 : Isibaar 1.1
689 : h 1.6 CheckDlgButton(hDlg, IDC_HINTEDME, config->hinted_me ? BST_CHECKED : BST_UNCHECKED);
690 :     SetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile);
691 : h 1.3 SetDlgItemText(hDlg, IDC_STATS1, config->stats1);
692 :     SetDlgItemText(hDlg, IDC_STATS2, config->stats2);
693 :     break;
694 : Isibaar 1.1
695 : h 1.4 case DLG_2PASSALT :
696 :     CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED);
697 :    
698 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0);
699 :     SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE);
700 :     SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE);
701 :     SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE);
702 :    
703 :     CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED);
704 :     SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE);
705 :    
706 :     CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED);
707 :     SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE);
708 : h 1.7
709 :     SetDlgItemInt(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate / CONFIG_KBPS, FALSE);
710 :     SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);
711 :     SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);
712 : h 1.4 break;
713 :    
714 : h 1.3 case DLG_CREDITS :
715 :     CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);
716 :     SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE);
717 :     SetDlgItemInt(hDlg, IDC_CREDITS_START_END, config->credits_start_end, FALSE);
718 :     CheckDlgButton(hDlg, IDC_CREDITS_END, config->credits_end ? BST_CHECKED : BST_UNCHECKED);
719 :     SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE);
720 :     SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE);
721 : Isibaar 1.1
722 : Foxer 1.18 // added by koepi for credits greyscale
723 :     CheckDlgButton(hDlg, IDC_CREDITS_GREYSCALE, config->credits_greyscale ? BST_CHECKED : BST_UNCHECKED);
724 :     // end of koepi's addition
725 : h 1.3 SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE);
726 :     SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE);
727 :     SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE);
728 :     SetDlgItemInt(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size, FALSE);
729 :     SetDlgItemInt(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size, FALSE);
730 : Isibaar 1.1
731 : h 1.3 if (config->credits_mode == CREDITS_MODE_RATE)
732 :     {
733 :     CheckDlgButton(hDlg, IDC_CREDITS_RATE_RADIO, BST_CHECKED);
734 :     }
735 :     else if (config->credits_mode == CREDITS_MODE_QUANT)
736 :     {
737 :     CheckDlgButton(hDlg, IDC_CREDITS_QUANT_RADIO, BST_CHECKED);
738 :     }
739 :     else // CREDITS_MODE_SIZE
740 :     {
741 :     CheckDlgButton(hDlg, IDC_CREDITS_SIZE_RADIO, BST_CHECKED);
742 :     }
743 :     break;
744 : Isibaar 1.1
745 : h 1.3 case DLG_CPU :
746 :     CheckDlgButton(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX) ? BST_CHECKED : BST_UNCHECKED);
747 :     CheckDlgButton(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT) ? BST_CHECKED : BST_UNCHECKED);
748 :     CheckDlgButton(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE) ? BST_CHECKED : BST_UNCHECKED);
749 :     CheckDlgButton(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2) ? BST_CHECKED : BST_UNCHECKED);
750 :     CheckDlgButton(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW) ? BST_CHECKED : BST_UNCHECKED);
751 :     CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT) ? BST_CHECKED : BST_UNCHECKED);
752 : Isibaar 1.1
753 : h 1.3 CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,
754 :     config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );
755 : h 1.8
756 : suxen_drol 1.13 #ifdef _SMP
757 :     SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);
758 :     #endif
759 : suxen_drol 1.14 SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);
760 : h 1.8 SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);
761 :     SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);
762 :     SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);
763 : h 1.3 break;
764 : Isibaar 1.1 }
765 :     }
766 :    
767 :    
768 : h 1.3 /* download config data from dialog
769 :     replaces invalid values instead of alerting user for now
770 :     */
771 :    
772 :     #define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z;
773 : Isibaar 1.1
774 : h 1.3 void adv_download(HWND hDlg, int page, CONFIG * config)
775 : Isibaar 1.1 {
776 : h 1.3 switch (page)
777 :     {
778 :     case DLG_GLOBAL :
779 :     config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);
780 :     config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);
781 :     config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
782 : syskin 1.20.2.7 config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0);
783 : suxen_drol 1.11 config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval);
784 :     config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval);
785 : h 1.3 config->lum_masking = ISDLGSET(IDC_LUMMASK);
786 : Foxer 1.18 config->interlacing = ISDLGSET(IDC_INTERLACING);
787 : suxen_drol 1.20.2.2
788 :     config->qpel = ISDLGSET(IDC_QPEL);
789 :     config->gmc = ISDLGSET(IDC_GMC);
790 :     config->chromame = ISDLGSET(IDC_CHROMAME);
791 : Foxer 1.18 // added by koepi for gruel's greyscale_mode
792 :     config->greyscale = ISDLGSET(IDC_GREYSCALE);
793 : chl 1.16 // end of koepi's addition
794 : suxen_drol 1.11 config->max_bframes = config_get_int(hDlg, IDC_MAXBFRAMES, config->max_bframes);
795 :     config->bquant_ratio = config_get_uint(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
796 : suxen_drol 1.20.2.2 config->bquant_offset = config_get_uint(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
797 : suxen_drol 1.11 config->packed = ISDLGSET(IDC_PACKED);
798 : suxen_drol 1.12 config->dx50bvop = ISDLGSET(IDC_DX50BVOP);
799 :     config->debug = ISDLGSET(IDC_DEBUG);
800 : suxen_drol 1.20.2.6 config->reduced_resolution = ISDLGSET(IDC_REDUCED);
801 : h 1.3 break;
802 :    
803 :     case DLG_QUANT :
804 : suxen_drol 1.11 config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);
805 :     config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);
806 :     config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);
807 :     config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);
808 : h 1.3
809 :     CONSTRAINVAL(config->min_iquant, 1, 31);
810 :     CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);
811 :     CONSTRAINVAL(config->min_pquant, 1, 31);
812 :     CONSTRAINVAL(config->max_pquant, config->min_pquant, 31);
813 :     break;
814 :    
815 :     case DLG_2PASS :
816 :     config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);
817 : Foxer 1.15 // added by koepi for the new 2pass curve treatment
818 :     config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE);
819 :     config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);
820 :     //end of koepi's additions
821 : h 1.3 config->discard1pass = ISDLGSET(IDC_DISCARD1PASS);
822 :     config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS);
823 :     config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);
824 :     config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
825 : suxen_drol 1.11 config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);
826 : h 1.3 config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);
827 : h 1.6 config->hinted_me = ISDLGSET(IDC_HINTEDME);
828 : h 1.3
829 : h 1.6 if (GetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile, MAX_PATH) == 0)
830 :     {
831 :     lstrcpy(config->hintfile, CONFIG_HINTFILE);
832 :     }
833 : h 1.3 if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)
834 :     {
835 :     lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);
836 :     }
837 :     if (GetDlgItemText(hDlg, IDC_STATS2, config->stats2, MAX_PATH) == 0)
838 :     {
839 :     lstrcpy(config->stats2, CONFIG_2PASS_2_FILE);
840 :     }
841 :    
842 :     CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000);
843 :     CONSTRAINVAL(config->keyframe_boost, 0, 1000);
844 :     CONSTRAINVAL(config->curve_compression_high, 0, 100);
845 :     CONSTRAINVAL(config->curve_compression_low, 0, 100);
846 :     break;
847 :    
848 : h 1.4 case DLG_2PASSALT :
849 :     config->use_alt_curve = ISDLGSET(IDC_USEALT);
850 :    
851 :     config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO);
852 : suxen_drol 1.11 config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str);
853 : h 1.4
854 :     config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS);
855 : suxen_drol 1.11 config->alt_curve_bonus_bias = config_get_uint(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias);
856 : h 1.4
857 :     config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0);
858 : suxen_drol 1.11 config->alt_curve_high_dist = config_get_uint(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist);
859 :     config->alt_curve_low_dist = config_get_uint(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist);
860 :     config->alt_curve_min_rel_qual = config_get_uint(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual);
861 : h 1.7
862 :     config->twopass_max_bitrate /= CONFIG_KBPS;
863 : suxen_drol 1.11 config->twopass_max_bitrate = config_get_uint(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate);
864 : h 1.7 config->twopass_max_bitrate *= CONFIG_KBPS;
865 : suxen_drol 1.11 config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);
866 :     config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);
867 : h 1.7
868 :     CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);
869 :     CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);
870 : h 1.4 break;
871 :    
872 : h 1.3 case DLG_CREDITS :
873 :     config->credits_start = ISDLGSET(IDC_CREDITS_START);
874 :     config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);
875 : suxen_drol 1.11 config->credits_start_end = config_get_uint(hDlg, IDC_CREDITS_START_END, config->credits_start_end);
876 : h 1.3 config->credits_end = ISDLGSET(IDC_CREDITS_END);
877 : suxen_drol 1.11 config->credits_end_begin = config_get_uint(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin);
878 :     config->credits_end_end = config_get_uint(hDlg, IDC_CREDITS_END_END, config->credits_end_end);
879 : h 1.3
880 : Foxer 1.18 // added by koepi for gruel's greyscale_mode
881 :     config->credits_greyscale = ISDLGSET(IDC_CREDITS_GREYSCALE);
882 :     // end of koepi's addition
883 : suxen_drol 1.11 config->credits_rate = config_get_uint(hDlg, IDC_CREDITS_RATE, config->credits_rate);
884 :     config->credits_quant_i = config_get_uint(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i);
885 :     config->credits_quant_p = config_get_uint(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p);
886 :     config->credits_start_size = config_get_uint(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size);
887 :     config->credits_end_size = config_get_uint(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size);
888 : h 1.3
889 :     config->credits_mode = 0;
890 :     config->credits_mode = ISDLGSET(IDC_CREDITS_RATE_RADIO) ? CREDITS_MODE_RATE : config->credits_mode;
891 :     config->credits_mode = ISDLGSET(IDC_CREDITS_QUANT_RADIO) ? CREDITS_MODE_QUANT : config->credits_mode;
892 :     config->credits_mode = ISDLGSET(IDC_CREDITS_SIZE_RADIO) ? CREDITS_MODE_SIZE : config->credits_mode;
893 :    
894 :     CONSTRAINVAL(config->credits_rate, 1, 100);
895 :     CONSTRAINVAL(config->credits_quant_i, 1, 31);
896 :     CONSTRAINVAL(config->credits_quant_p, 1, 31);
897 :    
898 :     if (config->credits_start_begin > config->credits_start_end)
899 :     {
900 :     config->credits_start_begin = config->credits_start_end;
901 :     config->credits_start = 0;
902 :     }
903 :     if (config->credits_end_begin > config->credits_end_end)
904 :     {
905 :     config->credits_end_begin = config->credits_end_end;
906 :     config->credits_end = 0;
907 :     }
908 :     break;
909 :    
910 :     case DLG_CPU :
911 :     config->cpu = 0;
912 :     config->cpu |= ISDLGSET(IDC_CPU_MMX) ? XVID_CPU_MMX : 0;
913 :     config->cpu |= ISDLGSET(IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT: 0;
914 :     config->cpu |= ISDLGSET(IDC_CPU_SSE) ? XVID_CPU_SSE: 0;
915 :     config->cpu |= ISDLGSET(IDC_CPU_SSE2) ? XVID_CPU_SSE2: 0;
916 :     config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0;
917 :     config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0;
918 :     config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;
919 : h 1.8
920 : suxen_drol 1.13 #ifdef _SMP
921 :     config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);
922 :     #endif
923 : suxen_drol 1.14 config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);
924 : suxen_drol 1.11 config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);
925 :     config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);
926 :     config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);
927 : h 1.3 break;
928 :     }
929 :     }
930 :    
931 :    
932 :     void quant_upload(HWND hDlg, CONFIG* config)
933 :     {
934 :     int i;
935 :    
936 :     for (i=0 ; i<64 ; ++i)
937 :     {
938 :     SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE);
939 :     SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE);
940 :     }
941 :     }
942 :    
943 : Isibaar 1.1
944 : h 1.3 void quant_download(HWND hDlg, CONFIG* config)
945 :     {
946 :     int i;
947 : Isibaar 1.1
948 : h 1.3 for (i=0 ; i<64 ; ++i)
949 : Isibaar 1.1 {
950 : h 1.3 int temp;
951 :    
952 : suxen_drol 1.11 temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);
953 : h 1.3 CONSTRAINVAL(temp, 1, 255);
954 : h 1.10 config->qmatrix_intra[i] = temp;
955 : h 1.3
956 : suxen_drol 1.11 temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);
957 : h 1.3 CONSTRAINVAL(temp, 1, 255);
958 : h 1.10 config->qmatrix_inter[i] = temp;
959 : h 1.3 }
960 :     }
961 : Isibaar 1.1
962 :    
963 : h 1.4 /* enumerates child windows, assigns tooltips */
964 : Isibaar 1.1
965 : h 1.4 BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
966 : h 1.3 {
967 : h 1.4 char help[500];
968 : Isibaar 1.1
969 : h 1.4 if (LoadString(hInst, GetDlgCtrlID(hWnd), help, 500))
970 : h 1.3 {
971 : h 1.4 TOOLINFO ti;
972 : Isibaar 1.1
973 : h 1.4 ti.cbSize = sizeof(TOOLINFO);
974 :     ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
975 :     ti.hwnd = GetParent(hWnd);
976 :     ti.uId = (LPARAM)hWnd;
977 :     ti.lpszText = help;
978 : Isibaar 1.1
979 : h 1.4 SendMessage(hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
980 : h 1.3 }
981 :    
982 : h 1.4 return TRUE;
983 : h 1.3 }
984 :    
985 :    
986 : suxen_drol 1.20.2.6
987 :     /* --- decoder options dialog --- */
988 :    
989 :     #define DEC_DLG_COUNT 1
990 :     #define DEC_DLG_POSTPROC 0
991 :    
992 :     /* decoder dialog: upload config data */
993 :    
994 :     void dec_upload(HWND hDlg, int page, CONFIG * config)
995 :     {
996 :     switch (page)
997 :     {
998 :     case DEC_DLG_POSTPROC :
999 :     CheckDlgButton(hDlg, IDC_DEBLOCK_Y, config->deblock_y ? BST_CHECKED : BST_UNCHECKED);
1000 :     CheckDlgButton(hDlg, IDC_DEBLOCK_UV, config->deblock_uv ? BST_CHECKED : BST_UNCHECKED);
1001 :     break;
1002 :     }
1003 :     }
1004 :    
1005 :    
1006 :     /* dec dialog: download config data */
1007 :    
1008 :     void dec_download(HWND hDlg, int page, CONFIG * config)
1009 :     {
1010 :     switch (page)
1011 :     {
1012 :     case DEC_DLG_POSTPROC :
1013 :     config->deblock_y = ISDLGSET(IDC_DEBLOCK_Y);
1014 :     config->deblock_uv = ISDLGSET(IDC_DEBLOCK_UV);
1015 :     break;
1016 :     }
1017 :     }
1018 :    
1019 :     /* decoder dialog proc */
1020 :    
1021 :     BOOL CALLBACK dec_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1022 :     {
1023 :     PROPSHEETINFO *psi;
1024 :    
1025 :     psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA);
1026 :    
1027 :     switch (uMsg)
1028 :     {
1029 :     case WM_INITDIALOG :
1030 :     psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;
1031 :    
1032 :     SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);
1033 :    
1034 :     if (hTooltip)
1035 :     {
1036 :     EnumChildWindows(hDlg, enum_tooltips, 0);
1037 :     }
1038 :    
1039 :     dec_upload(hDlg, psi->page, psi->config);
1040 :     break;
1041 :    
1042 :     case WM_NOTIFY :
1043 :     switch (((NMHDR *)lParam)->code)
1044 :     {
1045 :     case PSN_KILLACTIVE :
1046 :     /* validate */
1047 :     dec_download(hDlg, psi->page, psi->config);
1048 :     SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1049 :     break;
1050 :    
1051 :     case PSN_APPLY :
1052 :     /* apply */
1053 :     dec_download(hDlg, psi->page, psi->config);
1054 :     SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1055 :     psi->config->save = TRUE;
1056 :     break;
1057 :     }
1058 :     break;
1059 :    
1060 :     default :
1061 :     return 0;
1062 :     }
1063 :    
1064 :     return 1;
1065 :     }
1066 :    
1067 :    
1068 :     void dec_dialog(HWND hParent, CONFIG * config)
1069 :     {
1070 :     PROPSHEETINFO psi[DEC_DLG_COUNT];
1071 :     PROPSHEETPAGE psp[DEC_DLG_COUNT];
1072 :     PROPSHEETHEADER psh;
1073 :     CONFIG temp;
1074 :     int i;
1075 :    
1076 :     config->save = FALSE;
1077 :     memcpy(&temp, config, sizeof(CONFIG));
1078 :    
1079 :     for (i=0 ; i<DEC_DLG_COUNT ; ++i)
1080 :     {
1081 :     psp[i].dwSize = sizeof(PROPSHEETPAGE);
1082 :     psp[i].dwFlags = 0;
1083 :     psp[i].hInstance = hInst;
1084 :     psp[i].pfnDlgProc = dec_proc;
1085 :     psp[i].lParam = (LPARAM)&psi[i];
1086 :     psp[i].pfnCallback = NULL;
1087 :    
1088 :     psi[i].page = i;
1089 :     psi[i].config = &temp;
1090 :     }
1091 :    
1092 :     psp[DEC_DLG_POSTPROC].pszTemplate = MAKEINTRESOURCE(IDD_POSTPROC);
1093 :    
1094 :     psh.dwSize = sizeof(PROPSHEETHEADER);
1095 :     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
1096 :     psh.hwndParent = hParent;
1097 :     psh.hInstance = hInst;
1098 :     psh.pszCaption = (LPSTR) "XviD Configuration";
1099 :     psh.nPages = DEC_DLG_COUNT;
1100 :     psh.nStartPage = DEC_DLG_POSTPROC;
1101 :     psh.ppsp = (LPCPROPSHEETPAGE)&psp;
1102 :     psh.pfnCallback = NULL;
1103 :    
1104 :     PropertySheet(&psh);
1105 :    
1106 :     if (temp.save)
1107 :     {
1108 :     memcpy(config, &temp, sizeof(CONFIG));
1109 :     }
1110 :     }
1111 :    
1112 :    
1113 :    
1114 : h 1.3 /* main dialog proc */
1115 :    
1116 :     BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1117 :     {
1118 :     CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
1119 :    
1120 :     switch (uMsg)
1121 :     {
1122 :     case WM_INITDIALOG :
1123 :     SetWindowLong(hDlg, GWL_USERDATA, lParam);
1124 :    
1125 :     config = (CONFIG*)lParam;
1126 : Isibaar 1.1
1127 : h 1.3 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - CBR");
1128 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quality");
1129 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quantizer");
1130 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 1st pass");
1131 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Ext.");
1132 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Int.");
1133 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");
1134 : Isibaar 1.1
1135 : h 1.3 SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1136 :    
1137 : h 1.4 InitCommonControls();
1138 : Isibaar 1.1
1139 : h 1.4 if (hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
1140 :     CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1141 :     NULL, NULL, hInst, NULL))
1142 :     {
1143 :     SetWindowPos(hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
1144 :     SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
1145 :     SendMessage(hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
1146 : Isibaar 1.1
1147 : h 1.4 EnumChildWindows(hDlg, enum_tooltips, 0);
1148 : Isibaar 1.1 }
1149 :    
1150 : h 1.4 main_slider(hDlg, config);
1151 :     main_value(hDlg, config);
1152 : Isibaar 1.1 break;
1153 :    
1154 : h 1.3 case WM_HSCROLL :
1155 :     if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER))
1156 :     {
1157 :     SetDlgItemInt(hDlg, IDC_VALUE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE);
1158 :     }
1159 :     else
1160 : Isibaar 1.1 {
1161 : h 1.3 return 0;
1162 : Isibaar 1.1 }
1163 : h 1.3 break;
1164 : Isibaar 1.1
1165 :     case WM_COMMAND :
1166 :     if (LOWORD(wParam) == IDC_MODE && HIWORD(wParam) == LBN_SELCHANGE)
1167 :     {
1168 : h 1.3 main_download(hDlg, config);
1169 :     main_slider(hDlg, config);
1170 :     main_value(hDlg, config);
1171 : Isibaar 1.1 }
1172 : h 1.3 else if (LOWORD(wParam) == IDC_ADVANCED && HIWORD(wParam) == BN_CLICKED)
1173 : Isibaar 1.1 {
1174 : h 1.3 adv_dialog(hDlg, config);
1175 :    
1176 :     if (config->save)
1177 :     {
1178 :     config_reg_set(config);
1179 :     }
1180 : Isibaar 1.1 }
1181 : suxen_drol 1.20.2.6 else if (LOWORD(wParam) == IDC_DECODER && HIWORD(wParam) == BN_CLICKED)
1182 :     {
1183 :     dec_dialog(hDlg, config);
1184 :    
1185 :     if (config->save)
1186 :     {
1187 :     config_reg_set(config);
1188 :     }
1189 :     }
1190 : h 1.4 else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED)
1191 :     {
1192 :     config_reg_default(config);
1193 :    
1194 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1195 :    
1196 :     main_slider(hDlg, config);
1197 :     main_value(hDlg, config);
1198 :     }
1199 : Isibaar 1.1 else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)
1200 :     {
1201 : suxen_drol 1.11 int value = config_get_uint(hDlg, IDC_VALUE, 1);
1202 : Isibaar 1.1 int max = 1;
1203 :    
1204 : h 1.3 max = (config->mode == DLG_MODE_CBR) ? 10000 :
1205 :     ((config->mode == DLG_MODE_VBR_QUAL) ? 100 :
1206 :     ((config->mode == DLG_MODE_VBR_QUANT) ? 31 : 1<<30));
1207 : Isibaar 1.1
1208 :     if (value < 1)
1209 :     {
1210 :     value = 1;
1211 :     }
1212 :     if (value > max)
1213 :     {
1214 :     value = max;
1215 :     SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE);
1216 :     }
1217 :    
1218 : h 1.3 if (config->mode != DLG_MODE_2PASS_2_INT)
1219 : Isibaar 1.1 {
1220 : h 1.3 SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, value);
1221 : Isibaar 1.1 }
1222 :     }
1223 : h 1.3 else if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
1224 : Isibaar 1.1 {
1225 : h 1.3 main_download(hDlg, config);
1226 :     config->save = TRUE;
1227 :     EndDialog(hDlg, IDOK);
1228 : Isibaar 1.1 }
1229 : h 1.3 else if (LOWORD(wParam) == IDCANCEL)
1230 : Isibaar 1.1 {
1231 : h 1.3 config->save = FALSE;
1232 :     EndDialog(hDlg, IDCANCEL);
1233 : Isibaar 1.1 }
1234 :     break;
1235 :    
1236 :     default :
1237 :     return 0;
1238 :     }
1239 :    
1240 :     return 1;
1241 :     }
1242 :    
1243 :    
1244 : h 1.3 /* advanced dialog proc */
1245 : Isibaar 1.1
1246 : h 1.3 BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1247 : Isibaar 1.1 {
1248 : h 1.3 PROPSHEETINFO *psi;
1249 :    
1250 :     psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA);
1251 : Isibaar 1.1
1252 :     switch (uMsg)
1253 :     {
1254 :     case WM_INITDIALOG :
1255 : h 1.3 psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;
1256 : Isibaar 1.1
1257 : h 1.3 SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);
1258 : Isibaar 1.1
1259 : h 1.3 if (psi->page == DLG_GLOBAL)
1260 : Isibaar 1.1 {
1261 : h 1.3 SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None");
1262 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low");
1263 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low");
1264 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium");
1265 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High");
1266 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High");
1267 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High");
1268 : Isibaar 1.1
1269 : h 1.3 SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263");
1270 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");
1271 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");
1272 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"Modulated");
1273 : suxen_drol 1.20.2.2 SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"New Modulated HQ");
1274 : Isibaar 1.1
1275 : h 1.3 SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");
1276 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
1277 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
1278 : suxen_drol 1.20.2.6
1279 : syskin 1.20.2.7 SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"0 - Off");
1280 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"1 - Mode Decision");
1281 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"2 - Limited Search");
1282 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"3 - Medium Search");
1283 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"4 - Wide Search");
1284 : suxen_drol 1.20.2.6 /* XXX: reduced resolution is not ready for prime-time */
1285 :     ShowWindow(GetDlgItem(hDlg, IDC_REDUCED), SW_HIDE);
1286 : Isibaar 1.1 }
1287 : h 1.4 else if (psi->page == DLG_2PASSALT)
1288 :     {
1289 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low");
1290 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium");
1291 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High");
1292 :     }
1293 : suxen_drol 1.13 else if (psi->page == DLG_CPU)
1294 :     {
1295 : suxen_drol 1.14 #ifndef _SMP
1296 : suxen_drol 1.13 EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);
1297 :     EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);
1298 : suxen_drol 1.14 #endif
1299 : suxen_drol 1.13 }
1300 : h 1.4
1301 :     if (hTooltip)
1302 :     {
1303 :     EnumChildWindows(hDlg, enum_tooltips, 0);
1304 :     }
1305 : Isibaar 1.1
1306 : h 1.3 adv_upload(hDlg, psi->page, psi->config);
1307 :     adv_mode(hDlg, psi->config->mode);
1308 : Isibaar 1.1 break;
1309 :    
1310 :     case WM_COMMAND :
1311 : h 1.3 if (HIWORD(wParam) == BN_CLICKED)
1312 : Isibaar 1.1 {
1313 :     switch (LOWORD(wParam))
1314 :     {
1315 : h 1.6 case IDC_HINTEDME :
1316 : h 1.4 case IDC_USEALT :
1317 :     case IDC_USEAUTO :
1318 :     case IDC_USEAUTOBONUS :
1319 : Isibaar 1.1 case IDC_CREDITS_START :
1320 :     case IDC_CREDITS_END :
1321 :     case IDC_CREDITS_RATE_RADIO :
1322 :     case IDC_CREDITS_QUANT_RADIO :
1323 :     case IDC_CREDITS_SIZE_RADIO :
1324 : h 1.3 case IDC_CPU_AUTO :
1325 :     case IDC_CPU_FORCE :
1326 :     adv_mode(hDlg, psi->config->mode);
1327 : Isibaar 1.1 break;
1328 : h 1.3 }
1329 :     }
1330 : h 1.6 if ((LOWORD(wParam) == IDC_HINT_BROWSE || LOWORD(wParam) == IDC_STATS1_BROWSE || LOWORD(wParam) == IDC_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED)
1331 : h 1.3 {
1332 :     OPENFILENAME ofn;
1333 :     char tmp[MAX_PATH];
1334 :     int hComponent = (LOWORD(wParam) == IDC_STATS1_BROWSE ? IDC_STATS1 : IDC_STATS2);
1335 : Isibaar 1.1
1336 : h 1.3 GetDlgItemText(hDlg, hComponent, tmp, MAX_PATH);
1337 : Isibaar 1.1
1338 : h 1.3 memset(&ofn, 0, sizeof(OPENFILENAME));
1339 :     ofn.lStructSize = sizeof(OPENFILENAME);
1340 : Isibaar 1.1
1341 : h 1.3 ofn.hwndOwner = hDlg;
1342 :     ofn.lpstrFilter = "bitrate curve (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0";
1343 :     ofn.lpstrFile = tmp;
1344 :     ofn.nMaxFile = MAX_PATH;
1345 :     ofn.Flags = OFN_PATHMUSTEXIST;
1346 : Isibaar 1.1
1347 : h 1.6 if (LOWORD(wParam) == IDC_HINT_BROWSE)
1348 :     {
1349 :     ofn.lpstrFilter = "motion hints (*.mvh)\0*.mvh\0All files (*.*)\0*.*\0\0";
1350 :     if (GetOpenFileName(&ofn))
1351 :     {
1352 :     SetDlgItemText(hDlg, IDC_HINTFILE, tmp);
1353 :     }
1354 :     }
1355 :     else if (LOWORD(wParam) == IDC_STATS1_BROWSE &&
1356 : h 1.3 psi->config->mode == DLG_MODE_2PASS_1)
1357 :     {
1358 :     ofn.Flags |= OFN_OVERWRITEPROMPT;
1359 :     if (GetSaveFileName(&ofn))
1360 : Isibaar 1.1 {
1361 : h 1.3 SetDlgItemText(hDlg, hComponent, tmp);
1362 : Isibaar 1.1 }
1363 : h 1.3 }
1364 :     else
1365 :     {
1366 :     ofn.Flags |= OFN_FILEMUSTEXIST;
1367 :     if (GetOpenFileName(&ofn)) {
1368 :     SetDlgItemText(hDlg, hComponent, tmp);
1369 : Isibaar 1.1 }
1370 :     }
1371 :     }
1372 : h 1.3 else if (LOWORD(wParam) == IDC_QUANTMATRIX && HIWORD(wParam) == BN_CLICKED)
1373 :     {
1374 :     DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config);
1375 :     }
1376 : Isibaar 1.1 break;
1377 :    
1378 : h 1.3 case WM_NOTIFY :
1379 :     switch (((NMHDR *)lParam)->code)
1380 :     {
1381 :     case PSN_KILLACTIVE :
1382 :     /* validate */
1383 :     adv_download(hDlg, psi->page, psi->config);
1384 :     SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1385 :     break;
1386 : Isibaar 1.1
1387 : h 1.3 case PSN_APPLY :
1388 :     /* apply */
1389 :     adv_download(hDlg, psi->page, psi->config);
1390 :     SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1391 :     psi->config->save = TRUE;
1392 :     break;
1393 : Isibaar 1.1 }
1394 :     break;
1395 :    
1396 :     default :
1397 :     return 0;
1398 :     }
1399 :    
1400 :     return 1;
1401 :     }
1402 :    
1403 :    
1404 :     /* quantization matrix dialog proc */
1405 :    
1406 :     BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1407 :     {
1408 :     CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
1409 :    
1410 :     switch (uMsg)
1411 :     {
1412 :     case WM_INITDIALOG :
1413 :     SetWindowLong(hDlg, GWL_USERDATA, lParam);
1414 :     config = (CONFIG*)lParam;
1415 :     quant_upload(hDlg, config);
1416 :    
1417 : h 1.4 if (hTooltip)
1418 : h 1.3 {
1419 : h 1.4 EnumChildWindows(hDlg, enum_tooltips, 0);
1420 : h 1.3 }
1421 : h 1.4 break;
1422 : h 1.3
1423 : Isibaar 1.1 case WM_COMMAND :
1424 :     if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
1425 :     {
1426 :     quant_download(hDlg, config);
1427 :     EndDialog(hDlg, IDOK);
1428 :     }
1429 :     else if (LOWORD(wParam) == IDCANCEL)
1430 :     {
1431 :     EndDialog(hDlg, IDCANCEL);
1432 :     }
1433 :     else if ((LOWORD(wParam) == IDC_LOAD || LOWORD(wParam) == IDC_SAVE) && HIWORD(wParam) == BN_CLICKED)
1434 :     {
1435 :     OPENFILENAME ofn;
1436 :     char file[MAX_PATH];
1437 :    
1438 :     HANDLE hFile;
1439 :     DWORD read=128, wrote=0;
1440 :     BYTE quant_data[128];
1441 :    
1442 :     strcpy(file, "\\matrix");
1443 :     memset(&ofn, 0, sizeof(OPENFILENAME));
1444 :     ofn.lStructSize = sizeof(OPENFILENAME);
1445 :    
1446 :     ofn.hwndOwner = hDlg;
1447 :     ofn.lpstrFilter = "All files (*.*)\0*.*\0\0";
1448 :     ofn.lpstrFile = file;
1449 :     ofn.nMaxFile = MAX_PATH;
1450 :     ofn.Flags = OFN_PATHMUSTEXIST;
1451 :    
1452 :     if (LOWORD(wParam) == IDC_SAVE)
1453 :     {
1454 :     ofn.Flags |= OFN_OVERWRITEPROMPT;
1455 :     if (GetSaveFileName(&ofn))
1456 :     {
1457 :     hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
1458 :    
1459 :     quant_download(hDlg, config);
1460 :     memcpy(quant_data, config->qmatrix_intra, 64);
1461 :     memcpy(quant_data+64, config->qmatrix_inter, 64);
1462 :    
1463 :     if (hFile == INVALID_HANDLE_VALUE)
1464 :     {
1465 : h 1.4 DEBUGERR("Couldn't save quant matrix");
1466 : Isibaar 1.1 }
1467 :     else
1468 :     {
1469 :     if (!WriteFile(hFile, quant_data, 128, &wrote, 0))
1470 :     {
1471 : h 1.4 DEBUGERR("Couldnt write quant matrix");
1472 : Isibaar 1.1 }
1473 :     }
1474 :    
1475 :     CloseHandle(hFile);
1476 :     }
1477 :     }
1478 :     else
1479 :     {
1480 :     ofn.Flags |= OFN_FILEMUSTEXIST;
1481 :     if (GetOpenFileName(&ofn))
1482 :     {
1483 :     hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
1484 :    
1485 :     if (hFile == INVALID_HANDLE_VALUE)
1486 :     {
1487 : h 1.4 DEBUGERR("Couldn't load quant matrix");
1488 : Isibaar 1.1 }
1489 :     else
1490 :     {
1491 :     if (!ReadFile(hFile, quant_data, 128, &read, 0))
1492 :     {
1493 : h 1.4 DEBUGERR("Couldnt read quant matrix");
1494 : Isibaar 1.1 }
1495 :     else
1496 :     {
1497 :     memcpy(config->qmatrix_intra, quant_data, 64);
1498 :     memcpy(config->qmatrix_inter, quant_data+64, 64);
1499 :     quant_upload(hDlg, config);
1500 :     }
1501 :     }
1502 :    
1503 :     CloseHandle(hFile);
1504 :     }
1505 :     }
1506 : h 1.3 }
1507 :     break;
1508 :    
1509 :     default :
1510 :     return 0;
1511 :     }
1512 :    
1513 :     return 1;
1514 :     }
1515 :    
1516 :    
1517 :     /* about dialog proc */
1518 :    
1519 :     BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1520 :     {
1521 :     switch (uMsg)
1522 :     {
1523 :     case WM_INITDIALOG :
1524 :     {
1525 :     XVID_INIT_PARAM init_param;
1526 :     char core[100];
1527 :     HFONT hFont;
1528 :     LOGFONT lfData;
1529 :    
1530 : Foxer 1.18 SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD);
1531 : chl 1.17 SetDlgItemText(hDlg, IDC_SPECIAL_BUILD, XVID_SPECIAL_BUILD);
1532 : h 1.3
1533 : suxen_drol 1.12 init_param.cpu_flags = XVID_CPU_CHKONLY;
1534 : h 1.3 xvid_init(NULL, 0, &init_param, 0);
1535 :     wsprintf(core, "Core Version %d.%d", (init_param.api_version>>16),(init_param.api_version&0xFFFFU));
1536 :     SetDlgItemText(hDlg, IDC_CORE, core);
1537 :    
1538 :     hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L);
1539 :    
1540 :     if (GetObject(hFont, sizeof(LOGFONT), &lfData))
1541 :     {
1542 :     lfData.lfUnderline = 1;
1543 :    
1544 :     hFont = CreateFontIndirect(&lfData);
1545 :     if (hFont)
1546 :     {
1547 :     SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L);
1548 :     }
1549 :     }
1550 :    
1551 :     SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));
1552 :     SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE);
1553 :     }
1554 :     break;
1555 :    
1556 :     case WM_CTLCOLORSTATIC :
1557 :     if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE))
1558 :     {
1559 :     SetBkMode((HDC)wParam, TRANSPARENT) ;
1560 :     SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0));
1561 :     return (BOOL)GetStockObject(NULL_BRUSH);
1562 :     }
1563 :     return 0;
1564 :    
1565 :     case WM_COMMAND :
1566 :     if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED)
1567 :     {
1568 :     ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL);
1569 :     }
1570 :     else if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
1571 :     {
1572 :     EndDialog(hDlg, LOWORD(wParam));
1573 : Isibaar 1.1 }
1574 :     break;
1575 :    
1576 :     default :
1577 :     return 0;
1578 :     }
1579 :    
1580 :     return 1;
1581 :     }

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4