[cairo] Concerns about using filters for downscaling
Owen Taylor
otaylor at redhat.com
Tue Mar 25 13:39:44 PDT 2014
On Mon, 2014-03-24 at 17:04 -0400, Owen Taylor wrote:
> > Owen Taylor <otaylor at redhat.com> writes:
> I took a stab at implementing a pretty straightforward port of the
> pixman-fast-path.c code to SSE2 - attached. I was able to get roughly
> a 2x speedup:
>
> > scale NEAREST BILINEAR GOOD BEST
> > ---- ------ -------- ----- ------
> > 1.1 656 2860 15163 149147
> > 1.5 350 1574 7918 108820
> > 1.9 220 965 7176 89324
> > 2.0 51 873 6397 95665
> > 2.5 34 114 4331 71975
> > 3.0 25 392 4074 67211
> > 3.5 66 290 3101 60168
> > 4.0 15 223 3135 59207
> > 4.5 12 37 2524 58586
> > 5.0 34 143 2643 56798
>
> scale NEAREST BILINEAR GOOD BEST MIPMAP
> ----- ------- -------- ---- ---- ------
> 1.1 478 3073 10267 74341 3022
> 1.5 264 1662 5549 53639 1680
> 1.9 171 1053 3467 50495 1058
> 2.0 60 943 3080 46139 151
> 2.5 40 115 2709 40281 729
> 3.0 29 431 1907 37104 556
> 3.5 55 324 1878 35542 439
> 4.0 19 244 1515 34569 173
> 4.5 16 39 1451 33327 364
> 5.0 30 157 1219 33239 330
>
> I've added another column which is an implementation (in my test
> program) of the technique of creating a temporary power-of-two scaled
> down image and bilinear-filtering from that. As you can see, even
> tossing away the mipmaps, the performance is much better than with
> convolution - even though either way we have to touch all the pixels in
> the source image, it's much easier to write fast, cache friendly
> average-of-four-pixels code, then convolution code.
The other consideration is things look actually like, of course.
I've put up samples of the different downscaling methods on different
images at:
http://fishsoup.net/misc/downscaling/samples.html
Warning, large PNGs! (using JPEG would defeat the point of trying to look
for subtle differences in the fine details.)
The images are mostly chosen to be somewhat to very difficult to downscale.
I've also included trilinear scaling since it's come up a couple of times
in the discussion.
- Owen
More information about the cairo
mailing list