3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Native API implementation - |
* - Native API implementation - |
5 |
* |
* |
6 |
|
* Copyright(C) 2001-2002 Peter Ross <pross@cs.rmit.edu.au> |
7 |
|
* |
8 |
* This program is an implementation of a part of one or more MPEG-4 |
* 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 |
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
10 |
* to use this software module in hardware or software products are |
* to use this software module in hardware or software products are |
28 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
29 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
30 |
* |
* |
|
****************************************************************************/ |
|
|
|
|
|
/***************************************************************************** |
|
|
* |
|
|
* History |
|
|
* |
|
|
* - 23.06.2002 added XVID_CPU_CHKONLY |
|
|
* - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
|
|
* - 22.12.2001 API change: added xvid_init() - Isibaar |
|
|
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
* |
|
31 |
* $Id$ |
* $Id$ |
32 |
* |
* |
33 |
****************************************************************************/ |
****************************************************************************/ |
41 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
42 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
43 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
|
#include "utils/mbfunctions.h" |
|
44 |
#include "quant/quant_h263.h" |
#include "quant/quant_h263.h" |
45 |
#include "quant/quant_mpeg4.h" |
#include "quant/quant_mpeg4.h" |
46 |
#include "motion/motion.h" |
#include "motion/motion.h" |
72 |
|
|
73 |
|
|
74 |
/* |
/* |
75 |
calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled |
* Calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled |
76 |
return values: |
* Return values: |
77 |
-1 : could not determine |
* -1 : could not determine |
78 |
0 : SIGILL was *not* signalled |
* 0 : SIGILL was *not* signalled |
79 |
1 : SIGILL was signalled |
* 1 : SIGILL was signalled |
80 |
*/ |
*/ |
81 |
|
|
82 |
int |
int |
207 |
transfer_16to8add = transfer_16to8add_c; |
transfer_16to8add = transfer_16to8add_c; |
208 |
transfer8x8_copy = transfer8x8_copy_c; |
transfer8x8_copy = transfer8x8_copy_c; |
209 |
|
|
|
/* Interlacing functions */ |
|
|
MBFieldTest = MBFieldTest_c; |
|
|
|
|
210 |
/* Image interpolation related functions */ |
/* Image interpolation related functions */ |
211 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
212 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
213 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
214 |
|
|
|
interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c; |
|
|
interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c; |
|
|
interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c; |
|
|
|
|
|
interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c; |
|
|
interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c; |
|
|
interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c; |
|
|
|
|
|
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c; |
|
|
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c; |
|
|
|
|
|
interpolate8x8_avg2 = interpolate8x8_avg2_c; |
|
|
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
|
|
|
|
215 |
/* Initialize internal colorspace transformation tables */ |
/* Initialize internal colorspace transformation tables */ |
216 |
colorspace_init(); |
colorspace_init(); |
217 |
|
|
218 |
/* All colorspace transformation functions User Format->YV12 */ |
/* All colorspace transformation functions User Format->YV12 */ |
|
yv12_to_yv12 = yv12_to_yv12_c; |
|
219 |
rgb555_to_yv12 = rgb555_to_yv12_c; |
rgb555_to_yv12 = rgb555_to_yv12_c; |
220 |
rgb565_to_yv12 = rgb565_to_yv12_c; |
rgb565_to_yv12 = rgb565_to_yv12_c; |
221 |
bgr_to_yv12 = bgr_to_yv12_c; |
rgb24_to_yv12 = rgb24_to_yv12_c; |
222 |
bgra_to_yv12 = bgra_to_yv12_c; |
rgb32_to_yv12 = rgb32_to_yv12_c; |
223 |
abgr_to_yv12 = abgr_to_yv12_c; |
yuv_to_yv12 = yuv_to_yv12_c; |
|
rgba_to_yv12 = rgba_to_yv12_c; |
|
224 |
yuyv_to_yv12 = yuyv_to_yv12_c; |
yuyv_to_yv12 = yuyv_to_yv12_c; |
225 |
uyvy_to_yv12 = uyvy_to_yv12_c; |
uyvy_to_yv12 = uyvy_to_yv12_c; |
226 |
|
|
|
rgb555i_to_yv12 = rgb555i_to_yv12_c; |
|
|
rgb565i_to_yv12 = rgb565i_to_yv12_c; |
|
|
bgri_to_yv12 = bgri_to_yv12_c; |
|
|
bgrai_to_yv12 = bgrai_to_yv12_c; |
|
|
abgri_to_yv12 = abgri_to_yv12_c; |
|
|
rgbai_to_yv12 = rgbai_to_yv12_c; |
|
|
yuyvi_to_yv12 = yuyvi_to_yv12_c; |
|
|
uyvyi_to_yv12 = uyvyi_to_yv12_c; |
|
|
|
|
|
|
|
227 |
/* All colorspace transformation functions YV12->User format */ |
/* All colorspace transformation functions YV12->User format */ |
228 |
yv12_to_rgb555 = yv12_to_rgb555_c; |
yv12_to_rgb555 = yv12_to_rgb555_c; |
229 |
yv12_to_rgb565 = yv12_to_rgb565_c; |
yv12_to_rgb565 = yv12_to_rgb565_c; |
230 |
yv12_to_bgr = yv12_to_bgr_c; |
yv12_to_rgb24 = yv12_to_rgb24_c; |
231 |
yv12_to_bgra = yv12_to_bgra_c; |
yv12_to_rgb32 = yv12_to_rgb32_c; |
232 |
yv12_to_abgr = yv12_to_abgr_c; |
yv12_to_yuv = yv12_to_yuv_c; |
|
yv12_to_rgba = yv12_to_rgba_c; |
|
233 |
yv12_to_yuyv = yv12_to_yuyv_c; |
yv12_to_yuyv = yv12_to_yuyv_c; |
234 |
yv12_to_uyvy = yv12_to_uyvy_c; |
yv12_to_uyvy = yv12_to_uyvy_c; |
235 |
|
|
|
yv12_to_rgb555i = yv12_to_rgb555i_c; |
|
|
yv12_to_rgb565i = yv12_to_rgb565i_c; |
|
|
yv12_to_bgri = yv12_to_bgri_c; |
|
|
yv12_to_bgrai = yv12_to_bgrai_c; |
|
|
yv12_to_abgri = yv12_to_abgri_c; |
|
|
yv12_to_rgbai = yv12_to_rgbai_c; |
|
|
yv12_to_yuyvi = yv12_to_yuyvi_c; |
|
|
yv12_to_uyvyi = yv12_to_uyvyi_c; |
|
|
|
|
236 |
/* Functions used in motion estimation algorithms */ |
/* Functions used in motion estimation algorithms */ |
237 |
calc_cbp = calc_cbp_c; |
calc_cbp = calc_cbp_c; |
238 |
sad16 = sad16_c; |
sad16 = sad16_c; |
240 |
sad16bi = sad16bi_c; |
sad16bi = sad16bi_c; |
241 |
sad8bi = sad8bi_c; |
sad8bi = sad8bi_c; |
242 |
dev16 = dev16_c; |
dev16 = dev16_c; |
|
sad16v = sad16v_c; |
|
243 |
|
|
244 |
// Halfpel8_Refine = Halfpel8_Refine_c; |
Halfpel8_Refine = Halfpel8_Refine_c; |
245 |
|
|
246 |
#ifdef ARCH_X86 |
#ifdef ARCH_X86 |
|
|
|
|
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
|
|
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
|
|
(cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2)) |
|
|
{ |
|
|
/* Restore FPU context : emms_c is a nop functions */ |
|
|
emms = emms_mmx; |
|
|
} |
|
|
|
|
247 |
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
248 |
|
|
249 |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
250 |
fdct = fdct_mmx; |
fdct = fdct_mmx; |
251 |
idct = idct_mmx; |
idct = idct_mmx; |
252 |
|
|
253 |
|
/* To restore FPU context after mmx use */ |
254 |
|
emms = emms_mmx; |
255 |
|
|
256 |
/* Quantization related functions */ |
/* Quantization related functions */ |
257 |
quant_intra = quant_intra_mmx; |
quant_intra = quant_intra_mmx; |
258 |
dequant_intra = dequant_intra_mmx; |
dequant_intra = dequant_intra_mmx; |
272 |
transfer_16to8add = transfer_16to8add_mmx; |
transfer_16to8add = transfer_16to8add_mmx; |
273 |
transfer8x8_copy = transfer8x8_copy_mmx; |
transfer8x8_copy = transfer8x8_copy_mmx; |
274 |
|
|
|
/* Interlacing Functions */ |
|
|
MBFieldTest = MBFieldTest_mmx; |
|
275 |
|
|
276 |
/* Image Interpolation related functions */ |
/* Image Interpolation related functions */ |
277 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
278 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
279 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
280 |
|
|
281 |
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
/* Image RGB->YV12 related functions */ |
282 |
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; |
rgb24_to_yv12 = rgb24_to_yv12_mmx; |
283 |
|
rgb32_to_yv12 = rgb32_to_yv12_mmx; |
284 |
// interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
yuv_to_yv12 = yuv_to_yv12_mmx; |
|
interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
|
|
|
|
|
/* image input xxx_to_yv12 related functions */ |
|
|
yv12_to_yv12 = yv12_to_yv12_mmx; |
|
|
bgr_to_yv12 = bgr_to_yv12_mmx; |
|
|
bgra_to_yv12 = bgra_to_yv12_mmx; |
|
285 |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
286 |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
287 |
|
|
288 |
/* image output yv12_to_xxx related functions */ |
/* Image YV12->RGB related functions */ |
289 |
yv12_to_bgr = yv12_to_bgr_mmx; |
yv12_to_rgb24 = yv12_to_rgb24_mmx; |
290 |
yv12_to_bgra = yv12_to_bgra_mmx; |
yv12_to_rgb32 = yv12_to_rgb32_mmx; |
291 |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
292 |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
293 |
|
|
|
yv12_to_yuyvi = yv12_to_yuyvi_mmx; |
|
|
yv12_to_uyvyi = yv12_to_uyvyi_mmx; |
|
|
|
|
294 |
/* Motion estimation related functions */ |
/* Motion estimation related functions */ |
295 |
calc_cbp = calc_cbp_mmx; |
calc_cbp = calc_cbp_mmx; |
296 |
sad16 = sad16_mmx; |
sad16 = sad16_mmx; |
298 |
sad16bi = sad16bi_mmx; |
sad16bi = sad16bi_mmx; |
299 |
sad8bi = sad8bi_mmx; |
sad8bi = sad8bi_mmx; |
300 |
dev16 = dev16_mmx; |
dev16 = dev16_mmx; |
|
sad16v = sad16v_mmx; |
|
301 |
|
|
302 |
} |
} |
303 |
|
|
307 |
/* ME functions */ |
/* ME functions */ |
308 |
sad16bi = sad16bi_3dn; |
sad16bi = sad16bi_3dn; |
309 |
sad8bi = sad8bi_3dn; |
sad8bi = sad8bi_3dn; |
|
|
|
|
yuyv_to_yv12 = yuyv_to_yv12_3dn; |
|
|
uyvy_to_yv12 = uyvy_to_yv12_3dn; |
|
310 |
} |
} |
311 |
|
|
312 |
|
|
328 |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
329 |
|
|
330 |
/* Colorspace transformation */ |
/* Colorspace transformation */ |
331 |
yv12_to_yv12 = yv12_to_yv12_xmm; |
yuv_to_yv12 = yuv_to_yv12_xmm; |
|
yuyv_to_yv12 = yuyv_to_yv12_xmm; |
|
|
uyvy_to_yv12 = uyvy_to_yv12_xmm; |
|
332 |
|
|
333 |
/* ME functions */ |
/* ME functions */ |
334 |
sad16 = sad16_xmm; |
sad16 = sad16_xmm; |
336 |
sad16bi = sad16bi_xmm; |
sad16bi = sad16bi_xmm; |
337 |
sad8bi = sad8bi_xmm; |
sad8bi = sad8bi_xmm; |
338 |
dev16 = dev16_xmm; |
dev16 = dev16_xmm; |
339 |
sad16v = sad16v_xmm; |
|
340 |
} |
} |
341 |
|
|
342 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
382 |
sad16bi = sad16bi_ia64; |
sad16bi = sad16bi_ia64; |
383 |
sad8 = sad8_ia64; |
sad8 = sad8_ia64; |
384 |
dev16 = dev16_ia64; |
dev16 = dev16_ia64; |
385 |
// Halfpel8_Refine = Halfpel8_Refine_ia64; |
Halfpel8_Refine = Halfpel8_Refine_ia64; |
386 |
quant_intra = quant_intra_ia64; |
quant_intra = quant_intra_ia64; |
387 |
dequant_intra = dequant_intra_ia64; |
dequant_intra = dequant_intra_ia64; |
388 |
quant_inter = quant_inter_ia64; |
quant_inter = quant_inter_ia64; |
432 |
{ |
{ |
433 |
switch (opt) { |
switch (opt) { |
434 |
case XVID_DEC_DECODE: |
case XVID_DEC_DECODE: |
435 |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1); |
436 |
|
|
437 |
case XVID_DEC_CREATE: |
case XVID_DEC_CREATE: |
438 |
return decoder_create((XVID_DEC_PARAM *) param1); |
return decoder_create((XVID_DEC_PARAM *) param1); |
464 |
{ |
{ |
465 |
switch (opt) { |
switch (opt) { |
466 |
case XVID_ENC_ENCODE: |
case XVID_ENC_ENCODE: |
|
|
|
|
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
|
|
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
|
|
(XVID_ENC_STATS *) param2); |
|
|
else |
|
467 |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
468 |
(XVID_ENC_STATS *) param2); |
(XVID_ENC_STATS *) param2); |
469 |
|
|