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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 324 - (view) (download)
Original Path: trunk/vfw/src/config.c

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

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