49 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
50 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
51 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
52 |
|
#include "image/reduced.h" |
53 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
54 |
#include "utils/mbfunctions.h" |
#include "utils/mbfunctions.h" |
55 |
#include "quant/quant_h263.h" |
#include "quant/quant_h263.h" |
141 |
* |
* |
142 |
****************************************************************************/ |
****************************************************************************/ |
143 |
|
|
144 |
int |
|
145 |
xvid_init(void *handle, |
static |
146 |
int opt, |
int xvid_init_init(XVID_INIT_PARAM * init_param) |
|
void *param1, |
|
|
void *param2) |
|
147 |
{ |
{ |
148 |
int cpu_flags; |
int cpu_flags; |
|
XVID_INIT_PARAM *init_param; |
|
|
|
|
|
init_param = (XVID_INIT_PARAM *) param1; |
|
149 |
|
|
150 |
/* Inform the client the API version */ |
/* Inform the client the API version */ |
151 |
init_param->api_version = API_VERSION; |
init_param->api_version = API_VERSION; |
235 |
interpolate8x8_avg2 = interpolate8x8_avg2_c; |
interpolate8x8_avg2 = interpolate8x8_avg2_c; |
236 |
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
237 |
|
|
238 |
|
/* reduced resoltuion */ |
239 |
|
|
240 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
241 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; |
242 |
|
#ifdef ARCH_X86 |
243 |
|
vfilter_31 = xvid_VFilter_31_x86; |
244 |
|
hfilter_31 = xvid_HFilter_31_x86; |
245 |
|
#else |
246 |
|
vfilter_31 = xvid_VFilter_31_C; |
247 |
|
hfilter_31 = xvid_HFilter_31_C; |
248 |
|
#endif |
249 |
|
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
250 |
|
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
251 |
|
|
252 |
/* Initialize internal colorspace transformation tables */ |
/* Initialize internal colorspace transformation tables */ |
253 |
colorspace_init(); |
colorspace_init(); |
254 |
|
|
349 |
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
350 |
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; |
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; |
351 |
|
|
352 |
// interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
353 |
interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
354 |
|
|
355 |
|
/* reduced resolution */ |
356 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx; |
357 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx; |
358 |
|
hfilter_31 = xvid_HFilter_31_mmx; |
359 |
|
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx; |
360 |
|
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx; |
361 |
|
|
362 |
/* image input xxx_to_yv12 related functions */ |
/* image input xxx_to_yv12 related functions */ |
363 |
yv12_to_yv12 = yv12_to_yv12_mmx; |
yv12_to_yv12 = yv12_to_yv12_mmx; |
364 |
bgr_to_yv12 = bgr_to_yv12_mmx; |
bgr_to_yv12 = bgr_to_yv12_mmx; |
408 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
409 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
410 |
|
|
411 |
|
/* reduced resolution */ |
412 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm; |
413 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; |
414 |
|
|
415 |
/* Quantization */ |
/* Quantization */ |
416 |
|
quant4_intra = quant4_intra_xmm; |
417 |
|
quant4_inter = quant4_inter_xmm; |
418 |
|
|
419 |
dequant_intra = dequant_intra_xmm; |
dequant_intra = dequant_intra_xmm; |
420 |
dequant_inter = dequant_inter_xmm; |
dequant_inter = dequant_inter_xmm; |
421 |
|
|
444 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
445 |
} |
} |
446 |
|
|
447 |
|
if ((cpu_flags & XVID_CPU_3DNOWEXT) > 0) { |
448 |
|
|
449 |
|
/* Inverse DCT */ |
450 |
|
idct = idct_3dne; |
451 |
|
|
452 |
|
/* Buffer transfer */ |
453 |
|
transfer_8to16copy = transfer_8to16copy_3dne; |
454 |
|
transfer_16to8copy = transfer_16to8copy_3dne; |
455 |
|
transfer_8to16sub = transfer_8to16sub_3dne; |
456 |
|
transfer_8to16sub2 = transfer_8to16sub2_3dne; |
457 |
|
transfer_16to8add = transfer_16to8add_3dne; |
458 |
|
transfer8x8_copy = transfer8x8_copy_3dne; |
459 |
|
|
460 |
|
/* Quantization */ |
461 |
|
dequant4_intra = dequant4_intra_3dne; |
462 |
|
dequant4_inter = dequant4_inter_3dne; |
463 |
|
quant_intra = quant_intra_3dne; |
464 |
|
quant_inter = quant_inter_3dne; |
465 |
|
dequant_intra = dequant_intra_3dne; |
466 |
|
dequant_inter = dequant_inter_3dne; |
467 |
|
|
468 |
|
/* ME functions */ |
469 |
|
calc_cbp = calc_cbp_3dne; |
470 |
|
sad16 = sad16_3dne; |
471 |
|
sad8 = sad8_3dne; |
472 |
|
sad16bi = sad16bi_3dne; |
473 |
|
sad8bi = sad8bi_3dne; |
474 |
|
dev16 = dev16_3dne; |
475 |
|
|
476 |
|
/* Interpolation */ |
477 |
|
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne; |
478 |
|
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne; |
479 |
|
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne; |
480 |
|
} |
481 |
|
|
482 |
|
|
483 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
484 |
#ifdef EXPERIMENTAL_SSE2_CODE |
#ifdef EXPERIMENTAL_SSE2_CODE |
485 |
|
|
547 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
548 |
} |
} |
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
static int |
553 |
|
xvid_init_convert(XVID_INIT_CONVERTINFO* convert) |
554 |
|
{ |
555 |
|
// const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
556 |
|
const int width = convert->width; |
557 |
|
const int height = convert->height; |
558 |
|
const int width2 = convert->width/2; |
559 |
|
const int height2 = convert->height/2; |
560 |
|
IMAGE img; |
561 |
|
|
562 |
|
switch (convert->input.colorspace & ~XVID_CSP_VFLIP) |
563 |
|
{ |
564 |
|
case XVID_CSP_YV12 : |
565 |
|
img.y = convert->input.y; |
566 |
|
img.v = (uint8_t*)convert->input.y + width*height; |
567 |
|
img.u = (uint8_t*)convert->input.y + width*height + width2*height2; |
568 |
|
image_output(&img, width, height, width, |
569 |
|
convert->output.y, convert->output.y_stride, |
570 |
|
convert->output.colorspace, convert->interlacing); |
571 |
|
break; |
572 |
|
|
573 |
|
default : |
574 |
|
return XVID_ERR_FORMAT; |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
emms(); |
579 |
|
return XVID_ERR_OK; |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
|
int |
584 |
|
xvid_init(void *handle, |
585 |
|
int opt, |
586 |
|
void *param1, |
587 |
|
void *param2) |
588 |
|
{ |
589 |
|
switch(opt) |
590 |
|
{ |
591 |
|
case XVID_INIT_INIT : |
592 |
|
return xvid_init_init((XVID_INIT_PARAM*)param1); |
593 |
|
|
594 |
|
case XVID_INIT_CONVERT : |
595 |
|
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
596 |
|
|
597 |
|
default : |
598 |
|
return XVID_ERR_FAIL; |
599 |
|
} |
600 |
|
} |
601 |
|
|
602 |
/***************************************************************************** |
/***************************************************************************** |
603 |
* XviD Native decoder entry point |
* XviD Native decoder entry point |
604 |
* |
* |