vo_vdpau: Allocate one large surface for EOSD content
commitd9cea6a98b1f0879c163e198061f1380c5ee8432
authorUoti Urpala <uau@glyph.nonexistent.invalid>
Wed, 2 Sep 2009 17:21:24 +0000 (2 20:21 +0300)
committerUoti Urpala <uau@glyph.nonexistent.invalid>
Sat, 5 Sep 2009 03:25:47 +0000 (5 06:25 +0300)
treedbc78044c5211f09c603c116aa1cb495172dd0d0
parent575331d73cf3a992c779cca7f90ae4810d17dcfc
vo_vdpau: Allocate one large surface for EOSD content

Create a single large bitmap surface for EOSD objects and pack all the
bitmap rectangles inside that. The old code created a separate bitmap
surface for every bitmap and then resized the cached surfaces when
drawing later frames. The number of surfaces could be large (at least
about 2000 for one sample subtitle script) so this was very
inefficient. The old code also used a very simple strategy for pairing
existing surfaces to new bitmaps; it could resize tiny surfaces to
hold large glyphs while using existing large surfaces to hold tiny
glyphs and as a result allocate arbitrarily much more total surface
area than was necessary.

The new code only supports using a single surface, freeing it and
allocating a larger one if necessary. It would be possible to support
multiple surfaces in case of hitting the maximum bitmap surface size,
but I'll wait to see if that is actually needed before implementing
it. NVIDIA seems to support bitmap surface sizes up to 8192x8192, so
it would take either a really pathological subtitle script rendered at
a high resolution or an implementation with lower limits before
multiple surfaces would be necessary.

The packing algorithm should successfully pack the bitmaps into a
surface of size w*h as long as the total area of the bitmaps does not
exceed 16/17 (w-max_bitmap_width)*(h-max_bitmap_height), so there
should be no totally catastrophic failure cases. The 16/17 factor
comes from approximate sorting used in the algorithm. On average
performance should be better than this minimum guaranteed level.
TOOLS/vdpau_functions.py
libvo/vdpau_template.c
libvo/vo_vdpau.c