[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 1193 - (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 : edgomez 1053 #include <stdio.h> /* sprintf */
64 :     #include <xvid.h> /* XviD API */
65 : suxen_drol 889
66 : suxen_drol 983 #include "debug.h"
67 : suxen_drol 889 #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 : suxen_drol 1017 #define CheckDlg(hwnd,idc,value) CheckDlgButton(hwnd,idc, value?BST_CHECKED:BST_UNCHECKED)
74 : suxen_drol 983 #define EnableDlgWindow(hwnd,idc,state) EnableWindow(GetDlgItem(hwnd,idc),state)
75 : suxen_drol 889
76 : suxen_drol 983 HINSTANCE g_hInst;
77 :     HWND g_hTooltip;
78 : suxen_drol 889
79 : suxen_drol 983 /* enumerates child windows, assigns tooltips */
80 :     BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
81 :     {
82 :     char help[500];
83 :    
84 :     if (LoadString(g_hInst, GetDlgCtrlID(hWnd), help, 500))
85 :     {
86 :     TOOLINFO ti;
87 :     ti.cbSize = sizeof(TOOLINFO);
88 :     ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
89 :     ti.hwnd = GetParent(hWnd);
90 :     ti.uId = (LPARAM)hWnd;
91 :     ti.lpszText = help;
92 :     SendMessage(g_hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
93 :     }
94 :    
95 :     return TRUE;
96 :     }
97 :    
98 :    
99 :     /* ===================================================================================== */
100 :     /* MPEG-4 PROFILES/LEVELS ============================================================== */
101 :     /* ===================================================================================== */
102 :    
103 :    
104 :    
105 :     /* default vbv_occupancy is (64/170)*vbv_buffer_size */
106 :    
107 : suxen_drol 1017 const profile_t profiles[] =
108 : suxen_drol 983 {
109 : suxen_drol 1017 /* name p@l, w h fps obj Tvmv vmv vcv ac% vbv pkt kbps flags */
110 :     { "Simple @ L0", 0x08, 176, 144, 15, 1, 198, 99, 1485, 100, 10*16368, 2048, 64, 0 },
111 : edgomez 1184 /* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */
112 :     /* if ac preidition is used, adaptive quantization must not be used */
113 :     /* <=qcif must be used */
114 : suxen_drol 1017 { "Simple @ L1", 0x01, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 2048, 64, PROFILE_ADAPTQUANT },
115 :     { "Simple @ L2", 0x02, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128, PROFILE_ADAPTQUANT },
116 :     { "Simple @ L3", 0x03, 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384, PROFILE_ADAPTQUANT },
117 : suxen_drol 983
118 : suxen_drol 1017 { "ARTS @ L1", 0x91, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 8192, 64, PROFILE_ARTS },
119 :     { "ARTS @ L2", 0x92, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 16384, 128, PROFILE_ARTS },
120 :     { "ARTS @ L3", 0x93, 352, 288, 30, 4, 792, 396, 11880, 100, 40*16368, 16384, 384, PROFILE_ARTS },
121 :     { "ARTS @ L4", 0x94, 352, 288, 30, 16, 792, 396, 11880, 100, 80*16368, 16384, 2000, PROFILE_ARTS },
122 : suxen_drol 983
123 : suxen_drol 1017 { "AS @ L0", 0xf0, 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS },
124 :     { "AS @ L1", 0xf1, 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS },
125 :     { "AS @ L2", 0xf2, 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384, PROFILE_AS },
126 :     { "AS @ L3", 0xf3, 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768, PROFILE_AS },
127 : suxen_drol 1069 /* ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */
128 : suxen_drol 1017 { "AS @ L4", 0xf4, 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000, PROFILE_AS },
129 :     { "AS @ L5", 0xf5, 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000, PROFILE_AS },
130 : suxen_drol 983
131 : suxen_drol 1017 { "DXN Handheld", 0x00, 176, 144, 15, -1, 198, 99, 1485, 100, 16*16368, -1, 128, PROFILE_ADAPTQUANT },
132 :     { "DXN Portable NTSC", 0x00, 352, 240, 30, -1, 990, 330, 9900, 100, 64*16368, -1, 768, PROFILE_ADAPTQUANT|PROFILE_BVOP },
133 :     { "DXN Portable PAL", 0x00, 352, 288, 25, -1, 1188, 396, 9900, 100, 64*16368, -1, 768, PROFILE_ADAPTQUANT|PROFILE_BVOP },
134 :     { "DXN HT NTSC", 0x00, 720, 480, 30, -1, 4050, 1350, 40500, 100, 192*16368, -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },
135 :     { "DXN HT PAL", 0x00, 720, 576, 25, -1, 4860, 1620, 40500, 100, 192*16368, -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },
136 :     { "DXN HDTV", 0x00, 1280, 720, 30, -1,10800, 3600, 108000, 100, 384*16368, -1, 8000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },
137 :    
138 :     { "(unrestricted)", 0x00, 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, 0, 0, 0xffffffff },
139 : suxen_drol 983 };
140 :    
141 :    
142 :     /* ===================================================================================== */
143 :     /* REGISTRY ============================================================================ */
144 :     /* ===================================================================================== */
145 :    
146 :     /* registry info structs */
147 : suxen_drol 889 CONFIG reg;
148 :    
149 : suxen_drol 983 static const REG_INT reg_ints[] = {
150 : suxen_drol 1017 {"mode", &reg.mode, RC_MODE_1PASS},
151 :     {"bitrate", &reg.bitrate, 700},
152 : suxen_drol 1061 {"desired_size", &reg.desired_size, 570000},
153 :     {"use_2pass_bitrate", &reg.use_2pass_bitrate, 0},
154 : suxen_drol 1017
155 : suxen_drol 1061 /* profile */
156 :     {"quant_type", &reg.quant_type, 0},
157 : suxen_drol 889 {"lum_masking", &reg.lum_masking, 0},
158 :     {"interlacing", &reg.interlacing, 0},
159 :     {"qpel", &reg.qpel, 0},
160 :     {"gmc", &reg.gmc, 0},
161 : suxen_drol 1061 {"reduced_resolution", &reg.reduced_resolution, 0},
162 : suxen_drol 983 {"use_bvop", &reg.use_bvop, 0},
163 :     {"max_bframes", &reg.max_bframes, 2},
164 : suxen_drol 1017 {"bquant_ratio", &reg.bquant_ratio, 150}, /* 100-base float */
165 :     {"bquant_offset", &reg.bquant_offset, 100}, /* 100-base float */
166 : suxen_drol 889 {"packed", &reg.packed, 0},
167 : suxen_drol 983 {"closed_gov", &reg.closed_gov, 1},
168 : suxen_drol 889
169 : suxen_drol 1061 /* zones */
170 :     {"num_zones", &reg.num_zones, 1},
171 : suxen_drol 889
172 : suxen_drol 1061 /* single pass */
173 :     {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor, 16},
174 :     {"rc_averaging_period", &reg.rc_averaging_period, 100},
175 :     {"rc_buffer", &reg.rc_buffer, 100},
176 :    
177 :     /* 2pass1 */
178 :     {"discard1pass", &reg.discard1pass, 1},
179 :    
180 :     /* 2pass2 */
181 : suxen_drol 889 {"keyframe_boost", &reg.keyframe_boost, 0},
182 :     {"kftreshold", &reg.kftreshold, 10},
183 :     {"kfreduction", &reg.kfreduction, 20},
184 :     {"curve_compression_high", &reg.curve_compression_high, 0},
185 :     {"curve_compression_low", &reg.curve_compression_low, 0},
186 : suxen_drol 1052 {"bitrate_payback_delay", &reg.bitrate_payback_delay, 250},
187 :     {"bitrate_payback_method", &reg.bitrate_payback_method, XVID_PAYBACK_BIAS },
188 : suxen_drol 889 {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 60},
189 :     {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 60},
190 : suxen_drol 1052
191 : suxen_drol 1061 /* motion */
192 :     {"motion_search", &reg.motion_search, 6},
193 :     {"vhq_mode", &reg.vhq_mode, 0},
194 :     {"chromame", &reg.chromame, 0},
195 : edgomez 1193 {"cartoon_mode", &reg.cartoon_mode, 0},
196 : suxen_drol 1061 {"max_key_interval", &reg.max_key_interval, 300},
197 :     {"min_key_interval", &reg.min_key_interval, 1},
198 :     {"frame_drop_ratio", &reg.frame_drop_ratio, 0},
199 :    
200 :     /* quant */
201 :     {"min_iquant", &reg.min_iquant, 2},
202 :     {"max_iquant", &reg.max_iquant, 31},
203 :     {"min_pquant", &reg.min_pquant, 2},
204 :     {"max_pquant", &reg.max_pquant, 31},
205 :     {"min_bquant", &reg.min_bquant, 2},
206 :     {"max_bquant", &reg.max_bquant, 31},
207 :     {"trellis_quant", &reg.trellis_quant, 0},
208 :    
209 :     /* debug */
210 :     {"fourcc_used", &reg.fourcc_used, 0},
211 :     {"debug", &reg.debug, 0x0},
212 :     {"vop_debug", &reg.vop_debug, 0},
213 :     {"display_status", &reg.display_status, 1},
214 : suxen_drol 889 };
215 :    
216 : suxen_drol 983 static const REG_STR reg_strs[] = {
217 :     {"profile", reg.profile_name, "(unrestricted)"},
218 :     {"stats", reg.stats, CONFIG_2PASS_FILE},
219 : suxen_drol 889 };
220 :    
221 :    
222 : suxen_drol 1017 zone_t stmp;
223 :     static const REG_INT reg_zone[] = {
224 :     {"zone%i_frame", &stmp.frame, 0},
225 :     {"zone%i_mode", &stmp.mode, RC_ZONE_WEIGHT},
226 :     {"zone%i_weight", &stmp.weight, 100}, /* 100-base float */
227 :     {"zone%i_quant", &stmp.quant, 500}, /* 100-base float */
228 : suxen_drol 1069 {"zone%i_type", &stmp.type, XVID_TYPE_AUTO},
229 : suxen_drol 1017 {"zone%i_greyscale", &stmp.greyscale, 0},
230 :     {"zone%i_chroma_opt", &stmp.chroma_opt, 0},
231 :     {"zone%i_bvop_threshold", &stmp.bvop_threshold, 0},
232 :     };
233 :    
234 :     static const BYTE default_qmatrix_intra[] = {
235 :     8, 17,18,19,21,23,25,27,
236 :     17,18,19,21,23,25,27,28,
237 :     20,21,22,23,24,26,28,30,
238 :     21,22,23,24,26,28,30,32,
239 :     22,23,24,26,28,30,32,35,
240 :     23,24,26,28,30,32,35,38,
241 :     25,26,28,30,32,35,38,41,
242 :     27,28,30,32,35,38,41,45
243 :     };
244 :    
245 :     static const BYTE default_qmatrix_inter[] = {
246 :     16,17,18,19,20,21,22,23,
247 :     17,18,19,20,21,22,23,24,
248 :     18,19,20,21,22,23,24,25,
249 :     19,20,21,22,23,24,26,27,
250 :     20,21,22,23,25,26,27,28,
251 :     21,22,23,24,26,27,28,30,
252 :     22,23,24,26,27,28,30,31,
253 :     23,24,25,27,28,30,31,33
254 :     };
255 :    
256 :    
257 :    
258 : suxen_drol 889 #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)));}
259 :    
260 :     void config_reg_get(CONFIG * config)
261 :     {
262 : suxen_drol 1017 char tmp[32];
263 :     HKEY hKey;
264 : suxen_drol 889 DWORD size;
265 : suxen_drol 1017 int i,j;
266 : suxen_drol 889 xvid_gbl_info_t info;
267 :    
268 :     memset(&info, 0, sizeof(info));
269 :     info.version = XVID_VERSION;
270 :     xvid_global(0, XVID_GBL_INFO, &info, NULL);
271 :     reg.cpu = info.cpu_flags;
272 :     reg.num_threads = info.num_threads;
273 :    
274 :     RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey);
275 :    
276 : suxen_drol 1017 /* read integer values */
277 :     for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) {
278 : suxen_drol 889 size = sizeof(int);
279 : suxen_drol 1017 if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS) {
280 : suxen_drol 889 *reg_ints[i].config_int = reg_ints[i].def;
281 : suxen_drol 1017 }
282 : suxen_drol 889 }
283 :    
284 : suxen_drol 1017 /* read string values */
285 :     for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) {
286 : suxen_drol 889 size = MAX_PATH;
287 : suxen_drol 1017 if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS) {
288 : suxen_drol 889 memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
289 :     }
290 :     }
291 :    
292 : suxen_drol 983 reg.profile = 0;
293 :     for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) {
294 :     if (strcmpi(profiles[i].name, reg.profile_name) == 0) {
295 :     reg.profile = i;
296 :     }
297 :     }
298 :    
299 : suxen_drol 1017 memcpy(config, &reg, sizeof(CONFIG));
300 : suxen_drol 889
301 : suxen_drol 1017
302 :     /* read quant matrices */
303 :     REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra);
304 :     REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter);
305 :    
306 :    
307 :     /* read zones */
308 :     if (config->num_zones>MAX_ZONES) {
309 :     config->num_zones=MAX_ZONES;
310 :     }else if (config->num_zones<=0) {
311 :     config->num_zones = 1;
312 :     }
313 :    
314 :     for (i=0; i<config->num_zones; i++) {
315 :     for (j=0; j<sizeof(reg_zone)/sizeof(REG_INT); j++) {
316 :     size = sizeof(int);
317 :    
318 :     wsprintf(tmp, reg_zone[j].reg_value, i);
319 :     if (RegQueryValueEx(hKey, tmp, 0, 0, (LPBYTE)reg_zone[j].config_int, &size) != ERROR_SUCCESS)
320 :     *reg_zone[j].config_int = reg_zone[j].def;
321 :     }
322 :    
323 :     memcpy(&config->zones[i], &stmp, sizeof(zone_t));
324 :     }
325 :    
326 : suxen_drol 889 RegCloseKey(hKey);
327 :     }
328 :    
329 :    
330 :     /* put config settings in registry */
331 :    
332 :     #define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y)))
333 :    
334 :     void config_reg_set(CONFIG * config)
335 :     {
336 : suxen_drol 1017 char tmp[64];
337 :     HKEY hKey;
338 : suxen_drol 889 DWORD dispo;
339 : suxen_drol 1017 int i,j;
340 : suxen_drol 889
341 :     if (RegCreateKeyEx(
342 :     XVID_REG_KEY,
343 :     XVID_REG_PARENT "\\" XVID_REG_CHILD,
344 :     0,
345 :     XVID_REG_CLASS,
346 :     REG_OPTION_NON_VOLATILE,
347 :     KEY_WRITE,
348 :     0,
349 :     &hKey,
350 :     &dispo) != ERROR_SUCCESS)
351 :     {
352 : suxen_drol 983 DPRINTF("Couldn't create XVID_REG_SUBKEY - GetLastError=%i", GetLastError());
353 : suxen_drol 889 return;
354 :     }
355 :    
356 :     memcpy(&reg, config, sizeof(CONFIG));
357 :    
358 : suxen_drol 1017 /* set integer values */
359 :     for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) {
360 : suxen_drol 889 RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int));
361 :     }
362 :    
363 : suxen_drol 1017 /* set string values */
364 :     strcpy(reg.profile_name, profiles[reg.profile].name);
365 :     for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) {
366 : suxen_drol 889 RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1);
367 :     }
368 :    
369 : suxen_drol 1017 /* set quant matrices */
370 :     REG_SET_B("qmatrix_intra", config->qmatrix_intra);
371 :     REG_SET_B("qmatrix_inter", config->qmatrix_inter);
372 : suxen_drol 889
373 : suxen_drol 1017 /* set seections */
374 :     for (i=0; i<config->num_zones; i++) {
375 :     memcpy(&stmp, &config->zones[i], sizeof(zone_t));
376 :     for (j=0; j<sizeof(reg_zone)/sizeof(REG_INT); j++) {
377 :     wsprintf(tmp, reg_zone[j].reg_value, i);
378 :     RegSetValueEx(hKey, tmp, 0, REG_DWORD, (LPBYTE)reg_zone[j].config_int, sizeof(int));
379 :     }
380 :     }
381 :    
382 : suxen_drol 889 RegCloseKey(hKey);
383 :     }
384 :    
385 :    
386 :     /* clear XviD registry key, load defaults */
387 :    
388 :     void config_reg_default(CONFIG * config)
389 :     {
390 :     HKEY hKey;
391 :    
392 : suxen_drol 1017 if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey)) {
393 : suxen_drol 983 DPRINTF("Couldn't open registry key for deletion - GetLastError=%i", GetLastError());
394 : suxen_drol 889 return;
395 :     }
396 :    
397 : suxen_drol 1017 if (RegDeleteKey(hKey, XVID_REG_CHILD)) {
398 : suxen_drol 983 DPRINTF("Couldn't delete registry key - GetLastError=%i", GetLastError());
399 : suxen_drol 889 return;
400 :     }
401 :    
402 :     RegCloseKey(hKey);
403 :     config_reg_get(config);
404 :     config_reg_set(config);
405 :     }
406 :    
407 :    
408 :     /* leaves current config value if dialog item is empty */
409 :     int config_get_int(HWND hDlg, INT item, int config)
410 :     {
411 :     BOOL success = FALSE;
412 :     int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);
413 :     return (success) ? tmp : config;
414 :     }
415 :    
416 :    
417 :     int config_get_uint(HWND hDlg, UINT item, int config)
418 :     {
419 :     BOOL success = FALSE;
420 :     int tmp = GetDlgItemInt(hDlg, item, &success, FALSE);
421 :     return (success) ? tmp : config;
422 :     }
423 :    
424 :    
425 : suxen_drol 1017 /* we use "100 base" floats */
426 : suxen_drol 889
427 : suxen_drol 1017 #define FLOAT_BUF_SZ 20
428 :     int get_dlgitem_float(HWND hDlg, UINT item, int def)
429 :     {
430 :     char buf[FLOAT_BUF_SZ];
431 :    
432 :     if (GetDlgItemText(hDlg, item, buf, FLOAT_BUF_SZ) == 0)
433 :     return def;
434 :    
435 :     return (int)(atof(buf)*100);
436 :     }
437 :    
438 :     void set_dlgitem_float(HWND hDlg, UINT item, int value)
439 :     {
440 :     char buf[FLOAT_BUF_SZ];
441 :     sprintf(buf, "%.2f", (float)value/100);
442 :     SetDlgItemText(hDlg, item, buf);
443 :     }
444 :    
445 :    
446 : suxen_drol 1032 #define HEX_BUF_SZ 16
447 :     unsigned int get_dlgitem_hex(HWND hDlg, UINT item, unsigned int def)
448 :     {
449 :     char buf[HEX_BUF_SZ];
450 :     unsigned int value;
451 :    
452 :     if (GetDlgItemText(hDlg, item, buf, HEX_BUF_SZ) == 0)
453 :     return def;
454 :    
455 :     if (sscanf(buf,"0x%x", &value)==1 || sscanf(buf,"%x", &value)==1) {
456 :     return value;
457 :     }
458 :    
459 :     return def;
460 :     }
461 :    
462 :     void set_dlgitem_hex(HWND hDlg, UINT item, int value)
463 :     {
464 :     char buf[HEX_BUF_SZ];
465 :     wsprintf(buf, "0x%x", value);
466 :     SetDlgItemText(hDlg, item, buf);
467 :     }
468 :    
469 : suxen_drol 983 /* ===================================================================================== */
470 :     /* QUANT MATRIX DIALOG ================================================================= */
471 :     /* ===================================================================================== */
472 :    
473 :     void quant_upload(HWND hDlg, CONFIG* config)
474 : suxen_drol 889 {
475 : suxen_drol 983 int i;
476 : suxen_drol 889
477 : suxen_drol 1017 for (i=0 ; i<64; i++) {
478 : suxen_drol 983 SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE);
479 :     SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE);
480 : suxen_drol 889 }
481 :     }
482 :    
483 :    
484 : suxen_drol 983 void quant_download(HWND hDlg, CONFIG* config)
485 : suxen_drol 889 {
486 : suxen_drol 983 int i;
487 : suxen_drol 889
488 : suxen_drol 1017 for (i=0; i<64; i++) {
489 : suxen_drol 983 int temp;
490 : suxen_drol 889
491 : suxen_drol 983 temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);
492 :     CONSTRAINVAL(temp, 1, 255);
493 :     config->qmatrix_intra[i] = temp;
494 : suxen_drol 889
495 : suxen_drol 983 temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);
496 :     CONSTRAINVAL(temp, 1, 255);
497 :     config->qmatrix_inter[i] = temp;
498 : suxen_drol 889 }
499 :     }
500 :    
501 : suxen_drol 1017
502 :     void quant_loadsave(HWND hDlg, CONFIG * config, int save)
503 :     {
504 :     char file[MAX_PATH];
505 :     OPENFILENAME ofn;
506 :     HANDLE hFile;
507 :     DWORD read=128, wrote=0;
508 :     BYTE quant_data[128];
509 :    
510 :     strcpy(file, "\\matrix");
511 :     memset(&ofn, 0, sizeof(OPENFILENAME));
512 :     ofn.lStructSize = sizeof(OPENFILENAME);
513 :    
514 :     ofn.hwndOwner = hDlg;
515 :     ofn.lpstrFilter = "All files (*.*)\0*.*\0\0";
516 :     ofn.lpstrFile = file;
517 :     ofn.nMaxFile = MAX_PATH;
518 :     ofn.Flags = OFN_PATHMUSTEXIST;
519 :    
520 :     if (save) {
521 :     ofn.Flags |= OFN_OVERWRITEPROMPT;
522 :     if (GetSaveFileName(&ofn)) {
523 :     hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
524 :    
525 :     quant_download(hDlg, config);
526 :     memcpy(quant_data, config->qmatrix_intra, 64);
527 :     memcpy(quant_data+64, config->qmatrix_inter, 64);
528 :    
529 :     if (hFile == INVALID_HANDLE_VALUE) {
530 :     DPRINTF("Couldn't save quant matrix");
531 :     }else{
532 :     if (!WriteFile(hFile, quant_data, 128, &wrote, 0)) {
533 :     DPRINTF("Couldnt write quant matrix");
534 :     }
535 :     }
536 :     CloseHandle(hFile);
537 :     }
538 :     }else{
539 :     ofn.Flags |= OFN_FILEMUSTEXIST;
540 :     if (GetOpenFileName(&ofn)) {
541 :     hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
542 :    
543 :     if (hFile == INVALID_HANDLE_VALUE) {
544 :     DPRINTF("Couldn't load quant matrix");
545 :     } else {
546 :     if (!ReadFile(hFile, quant_data, 128, &read, 0)) {
547 :     DPRINTF("Couldnt read quant matrix");
548 :     }else{
549 :     memcpy(config->qmatrix_intra, quant_data, 64);
550 :     memcpy(config->qmatrix_inter, quant_data+64, 64);
551 :     quant_upload(hDlg, config);
552 :     }
553 :     }
554 :     CloseHandle(hFile);
555 :     }
556 :     }
557 :     }
558 :    
559 : suxen_drol 983 /* quantization matrix dialog proc */
560 : suxen_drol 889
561 : suxen_drol 983 BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
562 : suxen_drol 889 {
563 : suxen_drol 983 CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
564 : suxen_drol 889
565 : suxen_drol 983 switch (uMsg)
566 : suxen_drol 889 {
567 : suxen_drol 983 case WM_INITDIALOG :
568 :     SetWindowLong(hDlg, GWL_USERDATA, lParam);
569 :     config = (CONFIG*)lParam;
570 :     quant_upload(hDlg, config);
571 : suxen_drol 889
572 : suxen_drol 983 if (g_hTooltip)
573 :     {
574 :     EnumChildWindows(hDlg, enum_tooltips, 0);
575 :     }
576 : suxen_drol 889 break;
577 :    
578 : suxen_drol 983 case WM_COMMAND :
579 : suxen_drol 889
580 : suxen_drol 1017 if (HIWORD(wParam) == BN_CLICKED) {
581 :     switch(LOWORD(wParam)) {
582 :     case IDOK :
583 :     quant_download(hDlg, config);
584 :     EndDialog(hDlg, IDOK);
585 :     break;
586 : suxen_drol 889
587 : suxen_drol 1017 case IDCANCEL :
588 :     EndDialog(hDlg, IDCANCEL);
589 :     break;
590 : suxen_drol 889
591 : suxen_drol 1017 case IDC_SAVE :
592 :     quant_loadsave(hDlg, config, 1);
593 :     break;
594 : suxen_drol 889
595 : suxen_drol 1017 case IDC_LOAD :
596 :     quant_loadsave(hDlg, config, 0);
597 :     break;
598 : suxen_drol 889
599 : suxen_drol 1017 default :
600 :     return FALSE;
601 :     }
602 :     break;
603 :     }
604 :     return FALSE;
605 : suxen_drol 889
606 : suxen_drol 983 default :
607 : suxen_drol 1017 return FALSE;
608 : suxen_drol 889 }
609 : suxen_drol 983
610 : suxen_drol 1017 return TRUE;
611 : suxen_drol 889 }
612 :    
613 :    
614 : suxen_drol 983 /* ===================================================================================== */
615 :     /* ADVANCED DIALOG PAGES ================================================================ */
616 :     /* ===================================================================================== */
617 : suxen_drol 889
618 : suxen_drol 983 /* initialise pages */
619 :     void adv_init(HWND hDlg, int idd, CONFIG * config)
620 : suxen_drol 889 {
621 : suxen_drol 983 unsigned int i;
622 : suxen_drol 889
623 : suxen_drol 983 switch(idd) {
624 :     case IDD_PROFILE :
625 :     for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
626 :     SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
627 : suxen_drol 1017 SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263");
628 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");
629 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");
630 : suxen_drol 983 break;
631 : suxen_drol 1017
632 :     case IDD_LEVEL :
633 :     for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
634 :     SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
635 :     break;
636 : suxen_drol 983
637 : suxen_drol 1017 case IDD_ZONE :
638 : suxen_drol 1069 EnableDlgWindow(hDlg, IDC_ZONE_FETCH, config->ci_valid);
639 : suxen_drol 1017 break;
640 :    
641 : suxen_drol 983 case IDD_MOTION :
642 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None");
643 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low");
644 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low");
645 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium");
646 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High");
647 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High");
648 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High");
649 : suxen_drol 889
650 : suxen_drol 983 SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"0 - Off");
651 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"1 - Mode Decision");
652 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"2 - Limited Search");
653 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"3 - Medium Search");
654 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"4 - Wide Search");
655 :     break;
656 : suxen_drol 889
657 : suxen_drol 983 case IDD_DEBUG :
658 :     /* force threads disabled */
659 :     EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);
660 :     EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);
661 : suxen_drol 889
662 : suxen_drol 983 SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");
663 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
664 :     SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
665 :     break;
666 :     }
667 :     }
668 : suxen_drol 889
669 : suxen_drol 1017
670 : suxen_drol 983 /* enable/disable controls based on encoder-mode or user selection */
671 : suxen_drol 889
672 : suxen_drol 983 void adv_mode(HWND hDlg, int idd, CONFIG * config)
673 :     {
674 : suxen_drol 1017 int profile;
675 :     int weight_en, quant_en;
676 : suxen_drol 983 int cpu_force;
677 : suxen_drol 1017 int custom_quant, bvops;
678 : suxen_drol 983
679 :     switch(idd) {
680 :     case IDD_PROFILE :
681 : suxen_drol 1017 profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0);
682 :     EnableDlgWindow(hDlg, IDC_BVOP, profiles[profile].flags&PROFILE_BVOP);
683 :    
684 :     EnableDlgWindow(hDlg, IDC_QUANTTYPE_S, profiles[profile].flags&PROFILE_MPEGQUANT);
685 :     EnableDlgWindow(hDlg, IDC_QUANTTYPE_S, profiles[profile].flags&PROFILE_MPEGQUANT);
686 :     EnableDlgWindow(hDlg, IDC_QUANTTYPE, profiles[profile].flags&PROFILE_MPEGQUANT);
687 :     custom_quant = (profiles[profile].flags&PROFILE_MPEGQUANT) && SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0)==QUANT_MODE_CUSTOM;
688 :     EnableDlgWindow(hDlg, IDC_QUANTMATRIX, custom_quant);
689 :     EnableDlgWindow(hDlg, IDC_LUMMASK, profiles[profile].flags&PROFILE_ADAPTQUANT);
690 :     EnableDlgWindow(hDlg, IDC_INTERLACING, profiles[profile].flags&PROFILE_INTERLACE);
691 :     EnableDlgWindow(hDlg, IDC_QPEL, profiles[profile].flags&PROFILE_QPEL);
692 :     EnableDlgWindow(hDlg, IDC_GMC, profiles[profile].flags&PROFILE_GMC);
693 :     EnableDlgWindow(hDlg, IDC_REDUCED, profiles[profile].flags&PROFILE_REDUCED);
694 :    
695 :     bvops = (profiles[profile].flags&PROFILE_BVOP) && IsDlgChecked(hDlg, IDC_BVOP);
696 :     EnableDlgWindow(hDlg, IDC_MAXBFRAMES, bvops);
697 :     EnableDlgWindow(hDlg, IDC_BQUANTRATIO, bvops);
698 :     EnableDlgWindow(hDlg, IDC_BQUANTOFFSET, bvops);
699 :     EnableDlgWindow(hDlg, IDC_MAXBFRAMES_S, bvops);
700 :     EnableDlgWindow(hDlg, IDC_BQUANTRATIO_S, bvops);
701 :     EnableDlgWindow(hDlg, IDC_BQUANTOFFSET_S, bvops);
702 :     EnableDlgWindow(hDlg, IDC_PACKED, bvops);
703 :     EnableDlgWindow(hDlg, IDC_CLOSEDGOV, bvops);
704 :    
705 :     case IDD_LEVEL :
706 :     profile = SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_GETCURSEL, 0, 0);
707 :     SetDlgItemInt(hDlg, IDC_LEVEL_WIDTH, profiles[profile].width, FALSE);
708 :     SetDlgItemInt(hDlg, IDC_LEVEL_HEIGHT, profiles[profile].height, FALSE);
709 :     SetDlgItemInt(hDlg, IDC_LEVEL_FPS, profiles[profile].fps, FALSE);
710 :     SetDlgItemInt(hDlg, IDC_LEVEL_VMV, profiles[profile].max_vmv_buffer_sz, FALSE);
711 :     SetDlgItemInt(hDlg, IDC_LEVEL_VCV, profiles[profile].vcv_decoder_rate, FALSE);
712 :     SetDlgItemInt(hDlg, IDC_LEVEL_VBV, profiles[profile].max_vbv_size, FALSE);
713 :     SetDlgItemInt(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate, FALSE);
714 : suxen_drol 983 break;
715 : suxen_drol 889
716 : suxen_drol 1017 case IDD_ZONE :
717 :     weight_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT);
718 :     quant_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT);
719 :     EnableDlgWindow(hDlg, IDC_ZONE_WEIGHT, weight_en);
720 :     EnableDlgWindow(hDlg, IDC_ZONE_QUANT, quant_en);
721 :     EnableDlgWindow(hDlg, IDC_ZONE_SLIDER, weight_en|quant_en);
722 : suxen_drol 889
723 : suxen_drol 1017 if (weight_en) {
724 :     SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(001,200));
725 :     SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, 100));
726 :     SetDlgItemText(hDlg, IDC_ZONE_MIN, "0.01");
727 :     SetDlgItemText(hDlg, IDC_ZONE_MAX, "2.00");
728 :     }else if (quant_en) {
729 :     SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(100,3100));
730 :     SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_ZONE_QUANT, 100));
731 :     SetDlgItemText(hDlg, IDC_ZONE_MIN, "1");
732 :     SetDlgItemText(hDlg, IDC_ZONE_MAX, "31");
733 :     }
734 : suxen_drol 889
735 : suxen_drol 1017 bvops = (profiles[config->profile].flags&PROFILE_BVOP) && config->use_bvop;
736 :     EnableDlgWindow(hDlg, IDC_ZONE_BVOPTHRESHOLD_S, bvops);
737 :     EnableDlgWindow(hDlg, IDC_ZONE_BVOPTHRESHOLD, bvops);
738 : suxen_drol 983 break;
739 : suxen_drol 889
740 : suxen_drol 983 case IDD_DEBUG :
741 :     cpu_force = IsDlgChecked(hDlg, IDC_CPU_FORCE);
742 :     EnableDlgWindow(hDlg, IDC_CPU_MMX, cpu_force);
743 :     EnableDlgWindow(hDlg, IDC_CPU_MMXEXT, cpu_force);
744 :     EnableDlgWindow(hDlg, IDC_CPU_SSE, cpu_force);
745 :     EnableDlgWindow(hDlg, IDC_CPU_SSE2, cpu_force);
746 :     EnableDlgWindow(hDlg, IDC_CPU_3DNOW, cpu_force);
747 :     EnableDlgWindow(hDlg, IDC_CPU_3DNOWEXT, cpu_force);
748 :     break;
749 :     }
750 : suxen_drol 889 }
751 :    
752 :    
753 : suxen_drol 983 /* upload config data into dialog */
754 :     void adv_upload(HWND hDlg, int idd, CONFIG * config)
755 : suxen_drol 889 {
756 : suxen_drol 983 switch (idd)
757 : suxen_drol 889 {
758 : suxen_drol 983 case IDD_PROFILE :
759 :     SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_SETCURSEL, config->profile, 0);
760 : suxen_drol 1017
761 :     SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);
762 :     CheckDlg(hDlg, IDC_LUMMASK, config->lum_masking);
763 :     CheckDlg(hDlg, IDC_INTERLACING, config->interlacing);
764 :     CheckDlg(hDlg, IDC_QPEL, config->qpel);
765 :     CheckDlg(hDlg, IDC_GMC, config->gmc);
766 :     CheckDlg(hDlg, IDC_REDUCED, config->reduced_resolution);
767 :     CheckDlg(hDlg, IDC_BVOP, config->use_bvop);
768 :    
769 :     SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, FALSE);
770 :     set_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
771 :     set_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
772 :     CheckDlg(hDlg, IDC_PACKED, config->packed);
773 :     CheckDlg(hDlg, IDC_CLOSEDGOV, config->closed_gov);
774 : suxen_drol 889 break;
775 :    
776 : suxen_drol 1017 case IDD_LEVEL :
777 :     SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_SETCURSEL, config->profile, 0);
778 :     break;
779 :    
780 : suxen_drol 983 case IDD_RC_CBR :
781 :     SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);
782 :     SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);
783 :     SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);
784 : suxen_drol 889 break;
785 :    
786 : suxen_drol 983 case IDD_RC_2PASS1 :
787 :     SetDlgItemText(hDlg, IDC_STATS, config->stats);
788 : suxen_drol 1017 CheckDlg(hDlg, IDC_DISCARD1PASS, config->discard1pass);
789 : suxen_drol 983 break;
790 :    
791 :     case IDD_RC_2PASS2 :
792 :     SetDlgItemText(hDlg, IDC_STATS, config->stats);
793 :     SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);
794 : suxen_drol 889 SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE);
795 :     SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);
796 : suxen_drol 1017
797 :     SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);
798 :     SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);
799 :    
800 : suxen_drol 889 SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);
801 :     SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);
802 :     SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);
803 : suxen_drol 1052 CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == XVID_PAYBACK_BIAS));
804 :     CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == XVID_PAYBACK_PROP));
805 : suxen_drol 889 break;
806 :    
807 : suxen_drol 1017 case IDD_ZONE :
808 :     SetDlgItemInt(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame, FALSE);
809 :    
810 :     CheckDlgButton(hDlg, IDC_ZONE_MODE_WEIGHT, config->zones[config->cur_zone].mode == RC_ZONE_WEIGHT);
811 :     CheckDlgButton(hDlg, IDC_ZONE_MODE_QUANT, config->zones[config->cur_zone].mode == RC_ZONE_QUANT);
812 :    
813 :     set_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, config->zones[config->cur_zone].weight);
814 :     set_dlgitem_float(hDlg, IDC_ZONE_QUANT, config->zones[config->cur_zone].quant);
815 :    
816 : suxen_drol 1069 CheckDlgButton(hDlg, IDC_ZONE_FORCEIVOP, config->zones[config->cur_zone].type==XVID_TYPE_IVOP);
817 : suxen_drol 1017 CheckDlgButton(hDlg, IDC_ZONE_GREYSCALE, config->zones[config->cur_zone].greyscale);
818 :     CheckDlgButton(hDlg, IDC_ZONE_CHROMAOPT, config->zones[config->cur_zone].chroma_opt);
819 :    
820 :     SetDlgItemInt(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold, TRUE);
821 :     break;
822 : suxen_drol 983
823 :     case IDD_MOTION :
824 :     SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0);
825 :     SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0);
826 : suxen_drol 1017 CheckDlg(hDlg, IDC_CHROMAME, config->chromame);
827 : edgomez 1193 CheckDlg(hDlg, IDC_CARTOON, config->cartoon_mode);
828 : suxen_drol 1017 SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);
829 :     SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
830 :     SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);
831 : suxen_drol 983 break;
832 :    
833 :     case IDD_QUANT :
834 :     SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE);
835 :     SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE);
836 :     SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE);
837 :     SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE);
838 : suxen_drol 1017 SetDlgItemInt(hDlg, IDC_MINBQUANT, config->min_bquant, FALSE);
839 :     SetDlgItemInt(hDlg, IDC_MAXBQUANT, config->max_bquant, FALSE);
840 :     CheckDlg(hDlg, IDC_TRELLISQUANT, config->trellis_quant);
841 : suxen_drol 983 break;
842 :    
843 :     case IDD_DEBUG :
844 : suxen_drol 1017 CheckDlg(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX));
845 :     CheckDlg(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT));
846 :     CheckDlg(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE));
847 :     CheckDlg(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2));
848 :     CheckDlg(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW));
849 :     CheckDlg(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT));
850 : suxen_drol 889
851 :     CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,
852 :     config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );
853 :    
854 :     SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);
855 : suxen_drol 983
856 : suxen_drol 1061 SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
857 :     set_dlgitem_hex(hDlg, IDC_DEBUG, config->debug);
858 : suxen_drol 1032 CheckDlg(hDlg, IDC_VOPDEBUG, config->vop_debug);
859 : suxen_drol 1061 CheckDlg(hDlg, IDC_DISPLAY_STATUS, config->display_status);
860 : suxen_drol 889 break;
861 :     }
862 :     }
863 :    
864 :    
865 : suxen_drol 983 /* download config data from dialog */
866 : suxen_drol 889
867 : suxen_drol 983 void adv_download(HWND hDlg, int idd, CONFIG * config)
868 : suxen_drol 889 {
869 : suxen_drol 983 switch (idd)
870 : suxen_drol 889 {
871 : suxen_drol 983 case IDD_PROFILE :
872 :     config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0);
873 : suxen_drol 1017
874 :     config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);
875 :     config->lum_masking = IsDlgChecked(hDlg, IDC_LUMMASK);
876 :     config->interlacing = IsDlgChecked(hDlg, IDC_INTERLACING);
877 :     config->qpel = IsDlgChecked(hDlg, IDC_QPEL);
878 :     config->gmc = IsDlgChecked(hDlg, IDC_GMC);
879 :     config->reduced_resolution = IsDlgChecked(hDlg, IDC_REDUCED);
880 :    
881 :     config->use_bvop = IsDlgChecked(hDlg, IDC_BVOP);
882 :     config->max_bframes = config_get_uint(hDlg, IDC_MAXBFRAMES, config->max_bframes);
883 :     config->bquant_ratio = get_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
884 :     config->bquant_offset = get_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
885 :     config->packed = IsDlgChecked(hDlg, IDC_PACKED);
886 :     config->closed_gov = IsDlgChecked(hDlg, IDC_CLOSEDGOV);
887 : suxen_drol 983 break;
888 : suxen_drol 889
889 : suxen_drol 1017 case IDD_LEVEL :
890 :     config->profile = SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_GETCURSEL, 0, 0);
891 :     break;
892 :    
893 : suxen_drol 983 case IDD_RC_CBR :
894 :     config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);
895 :     config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);
896 :     config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);
897 : suxen_drol 889 break;
898 :    
899 : suxen_drol 983 case IDD_RC_2PASS1 :
900 :     if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0)
901 :     lstrcpy(config->stats, CONFIG_2PASS_FILE);
902 :     config->discard1pass = IsDlgChecked(hDlg, IDC_DISCARD1PASS);
903 :     break;
904 : suxen_drol 889
905 : suxen_drol 983 case IDD_RC_2PASS2 :
906 :     if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0)
907 :     lstrcpy(config->stats, CONFIG_2PASS_FILE);
908 : suxen_drol 889
909 : suxen_drol 983 config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);
910 : suxen_drol 889 config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE);
911 :     config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);
912 : suxen_drol 1017
913 :     config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);
914 :     config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);
915 :     CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);
916 :     CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);
917 : suxen_drol 983
918 : suxen_drol 889 config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);
919 :     config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
920 :     config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);
921 : suxen_drol 1052 config->bitrate_payback_method = IsDlgChecked(hDlg, IDC_PAYBACKPROP) ? XVID_PAYBACK_PROP : XVID_PAYBACK_BIAS;
922 : suxen_drol 889
923 :     CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000);
924 :     CONSTRAINVAL(config->keyframe_boost, 0, 1000);
925 :     CONSTRAINVAL(config->curve_compression_high, 0, 100);
926 :     CONSTRAINVAL(config->curve_compression_low, 0, 100);
927 :     break;
928 :    
929 : suxen_drol 1017 case IDD_ZONE :
930 :     config->zones[config->cur_zone].frame = config_get_uint(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame);
931 : suxen_drol 889
932 : suxen_drol 1017 if (IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT)) {
933 :     config->zones[config->cur_zone].mode = RC_ZONE_WEIGHT;
934 :     }else if (IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT)) {
935 :     config->zones[config->cur_zone].mode = RC_ZONE_QUANT;
936 :     }
937 : suxen_drol 889
938 : suxen_drol 1017 config->zones[config->cur_zone].weight = get_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, config->zones[config->cur_zone].weight);
939 :     config->zones[config->cur_zone].quant = get_dlgitem_float(hDlg, IDC_ZONE_QUANT, config->zones[config->cur_zone].quant);
940 :    
941 : suxen_drol 1069 config->zones[config->cur_zone].type = IsDlgButtonChecked(hDlg, IDC_ZONE_FORCEIVOP)?XVID_TYPE_IVOP:XVID_TYPE_AUTO;
942 : suxen_drol 1017 config->zones[config->cur_zone].greyscale = IsDlgButtonChecked(hDlg, IDC_ZONE_GREYSCALE);
943 :     config->zones[config->cur_zone].chroma_opt = IsDlgButtonChecked(hDlg, IDC_ZONE_CHROMAOPT);
944 :    
945 :     config->zones[config->cur_zone].bvop_threshold = config_get_int(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold);
946 :     break;
947 :    
948 : suxen_drol 983 case IDD_MOTION :
949 :     config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);
950 :     config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0);
951 :     config->chromame = IsDlgChecked(hDlg, IDC_CHROMAME);
952 : edgomez 1193 config->cartoon_mode = IsDlgChecked(hDlg, IDC_CARTOON);
953 : suxen_drol 889
954 : suxen_drol 1017 config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);
955 : suxen_drol 889
956 : suxen_drol 983 config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval);
957 :     config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval);
958 : suxen_drol 1017 break;
959 : suxen_drol 889
960 : suxen_drol 983 case IDD_QUANT :
961 :     config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);
962 :     config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);
963 :     config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);
964 :     config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);
965 : suxen_drol 1017 config->min_bquant = config_get_uint(hDlg, IDC_MINBQUANT, config->min_bquant);
966 :     config->max_bquant = config_get_uint(hDlg, IDC_MAXBQUANT, config->max_bquant);
967 : suxen_drol 889
968 : suxen_drol 983 CONSTRAINVAL(config->min_iquant, 1, 31);
969 :     CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);
970 :     CONSTRAINVAL(config->min_pquant, 1, 31);
971 :     CONSTRAINVAL(config->max_pquant, config->min_pquant, 31);
972 : suxen_drol 1017 CONSTRAINVAL(config->min_bquant, 1, 31);
973 :     CONSTRAINVAL(config->max_bquant, config->min_bquant, 31);
974 :    
975 :     config->trellis_quant = IsDlgChecked(hDlg, IDC_TRELLISQUANT);
976 : suxen_drol 983 break;
977 : suxen_drol 889
978 : suxen_drol 983 case IDD_DEBUG :
979 :     config->cpu = 0;
980 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMX) ? XVID_CPU_MMX : 0;
981 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT : 0;
982 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE) ? XVID_CPU_SSE : 0;
983 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE2) ? XVID_CPU_SSE2 : 0;
984 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOW) ? XVID_CPU_3DNOW : 0;
985 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT : 0;
986 :     config->cpu |= IsDlgChecked(hDlg, IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;
987 : suxen_drol 889
988 : suxen_drol 983 config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);
989 : suxen_drol 889
990 : suxen_drol 983 config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
991 : suxen_drol 1032 config->debug = get_dlgitem_hex(hDlg, IDC_DEBUG, config->debug);
992 : suxen_drol 1061 config->vop_debug = IsDlgChecked(hDlg, IDC_VOPDEBUG);
993 :     config->display_status = IsDlgChecked(hDlg, IDC_DISPLAY_STATUS);
994 : suxen_drol 983 break;
995 : suxen_drol 889 }
996 :     }
997 :    
998 :    
999 :    
1000 : suxen_drol 983 /* advanced dialog proc */
1001 : suxen_drol 889
1002 : suxen_drol 983 BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1003 : suxen_drol 889 {
1004 :     PROPSHEETINFO *psi;
1005 :    
1006 :     psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA);
1007 :    
1008 :     switch (uMsg)
1009 :     {
1010 :     case WM_INITDIALOG :
1011 :     psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;
1012 :     SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);
1013 :    
1014 : suxen_drol 983 if (g_hTooltip)
1015 : suxen_drol 889 EnumChildWindows(hDlg, enum_tooltips, 0);
1016 :    
1017 : suxen_drol 983 adv_init(hDlg, psi->idd, psi->config);
1018 : suxen_drol 889 break;
1019 :    
1020 : suxen_drol 983 case WM_COMMAND :
1021 :     if (HIWORD(wParam) == BN_CLICKED)
1022 :     {
1023 :     switch (LOWORD(wParam))
1024 :     {
1025 : suxen_drol 1017 case IDC_BVOP :
1026 :     case IDC_ZONE_MODE_WEIGHT :
1027 :     case IDC_ZONE_MODE_QUANT :
1028 :     case IDC_ZONE_BVOPTHRESHOLD_ENABLE :
1029 : suxen_drol 983 case IDC_CPU_AUTO :
1030 :     case IDC_CPU_FORCE :
1031 :     adv_mode(hDlg, psi->idd, psi->config);
1032 :     break;
1033 :    
1034 :     case IDC_QUANTMATRIX :
1035 :     DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config);
1036 :     break;
1037 :    
1038 :     case IDC_STATS_BROWSE :
1039 :     {
1040 :     OPENFILENAME ofn;
1041 :     char tmp[MAX_PATH];
1042 :    
1043 :     GetDlgItemText(hDlg, IDC_STATS, tmp, MAX_PATH);
1044 :    
1045 :     memset(&ofn, 0, sizeof(OPENFILENAME));
1046 :     ofn.lStructSize = sizeof(OPENFILENAME);
1047 :    
1048 :     ofn.hwndOwner = hDlg;
1049 :     ofn.lpstrFilter = "bitrate curve (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0";
1050 :     ofn.lpstrFile = tmp;
1051 :     ofn.nMaxFile = MAX_PATH;
1052 :     ofn.Flags = OFN_PATHMUSTEXIST;
1053 :    
1054 :     if (psi->idd == IDD_RC_2PASS1) {
1055 :     ofn.Flags |= OFN_OVERWRITEPROMPT;
1056 :     }else{
1057 :     ofn.Flags |= OFN_FILEMUSTEXIST;
1058 :     }
1059 :    
1060 :     if (GetSaveFileName(&ofn))
1061 :     {
1062 :     SetDlgItemText(hDlg, IDC_STATS, tmp);
1063 :     }
1064 :     }
1065 : suxen_drol 1017
1066 :     case IDC_ZONE_FETCH :
1067 :     SetDlgItemInt(hDlg, IDC_ZONE_FRAME, psi->config->ci.ciActiveFrame, FALSE);
1068 :     break;
1069 :    
1070 :     default :
1071 :     return TRUE;
1072 : suxen_drol 983 }
1073 : suxen_drol 1017 }else if (HIWORD(wParam) == LBN_SELCHANGE &&
1074 :     (LOWORD(wParam) == IDC_PROFILE_PROFILE ||
1075 :     LOWORD(wParam) == IDC_LEVEL_PROFILE ||
1076 :     LOWORD(wParam) == IDC_QUANTTYPE))
1077 : suxen_drol 983 {
1078 :     adv_mode(hDlg, psi->idd, psi->config);
1079 : suxen_drol 1017 }else if (HIWORD(wParam) == EN_UPDATE && (LOWORD(wParam)==IDC_ZONE_WEIGHT || LOWORD(wParam)==IDC_ZONE_QUANT)) {
1080 :    
1081 :     SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE,
1082 :     get_dlgitem_float(hDlg, LOWORD(wParam), 100));
1083 :     }else {
1084 :     return 0;
1085 : suxen_drol 983 }
1086 :     break;
1087 :    
1088 : suxen_drol 1017 case WM_HSCROLL :
1089 :     if((HWND)lParam == GetDlgItem(hDlg, IDC_ZONE_SLIDER)) {
1090 :     int idc = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT) ? IDC_ZONE_WEIGHT : IDC_ZONE_QUANT;
1091 :     set_dlgitem_float(hDlg, idc, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0) );
1092 :     break;
1093 :     }
1094 :     return 0;
1095 :    
1096 :    
1097 : suxen_drol 889 case WM_NOTIFY :
1098 :     switch (((NMHDR *)lParam)->code)
1099 :     {
1100 : suxen_drol 1017 case PSN_SETACTIVE :
1101 :     OutputDebugString("PSN_SET");
1102 :     adv_upload(hDlg, psi->idd, psi->config);
1103 :     adv_mode(hDlg, psi->idd, psi->config);
1104 :     SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1105 :     break;
1106 :    
1107 :     case PSN_KILLACTIVE :
1108 :     OutputDebugString("PSN_KILL");
1109 :     adv_download(hDlg, psi->idd, psi->config);
1110 : suxen_drol 889 SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1111 :     break;
1112 :    
1113 :     case PSN_APPLY :
1114 : suxen_drol 1017 OutputDebugString("PSN_APPLY");
1115 :     psi->config->save = TRUE;
1116 : suxen_drol 889 SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1117 :     break;
1118 :     }
1119 :     break;
1120 :    
1121 :     default :
1122 :     return 0;
1123 :     }
1124 :    
1125 :     return 1;
1126 :     }
1127 :    
1128 :    
1129 : suxen_drol 983
1130 :    
1131 : suxen_drol 1017 /* load advanced options property sheet
1132 :     returns true, if the user accepted the changes
1133 :     or fasle if changes were canceled.
1134 :    
1135 :     */
1136 :     BOOL adv_dialog(HWND hParent, CONFIG * config, const int * dlgs, int size)
1137 : suxen_drol 889 {
1138 : suxen_drol 983 PROPSHEETINFO psi[6];
1139 :     PROPSHEETPAGE psp[6];
1140 : suxen_drol 889 PROPSHEETHEADER psh;
1141 :     CONFIG temp;
1142 :     int i;
1143 :    
1144 :     config->save = FALSE;
1145 :     memcpy(&temp, config, sizeof(CONFIG));
1146 :    
1147 : suxen_drol 983 for (i=0; i<size; i++)
1148 : suxen_drol 889 {
1149 :     psp[i].dwSize = sizeof(PROPSHEETPAGE);
1150 :     psp[i].dwFlags = 0;
1151 : suxen_drol 983 psp[i].hInstance = g_hInst;
1152 :     psp[i].pfnDlgProc = adv_proc;
1153 : suxen_drol 889 psp[i].lParam = (LPARAM)&psi[i];
1154 :     psp[i].pfnCallback = NULL;
1155 : suxen_drol 983 psp[i].pszTemplate = MAKEINTRESOURCE(dlgs[i]);
1156 : suxen_drol 889
1157 : suxen_drol 983 psi[i].idd = dlgs[i];
1158 : suxen_drol 889 psi[i].config = &temp;
1159 :     }
1160 :    
1161 :     psh.dwSize = sizeof(PROPSHEETHEADER);
1162 :     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
1163 :     psh.hwndParent = hParent;
1164 : suxen_drol 983 psh.hInstance = g_hInst;
1165 : suxen_drol 889 psh.pszCaption = (LPSTR) "XviD Configuration";
1166 : suxen_drol 983 psh.nPages = size;
1167 :     psh.nStartPage = 0;
1168 : suxen_drol 889 psh.ppsp = (LPCPROPSHEETPAGE)&psp;
1169 :     psh.pfnCallback = NULL;
1170 :     PropertySheet(&psh);
1171 :    
1172 : suxen_drol 1017 if (temp.save)
1173 : suxen_drol 889 memcpy(config, &temp, sizeof(CONFIG));
1174 : suxen_drol 1017
1175 :     return temp.save;
1176 : suxen_drol 889 }
1177 :    
1178 : suxen_drol 983 /* ===================================================================================== */
1179 :     /* MAIN DIALOG ========================================================================= */
1180 :     /* ===================================================================================== */
1181 : suxen_drol 889
1182 :    
1183 : suxen_drol 1017 void main_insert_zone(HWND hDlg, zone_t * s, int i, BOOL insert)
1184 : suxen_drol 983 {
1185 : suxen_drol 1017 char tmp[32];
1186 : suxen_drol 983
1187 : suxen_drol 1017 wsprintf(tmp,"%i",s->frame);
1188 : suxen_drol 983
1189 : suxen_drol 1017 if (insert) {
1190 :     LVITEM lvi;
1191 : suxen_drol 983
1192 : suxen_drol 1017 lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
1193 :     lvi.state = 0;
1194 :     lvi.stateMask = 0;
1195 :     lvi.iImage = 0;
1196 :     lvi.pszText = tmp;
1197 :     lvi.cchTextMax = strlen(tmp);
1198 :     lvi.iItem = i;
1199 :     lvi.iSubItem = 0;
1200 :     ListView_InsertItem(hDlg, &lvi);
1201 :     }else{
1202 :     ListView_SetItemText(hDlg, i, 0, tmp);
1203 :     }
1204 : suxen_drol 983
1205 : suxen_drol 1017 if (s->mode == RC_ZONE_WEIGHT) {
1206 :     sprintf(tmp,"%.2f",(float)s->weight/100);
1207 :     }else if (s->mode == RC_ZONE_QUANT) {
1208 :     sprintf(tmp,"( %.2f )",(float)s->quant/100);
1209 :     }else {
1210 :     strcpy(tmp,"EXT");
1211 :     }
1212 :     ListView_SetItemText(hDlg, i, 1, tmp);
1213 : suxen_drol 983
1214 : suxen_drol 1017 tmp[0] = '\0';
1215 : suxen_drol 1069 if (s->type==XVID_TYPE_IVOP)
1216 :     strcat(tmp, "K ");
1217 :    
1218 : suxen_drol 1017 if (s->greyscale)
1219 :     strcat(tmp, "G ");
1220 :    
1221 :     if (s->chroma_opt)
1222 :     strcat(tmp, "C ");
1223 : suxen_drol 983
1224 : suxen_drol 1017 ListView_SetItemText(hDlg, i, 2, tmp);
1225 : suxen_drol 983 }
1226 :    
1227 : suxen_drol 1061 static int g_use_bitrate = 1;
1228 : suxen_drol 983
1229 : suxen_drol 1017 void main_mode(HWND hDlg, CONFIG * config)
1230 : suxen_drol 983 {
1231 : suxen_drol 1061 const int profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0);
1232 :     const int rc_mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
1233 :     /* enable target rate/size control only for 1pass and 2pass modes*/
1234 :     const int target_en = rc_mode==RC_MODE_1PASS || rc_mode==RC_MODE_2PASS2;
1235 :    
1236 : suxen_drol 1017 char buf[16];
1237 :     int max;
1238 : suxen_drol 983
1239 : suxen_drol 1061 g_use_bitrate = rc_mode==RC_MODE_1PASS || config->use_2pass_bitrate;
1240 : suxen_drol 983
1241 : suxen_drol 1061 if (g_use_bitrate) {
1242 :     SetDlgItemText(hDlg, IDC_BITRATE_S, "Target bitrate (kbps):");
1243 : suxen_drol 983
1244 : suxen_drol 1061 wsprintf(buf, "%i kbps", DEFAULT_MIN_KBPS);
1245 :     SetDlgItemText(hDlg, IDC_BITRATE_MIN, buf);
1246 : suxen_drol 983
1247 : suxen_drol 1061 max = profiles[profile].max_bitrate;
1248 :     if (max == 0) max = DEFAULT_MAX_KBPS;
1249 :     wsprintf(buf, "%i kbps", max);
1250 :     SetDlgItemText(hDlg, IDC_BITRATE_MAX, buf);
1251 :    
1252 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(DEFAULT_MIN_KBPS, max));
1253 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE,
1254 :     config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) );
1255 :    
1256 :     }else{
1257 :     SetDlgItemText(hDlg, IDC_BITRATE_S, "Target size (kbytes):");
1258 :     }
1259 :    
1260 :     EnableDlgWindow(hDlg, IDC_BITRATE_S, target_en);
1261 :     EnableDlgWindow(hDlg, IDC_BITRATE, target_en);
1262 :    
1263 :     EnableDlgWindow(hDlg, IDC_BITRATE_MIN, target_en && g_use_bitrate);
1264 :     EnableDlgWindow(hDlg, IDC_BITRATE_MAX, target_en && g_use_bitrate);
1265 :     EnableDlgWindow(hDlg, IDC_SLIDER, target_en && g_use_bitrate);
1266 : suxen_drol 1017 }
1267 : suxen_drol 983
1268 : suxen_drol 1061
1269 :    
1270 : suxen_drol 1017 void main_upload(HWND hDlg, CONFIG * config)
1271 :     {
1272 :     int i;
1273 : suxen_drol 983
1274 : suxen_drol 1017 SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0);
1275 : suxen_drol 1061 SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1276 : suxen_drol 983
1277 : suxen_drol 1061 if (g_use_bitrate) {
1278 :     SetDlgItemInt(hDlg, IDC_BITRATE, config->bitrate, FALSE);
1279 :     }else{
1280 :     SetDlgItemInt(hDlg, IDC_BITRATE, config->desired_size, FALSE);
1281 :     }
1282 :    
1283 : suxen_drol 1017 ListView_DeleteAllItems(GetDlgItem(hDlg,IDC_ZONES));
1284 :     for (i=0; i < config->num_zones; i++) {
1285 :     main_insert_zone(GetDlgItem(hDlg,IDC_ZONES), &config->zones[i], i, TRUE);
1286 :     }
1287 : suxen_drol 983 }
1288 :    
1289 :    
1290 : suxen_drol 1017 /* downloads data from main dialog */
1291 :     void main_download(HWND hDlg, CONFIG * config)
1292 : suxen_drol 983 {
1293 : suxen_drol 1017 config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0);
1294 :     config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
1295 : suxen_drol 1061
1296 :     if (g_use_bitrate) {
1297 :     config->bitrate = config_get_uint(hDlg, IDC_BITRATE, config->bitrate);
1298 :     }else{
1299 :     config->desired_size = config_get_uint(hDlg, IDC_BITRATE, config->desired_size);
1300 :     }
1301 : suxen_drol 1017 }
1302 : suxen_drol 983
1303 :    
1304 : suxen_drol 1017 /* main dialog proc */
1305 : suxen_drol 983
1306 : suxen_drol 1017 static const int profile_dlgs[] = { IDD_PROFILE, IDD_LEVEL };
1307 :     static const int single_dlgs[] = { IDD_RC_CBR };
1308 :     static const int pass1_dlgs[] = { IDD_RC_2PASS1 };
1309 : suxen_drol 1052 static const int pass2_dlgs[] = { IDD_RC_2PASS2 };
1310 : suxen_drol 1017 static const int zone_dlgs[] = { IDD_ZONE };
1311 :     static const int bitrate_dlgs[] = { IDD_CALC };
1312 :     static const int adv_dlgs[] = { IDD_MOTION, IDD_QUANT, IDD_DEBUG};
1313 : suxen_drol 983
1314 :    
1315 : suxen_drol 889 BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1316 :     {
1317 : suxen_drol 1017 CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
1318 :     unsigned int i;
1319 : suxen_drol 889
1320 :     switch (uMsg)
1321 :     {
1322 :     case WM_INITDIALOG :
1323 :     SetWindowLong(hDlg, GWL_USERDATA, lParam);
1324 :     config = (CONFIG*)lParam;
1325 :    
1326 : suxen_drol 983 for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
1327 :     SendDlgItemMessage(hDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
1328 :    
1329 : suxen_drol 1017 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Single pass");
1330 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 1st pass");
1331 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 2nd pass");
1332 :     #ifdef _DEBUG
1333 :     SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null test speed");
1334 :     #endif
1335 : suxen_drol 889
1336 :     InitCommonControls();
1337 :    
1338 : suxen_drol 983 if ((g_hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
1339 : suxen_drol 889 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1340 : suxen_drol 983 NULL, NULL, g_hInst, NULL)))
1341 : suxen_drol 889 {
1342 : suxen_drol 983 SetWindowPos(g_hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
1343 :     SendMessage(g_hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
1344 :     SendMessage(g_hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
1345 : suxen_drol 889
1346 :     EnumChildWindows(hDlg, enum_tooltips, 0);
1347 :     }
1348 :    
1349 : suxen_drol 1061 SetClassLong(GetDlgItem(hDlg, IDC_BITRATE_S), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));
1350 :    
1351 : suxen_drol 1017 {
1352 :     DWORD ext_style = ListView_GetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES));
1353 :     ext_style |= LVS_EX_FULLROWSELECT | LVS_EX_FLATSB ;
1354 :     ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES), ext_style);
1355 :     }
1356 : suxen_drol 889
1357 : suxen_drol 1017 {
1358 :     typedef struct {
1359 :     char * name;
1360 :     int value;
1361 :     } char_int_t;
1362 :    
1363 :     const static char_int_t columns[] = {
1364 :     {"Frame #", 64},
1365 :     {"Weight (Q)", 72},
1366 :     {"Modifiers", 120}};
1367 :    
1368 :     LVCOLUMN lvc;
1369 :     int i;
1370 :    
1371 : edgomez 1053 /* Initialize the LVCOLUMN structure. */
1372 : suxen_drol 1017 lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1373 :     lvc.fmt = LVCFMT_LEFT;
1374 :    
1375 : edgomez 1053 /* Add the columns. */
1376 : suxen_drol 1017 for (i=0; i<sizeof(columns)/sizeof(char_int_t); i++) {
1377 :     lvc.pszText = (char*)columns[i].name;
1378 :     lvc.cchTextMax = strlen(columns[i].name);
1379 :     lvc.iSubItem = i;
1380 :     lvc.cx = columns[i].value; /* column width, pixels */
1381 :     ListView_InsertColumn(GetDlgItem(hDlg,IDC_ZONES), i, &lvc);
1382 :     }
1383 :     }
1384 :    
1385 : suxen_drol 1061 /* XXX: main_mode needs RC_MODE_xxx, main_upload needs g_use_bitrate set correctly... */
1386 : suxen_drol 1017 main_upload(hDlg, config);
1387 :     main_mode(hDlg, config);
1388 : suxen_drol 1061 main_upload(hDlg, config);
1389 : suxen_drol 889 break;
1390 :    
1391 : suxen_drol 1017 case WM_NOTIFY :
1392 :     {
1393 :     NMHDR * n = (NMHDR*)lParam;
1394 :    
1395 :     if (n->code == NM_DBLCLK) {
1396 :     NMLISTVIEW * nmlv = (NMLISTVIEW*) lParam;
1397 :     config->cur_zone = nmlv->iItem;
1398 :    
1399 :     main_download(hDlg, config);
1400 :     if (config->cur_zone >= 0 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) {
1401 :     main_insert_zone(GetDlgItem(hDlg, IDC_ZONES), &config->zones[config->cur_zone], config->cur_zone, FALSE);
1402 :     }
1403 :     break;
1404 :     }
1405 :    
1406 :     if (n->code == NM_RCLICK) {
1407 :     OutputDebugString("Right click");
1408 :     }
1409 :     break;
1410 :     }
1411 :    
1412 : suxen_drol 889 case WM_COMMAND :
1413 : suxen_drol 1017 if (HIWORD(wParam) == BN_CLICKED) {
1414 : suxen_drol 983
1415 : suxen_drol 1017 switch(LOWORD(wParam)) {
1416 :     case IDC_PROFILE_ADV :
1417 :     main_download(hDlg, config);
1418 :     adv_dialog(hDlg, config, profile_dlgs, sizeof(profile_dlgs)/sizeof(int));
1419 : suxen_drol 889
1420 : suxen_drol 1017 SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0);
1421 :     main_mode(hDlg, config);
1422 :     break;
1423 : suxen_drol 889
1424 : suxen_drol 1017 case IDC_MODE_ADV :
1425 :     main_download(hDlg, config);
1426 :     if (config->mode == RC_MODE_1PASS) {
1427 :     adv_dialog(hDlg, config, single_dlgs, sizeof(single_dlgs)/sizeof(int));
1428 :     }else if (config->mode == RC_MODE_2PASS1) {
1429 :     adv_dialog(hDlg, config, pass1_dlgs, sizeof(pass1_dlgs)/sizeof(int));
1430 :     }else if (config->mode == RC_MODE_2PASS2) {
1431 :     adv_dialog(hDlg, config, pass2_dlgs, sizeof(pass2_dlgs)/sizeof(int));
1432 :     }
1433 :     break;
1434 : suxen_drol 889
1435 : suxen_drol 1061
1436 :     case IDC_BITRATE_S :
1437 :     /* alternate between bitrate/desired_length metrics */
1438 :     main_download(hDlg, config);
1439 :     config->use_2pass_bitrate = !config->use_2pass_bitrate;
1440 :     main_mode(hDlg, config);
1441 :     main_upload(hDlg, config);
1442 :     break;
1443 :    
1444 : suxen_drol 1017 case IDC_BITRATE_CALC :
1445 :     main_download(hDlg, config);
1446 :     adv_dialog(hDlg, config, bitrate_dlgs, sizeof(bitrate_dlgs)/sizeof(int));
1447 :     SetDlgItemInt(hDlg, IDC_BITRATE, config->bitrate, FALSE);
1448 :     main_mode(hDlg, config);
1449 :     break;
1450 : suxen_drol 889
1451 : suxen_drol 1017 case IDC_ADD :
1452 :     {
1453 :     int i, sel, new_frame;
1454 : suxen_drol 889
1455 : suxen_drol 1017 if (config->num_zones >= MAX_ZONES) {
1456 : suxen_drol 1069 MessageBox(hDlg, "Exceeded maximum number of zones.\nIncrease config.h:MAX_ZONES and rebuild.", "Warning", 0);
1457 : suxen_drol 1017 break;
1458 :     }
1459 : suxen_drol 889
1460 : suxen_drol 1017 sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED);
1461 : suxen_drol 889
1462 : suxen_drol 1017 if (sel<0) {
1463 :     if (config->ci_valid && config->ci.ciActiveFrame>0) {
1464 :     for(sel=0; sel<config->num_zones-1 && config->zones[sel].frame<config->ci.ciActiveFrame; sel++) ;
1465 :     sel--;
1466 :     new_frame = config->ci.ciActiveFrame;
1467 :     }else{
1468 :     sel = config->num_zones-1;
1469 : suxen_drol 1069 new_frame = sel<0 ? 0 : config->zones[sel].frame + 1;
1470 : suxen_drol 1017 }
1471 :     }else{
1472 :     new_frame = config->zones[sel].frame + 1;
1473 :     }
1474 :    
1475 :     for(i=config->num_zones-1; i>sel; i--) {
1476 :     config->zones[i+1] = config->zones[i];
1477 :     }
1478 :     config->num_zones++;
1479 :     config->zones[sel+1].frame = new_frame;
1480 :     config->zones[sel+1].mode = RC_ZONE_WEIGHT;
1481 :     config->zones[sel+1].weight = 100;
1482 :     config->zones[sel+1].quant = 500;
1483 : suxen_drol 1069 config->zones[sel+1].type = XVID_TYPE_AUTO;
1484 : suxen_drol 1017 config->zones[sel+1].greyscale = 0;
1485 :     config->zones[sel+1].chroma_opt = 0;
1486 :     config->zones[sel+1].bvop_threshold = 0;
1487 :    
1488 :     ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel, 0x00000000, LVIS_SELECTED);
1489 :     main_insert_zone(GetDlgItem(hDlg, IDC_ZONES), &config->zones[sel+1], sel+1, TRUE);
1490 :     ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel+1, 0xffffffff, LVIS_SELECTED);
1491 :     break;
1492 :     }
1493 :    
1494 :     case IDC_REMOVE :
1495 :     {
1496 :     int i, sel;
1497 :     sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED);
1498 :    
1499 :     if (sel == -1) {
1500 :     MessageBox(hDlg, "Nothing selected", "Warning", 0);
1501 :     break;
1502 :     }
1503 :    
1504 :     for (i=sel; i<config->num_zones-1; i++) {
1505 :     config->zones[i] = config->zones[i+1];
1506 :     }
1507 :     config->num_zones--;
1508 :     ListView_DeleteItem(GetDlgItem(hDlg, IDC_ZONES), sel);
1509 :    
1510 :     sel--;
1511 :     if (sel==0 && config->num_zones>1) {
1512 :     sel=1;
1513 :     }
1514 :     ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel, 0xffffffff, LVIS_SELECTED);
1515 :     break;
1516 :     }
1517 :    
1518 :     case IDC_EDIT :
1519 :     main_download(hDlg, config);
1520 :     config->cur_zone = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED);
1521 :     if (config->cur_zone != -1 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) {
1522 :     main_insert_zone(GetDlgItem(hDlg, IDC_ZONES), &config->zones[config->cur_zone], config->cur_zone, FALSE);
1523 :     }
1524 :     break;
1525 :    
1526 :     case IDC_ADVANCED :
1527 :     main_download(hDlg, config);
1528 :     adv_dialog(hDlg, config, adv_dlgs, sizeof(adv_dlgs)/sizeof(int));
1529 :     break;
1530 :    
1531 :     case IDC_DEFAULTS :
1532 :     config_reg_default(config);
1533 :     main_upload(hDlg, config);
1534 :     break;
1535 :    
1536 :     case IDOK :
1537 :     main_download(hDlg, config);
1538 :     config->save = TRUE;
1539 :     EndDialog(hDlg, IDOK);
1540 :     break;
1541 :    
1542 :     case IDCANCEL :
1543 :     config->save = FALSE;
1544 :     EndDialog(hDlg, IDCANCEL);
1545 :     break;
1546 :     }
1547 :     }else if (HIWORD(wParam) == LBN_SELCHANGE &&
1548 :     (LOWORD(wParam)==IDC_PROFILE || LOWORD(wParam)==IDC_MODE)) {
1549 : suxen_drol 1061
1550 :     main_download(hDlg, config);
1551 : suxen_drol 1017 main_mode(hDlg, config);
1552 : suxen_drol 1061 main_upload(hDlg, config);
1553 :    
1554 : suxen_drol 1017 }else if (HIWORD(wParam)==EN_UPDATE && LOWORD(wParam)==IDC_BITRATE) {
1555 :    
1556 : suxen_drol 1061 if (g_use_bitrate) {
1557 :     SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE,
1558 :     config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) );
1559 :     }
1560 :    
1561 : suxen_drol 1017 }else {
1562 :     return 0;
1563 :     }
1564 : suxen_drol 889 break;
1565 :    
1566 : suxen_drol 1017 case WM_HSCROLL :
1567 :     if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER)) {
1568 :     SetDlgItemInt(hDlg, IDC_BITRATE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE);
1569 :     break;
1570 :     }
1571 :     return 0;
1572 :    
1573 : suxen_drol 889 default :
1574 :     return 0;
1575 :     }
1576 :    
1577 :     return 1;
1578 :     }
1579 :    
1580 :    
1581 :    
1582 : suxen_drol 983 /* ===================================================================================== */
1583 :     /* ABOUT DIALOG ======================================================================== */
1584 :     /* ===================================================================================== */
1585 : suxen_drol 889
1586 :     BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1587 :     {
1588 :     switch (uMsg)
1589 :     {
1590 :     case WM_INITDIALOG :
1591 :     {
1592 :     xvid_gbl_info_t info;
1593 :     char core[100];
1594 :     HFONT hFont;
1595 :     LOGFONT lfData;
1596 :    
1597 :     SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD);
1598 :     SetDlgItemText(hDlg, IDC_SPECIAL_BUILD, XVID_SPECIAL_BUILD);
1599 :    
1600 :     memset(&info, 0, sizeof(info));
1601 :     info.version = XVID_VERSION;
1602 :     xvid_global(0, XVID_GBL_INFO, &info, NULL);
1603 :     wsprintf(core, "libxvidcore version %d.%d.%d (\"%s\")",
1604 : edgomez 1107 XVID_VERSION_MAJOR(info.actual_version),
1605 :     XVID_VERSION_MINOR(info.actual_version),
1606 :     XVID_VERSION_PATCH(info.actual_version),
1607 : suxen_drol 889 info.build);
1608 :    
1609 :     SetDlgItemText(hDlg, IDC_CORE, core);
1610 :    
1611 :     hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L);
1612 :    
1613 : suxen_drol 1017 if (GetObject(hFont, sizeof(LOGFONT), &lfData)) {
1614 : suxen_drol 889 lfData.lfUnderline = 1;
1615 :    
1616 :     hFont = CreateFontIndirect(&lfData);
1617 : suxen_drol 1017 if (hFont) {
1618 : suxen_drol 889 SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L);
1619 :     }
1620 :     }
1621 :    
1622 :     SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));
1623 :     SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE);
1624 :     }
1625 :     break;
1626 :    
1627 :     case WM_CTLCOLORSTATIC :
1628 :     if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE))
1629 :     {
1630 :     SetBkMode((HDC)wParam, TRANSPARENT) ;
1631 :     SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0));
1632 :     return (BOOL)GetStockObject(NULL_BRUSH);
1633 :     }
1634 :     return 0;
1635 :    
1636 :     case WM_COMMAND :
1637 :     if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED)
1638 :     {
1639 :     ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL);
1640 :     }
1641 :     else if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
1642 :     {
1643 :     EndDialog(hDlg, LOWORD(wParam));
1644 :     }
1645 :     break;
1646 :    
1647 :     default :
1648 :     return 0;
1649 :     }
1650 :    
1651 :     return 1;
1652 :     }

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