--- decoder.c 2004/05/21 14:40:15 1.57 +++ decoder.c 2004/07/14 23:26:06 1.62 @@ -20,7 +20,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: decoder.c,v 1.57 2004/05/21 14:40:15 edgomez Exp $ + * $Id: decoder.c,v 1.62 2004/07/14 23:26:06 edgomez Exp $ * ****************************************************************************/ @@ -48,6 +48,7 @@ #include "image/interpolate8x8.h" #include "image/reduced.h" #include "image/font.h" +#include "image/qpel.h" #include "bitstream/mbcoding.h" #include "prediction/mbprediction.h" @@ -61,6 +62,11 @@ #include "image/postprocessing.h" #include "utils/mem_align.h" +#ifdef ARCH_IS_IA32 +#define interpolate16x16_quarterpel new_interpolate16x16_quarterpel +#define interpolate8x8_quarterpel new_interpolate8x8_quarterpel +#endif + static int decoder_resize(DECODER * dec) { @@ -303,7 +309,7 @@ start_timer(); predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i, &block[i * 64], - iQuant, iDcScaler, predictors, bound, dec->bs_version); + iQuant, iDcScaler, predictors, bound); if (!acpred_flag) { pMB->acpred_directions[i] = 0; } @@ -339,7 +345,7 @@ stop_coding_timer(); start_timer(); - add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors); + add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version); stop_prediction_timer(); start_timer(); @@ -393,7 +399,6 @@ const int reduced_resolution, const MACROBLOCK * pMB) { - DECLARE_ALIGNED_MATRIX(block, 1, 64, int16_t, CACHE_LINE); DECLARE_ALIGNED_MATRIX(data, 6, 64, int16_t, CACHE_LINE); int stride = dec->edged_width; @@ -402,23 +407,30 @@ int i; const uint32_t iQuant = pMB->quant; const int direction = dec->alternate_vertical_scan ? 2 : 0; - const quant_interFuncPtr dequant = dec->quant_type == 0 ? dequant_h263_inter : dequant_mpeg_inter; + typedef void (*get_inter_block_function_t)( + Bitstream * bs, + int16_t * block, + int direction, + const int quant, + const uint16_t *matrix); + + const get_inter_block_function_t get_inter_block = (dec->quant_type == 0) + ? get_inter_block_h263 + : get_inter_block_mpeg; + + memset(&data[0], 0, 6*64*sizeof(int16_t)); /* clear */ for (i = 0; i < 6; i++) { if (cbp & (1 << (5 - i))) { /* coded */ - memset(block, 0, 64 * sizeof(int16_t)); /* clear */ + /* Decode coeffs and dequantize on the fly */ start_timer(); - get_inter_block(bs, block, direction); + get_inter_block(bs, &data[i*64], direction, iQuant, get_inter_matrix(dec->mpeg_quant_matrices)); stop_coding_timer(); start_timer(); - dequant(&data[i * 64], block, iQuant, dec->mpeg_quant_matrices); - stop_iquant_timer(); - - start_timer(); idct(&data[i * 64]); stop_idct_timer(); } @@ -1032,7 +1044,6 @@ if (!direct) { uv_dx = pMB->mvs[0].x; uv_dy = pMB->mvs[0].y; - b_uv_dx = pMB->b_mvs[0].x; b_uv_dy = pMB->b_mvs[0].y; @@ -1045,21 +1056,20 @@ uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; - b_uv_dx = (b_uv_dx >> 1) + roundtab_79[b_uv_dx & 0x3]; b_uv_dy = (b_uv_dy >> 1) + roundtab_79[b_uv_dy & 0x3]; } else { - if(dec->quarterpel) { - uv_dx = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); - uv_dy = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); - b_uv_dx = (pMB->b_mvs[0].x / 2) + (pMB->b_mvs[1].x / 2) + (pMB->b_mvs[2].x / 2) + (pMB->b_mvs[3].x / 2); - b_uv_dy = (pMB->b_mvs[0].y / 2) + (pMB->b_mvs[1].y / 2) + (pMB->b_mvs[2].y / 2) + (pMB->b_mvs[3].y / 2); - } else { - uv_dx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; - uv_dy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; - b_uv_dx = pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + pMB->b_mvs[3].x; - b_uv_dy = pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + pMB->b_mvs[3].y; + uv_dx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; + uv_dy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; + b_uv_dx = pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + pMB->b_mvs[3].x; + b_uv_dy = pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + pMB->b_mvs[3].y; + + if (dec->quarterpel) { + uv_dx /= 2; + uv_dy /= 2; + b_uv_dx /= 2; + b_uv_dy /= 2; } uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf]; @@ -1218,7 +1228,6 @@ uint32_t x, y; VECTOR mv; const VECTOR zeromv = {0,0}; - const int32_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp; int i; if (!dec->is_edged[0]) { @@ -1322,14 +1331,15 @@ case MODE_DIRECT_NONE_MV: for (i = 0; i < 4; i++) { - mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x); - mb->b_mvs[i].x = (int32_t) ((mv.x == 0) - ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD - : mb->mvs[i].x - last_mb->mvs[i].x); - mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y); - mb->b_mvs[i].y = (int32_t) ((mv.y == 0) - ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD - : mb->mvs[i].y - last_mb->mvs[i].y); + mb->mvs[i].x = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x; + mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y; + + mb->b_mvs[i].x = (mv.x) + ? mb->mvs[i].x - last_mb->mvs[i].x + : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp; + mb->b_mvs[i].y = (mv.y) + ? mb->mvs[i].y - last_mb->mvs[i].y + : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp; } decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], @@ -1573,7 +1583,7 @@ if (dec->low_delay) { DPRINTF(XVID_DEBUG_ERROR, "warning: bvop found in low_delay==1 stream\n"); - dec->low_delay = 1; + dec->low_delay = 0; } if (dec->frames < 2) {