[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.1, Fri Mar 8 02:44:46 2002 UTC revision 1.6, Fri Sep 6 17:37:07 2002 UTC
# Line 1  Line 1 
1    /*****************************************************************************
2     *
3     *  XVID MPEG-4 VIDEO CODEC
4     *  - 8x8 block-based halfpel interpolation - headers
5     *
6     *  Copyright(C) 2002 Peter Ross <pross@xvid.org>
7     *
8     *  This program is an implementation of a part of one or more MPEG-4
9     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10     *  to use this software module in hardware or software products are
11     *  advised that its use may infringe existing patents or copyrights, and
12     *  any such use would be at such party's own risk.  The original
13     *  developer of this software module and his/her company, and subsequent
14     *  editors and their companies, will have no liability for use of this
15     *  software or modifications or derivatives thereof.
16     *
17     *  This program is free software; you can redistribute it and/or modify
18     *  it under the terms of the GNU General Public License as published by
19     *  the Free Software Foundation; either version 2 of the License, or
20     *  (at your option) any later version.
21     *
22     *  This program is distributed in the hope that it will be useful,
23     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25     *  GNU General Public License for more details.
26     *
27     *  You should have received a copy of the GNU General Public License
28     *  along with this program; if not, write to the Free Software
29     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
30     *
31     ****************************************************************************/
32    
33  #include "../utils/mem_transfer.h"  #include "../utils/mem_transfer.h"
34    
35  typedef void (INTERPOLATE8X8)(uint8_t * const dst,  typedef void (INTERPOLATE8X8)(uint8_t * const dst,
# Line 26  Line 58 
58  INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn;  INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn;
59  INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn;  INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn;
60    
61  static __inline void interpolate8x8_switch(uint8_t * const cur,  INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64;
62    INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64;
63    INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64;
64    
65    void interpolate8x8_lowpass_h(uint8_t *dst, uint8_t *src, int32_t dst_stride, int32_t src_stride, int32_t rounding);
66    void interpolate8x8_lowpass_v(uint8_t *dst, uint8_t *src, int32_t dst_stride, int32_t src_stride, int32_t rounding);
67    void interpolate8x8_lowpass_hv(uint8_t *dst1, uint8_t *dst2, uint8_t *src, int32_t dst1_stride, int32_t dst2_stride, int32_t src_stride, int32_t rounding);
68    void interpolate8x8_bilinear2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int32_t dst_stride, int32_t src_stride, int32_t rounding);
69    void interpolate8x8_bilinear4(uint8_t *dst, uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4, int32_t stride, int32_t rounding);
70    
71    void interpolate8x8_c(uint8_t * const dst,
72                                              const uint8_t * const src,
73                                              const uint32_t x,
74                                              const uint32_t y,
75                                              const uint32_t stride);
76    
77    static __inline void
78    interpolate8x8_switch(uint8_t * const cur,
79                                       const uint8_t * const refn,                                       const uint8_t * const refn,
80                                       const uint32_t x, const uint32_t y,                                            const uint32_t x,
81                                           const int32_t dx,  const int dy,                                            const uint32_t y,
82                                              const int32_t dx,
83                                              const int dy,
84                                           const uint32_t stride,                                           const uint32_t stride,
85                                           const uint32_t rounding)                                           const uint32_t rounding)
86  {  {
# Line 40  Line 91 
91      case 0 :      case 0 :
92                  ddx = dx/2;                  ddx = dx/2;
93                  ddy = dy/2;                  ddy = dy/2;
94                  transfer8x8_copy(cur + y*stride + x, refn + (y+ddy)*stride + x + ddx, stride);                  transfer8x8_copy(cur + y * stride + x,
95                                                     refn + (int)((y + ddy) * stride + x + ddx), stride);
96                  break;                  break;
97    
98      case 1 :      case 1 :
99                  ddx = dx/2;                  ddx = dx/2;
100                  ddy = (dy-1)/2;                  ddy = (dy-1)/2;
101                  interpolate8x8_halfpel_v(cur + y*stride + x,                  interpolate8x8_halfpel_v(cur + y*stride + x,
102                                                          refn + (y+ddy)*stride + x + ddx, stride, rounding);                                                                   refn + (int)((y + ddy) * stride + x + ddx), stride,
103                                                                     rounding);
104                  break;                  break;
105    
106      case 2 :      case 2 :
107                  ddx = (dx-1)/2;                  ddx = (dx-1)/2;
108                  ddy = dy/2;                  ddy = dy/2;
109                  interpolate8x8_halfpel_h(cur + y*stride + x,                  interpolate8x8_halfpel_h(cur + y*stride + x,
110                                                          refn + (y+ddy)*stride + x + ddx, stride, rounding);                                                                   refn + (int)((y + ddy) * stride + x + ddx), stride,
111                                                                     rounding);
112                  break;                  break;
113    
114      default :      default :
115                  ddx = (dx-1)/2;                  ddx = (dx-1)/2;
116                  ddy = (dy-1)/2;                  ddy = (dy-1)/2;
117                  interpolate8x8_halfpel_hv(cur + y*stride + x,                  interpolate8x8_halfpel_hv(cur + y*stride + x,
118                                                          refn + (y+ddy)*stride + x + ddx, stride, rounding);                                                                   refn + (int)((y + ddy) * stride + x + ddx), stride,
119                                                                      rounding);
120                    break;
121            }
122    }
123    
124    
125    static __inline void interpolate8x8_quarterpel(uint8_t * const cur,
126                                         uint8_t * const refn,
127                                         const uint32_t x, const uint32_t y,
128                                             const int32_t dx,  const int dy,
129                                             const uint32_t stride,
130                                             const uint32_t rounding)
131    {
132            const int32_t xRef = x*4 + dx;
133            const int32_t yRef = y*4 + dy;
134    
135            uint8_t *src, *dst;
136            int32_t x_int, y_int, x_frac, y_frac;
137    
138            uint8_t halfpel_h[72];
139            uint8_t halfpel_v[64];
140            uint8_t halfpel_hv[64];
141    
142            x_int = xRef/4;
143            if (xRef < 0 && xRef % 4)
144                    x_int--;
145    
146            x_frac = xRef - (4*x_int);
147    
148            y_int  = yRef/4;
149            if (yRef < 0 && yRef % 4)
150                    y_int--;
151    
152            y_frac = yRef - (4*y_int);
153    
154            src = refn + y_int * stride + x_int;
155            dst = cur + y * stride + x;
156    
157            switch((y_frac << 2) | (x_frac)) {
158    
159            case 0:
160                    transfer8x8_copy(dst, src, stride);
161                    break;
162    
163            case 1:
164                    interpolate8x8_lowpass_h(halfpel_h, src, 8, stride, rounding);
165                    interpolate8x8_bilinear2(dst, src, halfpel_h, stride, stride, rounding);
166                    break;
167    
168            case 2:
169                interpolate8x8_lowpass_h(dst, src, stride, stride, rounding);
170                    break;
171    
172            case 3:
173                    interpolate8x8_lowpass_h(halfpel_h, src, 8, stride, rounding);
174                    interpolate8x8_bilinear2(dst, src+1, halfpel_h, stride, stride, rounding);
175                    break;
176    
177            case 4:
178                    interpolate8x8_lowpass_v(halfpel_v, src, 8, stride, rounding);
179                    interpolate8x8_bilinear2(dst, src, halfpel_v, stride, stride, rounding);
180                    break;
181    
182            case 5:
183                    interpolate8x8_lowpass_v(halfpel_v, src, 8, stride, rounding);
184                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
185                    interpolate8x8_bilinear4(dst, src, halfpel_h, halfpel_v, halfpel_hv, stride, rounding);
186                    break;
187    
188            case 6:
189                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
190                    interpolate8x8_bilinear2(dst, halfpel_h, halfpel_hv, stride, 8, 1-rounding);
191                    break;
192    
193            case 7:
194                    interpolate8x8_lowpass_v(halfpel_v, src+1, 8, stride, 16-rounding);
195                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
196                    interpolate8x8_bilinear4(dst, src+1, halfpel_h, halfpel_v, halfpel_hv, stride, rounding);
197                    break;
198    
199            case 8:
200                interpolate8x8_lowpass_v(dst, src, stride, stride, rounding);
201                    break;
202    
203            case 9:
204                    interpolate8x8_lowpass_v(halfpel_v, src, 8, stride, 16-rounding);
205                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
206                    interpolate8x8_bilinear2(dst, halfpel_v, halfpel_hv, stride, 8, rounding);
207                    break;
208    
209            case 10:
210                    interpolate8x8_lowpass_hv(dst, halfpel_h, src, stride, 8, stride, rounding);
211                    break;
212    
213            case 11:
214                    interpolate8x8_lowpass_v(halfpel_v, src+1, 8, stride, 16-rounding);
215                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
216                    interpolate8x8_bilinear2(dst, halfpel_v, halfpel_hv, stride, 8, rounding);
217                    break;
218    
219            case 12:
220                    interpolate8x8_lowpass_v(halfpel_v, src, 8, stride, rounding);
221                    interpolate8x8_bilinear2(dst, src+stride, halfpel_v, stride, stride, rounding);
222                    break;
223    
224            case 13:
225                    interpolate8x8_lowpass_v(halfpel_v, src, 8, stride, rounding);
226                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
227                    interpolate8x8_bilinear4(dst, src+stride, halfpel_h+8, halfpel_v, halfpel_hv, stride, rounding);
228                    break;
229    
230            case 14:
231                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
232                    interpolate8x8_bilinear2(dst, halfpel_h+8, halfpel_hv, stride, 8, rounding);
233                    break;
234    
235            case 15:
236                    interpolate8x8_lowpass_v(halfpel_v, src+1, 8, stride, rounding);
237                    interpolate8x8_lowpass_hv(halfpel_hv, halfpel_h, src, 8, 8, stride, rounding);
238                    interpolate8x8_bilinear4(dst, src+stride+1, halfpel_h+8, halfpel_v, halfpel_hv, stride, rounding);
239                  break;                  break;
240      }      }
241  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

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