--- interpolate8x8.h 2002/11/20 20:11:49 1.5.2.7 +++ interpolate8x8.h 2003/07/13 10:01:00 1.10.2.3 @@ -1,3 +1,28 @@ +/***************************************************************************** + * + * XVID MPEG-4 VIDEO CODEC + * - Interpolation related header - + * + * Copyright(C) 2001-2003 Peter Ross + * + * 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. + * + * 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. + * + * 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 + * + * $Id: interpolate8x8.h,v 1.10.2.3 2003/07/13 10:01:00 syskin Exp $ + * + ****************************************************************************/ + #ifndef _INTERPOLATE8X8_H_ #define _INTERPOLATE8X8_H_ @@ -83,6 +108,10 @@ INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; +INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne; +INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne; +INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne; + INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; @@ -118,45 +147,29 @@ const uint32_t stride, const uint32_t rounding) { - int32_t ddx, ddy; - switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) - { + const uint8_t * const src = refn + (y + (dy>>1)) * stride + x + (dx>>1); + uint8_t * const dst = cur + y * stride + x; + + switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ case 0: - ddx = dx / 2; - ddy = dy / 2; - transfer8x8_copy(cur + y * stride + x, - refn + (int)((y + ddy) * stride + x + ddx), stride); + transfer8x8_copy(dst, src, stride); break; - case 1: - ddx = dx / 2; - ddy = (dy - 1) / 2; - interpolate8x8_halfpel_v(cur + y * stride + x, - refn + (int)((y + ddy) * stride + x + ddx), stride, - rounding); + interpolate8x8_halfpel_v(dst, src, stride, rounding); break; - case 2: - ddx = (dx - 1) / 2; - ddy = dy / 2; - interpolate8x8_halfpel_h(cur + y * stride + x, - refn + (int)((y + ddy) * stride + x + ddx), stride, - rounding); + interpolate8x8_halfpel_h(dst, src, stride, rounding); break; - default: - ddx = (dx - 1) / 2; - ddy = (dy - 1) / 2; - interpolate8x8_halfpel_hv(cur + y * stride + x, - refn + (int)((y + ddy) * stride + x + ddx), stride, - rounding); + interpolate8x8_halfpel_hv(dst, src, stride, rounding); break; } } -static __inline uint8_t * -interpolate8x8_switch2(uint8_t * const buffer, + +static __inline void +interpolate16x16_switch(uint8_t * const cur, const uint8_t * const refn, const uint32_t x, const uint32_t y, @@ -165,35 +178,54 @@ const uint32_t stride, const uint32_t rounding) { - int32_t ddx, ddy; + interpolate8x8_switch(cur, refn, x, y, dx, dy, stride, rounding); + interpolate8x8_switch(cur, refn, x+8, y, dx, dy, stride, rounding); + interpolate8x8_switch(cur, refn, x, y+8, dx, dy, stride, rounding); + interpolate8x8_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding); +} - switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) - { - case 0: - return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); +static __inline void +interpolate32x32_switch(uint8_t * const cur, + const uint8_t * const refn, + const uint32_t x, + const uint32_t y, + const int32_t dx, + const int dy, + const uint32_t stride, + const uint32_t rounding) +{ + interpolate16x16_switch(cur, refn, x, y, dx, dy, stride, rounding); + interpolate16x16_switch(cur, refn, x+16, y, dx, dy, stride, rounding); + interpolate16x16_switch(cur, refn, x, y+16, dx, dy, stride, rounding); + interpolate16x16_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding); +} + + +static __inline uint8_t * +interpolate8x8_switch2(uint8_t * const buffer, + const uint8_t * const refn, + const int x, + const int y, + const int dx, + const int dy, + const uint32_t stride, + const uint32_t rounding) +{ + + const uint8_t * const src = refn + (y + (dy>>1)) * stride + x + (dx>>1); + + switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ + case 0: + return (uint8_t *)src; case 1: - ddx = dx / 2; - ddy = (dy - 1) / 2; - interpolate8x8_halfpel_v(buffer, - refn + (int)((y + ddy) * stride + x + ddx), stride, - rounding); + interpolate8x8_halfpel_v(buffer, src, stride, rounding); break; - case 2: - ddx = (dx - 1) / 2; - ddy = dy / 2; - interpolate8x8_halfpel_h(buffer, - refn + (int)((y + ddy) * stride + x + ddx), stride, - rounding); + interpolate8x8_halfpel_h(buffer, src, stride, rounding); break; - default: - ddx = (dx - 1) / 2; - ddy = (dy - 1) / 2; - interpolate8x8_halfpel_hv(buffer, - refn + (int)((y + ddy) * stride + x + ddx), stride, - rounding); + interpolate8x8_halfpel_hv(buffer, src, stride, rounding); break; } return buffer; @@ -364,10 +396,7 @@ switch((y_frac << 2) | (x_frac)) { case 0: - transfer8x8_copy(dst, src, stride); - transfer8x8_copy(dst+8, src+8, stride); - transfer8x8_copy(dst+8*stride, src+8*stride, stride); - transfer8x8_copy(dst+8*stride+8, src+8*stride+8, stride); + transfer16x16_copy(dst, src, stride); break; case 1: @@ -505,4 +534,5 @@ break; } } + #endif