[Ffmpeg-devel] Re: Apropos LRINTF
Mon Oct 16 15:07:41 CEST 2006
Michel Bardiaux wrote:
> 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,
On 2nd thought, more like rounding towards nearest indeed. Where the
rounding direction enters into it is far from clear.
> 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?
Only round would do.
> An application
> using lavc could call fesetround and completely mess up the codecs, no?
T +32  2 790 29 41
F +32  2 790 29 02
E mailto:mbardiaux at mediaxim.be
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
More information about the ffmpeg-devel