[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.9, Tue Feb 11 21:56:31 2003 UTC revision 1.14, Sun Oct 17 10:20:15 2004 UTC
# Line 1  Line 1 
1  /*****************************************************************************  /*****************************************************************************
2   *   *
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - 8x8 block-based halfpel interpolation - headers   *  - Interpolation related header  -
5   *   *
6   *  Copyright(C) 2002 Peter Ross <pross@xvid.org>   *  Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>
7   *   *
8   *  This file is part of XviD, a free MPEG-4 video encoder/decoder   *  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
  *  XviD is free software; you can redistribute it and/or modify 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   *  the Free Software Foundation; either version 2 of the License, or
11   *  (at your option) any later version.   *  (at your option) any later version.
12   *   *
# Line 21  Line 19 
19   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
  *  Under section 8 of the GNU General Public License, the copyright  
  *  holders of XVID explicitly forbid distribution in the following  
  *  countries:  
  *  
  *    - Japan  
  *    - United States of America  
  *  
  *  Linking XviD statically or dynamically with other modules is making a  
  *  combined work based on XviD.  Thus, the terms and conditions of the  
  *  GNU General Public License cover the whole combination.  
  *  
  *  As a special exception, the copyright holders of XviD give you  
  *  permission to link XviD with independent modules that communicate with  
  *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the  
  *  license terms of these independent modules, and to copy and distribute  
  *  the resulting combined work under terms of your choice, provided that  
  *  every copy of the combined work is accompanied by a complete copy of  
  *  the source code of XviD (the version of XviD used to produce the  
  *  combined work), being distributed under the terms of the GNU General  
  *  Public License plus this exception.  An independent module is a module  
  *  which is not derived from or based on XviD.  
  *  
  *  Note that people who make modified versions of XviD are not obligated  
  *  to grant this special exception for their modified versions; it is  
  *  their choice whether to do so.  The GNU General Public License gives  
  *  permission to release a modified version without this exception; this  
  *  exception also makes it possible to release a modified version which  
  *  carries forward this exception.  
  *  
22   * $Id$   * $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 62  Line 34 
34                                                             const uint32_t rounding);                                                             const uint32_t rounding);
35  typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR;  typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR;
36    
37    typedef void (INTERPOLATE8X8_AVG2) (uint8_t *dst,
38                                                                            const uint8_t *src1,
39                                                                            const uint8_t *src2,
40                                                                            const uint32_t stride,
41                                                                            const uint32_t rounding,
42                                                                            const uint32_t height);
43    typedef INTERPOLATE8X8_AVG2 *INTERPOLATE8X8_AVG2_PTR;
44    
45    typedef void (INTERPOLATE8X8_AVG4) (uint8_t *dst,
46                                                                            const uint8_t *src1,
47                                                                            const uint8_t *src2,
48                                                                            const uint8_t *src3,
49                                                                            const uint8_t *src4,
50                                                                            const uint32_t stride,
51                                                                            const uint32_t rounding);
52    typedef INTERPOLATE8X8_AVG4 *INTERPOLATE8X8_AVG4_PTR;
53    
54    typedef void (INTERPOLATE_LOWPASS) (uint8_t *dst,
55                                                                               uint8_t *src,
56                                                                               int32_t stride,
57                                                                               int32_t rounding);
58    
59    typedef INTERPOLATE_LOWPASS *INTERPOLATE_LOWPASS_PTR;
60    
61    typedef void (INTERPOLATE_LOWPASS_HV) (uint8_t *dst1,
62                                                                                      uint8_t *dst2,
63                                                                                      uint8_t *src,
64                                                                                      int32_t stride,
65                                                                                      int32_t rounding);
66    
67    typedef INTERPOLATE_LOWPASS_HV *INTERPOLATE_LOWPASS_HV_PTR;
68    
69    typedef void (INTERPOLATE8X8_6TAP_LOWPASS) (uint8_t *dst,
70                                                                                    uint8_t *src,
71                                                                                    int32_t stride,
72                                                                                    int32_t rounding);
73    
74    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;
93    extern INTERPOLATE8X8_AVG4_PTR interpolate8x8_avg4;
94    
95    extern INTERPOLATE_LOWPASS_PTR interpolate8x8_lowpass_h;
96    extern INTERPOLATE_LOWPASS_PTR interpolate8x8_lowpass_v;
97    
98    extern INTERPOLATE_LOWPASS_PTR interpolate16x16_lowpass_h;
99    extern INTERPOLATE_LOWPASS_PTR interpolate16x16_lowpass_v;
100    
101    extern INTERPOLATE_LOWPASS_HV_PTR interpolate8x8_lowpass_hv;
102    extern INTERPOLATE_LOWPASS_HV_PTR interpolate16x16_lowpass_hv;
103    
104    extern INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_h;
105    extern INTERPOLATE8X8_6TAP_LOWPASS_PTR interpolate8x8_6tap_lowpass_v;
106    
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  void interpolate8x8_c(uint8_t * const dst,  #ifdef ARCH_IS_PPC
150                                            const uint8_t * const src,  INTERPOLATE8X8 interpolate8x8_halfpel_h_altivec_c;
151                                            const uint32_t x,  INTERPOLATE8X8 interpolate8x8_halfpel_v_altivec_c;
152                                            const uint32_t y,  INTERPOLATE8X8 interpolate8x8_halfpel_hv_altivec_c;
153                                            const uint32_t stride);  
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    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c;
161    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c;
162    
163    #ifdef ARCH_IS_IA32
164    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx;
165    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx;
166    #endif
167    
168    #ifdef ARCH_IS_PPC
169    INTERPOLATE8X8_AVG2 interpolate8x8_avg2_altivec_c;
170    INTERPOLATE8X8_AVG4 interpolate8x8_avg4_altivec_c;
171    #endif
172    
173    INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c;
174    INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c;
175    
176    INTERPOLATE_LOWPASS interpolate16x16_lowpass_h_c;
177    INTERPOLATE_LOWPASS interpolate16x16_lowpass_v_c;
178    
179    INTERPOLATE_LOWPASS_HV interpolate8x8_lowpass_hv_c;
180    INTERPOLATE_LOWPASS_HV interpolate16x16_lowpass_hv_c;
181    
182    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c;
183    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c;
184    
185    #ifdef ARCH_IS_IA32
186    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx;
187    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx;
188    #endif
189    
190    #ifdef ARCH_IS_PPC
191    INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_altivec_c;
192    #endif
193    
194  static __inline void  static __inline void
195  interpolate8x8_switch(uint8_t * const cur,  interpolate8x8_switch(uint8_t * const cur,
# Line 102  Line 201 
201                                            const uint32_t stride,                                            const uint32_t stride,
202                                            const uint32_t rounding)                                            const uint32_t rounding)
203  {  {
         int32_t ddx, ddy;  
204    
205          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));
206          {          uint8_t * const dst = cur + (int)(y * stride + x);
207    
208            switch (((dx & 1) << 1) + (dy & 1))     { /* ((dx%2)?2:0)+((dy%2)?1:0) */
209          case 0:          case 0:
210                  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);  
211                  break;                  break;
   
