--- interpolate8x8.h 2003/02/15 15:22:18 1.10 +++ 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_ @@ -122,39 +147,22 @@ 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; } } @@ -197,42 +205,27 @@ static __inline uint8_t * interpolate8x8_switch2(uint8_t * const buffer, const uint8_t * const refn, - const uint32_t x, - const uint32_t y, - const int32_t dx, + const int x, + const int y, + const int dx, const int dy, 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) - { - case 0: - return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); + 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;