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

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