diff --git a/configure b/configure
index 7c1a54ed5a01a07c6d5b6d47f9abb6c252cc3567..862f851141a02816224e83f38b990e160da09f43 100755
--- a/configure
+++ b/configure
@@ -3179,6 +3179,10 @@ else
 fi
 check_cflags -fno-math-errno
 check_cflags -fno-signed-zeros
+check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
+int x;
+EOF
+
 
 if enabled icc; then
     # Just warnings, no remarks
@@ -3469,6 +3473,7 @@ SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
 SAMPLES:=${samples:-\$(FATE_SAMPLES)}
+NOREDZONE_FLAGS=$noredzone_flags
 EOF
 
 get_version(){
diff --git a/libswscale/Makefile b/libswscale/Makefile
index 7f74677ceca063ea23ae1b5637c8d32e3a25ae66..942545d2824ab6589ef32d7d3bae6328d28499f6 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -21,6 +21,8 @@ OBJS-$(HAVE_MMX)           +=  x86/rgb2rgb.o            \
 OBJS-$(HAVE_VIS)           +=  sparc/yuv2rgb_vis.o
 OBJS-$(HAVE_YASM)          +=  x86/scale.o
 
+$(SUBDIR)x86/swscale_mmx.o: CFLAGS += $(NOREDZONE_FLAGS)
+
 TESTPROGS = colorspace swscale
 
 DIRS = bfin mlib ppc sparc x86
diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
index 6a143f7481f96010baed3b5fe202518a61815875..35839bed03d48d9ca42c8e13694c78a1d90f7246 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -1963,10 +1963,6 @@ static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
 #if defined(PIC)
     DECLARE_ALIGNED(8, uint64_t, ebxsave);
 #endif
-    // HACK: gcc 4.6 no longer decrements esp,
-    // use this to make it reserve space for the call
-    // return address
-    void *dummy;
 
     __asm__ volatile(
 #if defined(PIC)
@@ -2018,7 +2014,6 @@ static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
 #if defined(PIC)
           ,"m" (ebxsave)
 #endif
-          ,"m" (dummy)
         : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
 #if !defined(PIC)
          ,"%"REG_b
@@ -2040,10 +2035,6 @@ static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
 #if defined(PIC)
     DECLARE_ALIGNED(8, uint64_t, ebxsave);
 #endif
-    // HACK: gcc 4.6 no longer decrements esp,
-    // use this to make it reserve space for the call
-    // return address
-    void *dummy;
 
     __asm__ volatile(
 #if defined(PIC)
@@ -2083,7 +2074,6 @@ static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
 #if defined(PIC)
           ,"m" (ebxsave)
 #endif
-          ,"m" (dummy)
         : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
 #if !defined(PIC)
          ,"%"REG_b