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 |
|
|
38 |
const uint8_t *src1, |
const uint8_t *src1, |
39 |
const uint8_t *src2, |
const uint8_t *src2, |
40 |
const uint32_t stride, |
const uint32_t stride, |
41 |
const uint32_t rounding); |
const uint32_t rounding, |
42 |
|
const uint32_t height); |
43 |
typedef INTERPOLATE8X8_AVG2 *INTERPOLATE8X8_AVG2_PTR; |
typedef INTERPOLATE8X8_AVG2 *INTERPOLATE8X8_AVG2_PTR; |
44 |
|
|
45 |
typedef void (INTERPOLATE8X8_AVG4) (uint8_t *dst, |
typedef void (INTERPOLATE8X8_AVG4) (uint8_t *dst, |
73 |
|
|
74 |
typedef INTERPOLATE8X8_6TAP_LOWPASS *INTERPOLATE8X8_6TAP_LOWPASS_PTR; |
typedef INTERPOLATE8X8_6TAP_LOWPASS *INTERPOLATE8X8_6TAP_LOWPASS_PTR; |
75 |
|
|
76 |
|
/* These function do: dst = interpolate(src) */ |
77 |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h; |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h; |
78 |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v; |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v; |
79 |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv; |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv; |
80 |
|
|
81 |
|
/* These functions do: dst = (dst+interpolate(src) + 1)/2 |
82 |
|
* Suitable for direct/interpolated bvop prediction block |
83 |
|
* building w/o the need for intermediate interpolated result |
84 |
|
* storing/reading |
85 |
|
* NB: the rounding applies to the interpolation, but not |
86 |
|
* the averaging step which will always use rounding=0 */ |
87 |
|
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_add; |
88 |
|
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h_add; |
89 |
|
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v_add; |
90 |
|
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv_add; |
91 |
|
|
92 |
extern INTERPOLATE8X8_AVG2_PTR interpolate8x8_avg2; |
extern INTERPOLATE8X8_AVG2_PTR interpolate8x8_avg2; |
93 |
extern INTERPOLATE8X8_AVG4_PTR interpolate8x8_avg4; |
extern INTERPOLATE8X8_AVG4_PTR interpolate8x8_avg4; |
94 |
|
|
107 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_c; |
108 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
109 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
110 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_add_c; |
111 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_add_c; |
112 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_add_c; |
113 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_c; |
114 |
|
|
115 |
|
#ifdef ARCH_IS_IA32 |
116 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx; |
117 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx; |
118 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx; |
119 |
|
|
120 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_add_mmx; |
121 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_add_mmx; |
122 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_add_mmx; |
123 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_mmx; |
124 |
|
|
125 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_xmm; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_xmm; |
126 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_xmm; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_xmm; |
127 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_xmm; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_xmm; |
128 |
|
|
129 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_add_xmm; |
130 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_add_xmm; |
131 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_add_xmm; |
132 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_xmm; |
133 |
|
|
134 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_3dn; |
135 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; |
136 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; |
137 |
|
|
138 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne; |
139 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne; |
140 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne; |
141 |
|
#endif |
142 |
|
|
143 |
|
#ifdef ARCH_IS_IA64 |
144 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
145 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
146 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
147 |
|
#endif |
148 |
|
|
149 |
|
#ifdef ARCH_IS_PPC |
150 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_altivec_c; |
151 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_altivec_c; |
152 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_altivec_c; |
153 |
|
|
154 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_add_altivec_c; |
155 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_add_altivec_c; |
156 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_add_altivec_c; |
157 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_altivec_c; |
158 |
|
#endif |
159 |
|
|
160 |
|
#ifdef ARCH_IS_X86_64 |
161 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_x86_64; |
162 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_x86_64; |
163 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_x86_64; |
164 |
|
|
165 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_add_x86_64; |
166 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_add_x86_64; |
167 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_add_x86_64; |
168 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_x86_64; |
169 |
|
#endif |
170 |
|
|
171 |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
172 |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
173 |
|
|
174 |
|
#ifdef ARCH_IS_IA32 |
175 |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
176 |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
177 |
|
#endif |
178 |
|
|
179 |
|
#ifdef ARCH_IS_PPC |
180 |
|
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_altivec_c; |
181 |
|
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_altivec_c; |
182 |
|
#endif |
183 |
|
|
184 |
|
#ifdef ARCH_IS_X86_64 |
185 |
|
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_x86_64; |
186 |
|
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_x86_64; |
187 |
|
#endif |
188 |
|
|
189 |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c; |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c; |
190 |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c; |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c; |
198 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
199 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
200 |
|
|
201 |
|
#ifdef ARCH_IS_IA32 |
202 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
203 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
204 |
|
#endif |
205 |
|
|
206 |
|
#ifdef ARCH_IS_PPC |
207 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_altivec_c; |
208 |
|
#endif |
209 |
|
|
210 |
|
#ifdef ARCH_IS_X86_64 |
211 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_x86_64; |
212 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_x86_64; |
213 |
|
#endif |
214 |
|
|
215 |
static __inline void |
static __inline void |
216 |
interpolate8x8_switch(uint8_t * const cur, |
interpolate8x8_switch(uint8_t * const cur, |
222 |
const uint32_t stride, |
const uint32_t stride, |
223 |
const uint32_t rounding) |
const uint32_t rounding) |
224 |
{ |
{ |
|
int32_t ddx, ddy; |
|
225 |
|
|
226 |
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)); |
227 |
{ |
uint8_t * const dst = cur + (int)(y * stride + x); |
228 |
|
|
229 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
230 |
case 0: |
case 0: |
231 |
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); |
|
232 |
break; |
break; |
|
|
|
233 |
case 1: |
case 1: |
234 |
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); |
|
235 |
break; |
break; |
|
|
|
236 |
case 2: |
case 2: |
237 |
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); |
|
238 |
break; |
break; |
|
|
|
239 |
default: |
default: |
240 |
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); |
|
241 |
break; |
break; |
242 |
} |
} |
243 |
} |
} |
244 |
|
|
245 |
static __inline uint8_t * |
static __inline void |
246 |
interpolate8x8_switch2(uint8_t * const buffer, |
interpolate8x8_add_switch(uint8_t * const cur, |
247 |
const uint8_t * const refn, |
const uint8_t * const refn, |
248 |
const uint32_t x, |
const uint32_t x, |
249 |
const uint32_t y, |
const uint32_t y, |
252 |
const uint32_t stride, |
const uint32_t stride, |
253 |
const uint32_t rounding) |
const uint32_t rounding) |
254 |
{ |
{ |
|
int32_t ddx, ddy; |
|
255 |
|
|
256 |
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)); |
257 |
{ |
uint8_t * const dst = cur + (int)(y * stride + x); |
|
case 0: |
|
|
return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); |
|
258 |
|
|
259 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
260 |
|
case 0: |
261 |
|
interpolate8x8_halfpel_add(dst, src, stride, rounding); |
262 |
|
break; |
263 |
case 1: |
case 1: |
264 |
ddx = dx / 2; |
interpolate8x8_halfpel_v_add(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
265 |
break; |
break; |
|
|
|
266 |
case 2: |
case 2: |
267 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h_add(dst, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
268 |
break; |
break; |
|
|
|
269 |
default: |
default: |
270 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv_add(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
271 |
break; |
break; |
272 |
} |
} |
|
return buffer; |
|
273 |
} |
} |
274 |
|
|
275 |
|
static __inline void |
276 |
static __inline void interpolate8x8_quarterpel(uint8_t * const cur, |
interpolate16x16_switch(uint8_t * const cur, |
277 |
uint8_t * const refn, |
const uint8_t * const refn, |
278 |
uint8_t * const refh, |
const uint32_t x, |
279 |
uint8_t * const refv, |
const uint32_t y, |
280 |
uint8_t * const refhv, |
const int32_t dx, |
281 |
const uint32_t x, const uint32_t y, |
const int dy, |
|
const int32_t dx, const int dy, |
|
282 |
const uint32_t stride, |
const uint32_t stride, |
283 |
const uint32_t rounding) |
const uint32_t rounding) |
284 |
{ |
{ |
285 |
const int32_t xRef = x*4 + dx; |
interpolate8x8_switch(cur, refn, x, y, dx, dy, stride, rounding); |
286 |
const int32_t yRef = y*4 + dy; |
interpolate8x8_switch(cur, refn, x+8, y, dx, dy, stride, rounding); |
287 |
|
interpolate8x8_switch(cur, refn, x, y+8, dx, dy, stride, rounding); |
288 |
uint8_t *src, *dst; |
interpolate8x8_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding); |
|
uint8_t *halfpel_h, *halfpel_v, *halfpel_hv; |
|
|
int32_t x_int, y_int, x_frac, y_frac; |
|
|
|
|
|
x_int = xRef/4; |
|
|
if (xRef < 0 && xRef % 4) |
|
|
x_int--; |
|
|
|
|
|
x_frac = xRef - (4*x_int); |
|
|
|
|
|
y_int = yRef/4; |
|
|
if (yRef < 0 && yRef % 4) |
|
|
y_int--; |
|
|
|
|
|
y_frac = yRef - (4*y_int); |
|
|
|
|
|
src = refn + y_int * stride + x_int; |
|
|
halfpel_h = refh; |
|
|
halfpel_v = refv; |
|
|
halfpel_hv = refhv; |
|
|
|
|
|
dst = cur + y * stride + x; |
|
|
|
|
|
switch((y_frac << 2) | (x_frac)) { |
|
|
|
|
|
case 0: |
|
|
transfer8x8_copy(dst, src, stride); |
|
|
break; |
|
|
|
|
|
case 1: |
|
|
interpolate8x8_lowpass_h(halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src, halfpel_h, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 2: |
|
|
interpolate8x8_lowpass_h(dst, src, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 3: |
|
|
interpolate8x8_lowpass_h(halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src + 1, halfpel_h, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 4: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src, halfpel_v, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 5: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src, halfpel_h, halfpel_v, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 6: |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_h, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 7: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src+1, stride, rounding); |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src+1, halfpel_h, halfpel_v, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 8: |
|
|
interpolate8x8_lowpass_v(dst, src, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 9: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_v, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 10: |
|
|
interpolate8x8_lowpass_hv(dst, halfpel_h, src, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 11: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src+1, stride, rounding); |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_v, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 12: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src+stride, halfpel_v, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 13: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src+stride, halfpel_h+stride, halfpel_v, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 14: |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_h+stride, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 15: |
|
|
interpolate8x8_lowpass_v(halfpel_v, src+1, stride, rounding); |
|
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src+stride+1, halfpel_h+stride, halfpel_v, halfpel_hv, stride, rounding); |
|
|
break; |
|
|
} |
|
289 |
} |
} |
290 |
|
|
291 |
|
static __inline void |
292 |
static __inline void interpolate16x16_quarterpel(uint8_t * const cur, |
interpolate16x16_add_switch(uint8_t * const cur, |
293 |
uint8_t * const refn, |
const uint8_t * const refn, |
294 |
uint8_t * const refh, |
const uint32_t x, |
295 |
uint8_t * const refv, |
const uint32_t y, |
296 |
uint8_t * const refhv, |
const int32_t dx, |
297 |
const uint32_t x, const uint32_t y, |
const int dy, |
|
const int32_t dx, const int dy, |
|
298 |
const uint32_t stride, |
const uint32_t stride, |
299 |
const uint32_t rounding) |
const uint32_t rounding) |
300 |
{ |
{ |
301 |
const int32_t xRef = x*4 + dx; |
interpolate8x8_add_switch(cur, refn, x, y, dx, dy, stride, rounding); |
302 |
const int32_t yRef = y*4 + dy; |
interpolate8x8_add_switch(cur, refn, x+8, y, dx, dy, stride, rounding); |
303 |
|
interpolate8x8_add_switch(cur, refn, x, y+8, dx, dy, stride, rounding); |
304 |
uint8_t *src, *dst; |
interpolate8x8_add_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding); |
305 |
uint8_t *halfpel_h, *halfpel_v, *halfpel_hv; |
} |
|
int32_t x_int, y_int, x_frac, y_frac; |
|
|
|
|
|
x_int = xRef/4; |
|
|
if (xRef < 0 && xRef % 4) |
|
|
x_int--; |
|
|
|
|
|
x_frac = xRef - (4*x_int); |
|
|
|
|
|
y_int = yRef/4; |
|
|
if (yRef < 0 && yRef % 4) |
|
|
y_int--; |
|
306 |
|
|
307 |
y_frac = yRef - (4*y_int); |
static __inline void |
308 |
|
interpolate32x32_switch(uint8_t * const cur, |
309 |
|
const uint8_t * const refn, |
310 |
|
const uint32_t x, |
311 |
|
const uint32_t y, |
312 |
|
const int32_t dx, |
313 |
|
const int dy, |
314 |
|
const uint32_t stride, |
315 |
|
const uint32_t rounding) |
316 |
|
{ |
317 |
|
interpolate16x16_switch(cur, refn, x, y, dx, dy, stride, rounding); |
318 |
|
interpolate16x16_switch(cur, refn, x+16, y, dx, dy, stride, rounding); |
319 |
|
interpolate16x16_switch(cur, refn, x, y+16, dx, dy, stride, rounding); |
320 |
|
interpolate16x16_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding); |
321 |
|
} |
322 |
|
|
323 |
src = refn + y_int * stride + x_int; |
static __inline void |
324 |
halfpel_h = refh; |
interpolate32x32_add_switch(uint8_t * const cur, |
325 |
halfpel_v = refv; |
const uint8_t * const refn, |
326 |
halfpel_hv = refhv; |
const uint32_t x, |
327 |
|
const uint32_t y, |
328 |
|
const int32_t dx, |
329 |
|
const int dy, |
330 |
|
const uint32_t stride, |
331 |
|
const uint32_t rounding) |
332 |
|
{ |
333 |
|
interpolate16x16_add_switch(cur, refn, x, y, dx, dy, stride, rounding); |
334 |
|
interpolate16x16_add_switch(cur, refn, x+16, y, dx, dy, stride, rounding); |
335 |
|
interpolate16x16_add_switch(cur, refn, x, y+16, dx, dy, stride, rounding); |
336 |
|
interpolate16x16_add_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding); |
337 |
|
} |
338 |
|
|
339 |
dst = cur + y * stride + x; |
static __inline uint8_t * |
340 |
|
interpolate8x8_switch2(uint8_t * const buffer, |
341 |
|
const uint8_t * const refn, |
342 |
|
const int x, |
343 |
|
const int y, |
344 |
|
const int dx, |
345 |
|
const int dy, |
346 |
|
const uint32_t stride, |
347 |
|
const uint32_t rounding) |
348 |
|
{ |
349 |
|
|
350 |
switch((y_frac << 2) | (x_frac)) { |
const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1)); |
351 |
|
|
352 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
353 |
case 0: |
case 0: |
354 |
transfer8x8_copy(dst, src, stride); |
return (uint8_t *)src; |
|
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); |
|
|
break; |
|
|
|
|
355 |
case 1: |
case 1: |
356 |
interpolate16x16_lowpass_h(halfpel_h, src, stride, rounding); |
interpolate8x8_halfpel_v(buffer, src, stride, rounding); |
|
interpolate8x8_avg2(dst, src, halfpel_h, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, src+8, halfpel_h+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, src+8*stride, halfpel_h+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, src+8*stride+8, halfpel_h+8*stride+8, stride, rounding); |
|
357 |
break; |
break; |
|
|
|
358 |
case 2: |
case 2: |
359 |
interpolate16x16_lowpass_h(dst, src, stride, rounding); |
interpolate8x8_halfpel_h(buffer, src, stride, rounding); |
|
break; |
|
|
|
|
|
case 3: |
|
|
interpolate16x16_lowpass_h(halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src + 1, halfpel_h, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, src + 8 + 1, halfpel_h+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, src + 8*stride + 1, halfpel_h+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, src+8*stride+8 + 1, halfpel_h+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 4: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src, halfpel_v, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, src+8, halfpel_v+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, src+8*stride, halfpel_v+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, src+8*stride+8, halfpel_v+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 5: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src, halfpel_h, halfpel_v, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8, src+8, halfpel_h+8, halfpel_v+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride, src+8*stride, halfpel_h+8*stride, halfpel_v+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride+8, src+8*stride+8, halfpel_h+8*stride+8, halfpel_v+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 6: |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_h, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, halfpel_h+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, halfpel_h+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, halfpel_h+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 7: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src+1, stride, rounding); |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src+1, halfpel_h, halfpel_v, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8, src+8+1, halfpel_h+8, halfpel_v+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride, src+1+8*stride, halfpel_h+8*stride, halfpel_v+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride+8, src+1+8*stride+8, halfpel_h+8*stride+8, halfpel_v+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 8: |
|
|
interpolate16x16_lowpass_v(dst, src, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 9: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_v, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, halfpel_v+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, halfpel_v+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, halfpel_v+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 10: |
|
|
interpolate16x16_lowpass_hv(dst, halfpel_h, src, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 11: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src+1, stride, rounding); |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_v, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, halfpel_v+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, halfpel_v+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, halfpel_v+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 12: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, src+stride, halfpel_v, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, src+stride+8, halfpel_v+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, src+stride+8*stride, halfpel_v+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, src+stride+8*stride+8, halfpel_v+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 13: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src, stride, rounding); |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src+stride, halfpel_h+stride, halfpel_v, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8, src+stride+8, halfpel_h+stride+8, halfpel_v+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride, src+stride+8*stride, halfpel_h+stride+8*stride, halfpel_v+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride+8, src+stride+8*stride+8, halfpel_h+stride+8*stride+8, halfpel_v+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 14: |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg2(dst, halfpel_h+stride, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8, halfpel_h+stride+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride, halfpel_h+stride+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg2(dst+8*stride+8, halfpel_h+stride+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
|
break; |
|
|
|
|
|
case 15: |
|
|
interpolate16x16_lowpass_v(halfpel_v, src+1, stride, rounding); |
|
|
interpolate16x16_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
|
|
interpolate8x8_avg4(dst, src+stride+1, halfpel_h+stride, halfpel_v, halfpel_hv, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8, src+stride+1+8, halfpel_h+stride+8, halfpel_v+8, halfpel_hv+8, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride, src+stride+1+8*stride, halfpel_h+stride+8*stride, halfpel_v+8*stride, halfpel_hv+8*stride, stride, rounding); |
|
|
interpolate8x8_avg4(dst+8*stride+8, src+stride+1+8*stride+8, halfpel_h+stride+8*stride+8, halfpel_v+8*stride+8, halfpel_hv+8*stride+8, stride, rounding); |
|
360 |
break; |
break; |
361 |
default: |
default: |
362 |
interpolate8x8_quarterpel(cur, refn, refh, refv, refhv, x, y, dx, dy, stride, rounding); |
interpolate8x8_halfpel_hv(buffer, src, stride, rounding); |
|
interpolate8x8_quarterpel(cur, refn, refh, refv, refhv, x+8, y, dx, dy, stride, rounding); |
|
|
interpolate8x8_quarterpel(cur, refn, refh, refv, refhv, x, y+8, dx, dy, stride, rounding); |
|
|
interpolate8x8_quarterpel(cur, refn, refh, refv, refhv, x+8, y+8, dx, dy, stride, rounding); |
|
|
return; |
|
363 |
break; |
break; |
364 |
} |
} |
365 |
|
return buffer; |
366 |
} |
} |
367 |
|
|
368 |
#endif |
#endif |