ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvs/xvidcore/src/image/interpolate8x8.h
Revision: 1.6
Committed: Fri Sep 6 17:37:07 2002 UTC (22 years, 1 month ago) by chl
Content type: text/plain
Branch: MAIN
Changes since 1.5: +33 -1 lines
Log Message:
- Update license/copyright header
- Removed history header

File Contents

# Content
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"
34
35 typedef void (INTERPOLATE8X8) (uint8_t * const dst,
36 const uint8_t * const src,
37 const uint32_t stride,
38 const uint32_t rounding);
39 typedef INTERPOLATE8X8 *INTERPOLATE8X8_PTR;
40
41 extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_h;
42 extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_v;
43 extern INTERPOLATE8X8_PTR interpolate8x8_halfpel_hv;
44
45 INTERPOLATE8X8 interpolate8x8_halfpel_h_c;
46 INTERPOLATE8X8 interpolate8x8_halfpel_v_c;
47 INTERPOLATE8X8 interpolate8x8_halfpel_hv_c;
48
49 INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx;
50 INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx;
51 INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx;
52
53 INTERPOLATE8X8 interpolate8x8_halfpel_h_xmm;
54 INTERPOLATE8X8 interpolate8x8_halfpel_v_xmm;
55 INTERPOLATE8X8 interpolate8x8_halfpel_hv_xmm;
56
57 INTERPOLATE8X8 interpolate8x8_halfpel_h_3dn;
58 INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn;
59 INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn;
60
61 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,
80 const uint32_t x,
81 const uint32_t y,
82 const int32_t dx,
83 const int dy,
84 const uint32_t stride,
85 const uint32_t rounding)
86 {
87 int32_t ddx, ddy;
88
89 switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0)
90 {
91 case 0:
92 ddx = dx / 2;
93 ddy = dy / 2;
94 transfer8x8_copy(cur + y * stride + x,
95 refn + (int)((y + ddy) * stride + x + ddx), stride);
96 break;
97
98 case 1:
99 ddx = dx / 2;
100 ddy = (dy - 1) / 2;
101 interpolate8x8_halfpel_v(cur + y * stride + x,
102 refn + (int)((y + ddy) * stride + x + ddx), stride,
103 rounding);
104 break;
105
106 case 2:
107 ddx = (dx - 1) / 2;
108 ddy = dy / 2;
109 interpolate8x8_halfpel_h(cur + y * stride + x,
110 refn + (int)((y + ddy) * stride + x + ddx), stride,
111 rounding);
112 break;
113
114 default:
115 ddx = (dx - 1) / 2;
116 ddy = (dy - 1) / 2;
117 interpolate8x8_halfpel_hv(cur + y * stride + x,
118 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;
240 }
241 }