1 |
|
#ifndef _INTERPOLATE8X8_H_ |
2 |
|
#define _INTERPOLATE8X8_H_ |
3 |
|
|
4 |
#include "../utils/mem_transfer.h" |
#include "../utils/mem_transfer.h" |
5 |
|
|
6 |
typedef void (INTERPOLATE8X8) (uint8_t * const dst, |
typedef void (INTERPOLATE8X8) (uint8_t * const dst, |
9 |
const uint32_t rounding); |
const uint32_t rounding); |
10 |
typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR; |
typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR; |
11 |
|
|
12 |
|
typedef void (INTERPOLATE8X8_AVG2) (uint8_t *dst, |
13 |
|
const uint8_t *src1, |
14 |
|
const uint8_t *src2, |
15 |
|
const uint32_t stride, |
16 |
|
const uint32_t rounding); |
17 |
|
typedef INTERPOLATE8X8_AVG2 *INTERPOLATE8X8_AVG2_PTR; |
18 |
|
|
19 |
|
typedef void (INTERPOLATE8X8_AVG4) (uint8_t *dst, |
20 |
|
const uint8_t *src1, |
21 |
|
const uint8_t *src2, |
22 |
|
const uint8_t *src3, |
23 |
|
const uint8_t *src4, |
24 |
|
const uint32_t stride, |
25 |
|
const uint32_t rounding); |
26 |
|
typedef INTERPOLATE8X8_AVG4 *INTERPOLATE8X8_AVG4_PTR; |
27 |
|
|
28 |
|
typedef void (INTERPOLATE8X8_LOWPASS) (uint8_t *dst, |
29 |
|
uint8_t *src, |
30 |
|
int32_t stride, |
31 |
|
int32_t rounding); |
32 |
|
|
33 |
|
typedef INTERPOLATE8X8_LOWPASS *INTERPOLATE8X8_LOWPASS_PTR; |
34 |
|
|
35 |
|
typedef void (INTERPOLATE8X8_LOWPASS_HV) (uint8_t *dst1, |
36 |
|
uint8_t *dst2, |
37 |
|
uint8_t *src, |
38 |
|
int32_t stride, |
39 |
|
int32_t rounding); |
40 |
|
|
41 |
|
typedef INTERPOLATE8X8_LOWPASS_HV *INTERPOLATE8X8_LOWPASS_HV_PTR; |
42 |
|
|
43 |
|
typedef void (INTERPOLATE8X8_6TAP_LOWPASS) (uint8_t *dst, |
44 |
|
uint8_t *src, |
45 |
|
int32_t stride, |
46 |
|
int32_t rounding); |
47 |
|
|
48 |
|
typedef INTERPOLATE8X8_6TAP_LOWPASS *INTERPOLATE8X8_6TAP_LOWPASS_PTR; |
49 |
|
|
50 |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h; |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h; |
51 |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v; |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v; |
52 |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv; |
extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv; |
53 |
|
|
54 |
|
extern INTERPOLATE8X8_AVG2_PTR interpolate8x8_avg2; |
55 |
|
extern INTERPOLATE8X8_AVG4_PTR interpolate8x8_avg4; |
56 |
|
|
57 |
|
extern INTERPOLATE8X8_LOWPASS_PTR interpolate8x8_lowpass_h; |
58 |
|
extern INTERPOLATE8X8_LOWPASS_PTR interpolate8x8_lowpass_v; |
59 |
|
|
60 |
|
extern INTERPOLATE8X8_LOWPASS_HV_PTR interpolate8x8_lowpass_hv; |
61 |
|
|
62 |
|
extern INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_h; |
63 |
|
extern INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_v; |
64 |
|
|
65 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_c; |
66 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
67 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
78 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; |
79 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; |
80 |
|
|
81 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
82 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
83 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
84 |
|
|
85 |
|
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
86 |
|
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
87 |
|
|
88 |
|
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
89 |
|
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
90 |
|
|
91 |
|
INTERPOLATE8X8_LOWPASS interpolate8x8_lowpass_h_c; |
92 |
|
INTERPOLATE8X8_LOWPASS interpolate8x8_lowpass_v_c; |
93 |
|
INTERPOLATE8X8_LOWPASS_HV interpolate8x8_lowpass_hv_c; |
94 |
|
|
95 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
96 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
97 |
|
|
98 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
99 |
|
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
100 |
|
|
101 |
static __inline void |
static __inline void |
102 |
interpolate8x8_switch(uint8_t * const cur, |
interpolate8x8_switch(uint8_t * const cur, |
103 |
const uint8_t * const refn, |
const uint8_t * const refn, |
116 |
ddx = dx / 2; |
ddx = dx / 2; |
117 |
ddy = dy / 2; |
ddy = dy / 2; |
118 |
transfer8x8_copy(cur + y * stride + x, |
transfer8x8_copy(cur + y * stride + x, |
119 |
refn + (y + ddy) * stride + x + ddx, stride); |
refn + (int)((y + ddy) * stride + x + ddx), stride); |
120 |
break; |
break; |
121 |
|
|
122 |
case 1: |
case 1: |
123 |
ddx = dx / 2; |
ddx = dx / 2; |
124 |
ddy = (dy - 1) / 2; |
ddy = (dy - 1) / 2; |
125 |
interpolate8x8_halfpel_v(cur + y * stride + x, |
interpolate8x8_halfpel_v(cur + y * stride + x, |
126 |
refn + (y + ddy) * stride + x + ddx, stride, |
refn + (int)((y + ddy) * stride + x + ddx), stride, |
127 |
rounding); |
rounding); |
128 |
break; |
break; |
129 |
|
|
131 |
ddx = (dx - 1) / 2; |
ddx = (dx - 1) / 2; |
132 |
ddy = dy / 2; |
ddy = dy / 2; |
133 |
interpolate8x8_halfpel_h(cur + y * stride + x, |
interpolate8x8_halfpel_h(cur + y * stride + x, |
134 |
refn + (y + ddy) * stride + x + ddx, stride, |
refn + (int)((y + ddy) * stride + x + ddx), stride, |
135 |
rounding); |
rounding); |
136 |
break; |
break; |
137 |
|
|
139 |
ddx = (dx - 1) / 2; |
ddx = (dx - 1) / 2; |
140 |
ddy = (dy - 1) / 2; |
ddy = (dy - 1) / 2; |
141 |
interpolate8x8_halfpel_hv(cur + y * stride + x, |
interpolate8x8_halfpel_hv(cur + y * stride + x, |
142 |
refn + (y + ddy) * stride + x + ddx, stride, |
refn + (int)((y + ddy) * stride + x + ddx), stride, |
143 |
rounding); |
rounding); |
144 |
break; |
break; |
145 |
} |
} |
146 |
} |
} |
147 |
|
|
148 |
|
static __inline uint8_t * |
149 |
void interpolate8x8_c(uint8_t * const dst, |
interpolate8x8_switch2(uint8_t * const buffer, |
150 |
const uint8_t * const src, |
const uint8_t * const refn, |
151 |
const uint32_t x, |
const uint32_t x, |
152 |
const uint32_t y, |
const uint32_t y, |
153 |
const uint32_t stride); |
const int32_t dx, |
154 |
|
const int dy, |
155 |
|
const uint32_t stride, |
156 |
|
const uint32_t rounding) |
157 |
|
{ |
158 |
|
int32_t ddx, ddy; |
159 |
|
|
160 |
|
switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) |
161 |
|
{ |
162 |
|
case 0: |
163 |
|
return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); |
164 |
|
|
165 |
|
case 1: |
166 |
|
ddx = dx / 2; |
167 |
|
ddy = (dy - 1) / 2; |
168 |
|
interpolate8x8_halfpel_v(buffer, |
169 |
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
170 |
|
rounding); |
171 |
|
break; |
172 |
|
|
173 |
|
case 2: |
174 |
|
ddx = (dx - 1) / 2; |
175 |
|
ddy = dy / 2; |
176 |
|
interpolate8x8_halfpel_h(buffer, |
177 |
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
178 |
|
rounding); |
179 |
|
break; |
180 |
|
|
181 |
|
default: |
182 |
|
ddx = (dx - 1) / 2; |
183 |
|
ddy = (dy - 1) / 2; |
184 |
|
interpolate8x8_halfpel_hv(buffer, |
185 |
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
186 |
|
rounding); |
187 |
|
break; |
188 |
|
} |
189 |
|
return buffer; |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
static __inline void interpolate8x8_quarterpel(uint8_t * const cur, |
194 |
|
uint8_t * const refn, |
195 |
|
uint8_t * const refh, |
196 |
|
uint8_t * const refv, |
197 |
|
uint8_t * const refhv, |
198 |
|
const uint32_t x, const uint32_t y, |
199 |
|
const int32_t dx, const int dy, |
200 |
|
const uint32_t stride, |
201 |
|
const uint32_t rounding) |
202 |
|
{ |
203 |
|
const int32_t xRef = x*4 + dx; |
204 |
|
const int32_t yRef = y*4 + dy; |
205 |
|
|
206 |
|
uint8_t *src, *dst; |
207 |
|
uint8_t *halfpel_h, *halfpel_v, *halfpel_hv; |
208 |
|
int32_t x_int, y_int, x_frac, y_frac; |
209 |
|
|
210 |
|
x_int = xRef/4; |
211 |
|
if (xRef < 0 && xRef % 4) |
212 |
|
x_int--; |
213 |
|
|
214 |
|
x_frac = xRef - (4*x_int); |
215 |
|
|
216 |
|
y_int = yRef/4; |
217 |
|
if (yRef < 0 && yRef % 4) |
218 |
|
y_int--; |
219 |
|
|
220 |
|
y_frac = yRef - (4*y_int); |
221 |
|
|
222 |
|
src = refn + y_int * stride + x_int; |
223 |
|
halfpel_h = refh; |
224 |
|
halfpel_v = refv; |
225 |
|
halfpel_hv = refhv; |
226 |
|
|
227 |
|
dst = cur + y * stride + x; |
228 |
|
|
229 |
|
switch((y_frac << 2) | (x_frac)) { |
230 |
|
|
231 |
|
case 0: |
232 |
|
transfer8x8_copy(dst, src, stride); |
233 |
|
break; |
234 |
|
|
235 |
|
case 1: |
236 |
|
interpolate8x8_lowpass_h(halfpel_h, src, stride, rounding); |
237 |
|
interpolate8x8_avg2(dst, src, halfpel_h, stride, rounding); |
238 |
|
break; |
239 |
|
|
240 |
|
case 2: |
241 |
|
interpolate8x8_lowpass_h(dst, src, stride, rounding); |
242 |
|
break; |
243 |
|
|
244 |
|
case 3: |
245 |
|
interpolate8x8_lowpass_h(halfpel_h, src, stride, rounding); |
246 |
|
interpolate8x8_avg2(dst, src + 1, halfpel_h, stride, rounding); |
247 |
|
break; |
248 |
|
|
249 |
|
case 4: |
250 |
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
251 |
|
interpolate8x8_avg2(dst, src, halfpel_v, stride, rounding); |
252 |
|
break; |
253 |
|
|
254 |
|
case 5: |
255 |
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
256 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
257 |
|
interpolate8x8_avg4(dst, src, halfpel_h, halfpel_v, halfpel_hv, stride, rounding); |
258 |
|
break; |
259 |
|
|
260 |
|
case 6: |
261 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
262 |
|
interpolate8x8_avg2(dst, halfpel_h, halfpel_hv, stride, rounding); |
263 |
|
break; |
264 |
|
|
265 |
|
case 7: |
266 |
|
interpolate8x8_lowpass_v(halfpel_v, src+1, stride, rounding); |
267 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
268 |
|
interpolate8x8_avg4(dst, src+1, halfpel_h, halfpel_v, halfpel_hv, stride, rounding); |
269 |
|
break; |
270 |
|
|
271 |
|
case 8: |
272 |
|
interpolate8x8_lowpass_v(dst, src, stride, rounding); |
273 |
|
break; |
274 |
|
|
275 |
|
case 9: |
276 |
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
277 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
278 |
|
interpolate8x8_avg2(dst, halfpel_v, halfpel_hv, stride, rounding); |
279 |
|
break; |
280 |
|
|
281 |
|
case 10: |
282 |
|
interpolate8x8_lowpass_hv(dst, halfpel_h, src, stride, rounding); |
283 |
|
break; |
284 |
|
|
285 |
|
case 11: |
286 |
|
interpolate8x8_lowpass_v(halfpel_v, src+1, stride, rounding); |
287 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
288 |
|
interpolate8x8_avg2(dst, halfpel_v, halfpel_hv, stride, rounding); |
289 |
|
break; |
290 |
|
|
291 |
|
case 12: |
292 |
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
293 |
|
interpolate8x8_avg2(dst, src+stride, halfpel_v, stride, rounding); |
294 |
|
break; |
295 |
|
|
296 |
|
case 13: |
297 |
|
interpolate8x8_lowpass_v(halfpel_v, src, stride, rounding); |
298 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
299 |
|
interpolate8x8_avg4(dst, src+stride, halfpel_h+stride, halfpel_v, halfpel_hv, stride, rounding); |
300 |
|
break; |
301 |
|
|
302 |
|
case 14: |
303 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
304 |
|
interpolate8x8_avg2(dst, halfpel_h+stride, halfpel_hv, stride, rounding); |
305 |
|
break; |
306 |
|
|
307 |
|
case 15: |
308 |
|
interpolate8x8_lowpass_v(halfpel_v, src+1, stride, rounding); |
309 |
|
interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, stride, rounding); |
310 |
|
interpolate8x8_avg4(dst, src+stride+1, halfpel_h+stride, halfpel_v, halfpel_hv, stride, rounding); |
311 |
|
break; |
312 |
|
} |
313 |
|
} |
314 |
|
|
315 |
|
#endif |