diff -urN xvidcore.orig/build/generic/configure.in xvidcore/build/generic/configure.in
--- xvidcore.orig/build/generic/configure.in	Tue Dec  2 01:35:47 2008
+++ xvidcore/build/generic/configure.in	Wed Feb 11 14:00:06 2009
@@ -562,13 +562,13 @@
 AC_CHECK_HEADER(
 	pthread.h,
 	AC_CHECK_LIB(
-		pthread,
+		pthread -lwsock32,
 		pthread_create,
 		AC_CHECK_LIB(
-			pthread,
+			pthread -lwsock32,
 			pthread_join,
-			SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -DHAVE_PTHREAD"
-			SPECIFIC_LDFLAGS="$SPECIFIC_LDFLAGS -lpthread",
+			SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -DHAVE_PTHREAD -DPTW32_STATIC_LIB"
+			SPECIFIC_LDFLAGS="$SPECIFIC_LDFLAGS -lpthread -lwsock32",
 			AC_MSG_WARN(Pthread not supported. No SMP support)),
 		AC_MSG_WARN(Pthread not supported. No SMP support)),
 	AC_MSG_WARN(Pthread not supported. No SMP support))
diff -urN xvidcore.orig/src/encoder.c xvidcore/src/encoder.c
--- xvidcore.orig/src/encoder.c	Thu Feb  8 22:10:24 2007
+++ xvidcore/src/encoder.c	Wed Feb 11 14:01:49 2009
@@ -134,11 +134,26 @@
 }
 
 
+#ifdef PTW32_STATIC_LIB
+static void
+detach_ptw32(void)
+{
+	pthread_win32_thread_detach_np();
+	pthread_win32_process_detach_np();
+}
+#endif
+
 int
 enc_create(xvid_enc_create_t * create)
 {
 	Encoder *pEnc;
 	int n;
+
+#ifdef PTW32_STATIC_LIB
+	pthread_win32_process_attach_np();
+	pthread_win32_thread_attach_np();
+	atexit(detach_ptw32);
+#endif
 
 	if (XVID_VERSION_MAJOR(create->version) != 1) /* v1.x.x */
 		return XVID_ERR_VERSION;
diff -urN xvidcore.orig/src/motion/motion_smp.h xvidcore/src/motion/motion_smp.h
--- xvidcore.orig/src/motion/motion_smp.h	Wed Nov 26 10:04:34 2008
+++ xvidcore/src/motion/motion_smp.h	Wed Feb 11 14:03:29 2009
@@ -32,11 +32,15 @@
 #ifdef WIN32
 
 # include <windows.h>
-# define pthread_t				HANDLE
-# define pthread_create(t,u,f,d) *(t)=CreateThread(NULL,0,f,d,0,NULL)
-# define pthread_join(t,s)		{ WaitForSingleObject(t,INFINITE); \
+
+# ifdef HAVE_PTHREAD
+#  include <pthread.h>
+# else
+#  define pthread_t				HANDLE
+#  define pthread_create(t,u,f,d) *(t)=CreateThread(NULL,0,f,d,0,NULL)
+#  define pthread_join(t,s)		{ WaitForSingleObject(t,INFINITE); \
 									CloseHandle(t); } 
-# define sched_yield()			Sleep(0);
+#  define sched_yield()			Sleep(0);
 static __inline int pthread_num_processors_np() 
 {
 	DWORD p_aff, s_aff, r = 0;
@@ -44,6 +48,7 @@
 	for(; p_aff != 0; p_aff>>=1) r += p_aff&1;
 	return r;
 }
+#endif
 
 #elif defined(SYS_BEOS)
 
diff -urN xvidcore.orig/src/utils/x86_asm/cpuid.asm xvidcore/src/utils/x86_asm/cpuid.asm
--- xvidcore.orig/src/utils/x86_asm/cpuid.asm	Tue Dec  2 23:00:09 2008
+++ xvidcore/src/utils/x86_asm/cpuid.asm	Wed Feb 11 14:03:55 2009
@@ -61,6 +61,7 @@
 
 vendorAMD:
 		db "AuthenticAMD"
+ALIGN 16
 
 ;=============================================================================
 ; Macros
