62 |
#include "image/postprocessing.h" |
#include "image/postprocessing.h" |
63 |
#include "utils/mem_align.h" |
#include "utils/mem_align.h" |
64 |
|
|
|
#ifdef ARCH_IS_IA32 |
|
|
#define interpolate16x16_quarterpel new_interpolate16x16_quarterpel |
|
|
#define interpolate8x8_quarterpel new_interpolate8x8_quarterpel |
|
|
#endif |
|
|
|
|
65 |
static int |
static int |
66 |
decoder_resize(DECODER * dec) |
decoder_resize(DECODER * dec) |
67 |
{ |
{ |
391 |
uint8_t * pY_Cur, |
uint8_t * pY_Cur, |
392 |
uint8_t * pU_Cur, |
uint8_t * pU_Cur, |
393 |
uint8_t * pV_Cur, |
uint8_t * pV_Cur, |
394 |
const int reduced_resolution, |
int reduced_resolution, |
395 |
const MACROBLOCK * pMB) |
const MACROBLOCK * pMB) |
396 |
{ |
{ |
397 |
DECLARE_ALIGNED_MATRIX(data, 6, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(data, 1, 64, int16_t, CACHE_LINE); |
398 |
|
|
399 |
int stride = dec->edged_width; |
int stride = dec->edged_width; |
400 |
int next_block = stride * (reduced_resolution ? 16 : 8); |
int next_block = stride * (reduced_resolution ? 16 : 8); |
|
const int stride2 = stride/2; |
|
401 |
int i; |
int i; |
402 |
const uint32_t iQuant = pMB->quant; |
const uint32_t iQuant = pMB->quant; |
403 |
const int direction = dec->alternate_vertical_scan ? 2 : 0; |
const int direction = dec->alternate_vertical_scan ? 2 : 0; |
407 |
int direction, |
int direction, |
408 |
const int quant, |
const int quant, |
409 |
const uint16_t *matrix); |
const uint16_t *matrix); |
410 |
|
typedef void (*add_residual_function_t)( |
411 |
|
uint8_t *predicted_block, |
412 |
|
const int16_t *residual, |
413 |
|
int stride); |
414 |
|
|
415 |
const get_inter_block_function_t get_inter_block = (dec->quant_type == 0) |
const get_inter_block_function_t get_inter_block = (dec->quant_type == 0) |
416 |
? get_inter_block_h263 |
? (get_inter_block_function_t)get_inter_block_h263 |
417 |
: get_inter_block_mpeg; |
: (get_inter_block_function_t)get_inter_block_mpeg; |
418 |
|
|
419 |
memset(&data[0], 0, 6*64*sizeof(int16_t)); /* clear */ |
const add_residual_function_t add_residual = (reduced_resolution) |
420 |
|
? (add_residual_function_t)add_upsampled_8x8_16to8 |
421 |
|
: (add_residual_function_t)transfer_16to8add; |
422 |
|
|
423 |
|
uint8_t *dst[6]; |
424 |
|
int strides[6]; |
425 |
|
|
|
for (i = 0; i < 6; i++) { |
|
426 |
|
|
427 |
if (cbp & (1 << (5 - i))) { /* coded */ |
if (dec->interlacing && pMB->field_dct) { |
428 |
|
next_block = stride; |
429 |
|
stride *= 2; |
430 |
|
} |
431 |
|
|
432 |
|
reduced_resolution = !!reduced_resolution; |
433 |
|
dst[0] = pY_Cur; |
434 |
|
dst[2] = pY_Cur + next_block; |
435 |
|
dst[1] = dst[0] + (8<<reduced_resolution); |
436 |
|
dst[3] = dst[2] + (8<<reduced_resolution); |
437 |
|
dst[4] = pU_Cur; |
438 |
|
dst[5] = pV_Cur; |
439 |
|
strides[0] = strides[1] = strides[2] = strides[3] = stride; |
440 |
|
strides[4] = stride/2; |
441 |
|
strides[5] = stride/2; |
442 |
|
|
443 |
|
for (i = 0; i < 6; i++) { |
444 |
|
/* Process only coded blocks */ |
445 |
|
if (cbp & (1 << (5 - i))) { |
446 |
|
|
447 |
|
/* Clear the block */ |
448 |
|
memset(&data[0], 0, 64*sizeof(int16_t)); |
449 |
|
|
450 |
/* Decode coeffs and dequantize on the fly */ |
/* Decode coeffs and dequantize on the fly */ |
451 |
start_timer(); |
start_timer(); |
452 |
get_inter_block(bs, &data[i*64], direction, iQuant, get_inter_matrix(dec->mpeg_quant_matrices)); |
get_inter_block(bs, &data[0], direction, iQuant, get_inter_matrix(dec->mpeg_quant_matrices)); |
453 |
stop_coding_timer(); |
stop_coding_timer(); |
454 |
|
|
455 |
|
/* iDCT */ |
456 |
start_timer(); |
start_timer(); |
457 |
idct(&data[i * 64]); |
idct(&data[0]); |
458 |
stop_idct_timer(); |
stop_idct_timer(); |
|
} |
|
|
} |
|
|
|
|
|
if (dec->interlacing && pMB->field_dct) { |
|
|
next_block = stride; |
|
|
stride *= 2; |
|
|
} |
|
459 |
|
|
460 |
|
/* Add this residual to the predicted block */ |
461 |
start_timer(); |
start_timer(); |
462 |
if (reduced_resolution) { |
add_residual(dst[i], &data[0], strides[i]); |
|
if (cbp & 32) |
|
|
add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
|
|
if (cbp & 16) |
|
|
add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); |
|
|
if (cbp & 8) |
|
|
add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride); |
|
|
if (cbp & 4) |
|
|
add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride); |
|
|
if (cbp & 2) |
|
|
add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2); |
|
|
if (cbp & 1) |
|
|
add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2); |
|
|
} else { |
|
|
if (cbp & 32) |
|
|
transfer_16to8add(pY_Cur, &data[0 * 64], stride); |
|
|
if (cbp & 16) |
|
|
transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride); |
|
|
if (cbp & 8) |
|
|
transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride); |
|
|
if (cbp & 4) |
|
|
transfer_16to8add(pY_Cur + 8 + next_block, &data[3 * 64], stride); |
|
|
if (cbp & 2) |
|
|
transfer_16to8add(pU_Cur, &data[4 * 64], stride2); |
|
|
if (cbp & 1) |
|
|
transfer_16to8add(pV_Cur, &data[5 * 64], stride2); |
|
|
} |
|
463 |
stop_transfer_timer(); |
stop_transfer_timer(); |
464 |
} |
} |
465 |
|
} |
466 |
|
} |
467 |
|
|
468 |
/* decode an inter macroblock */ |
/* decode an inter macroblock */ |
469 |
static void |
static void |
1110 |
|
|
1111 |
if(dec->quarterpel) { |
if(dec->quarterpel) { |
1112 |
if(!direct) { |
if(!direct) { |
1113 |
interpolate16x16_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
interpolate16x16_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1114 |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
1115 |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1116 |
} else { |
} else { |
1117 |
interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1118 |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
1119 |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1120 |
interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1121 |
dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos, |
dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos, |
1122 |
pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0); |
pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0); |
1123 |
interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1124 |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8, |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8, |
1125 |
pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0); |
pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0); |
1126 |
interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1127 |
dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
1128 |
pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0); |
pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0); |
1129 |
} |
} |
1130 |
} else { |
} else { |
1131 |
interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos, 16 * y_pos, |
interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos, 16 * y_pos, |
1132 |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1133 |
interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos + 8, |
interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos + 8, |
1134 |
16 * y_pos, pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0); |
16 * y_pos, pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0); |
1135 |
interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos, |
interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos, |
1136 |
16 * y_pos + 8, pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0); |
16 * y_pos + 8, pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0); |
1137 |
interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos + 8, |
interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos + 8, |
1138 |
16 * y_pos + 8, pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0); |
16 * y_pos + 8, pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0); |
1139 |
} |
} |
1140 |
|
|
1141 |
interpolate8x8_switch(dec->tmp.u, backward.u, 8 * x_pos, 8 * y_pos, |
interpolate8x8_add_switch(dec->cur.u, backward.u, 8 * x_pos, 8 * y_pos, |
1142 |
b_uv_dx, b_uv_dy, stride2, 0); |
b_uv_dx, b_uv_dy, stride2, 0); |
1143 |
interpolate8x8_switch(dec->tmp.v, backward.v, 8 * x_pos, 8 * y_pos, |
interpolate8x8_add_switch(dec->cur.v, backward.v, 8 * x_pos, 8 * y_pos, |
1144 |
b_uv_dx, b_uv_dy, stride2, 0); |
b_uv_dx, b_uv_dy, stride2, 0); |
1145 |
|
|
|
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
|
|
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
|
|
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos, |
|
|
stride, 1, 8); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
|
|
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
|
|
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
|
|
stride, 1, 8); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
|
|
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
|
|
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
|
|
stride, 1, 8); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
|
|
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
|
|
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
|
|
stride, 1, 8); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->tmp.u + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
stride2, 1, 8); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->tmp.v + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
stride2, 1, 8); |
|
|
|
|
1146 |
stop_comp_timer(); |
stop_comp_timer(); |
1147 |
|
|
1148 |
if (cbp) |
if (cbp) |