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