50 |
* * |
* * |
51 |
******************************************************************************/ |
******************************************************************************/ |
52 |
|
|
53 |
|
#include <stdlib.h> |
54 |
|
|
55 |
#include "../global.h" |
#include "../global.h" |
56 |
#include "../encoder.h" |
#include "../encoder.h" |
57 |
#include "mbprediction.h" |
#include "mbprediction.h" |
214 |
// determine ac prediction direction & ac/dc predictor |
// determine ac prediction direction & ac/dc predictor |
215 |
// place rescaled ac/dc predictions into predictors[] for later use |
// place rescaled ac/dc predictions into predictors[] for later use |
216 |
|
|
217 |
if (ABS(pLeft[0] - pDiag[0]) < ABS(pDiag[0] - pTop[0])) { |
if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) { |
218 |
*acpred_direction = 1; // vertical |
*acpred_direction = 1; // vertical |
219 |
predictors[0] = DIV_DIV(pTop[0], iDcScaler); |
predictors[0] = DIV_DIV(pTop[0], iDcScaler); |
220 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
320 |
int16_t level; |
int16_t level; |
321 |
|
|
322 |
level = qcoeff[i]; |
level = qcoeff[i]; |
323 |
S2 += ABS(level); |
S2 += abs(level); |
324 |
level -= predictors[i]; |
level -= predictors[i]; |
325 |
S1 += ABS(level); |
S1 += abs(level); |
326 |
predictors[i] = level; |
predictors[i] = level; |
327 |
} |
} |
328 |
} else // acpred_direction == 2 |
} else // acpred_direction == 2 |
331 |
int16_t level; |
int16_t level; |
332 |
|
|
333 |
level = qcoeff[i * 8]; |
level = qcoeff[i * 8]; |
334 |
S2 += ABS(level); |
S2 += abs(level); |
335 |
level -= predictors[i]; |
level -= predictors[i]; |
336 |
S1 += ABS(level); |
S1 += abs(level); |
337 |
predictors[i] = level; |
predictors[i] = level; |
338 |
} |
} |
339 |
|
|
440 |
{ |
{ |
441 |
|
|
442 |
int32_t j; |
int32_t j; |
443 |
int32_t iDcScaler, iQuant = frame->quant; |
int32_t iDcScaler, iQuant; |
444 |
int S = 0; |
int S = 0; |
445 |
int16_t predictors[6][8]; |
int16_t predictors[6][8]; |
446 |
|
|
447 |
MACROBLOCK *pMB = &frame->mbs[x + y * mb_width]; |
MACROBLOCK *pMB = &frame->mbs[x + y * mb_width]; |
448 |
|
iQuant = pMB->quant; |
449 |
|
|
450 |
if ((pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q)) { |
if ((pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q)) { |
451 |
|
|
455 |
predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], |
predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], |
456 |
iQuant, iDcScaler, predictors[j], 0); |
iQuant, iDcScaler, predictors[j], 0); |
457 |
|
|
458 |
if ((frame->global_flags & XVID_HQACPRED)) |
if ((frame->vop_flags & XVID_VOP_HQACPRED)) |
459 |
S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |
S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |
460 |
else |
else |
461 |
S += calc_acdc_coeff(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |
S += calc_acdc_coeff(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |