[cairo] Tentative patch for downscaling in Cairo

Chris Wilson chris at chris-wilson.co.uk
Tue Jun 4 04:19:49 PDT 2013


On Sun, Mar 31, 2013 at 05:03:36AM +0200, Krzysztof Kosiński wrote:
> Hello
> 
> I had a look at how complex would it be to add correct downscaling to
> Cairo now that Pixman supports convolution filters. It turns out it
> this is rather easy. Here is an initial, minimal attempt. It uses
> convolution filters only if the image is being downscaled by more than
> half a pixel in at least one dimension.

Looks very nice. My plan at the moment is to finish a bugfix 1.12
release, then start on 1.14 to add some new API. This improvement would
be better in a major release, so I'll add it then.
 
> Some discussion:
> 
> 1. The sampling and reconstruction kernels are picked in a way that
> gives comparable quality when upscaling and downscaling. I paired box
> sampling with bilinear reconstruction and impulse (point) sampling
> with box reconstruction. This gives the expected result for NEAREST
> filter. BEST filter uses Lanczos3 for both kernels.

Do we need to use a reconstruction filter for NEAREST at all? Or maybe
differentiate between NEAREST and FAST in that case?
 
> 2. Subsampling bits are always set to 1, since this doesn't seem to
> affect quality at all.

Can of course be tuned later.
 
> 3. I am not sure whether this code works correctly for matrices with a
> skew component. It should be OK for any combination of scale, rotation
> and translation.

Should be okay for all affine transformations, I believe. We are missing
a skew test though.
 
> 4. This patch causes new failures in the test suite:
[snip]
> - large-source-roi: this test attempts to downscale an image which is
> 30000 pixels wide down to 7 pixels. The filter parameters seem to be
> created correctly, but they might trigger an overflow somewhere in the
> convolution code; the output rectangle is white instead of red, as if
> nothing was drawn.
Only one worrisome failure near the limits, not too bad.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list