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

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