[FFmpeg-cvslog] r21922 - trunk/libavutil/internal.h

Michael Niedermayer michaelni
Sat Feb 20 18:39:01 CET 2010


On Sat, Feb 20, 2010 at 05:02:48PM +0100, mru wrote:
> Author: mru
> Date: Sat Feb 20 17:02:48 2010
> New Revision: 21922
> 
> Log:
> Add casts to correct return type in macros for missing libm funcs
> 
> Modified:
>    trunk/libavutil/internal.h
> 
> Modified: trunk/libavutil/internal.h
> ==============================================================================
> --- trunk/libavutil/internal.h	Sat Feb 20 16:39:27 2010	(r21921)
> +++ trunk/libavutil/internal.h	Sat Feb 20 17:02:48 2010	(r21922)
> @@ -221,12 +221,12 @@ static inline av_const unsigned int ff_s
>  
>  #if !HAVE_EXP2F
>  #undef exp2f
> -#define exp2f(x) exp2(x)
> +#define exp2f(x) ((float)exp2(x))
>  #endif /* HAVE_EXP2F */
>  
>  #if !HAVE_LLRINT
>  #undef llrint
> -#define llrint(x) rint(x)
> +#define llrint(x) ((long long)rint(x))
>  #endif /* HAVE_LLRINT */
>  
>  #if !HAVE_LOG2
> @@ -236,7 +236,7 @@ static inline av_const unsigned int ff_s
>  
>  #if !HAVE_LOG2F
>  #undef log2f
> -#define log2f(x) log2(x)
> +#define log2f(x) ((float)log2(x))
>  #endif /* HAVE_LOG2F */

This causes a serious speedloss

double func(double d){
    return log2(d);
}

double func2(double d){
    return (float)log2(d);
}

with gcc (Debian 4.3.3-14) 4.3.3
results in:

func2:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        fldl    8(%ebp)
        fstpl   (%esp)
        call    log2
        fstps   -4(%ebp)
        flds    -4(%ebp)
        leave
        ret
func:
        pushl   %ebp
        movl    %esp, %ebp
        popl    %ebp
        jmp     log2


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20100220/5f135e63/attachment-0001.pgp>



More information about the ffmpeg-cvslog mailing list