[Pixman] [PATCH v10 05/15] pixman-filter: Consistency in arg names to integral ()
spitzak at gmail.com
spitzak at gmail.com
Mon Feb 1 22:28:10 PST 2016
From: Bill Spitzak <spitzak at gmail.com>
Rename kernel1/2 to reconstruct/sample to match the other functions.
Rename "scale" to "size" to avoid confusion with the scale being applied
to the image, which is the reciprocol of this value.
v10: Renamed "scale" to "size"
Signed-off-by: Bill Spitzak <spitzak at gmail.com>
Reviewed-by: Oded Gabbay <oded.gabbay at gmail.com>
---
pixman/pixman-filter.c | 48 +++++++++++++++++++++++-------------------------
pixman/pixman.h | 6 +++---
2 files changed, 26 insertions(+), 28 deletions(-)
diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index 11c8548..acfb110 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -147,8 +147,8 @@ static const filter_info_t filters[] =
{ PIXMAN_KERNEL_LANCZOS3_STRETCHED, nice_kernel, 8.0 },
};
-/* This function scales @kernel2 by @scale, then
- * aligns @x1 in @kernel1 with @x2 in @kernel2 and
+/* This function scales the @sample filter by @size, then
+ * aligns @x1 in @reconstruct with @x2 in @sample and
* and integrates the product of the kernels across @width.
*
* This function assumes that the intervals are within
@@ -156,8 +156,8 @@ static const filter_info_t filters[] =
* try to integrate a linear kernel ouside of [-1:1]
*/
static double
-integral (pixman_kernel_t kernel1, double x1,
- pixman_kernel_t kernel2, double scale, double x2,
+integral (pixman_kernel_t reconstruct, double x1,
+ pixman_kernel_t sample, double size, double x2,
double width)
{
/* If the integration interval crosses zero, break it into
@@ -168,31 +168,31 @@ integral (pixman_kernel_t kernel1, double x1,
if (x1 < 0 && x1 + width > 0)
{
return
- integral (kernel1, x1, kernel2, scale, x2, - x1) +
- integral (kernel1, 0, kernel2, scale, x2 - x1, width + x1);
+ integral (reconstruct, x1, sample, size, x2, - x1) +
+ integral (reconstruct, 0, sample, size, x2 - x1, width + x1);
}
else if (x2 < 0 && x2 + width > 0)
{
return
- integral (kernel1, x1, kernel2, scale, x2, - x2) +
- integral (kernel1, x1 - x2, kernel2, scale, 0, width + x2);
+ integral (reconstruct, x1, sample, size, x2, - x2) +
+ integral (reconstruct, x1 - x2, sample, size, 0, width + x2);
}
- else if (kernel1 == PIXMAN_KERNEL_IMPULSE)
+ else if (reconstruct == PIXMAN_KERNEL_IMPULSE)
{
assert (width == 0.0);
- return filters[kernel2].func (x2 * scale);
+ return filters[sample].func (x2 / size);
}
- else if (kernel2 == PIXMAN_KERNEL_IMPULSE)
+ else if (sample == PIXMAN_KERNEL_IMPULSE)
{
assert (width == 0.0);
- return filters[kernel1].func (x1);
+ return filters[reconstruct].func (x1);
}
else
{
/* Integration via Simpson's rule */
#define N_SEGMENTS 128
#define SAMPLE(a1, a2) \
- (filters[kernel1].func ((a1)) * filters[kernel2].func ((a2) * scale))
+ (filters[reconstruct].func ((a1)) * filters[sample].func ((a2) / size))
double s = 0.0;
double h = width / (double)N_SEGMENTS;
@@ -221,16 +221,14 @@ static pixman_fixed_t *
create_1d_filter (int *width,
pixman_kernel_t reconstruct,
pixman_kernel_t sample,
- double scale,
+ double size,
int n_phases)
{
pixman_fixed_t *params, *p;
double step;
- double size;
int i;
- size = scale * filters[sample].width + filters[reconstruct].width;
- *width = ceil (size);
+ *width = ceil (size * filters[sample].width + filters[reconstruct].width);
p = params = malloc (*width * n_phases * sizeof (pixman_fixed_t));
if (!params)
@@ -259,8 +257,8 @@ create_1d_filter (int *width,
double pos = x + 0.5 - frac;
double rlow = - filters[reconstruct].width / 2.0;
double rhigh = rlow + filters[reconstruct].width;
- double slow = pos - scale * filters[sample].width / 2.0;
- double shigh = slow + scale * filters[sample].width;
+ double slow = pos - size * filters[sample].width / 2.0;
+ double shigh = slow + size * filters[sample].width;
double c = 0.0;
double ilow, ihigh;
@@ -270,7 +268,7 @@ create_1d_filter (int *width,
ihigh = MIN (shigh, rhigh);
c = integral (reconstruct, ilow,
- sample, 1.0 / scale, ilow - pos,
+ sample, size, ilow - pos,
ihigh - ilow);
}
@@ -339,12 +337,12 @@ gnuplot_filter(int width, int samples, const pixman_fixed_t* p)
#endif
/* Create the parameter list for a SEPARABLE_CONVOLUTION filter
- * with the given kernels and scale parameters
+ * with the given kernels and size parameters
*/
PIXMAN_EXPORT pixman_fixed_t *
pixman_filter_create_separable_convolution (int *n_values,
- pixman_fixed_t scale_x,
- pixman_fixed_t scale_y,
+ pixman_fixed_t size_x,
+ pixman_fixed_t size_y,
pixman_kernel_t reconstruct_x,
pixman_kernel_t reconstruct_y,
pixman_kernel_t sample_x,
@@ -352,8 +350,8 @@ pixman_filter_create_separable_convolution (int *n_values,
int subsample_bits_x,
int subsample_bits_y)
{
- double sx = fabs (pixman_fixed_to_double (scale_x));
- double sy = fabs (pixman_fixed_to_double (scale_y));
+ double sx = fabs (pixman_fixed_to_double (size_x));
+ double sy = fabs (pixman_fixed_to_double (size_y));
pixman_fixed_t *horz = NULL, *vert = NULL, *params = NULL;
int subsample_x, subsample_y;
int width, height;
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 509ba5e..b012a33 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -845,12 +845,12 @@ typedef enum
} pixman_kernel_t;
/* Create the parameter list for a SEPARABLE_CONVOLUTION filter
- * with the given kernels and scale parameters.
+ * with the given kernels and size parameters.
*/
pixman_fixed_t *
pixman_filter_create_separable_convolution (int *n_values,
- pixman_fixed_t scale_x,
- pixman_fixed_t scale_y,
+ pixman_fixed_t size_x,
+ pixman_fixed_t size_y,
pixman_kernel_t reconstruct_x,
pixman_kernel_t reconstruct_y,
pixman_kernel_t sample_x,
--
1.9.1
More information about the Pixman
mailing list