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

Víctor Paesa wzrlpy
Sun Oct 21 10:49:43 CEST 2007


Hi,

M?ns Rullg?rd said:
> "V?ctor Paesa" writes:
>
>>>> +    asm
>>>> +    ("fistpll %0"
>>>> +    : "=m" (llrintres) : "t" (x) : "st");
>>>
>>> The formatting of this asm() statement is incredibly ugly.
>>
>> I must confess I am an asm-illiterate, for me every asm is ugly. I
>> made another (mostly blind) attempt.
>
> If you don't know assembler, how do you know this code is correct?

Well, given the level of assembler familiarity of reviewers, and that it
is a one instruction statement, a non working code would have got an
objection to its correctness in the first review mail. And it had not.
Also http://www.google.com/search?q=fistpll+llrint

>> +    asm(
>> +        "fistpll %0" : "=m" (llrintres) : "t" (x) : "st"
>> +    );
>
> I, and I think most others, prefer writing it like this:
>
>     asm("fistpll %0" : "=m" (llrintres) : "t" (x) : "st");

Wow, almost right ;-) Patch updated.

Regards,
V?ctor

$ 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
@@ -1499,6 +1500,7 @@
 check_func gethrtime
 check_func getrusage
 check_func inet_aton
+check_func llrint
 check_func memalign
 check_func mkstemp
 check_func2 windows.h GetProcessTimes
Index: libavutil/internal.h
===================================================================
--- libavutil/internal.h        (revision 10822)
+++ libavutil/internal.h        (working copy)
@@ -278,4 +278,15 @@
 }
 #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