[Pixman] [PATCH pixman 02/11] pixman-filter: Correct Simpsons integration

Bill Spitzak spitzak at gmail.com
Wed Sep 10 19:01:56 PDT 2014


Samples are multiplied in a 1,4,2,4,2,4,1 pattern, previous version
did 1,2,4,4,4,2,1.

I also reduced the number of samples greatly as there is no
numerical difference with the filter functions.
---
 pixman/pixman-filter.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index b2bf53f..a9af72c 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -190,7 +190,7 @@ integral (pixman_kernel_t kernel1, double x1,
     else
     {
 	/* Integration via Simpson's rule */
-#define N_SEGMENTS 128
+#define N_SEGMENTS 16
 #define SAMPLE(a1, a2)							\
 	(filters[kernel1].func ((a1)) * filters[kernel2].func ((a2) * scale))
 	
@@ -204,11 +204,14 @@ integral (pixman_kernel_t kernel1, double x1,
 	{
 	    double a1 = x1 + h * i;
 	    double a2 = x2 + h * i;
+	    s += 4 * SAMPLE(a1, a2);
+	}
 
-	    s += 2 * SAMPLE (a1, a2);
-
-	    if (i >= 2 && i < N_SEGMENTS - 1)
-		s += 4 * SAMPLE (a1, a2);
+	for (i = 2; i < N_SEGMENTS; i += 2)
+	{
+	    double a1 = x1 + h * i;
+	    double a2 = x2 + h * i;
+	    s += 2 * SAMPLE(a1, a2);
 	}
 
 	s += SAMPLE (x1 + width, x2 + width);
-- 
1.7.9.5



More information about the Pixman mailing list