diff --git a/build/win32/libx264.dsp b/build/win32/libx264.dsp
index 4885b48..0ff587c 100644
--- a/build/win32/libx264.dsp
+++ b/build/win32/libx264.dsp
@@ -25,7 +25,7 @@ CFG=libx264 - Win32 Debug
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir "Release"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /G6 /W3 /GX /O2 /Ob2 /I "./common" /I "./encode" /I "./decode" /I "../../extras" /I "../.." /D "NDEBUG" /D "_LIB" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "ARCH_X86" /D "HAVE_STDINT_H" /FD /c
+# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /Ob2 /I "./common" /I "./encode" /I "./decode" /I "../../extras" /I "../.." /D "NDEBUG" /D "_LIB" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "ARCH_X86" /D "HAVE_STDINT_H" /FD /c
 # SUBTRACT CPP /YX
 # ADD BASE RSC /l 0x804 /d "NDEBUG"
 # ADD RSC /l 0x804 /d "NDEBUG"
@@ -65,8 +65,7 @@ LIB32=link.exe -lib
 # PROP Intermediate_Dir "Debug"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "./common" /I "./encode" /I "./decode" /I "../../extras" /I "../.." /D "_DEBUG" /D "_LIB" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "ARCH_X86" /D "HAVE_STDINT_H" /FD /GZ /c
-# SUBTRACT CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "./common" /I "./encode" /I "./decode" /I "../../extras" /I "../.." /D "_DEBUG" /D "_LIB" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "ARCH_X86" /D "HAVE_STDINT_H" /FD /GZ /c
 # ADD BASE RSC /l 0x804 /d "_DEBUG"
 # ADD RSC /l 0x804 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -308,34 +307,36 @@ SOURCE=..\..\common\set.h
 SOURCE=..\..\common\vlc.h
 # End Source File
 # End Group
-# Begin Group "I386"
+# Begin Group "x86"
 
 # PROP Default_Filter "*.h,*.c,*-a.asm"
 # Begin Source File
 
-SOURCE="..\..\common\i386\cpu-a.asm"
+SOURCE="..\..\common\x86\cabac-a.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\cpu-a.asm
-InputName=cpu-a
+IntDir=.\obj/core_release
+InputPath=..\..\common\x86\cabac-a.asm
+InputName=cabac-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\cpu-a.asm
-InputName=cpu-a
+IntDir=.\obj/core_debug
+InputPath=..\..\common\x86\cabac-a.asm
+InputName=cabac-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -344,29 +345,31 @@ InputName=cpu-a
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\dct-a.asm"
+SOURCE="..\..\common\x86\cpu-32.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\dct-a.asm
-InputName=dct-a
+IntDir=.\obj/core_release
+InputPath=..\..\common\x86\cpu-32.asm
+InputName=cpu-32
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\dct-a.asm
-InputName=dct-a
+IntDir=.\obj/core_debug
+InputPath=..\..\common\x86\cpu-32.asm
+InputName=cpu-32
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -375,41 +378,112 @@ InputName=dct-a
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\dct-c.c"
+SOURCE="..\..\common\x86\dct-32.asm"
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
+# Begin Custom Build - Assembly $(InputPath)
+IntDir=.\obj/core_release
+InputPath=..\..\common\x86\dct-32.asm
+InputName=dct-32
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+# Begin Custom Build - Assembly $(InputPath)
+IntDir=.\obj/core_debug
+InputPath=..\..\common\x86\dct-32.asm
+InputName=dct-32
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ENDIF 
+
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\predict-c.c"
+SOURCE="..\..\common\x86\dct-a.asm"
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
+# Begin Custom Build - Assembly $(InputPath)
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\dct-a.asm"
+InputName=dct-a
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+# Begin Custom Build - Assembly $(InputPath)
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\dct-a.asm"
+InputName=dct-a
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ENDIF 
+
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\common\i386\dct.h
+SOURCE=..\..\common\x86\dct.h
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+
+!ENDIF 
+
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\mc-a.asm"
+SOURCE="..\..\common\x86\deblock-a.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\mc-a.asm
-InputName=mc-a
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\deblock-a.asm"
+InputName=deblock-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\mc-a.asm
-InputName=mc-a
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\deblock-a.asm"
+InputName=deblock-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -418,29 +492,31 @@ InputName=mc-a
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\pixel-a.asm"
+SOURCE="..\..\common\x86\mc-a.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\pixel-a.asm
-InputName=pixel-a
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\mc-a.asm"
+InputName=mc-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\pixel-a.asm
-InputName=pixel-a
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\mc-a.asm"
+InputName=mc-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -449,29 +525,31 @@ InputName=pixel-a
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\pixel-sse2.asm"
+SOURCE="..\..\common\x86\mc-a2.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\pixel-sse2.asm
-InputName=pixel-sse2
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\mc-a2.asm"
+InputName=mc-a2
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\pixel-sse2.asm
-InputName=pixel-sse2
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\mc-a2.asm"
+InputName=mc-a2
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -480,29 +558,31 @@ InputName=pixel-sse2
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\mc-a2.asm"
+SOURCE="..\..\common\x86\pixel-32.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\mc-a2.asm
-InputName=mc-a2
+IntDir=.\obj/core_release
+InputPath=..\..\common\x86\pixel-32.asm
+InputName=pixel-32
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\mc-a2.asm
-InputName=mc-a2
+IntDir=.\obj/core_debug
+InputPath=..\..\common\x86\pixel-32.asm
+InputName=pixel-32
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -511,29 +591,31 @@ InputName=mc-a2
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\predict-a.asm"
+SOURCE="..\..\common\x86\pixel-a.asm"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\predict-a.asm
-InputName=predict-a
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\pixel-a.asm"
+InputName=pixel-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\predict-a.asm
-InputName=predict-a
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\pixel-a.asm"
+InputName=pixel-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -542,29 +624,46 @@ InputName=predict-a
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\deblock-a.asm"
+SOURCE=..\..\common\x86\pixel.h
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE="..\..\common\x86\predict-a.asm"
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\deblock-a.asm
-InputName=deblock-a
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\predict-a.asm"
+InputName=predict-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\deblock-a.asm
-InputName=deblock-a
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\predict-a.asm"
+InputName=predict-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -573,29 +672,46 @@ InputName=deblock-a
 # End Source File
 # Begin Source File
 
-SOURCE="..\..\common\i386\quant-a.asm"
+SOURCE="..\..\common\x86\predict-c.c"
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
+# PROP Intermediate_Dir "obj/core_release"
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE="..\..\common\x86\quant-a.asm"
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Release
-InputPath=..\..\common\i386\quant-a.asm
+IntDir=.\obj/core_release
+InputPath="..\..\common\x86\quant-a.asm"
 InputName=quant-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
 !ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
 
+# PROP Intermediate_Dir "obj/core_debug"
 # Begin Custom Build - Assembly $(InputPath)
-IntDir=.\Debug
-InputPath=..\..\common\i386\quant-a.asm
+IntDir=.\obj/core_debug
+InputPath="..\..\common\x86\quant-a.asm"
 InputName=quant-a
 
 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
-	nasm -I..\..\common\i386\ -f win32 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
 
 # End Custom Build
 
