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