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

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