[svn] / trunk / vfw / src / config.c Repository:
ViewVC logotype

Annotation of /trunk/vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (view) (download)

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

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4