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

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