]> code.delx.au - pulseaudio/commitdiff
smoother: avoid losing precision
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 6 Sep 2010 13:22:26 +0000 (15:22 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 7 Sep 2010 10:07:24 +0000 (12:07 +0200)
Avoid losing precision by subtracting uint64 values before converting them to
doubles.

src/pulsecore/time-smoother.c

index 1371ad562ef51f058cdc27434938ad051c284f91..0696cabc2c6ef4ce22c388b7ccded3dd791dbcb1 100644 (file)
@@ -320,10 +320,8 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
 
         calc_abc(s);
 
-        tx = (double) x;
-
         /* Move to origin */
-        tx -= (double) s->ex;
+        tx = (double) (x - s->ex);
 
         /* Horner scheme */
         ty = (tx * (s->c + tx * (s->b + tx * s->a)));