60 |
#include <shlobj.h> |
#include <shlobj.h> |
61 |
#include <prsht.h> |
#include <prsht.h> |
62 |
|
|
63 |
#include <stdio.h> // sprintf |
#include <stdio.h> /* sprintf */ |
64 |
#include <xvid.h> // XviD API |
#include <xvid.h> /* XviD API */ |
65 |
|
|
66 |
#include "debug.h" |
#include "debug.h" |
67 |
#include "codec.h" |
#include "codec.h" |
148 |
static const REG_INT reg_ints[] = { |
static const REG_INT reg_ints[] = { |
149 |
{"mode", ®.mode, RC_MODE_1PASS}, |
{"mode", ®.mode, RC_MODE_1PASS}, |
150 |
{"bitrate", ®.bitrate, 700}, |
{"bitrate", ®.bitrate, 700}, |
151 |
|
/* {"desired_size", ®.desired_size, 570000}, not used */ |
152 |
|
|
153 |
{"rc_reaction_delay_factor",®.rc_reaction_delay_factor, 16}, |
{"rc_reaction_delay_factor",®.rc_reaction_delay_factor, 16}, |
154 |
{"rc_averaging_period", ®.rc_averaging_period, 100}, |
{"rc_averaging_period", ®.rc_averaging_period, 100}, |
171 |
{"bquant_offset", ®.bquant_offset, 100}, /* 100-base float */ |
{"bquant_offset", ®.bquant_offset, 100}, /* 100-base float */ |
172 |
{"packed", ®.packed, 0}, |
{"packed", ®.packed, 0}, |
173 |
{"closed_gov", ®.closed_gov, 1}, |
{"closed_gov", ®.closed_gov, 1}, |
174 |
{"debug", ®.debug, 0}, |
{"vop_debug", ®.vop_debug, 0}, |
175 |
|
{"debug", ®.debug, 0x0}, |
176 |
{"reduced_resolution", ®.reduced_resolution, 0}, |
{"reduced_resolution", ®.reduced_resolution, 0}, |
177 |
{"frame_drop_ratio", ®.frame_drop_ratio, 0}, |
{"frame_drop_ratio", ®.frame_drop_ratio, 0}, |
178 |
|
|
184 |
{"max_bquant", ®.max_bquant, 31}, |
{"max_bquant", ®.max_bquant, 31}, |
185 |
{"trellis_quant", ®.trellis_quant, 0}, |
{"trellis_quant", ®.trellis_quant, 0}, |
186 |
|
|
|
{"desired_size", ®.desired_size, 570000}, |
|
187 |
{"keyframe_boost", ®.keyframe_boost, 0}, |
{"keyframe_boost", ®.keyframe_boost, 0}, |
188 |
{"discard1pass", ®.discard1pass, 1}, |
{"discard1pass", ®.discard1pass, 1}, |
189 |
{"kftreshold", ®.kftreshold, 10}, |
{"kftreshold", ®.kftreshold, 10}, |
190 |
{"kfreduction", ®.kfreduction, 20}, |
{"kfreduction", ®.kfreduction, 20}, |
191 |
{"curve_compression_high", ®.curve_compression_high, 0}, |
{"curve_compression_high", ®.curve_compression_high, 0}, |
192 |
{"curve_compression_low", ®.curve_compression_low, 0}, |
{"curve_compression_low", ®.curve_compression_low, 0}, |
|
{"use_alt_curve", ®.use_alt_curve, 0}, |
|
|
{"alt_curve_use_auto", ®.alt_curve_use_auto, 1}, |
|
|
{"alt_curve_auto_str", ®.alt_curve_auto_str, 30}, |
|
|
{"alt_curve_use_auto_bonus_bias", ®.alt_curve_use_auto_bonus_bias, 1}, |
|
|
{"alt_curve_bonus_bias", ®.alt_curve_bonus_bias, 50}, |
|
|
{"alt_curve_type", ®.alt_curve_type, 1}, |
|
|
{"alt_curve_high_dist", ®.alt_curve_high_dist, 500}, |
|
|
{"alt_curve_low_dist", ®.alt_curve_low_dist, 90}, |
|
|
{"alt_curve_min_rel_qual", ®.alt_curve_min_rel_qual, 50}, |
|
193 |
{"bitrate_payback_delay", ®.bitrate_payback_delay, 250}, |
{"bitrate_payback_delay", ®.bitrate_payback_delay, 250}, |
194 |
{"bitrate_payback_method", ®.bitrate_payback_method, 0}, |
{"bitrate_payback_method", ®.bitrate_payback_method, XVID_PAYBACK_BIAS }, |
195 |
{"twopass_max_overflow_improvement", ®.twopass_max_overflow_improvement, 60}, |
{"twopass_max_overflow_improvement", ®.twopass_max_overflow_improvement, 60}, |
196 |
{"twopass_max_overflow_degradation", ®.twopass_max_overflow_degradation, 60}, |
{"twopass_max_overflow_degradation", ®.twopass_max_overflow_degradation, 60}, |
197 |
|
|
198 |
{"num_zones", ®.num_zones, 1}, |
{"num_zones", ®.num_zones, 1}, |
199 |
}; |
}; |
200 |
|
|
427 |
} |
} |
428 |
|
|
429 |
|
|
430 |
|
#define HEX_BUF_SZ 16 |
431 |
|
unsigned int get_dlgitem_hex(HWND hDlg, UINT item, unsigned int def) |
432 |
|
{ |
433 |
|
char buf[HEX_BUF_SZ]; |
434 |
|
unsigned int value; |
435 |
|
|
436 |
|
if (GetDlgItemText(hDlg, item, buf, HEX_BUF_SZ) == 0) |
437 |
|
return def; |
438 |
|
|
439 |
|
if (sscanf(buf,"0x%x", &value)==1 || sscanf(buf,"%x", &value)==1) { |
440 |
|
return value; |
441 |
|
} |
442 |
|
|
443 |
|
return def; |
444 |
|
} |
445 |
|
|
446 |
|
void set_dlgitem_hex(HWND hDlg, UINT item, int value) |
447 |
|
{ |
448 |
|
char buf[HEX_BUF_SZ]; |
449 |
|
wsprintf(buf, "0x%x", value); |
450 |
|
SetDlgItemText(hDlg, item, buf); |
451 |
|
} |
452 |
|
|
453 |
/* ===================================================================================== */ |
/* ===================================================================================== */ |
454 |
/* QUANT MATRIX DIALOG ================================================================= */ |
/* QUANT MATRIX DIALOG ================================================================= */ |
455 |
/* ===================================================================================== */ |
/* ===================================================================================== */ |
618 |
SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name); |
SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name); |
619 |
break; |
break; |
620 |
|
|
|
case IDD_RC_2PASS2_ALT : |
|
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low"); |
|
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium"); |
|
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High"); |
|
|
break; |
|
|
|
|
621 |
case IDD_ZONE : |
case IDD_ZONE : |
622 |
EnableDlgWindow(hDlg, IDC_ZONE_FETCH, |
EnableDlgWindow(hDlg, IDC_ZONE_FETCH, |
623 |
config->cur_zone>0 && config->ci_valid && config->ci.ciActiveFrame>0); |
config->cur_zone>0 && config->ci_valid && config->ci.ciActiveFrame>0); |
657 |
void adv_mode(HWND hDlg, int idd, CONFIG * config) |
void adv_mode(HWND hDlg, int idd, CONFIG * config) |
658 |
{ |
{ |
659 |
int profile; |
int profile; |
|
int use_alt, use_alt_auto, use_alt_auto_bonus; |
|
660 |
int weight_en, quant_en; |
int weight_en, quant_en; |
661 |
int cpu_force; |
int cpu_force; |
662 |
int custom_quant, bvops; |
int custom_quant, bvops; |
698 |
SetDlgItemInt(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate, FALSE); |
SetDlgItemInt(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate, FALSE); |
699 |
break; |
break; |
700 |
|
|
|
case IDD_RC_2PASS2_ALT : |
|
|
use_alt = IsDlgChecked(hDlg, IDC_USEALT); |
|
|
use_alt_auto = IsDlgChecked(hDlg, IDC_USEAUTO); |
|
|
use_alt_auto_bonus = IsDlgChecked(hDlg, IDC_USEAUTOBONUS); |
|
|
EnableDlgWindow(hDlg, IDC_USEAUTO, use_alt); |
|
|
EnableDlgWindow(hDlg, IDC_AUTOSTR, use_alt && use_alt_auto); |
|
|
EnableDlgWindow(hDlg, IDC_USEAUTOBONUS, use_alt); |
|
|
EnableDlgWindow(hDlg, IDC_BONUSBIAS, use_alt && !use_alt_auto_bonus); |
|
|
EnableDlgWindow(hDlg, IDC_CURVETYPE, use_alt); |
|
|
EnableDlgWindow(hDlg, IDC_ALTCURVEHIGH, use_alt); |
|
|
EnableDlgWindow(hDlg, IDC_ALTCURVELOW, use_alt); |
|
|
EnableDlgWindow(hDlg, IDC_MINQUAL, use_alt && !use_alt_auto); |
|
|
break; |
|
|
|
|
701 |
case IDD_ZONE : |
case IDD_ZONE : |
702 |
weight_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT); |
weight_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT); |
703 |
quant_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT); |
quant_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT); |
785 |
SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); |
SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); |
786 |
SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); |
SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); |
787 |
SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE); |
SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE); |
788 |
CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0)); |
CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == XVID_PAYBACK_BIAS)); |
789 |
CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1)); |
CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == XVID_PAYBACK_PROP)); |
|
break; |
|
|
|
|
|
case IDD_RC_2PASS2_ALT : |
|
|
CheckDlg(hDlg, IDC_USEALT, config->use_alt_curve); |
|
|
|
|
|
SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0); |
|
|
SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE); |
|
|
SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE); |
|
|
|
|
|
CheckDlg(hDlg, IDC_USEAUTO, config->alt_curve_use_auto); |
|
|
SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE); |
|
|
|
|
|
CheckDlg(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias); |
|
|
SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE); |
|
790 |
break; |
break; |
791 |
|
|
792 |
case IDD_ZONE : |
case IDD_ZONE : |
838 |
|
|
839 |
SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE); |
SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE); |
840 |
|
|
841 |
CheckDlg(hDlg, IDC_DEBUG, config->debug); |
CheckDlg(hDlg, IDC_VOPDEBUG, config->vop_debug); |
842 |
|
set_dlgitem_hex(hDlg, IDC_DEBUG, config->debug); |
843 |
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0); |
SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0); |
844 |
break; |
break; |
845 |
} |
} |
902 |
config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); |
config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); |
903 |
config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); |
config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); |
904 |
config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); |
config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); |
905 |
config->bitrate_payback_method = IsDlgChecked(hDlg, IDC_PAYBACKPROP); |
config->bitrate_payback_method = IsDlgChecked(hDlg, IDC_PAYBACKPROP) ? XVID_PAYBACK_PROP : XVID_PAYBACK_BIAS; |
906 |
|
|
907 |
CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000); |
CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000); |
908 |
CONSTRAINVAL(config->keyframe_boost, 0, 1000); |
CONSTRAINVAL(config->keyframe_boost, 0, 1000); |
910 |
CONSTRAINVAL(config->curve_compression_low, 0, 100); |
CONSTRAINVAL(config->curve_compression_low, 0, 100); |
911 |
break; |
break; |
912 |
|
|
|
case IDD_RC_2PASS2_ALT : |
|
|
config->use_alt_curve = IsDlgChecked(hDlg, IDC_USEALT); |
|
|
|
|
|
config->alt_curve_use_auto = IsDlgChecked(hDlg, IDC_USEAUTO); |
|
|
config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str); |
|
|
|
|
|
config->alt_curve_use_auto_bonus_bias = IsDlgChecked(hDlg, IDC_USEAUTOBONUS); |
|
|
config->alt_curve_bonus_bias = config_get_uint(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias); |
|
|
|
|
|
config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0); |
|
|
config->alt_curve_high_dist = config_get_uint(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist); |
|
|
config->alt_curve_low_dist = config_get_uint(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist); |
|
|
config->alt_curve_min_rel_qual = config_get_uint(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual); |
|
|
break; |
|
|
|
|
913 |
case IDD_ZONE : |
case IDD_ZONE : |
914 |
config->zones[config->cur_zone].frame = config_get_uint(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame); |
config->zones[config->cur_zone].frame = config_get_uint(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame); |
915 |
|
|
970 |
config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads); |
config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads); |
971 |
|
|
972 |
config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); |
config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); |
973 |
config->debug = IsDlgChecked(hDlg, IDC_DEBUG); |
config->vop_debug = IsDlgChecked(hDlg, IDC_VOPDEBUG); |
974 |
|
config->debug = get_dlgitem_hex(hDlg, IDC_DEBUG, config->debug); |
975 |
break; |
break; |
976 |
} |
} |
977 |
} |
} |
1004 |
switch (LOWORD(wParam)) |
switch (LOWORD(wParam)) |
1005 |
{ |
{ |
1006 |
case IDC_BVOP : |
case IDC_BVOP : |
|
case IDC_USEALT : |
|
|
case IDC_USEAUTO : |
|
|
case IDC_USEAUTOBONUS : |
|
1007 |
case IDC_ZONE_MODE_WEIGHT : |
case IDC_ZONE_MODE_WEIGHT : |
1008 |
case IDC_ZONE_MODE_QUANT : |
case IDC_ZONE_MODE_QUANT : |
1009 |
case IDC_ZONE_BVOPTHRESHOLD_ENABLE : |
case IDC_ZONE_BVOPTHRESHOLD_ENABLE : |
1263 |
static const int profile_dlgs[] = { IDD_PROFILE, IDD_LEVEL }; |
static const int profile_dlgs[] = { IDD_PROFILE, IDD_LEVEL }; |
1264 |
static const int single_dlgs[] = { IDD_RC_CBR }; |
static const int single_dlgs[] = { IDD_RC_CBR }; |
1265 |
static const int pass1_dlgs[] = { IDD_RC_2PASS1 }; |
static const int pass1_dlgs[] = { IDD_RC_2PASS1 }; |
1266 |
static const int pass2_dlgs[] = { IDD_RC_2PASS2, IDD_RC_2PASS2_ALT}; |
static const int pass2_dlgs[] = { IDD_RC_2PASS2 }; |
1267 |
static const int zone_dlgs[] = { IDD_ZONE }; |
static const int zone_dlgs[] = { IDD_ZONE }; |
1268 |
static const int bitrate_dlgs[] = { IDD_CALC }; |
static const int bitrate_dlgs[] = { IDD_CALC }; |
1269 |
static const int adv_dlgs[] = { IDD_MOTION, IDD_QUANT, IDD_DEBUG}; |
static const int adv_dlgs[] = { IDD_MOTION, IDD_QUANT, IDD_DEBUG}; |
1324 |
LVCOLUMN lvc; |
LVCOLUMN lvc; |
1325 |
int i; |
int i; |
1326 |
|
|
1327 |
// Initialize the LVCOLUMN structure. |
/* Initialize the LVCOLUMN structure. */ |
1328 |
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; |
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; |
1329 |
lvc.fmt = LVCFMT_LEFT; |
lvc.fmt = LVCFMT_LEFT; |
1330 |
|
|
1331 |
// Add the columns. |
/* Add the columns. */ |
1332 |
for (i=0; i<sizeof(columns)/sizeof(char_int_t); i++) { |
for (i=0; i<sizeof(columns)/sizeof(char_int_t); i++) { |
1333 |
lvc.pszText = (char*)columns[i].name; |
lvc.pszText = (char*)columns[i].name; |
1334 |
lvc.cchTextMax = strlen(columns[i].name); |
lvc.cchTextMax = strlen(columns[i].name); |