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.33.2.12 2002-11-07 15:21:31 Isibaar Exp $ |
* $Id: xvid.c,v 1.33.2.17 2002-12-09 10:47:05 suxen_drol Exp $ |
41 |
* |
* |
42 |
****************************************************************************/ |
****************************************************************************/ |
43 |
|
|
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 |
dequant_intra = dequant_intra_xmm; |
dequant_intra = dequant_intra_xmm; |
417 |
dequant_inter = dequant_inter_xmm; |
dequant_inter = dequant_inter_xmm; |
508 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
509 |
} |
} |
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
static int |
514 |
|
xvid_init_convert(XVID_INIT_CONVERTINFO* convert) |
515 |
|
{ |
516 |
|
// const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
517 |
|
const int width = convert->width; |
518 |
|
const int height = convert->height; |
519 |
|
const int width2 = convert->width/2; |
520 |
|
const int height2 = convert->height/2; |
521 |
|
IMAGE img; |
522 |
|
|
523 |
|
switch (convert->input.colorspace & ~XVID_CSP_VFLIP) |
524 |
|
{ |
525 |
|
case XVID_CSP_YV12 : |
526 |
|
img.y = convert->input.y; |
527 |
|
img.v = (uint8_t*)convert->input.y + width*height; |
528 |
|
img.u = (uint8_t*)convert->input.y + width*height + width2*height2; |
529 |
|
image_output(&img, width, height, width, |
530 |
|
convert->output.y, convert->output.y_stride, |
531 |
|
convert->output.colorspace, convert->interlacing); |
532 |
|
break; |
533 |
|
|
534 |
|
default : |
535 |
|
return XVID_ERR_FORMAT; |
536 |
|
} |
537 |
|
|
538 |
|
|
539 |
|
emms(); |
540 |
|
return XVID_ERR_OK; |
541 |
|
} |
542 |
|
|
543 |
|
|
544 |
|
int |
545 |
|
xvid_init(void *handle, |
546 |
|
int opt, |
547 |
|
void *param1, |
548 |
|
void *param2) |
549 |
|
{ |
550 |
|
switch(opt) |
551 |
|
{ |
552 |
|
case XVID_INIT_INIT : |
553 |
|
return xvid_init_init((XVID_INIT_PARAM*)param1); |
554 |
|
|
555 |
|
case XVID_INIT_CONVERT : |
556 |
|
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
557 |
|
|
558 |
|
default : |
559 |
|
return XVID_ERR_FAIL; |
560 |
|
} |
561 |
|
} |
562 |
|
|
563 |
/***************************************************************************** |
/***************************************************************************** |
564 |
* XviD Native decoder entry point |
* XviD Native decoder entry point |
565 |
* |
* |