--- trunk/vfw/src/codec.c 2002/04/17 14:04:41 127 +++ trunk/vfw/src/codec.c 2002/08/06 23:41:01 362 @@ -23,6 +23,9 @@ * * History: * + * 12.07.2002 num_threads + * 23.06.2002 XVID_CPU_CHKONLY; loading speed up + * 25.04.2002 ICDECOMPRESS_PREROLL * 17.04.2002 re-enabled lumi masking for 1st pass * 15.04.2002 updated cbr support * 04.04.2002 separated 2-pass code to 2pass.c @@ -55,7 +58,7 @@ PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8, PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8, PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 | - PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8 + PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8 | PMV_USESQUARES16 }; /* return xvid compatbile colorspace, @@ -217,7 +220,11 @@ LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) { - return lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3; + return +#ifdef BFRAMES + 2 * +#endif + lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3; } @@ -288,6 +295,20 @@ param.max_quantizer = codec->config.max_pquant; param.max_key_interval = codec->config.max_key_interval; +#ifdef _SMP + param.num_threads = codec->config.num_threads; +#endif + +#ifdef BFRAMES + param.global = 0; + if (codec->config.packed) param.global |= XVID_GLOBAL_PACKED; + if (codec->config.dx50bvop) param.global |= XVID_GLOBAL_DX50BVOP; + if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG; + param.max_bframes = codec->config.max_bframes; + param.bquant_ratio = codec->config.bquant_ratio; + param.frame_drop_ratio = codec->config.frame_drop_ratio; +#endif + switch(xvid_encore(0, XVID_ENC_CREATE, ¶m, NULL)) { case XVID_ERR_FAIL : @@ -364,6 +385,7 @@ frame.intra = -1; frame.general |= XVID_HALFPEL; +// frame.general |= XVID_ME_EPZS; if (codec->config.motion_search > 4) frame.general |= XVID_INTER4V; @@ -372,7 +394,18 @@ frame.general |= XVID_LUMIMASKING; if (codec->config.interlacing) - frame.general |= XVID_INTERLACING; + frame.general |= XVID_INTERLACING; + +// added by koepi for credits greyscale + check_greyscale_mode(&codec->config, &frame, codec->framenum); +// end of koepi's addition + +// fix 1pass modes/hinted MV by koepi + if (codec->config.hinted_me && (codec->config.mode == DLG_MODE_CBR || codec->config.mode == DLG_MODE_VBR_QUAL || codec->config.mode == DLG_MODE_VBR_QUANT)) + { + codec->config.hinted_me = 0; + } +// end of ugly hack if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1) { @@ -489,6 +522,11 @@ frame.intra = 0; } +#ifdef BFRAMES + frame.bquant = 0; +#endif + +// OutputDebugString(" "); switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats)) { case XVID_ERR_FAIL : @@ -526,7 +564,7 @@ if (codec->twopass.hints == INVALID_HANDLE_VALUE) { codec->twopass.hints = CreateFile(codec->config.hintfile, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); - if (codec->twopass.hints == INVALID_HANDLE_VALUE) + if (codec->twopass.hints == INVALID_HANDLE_VALUE) { DEBUGERR("couldn't create hints file"); return ICERR_ERROR; @@ -667,7 +705,7 @@ frame.image = icd->lpOutput; frame.stride = icd->lpbiOutput->biWidth; - if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE))) + if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL))) { if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL) { @@ -701,6 +739,9 @@ case DLG_MODE_VBR_QUAL : if (codec_is_in_credits(&codec->config, codec->framenum)) { +// added by koepi for credits greyscale + check_greyscale_mode(&codec->config, frame, codec->framenum); +// end of koepi's addition switch (codec->config.credits_mode) { case CREDITS_MODE_RATE : @@ -718,6 +759,9 @@ } else { +// added by koepi for credits greyscale + check_greyscale_mode(&codec->config, frame, codec->framenum); +// end of koepi's addition frame->quant = codec_get_vbr_quant(&codec->config, codec->config.quality); } return ICERR_OK; @@ -725,6 +769,9 @@ case DLG_MODE_VBR_QUANT : if (codec_is_in_credits(&codec->config, codec->framenum)) { +// added by koepi for credits greyscale + check_greyscale_mode(&codec->config, frame, codec->framenum); +// end of koepi's addition switch (codec->config.credits_mode) { case CREDITS_MODE_RATE : @@ -744,11 +791,17 @@ } else { +// added by koepi for credits greyscale + check_greyscale_mode(&codec->config, frame, codec->framenum); +// end of koepi's addition frame->quant = codec->config.quant; } return ICERR_OK; case DLG_MODE_2PASS_1 : +// added by koepi for credits greyscale + check_greyscale_mode(&codec->config, frame, codec->framenum); +// end of koepi's addition if (codec->config.credits_mode == CREDITS_MODE_QUANT) { if (codec_is_in_credits(&codec->config, codec->framenum)) @@ -839,3 +892,29 @@ return quant; } +// added by koepi for credits greyscale +int check_greyscale_mode(CONFIG* config, XVID_ENC_FRAME* frame, int framenum) +{ + if ((codec_is_in_credits(config, framenum)) && (config->mode!=DLG_MODE_CBR)) + { + if (config->credits_greyscale) + { + if ((frame->general && XVID_GREYSCALE)) // use only if not already in greyscale + frame->general |= XVID_GREYSCALE; + } else { + if (!(frame->general && XVID_GREYSCALE)) // if movie is in greyscale, switch back + frame->general |= XVID_GREYSCALE; + } + } else { + if (config->greyscale) + { + if ((frame->general && XVID_GREYSCALE)) // use only if not already in greyscale + frame->general |= XVID_GREYSCALE; + } else { + if (!(frame->general && XVID_GREYSCALE)) // if credits is in greyscale, switch back + frame->general |= XVID_GREYSCALE; + } + } + return 0; +} +// end of koepi's addition