[FFmpeg-devel] [RFC] remove lrintf fallback implementation

Víctor Paesa wzrlpy
Sun Oct 21 00:19:33 CEST 2007


Hi,

Michael Niedermayer said:
> Hi
>
> On Tue, Oct 02, 2007 at 12:50:26PM +0200, V?ctor Paesa wrote:
>> AUTHOR said Michael Niedermayer
>> > Hi
>> >
>> > On Mon, Oct 01, 2007 at 04:23:46PM +0200, Reimar D?ffinger wrote:
>> >> Hello,
>> >> On Mon, Oct 01, 2007 at 03:55:18PM +0200, Diego Biurrun wrote:
>> [...]
>> >> > I'm not sure which systems still lack lrintf, but we refused to
>> add
>> >> a fallback implementation of llrint for Cygwin.  So IMO the lrintf
>> fallback should go.
>> >>
>> >> I don't disagree with removing it, but IIRC just nobody came up
>> with a correct llrint implementation...
>> >
>> > IIRC noone tried, there where just people from win32 who had no
>> brain or just wanted to troll and then there where the unix people
>> who just didnt care about cygwin
>> >
>> > maybe a simple (int64_t)rint() would work well enough i dunno and i
>> dont care about cygwin
>> > also theres (int64_t)rintl() as option and theres the one of just
>> not using any float&doubles but use integers instead to emulate it
>> >
>> > and one could use asm() as well
>>
>> Do you mean an asm() like this?
>>
>> Index: libavcodec/i386/mathops.h
>> ==================================================================>
>> --- libavcodec/i386/mathops.h   (revision 9441) +++
>> libavcodec/i386/mathops.h   (working copy)
>
> wrong file, its not an optimization

OK, moved to libavutil/internal.h, hope is the right place.


>> @@ -42,4 +42,15 @@
>>       asm ("imull %2\n\t" : "=A"(rt) : "a" (ra), "g" (rb));\
>>       rt; })
>>
>> +#ifndef llrint
>
> well i doubt that will work

Now I'm using the HAVE_LLRINT style.

>> +inline long long int llrint (double x)
>
> hmm shouldnt that be int64_t ?

The http://www.opengroup.org/onlinepubs/000095399/functions/llrint.html
says it is long long.

> also please see all the non static inline discussions

Now is static av_always_inline

Regards,
V?ctor

P.S.: Patch follows:

$ svn diff configure libavutil/internal.h
Index: configure
===================================================================
--- configure   (revision 10822)
+++ configure   (working copy)
@@ -701,6 +701,7 @@
     getrusage
     imlib2
     inet_aton
+    llrint
     lrintf
     machine_ioctl_bt848_h
     machine_ioctl_meteor_h
@@ -1501,6 +1502,7 @@
 check_func inet_aton
 check_func memalign
 check_func mkstemp
+check_func2 math.h llrint
 check_func2 windows.h GetProcessTimes

 check_header byteswap.h
Index: libavutil/internal.h
===================================================================
--- libavutil/internal.h        (revision 10822)
+++ libavutil/internal.h        (working copy)
@@ -278,4 +278,17 @@
 }
 #endif /* HAVE_LRINTF */

+#ifndef HAVE_LLRINT
+#if defined(ARCH_X86)
+static av_always_inline long long int llrint(double x)
+{
+    long long int llrintres;
+    asm
+    ("fistpll %0"
+    : "=m" (llrintres) : "t" (x) : "st");
+    return llrintres;
+}
+#endif /* defined(ARCH_X86) */
+#endif /* HAVE_LLRINT */
+
 #endif /* FFMPEG_INTERNAL_H */







More information about the ffmpeg-devel mailing list