67 |
uint32_t current_quant, |
uint32_t current_quant, |
68 |
int32_t iDcScaler, |
int32_t iDcScaler, |
69 |
int16_t predictors[8], |
int16_t predictors[8], |
70 |
const int bound) |
const int bound, |
71 |
|
const int bsversion) |
72 |
|
|
73 |
{ |
{ |
74 |
const int mbpos = (y * mb_width) + x; |
const int mbpos = (y * mb_width) + x; |
185 |
break; |
break; |
186 |
} |
} |
187 |
|
|
188 |
/* |
/* determine ac prediction direction & ac/dc predictor place rescaled ac/dc |
189 |
* determine ac prediction direction & ac/dc predictor place rescaled ac/dc |
* predictions into predictors[] for later use */ |
|
* predictions into predictors[] for later use |
|
|
*/ |
|
190 |
|
|
191 |
|
/* Workaround: Bitstream versions <= 32 used to have a wrong predictor |
192 |
|
* stored as it wasn't clipped to the [-2048, 2047] range. We only |
193 |
|
* use the right predictors for bs versions > 32 */ |
194 |
|
#define BUGGY_CLIPPING_BS_VERSION 32 |
195 |
if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) { |
if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) { |
196 |
*acpred_direction = 1; /* vertical */ |
*acpred_direction = 1; /* vertical */ |
197 |
predictors[0] = DIV_DIV(pTop[0], iDcScaler); |
predictors[0] = DIV_DIV(pTop[0], iDcScaler); |
198 |
|
if (bsversion == 0 || bsversion > BUGGY_CLIPPING_BS_VERSION) |
199 |
|
predictors[0] = CLIP(predictors[0], -2048, 2047); |
200 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
201 |
predictors[i] = rescale(top_quant, current_quant, pTop[i]); |
predictors[i] = rescale(top_quant, current_quant, pTop[i]); |
202 |
} |
} |
203 |
} else { |
} else { |
204 |
*acpred_direction = 2; /* horizontal */ |
*acpred_direction = 2; /* horizontal */ |
205 |
predictors[0] = DIV_DIV(pLeft[0], iDcScaler); |
predictors[0] = DIV_DIV(pLeft[0], iDcScaler); |
206 |
|
if (bsversion == 0 || bsversion > BUGGY_CLIPPING_BS_VERSION) |
207 |
|
predictors[0] = CLIP(predictors[0], -2048, 2047); |
208 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
209 |
predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]); |
predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]); |
210 |
} |
} |
427 |
iDcScaler = get_dc_scaler(iQuant, j<4); |
iDcScaler = get_dc_scaler(iQuant, j<4); |
428 |
|
|
429 |
predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], |
predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], |
430 |
iQuant, iDcScaler, predictors[j], 0); |
iQuant, iDcScaler, predictors[j], 0, 0); |
431 |
|
|
432 |
if ((frame->vop_flags & XVID_VOP_HQACPRED)) |
if ((frame->vop_flags & XVID_VOP_HQACPRED)) |
433 |
S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |
S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |