--- encoder.c 2002/05/01 13:00:01 1.32 +++ encoder.c 2002/05/09 00:15:50 1.36 @@ -32,9 +32,11 @@ * * History * + * 08.05.2002 fix some problem in DEBUG mode; + * MinChen * 14.04.2002 added FrameCodeB() * - * $Id: encoder.c,v 1.32 2002/05/01 13:00:01 suxen_drol Exp $ + * $Id: encoder.c,v 1.36 2002/05/09 00:15:50 chenm001 Exp $ * ***************************************************************************/ @@ -264,15 +266,15 @@ #ifdef BFRAMES // TODO: handle malloc() == NULL - pEnc->max_bframes = pParam->max_bframes; + pEnc->mbParam.max_bframes = pParam->max_bframes; pEnc->bquant_ratio = pParam->bquant_ratio; - if (pEnc->max_bframes > 0) + if (pEnc->mbParam.max_bframes > 0) { int n; - pEnc->bframes = malloc(pEnc->max_bframes * sizeof(FRAMEINFO *)); + pEnc->bframes = malloc(pEnc->mbParam.max_bframes * sizeof(FRAMEINFO *)); - for (n = 0; n < pEnc->max_bframes; n++) + for (n = 0; n < pEnc->mbParam.max_bframes; n++) { pEnc->bframes[n] = malloc(sizeof(FRAMEINFO)); pEnc->bframes[n]->mbs = malloc(sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height); @@ -316,10 +318,10 @@ // ================================================================= #ifdef BFRAMES - if (pEnc->max_bframes > 0) + if (pEnc->mbParam.max_bframes > 0) { int n; - for (n = 0; n < pEnc->max_bframes; n++) + for (n = 0; n < pEnc->mbParam.max_bframes; n++) { image_destroy(&pEnc->bframes[n]->image, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); free(pEnc->bframes[n]->mbs); @@ -327,7 +329,7 @@ } free(pEnc->bframes); } -#endif BFRAMES +#endif //==================================================================== image_destroy(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height); @@ -365,6 +367,11 @@ Bitstream bs; uint32_t bits; +#ifdef _DEBUG + float psnr; + char temp[128]; +#endif + ENC_CHECK(pEnc); ENC_CHECK(pFrame); @@ -433,6 +440,13 @@ SWAP(pEnc->current, pEnc->reference); pEnc->current->quant = (pFrame->quant == 0) ? RateControlGetQ(0) : pFrame->quant; + + if(pEnc->current->quant < 1) + pEnc->current->quant = 1; + + if(pEnc->current->quant > 31) + pEnc->current->quant = 31; + pEnc->current->global_flags = pFrame->general; pEnc->current->motion_flags = pFrame->motion; pEnc->current->seconds = pEnc->mbParam.m_seconds; @@ -450,7 +464,7 @@ stop_conv_timer(); #ifdef _DEBUG - image_copy(&pEnc->sOriginal, &pEnc->sCurrent, pEnc->mbParam.edged_width, pEnc->mbParam.height); + image_copy(&pEnc->sOriginal, &pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height); #endif @@ -500,7 +514,7 @@ /* note: sequences like "IIBB" decode fine with msfdam but, go screwy with divx5.00 */ } - else if (pEnc->bframenum_tail >= pEnc->max_bframes) + else if (pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) { dprintf("--- PFRAME ---");