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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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