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

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