--- trunk/xvidcore/vfw/src/codec.c 2004/07/03 14:48:30 1477 +++ trunk/xvidcore/vfw/src/codec.c 2005/01/08 12:28:48 1588 @@ -502,6 +502,12 @@ pass2.kfthreshold = codec->config.kfthreshold; pass2.container_frame_overhead = 24; /* AVI */ + /* VBV */ + pass2.vbv_size = profiles[codec->config.profile].max_vbv_size; + pass2.vbv_initial = (profiles[codec->config.profile].max_vbv_size*3)/4; + pass2.vbv_maxrate = 1000*profiles[codec->config.profile].max_bitrate; + pass2.vbv_peakrate = 10000000; /* 10mbps -- fixme */ + plugins[create.num_plugins].func = codec->xvid_plugin_2pass2_func; plugins[create.num_plugins].param = &pass2; create.num_plugins++; @@ -637,12 +643,19 @@ frame->vop_flags |= XVID_VOP_CHROMAOPT; } + if (config->zones[i].cartoon_mode) { + frame->vop_flags |= XVID_VOP_CARTOON; + frame->motion |= XVID_ME_DETECT_STATIC_MOTION; + } + if ((profiles[config->profile].flags & PROFILE_BVOP) && config->use_bvop) { frame->bframe_threshold = config->zones[i].bvop_threshold; } } +#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) + LRESULT compress(CODEC * codec, ICCOMPRESS * icc) { BITMAPINFOHEADER * inhdr = icc->lpbiInput; @@ -711,6 +724,10 @@ frame.vop_flags |= XVID_VOP_HALFPEL; frame.vop_flags |= XVID_VOP_HQACPRED; + if (codec->config.interlacing && codec->config.tff) + frame.vop_flags |= XVID_VOP_TOPFIELDFIRST; + + if (codec->config.vop_debug) frame.vop_flags |= XVID_VOP_DEBUG; @@ -724,11 +741,6 @@ if (codec->config.chromame) frame.motion |= XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP; - if (codec->config.cartoon_mode) { - frame.vop_flags |= XVID_VOP_CARTOON; - frame.motion |= XVID_ME_DETECT_STATIC_MOTION; - } - if (codec->config.turbo) frame.motion |= XVID_ME_FASTREFINE16 | XVID_ME_FASTREFINE8 | XVID_ME_SKIP_DELTASEARCH | XVID_ME_FAST_MODEINTERPOLATE | @@ -736,6 +748,9 @@ frame.motion |= pmvfast_presets[codec->config.motion_search]; + if (codec->config.vhq_bframe) frame.vop_flags |= XVID_VOP_RD_BVOP; + + switch (codec->config.vhq_mode) { case VHQ_MODE_DECISION : @@ -772,7 +787,7 @@ } frame.input.plane[0] = icc->lpInput; - frame.input.stride[0] = (((icc->lpbiInput->biWidth * icc->lpbiInput->biBitCount) + 31) & ~31) >> 3; + frame.input.stride[0] = CALC_BI_STRIDE(icc->lpbiInput->biWidth, icc->lpbiInput->biBitCount); if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL) return ICERR_BADFORMAT; @@ -925,7 +940,8 @@ outhdr->biPlanes = 1; outhdr->biBitCount = 24; outhdr->biCompression = BI_RGB; /* sonic foundry vegas video v3 only supports BI_RGB */ - outhdr->biSizeImage = outhdr->biWidth * outhdr->biHeight * outhdr->biBitCount / 8; + outhdr->biSizeImage = outhdr->biHeight * CALC_BI_STRIDE(outhdr->biWidth, outhdr->biBitCount); + outhdr->biXPelsPerMeter = 0; outhdr->biYPelsPerMeter = 0; outhdr->biClrUsed = 0; @@ -1031,13 +1047,13 @@ convert.input.csp = get_colorspace(icd->lpbiInput); convert.input.plane[0] = icd->lpInput; - convert.input.stride[0] = (((icd->lpbiInput->biWidth *icd->lpbiInput->biBitCount) + 31) & ~31) >> 3; + convert.input.stride[0] = CALC_BI_STRIDE(icd->lpbiInput->biWidth, icd->lpbiInput->biBitCount); if (convert.input.csp == XVID_CSP_I420 || convert.input.csp == XVID_CSP_YV12) convert.input.stride[0] = (convert.input.stride[0]*2)/3; convert.output.csp = get_colorspace(icd->lpbiOutput); convert.output.plane[0] = icd->lpOutput; - convert.output.stride[0] = (((icd->lpbiOutput->biWidth *icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3; + convert.output.stride[0] = CALC_BI_STRIDE(icd->lpbiOutput->biWidth, icd->lpbiOutput->biBitCount); if (convert.output.csp == XVID_CSP_I420 || convert.output.csp == XVID_CSP_YV12) convert.output.stride[0] = (convert.output.stride[0]*2)/3; @@ -1067,9 +1083,9 @@ return ICERR_BADFORMAT; } frame.output.plane[0] = icd->lpOutput; - frame.output.stride[0] = (((icd->lpbiOutput->biWidth * icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3; + frame.output.stride[0] = CALC_BI_STRIDE(icd->lpbiOutput->biWidth, icd->lpbiOutput->biBitCount); if (frame.output.csp == XVID_CSP_I420 || frame.output.csp == XVID_CSP_YV12) - frame.output.stride[0] = (frame.output.stride[0]*2)/3; + frame.output.stride[0] = CALC_BI_STRIDE(icd->lpbiOutput->biWidth, 8); } else {