50 |
* * |
* * |
51 |
******************************************************************************/ |
******************************************************************************/ |
52 |
|
|
53 |
|
#include "../global.h" |
54 |
#include "../encoder.h" |
#include "../encoder.h" |
55 |
#include "mbprediction.h" |
#include "mbprediction.h" |
56 |
#include "../utils/mbfunctions.h" |
#include "../utils/mbfunctions.h" |
57 |
#include "../bitstream/cbp.h" |
#include "../bitstream/cbp.h" |
58 |
|
|
59 |
|
|
|
#define ABS(X) (((X)>0)?(X):-(X)) |
|
|
#define DIV_DIV(A,B) ( (A) > 0 ? ((A)+((B)>>1))/(B) : ((A)-((B)>>1))/(B) ) |
|
|
|
|
|
|
|
60 |
static int __inline |
static int __inline |
61 |
rescale(int predict_quant, |
rescale(int predict_quant, |
62 |
int current_quant, |
int current_quant, |
89 |
uint32_t current_quant, |
uint32_t current_quant, |
90 |
int32_t iDcScaler, |
int32_t iDcScaler, |
91 |
int16_t predictors[8], |
int16_t predictors[8], |
92 |
const unsigned int bound_x, |
const int bound) |
|
const unsigned int bound_y) |
|
93 |
|
|
94 |
{ |
{ |
95 |
const unsigned bound = (bound_y * mb_width) + bound_x; |
const int mbpos = (y * mb_width) + x; |
|
const unsigned mbpos = (y * mb_width) + x; |
|
96 |
int16_t *left, *top, *diag, *current; |
int16_t *left, *top, *diag, *current; |
97 |
|
|
98 |
int32_t left_quant = current_quant; |
int32_t left_quant = current_quant; |
122 |
} |
} |
123 |
// top macroblock |
// top macroblock |
124 |
|
|
125 |
if (mbpos >= bound + mb_width && |
if (mbpos >= bound + (int)mb_width && |
126 |
(pMBs[index - mb_width].mode == MODE_INTRA || |
(pMBs[index - mb_width].mode == MODE_INTRA || |
127 |
pMBs[index - mb_width].mode == MODE_INTRA_Q)) { |
pMBs[index - mb_width].mode == MODE_INTRA_Q)) { |
128 |
|
|
131 |
} |
} |
132 |
// diag macroblock |
// diag macroblock |
133 |
|
|
134 |
if (x && mbpos >= bound + mb_width + 1 && |
if (x && mbpos >= bound + (int)mb_width + 1 && |
135 |
(pMBs[index - 1 - mb_width].mode == MODE_INTRA || |
(pMBs[index - 1 - mb_width].mode == MODE_INTRA || |
136 |
pMBs[index - 1 - mb_width].mode == MODE_INTRA_Q)) { |
pMBs[index - 1 - mb_width].mode == MODE_INTRA_Q)) { |
137 |
|
|
242 |
int16_t *pCurrent = pMB->pred_values[block]; |
int16_t *pCurrent = pMB->pred_values[block]; |
243 |
uint32_t i; |
uint32_t i; |
244 |
|
|
245 |
|
DPRINTF(DPRINTF_COEFF,"predictor[0] %i", predictors[0]); |
246 |
|
|
247 |
dct_codes[0] += predictors[0]; // dc prediction |
dct_codes[0] += predictors[0]; // dc prediction |
248 |
pCurrent[0] = dct_codes[0] * iDcScaler; |
pCurrent[0] = dct_codes[0] * iDcScaler; |
249 |
|
|
251 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
252 |
int level = dct_codes[i] + predictors[i]; |
int level = dct_codes[i] + predictors[i]; |
253 |
|
|
254 |
|
DPRINTF(DPRINTF_COEFF,"predictor[%i] %i",i, predictors[i]); |
255 |
|
|
256 |
dct_codes[i] = level; |
dct_codes[i] = level; |
257 |
pCurrent[i] = level; |
pCurrent[i] = level; |
258 |
pCurrent[i + 7] = dct_codes[i * 8]; |
pCurrent[i + 7] = dct_codes[i * 8]; |
260 |
} else if (acpred_direction == 2) { |
} else if (acpred_direction == 2) { |
261 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
262 |
int level = dct_codes[i * 8] + predictors[i]; |
int level = dct_codes[i * 8] + predictors[i]; |
263 |
|
DPRINTF(DPRINTF_COEFF,"predictor[%i] %i",i*8, predictors[i]); |
264 |
|
|
265 |
dct_codes[i * 8] = level; |
dct_codes[i * 8] = level; |
266 |
pCurrent[i + 7] = level; |
pCurrent[i + 7] = level; |
385 |
iDcScaler = get_dc_scaler(iQuant, (j < 4) ? 1 : 0); |
iDcScaler = get_dc_scaler(iQuant, (j < 4) ? 1 : 0); |
386 |
|
|
387 |
predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], |
predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64], |
388 |
iQuant, iDcScaler, predictors[j], 0, 0); |
iQuant, iDcScaler, predictors[j], 0); |
389 |
|
|
390 |
S += calc_acdc(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |
S += calc_acdc(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]); |
391 |
|
|