23 |
* |
* |
24 |
* History: |
* History: |
25 |
* |
* |
26 |
* ... ??? |
* 15.04.2002 updated cbr support |
27 |
* 11.03.2002 Version 0.02; Min Chen <chenm001@163.com> |
* 07.04.2002 min keyframe interval checkbox |
28 |
|
* 2-pass max bitrate and overflow customization |
29 |
|
* 04.04.2002 interlacing support |
30 |
|
* hinted ME support |
31 |
|
* 24.03.2002 daniel smith <danielsmith@astroboymail.com> |
32 |
|
* added Foxer's new CBR engine |
33 |
|
* - cbr_buffer is being used as reaction delay (quick hack) |
34 |
|
* 23.03.2002 daniel smith <danielsmith@astroboymail.com> |
35 |
|
* added load defaults button |
36 |
|
* merged foxer's alternative 2-pass code (2-pass alt tab) |
37 |
|
* added proper tooltips |
38 |
|
* moved registry data into reg_ints/reg_strs arrays |
39 |
|
* added DEBUGERR output on errors instead of returning |
40 |
|
* 16.03.2002 daniel smith <danielsmith@astroboymail.com> |
41 |
|
* rewrote/restructured most of file |
42 |
|
* added tooltips (kind of - dirty message hook method) |
43 |
|
* split tabs into a main dialog / advanced prop sheet |
44 |
|
* advanced controls are now enabled/disabled by mode |
45 |
|
* added modulated quantization, DX50 fourcc |
46 |
|
* 11.03.2002 Min Chen <chenm001@163.com> |
47 |
* now get Core Version use xvid_init() |
* now get Core Version use xvid_init() |
48 |
* 05.03.2002 Version 0.01; Min Chen <chenm001@163.com> |
* 05.03.2002 Min Chen <chenm001@163.com> |
49 |
* Add Core version display to about box |
* Add Core version display to about box |
|
* |
|
50 |
* 01.12.2001 inital version; (c)2001 peter ross <suxen_drol@hotmail.com> |
* 01.12.2001 inital version; (c)2001 peter ross <suxen_drol@hotmail.com> |
51 |
* |
* |
52 |
*************************************************************************/ |
*************************************************************************/ |
53 |
|
|
54 |
|
|
55 |
#include <windows.h> |
#include <windows.h> |
56 |
|
#include <commctrl.h> |
57 |
#include <shlobj.h> |
#include <shlobj.h> |
58 |
#include <prsht.h> |
#include <prsht.h> |
59 |
|
|
60 |
#include "codec.h" |
#include "codec.h" |
61 |
#include "config.h" |
#include "config.h" |
|
#include "resource.h" |
|
62 |
#include "xvid.h" // cpu masks |
#include "xvid.h" // cpu masks |
63 |
#include <stdio.h> // sprintf() |
#include "resource.h" |
64 |
|
|
65 |
|
|
66 |
|
/* registry info structs */ |
67 |
|
|
68 |
|
CONFIG reg; |
69 |
|
|
70 |
|
REG_INT const reg_ints[] = { |
71 |
|
{"mode", ®.mode, DLG_MODE_CBR}, |
72 |
|
{"quality", ®.quality, 85}, |
73 |
|
{"quant", ®.quant, 5}, |
74 |
|
{"rc_bitrate", ®.rc_bitrate, 900000}, |
75 |
|
{"rc_reaction_delay_factor",®.rc_reaction_delay_factor, 16}, |
76 |
|
{"rc_averaging_period", ®.rc_averaging_period, 100}, |
77 |
|
{"rc_buffer", ®.rc_buffer, 100}, |
78 |
|
|
79 |
|
{"motion_search", ®.motion_search, 5}, |
80 |
|
{"quant_type", ®.quant_type, 0}, |
81 |
|
{"fourcc_used", ®.fourcc_used, 0}, |
82 |
|
{"max_key_interval", ®.max_key_interval, 300}, |
83 |
|
{"min_key_interval", ®.min_key_interval, 1}, |
84 |
|
{"lum_masking", ®.lum_masking, 0}, |
85 |
|
{"interlacing", ®.interlacing, 0}, |
86 |
|
|
87 |
|
{"min_iquant", ®.min_iquant, 1}, |
88 |
|
{"max_iquant", ®.max_iquant, 31}, |
89 |
|
{"min_pquant", ®.min_pquant, 1}, |
90 |
|
{"max_pquant", ®.max_pquant, 31}, |
91 |
|
|
92 |
|
{"desired_size", ®.desired_size, 570000}, |
93 |
|
{"keyframe_boost", ®.keyframe_boost, 20}, |
94 |
|
{"discard1pass", ®.discard1pass, 1}, |
95 |
|
{"dummy2pass", ®.dummy2pass, 0}, |
96 |
|
{"curve_compression_high", ®.curve_compression_high, 25}, |
97 |
|
{"curve_compression_low", ®.curve_compression_low, 10}, |
98 |
|
{"use_alt_curve", ®.use_alt_curve, 0}, |
99 |
|
{"alt_curve_use_auto", ®.alt_curve_use_auto, 1}, |
100 |
|
{"alt_curve_auto_str", ®.alt_curve_auto_str, 50}, |
101 |
|
{"alt_curve_use_auto_bonus_bias", ®.alt_curve_use_auto_bonus_bias, 1}, |
102 |
|
{"alt_curve_bonus_bias", ®.alt_curve_bonus_bias, 50}, |
103 |
|
{"alt_curve_type", ®.alt_curve_type, 1}, |
104 |
|
{"alt_curve_high_dist", ®.alt_curve_high_dist, 300}, |
105 |
|
{"alt_curve_low_dist", ®.alt_curve_low_dist, 300}, |
106 |
|
{"alt_curve_min_rel_qual", ®.alt_curve_min_rel_qual, 50}, |
107 |
|
{"bitrate_payback_delay", ®.bitrate_payback_delay, 240}, |
108 |
|
{"bitrate_payback_method", ®.bitrate_payback_method, 0}, |
109 |
|
{"twopass_max_bitrate", ®.twopass_max_bitrate, 10000 * CONFIG_KBPS}, |
110 |
|
{"twopass_max_overflow_improvement", ®.twopass_max_overflow_improvement, 60}, |
111 |
|
{"twopass_max_overflow_degradation", ®.twopass_max_overflow_degradation, 60}, |
112 |
|
{"hinted_me", ®.hinted_me, 0}, |
113 |
|
|
114 |
|
{"credits_start", ®.credits_start, 0}, |
115 |
|
{"credits_start_begin", ®.credits_start_begin, 0}, |
116 |
|
{"credits_start_end", ®.credits_start_end, 0}, |
117 |
|
{"credits_end", ®.credits_end, 0}, |
118 |
|
{"credits_end_begin", ®.credits_end_begin, 0}, |
119 |
|
{"credits_end_end", ®.credits_end_end, 0}, |
120 |
|
|
121 |
|
{"credits_mode", ®.credits_mode, 0}, |
122 |
|
{"credits_rate", ®.credits_rate, 20}, |
123 |
|
{"credits_quant_i", ®.credits_quant_i, 20}, |
124 |
|
{"credits_quant_p", ®.credits_quant_p, 20}, |
125 |
|
{"credits_start_size", ®.credits_start_size, 10000}, |
126 |
|
{"credits_end_size", ®.credits_end_size, 10000} |
127 |
|
}; |
128 |
|
|
129 |
|
REG_STR const reg_strs[] = { |
130 |
|
{"hintfile", reg.hintfile, CONFIG_HINTFILE}, |
131 |
|
{"stats1", reg.stats1, CONFIG_2PASS_1_FILE}, |
132 |
|
{"stats2", reg.stats2, CONFIG_2PASS_2_FILE} |
133 |
|
// {"build", reg.build, XVID_BUILD} |
134 |
|
}; |
135 |
|
|
136 |
/* get config settings from registry */ |
/* get config settings from registry */ |
137 |
|
|
|
#define REG_GET_N(X, Y, Z) size=sizeof(int);if(RegQueryValueEx(hKey, X, 0, 0, (LPBYTE)&Y, &size) != ERROR_SUCCESS) {Y=Z;} |
|
|
#define REG_GET_S(X, Y, Z) size=MAX_PATH;if(RegQueryValueEx(hKey, X, 0, 0, Y, &size) != ERROR_SUCCESS) {lstrcpy(Y, Z);} |
|
138 |
#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)));} |
#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)));} |
139 |
|
|
140 |
void config_reg_get(CONFIG * config) |
void config_reg_get(CONFIG * config) |
142 |
HKEY hKey; |
HKEY hKey; |
143 |
DWORD size; |
DWORD size; |
144 |
XVID_INIT_PARAM init_param; |
XVID_INIT_PARAM init_param; |
145 |
|
int i; |
146 |
|
|
147 |
init_param.cpu_flags = 0; |
init_param.cpu_flags = 0; |
148 |
xvid_init(0, 0, &init_param, NULL); |
xvid_init(0, 0, &init_param, NULL); |
149 |
config->cpu = init_param.cpu_flags; |
config->cpu = init_param.cpu_flags; |
150 |
|
|
151 |
RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey); |
RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey); |
152 |
|
|
153 |
|
for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i) |
154 |
|
{ |
155 |
|
size = sizeof(int); |
156 |
|
|
157 |
|
if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS) |
158 |
|
{ |
159 |
|
*reg_ints[i].config_int = reg_ints[i].def; |
160 |
|
} |
161 |
|
} |
162 |
|
|
163 |
REG_GET_N("mode", config->mode, DLG_MODE_CBR) |
for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i) |
164 |
REG_GET_N("bitrate", config->bitrate, 900000) |
{ |
165 |
REG_GET_N("quality", config->quality, 85) |
size = MAX_PATH; |
|
REG_GET_N("quant", config->quant, 5) |
|
|
|
|
|
REG_GET_S("stats1", config->stats1, CONFIG_2PASS_1_FILE) |
|
|
REG_GET_S("stats2", config->stats2, CONFIG_2PASS_2_FILE) |
|
|
REG_GET_N("discard1pass", config->discard1pass, 1) |
|
|
REG_GET_N("dummy2pass", config->dummy2pass, 0) |
|
|
REG_GET_N("desired_size", config->desired_size, 570000) |
|
|
|
|
|
REG_GET_N("min_iquant", config->min_iquant, 1) |
|
|
REG_GET_N("max_iquant", config->max_iquant, 31) |
|
|
|
|
|
REG_GET_N("keyframe_boost", config->keyframe_boost, 20) |
|
|
REG_GET_N("min_key_interval", config->min_key_interval, 6) |
|
|
REG_GET_N("bitrate_payback_delay", config->bitrate_payback_delay, 240) |
|
|
REG_GET_N("bitrate_payback_method", config->bitrate_payback_method, 0) |
|
|
REG_GET_N("curve_compression_high", config->curve_compression_high, 25) |
|
|
REG_GET_N("curve_compression_low", config->curve_compression_low, 15) |
|
|
|
|
|
REG_GET_N("credits_start", config->credits_start, 0) |
|
|
REG_GET_N("credits_start_begin", config->credits_start_begin, 0) |
|
|
REG_GET_N("credits_start_end", config->credits_start_end, 0) |
|
|
REG_GET_N("credits_end", config->credits_end, 0) |
|
|
REG_GET_N("credits_end_begin", config->credits_end_begin, 0) |
|
|
REG_GET_N("credits_end_end", config->credits_end_end, 0) |
|
|
|
|
|
REG_GET_N("credits_mode", config->credits_mode, 0) |
|
|
REG_GET_N("credits_rate", config->credits_rate, 10) |
|
|
REG_GET_N("credits_quant_i", config->credits_quant_i, 20) |
|
|
REG_GET_N("credits_quant_p", config->credits_quant_p, 20) |
|
|
REG_GET_N("credits_start_size", config->credits_start_size, 10000) |
|
|
REG_GET_N("credits_end_size", config->credits_end_size, 10000) |
|
|
|
|
|
REG_GET_N("motion_search", config->motion_search, 5) |
|
|
REG_GET_N("quant_type", config->quant_type, 0) |
|
|
REG_GET_N("max_key_interval", config->max_key_interval, 300) |
|
|
|
|
|
REG_GET_N("rc_buffersize", config->rc_buffersize, 2048000) |
|
|
|
|
|
REG_GET_N("max_quant", config->max_quant, 31) |
|
|
REG_GET_N("min_quant", config->min_quant, 1) |
|
|
REG_GET_N("lum_masking", config->lum_masking, 0) |
|
166 |
|
|
167 |
REG_GET_N("fourcc_used", config->fourcc_used, 0) |
if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS) |
168 |
|
{ |
169 |
|
memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH); |
170 |
|
} |
171 |
|
} |
172 |
|
|
173 |
{ |
{ |
174 |
BYTE default_qmatrix_intra[] = { |
BYTE default_qmatrix_intra[] = { |
193 |
23,24,25,27,28,30,31,33 |
23,24,25,27,28,30,31,33 |
194 |
}; |
}; |
195 |
|
|
196 |
REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra) |
REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra); |
197 |
REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter) |
REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter); |
198 |
} |
} |
199 |
|
|
200 |
|
memcpy(config, ®, sizeof(CONFIG)); |
201 |
|
|
202 |
RegCloseKey(hKey); |
RegCloseKey(hKey); |
203 |
} |
} |
204 |
|
|
205 |
|
|
206 |
/* put config settings in registry */ |
/* put config settings in registry */ |
207 |
|
|
|
#define REG_SET_N(X, Y) RegSetValueEx(hKey, X, 0, REG_DWORD, (LPBYTE)&Y, sizeof(int)) |
|
|
#define REG_SET_S(X, Y) RegSetValueEx(hKey, X, 0, REG_SZ, Y, lstrlen(Y)+1) |
|
208 |
#define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y))) |
#define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y))) |
209 |
|
|
210 |
void config_reg_set(CONFIG * config) |
void config_reg_set(CONFIG * config) |
211 |
{ |
{ |
212 |
HKEY hKey; |
HKEY hKey; |
213 |
DWORD dispo; |
DWORD dispo; |
214 |
|
int i; |
215 |
|
|
216 |
if (RegCreateKeyEx( |
if (RegCreateKeyEx( |
217 |
XVID_REG_KEY, |
XVID_REG_KEY, |
218 |
XVID_REG_SUBKEY, |
XVID_REG_PARENT "\\" XVID_REG_CHILD, |
219 |
0, |
0, |
220 |
XVID_REG_CLASS, |
XVID_REG_CLASS, |
221 |
REG_OPTION_NON_VOLATILE, |
REG_OPTION_NON_VOLATILE, |
228 |
return; |
return; |
229 |
} |
} |
230 |
|
|
231 |
REG_SET_N("mode", config->mode); |
memcpy(®, config, sizeof(CONFIG)); |
232 |
REG_SET_N("bitrate", config->bitrate); |
|
233 |
REG_SET_N("quality", config->quality); |
for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i) |
234 |
REG_SET_N("quant", config->quant); |
{ |
235 |
|
RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int)); |
236 |
REG_SET_S("stats1", config->stats1); |
} |
|
REG_SET_S("stats2", config->stats2); |
|
|
REG_SET_N("discard1pass", config->discard1pass); |
|
|
REG_SET_N("dummy2pass", config->dummy2pass); |
|
|
REG_SET_N("desired_size", config->desired_size); |
|
|
|
|
|
REG_SET_N("min_iquant", config->min_iquant); |
|
|
REG_SET_N("max_iquant", config->max_iquant); |
|
|
|
|
|
REG_SET_N("keyframe_boost", config->keyframe_boost); |
|
|
REG_SET_N("min_key_interval", config->min_key_interval); |
|
|
REG_SET_N("bitrate_payback_delay", config->bitrate_payback_delay); |
|
|
REG_SET_N("bitrate_payback_method", config->bitrate_payback_method); |
|
|
REG_SET_N("curve_compression_high", config->curve_compression_high); |
|
|
REG_SET_N("curve_compression_low", config->curve_compression_low); |
|
|
|
|
|
REG_SET_N("credits_start", config->credits_start); |
|
|
REG_SET_N("credits_start_begin", config->credits_start_begin); |
|
|
REG_SET_N("credits_start_end", config->credits_start_end); |
|
|
REG_SET_N("credits_end", config->credits_end); |
|
|
REG_SET_N("credits_end_begin", config->credits_end_begin); |
|
|
REG_SET_N("credits_end_end", config->credits_end_end); |
|
|
|
|
|
REG_SET_N("credits_mode", config->credits_mode); |
|
|
REG_SET_N("credits_rate", config->credits_rate); |
|
|
REG_SET_N("credits_quant_i", config->credits_quant_i); |
|
|
REG_SET_N("credits_quant_p", config->credits_quant_p); |
|
|
REG_SET_N("credits_start_size", config->credits_start_size); |
|
|
REG_SET_N("credits_end_size", config->credits_end_size); |
|
|
|
|
|
REG_SET_N("motion_search", config->motion_search); |
|
|
REG_SET_N("quant_type", config->quant_type); |
|
|
REG_SET_N("max_key_interval", config->max_key_interval); |
|
|
|
|
|
REG_SET_N("rc_buffersize", config->rc_buffersize); |
|
|
|
|
|
REG_SET_N("max_quant", config->max_quant); |
|
|
REG_SET_N("min_quant", config->min_quant); |
|
|
REG_SET_N("lum_masking", config->lum_masking); |
|
237 |
|
|
238 |
REG_SET_N("fourcc_used", config->fourcc_used); |
for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i) |
239 |
|
{ |
240 |
|
RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1); |
241 |
|
} |
242 |
|
|
243 |
REG_SET_B("qmatrix_intra", config->qmatrix_intra); |
REG_SET_B("qmatrix_intra", reg.qmatrix_intra); |
244 |
REG_SET_B("qmatrix_inter", config->qmatrix_inter); |
REG_SET_B("qmatrix_inter", reg.qmatrix_inter); |
245 |
|
|
246 |
RegCloseKey(hKey); |
RegCloseKey(hKey); |
247 |
} |
} |
248 |
|
|
249 |
|
|
250 |
/* enable/disable dialog controls based on encoder mode */ |
/* clear XviD registry key, load defaults */ |
251 |
|
|
252 |
#define ENABLE(X) EnableWindow(GetDlgItem(hDlg, (X)), TRUE); |
void config_reg_default(CONFIG * config) |
|
#define DISABLE(X) EnableWindow(GetDlgItem(hDlg, (X)), FALSE); |
|
|
#define ISDLGSET(X) (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED) |
|
|
|
|
|
void config_mode(HWND hDlg) |
|
253 |
{ |
{ |
254 |
XVID_INIT_PARAM init_param; |
HKEY hKey; |
|
LONG mode; |
|
|
|
|
|
mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); |
|
255 |
|
|
256 |
if (mode == DLG_MODE_VBR_QUAL || mode == DLG_MODE_VBR_QUANT || |
if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey)) |
|
mode == DLG_MODE_2PASS_1 || mode == DLG_MODE_2PASS_2_INT) |
|
|
{ |
|
|
ENABLE(IDC_CREDITS); |
|
|
} |
|
|
else |
|
257 |
{ |
{ |
258 |
DISABLE(IDC_CREDITS); |
DEBUG1("Couldn't open registry key for deletion - ", GetLastError()); |
259 |
|
return; |
260 |
} |
} |
261 |
|
|
262 |
if (mode == DLG_MODE_VBR_QUAL || mode == DLG_MODE_VBR_QUANT || mode == DLG_MODE_CBR) |
if (RegDeleteKey(hKey, XVID_REG_CHILD)) |
|
{ |
|
|
ENABLE(IDC_VALUE_STATIC); |
|
|
ENABLE(IDC_VALUE); |
|
|
ENABLE(IDC_SLIDER_STATIC); |
|
|
ENABLE(IDC_SLIDER); |
|
|
} |
|
|
else |
|
263 |
{ |
{ |
264 |
DISABLE(IDC_VALUE_STATIC); |
DEBUG1("Couldn't delete registry key - ", GetLastError()); |
265 |
DISABLE(IDC_VALUE); |
return; |
|
DISABLE(IDC_SLIDER_STATIC); |
|
|
DISABLE(IDC_SLIDER); |
|
266 |
} |
} |
267 |
|
|
268 |
if (mode == DLG_MODE_2PASS_1 || mode == DLG_MODE_2PASS_2_EXT || mode == DLG_MODE_2PASS_2_INT) |
RegCloseKey(hKey); |
269 |
{ |
config_reg_get(config); |
270 |
ENABLE(IDC_2PASS_STATS1_STATIC); |
config_reg_set(config); |
|
ENABLE(IDC_2PASS_STATS1); |
|
|
ENABLE(IDC_2PASS_STATS1_BROWSE); |
|
|
ENABLE(IDC_2PASS_INT); |
|
|
} |
|
|
else |
|
|
{ |
|
|
DISABLE(IDC_2PASS_STATS1_STATIC); |
|
|
DISABLE(IDC_2PASS_STATS1); |
|
|
DISABLE(IDC_2PASS_STATS1_BROWSE); |
|
|
DISABLE(IDC_2PASS_INT); |
|
271 |
} |
} |
272 |
|
|
|
if (mode == DLG_MODE_2PASS_1) |
|
|
{ |
|
|
ENABLE(IDC_DISCARD1PASS); |
|
|
} |
|
|
else |
|
|
{ |
|
|
DISABLE(IDC_DISCARD1PASS); |
|
|
} |
|
273 |
|
|
274 |
if (mode == DLG_MODE_2PASS_2_EXT) |
/* leaves current config value if dialog item is empty */ |
275 |
{ |
|
276 |
ENABLE(IDC_2PASS_STATS1_STATIC); |
int config_get_int(HWND hDlg, UINT item, int config) |
|
ENABLE(IDC_2PASS_STATS2); |
|
|
ENABLE(IDC_2PASS_STATS2_BROWSE); |
|
|
} |
|
|
else |
|
277 |
{ |
{ |
278 |
DISABLE(IDC_2PASS_STATS1_STATIC); |
BOOL success = FALSE; |
|
DISABLE(IDC_2PASS_STATS2); |
|
|
DISABLE(IDC_2PASS_STATS2_BROWSE); |
|
|
} |
|
279 |
|
|
280 |
if (ISDLGSET(IDC_CPU_FORCE)) { |
int tmp = GetDlgItemInt(hDlg, item, &success, FALSE); |
|
ENABLE(IDC_CPU_MMX); |
|
|
ENABLE(IDC_CPU_MMXEXT); |
|
|
ENABLE(IDC_CPU_SSE); |
|
|
ENABLE(IDC_CPU_SSE2); |
|
|
ENABLE(IDC_CPU_3DNOW); |
|
|
ENABLE(IDC_CPU_3DNOWEXT); |
|
|
} else { |
|
|
xvid_init(0, 0, &init_param, NULL); |
|
281 |
|
|
282 |
CheckDlgButton(hDlg, IDC_CPU_MMX, init_param.cpu_flags & XVID_CPU_MMX ? BST_CHECKED : BST_UNCHECKED); |
return (success) ? tmp : config; |
|
CheckDlgButton(hDlg, IDC_CPU_MMXEXT, init_param.cpu_flags & XVID_CPU_MMXEXT ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_SSE, init_param.cpu_flags & XVID_CPU_SSE ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_SSE2, init_param.cpu_flags & XVID_CPU_SSE2 ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_3DNOW, init_param.cpu_flags & XVID_CPU_3DNOW ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, init_param.cpu_flags & XVID_CPU_3DNOWEXT ? BST_CHECKED : BST_UNCHECKED); |
|
|
|
|
|
DISABLE(IDC_CPU_MMX); |
|
|
DISABLE(IDC_CPU_MMXEXT); |
|
|
DISABLE(IDC_CPU_SSE); |
|
|
DISABLE(IDC_CPU_SSE2); |
|
|
DISABLE(IDC_CPU_3DNOW); |
|
|
DISABLE(IDC_CPU_3DNOWEXT); |
|
|
} |
|
283 |
} |
} |
284 |
|
|
285 |
|
|
286 |
/* upload config data into dialog */ |
/* downloads data from main dialog */ |
287 |
|
|
288 |
void config_upload(HWND hDlg, int page, CONFIG * config) |
void main_download(HWND hDlg, CONFIG * config) |
289 |
{ |
{ |
290 |
switch (page) |
switch(config->mode) |
291 |
{ |
{ |
292 |
case DLG_MAIN : |
default : |
293 |
SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); |
case DLG_MODE_CBR : |
294 |
config_mode(hDlg); |
config->rc_bitrate = config_get_int(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS; |
|
|
|
|
config_slider(hDlg, config); |
|
|
config_value(hDlg, config); |
|
|
|
|
|
SetDlgItemText(hDlg, IDC_2PASS_STATS1, config->stats1); |
|
|
SetDlgItemText(hDlg, IDC_2PASS_STATS2, config->stats2); |
|
|
CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED); |
|
295 |
break; |
break; |
296 |
|
|
297 |
case DLG_ADV : |
case DLG_MODE_VBR_QUAL : |
298 |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0); |
config->quality = config_get_int(hDlg, IDC_VALUE, config->quality); |
|
SendDlgItemMessage(hDlg, IDC_QTYPE, CB_SETCURSEL, config->quant_type, 0); |
|
|
SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE); |
|
|
|
|
|
SetDlgItemInt(hDlg, IDC_MINQ, config->min_quant, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_MAXQ, config->max_quant, FALSE); |
|
|
CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED); |
|
|
|
|
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0); |
|
299 |
break; |
break; |
300 |
|
|
301 |
case DLG_DEBUG : |
case DLG_MODE_VBR_QUANT : |
302 |
SetDlgItemInt(hDlg, IDC_RC_BUFFERSIZE, config->rc_buffersize, FALSE); |
config->quant = config_get_int(hDlg, IDC_VALUE, config->quant); |
|
|
|
|
SetDlgItemInt(hDlg, IDC_IMINQ, config->min_iquant, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_IMAXQ, config->max_iquant, FALSE); |
|
|
CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED); |
|
303 |
break; |
break; |
304 |
|
|
305 |
case DLG_CPU : |
case DLG_MODE_2PASS_2_INT : |
306 |
CheckDlgButton(hDlg, IDC_CPU_MMX, config->cpu & XVID_CPU_MMX ? BST_CHECKED : BST_UNCHECKED); |
config->desired_size = config_get_int(hDlg, IDC_VALUE, config->desired_size); |
|
CheckDlgButton(hDlg, IDC_CPU_MMXEXT, config->cpu & XVID_CPU_MMXEXT ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_SSE, config->cpu & XVID_CPU_SSE ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_SSE2, config->cpu & XVID_CPU_SSE2 ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_3DNOW, config->cpu & XVID_CPU_3DNOW ? BST_CHECKED : BST_UNCHECKED); |
|
|
CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, config->cpu & XVID_CPU_3DNOWEXT ? BST_CHECKED : BST_UNCHECKED); |
|
|
|
|
|
CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE, |
|
|
config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO ); |
|
307 |
break; |
break; |
308 |
} |
} |
|
} |
|
309 |
|
|
310 |
|
config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); |
311 |
|
} |
312 |
|
|
|
/* download config data from dialog |
|
|
replaces invalid values instead of alerting user for now |
|
|
*/ |
|
313 |
|
|
314 |
#define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z; |
/* updates the edit box */ |
315 |
|
|
316 |
void config_download(HWND hDlg, int page, CONFIG * config) |
void main_value(HWND hDlg, CONFIG* config) |
317 |
{ |
{ |
318 |
|
char* text; |
319 |
int value; |
int value; |
320 |
|
int enabled = TRUE; |
321 |
|
|
322 |
switch (page) |
switch (config->mode) |
323 |
{ |
{ |
324 |
case DLG_MAIN : |
default : |
325 |
config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); |
enabled = FALSE; |
|
|
|
|
value = config_get_int(hDlg, IDC_VALUE, 2); |
|
326 |
|
|
327 |
switch (SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_GETRANGEMAX, 0, 0)) |
case DLG_MODE_CBR : |
328 |
{ |
text = "Bitrate (Kbps):"; |
329 |
case 10000 : |
value = config->rc_bitrate / CONFIG_KBPS; |
|
CONSTRAINVAL(value, 1, 10000) |
|
|
config->bitrate = value * CONFIG_KBPS; |
|
330 |
break; |
break; |
331 |
|
|
332 |
case 100 : |
case DLG_MODE_VBR_QUAL : |
333 |
CONSTRAINVAL(value, 0, 100) |
text = "Quality:"; |
334 |
config->quality = value; |
value = config->quality; |
335 |
break; |
break; |
336 |
|
|
337 |
case 31 : |
case DLG_MODE_VBR_QUANT : |
338 |
CONSTRAINVAL(value, 1, 31) |
text = "Quantizer:"; |
339 |
config->quant = value; |
value = config->quant; |
340 |
break; |
break; |
|
} |
|
|
|
|
|
GetDlgItemText(hDlg, IDC_2PASS_STATS1, config->stats1, MAX_PATH); |
|
|
if (config->stats1[0] == '\0') |
|
|
{ |
|
|
lstrcpy(config->stats1, CONFIG_2PASS_1_FILE); |
|
|
} |
|
|
GetDlgItemText(hDlg, IDC_2PASS_STATS2, config->stats2, MAX_PATH); |
|
|
if (config->stats2[0] == '\0') |
|
|
{ |
|
|
lstrcpy(config->stats2, CONFIG_2PASS_2_FILE); |
|
|
} |
|
341 |
|
|
342 |
config->discard1pass = ISDLGSET(IDC_DISCARD1PASS); |
case DLG_MODE_2PASS_2_INT : |
343 |
|
text = "Desired size (Kbtyes):"; |
344 |
|
value = config->desired_size; |
345 |
break; |
break; |
|
|
|
|
case DLG_ADV : |
|
|
config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0); |
|
|
config->quant_type = SendDlgItemMessage(hDlg, IDC_QTYPE, CB_GETCURSEL, 0, 0); |
|
|
config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval); |
|
|
|
|
|
config->min_quant = config_get_int(hDlg, IDC_MINQ, config->min_quant); |
|
|
config->max_quant = config_get_int(hDlg, IDC_MAXQ, config->max_quant); |
|
|
config->lum_masking = ISDLGSET(IDC_LUMMASK); |
|
|
|
|
|
CONSTRAINVAL(config->min_quant, 1, 31) |
|
|
CONSTRAINVAL(config->max_quant, 1, 31) |
|
|
if(config->max_quant < config->min_quant) |
|
|
{ |
|
|
config->max_quant = config->min_quant; |
|
346 |
} |
} |
347 |
|
|
348 |
config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); |
SetDlgItemText(hDlg, IDC_VALUE_STATIC, text); |
349 |
break; |
SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE); |
|
|
|
|
case DLG_DEBUG: |
|
|
config->rc_buffersize = config_get_int(hDlg, IDC_RC_BUFFERSIZE, config->rc_buffersize); |
|
|
|
|
|
config->min_iquant = config_get_int(hDlg, IDC_IMINQ, config->min_iquant); |
|
|
config->max_iquant = config_get_int(hDlg, IDC_IMAXQ, config->max_iquant); |
|
|
config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS); |
|
|
|
|
|
CONSTRAINVAL(config->min_iquant, 1, 31) |
|
|
CONSTRAINVAL(config->min_iquant, 1, 31) |
|
|
if(config->max_iquant < config->min_iquant) |
|
|
{ |
|
|
config->max_iquant = config->min_iquant; |
|
|
} |
|
|
break; |
|
350 |
|
|
351 |
case DLG_CPU : |
EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled); |
352 |
config->cpu = 0; |
EnableWindow(GetDlgItem(hDlg, IDC_VALUE), enabled); |
|
config->cpu |= ISDLGSET(IDC_CPU_MMX) ? XVID_CPU_MMX : 0; |
|
|
config->cpu |= ISDLGSET(IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT: 0; |
|
|
config->cpu |= ISDLGSET(IDC_CPU_SSE) ? XVID_CPU_SSE: 0; |
|
|
config->cpu |= ISDLGSET(IDC_CPU_SSE2) ? XVID_CPU_SSE2: 0; |
|
|
config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0; |
|
|
config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0; |
|
|
config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0; |
|
|
break; |
|
|
} |
|
353 |
} |
} |
354 |
|
|
355 |
|
|
356 |
/* updates the slider */ |
/* updates the slider */ |
357 |
|
|
358 |
void config_slider(HWND hDlg, CONFIG* config) |
void main_slider(HWND hDlg, CONFIG * config) |
359 |
{ |
{ |
360 |
char* text; |
char* text; |
361 |
long range; |
long range; |
362 |
int pos; |
int pos; |
363 |
|
int enabled = TRUE; |
364 |
|
|
365 |
switch (config->mode) |
switch (config->mode) |
366 |
{ |
{ |
367 |
default : |
default : |
368 |
|
enabled = FALSE; |
369 |
|
|
370 |
case DLG_MODE_CBR : |
case DLG_MODE_CBR : |
371 |
text = "Bitrate (Kbps):"; |
text = "Bitrate (Kbps):"; |
372 |
range = MAKELONG(0,10000); |
range = MAKELONG(0,10000); |
373 |
pos = config->bitrate / CONFIG_KBPS; |
pos = config->rc_bitrate / CONFIG_KBPS; |
374 |
break; |
break; |
375 |
|
|
376 |
case DLG_MODE_VBR_QUAL : |
case DLG_MODE_VBR_QUAL : |
389 |
SetDlgItemText(hDlg, IDC_SLIDER_STATIC, text); |
SetDlgItemText(hDlg, IDC_SLIDER_STATIC, text); |
390 |
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, range); |
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, range); |
391 |
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, pos); |
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, pos); |
392 |
|
|
393 |
|
EnableWindow(GetDlgItem(hDlg, IDC_SLIDER_STATIC), enabled); |
394 |
|
EnableWindow(GetDlgItem(hDlg, IDC_SLIDER), enabled); |
395 |
} |
} |
396 |
|
|
397 |
|
|
398 |
/* updates the edit box */ |
/* load advanced options property sheet */ |
399 |
|
|
400 |
void config_value(HWND hDlg, CONFIG* config) |
void adv_dialog(HWND hParent, CONFIG * config) |
401 |
{ |
{ |
402 |
char* text; |
PROPSHEETINFO psi[DLG_COUNT]; |
403 |
int value; |
PROPSHEETPAGE psp[DLG_COUNT]; |
404 |
|
PROPSHEETHEADER psh; |
405 |
|
CONFIG temp; |
406 |
|
int i; |
407 |
|
|
408 |
switch (config->mode) |
config->save = FALSE; |
409 |
{ |
memcpy(&temp, config, sizeof(CONFIG)); |
|
default : |
|
|
case DLG_MODE_CBR : |
|
|
text = "Bitrate (Kbps):"; |
|
|
value = config->bitrate / CONFIG_KBPS; |
|
|
break; |
|
410 |
|
|
411 |
case DLG_MODE_VBR_QUAL : |
for (i=0 ; i<DLG_COUNT ; ++i) |
412 |
text = "Quality:"; |
{ |
413 |
value = config->quality; |
psp[i].dwSize = sizeof(PROPSHEETPAGE); |
414 |
break; |
psp[i].dwFlags = 0; |
415 |
|
psp[i].hInstance = hInst; |
416 |
|
psp[i].pfnDlgProc = adv_proc; |
417 |
|
psp[i].lParam = (LPARAM)&psi[i]; |
418 |
|
psp[i].pfnCallback = NULL; |
419 |
|
|
420 |
case DLG_MODE_VBR_QUANT : |
psi[i].page = i; |
421 |
text = "Quantizer:"; |
psi[i].config = &temp; |
|
value = config->quant; |
|
|
break; |
|
422 |
} |
} |
423 |
|
|
424 |
SetDlgItemText(hDlg, IDC_VALUE_STATIC, text); |
psp[DLG_GLOBAL].pszTemplate = MAKEINTRESOURCE(IDD_GLOBAL); |
425 |
SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE); |
psp[DLG_QUANT].pszTemplate = MAKEINTRESOURCE(IDD_QUANT); |
426 |
} |
psp[DLG_2PASS].pszTemplate = MAKEINTRESOURCE(IDD_2PASS); |
427 |
|
psp[DLG_2PASSALT].pszTemplate = MAKEINTRESOURCE(IDD_2PASSALT); |
428 |
|
psp[DLG_CREDITS].pszTemplate = MAKEINTRESOURCE(IDD_CREDITS); |
429 |
|
psp[DLG_CPU].pszTemplate = MAKEINTRESOURCE(IDD_CPU); |
430 |
|
|
431 |
|
psh.dwSize = sizeof(PROPSHEETHEADER); |
432 |
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; |
433 |
|
psh.hwndParent = hParent; |
434 |
|
psh.hInstance = hInst; |
435 |
|
psh.pszCaption = (LPSTR) "XviD Configuration"; |
436 |
|
psh.nPages = DLG_COUNT; |
437 |
|
psh.nStartPage = DLG_GLOBAL; |
438 |
|
psh.ppsp = (LPCPROPSHEETPAGE)&psp; |
439 |
|
psh.pfnCallback = NULL; |
440 |
|
|
441 |
/* leaves current config value if dialog item is empty */ |
PropertySheet(&psh); |
442 |
|
|
443 |
int config_get_int(HWND hDlg, UINT item, int config) |
if (temp.save) |
444 |
{ |
{ |
445 |
BOOL success = FALSE; |
memcpy(config, &temp, sizeof(CONFIG)); |
|
|
|
|
int tmp = GetDlgItemInt(hDlg, item, &success, FALSE); |
|
|
|
|
|
if(success) { |
|
|
return tmp; |
|
|
} else { |
|
|
return config; |
|
446 |
} |
} |
447 |
} |
} |
448 |
|
|
449 |
|
|
450 |
/* configure credits dialog controls */ |
/* enable/disable advanced controls based on encoder mode */ |
451 |
|
|
452 |
|
#define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y)) |
453 |
|
#define ISDLGSET(X) (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED) |
454 |
|
|
455 |
|
#define MOD_CBR |
456 |
|
|
457 |
void credits_controls(HWND hDlg) |
void adv_mode(HWND hDlg, int mode) |
458 |
{ |
{ |
459 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_START_BEGIN), ISDLGSET(IDC_CREDITS_START)); |
// create arrays of controls to be disabled for each mode |
460 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_START_END), ISDLGSET(IDC_CREDITS_START)); |
const int cbr_disable[] = { |
461 |
|
IDC_KFBOOST, IDC_DISCARD1PASS, IDC_DUMMY2PASS, |
462 |
|
IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP, |
463 |
|
IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE, |
464 |
|
IDC_CREDITS_START, IDC_CREDITS_END, IDC_CREDITS_START_BEGIN, IDC_CREDITS_START_END, |
465 |
|
IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO, |
466 |
|
IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO, |
467 |
|
IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE, IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, |
468 |
|
IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE, |
469 |
|
}; |
470 |
|
|
471 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_END_BEGIN), ISDLGSET(IDC_CREDITS_END)); |
const int qual_disable[] = { |
472 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_END_END), ISDLGSET(IDC_CREDITS_END)); |
IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER, |
473 |
|
IDC_KFBOOST, IDC_DISCARD1PASS, IDC_DUMMY2PASS, |
474 |
|
IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP, |
475 |
|
IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE, |
476 |
|
IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE |
477 |
|
}; |
478 |
|
|
479 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_RATE), ISDLGSET(IDC_CREDITS_RATE_RADIO)); |
const int quant_disable[] = { |
480 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_QUANTI), ISDLGSET(IDC_CREDITS_QUANT_RADIO)); |
IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER, |
481 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_QUANTP), ISDLGSET(IDC_CREDITS_QUANT_RADIO)); |
IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT, |
482 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_START_SIZE), ISDLGSET(IDC_CREDITS_SIZE_RADIO)); |
IDC_KFBOOST, IDC_DISCARD1PASS, IDC_DUMMY2PASS, |
483 |
EnableWindow(GetDlgItem(hDlg, IDC_CREDITS_END_SIZE), ISDLGSET(IDC_CREDITS_SIZE_RADIO)); |
IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP, |
484 |
} |
IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE, |
485 |
|
IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE |
486 |
|
}; |
487 |
|
|
488 |
|
const int twopass1_disable[] = { |
489 |
|
IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER, |
490 |
|
IDC_LUMMASK, IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT, |
491 |
|
IDC_KFBOOST, IDC_DUMMY2PASS, |
492 |
|
IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP, |
493 |
|
IDC_STATS2, IDC_STATS2_BROWSE, |
494 |
|
IDC_CREDITS_RATE_RADIO, IDC_CREDITS_RATE, IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, |
495 |
|
IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE |
496 |
|
}; |
497 |
|
|
498 |
void quant_upload(HWND hDlg, CONFIG* config) |
const int twopass2_ext_disable[] = { |
499 |
{ |
IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER, |
500 |
int i; |
IDC_CREDITS_RATE_RADIO, IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, |
501 |
|
IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE, |
502 |
|
IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE |
503 |
|
}; |
504 |
|
|
505 |
for (i=0 ; i<64 ; ++i) |
const int twopass2_int_disable[] = { |
506 |
{ |
IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER, |
507 |
SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE); |
IDC_STATS2, IDC_STATS2_BROWSE |
508 |
SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE); |
}; |
|
} |
|
|
} |
|
509 |
|
|
510 |
|
// store pointers in order so we can lookup using config->mode |
511 |
|
const int* modes[] = { |
512 |
|
cbr_disable, qual_disable, quant_disable, |
513 |
|
twopass1_disable, twopass2_ext_disable, twopass2_int_disable |
514 |
|
}; |
515 |
|
|
516 |
|
// ditto modes[] |
517 |
|
const int lengths[] = { |
518 |
|
sizeof(cbr_disable)/sizeof(int), sizeof(qual_disable)/sizeof(int), |
519 |
|
sizeof(quant_disable)/sizeof(int), sizeof(twopass1_disable)/sizeof(int), |
520 |
|
sizeof(twopass2_ext_disable)/sizeof(int), sizeof(twopass2_int_disable)/sizeof(int) |
521 |
|
}; |
522 |
|
|
|
void quant_download(HWND hDlg, CONFIG* config) |
|
|
{ |
|
523 |
int i; |
int i; |
524 |
|
|
525 |
for (i=0 ; i<64 ; ++i) |
// first perform checkbox-based enable/disable |
526 |
{ |
CONTROLDLG(IDC_HINTFILE, ISDLGSET(IDC_HINTEDME)); |
527 |
config->qmatrix_intra[i] = config_get_int(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]); |
CONTROLDLG(IDC_HINT_BROWSE, ISDLGSET(IDC_HINTEDME)); |
528 |
CONSTRAINVAL(config->qmatrix_intra[i], 1, 255) |
|
529 |
|
CONTROLDLG(IDC_USEAUTO, ISDLGSET(IDC_USEALT)); |
530 |
|
CONTROLDLG(IDC_AUTOSTR, ISDLGSET(IDC_USEALT) && ISDLGSET(IDC_USEAUTO)); |
531 |
|
CONTROLDLG(IDC_USEAUTOBONUS, ISDLGSET(IDC_USEALT)); |
532 |
|
CONTROLDLG(IDC_BONUSBIAS, (ISDLGSET(IDC_USEALT) && !(ISDLGSET(IDC_USEAUTOBONUS)))); |
533 |
|
CONTROLDLG(IDC_CURVETYPE, ISDLGSET(IDC_USEALT)); |
534 |
|
CONTROLDLG(IDC_ALTCURVEHIGH, ISDLGSET(IDC_USEALT)); |
535 |
|
CONTROLDLG(IDC_ALTCURVELOW, ISDLGSET(IDC_USEALT)); |
536 |
|
CONTROLDLG(IDC_MINQUAL, ISDLGSET(IDC_USEALT) && !(ISDLGSET(IDC_USEAUTO))); |
537 |
|
|
538 |
|
CONTROLDLG(IDC_CREDITS_START_BEGIN, ISDLGSET(IDC_CREDITS_START)); |
539 |
|
CONTROLDLG(IDC_CREDITS_START_END, ISDLGSET(IDC_CREDITS_START)); |
540 |
|
|
541 |
|
CONTROLDLG(IDC_CREDITS_END_BEGIN, ISDLGSET(IDC_CREDITS_END)); |
542 |
|
CONTROLDLG(IDC_CREDITS_END_END, ISDLGSET(IDC_CREDITS_END)); |
543 |
|
|
544 |
|
CONTROLDLG(IDC_CREDITS_RATE, ISDLGSET(IDC_CREDITS_RATE_RADIO)); |
545 |
|
CONTROLDLG(IDC_CREDITS_QUANTI, ISDLGSET(IDC_CREDITS_QUANT_RADIO)); |
546 |
|
CONTROLDLG(IDC_CREDITS_QUANTP, ISDLGSET(IDC_CREDITS_QUANT_RADIO)); |
547 |
|
CONTROLDLG(IDC_CREDITS_START_SIZE, ISDLGSET(IDC_CREDITS_SIZE_RADIO)); |
548 |
|
CONTROLDLG(IDC_CREDITS_END_SIZE, ISDLGSET(IDC_CREDITS_SIZE_RADIO)); |
549 |
|
|
550 |
|
CONTROLDLG(IDC_CPU_MMX, ISDLGSET(IDC_CPU_FORCE)); |
551 |
|
CONTROLDLG(IDC_CPU_MMXEXT, ISDLGSET(IDC_CPU_FORCE)); |
552 |
|
CONTROLDLG(IDC_CPU_SSE, ISDLGSET(IDC_CPU_FORCE)); |
553 |
|
CONTROLDLG(IDC_CPU_SSE2, ISDLGSET(IDC_CPU_FORCE)); |
554 |
|
CONTROLDLG(IDC_CPU_3DNOW, ISDLGSET(IDC_CPU_FORCE)); |
555 |
|
CONTROLDLG(IDC_CPU_3DNOWEXT, ISDLGSET(IDC_CPU_FORCE)); |
556 |
|
|
557 |
config->qmatrix_inter[i] = config_get_int(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]); |
// now perform codec mode enable/disable |
558 |
CONSTRAINVAL(config->qmatrix_inter[i], 1, 255) |
for (i=0 ; i<lengths[mode] ; ++i) |
559 |
|
{ |
560 |
|
EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE); |
561 |
} |
} |
562 |
} |
} |
563 |
|
|
564 |
|
|
565 |
/* dialog proc */ |
/* upload config data into dialog */ |
566 |
|
|
567 |
BOOL CALLBACK config_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
void adv_upload(HWND hDlg, int page, CONFIG * config) |
568 |
{ |
{ |
569 |
PROPSHEETINFO *psi; |
switch (page) |
|
|
|
|
psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA); |
|
|
|
|
|
switch (uMsg) |
|
570 |
{ |
{ |
571 |
case WM_INITDIALOG : |
case DLG_GLOBAL : |
572 |
psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam; |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0); |
573 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0); |
574 |
SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi); |
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0); |
575 |
|
SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE); |
576 |
|
SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE); |
577 |
|
CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED); |
578 |
|
CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED); |
579 |
|
break; |
580 |
|
|
581 |
switch (psi->page) |
case DLG_QUANT : |
582 |
{ |
SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE); |
583 |
case DLG_MAIN : |
SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE); |
584 |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - CBR"); |
SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE); |
585 |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quality"); |
SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE); |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quantizer"); |
|
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 1st pass"); |
|
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Ext."); |
|
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Int."); |
|
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed"); |
|
586 |
break; |
break; |
587 |
|
|
588 |
case DLG_ADV : |
case DLG_2PASS : |
589 |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None"); |
SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE); |
590 |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low"); |
CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED); |
591 |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low"); |
CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED); |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium"); |
|
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High"); |
|
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High"); |
|
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High"); |
|
592 |
|
|
593 |
SendDlgItemMessage(hDlg, IDC_QTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263"); |
SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); |
594 |
SendDlgItemMessage(hDlg, IDC_QTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG"); |
SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); |
595 |
SendDlgItemMessage(hDlg, IDC_QTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom"); |
SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE); |
596 |
|
CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0)); |
597 |
|
CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1)); |
598 |
|
|
599 |
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID"); |
CheckDlgButton(hDlg, IDC_HINTEDME, config->hinted_me ? BST_CHECKED : BST_UNCHECKED); |
600 |
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX"); |
SetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile); |
601 |
|
SetDlgItemText(hDlg, IDC_STATS1, config->stats1); |
602 |
|
SetDlgItemText(hDlg, IDC_STATS2, config->stats2); |
603 |
break; |
break; |
604 |
|
|
605 |
case DLG_ABOUT : |
case DLG_2PASSALT : |
606 |
{ |
CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED); |
|
HFONT hFont; |
|
|
LOGFONT lfData; |
|
607 |
|
|
608 |
SetDlgItemText(hDlg, IDC_BUILD, __TIME__ ", " __DATE__); |
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0); |
609 |
|
SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE); |
610 |
|
SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE); |
611 |
|
SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE); |
612 |
|
|
613 |
// Add by Chen at 2002-03-05 to display core version at about box |
CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED); |
614 |
// Change by Chen at 2002-03-11 now use xvid_init() to get core version |
SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE); |
|
{ |
|
|
char chTemp[64]; |
|
|
// 2002-03-11 Change start |
|
|
XVID_INIT_PARAM xinit; |
|
|
xvid_init(NULL,0,&xinit,NULL); |
|
|
sprintf(chTemp,"Core Version %d.%d",(xinit.api_version>>16),(xinit.api_version&0xFFFFU)); |
|
|
// 2002-03-11 Change End |
|
|
//sprintf(chTemp,"Core Version %d.%d",(API_VERSION>>16),(API_VERSION&0xFFFFU)); |
|
|
SetDlgItemText(hDlg, IDC_CORE_VERSION, chTemp); |
|
|
} |
|
615 |
|
|
616 |
hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L); |
CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED); |
617 |
|
SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE); |
618 |
|
|
619 |
if (GetObject(hFont, sizeof(LOGFONT), &lfData)) |
SetDlgItemInt(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate / CONFIG_KBPS, FALSE); |
620 |
{ |
SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE); |
621 |
lfData.lfUnderline = 1; |
SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE); |
622 |
|
break; |
623 |
|
|
624 |
hFont = CreateFontIndirect(&lfData); |
case DLG_CREDITS : |
625 |
if (hFont) |
CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED); |
626 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE); |
627 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_START_END, config->credits_start_end, FALSE); |
628 |
|
CheckDlgButton(hDlg, IDC_CREDITS_END, config->credits_end ? BST_CHECKED : BST_UNCHECKED); |
629 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE); |
630 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE); |
631 |
|
|
632 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE); |
633 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE); |
634 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE); |
635 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size, FALSE); |
636 |
|
SetDlgItemInt(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size, FALSE); |
637 |
|
|
638 |
|
if (config->credits_mode == CREDITS_MODE_RATE) |
639 |
{ |
{ |
640 |
SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L); |
CheckDlgButton(hDlg, IDC_CREDITS_RATE_RADIO, BST_CHECKED); |
|
} |
|
641 |
} |
} |
642 |
|
else if (config->credits_mode == CREDITS_MODE_QUANT) |
643 |
SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); |
{ |
644 |
SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE); |
CheckDlgButton(hDlg, IDC_CREDITS_QUANT_RADIO, BST_CHECKED); |
645 |
} |
} |
646 |
|
else // CREDITS_MODE_SIZE |
647 |
|
{ |
648 |
|
CheckDlgButton(hDlg, IDC_CREDITS_SIZE_RADIO, BST_CHECKED); |
649 |
} |
} |
|
|
|
|
config_upload(hDlg, psi->page, psi->config); |
|
|
config_mode(hDlg); |
|
650 |
break; |
break; |
651 |
|
|
652 |
case WM_CTLCOLORSTATIC : |
case DLG_CPU : |
653 |
if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE)) |
CheckDlgButton(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX) ? BST_CHECKED : BST_UNCHECKED); |
654 |
{ |
CheckDlgButton(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT) ? BST_CHECKED : BST_UNCHECKED); |
655 |
SetBkMode((HDC)wParam, TRANSPARENT) ; |
CheckDlgButton(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE) ? BST_CHECKED : BST_UNCHECKED); |
656 |
SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0)); |
CheckDlgButton(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2) ? BST_CHECKED : BST_UNCHECKED); |
657 |
return (BOOL)GetStockObject(NULL_BRUSH); |
CheckDlgButton(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW) ? BST_CHECKED : BST_UNCHECKED); |
658 |
} |
CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT) ? BST_CHECKED : BST_UNCHECKED); |
|
return FALSE; |
|
659 |
|
|
660 |
case WM_COMMAND : |
CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE, |
661 |
if (LOWORD(wParam) == IDC_MODE && HIWORD(wParam) == LBN_SELCHANGE) |
config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO ); |
662 |
{ |
|
663 |
config_mode(hDlg); |
SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE); |
664 |
config_download(hDlg, psi->page, psi->config); |
SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE); |
665 |
config_value(hDlg, psi->config); |
SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE); |
666 |
config_slider(hDlg, psi->config); |
break; |
667 |
} |
} |
|
else if ((LOWORD(wParam) == IDC_CPU_AUTO || LOWORD(wParam) == IDC_CPU_FORCE) && HIWORD(wParam) == BN_CLICKED) |
|
|
{ |
|
|
config_mode(hDlg); |
|
668 |
} |
} |
|
else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE) |
|
|
{ |
|
|
int value = config_get_int(hDlg, IDC_VALUE, 1); |
|
|
int max = 1; |
|
669 |
|
|
670 |
switch (SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0)) |
|
671 |
|
/* download config data from dialog |
672 |
|
replaces invalid values instead of alerting user for now |
673 |
|
*/ |
674 |
|
|
675 |
|
#define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z; |
676 |
|
|
677 |
|
void adv_download(HWND hDlg, int page, CONFIG * config) |
678 |
{ |
{ |
679 |
default : |
switch (page) |
680 |
case DLG_MODE_CBR : |
{ |
681 |
max = 10000; |
case DLG_GLOBAL : |
682 |
|
config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0); |
683 |
|
config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0); |
684 |
|
config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); |
685 |
|
config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval); |
686 |
|
config->min_key_interval = config_get_int(hDlg, IDC_MINKEY, config->min_key_interval); |
687 |
|
config->lum_masking = ISDLGSET(IDC_LUMMASK); |
688 |
|
config->interlacing = ISDLGSET(IDC_INTERLACING); |
689 |
break; |
break; |
690 |
|
|
691 |
case DLG_MODE_VBR_QUAL : |
case DLG_QUANT : |
692 |
max = 100; |
config->min_iquant = config_get_int(hDlg, IDC_MINIQUANT, config->min_iquant); |
693 |
break; |
config->max_iquant = config_get_int(hDlg, IDC_MAXIQUANT, config->max_iquant); |
694 |
|
config->min_pquant = config_get_int(hDlg, IDC_MINPQUANT, config->min_pquant); |
695 |
|
config->max_pquant = config_get_int(hDlg, IDC_MAXPQUANT, config->max_pquant); |
696 |
|
|
697 |
case DLG_MODE_VBR_QUANT : |
CONSTRAINVAL(config->min_iquant, 1, 31); |
698 |
max = 31; |
CONSTRAINVAL(config->max_iquant, config->min_iquant, 31); |
699 |
|
CONSTRAINVAL(config->min_pquant, 1, 31); |
700 |
|
CONSTRAINVAL(config->max_pquant, config->min_pquant, 31); |
701 |
break; |
break; |
|
} |
|
702 |
|
|
703 |
if (value < 1) |
case DLG_2PASS : |
704 |
|
config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE); |
705 |
|
config->discard1pass = ISDLGSET(IDC_DISCARD1PASS); |
706 |
|
config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS); |
707 |
|
config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); |
708 |
|
config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); |
709 |
|
config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); |
710 |
|
config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP); |
711 |
|
config->hinted_me = ISDLGSET(IDC_HINTEDME); |
712 |
|
|
713 |
|
if (GetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile, MAX_PATH) == 0) |
714 |
{ |
{ |
715 |
value = 1; |
lstrcpy(config->hintfile, CONFIG_HINTFILE); |
716 |
} |
} |
717 |
if (value > max) |
if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0) |
718 |
{ |
{ |
719 |
value = max; |
lstrcpy(config->stats1, CONFIG_2PASS_1_FILE); |
|
SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE); |
|
|
} |
|
|
|
|
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, value); |
|
720 |
} |
} |
721 |
else if ((LOWORD(wParam) == IDC_2PASS_STATS1_BROWSE || LOWORD(wParam) == IDC_2PASS_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED) |
if (GetDlgItemText(hDlg, IDC_STATS2, config->stats2, MAX_PATH) == 0) |
722 |
{ |
{ |
723 |
OPENFILENAME ofn; |
lstrcpy(config->stats2, CONFIG_2PASS_2_FILE); |
724 |
char tmp[MAX_PATH]; |
} |
|
int hComponent = (LOWORD(wParam) == IDC_2PASS_STATS1_BROWSE ? IDC_2PASS_STATS1 : IDC_2PASS_STATS2 ); |
|
725 |
|
|
726 |
GetDlgItemText(hDlg, hComponent, tmp, MAX_PATH); |
CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000); |
727 |
|
CONSTRAINVAL(config->keyframe_boost, 0, 1000); |
728 |
|
CONSTRAINVAL(config->curve_compression_high, 0, 100); |
729 |
|
CONSTRAINVAL(config->curve_compression_low, 0, 100); |
730 |
|
break; |
731 |
|
|
732 |
memset(&ofn, 0, sizeof(OPENFILENAME)); |
case DLG_2PASSALT : |
733 |
ofn.lStructSize = sizeof(OPENFILENAME); |
config->use_alt_curve = ISDLGSET(IDC_USEALT); |
734 |
|
|
735 |
ofn.hwndOwner = hDlg; |
config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO); |
736 |
ofn.lpstrFilter = "bitrate curve (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0"; |
config->alt_curve_auto_str = config_get_int(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str); |
|
ofn.lpstrFile = tmp; |
|
|
ofn.nMaxFile = MAX_PATH; |
|
|
ofn.Flags = OFN_PATHMUSTEXIST; |
|
737 |
|
|
738 |
// display save box for stats1 using 1st-pass |
config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS); |
739 |
if (LOWORD(wParam) == IDC_2PASS_STATS1_BROWSE && |
config->alt_curve_bonus_bias = config_get_int(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias); |
740 |
SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0) == DLG_MODE_2PASS_1) |
|
741 |
{ |
config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0); |
742 |
ofn.Flags |= OFN_OVERWRITEPROMPT; |
config->alt_curve_high_dist = config_get_int(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist); |
743 |
if (GetSaveFileName(&ofn)) |
config->alt_curve_low_dist = config_get_int(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist); |
744 |
|
config->alt_curve_min_rel_qual = config_get_int(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual); |
745 |
|
|
746 |
|
config->twopass_max_bitrate /= CONFIG_KBPS; |
747 |
|
config->twopass_max_bitrate = config_get_int(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate); |
748 |
|
config->twopass_max_bitrate *= CONFIG_KBPS; |
749 |
|
config->twopass_max_overflow_improvement = config_get_int(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement); |
750 |
|
config->twopass_max_overflow_degradation = config_get_int(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation); |
751 |
|
|
752 |
|
CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80); |
753 |
|
CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80); |
754 |
|
break; |
755 |
|
|
756 |
|
case DLG_CREDITS : |
757 |
|
config->credits_start = ISDLGSET(IDC_CREDITS_START); |
758 |
|
config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE); |
759 |
|
config->credits_start_end = config_get_int(hDlg, IDC_CREDITS_START_END, config->credits_start_end); |
760 |
|
config->credits_end = ISDLGSET(IDC_CREDITS_END); |
761 |
|
config->credits_end_begin = config_get_int(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin); |
762 |
|
config->credits_end_end = config_get_int(hDlg, IDC_CREDITS_END_END, config->credits_end_end); |
763 |
|
|
764 |
|
config->credits_rate = config_get_int(hDlg, IDC_CREDITS_RATE, config->credits_rate); |
765 |
|
config->credits_quant_i = config_get_int(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i); |
766 |
|
config->credits_quant_p = config_get_int(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p); |
767 |
|
config->credits_start_size = config_get_int(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size); |
768 |
|
config->credits_end_size = config_get_int(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size); |
769 |
|
|
770 |
|
config->credits_mode = 0; |
771 |
|
config->credits_mode = ISDLGSET(IDC_CREDITS_RATE_RADIO) ? CREDITS_MODE_RATE : config->credits_mode; |
772 |
|
config->credits_mode = ISDLGSET(IDC_CREDITS_QUANT_RADIO) ? CREDITS_MODE_QUANT : config->credits_mode; |
773 |
|
config->credits_mode = ISDLGSET(IDC_CREDITS_SIZE_RADIO) ? CREDITS_MODE_SIZE : config->credits_mode; |
774 |
|
|
775 |
|
CONSTRAINVAL(config->credits_rate, 1, 100); |
776 |
|
CONSTRAINVAL(config->credits_quant_i, 1, 31); |
777 |
|
CONSTRAINVAL(config->credits_quant_p, 1, 31); |
778 |
|
|
779 |
|
if (config->credits_start_begin > config->credits_start_end) |
780 |
{ |
{ |
781 |
SetDlgItemText(hDlg, hComponent, tmp); |
config->credits_start_begin = config->credits_start_end; |
782 |
} |
config->credits_start = 0; |
783 |
} |
} |
784 |
else |
if (config->credits_end_begin > config->credits_end_end) |
785 |
{ |
{ |
786 |
ofn.Flags |= OFN_FILEMUSTEXIST; |
config->credits_end_begin = config->credits_end_end; |
787 |
if (GetOpenFileName(&ofn)) { |
config->credits_end = 0; |
|
SetDlgItemText(hDlg, hComponent, tmp); |
|
788 |
} |
} |
789 |
|
break; |
790 |
|
|
791 |
|
case DLG_CPU : |
792 |
|
config->cpu = 0; |
793 |
|
config->cpu |= ISDLGSET(IDC_CPU_MMX) ? XVID_CPU_MMX : 0; |
794 |
|
config->cpu |= ISDLGSET(IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT: 0; |
795 |
|
config->cpu |= ISDLGSET(IDC_CPU_SSE) ? XVID_CPU_SSE: 0; |
796 |
|
config->cpu |= ISDLGSET(IDC_CPU_SSE2) ? XVID_CPU_SSE2: 0; |
797 |
|
config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0; |
798 |
|
config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0; |
799 |
|
config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0; |
800 |
|
|
801 |
|
config->rc_reaction_delay_factor = config_get_int(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor); |
802 |
|
config->rc_averaging_period = config_get_int(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period); |
803 |
|
config->rc_buffer = config_get_int(hDlg, IDC_CBR_BUFFER, config->rc_buffer); |
804 |
|
break; |
805 |
} |
} |
806 |
} |
} |
807 |
else if (LOWORD(wParam) == IDC_CREDITS && HIWORD(wParam) == BN_CLICKED) |
|
808 |
|
|
809 |
|
void quant_upload(HWND hDlg, CONFIG* config) |
810 |
{ |
{ |
811 |
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CREDITS), hDlg, credits_proc, (LPARAM)psi->config); |
int i; |
812 |
} |
|
813 |
else if (LOWORD(wParam) == IDC_2PASS_INT && HIWORD(wParam) == BN_CLICKED) |
for (i=0 ; i<64 ; ++i) |
814 |
{ |
{ |
815 |
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_2PASS), hDlg, twopass_proc, (LPARAM)psi->config); |
SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE); |
816 |
|
SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE); |
817 |
} |
} |
|
else if (LOWORD(wParam) == IDC_QUANTMATRIX && HIWORD(wParam) == BN_CLICKED) |
|
|
{ |
|
|
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config); |
|
818 |
} |
} |
819 |
else if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED) |
|
820 |
|
|
821 |
|
void quant_download(HWND hDlg, CONFIG* config) |
822 |
{ |
{ |
823 |
ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL); |
int i; |
|
} |
|
|
break; |
|
824 |
|
|
825 |
case WM_HSCROLL: |
for (i=0 ; i<64 ; ++i) |
|
if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER)) |
|
826 |
{ |
{ |
827 |
SetDlgItemInt(hDlg, IDC_VALUE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE); |
int temp; |
828 |
|
|
829 |
|
temp = config_get_int(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]); |
830 |
|
CONSTRAINVAL(temp, 1, 255); |
831 |
|
temp = config->qmatrix_intra[i]; |
832 |
|
|
833 |
|
temp = config_get_int(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]); |
834 |
|
CONSTRAINVAL(temp, 1, 255); |
835 |
|
temp = config->qmatrix_inter[i]; |
836 |
} |
} |
|
else |
|
|
{ |
|
|
return 0; |
|
837 |
} |
} |
|
break; |
|
838 |
|
|
839 |
case WM_NOTIFY : |
|
840 |
switch (((NMHDR *)lParam)->code) |
/* enumerates child windows, assigns tooltips */ |
841 |
|
|
842 |
|
BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam) |
843 |
{ |
{ |
844 |
case PSN_KILLACTIVE : |
char help[500]; |
|
/* validate */ |
|
|
config_download(hDlg, psi->page, psi->config); |
|
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
|
|
break; |
|
845 |
|
|
846 |
case PSN_APPLY : |
if (LoadString(hInst, GetDlgCtrlID(hWnd), help, 500)) |
847 |
/* apply */ |
{ |
848 |
config_download(hDlg, psi->page, psi->config); |
TOOLINFO ti; |
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
|
|
config_reg_set(psi->config); |
|
|
psi->config->save = TRUE; |
|
|
break; |
|
|
} |
|
|
break; |
|
849 |
|
|
850 |
default : |
ti.cbSize = sizeof(TOOLINFO); |
851 |
return 0; |
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND; |
852 |
|
ti.hwnd = GetParent(hWnd); |
853 |
|
ti.uId = (LPARAM)hWnd; |
854 |
|
ti.lpszText = help; |
855 |
|
|
856 |
|
SendMessage(hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti); |
857 |
} |
} |
858 |
|
|
859 |
return 1; |
return TRUE; |
860 |
} |
} |
861 |
|
|
862 |
|
|
863 |
/* credits dialog proc */ |
/* main dialog proc */ |
864 |
|
|
865 |
BOOL CALLBACK credits_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
866 |
{ |
{ |
867 |
CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); |
CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); |
868 |
|
|
873 |
|
|
874 |
config = (CONFIG*)lParam; |
config = (CONFIG*)lParam; |
875 |
|
|
876 |
CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - CBR"); |
877 |
SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quality"); |
878 |
SetDlgItemInt(hDlg, IDC_CREDITS_START_END, config->credits_start_end, FALSE); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quantizer"); |
879 |
CheckDlgButton(hDlg, IDC_CREDITS_END, config->credits_end ? BST_CHECKED : BST_UNCHECKED); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 1st pass"); |
880 |
SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Ext."); |
881 |
SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Int."); |
882 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed"); |
883 |
|
|
884 |
SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE); |
SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); |
|
SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size, FALSE); |
|
885 |
|
|
886 |
switch (config->credits_mode) |
InitCommonControls(); |
|
{ |
|
|
case CREDITS_MODE_RATE : |
|
|
CheckDlgButton(hDlg, IDC_CREDITS_RATE_RADIO, BST_CHECKED); |
|
|
break; |
|
887 |
|
|
888 |
case CREDITS_MODE_QUANT : |
if (hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP, |
889 |
CheckDlgButton(hDlg, IDC_CREDITS_QUANT_RADIO, BST_CHECKED); |
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
890 |
break; |
NULL, NULL, hInst, NULL)) |
891 |
|
{ |
892 |
|
SetWindowPos(hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); |
893 |
|
SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0)); |
894 |
|
SendMessage(hTooltip, TTM_SETMAXTIPWIDTH, 0, 400); |
895 |
|
|
896 |
case CREDITS_MODE_SIZE : |
EnumChildWindows(hDlg, enum_tooltips, 0); |
|
CheckDlgButton(hDlg, IDC_CREDITS_SIZE_RADIO, BST_CHECKED); |
|
|
break; |
|
897 |
} |
} |
898 |
|
|
899 |
credits_controls(hDlg); |
main_slider(hDlg, config); |
900 |
|
main_value(hDlg, config); |
901 |
break; |
break; |
902 |
|
|
903 |
case WM_COMMAND : |
case WM_HSCROLL : |
904 |
if (LOWORD(wParam) == IDCANCEL) |
if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER)) |
905 |
{ |
{ |
906 |
EndDialog(hDlg, IDCANCEL); |
SetDlgItemInt(hDlg, IDC_VALUE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE); |
907 |
} |
} |
908 |
else if (HIWORD(wParam) == BN_CLICKED) |
else |
|
{ |
|
|
switch (LOWORD(wParam)) |
|
909 |
{ |
{ |
910 |
case IDC_CREDITS_START : |
return 0; |
911 |
case IDC_CREDITS_END : |
} |
|
case IDC_CREDITS_RATE_RADIO : |
|
|
case IDC_CREDITS_QUANT_RADIO : |
|
|
case IDC_CREDITS_SIZE_RADIO : |
|
|
credits_controls(hDlg); |
|
912 |
break; |
break; |
913 |
|
|
914 |
case IDOK : |
case WM_COMMAND : |
915 |
config->credits_start = ISDLGSET(IDC_CREDITS_START); |
if (LOWORD(wParam) == IDC_MODE && HIWORD(wParam) == LBN_SELCHANGE) |
|
config->credits_start_begin = config_get_int(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin); |
|
|
config->credits_start_end = config_get_int(hDlg, IDC_CREDITS_START_END, config->credits_start_end); |
|
|
config->credits_end = ISDLGSET(IDC_CREDITS_END); |
|
|
config->credits_end_begin = config_get_int(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin); |
|
|
config->credits_end_end = config_get_int(hDlg, IDC_CREDITS_END_END, config->credits_end_end); |
|
|
|
|
|
config->credits_rate = config_get_int(hDlg, IDC_CREDITS_RATE, config->credits_rate); |
|
|
config->credits_quant_i = config_get_int(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i); |
|
|
config->credits_quant_p = config_get_int(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p); |
|
|
config->credits_start_size = config_get_int(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size); |
|
|
config->credits_end_size = config_get_int(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size); |
|
|
|
|
|
if (ISDLGSET(IDC_CREDITS_RATE_RADIO)) |
|
916 |
{ |
{ |
917 |
config->credits_mode = CREDITS_MODE_RATE; |
main_download(hDlg, config); |
918 |
|
main_slider(hDlg, config); |
919 |
|
main_value(hDlg, config); |
920 |
} |
} |
921 |
if (ISDLGSET(IDC_CREDITS_QUANT_RADIO)) |
else if (LOWORD(wParam) == IDC_ADVANCED && HIWORD(wParam) == BN_CLICKED) |
922 |
{ |
{ |
923 |
config->credits_mode = CREDITS_MODE_QUANT; |
adv_dialog(hDlg, config); |
924 |
|
|
925 |
|
if (config->save) |
926 |
|
{ |
927 |
|
config_reg_set(config); |
928 |
|
} |
929 |
} |
} |
930 |
if (ISDLGSET(IDC_CREDITS_SIZE_RADIO)) |
else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED) |
931 |
{ |
{ |
932 |
config->credits_mode = CREDITS_MODE_SIZE; |
config_reg_default(config); |
933 |
|
|
934 |
|
SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); |
935 |
|
|
936 |
|
main_slider(hDlg, config); |
937 |
|
main_value(hDlg, config); |
938 |
} |
} |
939 |
|
else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE) |
940 |
|
{ |
941 |
|
int value = config_get_int(hDlg, IDC_VALUE, 1); |
942 |
|
int max = 1; |
943 |
|
|
944 |
CONSTRAINVAL(config->credits_rate, 1, 100) |
max = (config->mode == DLG_MODE_CBR) ? 10000 : |
945 |
CONSTRAINVAL(config->credits_quant_i, 1, 31) |
((config->mode == DLG_MODE_VBR_QUAL) ? 100 : |
946 |
CONSTRAINVAL(config->credits_quant_p, 1, 31) |
((config->mode == DLG_MODE_VBR_QUANT) ? 31 : 1<<30)); |
947 |
|
|
948 |
if (config->credits_start_begin > config->credits_start_end) |
if (value < 1) |
949 |
{ |
{ |
950 |
config->credits_start_begin = config->credits_start_end; |
value = 1; |
|
config->credits_start = 0; |
|
951 |
} |
} |
952 |
if (config->credits_end_begin > config->credits_end_end) |
if (value > max) |
953 |
{ |
{ |
954 |
config->credits_end_begin = config->credits_end_end; |
value = max; |
955 |
config->credits_end = 0; |
SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE); |
956 |
} |
} |
957 |
|
|
958 |
|
if (config->mode != DLG_MODE_2PASS_2_INT) |
959 |
|
{ |
960 |
|
SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, value); |
961 |
|
} |
962 |
|
} |
963 |
|
else if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED) |
964 |
|
{ |
965 |
|
main_download(hDlg, config); |
966 |
|
config->save = TRUE; |
967 |
EndDialog(hDlg, IDOK); |
EndDialog(hDlg, IDOK); |
|
break; |
|
968 |
} |
} |
969 |
|
else if (LOWORD(wParam) == IDCANCEL) |
970 |
|
{ |
971 |
|
config->save = FALSE; |
972 |
|
EndDialog(hDlg, IDCANCEL); |
973 |
} |
} |
974 |
break; |
break; |
975 |
|
|
981 |
} |
} |
982 |
|
|
983 |
|
|
984 |
/* 2-pass dialog proc */ |
/* advanced dialog proc */ |
985 |
|
|
986 |
BOOL CALLBACK twopass_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
987 |
{ |
{ |
988 |
CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); |
PROPSHEETINFO *psi; |
989 |
|
|
990 |
|
psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA); |
991 |
|
|
992 |
switch (uMsg) |
switch (uMsg) |
993 |
{ |
{ |
994 |
case WM_INITDIALOG : |
case WM_INITDIALOG : |
995 |
SetWindowLong(hDlg, GWL_USERDATA, lParam); |
psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam; |
996 |
|
|
997 |
config = (CONFIG*)lParam; |
SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi); |
998 |
|
|
999 |
SetDlgItemInt(hDlg, IDC_DESIRED, config->desired_size, FALSE); |
if (psi->page == DLG_GLOBAL) |
1000 |
SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE); |
{ |
1001 |
SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE); |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None"); |
1002 |
SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low"); |
1003 |
SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low"); |
1004 |
SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE); |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium"); |
1005 |
CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0)); |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High"); |
1006 |
CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1)); |
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High"); |
1007 |
|
SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High"); |
1008 |
|
|
1009 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263"); |
1010 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG"); |
1011 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom"); |
1012 |
|
SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"Modulated"); |
1013 |
|
|
1014 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID"); |
1015 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX"); |
1016 |
|
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50"); |
1017 |
|
} |
1018 |
|
else if (psi->page == DLG_2PASSALT) |
1019 |
|
{ |
1020 |
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low"); |
1021 |
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium"); |
1022 |
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High"); |
1023 |
|
} |
1024 |
|
|
1025 |
|
if (hTooltip) |
1026 |
|
{ |
1027 |
|
EnumChildWindows(hDlg, enum_tooltips, 0); |
1028 |
|
} |
1029 |
|
|
1030 |
|
adv_upload(hDlg, psi->page, psi->config); |
1031 |
|
adv_mode(hDlg, psi->config->mode); |
1032 |
break; |
break; |
1033 |
|
|
1034 |
case WM_COMMAND : |
case WM_COMMAND : |
1035 |
if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED) |
if (HIWORD(wParam) == BN_CLICKED) |
1036 |
{ |
{ |
1037 |
config->desired_size = config_get_int(hDlg, IDC_DESIRED, config->desired_size); |
switch (LOWORD(wParam)) |
1038 |
config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE); |
{ |
1039 |
config->min_key_interval = config_get_int(hDlg, IDC_MINKEY, config->max_key_interval); |
case IDC_HINTEDME : |
1040 |
config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); |
case IDC_USEALT : |
1041 |
config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); |
case IDC_USEAUTO : |
1042 |
config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); |
case IDC_USEAUTOBONUS : |
1043 |
config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP); |
case IDC_CREDITS_START : |
1044 |
|
case IDC_CREDITS_END : |
1045 |
|
case IDC_CREDITS_RATE_RADIO : |
1046 |
|
case IDC_CREDITS_QUANT_RADIO : |
1047 |
|
case IDC_CREDITS_SIZE_RADIO : |
1048 |
|
case IDC_CPU_AUTO : |
1049 |
|
case IDC_CPU_FORCE : |
1050 |
|
adv_mode(hDlg, psi->config->mode); |
1051 |
|
break; |
1052 |
|
} |
1053 |
|
} |
1054 |
|
if ((LOWORD(wParam) == IDC_HINT_BROWSE || LOWORD(wParam) == IDC_STATS1_BROWSE || LOWORD(wParam) == IDC_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED) |
1055 |
|
{ |
1056 |
|
OPENFILENAME ofn; |
1057 |
|
char tmp[MAX_PATH]; |
1058 |
|
int hComponent = (LOWORD(wParam) == IDC_STATS1_BROWSE ? IDC_STATS1 : IDC_STATS2); |
1059 |
|
|
1060 |
CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000) |
GetDlgItemText(hDlg, hComponent, tmp, MAX_PATH); |
|
CONSTRAINVAL(config->keyframe_boost, 0, 1000) |
|
|
CONSTRAINVAL(config->curve_compression_high, 0, 100) |
|
|
CONSTRAINVAL(config->curve_compression_low, 0, 100) |
|
1061 |
|
|
1062 |
EndDialog(hDlg, IDOK); |
memset(&ofn, 0, sizeof(OPENFILENAME)); |
1063 |
|
ofn.lStructSize = sizeof(OPENFILENAME); |
1064 |
|
|
1065 |
|
ofn.hwndOwner = hDlg; |
1066 |
|
ofn.lpstrFilter = "bitrate curve (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0"; |
1067 |
|
ofn.lpstrFile = tmp; |
1068 |
|
ofn.nMaxFile = MAX_PATH; |
1069 |
|
ofn.Flags = OFN_PATHMUSTEXIST; |
1070 |
|
|
1071 |
|
if (LOWORD(wParam) == IDC_HINT_BROWSE) |
1072 |
|
{ |
1073 |
|
ofn.lpstrFilter = "motion hints (*.mvh)\0*.mvh\0All files (*.*)\0*.*\0\0"; |
1074 |
|
if (GetOpenFileName(&ofn)) |
1075 |
|
{ |
1076 |
|
SetDlgItemText(hDlg, IDC_HINTFILE, tmp); |
1077 |
} |
} |
1078 |
else if (LOWORD(wParam) == IDCANCEL) |
} |
1079 |
|
else if (LOWORD(wParam) == IDC_STATS1_BROWSE && |
1080 |
|
psi->config->mode == DLG_MODE_2PASS_1) |
1081 |
{ |
{ |
1082 |
EndDialog(hDlg, IDCANCEL); |
ofn.Flags |= OFN_OVERWRITEPROMPT; |
1083 |
|
if (GetSaveFileName(&ofn)) |
1084 |
|
{ |
1085 |
|
SetDlgItemText(hDlg, hComponent, tmp); |
1086 |
|
} |
1087 |
|
} |
1088 |
|
else |
1089 |
|
{ |
1090 |
|
ofn.Flags |= OFN_FILEMUSTEXIST; |
1091 |
|
if (GetOpenFileName(&ofn)) { |
1092 |
|
SetDlgItemText(hDlg, hComponent, tmp); |
1093 |
|
} |
1094 |
|
} |
1095 |
|
} |
1096 |
|
else if (LOWORD(wParam) == IDC_QUANTMATRIX && HIWORD(wParam) == BN_CLICKED) |
1097 |
|
{ |
1098 |
|
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config); |
1099 |
|
} |
1100 |
|
break; |
1101 |
|
|
1102 |
|
case WM_NOTIFY : |
1103 |
|
switch (((NMHDR *)lParam)->code) |
1104 |
|
{ |
1105 |
|
case PSN_KILLACTIVE : |
1106 |
|
/* validate */ |
1107 |
|
adv_download(hDlg, psi->page, psi->config); |
1108 |
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
1109 |
|
break; |
1110 |
|
|
1111 |
|
case PSN_APPLY : |
1112 |
|
/* apply */ |
1113 |
|
adv_download(hDlg, psi->page, psi->config); |
1114 |
|
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); |
1115 |
|
psi->config->save = TRUE; |
1116 |
|
break; |
1117 |
} |
} |
1118 |
break; |
break; |
1119 |
|
|
1135 |
{ |
{ |
1136 |
case WM_INITDIALOG : |
case WM_INITDIALOG : |
1137 |
SetWindowLong(hDlg, GWL_USERDATA, lParam); |
SetWindowLong(hDlg, GWL_USERDATA, lParam); |
|
|
|
1138 |
config = (CONFIG*)lParam; |
config = (CONFIG*)lParam; |
|
|
|
1139 |
quant_upload(hDlg, config); |
quant_upload(hDlg, config); |
1140 |
|
|
1141 |
|
if (hTooltip) |
1142 |
|
{ |
1143 |
|
EnumChildWindows(hDlg, enum_tooltips, 0); |
1144 |
|
} |
1145 |
break; |
break; |
1146 |
|
|
1147 |
case WM_COMMAND : |
case WM_COMMAND : |
1148 |
if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED) |
if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED) |
1149 |
{ |
{ |
1150 |
quant_download(hDlg, config); |
quant_download(hDlg, config); |
|
|
|
1151 |
EndDialog(hDlg, IDOK); |
EndDialog(hDlg, IDOK); |
1152 |
} |
} |
1153 |
else if (LOWORD(wParam) == IDCANCEL) |
else if (LOWORD(wParam) == IDCANCEL) |
1186 |
|
|
1187 |
if (hFile == INVALID_HANDLE_VALUE) |
if (hFile == INVALID_HANDLE_VALUE) |
1188 |
{ |
{ |
1189 |
DEBUG("Couldn't save quant matrix"); |
DEBUGERR("Couldn't save quant matrix"); |
1190 |
} |
} |
1191 |
else |
else |
1192 |
{ |
{ |
1193 |
if (!WriteFile(hFile, quant_data, 128, &wrote, 0)) |
if (!WriteFile(hFile, quant_data, 128, &wrote, 0)) |
1194 |
{ |
{ |
1195 |
DEBUG("Couldnt write quant matrix"); |
DEBUGERR("Couldnt write quant matrix"); |
1196 |
} |
} |
1197 |
} |
} |
1198 |
|
|
1208 |
|
|
1209 |
if (hFile == INVALID_HANDLE_VALUE) |
if (hFile == INVALID_HANDLE_VALUE) |
1210 |
{ |
{ |
1211 |
DEBUG("Couldn't load quant matrix"); |
DEBUGERR("Couldn't load quant matrix"); |
1212 |
} |
} |
1213 |
else |
else |
1214 |
{ |
{ |
1215 |
if (!ReadFile(hFile, quant_data, 128, &read, 0)) |
if (!ReadFile(hFile, quant_data, 128, &read, 0)) |
1216 |
{ |
{ |
1217 |
DEBUG("Couldnt read quant matrix"); |
DEBUGERR("Couldnt read quant matrix"); |
1218 |
} |
} |
1219 |
else |
else |
1220 |
{ |
{ |
1236 |
|
|
1237 |
return 1; |
return 1; |
1238 |
} |
} |
1239 |
|
|
1240 |
|
|
1241 |
|
/* about dialog proc */ |
1242 |
|
|
1243 |
|
BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
1244 |
|
{ |
1245 |
|
switch (uMsg) |
1246 |
|
{ |
1247 |
|
case WM_INITDIALOG : |
1248 |
|
{ |
1249 |
|
XVID_INIT_PARAM init_param; |
1250 |
|
char core[100]; |
1251 |
|
HFONT hFont; |
1252 |
|
LOGFONT lfData; |
1253 |
|
|
1254 |
|
SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD); |
1255 |
|
|
1256 |
|
xvid_init(NULL, 0, &init_param, 0); |
1257 |
|
wsprintf(core, "Core Version %d.%d", (init_param.api_version>>16),(init_param.api_version&0xFFFFU)); |
1258 |
|
SetDlgItemText(hDlg, IDC_CORE, core); |
1259 |
|
|
1260 |
|
hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L); |
1261 |
|
|
1262 |
|
if (GetObject(hFont, sizeof(LOGFONT), &lfData)) |
1263 |
|
{ |
1264 |
|
lfData.lfUnderline = 1; |
1265 |
|
|
1266 |
|
hFont = CreateFontIndirect(&lfData); |
1267 |
|
if (hFont) |
1268 |
|
{ |
1269 |
|
SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L); |
1270 |
|
} |
1271 |
|
} |
1272 |
|
|
1273 |
|
SetClassLong(GetDlgItem(hDlg, IDC_WEBSITE), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); |
1274 |
|
SetDlgItemText(hDlg, IDC_WEBSITE, XVID_WEBSITE); |
1275 |
|
} |
1276 |
|
break; |
1277 |
|
|
1278 |
|
case WM_CTLCOLORSTATIC : |
1279 |
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_WEBSITE)) |
1280 |
|
{ |
1281 |
|
SetBkMode((HDC)wParam, TRANSPARENT) ; |
1282 |
|
SetTextColor((HDC)wParam, RGB(0x00,0x00,0xc0)); |
1283 |
|
return (BOOL)GetStockObject(NULL_BRUSH); |
1284 |
|
} |
1285 |
|
return 0; |
1286 |
|
|
1287 |
|
case WM_COMMAND : |
1288 |
|
if (LOWORD(wParam) == IDC_WEBSITE && HIWORD(wParam) == STN_CLICKED) |
1289 |
|
{ |
1290 |
|
ShellExecute(hDlg, "open", XVID_WEBSITE, NULL, NULL, SW_SHOWNORMAL); |
1291 |
|
} |
1292 |
|
else if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) |
1293 |
|
{ |
1294 |
|
EndDialog(hDlg, LOWORD(wParam)); |
1295 |
|
} |
1296 |
|
break; |
1297 |
|
|
1298 |
|
default : |
1299 |
|
return 0; |
1300 |
|
} |
1301 |
|
|
1302 |
|
return 1; |
1303 |
|
} |