[svn] / trunk / xvidcore / src / image / interpolate8x8.h Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/image/interpolate8x8.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1632 - (view) (download)

1 : edgomez 1382 /*****************************************************************************
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 : suxen_drol 1632 * $Id: interpolate8x8.h,v 1.16 2005-09-13 12:12:15 suxen_drol Exp $
23 : edgomez 1382 *
24 :     ****************************************************************************/
25 :    
26 : edgomez 851 #ifndef _INTERPOLATE8X8_H_
27 :     #define _INTERPOLATE8X8_H_
28 : chl 433
29 : Isibaar 3 #include "../utils/mem_transfer.h"
30 :    
31 : edgomez 195 typedef void (INTERPOLATE8X8) (uint8_t * const dst,
32 :     const uint8_t * const src,
33 :     const uint32_t stride,
34 :     const uint32_t rounding);
35 :     typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR;
36 : Isibaar 3
37 : suxen_drol 1632 typedef void (INTERPOLATE8X4) (uint8_t * const dst,
38 :     const uint8_t * const src,
39 :     const uint32_t stride,
40 :     const uint32_t rounding);
41 :     typedef INTERPOLATE8X4 *INTERPOLATE8X4_PTR;
42 :    
43 : edgomez 851 typedef void (INTERPOLATE8X8_AVG2) (uint8_t *dst,
44 :     const uint8_t *src1,
45 :     const uint8_t *src2,
46 :     const uint32_t stride,
47 :     const uint32_t rounding,
48 :     const uint32_t height);
49 :     typedef INTERPOLATE8X8_AVG2 *INTERPOLATE8X8_AVG2_PTR;
50 :    
51 :     typedef void (INTERPOLATE8X8_AVG4) (uint8_t *dst,
52 :     const uint8_t *src1,
53 :     const uint8_t *src2,
54 :     const uint8_t *src3,
55 :     const uint8_t *src4,
56 :     const uint32_t stride,
57 :     const uint32_t rounding);
58 :     typedef INTERPOLATE8X8_AVG4 *INTERPOLATE8X8_AVG4_PTR;
59 :    
60 :     typedef void (INTERPOLATE_LOWPASS) (uint8_t *dst,
61 :     uint8_t *src,
62 :     int32_t stride,
63 :     int32_t rounding);
64 :    
65 :     typedef INTERPOLATE_LOWPASS *INTERPOLATE_LOWPASS_PTR;
66 :    
67 :     typedef void (INTERPOLATE_LOWPASS_HV) (uint8_t *dst1,
68 :     uint8_t *dst2,
69 :     uint8_t *src,
70 :     int32_t stride,
71 :     int32_t rounding);
72 :    
73 :     typedef INTERPOLATE_LOWPASS_HV *INTERPOLATE_LOWPASS_HV_PTR;
74 :    
75 :     typedef void (INTERPOLATE8X8_6TAP_LOWPASS) (uint8_t *dst,
76 :     uint8_t *src,
77 :     int32_t stride,
78 :     int32_t rounding);
79 :    
80 :     typedef INTERPOLATE8X8_6TAP_LOWPASS *INTERPOLATE8X8_6TAP_LOWPASS_PTR;
81 :    
82 : edgomez 1530 /* These function do: dst = interpolate(src) */
83 : Isibaar 3 extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h;
84 :     extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v;
85 :     extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv;
86 :    
87 : suxen_drol 1632 extern INTERPOLATE8X4_PTR interpolate8x4_halfpel_h;
88 :     extern INTERPOLATE8X4_PTR interpolate8x4_halfpel_v;
89 :     extern INTERPOLATE8X4_PTR interpolate8x4_halfpel_hv;
90 :    
91 : edgomez 1530 /* These functions do: dst = (dst+interpolate(src) + 1)/2
92 :     * Suitable for direct/interpolated bvop prediction block
93 :     * building w/o the need for intermediate interpolated result
94 :     * storing/reading
95 :     * NB: the rounding applies to the interpolation, but not
96 :     * the averaging step which will always use rounding=0 */
97 :     extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_add;
98 :     extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h_add;
99 :     extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v_add;
100 :     extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv_add;
101 :    
102 : edgomez 851 extern INTERPOLATE8X8_AVG2_PTR interpolate8x8_avg2;
103 :     extern INTERPOLATE8X8_AVG4_PTR interpolate8x8_avg4;
104 :    
105 :     extern INTERPOLATE_LOWPASS_PTR interpolate8x8_lowpass_h;
106 :     extern INTERPOLATE_LOWPASS_PTR interpolate8x8_lowpass_v;
107 :    
108 :     extern INTERPOLATE_LOWPASS_PTR interpolate16x16_lowpass_h;
109 :     extern INTERPOLATE_LOWPASS_PTR interpolate16x16_lowpass_v;
110 :    
111 :     extern INTERPOLATE_LOWPASS_HV_PTR interpolate8x8_lowpass_hv;
112 :     extern INTERPOLATE_LOWPASS_HV_PTR interpolate16x16_lowpass_hv;
113 :    
114 :     extern INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_h;
115 :     extern INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_v;
116 :    
117 : Isibaar 3 INTERPOLATE8X8 interpolate8x8_halfpel_h_c;
118 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_c;
119 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_c;
120 : suxen_drol 1632
121 :     INTERPOLATE8X4 interpolate8x4_halfpel_h_c;
122 :     INTERPOLATE8X4 interpolate8x4_halfpel_v_c;
123 :     INTERPOLATE8X4 interpolate8x4_halfpel_hv_c;
124 :    
125 : edgomez 1530 INTERPOLATE8X8 interpolate8x8_halfpel_add_c;
126 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_add_c;
127 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_add_c;
128 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_c;
129 : Isibaar 3
130 : edgomez 1382 #ifdef ARCH_IS_IA32
131 : Isibaar 3 INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx;
132 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx;
133 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx;
134 :    
135 : suxen_drol 1632 INTERPOLATE8X4 interpolate8x4_halfpel_h_mmx;
136 :     INTERPOLATE8X4 interpolate8x4_halfpel_v_mmx;
137 :     INTERPOLATE8X4 interpolate8x4_halfpel_hv_mmx;
138 :    
139 : edgomez 1530 INTERPOLATE8X8 interpolate8x8_halfpel_add_mmx;
140 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_add_mmx;
141 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_add_mmx;
142 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_mmx;
143 :    
144 : Isibaar 3 INTERPOLATE8X8 interpolate8x8_halfpel_h_xmm;
145 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_xmm;
146 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_xmm;
147 :    
148 : suxen_drol 1632 INTERPOLATE8X4 interpolate8x4_halfpel_h_xmm;
149 :     INTERPOLATE8X4 interpolate8x4_halfpel_v_xmm;
150 :     INTERPOLATE8X4 interpolate8x4_halfpel_hv_xmm;
151 :    
152 : edgomez 1530 INTERPOLATE8X8 interpolate8x8_halfpel_add_xmm;
153 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_add_xmm;
154 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_add_xmm;
155 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_xmm;
156 :    
157 : Isibaar 3 INTERPOLATE8X8 interpolate8x8_halfpel_h_3dn;
158 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn;
159 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn;
160 :    
161 : suxen_drol 1632 INTERPOLATE8X4 interpolate8x4_halfpel_h_3dn;
162 :     INTERPOLATE8X4 interpolate8x4_halfpel_v_3dn;
163 :     INTERPOLATE8X4 interpolate8x4_halfpel_hv_3dn;
164 :    
165 : edgomez 851 INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne;
166 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne;
167 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne;
168 : suxen_drol 1632
169 :     INTERPOLATE8X4 interpolate8x4_halfpel_h_3dne;
170 :     INTERPOLATE8X4 interpolate8x4_halfpel_v_3dne;
171 :     INTERPOLATE8X4 interpolate8x4_halfpel_hv_3dne;
172 : edgomez 1382 #endif
173 : edgomez 851
174 : edgomez 1382 #ifdef ARCH_IS_IA64
175 : Isibaar 209 INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64;
176 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64;
177 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64;
178 : edgomez 1382 #endif
179 : Isibaar 209
180 : edgomez 1412 #ifdef ARCH_IS_PPC
181 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_altivec_c;
182 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_altivec_c;
183 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_altivec_c;
184 : edgomez 1557
185 :     INTERPOLATE8X8 interpolate8x8_halfpel_add_altivec_c;
186 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_add_altivec_c;
187 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_add_altivec_c;
188 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_altivec_c;
189 : edgomez 1412 #endif
190 :    
191 : edgomez 1586 #ifdef ARCH_IS_X86_64
192 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_x86_64;
193 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_x86_64;
194 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_x86_64;
195 :    
196 :     INTERPOLATE8X8 interpolate8x8_halfpel_add_x86_64;
197 :     INTERPOLATE8X8 interpolate8x8_halfpel_h_add_x86_64;
198 :     INTERPOLATE8X8 interpolate8x8_halfpel_v_add_x86_64;
199 :     INTERPOLATE8X8 interpolate8x8_halfpel_hv_add_x86_64;
200 :     #endif
201 :    
202 : edgomez 851 INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c;
203 :     INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c;
204 : Isibaar 333
205 : edgomez 1382 #ifdef ARCH_IS_IA32
206 : edgomez 851 INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx;
207 :     INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx;
208 : edgomez 1382 #endif
209 : edgomez 851
210 : edgomez 1412 #ifdef ARCH_IS_PPC
211 :     INTERPOLATE8X8_AVG2 interpolate8x8_avg2_altivec_c;
212 :     INTERPOLATE8X8_AVG4 interpolate8x8_avg4_altivec_c;
213 :     #endif
214 :    
215 : edgomez 1586 #ifdef ARCH_IS_X86_64
216 :     INTERPOLATE8X8_AVG2 interpolate8x8_avg2_x86_64;
217 :     INTERPOLATE8X8_AVG4 interpolate8x8_avg4_x86_64;
218 :     #endif
219 :    
220 : edgomez 851 INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c;
221 :     INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c;
222 :    
223 :     INTERPOLATE_LOWPASS interpolate16x16_lowpass_h_c;
224 :     INTERPOLATE_LOWPASS interpolate16x16_lowpass_v_c;
225 :    
226 :     INTERPOLATE_LOWPASS_HV interpolate8x8_lowpass_hv_c;
227 :     INTERPOLATE_LOWPASS_HV interpolate16x16_lowpass_hv_c;
228 :    
229 :     INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c;
230 :     INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c;
231 :    
232 : edgomez 1382 #ifdef ARCH_IS_IA32
233 : edgomez 851 INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx;
234 :     INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx;
235 : edgomez 1382 #endif
236 : edgomez 851
237 : edgomez 1412 #ifdef ARCH_IS_PPC
238 :     INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_altivec_c;
239 :     #endif
240 :    
241 : edgomez 1586 #ifdef ARCH_IS_X86_64
242 :     INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_x86_64;
243 :     INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_x86_64;
244 :     #endif
245 :    
246 : edgomez 195 static __inline void
247 : suxen_drol 1632 interpolate8x4_switch(uint8_t * const cur,
248 :     const uint8_t * const refn,
249 :     const uint32_t x,
250 :     const uint32_t y,
251 :     const int32_t dx,
252 :     const int dy,
253 :     const uint32_t stride,
254 :     const uint32_t rounding)
255 :     {
256 :    
257 :     const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1));
258 :     uint8_t * const dst = cur + (int)(y * stride + x);
259 :    
260 :     switch (((dx & 1) << 1) + (dy & 1))
261 :     { /* ((dx%2)?2:0)+((dy%2)?1:0) */
262 :     case 0:
263 :     transfer8x4_copy(dst, src, stride);
264 :     break;
265 :     case 1:
266 :     interpolate8x4_halfpel_v(dst, src, stride, rounding);
267 :     break;
268 :     case 2:
269 :     interpolate8x4_halfpel_h(dst, src, stride, rounding);
270 :     break;
271 :     default:
272 :     interpolate8x4_halfpel_hv(dst, src, stride, rounding);
273 :     break;
274 :     }
275 :     }
276 :    
277 :     static __inline void
278 : edgomez 195 interpolate8x8_switch(uint8_t * const cur,
279 :     const uint8_t * const refn,
280 :     const uint32_t x,
281 :     const uint32_t y,
282 :     const int32_t dx,
283 :     const int dy,
284 :     const uint32_t stride,
285 :     const uint32_t rounding)
286 : Isibaar 3 {
287 :    
288 : edgomez 1382 const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1));
289 :     uint8_t * const dst = cur + (int)(y * stride + x);
290 :    
291 :     switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */
292 : edgomez 195 case 0:
293 : edgomez 1382 transfer8x8_copy(dst, src, stride);
294 : Isibaar 3 break;
295 : edgomez 195 case 1:
296 : edgomez 1382 interpolate8x8_halfpel_v(dst, src, stride, rounding);
297 : Isibaar 3 break;
298 : edgomez 195 case 2:
299 : edgomez 1382 interpolate8x8_halfpel_h(dst, src, stride, rounding);
300 : Isibaar 3 break;
301 : edgomez 195 default:
302 : edgomez 1382 interpolate8x8_halfpel_hv(dst, src, stride, rounding);
303 : Isibaar 3 break;
304 : edgomez 195 }
305 : Isibaar 3 }
306 : chenm001 156
307 : edgomez 1530 static __inline void
308 :     interpolate8x8_add_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 : edgomez 851
318 : edgomez 1530 const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1));
319 :     uint8_t * const dst = cur + (int)(y * stride + x);
320 :    
321 :     switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */
322 :     case 0:
323 :     interpolate8x8_halfpel_add(dst, src, stride, rounding);
324 :     break;
325 :     case 1:
326 :     interpolate8x8_halfpel_v_add(dst, src, stride, rounding);
327 :     break;
328 :     case 2:
329 :     interpolate8x8_halfpel_h_add(dst, src, stride, rounding);
330 :     break;
331 :     default:
332 :     interpolate8x8_halfpel_hv_add(dst, src, stride, rounding);
333 :     break;
334 :     }
335 :     }
336 :    
337 : edgomez 851 static __inline void
338 :     interpolate16x16_switch(uint8_t * const cur,
339 :     const uint8_t * const refn,
340 :     const uint32_t x,
341 :     const uint32_t y,
342 :     const int32_t dx,
343 :     const int dy,
344 :     const uint32_t stride,
345 :     const uint32_t rounding)
346 :     {
347 :     interpolate8x8_switch(cur, refn, x, y, dx, dy, stride, rounding);
348 :     interpolate8x8_switch(cur, refn, x+8, y, dx, dy, stride, rounding);
349 :     interpolate8x8_switch(cur, refn, x, y+8, dx, dy, stride, rounding);
350 :     interpolate8x8_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding);
351 :     }
352 :    
353 : edgomez 1530 static __inline void
354 :     interpolate16x16_add_switch(uint8_t * const cur,
355 :     const uint8_t * const refn,
356 :     const uint32_t x,
357 :     const uint32_t y,
358 :     const int32_t dx,
359 :     const int dy,
360 :     const uint32_t stride,
361 :     const uint32_t rounding)
362 :     {
363 :     interpolate8x8_add_switch(cur, refn, x, y, dx, dy, stride, rounding);
364 :     interpolate8x8_add_switch(cur, refn, x+8, y, dx, dy, stride, rounding);
365 :     interpolate8x8_add_switch(cur, refn, x, y+8, dx, dy, stride, rounding);
366 :     interpolate8x8_add_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding);
367 :     }
368 : edgomez 851
369 :     static __inline void
370 :     interpolate32x32_switch(uint8_t * const cur,
371 :     const uint8_t * const refn,
372 :     const uint32_t x,
373 :     const uint32_t y,
374 :     const int32_t dx,
375 :     const int dy,
376 :     const uint32_t stride,
377 :     const uint32_t rounding)
378 :     {
379 :     interpolate16x16_switch(cur, refn, x, y, dx, dy, stride, rounding);
380 :     interpolate16x16_switch(cur, refn, x+16, y, dx, dy, stride, rounding);
381 :     interpolate16x16_switch(cur, refn, x, y+16, dx, dy, stride, rounding);
382 :     interpolate16x16_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding);
383 :     }
384 :    
385 : edgomez 1530 static __inline void
386 :     interpolate32x32_add_switch(uint8_t * const cur,
387 :     const uint8_t * const refn,
388 :     const uint32_t x,
389 :     const uint32_t y,
390 :     const int32_t dx,
391 :     const int dy,
392 :     const uint32_t stride,
393 :     const uint32_t rounding)
394 :     {
395 :     interpolate16x16_add_switch(cur, refn, x, y, dx, dy, stride, rounding);
396 :     interpolate16x16_add_switch(cur, refn, x+16, y, dx, dy, stride, rounding);
397 :     interpolate16x16_add_switch(cur, refn, x, y+16, dx, dy, stride, rounding);
398 :     interpolate16x16_add_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding);
399 :     }
400 : edgomez 851
401 :     static __inline uint8_t *
402 :     interpolate8x8_switch2(uint8_t * const buffer,
403 :     const uint8_t * const refn,
404 : edgomez 1382 const int x,
405 :     const int y,
406 :     const int dx,
407 : edgomez 851 const int dy,
408 :     const uint32_t stride,
409 :     const uint32_t rounding)
410 :     {
411 :    
412 : edgomez 1382 const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1));
413 :    
414 :     switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */
415 : edgomez 851 case 0:
416 : edgomez 1382 return (uint8_t *)src;
417 : edgomez 851 case 1:
418 : edgomez 1382 interpolate8x8_halfpel_v(buffer, src, stride, rounding);
419 : edgomez 851 break;
420 :     case 2:
421 : edgomez 1382 interpolate8x8_halfpel_h(buffer, src, stride, rounding);
422 : edgomez 851 break;
423 :     default:
424 : edgomez 1382 interpolate8x8_halfpel_hv(buffer, src, stride, rounding);
425 : edgomez 851 break;
426 :     }
427 :     return buffer;
428 :     }
429 :    
430 :     #endif

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4