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

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