@@ -604,7 +720,36 @@ InputName=quant-a
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\common\i386\pixel.h
+SOURCE="..\..\common\x86\sad-a.asm"
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
+# Begin Custom Build - Assembly $(InputPath)
+IntDir=.\obj/core_release
+InputPath=..\..\common\x86\sad-a.asm
+InputName=sad-a
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+# Begin Custom Build - Assembly $(InputPath)
+IntDir=.\obj/core_debug
+InputPath=..\..\common\x86\sad-a.asm
+InputName=sad-a
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+	nasm -I..\..\common\x86\ -f win32 -Xvc -O2 -DPREFIX -o $(IntDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ENDIF 
+
 # End Source File
 # End Group
 # Begin Source File
@@ -654,10 +799,6 @@ SOURCE=..\..\common\cpu.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\common\csp.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\..\common\dct.c
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
@@ -703,6 +844,21 @@ SOURCE=..\..\common\macroblock.c
 # End Source File
 # Begin Source File
 
+SOURCE="..\..\common\x86\mc-c.c"
+
+!IF  "$(CFG)" == "libx264 - Win32 Release"
+
+# PROP Intermediate_Dir "obj/core_release"
+
+!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"
+
+# PROP Intermediate_Dir "obj/core_debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\common\mc.c
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
@@ -763,7 +919,7 @@ SOURCE=..\..\common\predict.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\common\set.c
+SOURCE=..\..\common\quant.c
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
@@ -778,7 +934,7 @@ SOURCE=..\..\common\set.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\common\quant.c
+SOURCE=..\..\common\set.c
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
@@ -793,7 +949,7 @@ SOURCE=..\..\common\quant.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\common\i386\mc-c.c
+SOURCE=..\..\common\vlc.c
 
 !IF  "$(CFG)" == "libx264 - Win32 Release"
 
diff --git a/build/win32/x264.dsp b/build/win32/x264.dsp
index 22acf02..8e4c3f0 100644
--- a/build/win32/x264.dsp
+++ b/build/win32/x264.dsp
@@ -25,7 +25,7 @@ CFG=x264 - Win32 Debug
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "x264 - Win32 Release"
@@ -42,13 +42,13 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "./common" /I "./encode" /I "./decode" /I "../../extras" /I "../.." /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "HAVE_STDINT_H" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "./common" /I "./encode" /I "./decode" /I "../../extras" /I "../.." /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "HAVE_STDINT_H" /YX /FD /c
 # ADD BASE RSC /l 0x804 /d "NDEBUG"
 # ADD RSC /l 0x804 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"bin/x264.exe"
 
@@ -66,13 +66,13 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "../../common" /I "../../encode" /I "../../decode" /I "../../extras" /I "../.." /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "HAVE_STDINT_H" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../common" /I "../../encode" /I "../../decode" /I "../../extras" /I "../.." /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__X264__" /D "HAVE_MMX" /D "HAVE_STDINT_H" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x804 /d "_DEBUG"
 # ADD RSC /l 0x804 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"bin/x264.exe" /pdbtype:sept
 
@@ -84,27 +84,27 @@ LINK32=link.exe
 # Name "x264 - Win32 Debug"
 # Begin Source File
 
-SOURCE=..\..\x264.c
+SOURCE=..\..\matroska.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\x264.h
+SOURCE=..\..\matroska.h
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\matroska.c
+SOURCE=..\..\muxers.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\matroska.h
+SOURCE=..\..\muxers.h
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\muxers.c
+SOURCE=..\..\x264.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\muxers.h
+SOURCE=..\..\x264.h
 # End Source File
 # End Target
 # End Project
diff --git a/common/macroblock.c b/common/macroblock.c
index 1bf995f..aa5e2bd 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -1412,7 +1412,7 @@ void x264_macroblock_cache_save( x264_t *h )
                                                        h->mb.cache.intra4x4_pred_mode[x264_scan8[13] ], 0);
     }
     else
-        *(uint64_t*)intra4x4_pred_mode = I_PRED_4x4_DC * 0x0101010101010101ULL;
+        *(uint64_t*)intra4x4_pred_mode = I_PRED_4x4_DC * UINT64_C(0x0101010101010101);
 
     if( i_mb_type == I_PCM )
     {
diff --git a/common/osdep.h b/common/osdep.h
index e54c319..b899ee2 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -44,11 +44,15 @@
 #define strcasecmp stricmp
 #define strncasecmp strnicmp
 #define snprintf _snprintf
-#define fseek _fseeki64
-#define ftell _ftelli64
 #define isfinite _finite
 #define _CRT_SECURE_NO_DEPRECATE
 #define X264_VERSION "" // no configure script for msvc
+
+#if _MSC_VER > 1300
+#   define fseek _fseeki64
+#   define ftell _ftelli64
+#endif
+
 #endif
 
 #ifdef SYS_OPENBSD
diff --git a/common/predict.c b/common/predict.c
index ccd523b..2135ccf 100644
--- a/common/predict.c
+++ b/common/predict.c
@@ -535,7 +535,7 @@ void x264_predict_8x8_filter( uint8_t *src, uint8_t edge[33], int i_neighbor, in
             }
             else
             {
-                *(uint64_t*)(edge+24) = SRC(7,-1) * 0x0101010101010101ULL;
+                *(uint64_t*)(edge+24) = SRC(7,-1) * UINT64_C(0x0101010101010101);
                 edge[32] = SRC(7,-1);
             }
         }
