1 |
|
/***************************************************************************** |
2 |
|
* |
3 |
|
* XVID MPEG-4 VIDEO CODEC |
4 |
|
* - Interpolation related header - |
5 |
|
* |
6 |
|
* Copyright(C) 2001-2003 Peter Ross <pross@xvid.org> |
7 |
|
* |
8 |
|
* This program is free software ; you can redistribute it and/or modify |
9 |
|
* it under the terms of the GNU General Public License as published by |
10 |
|
* the Free Software Foundation ; either version 2 of the License, or |
11 |
|
* (at your option) any later version. |
12 |
|
* |
13 |
|
* This program is distributed in the hope that it will be useful, |
14 |
|
* but WITHOUT ANY WARRANTY ; without even the implied warranty of |
15 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
* GNU General Public License for more details. |
17 |
|
* |
18 |
|
* You should have received a copy of the GNU General Public License |
19 |
|
* along with this program ; if not, write to the Free Software |
20 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
|
* |
22 |
|
* $Id$ |
23 |
|
* |
24 |
|
****************************************************************************/ |
25 |
|
|
26 |
#ifndef _INTERPOLATE8X8_H_ |
#ifndef _INTERPOLATE8X8_H_ |
27 |
#define _INTERPOLATE8X8_H_ |
#define _INTERPOLATE8X8_H_ |
28 |
|
|
96 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
97 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
98 |
|
|
99 |
|
#ifdef ARCH_IS_IA32 |
100 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx; |
101 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx; |
102 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx; |
112 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne; |
113 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne; |
114 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne; |
115 |
|
#endif |
116 |
|
|
117 |
|
#ifdef ARCH_IS_IA64 |
118 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
119 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
120 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
121 |
|
#endif |
122 |
|
|
123 |
|
#ifdef ARCH_IS_PPC |
124 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_altivec_c; |
125 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_altivec_c; |
126 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_altivec_c; |
127 |
|
#endif |
128 |
|
|
129 |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
130 |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
131 |
|
|
132 |
|
#ifdef ARCH_IS_IA32 |
133 |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
134 |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
135 |
|
#endif |
136 |
|
|
137 |
|
#ifdef ARCH_IS_PPC |
138 |
|
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_altivec_c; |
139 |
|
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_altivec_c; |
140 |
|
#endif |
141 |
|
|
142 |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c; |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c; |
143 |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c; |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c; |
151 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
152 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
153 |
|
|
154 |
|
#ifdef ARCH_IS_IA32 |
155 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
156 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
157 |
|
#endif |
158 |
|
|
159 |
|
#ifdef ARCH_IS_PPC |
160 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_altivec_c; |
161 |
|
#endif |
162 |
|
|
163 |
static __inline void |
static __inline void |
164 |
interpolate8x8_switch(uint8_t * const cur, |
interpolate8x8_switch(uint8_t * const cur, |
170 |
const uint32_t stride, |
const uint32_t stride, |
171 |
const uint32_t rounding) |
const uint32_t rounding) |
172 |
{ |
{ |
|
int32_t ddx, ddy; |
|
173 |
|
|
174 |
switch (((dx & 1) << 1) + (dy & 1)) /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1)); |
175 |
{ |
uint8_t * const dst = cur + (int)(y * stride + x); |
176 |
|
|
177 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
178 |
case 0: |
case 0: |
179 |
ddx = dx / 2; |
transfer8x8_copy(dst, src, stride); |
|
ddy = dy / 2; |
|
|
transfer8x8_copy(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride); |
|
180 |
break; |
break; |
|
|
|
181 |
case 1: |
case 1: |
182 |
ddx = dx / 2; |
interpolate8x8_halfpel_v(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
183 |
break; |
break; |
|
|
|
184 |
case 2: |
case 2: |
185 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h(dst, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
186 |
break; |
break; |
|
|
|
187 |
default: |
default: |
188 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
189 |
break; |
break; |
190 |
} |
} |
191 |
} |
} |
228 |
static __inline uint8_t * |
static __inline uint8_t * |
229 |
interpolate8x8_switch2(uint8_t * const buffer, |
interpolate8x8_switch2(uint8_t * const buffer, |
230 |
const uint8_t * const refn, |
const uint8_t * const refn, |
231 |
const uint32_t x, |
const int x, |
232 |
const uint32_t y, |
const int y, |
233 |
const int32_t dx, |
const int dx, |
234 |
const int dy, |
const int dy, |
235 |
const uint32_t stride, |
const uint32_t stride, |
236 |
const uint32_t rounding) |
const uint32_t rounding) |
237 |
{ |
{ |
|
int32_t ddx, ddy; |
|
238 |
|
|
239 |
switch (((dx & 1) << 1) + (dy & 1)) /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1)); |
|
{ |
|
|
case 0: |
|
|
return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); |
|
240 |
|
|
241 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
242 |
|
case 0: |
243 |
|
return (uint8_t *)src; |
244 |
case 1: |
case 1: |
245 |
ddx = dx / 2; |
interpolate8x8_halfpel_v(buffer, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
246 |
break; |
break; |
|
|
|
247 |
case 2: |
case 2: |
248 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h(buffer, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
249 |
break; |
break; |
|
|
|
250 |
default: |
default: |
251 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv(buffer, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
252 |
break; |
break; |
253 |
} |
} |
254 |
return buffer; |
return buffer; |