Alexey-Yakovenko/deadbeef — pull request #18 by Lithopsian (2014-07-21 21:08:12+00:00)
Title: Bilinear downscale tweaks, bicubic, data types.  Sanity check needed?

Bilinear downscaling has a major problem when the scale factor is an integer. For example scaling to half size simply throws away three quarters of the pixels and interpolates nothing. This is a simple fix to force interpolation in all cases. It looks like rounding, but is actually forcing the interpolation point up by half a pixel so that it never gets stuck exactly on the original pixels.

I've added an optional bicubic algorithm for comparison (compile with -DUSE_BICUBIC). The quality improvement is debatable, certainly not visible on a real size thumbnail image, slightly less blurry at the risk of clipping and ringing artefacts. The downside is that it runs an order of magnitude slower than bilinear, partly from sampling more pixels and partly because it relies on float arithmetic. Probably not worth it for the notifier plugin, but you can take a look if you want to check it out.

I'm wondering whether we should clamp the maximum value allowed for the notifier image size so that weird stuff can't happen with absurdly large values. The notifer daemons can't display large images anyway and sometimes crash. libjpeg fails gracefully when asked to create an image of about 10,000 pixels and libimlib2 just seems to chew memory until you get fed up, but libpng will try to generate images of any size and will succeed to a large degree because it outputs one line at a time. Currently there is a practical limit on the size of the scaled image set by what will fit in an int, after which overflows will happen, so entering a ridiculous number in the notify config causes behaviour that isn't clearly defined.