[svn] / branches / dev-api-3 / vfw / src / config.c Repository:
ViewVC logotype

Annotation of /branches/dev-api-3/vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 670 - (view) (download)

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

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