vo_gl: fix crash with ati-hack after 20256a8a64c9679bc9136bb
commit23fa8e99643e020c2f637e0da7e61b312176b966
authorwm4 <wm4@mplayer2.org>
Sun, 23 Oct 2011 22:08:57 +0000 (24 00:08 +0200)
committerUoti Urpala <uau@mplayer2.org>
Mon, 24 Oct 2011 05:36:13 +0000 (24 08:36 +0300)
tree8604ff367f57d1abe0a2bcedc89caee4e5a6df22
parent64f44ad316e963046c47d8eff5aead5a733974c8
vo_gl: fix crash with ati-hack after 20256a8a64c9679bc9136bb

Using the ati-hack and force-pbo suboptions (both can be enabled
automatically when particular ATI drivers are detected) could lead to
segfaults due to incorrect length calculation.

The problem is that width*((bpp+7)/8) == width*(bpp+7)/8 doesn't hold
true in general. The old code used bpp/8, because bpp was always
guaranteed to be divisible by 8. When commit 20256a8a64c96 fixed bugs
around 10 bit pixel formats, this assumption was broken, and resulted
in out of bounds memory accesses.

Additionally, the color values that were used to clear image borders
were incorrect and showed up as pink borders on the right/bottom sides
of the video when playing 10 bit content. Make the clear value
approximately correct; the borders are still filled with a single byte
value even though formats with 9-16 bits should be cleared with 2-byte
values with the low byte 0.

This commit also contains some other minor cleanups with no functional
changes.
libvo/vo_gl.c