--- xvid.c 2003/07/10 17:39:51 1.45.2.9 +++ xvid.c 2003/10/01 23:23:01 1.45.2.15 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: xvid.c,v 1.45.2.9 2003/07/10 17:39:51 edgomez Exp $ + * $Id: xvid.c,v 1.45.2.15 2003/10/01 23:23:01 edgomez Exp $ * ****************************************************************************/ @@ -46,6 +46,7 @@ #include "utils/emms.h" #include "utils/timer.h" #include "bitstream/mbcoding.h" +#include "image/qpel.h" #if defined(_DEBUG) unsigned int xvid_debug = 0; /* xvid debug mask */ @@ -150,7 +151,7 @@ * to the CPU features forced by the library client or autodetected (depending * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all * image colorspace transformation tables. - * + * * Returned value : XVID_ERR_OK * + API_VERSION in the input XVID_INIT_PARAM structure * + core build " " " " " @@ -158,12 +159,12 @@ ****************************************************************************/ -static +static int xvid_gbl_init(xvid_gbl_init_t * init) { unsigned int cpu_flags; - if (XVID_MAJOR(init->version) != 1) /* v1.x.x */ + if (XVID_VERSION_MAJOR(init->version) != 1) /* v1.x.x */ return XVID_ERR_VERSION; cpu_flags = (init->cpu_flags & XVID_CPU_FORCE) ? init->cpu_flags : detect_cpu_flags(); @@ -182,6 +183,11 @@ /* Restore FPU context : emms_c is a nop functions */ emms = emms_c; + /* Qpel stuff */ + xvid_QP_Funcs = &xvid_QP_Funcs_C; + xvid_QP_Add_Funcs = &xvid_QP_Add_Funcs_C; + xvid_Init_QP(); + /* Quantization functions */ quant_intra = quant_intra_c; dequant_intra = dequant_intra_c; @@ -265,7 +271,7 @@ yv12_to_rgba = yv12_to_rgba_c; yv12_to_yuyv = yv12_to_yuyv_c; yv12_to_uyvy = yv12_to_uyvy_c; - + yv12_to_rgb555i = yv12_to_rgb555i_c; yv12_to_rgb565i = yv12_to_rgb565i_c; yv12_to_bgri = yv12_to_bgri_c; @@ -283,7 +289,7 @@ sad8bi = sad8bi_c; dev16 = dev16_c; sad16v = sad16v_c; - + /* Halfpel8_Refine = Halfpel8_Refine_c; */ #if defined(ARCH_IS_IA32) @@ -307,6 +313,10 @@ fdct = fdct_mmx; idct = idct_mmx; + /* Qpel stuff */ + xvid_QP_Funcs = &xvid_QP_Funcs_mmx; + xvid_QP_Add_Funcs = &xvid_QP_Add_Funcs_mmx; + /* Quantization related functions */ quant_intra = quant_intra_mmx; dequant_intra = dequant_intra_mmx; @@ -360,7 +370,7 @@ yv12_to_bgra = yv12_to_bgra_mmx; yv12_to_yuyv = yv12_to_yuyv_mmx; yv12_to_uyvy = yv12_to_uyvy_mmx; - + yv12_to_yuyvi = yv12_to_yuyvi_mmx; yv12_to_uyvyi = yv12_to_uyvyi_mmx; @@ -470,7 +480,8 @@ interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne; } - +#if defined(EXPERIMENTAL_SSE2_CODE) /* mark the whole SSE2 stuff as experimental. At least on + my P4, it crashes... */ if ((cpu_flags & XVID_CPU_SSE2)) { calc_cbp = calc_cbp_sse2; @@ -481,11 +492,9 @@ quant_inter = quant_inter_sse2; dequant_inter = dequant_inter_sse2; -#if defined(EXPERIMENTAL_SSE2_CODE) /* ME; slower than xmm */ sad16 = sad16_sse2; dev16 = dev16_sse2; -#endif /* Forward and Inverse DCT */ #if 0 /* Both function are known to be unprecise, better keep them deactivated */ idct = idct_sse2; @@ -493,6 +502,7 @@ #endif } #endif +#endif #if defined(ARCH_IS_IA64) if ((cpu_flags & XVID_CPU_ASM)) { /* use assembler routines? */ @@ -518,7 +528,7 @@ transfer_16to8add = transfer_16to8add_ia64; transfer8x8_copy = transfer8x8_copy_ia64; } -#endif +#endif #if defined(ARCH_IS_PPC) if ((cpu_flags & XVID_CPU_ASM)) @@ -549,7 +559,7 @@ static int xvid_gbl_info(xvid_gbl_info_t * info) { - if (XVID_MAJOR(info->version) != 1) /* v1.x.x */ + if (XVID_VERSION_MAJOR(info->version) != 1) /* v1.x.x */ return XVID_ERR_VERSION; info->actual_version = XVID_VERSION; @@ -575,7 +585,7 @@ int height2; IMAGE img; - if (XVID_MAJOR(convert->version) != 1) /* v1.x.x */ + if (XVID_VERSION_MAJOR(convert->version) != 1) /* v1.x.x */ return XVID_ERR_VERSION; #if 0 @@ -590,7 +600,7 @@ { case XVID_CSP_YV12 : img.y = convert->input.plane[0]; - img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height; + img.v = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height; img.u = (uint8_t*)convert->input.plane[0] + convert->input.stride[0]*height + (convert->input.stride[0]/2)*height2; image_output(&img, width, height, width, (uint8_t**)convert->output.plane, convert->output.stride, @@ -676,7 +686,7 @@ DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); int min, max; int count = 0; - + int tmp; int min_error = 0x10000*64; int max_error = 0; @@ -818,7 +828,7 @@ if (errors>0) printf("\t(%i errors out of %i)", errors, count); printf("\n"); - + return 0; } @@ -980,7 +990,7 @@ * to the CPU features forced by the library client or autodetected (depending * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all * image colorspace transformation tables. - * + * ****************************************************************************/