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