--- decoder.c 2002/09/04 03:23:23 1.37 +++ decoder.c 2002/10/10 12:16:00 1.37.2.3 @@ -55,7 +55,7 @@ * 22.12.2001 lock based interpolation * 01.12.2001 inital version; (c)2001 peter ross * - * $Id: decoder.c,v 1.37 2002/09/04 03:23:23 h Exp $ + * $Id: decoder.c,v 1.37.2.3 2002/10/10 12:16:00 Isibaar Exp $ * *************************************************************************/ @@ -136,6 +136,15 @@ return XVID_ERR_MEMORY; } + if (image_create(&dec->refh, dec->edged_width, dec->edged_height)) { + image_destroy(&dec->cur, dec->edged_width, dec->edged_height); + image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); + image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); + image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); + xvid_free(dec); + return XVID_ERR_MEMORY; + } + dec->mbs = xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, CACHE_LINE); @@ -144,6 +153,7 @@ image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); + image_destroy(&dec->refh, dec->edged_width, dec->edged_height); xvid_free(dec); return XVID_ERR_MEMORY; } @@ -161,6 +171,7 @@ image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); + image_destroy(&dec->refh, dec->edged_width, dec->edged_height); xvid_free(dec); return XVID_ERR_MEMORY; } @@ -186,6 +197,7 @@ image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); + image_destroy(&dec->refh, dec->edged_width, dec->edged_height); image_destroy(&dec->cur, dec->edged_width, dec->edged_height); xvid_free(dec); @@ -268,8 +280,10 @@ start_timer(); if (cbp & (1 << (5 - i))) // coded { - get_intra_block(bs, &block[i * 64], pMB->acpred_directions[i], - start_coeff); + int direction = dec->alternate_vertical_scan ? + 2 : pMB->acpred_directions[i]; + + get_intra_block(bs, &block[i * 64], direction, start_coeff); } stop_coding_timer(); @@ -356,6 +370,30 @@ uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; + + start_timer(); + if(dec->quarterpel) { + interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, + dec->refh.y + 128, 16*x_pos, 16*y_pos, + pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); + } + else { + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, + pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, + pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, + pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, + pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); + } + + interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, + uv_dx, uv_dy, stride2, rounding); + interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, + uv_dx, uv_dy, stride2, rounding); + stop_comp_timer(); + } else { int sum; sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; @@ -375,44 +413,49 @@ } uv_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); - } - start_timer(); - if(dec->quarterpel) { - DEBUG("QUARTERPEL"); - interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, + start_timer(); + if(dec->quarterpel) { + interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, + dec->refh.y + 128, 16*x_pos, 16*y_pos, + pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); + interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, + dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, + pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); + interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, + dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, + pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); + interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, + dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, + pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); + } + else { + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); - interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); - interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); - interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, + interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); - } - else { - interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, - pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); - interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, - pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); - interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, - pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); - interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, - pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); - } + } - interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, - uv_dx, uv_dy, stride2, rounding); - interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, - uv_dx, uv_dy, stride2, rounding); - stop_comp_timer(); + interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, + uv_dx, uv_dy, stride2, rounding); + interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, + uv_dx, uv_dy, stride2, rounding); + stop_comp_timer(); + } for (i = 0; i < 6; i++) { + int direction = dec->alternate_vertical_scan ? 2 : 0; + if (cbp & (1 << (5 - i))) // coded { memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear start_timer(); - get_inter_block(bs, &block[i * 64]); + get_inter_block(bs, &block[i * 64], direction); stop_coding_timer(); start_timer(); @@ -585,7 +628,7 @@ start_timer(); image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, - dec->width, dec->height, dec->interlacing); + dec->width, dec->height); stop_edges_timer(); bound = 0; @@ -876,12 +919,14 @@ stop_comp_timer(); for (i = 0; i < 6; i++) { + int direction = dec->alternate_vertical_scan ? 2 : 0; + if (cbp & (1 << (5 - i))) // coded { memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear start_timer(); - get_inter_block(bs, &block[i * 64]); + get_inter_block(bs, &block[i * 64], direction); stop_coding_timer(); start_timer(); @@ -1027,27 +1072,47 @@ interpolate8x8_switch(dec->refn[2].v, backward.v, 8 * x_pos, 8 * y_pos, b_uv_dx, b_uv_dy, stride2, 0); - interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos, - stride); - interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, 16 * y_pos, - stride); - interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos + 8, - stride); - interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, - 16 * y_pos + 8, stride); - interpolate8x8_c(dec->cur.u, dec->refn[2].u, 8 * x_pos, 8 * y_pos, - stride2); - interpolate8x8_c(dec->cur.v, dec->refn[2].v, 8 * x_pos, 8 * y_pos, - stride2); + interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, + dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, + dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos, + stride, 0); + + 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->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8, + stride, 0); + + 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->refn[2].y + (16 * (y_pos + 8) * stride) + 16 * x_pos, + stride, 0); + + 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->refn[2].y + (16 * (y_pos + 8) * stride) + 16 * x_pos + 8, + stride, 0); + + interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride) + 8 * x_pos, + dec->cur.u + (8 * y_pos * stride) + 8 * x_pos, + dec->refn[2].u + (8 * y_pos * stride) + 8 * x_pos, + stride2, 0); + + interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride) + 8 * x_pos, + dec->cur.v + (8 * y_pos * stride) + 8 * x_pos, + dec->refn[2].v + (8 * y_pos * stride) + 8 * x_pos, + stride2, 0); + stop_comp_timer(); for (i = 0; i < 6; i++) { + int direction = dec->alternate_vertical_scan ? 2 : 0; + if (cbp & (1 << (5 - i))) // coded { memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear start_timer(); - get_inter_block(bs, &block[i * 64]); + get_inter_block(bs, &block[i * 64], direction); stop_coding_timer(); start_timer(); @@ -1142,9 +1207,9 @@ start_timer(); image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, - dec->width, dec->height, dec->interlacing); + dec->width, dec->height); image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, - dec->width, dec->height, dec->interlacing); + dec->width, dec->height); stop_edges_timer(); #ifdef BFRAMES_DEC_DEBUG