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_ |
#ifndef _INTERPOLATE8X8_H_ |
27 |
#define _INTERPOLATE8X8_H_ |
#define _INTERPOLATE8X8_H_ |
28 |
|
|
96 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_c; |
97 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_c; |
98 |
|
|
99 |
|
#ifdef ARCH_IS_IA32 |
100 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_mmx; |
101 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_mmx; |
102 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_mmx; |
109 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dn; |
110 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dn; |
111 |
|
|
112 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_h_3dne; |
113 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_v_3dne; |
114 |
|
INTERPOLATE8X8 interpolate8x8_halfpel_hv_3dne; |
115 |
|
#endif |
116 |
|
|
117 |
|
#ifdef ARCH_IS_IA64 |
118 |
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_h_ia64; |
119 |
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_v_ia64; |
120 |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
INTERPOLATE8X8 interpolate8x8_halfpel_hv_ia64; |
121 |
|
#endif |
122 |
|
|
123 |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_c; |
124 |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_c; |
125 |
|
|
126 |
|
#ifdef ARCH_IS_IA32 |
127 |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
INTERPOLATE8X8_AVG2 interpolate8x8_avg2_mmx; |
128 |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
INTERPOLATE8X8_AVG4 interpolate8x8_avg4_mmx; |
129 |
|
#endif |
130 |
|
|
131 |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c; |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_h_c; |
132 |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c; |
INTERPOLATE_LOWPASS interpolate8x8_lowpass_v_c; |
140 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_c; |
141 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_c; |
142 |
|
|
143 |
|
#ifdef ARCH_IS_IA32 |
144 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_h_mmx; |
145 |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
INTERPOLATE8X8_6TAP_LOWPASS interpolate8x8_6tap_lowpass_v_mmx; |
146 |
|
#endif |
147 |
|
|
148 |
static __inline void |
static __inline void |
149 |
interpolate8x8_switch(uint8_t * const cur, |
interpolate8x8_switch(uint8_t * const cur, |
155 |
const uint32_t stride, |
const uint32_t stride, |
156 |
const uint32_t rounding) |
const uint32_t rounding) |
157 |
{ |
{ |
|
int32_t ddx, ddy; |
|
158 |
|
|
159 |
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)); |
160 |
{ |
uint8_t * const dst = cur + (int)(y * stride + x); |
161 |
|
|
162 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
163 |
case 0: |
case 0: |
164 |
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); |
|
165 |
break; |
break; |
|
|
|
166 |
case 1: |
case 1: |
167 |
ddx = dx / 2; |
interpolate8x8_halfpel_v(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
168 |
break; |
break; |
|
|
|
169 |
case 2: |
case 2: |
170 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h(dst, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
171 |
break; |
break; |
|
|
|
172 |
default: |
default: |
173 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
174 |
break; |
break; |
175 |
} |
} |
176 |
} |
} |
177 |
|
|
178 |
static __inline uint8_t * |
|
179 |
interpolate8x8_switch2(uint8_t * const buffer, |
static __inline void |
180 |
|
interpolate16x16_switch(uint8_t * const cur, |
181 |
const uint8_t * const refn, |
const uint8_t * const refn, |
182 |
const uint32_t x, |
const uint32_t x, |
183 |
const uint32_t y, |
const uint32_t y, |
186 |
const uint32_t stride, |
const uint32_t stride, |
187 |
const uint32_t rounding) |
const uint32_t rounding) |
188 |
{ |
{ |
189 |
int32_t ddx, ddy; |
interpolate8x8_switch(cur, refn, x, y, dx, dy, stride, rounding); |
190 |
|
interpolate8x8_switch(cur, refn, x+8, y, dx, dy, stride, rounding); |
191 |
|
interpolate8x8_switch(cur, refn, x, y+8, dx, dy, stride, rounding); |
192 |
|
interpolate8x8_switch(cur, refn, x+8, y+8, dx, dy, stride, rounding); |
193 |
|
} |
194 |
|
|
195 |
switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) |
|
196 |
|
static __inline void |
197 |
|
interpolate32x32_switch(uint8_t * const cur, |
198 |
|
const uint8_t * const refn, |
199 |
|
const uint32_t x, |
200 |
|
const uint32_t y, |
201 |
|
const int32_t dx, |
202 |
|
const int dy, |
203 |
|
const uint32_t stride, |
204 |
|
const uint32_t rounding) |
205 |
{ |
{ |
206 |
case 0: |
interpolate16x16_switch(cur, refn, x, y, dx, dy, stride, rounding); |
207 |
return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); |
interpolate16x16_switch(cur, refn, x+16, y, dx, dy, stride, rounding); |
208 |
|
interpolate16x16_switch(cur, refn, x, y+16, dx, dy, stride, rounding); |
209 |
|
interpolate16x16_switch(cur, refn, x+16, y+16, dx, dy, stride, rounding); |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
|
static __inline uint8_t * |
214 |
|
interpolate8x8_switch2(uint8_t * const buffer, |
215 |
|
const uint8_t * const refn, |
216 |
|
const int x, |
217 |
|
const int y, |
218 |
|
const int dx, |
219 |
|
const int dy, |
220 |
|
const uint32_t stride, |
221 |
|
const uint32_t rounding) |
222 |
|
{ |
223 |
|
|
224 |
|
const uint8_t * const src = refn + (int)((y + (dy>>1)) * stride + x + (dx>>1)); |
225 |
|
|
226 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
227 |
|
case 0: |
228 |
|
return (uint8_t *)src; |
229 |
case 1: |
case 1: |
230 |
ddx = dx / 2; |
interpolate8x8_halfpel_v(buffer, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
231 |
break; |
break; |
|
|
|
232 |
case 2: |
case 2: |
233 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h(buffer, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
234 |
break; |
break; |
|
|
|
235 |
default: |
default: |
236 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv(buffer, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
237 |
break; |
break; |
238 |
} |
} |
239 |
return buffer; |
return buffer; |
404 |
switch((y_frac << 2) | (x_frac)) { |
switch((y_frac << 2) | (x_frac)) { |
405 |
|
|
406 |
case 0: |
case 0: |
407 |
transfer8x8_copy(dst, src, stride); |
transfer16x16_copy(dst, src, stride); |
|
transfer8x8_copy(dst+8, src+8, stride); |
|
|
transfer8x8_copy(dst+8*stride, src+8*stride, stride); |
|
|
transfer8x8_copy(dst+8*stride+8, src+8*stride+8, stride); |
|
408 |
break; |
break; |
409 |
|
|
410 |
case 1: |
case 1: |
542 |
break; |
break; |
543 |
} |
} |
544 |
} |
} |
545 |
|
|
546 |
#endif |
#endif |