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