Parent Directory | Revision Log
Revision 24 -
(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 : | * ... ??? | ||
27 : | chenm001 | 24 | * 11.03.2002 Version 0.02; Min Chen <chenm001@163.com> |
28 : | * now get Core Version use xvid_init() | ||
29 : | Isibaar | 3 | * 05.03.2002 Version 0.01; Min Chen <chenm001@163.com> |
30 : | * Add Core version display to about box | ||
31 : | * | ||
32 : | * 01.12.2001 inital version; (c)2001 peter ross <suxen_drol@hotmail.com> | ||
33 : | * | ||
34 : | *************************************************************************/ | ||
35 : | |||
36 : | |||
37 : | #include <windows.h> | ||
38 : | #include <shlobj.h> | ||
39 : | #include <prsht.h> | ||
40 : | |||
41 : | #include "codec.h" | ||
42 : | #include "config.h" | ||
43 : | #include "resource.h" | ||
44 : | #include "xvid.h" // cpu masks | ||
45 : | #include <stdio.h> // sprintf() | ||
46 : | |||
47 : | /* get config settings from registry */ | ||
48 : | |||
49 : | #define REG_GET_N(X, Y, Z) size=sizeof(int);if(RegQueryValueEx(hKey, X, 0, 0, (LPBYTE)&Y, &size) != ERROR_SUCCESS) {Y=Z;} | ||
50 : | #define REG_GET_S(X, Y, Z) size=MAX_PATH;if(RegQueryValueEx(hKey, X, 0, 0, Y, &size) != ERROR_SUCCESS) {lstrcpy(Y, Z);} | ||
51 : | #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)));} | ||
52 : | |||
53 : | void config_reg_get(CONFIG * config) | ||
54 : | { | ||
55 : | HKEY hKey; | ||
56 : | DWORD size; | ||
57 : | XVID_INIT_PARAM init_param; | ||
58 : | |||
59 : | init_param.cpu_flags = 0; | ||
60 : | xvid_init(0, 0, &init_param, NULL); | ||
61 : | config->cpu = init_param.cpu_flags; | ||
62 : | |||
63 : | RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey); | ||
64 : | |||
65 : | REG_GET_N("mode", config->mode, DLG_MODE_CBR) | ||
66 : | REG_GET_N("bitrate", config->bitrate, 900000) | ||
67 : | REG_GET_N("quality", config->quality, 85) | ||
68 : | REG_GET_N("quant", config->quant, 5) | ||
69 : | |||
70 : | REG_GET_S("stats1", config->stats1, CONFIG_2PASS_1_FILE) | ||
71 : | REG_GET_S("stats2", config->stats2, CONFIG_2PASS_2_FILE) | ||
72 : | REG_GET_N("discard1pass", config->discard1pass, 1) | ||
73 : | REG_GET_N("dummy2pass", config->dummy2pass, 0) | ||
74 : | REG_GET_N("desired_size", config->desired_size, 570000) | ||
75 : | |||
76 : | REG_GET_N("min_iquant", config->min_iquant, 1) | ||
77 : | REG_GET_N("max_iquant", config->max_iquant, 31) | ||
78 : | |||
79 : | REG_GET_N("keyframe_boost", config->keyframe_boost, 20) | ||
80 : | REG_GET_N("min_key_interval", config->min_key_interval, 6) | ||
81 : | REG_GET_N("bitrate_payback_delay", config->bitrate_payback_delay, 240) | ||
82 : | REG_GET_N("bitrate_payback_method", config->bitrate_payback_method, 0) | ||
83 : | REG_GET_N("curve_compression_high", config->curve_compression_high, 25) | ||
84 : | REG_GET_N("curve_compression_low", config->curve_compression_low, 15) | ||
85 : | |||
86 : | REG_GET_N("credits_start", config->credits_start, 0) | ||
87 : | REG_GET_N("credits_start_begin", config->credits_start_begin, 0) | ||
88 : | REG_GET_N("credits_start_end", config->credits_start_end, 0) | ||
89 : | REG_GET_N("credits_end", config->credits_end, 0) | ||
90 : | REG_GET_N("credits_end_begin", config->credits_end_begin, 0) | ||
91 : | REG_GET_N("credits_end_end", config->credits_end_end, 0) | ||
92 : | |||
93 : | REG_GET_N("credits_mode", config->credits_mode, 0) | ||
94 : | REG_GET_N("credits_rate", config->credits_rate, 10) | ||
95 : | REG_GET_N("credits_quant_i", config->credits_quant_i, 20) | ||
96 : | REG_GET_N("credits_quant_p", config->credits_quant_p, 20) | ||
97 : | REG_GET_N("credits_start_size", config->credits_start_size, 10000) | ||
98 : | REG_GET_N("credits_end_size", config->credits_end_size, 10000) | ||
99 : | |||
100 : | REG_GET_N("motion_search", config->motion_search, 5) | ||
101 : | REG_GET_N("quant_type", config->quant_type, 0) | ||
102 : | REG_GET_N("max_key_interval", config->max_key_interval, 300) | ||
103 : | |||
104 : | REG_GET_N("rc_buffersize", config->rc_buffersize, 2048000) | ||
105 : | |||
106 : | REG_GET_N("max_quant", config->max_quant, 31) | ||
107 : | REG_GET_N("min_quant", config->min_quant, 1) | ||
108 : | REG_GET_N("lum_masking", config->lum_masking, 0) | ||
109 : | |||
110 : | REG_GET_N("fourcc_used", config->fourcc_used, 0) | ||
111 : | |||
112 : | { | ||
113 : | BYTE default_qmatrix_intra[] = { | ||
114 : | 8, 17,18,19,21,23,25,27, | ||
115 : | 17,18,19,21,23,25,27,28, | ||
116 : | 20,21,22,23,24,26,28,30, | ||
117 : | 21,22,23,24,26,28,30,32, | ||
118 : | 22,23,24,26,28,30,32,35, | ||
119 : | 23,24,26,28,30,32,35,38, | ||
120 : | 25,26,28,30,32,35,38,41, | ||
121 : | 27,28,30,32,35,38,41,45 | ||
122 : | }; | ||
123 : | |||
124 : | BYTE default_qmatrix_inter[] = { | ||
125 : | 16,17,18,19,20,21,22,23, | ||
126 : | 17,18,19,20,21,22,23,24, | ||
127 : | 18,19,20,21,22,23,24,25, | ||
128 : | 19,20,21,22,23,24,26,27, | ||
129 : | 20,21,22,23,25,26,27,28, | ||
130 : | 21,22,23,24,26,27,28,30, | ||
131 : | 22,23,24,26,27,28,30,31, | ||
132 : | 23,24,25,27,28,30,31,33 | ||
133 : | }; | ||
134 : | |||
135 : | REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra) | ||
136 : | REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter) | ||
137 : | } | ||
138 : | |||
139 : | RegCloseKey(hKey); | ||
140 : | } | ||
141 : | |||
142 : | |||
143 : | /* put config settings in registry */ | ||
144 : | |||
145 : | #define REG_SET_N(X, Y) RegSetValueEx(hKey, X, 0, REG_DWORD, (LPBYTE)&Y, sizeof(int)) | ||
146 : | #define REG_SET_S(X, Y) RegSetValueEx(hKey, X, 0, REG_SZ, Y, lstrlen(Y)+1) | ||
147 : | #define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y))) | ||
148 : | |||
149 : | void config_reg_set(CONFIG * config) | ||
150 : | { | ||
151 : | HKEY hKey; | ||
152 : | DWORD dispo; | ||
153 : | |||
154 : | if (RegCreateKeyEx( | ||
155 : | XVID_REG_KEY, | ||
156 : | XVID_REG_SUBKEY, | ||
157 : | 0, | ||
158 : | XVID_REG_CLASS, | ||
159 : | REG_OPTION_NON_VOLATILE, | ||
160 : | KEY_WRITE, | ||
161 : | 0, | ||
162 : | &hKey, | ||
163 : | &dispo) != ERROR_SUCCESS) | ||
164 : | { | ||
165 : | DEBUG1("Couldn't create XVID_REG_SUBKEY - ", GetLastError()); | ||
166 : | return; | ||
167 : | } | ||
168 : | |||
169 : | REG_SET_N("mode", config->mode); | ||
170 : | REG_SET_N("bitrate", config->bitrate); | ||
171 : | REG_SET_N("quality", config->quality); | ||
172 : | REG_SET_N("quant", config->quant); | ||
173 : | |||
174 : | REG_SET_S("stats1", config->stats1); | ||
175 : | REG_SET_S("stats2", config->stats2); | ||
176 : | REG_SET_N("discard1pass", config->discard1pass); | ||
177 : | REG_SET_N("dummy2pass", config->dummy2pass); | ||
178 : | REG_SET_N("desired_size", config->desired_size); | ||
179 : | |||
180 : | REG_SET_N("min_iquant", config->min_iquant); | ||
181 : | REG_SET_N("max_iquant", config->max_iquant); | ||
182 : | |||
183 : | REG_SET_N("keyframe_boost", config->keyframe_boost); | ||
184 : | REG_SET_N("min_key_interval", config->min_key_interval); | ||
185 : | REG_SET_N("bitrate_payback_delay", config->bitrate_payback_delay); | ||
186 : | REG_SET_N("bitrate_payback_method", config->bitrate_payback_method); | ||
187 : | REG_SET_N("curve_compression_high", config->curve_compression_high); | ||
188 : | REG_SET_N("curve_compression_low", config->curve_compression_low); | ||
189 : | |||
190 : | REG_SET_N("credits_start", config->credits_start); | ||
191 : | REG_SET_N("credits_start_begin", config->credits_start_begin); | ||
192 : | REG_SET_N("credits_start_end", config->credits_start_end); | ||
193 : | REG_SET_N("credits_end", config->credits_end); | ||
194 : | REG_SET_N("credits_end_begin", config->credits_end_begin); | ||
195 : | REG_SET_N("credits_end_end", config->credits_end_end); | ||
196 : | |||
197 : | REG_SET_N("credits_mode", config->credits_mode); | ||
198 : | REG_SET_N("credits_rate", config->credits_rate); | ||
199 : | REG_SET_N("credits_quant_i", config->credits_quant_i); | ||
200 : | REG_SET_N("credits_quant_p", config->credits_quant_p); | ||
201 : | REG_SET_N("credits_start_size", config->credits_start_size); | ||
202 : | REG_SET_N("credits_end_size", config->credits_end_size); | ||
203 : | |||
204 : | REG_SET_N("motion_search", config->motion_search); | ||
205 : | REG_SET_N("quant_type", config->quant_type); | ||
206 : | REG_SET_N("max_key_interval", config->max_key_interval); | ||
207 : | |||
208 : | REG_SET_N("rc_buffersize", config->rc_buffersize); | ||
209 : | |||
210 : | REG_SET_N("max_quant", config->max_quant); | ||
211 : | REG_SET_N("min_quant", config->min_quant); | ||
212 : | REG_SET_N("lum_masking", config->lum_masking); | ||
213 : | |||
214 : | REG_SET_N("fourcc_used", config->fourcc_used); | ||
215 : | |||
216 : | REG_SET_B("qmatrix_intra", config->qmatrix_intra); | ||
217 : | REG_SET_B("qmatrix_inter", config->qmatrix_inter); | ||
218 : | |||
219 : | RegCloseKey(hKey); | ||
220 : | } | ||
221 : | |||
222 : | |||
223 : | /* enable/disable dialog controls based on encoder mode */ | ||
224 : | |||
225 : | #define ENABLE(X) EnableWindow(GetDlgItem(hDlg, (X)), TRUE); | ||
226 : | #define DISABLE(X) EnableWindow(GetDlgItem(hDlg, (X)), FALSE); | ||
227 : | #define ISDLGSET(X) (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED) | ||
228 : | |||
229 : | void config_mode(HWND hDlg) | ||
230 : | { | ||
231 : | XVID_INIT_PARAM init_param; | ||
232 : | LONG mode; | ||
233 : | |||
234 : | mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); | ||
235 : | |||
236 : | if (mode == DLG_MODE_VBR_QUAL || mode == DLG_MODE_VBR_QUANT || | ||
237 : | mode == DLG_MODE_2PASS_1 || mode == DLG_MODE_2PASS_2_INT) | ||
238 : | { | ||
239 : | ENABLE(IDC_CREDITS); | ||
240 : | } | ||
241 : | else | ||
242 : | { | ||
243 : | DISABLE(IDC_CREDITS); | ||
244 : | } | ||
245 : | |||
246 : | if (mode == DLG_MODE_VBR_QUAL || mode == DLG_MODE_VBR_QUANT || mode == DLG_MODE_CBR) | ||
247 : | { | ||
248 : | ENABLE(IDC_VALUE_STATIC); | ||
249 : | ENABLE(IDC_VALUE); | ||
250 : | ENABLE(IDC_SLIDER_STATIC); | ||
251 : | ENABLE(IDC_SLIDER); | ||
252 : | } | ||
253 : | else | ||
254 : | { | ||
255 : | DISABLE(IDC_VALUE_STATIC); | ||
256 : | DISABLE(IDC_VALUE); | ||
257 : | DISABLE(IDC_SLIDER_STATIC); | ||
258 : | DISABLE(IDC_SLIDER); | ||
259 : | } | ||
260 : | |||
261 : | if (mode == DLG_MODE_2PASS_1 || mode == DLG_MODE_2PASS_2_EXT || mode == DLG_MODE_2PASS_2_INT) | ||
262 : | { | ||
263 : | ENABLE(IDC_2PASS_STATS1_STATIC); | ||
264 : | ENABLE(IDC_2PASS_STATS1); | ||
265 : | ENABLE(IDC_2PASS_STATS1_BROWSE); | ||
266 : | ENABLE(IDC_2PASS_INT); | ||
267 : | } | ||
268 : | else | ||
269 : | { | ||
270 : | DISABLE(IDC_2PASS_STATS1_STATIC); | ||
271 : | DISABLE(IDC_2PASS_STATS1); | ||
272 : | DISABLE(IDC_2PASS_STATS1_BROWSE); | ||
273 : | DISABLE(IDC_2PASS_INT); | ||
274 : | } | ||
275 : | |||
276 : | if (mode == DLG_MODE_2PASS_1) | ||
277 : | { | ||
278 : | ENABLE(IDC_DISCARD1PASS); | ||
279 : | } | ||
280 : | else | ||
281 : | { | ||
282 : | DISABLE(IDC_DISCARD1PASS); | ||
283 : | } | ||
284 : | |||
285 : | if (mode == DLG_MODE_2PASS_2_EXT) | ||
286 : | { | ||
287 : | ENABLE(IDC_2PASS_STATS1_STATIC); | ||
288 : | ENABLE(IDC_2PASS_STATS2); | ||
289 : | ENABLE(IDC_2PASS_STATS2_BROWSE); | ||
290 : | } | ||
291 : | else | ||
292 : | { | ||
293 : | DISABLE(IDC_2PASS_STATS1_STATIC); | ||
294 : | DISABLE(IDC_2PASS_STATS2); | ||
295 : | DISABLE(IDC_2PASS_STATS2_BROWSE); | ||
296 : | } | ||
297 : | |||
298 : | if (ISDLGSET(IDC_CPU_FORCE)) { | ||
299 : | ENABLE(IDC_CPU_MMX); | ||
300 : | ENABLE(IDC_CPU_MMXEXT); | ||
301 : | ENABLE(IDC_CPU_SSE); | ||
302 : | ENABLE(IDC_CPU_SSE2); | ||
303 : | ENABLE(IDC_CPU_3DNOW); | ||
304 : | ENABLE(IDC_CPU_3DNOWEXT); | ||
305 : | } else { | ||
306 : | xvid_init(0, 0, &init_param, NULL); | ||
307 : | |||
308 : | CheckDlgButton(hDlg, IDC_CPU_MMX, init_param.cpu_flags & XVID_CPU_MMX ? BST_CHECKED : BST_UNCHECKED); | ||
309 : | CheckDlgButton(hDlg, IDC_CPU_MMXEXT, init_param.cpu_flags & XVID_CPU_MMXEXT ? BST_CHECKED : BST_UNCHECKED); | ||
310 : | CheckDlgButton(hDlg, IDC_CPU_SSE, init_param.cpu_flags & XVID_CPU_SSE ? BST_CHECKED : BST_UNCHECKED); | ||
311 : | CheckDlgButton(hDlg, IDC_CPU_SSE2, init_param.cpu_flags & XVID_CPU_SSE2 ? BST_CHECKED : BST_UNCHECKED); | ||
312 : | CheckDlgButton(hDlg, IDC_CPU_3DNOW, init_param.cpu_flags & XVID_CPU_3DNOW ? BST_CHECKED : BST_UNCHECKED); | ||
313 : | CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, init_param.cpu_flags & XVID_CPU_3DNOWEXT ? BST_CHECKED : BST_UNCHECKED); | ||
314 : | |||
315 : | DISABLE(IDC_CPU_MMX); | ||
316 : | DISABLE(IDC_CPU_MMXEXT); | ||
317 : | DISABLE(IDC_CPU_SSE); | ||
318 : | DISABLE(IDC_CPU_SSE2); | ||
319 : | DISABLE(IDC_CPU_3DNOW); | ||
320 : | DISABLE(IDC_CPU_3DNOWEXT); | ||
321 : | } | ||
322 : | } | ||
323 : | |||
324 : | |||
325 : | /* upload config data into dialog */ | ||
326 : | |||
327 : | void config_upload(HWND hDlg, int page, CONFIG * config) | ||
328 : | { | ||
329 : | switch (page) | ||
330 : | { | ||
331 : | case DLG_MAIN : | ||
332 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); | ||
333 : | config_mode(hDlg); | ||
334 : | |||
335 : | config_slider(hDlg, config); | ||
336 : | config_value(hDlg, config); | ||
337 : | |||
338 : | SetDlgItemText(hDlg, IDC_2PASS_STATS1, config->stats1); | ||
339 : | SetDlgItemText(hDlg, IDC_2PASS_STATS2, config->stats2); | ||
340 : | CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED); | ||
341 : | break; | ||
342 : | |||
343 : | case DLG_ADV : | ||
344 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0); | ||
345 : | SendDlgItemMessage(hDlg, IDC_QTYPE, CB_SETCURSEL, config->quant_type, 0); | ||
346 : | SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE); | ||
347 : | |||
348 : | SetDlgItemInt(hDlg, IDC_MINQ, config->min_quant, FALSE); | ||
349 : | SetDlgItemInt(hDlg, IDC_MAXQ, config->max_quant, FALSE); | ||
350 : | CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED); | ||
351 : | |||
352 : | SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0); | ||
353 : | break; | ||
354 : | |||
355 : | case DLG_DEBUG : | ||
356 : | SetDlgItemInt(hDlg, IDC_RC_BUFFERSIZE, config->rc_buffersize, FALSE); | ||
357 : | |||
358 : | SetDlgItemInt(hDlg, IDC_IMINQ, config->min_iquant, FALSE); | ||
359 : | SetDlgItemInt(hDlg, IDC_IMAXQ, config->max_iquant, FALSE); | ||
360 : | CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED); | ||
361 : | break; | ||
362 : | |||
363 : | case DLG_CPU : | ||
364 : | CheckDlgButton(hDlg, IDC_CPU_MMX, config->cpu & XVID_CPU_MMX ? BST_CHECKED : BST_UNCHECKED); | ||
365 : | CheckDlgButton(hDlg, IDC_CPU_MMXEXT, config->cpu & XVID_CPU_MMXEXT ? BST_CHECKED : BST_UNCHECKED); | ||
366 : | CheckDlgButton(hDlg, IDC_CPU_SSE, config->cpu & XVID_CPU_SSE ? BST_CHECKED : BST_UNCHECKED); | ||
367 : | CheckDlgButton(hDlg, IDC_CPU_SSE2, config->cpu & XVID_CPU_SSE2 ? BST_CHECKED : BST_UNCHECKED); | ||
368 : | CheckDlgButton(hDlg, IDC_CPU_3DNOW, config->cpu & XVID_CPU_3DNOW ? BST_CHECKED : BST_UNCHECKED); | ||
369 : | CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, config->cpu & XVID_CPU_3DNOWEXT ? BST_CHECKED : BST_UNCHECKED); | ||
370 : | |||
371 : | CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE, | ||
372 : | config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO ); | ||
373 : | break; | ||
374 : | } | ||
375 : | } | ||
376 : | |||
377 : | |||
378 : | /* download config data from dialog | ||
379 : | replaces invalid values instead of alerting user for now | ||
380 : | */ | ||
381 : | |||
382 : | #define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z; | ||
383 : | |||
384 : | void config_download(HWND hDlg, int page, CONFIG * config) | ||
385 : | { | ||
386 : | int value; | ||
387 : | |||
388 : | switch (page) | ||
389 : | { | ||
390 : | case DLG_MAIN : | ||
391 : | config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); | ||
392 : | |||
393 : | value = config_get_int(hDlg, IDC_VALUE, 2); | ||
394 : | |||
395 : | switch (SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_GETRANGEMAX, 0, 0)) | ||
396 : | { | ||
397 : | case 10000 : | ||
398 : | CONSTRAINVAL(value, 1, 10000) | ||
399 : | config->bitrate = value * CONFIG_KBPS; | ||
400 : | break; | ||
401 : | |||
402 : | case 100 : | ||
403 : | CONSTRAINVAL(value, 0, 100) | ||
404 : | config->quality = value; | ||
405 : | break; | ||
406 : | |||
407 : | case 31 : | ||
408 : | CONSTRAINVAL(value, 1, 31) | ||
409 : | config->quant = value; | ||
410 : | break; | ||
411 : | } | ||
412 : | |||
413 : | GetDlgItemText(hDlg, IDC_2PASS_STATS1, config->stats1, MAX_PATH); | ||
414 : | if (config->stats1[0] == '\0') | ||
415 : | { | ||
416 : | lstrcpy(config->stats1, CONFIG_2PASS_1_FILE); | ||
417 : | } | ||
418 : | GetDlgItemText(hDlg, IDC_2PASS_STATS2, config->stats2, MAX_PATH); | ||
419 : | if (config->stats2[0] == '\0') | ||
420 : | { | ||
421 : | lstrcpy(config->stats2, CONFIG_2PASS_2_FILE); | ||
422 : | } | ||
423 : | |||
424 : | config->discard1pass = ISDLGSET(IDC_DISCARD1PASS); | ||
425 : | break; | ||
426 : | |||
427 : | case DLG_ADV : | ||
428 : | config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0); | ||
429 : | config->quant_type = SendDlgItemMessage(hDlg, IDC_QTYPE, CB_GETCURSEL, 0, 0); | ||
430 : | config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval); | ||
431 : | |||
432 : | config->min_quant = config_get_int(hDlg, IDC_MINQ, config->min_quant); | ||
433 : | config->max_quant = config_get_int(hDlg, IDC_MAXQ, config->max_quant); | ||
434 : | config->lum_masking = ISDLGSET(IDC_LUMMASK); | ||
435 : | |||
436 : | CONSTRAINVAL(config->min_quant, 1, 31) | ||
437 : | CONSTRAINVAL(config->max_quant, 1, 31) | ||
438 : | if(config->max_quant < config->min_quant) | ||
439 : | { | ||
440 : | config->max_quant = config->min_quant; | ||
441 : | } | ||
442 : | |||
443 : | config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); | ||
444 : | break; | ||
445 : | |||
446 : | case DLG_DEBUG: | ||
447 : | config->rc_buffersize = config_get_int(hDlg, IDC_RC_BUFFERSIZE, config->rc_buffersize); | ||
448 : | |||
449 : | config->min_iquant = config_get_int(hDlg, IDC_IMINQ, config->min_iquant); | ||
450 : | config->max_iquant = config_get_int(hDlg, IDC_IMAXQ, config->max_iquant); | ||
451 : | config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS); | ||
452 : | |||
453 : | CONSTRAINVAL(config->min_iquant, 1, 31) | ||
454 : | CONSTRAINVAL(config->min_iquant, 1, 31) | ||
455 : | if(config->max_iquant < config->min_iquant) | ||
456 : | { | ||
457 : | config->max_iquant = config->min_iquant; | ||
458 : | } | ||
459 : | break; | ||
460 : | |||
461 : | case DLG_CPU : | ||
462 : | config->cpu = 0; | ||
463 : | config->cpu |= ISDLGSET(IDC_CPU_MMX) ? XVID_CPU_MMX : 0; | ||
464 : | config->cpu |= ISDLGSET(IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT: 0; | ||
465 : | config->cpu |= ISDLGSET(IDC_CPU_SSE) ? XVID_CPU_SSE: 0; | ||
466 : | config->cpu |= ISDLGSET(IDC_CPU_SSE2) ? XVID_CPU_SSE2: 0; | ||
467 : | config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0; | ||
468 : | config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0; | ||
469 : | config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0; | ||
470 : | break; | ||
471 : | } | ||
472 : | } | ||
473 : | |||
474 : | |||
475 : | /* updates the slider */ | ||
476 : | |||
477 : | void config_slider(HWND hDlg, CONFIG* config) | ||
478 : | { | ||
479 : | char* text; | ||
480 : | long range; | ||
481 : | int pos; | ||
482 : | |||
483 : | switch (config->mode) | ||
484 : | { | ||
485 : | default : | ||
486 : | case DLG_MODE_CBR : | ||
487 : | text = "Bitrate (Kbps):"; | ||
488 : | range = MAKELONG(0,10000); | ||
489 : | pos = config->bitrate / CONFIG_KBPS; | ||
490 : | break; | ||
491 : | |||
492 : | case DLG_MODE_VBR_QUAL : | ||
493 : | text = "Quality:"; | ||
494 : | range = MAKELONG(0,100); | ||
495 : | pos = config->quality; | ||
496 : | break; | ||
497 : | |||
498 : | case DLG_MODE_VBR_QUANT : | ||
499 : | text = "Quantizer:"; | ||
500 : | range = MAKELONG(1,31); | ||
501 : | pos = config->quant; | ||
502 : | break; | ||
503 : | } | ||
504 : | |||
505 : | SetDlgItemText(hDlg, IDC_SLIDER_STATIC, text); | ||
506 : | SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, range); | ||
507 : | SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, pos); | ||
508 : | } | ||
509 : | |||
510 : | |||
511 : | /* updates the edit box */ | ||
512 : | |||
513 : | void config_value(HWND hDlg, CONFIG* config) | ||
514 : | { | ||
515 : | char* text; | ||
516 : | int value; | ||
517 : | |||
518 : | switch (config->mode) | ||
519 : | { | ||
520 : | default : | ||
521 : | case DLG_MODE_CBR : | ||
522 : | text = "Bitrate (Kbps):"; | ||
523 : | value = config->bitrate / CONFIG_KBPS; | ||
524 : | break; | ||
525 : | |||
526 : | case DLG_MODE_VBR_QUAL : | ||
527 : | text = "Quality:"; | ||
528 : | value = config->quality; | ||
529 : | break; | ||
530 : | |||
531 : | case DLG_MODE_VBR_QUANT : | ||
532 : | text = "Quantizer:"; | ||
533 : | value = config->quant; | ||
534 : | break; | ||
535 : | } | ||
536 : | |||
537 : | SetDlgItemText(hDlg, IDC_VALUE_STATIC, text); | ||
538 : | SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE); | ||
539 : | } | ||
540 : | |||
541 : | |||
542 : | /* leaves current config value if dialog item is empty */ | ||
543 : | |||
544 : | int config_get_int(HWND hDlg, UINT item, int config) | ||
545 : | { | ||
546 : | BOOL success = FALSE; | ||
547 : | |||
548 : | int tmp = GetDlgItemInt(hDlg, item, &success, FALSE); | ||
549 : | |||
550 : | if(success) { | ||
551 : | return tmp; | ||
552 : | } else { | ||
553 : | return config; | ||
554 : | } | ||
555 : | } | ||
556 : | |||
557 : | |||
558 : | /* configure credits dialog controls */ | ||
559 : | |||
560 : | void credits_controls(HWND hDlg) | ||
561 : | { | ||
562 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_START_BEGIN), ISDLGSET(IDC_CREDITS_START)); | ||
563 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_START_END), ISDLGSET(IDC_CREDITS_START)); | ||
564 : | |||
565 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_END_BEGIN), ISDLGSET(IDC_CREDITS_END)); | ||
566 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_END_END), ISDLGSET(IDC_CREDITS_END)); | ||
567 : | |||
568 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_RATE), ISDLGSET(IDC_CREDITS_RATE_RADIO)); | ||
569 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_QUANTI), ISDLGSET(IDC_CREDITS_QUANT_RADIO)); | ||
570 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_QUANTP), ISDLGSET(IDC_CREDITS_QUANT_RADIO)); | ||
571 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_START_SIZE), ISDLGSET(IDC_CREDITS_SIZE_RADIO)); | ||
572 : | EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_END_SIZE), ISDLGSET(IDC_CREDITS_SIZE_RADIO)); | ||
573 : | } | ||
574 : | |||
575 : | |||
576 : | void quant_upload(HWND hDlg, CONFIG* config) | ||
577 : | { | ||
578 : | int i; | ||
579 : | |||
580 : | for (i=0 ; i<64 ; ++i) | ||
581 : | { | ||
582 : | SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE); | ||
583 : | SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE); | ||
584 : | } | ||
585 : | } | ||
586 : | |||
587 : | |||
588 : | void quant_download(HWND hDlg, CONFIG* config) | ||
589 : | { | ||
590 : | int i; | ||
591 : | |||
592 : | for (i=0 ; i<64 ; ++i) | ||
593 : | { | ||
594 : | config->qmatrix_intra[i] = config_get_int(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]); | ||
595 : | CONSTRAINVAL(config->qmatrix_intra[i], 1, 255) | ||
596 : | |||
597 : | config->qmatrix_inter[i] = config_get_int(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]); | ||
598 : | CONSTRAINVAL(config->qmatrix_inter[i], 1, 255) | ||
599 : | } | ||
600 : | } | ||
601 : | |||
602 : | |||
603 : | /* dialog proc */ | ||
604 : | |||
605 : | BOOL CALLBACK config_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
606 : | { | ||
607 : | PROPSHEETINFO *psi; | ||
608 : | |||
609 : | psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA); | ||
610 : | |||
611 : | switch (uMsg) | ||
612 : | { | ||
613 : | case WM_INITDIALOG : | ||
614 : | psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam; | ||
615 : | |||
616 : | SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi); | ||
617 : | |||
618 : | switch (psi->page) | ||
619 : | { | ||
620 : | case DLG_MAIN : | ||
621 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - CBR"); | ||
622 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quality"); | ||
623 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quantizer"); | ||
624 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 1st pass"); | ||
625 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Ext."); | ||
626 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Int."); | ||
627 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed"); | ||
628 : | break; | ||
629 : | |||
630 : | case DLG_ADV : | ||
631 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None"); | ||
632 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low"); | ||
633 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low"); | ||
634 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium"); | ||
635 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High"); | ||
636 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High"); | ||
637 : | SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High"); | ||
638 : | |||
639 : | SendDlgItemMessage(hDlg, IDC_QTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263"); | ||
640 : | SendDlgItemMessage(hDlg, IDC_QTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG"); | ||
641 : | SendDlgItemMessage(hDlg, IDC_QTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom"); | ||
642 : | |||
643 : | SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID"); | ||
644 : | SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX"); | ||
645 : | break; | ||
646 : | |||
647 : | case DLG_ABOUT : | ||
648 : | { | ||
649 : | HFONT hFont; | ||
650 : | LOGFONT lfData; | ||
651 : | |||
652 : | SetDlgItemText(hDlg, IDC_BUILD, __TIME__ ", " __DATE__); | ||
653 : | |||
654 : | chenm001 | 24 | // Add by Chen at 2002-03-05 to display core version at about box |
655 : | // Change by Chen at 2002-03-11 now use xvid_init() to get core version | ||
656 : | Isibaar | 3 | { |
657 : | char chTemp[64]; | ||
658 : | chenm001 | 24 | // 2002-03-11 Change start |
659 : | XVID_INIT_PARAM xinit; | ||
660 : | xvid_init(NULL,0,&xinit,NULL); | ||
661 : | sprintf(chTemp,"Core Version %d.%d",(xinit.api_version>>16),(xinit.api_version&0xFFFFU)); | ||
662 : | // 2002-03-11 Change End | ||
663 : | //sprintf(chTemp,"Core Version %d.%d",(API_VERSION>>16),(API_VERSION&0xFFFFU)); | ||
664 : | Isibaar | 3 | SetDlgItemText(hDlg, IDC_CORE_VERSION, chTemp); |
665 : | } | ||
666 : | |||
667 : | hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L); | ||
668 : | |||
669 : | if (GetObject(hFont, sizeof(LOGFONT), &lfData)) | ||
670 : | { | ||
671 : | lfData.lfUnderline = 1; | ||
672 : | |||
673 : | hFont = CreateFontIndirect(&lfData); | ||
674 : | if (hFont) | ||
675 : | { | ||
676 : | SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L); | ||
677 : | } | ||
678 : | } | ||
679 : | |||
680 : | SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); | ||
681 : | SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE); | ||
682 : | } | ||
683 : | } | ||
684 : | |||
685 : | config_upload(hDlg, psi->page, psi->config); | ||
686 : | config_mode(hDlg); | ||
687 : | break; | ||
688 : | |||
689 : | case WM_CTLCOLORSTATIC : | ||
690 : | if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE)) | ||
691 : | { | ||
692 : | SetBkMode((HDC)wParam, TRANSPARENT) ; | ||
693 : | SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0)); | ||
694 : | return (BOOL)GetStockObject(NULL_BRUSH); | ||
695 : | } | ||
696 : | return FALSE; | ||
697 : | |||
698 : | case WM_COMMAND : | ||
699 : | if (LOWORD(wParam) == IDC_MODE && HIWORD(wParam) == LBN_SELCHANGE) | ||
700 : | { | ||
701 : | config_mode(hDlg); | ||
702 : | config_download(hDlg, psi->page, psi->config); | ||
703 : | config_value(hDlg, psi->config); | ||
704 : | config_slider(hDlg, psi->config); | ||
705 : | } | ||
706 : | else if ((LOWORD(wParam) == IDC_CPU_AUTO || LOWORD(wParam) == IDC_CPU_FORCE) && HIWORD(wParam) == BN_CLICKED) | ||
707 : | { | ||
708 : | config_mode(hDlg); | ||
709 : | } | ||
710 : | else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE) | ||
711 : | { | ||
712 : | int value = config_get_int(hDlg, IDC_VALUE, 1); | ||
713 : | int max = 1; | ||
714 : | |||
715 : | switch (SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0)) | ||
716 : | { | ||
717 : | default : | ||
718 : | case DLG_MODE_CBR : | ||
719 : | max = 10000; | ||
720 : | break; | ||
721 : | |||
722 : | case DLG_MODE_VBR_QUAL : | ||
723 : | max = 100; | ||
724 : | break; | ||
725 : | |||
726 : | case DLG_MODE_VBR_QUANT : | ||
727 : | max = 31; | ||
728 : | break; | ||
729 : | } | ||
730 : | |||
731 : | if (value < 1) | ||
732 : | { | ||
733 : | value = 1; | ||
734 : | } | ||
735 : | if (value > max) | ||
736 : | { | ||
737 : | value = max; | ||
738 : | SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE); | ||
739 : | } | ||
740 : | |||
741 : | SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, value); | ||
742 : | } | ||
743 : | else if ((LOWORD(wParam) == IDC_2PASS_STATS1_BROWSE || LOWORD(wParam) == IDC_2PASS_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED) | ||
744 : | { | ||
745 : | OPENFILENAME ofn; | ||
746 : | char tmp[MAX_PATH]; | ||
747 : | int hComponent = (LOWORD(wParam) == IDC_2PASS_STATS1_BROWSE ? IDC_2PASS_STATS1 : IDC_2PASS_STATS2 ); | ||
748 : | |||
749 : | GetDlgItemText(hDlg, hComponent, tmp, MAX_PATH); | ||
750 : | |||
751 : | memset(&ofn, 0, sizeof(OPENFILENAME)); | ||
752 : | ofn.lStructSize = sizeof(OPENFILENAME); | ||
753 : | |||
754 : | ofn.hwndOwner = hDlg; | ||
755 : | ofn.lpstrFilter = "bitrate curve (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0"; | ||
756 : | ofn.lpstrFile = tmp; | ||
757 : | ofn.nMaxFile = MAX_PATH; | ||
758 : | ofn.Flags = OFN_PATHMUSTEXIST; | ||
759 : | |||
760 : | // display save box for stats1 using 1st-pass | ||
761 : | if (LOWORD(wParam) == IDC_2PASS_STATS1_BROWSE && | ||
762 : | SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0) == DLG_MODE_2PASS_1) | ||
763 : | { | ||
764 : | ofn.Flags |= OFN_OVERWRITEPROMPT; | ||
765 : | if (GetSaveFileName(&ofn)) | ||
766 : | { | ||
767 : | SetDlgItemText(hDlg, hComponent, tmp); | ||
768 : | } | ||
769 : | } | ||
770 : | else | ||
771 : | { | ||
772 : | ofn.Flags |= OFN_FILEMUSTEXIST; | ||
773 : | if (GetOpenFileName(&ofn)) { | ||
774 : | SetDlgItemText(hDlg, hComponent, tmp); | ||
775 : | } | ||
776 : | } | ||
777 : | } | ||
778 : | else if (LOWORD(wParam) == IDC_CREDITS && HIWORD(wParam) == BN_CLICKED) | ||
779 : | { | ||
780 : | DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CREDITS), hDlg, credits_proc, (LPARAM)psi->config); | ||
781 : | } | ||
782 : | else if (LOWORD(wParam) == IDC_2PASS_INT && HIWORD(wParam) == BN_CLICKED) | ||
783 : | { | ||
784 : | DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_2PASS), hDlg, twopass_proc, (LPARAM)psi->config); | ||
785 : | } | ||
786 : | else if (LOWORD(wParam) == IDC_QUANTMATRIX && HIWORD(wParam) == BN_CLICKED) | ||
787 : | { | ||
788 : | DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config); | ||
789 : | } | ||
790 : | else if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED) | ||
791 : | { | ||
792 : | ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL); | ||
793 : | } | ||
794 : | break; | ||
795 : | |||
796 : | case WM_HSCROLL: | ||
797 : | if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER)) | ||
798 : | { | ||
799 : | SetDlgItemInt(hDlg, IDC_VALUE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE); | ||
800 : | } | ||
801 : | else | ||
802 : | { | ||
803 : | return 0; | ||
804 : | } | ||
805 : | break; | ||
806 : | |||
807 : | case WM_NOTIFY : | ||
808 : | switch (((NMHDR *)lParam)->code) | ||
809 : | { | ||
810 : | case PSN_KILLACTIVE : | ||
811 : | /* validate */ | ||
812 : | config_download(hDlg, psi->page, psi->config); | ||
813 : | SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); | ||
814 : | break; | ||
815 : | |||
816 : | case PSN_APPLY : | ||
817 : | /* apply */ | ||
818 : | config_download(hDlg, psi->page, psi->config); | ||
819 : | SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); | ||
820 : | config_reg_set(psi->config); | ||
821 : | psi->config->save = TRUE; | ||
822 : | break; | ||
823 : | } | ||
824 : | break; | ||
825 : | |||
826 : | default : | ||
827 : | return 0; | ||
828 : | } | ||
829 : | |||
830 : | return 1; | ||
831 : | } | ||
832 : | |||
833 : | |||
834 : | /* credits dialog proc */ | ||
835 : | |||
836 : | BOOL CALLBACK credits_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
837 : | { | ||
838 : | CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); | ||
839 : | |||
840 : | switch (uMsg) | ||
841 : | { | ||
842 : | case WM_INITDIALOG : | ||
843 : | SetWindowLong(hDlg, GWL_USERDATA, lParam); | ||
844 : | |||
845 : | config = (CONFIG*)lParam; | ||
846 : | |||
847 : | CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED); | ||
848 : | SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE); | ||
849 : | SetDlgItemInt(hDlg, IDC_CREDITS_START_END, config->credits_start_end, FALSE); | ||
850 : | CheckDlgButton(hDlg, IDC_CREDITS_END, config->credits_end ? BST_CHECKED : BST_UNCHECKED); | ||
851 : | SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE); | ||
852 : | SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE); | ||
853 : | |||
854 : | SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE); | ||
855 : | SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE); | ||
856 : | SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE); | ||
857 : | SetDlgItemInt(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size, FALSE); | ||
858 : | SetDlgItemInt(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size, FALSE); | ||
859 : | |||
860 : | switch (config->credits_mode) | ||
861 : | { | ||
862 : | case CREDITS_MODE_RATE : | ||
863 : | CheckDlgButton(hDlg, IDC_CREDITS_RATE_RADIO, BST_CHECKED); | ||
864 : | break; | ||
865 : | |||
866 : | case CREDITS_MODE_QUANT : | ||
867 : | CheckDlgButton(hDlg, IDC_CREDITS_QUANT_RADIO, BST_CHECKED); | ||
868 : | break; | ||
869 : | |||
870 : | case CREDITS_MODE_SIZE : | ||
871 : | CheckDlgButton(hDlg, IDC_CREDITS_SIZE_RADIO, BST_CHECKED); | ||
872 : | break; | ||
873 : | } | ||
874 : | |||
875 : | credits_controls(hDlg); | ||
876 : | |||
877 : | break; | ||
878 : | |||
879 : | case WM_COMMAND : | ||
880 : | if (LOWORD(wParam) == IDCANCEL) | ||
881 : | { | ||
882 : | EndDialog(hDlg, IDCANCEL); | ||
883 : | } | ||
884 : | else if (HIWORD(wParam) == BN_CLICKED) | ||
885 : | { | ||
886 : | switch (LOWORD(wParam)) | ||
887 : | { | ||
888 : | case IDC_CREDITS_START : | ||
889 : | case IDC_CREDITS_END : | ||
890 : | case IDC_CREDITS_RATE_RADIO : | ||
891 : | case IDC_CREDITS_QUANT_RADIO : | ||
892 : | case IDC_CREDITS_SIZE_RADIO : | ||
893 : | credits_controls(hDlg); | ||
894 : | break; | ||
895 : | |||
896 : | case IDOK : | ||
897 : | config->credits_start = ISDLGSET(IDC_CREDITS_START); | ||
898 : | config->credits_start_begin = config_get_int(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin); | ||
899 : | config->credits_start_end = config_get_int(hDlg, IDC_CREDITS_START_END, config->credits_start_end); | ||
900 : | config->credits_end = ISDLGSET(IDC_CREDITS_END); | ||
901 : | config->credits_end_begin = config_get_int(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin); | ||
902 : | config->credits_end_end = config_get_int(hDlg, IDC_CREDITS_END_END, config->credits_end_end); | ||
903 : | |||
904 : | config->credits_rate = config_get_int(hDlg, IDC_CREDITS_RATE, config->credits_rate); | ||
905 : | config->credits_quant_i = config_get_int(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i); | ||
906 : | config->credits_quant_p = config_get_int(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p); | ||
907 : | config->credits_start_size = config_get_int(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size); | ||
908 : | config->credits_end_size = config_get_int(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size); | ||
909 : | |||
910 : | if (ISDLGSET(IDC_CREDITS_RATE_RADIO)) | ||
911 : | { | ||
912 : | config->credits_mode = CREDITS_MODE_RATE; | ||
913 : | } | ||
914 : | if (ISDLGSET(IDC_CREDITS_QUANT_RADIO)) | ||
915 : | { | ||
916 : | config->credits_mode = CREDITS_MODE_QUANT; | ||
917 : | } | ||
918 : | if (ISDLGSET(IDC_CREDITS_SIZE_RADIO)) | ||
919 : | { | ||
920 : | config->credits_mode = CREDITS_MODE_SIZE; | ||
921 : | } | ||
922 : | |||
923 : | CONSTRAINVAL(config->credits_rate, 1, 100) | ||
924 : | CONSTRAINVAL(config->credits_quant_i, 1, 31) | ||
925 : | CONSTRAINVAL(config->credits_quant_p, 1, 31) | ||
926 : | |||
927 : | if (config->credits_start_begin > config->credits_start_end) | ||
928 : | { | ||
929 : | config->credits_start_begin = config->credits_start_end; | ||
930 : | config->credits_start = 0; | ||
931 : | } | ||
932 : | if (config->credits_end_begin > config->credits_end_end) | ||
933 : | { | ||
934 : | config->credits_end_begin = config->credits_end_end; | ||
935 : | config->credits_end = 0; | ||
936 : | } | ||
937 : | |||
938 : | EndDialog(hDlg, IDOK); | ||
939 : | break; | ||
940 : | } | ||
941 : | } | ||
942 : | break; | ||
943 : | |||
944 : | default : | ||
945 : | return 0; | ||
946 : | } | ||
947 : | |||
948 : | return 1; | ||
949 : | } | ||
950 : | |||
951 : | |||
952 : | /* 2-pass dialog proc */ | ||
953 : | |||
954 : | BOOL CALLBACK twopass_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
955 : | { | ||
956 : | CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); | ||
957 : | |||
958 : | switch (uMsg) | ||
959 : | { | ||
960 : | case WM_INITDIALOG : | ||
961 : | SetWindowLong(hDlg, GWL_USERDATA, lParam); | ||
962 : | |||
963 : | config = (CONFIG*)lParam; | ||
964 : | |||
965 : | SetDlgItemInt(hDlg, IDC_DESIRED, config->desired_size, FALSE); | ||
966 : | SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE); | ||
967 : | SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE); | ||
968 : | SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); | ||
969 : | SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); | ||
970 : | SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE); | ||
971 : | CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0)); | ||
972 : | CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1)); | ||
973 : | break; | ||
974 : | |||
975 : | case WM_COMMAND : | ||
976 : | if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED) | ||
977 : | { | ||
978 : | config->desired_size = config_get_int(hDlg, IDC_DESIRED, config->desired_size); | ||
979 : | config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE); | ||
980 : | config->min_key_interval = config_get_int(hDlg, IDC_MINKEY, config->max_key_interval); | ||
981 : | config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); | ||
982 : | config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); | ||
983 : | config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); | ||
984 : | config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP); | ||
985 : | |||
986 : | CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000) | ||
987 : | CONSTRAINVAL(config->keyframe_boost, 0, 1000) | ||
988 : | CONSTRAINVAL(config->curve_compression_high, 0, 100) | ||
989 : | CONSTRAINVAL(config->curve_compression_low, 0, 100) | ||
990 : | |||
991 : | EndDialog(hDlg, IDOK); | ||
992 : | } | ||
993 : | else if (LOWORD(wParam) == IDCANCEL) | ||
994 : | { | ||
995 : | EndDialog(hDlg, IDCANCEL); | ||
996 : | } | ||
997 : | break; | ||
998 : | |||
999 : | default : | ||
1000 : | return 0; | ||
1001 : | } | ||
1002 : | |||
1003 : | return 1; | ||
1004 : | } | ||
1005 : | |||
1006 : | |||
1007 : | /* quantization matrix dialog proc */ | ||
1008 : | |||
1009 : | BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
1010 : | { | ||
1011 : | CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); | ||
1012 : | |||
1013 : | switch (uMsg) | ||
1014 : | { | ||
1015 : | case WM_INITDIALOG : | ||
1016 : | SetWindowLong(hDlg, GWL_USERDATA, lParam); | ||
1017 : | |||
1018 : | config = (CONFIG*)lParam; | ||
1019 : | |||
1020 : | quant_upload(hDlg, config); | ||
1021 : | break; | ||
1022 : | |||
1023 : | case WM_COMMAND : | ||
1024 : | if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED) | ||
1025 : | { | ||
1026 : | quant_download(hDlg, config); | ||
1027 : | |||
1028 : | EndDialog(hDlg, IDOK); | ||
1029 : | } | ||
1030 : | else if (LOWORD(wParam) == IDCANCEL) | ||
1031 : | { | ||
1032 : | EndDialog(hDlg, IDCANCEL); | ||
1033 : | } | ||
1034 : | else if ((LOWORD(wParam) == IDC_LOAD || LOWORD(wParam) == IDC_SAVE) && HIWORD(wParam) == BN_CLICKED) | ||
1035 : | { | ||
1036 : | OPENFILENAME ofn; | ||
1037 : | char file[MAX_PATH]; | ||
1038 : | |||
1039 : | HANDLE hFile; | ||
1040 : | DWORD read=128, wrote=0; | ||
1041 : | BYTE quant_data[128]; | ||
1042 : | |||
1043 : | strcpy(file, "\\matrix"); | ||
1044 : | memset(&ofn, 0, sizeof(OPENFILENAME)); | ||
1045 : | ofn.lStructSize = sizeof(OPENFILENAME); | ||
1046 : | |||
1047 : | ofn.hwndOwner = hDlg; | ||
1048 : | ofn.lpstrFilter = "All files (*.*)\0*.*\0\0"; | ||
1049 : | ofn.lpstrFile = file; | ||
1050 : | ofn.nMaxFile = MAX_PATH; | ||
1051 : | ofn.Flags = OFN_PATHMUSTEXIST; | ||
1052 : | |||
1053 : | if (LOWORD(wParam) == IDC_SAVE) | ||
1054 : | { | ||
1055 : | ofn.Flags |= OFN_OVERWRITEPROMPT; | ||
1056 : | if (GetSaveFileName(&ofn)) | ||
1057 : | { | ||
1058 : | hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); | ||
1059 : | |||
1060 : | quant_download(hDlg, config); | ||
1061 : | memcpy(quant_data, config->qmatrix_intra, 64); | ||
1062 : | memcpy(quant_data+64, config->qmatrix_inter, 64); | ||
1063 : | |||
1064 : | if (hFile == INVALID_HANDLE_VALUE) | ||
1065 : | { | ||
1066 : | DEBUG("Couldn't save quant matrix"); | ||
1067 : | } | ||
1068 : | else | ||
1069 : | { | ||
1070 : | if (!WriteFile(hFile, quant_data, 128, &wrote, 0)) | ||
1071 : | { | ||
1072 : | DEBUG("Couldnt write quant matrix"); | ||
1073 : | } | ||
1074 : | } | ||
1075 : | |||
1076 : | CloseHandle(hFile); | ||
1077 : | } | ||
1078 : | } | ||
1079 : | else | ||
1080 : | { | ||
1081 : | ofn.Flags |= OFN_FILEMUSTEXIST; | ||
1082 : | if (GetOpenFileName(&ofn)) | ||
1083 : | { | ||
1084 : | hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); | ||
1085 : | |||
1086 : | if (hFile == INVALID_HANDLE_VALUE) | ||
1087 : | { | ||
1088 : | DEBUG("Couldn't load quant matrix"); | ||
1089 : | } | ||
1090 : | else | ||
1091 : | { | ||
1092 : | if (!ReadFile(hFile, quant_data, 128, &read, 0)) | ||
1093 : | { | ||
1094 : | DEBUG("Couldnt read quant matrix"); | ||
1095 : | } | ||
1096 : | else | ||
1097 : | { | ||
1098 : | memcpy(config->qmatrix_intra, quant_data, 64); | ||
1099 : | memcpy(config->qmatrix_inter, quant_data+64, 64); | ||
1100 : | quant_upload(hDlg, config); | ||
1101 : | } | ||
1102 : | } | ||
1103 : | |||
1104 : | CloseHandle(hFile); | ||
1105 : | } | ||
1106 : | } | ||
1107 : | } | ||
1108 : | break; | ||
1109 : | |||
1110 : | default : | ||
1111 : | return 0; | ||
1112 : | } | ||
1113 : | |||
1114 : | return 1; | ||
1115 : | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |