--- interpolate8x8.c 2002/07/24 00:50:05 1.4 +++ interpolate8x8.c 2002/12/15 01:21:12 1.8 @@ -1,45 +1,70 @@ -/************************************************************************** +/***************************************************************************** * - * XVID MPEG-4 VIDEO CODEC - * 8x8 block-based halfpel interpolation + * XVID MPEG-4 VIDEO CODEC + * - 8x8 block-based halfpel interpolation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright(C) 2002 Peter Ross + * Copyright(C) 2002 MinChen * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This file is part of XviD, a free MPEG-4 video encoder/decoder * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * XviD is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - *************************************************************************/ - -/************************************************************************** + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * History: - * - * 02.05.2002 add "interpolate8x8_c" for B-frame; MinChen - * 27.12.2001 modified "compensate_halfpel" - * 05.11.2001 initial version; (c)2001 peter ross + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - *************************************************************************/ - + * Under section 8 of the GNU General Public License, the copyright + * holders of XVID explicitly forbid distribution in the following + * countries: + * + * - Japan + * - United States of America + * + * Linking XviD statically or dynamically with other modules is making a + * combined work based on XviD. Thus, the terms and conditions of the + * GNU General Public License cover the whole combination. + * + * As a special exception, the copyright holders of XviD give you + * permission to link XviD with independent modules that communicate with + * XviD solely through the VFW1.1 and DShow interfaces, regardless of the + * license terms of these independent modules, and to copy and distribute + * the resulting combined work under terms of your choice, provided that + * every copy of the combined work is accompanied by a complete copy of + * the source code of XviD (the version of XviD used to produce the + * combined work), being distributed under the terms of the GNU General + * Public License plus this exception. An independent module is a module + * which is not derived from or based on XviD. + * + * Note that people who make modified versions of XviD are not obligated + * to grant this special exception for their modified versions; it is + * their choice whether to do so. The GNU General Public License gives + * permission to release a modified version without this exception; this + * exception also makes it possible to release a modified version which + * carries forward this exception. + * + * $Id: interpolate8x8.c,v 1.8 2002/12/15 01:21:12 edgomez Exp $ + * + ****************************************************************************/ #include "../portab.h" #include "interpolate8x8.h" -// function pointers +/* function pointers */ INTERPOLATE8X8_PTR interpolate8x8_halfpel_h; INTERPOLATE8X8_PTR interpolate8x8_halfpel_v; INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv; -// dst = interpolate(src) +/* dst = interpolate(src) */ void interpolate8x8_halfpel_h_c(uint8_t * const dst, @@ -52,11 +77,10 @@ for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { - int16_t tot = - (int32_t) src[j * stride + i] + (int32_t) src[j * stride + i + - 1]; + int32_t tot = + (int32_t) src[j * stride + i] + (int32_t) src[j * stride + i + 1]; - tot = (int32_t) ((tot + 1 - rounding) >> 1); + tot = (tot + 1 - rounding) >> 1; dst[j * stride + i] = (uint8_t) tot; } } @@ -74,7 +98,8 @@ for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { - int16_t tot = src[j * stride + i] + src[j * stride + i + stride]; + int32_t tot = + (int32_t)src[j * stride + i] + (int32_t)src[j * stride + i + stride]; tot = ((tot + 1 - rounding) >> 1); dst[j * stride + i] = (uint8_t) tot; @@ -93,18 +118,17 @@ for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { - int16_t tot = - src[j * stride + i] + src[j * stride + i + 1] + - src[j * stride + i + stride] + src[j * stride + i + stride + - 1]; + int32_t tot = + (int32_t)src[j * stride + i] + (int32_t)src[j * stride + i + 1] + + (int32_t)src[j * stride + i + stride] + (int32_t)src[j * stride + i + stride + 1]; tot = ((tot + 2 - rounding) >> 2); dst[j * stride + i] = (uint8_t) tot; } } } -// add by MinChen -// interpolate8x8 two pred block +/* add by MinChen */ +/* interpolate8x8 two pred block */ void interpolate8x8_c(uint8_t * const dst, const uint8_t * const src, @@ -117,8 +141,8 @@ for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { int32_t tot = - ((src[(y + j) * stride + x + i] + - dst[(y + j) * stride + x + i] + 1) >> 1); + (((int32_t)src[(y + j) * stride + x + i] + + (int32_t)dst[(y + j) * stride + x + i] + 1) >> 1); dst[(y + j) * stride + x + i] = (uint8_t) tot; } } @@ -233,14 +257,14 @@ for(i = 0; i < 8; i++) { - dst[0] = (src1[0] + src2[0] + (1 - rounding)) >> 1; - dst[1] = (src1[1] + src2[1] + (1 - rounding)) >> 1; - dst[2] = (src1[2] + src2[2] + (1 - rounding)) >> 1; - dst[3] = (src1[3] + src2[3] + (1 - rounding)) >> 1; - dst[4] = (src1[4] + src2[4] + (1 - rounding)) >> 1; - dst[5] = (src1[5] + src2[5] + (1 - rounding)) >> 1; - dst[6] = (src1[6] + src2[6] + (1 - rounding)) >> 1; - dst[7] = (src1[7] + src2[7] + (1 - rounding)) >> 1; + dst[0] = (uint8_t)((src1[0] + src2[0] + (1 - rounding)) >> 1); + dst[1] = (uint8_t)((src1[1] + src2[1] + (1 - rounding)) >> 1); + dst[2] = (uint8_t)((src1[2] + src2[2] + (1 - rounding)) >> 1); + dst[3] = (uint8_t)((src1[3] + src2[3] + (1 - rounding)) >> 1); + dst[4] = (uint8_t)((src1[4] + src2[4] + (1 - rounding)) >> 1); + dst[5] = (uint8_t)((src1[5] + src2[5] + (1 - rounding)) >> 1); + dst[6] = (uint8_t)((src1[6] + src2[6] + (1 - rounding)) >> 1); + dst[7] = (uint8_t)((src1[7] + src2[7] + (1 - rounding)) >> 1); dst += dst_stride; src1 += src_stride; @@ -254,14 +278,14 @@ for(i = 0; i < 8; i++) { - dst[0] = (src1[0] + src2[0] + src3[0] + src4[0] + (2 - rounding)) >> 2; - dst[1] = (src1[1] + src2[1] + src3[1] + src4[1] + (2 - rounding)) >> 2; - dst[2] = (src1[2] + src2[2] + src3[2] + src4[2] + (2 - rounding)) >> 2; - dst[3] = (src1[3] + src2[3] + src3[3] + src4[3] + (2 - rounding)) >> 2; - dst[4] = (src1[4] + src2[4] + src3[4] + src4[4] + (2 - rounding)) >> 2; - dst[5] = (src1[5] + src2[5] + src3[5] + src4[5] + (2 - rounding)) >> 2; - dst[6] = (src1[6] + src2[6] + src3[6] + src4[6] + (2 - rounding)) >> 2; - dst[7] = (src1[7] + src2[7] + src3[7] + src4[7] + (2 - rounding)) >> 2; + dst[0] = (uint8_t)((src1[0] + src2[0] + src3[0] + src4[0] + (2 - rounding)) >> 2); + dst[1] = (uint8_t)((src1[1] + src2[1] + src3[1] + src4[1] + (2 - rounding)) >> 2); + dst[2] = (uint8_t)((src1[2] + src2[2] + src3[2] + src4[2] + (2 - rounding)) >> 2); + dst[3] = (uint8_t)((src1[3] + src2[3] + src3[3] + src4[3] + (2 - rounding)) >> 2); + dst[4] = (uint8_t)((src1[4] + src2[4] + src3[4] + src4[4] + (2 - rounding)) >> 2); + dst[5] = (uint8_t)((src1[5] + src2[5] + src3[5] + src4[5] + (2 - rounding)) >> 2); + dst[6] = (uint8_t)((src1[6] + src2[6] + src3[6] + src4[6] + (2 - rounding)) >> 2); + dst[7] = (uint8_t)((src1[7] + src2[7] + src3[7] + src4[7] + (2 - rounding)) >> 2); dst += stride; src1 += stride;