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

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

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