27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
****************************************************************************/ |
****************************************************************************/ |
30 |
|
|
31 |
/***************************************************************************** |
/***************************************************************************** |
32 |
* |
* |
33 |
* History |
* History |
34 |
* |
* |
35 |
|
* - 23.06.2002 added XVID_CPU_CHKONLY |
36 |
* - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
* - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
37 |
* - 22.12.2001 API change: added xvid_init() - Isibaar |
* - 22.12.2001 API change: added xvid_init() - Isibaar |
38 |
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
39 |
* |
* |
40 |
* $Id: xvid.c,v 1.17 2002-06-13 21:35:01 edgomez Exp $ |
* $Id: xvid.c,v 1.25 2002-07-07 13:21:34 Isibaar Exp $ |
41 |
* |
* |
42 |
****************************************************************************/ |
****************************************************************************/ |
43 |
|
|
82 |
|
|
83 |
init_param = (XVID_INIT_PARAM *) param1; |
init_param = (XVID_INIT_PARAM *) param1; |
84 |
|
|
85 |
|
/* Inform the client the API version */ |
86 |
|
init_param->api_version = API_VERSION; |
87 |
|
|
88 |
|
/* Inform the client the core build - unused because we're still alpha */ |
89 |
|
init_param->core_build = 1000; |
90 |
|
|
91 |
|
if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) |
92 |
|
{ |
93 |
|
init_param->cpu_flags = check_cpu_features(); |
94 |
|
return XVID_ERR_OK; |
95 |
|
} |
96 |
|
|
97 |
/* Do we have to force CPU features ? */ |
/* Do we have to force CPU features ? */ |
98 |
if ((init_param->cpu_flags & XVID_CPU_FORCE) > 0) { |
if ((init_param->cpu_flags & XVID_CPU_FORCE) > 0) { |
99 |
cpu_flags = init_param->cpu_flags; |
cpu_flags = init_param->cpu_flags; |
100 |
} else { |
} else { |
101 |
|
|
|
#ifdef ARCH_X86 |
|
102 |
cpu_flags = check_cpu_features(); |
cpu_flags = check_cpu_features(); |
|
#else |
|
|
cpu_flags = 0; |
|
|
#endif |
|
103 |
init_param->cpu_flags = cpu_flags; |
init_param->cpu_flags = cpu_flags; |
104 |
} |
} |
105 |
|
|
194 |
transfer_8to16copy = transfer_8to16copy_mmx; |
transfer_8to16copy = transfer_8to16copy_mmx; |
195 |
transfer_16to8copy = transfer_16to8copy_mmx; |
transfer_16to8copy = transfer_16to8copy_mmx; |
196 |
transfer_8to16sub = transfer_8to16sub_mmx; |
transfer_8to16sub = transfer_8to16sub_mmx; |
197 |
|
transfer_8to16sub2 = transfer_8to16sub2_mmx; |
198 |
transfer_16to8add = transfer_16to8add_mmx; |
transfer_16to8add = transfer_16to8add_mmx; |
199 |
transfer8x8_copy = transfer8x8_copy_mmx; |
transfer8x8_copy = transfer8x8_copy_mmx; |
200 |
|
|
201 |
|
|
202 |
/* Image Interpolation related functions */ |
/* Image Interpolation related functions */ |
203 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
204 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
235 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
236 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
237 |
|
|
238 |
|
/* Quantization */ |
239 |
|
dequant_intra = dequant_intra_xmm; |
240 |
|
dequant_inter = dequant_inter_xmm; |
241 |
|
|
242 |
|
/* Buffer transfer */ |
243 |
|
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
244 |
|
|
245 |
/* Colorspace transformation */ |
/* Colorspace transformation */ |
246 |
yuv_to_yv12 = yuv_to_yv12_xmm; |
yuv_to_yv12 = yuv_to_yv12_xmm; |
247 |
|
|
248 |
/* ME functions */ |
/* ME functions */ |
249 |
sad16 = sad16_xmm; |
sad16 = sad16_xmm; |
250 |
|
sad16bi = sad16bi_xmm; |
251 |
sad8 = sad8_xmm; |
sad8 = sad8_xmm; |
252 |
dev16 = dev16_xmm; |
dev16 = dev16_xmm; |
253 |
|
|
264 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
265 |
#ifdef EXPERIMENTAL_SSE2_CODE |
#ifdef EXPERIMENTAL_SSE2_CODE |
266 |
|
|
267 |
|
calc_cbp = calc_cbp_sse2; |
268 |
|
|
269 |
/* Quantization */ |
/* Quantization */ |
270 |
quant_intra = quant_intra_sse2; |
quant_intra = quant_intra_sse2; |
271 |
dequant_intra = dequant_intra_sse2; |
dequant_intra = dequant_intra_sse2; |
273 |
dequant_inter = dequant_inter_sse2; |
dequant_inter = dequant_inter_sse2; |
274 |
|
|
275 |
/* ME */ |
/* ME */ |
|
calc_cbp = calc_cbp_sse2; |
|
276 |
sad16 = sad16_sse2; |
sad16 = sad16_sse2; |
277 |
dev16 = dev16_sse2; |
dev16 = dev16_sse2; |
278 |
|
|
284 |
|
|
285 |
#endif |
#endif |
286 |
|
|
287 |
|
#ifdef ARCH_IA64 |
288 |
|
if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines? |
289 |
|
idct_ia64_init(); |
290 |
|
fdct = fdct_ia64; |
291 |
|
idct = idct_ia64; //not yet working, crashes |
292 |
|
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; |
293 |
|
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; |
294 |
|
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; |
295 |
|
sad16 = sad16_ia64; |
296 |
|
sad16bi = sad16bi_ia64; |
297 |
|
sad8 = sad8_ia64; |
298 |
|
dev16 = dev16_ia64; |
299 |
|
quant_intra = quant_intra_ia64; |
300 |
|
dequant_intra = dequant_intra_ia64; |
301 |
|
quant_inter = quant_inter_ia64; |
302 |
|
dequant_inter = dequant_inter_ia64; |
303 |
|
transfer_8to16copy = transfer_8to16copy_ia64; |
304 |
|
transfer_16to8copy = transfer_16to8copy_ia64; |
305 |
|
transfer_8to16sub = transfer_8to16sub_ia64; |
306 |
|
transfer_8to16sub2 = transfer_8to16sub2_ia64; |
307 |
|
transfer_16to8add = transfer_16to8add_ia64; |
308 |
|
transfer8x8_copy = transfer8x8_copy_ia64; |
309 |
|
DEBUG("Using IA-64 assembler routines.\n"); |
310 |
|
} |
311 |
|
#endif |
312 |
|
|
313 |
#ifdef ARCH_PPC |
#ifdef ARCH_PPC |
314 |
#ifdef ARCH_PPC_ALTIVEC |
#ifdef ARCH_PPC_ALTIVEC |
315 |
calc_cbp = calc_cbp_altivec; |
calc_cbp = calc_cbp_altivec; |
324 |
#endif |
#endif |
325 |
#endif |
#endif |
326 |
|
|
|
/* Inform the client the API version */ |
|
|
init_param->api_version = API_VERSION; |
|
|
|
|
|
/* Inform the client the core build - unused because we're still alpha */ |
|
|
init_param->core_build = 1000; |
|
|
|
|
327 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
328 |
} |
} |
329 |
|
|
377 |
{ |
{ |
378 |
switch (opt) { |
switch (opt) { |
379 |
case XVID_ENC_ENCODE: |
case XVID_ENC_ENCODE: |
380 |
|
#ifdef BFRAMES |
381 |
|
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
382 |
|
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
383 |
|
(XVID_ENC_STATS *) param2); |
384 |
|
else |
385 |
|
#endif |
386 |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
387 |
(XVID_ENC_STATS *) param2); |
(XVID_ENC_STATS *) param2); |
388 |
|
|