212          case 1:          case 1:
213                  ddx = dx / 2;                  interpolate8x8_halfpel_v(dst, src, stride, rounding);
214                  ddy = (dy - 1) / 2;                  break;
215                  interpolate8x8_halfpel_v(cur + y * stride + x,          case 2:
216                                                                   refn + (int)((y + ddy) * stride + x + ddx), stride,                  interpolate8x8_halfpel_h(dst, src, stride, rounding);
217                                                                   rounding);                  break;
218            default:
219                    interpolate8x8_halfpel_hv(dst, src, stride, rounding);
220                  break;                  break;
221            }
222    }
223    
224    static __inline void
225    interpolate8x8_add_switch(uint8_t * const cur,
226                                              const uint8_t * const refn,
227                                              const uint32_t x,
228                                              const uint32_t y,
229                                              const int32_t dx,
230                                              const int dy,
231                                              const uint32_t stride,
232                                              const uint32_t rounding)
233    {
234    
235            const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1));
236            uint8_t * const dst = cur + (int)(y * stride + x);
237    
238            switch (((dx & 1) << 1) + (dy & 1))     { /* ((dx%2)?2:0)+((dy%2)?1:0) */
239            case 0:
240                    interpolate8x8_halfpel_add(dst, src, stride, rounding);
241                    break;
242            case 1:
243                    interpolate8x8_halfpel_v_add(dst, src, stride, rounding);
244                    break;
245          case 2:          case 2:
246                  ddx = (dx - 1) / 2;                  interpolate8x8_halfpel_h_add(dst, src, stride, rounding);
                 ddy = dy / 2;  
                 interpolate8x8_halfpel_h(cur + y * stride + x,  
                                                                  refn + (int)((y + ddy) * stride + x + ddx), stride,  
                                                                  rounding);  
247                  break;                  break;
248            default:
249                    interpolate8x8_halfpel_hv_add(dst, src, stride, rounding);
250                    break;
251            }
252    }
253    
254    static __inline void
255    interpolate16x16_switch(uint8_t * const cur,
256                                              const uint8_t * const refn,
257                                              const uint32_t x,
258                                              const uint32_t y,
259                                              const int32_t dx,
260                                              const int dy,
261                                              const uint32_t stride,
262                                              const uint32_t rounding)
263    {
264            interpolate8x8_switch(cur, refn, x,   y,   dx, dy, stride, rounding);
265            interpolate8x8_switch(cur, refn, x+8, y,   dx, dy, stride, rounding);
266            interpolate8x8_switch(cur, refn, x,   y+8, dx, dy, stride, rounding);
267            interpolate8x8_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding);
268    }
269    
270    static __inline void
271    interpolate16x16_add_switch(uint8_t * const cur,
272                                              const uint8_t * const refn,
273                                              const uint32_t x,
274                                              const uint32_t y,
275                                              const int32_t dx,
276                                              const int dy,
277                                              const uint32_t stride,
278                                              const uint32_t rounding)
279    {
280            interpolate8x8_add_switch(cur, refn, x,   y,   dx, dy, stride, rounding);
281            interpolate8x8_add_switch(cur, refn, x+8, y,   dx, dy, stride, rounding);
282            interpolate8x8_add_switch(cur, refn, x,   y+8, dx, dy, stride, rounding);
283            interpolate8x8_add_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding);
284    }
285    
286    static __inline void
287    interpolate32x32_switch(uint8_t * const cur,
288                                              const uint8_t * const refn,
289                                              const uint32_t x,
290                                              const uint32_t y,
291                                              const int32_t dx,
292                                              const int dy,
293                                              const uint32_t stride,
294                                              const uint32_t rounding)
295    {
296            interpolate16x16_switch(cur, refn, x,    y,    dx, dy, stride, rounding);
297            interpolate16x16_switch(cur, refn, x+16, y,    dx, dy, stride, rounding);
298            interpolate16x16_switch(cur, refn, x,    y+16, dx, dy, stride, rounding);
299            interpolate16x16_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding);
300    }
301    
302    static __inline void
303    interpolate32x32_add_switch(uint8_t * const cur,
304                                              const uint8_t * const refn,
305                                              const uint32_t x,
306                                              const uint32_t y,
307                                              const int32_t dx,
308                                              const int dy,
309                                              const uint32_t stride,
310                                              const uint32_t rounding)
311    {
312            interpolate16x16_add_switch(cur, refn, x,    y,    dx, dy, stride, rounding);
313            interpolate16x16_add_switch(cur, refn, x+16, y,    dx, dy, stride, rounding);
314            interpolate16x16_add_switch(cur, refn, x,    y+16, dx, dy, stride, rounding);
315            interpolate16x16_add_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding);
316    }
317    
318    static __inline uint8_t *
319    interpolate8x8_switch2(uint8_t * const buffer,
320                                              const uint8_t * const refn,
321                                              const int x,
322                                              const int y,
323                                              const int dx,
324                                              const int dy,
325                                              const uint32_t stride,
326                                              const uint32_t rounding)
327    {
328    
329            const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1));
330    
331            switch (((dx & 1) << 1) + (dy & 1))     { /* ((dx%2)?2:0)+((dy%2)?1:0) */
332            case 0:
333                    return (uint8_t *)src;
334            case 1:
335                    interpolate8x8_halfpel_v(buffer, src, stride, rounding);
336                    break;
337            case 2:
338                    interpolate8x8_halfpel_h(buffer, src, stride, rounding);
339                    break;
340          default:          default:
341                  ddx = (dx - 1) / 2;                  interpolate8x8_halfpel_hv(buffer, src, stride, rounding);
                 ddy = (dy - 1) / 2;  
                 interpolate8x8_halfpel_hv(cur + y * stride + x,  
                                                                  refn + (int)((y + ddy) * stride + x + ddx), stride,  
                                                                   rounding);  
342                  break;                  break;
343          }          }
344            return buffer;
345  }  }
346    
347    #endif

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.14

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