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