--- xvid.c 2003/02/22 08:49:44 1.45.2.1 +++ xvid.c 2003/08/23 15:11:23 1.45.2.14 @@ -3,6 +3,8 @@ * XVID MPEG-4 VIDEO CODEC * - Native API implementation - * + * Copyright(C) 2001-2003 Peter Ross + * * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation ; either version 2 of the License, or @@ -17,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.1 2003/02/22 08:49:44 suxen_drol Exp $ + * $Id: xvid.c,v 1.45.2.14 2003/08/23 15:11:23 edgomez Exp $ * ****************************************************************************/ @@ -44,6 +46,11 @@ #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 */ +#endif #if defined(ARCH_IS_IA32) @@ -157,7 +164,7 @@ { 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(); @@ -176,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; @@ -282,8 +294,7 @@ #if defined(ARCH_IS_IA32) - if ((cpu_flags & XVID_CPU_ASM)) - { + if ((cpu_flags & XVID_CPU_ASM)) { vfilter_31 = xvid_VFilter_31_x86; hfilter_31 = xvid_HFilter_31_x86; } @@ -302,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; @@ -465,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; @@ -476,16 +492,17 @@ 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; fdct = fdct_sse2; +#endif } #endif +#endif #if defined(ARCH_IS_IA64) if ((cpu_flags & XVID_CPU_ASM)) { /* use assembler routines? */ @@ -510,7 +527,6 @@ transfer_8to16sub2 = transfer_8to16sub2_ia64; transfer_16to8add = transfer_16to8add_ia64; transfer8x8_copy = transfer8x8_copy_ia64; - DPRINTF(DPRINTF_DEBUG, "Using IA-64 assembler routines."); } #endif @@ -532,14 +548,18 @@ } #endif - return 0; +#if defined(_DEBUG) + xvid_debug = init->debug; +#endif + + return 0; } 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; @@ -565,10 +585,12 @@ 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; - // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); +#if 0 + const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); +#endif width = convert->width; height = convert->height; width2 = convert->width/2; @@ -640,7 +662,7 @@ { int i, diff = 0; for (i = 0; i < size; i++) - diff += ABS(blockA[i]-blockB[i]); + diff += abs(blockA[i]-blockB[i]); return diff; } @@ -1055,7 +1077,7 @@ (xvid_enc_stats_t *) param2); case XVID_ENC_CREATE: - return enc_create((xvid_enc_create_t *) param1, (xvid_enc_rc_t*)param2); + return enc_create((xvid_enc_create_t *) param1); case XVID_ENC_DESTROY: return enc_destroy((Encoder *) handle);