[Ffmpeg-devel] Apropos LRINTF

Michel Bardiaux mbardiaux
Mon Oct 16 13:52:03 CEST 2006

No, this is not "again a thread about lrintf missing"!

Because I need an ultra-super-hyper-optimized rounding function for some 
app (specifically, julian date calculations), I had a look at how lrintf 
was supplied and used in ffmpeg. Some things had me puzzled.

The man page for lrintf says "These  functions round their argument to 
the nearest integer value, using the current rounding direction". The 
inline for mingw uses fistpl, which will do just that. Then why is there 
a comment " better than nothing implementation."?

Also, this implies that the "current rounding direction" is set, but 
there is no call (nor stub) to fesetround anywhere. It looks like the 
intent is rounding towards zero, but then why is the naive C 
implementation "(int)(x + (x < 0 ? -0.5 : 0.5)" branded as incorrect?

Why is lrintf used at all, instead of round or trunc? An application 
using lavc could call fesetround and completely mess up the codecs, no?

Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles

More information about the ffmpeg-devel mailing list