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

Diff of /xvidcore/src/image/interpolate8x8.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4, Fri Jun 14 13:26:32 2002 UTC revision 1.16, Tue Sep 13 12:12:15 2005 UTC
# Line 1  Line 1 
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_
27    #define _INTERPOLATE8X8_H_
28    
29  #include "../utils/mem_transfer.h"  #include "../utils/mem_transfer.h"
30    
31  typedef void (INTERPOLATE8X8) (uint8_t * const dst,  typedef void (INTERPOLATE8X8) (uint8_t * const dst,
# Line 6  Line 34 
34                                                             const uint32_t rounding);                                                             const uint32_t rounding);
35  typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR;  typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR;
36    
37    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    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    /* These function do: dst = interpolate(src) */
83  extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h;  extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h;
84  extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v;  extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v;
85  extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv;  extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv;
86    
87    extern INTERPOLATE8X4_PTR interpolate8x4_halfpel_h;
88    extern INTERPOLATE8X4_PTR interpolate8x4_halfpel_v;
89    extern INTERPOLATE8X4_PTR interpolate8x4_halfpel_hv;
90    
91    /* 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    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  INTERPOLATE8X8 interpolate8x8_halfpel_h_c;  INTERPOLATE8X8 interpolate8x8_halfpel_h_c;
118  INTERPOLATE8X8 interpolate8x8_halfpel_v_c;  INTERPOLATE8X8 interpolate8x8_halfpel_v_c;
119  INTERPOLATE8X8 interpolate8x8_halfpel_hv_c;  INTERPOLATE8X8 interpolate8x8_halfpel_hv_c;
120    
121    INTERPOLATE8X4 interpolate8x4_halfpel_h_c;
122    INTERPOLATE8X4 interpolate8x4_halfpel_v_c;
123    INTERPOLATE8X4 interpolate8x4_halfpel_hv_c;
124    
125    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    
130    #ifdef ARCH_IS_IA32
131  INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx;  INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx;
132  INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx;  INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx;
133  INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx;  INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx;
134    
135    INTERPOLATE8X4 interpolate8x4_halfpel_h_mmx;
136    INTERPOLATE8X4 interpolate8x4_halfpel_v_mmx;
137    INTERPOLATE8X4 interpolate8x4_halfpel_hv_mmx;
138    
139    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  INTERPOLATE8X8 interpolate8x8_halfpel_h_xmm;  INTERPOLATE8X8 interpolate8x8_halfpel_h_xmm;
145  INTERPOLATE8X8 interpolate8x8_halfpel_v_xmm;  INTERPOLATE8X8 interpolate8x8_halfpel_v_xmm;
146  INTERPOLATE8X8 interpolate8x8_halfpel_hv_xmm;  INTERPOLATE8X8 interpolate8x8_halfpel_hv_xmm;
147    
148    INTERPOLATE8X4 interpolate8x4_halfpel_h_xmm;
149    INTERPOLATE8X4 interpolate8x4_halfpel_v_xmm;
150    INTERPOLATE8X4 interpolate8x4_halfpel_hv_xmm;
151    
152    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  INTERPOLATE8X8 interpolate8x8_halfpel_h_3dn;  INTERPOLATE8X8 interpolate8x8_halfpel_h_3dn;
158  INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn;  INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn;
159  INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn;  INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn;
160    
161    INTERPOLATE8X4 interpolate8x4_halfpel_h_3dn;
162    INTERPOLATE8X4 interpolate8x4_halfpel_v_3dn;
163    INTERPOLATE8X4 interpolate8x4_halfpel_hv_3dn;
164    
165    INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne;
166    INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne;
167    INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne;
168    
169    INTERPOLATE8X4 interpolate8x4_halfpel_h_3dne;
170    INTERPOLATE8X4 interpolate8x4_halfpel_v_3dne;
171    INTERPOLATE8X4 interpolate8x4_halfpel_hv_3dne;
172    #endif
173    
174    #ifdef ARCH_IS_IA64
175  INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64;  INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64;
176  INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64;  INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64;
177  INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64;  INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64;
178    #endif
179    
180    #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    
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    #endif
190    
191    #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    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c;
203    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c;
204    
205    #ifdef ARCH_IS_IA32
206    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx;
207    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx;
208    #endif
209    
210    #ifdef ARCH_IS_PPC
211    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_altivec_c;
212    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_altivec_c;
213    #endif
214    
215    #ifdef ARCH_IS_X86_64
216    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_x86_64;
217    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_x86_64;
218    #endif
219    
220    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    #ifdef ARCH_IS_IA32
233    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx;
234    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx;
235    #endif
236    
237    #ifdef ARCH_IS_PPC
238    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_altivec_c;
239    #endif
240    
241    #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  static __inline void  static __inline void
247  interpolate8x8_switch(uint8_t * const cur,  interpolate8x4_switch(uint8_t * const cur,
248                                            const uint8_t * const refn,                                            const uint8_t * const refn,
249                                            const uint32_t x,                                            const uint32_t x,
250                                            const uint32_t y,                                            const uint32_t y,
# Line 40  Line 253 
253                                            const uint32_t stride,                                            const uint32_t stride,
254                                            const uint32_t rounding)                                            const uint32_t rounding)
255  {  {
         int32_t ddx, ddy;  
256    
257          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));
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:          case 0:
263                  ddx = dx / 2;                  transfer8x4_copy(dst, src, stride);
                 ddy = dy / 2;  
                 transfer8x8_copy(cur + y * stride + x,  
                                                  refn + (int)((y + ddy) * stride + x + ddx), stride);  
264                  break;                  break;
   
265          case 1:          case 1:
266                  ddx = dx / 2;                  interpolate8x4_halfpel_v(dst, src, stride, rounding);
267                  ddy = (dy - 1) / 2;                  break;
268                  interpolate8x8_halfpel_v(cur + y * stride + x,          case 2:
269                                                                   refn + (int)((y + ddy) * stride + x + ddx), stride,                  interpolate8x4_halfpel_h(dst, src, stride, rounding);
270                                                                   rounding);                  break;
271            default:
272                    interpolate8x4_halfpel_hv(dst, src, stride, rounding);
273                  break;                  break;
274            }
275    }
276    
277    static __inline void
278    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    {
287    
288            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            case 0:
293                    transfer8x8_copy(dst, src, stride);
294                    break;
295            case 1:
296                    interpolate8x8_halfpel_v(dst, src, stride, rounding);
297                    break;
298          case 2:          case 2:
299                  ddx = (dx - 1) / 2;                  interpolate8x8_halfpel_h(dst, src, stride, rounding);
300                  ddy = dy / 2;                  break;
301                  interpolate8x8_halfpel_h(cur + y * stride + x,          default:
302                                                                   refn + (int)((y + ddy) * stride + x + ddx), stride,                  interpolate8x8_halfpel_hv(dst, src, stride, rounding);
                                                                  rounding);  
303                  break;                  break;
304            }
305    }
306    
307    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    
318            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:          default:
332                  ddx = (dx - 1) / 2;                  interpolate8x8_halfpel_hv_add(dst, src, stride, rounding);
                 ddy = (dy - 1) / 2;  
                 interpolate8x8_halfpel_hv(cur + y * stride + x,  
                                                                  refn + (int)((y + ddy) * stride + x + ddx), stride,  
                                                                   rounding);  
333                  break;                  break;
334          }          }
335  }  }
336    
337    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  void interpolate8x8_c(uint8_t * const dst,  static __inline void
354                                            const uint8_t * const src,  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    
369    static __inline void
370    interpolate32x32_switch(uint8_t * const cur,
371                                              const uint8_t * const refn,
372                                            const uint32_t x,                                            const uint32_t x,
373                                            const uint32_t y,                                            const uint32_t y,
374                                            const uint32_t stride);                                            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    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    
401    static __inline uint8_t *
402    interpolate8x8_switch2(uint8_t * const buffer,
403                                              const uint8_t * const refn,
404                                              const int x,
405                                              const int y,
406                                              const int dx,
407                                              const int dy,
408                                              const uint32_t stride,
409                                              const uint32_t rounding)
410    {
411    
412            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            case 0:
416                    return (uint8_t *)src;
417            case 1:
418                    interpolate8x8_halfpel_v(buffer, src, stride, rounding);
419                    break;
420            case 2:
421                    interpolate8x8_halfpel_h(buffer, src, stride, rounding);
422                    break;
423            default:
424                    interpolate8x8_halfpel_hv(buffer, src, stride, rounding);
425                    break;
426            }
427            return buffer;
428    }
429    
430    #endif

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.16

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