[Pixman] [PATCH 08/15] pixman-filter: Don't recurse unnecessarily.
Oded Gabbay
oded.gabbay at gmail.com
Wed Dec 23 01:58:41 PST 2015
On Tue, Dec 22, 2015 at 9:38 PM, Bill Spitzak <spitzak at gmail.com> wrote:
> On Tue, Dec 22, 2015 at 1:38 AM, Oded Gabbay <oded.gabbay at gmail.com> wrote:
>>
>> On Sat, Dec 12, 2015 at 8:06 PM, <spitzak at gmail.com> wrote:
>> > From: Bill Spitzak <spitzak at gmail.com>
>> >
>> > Only LINEAR is not differentiable at zero,
>>
>> I'm sorry, I don't understand this sentence. Could you please give me
>> a more detailed explanation + reference ?
>
>
> All the other filter functions have a continuous first derivative over their
> entire range.
>
> The LINEAR function is a triangle and the first derivative changes from +1
> to -1 at 0.0.
ok, so add it to the commit msg and this patch is:
Acked-by: Oded Gabbay <oded.gabbay at gmail.com>
>
> I believe Søren was concerned that the Simpson's integration would not work
> at this point. He solved this by splitting the integral into 2 or 3 at the
> zeros, so the integration is not done across these points.
>
> I figured I should keep this, though I suspect the error is really invisibly
> tiny. Apparently Simpsons integration will have some error for any function
> where the third derivative is not constant, which is true for all the
> filters here except box. But the error is really really tiny and was being
> ignored for all the other filters, and it may be ok to ignore it here too.
>
>> Thanks,
>>
>> Oded
>>
>> > so only do the recursive split of the integral for it.
>> > ---
>> > pixman/pixman-filter.c | 34 +++++++++++++++++-----------------
>> > 1 file changed, 17 insertions(+), 17 deletions(-)
>> >
>> > diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
>> > index 782f73d..0cd4a68 100644
>> > --- a/pixman/pixman-filter.c
>> > +++ b/pixman/pixman-filter.c
>> > @@ -160,38 +160,38 @@ integral (pixman_kernel_t reconstruct, double x1,
>> > pixman_kernel_t sample, double scale, double x2,
>> > double width)
>> > {
>> > + if (reconstruct == PIXMAN_KERNEL_IMPULSE)
>> > + {
>> > + assert (width == 0.0);
>> > + return filters[sample].func (x2 / scale);
>> > + }
>> > + else if (reconstruct == PIXMAN_KERNEL_BOX && sample ==
>> > PIXMAN_KERNEL_BOX)
>> > + {
>> > + assert (width <= 1.0);
>> > + return width;
>> > + }
>> > + else if (sample == PIXMAN_KERNEL_IMPULSE)
>> > + {
>> > + assert (width == 0.0);
>> > + return filters[reconstruct].func (x1);
>> > + }
>> > /* If the integration interval crosses zero, break it into
>> > * two separate integrals. This ensures that filters such
>> > * as LINEAR that are not differentiable at 0 will still
>> > * integrate properly.
>> > */
>> > - if (x1 < 0 && x1 + width > 0)
>> > + else if (reconstruct == PIXMAN_KERNEL_LINEAR && x1 < 0 && x1 +
>> > width > 0)
>> > {
>> > return
>> > integral (reconstruct, x1, sample, scale, x2, - x1) +
>> > integral (reconstruct, 0, sample, scale, x2 - x1, width +
>> > x1);
>> > }
>> > - else if (x2 < 0 && x2 + width > 0)
>> > + else if (sample == PIXMAN_KERNEL_LINEAR && x2 < 0 && x2 + width >
>> > 0)
>> > {
>> > return
>> > integral (reconstruct, x1, sample, scale, x2, - x2) +
>> > integral (reconstruct, x1 - x2, sample, scale, 0, width +
>> > x2);
>> > }
>> > - else if (reconstruct == PIXMAN_KERNEL_IMPULSE)
>> > - {
>> > - assert (width == 0.0);
>> > - return filters[sample].func (x2 / scale);
>> > - }
>> > - else if (reconstruct == PIXMAN_KERNEL_BOX && sample ==
>> > PIXMAN_KERNEL_BOX)
>> > - {
>> > - assert (width <= 1.0);
>> > - return width;
>> > - }
>> > - else if (sample == PIXMAN_KERNEL_IMPULSE)
>> > - {
>> > - assert (width == 0.0);
>> > - return filters[reconstruct].func (x1);
>> > - }
>> > else
>> > {
>> > /* Integration via Simpson's rule */
>> > --
>> > 1.9.1
>> >
>> > _______________________________________________
>> > Pixman mailing list
>> > Pixman at lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/pixman
>
>
More information about the Pixman
mailing list