[svn] / branches / dev-api-4 / xvidcore / vfw / src / config.c Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 983 - (view) (download)

1 : suxen_drol 889 /**************************************************************************
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 :     * 15.06.2002 added bframes options
27 :     * 21.04.2002 fixed custom matrix support, tried to get dll size down
28 :     * 17.04.2002 re-enabled lumi masking in 1st pass
29 :     * 15.04.2002 updated cbr support
30 :     * 07.04.2002 min keyframe interval checkbox
31 :     * 2-pass max bitrate and overflow customization
32 :     * 04.04.2002 interlacing support
33 :     * hinted ME support
34 :     * 24.03.2002 daniel smith <danielsmith@astroboymail.com>
35 :     * added Foxer's new CBR engine
36 :     * - cbr_buffer is being used as reaction delay (quick hack)
37 :     * 23.03.2002 daniel smith <danielsmith@astroboymail.com>
38 :     * added load defaults button
39 :     * merged foxer's alternative 2-pass code (2-pass alt tab)
40 :     * added proper tooltips
41 :     * moved registry data into reg_ints/reg_strs arrays
42 :     * added DEBUGERR output on errors instead of returning
43 :     * 16.03.2002 daniel smith <danielsmith@astroboymail.com>
44 :     * rewrote/restructured most of file
45 :     * added tooltips (kind of - dirty message hook method)
46 :     * split tabs into a main dialog / advanced prop sheet
47 :     * advanced controls are now enabled/disabled by mode
48 :     * added modulated quantization, DX50 fourcc
49 :     * 11.03.2002 Min Chen <chenm001@163.com>
50 :     * now get Core Version use xvid_init()
51 :     * 05.03.2002 Min Chen <chenm001@163.com>
52 :     * Add Core version display to about box
53 :     * 01.12.2001 inital version; (c)2001 peter ross <pross@xvid.org>
54 :     *
55 :     *************************************************************************/
56 :    
57 :    
58 :     #include <windows.h>
59 :     #include <commctrl.h>
60 :     #include <shlobj.h>
61 :     #include <prsht.h>
62 :    
63 :     #include <xvid.h> // XviD API
64 :    
65 : suxen_drol 983 #include "debug.h"
66 : suxen_drol 889 #include "codec.h"
67 :     #include "config.h"
68 :     #include "resource.h"
69 :    
70 :    
71 : suxen_drol 983 #define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z;
72 :     #define IsDlgChecked(hwnd,idc) (IsDlgButtonChecked(hwnd,idc) == BST_CHECKED)
73 :     #define EnableDlgWindow(hwnd,idc,state) EnableWindow(GetDlgItem(hwnd,idc),state)
74 : suxen_drol 889
75 : suxen_drol 983 HINSTANCE g_hInst;
76 :     HWND g_hTooltip;
77 : suxen_drol 889
78 : suxen_drol 983 /* enumerates child windows, assigns tooltips */
79 :     BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
80 :     {
81 :     char help[500];
82 :    
83 :     if (LoadString(g_hInst, GetDlgCtrlID(hWnd), help, 500))
84 :     {
85 :     TOOLINFO ti;
86 :     ti.cbSize = sizeof(TOOLINFO);
87 :     ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
88 :     ti.hwnd = GetParent(hWnd);
89 :     ti.uId = (LPARAM)hWnd;
90 :     ti.lpszText = help;
91 :     SendMessage(g_hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
92 :     }
93 :    
94 :     return TRUE;
95 :     }
96 :    
97 :    
98 :     /* ===================================================================================== */
99 :     /* MPEG-4 PROFILES/LEVELS ============================================================== */
100 :     /* ===================================================================================== */
101 :    
102 :     #define PROFILE_BVOP 0x00000001
103 :     #define PROFILE_MPEGQUANT 0x00000002
104 :     #define PROFILE_INTERLACE 0x00000004
105 :     #define PROFILE_QPEL 0x00000008
106 :     #define PROFILE_GMC 0x00000010
107 :     #define PROFILE_REDUCED 0x00000020 /* dynamic resolution conversion */
108 :    
109 :     #define PROFILE_AS (PROFILE_BVOP|PROFILE_MPEGQUANT|PROFILE_INTERLACE|PROFILE_QPEL|PROFILE_GMC)
110 :     #define PROFILE_ARTS (PROFILE_REDUCED)
111 :    
112 :    
113 :     typedef struct
114 :     {
115 :     char * name;
116 :     int width;
117 :     int height;
118 :     int fps;
119 :     int max_objects;
120 :     int total_vmv_buffer_sz; /* macroblock memory; when BVOPS=false, vmv = 2*vcv; when BVOPS=true, vmv = 3*vcv*/
121 :     int max_vmv_buffer_sz; /* max macroblocks per vop */
122 :     int vcv_decoder_rate; /* macroblocks decoded per second */
123 :     int max_acpred_mbs; /* percentage */
124 :     int max_vbv_size; /* max vbv size (bits) 16368 bits */
125 :     int max_video_packet_length; /* bits */
126 :     int max_bitrate; /* kbits/s */
127 :     unsigned int flags;
128 :     } profile_t;
129 :    
130 :     /* default vbv_occupancy is (64/170)*vbv_buffer_size */
131 :    
132 :     static const profile_t profiles[] =
133 :     {
134 :     /* name w h fps obj Tvmv vmv vcv ac% vbv pkt kbps flags */
135 :     { "(unrestricted)", 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, 0, 0, 0xffffffff },
136 :    
137 :     { "Simple @ L1", 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 2048, 64, 0 },
138 :     { "Simple @ L2", 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128, 0 },
139 :     { "Simple @ L3", 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384, 0 },
140 :    
141 :     { "ARTS @ L1", 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 8192, 64, PROFILE_ARTS },
142 :     { "ARTS @ L2", 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 16384, 128, PROFILE_ARTS },
143 :     { "ARTS @ L3", 352, 288, 30, 4, 792, 396, 11880, 100, 40*16368, 16384, 384, PROFILE_ARTS },
144 :     { "ARTS @ L4", 352, 288, 30, 16, 792, 396, 11880, 100, 80*16368, 16384, 2000, PROFILE_ARTS },
145 :    
146 :     { "AS @ L0", 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS },
147 :     { "AS @ L1", 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS },
148 :     { "AS @ L2", 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384, PROFILE_AS },
149 :     { "AS @ L3", 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768, PROFILE_AS },
150 :     { "AS @ L4", 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000, PROFILE_AS },
151 :     { "AS @ L5", 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000, PROFILE_AS },
152 :    
153 :     { "DXN Handheld", 176, 144, 15, -1, 198, 99, 1485, 100, 16*16368, -1, 128, 0 },
154 :     { "DXN Portable NTSC", 352, 240, 30, -1, 990, 330, 9900, 100, 64*16368, -1, 768, PROFILE_BVOP },
155 :     { "DXN Portable PAL", 352, 288, 25, -1, 1188, 396, 9900, 100, 64*16368, -1, 768, PROFILE_BVOP },
156 :     { "DXN HT NTSC", 720, 480, 30, -1, 4050, 1350, 40500, 100, 192*16368, -1, 4000, PROFILE_BVOP|PROFILE_INTERLACE },
157 :     { "DXN HT NTSC", 720, 576, 25, -1, 4860, 1620, 40500, 100, 192*16368, -1, 4000, PROFILE_BVOP|PROFILE_INTERLACE },
158 :     { "DXN HDTV", 1280, 720, 30, -1,10800, 3600, 108000, 100, 384*16368, -1, 8000, PROFILE_BVOP|PROFILE_INTERLACE },
159 :     };
160 :    
161 :    
162 :     /* ===================================================================================== */
163 :     /* REGISTRY ============================================================================ */
164 :     /* ===================================================================================== */
165 :    
166 :     /* registry info structs */
167 : suxen_drol 889 CONFIG reg;
168 :    
169 : suxen_drol 983 static const REG_INT reg_ints[] = {
170 :     {"mode", &reg.mode, RC_MODE_CBR},
171 : suxen_drol 889 {"quality", &reg.quality, 85},
172 :     {"quant", &reg.quant, 5},
173 :     {"rc_bitrate", &reg.rc_bitrate, 900000},
174 :     {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor, 16},
175 :     {"rc_averaging_period", &reg.rc_averaging_period, 100},
176 : suxen_drol 983 {"rc_buffer", &reg.rc_buffer, 100},
177 : suxen_drol 889
178 :     {"motion_search", &reg.motion_search, 6},
179 :     {"quant_type", &reg.quant_type, 0},
180 :     {"fourcc_used", &reg.fourcc_used, 0},
181 :     {"vhq_mode", &reg.vhq_mode, 0},
182 :     {"max_key_interval", &reg.max_key_interval, 300},
183 :     {"min_key_interval", &reg.min_key_interval, 1},
184 :     {"lum_masking", &reg.lum_masking, 0},
185 :     {"interlacing", &reg.interlacing, 0},
186 :     {"qpel", &reg.qpel, 0},
187 :     {"gmc", &reg.gmc, 0},
188 :     {"chromame", &reg.chromame, 0},
189 :     {"greyscale", &reg.greyscale, 0},
190 : suxen_drol 983 {"use_bvop", &reg.use_bvop, 0},
191 :     {"max_bframes", &reg.max_bframes, 2},
192 : suxen_drol 889 {"bquant_ratio", &reg.bquant_ratio, 150},
193 :     {"bquant_offset", &reg.bquant_offset, 100},
194 : suxen_drol 983 {"bvop_threshold", &reg.bvop_threshold, 0},
195 : suxen_drol 889 {"packed", &reg.packed, 0},
196 : suxen_drol 983 {"closed_gov", &reg.closed_gov, 1},
197 : suxen_drol 889 {"debug", &reg.debug, 0},
198 :     {"reduced_resolution", &reg.reduced_resolution, 0},
199 :     {"chroma_opt", &reg.chroma_opt, 0},
200 :     {"frame_drop_ratio", &reg.frame_drop_ratio, 0},
201 :    
202 :     {"min_iquant", &reg.min_iquant, 2},
203 :     {"max_iquant", &reg.max_iquant, 31},
204 :     {"min_pquant", &reg.min_pquant, 2},
205 :     {"max_pquant", &reg.max_pquant, 31},
206 :    
207 :     {"desired_size", &reg.desired_size, 570000},
208 :     {"keyframe_boost", &reg.keyframe_boost, 0},
209 :     {"discard1pass", &reg.discard1pass, 1},
210 :     {"kftreshold", &reg.kftreshold, 10},
211 :     {"kfreduction", &reg.kfreduction, 20},
212 :     {"curve_compression_high", &reg.curve_compression_high, 0},
213 :     {"curve_compression_low", &reg.curve_compression_low, 0},
214 :     {"use_alt_curve", &reg.use_alt_curve, 0},
215 :     {"alt_curve_use_auto", &reg.alt_curve_use_auto, 1},
216 :     {"alt_curve_auto_str", &reg.alt_curve_auto_str, 30},
217 :     {"alt_curve_use_auto_bonus_bias", &reg.alt_curve_use_auto_bonus_bias, 1},
218 :     {"alt_curve_bonus_bias", &reg.alt_curve_bonus_bias, 50},
219 :     {"alt_curve_type", &reg.alt_curve_type, 1},
220 :     {"alt_curve_high_dist", &reg.alt_curve_high_dist, 500},
221 :     {"alt_curve_low_dist", &reg.alt_curve_low_dist, 90},
222 :     {"alt_curve_min_rel_qual", &reg.alt_curve_min_rel_qual, 50},
223 :     {"bitrate_payback_delay", &reg.bitrate_payback_delay, 250},
224 :     {"bitrate_payback_method", &reg.bitrate_payback_method, 0},
225 :     {"twopass_max_bitrate", &reg.twopass_max_bitrate, 10000 * CONFIG_KBPS},
226 :     {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 60},
227 :     {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 60},
228 :    
229 :     /* decoder */
230 : suxen_drol 983 // {"deblock_y", &reg.deblock_y, 0},
231 :     // {"deblock_uv", &reg.deblock_uv, 0}
232 : suxen_drol 889 };
233 :    
234 : suxen_drol 983 static const REG_STR reg_strs[] = {
235 :     {"profile", reg.profile_name, "(unrestricted)"},
236 :     {"stats", reg.stats, CONFIG_2PASS_FILE},
237 : suxen_drol 889 };
238 :    
239 :     /* get config settings from registry */
240 :    
241 :     #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)));}
242 :    
243 :     void config_reg_get(CONFIG * config)
244 :     {
245 :     HKEY hKey;
246 :     DWORD size;
247 :     int i;
248 :     xvid_gbl_info_t info;
249 :    
250 :     memset(&info, 0, sizeof(info));
251 :     info.version = XVID_VERSION;
252 :     xvid_global(0, XVID_GBL_INFO, &info, NULL);
253 :     reg.cpu = info.cpu_flags;
254 :     reg.num_threads = info.num_threads;
255 :    
256 :     RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey);
257 :    
258 :     for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
259 :     {
260 :     size = sizeof(int);
261 :    
262 :     if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS)
263 :     {
264 :     *reg_ints[i].config_int = reg_ints[i].def;
265 :     }
266 :     }
267 :    
268 :     for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
269 :     {
270 :     size = MAX_PATH;
271 :    
272 :     if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS)
273 :     {
274 :     memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
275 :     }
276 :     }
277 :    
278 :     {
279 :     BYTE default_qmatrix_intra[] = {
280 :     8, 17,18,19,21,23,25,27,
281 :     17,18,19,21,23,25,27,28,
282 :     20,21,22,23,24,26,28,30,
283 :     21,22,23,24,26,28,30,32,
284 :     22,23,24,26,28,30,32,35,
285 :     23,24,26,28,30,32,35,38,
286 :     25,26,28,30,32,35,38,41,
287 :     27,28,30,32,35,38,41,45
288 :     };
289 :    
290 :     BYTE default_qmatrix_inter[] = {
291 :     16,17,18,19,20,21,22,23,
292 :     17,18,19,20,21,22,23,24,
293 :     18,19,20,21,22,23,24,25,
294 :     19,20,21,22,23,24,26,27,
295 :     20,21,22,23,25,26,27,28,
296 :     21,22,23,24,26,27,28,30,
297 :     22,23,24,26,27,28,30,31,
298 :     23,24,25,27,28,30,31,33
299 :     };
300 :    
301 :     REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra);
302 :     REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter);
303 :     }
304 :    
305 : suxen_drol 983 reg.profile = 0;
306 :     for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) {
307 :     if (strcmpi(profiles[i].name, reg.profile_name) == 0) {
308 :     reg.profile = i;
309 :     }
310 :     }
311 :    
312 : suxen_drol 889 memcpy(config, &reg, sizeof(CONFIG));
313 :    
314 :     RegCloseKey(hKey);
315 :     }
316 :    
317 :    
318 :     /* put config settings in registry */
319 :    
320 :     #define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y)))
321 :    
322 :     void config_reg_set(CONFIG * config)
323 :     {
324 :     HKEY hKey;
325 :     DWORD dispo;
326 :     int i;
327 :    
328 :     if (RegCreateKeyEx(
329 :     XVID_REG_KEY,
330 :     XVID_REG_PARENT "\\" XVID_REG_CHILD,
331 :     0,
332 :     XVID_REG_CLASS,
333 :     REG_OPTION_NON_VOLATILE,
334 :     KEY_WRITE,
335 :     0,
336 :     &hKey,
337 :     &dispo) != ERROR_SUCCESS)
338 :     {
339 : suxen_drol 983 DPRINTF("Couldn't create XVID_REG_SUBKEY - GetLastError=%i", GetLastError());
340 : suxen_drol 889 return;
341 :     }
342 :    
343 :     memcpy(&reg, config, sizeof(CONFIG));
344 :    
345 : suxen_drol 983 strcpy(reg.profile_name, profiles[reg.profile].name);
346 :    
347 : suxen_drol 889 for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
348 :     {
349 :     RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int));
350 :     }
351 :    
352 :     for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
353 :     {
354 :     RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1);
355 :     }
356 :    
357 :     REG_SET_B("qmatrix_intra", reg.qmatrix_intra);
358 :     REG_SET_B("qmatrix_inter", reg.qmatrix_inter);
359 :    
360 :     RegCloseKey(hKey);
361 :     }
362 :    
363 :    
364 :     /* clear XviD registry key, load defaults */
365 :    
366 :     void config_reg_default(CONFIG * config)
367 :     {
368 :     HKEY hKey;
369 :    
370 :     if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey))
371 :     {
372 : suxen_drol 983 DPRINTF("Couldn't open registry key for deletion - GetLastError=%i", GetLastError());
373 : suxen_drol 889 return;
374 :     }
375 :    
376 :     if (RegDeleteKey(hKey, XVID_REG_CHILD))
377 :     {
378 : suxen_drol 983 DPRINTF("Couldn't delete registry key - GetLastError=%i", GetLastError());
379 : suxen_drol 889 return;
380 :     }
381 :    
382 :     RegCloseKey(hKey);
383 :     config_reg_get(config);
384 :     config_reg_set(config);
385 :     }
386 :    
387 :    
388 :     /* leaves current config value if dialog item is empty */
389 :    
390 :     int config_get_int(HWND hDlg, INT item, int config)
391 :     {
392 :     BOOL success = FALSE;
393 :    
394 :     int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);
395 :    
396 :     return (success) ? tmp : config;
397 :     }
398 :    
399 :    
400 :     int config_get_uint(HWND hDlg, UINT item, int config)
401 :     {
402 :     BOOL success = FALSE;
403 :    
404 :     int tmp = GetDlgItemInt(hDlg, item, &success, FALSE);
405 :    
406 :     return (success) ? tmp : config;
407 :     }
408 :    
409 :    
410 :    
411 : suxen_drol 983 /* ===================================================================================== */
412 :     /* QUANT MATRIX DIALOG ================================================================= */
413 :     /* ===================================================================================== */
414 :    
415 :     void quant_upload(HWND hDlg, CONFIG* config)
416 : suxen_drol 889 {
417 : suxen_drol 983 int i;
418 : suxen_drol 889
419 : suxen_drol 983 for (i=0 ; i<64 ; ++i)
420 :     {
421 :     SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE);
422 :     SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE);
423 : suxen_drol 889 }
424 :     }
425 :    
426 :    
427 : suxen_drol 983 void quant_download(HWND hDlg, CONFIG* config)
428 : suxen_drol 889 {
429 : suxen_drol 983 int i;
430 : suxen_drol 889
431 : suxen_drol 983 for (i=0; i<64 ; ++i)
432 : suxen_drol 889 {
433 : suxen_drol 983 int temp;
434 : suxen_drol 889
435 : suxen_drol 983 temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);
436 :     CONSTRAINVAL(temp, 1, 255);
437 :     config->qmatrix_intra[i] = temp;
438 : suxen_drol 889
439 : suxen_drol 983 temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);
440 :     CONSTRAINVAL(temp, 1, 255);
441 :     config->qmatrix_inter[i] = temp;
442 : suxen_drol 889 }
443 :     }
444 :    
445 : suxen_drol 983 /* quantization matrix dialog proc */
446 : suxen_drol 889
447 : suxen_drol 983 BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
448 : suxen_drol 889 {
449 : suxen_drol 983 CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
450 : suxen_drol 889
451 : suxen_drol 983 switch (uMsg)
452 : suxen_drol 889 {
453 : suxen_drol 983 case WM_INITDIALOG :
454 :     SetWindowLong(hDlg, GWL_USERDATA, lParam);
455 :     config = (CONFIG*)lParam;
456 :     quant_upload(hDlg, config);
457 : suxen_drol 889
458 : suxen_drol 983 if (g_hTooltip)
459 :     {
460 :     EnumChildWindows(hDlg, enum_tooltips, 0);
461 :     }
462 : suxen_drol 889 break;
463 :    
464 : suxen_drol 983 case WM_COMMAND :
465 :     if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
466 :     {
467 :     quant_download(hDlg, config);
468 :     EndDialog(hDlg, IDOK);
469 :     }
470 :     else if (LOWORD(wParam) == IDCANCEL)
471 :     {
472 :     EndDialog(hDlg, IDCANCEL);
473 :     }
474 :     else if ((LOWORD(wParam) == IDC_LOAD || LOWORD(wParam) == IDC_SAVE) && HIWORD(wParam) == BN_CLICKED)
475 :     {
476 :     OPENFILENAME ofn;
477 :     char file[MAX_PATH];
478 : suxen_drol 889
479 : suxen_drol 983 HANDLE hFile;
480 :     DWORD read=128, wrote=0;
481 :     BYTE quant_data[128];
482 : suxen_drol 889
483 : suxen_drol 983 strcpy(file, "\\matrix");
484 :     memset(&ofn, 0, sizeof(OPENFILENAME));
485 :     ofn.lStructSize = sizeof(OPENFILENAME);
486 : suxen_drol 889
487 : suxen_drol 983 ofn.hwndOwner = hDlg;
488 :     ofn.lpstrFilter = "All files (*.*)\0*.*\0\0";
489 :     ofn.lpstrFile = file;
490 :     ofn.nMaxFile = MAX_PATH;
491 :     ofn.Flags = OFN_PATHMUSTEXIST;
492 : suxen_drol 889
493 : suxen_drol 983 if (LOWORD(wParam) == IDC_SAVE)
494 :     {
495 :     ofn.Flags |= OFN_OVERWRITEPROMPT;
496 :     if (GetSaveFileName(&ofn))
497 :     {
498 :     hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
499 : suxen_drol 889
500 : suxen_drol 983 quant_download(hDlg, config);
501 :     memcpy(quant_data, config->qmatrix_intra, 64);
502 :     memcpy(quant_data+64, config->qmatrix_inter, 64);
503 : suxen_drol 889
504 : suxen_drol 983 if (hFile == INVALID_HANDLE_VALUE)
505 :     {
506 :     DPRINTF("Couldn't save quant matrix");
507 :     }
508 :     else
509 :     {
510 :     if (!WriteFile(hFile, quant_data, 128, &wrote, 0))
511 :     {
512 :     DPRINTF("Couldnt write quant matrix");
513 :     }
514 :     }
515 : suxen_drol 889
516 : suxen_drol 983 CloseHandle(hFile);
517 :     }
518 :     }
519 :     else
520 :     {
521 :     ofn.Flags |= OFN_FILEMUSTEXIST;
522 :     if (GetOpenFileName(&ofn))
523 :     {
524 :     hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
525 : suxen_drol 889
526 : suxen_drol 983 if (hFile == INVALID_HANDLE_VALUE)
527 :     {
528 :     DPRINTF("Couldn't load quant matrix");
529 :     }
530 :     else
531 :     {
532 :     if (!ReadFile(hFile, quant_data, 128, &read, 0))
533 :     {
534 :     DPRINTF("Couldnt read quant matrix");
535 :     }
536 :     else
537 :     {
538 :     memcpy(config->qmatrix_intra, quant_data, 64);
539 :     memcpy(config->qmatrix_inter, quant_data+64, 64);
540 :     quant_upload(hDlg, config);
541 :     }
542 :     }
543 : suxen_drol 889
544 : suxen_drol 983 CloseHandle(hFile);
545 :     }
546 :     }
547 :     }
548 :     break;
549 : suxen_drol 889
550 : suxen_drol 983 default :
551 :     return 0;
552 : suxen_drol 889 }
553 : suxen_drol 983
554 :     return 1;
555 : suxen_drol 889 }
556 :    
557 :    
558 : suxen_drol 983 /* ===================================================================================== */
559 :     /* ADVANCED DIALOG PAGES ================================================================ */
560 :     /* ===================================================================================== */
561 : suxen_drol 889
562 : suxen_drol 983 /* initialise pages */
563 :     void adv_init(HWND hDlg, int idd, CONFIG * config)
564 : suxen_drol 889 {
565 : suxen_drol 983 unsigned int i;
566 : suxen_drol 889
567 : suxen_drol 983 switch(idd) {
568 :     case IDD_PROFILE :
569 :     for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
570 :     SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
571 :     break;
572 :    
573 :     case IDD_RC_2PASS2_ALT :
574 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low");
575 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium");
576 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High");
577 :     break;
578 : suxen_drol 889
579 : suxen_drol 983 case IDD_MOTION :
580 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None");
581 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low");
582 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low");
583 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium");
584 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High");
585 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High");
586 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High");
587 : suxen_drol 889
588 : suxen_drol 983 SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"0 - Off");
589 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"1 - Mode Decision");
590 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"2 - Limited Search");
591 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"3 - Medium Search");
592 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"4 - Wide Search");
593 :     break;
594 : suxen_drol 889
595 : suxen_drol 983 case IDD_TOOLS :
596 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263");
597 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");
598 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");
599 :     break;
600 :    
601 :     case IDD_DEBUG :
602 :     /* force threads disabled */
603 :     EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);
604 :     EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);
605 : suxen_drol 889
606 : suxen_drol 983 SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");
607 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
608 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
609 :     break;
610 :     }
611 :     }
612 : suxen_drol 889
613 : suxen_drol 983 /* enable/disable controls based on encoder-mode or user selection */
614 : suxen_drol 889
615 : suxen_drol 983 void adv_mode(HWND hDlg, int idd, CONFIG * config)
616 :     {
617 :     int use_alt, use_alt_auto, use_alt_auto_bonus;
618 :     int cpu_force;
619 :     int bvops;
620 :    
621 :     switch(idd) {
622 :     case IDD_PROFILE :
623 :     CheckDlgButton(hDlg, IDC_PROFILE_BVOP, profiles[config->profile].flags&PROFILE_BVOP ? BST_CHECKED : BST_UNCHECKED);
624 :     CheckDlgButton(hDlg, IDC_PROFILE_MPEGQUANT, profiles[config->profile].flags&PROFILE_MPEGQUANT ? BST_CHECKED : BST_UNCHECKED);
625 :     CheckDlgButton(hDlg, IDC_PROFILE_INTERLACE, profiles[config->profile].flags&PROFILE_INTERLACE ? BST_CHECKED : BST_UNCHECKED);
626 :     CheckDlgButton(hDlg, IDC_PROFILE_QPEL, profiles[config->profile].flags&PROFILE_QPEL ? BST_CHECKED : BST_UNCHECKED);
627 :     CheckDlgButton(hDlg, IDC_PROFILE_GMC, profiles[config->profile].flags&PROFILE_GMC ? BST_CHECKED : BST_UNCHECKED);
628 :     CheckDlgButton(hDlg, IDC_PROFILE_REDUCED, profiles[config->profile].flags&PROFILE_REDUCED ? BST_CHECKED : BST_UNCHECKED);
629 :     break;
630 : suxen_drol 889
631 : suxen_drol 983 case IDD_RC_2PASS2_ALT :
632 :     use_alt = IsDlgChecked(hDlg, IDC_USEALT);
633 :     use_alt_auto = IsDlgChecked(hDlg, IDC_USEAUTO);
634 :     use_alt_auto_bonus = IsDlgChecked(hDlg, IDC_USEAUTOBONUS);
635 :     EnableDlgWindow(hDlg, IDC_USEAUTO, use_alt);
636 :     EnableDlgWindow(hDlg, IDC_AUTOSTR, use_alt && use_alt_auto);
637 :     EnableDlgWindow(hDlg, IDC_USEAUTOBONUS, use_alt);
638 :     EnableDlgWindow(hDlg, IDC_BONUSBIAS, use_alt && !use_alt_auto_bonus);
639 :     EnableDlgWindow(hDlg, IDC_CURVETYPE, use_alt);
640 :     EnableDlgWindow(hDlg, IDC_ALTCURVEHIGH, use_alt);
641 :     EnableDlgWindow(hDlg, IDC_ALTCURVELOW, use_alt);
642 :     EnableDlgWindow(hDlg, IDC_MINQUAL, use_alt && !use_alt_auto);
643 :     break;
644 : suxen_drol 889
645 : suxen_drol 983 case IDD_TOOLS :
646 :     bvops = IsDlgChecked(hDlg, IDC_BVOP);
647 :     EnableDlgWindow(hDlg, IDC_MAXBFRAMES, bvops);
648 :     EnableDlgWindow(hDlg, IDC_BQUANTRATIO, bvops);
649 :     EnableDlgWindow(hDlg, IDC_BQUANTOFFSET, bvops);
650 :     EnableDlgWindow(hDlg, IDC_BVOP_THRESHOLD, bvops);
651 : suxen_drol 889
652 : suxen_drol 983 EnableDlgWindow(hDlg, IDC_MAXBFRAMES_S, bvops);
653 :     EnableDlgWindow(hDlg, IDC_BQUANTRATIO_S, bvops);
654 :     EnableDlgWindow(hDlg, IDC_BQUANTOFFSET_S, bvops);
655 :     EnableDlgWindow(hDlg, IDC_BVOP_THRESHOLD_S, bvops);
656 : suxen_drol 889
657 : suxen_drol 983 EnableDlgWindow(hDlg, IDC_PACKED, bvops);
658 :     EnableDlgWindow(hDlg, IDC_CLOSEDGOV, bvops);
659 :     break;
660 : suxen_drol 889
661 : suxen_drol 983 case IDD_DEBUG :
662 :     cpu_force = IsDlgChecked(hDlg, IDC_CPU_FORCE);
663 :     EnableDlgWindow(hDlg, IDC_CPU_MMX, cpu_force);
664 :     EnableDlgWindow(hDlg, IDC_CPU_MMXEXT, cpu_force);
665 :     EnableDlgWindow(hDlg, IDC_CPU_SSE, cpu_force);
666 :     EnableDlgWindow(hDlg, IDC_CPU_SSE2, cpu_force);
667 :     EnableDlgWindow(hDlg, IDC_CPU_3DNOW, cpu_force);
668 :     EnableDlgWindow(hDlg, IDC_CPU_3DNOWEXT, cpu_force);
669 :     break;
670 :     }
671 : suxen_drol 889 }
672 :    
673 :    
674 :    
675 : suxen_drol 983 /* upload config data into dialog */
676 :     void adv_upload(HWND hDlg, int idd, CONFIG * config)
677 : suxen_drol 889 {
678 : suxen_drol 983 switch (idd)
679 : suxen_drol 889 {
680 : suxen_drol 983 case IDD_PROFILE :
681 :     SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_SETCURSEL, config->profile, 0);
682 :     SetDlgItemInt(hDlg, IDC_PROFILE_WIDTH, profiles[config->profile].width, FALSE);
683 :     SetDlgItemInt(hDlg, IDC_PROFILE_HEIGHT, profiles[config->profile].height, FALSE);
684 :     SetDlgItemInt(hDlg, IDC_PROFILE_FPS, profiles[config->profile].fps, FALSE);
685 :     SetDlgItemInt(hDlg, IDC_PROFILE_VMV, profiles[config->profile].max_vmv_buffer_sz, FALSE);
686 :     SetDlgItemInt(hDlg, IDC_PROFILE_VCV, profiles[config->profile].vcv_decoder_rate, FALSE);
687 :     SetDlgItemInt(hDlg, IDC_PROFILE_VBV, profiles[config->profile].max_vbv_size, FALSE);
688 :     SetDlgItemInt(hDlg, IDC_PROFILE_BITRATE, profiles[config->profile].max_bitrate, FALSE);
689 : suxen_drol 889 break;
690 :    
691 : suxen_drol 983 case IDD_RC_CBR :
692 :     SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);
693 :     SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);
694 :     SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);
695 : suxen_drol 889 break;
696 :    
697 : suxen_drol 983 case IDD_RC_2PASS1 :
698 :     SetDlgItemText(hDlg, IDC_STATS, config->stats);
699 :     CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);
700 :     break;
701 :    
702 :     case IDD_RC_2PASS2 :
703 :     SetDlgItemText(hDlg, IDC_STATS, config->stats);
704 :     SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);
705 : suxen_drol 889 SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE);
706 :     SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);
707 :     SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);
708 :     SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);
709 :     SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);
710 :     CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));
711 :     CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));
712 :     break;
713 :    
714 : suxen_drol 983 case IDD_RC_2PASS2_ALT :
715 : suxen_drol 889 CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED);
716 :    
717 :     SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0);
718 :     SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE);
719 :     SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE);
720 :     SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE);
721 :    
722 :     CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED);
723 :     SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE);
724 :    
725 :     CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED);
726 :     SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE);
727 :    
728 :     SetDlgItemInt(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate / CONFIG_KBPS, FALSE);
729 :     SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);
730 :     SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);
731 :     break;
732 :    
733 : suxen_drol 983
734 :     case IDD_MOTION :
735 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0);
736 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0);
737 :     CheckDlgButton(hDlg, IDC_CHROMAME, config->chromame ? BST_CHECKED : BST_UNCHECKED);
738 :     CheckDlgButton(hDlg, IDC_GREYSCALE, config->greyscale ? BST_CHECKED : BST_UNCHECKED);
739 :     break;
740 :    
741 :     case IDD_TOOLS :
742 :     if (profiles[config->profile].flags & PROFILE_MPEGQUANT) {
743 :     EnableDlgWindow(hDlg, IDC_QUANTTYPE, TRUE);
744 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);
745 :     }else{
746 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, 0 /* h263 */, 0);
747 :     EnableDlgWindow(hDlg, IDC_QUANTTYPE, FALSE);
748 :     }
749 : suxen_drol 889
750 : suxen_drol 983 if (profiles[config->profile].flags & PROFILE_INTERLACE) {
751 :     EnableDlgWindow(hDlg, IDC_INTERLACING, TRUE);
752 :     CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED);
753 :     }else{
754 :     CheckDlgButton(hDlg, IDC_INTERLACING, BST_UNCHECKED);
755 :     EnableDlgWindow(hDlg, IDC_INTERLACING, FALSE);
756 :     }
757 : suxen_drol 889
758 : suxen_drol 983 if (profiles[config->profile].flags & PROFILE_QPEL) {
759 :     EnableDlgWindow(hDlg, IDC_QPEL, TRUE);
760 :     CheckDlgButton(hDlg, IDC_QPEL, config->qpel ? BST_CHECKED : BST_UNCHECKED);
761 :     }else{
762 :     CheckDlgButton(hDlg, IDC_QPEL, BST_UNCHECKED);
763 :     EnableDlgWindow(hDlg, IDC_QPEL, FALSE);
764 :     }
765 :    
766 :     if (profiles[config->profile].flags & PROFILE_GMC) {
767 :     EnableDlgWindow(hDlg, IDC_GMC, TRUE);
768 :     CheckDlgButton(hDlg, IDC_GMC, config->gmc ? BST_CHECKED : BST_UNCHECKED);
769 :     }else{
770 :     CheckDlgButton(hDlg, IDC_GMC, BST_UNCHECKED);
771 :     EnableDlgWindow(hDlg, IDC_GMC, FALSE);
772 :     }
773 :    
774 :     if (profiles[config->profile].flags & PROFILE_REDUCED) {
775 :     EnableDlgWindow(hDlg, IDC_REDUCED, TRUE);
776 :     CheckDlgButton(hDlg, IDC_REDUCED, config->reduced_resolution ? BST_CHECKED : BST_UNCHECKED);
777 :     }else{
778 :     CheckDlgButton(hDlg, IDC_REDUCED, BST_UNCHECKED);
779 :     EnableDlgWindow(hDlg, IDC_REDUCED, FALSE);
780 :     }
781 :    
782 :     if (profiles[config->profile].flags & PROFILE_BVOP) {
783 :     EnableDlgWindow(hDlg, IDC_BVOP, TRUE);
784 :     CheckDlgButton(hDlg, IDC_BVOP, config->use_bvop ? BST_CHECKED : BST_UNCHECKED);
785 :     }else{
786 :     EnableDlgWindow(hDlg, IDC_BVOP, FALSE);
787 :     CheckDlgButton(hDlg, IDC_BVOP, BST_UNCHECKED);
788 :     }
789 :     SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, FALSE);
790 :     SetDlgItemInt(hDlg, IDC_BQUANTRATIO, config->bquant_ratio, FALSE);
791 :     SetDlgItemInt(hDlg, IDC_BQUANTOFFSET, config->bquant_offset, FALSE);
792 :     SetDlgItemInt(hDlg, IDC_BVOP_THRESHOLD, config->bvop_threshold, FALSE);
793 :     CheckDlgButton(hDlg, IDC_PACKED, config->packed ? BST_CHECKED : BST_UNCHECKED);
794 :     CheckDlgButton(hDlg, IDC_CLOSEDGOV, config->closed_gov ? BST_CHECKED : BST_UNCHECKED);
795 :    
796 :     CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);
797 :     SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
798 :     SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);
799 :    
800 : suxen_drol 889 break;
801 :    
802 : suxen_drol 983 case IDD_QUANT :
803 :     SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE);
804 :     SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE);
805 :     SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE);
806 :     SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE);
807 :     break;
808 :    
809 :     case IDD_DEBUG :
810 : suxen_drol 889 CheckDlgButton(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX) ? BST_CHECKED : BST_UNCHECKED);
811 :     CheckDlgButton(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT) ? BST_CHECKED : BST_UNCHECKED);
812 :     CheckDlgButton(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE) ? BST_CHECKED : BST_UNCHECKED);
813 :     CheckDlgButton(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2) ? BST_CHECKED : BST_UNCHECKED);
814 :     CheckDlgButton(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW) ? BST_CHECKED : BST_UNCHECKED);
815 :     CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT) ? BST_CHECKED : BST_UNCHECKED);
816 :    
817 :     CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,
818 :     config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );
819 :    
820 :     SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);
821 :     CheckDlgButton(hDlg, IDC_CHROMA_OPT, (config->chroma_opt) ? BST_CHECKED : BST_UNCHECKED);
822 :     SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);
823 : suxen_drol 983
824 :     CheckDlgButton(hDlg, IDC_DEBUG, config->debug ? BST_CHECKED : BST_UNCHECKED);
825 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
826 : suxen_drol 889 break;
827 : suxen_drol 983
828 :     case IDD_POSTPROC :
829 :     // CheckDlgButton(hDlg, IDC_DEBLOCK_Y, config->deblock_y ? BST_CHECKED : BST_UNCHECKED);
830 :     // CheckDlgButton(hDlg, IDC_DEBLOCK_UV, config->deblock_uv ? BST_CHECKED : BST_UNCHECKED);
831 :     break;
832 :    
833 : suxen_drol 889 }
834 :     }
835 :    
836 :    
837 : suxen_drol 983 /* download config data from dialog */
838 : suxen_drol 889
839 : suxen_drol 983 void adv_download(HWND hDlg, int idd, CONFIG * config)
840 : suxen_drol 889 {
841 : suxen_drol 983 switch (idd)
842 : suxen_drol 889 {
843 : suxen_drol 983 case IDD_PROFILE :
844 :     config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0);
845 :     break;
846 : suxen_drol 889
847 : suxen_drol 983 case IDD_RC_CBR :
848 :     config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);
849 :     config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);
850 :     config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);
851 : suxen_drol 889 break;
852 :    
853 : suxen_drol 983 case IDD_RC_2PASS1 :
854 :     if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0)
855 :     lstrcpy(config->stats, CONFIG_2PASS_FILE);
856 :     config->discard1pass = IsDlgChecked(hDlg, IDC_DISCARD1PASS);
857 :     break;
858 : suxen_drol 889
859 : suxen_drol 983 case IDD_RC_2PASS2 :
860 :     if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0)
861 :     lstrcpy(config->stats, CONFIG_2PASS_FILE);
862 : suxen_drol 889
863 : suxen_drol 983 config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);
864 : suxen_drol 889 config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE);
865 :     config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);
866 : suxen_drol 983
867 : suxen_drol 889 config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);
868 :     config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
869 :     config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);
870 : suxen_drol 983 config->bitrate_payback_method = IsDlgChecked(hDlg, IDC_PAYBACKPROP);
871 : suxen_drol 889
872 :    
873 :     CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000);
874 :     CONSTRAINVAL(config->keyframe_boost, 0, 1000);
875 :     CONSTRAINVAL(config->curve_compression_high, 0, 100);
876 :     CONSTRAINVAL(config->curve_compression_low, 0, 100);
877 :     break;
878 :    
879 : suxen_drol 983 case IDD_RC_2PASS2_ALT :
880 :     config->use_alt_curve = IsDlgChecked(hDlg, IDC_USEALT);
881 : suxen_drol 889
882 : suxen_drol 983 config->alt_curve_use_auto = IsDlgChecked(hDlg, IDC_USEAUTO);
883 : suxen_drol 889 config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str);
884 :    
885 : suxen_drol 983 config->alt_curve_use_auto_bonus_bias = IsDlgChecked(hDlg, IDC_USEAUTOBONUS);
886 : suxen_drol 889 config->alt_curve_bonus_bias = config_get_uint(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias);
887 :    
888 :     config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0);
889 :     config->alt_curve_high_dist = config_get_uint(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist);
890 :     config->alt_curve_low_dist = config_get_uint(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist);
891 :     config->alt_curve_min_rel_qual = config_get_uint(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual);
892 :    
893 :     config->twopass_max_bitrate /= CONFIG_KBPS;
894 :     config->twopass_max_bitrate = config_get_uint(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate);
895 :     config->twopass_max_bitrate *= CONFIG_KBPS;
896 :     config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);
897 :     config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);
898 :    
899 :     CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);
900 :     CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);
901 :     break;
902 :    
903 : suxen_drol 983 case IDD_MOTION :
904 :     config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);
905 :     config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0);
906 : suxen_drol 889
907 : suxen_drol 983 config->chromame = IsDlgChecked(hDlg, IDC_CHROMAME);
908 :     config->greyscale = IsDlgChecked(hDlg, IDC_GREYSCALE);
909 : suxen_drol 889
910 : suxen_drol 983 config->chroma_opt = IsDlgChecked(hDlg, IDC_CHROMA_OPT);
911 : suxen_drol 889 config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);
912 :     break;
913 :    
914 : suxen_drol 983 case IDD_TOOLS :
915 :     config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);
916 :     config->interlacing = IsDlgChecked(hDlg, IDC_INTERLACING);
917 :     config->qpel = IsDlgChecked(hDlg, IDC_QPEL);
918 :     config->gmc = IsDlgChecked(hDlg, IDC_GMC);
919 :     config->reduced_resolution = IsDlgChecked(hDlg, IDC_REDUCED);
920 : suxen_drol 889
921 : suxen_drol 983 config->use_bvop = IsDlgChecked(hDlg, IDC_BVOP);
922 :     config->max_bframes = config_get_int(hDlg, IDC_MAXBFRAMES, config->max_bframes);
923 :     config->bquant_ratio = config_get_uint(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
924 :     config->bquant_offset = config_get_uint(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
925 :     config->bvop_threshold = config_get_uint(hDlg, IDC_BVOP_THRESHOLD, config->bvop_threshold);
926 :     config->packed = IsDlgChecked(hDlg, IDC_PACKED);
927 :     config->closed_gov = IsDlgChecked(hDlg, IDC_CLOSEDGOV);
928 : suxen_drol 889
929 : suxen_drol 983 config->lum_masking = IsDlgChecked(hDlg, IDC_LUMMASK);
930 :     config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval);
931 :     config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval);
932 :     break;
933 : suxen_drol 889
934 : suxen_drol 983 case IDD_QUANT :
935 :     config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);
936 :     config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);
937 :     config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);
938 :     config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);
939 : suxen_drol 889
940 : suxen_drol 983 CONSTRAINVAL(config->min_iquant, 1, 31);
941 :     CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);
942 :     CONSTRAINVAL(config->min_pquant, 1, 31);
943 :     CONSTRAINVAL(config->max_pquant, config->min_pquant, 31);
944 :     break;
945 : suxen_drol 889
946 : suxen_drol 983 case IDD_DEBUG :
947 :     config->cpu = 0;
948 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMX) ? XVID_CPU_MMX : 0;
949 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT : 0;
950 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE) ? XVID_CPU_SSE : 0;
951 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE2) ? XVID_CPU_SSE2 : 0;
952 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOW) ? XVID_CPU_3DNOW : 0;
953 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT : 0;
954 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;
955 : suxen_drol 889
956 : suxen_drol 983 config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);
957 : suxen_drol 889
958 : suxen_drol 983 config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
959 :     config->debug = IsDlgChecked(hDlg, IDC_DEBUG);
960 :     break;
961 : suxen_drol 889
962 :    
963 : suxen_drol 983 case IDD_POSTPROC :
964 :     // config->deblock_y = IsDlgChecked(hDlg, IDC_DEBLOCK_Y);
965 :     // config->deblock_uv = IsDlgChecked(hDlg, IDC_DEBLOCK_UV);
966 : suxen_drol 889 break;
967 :     }
968 :     }
969 :    
970 :    
971 :    
972 : suxen_drol 983 /* advanced dialog proc */
973 : suxen_drol 889
974 : suxen_drol 983 BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
975 : suxen_drol 889 {
976 :     PROPSHEETINFO *psi;
977 :    
978 :     psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA);
979 :    
980 :     switch (uMsg)
981 :     {
982 :     case WM_INITDIALOG :
983 :     psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;
984 :     SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);
985 :    
986 : suxen_drol 983 if (g_hTooltip)
987 : suxen_drol 889 EnumChildWindows(hDlg, enum_tooltips, 0);
988 :    
989 : suxen_drol 983 adv_init(hDlg, psi->idd, psi->config);
990 :     adv_upload(hDlg, psi->idd, psi->config);
991 :     adv_mode(hDlg, psi->idd, psi->config);
992 : suxen_drol 889 break;
993 :    
994 : suxen_drol 983 case WM_COMMAND :
995 :     if (HIWORD(wParam) == BN_CLICKED)
996 :     {
997 :     switch (LOWORD(wParam))
998 :     {
999 :     case IDC_PROFILE_MPEGQUANT :
1000 :     case IDC_PROFILE_INTERLACE :
1001 :     case IDC_PROFILE_QPEL :
1002 :     case IDC_PROFILE_GMC :
1003 :     case IDC_PROFILE_REDUCED :
1004 :     case IDC_PROFILE_BVOP :
1005 :     case IDC_USEALT :
1006 :     case IDC_USEAUTO :
1007 :     case IDC_USEAUTOBONUS :
1008 :     case IDC_BVOP :
1009 :     case IDC_CPU_AUTO :
1010 :     case IDC_CPU_FORCE :
1011 :     adv_mode(hDlg, psi->idd, psi->config);
1012 :     break;
1013 :    
1014 :     case IDC_QUANTMATRIX :
1015 :     DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config);
1016 :     break;
1017 :    
1018 :     case IDC_STATS_BROWSE :
1019 :     {
1020 :     OPENFILENAME ofn;
1021 :     char tmp[MAX_PATH];
1022 :    
1023 :     GetDlgItemText(hDlg, IDC_STATS, tmp, MAX_PATH);
1024 :    
1025 :     memset(&ofn, 0, sizeof(OPENFILENAME));
1026 :     ofn.lStructSize = sizeof(OPENFILENAME);
1027 :    
1028 :     ofn.hwndOwner = hDlg;
1029 :     ofn.lpstrFilter = "bitrate curve (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0";
1030 :     ofn.lpstrFile = tmp;
1031 :     ofn.nMaxFile = MAX_PATH;
1032 :     ofn.Flags = OFN_PATHMUSTEXIST;
1033 :    
1034 :     if (psi->idd == IDD_RC_2PASS1) {
1035 :     ofn.Flags |= OFN_OVERWRITEPROMPT;
1036 :     }else{
1037 :     ofn.Flags |= OFN_FILEMUSTEXIST;
1038 :     }
1039 :    
1040 :     if (GetSaveFileName(&ofn))
1041 :     {
1042 :     SetDlgItemText(hDlg, IDC_STATS, tmp);
1043 :     }
1044 :     }
1045 :     }
1046 :     }else if (LOWORD(wParam) == IDC_PROFILE_PROFILE && HIWORD(wParam) == LBN_SELCHANGE)
1047 :     {
1048 :     adv_download(hDlg, psi->idd, psi->config);
1049 :     adv_upload(hDlg, psi->idd, psi->config);
1050 :     adv_mode(hDlg, psi->idd, psi->config);
1051 :     }
1052 :     break;
1053 :    
1054 : suxen_drol 889 case WM_NOTIFY :
1055 :     switch (((NMHDR *)lParam)->code)
1056 :     {
1057 :     case PSN_KILLACTIVE :
1058 :     /* validate */
1059 : suxen_drol 983 adv_download(hDlg, psi->idd, psi->config);
1060 : suxen_drol 889 SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1061 :     break;
1062 :    
1063 :     case PSN_APPLY :
1064 :     /* apply */
1065 : suxen_drol 983 adv_download(hDlg, psi->idd, psi->config);
1066 : suxen_drol 889 SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1067 :     psi->config->save = TRUE;
1068 :     break;
1069 :     }
1070 :     break;
1071 :    
1072 :     default :
1073 :     return 0;
1074 :     }
1075 :    
1076 :     return 1;
1077 :     }
1078 :    
1079 :    
1080 : suxen_drol 983
1081 :    
1082 :     /* load advanced options property sheet */
1083 :     void adv_dialog(HWND hParent, CONFIG * config, const int * dlgs, int size)
1084 : suxen_drol 889 {
1085 : suxen_drol 983 PROPSHEETINFO psi[6];
1086 :     PROPSHEETPAGE psp[6];
1087 : suxen_drol 889 PROPSHEETHEADER psh;
1088 :     CONFIG temp;
1089 :     int i;
1090 :    
1091 :     config->save = FALSE;
1092 :     memcpy(&temp, config, sizeof(CONFIG));
1093 :    
1094 : suxen_drol 983 for (i=0; i<size; i++)
1095 : suxen_drol 889 {
1096 :     psp[i].dwSize = sizeof(PROPSHEETPAGE);
1097 :     psp[i].dwFlags = 0;
1098 : suxen_drol 983 psp[i].hInstance = g_hInst;
1099 :     psp[i].pfnDlgProc = adv_proc;
1100 : suxen_drol 889 psp[i].lParam = (LPARAM)&psi[i];
1101 :     psp[i].pfnCallback = NULL;
1102 : suxen_drol 983 psp[i].pszTemplate = MAKEINTRESOURCE(dlgs[i]);
1103 : suxen_drol 889
1104 : suxen_drol 983 psi[i].idd = dlgs[i];
1105 : suxen_drol 889 psi[i].config = &temp;
1106 :     }
1107 :    
1108 :     psh.dwSize = sizeof(PROPSHEETHEADER);
1109 :     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
1110 :     psh.hwndParent = hParent;
1111 : suxen_drol 983 psh.hInstance = g_hInst;
1112 : suxen_drol 889 psh.pszCaption = (LPSTR) "XviD Configuration";
1113 : suxen_drol 983 psh.nPages = size;
1114 :     psh.nStartPage = 0;
1115 : suxen_drol 889 psh.ppsp = (LPCPROPSHEETPAGE)&psp;
1116 :     psh.pfnCallback = NULL;
1117 :     PropertySheet(&psh);
1118 :    
1119 :     if (temp.save)
1120 :     {
1121 :     memcpy(config, &temp, sizeof(CONFIG));
1122 :     }
1123 :     }
1124 :    
1125 : suxen_drol 983 /* ===================================================================================== */
1126 :     /* MAIN DIALOG ========================================================================= */
1127 :     /* ===================================================================================== */
1128 : suxen_drol 889
1129 :    
1130 : suxen_drol 983 /* downloads data from main dialog */
1131 :    
1132 :     void main_download(HWND hDlg, CONFIG * config)
1133 :     {
1134 :    
1135 :     config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0);
1136 :    
1137 :     switch(config->mode)
1138 :     {
1139 :     default :
1140 :     case RC_MODE_CBR :
1141 :     config->rc_bitrate = config_get_uint(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS;
1142 :     break;
1143 :    
1144 :     /* case RC_MODE_VBR_QUAL :
1145 :     config->quality = config_get_uint(hDlg, IDC_VALUE, config->quality);
1146 :     break; */
1147 :    
1148 :     case RC_MODE_FIXED :
1149 :     config->quant = config_get_uint(hDlg, IDC_VALUE, config->quant);
1150 :     break;
1151 :    
1152 :     case RC_MODE_2PASS2_INT :
1153 :     config->desired_size = config_get_uint(hDlg, IDC_VALUE, config->desired_size);
1154 :     break;
1155 :     }
1156 :    
1157 :     config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
1158 :     }
1159 :    
1160 :    
1161 :     /* updates the edit box */
1162 :    
1163 :     void main_value(HWND hDlg, CONFIG* config)
1164 :     {
1165 :     char* text;
1166 :     int value;
1167 :     int enabled = TRUE;
1168 :    
1169 :     switch (config->mode)
1170 :     {
1171 :     default :
1172 :     enabled = FALSE;
1173 :    
1174 :     case RC_MODE_CBR :
1175 :     text = "Bitrate (Kbps):";
1176 :     value = config->rc_bitrate / CONFIG_KBPS;
1177 :     break;
1178 :    
1179 :     /* case DLG_MODE_VBR_QUAL :
1180 :     text = "Quality:";
1181 :     value = config->quality;
1182 :     break; */
1183 :    
1184 :     case RC_MODE_FIXED :
1185 :     text = "Quantizer:";
1186 :     value = config->quant;
1187 :     break;
1188 :    
1189 :     case RC_MODE_2PASS2_INT :
1190 :     text = "Desired size (Kbtyes):";
1191 :     value = config->desired_size;
1192 :     break;
1193 :     }
1194 :    
1195 :     SetDlgItemText(hDlg, IDC_VALUE_STATIC, text);
1196 :     SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE);
1197 :    
1198 :     EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);
1199 :     EnableWindow(GetDlgItem(hDlg, IDC_VALUE), enabled);
1200 :    
1201 :     if (config->mode == RC_MODE_CBR || config->mode == RC_MODE_2PASS1 ||
1202 :     config->mode == RC_MODE_2PASS2_INT || config->mode == RC_MODE_2PASS2_EXT) {
1203 :     EnableWindow(GetDlgItem(hDlg, IDC_MODE_ADV), TRUE);
1204 :     }else{
1205 :     EnableWindow(GetDlgItem(hDlg, IDC_MODE_ADV), FALSE);
1206 :     }
1207 :     }
1208 :    
1209 :    
1210 :     /* updates the slider */
1211 :    
1212 :     void main_slider(HWND hDlg, CONFIG * config)
1213 :     {
1214 :     char* text;
1215 :     long range;
1216 :     int pos;
1217 :     int enabled = TRUE;
1218 :    
1219 :     switch (config->mode)
1220 :     {
1221 :     default :
1222 :     enabled = FALSE;
1223 :    
1224 :     case RC_MODE_CBR :
1225 :     text = "Bitrate (Kbps):";
1226 :     range = MAKELONG(0,10000);
1227 :     pos = config->rc_bitrate / CONFIG_KBPS;
1228 :     break;
1229 :    
1230 :     /* case RC_MODE_VBR_QUAL :
1231 :     text = "Quality:";
1232 :     range = MAKELONG(0,100);
1233 :     pos = config->quality;
1234 :     break; */
1235 :    
1236 :     case RC_MODE_FIXED :
1237 :     text = "Quantizer:";
1238 :     range = MAKELONG(1,31);
1239 :     pos = config->quant;
1240 :     break;
1241 :     }
1242 :    
1243 :     SetDlgItemText(hDlg, IDC_SLIDER_STATIC, text);
1244 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, range);
1245 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, pos);
1246 :    
1247 :     EnableWindow(GetDlgItem(hDlg, IDC_SLIDER_STATIC), enabled);
1248 :     EnableWindow(GetDlgItem(hDlg, IDC_SLIDER), enabled);
1249 :     }
1250 :    
1251 :    
1252 : suxen_drol 889 /* main dialog proc */
1253 :    
1254 :     BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1255 :     {
1256 :     CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
1257 : suxen_drol 983 unsigned int i;
1258 : suxen_drol 889
1259 :     switch (uMsg)
1260 :     {
1261 :     case WM_INITDIALOG :
1262 :     SetWindowLong(hDlg, GWL_USERDATA, lParam);
1263 :    
1264 :     config = (CONFIG*)lParam;
1265 :    
1266 : suxen_drol 983 for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
1267 :     SendDlgItemMessage(hDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
1268 :     SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0);
1269 :    
1270 : suxen_drol 889 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - CBR");
1271 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quality");
1272 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quantizer");
1273 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 1st pass");
1274 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Ext.");
1275 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Int.");
1276 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");
1277 :    
1278 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1279 :    
1280 :     InitCommonControls();
1281 :    
1282 : suxen_drol 983 if ((g_hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
1283 : suxen_drol 889 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1284 : suxen_drol 983 NULL, NULL, g_hInst, NULL)))
1285 : suxen_drol 889 {
1286 : suxen_drol 983 SetWindowPos(g_hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
1287 :     SendMessage(g_hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
1288 :     SendMessage(g_hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
1289 : suxen_drol 889
1290 :     EnumChildWindows(hDlg, enum_tooltips, 0);
1291 :     }
1292 :    
1293 :     main_slider(hDlg, config);
1294 :     main_value(hDlg, config);
1295 :     break;
1296 :    
1297 :     case WM_HSCROLL :
1298 :     if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER))
1299 :     {
1300 :     SetDlgItemInt(hDlg, IDC_VALUE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE);
1301 :     }
1302 :     else
1303 :     {
1304 :     return 0;
1305 :     }
1306 :     break;
1307 :    
1308 :     case WM_COMMAND :
1309 : suxen_drol 983 if (HIWORD(wParam) == LBN_SELCHANGE && (LOWORD(wParam) == IDC_PROFILE || LOWORD(wParam) == IDC_MODE))
1310 : suxen_drol 889 {
1311 :     main_download(hDlg, config);
1312 :     main_slider(hDlg, config);
1313 :     main_value(hDlg, config);
1314 :     }
1315 : suxen_drol 983 else if (LOWORD(wParam) == IDC_PROFILE_ADV && HIWORD(wParam) == BN_CLICKED) /* profile dlg */
1316 :     {
1317 :     static const int dlgs[] = { IDD_PROFILE };
1318 :    
1319 :     adv_dialog(hDlg, config, dlgs, sizeof(dlgs)/sizeof(int));
1320 :     if (config->save)
1321 :     {
1322 :     config_reg_set(config);
1323 :     }
1324 :     SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0);
1325 :     }
1326 :     else if (LOWORD(wParam) == IDC_MODE_ADV && HIWORD(wParam) == BN_CLICKED) /* rate control dialog */
1327 :     {
1328 :     if (config->mode == RC_MODE_CBR) {
1329 :     static const int dlgs[] = { IDD_RC_CBR };
1330 :     adv_dialog(hDlg, config, dlgs, sizeof(dlgs)/sizeof(int));
1331 :     }else if (config->mode == RC_MODE_2PASS1) {
1332 :     static const int dlgs[] = { IDD_RC_2PASS1 };
1333 :     adv_dialog(hDlg, config, dlgs, sizeof(dlgs)/sizeof(int));
1334 :     }else if (config->mode == RC_MODE_2PASS2_INT || config->mode == RC_MODE_2PASS2_EXT) {
1335 :     static const int dlgs[] = { IDD_RC_2PASS2, IDD_RC_2PASS2_ALT};
1336 :     adv_dialog(hDlg, config, dlgs, sizeof(dlgs)/sizeof(int));
1337 :     }
1338 :     if (config->save)
1339 :     {
1340 :     config_reg_set(config);
1341 :     }
1342 :     }
1343 : suxen_drol 889 else if (LOWORD(wParam) == IDC_ADVANCED && HIWORD(wParam) == BN_CLICKED)
1344 :     {
1345 : suxen_drol 983 static const int dlgs[] = { IDD_MOTION, IDD_TOOLS, IDD_QUANT, IDD_DEBUG};
1346 :     adv_dialog(hDlg, config, dlgs, sizeof(dlgs)/sizeof(int));
1347 : suxen_drol 889
1348 :     if (config->save)
1349 :     {
1350 :     config_reg_set(config);
1351 :     }
1352 :     }
1353 :     else if (LOWORD(wParam) == IDC_DECODER && HIWORD(wParam) == BN_CLICKED)
1354 :     {
1355 : suxen_drol 983 static const int dlgs[] = { IDD_POSTPROC };
1356 :     adv_dialog(hDlg, config, dlgs, sizeof(dlgs)/sizeof(int));
1357 : suxen_drol 889
1358 :     if (config->save)
1359 :     {
1360 :     config_reg_set(config);
1361 :     }
1362 :     }
1363 :     else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED)
1364 :     {
1365 :     config_reg_default(config);
1366 :    
1367 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1368 :    
1369 :     main_slider(hDlg, config);
1370 :     main_value(hDlg, config);
1371 :     }
1372 :     else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)
1373 :     {
1374 :     int value = config_get_uint(hDlg, IDC_VALUE, 1);
1375 :     int max = 1;
1376 :    
1377 : suxen_drol 983 max = (config->mode == RC_MODE_CBR) ? 10000 :
1378 :     /*((config->mode == DLG_MODE_VBR_QUAL) ? 100 :*/
1379 :     ((config->mode == RC_MODE_FIXED) ? 31 : 1<<30) /*)*/;
1380 : suxen_drol 889
1381 :     if (value < 1)
1382 :     {
1383 :     value = 1;
1384 :     }
1385 :     if (value > max)
1386 :     {
1387 :     value = max;
1388 :     SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE);
1389 :     }
1390 :    
1391 : suxen_drol 983 if (config->mode != RC_MODE_2PASS2_INT)
1392 : suxen_drol 889 {
1393 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, value);
1394 :     }
1395 :     }
1396 :     else if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
1397 :     {
1398 :     main_download(hDlg, config);
1399 :     config->save = TRUE;
1400 :     EndDialog(hDlg, IDOK);
1401 :     }
1402 :     else if (LOWORD(wParam) == IDCANCEL)
1403 :     {
1404 :     config->save = FALSE;
1405 :     EndDialog(hDlg, IDCANCEL);
1406 :     }
1407 :     break;
1408 :    
1409 :     default :
1410 :     return 0;
1411 :     }
1412 :    
1413 :     return 1;
1414 :     }
1415 :    
1416 :    
1417 :    
1418 : suxen_drol 983 /* ===================================================================================== */
1419 :     /* ABOUT DIALOG ======================================================================== */
1420 :     /* ===================================================================================== */
1421 : suxen_drol 889
1422 :     BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1423 :     {
1424 :     switch (uMsg)
1425 :     {
1426 :     case WM_INITDIALOG :
1427 :     {
1428 :     xvid_gbl_info_t info;
1429 :     char core[100];
1430 :     HFONT hFont;
1431 :     LOGFONT lfData;
1432 :    
1433 :     SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD);
1434 :     SetDlgItemText(hDlg, IDC_SPECIAL_BUILD, XVID_SPECIAL_BUILD);
1435 :    
1436 :     memset(&info, 0, sizeof(info));
1437 :     info.version = XVID_VERSION;
1438 :     xvid_global(0, XVID_GBL_INFO, &info, NULL);
1439 :     wsprintf(core, "libxvidcore version %d.%d.%d (\"%s\")",
1440 :     XVID_MAJOR(info.actual_version),
1441 :     XVID_MINOR(info.actual_version),
1442 :     XVID_PATCH(info.actual_version),
1443 :     info.build);
1444 :    
1445 :     SetDlgItemText(hDlg, IDC_CORE, core);
1446 :    
1447 :     hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L);
1448 :    
1449 :     if (GetObject(hFont, sizeof(LOGFONT), &lfData))
1450 :     {
1451 :     lfData.lfUnderline = 1;
1452 :    
1453 :     hFont = CreateFontIndirect(&lfData);
1454 :     if (hFont)
1455 :     {
1456 :     SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L);
1457 :     }
1458 :     }
1459 :    
1460 :     SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));
1461 :     SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE);
1462 :     }
1463 :     break;
1464 :    
1465 :     case WM_CTLCOLORSTATIC :
1466 :     if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE))
1467 :     {
1468 :     SetBkMode((HDC)wParam, TRANSPARENT) ;
1469 :     SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0));
1470 :     return (BOOL)GetStockObject(NULL_BRUSH);
1471 :     }
1472 :     return 0;
1473 :    
1474 :     case WM_COMMAND :
1475 :     if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED)
1476 :     {
1477 :     ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL);
1478 :     }
1479 :     else if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
1480 :     {
1481 :     EndDialog(hDlg, LOWORD(wParam));
1482 :     }
1483 :     break;
1484 :    
1485 :     default :
1486 :     return 0;
1487 :     }
1488 :    
1489 :     return 1;
1490 :     }

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