Parent Directory
|
Revision Log
Revision 698 - (view) (download)
1 : | edgomez | 200 | /***************************************************************************** |
2 : | edgomez | 201 | * |
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * - Native API implementation - | ||
5 : | * | ||
6 : | * This program is an implementation of a part of one or more MPEG-4 | ||
7 : | * Video tools as specified in ISO/IEC 14496-2 standard. Those intending | ||
8 : | * to use this software module in hardware or software products are | ||
9 : | * advised that its use may infringe existing patents or copyrights, and | ||
10 : | * any such use would be at such party's own risk. The original | ||
11 : | * developer of this software module and his/her company, and subsequent | ||
12 : | * editors and their companies, will have no liability for use of this | ||
13 : | * software or modifications or derivatives thereof. | ||
14 : | * | ||
15 : | * This program is free software ; you can redistribute it and/or modify | ||
16 : | * it under the terms of the GNU General Public License as published by | ||
17 : | * the Free Software Foundation ; either version 2 of the License, or | ||
18 : | * (at your option) any later version. | ||
19 : | * | ||
20 : | * This program is distributed in the hope that it will be useful, | ||
21 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
22 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 : | * GNU General Public License for more details. | ||
24 : | * | ||
25 : | * You should have received a copy of the GNU General Public License | ||
26 : | * along with this program ; if not, write to the Free Software | ||
27 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
28 : | * | ||
29 : | ****************************************************************************/ | ||
30 : | chenm001 | 274 | |
31 : | edgomez | 200 | /***************************************************************************** |
32 : | edgomez | 201 | * |
33 : | * History | ||
34 : | * | ||
35 : | suxen_drol | 234 | * - 23.06.2002 added XVID_CPU_CHKONLY |
36 : | edgomez | 201 | * - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
37 : | * - 22.12.2001 API change: added xvid_init() - Isibaar | ||
38 : | * - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> | ||
39 : | * | ||
40 : | suxen_drol | 698 | * $Id: xvid.c,v 1.33.2.16 2002-12-08 06:43:34 suxen_drol Exp $ |
41 : | edgomez | 201 | * |
42 : | ****************************************************************************/ | ||
43 : | Isibaar | 3 | |
44 : | #include "xvid.h" | ||
45 : | #include "decoder.h" | ||
46 : | #include "encoder.h" | ||
47 : | #include "bitstream/cbp.h" | ||
48 : | #include "dct/idct.h" | ||
49 : | #include "dct/fdct.h" | ||
50 : | #include "image/colorspace.h" | ||
51 : | #include "image/interpolate8x8.h" | ||
52 : | suxen_drol | 695 | #include "image/reduced.h" |
53 : | Isibaar | 3 | #include "utils/mem_transfer.h" |
54 : | h | 540 | #include "utils/mbfunctions.h" |
55 : | Isibaar | 3 | #include "quant/quant_h263.h" |
56 : | #include "quant/quant_mpeg4.h" | ||
57 : | ia64p | 299 | #include "motion/motion.h" |
58 : | Isibaar | 3 | #include "motion/sad.h" |
59 : | #include "utils/emms.h" | ||
60 : | #include "utils/timer.h" | ||
61 : | Isibaar | 100 | #include "bitstream/mbcoding.h" |
62 : | Isibaar | 3 | |
63 : | suxen_drol | 311 | #if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE) |
64 : | |||
65 : | #ifdef WIN32 | ||
66 : | #include <windows.h> | ||
67 : | #else | ||
68 : | #include <signal.h> | ||
69 : | #include <setjmp.h> | ||
70 : | #endif | ||
71 : | |||
72 : | |||
73 : | #ifndef WIN32 | ||
74 : | |||
75 : | static jmp_buf mark; | ||
76 : | |||
77 : | static void | ||
78 : | sigill_handler(int signal) | ||
79 : | { | ||
80 : | longjmp(mark, 1); | ||
81 : | } | ||
82 : | #endif | ||
83 : | |||
84 : | |||
85 : | /* | ||
86 : | calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled | ||
87 : | return values: | ||
88 : | -1 : could not determine | ||
89 : | 0 : SIGILL was *not* signalled | ||
90 : | 1 : SIGILL was signalled | ||
91 : | */ | ||
92 : | |||
93 : | int | ||
94 : | sigill_check(void (*func)()) | ||
95 : | { | ||
96 : | #ifdef WIN32 | ||
97 : | _try { | ||
98 : | func(); | ||
99 : | } | ||
100 : | _except(EXCEPTION_EXECUTE_HANDLER) { | ||
101 : | |||
102 : | if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION) | ||
103 : | return 1; | ||
104 : | } | ||
105 : | return 0; | ||
106 : | #else | ||
107 : | void * old_handler; | ||
108 : | int jmpret; | ||
109 : | |||
110 : | |||
111 : | old_handler = signal(SIGILL, sigill_handler); | ||
112 : | if (old_handler == SIG_ERR) | ||
113 : | { | ||
114 : | return -1; | ||
115 : | } | ||
116 : | |||
117 : | jmpret = setjmp(mark); | ||
118 : | if (jmpret == 0) | ||
119 : | { | ||
120 : | func(); | ||
121 : | } | ||
122 : | |||
123 : | signal(SIGILL, old_handler); | ||
124 : | |||
125 : | return jmpret; | ||
126 : | #endif | ||
127 : | } | ||
128 : | #endif | ||
129 : | |||
130 : | edgomez | 200 | /***************************************************************************** |
131 : | * XviD Init Entry point | ||
132 : | * | ||
133 : | * Well this function initialize all internal function pointers according | ||
134 : | * to the CPU features forced by the library client or autodetected (depending | ||
135 : | * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all | ||
136 : | * image colorspace transformation tables. | ||
137 : | * | ||
138 : | * Returned value : XVID_ERR_OK | ||
139 : | * + API_VERSION in the input XVID_INIT_PARAM structure | ||
140 : | * + core build " " " " " | ||
141 : | * | ||
142 : | ****************************************************************************/ | ||
143 : | |||
144 : | suxen_drol | 634 | |
145 : | static | ||
146 : | int xvid_init_init(XVID_INIT_PARAM * init_param) | ||
147 : | Isibaar | 3 | { |
148 : | int cpu_flags; | ||
149 : | |||
150 : | suxen_drol | 234 | /* Inform the client the API version */ |
151 : | init_param->api_version = API_VERSION; | ||
152 : | |||
153 : | /* Inform the client the core build - unused because we're still alpha */ | ||
154 : | init_param->core_build = 1000; | ||
155 : | |||
156 : | suxen_drol | 311 | /* Do we have to force CPU features ? */ |
157 : | if ((init_param->cpu_flags & XVID_CPU_FORCE)) { | ||
158 : | suxen_drol | 234 | |
159 : | Isibaar | 3 | cpu_flags = init_param->cpu_flags; |
160 : | suxen_drol | 311 | |
161 : | edgomez | 200 | } else { |
162 : | Isibaar | 3 | |
163 : | chenm001 | 274 | cpu_flags = check_cpu_features(); |
164 : | suxen_drol | 311 | |
165 : | #if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE) | ||
166 : | if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) | ||
167 : | cpu_flags &= ~XVID_CPU_SSE; | ||
168 : | |||
169 : | if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger)) | ||
170 : | cpu_flags &= ~XVID_CPU_SSE2; | ||
171 : | #endif | ||
172 : | } | ||
173 : | |||
174 : | if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) | ||
175 : | { | ||
176 : | Isibaar | 3 | init_param->cpu_flags = cpu_flags; |
177 : | suxen_drol | 311 | return XVID_ERR_OK; |
178 : | Isibaar | 3 | } |
179 : | |||
180 : | suxen_drol | 311 | init_param->cpu_flags = cpu_flags; |
181 : | |||
182 : | |||
183 : | edgomez | 200 | /* Initialize the function pointers */ |
184 : | Isibaar | 3 | idct_int32_init(); |
185 : | Isibaar | 100 | init_vlc_tables(); |
186 : | |||
187 : | edgomez | 200 | /* Fixed Point Forward/Inverse DCT transformations */ |
188 : | Isibaar | 3 | fdct = fdct_int32; |
189 : | idct = idct_int32; | ||
190 : | |||
191 : | edgomez | 200 | /* Only needed on PPC Altivec archs */ |
192 : | canard | 115 | sadInit = 0; |
193 : | edgomez | 195 | |
194 : | edgomez | 200 | /* Restore FPU context : emms_c is a nop functions */ |
195 : | Isibaar | 3 | emms = emms_c; |
196 : | |||
197 : | edgomez | 200 | /* Quantization functions */ |
198 : | quant_intra = quant_intra_c; | ||
199 : | Isibaar | 3 | dequant_intra = dequant_intra_c; |
200 : | edgomez | 200 | quant_inter = quant_inter_c; |
201 : | Isibaar | 3 | dequant_inter = dequant_inter_c; |
202 : | |||
203 : | edgomez | 200 | quant4_intra = quant4_intra_c; |
204 : | Isibaar | 3 | dequant4_intra = dequant4_intra_c; |
205 : | edgomez | 200 | quant4_inter = quant4_inter_c; |
206 : | Isibaar | 3 | dequant4_inter = dequant4_inter_c; |
207 : | |||
208 : | edgomez | 200 | /* Block transfer related functions */ |
209 : | Isibaar | 3 | transfer_8to16copy = transfer_8to16copy_c; |
210 : | transfer_16to8copy = transfer_16to8copy_c; | ||
211 : | edgomez | 200 | transfer_8to16sub = transfer_8to16sub_c; |
212 : | suxen_drol | 118 | transfer_8to16sub2 = transfer_8to16sub2_c; |
213 : | edgomez | 200 | transfer_16to8add = transfer_16to8add_c; |
214 : | transfer8x8_copy = transfer8x8_copy_c; | ||
215 : | Isibaar | 3 | |
216 : | h | 540 | /* Interlacing functions */ |
217 : | MBFieldTest = MBFieldTest_c; | ||
218 : | |||
219 : | edgomez | 200 | /* Image interpolation related functions */ |
220 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; | ||
221 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; | ||
222 : | Isibaar | 3 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
223 : | |||
224 : | Isibaar | 588 | interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c; |
225 : | interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c; | ||
226 : | interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c; | ||
227 : | |||
228 : | Isibaar | 579 | interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c; |
229 : | interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c; | ||
230 : | interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c; | ||
231 : | |||
232 : | interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c; | ||
233 : | interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c; | ||
234 : | |||
235 : | interpolate8x8_avg2 = interpolate8x8_avg2_c; | ||
236 : | interpolate8x8_avg4 = interpolate8x8_avg4_c; | ||
237 : | |||
238 : | suxen_drol | 695 | /* reduced resoltuion */ |
239 : | |||
240 : | #ifdef ARCH_X86 | ||
241 : | vfilter_31 = xvid_VFilter_31_x86; | ||
242 : | hfilter_31 = xvid_HFilter_31_x86; | ||
243 : | #else | ||
244 : | copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; | ||
245 : | add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; | ||
246 : | vfilter_31 = xvid_VFilter_31_C; | ||
247 : | hfilter_31 = xvid_HFilter_31_C; | ||
248 : | #endif | ||
249 : | |||
250 : | edgomez | 200 | /* Initialize internal colorspace transformation tables */ |
251 : | Isibaar | 3 | colorspace_init(); |
252 : | |||
253 : | edgomez | 200 | /* All colorspace transformation functions User Format->YV12 */ |
254 : | suxen_drol | 631 | yv12_to_yv12 = yv12_to_yv12_c; |
255 : | rgb555_to_yv12 = rgb555_to_yv12_c; | ||
256 : | rgb565_to_yv12 = rgb565_to_yv12_c; | ||
257 : | bgr_to_yv12 = bgr_to_yv12_c; | ||
258 : | bgra_to_yv12 = bgra_to_yv12_c; | ||
259 : | abgr_to_yv12 = abgr_to_yv12_c; | ||
260 : | rgba_to_yv12 = rgba_to_yv12_c; | ||
261 : | yuyv_to_yv12 = yuyv_to_yv12_c; | ||
262 : | uyvy_to_yv12 = uyvy_to_yv12_c; | ||
263 : | Isibaar | 3 | |
264 : | suxen_drol | 631 | rgb555i_to_yv12 = rgb555i_to_yv12_c; |
265 : | rgb565i_to_yv12 = rgb565i_to_yv12_c; | ||
266 : | bgri_to_yv12 = bgri_to_yv12_c; | ||
267 : | bgrai_to_yv12 = bgrai_to_yv12_c; | ||
268 : | abgri_to_yv12 = abgri_to_yv12_c; | ||
269 : | rgbai_to_yv12 = rgbai_to_yv12_c; | ||
270 : | yuyvi_to_yv12 = yuyvi_to_yv12_c; | ||
271 : | uyvyi_to_yv12 = uyvyi_to_yv12_c; | ||
272 : | |||
273 : | |||
274 : | edgomez | 200 | /* All colorspace transformation functions YV12->User format */ |
275 : | suxen_drol | 631 | yv12_to_rgb555 = yv12_to_rgb555_c; |
276 : | yv12_to_rgb565 = yv12_to_rgb565_c; | ||
277 : | yv12_to_bgr = yv12_to_bgr_c; | ||
278 : | yv12_to_bgra = yv12_to_bgra_c; | ||
279 : | yv12_to_abgr = yv12_to_abgr_c; | ||
280 : | yv12_to_rgba = yv12_to_rgba_c; | ||
281 : | yv12_to_yuyv = yv12_to_yuyv_c; | ||
282 : | yv12_to_uyvy = yv12_to_uyvy_c; | ||
283 : | |||
284 : | yv12_to_rgb555i = yv12_to_rgb555i_c; | ||
285 : | yv12_to_rgb565i = yv12_to_rgb565i_c; | ||
286 : | yv12_to_bgri = yv12_to_bgri_c; | ||
287 : | yv12_to_bgrai = yv12_to_bgrai_c; | ||
288 : | yv12_to_abgri = yv12_to_abgri_c; | ||
289 : | yv12_to_rgbai = yv12_to_rgbai_c; | ||
290 : | yv12_to_yuyvi = yv12_to_yuyvi_c; | ||
291 : | yv12_to_uyvyi = yv12_to_uyvyi_c; | ||
292 : | Isibaar | 3 | |
293 : | edgomez | 200 | /* Functions used in motion estimation algorithms */ |
294 : | Isibaar | 3 | calc_cbp = calc_cbp_c; |
295 : | edgomez | 200 | sad16 = sad16_c; |
296 : | suxen_drol | 329 | sad8 = sad8_c; |
297 : | edgomez | 200 | sad16bi = sad16bi_c; |
298 : | suxen_drol | 329 | sad8bi = sad8bi_c; |
299 : | edgomez | 200 | dev16 = dev16_c; |
300 : | chl | 530 | sad16v = sad16v_c; |
301 : | suxen_drol | 329 | |
302 : | chl | 530 | // Halfpel8_Refine = Halfpel8_Refine_c; |
303 : | Isibaar | 3 | |
304 : | #ifdef ARCH_X86 | ||
305 : | suxen_drol | 631 | |
306 : | if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || | ||
307 : | (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || | ||
308 : | (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2)) | ||
309 : | { | ||
310 : | /* Restore FPU context : emms_c is a nop functions */ | ||
311 : | emms = emms_mmx; | ||
312 : | } | ||
313 : | |||
314 : | edgomez | 195 | if ((cpu_flags & XVID_CPU_MMX) > 0) { |
315 : | edgomez | 200 | |
316 : | /* Forward and Inverse Discrete Cosine Transformation functions */ | ||
317 : | Isibaar | 3 | fdct = fdct_mmx; |
318 : | idct = idct_mmx; | ||
319 : | |||
320 : | edgomez | 200 | /* Quantization related functions */ |
321 : | quant_intra = quant_intra_mmx; | ||
322 : | Isibaar | 3 | dequant_intra = dequant_intra_mmx; |
323 : | edgomez | 200 | quant_inter = quant_inter_mmx; |
324 : | Isibaar | 3 | dequant_inter = dequant_inter_mmx; |
325 : | |||
326 : | edgomez | 200 | quant4_intra = quant4_intra_mmx; |
327 : | Isibaar | 3 | dequant4_intra = dequant4_intra_mmx; |
328 : | edgomez | 200 | quant4_inter = quant4_inter_mmx; |
329 : | Isibaar | 3 | dequant4_inter = dequant4_inter_mmx; |
330 : | |||
331 : | edgomez | 200 | /* Block related functions */ |
332 : | Isibaar | 3 | transfer_8to16copy = transfer_8to16copy_mmx; |
333 : | transfer_16to8copy = transfer_16to8copy_mmx; | ||
334 : | edgomez | 200 | transfer_8to16sub = transfer_8to16sub_mmx; |
335 : | edgomez | 236 | transfer_8to16sub2 = transfer_8to16sub2_mmx; |
336 : | edgomez | 200 | transfer_16to8add = transfer_16to8add_mmx; |
337 : | transfer8x8_copy = transfer8x8_copy_mmx; | ||
338 : | Isibaar | 3 | |
339 : | h | 540 | /* Interlacing Functions */ |
340 : | MBFieldTest = MBFieldTest_mmx; | ||
341 : | edgomez | 236 | |
342 : | edgomez | 200 | /* Image Interpolation related functions */ |
343 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; | ||
344 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; | ||
345 : | Isibaar | 3 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
346 : | |||
347 : | Isibaar | 579 | interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
348 : | interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; | ||
349 : | |||
350 : | Isibaar | 664 | interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
351 : | Isibaar | 579 | interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
352 : | |||
353 : | suxen_drol | 695 | /* reduced resolution */ |
354 : | copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx; | ||
355 : | add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx; | ||
356 : | hfilter_31 = xvid_HFilter_31_mmx; | ||
357 : | |||
358 : | suxen_drol | 631 | /* image input xxx_to_yv12 related functions */ |
359 : | yv12_to_yv12 = yv12_to_yv12_mmx; | ||
360 : | bgr_to_yv12 = bgr_to_yv12_mmx; | ||
361 : | bgra_to_yv12 = bgra_to_yv12_mmx; | ||
362 : | edgomez | 200 | yuyv_to_yv12 = yuyv_to_yv12_mmx; |
363 : | uyvy_to_yv12 = uyvy_to_yv12_mmx; | ||
364 : | Isibaar | 3 | |
365 : | suxen_drol | 631 | /* image output yv12_to_xxx related functions */ |
366 : | yv12_to_bgr = yv12_to_bgr_mmx; | ||
367 : | yv12_to_bgra = yv12_to_bgra_mmx; | ||
368 : | edgomez | 200 | yv12_to_yuyv = yv12_to_yuyv_mmx; |
369 : | yv12_to_uyvy = yv12_to_uyvy_mmx; | ||
370 : | suxen_drol | 631 | |
371 : | yv12_to_yuyvi = yv12_to_yuyvi_mmx; | ||
372 : | yv12_to_uyvyi = yv12_to_uyvyi_mmx; | ||
373 : | Isibaar | 3 | |
374 : | edgomez | 200 | /* Motion estimation related functions */ |
375 : | Isibaar | 3 | calc_cbp = calc_cbp_mmx; |
376 : | edgomez | 200 | sad16 = sad16_mmx; |
377 : | sad8 = sad8_mmx; | ||
378 : | suxen_drol | 329 | sad16bi = sad16bi_mmx; |
379 : | sad8bi = sad8bi_mmx; | ||
380 : | edgomez | 200 | dev16 = dev16_mmx; |
381 : | Isibaar | 534 | sad16v = sad16v_mmx; |
382 : | Isibaar | 3 | |
383 : | } | ||
384 : | |||
385 : | suxen_drol | 329 | /* these 3dnow functions are faster than mmx, but slower than xmm. */ |
386 : | if ((cpu_flags & XVID_CPU_3DNOW) > 0) { | ||
387 : | |||
388 : | /* ME functions */ | ||
389 : | sad16bi = sad16bi_3dn; | ||
390 : | sad8bi = sad8bi_3dn; | ||
391 : | suxen_drol | 631 | |
392 : | yuyv_to_yv12 = yuyv_to_yv12_3dn; | ||
393 : | uyvy_to_yv12 = uyvy_to_yv12_3dn; | ||
394 : | suxen_drol | 329 | } |
395 : | |||
396 : | |||
397 : | edgomez | 195 | if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
398 : | edgomez | 200 | |
399 : | /* Inverse DCT */ | ||
400 : | Isibaar | 3 | idct = idct_xmm; |
401 : | edgomez | 200 | |
402 : | /* Interpolation */ | ||
403 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_xmm; | ||
404 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; | ||
405 : | h | 38 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
406 : | edgomez | 200 | |
407 : | suxen_drol | 695 | /* reduced resolution */ |
408 : | copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm; | ||
409 : | add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; | ||
410 : | |||
411 : | chenm001 | 274 | /* Quantization */ |
412 : | dequant_intra = dequant_intra_xmm; | ||
413 : | dequant_inter = dequant_inter_xmm; | ||
414 : | |||
415 : | edgomez | 218 | /* Buffer transfer */ |
416 : | transfer_8to16sub2 = transfer_8to16sub2_xmm; | ||
417 : | |||
418 : | edgomez | 200 | /* Colorspace transformation */ |
419 : | suxen_drol | 631 | yv12_to_yv12 = yv12_to_yv12_xmm; |
420 : | yuyv_to_yv12 = yuyv_to_yv12_xmm; | ||
421 : | Isibaar | 633 | uyvy_to_yv12 = uyvy_to_yv12_xmm; |
422 : | Isibaar | 3 | |
423 : | edgomez | 200 | /* ME functions */ |
424 : | Isibaar | 3 | sad16 = sad16_xmm; |
425 : | suxen_drol | 329 | sad8 = sad8_xmm; |
426 : | chenm001 | 274 | sad16bi = sad16bi_xmm; |
427 : | suxen_drol | 329 | sad8bi = sad8bi_xmm; |
428 : | Isibaar | 3 | dev16 = dev16_xmm; |
429 : | chl | 530 | sad16v = sad16v_xmm; |
430 : | Isibaar | 3 | } |
431 : | |||
432 : | edgomez | 195 | if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
433 : | edgomez | 200 | |
434 : | /* Interpolation */ | ||
435 : | Isibaar | 3 | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
436 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dn; | ||
437 : | h | 40 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
438 : | Isibaar | 3 | } |
439 : | |||
440 : | edgomez | 195 | if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
441 : | Isibaar | 154 | #ifdef EXPERIMENTAL_SSE2_CODE |
442 : | edgomez | 200 | |
443 : | chenm001 | 274 | calc_cbp = calc_cbp_sse2; |
444 : | |||
445 : | edgomez | 200 | /* Quantization */ |
446 : | quant_intra = quant_intra_sse2; | ||
447 : | Isibaar | 154 | dequant_intra = dequant_intra_sse2; |
448 : | edgomez | 200 | quant_inter = quant_inter_sse2; |
449 : | Isibaar | 154 | dequant_inter = dequant_inter_sse2; |
450 : | h | 135 | |
451 : | edgomez | 200 | /* ME */ |
452 : | sad16 = sad16_sse2; | ||
453 : | dev16 = dev16_sse2; | ||
454 : | |||
455 : | /* Forward and Inverse DCT */ | ||
456 : | idct = idct_sse2; | ||
457 : | Isibaar | 154 | fdct = fdct_sse2; |
458 : | #endif | ||
459 : | h | 126 | } |
460 : | edgomez | 200 | |
461 : | Isibaar | 3 | #endif |
462 : | edgomez | 200 | |
463 : | Isibaar | 209 | #ifdef ARCH_IA64 |
464 : | if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines? | ||
465 : | idct_ia64_init(); | ||
466 : | fdct = fdct_ia64; | ||
467 : | idct = idct_ia64; //not yet working, crashes | ||
468 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; | ||
469 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; | ||
470 : | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; | ||
471 : | sad16 = sad16_ia64; | ||
472 : | sad16bi = sad16bi_ia64; | ||
473 : | sad8 = sad8_ia64; | ||
474 : | dev16 = dev16_ia64; | ||
475 : | chl | 530 | // Halfpel8_Refine = Halfpel8_Refine_ia64; |
476 : | Isibaar | 209 | quant_intra = quant_intra_ia64; |
477 : | dequant_intra = dequant_intra_ia64; | ||
478 : | quant_inter = quant_inter_ia64; | ||
479 : | dequant_inter = dequant_inter_ia64; | ||
480 : | transfer_8to16copy = transfer_8to16copy_ia64; | ||
481 : | transfer_16to8copy = transfer_16to8copy_ia64; | ||
482 : | transfer_8to16sub = transfer_8to16sub_ia64; | ||
483 : | transfer_8to16sub2 = transfer_8to16sub2_ia64; | ||
484 : | transfer_16to8add = transfer_16to8add_ia64; | ||
485 : | transfer8x8_copy = transfer8x8_copy_ia64; | ||
486 : | DEBUG("Using IA-64 assembler routines.\n"); | ||
487 : | } | ||
488 : | #endif | ||
489 : | |||
490 : | canard | 52 | #ifdef ARCH_PPC |
491 : | canard | 71 | #ifdef ARCH_PPC_ALTIVEC |
492 : | calc_cbp = calc_cbp_altivec; | ||
493 : | canard | 76 | fdct = fdct_altivec; |
494 : | idct = idct_altivec; | ||
495 : | canard | 115 | sadInit = sadInit_altivec; |
496 : | canard | 89 | sad16 = sad16_altivec; |
497 : | sad8 = sad8_altivec; | ||
498 : | dev16 = dev16_altivec; | ||
499 : | canard | 71 | #else |
500 : | canard | 52 | calc_cbp = calc_cbp_ppc; |
501 : | #endif | ||
502 : | canard | 71 | #endif |
503 : | edgomez | 195 | |
504 : | Isibaar | 3 | return XVID_ERR_OK; |
505 : | } | ||
506 : | |||
507 : | suxen_drol | 634 | |
508 : | |||
509 : | static int | ||
510 : | xvid_init_convert(XVID_INIT_CONVERTINFO* convert) | ||
511 : | { | ||
512 : | suxen_drol | 698 | // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
513 : | suxen_drol | 634 | const int width = convert->width; |
514 : | const int height = convert->height; | ||
515 : | const int width2 = convert->width/2; | ||
516 : | const int height2 = convert->height/2; | ||
517 : | IMAGE img; | ||
518 : | |||
519 : | switch (convert->input.colorspace & ~XVID_CSP_VFLIP) | ||
520 : | { | ||
521 : | case XVID_CSP_YV12 : | ||
522 : | img.y = convert->input.y; | ||
523 : | img.v = (uint8_t*)convert->input.y + width*height; | ||
524 : | img.u = (uint8_t*)convert->input.y + width*height + width2*height2; | ||
525 : | image_output(&img, width, height, width, | ||
526 : | convert->output.y, convert->output.y_stride, | ||
527 : | convert->output.colorspace, convert->interlacing); | ||
528 : | break; | ||
529 : | |||
530 : | default : | ||
531 : | return XVID_ERR_FORMAT; | ||
532 : | } | ||
533 : | |||
534 : | |||
535 : | emms(); | ||
536 : | return XVID_ERR_OK; | ||
537 : | } | ||
538 : | |||
539 : | |||
540 : | int | ||
541 : | xvid_init(void *handle, | ||
542 : | int opt, | ||
543 : | void *param1, | ||
544 : | void *param2) | ||
545 : | { | ||
546 : | switch(opt) | ||
547 : | { | ||
548 : | case XVID_INIT_INIT : | ||
549 : | return xvid_init_init((XVID_INIT_PARAM*)param1); | ||
550 : | |||
551 : | case XVID_INIT_CONVERT : | ||
552 : | return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); | ||
553 : | |||
554 : | default : | ||
555 : | return XVID_ERR_FAIL; | ||
556 : | } | ||
557 : | } | ||
558 : | |||
559 : | edgomez | 200 | /***************************************************************************** |
560 : | * XviD Native decoder entry point | ||
561 : | * | ||
562 : | * This function is just a wrapper to all the option cases. | ||
563 : | * | ||
564 : | * Returned values : XVID_ERR_FAIL when opt is invalid | ||
565 : | * else returns the wrapped function result | ||
566 : | * | ||
567 : | ****************************************************************************/ | ||
568 : | |||
569 : | edgomez | 195 | int |
570 : | xvid_decore(void *handle, | ||
571 : | int opt, | ||
572 : | void *param1, | ||
573 : | void *param2) | ||
574 : | Isibaar | 3 | { |
575 : | edgomez | 195 | switch (opt) { |
576 : | case XVID_DEC_DECODE: | ||
577 : | suxen_drol | 631 | return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
578 : | Isibaar | 3 | |
579 : | edgomez | 195 | case XVID_DEC_CREATE: |
580 : | chenm001 | 274 | return decoder_create((XVID_DEC_PARAM *) param1); |
581 : | Isibaar | 3 | |
582 : | edgomez | 195 | case XVID_DEC_DESTROY: |
583 : | return decoder_destroy((DECODER *) handle); | ||
584 : | |||
585 : | Isibaar | 3 | default: |
586 : | edgomez | 195 | return XVID_ERR_FAIL; |
587 : | } | ||
588 : | Isibaar | 3 | } |
589 : | |||
590 : | |||
591 : | edgomez | 200 | /***************************************************************************** |
592 : | * XviD Native encoder entry point | ||
593 : | * | ||
594 : | * This function is just a wrapper to all the option cases. | ||
595 : | * | ||
596 : | * Returned values : XVID_ERR_FAIL when opt is invalid | ||
597 : | * else returns the wrapped function result | ||
598 : | * | ||
599 : | ****************************************************************************/ | ||
600 : | |||
601 : | edgomez | 195 | int |
602 : | xvid_encore(void *handle, | ||
603 : | int opt, | ||
604 : | void *param1, | ||
605 : | void *param2) | ||
606 : | Isibaar | 3 | { |
607 : | edgomez | 195 | switch (opt) { |
608 : | case XVID_ENC_ENCODE: | ||
609 : | chl | 620 | |
610 : | suxen_drol | 232 | if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
611 : | return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, | ||
612 : | (XVID_ENC_STATS *) param2); | ||
613 : | else | ||
614 : | edgomez | 195 | return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
615 : | (XVID_ENC_STATS *) param2); | ||
616 : | Isibaar | 3 | |
617 : | edgomez | 195 | case XVID_ENC_CREATE: |
618 : | return encoder_create((XVID_ENC_PARAM *) param1); | ||
619 : | Isibaar | 3 | |
620 : | edgomez | 195 | case XVID_ENC_DESTROY: |
621 : | return encoder_destroy((Encoder *) handle); | ||
622 : | |||
623 : | Isibaar | 3 | default: |
624 : | edgomez | 195 | return XVID_ERR_FAIL; |
625 : | } | ||
626 : | Isibaar | 3 | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |