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

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