106 |
const int16_t *pTop = default_acdc_values; |
const int16_t *pTop = default_acdc_values; |
107 |
const int16_t *pDiag = default_acdc_values; |
const int16_t *pDiag = default_acdc_values; |
108 |
|
|
109 |
uint32_t index = x + y * mb_width; // current macroblock |
uint32_t index = x + y * mb_width; /* current macroblock */ |
110 |
int *acpred_direction = &pMBs[index].acpred_directions[block]; |
int *acpred_direction = &pMBs[index].acpred_directions[block]; |
111 |
uint32_t i; |
uint32_t i; |
112 |
|
|
113 |
left = top = diag = current = 0; |
left = top = diag = current = 0; |
114 |
|
|
115 |
// grab left,top and diag macroblocks |
/* grab left,top and diag macroblocks */ |
116 |
|
|
117 |
// left macroblock |
/* left macroblock */ |
118 |
|
|
119 |
if (x && mbpos >= bound + 1 && |
if (x && mbpos >= bound + 1 && |
120 |
(pMBs[index - 1].mode == MODE_INTRA || |
(pMBs[index - 1].mode == MODE_INTRA || |
122 |
|
|
123 |
left = pMBs[index - 1].pred_values[0]; |
left = pMBs[index - 1].pred_values[0]; |
124 |
left_quant = pMBs[index - 1].quant; |
left_quant = pMBs[index - 1].quant; |
|
//DEBUGI("LEFT", *(left+MBPRED_SIZE)); |
|
125 |
} |
} |
126 |
// top macroblock |
/* top macroblock */ |
127 |
|
|
128 |
if (mbpos >= bound + (int)mb_width && |
if (mbpos >= bound + (int)mb_width && |
129 |
(pMBs[index - mb_width].mode == MODE_INTRA || |
(pMBs[index - mb_width].mode == MODE_INTRA || |
132 |
top = pMBs[index - mb_width].pred_values[0]; |
top = pMBs[index - mb_width].pred_values[0]; |
133 |
top_quant = pMBs[index - mb_width].quant; |
top_quant = pMBs[index - mb_width].quant; |
134 |
} |
} |
135 |
// diag macroblock |
/* diag macroblock */ |
136 |
|
|
137 |
if (x && mbpos >= bound + (int)mb_width + 1 && |
if (x && mbpos >= bound + (int)mb_width + 1 && |
138 |
(pMBs[index - 1 - mb_width].mode == MODE_INTRA || |
(pMBs[index - 1 - mb_width].mode == MODE_INTRA || |
143 |
|
|
144 |
current = pMBs[index].pred_values[0]; |
current = pMBs[index].pred_values[0]; |
145 |
|
|
146 |
// now grab pLeft, pTop, pDiag _blocks_ |
/* now grab pLeft, pTop, pDiag _blocks_ */ |
147 |
|
|
148 |
switch (block) { |
switch (block) { |
149 |
|
|
210 |
break; |
break; |
211 |
} |
} |
212 |
|
|
213 |
// determine ac prediction direction & ac/dc predictor |
/* |
214 |
// place rescaled ac/dc predictions into predictors[] for later use |
* determine ac prediction direction & ac/dc predictor place rescaled ac/dc |
215 |
|
* predictions into predictors[] for later use |
216 |
|
*/ |
217 |
|
|
218 |
if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) { |
if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) { |
219 |
*acpred_direction = 1; // vertical |
*acpred_direction = 1; /* vertical */ |
220 |
predictors[0] = DIV_DIV(pTop[0], iDcScaler); |
predictors[0] = DIV_DIV(pTop[0], iDcScaler); |
221 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
222 |
predictors[i] = rescale(top_quant, current_quant, pTop[i]); |
predictors[i] = rescale(top_quant, current_quant, pTop[i]); |
223 |
} |
} |
224 |
} else { |
} else { |
225 |
*acpred_direction = 2; // horizontal |
*acpred_direction = 2; /* horizontal */ |
226 |
predictors[0] = DIV_DIV(pLeft[0], iDcScaler); |
predictors[0] = DIV_DIV(pLeft[0], iDcScaler); |
227 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
228 |
predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]); |
predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]); |
249 |
|
|
250 |
DPRINTF(XVID_DEBUG_COEFF,"predictor[0] %i\n", predictors[0]); |
DPRINTF(XVID_DEBUG_COEFF,"predictor[0] %i\n", predictors[0]); |
251 |
|
|
252 |
dct_codes[0] += predictors[0]; // dc prediction |
dct_codes[0] += predictors[0]; /* dc prediction */ |
253 |
pCurrent[0] = dct_codes[0] * iDcScaler; |
pCurrent[0] = dct_codes[0] * iDcScaler; |
254 |
|
|
255 |
if (acpred_direction == 1) { |
if (acpred_direction == 1) { |
281 |
|
|
282 |
|
|
283 |
|
|
284 |
// ****************************************************************** |
/***************************************************************************** |
285 |
// ****************************************************************** |
****************************************************************************/ |
286 |
|
|
287 |
/* encoder: subtract predictors from qcoeff[] and calculate S1/S2 |
/* encoder: subtract predictors from qcoeff[] and calculate S1/S2 |
288 |
|
|
326 |
S1 += abs(level); |
S1 += abs(level); |
327 |
predictors[i] = level; |
predictors[i] = level; |
328 |
} |
} |
329 |
} else // acpred_direction == 2 |
} else /* acpred_direction == 2 */ |
330 |
{ |
{ |
331 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
332 |
int16_t level; |
int16_t level; |
386 |
qcoeff[i] -= predictors[i]; |
qcoeff[i] -= predictors[i]; |
387 |
predictors[i] = qcoeff[i]; |
predictors[i] = qcoeff[i]; |
388 |
} |
} |
389 |
}else{ // acpred_direction == 2 |
}else{ /* acpred_direction == 2 */ |
390 |
for (i = 1; i < 8; i++) { |
for (i = 1; i < 8; i++) { |
391 |
tmp[i] = qcoeff[i*8]; |
tmp[i] = qcoeff[i*8]; |
392 |
qcoeff[i*8] -= predictors[i]; |
qcoeff[i*8] -= predictors[i]; |
404 |
if (direction == 1) { |
if (direction == 1) { |
405 |
for (i = 1; i < 8; i++) |
for (i = 1; i < 8; i++) |
406 |
qcoeff[i] = tmp[i]; |
qcoeff[i] = tmp[i]; |
407 |
}else{ // acpred_direction == 2 |
}else{ /* acpred_direction == 2 */ |
408 |
for (i = 1; i < 8; i++) |
for (i = 1; i < 8; i++) |
409 |
qcoeff[i*8] = tmp[i]; |
qcoeff[i*8] = tmp[i]; |
410 |
} |
} |
463 |
|
|
464 |
} |
} |
465 |
|
|
466 |
if (S<=0) { // dont predict |
if (S<=0) { /* dont predict */ |
467 |
for (j = 0; j < 6; j++) |
for (j = 0; j < 6; j++) |
468 |
pMB->acpred_directions[j] = 0; |
pMB->acpred_directions[j] = 0; |
469 |
}else{ |
}else{ |