Re: [Pixman] [PATCH 12/15] pixman-filter: Turn off subsampling when not necessary

2015-12-22 Thread Bill Spitzak
On Tue, Dec 22, 2015 at 4:44 AM, Oded Gabbay  wrote:

> On Sat, Dec 12, 2015 at 8:06 PM,   wrote:
> > From: Bill Spitzak 
> >
> > If sample is IMPULSE and reconstruct is BOX or IMPULSE the sub-pixel
> > position of the sample is not relevant, so only one subsample is needed.
> Why ?
> I mean why it is not relevant ? and why only one subsample is needed ?
>

Because all the filters for all the subsample positions are the same (a
single 1).

Actually though, the code is indicating this is happening by returning a
width of zero. But I think that is not necessary: if the filter width is 1,
and the filters are normalized so they sum to 1, then all the filters must
be equal and be a single 1. So I think the filter_width function can return
1 and the caller treats all values <= 1 as an indication that subsampling
is not needed.

Oded
> > ---
> >  pixman/pixman-filter.c | 12 +++-
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
> > index 64981cd..7e10108 100644
> > --- a/pixman/pixman-filter.c
> > +++ b/pixman/pixman-filter.c
> > @@ -230,6 +230,8 @@ filter_width (pixman_kernel_t reconstruct,
> >   pixman_kernel_t sample,
> >   double scale)
> >  {
> > +if (reconstruct == PIXMAN_KERNEL_BOX && sample ==
> PIXMAN_KERNEL_IMPULSE)
> > +   return 0;
> >  return ceil (scale * filters[sample].width +
> filters[reconstruct].width);
> >  }
> >
> > @@ -323,13 +325,13 @@ pixman_filter_create_separable_convolution (int
>  *n_values,
> >  int subsample_x, subsample_y;
> >  int width, height;
> >
> > -subsample_x = (1 << subsample_bits_x);
> > -subsample_y = (1 << subsample_bits_y);
> > -
> >  width = filter_width (reconstruct_x, sample_x, sx);
> > -if (width < 1) width = 1;
> > +if (width < 1) { width = 1; subsample_bits_x = 0; }
> >  height = filter_width (reconstruct_y, sample_y, sy);
> > -if (height < 1) height = 1;
> > +if (height < 1) { height = 1; subsample_bits_y = 0; }
> > +
> > +subsample_x = (1 << subsample_bits_x);
> > +subsample_y = (1 << subsample_bits_y);
> >
> >  *n_values = 4 + width * subsample_x + height * subsample_y;
> >
> > --
> > 1.9.1
> >
> > ___
> > Pixman mailing list
> > Pixman@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/pixman
>
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 12/15] pixman-filter: Turn off subsampling when not necessary

2015-12-22 Thread Oded Gabbay
On Sat, Dec 12, 2015 at 8:06 PM,   wrote:
> From: Bill Spitzak 
>
> If sample is IMPULSE and reconstruct is BOX or IMPULSE the sub-pixel
> position of the sample is not relevant, so only one subsample is needed.
Why ?
I mean why it is not relevant ? and why only one subsample is needed ?

Oded
> ---
>  pixman/pixman-filter.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
> index 64981cd..7e10108 100644
> --- a/pixman/pixman-filter.c
> +++ b/pixman/pixman-filter.c
> @@ -230,6 +230,8 @@ filter_width (pixman_kernel_t reconstruct,
>   pixman_kernel_t sample,
>   double scale)
>  {
> +if (reconstruct == PIXMAN_KERNEL_BOX && sample == PIXMAN_KERNEL_IMPULSE)
> +   return 0;
>  return ceil (scale * filters[sample].width + filters[reconstruct].width);
>  }
>
> @@ -323,13 +325,13 @@ pixman_filter_create_separable_convolution (int 
> *n_values,
>  int subsample_x, subsample_y;
>  int width, height;
>
> -subsample_x = (1 << subsample_bits_x);
> -subsample_y = (1 << subsample_bits_y);
> -
>  width = filter_width (reconstruct_x, sample_x, sx);
> -if (width < 1) width = 1;
> +if (width < 1) { width = 1; subsample_bits_x = 0; }
>  height = filter_width (reconstruct_y, sample_y, sy);
> -if (height < 1) height = 1;
> +if (height < 1) { height = 1; subsample_bits_y = 0; }
> +
> +subsample_x = (1 << subsample_bits_x);
> +subsample_y = (1 << subsample_bits_y);
>
>  *n_values = 4 + width * subsample_x + height * subsample_y;
>
> --
> 1.9.1
>
> ___
> Pixman mailing list
> Pixman@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pixman
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 12/15] pixman-filter: Turn off subsampling when not necessary

2015-12-12 Thread spitzak
From: Bill Spitzak 

If sample is IMPULSE and reconstruct is BOX or IMPULSE the sub-pixel
position of the sample is not relevant, so only one subsample is needed.
---
 pixman/pixman-filter.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index 64981cd..7e10108 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -230,6 +230,8 @@ filter_width (pixman_kernel_t reconstruct,
  pixman_kernel_t sample,
  double scale)
 {
+if (reconstruct == PIXMAN_KERNEL_BOX && sample == PIXMAN_KERNEL_IMPULSE)
+   return 0;
 return ceil (scale * filters[sample].width + filters[reconstruct].width);
 }
 
@@ -323,13 +325,13 @@ pixman_filter_create_separable_convolution (int   
  *n_values,
 int subsample_x, subsample_y;
 int width, height;
 
-subsample_x = (1 << subsample_bits_x);
-subsample_y = (1 << subsample_bits_y);
-
 width = filter_width (reconstruct_x, sample_x, sx);
-if (width < 1) width = 1;
+if (width < 1) { width = 1; subsample_bits_x = 0; }
 height = filter_width (reconstruct_y, sample_y, sy);
-if (height < 1) height = 1;
+if (height < 1) { height = 1; subsample_bits_y = 0; }
+
+subsample_x = (1 << subsample_bits_x);
+subsample_y = (1 << subsample_bits_y);
 
 *n_values = 4 + width * subsample_x + height * subsample_y;
 
-- 
1.9.1

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman