--- xvid.c 2002/11/07 15:21:31 1.33.2.12 +++ xvid.c 2002/12/08 05:38:56 1.33.2.15 @@ -37,7 +37,7 @@ * - 22.12.2001 API change: added xvid_init() - Isibaar * - 16.12.2001 inital version; (c)2001 peter ross * - * $Id: xvid.c,v 1.33.2.12 2002/11/07 15:21:31 Isibaar Exp $ + * $Id: xvid.c,v 1.33.2.15 2002/12/08 05:38:56 suxen_drol Exp $ * ****************************************************************************/ @@ -49,6 +49,7 @@ #include "dct/fdct.h" #include "image/colorspace.h" #include "image/interpolate8x8.h" +#include "image/reduced.h" #include "utils/mem_transfer.h" #include "utils/mbfunctions.h" #include "quant/quant_h263.h" @@ -140,16 +141,11 @@ * ****************************************************************************/ -int -xvid_init(void *handle, - int opt, - void *param1, - void *param2) + +static +int xvid_init_init(XVID_INIT_PARAM * init_param) { int cpu_flags; - XVID_INIT_PARAM *init_param; - - init_param = (XVID_INIT_PARAM *) param1; /* Inform the client the API version */ init_param->api_version = API_VERSION; @@ -239,6 +235,18 @@ interpolate8x8_avg2 = interpolate8x8_avg2_c; interpolate8x8_avg4 = interpolate8x8_avg4_c; + /* reduced resoltuion */ + +#ifdef ARCH_X86 + vfilter_31 = xvid_VFilter_31_x86; + hfilter_31 = xvid_HFilter_31_x86; +#else + copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; + add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; + vfilter_31 = xvid_VFilter_31_C; + hfilter_31 = xvid_HFilter_31_C; +#endif + /* Initialize internal colorspace transformation tables */ colorspace_init(); @@ -339,9 +347,14 @@ interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; -// interpolate8x8_avg2 = interpolate8x8_avg2_mmx; + interpolate8x8_avg2 = interpolate8x8_avg2_mmx; interpolate8x8_avg4 = interpolate8x8_avg4_mmx; + /* reduced resolution */ + copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx; + add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx; + hfilter_31 = xvid_HFilter_31_mmx; + /* image input xxx_to_yv12 related functions */ yv12_to_yv12 = yv12_to_yv12_mmx; bgr_to_yv12 = bgr_to_yv12_mmx; @@ -391,6 +404,10 @@ interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; + /* reduced resolution */ + copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm; + add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; + /* Quantization */ dequant_intra = dequant_intra_xmm; dequant_inter = dequant_inter_xmm; @@ -487,6 +504,58 @@ return XVID_ERR_OK; } + + +static int +xvid_init_convert(XVID_INIT_CONVERTINFO* convert) +{ + const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); + const int width = convert->width; + const int height = convert->height; + const int width2 = convert->width/2; + const int height2 = convert->height/2; + IMAGE img; + + switch (convert->input.colorspace & ~XVID_CSP_VFLIP) + { + case XVID_CSP_YV12 : + img.y = convert->input.y; + img.v = (uint8_t*)convert->input.y + width*height; + img.u = (uint8_t*)convert->input.y + width*height + width2*height2; + image_output(&img, width, height, width, + convert->output.y, convert->output.y_stride, + convert->output.colorspace, convert->interlacing); + break; + + default : + return XVID_ERR_FORMAT; + } + + + emms(); + return XVID_ERR_OK; +} + + +int +xvid_init(void *handle, + int opt, + void *param1, + void *param2) +{ + switch(opt) + { + case XVID_INIT_INIT : + return xvid_init_init((XVID_INIT_PARAM*)param1); + + case XVID_INIT_CONVERT : + return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); + + default : + return XVID_ERR_FAIL; + } +} + /***************************************************************************** * XviD Native decoder entry point *