1 /*****************************************************************************
2 *
3 * XVID MPEG-4 VIDEO CODEC
4 * - 8<->16 bit buffer transfer 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: mem_transfer.h 1985 2011-05-18 09:02:35Z Isibaar $
23 *
24 ****************************************************************************/
25
26 #ifndef _MEM_TRANSFER_H
27 #define _MEM_TRANSFER_H
28
29 /*****************************************************************************
30 * transfer8to16 API
31 ****************************************************************************/
32
33 typedef void (TRANSFER_8TO16COPY) (int16_t * const dst,
34 const uint8_t * const src,
35 uint32_t stride);
36
37 typedef TRANSFER_8TO16COPY *TRANSFER_8TO16COPY_PTR;
38
39 /* Our global function pointer - Initialized in xvid.c */
40 extern TRANSFER_8TO16COPY_PTR transfer_8to16copy;
41
42 /* Implemented functions */
43 extern TRANSFER_8TO16COPY transfer_8to16copy_c;
44
45 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
46 extern TRANSFER_8TO16COPY transfer_8to16copy_mmx;
47 extern TRANSFER_8TO16COPY transfer_8to16copy_3dne;
48 #endif
49
50 #ifdef ARCH_IS_IA64
51 extern TRANSFER_8TO16COPY transfer_8to16copy_ia64;
52 #endif
53
54 #ifdef ARCH_IS_PPC
55 extern TRANSFER_8TO16COPY transfer_8to16copy_altivec_c;
56 #endif
57
58 /*****************************************************************************
59 * transfer16to8 API
60 ****************************************************************************/
61
62 typedef void (TRANSFER_16TO8COPY) (uint8_t * const dst,
63 const int16_t * const src,
64 uint32_t stride);
65 typedef TRANSFER_16TO8COPY *TRANSFER_16TO8COPY_PTR;
66
67 /* Our global function pointer - Initialized in xvid.c */
68 extern TRANSFER_16TO8COPY_PTR transfer_16to8copy;
69
70 /* Implemented functions */
71 extern TRANSFER_16TO8COPY transfer_16to8copy_c;
72
73 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
74 extern TRANSFER_16TO8COPY transfer_16to8copy_mmx;
75 extern TRANSFER_16TO8COPY transfer_16to8copy_3dne;
76 #endif
77
78 #ifdef ARCH_IS_IA64
79 extern TRANSFER_16TO8COPY transfer_16to8copy_ia64;
80 #endif
81
82 #ifdef ARCH_IS_PPC
83 extern TRANSFER_16TO8COPY transfer_16to8copy_altivec_c;
84 #endif
85
86 #ifdef ARCH_IS_X86_64
87 extern TRANSFER_16TO8COPY transfer_16to8copy_x86_64;
88 #endif
89
90 /*****************************************************************************
91 * transfer8to16 + substraction *writeback* op API
92 ****************************************************************************/
93
94 typedef void (TRANSFER_8TO16SUB) (int16_t * const dct,
95 uint8_t * const cur,
96 const uint8_t * ref,
97 const uint32_t stride);
98
99 typedef TRANSFER_8TO16SUB *TRANSFER_8TO16SUB_PTR;
100
101 /* Our global function pointer - Initialized in xvid.c */
102 extern TRANSFER_8TO16SUB_PTR transfer_8to16sub;
103
104 /* Implemented functions */
105 extern TRANSFER_8TO16SUB transfer_8to16sub_c;
106
107 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
108 extern TRANSFER_8TO16SUB transfer_8to16sub_mmx;
109 extern TRANSFER_8TO16SUB transfer_8to16sub_3dne;
110 #endif
111
112 #ifdef ARCH_IS_IA64
113 extern TRANSFER_8TO16SUB transfer_8to16sub_ia64;
114 #endif
115
116 #ifdef ARCH_IS_PPC
117 extern TRANSFER_8TO16SUB transfer_8to16sub_altivec_c;
118 #endif
119
120 #ifdef ARCH_IS_X86_64
121 extern TRANSFER_8TO16SUB transfer_8to16sub_x86_64;
122 #endif
123
124 /*****************************************************************************
125 * transfer8to16 + substraction *readonly* op API
126 ****************************************************************************/
127
128 typedef void (TRANSFER_8TO16SUBRO) (int16_t * const dct,
129 const uint8_t * const cur,
130 const uint8_t * ref,
131 const uint32_t stride);
132
133 typedef TRANSFER_8TO16SUBRO *TRANSFER_8TO16SUBRO_PTR;
134
135 /* Our global function pointer - Initialized in xvid.c */
136 extern TRANSFER_8TO16SUBRO_PTR transfer_8to16subro;
137
138 /* Implemented functions */
139 extern TRANSFER_8TO16SUBRO transfer_8to16subro_c;
140
141 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
142 extern TRANSFER_8TO16SUBRO transfer_8to16subro_mmx;
143 extern TRANSFER_8TO16SUBRO transfer_8to16subro_3dne;
144 #endif
145
146 #ifdef ARCH_IS_PPC
147 extern TRANSFER_8TO16SUBRO transfer_8to16subro_altivec_c;
148 #endif
149
150 #ifdef ARCH_IS_X86_64
151 extern TRANSFER_8TO16SUBRO transfer_8to16subro_x86_64;
152 #endif
153
154 /*****************************************************************************
155 * transfer8to16 + substraction op API - Bidirectionnal Version
156 ****************************************************************************/
157
158 typedef void (TRANSFER_8TO16SUB2) (int16_t * const dct,
159 uint8_t * const cur,
160 const uint8_t * ref1,
161 const uint8_t * ref2,
162 const uint32_t stride);
163
164 typedef TRANSFER_8TO16SUB2 *TRANSFER_8TO16SUB2_PTR;
165
166 /* Our global function pointer - Initialized in xvid.c */
167 extern TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;
168
169 /* Implemented functions */
170 TRANSFER_8TO16SUB2 transfer_8to16sub2_c;
171
172 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
173 extern TRANSFER_8TO16SUB2 transfer_8to16sub2_mmx;
174 extern TRANSFER_8TO16SUB2 transfer_8to16sub2_xmm;
175 extern TRANSFER_8TO16SUB2 transfer_8to16sub2_3dne;
176 #endif
177
178 #ifdef ARCH_IS_IA64
179 extern TRANSFER_8TO16SUB2 transfer_8to16sub2_ia64;
180 #endif
181
182 #ifdef ARCH_IS_PPC
183 extern TRANSFER_8TO16SUB2 transfer_8to16sub2_altivec_c;
184 #endif
185
186 #ifdef ARCH_IS_X86_64
187 extern TRANSFER_8TO16SUB2 transfer_8to16sub2_x86_64;
188 #endif
189
190 /*****************************************************************************
191 * transfer8to16 + substraction op API - Bidirectionnal Version *readonly*
192 ****************************************************************************/
193
194 typedef void (TRANSFER_8TO16SUB2RO) (int16_t * const dct,
195 const uint8_t * const cur,
196 const uint8_t * ref1,
197 const uint8_t * ref2,
198 const uint32_t stride);
199
200 typedef TRANSFER_8TO16SUB2RO *TRANSFER_8TO16SUB2RO_PTR;
201
202 /* Our global function pointer - Initialized in xvid.c */
203 extern TRANSFER_8TO16SUB2RO_PTR transfer_8to16sub2ro;
204
205 /* Implemented functions */
206 TRANSFER_8TO16SUB2RO transfer_8to16sub2ro_c;
207
208 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
209 extern TRANSFER_8TO16SUB2RO transfer_8to16sub2ro_xmm;
210 #endif
211
212 #ifdef ARCH_IS_X86_64
213 extern TRANSFER_8TO16SUB2RO transfer_8to16sub2ro_x86_64;
214 #endif
215
216 /*****************************************************************************
217 * transfer16to8 + addition op API
218 ****************************************************************************/
219
220 typedef void (TRANSFER_16TO8ADD) (uint8_t * const dst,
221 const int16_t * const src,
222 uint32_t stride);
223
224 typedef TRANSFER_16TO8ADD *TRANSFER_16TO8ADD_PTR;
225
226 /* Our global function pointer - Initialized in xvid.c */
227 extern TRANSFER_16TO8ADD_PTR transfer_16to8add;
228
229 /* Implemented functions */
230 extern TRANSFER_16TO8ADD transfer_16to8add_c;
231
232 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
233 extern TRANSFER_16TO8ADD transfer_16to8add_mmx;
234 extern TRANSFER_16TO8ADD transfer_16to8add_3dne;
235 #endif
236
237 #ifdef ARCH_IS_IA64
238 extern TRANSFER_16TO8ADD transfer_16to8add_ia64;
239 #endif
240
241 #ifdef ARCH_IS_PPC
242 extern TRANSFER_16TO8ADD transfer_16to8add_altivec_c;
243 #endif
244
245 #ifdef ARCH_IS_X86_64
246 extern TRANSFER_16TO8ADD transfer_16to8add_x86_64;
247 #endif
248
249 /*****************************************************************************
250 * transfer8to8 + no op
251 ****************************************************************************/
252
253 typedef void (TRANSFER8X8_COPY) (uint8_t * const dst,
254 const uint8_t * const src,
255 const uint32_t stride);
256
257 typedef TRANSFER8X8_COPY *TRANSFER8X8_COPY_PTR;
258
259 /* Our global function pointer - Initialized in xvid.c */
260 extern TRANSFER8X8_COPY_PTR transfer8x8_copy;
261
262 /* Implemented functions */
263 extern TRANSFER8X8_COPY transfer8x8_copy_c;
264
265 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
266 extern TRANSFER8X8_COPY transfer8x8_copy_mmx;
267 extern TRANSFER8X8_COPY transfer8x8_copy_3dne;
268 #endif
269
270 #ifdef ARCH_IS_IA64
271 extern TRANSFER8X8_COPY transfer8x8_copy_ia64;
272 #endif
273
274 #ifdef ARCH_IS_PPC
275 extern TRANSFER8X8_COPY transfer8x8_copy_altivec_c;
276 #endif
277
278 #ifdef ARCH_IS_X86_64
279 extern TRANSFER8X8_COPY transfer8x8_copy_x86_64;
280 #endif
281
282 /*****************************************************************************
283 * transfer8to4 + no op
284 ****************************************************************************/
285
286 typedef void (TRANSFER8X4_COPY) (uint8_t * const dst,
287 const uint8_t * const src,
288 const uint32_t stride);
289
290 typedef TRANSFER8X4_COPY *TRANSFER8X4_COPY_PTR;
291
292 /* Our global function pointer - Initialized in xvid.c */
293 extern TRANSFER8X4_COPY_PTR transfer8x4_copy;
294
295 /* Implemented functions */
296 extern TRANSFER8X4_COPY transfer8x4_copy_c;
297
298 #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
299 extern TRANSFER8X4_COPY transfer8x4_copy_mmx;
300 extern TRANSFER8X4_COPY transfer8x4_copy_3dne;
301 #endif
302
303
304 static __inline void
transfer16x16_copy(uint8_t * const dst,const uint8_t * const src,const uint32_t stride)305 transfer16x16_copy(uint8_t * const dst,
306 const uint8_t * const src,
307 const uint32_t stride)
308 {
309 transfer8x8_copy(dst, src, stride);
310 transfer8x8_copy(dst + 8, src + 8, stride);
311 transfer8x8_copy(dst + 8*stride, src + 8*stride, stride);
312 transfer8x8_copy(dst + 8*stride + 8, src + 8*stride + 8, stride);
313 }
314
315 static __inline void
transfer32x32_copy(uint8_t * const dst,const uint8_t * const src,const uint32_t stride)316 transfer32x32_copy(uint8_t * const dst,
317 const uint8_t * const src,
318 const uint32_t stride)
319 {
320 transfer16x16_copy(dst, src, stride);
321 transfer16x16_copy(dst + 16, src + 16, stride);
322 transfer16x16_copy(dst + 16*stride, src + 16*stride, stride);
323 transfer16x16_copy(dst + 16*stride + 16, src + 16*stride + 16, stride);
324 }
325
326
327 #endif
328