--- trunk/xvidcore/vfw/src/config.c 2004/11/22 10:40:03 1562 +++ trunk/xvidcore/vfw/src/config.c 2005/09/09 11:34:51 1630 @@ -108,40 +108,48 @@ /* default vbv_occupancy is (64/170)*vbv_buffer_size */ +#define PROFILE_S (PROFILE_4MV) +#define PROFILE_ARTS (PROFILE_4MV|PROFILE_ADAPTQUANT) +#define PROFILE_AS (PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_MPEGQUANT|PROFILE_INTERLACE|PROFILE_QPEL|PROFILE_GMC) + const profile_t profiles[] = { -/* name p@l, w h fps obj Tvmv vmv vcv ac% vbv pkt kbps flags */ - { "Simple @ L0", 0x08, 176, 144, 15, 1, 198, 99, 1485, 100, 10*16368, 2048, 64, 0 }, - /* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */ - /* if ac preidition is used, adaptive quantization must not be used */ - /* <=qcif must be used */ - { "Simple @ L1", 0x01, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 2048, 64, PROFILE_ADAPTQUANT }, - { "Simple @ L2", 0x02, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128, PROFILE_ADAPTQUANT }, - { "Simple @ L3", 0x03, 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384, PROFILE_ADAPTQUANT }, - - { "ARTS @ L1", 0x91, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 8192, 64, PROFILE_ARTS }, - { "ARTS @ L2", 0x92, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 16384, 128, PROFILE_ARTS }, - { "ARTS @ L3", 0x93, 352, 288, 30, 4, 792, 396, 11880, 100, 40*16368, 16384, 384, PROFILE_ARTS }, - { "ARTS @ L4", 0x94, 352, 288, 30, 16, 792, 396, 11880, 100, 80*16368, 16384, 2000, PROFILE_ARTS }, - - { "AS @ L0", 0xf0, 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS }, - { "AS @ L1", 0xf1, 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS }, - { "AS @ L2", 0xf2, 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384, PROFILE_AS }, - { "AS @ L3", 0xf3, 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768, PROFILE_AS }, +/* name p@l w h fps obj Tvmv vmv vcv ac% vbv pkt bps vbv_peak dbf flags */ + { "Simple @ L0", 0x08, 176, 144, 15, 1, 198, 99, 1485, 100, 10*16368, 2048, 64000, 0, -1, PROFILE_S }, + /* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */ + /* if ac preidition is used, adaptive quantization must not be used */ + /* <=qcif must be used */ + { "Simple @ L1", 0x01, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 2048, 64000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, + { "Simple @ L2", 0x02, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, + { "Simple @ L3", 0x03, 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, + +#if 0 /* since rrv encoding is no longer support, these profiles have little use */ + { "ARTS @ L1", 0x91, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 8192, 64000, 0, -1, PROFILE_ARTS }, + { "ARTS @ L2", 0x92, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 16384, 128000, 0, -1, PROFILE_ARTS }, + { "ARTS @ L3", 0x93, 352, 288, 30, 4, 792, 396, 11880, 100, 40*16368, 16384, 384000, 0, -1, PROFILE_ARTS }, + { "ARTS @ L4", 0x94, 352, 288, 30, 16, 792, 396, 11880, 100, 80*16368, 16384, 2000000, 0, -1, PROFILE_ARTS }, +#endif + + { "AS @ L0", 0xf0, 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128000, 0, -1, PROFILE_AS }, + { "AS @ L1", 0xf1, 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128000, 0, -1, PROFILE_AS }, + { "AS @ L2", 0xf2, 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384000, 0, -1, PROFILE_AS }, + { "AS @ L3", 0xf3, 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768000, 0, -1, PROFILE_AS }, /* ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */ - { "AS @ L4", 0xf4, 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000, PROFILE_AS }, - { "AS @ L5", 0xf5, 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000, PROFILE_AS }, + { "AS @ L4", 0xf4, 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000000, 0, -1, PROFILE_AS }, + { "AS @ L5", 0xf5, 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000000, 0, -1, PROFILE_AS }, #ifdef DXN_PROFILES - { "DXN Handheld", 0x00, 176, 144, 15, -1, 198, 99, 1485, 100, 16*16368, -1, 128, PROFILE_ADAPTQUANT }, - { "DXN Portable NTSC", 0x00, 352, 240, 30, -1, 990, 330, 9900, 100, 64*16368, -1, 768, PROFILE_ADAPTQUANT|PROFILE_BVOP }, - { "DXN Portable PAL", 0x00, 352, 288, 25, -1, 1188, 396, 9900, 100, 64*16368, -1, 768, PROFILE_ADAPTQUANT|PROFILE_BVOP }, - { "DXN HT NTSC", 0x00, 720, 480, 30, -1, 4050, 1350, 40500, 100, 192*16368, -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE }, - { "DXN HT PAL", 0x00, 720, 576, 25, -1, 4860, 1620, 40500, 100, 192*16368, -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE }, - { "DXN HDTV", 0x00, 1280, 720, 30, -1,10800, 3600, 108000, 100, 384*16368, -1, 8000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE }, +// information provided by DivXNetworks, USA. +// "DivX Certified Profile Compatibility v1.1", February 2005 + { "DXN Handheld", 0x00, 176, 144, 15, 1, 198, 99, 1485, 100, 32*8192, -1, 537600, 800000, 0, PROFILE_ADAPTQUANT|PROFILE_DXN }, + { "DXN Portable NTSC",0x00, 352, 240, 30, 1, 990, 330, 36000, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_DXN }, + { "DXN Portable PAL", 0x00, 352, 288, 25, 1, 1188, 396, 36000, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_DXN }, + { "DXN HT NTSC", 0x00, 720, 480, 30, 1, 4050, 1350, 40500, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, + { "DXN HT PAL", 0x00, 720, 576, 25, 1, 4860, 1620, 40500, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, + { "DXN HDTV", 0x00, 1280, 720, 30, 1,10800, 3600, 108000, 100, 768*8192, -1, 9708400, 16000000, 2, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, #endif - { "(unrestricted)", 0x00, 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, 0, 0, 0xffffffff }, + { "(unrestricted)", 0x00, 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, -1, 0, 0, -1, 0xffffffff & ~PROFILE_DXN }, }; @@ -203,13 +211,11 @@ {"tff", ®.tff, 0}, {"qpel", ®.qpel, 0}, {"gmc", ®.gmc, 0}, - {"reduced_resolution", ®.reduced_resolution, 0}, {"use_bvop", ®.use_bvop, 1}, {"max_bframes", ®.max_bframes, 2}, {"bquant_ratio", ®.bquant_ratio, 150}, /* 100-base float */ {"bquant_offset", ®.bquant_offset, 100}, /* 100-base float */ {"packed", ®.packed, 1}, - {"closed_gov", ®.closed_gov, 1}, /* aspect ratio */ {"ar_mode", ®.ar_mode, 0}, @@ -259,7 +265,6 @@ {"vhq_mode", ®.vhq_mode, 1}, {"vhq_bframe", ®.vhq_bframe, 0}, {"chromame", ®.chromame, 1}, - {"cartoon_mode", ®.cartoon_mode, 0}, {"turbo", ®.turbo, 0}, {"max_key_interval", ®.max_key_interval, 300}, {"frame_drop_ratio", ®.frame_drop_ratio, 0}, @@ -271,7 +276,7 @@ {"max_pquant", ®.max_pquant, 31}, {"min_bquant", ®.min_bquant, 1}, {"max_bquant", ®.max_bquant, 31}, - {"trellis_quant", ®.trellis_quant, 0}, + {"trellis_quant", ®.trellis_quant, 1}, /* debug */ {"fourcc_used", ®.fourcc_used, 0}, @@ -305,6 +310,7 @@ {"zone%i_greyscale", &stmp.greyscale, 0}, {"zone%i_chroma_opt", &stmp.chroma_opt, 0}, {"zone%i_bvop_threshold", &stmp.bvop_threshold, 0}, + {"zone%i_cartoon_mode", &stmp.cartoon_mode, 0}, }; static const BYTE default_qmatrix_intra[] = { @@ -549,6 +555,12 @@ SetDlgItemText(hDlg, item, buf); } +static void set_dlgitem_float1000(HWND hDlg, UINT item, int value) +{ + char buf[FLOAT_BUF_SZ]; + sprintf(buf, "%.3f", (float)value/1000); + SetDlgItemText(hDlg, item, buf); +} #define HEX_BUF_SZ 16 static unsigned int get_dlgitem_hex(HWND hDlg, UINT item, unsigned int def) @@ -846,7 +858,6 @@ EnableDlgWindow(hDlg, IDC_TFF, IsDlgChecked(hDlg, IDC_INTERLACING)); EnableDlgWindow(hDlg, IDC_QPEL, profiles[profile].flags&PROFILE_QPEL); EnableDlgWindow(hDlg, IDC_GMC, profiles[profile].flags&PROFILE_GMC); - EnableDlgWindow(hDlg, IDC_REDUCED, profiles[profile].flags&PROFILE_REDUCED); bvops = (profiles[profile].flags&PROFILE_BVOP) && IsDlgChecked(hDlg, IDC_BVOP); EnableDlgWindow(hDlg, IDC_MAXBFRAMES, bvops); @@ -855,8 +866,7 @@ EnableDlgWindow(hDlg, IDC_MAXBFRAMES_S, bvops); EnableDlgWindow(hDlg, IDC_BQUANTRATIO_S, bvops); EnableDlgWindow(hDlg, IDC_BQUANTOFFSET_S, bvops); - EnableDlgWindow(hDlg, IDC_PACKED, bvops); - EnableDlgWindow(hDlg, IDC_CLOSEDGOV, bvops); + EnableDlgWindow(hDlg, IDC_PACKED, bvops && !(profiles[profile].flags & PROFILE_DXN)); break; case IDD_AR: @@ -894,7 +904,36 @@ SetDlgItemInt(hDlg, IDC_LEVEL_VMV, profiles[profile].max_vmv_buffer_sz, FALSE); SetDlgItemInt(hDlg, IDC_LEVEL_VCV, profiles[profile].vcv_decoder_rate, FALSE); SetDlgItemInt(hDlg, IDC_LEVEL_VBV, profiles[profile].max_vbv_size, FALSE); - SetDlgItemInt(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate, FALSE); + set_dlgitem_float1000(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate); + SetDlgItemInt(hDlg, IDC_LEVEL_PEAKRATE, profiles[profile].vbv_peakrate, FALSE); + + { + int en_dim = profiles[profile].width && profiles[profile].height; + int en_vmv = profiles[profile].max_vmv_buffer_sz; + int en_vcv = profiles[profile].vcv_decoder_rate; + EnableDlgWindow(hDlg, IDC_LEVEL_LEVEL_G, en_dim || en_vmv || en_vcv); + EnableDlgWindow(hDlg, IDC_LEVEL_DIM_S, en_dim); + EnableDlgWindow(hDlg, IDC_LEVEL_WIDTH, en_dim); + EnableDlgWindow(hDlg, IDC_LEVEL_HEIGHT,en_dim); + EnableDlgWindow(hDlg, IDC_LEVEL_FPS, en_dim); + EnableDlgWindow(hDlg, IDC_LEVEL_VMV_S, en_vmv); + EnableDlgWindow(hDlg, IDC_LEVEL_VMV, en_vmv); + EnableDlgWindow(hDlg, IDC_LEVEL_VCV_S, en_vcv); + EnableDlgWindow(hDlg, IDC_LEVEL_VCV, en_vcv); + } + { + int en_vbv = profiles[profile].max_vbv_size; + int en_br = profiles[profile].max_bitrate; + int en_pr = profiles[profile].vbv_peakrate; + + EnableDlgWindow(hDlg, IDC_LEVEL_VBV_G, en_vbv || en_br || en_pr); + EnableDlgWindow(hDlg, IDC_LEVEL_VBV_S, en_vbv); + EnableDlgWindow(hDlg, IDC_LEVEL_VBV, en_vbv); + EnableDlgWindow(hDlg, IDC_LEVEL_BITRATE_S, en_br); + EnableDlgWindow(hDlg, IDC_LEVEL_BITRATE, en_br); + EnableDlgWindow(hDlg, IDC_LEVEL_PEAKRATE_S, en_pr); + EnableDlgWindow(hDlg, IDC_LEVEL_PEAKRATE, en_pr); + } break; case IDD_BITRATE : @@ -940,8 +979,13 @@ /* step 2: calculate audio_size (kbytes)*/ if (audio_type!=NO_AUDIO) { if (audio_mode==0) { - audio_size = (int)( (1000.0 * duration * audio_rate) / (8.0*1024) ); - SetDlgItemInt(hDlg, IDC_BITRATE_ASIZE, audio_size, TRUE); + int new_audio_size = (int)( (1000.0 * duration * audio_rate) / (8.0*1024) ); + + /* this check is needed to avoid a loop */ + if (new_audio_size!=audio_size) { + audio_size = new_audio_size; + SetDlgItemInt(hDlg, IDC_BITRATE_ASIZE, new_audio_size, TRUE); + } }else{ int tmp_rate = (int)( (audio_size * 8.0 * 1024) / (1000.0 * duration) ); SetDlgItemInt(hDlg, IDC_BITRATE_ARATE, tmp_rate, TRUE); @@ -1000,7 +1044,7 @@ if (vsize > 0) { SetDlgItemInt(hDlg, IDC_BITRATE_VSIZE, vsize, TRUE); /* convert from kbytes to kbits-per-second */ - SetDlgItemInt(hDlg, IDC_BITRATE_VRATE, (vsize * 8 * 128) / (duration * 125), TRUE); + SetDlgItemInt(hDlg, IDC_BITRATE_VRATE, (int)(((__int64)vsize * 8 * 128) / (duration * 125)), TRUE); }else{ SetDlgItemText(hDlg, IDC_BITRATE_VSIZE, "Overflow"); SetDlgItemText(hDlg, IDC_BITRATE_VRATE, "Overflow"); @@ -1060,14 +1104,12 @@ CheckDlg(hDlg, IDC_TFF, config->tff); CheckDlg(hDlg, IDC_QPEL, config->qpel); CheckDlg(hDlg, IDC_GMC, config->gmc); - CheckDlg(hDlg, IDC_REDUCED, config->reduced_resolution); CheckDlg(hDlg, IDC_BVOP, config->use_bvop); SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, FALSE); set_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio); set_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset); CheckDlg(hDlg, IDC_PACKED, config->packed); - CheckDlg(hDlg, IDC_CLOSEDGOV, config->closed_gov); break; case IDD_AR: @@ -1136,6 +1178,8 @@ CheckDlgButton(hDlg, IDC_ZONE_GREYSCALE, config->zones[config->cur_zone].greyscale); CheckDlgButton(hDlg, IDC_ZONE_CHROMAOPT, config->zones[config->cur_zone].chroma_opt); + CheckDlg(hDlg, IDC_CARTOON, config->zones[config->cur_zone].cartoon_mode); + SetDlgItemInt(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold, TRUE); break; @@ -1144,7 +1188,6 @@ SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0); CheckDlg(hDlg, IDC_VHQ_BFRAME, config->vhq_bframe); CheckDlg(hDlg, IDC_CHROMAME, config->chromame); - CheckDlg(hDlg, IDC_CARTOON, config->cartoon_mode); CheckDlg(hDlg, IDC_TURBO, config->turbo); SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE); SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE); @@ -1208,14 +1251,12 @@ config->tff = IsDlgChecked(hDlg, IDC_TFF); config->qpel = IsDlgChecked(hDlg, IDC_QPEL); config->gmc = IsDlgChecked(hDlg, IDC_GMC); - config->reduced_resolution = IsDlgChecked(hDlg, IDC_REDUCED); config->use_bvop = IsDlgChecked(hDlg, IDC_BVOP); config->max_bframes = config_get_uint(hDlg, IDC_MAXBFRAMES, config->max_bframes); config->bquant_ratio = get_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio); config->bquant_offset = get_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset); config->packed = IsDlgChecked(hDlg, IDC_PACKED); - config->closed_gov = IsDlgChecked(hDlg, IDC_CLOSEDGOV); break; case IDD_AR: @@ -1320,6 +1361,7 @@ config->zones[config->cur_zone].chroma_opt = IsDlgButtonChecked(hDlg, IDC_ZONE_CHROMAOPT); config->zones[config->cur_zone].bvop_threshold = config_get_int(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold); + config->zones[config->cur_zone].cartoon_mode = IsDlgChecked(hDlg, IDC_CARTOON); break; case IDD_MOTION : @@ -1327,7 +1369,6 @@ config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0); config->vhq_bframe = IsDlgButtonChecked(hDlg, IDC_VHQ_BFRAME); config->chromame = IsDlgChecked(hDlg, IDC_CHROMAME); - config->cartoon_mode = IsDlgChecked(hDlg, IDC_CARTOON); config->turbo = IsDlgChecked(hDlg, IDC_TURBO); config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio); @@ -1707,6 +1748,9 @@ strcat(tmp, "G "); if (s->chroma_opt) + strcat(tmp, "O "); + + if (s->cartoon_mode) strcat(tmp, "C "); ListView_SetItemText(hDlg, i, 2, tmp); @@ -1733,7 +1777,7 @@ wsprintf(buf, "%i kbps", DEFAULT_MIN_KBPS); SetDlgItemText(hDlg, IDC_BITRATE_MIN, buf); - max = profiles[profile].max_bitrate; + max = profiles[profile].max_bitrate / 1000; if (max == 0) max = DEFAULT_MAX_KBPS; wsprintf(buf, "%i kbps", max); SetDlgItemText(hDlg, IDC_BITRATE_MAX, buf); @@ -1841,7 +1885,9 @@ { SetWindowPos(g_hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); SendMessage(g_hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0)); +#if (_WIN32_IE >= 0x0300) SendMessage(g_hTooltip, TTM_SETMAXTIPWIDTH, 0, 400); +#endif EnumChildWindows(hDlg, enum_tooltips, 0); } @@ -1850,7 +1896,12 @@ { DWORD ext_style = ListView_GetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES)); - ext_style |= LVS_EX_FULLROWSELECT | LVS_EX_FLATSB ; +#if (_WIN32_IE >= 0x0300) + ext_style |= LVS_EX_FULLROWSELECT; +#endif +#if( _WIN32_IE >= 0x0400 ) + ext_style |= LVS_EX_FLATSB ; +#endif ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES), ext_style); }