[svn] / trunk / vfw / src / config.c Repository:
ViewVC logotype

Annotation of /trunk/vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


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

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