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

Annotation of /trunk/vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


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

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