[MPlayer-dev-eng] Changing the weight functions in the opengl bicubic scaler?

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jun 4 12:58:54 CEST 2011


On Fri, Jun 03, 2011 at 10:42:06PM +0200, Thomas Lindroth wrote:
> Mplayer's gl implementation use some kind of clever trick where 4 texel
> lookups can be replaced with 2 filtered texture lookups. It's described
> here http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter20.html
> (yes, the url is suppose to look like that). I don't understand how it
> works but it might make assumptions that are only true for a B-spline
> filter. Some help sorting this thing out would be appreciated.

Negative weights or weights > 1 can't be stored in textures and
using interpolation for parts of the calculation does not allow for
coefficients outside that range.
Thus this algorithm is only usable for purely smoothing up- or downscaling.
Modern GPUs probably have the power to do the "proper" variant, but it's
going to be a good bit of code, passing 16 coefficients via textures is
not really sensible, so you'd have to calculated the 16 coefficients,
then do 16 texture lookups and the sum it all together.

> While digging I also found a bug in the scaler. The right and bottom
> border pixels are always black.
> gl: http://oi55.tinypic.com/2znn5th.jpg
> sws with B=1,C=0: http://oi54.tinypic.com/282hwlv.jpg

That is because pixels outside the picture are considered to be black.
Changing it would be possible at the cost of actually passing the size
of the image and adding 8 coordinate clamps.
Haven't really considered it worth it so far.
Another possibility is considering the pixels outside to be gray, but
that tends to look worse in most cases.


More information about the MPlayer-dev-eng mailing list