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