--- trunk/vfw/src/codec.c 2002/04/25 07:16:00 137 +++ trunk/vfw/src/codec.c 2002/08/05 18:26:31 361 @@ -23,6 +23,8 @@ * * 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 @@ -56,7 +58,8 @@ 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, @@ -218,7 +221,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; } @@ -289,6 +296,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 : @@ -365,6 +386,7 @@ frame.intra = -1; frame.general |= XVID_HALFPEL; +// frame.general |= XVID_ME_EPZS; if (codec->config.motion_search > 4) frame.general |= XVID_INTER4V; @@ -373,7 +395,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) { @@ -490,6 +523,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 : @@ -527,7 +565,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; @@ -702,6 +740,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 : @@ -719,6 +760,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; @@ -726,6 +770,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 : @@ -745,11 +792,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)) @@ -840,3 +893,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