--- configure.orig	2008-11-06 07:06:20.000000000 +0300
+++ configure	2008-11-06 10:31:48.000000000 +0300
@@ -78,6 +78,19 @@
   compile_check $TMPCPP $@ -lstdc++
 }
 
+yasm_check() {
+  echo >> "$TMPLOG"
+  cat "$TMPS" >> "$TMPLOG"
+  echo >> "$TMPLOG"
+  echo "$_yasm $YASMFLAGS -o $TMPEXE $TMPS $@" >> "$TMPLOG"
+  rm -f "$TMPEXE"
+  $_yasm $YASMFLAGS -o "$TMPEXE" "$TMPS" "$@" >> "$TMPLOG" 2>&1
+  TMP="$?"
+  echo >> "$TMPLOG"
+  echo >> "$TMPLOG"
+  return "$TMP"
+}
+
 tmp_run() {
   "$TMPEXE" >> "$TMPLOG" 2>&1
 }
@@ -408,6 +421,7 @@
   --cc=COMPILER          C compiler to build MPlayer [gcc]
   --host-cc=COMPILER     C compiler for tools needed while building [gcc]
   --as=ASSEMBLER         assembler to build MPlayer [as]
+  --yasm=YASM            yasm assembler to build MPlayer [yasm]
   --ar=AR                librarian to build MPlayer [ar]
   --ranlib=RANLIB        ranlib to build MPlayer [ranlib]
   --windres=WINDRES      windres to build MPlayer [windres]
@@ -493,6 +507,7 @@
 _ar=ar
 test "$CC" && _cc="$CC"
 _as=auto
+_yasm=yasm
 _runtime_cpudetection=no
 _cross_compile=auto
 _prefix="/usr/local"
@@ -790,6 +805,9 @@
   --as=*)
     _as=`echo $ac_option | cut -d '=' -f 2`
     ;;
+  --yasm=*)
+    _yasm=`echo $ac_option | cut -d '=' -f 2`
+    ;;
   --ar=*)
     _ar=`echo $ac_option | cut -d '=' -f 2`
     ;;
@@ -2385,6 +2403,43 @@
 fi
 echores $_asmalign_pot
 
+echocheck "yasm"
+if test -z "$YASMFLAGS" ; then
+    if darwin ; then
+        if x86_64 ; then
+            objformat="macho64"
+        else
+            objformat="macho"
+        fi
+    elif win32 ; then
+        objformat="win32"
+    else 
+        objformat="elf"
+    fi
+    # currently tested for Linux x86, x86_64
+    YASMFLAGS="-f $objformat"
+    x86_64 && YASMFLAGS="$YASMFLAGS -m amd64"
+    case "$objformat" in
+        elf) test $_debug && YASMFLAGS="$YASMFLAGS -g dwarf2" ;;
+        macho64)             YASMFLAGS="$YASMFLAGS -DPIC -DPREFIX" ;;
+        *)                   YASMFLAGS="$YASMFLAGS -DPREFIX"  ;;
+    esac
+else
+    _warn_CFLAGS=yes
+fi
+
+echo "pabsw xmm0, xmm0" > $TMPS
+yasm_check || _yasm=""
+if test $_yasm ; then
+  _def_yasm='#define HAVE_YASM 1'
+  _def_makefile_yasm='HAVE_YASM=yes'
+  # check for mmx in order to enable FFT_MMX
+  test "$_mmx" == "yes" && _def_makefile_fft_mmx="CONFIG_FFT_MMX=yes"
+  echores "$_yasm"
+else
+  _def_yasm='#undef HAVE_YASM'
+  echores "no"
+fi
 
 #FIXME: This should happen before the check for CFLAGS..
 if ppc && ( test "$_altivec" = yes || test "$_runtime_cpudetection" = yes ) ; then
@@ -7797,6 +7852,7 @@
 AR = $_ar
 CC = $_cc
 CXX = $_cc
+YASM = $_yasm
 HOST_CC = $_host_cc
 INSTALL = $_install
 INSTALLSTRIP = $_install_strip
@@ -7816,6 +7872,7 @@
 CFLAGS_STACKREALIGN = $cflags_stackrealign
 CFLAGS_SVGALIB_HELPER = $cflags_svgalib_helper
 CFLAGS_TREMOR_LOW = $cflags_tremor_low
+YASMFLAGS = $YASMFLAGS
 
 EXTRALIBS = $_extra_libs
 EXTRA_LIB = $_ld_extra $_ld_static $_ld_lm
@@ -7839,6 +7896,7 @@
 $_target_arch
 $_target_arch_x86
 `echo $_cpuexts | tr '[a-z] ' '[A-Z]\n' | sed 's/^/HAVE_/;s/$/=yes/'`
+$_def_makefile_yasm
 
 MENCODER = $_mencoder
 MPLAYER = $_mplayer
@@ -7983,6 +8041,7 @@
 
 # Some FFmpeg codecs depend on these. Enable them unconditionally for now.
 CONFIG_FFT=yes
+$_def_makefile_fft_mmx
 CONFIG_GOLOMB=yes
 CONFIG_MDCT=yes
 
@@ -8410,6 +8469,7 @@
 #else
 #define ENABLE_THREADS 0
 #endif
+$_def_yasm
 
 #define CONFIG_GPL 1
 #define ENABLE_SMALL 0
@@ -8538,7 +8598,8 @@
 if test "$_warn_CFLAGS" = yes; then
   cat <<EOF
 
-MPlayer compilation will use the CPPFLAGS/CFLAGS/LDFLAGS set by you, but:
+MPlayer compilation will use the CPPFLAGS/CFLAGS/LDFLAGS/YASMFLAGS set by you,
+but:
 
     *** ***  DO NOT REPORT BUGS IF IT DOES NOT COMPILE/WORK!  *** ***
 
--- common.mak.orig	2008-05-12 21:50:30.000000000 +0400
+++ common.mak	2008-11-06 09:57:20.000000000 +0300
@@ -80,6 +80,12 @@
 $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
 	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
 
+$(SUBDIR)i386/%.o: $(SUBDIR)i386/%.asm
+	$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
+
+$(SUBDIR)i386/%.d: $(SUBDIR)i386/%.asm
+	$(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
+
 clean::
 	rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
 	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
--- Makefile.orig	2008-11-06 07:06:27.000000000 +0300
+++ Makefile	2008-11-06 09:37:44.000000000 +0300
@@ -873,10 +873,10 @@
 	doxygen DOCS/tech/Doxyfile
 
 TAGS:
-	rm -f $@; ( find -name '*.[chS]' -print ) | xargs etags -a
+	rm -f $@; ( find -name '*.[chS]' -o -name '*.asm' -print ) | xargs etags -a
 
 tags:
-	rm -f $@; ( find -name '*.[chS]' -print ) | xargs ctags -a
+	rm -f $@; ( find -name '*.[chS]' -o -name '*.asm' -print ) | xargs ctags -a
 
 
 
