--- trunk/xvidcore/src/xvid.c 2005/11/22 10:53:10 1656 +++ trunk/xvidcore/src/xvid.c 2006/12/06 19:55:07 1764 @@ -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.66 2005-11-22 10:53:10 suxen_drol Exp $ + * $Id: xvid.c,v 1.73 2006-12-06 19:55:07 Isibaar Exp $ * ****************************************************************************/ @@ -40,6 +40,7 @@ #include "utils/mbfunctions.h" #include "quant/quant.h" #include "motion/motion.h" +#include "motion/gmc.h" #include "motion/sad.h" #include "utils/emms.h" #include "utils/timer.h" @@ -136,8 +137,8 @@ if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) cpu_flags &= ~XVID_CPU_SSE; - if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger)) - cpu_flags &= ~XVID_CPU_SSE2; + if ((cpu_flags & (XVID_CPU_SSE2|XVID_CPU_SSE3)) && sigill_check(sse2_os_trigger)) + cpu_flags &= ~(XVID_CPU_SSE2|XVID_CPU_SSE3); #endif #if defined(ARCH_IS_PPC) @@ -256,6 +257,7 @@ yv12_to_yv12 = yv12_to_yv12_c; rgb555_to_yv12 = rgb555_to_yv12_c; rgb565_to_yv12 = rgb565_to_yv12_c; + rgb_to_yv12 = rgb_to_yv12_c; bgr_to_yv12 = bgr_to_yv12_c; bgra_to_yv12 = bgra_to_yv12_c; abgr_to_yv12 = abgr_to_yv12_c; @@ -277,6 +279,7 @@ /* All colorspace transformation functions YV12->User format */ yv12_to_rgb555 = yv12_to_rgb555_c; yv12_to_rgb565 = yv12_to_rgb565_c; + yv12_to_rgb = yv12_to_rgb_c; yv12_to_bgr = yv12_to_bgr_c; yv12_to_bgra = yv12_to_bgra_c; yv12_to_abgr = yv12_to_abgr_c; @@ -306,6 +309,8 @@ sse8_16bit = sse8_16bit_c; sse8_8bit = sse8_8bit_c; + init_GMC(cpu_flags); + #if defined(ARCH_IS_IA32) if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || @@ -376,7 +381,9 @@ /* image input xxx_to_yv12 related functions */ yv12_to_yv12 = yv12_to_yv12_mmx; bgr_to_yv12 = bgr_to_yv12_mmx; + rgb_to_yv12 = rgb_to_yv12_mmx; bgra_to_yv12 = bgra_to_yv12_mmx; + rgba_to_yv12 = rgba_to_yv12_mmx; yuyv_to_yv12 = yuyv_to_yv12_mmx; uyvy_to_yv12 = uyvy_to_yv12_mmx; @@ -436,7 +443,6 @@ interpolate8x8_halfpel_hv_add = interpolate8x8_halfpel_hv_add_xmm; /* Quantization */ - quant_mpeg_intra = quant_mpeg_intra_xmm; quant_mpeg_inter = quant_mpeg_inter_xmm; dequant_h263_intra = dequant_h263_intra_xmm; @@ -539,6 +545,15 @@ /* postprocessing */ image_brightness = image_brightness_sse2; } + +#if 0 // TODO: test... + if ((cpu_flags & XVID_CPU_SSE3)) { + + /* SAD operators */ + sad16 = sad16_sse3; + dev16 = dev16_sse3; + } +#endif #endif /* ARCH_IS_IA32 */ #if defined(ARCH_IS_IA64) @@ -636,7 +651,7 @@ * features there really are. */ if (cpu_flags & XVID_CPU_ASM) { /* SIMD state flusher */ - emms = emms_3dn; + emms = emms_mmx; /* DCT operators */ fdct = fdct_skal_x86_64; @@ -673,7 +688,7 @@ quant_h263_inter = quant_h263_inter_x86_64; dequant_h263_intra = dequant_h263_intra_x86_64; dequant_h263_inter = dequant_h263_inter_x86_64; - quant_mpeg_intra = quant_mpeg_intra_x86_64; + /*quant_mpeg_intra = quant_mpeg_intra_x86_64; fix me! */ quant_mpeg_inter = quant_mpeg_inter_x86_64; dequant_mpeg_intra = dequant_mpeg_intra_x86_64; dequant_mpeg_inter = dequant_mpeg_inter_x86_64; @@ -714,11 +729,19 @@ info->actual_version = XVID_VERSION; info->build = "xvid-1.2.0-dev"; info->cpu_flags = detect_cpu_flags(); + info->num_threads = 0; -#if defined(_SMP) && defined(WIN32) - info->num_threads = pthread_num_processors_np();; -#else - info->num_threads = 0; +#if defined(WIN32) + { + DWORD dwProcessAffinityMask, dwSystemAffinityMask; + if (GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask)) { + int i; + for(i=0; i<32; i++) { + if ((dwProcessAffinityMask & (1<num_threads++; + } + } + } #endif return 0;