[libav-devel] [PATCH] swscale: fix crash in fast_bilinear code when compiled with -mred-zone.

Måns Rullgård mans at mansr.com
Mon Nov 21 16:40:02 CET 2011


"Ronald S. Bultje" <rsbultje at gmail.com> writes:

> Fixes bug 78. I'd normally prefer a -mno-red-zone per-function
> attribute, but it seems gcc doesn't support that yet (it's not in the
> docs, and trying what should work extrapolating from other -m options
> generated compiler errors saying it didn't recognize that attribute).
>
> Sean confirmed it fixes the crash.
>
> Ronald
>
> From 9908ee0200ee3911452f10c6214d9ba0425b1da7 Mon Sep 17 00:00:00 2001
> From: Ronald S. Bultje <rsbultje at gmail.com>
> Date: Sun, 20 Nov 2011 15:54:15 -0800
> Subject: [PATCH] swscale: fix crash in fast_bilinear code when compiled with -mred-zone.
>
> ---
>  libswscale/x86/swscale_template.c |   48 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 48 insertions(+), 0 deletions(-)
>
> diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
> index 5e7df5c..c6d7e98 100644
> --- a/libswscale/x86/swscale_template.c
> +++ b/libswscale/x86/swscale_template.c
> @@ -1656,10 +1656,22 @@ static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
>  #if defined(PIC)
>      DECLARE_ALIGNED(8, uint64_t, ebxsave);
>  #endif
> +#if ARCH_X86_64
> +    DECLARE_ALIGNED(8, uint64_t, retsave);
> +#endif
>  
>      __asm__ volatile(
>  #if defined(PIC)
>          "mov               %%"REG_b", %5        \n\t"
> +#if ARCH_X86_64
> +        "mov               -8(%%rsp), %%"REG_a" \n\t"
> +        "mov               %%"REG_a", %6        \n\t"
> +#endif
> +#else
> +#if ARCH_X86_64
> +        "mov               -8(%%rsp), %%"REG_a" \n\t"
> +        "mov               %%"REG_a", %5        \n\t"
> +#endif
>  #endif
>          "pxor                  %%mm7, %%mm7     \n\t"
>          "mov                      %0, %%"REG_c" \n\t"

OMFG that is ugly, and it's not even correct.

Why is this using asm at all?  It's only calling a function a few times.
If some subtlety prevents it being written in C, do it in yasm instead.

-- 
Måns Rullgård
mans at mansr.com


More information about the libav-devel mailing list