diff --git a/common/set.c b/common/set.c
index df1c2de..a938c6b 100644
--- a/common/set.c
+++ b/common/set.c
@@ -144,7 +144,7 @@ int x264_cqm_init( x264_t *h )
         for( i_list = 0; i_list < 4; i_list++ )
             for( i = 0; i < 16; i++ )
             {
-                h->unquant4_mf[i_list][q][i] = (1ULL << (q/6 + 15 + 8)) / quant4_mf[i_list][q%6][0][i];
+                h->unquant4_mf[i_list][q][i] = (UINT64_C(1) << (q/6 + 15 + 8)) / quant4_mf[i_list][q%6][0][i];
                 h->  quant4_mf[i_list][q][i] = j = SHIFT(quant4_mf[i_list][q%6][0][i], q/6 - 1);
                 // round to nearest, unless that would cause the deadzone to be negative
                 h->quant4_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j );
@@ -155,7 +155,7 @@ int x264_cqm_init( x264_t *h )
         for( i_list = 0; i_list < 2; i_list++ )
             for( i = 0; i < 64; i++ )
             {
-                h->unquant8_mf[i_list][q][i] = (1ULL << (q/6 + 16 + 8)) / quant8_mf[i_list][q%6][0][i];
+                h->unquant8_mf[i_list][q][i] = (UINT64_C(1) << (q/6 + 16 + 8)) / quant8_mf[i_list][q%6][0][i];
                 h->  quant8_mf[i_list][q][i] = j = SHIFT(quant8_mf[i_list][q%6][0][i], q/6);
                 h->quant8_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j );
                 if( j > 0xffff && q > max_qp_err )
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 10f4df0..1b6bfa2 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -34,6 +34,10 @@
 #include "common/cpu.h"
 #include "ratecontrol.h"
 
+#ifdef _MSC_VER
+#define logf(x)     ((float)log(x))
+#endif
+
 typedef struct
 {
     int pict_type;
diff --git a/encoder/set.c b/encoder/set.c
index 1008551..4539ae4 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -526,12 +526,17 @@ const x264_level_t x264_levels[] =
     { 0 }
 };
 
+#ifndef _MSC_VER
 #define ERROR(...)\
 {\
     if( verbose )\
         x264_log( h, X264_LOG_WARNING, __VA_ARGS__ );\
     ret = 1;\
 }
+#else
+#define ERROR() {}
+#pragma warning(disable:4002)   /* disable warning "too many actual parameters for macro" */
+#endif
 
 int x264_validate_levels( x264_t *h, int verbose )
 {
diff --git a/extras/stdint.h b/extras/stdint.h
index 92dfa88..bd20b3a 100644
--- a/extras/stdint.h
+++ b/extras/stdint.h
@@ -83,6 +83,13 @@ typedef unsigned __int64   uintmax_t;
 #define UINT32_MAX 0xffffffff  /* 4294967295U */
 #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
 
+#ifdef _MSC_VER
+#   undef INT64_MAX
+#   undef UINT64_MAX
+#   define INT64_MAX 9223372036854775807
+#   define UINT64_MAX 0xffffffffffffffff  /* 18446744073709551615ULL */
+#endif
+
 /* 7.18.2.2  Limits of minimum-width integer types */
 #define INT_LEAST8_MIN INT8_MIN
 #define INT_LEAST16_MIN INT16_MIN
diff --git a/matroska.c b/matroska.c
index b3029c6..56e09f5 100644
--- a/matroska.c
+++ b/matroska.c
@@ -416,7 +416,7 @@ int	  mk_flushFrame(mk_Writer *w) {
     return 0;
 
   delta = w->frame_tc/w->timescale - w->cluster_tc_scaled;
-  if (delta > 32767ll || delta < -32768ll)
+  if (delta > INT64_C(32767) || delta < INT64_C(-32768))
     CHECK(mk_closeCluster(w));
 
   if (w->cluster == NULL) {
