[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 1277 - (view) (download)

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

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