--- mbprediction.c 2003/02/15 15:22:19 1.13 +++ mbprediction.c 2003/06/09 01:22:58 1.13.2.7 @@ -50,6 +50,8 @@ * * ******************************************************************************/ +#include + #include "../global.h" #include "../encoder.h" #include "mbprediction.h" @@ -104,15 +106,15 @@ const int16_t *pTop = default_acdc_values; const int16_t *pDiag = default_acdc_values; - uint32_t index = x + y * mb_width; // current macroblock + uint32_t index = x + y * mb_width; /* current macroblock */ int *acpred_direction = &pMBs[index].acpred_directions[block]; uint32_t i; left = top = diag = current = 0; - // grab left,top and diag macroblocks + /* grab left,top and diag macroblocks */ - // left macroblock + /* left macroblock */ if (x && mbpos >= bound + 1 && (pMBs[index - 1].mode == MODE_INTRA || @@ -120,9 +122,8 @@ left = pMBs[index - 1].pred_values[0]; left_quant = pMBs[index - 1].quant; - //DEBUGI("LEFT", *(left+MBPRED_SIZE)); } - // top macroblock + /* top macroblock */ if (mbpos >= bound + (int)mb_width && (pMBs[index - mb_width].mode == MODE_INTRA || @@ -131,7 +132,7 @@ top = pMBs[index - mb_width].pred_values[0]; top_quant = pMBs[index - mb_width].quant; } - // diag macroblock + /* diag macroblock */ if (x && mbpos >= bound + (int)mb_width + 1 && (pMBs[index - 1 - mb_width].mode == MODE_INTRA || @@ -142,7 +143,7 @@ current = pMBs[index].pred_values[0]; - // now grab pLeft, pTop, pDiag _blocks_ + /* now grab pLeft, pTop, pDiag _blocks_ */ switch (block) { @@ -209,17 +210,19 @@ break; } - // determine ac prediction direction & ac/dc predictor - // place rescaled ac/dc predictions into predictors[] for later use + /* + * determine ac prediction direction & ac/dc predictor place rescaled ac/dc + * predictions into predictors[] for later use + */ - if (ABS(pLeft[0] - pDiag[0]) < ABS(pDiag[0] - pTop[0])) { - *acpred_direction = 1; // vertical + if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) { + *acpred_direction = 1; /* vertical */ predictors[0] = DIV_DIV(pTop[0], iDcScaler); for (i = 1; i < 8; i++) { predictors[i] = rescale(top_quant, current_quant, pTop[i]); } } else { - *acpred_direction = 2; // horizontal + *acpred_direction = 2; /* horizontal */ predictors[0] = DIV_DIV(pLeft[0], iDcScaler); for (i = 1; i < 8; i++) { predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]); @@ -244,16 +247,16 @@ int16_t *pCurrent = pMB->pred_values[block]; uint32_t i; - DPRINTF(DPRINTF_COEFF,"predictor[0] %i", predictors[0]); + DPRINTF(XVID_DEBUG_COEFF,"predictor[0] %i\n", predictors[0]); - dct_codes[0] += predictors[0]; // dc prediction + dct_codes[0] += predictors[0]; /* dc prediction */ pCurrent[0] = dct_codes[0] * iDcScaler; if (acpred_direction == 1) { for (i = 1; i < 8; i++) { int level = dct_codes[i] + predictors[i]; - DPRINTF(DPRINTF_COEFF,"predictor[%i] %i",i, predictors[i]); + DPRINTF(XVID_DEBUG_COEFF,"predictor[%i] %i\n",i, predictors[i]); dct_codes[i] = level; pCurrent[i] = level; @@ -262,7 +265,7 @@ } else if (acpred_direction == 2) { for (i = 1; i < 8; i++) { int level = dct_codes[i * 8] + predictors[i]; - DPRINTF(DPRINTF_COEFF,"predictor[%i] %i",i*8, predictors[i]); + DPRINTF(XVID_DEBUG_COEFF,"predictor[%i] %i\n",i*8, predictors[i]); dct_codes[i * 8] = level; pCurrent[i + 7] = level; @@ -278,8 +281,8 @@ -// ****************************************************************** -// ****************************************************************** +/***************************************************************************** + ****************************************************************************/ /* encoder: subtract predictors from qcoeff[] and calculate S1/S2 @@ -318,20 +321,20 @@ int16_t level; level = qcoeff[i]; - S2 += ABS(level); + S2 += abs(level); level -= predictors[i]; - S1 += ABS(level); + S1 += abs(level); predictors[i] = level; } - } else // acpred_direction == 2 + } else /* acpred_direction == 2 */ { for (i = 1; i < 8; i++) { int16_t level; level = qcoeff[i * 8]; - S2 += ABS(level); + S2 += abs(level); level -= predictors[i]; - S1 += ABS(level); + S1 += abs(level); predictors[i] = level; } @@ -383,7 +386,7 @@ qcoeff[i] -= predictors[i]; predictors[i] = qcoeff[i]; } - }else{ // acpred_direction == 2 + }else{ /* acpred_direction == 2 */ for (i = 1; i < 8; i++) { tmp[i] = qcoeff[i*8]; qcoeff[i*8] -= predictors[i]; @@ -401,7 +404,7 @@ if (direction == 1) { for (i = 1; i < 8; i++) qcoeff[i] = tmp[i]; - }else{ // acpred_direction == 2 + }else{ /* acpred_direction == 2 */ for (i = 1; i < 8; i++) qcoeff[i*8] = tmp[i]; } @@ -438,11 +441,12 @@ { int32_t j; - int32_t iDcScaler, iQuant = frame->quant; + int32_t iDcScaler, iQuant; int S = 0; int16_t predictors[6][8]; MACROBLOCK *pMB = &frame->mbs[x + y * mb_width]; + iQuant = pMB->quant; if ((pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q)) { @@ -452,14 +456,14 @@ predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], iQuant, iDcScaler, predictors[j], 0); - if ((frame->global_flags & XVID_HQACPRED)) + if ((frame->vop_flags & XVID_VOP_HQACPRED)) S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); else S += calc_acdc_coeff(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); } - if (S<=0) { // dont predict + if (S<=0) { /* dont predict */ for (j = 0; j < 6; j++) pMB->acpred_directions[j] = 0; }else{