[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 355 - (view) (download)

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

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