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

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