--- trunk/vfw/src/config.c 2002/04/21 10:47:53 131 +++ trunk/vfw/src/config.c 2002/07/27 21:38:19 343 @@ -23,6 +23,7 @@ * * History: * + * 15.06.2002 added bframes options * 21.04.2002 fixed custom matrix support, tried to get dll size down * 17.04.2002 re-enabled lumi masking in 1st pass * 15.04.2002 updated cbr support @@ -58,6 +59,9 @@ #include #include #include +#ifdef _SMP +#include +#endif #include "codec.h" #include "config.h" @@ -65,6 +69,7 @@ #include "resource.h" + /* registry info structs */ CONFIG reg; @@ -85,6 +90,14 @@ {"min_key_interval", ®.min_key_interval, 1}, {"lum_masking", ®.lum_masking, 0}, {"interlacing", ®.interlacing, 0}, +#ifdef BFRAMES + {"max_bframes", ®.max_bframes, -1}, + {"bquant_ratio", ®.bquant_ratio, 200}, + {"packed", ®.packed, 0}, + {"dx50bvop", ®.dx50bvop, 0}, + {"debug", ®.debug, 0}, + {"frame_drop_ratio", ®.frame_drop_ratio, 0}, +#endif {"min_iquant", ®.min_iquant, 1}, {"max_iquant", ®.max_iquant, 31}, @@ -95,6 +108,10 @@ {"keyframe_boost", ®.keyframe_boost, 20}, {"discard1pass", ®.discard1pass, 1}, {"dummy2pass", ®.dummy2pass, 0}, +// added by koepi for new two-pass curve treatment + {"kftreshold", ®.kftreshold, 10}, + {"kfreduction", ®.kfreduction, 30}, +// end of koepi's additions {"curve_compression_high", ®.curve_compression_high, 25}, {"curve_compression_low", ®.curve_compression_low, 10}, {"use_alt_curve", ®.use_alt_curve, 0}, @@ -146,9 +163,13 @@ XVID_INIT_PARAM init_param; int i; - init_param.cpu_flags = 0; + init_param.cpu_flags = XVID_CPU_CHKONLY; xvid_init(0, 0, &init_param, NULL); - config->cpu = init_param.cpu_flags; + reg.cpu = init_param.cpu_flags; + +#ifdef _SMP + reg.num_threads = pthread_num_processors_np(); +#endif RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey); @@ -275,7 +296,17 @@ /* leaves current config value if dialog item is empty */ -int config_get_int(HWND hDlg, UINT item, int config) +int config_get_int(HWND hDlg, INT item, int config) +{ + BOOL success = FALSE; + + int tmp = GetDlgItemInt(hDlg, item, &success, TRUE); + + return (success) ? tmp : config; +} + + +int config_get_uint(HWND hDlg, UINT item, int config) { BOOL success = FALSE; @@ -293,19 +324,19 @@ { default : case DLG_MODE_CBR : - config->rc_bitrate = config_get_int(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS; + config->rc_bitrate = config_get_uint(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS; break; case DLG_MODE_VBR_QUAL : - config->quality = config_get_int(hDlg, IDC_VALUE, config->quality); + config->quality = config_get_uint(hDlg, IDC_VALUE, config->quality); break; case DLG_MODE_VBR_QUANT : - config->quant = config_get_int(hDlg, IDC_VALUE, config->quant); + config->quant = config_get_uint(hDlg, IDC_VALUE, config->quant); break; case DLG_MODE_2PASS_2_INT : - config->desired_size = config_get_int(hDlg, IDC_VALUE, config->desired_size); + config->desired_size = config_get_uint(hDlg, IDC_VALUE, config->desired_size); break; } @@ -461,6 +492,9 @@ // create arrays of controls to be disabled for each mode const short twopass_disable[] = { IDC_KFBOOST, IDC_DUMMY2PASS, IDC_USEALT, +// added by koepi for new curve treatment + IDC_KFTRESHOLD, IDC_KFREDUCTION, +//end of koepi's additions IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP, IDC_STATS2, IDC_STATS2_BROWSE, }; @@ -596,6 +630,13 @@ SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE); CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED); +#ifdef BFRAMES + SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, TRUE); + SetDlgItemInt(hDlg, IDC_BQUANTRATIO, config->bquant_ratio, FALSE); + CheckDlgButton(hDlg, IDC_PACKED, config->packed ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_DX50BVOP, config->dx50bvop ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_DEBUG, config->debug ? BST_CHECKED : BST_UNCHECKED); +#endif break; case DLG_QUANT : @@ -609,7 +650,10 @@ SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE); CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED); - +// added by koepi for new 2pass curve treatment + SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE); + SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE); +// end of koepi's additions SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE); SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE); SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE); @@ -680,6 +724,14 @@ CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE, config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO ); +#ifdef _SMP + SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE); +#endif + +#ifdef BFRAMES + SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE); +#endif + SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE); SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE); SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE); @@ -702,17 +754,24 @@ config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0); config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0); config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0); - config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval); - config->min_key_interval = config_get_int(hDlg, IDC_MINKEY, config->min_key_interval); + config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval); + config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval); config->lum_masking = ISDLGSET(IDC_LUMMASK); config->interlacing = ISDLGSET(IDC_INTERLACING); +#ifdef BFRAMES + config->max_bframes = config_get_int(hDlg, IDC_MAXBFRAMES, config->max_bframes); + config->bquant_ratio = config_get_uint(hDlg, IDC_BQUANTRATIO, config->bquant_ratio); + config->packed = ISDLGSET(IDC_PACKED); + config->dx50bvop = ISDLGSET(IDC_DX50BVOP); + config->debug = ISDLGSET(IDC_DEBUG); +#endif break; case DLG_QUANT : - config->min_iquant = config_get_int(hDlg, IDC_MINIQUANT, config->min_iquant); - config->max_iquant = config_get_int(hDlg, IDC_MAXIQUANT, config->max_iquant); - config->min_pquant = config_get_int(hDlg, IDC_MINPQUANT, config->min_pquant); - config->max_pquant = config_get_int(hDlg, IDC_MAXPQUANT, config->max_pquant); + config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant); + config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant); + config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant); + config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant); CONSTRAINVAL(config->min_iquant, 1, 31); CONSTRAINVAL(config->max_iquant, config->min_iquant, 31); @@ -722,11 +781,15 @@ case DLG_2PASS : config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE); +// added by koepi for the new 2pass curve treatment + config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE); + config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE); +//end of koepi's additions config->discard1pass = ISDLGSET(IDC_DISCARD1PASS); config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS); config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE); config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE); - config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); + config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay); config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP); config->hinted_me = ISDLGSET(IDC_HINTEDME); @@ -753,21 +816,21 @@ config->use_alt_curve = ISDLGSET(IDC_USEALT); config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO); - config->alt_curve_auto_str = config_get_int(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str); + config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str); config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS); - config->alt_curve_bonus_bias = config_get_int(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias); + 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_int(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist); - config->alt_curve_low_dist = config_get_int(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist); - config->alt_curve_min_rel_qual = config_get_int(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual); + 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); config->twopass_max_bitrate /= CONFIG_KBPS; - config->twopass_max_bitrate = config_get_int(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate); + config->twopass_max_bitrate = config_get_uint(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate); config->twopass_max_bitrate *= CONFIG_KBPS; - config->twopass_max_overflow_improvement = config_get_int(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement); - config->twopass_max_overflow_degradation = config_get_int(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation); + config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement); + config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation); CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80); CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80); @@ -776,16 +839,16 @@ case DLG_CREDITS : config->credits_start = ISDLGSET(IDC_CREDITS_START); config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE); - config->credits_start_end = config_get_int(hDlg, IDC_CREDITS_START_END, config->credits_start_end); + config->credits_start_end = config_get_uint(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_end_begin = config_get_uint(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin); + config->credits_end_end = config_get_uint(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); + config->credits_rate = config_get_uint(hDlg, IDC_CREDITS_RATE, config->credits_rate); + config->credits_quant_i = config_get_uint(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i); + config->credits_quant_p = config_get_uint(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p); + config->credits_start_size = config_get_uint(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size); + config->credits_end_size = config_get_uint(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size); config->credits_mode = 0; config->credits_mode = ISDLGSET(IDC_CREDITS_RATE_RADIO) ? CREDITS_MODE_RATE : config->credits_mode; @@ -818,9 +881,16 @@ config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0; config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0; - config->rc_reaction_delay_factor = config_get_int(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor); - config->rc_averaging_period = config_get_int(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period); - config->rc_buffer = config_get_int(hDlg, IDC_CBR_BUFFER, config->rc_buffer); +#ifdef _SMP + config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads); +#endif +#ifdef BFRAMES + config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio); +#endif + + config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor); + config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period); + config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer); break; } } @@ -846,11 +916,11 @@ { int temp; - temp = config_get_int(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]); + temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]); CONSTRAINVAL(temp, 1, 255); config->qmatrix_intra[i] = temp; - temp = config_get_int(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]); + temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]); CONSTRAINVAL(temp, 1, 255); config->qmatrix_inter[i] = temp; } @@ -958,7 +1028,7 @@ } else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE) { - int value = config_get_int(hDlg, IDC_VALUE, 1); + int value = config_get_uint(hDlg, IDC_VALUE, 1); int max = 1; max = (config->mode == DLG_MODE_CBR) ? 10000 : @@ -1034,6 +1104,17 @@ SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID"); SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX"); SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50"); + +#ifndef BFRAMES + EnableWindow(GetDlgItem(hDlg, IDC_BSTATIC1), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_BSTATIC2), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_BSTATIC3), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_MAXBFRAMES), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_BQUANTRATIO), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PACKED), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DX50BVOP), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEBUG), FALSE); +#endif } else if (psi->page == DLG_2PASSALT) { @@ -1041,6 +1122,18 @@ SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium"); SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High"); } + else if (psi->page == DLG_CPU) + { +#ifndef _SMP + + EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE); +#endif +#ifndef BFRAMES + EnableWindow(GetDlgItem(hDlg, IDC_FRAMEDROP_STATIC), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_FRAMEDROP), FALSE); +#endif + } if (hTooltip) { @@ -1273,6 +1366,7 @@ SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD); + init_param.cpu_flags = XVID_CPU_CHKONLY; xvid_init(NULL, 0, &init_param, 0); wsprintf(core, "Core Version %d.%d", (init_param.api_version>>16),(init_param.api_version&0xFFFFU)); SetDlgItemText(hDlg, IDC_CORE, core);