1 |
/***************************************************************************** |
/************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID VFW FRONTEND |
4 |
* - Configuration processing - |
* config |
|
* |
|
|
* Copyright(C) 2002-2004 Peter Ross <pross@xvid.org> |
|
5 |
* |
* |
6 |
* This program is free software ; you can redistribute it and/or modify |
* 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 |
* it under the terms of the GNU General Public License as published by |
15 |
* |
* |
16 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
* |
20 |
|
*************************************************************************/ |
21 |
|
|
22 |
|
/************************************************************************** |
23 |
|
* |
24 |
|
* History: |
25 |
* |
* |
26 |
* $Id: config.c,v 1.11 2004-07-16 13:52:18 syskin Exp $ |
* 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> |
#include <windows.h> |
59 |
#include <commctrl.h> |
#include <commctrl.h> |
60 |
#include "config.h" |
#include <stdio.h> /* sprintf */ |
61 |
|
#include <xvid.h> /* XviD API */ |
62 |
|
|
63 |
#include "debug.h" |
#include "debug.h" |
64 |
|
#include "config.h" |
65 |
#include "resource.h" |
#include "resource.h" |
66 |
|
|
67 |
|
|
68 |
// ----------------------------------------- |
#define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z; |
69 |
// global config structure |
#define IsDlgChecked(hwnd,idc) (IsDlgButtonChecked(hwnd,idc) == BST_CHECKED) |
70 |
CONFIG g_config; |
#define CheckDlg(hwnd,idc,value) CheckDlgButton(hwnd,idc, value?BST_CHECKED:BST_UNCHECKED) |
71 |
|
#define EnableDlgWindow(hwnd,idc,state) EnableWindow(GetDlgItem(hwnd,idc),state) |
72 |
|
|
73 |
|
static void zones_update(HWND hDlg, CONFIG * config); |
74 |
|
|
75 |
|
HINSTANCE g_hInst; |
76 |
|
HWND g_hTooltip; |
77 |
|
|
78 |
|
static int g_use_bitrate = 1; |
79 |
|
|
80 |
|
|
81 |
|
int pp_brightness, pp_dy, pp_duv, pp_fe, pp_dry, pp_druv; /* decoder options */ |
82 |
|
|
83 |
|
/* enumerates child windows, assigns tooltips */ |
84 |
|
BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam) |
85 |
|
{ |
86 |
|
char help[500]; |
87 |
|
|
88 |
|
if (LoadString(g_hInst, GetDlgCtrlID(hWnd), help, 500)) |
89 |
|
{ |
90 |
|
TOOLINFO ti; |
91 |
|
ti.cbSize = sizeof(TOOLINFO); |
92 |
|
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND; |
93 |
|
ti.hwnd = GetParent(hWnd); |
94 |
|
ti.uId = (LPARAM)hWnd; |
95 |
|
ti.lpszText = help; |
96 |
|
SendMessage(g_hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti); |
97 |
|
} |
98 |
|
|
99 |
|
return TRUE; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
/* ===================================================================================== */ |
104 |
|
/* MPEG-4 PROFILES/LEVELS ============================================================== */ |
105 |
|
/* ===================================================================================== */ |
106 |
|
|
107 |
|
#define DXN_PROFILES |
108 |
|
|
109 |
|
/* default vbv_occupancy is (64/170)*vbv_buffer_size */ |
110 |
|
|
111 |
|
#define PROFILE_S (PROFILE_4MV) |
112 |
|
#define PROFILE_ARTS (PROFILE_4MV|PROFILE_ADAPTQUANT) |
113 |
|
#define PROFILE_AS (PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_MPEGQUANT|PROFILE_INTERLACE|PROFILE_QPEL|PROFILE_GMC) |
114 |
|
|
115 |
|
const profile_t profiles[] = |
116 |
|
{ |
117 |
|
/* name p@l w h fps obj Tvmv vmv vcv ac% vbv pkt bps vbv_peak dbf flags */ |
118 |
|
{ "Simple @ L0", 0x08, 176, 144, 15, 1, 198, 99, 1485, 100, 10*16368, 2048, 64000, 0, -1, PROFILE_S }, |
119 |
|
/* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */ |
120 |
|
/* if ac preidition is used, adaptive quantization must not be used */ |
121 |
|
/* <=qcif must be used */ |
122 |
|
{ "Simple @ L1", 0x01, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 2048, 64000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
123 |
|
{ "Simple @ L2", 0x02, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
124 |
|
{ "Simple @ L3", 0x03, 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
125 |
|
|
126 |
|
#if 0 /* since rrv encoding is no longer support, these profiles have little use */ |
127 |
|
{ "ARTS @ L1", 0x91, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 8192, 64000, 0, -1, PROFILE_ARTS }, |
128 |
|
{ "ARTS @ L2", 0x92, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 16384, 128000, 0, -1, PROFILE_ARTS }, |
129 |
|
{ "ARTS @ L3", 0x93, 352, 288, 30, 4, 792, 396, 11880, 100, 40*16368, 16384, 384000, 0, -1, PROFILE_ARTS }, |
130 |
|
{ "ARTS @ L4", 0x94, 352, 288, 30, 16, 792, 396, 11880, 100, 80*16368, 16384, 2000000, 0, -1, PROFILE_ARTS }, |
131 |
|
#endif |
132 |
|
|
133 |
|
{ "AS @ L0", 0xf0, 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128000, 0, -1, PROFILE_AS }, |
134 |
|
{ "AS @ L1", 0xf1, 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128000, 0, -1, PROFILE_AS }, |
135 |
|
{ "AS @ L2", 0xf2, 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384000, 0, -1, PROFILE_AS }, |
136 |
|
{ "AS @ L3", 0xf3, 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768000, 0, -1, PROFILE_AS }, |
137 |
|
/* ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */ |
138 |
|
{ "AS @ L4", 0xf4, 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000000, 0, -1, PROFILE_AS }, |
139 |
|
{ "AS @ L5", 0xf5, 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000000, 0, -1, PROFILE_AS }, |
140 |
|
|
141 |
|
#ifdef DXN_PROFILES |
142 |
|
// information provided by DivXNetworks, USA. |
143 |
|
// "DivX Certified Profile Compatibility v1.1", February 2005 |
144 |
|
{ "DXN Handheld", 0x00, 176, 144, 15, 1, 198, 99, 1485, 100, 32*8192, -1, 537600, 800000, 0, PROFILE_ADAPTQUANT|PROFILE_DXN }, |
145 |
|
{ "DXN Portable NTSC",0x00, 352, 240, 30, 1, 990, 330, 36000, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_DXN }, |
146 |
|
{ "DXN Portable PAL", 0x00, 352, 288, 25, 1, 1188, 396, 36000, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_DXN }, |
147 |
|
{ "DXN HT NTSC", 0x00, 720, 480, 30, 1, 4050, 1350, 40500, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, |
148 |
|
{ "DXN HT PAL", 0x00, 720, 576, 25, 1, 4860, 1620, 40500, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, |
149 |
|
{ "DXN HDTV", 0x00, 1280, 720, 30, 1,10800, 3600, 108000, 100, 768*8192, -1, 9708400, 16000000, 2, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, |
150 |
|
#endif |
151 |
|
|
152 |
|
{ "(unrestricted)", 0x00, 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, -1, 0, 0, -1, 0xffffffff & ~PROFILE_DXN }, |
153 |
|
}; |
154 |
|
|
155 |
|
|
156 |
|
typedef struct { |
157 |
|
char * name; |
158 |
|
float value; |
159 |
|
} named_float_t; |
160 |
|
|
161 |
|
static const named_float_t video_fps_list[] = { |
162 |
|
{ "15.0", 15.0F }, |
163 |
|
{ "23.976 (FILM)", 23.976F }, |
164 |
|
{ "25.0 (PAL)", 25.0F }, |
165 |
|
{ "29.97 (NTSC)", 29.970F }, |
166 |
|
{ "30.0", 30.0F }, |
167 |
|
{ "50.0 (HD PAL)", 50.0F }, |
168 |
|
{ "59.94 (HD NTSC)", 59.940F }, |
169 |
|
{ "60.0", 60.0F }, |
170 |
|
}; |
171 |
|
|
172 |
|
|
173 |
|
typedef struct { |
174 |
|
char * name; |
175 |
|
int avi_interval; /* audio overhead intervals (milliseconds) */ |
176 |
|
float mkv_multiplier; /* mkv multiplier */ |
177 |
|
} named_int_t; |
178 |
|
|
179 |
|
|
180 |
|
#define NO_AUDIO 7 |
181 |
|
static const named_int_t audio_type_list[] = { |
182 |
|
{ "MP3-CBR", 1000, 48000/1152/6 }, |
183 |
|
{ "MP3-VBR", 24, 48000/1152/6 }, |
184 |
|
{ "OGG", /*?*/1000, 48000*(0.7F/1024 + 0.3F/180) }, |
185 |
|
{ "AC3", 64, 48000/1536/6 }, |
186 |
|
{ "DTS", 21, /*?*/48000/1152/6 }, |
187 |
|
{ "AAC", 21, 48000/1024/6 }, |
188 |
|
{ "HE-AAC", 42, 48000/1024/6 }, |
189 |
|
{ "(None)", 0, 0 }, |
190 |
|
}; |
191 |
|
|
192 |
|
|
193 |
|
/* ===================================================================================== */ |
194 |
|
/* REGISTRY ============================================================================ */ |
195 |
|
/* ===================================================================================== */ |
196 |
|
|
197 |
|
/* registry info structs */ |
198 |
|
CONFIG reg; |
199 |
|
|
200 |
|
static const REG_INT reg_ints[] = { |
201 |
|
{"mode", ®.mode, RC_MODE_1PASS}, |
202 |
|
{"bitrate", ®.bitrate, 700}, |
203 |
|
{"desired_size", ®.desired_size, 570000}, |
204 |
|
{"use_2pass_bitrate", ®.use_2pass_bitrate, 0}, |
205 |
|
{"desired_quant", ®.desired_quant, DEFAULT_QUANT}, /* 100-base float */ |
206 |
|
|
207 |
|
/* profile */ |
208 |
|
{"quant_type", ®.quant_type, 0}, |
209 |
|
{"lum_masking", ®.lum_masking, 0}, |
210 |
|
{"interlacing", ®.interlacing, 0}, |
211 |
|
{"tff", ®.tff, 0}, |
212 |
|
{"qpel", ®.qpel, 0}, |
213 |
|
{"gmc", ®.gmc, 0}, |
214 |
|
{"use_bvop", ®.use_bvop, 1}, |
215 |
|
{"max_bframes", ®.max_bframes, 2}, |
216 |
|
{"bquant_ratio", ®.bquant_ratio, 150}, /* 100-base float */ |
217 |
|
{"bquant_offset", ®.bquant_offset, 100}, /* 100-base float */ |
218 |
|
{"packed", ®.packed, 1}, |
219 |
|
|
220 |
|
/* aspect ratio */ |
221 |
|
{"ar_mode", ®.ar_mode, 0}, |
222 |
|
{"aspect_ratio", ®.display_aspect_ratio, 0}, |
223 |
|
{"par_x", ®.par_x, 1}, |
224 |
|
{"par_y", ®.par_y, 1}, |
225 |
|
{"ar_x", ®.ar_x, 4}, |
226 |
|
{"ar_y", ®.ar_y, 3}, |
227 |
|
|
228 |
|
/* zones */ |
229 |
|
{"num_zones", ®.num_zones, 1}, |
230 |
|
|
231 |
|
/* single pass */ |
232 |
|
{"rc_reaction_delay_factor",®.rc_reaction_delay_factor, 16}, |
233 |
|
{"rc_averaging_period", ®.rc_averaging_period, 100}, |
234 |
|
{"rc_buffer", ®.rc_buffer, 100}, |
235 |
|
|
236 |
|
/* 2pass1 */ |
237 |
|
{"discard1pass", ®.discard1pass, 1}, |
238 |
|
{"full1pass", ®.full1pass, 0}, |
239 |
|
|
240 |
|
/* 2pass2 */ |
241 |
|
{"keyframe_boost", ®.keyframe_boost, 10}, |
242 |
|
{"kfreduction", ®.kfreduction, 20}, |
243 |
|
{"kfthreshold", ®.kfthreshold, 1}, |
244 |
|
{"curve_compression_high", ®.curve_compression_high, 0}, |
245 |
|
{"curve_compression_low", ®.curve_compression_low, 0}, |
246 |
|
{"overflow_control_strength", ®.overflow_control_strength, 5}, |
247 |
|
{"twopass_max_overflow_improvement", ®.twopass_max_overflow_improvement, 5}, |
248 |
|
{"twopass_max_overflow_degradation", ®.twopass_max_overflow_degradation, 5}, |
249 |
|
|
250 |
|
/* bitrate calculator */ |
251 |
|
{"container_type", ®.container_type, 1}, |
252 |
|
{"target_size", ®.target_size, 650 * 1024}, |
253 |
|
{"subtitle_size", ®.subtitle_size, 0}, |
254 |
|
{"hours", ®.hours, 1}, |
255 |
|
{"minutes", ®.minutes, 30}, |
256 |
|
{"seconds", ®.seconds, 0}, |
257 |
|
{"fps", ®.fps, 2}, |
258 |
|
{"audio_mode", ®.audio_mode, 0}, |
259 |
|
{"audio_type", ®.audio_type, 0}, |
260 |
|
{"audio_rate", ®.audio_rate, 128}, |
261 |
|
{"audio_size", ®.audio_size, 0}, |
262 |
|
|
263 |
|
/* motion */ |
264 |
|
{"motion_search", ®.motion_search, 6}, |
265 |
|
{"vhq_mode", ®.vhq_mode, 1}, |
266 |
|
{"vhq_bframe", ®.vhq_bframe, 0}, |
267 |
|
{"chromame", ®.chromame, 1}, |
268 |
|
{"turbo", ®.turbo, 0}, |
269 |
|
{"max_key_interval", ®.max_key_interval, 300}, |
270 |
|
{"frame_drop_ratio", ®.frame_drop_ratio, 0}, |
271 |
|
|
272 |
|
/* quant */ |
273 |
|
{"min_iquant", ®.min_iquant, 1}, |
274 |
|
{"max_iquant", ®.max_iquant, 31}, |
275 |
|
{"min_pquant", ®.min_pquant, 1}, |
276 |
|
{"max_pquant", ®.max_pquant, 31}, |
277 |
|
{"min_bquant", ®.min_bquant, 1}, |
278 |
|
{"max_bquant", ®.max_bquant, 31}, |
279 |
|
{"trellis_quant", ®.trellis_quant, 1}, |
280 |
|
|
281 |
|
/* debug */ |
282 |
|
{"fourcc_used", ®.fourcc_used, 0}, |
283 |
|
{"debug", ®.debug, 0x0}, |
284 |
|
{"vop_debug", ®.vop_debug, 0}, |
285 |
|
{"display_status", ®.display_status, 1}, |
286 |
|
|
287 |
|
/* decoder, shared with dshow */ |
288 |
|
{"Brightness", &pp_brightness, 0}, |
289 |
|
{"Deblock_Y", &pp_dy, 0}, |
290 |
|
{"Deblock_UV", &pp_duv, 0}, |
291 |
|
{"Dering_Y", &pp_dry, 0}, |
292 |
|
{"Dering_UV", &pp_druv, 0}, |
293 |
|
{"FilmEffect", &pp_fe, 0}, |
294 |
|
|
295 |
|
}; |
296 |
|
|
297 |
|
static const REG_STR reg_strs[] = { |
298 |
|
{"profile", reg.profile_name, "(unrestricted)"}, |
299 |
|
{"stats", reg.stats, CONFIG_2PASS_FILE}, |
300 |
|
}; |
301 |
|
|
302 |
|
|
303 |
|
zone_t stmp; |
304 |
|
static const REG_INT reg_zone[] = { |
305 |
|
{"zone%i_frame", &stmp.frame, 0}, |
306 |
|
{"zone%i_mode", &stmp.mode, RC_ZONE_WEIGHT}, |
307 |
|
{"zone%i_weight", &stmp.weight, 100}, /* 100-base float */ |
308 |
|
{"zone%i_quant", &stmp.quant, 500}, /* 100-base float */ |
309 |
|
{"zone%i_type", &stmp.type, XVID_TYPE_AUTO}, |
310 |
|
{"zone%i_greyscale", &stmp.greyscale, 0}, |
311 |
|
{"zone%i_chroma_opt", &stmp.chroma_opt, 0}, |
312 |
|
{"zone%i_bvop_threshold", &stmp.bvop_threshold, 0}, |
313 |
|
{"zone%i_cartoon_mode", &stmp.cartoon_mode, 0}, |
314 |
|
}; |
315 |
|
|
316 |
|
static const BYTE default_qmatrix_intra[] = { |
317 |
|
8, 17,18,19,21,23,25,27, |
318 |
|
17,18,19,21,23,25,27,28, |
319 |
|
20,21,22,23,24,26,28,30, |
320 |
|
21,22,23,24,26,28,30,32, |
321 |
|
22,23,24,26,28,30,32,35, |
322 |
|
23,24,26,28,30,32,35,38, |
323 |
|
25,26,28,30,32,35,38,41, |
324 |
|
27,28,30,32,35,38,41,45 |
325 |
|
}; |
326 |
|
|
327 |
|
static const BYTE default_qmatrix_inter[] = { |
328 |
|
16,17,18,19,20,21,22,23, |
329 |
|
17,18,19,20,21,22,23,24, |
330 |
|
18,19,20,21,22,23,24,25, |
331 |
|
19,20,21,22,23,24,26,27, |
332 |
|
20,21,22,23,25,26,27,28, |
333 |
|
21,22,23,24,26,27,28,30, |
334 |
|
22,23,24,26,27,28,30,31, |
335 |
|
23,24,25,27,28,30,31,33 |
336 |
|
}; |
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
#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)));} |
341 |
|
|
342 |
void LoadRegistryInfo() |
#define XVID_DLL_NAME "xvidcore.dll" |
343 |
|
|
344 |
|
void config_reg_get(CONFIG * config) |
345 |
{ |
{ |
346 |
|
char tmp[32]; |
347 |
HKEY hKey; |
HKEY hKey; |
348 |
DWORD size; |
DWORD size; |
349 |
RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey); |
int i,j; |
350 |
|
xvid_gbl_info_t info; |
351 |
|
HINSTANCE m_hdll; |
352 |
|
|
353 |
|
memset(&info, 0, sizeof(info)); |
354 |
|
info.version = XVID_VERSION; |
355 |
|
|
356 |
|
m_hdll = LoadLibrary(XVID_DLL_NAME); |
357 |
|
if (m_hdll != NULL) { |
358 |
|
|
359 |
|
((int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global")) |
360 |
|
(0, XVID_GBL_INFO, &info, NULL); |
361 |
|
|
362 |
|
FreeLibrary(m_hdll); |
363 |
|
} |
364 |
|
|
365 |
|
reg.cpu = info.cpu_flags; |
366 |
|
reg.num_threads = info.num_threads; |
367 |
|
|
368 |
|
RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey); |
369 |
|
|
370 |
|
/* read integer values */ |
371 |
|
for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) { |
372 |
|
size = sizeof(int); |
373 |
|
if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS) { |
374 |
|
*reg_ints[i].config_int = reg_ints[i].def; |
375 |
|
} |
376 |
|
} |
377 |
|
|
378 |
|
/* read string values */ |
379 |
|
for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) { |
380 |
|
size = MAX_PATH; |
381 |
|
if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS) { |
382 |
|
memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH); |
383 |
|
} |
384 |
|
} |
385 |
|
|
386 |
|
reg.profile = 0; |
387 |
|
for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) { |
388 |
|
if (lstrcmpi(profiles[i].name, reg.profile_name) == 0) { |
389 |
|
reg.profile = i; |
390 |
|
} |
391 |
|
} |
392 |
|
|
393 |
|
memcpy(config, ®, sizeof(CONFIG)); |
394 |
|
|
395 |
|
|
396 |
|
/* read quant matrices */ |
397 |
|
REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra); |
398 |
|
REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter); |
399 |
|
|
400 |
// Set the default post-processing settings |
|
401 |
REG_GET_N("Brightness", g_config.nBrightness, 25) |
/* read zones */ |
402 |
REG_GET_N("Deblock_Y", g_config.nDeblock_Y, 0) |
if (config->num_zones>MAX_ZONES) { |
403 |
REG_GET_N("Deblock_UV", g_config.nDeblock_UV, 0) |
config->num_zones=MAX_ZONES; |
404 |
REG_GET_N("Dering_Y", g_config.nDering_Y, 0) |
}else if (config->num_zones<=0) { |
405 |
REG_GET_N("Dering_UV", g_config.nDering_UV, 0) |
config->num_zones = 1; |
406 |
REG_GET_N("FilmEffect", g_config.nFilmEffect, 0) |
} |
407 |
REG_GET_N("ForceColorspace", g_config.nForceColorspace, 0) |
|
408 |
REG_GET_N("FlipVideo", g_config.nFlipVideo, 0) |
for (i=0; i<config->num_zones; i++) { |
409 |
REG_GET_N("Supported_4CC", g_config.supported_4cc, 0) |
for (j=0; j<sizeof(reg_zone)/sizeof(REG_INT); j++) { |
410 |
REG_GET_N("Videoinfo_Compat", g_config.videoinfo_compat, 0) |
size = sizeof(int); |
411 |
REG_GET_N("Aspect_Ratio", g_config.aspect_ratio, 0) |
|
412 |
|
wsprintf(tmp, reg_zone[j].reg_value, i); |
413 |
|
if (RegQueryValueEx(hKey, tmp, 0, 0, (LPBYTE)reg_zone[j].config_int, &size) != ERROR_SUCCESS) |
414 |
|
*reg_zone[j].config_int = reg_zone[j].def; |
415 |
|
} |
416 |
|
|
417 |
|
memcpy(&config->zones[i], &stmp, sizeof(zone_t)); |
418 |
|
} |
419 |
|
|
420 |
RegCloseKey(hKey); |
RegCloseKey(hKey); |
421 |
} |
} |
422 |
|
|
423 |
void SaveRegistryInfo() |
|
424 |
|
/* put config settings in registry */ |
425 |
|
|
426 |
|
#define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y))) |
427 |
|
|
428 |
|
void config_reg_set(CONFIG * config) |
429 |
{ |
{ |
430 |
|
char tmp[64]; |
431 |
HKEY hKey; |
HKEY hKey; |
432 |
DWORD dispo; |
DWORD dispo; |
433 |
|
int i,j; |
434 |
|
|
435 |
if (RegCreateKeyEx( |
if (RegCreateKeyEx( |
436 |
XVID_REG_KEY, |
XVID_REG_KEY, |
437 |
XVID_REG_SUBKEY, |
XVID_REG_PARENT "\\" XVID_REG_CHILD, |
438 |
0, |
0, |
439 |
XVID_REG_CLASS, |
XVID_REG_CLASS, |
440 |
REG_OPTION_NON_VOLATILE, |
REG_OPTION_NON_VOLATILE, |
443 |
&hKey, |
&hKey, |
444 |
&dispo) != ERROR_SUCCESS) |
&dispo) != ERROR_SUCCESS) |
445 |
{ |
{ |
446 |
OutputDebugString("Couldn't create XVID_REG_SUBKEY"); |
DPRINTF("Couldn't create XVID_REG_SUBKEY - GetLastError=%i", GetLastError()); |
447 |
|
return; |
448 |
|
} |
449 |
|
|
450 |
|
memcpy(®, config, sizeof(CONFIG)); |
451 |
|
|
452 |
|
/* set integer values */ |
453 |
|
for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) { |
454 |
|
RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int)); |
455 |
|
} |
456 |
|
|
457 |
|
/* set string values */ |
458 |
|
strcpy(reg.profile_name, profiles[reg.profile].name); |
459 |
|
for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) { |
460 |
|
RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1); |
461 |
|
} |
462 |
|
|
463 |
|
/* set quant matrices */ |
464 |
|
REG_SET_B("qmatrix_intra", config->qmatrix_intra); |
465 |
|
REG_SET_B("qmatrix_inter", config->qmatrix_inter); |
466 |
|
|
467 |
|
/* set seections */ |
468 |
|
for (i=0; i<config->num_zones; i++) { |
469 |
|
memcpy(&stmp, &config->zones[i], sizeof(zone_t)); |
470 |
|
for (j=0; j<sizeof(reg_zone)/sizeof(REG_INT); j++) { |
471 |
|
wsprintf(tmp, reg_zone[j].reg_value, i); |
472 |
|
RegSetValueEx(hKey, tmp, 0, REG_DWORD, (LPBYTE)reg_zone[j].config_int, sizeof(int)); |
473 |
|
} |
474 |
|
} |
475 |
|
|
476 |
|
RegCloseKey(hKey); |
477 |
|
} |
478 |
|
|
479 |
|
|
480 |
|
/* clear XviD registry key, load defaults */ |
481 |
|
|
482 |
|
static void config_reg_default(CONFIG * config) |
483 |
|
{ |
484 |
|
HKEY hKey; |
485 |
|
|
486 |
|
if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey)) { |
487 |
|
DPRINTF("Couldn't open registry key for deletion - GetLastError=%i", GetLastError()); |
488 |
return; |
return; |
489 |
} |
} |
490 |
|
|
491 |
REG_SET_N("Brightness", g_config.nBrightness); |
if (RegDeleteKey(hKey, XVID_REG_CHILD)) { |
492 |
REG_SET_N("Deblock_Y", g_config.nDeblock_Y); |
DPRINTF("Couldn't delete registry key - GetLastError=%i", GetLastError()); |
493 |
REG_SET_N("Deblock_UV", g_config.nDeblock_UV); |
return; |
494 |
REG_SET_N("Dering_Y", g_config.nDering_Y); |
} |
|
REG_SET_N("Dering_UV", g_config.nDering_UV); |
|
|
REG_SET_N("FilmEffect", g_config.nFilmEffect); |
|
|
REG_SET_N("ForceColorspace", g_config.nForceColorspace); |
|
|
REG_SET_N("FlipVideo", g_config.nFlipVideo); |
|
|
REG_SET_N("Supported_4CC", g_config.supported_4cc); |
|
|
REG_SET_N("Videoinfo_Compat", g_config.videoinfo_compat); |
|
|
REG_SET_N("Aspect_Ratio", g_config.aspect_ratio); |
|
495 |
|
|
496 |
RegCloseKey(hKey); |
RegCloseKey(hKey); |
497 |
|
config_reg_get(config); |
498 |
|
config_reg_set(config); |
499 |
|
} |
500 |
|
|
501 |
|
|
502 |
|
/* leaves current config value if dialog item is empty */ |
503 |
|
static int config_get_int(HWND hDlg, INT item, int config) |
504 |
|
{ |
505 |
|
BOOL success = FALSE; |
506 |
|
int tmp = GetDlgItemInt(hDlg, item, &success, TRUE); |
507 |
|
return (success) ? tmp : config; |
508 |
} |
} |
509 |
|
|
510 |
|
|
511 |
|
static int config_get_uint(HWND hDlg, UINT item, int config) |
512 |
|
{ |
513 |
|
BOOL success = FALSE; |
514 |
|
int tmp = GetDlgItemInt(hDlg, item, &success, FALSE); |
515 |
|
return (success) ? tmp : config; |
516 |
|
} |
517 |
|
|
518 |
BOOL CALLBACK adv_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
/* get uint from combobox |
519 |
|
GetDlgItemInt doesnt work properly for cb list items */ |
520 |
|
#define UINT_BUF_SZ 20 |
521 |
|
static int config_get_cbuint(HWND hDlg, UINT item, int def) |
522 |
{ |
{ |
523 |
HWND hBrightness; |
int sel = SendMessage(GetDlgItem(hDlg, item), CB_GETCURSEL, 0, 0); |
524 |
|
char buf[UINT_BUF_SZ]; |
525 |
|
|
526 |
switch ( uMsg ) |
if (sel<0) { |
527 |
|
return config_get_uint(hDlg, item, def); |
528 |
|
} |
529 |
|
|
530 |
|
if (SendMessage(GetDlgItem(hDlg, item), CB_GETLBTEXT, sel, (LPARAM)buf) == CB_ERR) { |
531 |
|
return def; |
532 |
|
} |
533 |
|
|
534 |
|
return atoi(buf); |
535 |
|
} |
536 |
|
|
537 |
|
|
538 |
|
/* we use "100 base" floats */ |
539 |
|
|
540 |
|
#define FLOAT_BUF_SZ 20 |
541 |
|
static int get_dlgitem_float(HWND hDlg, UINT item, int def) |
542 |
{ |
{ |
543 |
case WM_DESTROY: |
char buf[FLOAT_BUF_SZ]; |
544 |
|
|
545 |
|
if (GetDlgItemText(hDlg, item, buf, FLOAT_BUF_SZ) == 0) |
546 |
|
return def; |
547 |
|
|
548 |
|
return (int)(atof(buf)*100); |
549 |
|
} |
550 |
|
|
551 |
|
static void set_dlgitem_float(HWND hDlg, UINT item, int value) |
552 |
{ |
{ |
553 |
int nForceColorspace; |
char buf[FLOAT_BUF_SZ]; |
554 |
int aspect_ratio; |
sprintf(buf, "%.2f", (float)value/100); |
555 |
|
SetDlgItemText(hDlg, item, buf); |
556 |
|
} |
557 |
|
|
558 |
nForceColorspace = SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_GETCURSEL, 0, 0); |
static void set_dlgitem_float1000(HWND hDlg, UINT item, int value) |
|
if ( g_config.nForceColorspace != nForceColorspace ) |
|
559 |
{ |
{ |
560 |
MessageBox(0, "You have changed the output colorspace.\r\nClose the movie and open it for the new colorspace to take effect.", "XviD DShow", MB_TOPMOST); |
char buf[FLOAT_BUF_SZ]; |
561 |
|
sprintf(buf, "%.3f", (float)value/1000); |
562 |
|
SetDlgItemText(hDlg, item, buf); |
563 |
} |
} |
|
g_config.nForceColorspace = nForceColorspace; |
|
564 |
|
|
565 |
aspect_ratio = SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_GETCURSEL, 0, 0); |
#define HEX_BUF_SZ 16 |
566 |
if ( g_config.aspect_ratio != aspect_ratio ) |
static unsigned int get_dlgitem_hex(HWND hDlg, UINT item, unsigned int def) |
567 |
{ |
{ |
568 |
MessageBox(0, "You have changed the default aspect ratio.\r\nClose the movie and open it for the new aspect ratio to take effect.", "XviD DShow", MB_TOPMOST); |
char buf[HEX_BUF_SZ]; |
569 |
|
unsigned int value; |
570 |
|
|
571 |
|
if (GetDlgItemText(hDlg, item, buf, HEX_BUF_SZ) == 0) |
572 |
|
return def; |
573 |
|
|
574 |
|
if (sscanf(buf,"0x%x", &value)==1 || sscanf(buf,"%x", &value)==1) { |
575 |
|
return value; |
576 |
} |
} |
577 |
g_config.aspect_ratio = aspect_ratio; |
|
578 |
SaveRegistryInfo(); |
return def; |
579 |
} |
} |
|
break; |
|
580 |
|
|
581 |
case WM_INITDIALOG: |
static void set_dlgitem_hex(HWND hDlg, UINT item, int value) |
582 |
|
{ |
583 |
|
char buf[HEX_BUF_SZ]; |
584 |
|
wsprintf(buf, "0x%x", value); |
585 |
|
SetDlgItemText(hDlg, item, buf); |
586 |
|
} |
587 |
|
|
588 |
|
/* ===================================================================================== */ |
589 |
|
/* QUANT MATRIX DIALOG ================================================================= */ |
590 |
|
/* ===================================================================================== */ |
591 |
|
|
592 |
|
static void quant_upload(HWND hDlg, CONFIG* config) |
593 |
|
{ |
594 |
|
int i; |
595 |
|
|
596 |
|
for (i=0 ; i<64; i++) { |
597 |
|
SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE); |
598 |
|
SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE); |
599 |
|
} |
600 |
|
} |
601 |
|
|
602 |
|
|
603 |
|
static void quant_download(HWND hDlg, CONFIG* config) |
604 |
|
{ |
605 |
|
int i; |
606 |
|
|
607 |
|
for (i=0; i<64; i++) { |
608 |
|
int temp; |
609 |
|
|
610 |
|
temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]); |
611 |
|
CONSTRAINVAL(temp, 1, 255); |
612 |
|
config->qmatrix_intra[i] = temp; |
613 |
|
|
614 |
|
temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]); |
615 |
|
CONSTRAINVAL(temp, 1, 255); |
616 |
|
config->qmatrix_inter[i] = temp; |
617 |
|
} |
618 |
|
} |
619 |
|
|
620 |
|
|
621 |
|
static void quant_loadsave(HWND hDlg, CONFIG * config, int save) |
622 |
|
{ |
623 |
|
char file[MAX_PATH]; |
624 |
|
OPENFILENAME ofn; |
625 |
|
HANDLE hFile; |
626 |
|
DWORD read=128, wrote=0; |
627 |
|
BYTE quant_data[128]; |
628 |
|
|
629 |
|
strcpy(file, "\\matrix"); |
630 |
|
memset(&ofn, 0, sizeof(OPENFILENAME)); |
631 |
|
ofn.lStructSize = sizeof(OPENFILENAME); |
632 |
|
|
633 |
|
ofn.hwndOwner = hDlg; |
634 |
|
ofn.lpstrFilter = "All files (*.*)\0*.*\0\0"; |
635 |
|
ofn.lpstrFile = file; |
636 |
|
ofn.nMaxFile = MAX_PATH; |
637 |
|
ofn.Flags = OFN_PATHMUSTEXIST; |
638 |
|
|
639 |
|
if (save) { |
640 |
|
ofn.Flags |= OFN_OVERWRITEPROMPT; |
641 |
|
if (GetSaveFileName(&ofn)) { |
642 |
|
hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); |
643 |
|
|
644 |
|
quant_download(hDlg, config); |
645 |
|
memcpy(quant_data, config->qmatrix_intra, 64); |
646 |
|
memcpy(quant_data+64, config->qmatrix_inter, 64); |
647 |
|
|
648 |
|
if (hFile == INVALID_HANDLE_VALUE) { |
649 |
|
DPRINTF("Couldn't save quant matrix"); |
650 |
|
}else{ |
651 |
|
if (!WriteFile(hFile, quant_data, 128, &wrote, 0)) { |
652 |
|
DPRINTF("Couldnt write quant matrix"); |
653 |
|
} |
654 |
|
} |
655 |
|
CloseHandle(hFile); |
656 |
|
} |
657 |
|
}else{ |
658 |
|
ofn.Flags |= OFN_FILEMUSTEXIST; |
659 |
|
if (GetOpenFileName(&ofn)) { |
660 |
|
hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); |
661 |
|
|
662 |
|
if (hFile == INVALID_HANDLE_VALUE) { |
663 |
|
DPRINTF("Couldn't load quant matrix"); |
664 |
|
} else { |
665 |
|
if (!ReadFile(hFile, quant_data, 128, &read, 0)) { |
666 |
|
DPRINTF("Couldnt read quant matrix"); |
667 |
|
}else{ |
668 |
|
memcpy(config->qmatrix_intra, quant_data, 64); |
669 |
|
memcpy(config->qmatrix_inter, quant_data+64, 64); |
670 |
|
quant_upload(hDlg, config); |
671 |
|
} |
672 |
|
} |
673 |
|
CloseHandle(hFile); |
674 |
|
} |
675 |
|
} |
676 |
|
} |
677 |
|
|
678 |
// Load Force Colorspace Box |
/* quantization matrix dialog proc */ |
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"No Force"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YV12"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YUY2"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB24"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB32"); |
|
|
|
|
|
// Select Colorspace |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0); |
|
|
|
|
|
hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS); |
|
|
SendMessage(hBrightness, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(-96, 96)); |
|
|
SendMessage(hBrightness, TBM_SETTICFREQ, (WPARAM)16, (LPARAM)0); |
|
|
SendMessage(hBrightness, TBM_SETPOS, (WPARAM)TRUE, (LPARAM) g_config.nBrightness); |
|
|
|
|
|
// Load Aspect Ratio Box |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"Auto (mpeg-4 first)"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"Auto (external first)"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"4:3"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"16:9"); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"2.35:1"); |
|
|
|
|
|
// Select Aspect Ratio |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0); |
|
|
|
|
|
|
|
|
// Load Buttons |
|
|
SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0); |
|
|
|
|
|
// 4CC checkbuttons |
|
|
SendMessage(GetDlgItem(hwnd, IDC_DIVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DIVX, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_DX50), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DX50, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_MP4V), BM_SETCHECK, g_config.supported_4cc & SUPPORT_MP4V, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COMPAT), BM_SETCHECK, g_config.videoinfo_compat, 0); |
|
679 |
|
|
680 |
EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y); |
static BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
681 |
EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV); |
{ |
682 |
|
CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); |
683 |
|
|
684 |
EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat); |
switch (uMsg) |
685 |
|
{ |
686 |
|
case WM_INITDIALOG : |
687 |
|
SetWindowLong(hDlg, GWL_USERDATA, lParam); |
688 |
|
config = (CONFIG*)lParam; |
689 |
|
quant_upload(hDlg, config); |
690 |
|
|
691 |
// Set Date & Time of Compilation |
if (g_hTooltip) |
692 |
DPRINTF("(%s %s)", __DATE__, __TIME__); |
{ |
693 |
|
EnumChildWindows(hDlg, enum_tooltips, 0); |
694 |
|
} |
695 |
break; |
break; |
696 |
|
|
697 |
case WM_COMMAND: |
case WM_COMMAND: |
698 |
switch ( wParam ) |
|
699 |
{ |
if (HIWORD(wParam) == BN_CLICKED) { |
700 |
case IDC_RESET: |
switch(LOWORD(wParam)) { |
701 |
ZeroMemory(&g_config, sizeof(CONFIG)); |
case IDOK : |
702 |
hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS); |
quant_download(hDlg, config); |
703 |
SendMessage(hBrightness, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) g_config.nBrightness); |
EndDialog(hDlg, IDOK); |
704 |
// Load Buttons |
break; |
705 |
SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0); |
|
706 |
SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0); |
case IDCANCEL : |
707 |
SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0); |
EndDialog(hDlg, IDCANCEL); |
|
SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0); |
|
|
SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0); |
|
|
g_config.nForceColorspace = 0; |
|
|
SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0); |
|
|
g_config.aspect_ratio = 0; |
|
|
SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0); |
|
|
break; |
|
|
case IDC_DEBLOCK_Y: |
|
|
g_config.nDeblock_Y = !g_config.nDeblock_Y; |
|
|
break; |
|
|
case IDC_DEBLOCK_UV: |
|
|
g_config.nDeblock_UV = !g_config.nDeblock_UV; |
|
|
break; |
|
|
case IDC_DERINGY: |
|
|
g_config.nDering_Y = !g_config.nDering_Y; |
|
|
break; |
|
|
case IDC_DERINGUV: |
|
|
g_config.nDering_UV = !g_config.nDering_UV; |
|
|
break; |
|
|
case IDC_FILMEFFECT: |
|
|
g_config.nFilmEffect = !g_config.nFilmEffect; |
|
|
break; |
|
|
case IDC_FLIPVIDEO: |
|
|
g_config.nFlipVideo = !g_config.nFlipVideo; |
|
|
break; |
|
|
case IDC_DIVX: |
|
|
g_config.supported_4cc ^= SUPPORT_DIVX; |
|
708 |
break; |
break; |
709 |
case IDC_DX50: |
|
710 |
g_config.supported_4cc ^= SUPPORT_DX50; |
case IDC_SAVE : |
711 |
|
quant_loadsave(hDlg, config, 1); |
712 |
break; |
break; |
713 |
case IDC_MP4V: |
|
714 |
g_config.supported_4cc ^= SUPPORT_MP4V; |
case IDC_LOAD : |
715 |
|
quant_loadsave(hDlg, config, 0); |
716 |
break; |
break; |
717 |
case IDC_COMPAT: |
|
718 |
g_config.videoinfo_compat = !g_config.videoinfo_compat; |
default : |
719 |
|
return FALSE; |
720 |
|
} |
721 |
break; |
break; |
722 |
|
} |
723 |
|
return FALSE; |
724 |
|
|
725 |
default : |
default : |
726 |
return FALSE; |
return FALSE; |
727 |
} |
} |
|
EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y); |
|
|
EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV); |
|
728 |
|
|
729 |
EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat); |
return TRUE; |
730 |
|
} |
731 |
|
|
732 |
|
|
733 |
|
/* ===================================================================================== */ |
734 |
|
/* ADVANCED DIALOG PAGES ================================================================ */ |
735 |
|
/* ===================================================================================== */ |
736 |
|
|
737 |
SaveRegistryInfo(); |
/* initialise pages */ |
738 |
|
static void adv_init(HWND hDlg, int idd, CONFIG * config) |
739 |
|
{ |
740 |
|
unsigned int i; |
741 |
|
|
742 |
|
switch(idd) { |
743 |
|
case IDD_PROFILE : |
744 |
|
for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) |
745 |
|
SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name); |
746 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263"); |
747 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG"); |
748 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom"); |
749 |
|
break; |
750 |
|
|
751 |
|
case IDD_AR: |
752 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"Square (default)"); |
753 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"4:3 PAL"); |
754 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"4:3 NTSC"); |
755 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"16:9 PAL"); |
756 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"16:9 NTSC"); |
757 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"Custom..."); |
758 |
break; |
break; |
759 |
case WM_NOTIFY: |
|
760 |
hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS); |
case IDD_LEVEL : |
761 |
g_config.nBrightness = SendMessage(hBrightness, TBM_GETPOS, (WPARAM)NULL, (LPARAM)NULL); |
for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) |
762 |
SaveRegistryInfo(); |
SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name); |
763 |
break; |
break; |
764 |
default : |
|
765 |
return FALSE; |
case IDD_BITRATE : |
766 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_ADDSTRING, 0, (LPARAM)"AVI-Legacy"); |
767 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_ADDSTRING, 0, (LPARAM)"AVI-OpenDML"); |
768 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_ADDSTRING, 0, (LPARAM)"Matroska"); |
769 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_ADDSTRING, 0, (LPARAM)"OGM"); |
770 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_ADDSTRING, 0, (LPARAM)"(None)"); |
771 |
|
|
772 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_TSIZE, CB_ADDSTRING, 0, (LPARAM)"665600"); |
773 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_TSIZE, CB_ADDSTRING, 0, (LPARAM)"716800"); |
774 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_TSIZE, CB_ADDSTRING, 0, (LPARAM)"1331200"); |
775 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_TSIZE, CB_ADDSTRING, 0, (LPARAM)"1433600"); |
776 |
|
|
777 |
|
for (i=0; i<sizeof(video_fps_list)/sizeof(named_float_t); i++) |
778 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_FPS, CB_ADDSTRING, 0, (LPARAM)video_fps_list[i].name); |
779 |
|
|
780 |
|
for (i=0; i<sizeof(audio_type_list)/sizeof(named_int_t); i++) |
781 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_AFORMAT, CB_ADDSTRING, 0, (LPARAM)audio_type_list[i].name); |
782 |
|
|
783 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"32"); |
784 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"56"); |
785 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"64"); |
786 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"96"); |
787 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"112"); |
788 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"128"); |
789 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"160"); |
790 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"192"); |
791 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"224"); |
792 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"256"); |
793 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"384"); |
794 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"448"); |
795 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_ARATE, CB_ADDSTRING, 0, (LPARAM)"512"); |
796 |
|
break; |
797 |
|
|
798 |
|
case IDD_ZONE : |
799 |
|
EnableDlgWindow(hDlg, IDC_ZONE_FETCH, config->ci_valid); |
800 |
|
break; |
801 |
|
|
802 |
|
case IDD_MOTION : |
803 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None"); |
804 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low"); |
805 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low"); |
806 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium"); |
807 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High"); |
808 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High"); |
809 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High"); |
810 |
|
|
811 |
|
SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"0 - Off"); |
812 |
|
SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"1 - Mode Decision"); |
813 |
|
SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"2 - Limited Search"); |
814 |
|
SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"3 - Medium Search"); |
815 |
|
SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"4 - Wide Search"); |
816 |
|
break; |
817 |
|
|
818 |
|
case IDD_DEBUG : |
819 |
|
/* force threads disabled */ |
820 |
|
EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE); |
821 |
|
EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE); |
822 |
|
|
823 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID"); |
824 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX"); |
825 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50"); |
826 |
|
break; |
827 |
|
|
828 |
|
case IDD_DEC : |
829 |
|
SendDlgItemMessage(hDlg, IDC_DEC_BRIGHTNESS, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(-96, 96)); |
830 |
|
SendDlgItemMessage(hDlg, IDC_DEC_BRIGHTNESS, TBM_SETTICFREQ, (WPARAM)16, (LPARAM)0); |
831 |
|
break; |
832 |
|
} |
833 |
|
} |
834 |
|
|
835 |
|
|
836 |
|
/* enable/disable controls based on encoder-mode or user selection */ |
837 |
|
|
838 |
|
static void adv_mode(HWND hDlg, int idd, CONFIG * config) |
839 |
|
{ |
840 |
|
int profile; |
841 |
|
int weight_en, quant_en; |
842 |
|
int cpu_force; |
843 |
|
int custom_quant, bvops; |
844 |
|
int ar_mode, ar_par; |
845 |
|
|
846 |
|
switch(idd) { |
847 |
|
case IDD_PROFILE : |
848 |
|
profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0); |
849 |
|
EnableDlgWindow(hDlg, IDC_BVOP, profiles[profile].flags&PROFILE_BVOP); |
850 |
|
|
851 |
|
EnableDlgWindow(hDlg, IDC_QUANTTYPE_S, profiles[profile].flags&PROFILE_MPEGQUANT); |
852 |
|
EnableDlgWindow(hDlg, IDC_QUANTTYPE_S, profiles[profile].flags&PROFILE_MPEGQUANT); |
853 |
|
EnableDlgWindow(hDlg, IDC_QUANTTYPE, profiles[profile].flags&PROFILE_MPEGQUANT); |
854 |
|
custom_quant = (profiles[profile].flags&PROFILE_MPEGQUANT) && SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0)==QUANT_MODE_CUSTOM; |
855 |
|
EnableDlgWindow(hDlg, IDC_QUANTMATRIX, custom_quant); |
856 |
|
EnableDlgWindow(hDlg, IDC_LUMMASK, profiles[profile].flags&PROFILE_ADAPTQUANT); |
857 |
|
EnableDlgWindow(hDlg, IDC_INTERLACING, profiles[profile].flags&PROFILE_INTERLACE); |
858 |
|
EnableDlgWindow(hDlg, IDC_TFF, IsDlgChecked(hDlg, IDC_INTERLACING)); |
859 |
|
EnableDlgWindow(hDlg, IDC_QPEL, profiles[profile].flags&PROFILE_QPEL); |
860 |
|
EnableDlgWindow(hDlg, IDC_GMC, profiles[profile].flags&PROFILE_GMC); |
861 |
|
|
862 |
|
bvops = (profiles[profile].flags&PROFILE_BVOP) && IsDlgChecked(hDlg, IDC_BVOP); |
863 |
|
EnableDlgWindow(hDlg, IDC_MAXBFRAMES, bvops); |
864 |
|
EnableDlgWindow(hDlg, IDC_BQUANTRATIO, bvops); |
865 |
|
EnableDlgWindow(hDlg, IDC_BQUANTOFFSET, bvops); |
866 |
|
EnableDlgWindow(hDlg, IDC_MAXBFRAMES_S, bvops); |
867 |
|
EnableDlgWindow(hDlg, IDC_BQUANTRATIO_S, bvops); |
868 |
|
EnableDlgWindow(hDlg, IDC_BQUANTOFFSET_S, bvops); |
869 |
|
EnableDlgWindow(hDlg, IDC_PACKED, bvops && !(profiles[profile].flags & PROFILE_DXN)); |
870 |
|
break; |
871 |
|
|
872 |
|
case IDD_AR: |
873 |
|
ar_mode = IsDlgChecked(hDlg, IDC_PAR); |
874 |
|
EnableDlgWindow(hDlg, IDC_ASPECT_RATIO, ar_mode); |
875 |
|
|
876 |
|
ar_par = SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_GETCURSEL, 0, 0); |
877 |
|
if (ar_par == 5) { /* custom par */ |
878 |
|
SetDlgItemInt(hDlg, IDC_PARY, config->par_y, FALSE); |
879 |
|
SetDlgItemInt(hDlg, IDC_PARX, config->par_x, FALSE); |
880 |
|
|
881 |
|
EnableDlgWindow(hDlg, IDC_PARX, ar_mode); |
882 |
|
EnableDlgWindow(hDlg, IDC_PARY, ar_mode); |
883 |
|
} else { |
884 |
|
SetDlgItemInt(hDlg, IDC_PARX, PARS[ar_par][0], FALSE); |
885 |
|
SetDlgItemInt(hDlg, IDC_PARY, PARS[ar_par][1], FALSE); |
886 |
|
EnableDlgWindow(hDlg, IDC_PARX, FALSE); |
887 |
|
EnableDlgWindow(hDlg, IDC_PARY, FALSE); |
888 |
|
} |
889 |
|
|
890 |
|
ar_mode = IsDlgChecked(hDlg, IDC_AR); |
891 |
|
|
892 |
|
config->ar_x = config_get_uint(hDlg, IDC_ARX, config->ar_x); |
893 |
|
config->ar_y = config_get_uint(hDlg, IDC_ARY, config->ar_y); |
894 |
|
|
895 |
|
EnableDlgWindow(hDlg, IDC_ARX, ar_mode); |
896 |
|
EnableDlgWindow(hDlg, IDC_ARY, ar_mode); |
897 |
|
break; |
898 |
|
|
899 |
|
case IDD_LEVEL : |
900 |
|
profile = SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_GETCURSEL, 0, 0); |
901 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_WIDTH, profiles[profile].width, FALSE); |
902 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_HEIGHT, profiles[profile].height, FALSE); |
903 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_FPS, profiles[profile].fps, FALSE); |
904 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_VMV, profiles[profile].max_vmv_buffer_sz, FALSE); |
905 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_VCV, profiles[profile].vcv_decoder_rate, FALSE); |
906 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_VBV, profiles[profile].max_vbv_size, FALSE); |
907 |
|
set_dlgitem_float1000(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate); |
908 |
|
SetDlgItemInt(hDlg, IDC_LEVEL_PEAKRATE, profiles[profile].vbv_peakrate, FALSE); |
909 |
|
|
910 |
|
{ |
911 |
|
int en_dim = profiles[profile].width && profiles[profile].height; |
912 |
|
int en_vmv = profiles[profile].max_vmv_buffer_sz; |
913 |
|
int en_vcv = profiles[profile].vcv_decoder_rate; |
914 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_LEVEL_G, en_dim || en_vmv || en_vcv); |
915 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_DIM_S, en_dim); |
916 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_WIDTH, en_dim); |
917 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_HEIGHT,en_dim); |
918 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_FPS, en_dim); |
919 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VMV_S, en_vmv); |
920 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VMV, en_vmv); |
921 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VCV_S, en_vcv); |
922 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VCV, en_vcv); |
923 |
|
} |
924 |
|
{ |
925 |
|
int en_vbv = profiles[profile].max_vbv_size; |
926 |
|
int en_br = profiles[profile].max_bitrate; |
927 |
|
int en_pr = profiles[profile].vbv_peakrate; |
928 |
|
|
929 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VBV_G, en_vbv || en_br || en_pr); |
930 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VBV_S, en_vbv); |
931 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_VBV, en_vbv); |
932 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_BITRATE_S, en_br); |
933 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_BITRATE, en_br); |
934 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_PEAKRATE_S, en_pr); |
935 |
|
EnableDlgWindow(hDlg, IDC_LEVEL_PEAKRATE, en_pr); |
936 |
|
} |
937 |
|
break; |
938 |
|
|
939 |
|
case IDD_BITRATE : |
940 |
|
{ |
941 |
|
int ctype = SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_GETCURSEL, 0, 0); |
942 |
|
int target_size = config_get_cbuint(hDlg, IDC_BITRATE_TSIZE, 0); |
943 |
|
int subtitle_size = config_get_uint(hDlg, IDC_BITRATE_SSIZE, 0); |
944 |
|
int fps = SendDlgItemMessage(hDlg, IDC_BITRATE_FPS, CB_GETCURSEL, 0, 0); |
945 |
|
|
946 |
|
int duration = |
947 |
|
3600 * config_get_uint(hDlg, IDC_BITRATE_HOURS, 0) + |
948 |
|
60 * config_get_uint(hDlg, IDC_BITRATE_MINUTES, 0) + |
949 |
|
config_get_uint(hDlg, IDC_BITRATE_SECONDS, 0); |
950 |
|
|
951 |
|
int audio_type = SendDlgItemMessage(hDlg, IDC_BITRATE_AFORMAT, CB_GETCURSEL, 0, 0); |
952 |
|
int audio_mode = IsDlgChecked(hDlg, IDC_BITRATE_AMODE_SIZE); |
953 |
|
int audio_rate = config_get_cbuint(hDlg, IDC_BITRATE_ARATE, 0); |
954 |
|
int audio_size = config_get_uint(hDlg, IDC_BITRATE_ASIZE, 0); |
955 |
|
|
956 |
|
int frames; |
957 |
|
int overhead; |
958 |
|
int vsize; |
959 |
|
|
960 |
|
if (duration == 0) |
961 |
|
break; |
962 |
|
|
963 |
|
if (fps < 0 || fps >= sizeof(video_fps_list)/sizeof(named_float_t)) { |
964 |
|
fps = 0; |
965 |
|
} |
966 |
|
if (audio_type < 0 || audio_type >= sizeof(audio_type_list)/sizeof(named_int_t)) { |
967 |
|
audio_type = 0; |
968 |
|
} |
969 |
|
|
970 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_AMODE_RATE, audio_type!=NO_AUDIO); |
971 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_AMODE_SIZE, audio_type!=NO_AUDIO); |
972 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_ARATE, audio_type!=NO_AUDIO && !audio_mode); |
973 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_ASIZE, audio_type!=NO_AUDIO && audio_mode); |
974 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_ASELECT, audio_type!=NO_AUDIO && audio_mode); |
975 |
|
|
976 |
|
/* step 1: calculate number of frames */ |
977 |
|
frames = (int)(duration * video_fps_list[fps].value); |
978 |
|
|
979 |
|
/* step 2: calculate audio_size (kbytes)*/ |
980 |
|
if (audio_type!=NO_AUDIO) { |
981 |
|
if (audio_mode==0) { |
982 |
|
int new_audio_size = (int)( (1000.0 * duration * audio_rate) / (8.0*1024) ); |
983 |
|
|
984 |
|
/* this check is needed to avoid a loop */ |
985 |
|
if (new_audio_size!=audio_size) { |
986 |
|
audio_size = new_audio_size; |
987 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_ASIZE, new_audio_size, TRUE); |
988 |
|
} |
989 |
|
}else{ |
990 |
|
int tmp_rate = (int)( (audio_size * 8.0 * 1024) / (1000.0 * duration) ); |
991 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_ARATE, tmp_rate, TRUE); |
992 |
|
} |
993 |
|
}else{ |
994 |
|
audio_size = 0; |
995 |
|
} |
996 |
|
|
997 |
|
/* step 3: calculate container overhead */ |
998 |
|
|
999 |
|
switch(ctype) { |
1000 |
|
case 0 : /* AVI */ |
1001 |
|
case 1 : /* AVI-OpenDML */ |
1002 |
|
|
1003 |
|
overhead = frames; |
1004 |
|
|
1005 |
|
if (audio_type!=NO_AUDIO) { |
1006 |
|
overhead += (duration * 1000) / audio_type_list[audio_type].avi_interval; |
1007 |
|
} |
1008 |
|
|
1009 |
|
overhead *= (ctype==0) ? 24 : 16; |
1010 |
|
|
1011 |
|
overhead /= 1024; |
1012 |
|
break; |
1013 |
|
|
1014 |
|
case 2 : /* Matroska: gknot formula */ |
1015 |
|
|
1016 |
|
/* common overhead */ |
1017 |
|
overhead = 40 + 12 + 8+ 16*duration + 200 + 100*1/*one audio stream*/ + 11*duration; |
1018 |
|
|
1019 |
|
/* video overhead */ |
1020 |
|
overhead += frames*8 + (int)(frames * 4 * 0.94); |
1021 |
|
|
1022 |
|
/* cue tables and menu seek entries (300k default) */ |
1023 |
|
overhead += 300 * 1024; |
1024 |
|
|
1025 |
|
/* audio */ |
1026 |
|
overhead += (int)(duration * audio_type_list[audio_type].mkv_multiplier); |
1027 |
|
|
1028 |
|
overhead /= 1024; |
1029 |
|
break; |
1030 |
|
|
1031 |
|
case 3 : /* alexnoe formula */ |
1032 |
|
overhead = (int)( (target_size - subtitle_size) * (28.0/4224.0 + (1.0/255.0)) ); |
1033 |
|
break; |
1034 |
|
|
1035 |
|
default : /* (none) */ |
1036 |
|
overhead = 0; |
1037 |
|
break; |
1038 |
|
} |
1039 |
|
|
1040 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_COVERHEAD, overhead, TRUE); |
1041 |
|
|
1042 |
|
/* final video bitstream size */ |
1043 |
|
vsize = target_size - subtitle_size - audio_size - overhead; |
1044 |
|
if (vsize > 0) { |
1045 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_VSIZE, vsize, TRUE); |
1046 |
|
/* convert from kbytes to kbits-per-second */ |
1047 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_VRATE, (int)(((__int64)vsize * 8 * 128) / (duration * 125)), TRUE); |
1048 |
|
}else{ |
1049 |
|
SetDlgItemText(hDlg, IDC_BITRATE_VSIZE, "Overflow"); |
1050 |
|
SetDlgItemText(hDlg, IDC_BITRATE_VRATE, "Overflow"); |
1051 |
|
} |
1052 |
|
|
1053 |
|
} |
1054 |
|
break; |
1055 |
|
|
1056 |
|
case IDD_ZONE : |
1057 |
|
weight_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT); |
1058 |
|
quant_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT); |
1059 |
|
EnableDlgWindow(hDlg, IDC_ZONE_WEIGHT, weight_en); |
1060 |
|
EnableDlgWindow(hDlg, IDC_ZONE_QUANT, quant_en); |
1061 |
|
EnableDlgWindow(hDlg, IDC_ZONE_SLIDER, weight_en|quant_en); |
1062 |
|
|
1063 |
|
if (weight_en) { |
1064 |
|
SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(001,200)); |
1065 |
|
SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, 100)); |
1066 |
|
SetDlgItemText(hDlg, IDC_ZONE_MIN, "0.01"); |
1067 |
|
SetDlgItemText(hDlg, IDC_ZONE_MAX, "2.00"); |
1068 |
|
}else if (quant_en) { |
1069 |
|
SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(100,3100)); |
1070 |
|
SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_ZONE_QUANT, 100)); |
1071 |
|
SetDlgItemText(hDlg, IDC_ZONE_MIN, "1"); |
1072 |
|
SetDlgItemText(hDlg, IDC_ZONE_MAX, "31"); |
1073 |
} |
} |
1074 |
|
|
1075 |
return TRUE; /* ok */ |
bvops = (profiles[config->profile].flags&PROFILE_BVOP) && config->use_bvop; |
1076 |
|
EnableDlgWindow(hDlg, IDC_ZONE_BVOPTHRESHOLD_S, bvops); |
1077 |
|
EnableDlgWindow(hDlg, IDC_ZONE_BVOPTHRESHOLD, bvops); |
1078 |
|
break; |
1079 |
|
|
1080 |
|
case IDD_DEBUG : |
1081 |
|
cpu_force = IsDlgChecked(hDlg, IDC_CPU_FORCE); |
1082 |
|
EnableDlgWindow(hDlg, IDC_CPU_MMX, cpu_force); |
1083 |
|
EnableDlgWindow(hDlg, IDC_CPU_MMXEXT, cpu_force); |
1084 |
|
EnableDlgWindow(hDlg, IDC_CPU_SSE, cpu_force); |
1085 |
|
EnableDlgWindow(hDlg, IDC_CPU_SSE2, cpu_force); |
1086 |
|
EnableDlgWindow(hDlg, IDC_CPU_3DNOW, cpu_force); |
1087 |
|
EnableDlgWindow(hDlg, IDC_CPU_3DNOWEXT, cpu_force); |
1088 |
|
break; |
1089 |
|
} |
1090 |
} |
} |
1091 |
|
|
1092 |
|
|
1093 |
|
/* upload config data into dialog */ |
1094 |
|
static void adv_upload(HWND hDlg, int idd, CONFIG * config) |
1095 |
|
{ |
1096 |
|
switch (idd) |
1097 |
|
{ |
1098 |
|
case IDD_PROFILE : |
1099 |
|
SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_SETCURSEL, config->profile, 0); |
1100 |
|
|
1101 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0); |
1102 |
|
CheckDlg(hDlg, IDC_LUMMASK, config->lum_masking); |
1103 |
|
CheckDlg(hDlg, IDC_INTERLACING, config->interlacing); |
1104 |
|
CheckDlg(hDlg, IDC_TFF, config->tff); |
1105 |
|
CheckDlg(hDlg, IDC_QPEL, config->qpel); |
1106 |
|
CheckDlg(hDlg, IDC_GMC, config->gmc); |
1107 |
|
CheckDlg(hDlg, IDC_BVOP, config->use_bvop); |
1108 |
|
|
1109 |
|
SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, FALSE); |
1110 |
|
set_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio); |
1111 |
|
set_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset); |
1112 |
|
CheckDlg(hDlg, IDC_PACKED, config->packed); |
1113 |
|
|
1114 |
|
break; |
1115 |
|
case IDD_AR: |
1116 |
|
CheckRadioButton(hDlg, IDC_AR, IDC_PAR, config->ar_mode == 0 ? IDC_PAR : IDC_AR); |
1117 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_SETCURSEL, (config->display_aspect_ratio), 0); |
1118 |
|
SetDlgItemInt(hDlg, IDC_ARX, config->ar_x, FALSE); |
1119 |
|
SetDlgItemInt(hDlg, IDC_ARY, config->ar_y, FALSE); |
1120 |
|
break; |
1121 |
|
|
1122 |
|
case IDD_LEVEL : |
1123 |
|
SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_SETCURSEL, config->profile, 0); |
1124 |
|
break; |
1125 |
|
|
1126 |
|
case IDD_RC_CBR : |
1127 |
|
SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE); |
1128 |
|
SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE); |
1129 |
|
SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE); |
1130 |
|
break; |
1131 |
|
|
1132 |
|
case IDD_RC_2PASS1 : |
1133 |
|
SetDlgItemText(hDlg, IDC_STATS, config->stats); |
1134 |
|
CheckDlg(hDlg, IDC_DISCARD1PASS, config->discard1pass); |
1135 |
|
CheckDlg(hDlg, IDC_FULL1PASS, config->full1pass); |
1136 |
|
break; |
1137 |
|
|
1138 |
|
case IDD_RC_2PASS2 : |
1139 |
|
SetDlgItemText(hDlg, IDC_STATS, config->stats); |
1140 |
|
SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE); |
1141 |
|
SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE); |
1142 |
|
|
1143 |
|
SetDlgItemInt(hDlg, IDC_OVERFLOW_CONTROL_STRENGTH, config->overflow_control_strength, FALSE); |
1144 |
|
SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE); |
1145 |
|
SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE); |
1146 |
|
|
1147 |
|
SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); |
1148 |
|
SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); |
1149 |
|
SetDlgItemInt(hDlg, IDC_MINKEY, config->kfthreshold, FALSE); |
1150 |
|
break; |
1151 |
|
|
1152 |
|
case IDD_BITRATE : |
1153 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_SETCURSEL, config->container_type, 0); |
1154 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_TSIZE, config->target_size, FALSE); |
1155 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_SSIZE, config->subtitle_size, FALSE); |
1156 |
|
|
1157 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_HOURS, config->hours, FALSE); |
1158 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_MINUTES, config->minutes, FALSE); |
1159 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_SECONDS, config->seconds, FALSE); |
1160 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_FPS, CB_SETCURSEL, config->fps, 0); |
1161 |
|
|
1162 |
|
SendDlgItemMessage(hDlg, IDC_BITRATE_AFORMAT, CB_SETCURSEL, config->audio_type, 0); |
1163 |
|
CheckRadioButton(hDlg, IDC_BITRATE_AMODE_RATE, IDC_BITRATE_AMODE_SIZE, config->audio_mode == 0 ? IDC_BITRATE_AMODE_RATE : IDC_BITRATE_AMODE_SIZE); |
1164 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_ARATE, config->audio_rate, FALSE); |
1165 |
|
SetDlgItemInt(hDlg, IDC_BITRATE_ASIZE, config->audio_size, FALSE); |
1166 |
|
break; |
1167 |
|
|
1168 |
|
case IDD_ZONE : |
1169 |
|
SetDlgItemInt(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame, FALSE); |
1170 |
|
|
1171 |
|
CheckDlgButton(hDlg, IDC_ZONE_MODE_WEIGHT, config->zones[config->cur_zone].mode == RC_ZONE_WEIGHT); |
1172 |
|
CheckDlgButton(hDlg, IDC_ZONE_MODE_QUANT, config->zones[config->cur_zone].mode == RC_ZONE_QUANT); |
1173 |
|
|
1174 |
|
set_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, config->zones[config->cur_zone].weight); |
1175 |
|
set_dlgitem_float(hDlg, IDC_ZONE_QUANT, config->zones[config->cur_zone].quant); |
1176 |
|
|
1177 |
|
CheckDlgButton(hDlg, IDC_ZONE_FORCEIVOP, config->zones[config->cur_zone].type==XVID_TYPE_IVOP); |
1178 |
|
CheckDlgButton(hDlg, IDC_ZONE_GREYSCALE, config->zones[config->cur_zone].greyscale); |
1179 |
|
CheckDlgButton(hDlg, IDC_ZONE_CHROMAOPT, config->zones[config->cur_zone].chroma_opt); |
1180 |
|
|
1181 |
|
CheckDlg(hDlg, IDC_CARTOON, config->zones[config->cur_zone].cartoon_mode); |
1182 |
|
|
1183 |
|
SetDlgItemInt(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold, TRUE); |
1184 |
|
break; |
1185 |
|
|
1186 |
|
case IDD_MOTION : |
1187 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0); |
1188 |
|
SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0); |
1189 |
|
CheckDlg(hDlg, IDC_VHQ_BFRAME, config->vhq_bframe); |
1190 |
|
CheckDlg(hDlg, IDC_CHROMAME, config->chromame); |
1191 |
|
CheckDlg(hDlg, IDC_TURBO, config->turbo); |
1192 |
|
SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE); |
1193 |
|
SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE); |
1194 |
|
break; |
1195 |
|
|
1196 |
|
case IDD_QUANT : |
1197 |
|
SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE); |
1198 |
|
SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE); |
1199 |
|
SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE); |
1200 |
|
SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE); |
1201 |
|
SetDlgItemInt(hDlg, IDC_MINBQUANT, config->min_bquant, FALSE); |
1202 |
|
SetDlgItemInt(hDlg, IDC_MAXBQUANT, config->max_bquant, FALSE); |
1203 |
|
CheckDlg(hDlg, IDC_TRELLISQUANT, config->trellis_quant); |
1204 |
|
break; |
1205 |
|
|
1206 |
|
case IDD_DEBUG : |
1207 |
|
CheckDlg(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX)); |
1208 |
|
CheckDlg(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT)); |
1209 |
|
CheckDlg(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE)); |
1210 |
|
CheckDlg(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2)); |
1211 |
|
CheckDlg(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW)); |
1212 |
|
CheckDlg(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT)); |
1213 |
|
|
1214 |
|
CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE, |
1215 |
|
config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO ); |
1216 |
|
|
1217 |
|
SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE); |
1218 |
|
|
1219 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0); |
1220 |
|
set_dlgitem_hex(hDlg, IDC_DEBUG, config->debug); |
1221 |
|
CheckDlg(hDlg, IDC_VOPDEBUG, config->vop_debug); |
1222 |
|
CheckDlg(hDlg, IDC_DISPLAY_STATUS, config->display_status); |
1223 |
|
break; |
1224 |
|
|
1225 |
|
case IDD_DEC : |
1226 |
|
SendDlgItemMessage(hDlg, IDC_DEC_BRIGHTNESS, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pp_brightness); |
1227 |
|
CheckDlg(hDlg, IDC_DEC_DY, pp_dy); |
1228 |
|
CheckDlg(hDlg, IDC_DEC_DUV, pp_duv); |
1229 |
|
CheckDlg(hDlg, IDC_DEC_DRY, pp_dry); |
1230 |
|
CheckDlg(hDlg, IDC_DEC_DRUV,pp_druv); |
1231 |
|
CheckDlg(hDlg, IDC_DEC_FE, pp_fe); |
1232 |
|
EnableDlgWindow(hDlg, IDC_DEC_DRY, pp_dy); |
1233 |
|
EnableDlgWindow(hDlg, IDC_DEC_DRUV, pp_duv); |
1234 |
|
break; |
1235 |
|
} |
1236 |
|
} |
1237 |
|
|
1238 |
|
|
1239 |
|
/* download config data from dialog */ |
1240 |
|
|
1241 |
|
static void adv_download(HWND hDlg, int idd, CONFIG * config) |
1242 |
|
{ |
1243 |
|
switch (idd) |
1244 |
|
{ |
1245 |
|
case IDD_PROFILE : |
1246 |
|
config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0); |
1247 |
|
|
1248 |
|
config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0); |
1249 |
|
config->lum_masking = IsDlgChecked(hDlg, IDC_LUMMASK); |
1250 |
|
config->interlacing = IsDlgChecked(hDlg, IDC_INTERLACING); |
1251 |
|
config->tff = IsDlgChecked(hDlg, IDC_TFF); |
1252 |
|
config->qpel = IsDlgChecked(hDlg, IDC_QPEL); |
1253 |
|
config->gmc = IsDlgChecked(hDlg, IDC_GMC); |
1254 |
|
|
1255 |
|
config->use_bvop = IsDlgChecked(hDlg, IDC_BVOP); |
1256 |
|
config->max_bframes = config_get_uint(hDlg, IDC_MAXBFRAMES, config->max_bframes); |
1257 |
|
config->bquant_ratio = get_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio); |
1258 |
|
config->bquant_offset = get_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset); |
1259 |
|
config->packed = IsDlgChecked(hDlg, IDC_PACKED); |
1260 |
|
break; |
1261 |
|
|
1262 |
|
case IDD_AR: |
1263 |
|
config->ar_mode = IsDlgChecked(hDlg, IDC_PAR) ? 0:1; |
1264 |
|
config->ar_x = config_get_uint(hDlg, IDC_ARX, config->ar_x); |
1265 |
|
config->ar_y = config_get_uint(hDlg, IDC_ARY, config->ar_y); |
1266 |
|
config->display_aspect_ratio = SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_GETCURSEL, 0, 0); |
1267 |
|
if (config->display_aspect_ratio == 5) { |
1268 |
|
config->par_x = config_get_uint(hDlg, IDC_PARX, config->par_x); |
1269 |
|
config->par_y = config_get_uint(hDlg, IDC_PARY, config->par_y); |
1270 |
|
} |
1271 |
|
break; |
1272 |
|
|
1273 |
|
case IDD_LEVEL : |
1274 |
|
config->profile = SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_GETCURSEL, 0, 0); |
1275 |
|
break; |
1276 |
|
|
1277 |
|
case IDD_RC_CBR : |
1278 |
|
config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor); |
1279 |
|
config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period); |
1280 |
|
config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer); |
1281 |
|
break; |
1282 |
|
|
1283 |
|
case IDD_RC_2PASS1 : |
1284 |
|
if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0) |
1285 |
|
lstrcpy(config->stats, CONFIG_2PASS_FILE); |
1286 |
|
config->discard1pass = IsDlgChecked(hDlg, IDC_DISCARD1PASS); |
1287 |
|
config->full1pass = IsDlgChecked(hDlg, IDC_FULL1PASS); |
1288 |
|
break; |
1289 |
|
|
1290 |
|
case IDD_RC_2PASS2 : |
1291 |
|
if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0) |
1292 |
|
lstrcpy(config->stats, CONFIG_2PASS_FILE); |
1293 |
|
|
1294 |
|
config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE); |
1295 |
|
config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE); |
1296 |
|
CONSTRAINVAL(config->keyframe_boost, 0, 1000); |
1297 |
|
|
1298 |
|
config->overflow_control_strength = GetDlgItemInt(hDlg, IDC_OVERFLOW_CONTROL_STRENGTH, NULL, FALSE); |
1299 |
|
config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement); |
1300 |
|
config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation); |
1301 |
|
CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80); |
1302 |
|
CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80); |
1303 |
|
CONSTRAINVAL(config->overflow_control_strength, 0, 100); |
1304 |
|
|
1305 |
|
config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); |
1306 |
|
config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); |
1307 |
|
CONSTRAINVAL(config->curve_compression_high, 0, 100); |
1308 |
|
CONSTRAINVAL(config->curve_compression_low, 0, 100); |
1309 |
|
|
1310 |
|
config->kfthreshold = config_get_uint(hDlg, IDC_MINKEY, config->kfthreshold); |
1311 |
|
|
1312 |
|
break; |
1313 |
|
|
1314 |
|
case IDD_BITRATE : |
1315 |
|
config->container_type = SendDlgItemMessage(hDlg, IDC_BITRATE_CFORMAT, CB_GETCURSEL, 0, 0); |
1316 |
|
config->target_size = config_get_uint(hDlg, IDC_BITRATE_TSIZE, config->target_size); |
1317 |
|
config->subtitle_size = config_get_uint(hDlg, IDC_BITRATE_SSIZE, config->subtitle_size); |
1318 |
|
|
1319 |
|
config->hours = config_get_uint(hDlg, IDC_BITRATE_HOURS, config->hours); |
1320 |
|
config->minutes = config_get_uint(hDlg, IDC_BITRATE_MINUTES, config->minutes); |
1321 |
|
config->seconds = config_get_uint(hDlg, IDC_BITRATE_SECONDS, config->seconds); |
1322 |
|
config->fps = SendDlgItemMessage(hDlg, IDC_BITRATE_FPS, CB_GETCURSEL, 0, 0); |
1323 |
|
|
1324 |
|
config->audio_type = SendDlgItemMessage(hDlg, IDC_BITRATE_AFORMAT, CB_GETCURSEL, 0, 0); |
1325 |
|
config->audio_mode = IsDlgChecked(hDlg, IDC_BITRATE_AMODE_SIZE) ? 1 : 0 ; |
1326 |
|
config->audio_rate = config_get_uint(hDlg, IDC_BITRATE_ARATE, config->audio_rate); |
1327 |
|
config->audio_size = config_get_uint(hDlg, IDC_BITRATE_ASIZE, config->audio_size); |
1328 |
|
|
1329 |
|
/* the main window uses "AVI bitrate/filesize" not "video bitrate/filesize", |
1330 |
|
so we have to compensate by frames * 24 bytes */ |
1331 |
|
{ |
1332 |
|
int frame_compensate = 24 * (int)( |
1333 |
|
(3600*config->hours + |
1334 |
|
60*config->minutes + |
1335 |
|
config->seconds) * video_fps_list[config->fps].value) / 1024; |
1336 |
|
|
1337 |
|
int bitrate_compensate = (int)(24 * video_fps_list[config->fps].value) / 125; |
1338 |
|
|
1339 |
|
config->desired_size = |
1340 |
|
config_get_uint(hDlg, IDC_BITRATE_VSIZE, config->desired_size) + frame_compensate; |
1341 |
|
|
1342 |
|
config->bitrate = |
1343 |
|
config_get_uint(hDlg, IDC_BITRATE_VRATE, config->bitrate) + bitrate_compensate; |
1344 |
|
} |
1345 |
|
break; |
1346 |
|
|
1347 |
|
case IDD_ZONE : |
1348 |
|
config->zones[config->cur_zone].frame = config_get_uint(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame); |
1349 |
|
|
1350 |
|
if (IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT)) { |
1351 |
|
config->zones[config->cur_zone].mode = RC_ZONE_WEIGHT; |
1352 |
|
}else if (IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT)) { |
1353 |
|
config->zones[config->cur_zone].mode = RC_ZONE_QUANT; |
1354 |
|
} |
1355 |
|
|
1356 |
|
config->zones[config->cur_zone].weight = get_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, config->zones[config->cur_zone].weight); |
1357 |
|
config->zones[config->cur_zone].quant = get_dlgitem_float(hDlg, IDC_ZONE_QUANT, config->zones[config->cur_zone].quant); |
1358 |
|
|
1359 |
|
config->zones[config->cur_zone].type = IsDlgButtonChecked(hDlg, IDC_ZONE_FORCEIVOP)?XVID_TYPE_IVOP:XVID_TYPE_AUTO; |
1360 |
|
config->zones[config->cur_zone].greyscale = IsDlgButtonChecked(hDlg, IDC_ZONE_GREYSCALE); |
1361 |
|
config->zones[config->cur_zone].chroma_opt = IsDlgButtonChecked(hDlg, IDC_ZONE_CHROMAOPT); |
1362 |
|
|
1363 |
|
config->zones[config->cur_zone].bvop_threshold = config_get_int(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold); |
1364 |
|
config->zones[config->cur_zone].cartoon_mode = IsDlgChecked(hDlg, IDC_CARTOON); |
1365 |
|
break; |
1366 |
|
|
1367 |
|
case IDD_MOTION : |
1368 |
|
config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0); |
1369 |
|
config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0); |
1370 |
|
config->vhq_bframe = IsDlgButtonChecked(hDlg, IDC_VHQ_BFRAME); |
1371 |
|
config->chromame = IsDlgChecked(hDlg, IDC_CHROMAME); |
1372 |
|
config->turbo = IsDlgChecked(hDlg, IDC_TURBO); |
1373 |
|
|
1374 |
|
config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio); |
1375 |
|
|
1376 |
|
config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval); |
1377 |
|
break; |
1378 |
|
|
1379 |
|
case IDD_QUANT : |
1380 |
|
config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant); |
1381 |
|
config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant); |
1382 |
|
config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant); |
1383 |
|
config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant); |
1384 |
|
config->min_bquant = config_get_uint(hDlg, IDC_MINBQUANT, config->min_bquant); |
1385 |
|
config->max_bquant = config_get_uint(hDlg, IDC_MAXBQUANT, config->max_bquant); |
1386 |
|
|
1387 |
|
CONSTRAINVAL(config->min_iquant, 1, 31); |
1388 |
|
CONSTRAINVAL(config->max_iquant, config->min_iquant, 31); |
1389 |
|
CONSTRAINVAL(config->min_pquant, 1, 31); |
1390 |
|
CONSTRAINVAL(config->max_pquant, config->min_pquant, 31); |
1391 |
|
CONSTRAINVAL(config->min_bquant, 1, 31); |
1392 |
|
CONSTRAINVAL(config->max_bquant, config->min_bquant, 31); |
1393 |
|
|
1394 |
|
config->trellis_quant = IsDlgChecked(hDlg, IDC_TRELLISQUANT); |
1395 |
|
break; |
1396 |
|
|
1397 |
|
case IDD_DEBUG : |
1398 |
|
config->cpu = 0; |
1399 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMX) ? XVID_CPU_MMX : 0; |
1400 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT : 0; |
1401 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE) ? XVID_CPU_SSE : 0; |
1402 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE2) ? XVID_CPU_SSE2 : 0; |
1403 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOW) ? XVID_CPU_3DNOW : 0; |
1404 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT : 0; |
1405 |
|
config->cpu |= IsDlgChecked(hDlg, IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0; |
1406 |
|
|
1407 |
|
config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads); |
1408 |
|
|
1409 |
|
config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); |
1410 |
|
config->debug = get_dlgitem_hex(hDlg, IDC_DEBUG, config->debug); |
1411 |
|
config->vop_debug = IsDlgChecked(hDlg, IDC_VOPDEBUG); |
1412 |
|
config->display_status = IsDlgChecked(hDlg, IDC_DISPLAY_STATUS); |
1413 |
|
break; |
1414 |
|
|
1415 |
|
case IDD_DEC : |
1416 |
|
pp_brightness = SendDlgItemMessage(hDlg, IDC_DEC_BRIGHTNESS, TBM_GETPOS, (WPARAM)NULL, (LPARAM)NULL); |
1417 |
|
pp_dy = IsDlgChecked(hDlg, IDC_DEC_DY); |
1418 |
|
pp_duv = IsDlgChecked(hDlg, IDC_DEC_DUV); |
1419 |
|
pp_dry = IsDlgChecked(hDlg, IDC_DEC_DRY); |
1420 |
|
pp_druv = IsDlgChecked(hDlg, IDC_DEC_DRUV); |
1421 |
|
pp_fe = IsDlgChecked(hDlg, IDC_DEC_FE); |
1422 |
|
break; |
1423 |
|
} |
1424 |
|
} |
1425 |
|
|
1426 |
|
|
1427 |
|
|
1428 |
|
/* advanced dialog proc */ |
1429 |
|
|
1430 |
|
static BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
1431 |
|
{ |
1432 |
|
PROPSHEETINFO *psi; |
1433 |
|
|
1434 |
|
psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA); |
1435 |
|
|
1436 |
|
switch (uMsg) |
1437 |
|
{ |
1438 |
|
case WM_INITDIALOG : |
1439 |
|
psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam; |
1440 |
|
SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi); |
1441 |
|
|
1442 |
|
if (g_hTooltip) |
1443 |
|
EnumChildWindows(hDlg, enum_tooltips, 0); |
1444 |
|
|
1445 |
|
adv_init(hDlg, psi->idd, psi->config); |
1446 |
|
break; |
1447 |
|
|
1448 |
|
case WM_COMMAND : |
1449 |
|
if (HIWORD(wParam) == BN_CLICKED) |
1450 |
|
{ |
1451 |
|
switch (LOWORD(wParam)) |
1452 |
|
{ |
1453 |
|
case IDC_INTERLACING : |
1454 |
|
case IDC_VHQ_BFRAME : |
1455 |
|
case IDC_BVOP : |
1456 |
|
case IDC_ZONE_MODE_WEIGHT : |
1457 |
|
case IDC_ZONE_MODE_QUANT : |
1458 |
|
case IDC_ZONE_BVOPTHRESHOLD_ENABLE : |
1459 |
|
case IDC_CPU_AUTO : |
1460 |
|
case IDC_CPU_FORCE : |
1461 |
|
case IDC_AR : |
1462 |
|
case IDC_PAR : |
1463 |
|
case IDC_BITRATE_AMODE_RATE : |
1464 |
|
case IDC_BITRATE_AMODE_SIZE : |
1465 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1466 |
|
break; |
1467 |
|
|
1468 |
|
case IDC_BITRATE_SSELECT : |
1469 |
|
case IDC_BITRATE_ASELECT : |
1470 |
|
{ |
1471 |
|
OPENFILENAME ofn; |
1472 |
|
char filename[MAX_PATH] = ""; |
1473 |
|
|
1474 |
|
memset(&ofn, 0, sizeof(OPENFILENAME)); |
1475 |
|
ofn.lStructSize = sizeof(OPENFILENAME); |
1476 |
|
|
1477 |
|
ofn.hwndOwner = hDlg; |
1478 |
|
if (LOWORD(wParam)==IDC_BITRATE_SSELECT) { |
1479 |
|
ofn.lpstrFilter = "Subtitle files (*.sub, *.ssa, *.txt, *.dat)\0*.sub;*.ssa;*.txt;*.dat\0All files (*.*)\0*.*\0\0"; |
1480 |
|
}else{ |
1481 |
|
ofn.lpstrFilter = "Audio files (*.mp3, *.ac3, *.aac, *.ogg, *.wav)\0*.mp3; *.ac3; *.aac; *.ogg; *.wav\0All files (*.*)\0*.*\0\0"; |
1482 |
|
} |
1483 |
|
|
1484 |
|
ofn.lpstrFile = filename; |
1485 |
|
ofn.nMaxFile = MAX_PATH; |
1486 |
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; |
1487 |
|
|
1488 |
|
if (GetOpenFileName(&ofn)) { |
1489 |
|
HANDLE hFile; |
1490 |
|
DWORD filesize; |
1491 |
|
|
1492 |
|
if ((hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) == INVALID_HANDLE_VALUE || |
1493 |
|
(filesize = GetFileSize(hFile, NULL)) == INVALID_FILE_SIZE) { |
1494 |
|
MessageBox(hDlg, "Could not get file size", "Error", 0); |
1495 |
|
}else{ |
1496 |
|
SetDlgItemInt(hDlg, |
1497 |
|
LOWORD(wParam)==IDC_BITRATE_SSELECT? IDC_BITRATE_SSIZE : IDC_BITRATE_ASIZE, |
1498 |
|
filesize / 1024, FALSE); |
1499 |
|
CloseHandle(hFile); |
1500 |
|
} |
1501 |
|
} |
1502 |
|
} |
1503 |
|
break; |
1504 |
|
|
1505 |
|
case IDC_QUANTMATRIX : |
1506 |
|
DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config); |
1507 |
|
break; |
1508 |
|
|
1509 |
|
case IDC_STATS_BROWSE : |
1510 |
|
{ |
1511 |
|
OPENFILENAME ofn; |
1512 |
|
char tmp[MAX_PATH]; |
1513 |
|
|
1514 |
|
GetDlgItemText(hDlg, IDC_STATS, tmp, MAX_PATH); |
1515 |
|
|
1516 |
|
memset(&ofn, 0, sizeof(OPENFILENAME)); |
1517 |
|
ofn.lStructSize = sizeof(OPENFILENAME); |
1518 |
|
|
1519 |
|
ofn.hwndOwner = hDlg; |
1520 |
|
ofn.lpstrFilter = "bitrate curve (*.pass)\0*.pass\0All files (*.*)\0*.*\0\0"; |
1521 |
|
ofn.lpstrFile = tmp; |
1522 |
|
ofn.nMaxFile = MAX_PATH; |
1523 |
|
ofn.Flags = OFN_PATHMUSTEXIST; |
1524 |
|
|
1525 |
|
if (psi->idd == IDD_RC_2PASS1) { |
1526 |
|
ofn.Flags |= OFN_OVERWRITEPROMPT; |
1527 |
|
}else{ |
1528 |
|
ofn.Flags |= OFN_FILEMUSTEXIST; |
1529 |
|
} |
1530 |
|
|
1531 |
|
if ((psi->idd==IDD_RC_2PASS1 && GetSaveFileName(&ofn)) || |
1532 |
|
(psi->idd==IDD_RC_2PASS2 && GetOpenFileName(&ofn))) { |
1533 |
|
SetDlgItemText(hDlg, IDC_STATS, tmp); |
1534 |
|
} |
1535 |
|
} |
1536 |
|
break; |
1537 |
|
|
1538 |
|
case IDC_ZONE_FETCH : |
1539 |
|
SetDlgItemInt(hDlg, IDC_ZONE_FRAME, psi->config->ci.ciActiveFrame, FALSE); |
1540 |
|
break; |
1541 |
|
|
1542 |
|
case IDC_AR_DEFAULT: |
1543 |
|
CheckRadioButton(hDlg, IDC_AR, IDC_PAR, IDC_PAR); |
1544 |
|
SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_SETCURSEL, 0, 0); |
1545 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1546 |
|
break; |
1547 |
|
case IDC_AR_4_3: |
1548 |
|
SetDlgItemInt(hDlg, IDC_ARX, 4, FALSE); |
1549 |
|
SetDlgItemInt(hDlg, IDC_ARY, 3, FALSE); |
1550 |
|
CheckRadioButton(hDlg, IDC_AR, IDC_PAR, IDC_AR); |
1551 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1552 |
|
break; |
1553 |
|
case IDC_AR_16_9: |
1554 |
|
SetDlgItemInt(hDlg, IDC_ARX, 16, FALSE); |
1555 |
|
SetDlgItemInt(hDlg, IDC_ARY, 9, FALSE); |
1556 |
|
CheckRadioButton(hDlg, IDC_AR, IDC_PAR, IDC_AR); |
1557 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1558 |
|
break; |
1559 |
|
case IDC_AR_235_100: |
1560 |
|
SetDlgItemInt(hDlg, IDC_ARX, 235, FALSE); |
1561 |
|
SetDlgItemInt(hDlg, IDC_ARY, 100, FALSE); |
1562 |
|
CheckRadioButton(hDlg, IDC_AR, IDC_PAR, IDC_AR); |
1563 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1564 |
|
break; |
1565 |
|
case IDC_DEC_DY: |
1566 |
|
case IDC_DEC_DUV: |
1567 |
|
EnableDlgWindow(hDlg, IDC_DEC_DRY, IsDlgChecked(hDlg, IDC_DEC_DY)); |
1568 |
|
EnableDlgWindow(hDlg, IDC_DEC_DRUV, IsDlgChecked(hDlg, IDC_DEC_DUV)); |
1569 |
|
break; |
1570 |
|
default : |
1571 |
|
return TRUE; |
1572 |
|
} |
1573 |
|
}else if ((HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam)==CBN_SELCHANGE) && |
1574 |
|
(LOWORD(wParam)==IDC_BITRATE_TSIZE || |
1575 |
|
LOWORD(wParam)==IDC_BITRATE_ARATE )) { |
1576 |
|
|
1577 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1578 |
|
|
1579 |
|
}else if (HIWORD(wParam) == LBN_SELCHANGE && |
1580 |
|
(LOWORD(wParam) == IDC_PROFILE_PROFILE || |
1581 |
|
LOWORD(wParam) == IDC_LEVEL_PROFILE || |
1582 |
|
LOWORD(wParam) == IDC_QUANTTYPE || |
1583 |
|
LOWORD(wParam) == IDC_ASPECT_RATIO || |
1584 |
|
LOWORD(wParam) == IDC_BITRATE_CFORMAT || |
1585 |
|
LOWORD(wParam) == IDC_BITRATE_AFORMAT || |
1586 |
|
LOWORD(wParam) == IDC_BITRATE_FPS)) { |
1587 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1588 |
|
}else if (HIWORD(wParam) == EN_UPDATE && (LOWORD(wParam)==IDC_ZONE_WEIGHT || LOWORD(wParam)==IDC_ZONE_QUANT)) { |
1589 |
|
|
1590 |
|
SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, |
1591 |
|
get_dlgitem_float(hDlg, LOWORD(wParam), 100)); |
1592 |
|
|
1593 |
|
} else if (HIWORD(wParam) == EN_UPDATE && (LOWORD(wParam)==IDC_PARX || LOWORD(wParam)==IDC_PARY)) { |
1594 |
|
|
1595 |
|
if (5 == SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_GETCURSEL, 0, 0)) { |
1596 |
|
if(LOWORD(wParam)==IDC_PARX) |
1597 |
|
psi->config->par_x = config_get_uint(hDlg, LOWORD(wParam), psi->config->par_x); |
1598 |
|
else |
1599 |
|
psi->config->par_y = config_get_uint(hDlg, LOWORD(wParam), psi->config->par_y); |
1600 |
|
} |
1601 |
|
} else if (HIWORD(wParam) == EN_UPDATE && |
1602 |
|
(LOWORD(wParam)==IDC_BITRATE_SSIZE || |
1603 |
|
LOWORD(wParam)==IDC_BITRATE_HOURS || |
1604 |
|
LOWORD(wParam)==IDC_BITRATE_MINUTES || |
1605 |
|
LOWORD(wParam)==IDC_BITRATE_SECONDS || |
1606 |
|
LOWORD(wParam)==IDC_BITRATE_ASIZE)) { |
1607 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1608 |
|
} else |
1609 |
|
return 0; |
1610 |
|
break; |
1611 |
|
|
1612 |
|
case WM_HSCROLL : |
1613 |
|
if((HWND)lParam == GetDlgItem(hDlg, IDC_ZONE_SLIDER)) { |
1614 |
|
int idc = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT) ? IDC_ZONE_WEIGHT : IDC_ZONE_QUANT; |
1615 |
|
set_dlgitem_float(hDlg, idc, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0) ); |
1616 |
|
break; |
1617 |
|
} |
1618 |
|
return 0; |
1619 |
|
|
1620 |
|
|
1621 |
|
case WM_NOTIFY : |
1622 |
|
switch (((NMHDR *)lParam)->code) |
1623 |
|
{ |
1624 |
|
case PSN_SETACTIVE : |
1625 |
|
DPRINTF("PSN_SET"); |
1626 |
|
adv_upload(hDlg, psi->idd, psi->config); |
1627 |
|
adv_mode(hDlg, psi->idd, psi->config); |
1628 |
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
1629 |
|
break; |
1630 |
|
|
1631 |
|
case PSN_KILLACTIVE : |
1632 |
|
DPRINTF("PSN_KILL"); |
1633 |
|
adv_download(hDlg, psi->idd, psi->config); |
1634 |
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
1635 |
|
break; |
1636 |
|
|
1637 |
|
case PSN_APPLY : |
1638 |
|
DPRINTF("PSN_APPLY"); |
1639 |
|
psi->config->save = TRUE; |
1640 |
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
1641 |
|
break; |
1642 |
|
} |
1643 |
|
break; |
1644 |
|
|
1645 |
|
default : |
1646 |
|
return 0; |
1647 |
|
} |
1648 |
|
|
1649 |
|
return 1; |
1650 |
|
} |
1651 |
|
|
1652 |
|
|
1653 |
|
|
1654 |
|
|
1655 |
|
/* load advanced options property sheet |
1656 |
|
returns true, if the user accepted the changes |
1657 |
|
or fasle if changes were canceled. |
1658 |
|
|
1659 |
|
*/ |
1660 |
|
|
1661 |
|
#ifndef PSH_NOCONTEXTHELP |
1662 |
|
#define PSH_NOCONTEXTHELP 0x02000000 |
1663 |
|
#endif |
1664 |
|
|
1665 |
|
static BOOL adv_dialog(HWND hParent, CONFIG * config, const int * dlgs, int size) |
1666 |
|
{ |
1667 |
|
PROPSHEETINFO psi[6]; |
1668 |
|
PROPSHEETPAGE psp[6]; |
1669 |
|
PROPSHEETHEADER psh; |
1670 |
|
CONFIG temp; |
1671 |
|
int i; |
1672 |
|
|
1673 |
|
config->save = FALSE; |
1674 |
|
memcpy(&temp, config, sizeof(CONFIG)); |
1675 |
|
|
1676 |
|
for (i=0; i<size; i++) |
1677 |
|
{ |
1678 |
|
psp[i].dwSize = sizeof(PROPSHEETPAGE); |
1679 |
|
psp[i].dwFlags = 0; |
1680 |
|
psp[i].hInstance = g_hInst; |
1681 |
|
psp[i].pfnDlgProc = adv_proc; |
1682 |
|
psp[i].lParam = (LPARAM)&psi[i]; |
1683 |
|
psp[i].pfnCallback = NULL; |
1684 |
|
psp[i].pszTemplate = MAKEINTRESOURCE(dlgs[i]); |
1685 |
|
|
1686 |
|
psi[i].idd = dlgs[i]; |
1687 |
|
psi[i].config = &temp; |
1688 |
|
} |
1689 |
|
|
1690 |
|
psh.dwSize = sizeof(PROPSHEETHEADER); |
1691 |
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP; |
1692 |
|
psh.hwndParent = hParent; |
1693 |
|
psh.hInstance = g_hInst; |
1694 |
|
psh.pszCaption = (LPSTR) "XviD Configuration"; |
1695 |
|
psh.nPages = size; |
1696 |
|
psh.nStartPage = 0; |
1697 |
|
psh.ppsp = (LPCPROPSHEETPAGE)&psp; |
1698 |
|
psh.pfnCallback = NULL; |
1699 |
|
PropertySheet(&psh); |
1700 |
|
|
1701 |
|
if (temp.save) |
1702 |
|
memcpy(config, &temp, sizeof(CONFIG)); |
1703 |
|
|
1704 |
|
return temp.save; |
1705 |
|
} |
1706 |
|
|
1707 |
|
/* ===================================================================================== */ |
1708 |
|
/* MAIN DIALOG ========================================================================= */ |
1709 |
|
/* ===================================================================================== */ |
1710 |
|
|
1711 |
|
|
1712 |
|
static void main_insert_zone(HWND hDlg, zone_t * s, int i, BOOL insert) |
1713 |
|
{ |
1714 |
|
char tmp[32]; |
1715 |
|
|
1716 |
|
wsprintf(tmp,"%i",s->frame); |
1717 |
|
|
1718 |
|
if (insert) { |
1719 |
|
LVITEM lvi; |
1720 |
|
|
1721 |
|
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE; |
1722 |
|
lvi.state = 0; |
1723 |
|
lvi.stateMask = 0; |
1724 |
|
lvi.iImage = 0; |
1725 |
|
lvi.pszText = tmp; |
1726 |
|
lvi.cchTextMax = strlen(tmp); |
1727 |
|
lvi.iItem = i; |
1728 |
|
lvi.iSubItem = 0; |
1729 |
|
ListView_InsertItem(hDlg, &lvi); |
1730 |
|
}else{ |
1731 |
|
ListView_SetItemText(hDlg, i, 0, tmp); |
1732 |
|
} |
1733 |
|
|
1734 |
|
if (s->mode == RC_ZONE_WEIGHT) { |
1735 |
|
sprintf(tmp,"W %.2f",(float)s->weight/100); |
1736 |
|
}else if (s->mode == RC_ZONE_QUANT) { |
1737 |
|
sprintf(tmp,"Q %.2f",(float)s->quant/100); |
1738 |
|
}else { |
1739 |
|
strcpy(tmp,"EXT"); |
1740 |
|
} |
1741 |
|
ListView_SetItemText(hDlg, i, 1, tmp); |
1742 |
|
|
1743 |
|
tmp[0] = '\0'; |
1744 |
|
if (s->type==XVID_TYPE_IVOP) |
1745 |
|
strcat(tmp, "K "); |
1746 |
|
|
1747 |
|
if (s->greyscale) |
1748 |
|
strcat(tmp, "G "); |
1749 |
|
|
1750 |
|
if (s->chroma_opt) |
1751 |
|
strcat(tmp, "O "); |
1752 |
|
|
1753 |
|
if (s->cartoon_mode) |
1754 |
|
strcat(tmp, "C "); |
1755 |
|
|
1756 |
|
ListView_SetItemText(hDlg, i, 2, tmp); |
1757 |
|
} |
1758 |
|
|
1759 |
|
|
1760 |
|
static void main_mode(HWND hDlg, CONFIG * config) |
1761 |
|
{ |
1762 |
|
const int profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0); |
1763 |
|
const int rc_mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); |
1764 |
|
/* enable target rate/size control only for 1pass and 2pass modes*/ |
1765 |
|
const int target_en = rc_mode==RC_MODE_1PASS || rc_mode==RC_MODE_2PASS2; |
1766 |
|
const int target_en_slider = rc_mode==RC_MODE_1PASS || |
1767 |
|
(rc_mode==RC_MODE_2PASS2 && config->use_2pass_bitrate); |
1768 |
|
|
1769 |
|
char buf[16]; |
1770 |
|
int max; |
1771 |
|
|
1772 |
|
g_use_bitrate = config->use_2pass_bitrate; |
1773 |
|
|
1774 |
|
if (g_use_bitrate) { |
1775 |
|
SetDlgItemText(hDlg, IDC_BITRATE_S, "Target bitrate (kbps):"); |
1776 |
|
|
1777 |
|
wsprintf(buf, "%i kbps", DEFAULT_MIN_KBPS); |
1778 |
|
SetDlgItemText(hDlg, IDC_BITRATE_MIN, buf); |
1779 |
|
|
1780 |
|
max = profiles[profile].max_bitrate / 1000; |
1781 |
|
if (max == 0) max = DEFAULT_MAX_KBPS; |
1782 |
|
wsprintf(buf, "%i kbps", max); |
1783 |
|
SetDlgItemText(hDlg, IDC_BITRATE_MAX, buf); |
1784 |
|
|
1785 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(DEFAULT_MIN_KBPS, max)); |
1786 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, |
1787 |
|
config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) ); |
1788 |
|
|
1789 |
|
} else if (rc_mode==RC_MODE_2PASS2) { |
1790 |
|
SetDlgItemText(hDlg, IDC_BITRATE_S, "Target size (kbytes):"); |
1791 |
|
} else if (rc_mode==RC_MODE_1PASS) { |
1792 |
|
SetDlgItemText(hDlg, IDC_BITRATE_S, "Target quantizer:"); |
1793 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(100, 3100)); |
1794 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, |
1795 |
|
get_dlgitem_float(hDlg, IDC_BITRATE, DEFAULT_QUANT )); |
1796 |
|
SetDlgItemText(hDlg, IDC_BITRATE_MIN, "1 (maximum quality)"); |
1797 |
|
SetDlgItemText(hDlg, IDC_BITRATE_MAX, "(smallest file) 31"); |
1798 |
|
|
1799 |
|
} |
1800 |
|
|
1801 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_S, target_en); |
1802 |
|
EnableDlgWindow(hDlg, IDC_BITRATE, target_en); |
1803 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_ADV, target_en); |
1804 |
|
|
1805 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_MIN, target_en_slider); |
1806 |
|
EnableDlgWindow(hDlg, IDC_BITRATE_MAX, target_en_slider); |
1807 |
|
EnableDlgWindow(hDlg, IDC_SLIDER, target_en_slider); |
1808 |
|
} |
1809 |
|
|
1810 |
|
|
1811 |
|
static void main_upload(HWND hDlg, CONFIG * config) |
1812 |
|
{ |
1813 |
|
|
1814 |
|
SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0); |
1815 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); |
1816 |
|
|
1817 |
|
g_use_bitrate = config->use_2pass_bitrate; |
1818 |
|
|
1819 |
|
if (g_use_bitrate) { |
1820 |
|
SetDlgItemInt(hDlg, IDC_BITRATE, config->bitrate, FALSE); |
1821 |
|
} else if (config->mode == RC_MODE_2PASS2) { |
1822 |
|
SetDlgItemInt(hDlg, IDC_BITRATE, config->desired_size, FALSE); |
1823 |
|
} else if (config->mode == RC_MODE_1PASS) { |
1824 |
|
set_dlgitem_float(hDlg, IDC_BITRATE, config->desired_quant); |
1825 |
|
} |
1826 |
|
|
1827 |
|
zones_update(hDlg, config); |
1828 |
|
} |
1829 |
|
|
1830 |
|
|
1831 |
|
/* downloads data from main dialog */ |
1832 |
|
static void main_download(HWND hDlg, CONFIG * config) |
1833 |
|
{ |
1834 |
|
config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0); |
1835 |
|
config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); |
1836 |
|
|
1837 |
|
if (g_use_bitrate) { |
1838 |
|
config->bitrate = config_get_uint(hDlg, IDC_BITRATE, config->bitrate); |
1839 |
|
} else if (config->mode == RC_MODE_2PASS2) { |
1840 |
|
config->desired_size = config_get_uint(hDlg, IDC_BITRATE, config->desired_size); |
1841 |
|
} else if (config->mode == RC_MODE_1PASS) { |
1842 |
|
config->desired_quant = get_dlgitem_float(hDlg, IDC_BITRATE, config->desired_quant); |
1843 |
|
} |
1844 |
|
} |
1845 |
|
|
1846 |
|
|
1847 |
|
/* main dialog proc */ |
1848 |
|
|
1849 |
|
static const int profile_dlgs[] = { IDD_PROFILE, IDD_LEVEL, IDD_AR }; |
1850 |
|
static const int single_dlgs[] = { IDD_RC_CBR }; |
1851 |
|
static const int pass1_dlgs[] = { IDD_RC_2PASS1 }; |
1852 |
|
static const int pass2_dlgs[] = { IDD_RC_2PASS2 }; |
1853 |
|
static const int bitrate_dlgs[] = { IDD_BITRATE }; |
1854 |
|
static const int zone_dlgs[] = { IDD_ZONE }; |
1855 |
|
static const int decoder_dlgs[] = { IDD_DEC }; |
1856 |
|
static const int adv_dlgs[] = { IDD_MOTION, IDD_QUANT, IDD_DEBUG}; |
1857 |
|
|
1858 |
|
|
1859 |
|
BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
1860 |
|
{ |
1861 |
|
CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); |
1862 |
|
unsigned int i; |
1863 |
|
|
1864 |
|
switch (uMsg) |
1865 |
|
{ |
1866 |
|
case WM_INITDIALOG : |
1867 |
|
SetWindowLong(hDlg, GWL_USERDATA, lParam); |
1868 |
|
config = (CONFIG*)lParam; |
1869 |
|
|
1870 |
|
for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) |
1871 |
|
SendDlgItemMessage(hDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name); |
1872 |
|
|
1873 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Single pass"); |
1874 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 1st pass"); |
1875 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 2nd pass"); |
1876 |
|
#ifdef _DEBUG |
1877 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null test speed"); |
1878 |
|
#endif |
1879 |
|
|
1880 |
|
InitCommonControls(); |
1881 |
|
|
1882 |
|
if ((g_hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP, |
1883 |
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
1884 |
|
NULL, NULL, g_hInst, NULL))) |
1885 |
|
{ |
1886 |
|
SetWindowPos(g_hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); |
1887 |
|
SendMessage(g_hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0)); |
1888 |
|
SendMessage(g_hTooltip, TTM_SETMAXTIPWIDTH, 0, 400); |
1889 |
|
|
1890 |
|
EnumChildWindows(hDlg, enum_tooltips, 0); |
1891 |
|
} |
1892 |
|
|
1893 |
|
SetClassLong(GetDlgItem(hDlg, IDC_BITRATE_S), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); |
1894 |
|
|
1895 |
|
{ |
1896 |
|
DWORD ext_style = ListView_GetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES)); |
1897 |
|
ext_style |= LVS_EX_FULLROWSELECT | LVS_EX_FLATSB ; |
1898 |
|
ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES), ext_style); |
1899 |
|
} |
1900 |
|
|
1901 |
|
{ |
1902 |
|
typedef struct { |
1903 |
|
char * name; |
1904 |
|
int value; |
1905 |
|
} char_int_t; |
1906 |
|
|
1907 |
|
const static char_int_t columns[] = { |
1908 |
|
{"Frame #", 64}, |
1909 |
|
{"Weight/Quant", 82}, |
1910 |
|
{"Modifiers", 120}}; |
1911 |
|
|
1912 |
|
LVCOLUMN lvc; |
1913 |
|
int i; |
1914 |
|
|
1915 |
|
/* Initialize the LVCOLUMN structure. */ |
1916 |
|
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; |
1917 |
|
lvc.fmt = LVCFMT_LEFT; |
1918 |
|
|
1919 |
|
/* Add the columns. */ |
1920 |
|
for (i=0; i<sizeof(columns)/sizeof(char_int_t); i++) { |
1921 |
|
lvc.pszText = (char*)columns[i].name; |
1922 |
|
lvc.cchTextMax = strlen(columns[i].name); |
1923 |
|
lvc.iSubItem = i; |
1924 |
|
lvc.cx = columns[i].value; /* column width, pixels */ |
1925 |
|
ListView_InsertColumn(GetDlgItem(hDlg,IDC_ZONES), i, &lvc); |
1926 |
|
} |
1927 |
|
} |
1928 |
|
|
1929 |
|
/* XXX: main_mode needs RC_MODE_xxx, main_upload needs g_use_bitrate set correctly... */ |
1930 |
|
main_upload(hDlg, config); |
1931 |
|
main_mode(hDlg, config); |
1932 |
|
main_upload(hDlg, config); |
1933 |
|
break; |
1934 |
|
|
1935 |
|
case WM_NOTIFY : |
1936 |
|
{ |
1937 |
|
NMHDR * n = (NMHDR*)lParam; |
1938 |
|
|
1939 |
|
if (n->code == NM_DBLCLK) { |
1940 |
|
NMLISTVIEW * nmlv = (NMLISTVIEW*) lParam; |
1941 |
|
config->cur_zone = nmlv->iItem; |
1942 |
|
|
1943 |
|
main_download(hDlg, config); |
1944 |
|
if (config->cur_zone >= 0 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) { |
1945 |
|
zones_update(hDlg, config); |
1946 |
|
} |
1947 |
|
break; |
1948 |
|
} |
1949 |
|
|
1950 |
|
break; |
1951 |
|
} |
1952 |
|
|
1953 |
|
case WM_COMMAND : |
1954 |
|
if (HIWORD(wParam) == BN_CLICKED) { |
1955 |
|
|
1956 |
|
switch(LOWORD(wParam)) { |
1957 |
|
case IDC_PROFILE_ADV : |
1958 |
|
main_download(hDlg, config); |
1959 |
|
adv_dialog(hDlg, config, profile_dlgs, sizeof(profile_dlgs)/sizeof(int)); |
1960 |
|
|
1961 |
|
SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0); |
1962 |
|
main_mode(hDlg, config); |
1963 |
|
break; |
1964 |
|
|
1965 |
|
case IDC_MODE_ADV : |
1966 |
|
main_download(hDlg, config); |
1967 |
|
if (config->mode == RC_MODE_1PASS) { |
1968 |
|
adv_dialog(hDlg, config, single_dlgs, sizeof(single_dlgs)/sizeof(int)); |
1969 |
|
}else if (config->mode == RC_MODE_2PASS1) { |
1970 |
|
adv_dialog(hDlg, config, pass1_dlgs, sizeof(pass1_dlgs)/sizeof(int)); |
1971 |
|
}else if (config->mode == RC_MODE_2PASS2) { |
1972 |
|
adv_dialog(hDlg, config, pass2_dlgs, sizeof(pass2_dlgs)/sizeof(int)); |
1973 |
|
} |
1974 |
|
break; |
1975 |
|
|
1976 |
|
case IDC_BITRATE_S : |
1977 |
|
/* alternate between bitrate/desired_length metrics */ |
1978 |
|
main_download(hDlg, config); |
1979 |
|
config->use_2pass_bitrate = !config->use_2pass_bitrate; |
1980 |
|
main_mode(hDlg, config); |
1981 |
|
main_upload(hDlg, config); |
1982 |
|
break; |
1983 |
|
|
1984 |
|
case IDC_BITRATE_ADV : |
1985 |
|
main_download(hDlg, config); |
1986 |
|
adv_dialog(hDlg, config, bitrate_dlgs, sizeof(bitrate_dlgs)/sizeof(int)); |
1987 |
|
main_mode(hDlg, config); |
1988 |
|
main_upload(hDlg, config); |
1989 |
|
break; |
1990 |
|
|
1991 |
|
case IDC_DECODER : |
1992 |
|
main_download(hDlg, config); |
1993 |
|
adv_dialog(hDlg, config, decoder_dlgs, sizeof(decoder_dlgs)/sizeof(int)); |
1994 |
|
main_mode(hDlg, config); |
1995 |
|
break; |
1996 |
|
|
1997 |
|
case IDC_ADD : |
1998 |
|
{ |
1999 |
|
int i, sel, new_frame; |
2000 |
|
|
2001 |
|
if (config->num_zones >= MAX_ZONES) { |
2002 |
|
MessageBox(hDlg, "Exceeded maximum number of zones.\nIncrease config.h:MAX_ZONES and rebuild.", "Warning", 0); |
2003 |
|
break; |
2004 |
|
} |
2005 |
|
|
2006 |
|
sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED); |
2007 |
|
|
2008 |
|
if (sel<0) { |
2009 |
|
if (config->ci_valid && config->ci.ciActiveFrame>0) { |
2010 |
|
for(sel=0; sel<config->num_zones-1 && config->zones[sel].frame<config->ci.ciActiveFrame; sel++) ; |
2011 |
|
sel--; |
2012 |
|
new_frame = config->ci.ciActiveFrame; |
2013 |
|
}else{ |
2014 |
|
sel = config->num_zones-1; |
2015 |
|
new_frame = sel<0 ? 0 : config->zones[sel].frame + 1; |
2016 |
|
} |
2017 |
|
}else{ |
2018 |
|
new_frame = config->zones[sel].frame + 1; |
2019 |
|
} |
2020 |
|
|
2021 |
|
for(i=config->num_zones-1; i>sel; i--) { |
2022 |
|
config->zones[i+1] = config->zones[i]; |
2023 |
|
} |
2024 |
|
config->num_zones++; |
2025 |
|
config->zones[sel+1].frame = new_frame; |
2026 |
|
config->zones[sel+1].mode = RC_ZONE_WEIGHT; |
2027 |
|
config->zones[sel+1].weight = 100; |
2028 |
|
config->zones[sel+1].quant = 500; |
2029 |
|
config->zones[sel+1].type = XVID_TYPE_AUTO; |
2030 |
|
config->zones[sel+1].greyscale = 0; |
2031 |
|
config->zones[sel+1].chroma_opt = 0; |
2032 |
|
config->zones[sel+1].bvop_threshold = 0; |
2033 |
|
|
2034 |
|
ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel, 0x00000000, LVIS_SELECTED); |
2035 |
|
zones_update(hDlg, config); |
2036 |
|
ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel+1, 0xffffffff, LVIS_SELECTED); |
2037 |
|
break; |
2038 |
|
} |
2039 |
|
|
2040 |
|
case IDC_REMOVE : |
2041 |
|
{ |
2042 |
|
int i, sel; |
2043 |
|
sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED); |
2044 |
|
|
2045 |
|
if (sel == -1 || config->num_zones < 1) { |
2046 |
|
/*MessageBox(hDlg, "Nothing selected", "Warning", 0);*/ |
2047 |
|
break; |
2048 |
|
} |
2049 |
|
|
2050 |
|
for (i=sel; i<config->num_zones-1; i++) |
2051 |
|
config->zones[i] = config->zones[i+1]; |
2052 |
|
|
2053 |
|
config->num_zones--; |
2054 |
|
|
2055 |
|
zones_update(hDlg, config); |
2056 |
|
break; |
2057 |
|
} |
2058 |
|
|
2059 |
|
case IDC_EDIT : |
2060 |
|
main_download(hDlg, config); |
2061 |
|
config->cur_zone = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED); |
2062 |
|
if (config->cur_zone != -1 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) { |
2063 |
|
zones_update(hDlg, config); |
2064 |
|
} |
2065 |
|
break; |
2066 |
|
|
2067 |
|
case IDC_ADVANCED : |
2068 |
|
main_download(hDlg, config); |
2069 |
|
adv_dialog(hDlg, config, adv_dlgs, sizeof(adv_dlgs)/sizeof(int)); |
2070 |
|
break; |
2071 |
|
|
2072 |
|
case IDC_DEFAULTS : |
2073 |
|
config_reg_default(config); |
2074 |
|
SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0); |
2075 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); |
2076 |
|
main_mode(hDlg, config); |
2077 |
|
main_upload(hDlg, config); |
2078 |
|
break; |
2079 |
|
|
2080 |
|
case IDOK : |
2081 |
|
main_download(hDlg, config); |
2082 |
|
config->save = TRUE; |
2083 |
|
EndDialog(hDlg, IDOK); |
2084 |
|
break; |
2085 |
|
|
2086 |
|
case IDCANCEL : |
2087 |
|
config->save = FALSE; |
2088 |
|
EndDialog(hDlg, IDCANCEL); |
2089 |
|
break; |
2090 |
|
} |
2091 |
|
} else if (HIWORD(wParam) == LBN_SELCHANGE && |
2092 |
|
(LOWORD(wParam)==IDC_PROFILE || LOWORD(wParam)==IDC_MODE)) { |
2093 |
|
|
2094 |
|
config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); |
2095 |
|
config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0); |
2096 |
|
|
2097 |
|
if (!g_use_bitrate) { |
2098 |
|
if (config->mode == RC_MODE_1PASS) |
2099 |
|
set_dlgitem_float(hDlg, IDC_BITRATE, config->desired_quant); |
2100 |
|
else if (config->mode == RC_MODE_2PASS2) |
2101 |
|
SetDlgItemInt(hDlg, IDC_BITRATE, config->desired_size, FALSE); |
2102 |
|
} |
2103 |
|
|
2104 |
|
main_mode(hDlg, config); |
2105 |
|
main_upload(hDlg, config); |
2106 |
|
|
2107 |
|
}else if (HIWORD(wParam)==EN_UPDATE && LOWORD(wParam)==IDC_BITRATE) { |
2108 |
|
|
2109 |
|
if (g_use_bitrate) { |
2110 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, |
2111 |
|
config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) ); |
2112 |
|
} else if (config->mode == RC_MODE_1PASS) { |
2113 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, |
2114 |
|
get_dlgitem_float(hDlg, IDC_BITRATE, DEFAULT_QUANT) ); |
2115 |
|
} |
2116 |
|
main_download(hDlg, config); |
2117 |
|
|
2118 |
|
}else { |
2119 |
|
return 0; |
2120 |
|
} |
2121 |
|
break; |
2122 |
|
|
2123 |
|
case WM_HSCROLL : |
2124 |
|
if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER)) { |
2125 |
|
if (g_use_bitrate) |
2126 |
|
SetDlgItemInt(hDlg, IDC_BITRATE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE); |
2127 |
|
else |
2128 |
|
set_dlgitem_float(hDlg, IDC_BITRATE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0)); |
2129 |
|
|
2130 |
|
main_download(hDlg, config); |
2131 |
|
break; |
2132 |
|
} |
2133 |
|
return 0; |
2134 |
|
|
2135 |
|
default : |
2136 |
|
return 0; |
2137 |
|
} |
2138 |
|
|
2139 |
|
return 1; |
2140 |
|
} |
2141 |
|
|
2142 |
|
|
2143 |
|
/* ===================================================================================== */ |
2144 |
|
/* LICENSE DIALOG ====================================================================== */ |
2145 |
|
/* ===================================================================================== */ |
2146 |
|
|
2147 |
|
static BOOL CALLBACK license_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
2148 |
|
{ |
2149 |
|
switch (uMsg) |
2150 |
|
{ |
2151 |
|
case WM_INITDIALOG : |
2152 |
|
{ |
2153 |
|
HRSRC hRSRC; |
2154 |
|
HGLOBAL hGlobal = NULL; |
2155 |
|
if ((hRSRC = FindResource(g_hInst, MAKEINTRESOURCE(IDR_GPL), "TEXT"))) { |
2156 |
|
if ((hGlobal = LoadResource(g_hInst, hRSRC))) { |
2157 |
|
LPVOID lpData; |
2158 |
|
if ((lpData = LockResource(hGlobal))) { |
2159 |
|
SendDlgItemMessage(hDlg, IDC_LICENSE_TEXT, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), MAKELPARAM(TRUE, 0)); |
2160 |
|
SetDlgItemText(hDlg, IDC_LICENSE_TEXT, lpData); |
2161 |
|
SendDlgItemMessage(hDlg, IDC_LICENSE_TEXT, EM_SETSEL, (WPARAM)-1, (LPARAM)0); |
2162 |
|
} |
2163 |
|
} |
2164 |
|
} |
2165 |
|
SetWindowLong(hDlg, GWL_USERDATA, (LONG)hGlobal); |
2166 |
|
} |
2167 |
|
break; |
2168 |
|
|
2169 |
|
case WM_DESTROY : |
2170 |
|
{ |
2171 |
|
HGLOBAL hGlobal = (HGLOBAL)GetWindowLong(hDlg, GWL_USERDATA); |
2172 |
|
if (hGlobal) { |
2173 |
|
FreeResource(hGlobal); |
2174 |
|
} |
2175 |
|
} |
2176 |
|
break; |
2177 |
|
|
2178 |
|
case WM_COMMAND : |
2179 |
|
if (HIWORD(wParam) == BN_CLICKED) { |
2180 |
|
switch(LOWORD(wParam)) { |
2181 |
|
case IDOK : |
2182 |
|
case IDCANCEL : |
2183 |
|
EndDialog(hDlg, 0); |
2184 |
|
break; |
2185 |
|
default : |
2186 |
|
return 0; |
2187 |
|
} |
2188 |
|
break; |
2189 |
|
} |
2190 |
|
break; |
2191 |
|
|
2192 |
|
default : |
2193 |
|
return 0; |
2194 |
|
} |
2195 |
|
|
2196 |
|
return 1; |
2197 |
|
} |
2198 |
|
|
2199 |
|
/* ===================================================================================== */ |
2200 |
|
/* ABOUT DIALOG ======================================================================== */ |
2201 |
|
/* ===================================================================================== */ |
2202 |
|
|
2203 |
|
BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
2204 |
|
{ |
2205 |
|
switch (uMsg) |
2206 |
|
{ |
2207 |
|
case WM_INITDIALOG : |
2208 |
|
{ |
2209 |
|
xvid_gbl_info_t info; |
2210 |
|
char core[100]; |
2211 |
|
HFONT hFont; |
2212 |
|
LOGFONT lfData; |
2213 |
|
HINSTANCE m_hdll; |
2214 |
|
|
2215 |
|
SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD); |
2216 |
|
SetDlgItemText(hDlg, IDC_SPECIAL_BUILD, XVID_SPECIAL_BUILD); |
2217 |
|
|
2218 |
|
memset(&info, 0, sizeof(info)); |
2219 |
|
info.version = XVID_VERSION; |
2220 |
|
|
2221 |
|
m_hdll = LoadLibrary(XVID_DLL_NAME); |
2222 |
|
if (m_hdll != NULL) { |
2223 |
|
|
2224 |
|
((int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global")) |
2225 |
|
(0, XVID_GBL_INFO, &info, NULL); |
2226 |
|
|
2227 |
|
wsprintf(core, "xvidcore.dll version %d.%d.%d (\"%s\")", |
2228 |
|
XVID_VERSION_MAJOR(info.actual_version), |
2229 |
|
XVID_VERSION_MINOR(info.actual_version), |
2230 |
|
XVID_VERSION_PATCH(info.actual_version), |
2231 |
|
info.build); |
2232 |
|
|
2233 |
|
FreeLibrary(m_hdll); |
2234 |
|
} else { |
2235 |
|
wsprintf(core, "xvidcore.dll not found!"); |
2236 |
|
} |
2237 |
|
|
2238 |
|
SetDlgItemText(hDlg, IDC_CORE, core); |
2239 |
|
|
2240 |
|
hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L); |
2241 |
|
|
2242 |
|
if (GetObject(hFont, sizeof(LOGFONT), &lfData)) { |
2243 |
|
lfData.lfUnderline = 1; |
2244 |
|
|
2245 |
|
hFont = CreateFontIndirect(&lfData); |
2246 |
|
if (hFont) { |
2247 |
|
SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L); |
2248 |
|
} |
2249 |
|
} |
2250 |
|
|
2251 |
|
SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); |
2252 |
|
SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE); |
2253 |
|
} |
2254 |
|
break; |
2255 |
|
case WM_CTLCOLORSTATIC : |
2256 |
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE)) |
2257 |
|
{ |
2258 |
|
SetBkMode((HDC)wParam, TRANSPARENT) ; |
2259 |
|
SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0)); |
2260 |
|
return (BOOL)GetStockObject(NULL_BRUSH); |
2261 |
|
} |
2262 |
|
return 0; |
2263 |
|
|
2264 |
|
case WM_COMMAND : |
2265 |
|
if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED) { |
2266 |
|
ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL); |
2267 |
|
}else if (LOWORD(wParam) == IDC_LICENSE) { |
2268 |
|
DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_LICENSE), hDlg, license_proc, (LPARAM)0); |
2269 |
|
} else if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { |
2270 |
|
EndDialog(hDlg, LOWORD(wParam)); |
2271 |
|
} |
2272 |
|
break; |
2273 |
|
|
2274 |
|
default : |
2275 |
|
return 0; |
2276 |
|
} |
2277 |
|
|
2278 |
|
return 1; |
2279 |
|
} |
2280 |
|
|
2281 |
|
|
2282 |
|
void |
2283 |
|
sort_zones(zone_t * zones, int zone_num, int * sel) |
2284 |
|
{ |
2285 |
|
int i, j; |
2286 |
|
zone_t tmp; |
2287 |
|
for (i = 0; i < zone_num; i++) { |
2288 |
|
int cur = i; |
2289 |
|
int min_f = zones[i].frame; |
2290 |
|
for (j = i + 1; j < zone_num; j++) { |
2291 |
|
if (zones[j].frame < min_f) { |
2292 |
|
min_f = zones[j].frame; |
2293 |
|
cur = j; |
2294 |
|
} |
2295 |
|
} |
2296 |
|
if (cur != i) { |
2297 |
|
tmp = zones[i]; |
2298 |
|
zones[i] = zones[cur]; |
2299 |
|
zones[cur] = tmp; |
2300 |
|
if (i == *sel) *sel = cur; |
2301 |
|
else if (cur == *sel) *sel = i; |
2302 |
|
} |
2303 |
|
} |
2304 |
|
} |
2305 |
|
|
2306 |
|
|
2307 |
|
static void |
2308 |
|
zones_update(HWND hDlg, CONFIG * config) |
2309 |
|
{ |
2310 |
|
int i, sel; |
2311 |
|
|
2312 |
|
sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED); |
2313 |
|
|
2314 |
|
sort_zones(config->zones, config->num_zones, &sel); |
2315 |
|
|
2316 |
|
ListView_DeleteAllItems(GetDlgItem(hDlg,IDC_ZONES)); |
2317 |
|
|
2318 |
|
for (i = 0; i < config->num_zones; i++) |
2319 |
|
main_insert_zone(GetDlgItem(hDlg,IDC_ZONES), &config->zones[i], i, TRUE); |
2320 |
|
|
2321 |
|
if (sel == -1 && config->num_zones > 0) sel = 0; |
2322 |
|
if (sel >= config->num_zones) sel = config->num_zones-1; |
2323 |
|
|
2324 |
|
config->cur_zone = sel; |
2325 |
|
ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel, 0xffffffff, LVIS_SELECTED); |
2326 |
|
} |