osd: rewrite OSD rendering to use libass

Render OSD contents with libass. Delete the old rendering code which
used freetype/fontconfig directly and did text layout manually.
Compiling without libass enabled is still possible, but now there is
no OSD support whatsoever in this case.

The "--no-ass" switch still exists, and enables a mode where text is
drawn unstyled in a manner similar to old rendering. However, most of
the switches controlling old subtitle rendering which do not work with
libass rendering (such as --subalign, --subfont-blur etc) now do not
work in this mode either. Some of them could be supported by setting
suitable libass style attributes or other means.

Teletext rendering is not implemented in the new OSD rendering code. I
don't have any teletext sources for testing, and since teletext is
being phased out world-wide, the need for this is questionable.

Note that rendering is inefficient, mostly because the libass output
is converted into the strange mplayer OSD format to work with existing
VO drawing routines. This could be improved at a later point.

Also do some cleanup. Subtitle and OSD related variable declarations
were literally all over the place. Move them to sub.h and sub.c, which
were hoarding most of these declarations already (proper fix would be
to move them to the option struct though).

Based on original patches by wm4, with multiple fixes and
modifications.
osd: osd_font.h -> osd_font.pfb

Add osd_font.pfb, which is the actual font file that was previously
stored in osd_font.h. Use file2string.py to turn it back into a header
during the build process.

Fix file2string.py to work with the font file. The script was written
to be able to deal with binary files, but it had a bug corrupting some
data: e.g. the byte sequence 0x1 0x37 was printed as "\17" (0x1 was
escaped as "\1", and 0x37 was kept as a literal "7"), which would be
interpreted as the single character 0xF. Always pad octal literals to
length 3, which makes the escape sequences unambiguous.
stream/rtsp: remove live555, nemesi, native rtsp implementations

Libavformat has rtsp support that is being actively developed. Remove
alternative implementations. Remove no longer needed build system
support for C++ files.

Libnemesi is dead. Native is unmaintained and probably won't work
better than libavformat. Live555 could still work better for some
streams, but it'd likely need maintenance because of upstream API
changes, and building the interface for it causes extra problems as
it's the only part of the player using C++. For those reasons it was
already disabled by default in commit 3f659fd1766 ("configure: disable
live555 by default") earlier.
cleanup: remove pointless #defines

Remove the following #defines, which should never change in practice:

CONFIG_FAKE_MONO, OUTBURST, FAST_OSD, FAST_OSD_TABLE
The configure script hardcoded these to particular values in config.h.
They could only be changed by manually editing it. I don't think
anyone would want to.

X11_FULLSCREEN
This once did something, but became meaningless years ago and was now
always set to true if the files using it were compiled at all.
sd_lavc: use subtitle framework for former av_sub.c code

Change libavcodec subtitle decoding code (used for some bitmap
subtitle types) to use the same decoding framework as sd_ass. The
functionality that was previously in av_sub.c and was directly called
from mplayer.c is now in sd_lavc.c.
subs: libass: use a single persistent renderer for subtitles

To draw libass subtitles, the code used ASS_Renderer objects created
in vf_vo (VO rendering) or vf_ass. They were destroyed and recreated
together with the video filter  chain. Change the code to use a single
persistent renderer instance stored in the main osd_state struct.
Because libass seems to misbehave if fonts are changed while a
renderer exists (even if ass_set_fonts() is called on the renderer
afterwards), the renderer is recreated after adding embedded fonts.

The known benefits are simpler code and avoiding delays when switching
between timeline parts from different files (libass fontconfig
initialization, needed when creating a new renderer, can take a long
time in some cases; switching between files rebuilds the video filter
chain, and this required recreating the renderers). On the other hand,
I'm not sure whether this could cause inefficient bitmap caching in
libass; explicitly resetting the renderer in some cases could be
beneficial. The new code does not keep the distinction of separate
renderers for vsfilter munged aspect vs normal; this means that
changing subtitle tracks can lose cache for the previous track.

The new code always sets some libass parameters on each rendering
call, which were previously only set if they had potentially changed.
This should be harmless as libass itself has checks to see if the
values differ from previous ones.
subs: always use sub decoder framework for libass rendering

Remove subtitle selection code setting osd->ass_track directly and
vf_ass/vf_vo code rendering the track directly with libass. Instead,
do track selection and rendering with dec_sub.c functions.

Before, mpctx->set_of_ass_tracks[] contained bare libass tracks
generated from external subtitle files. For use with dec_sub.c, it now
contains struct sh_sub instances with decoder already initialized.

This commit breaks the sub_step command ('g' and 'y' keys) for
libass-rendered subtitles. It could be fixed, but it's so useless -
especially as with the existing implementation there's no practical
way to get subtitle delay back to normal after using it - that I
didn't bother.
vo: fix crash if all VO open fallback attempts fail

If init_best_video_out() code tried to open every available VO in turn
but all failed, the final code returning failure incorrectly used
free() instead of talloc_free(), triggering a crash. Fix. Also fix a
minor memory leak after failure to open user-specified VO(s) without
fallback, and remove no longer necessary vo_subdevice hacks.
VO: don't keep a persistent X11 connection across VOs

The player kept a single persistent instance of X11-related state
shared by all X-using VOs. This has no obvious benefit; even if a new
VO instance initializes a new X connection that shouldn't cause
noticeable overhead. Remove the shared instance and initialize X state
per VO. This reduces X-specific code outside the VOs using it.
vo_vdpau: split bitmap packing code into a separate file

Split the vo_vdpau code that calculates how to pack all subtitle
bitmaps into a larger surface into a separate file. This will allow
using it in other VOs.
vo_vdpau: change how OSD is rendered

When processing OSD bitmaps, the OSD rendering code in vo_vdpau first
uploaded them to an output surface identical to main video display
surfaces, and then blended them from there. Change the code to instead
pack them into an alpha-only surface which is only resized to be
larger if necessary. The main benefit is using less video memory -
a smaller alpha-only surface instead of a fullscreen RGBA surface.

The code currently doesn't keep the bitmaps over multiple OSD calls,
so the packing isn't actually beneficial at the moment (they could
just as well be individually uploaded to and rendered from one shared
area). The code relies on some assumptions about the behavior of the
old OSD code: there can't be more than 6 separate bitmaps, and the
bitmaps provided in the draw callbacks are still valid after the call.

Since main OSD rendering uses libass now, just rendering the libass
bitmaps directly (instead of improving the rendering of the old-style
results generated from them) would be an alternative. However, not all
the OSD types are trivial to convert, and this change moves in a
direction which should help such future changes.
subs, vo: do sub bitmap change detection by comparing IDs

vo_vdpau and vo_gl cache the last subtitle bitmaps uploaded to video
card in case they stay the same over multiple frames. Detecting
whether the bitmaps have changed and should be re-uploaded was
somewhat fragile. Change the VO API to provide a bitmap ID which can
be compared with what the VO has to determine whether a new upload of
the bitmaps is needed.
vo_gl: use a single texture for libass-rendered bitmaps

Use the bitmap packer code split from vo_vdpau to pack all
libass-generated subtitle bitmaps into one texture. This reportedly
improves performance in a lot in some cases on OS X at least.

One issue with the old code was that "large" images caused each
sub-image to be created and rendered as a new texture. "Large" in this
case means larger than 32x32 pixels, which actually isn't very large
with screen sizes beyond 1500x1000 pixels. This means rendering a
simple subtitle for a fullscreened video may allocate many small
textures, one for each glyph.

The new code also uses less deprecated OpenGL features and draws all
sub-images in one batch.

There are two possible issues the new code could cause:
- Drivers could have performance issues with the larger texture sizes
  and the number of glTexSubImage2D calls on it.
- There is only one EOSD texture, which could become full (the size
  is increased on demand, but that is restricted by driver texture
  size limitations).

Modified by Uoti Urpala to work with a different bitmap packer
interface than the commit was originally created against.
subs, vo_vdpau: support RGBA color for PGS subtitles

Support passing bitmap subtitles to VOs in full RGBA color, and
implement this for libavcodec-decoded subtitle formats on decoding
side and vo_vdpau on display side. Currently this is enabled for PGS
(blu-ray) and DVB subtitles.

VDPAU seems to have sampling issues similar to known GL ones when
drawing a sub-rectangle from a larger texture with scaling, where
adjacent pixels outside the specified source rectangle affect the
result. As the bitmap subtitles may be scaled, add padding support to
the bitmap packer code.

In principle, this could be used for colored DVD subtitles too.
However, the libavcodec DVD decoder lacks parts of the resolution and
palette handling that are present in spudec.c.
core, timeline: cache external ordered chapter files too

Previously, Matroska source files other than the initially opened one
were always accessed without caching. Enable cache for extra files
too. A separate cache process/thread is started for each file, which
is less than optimal but probably better than no caching if the user
explicitly enabled cache. This commit only implements caching for
Matroska ordered chapters (not for EDL timeline).

To build the timeline we need to demux the files in the current
directory to look for segments with matching uuid. This first demux is
done with no cache since we don't need to read a lot of the stream. If
the file is recognized as one of the needed sources it's reopened with
cache enabled.

Also move the stream_cache_size global variable to the options struct.
vo_gl: add noise filter

Add disabled feature: noise filter for vo_gl.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34014 b3059339-0415-0410-9bf9-f77b7e298cf2

Hook up -vo gl noise support.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34015 b3059339-0415-0410-9bf9-f77b7e298cf2
cleanup: vo_gl: minor cleanups

Fix spelling.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34006 b3059339-0415-0410-9bf9-f77b7e298cf2

Fix disabled code.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34007 b3059339-0415-0410-9bf9-f77b7e298cf2

Remove pointless pointer indirection for shader program strings.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34016 b3059339-0415-0410-9bf9-f77b7e298cf2

Remove usage of glColor3f, there is not really a point in it.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34149 b3059339-0415-0410-9bf9-f77b7e298cf2
vo_gl: add "backend" suboption to select x11/sdl etc backend

Add new "backend" suboption that allows selecting the display
backend used by vo_gl. Normally, it's auto-selected, but sometimes
it's desireable to explicitly select it.

Remove the gl_sdl VO. SDL backend can now be selected with
--vo=gl:backend=sdl

This is based on svn commit 34438, and tries to be compatible with it.
The undocumented numeric backend names serve this purpose. (They are
undocumented because names are preferred.)
cleanup: remove mp_image_t.x/y fields

These were never used.
gl_common: add OpenGL 3.x context creation

Also add a bunch of GL functions to the function loader, which will be
needed by vo_gl3. Remove some unused legacy GL functions from the
loader.

Use the proper name for glGetProgramivARB. glGetProgramiv is a different
and incompatible function. The ARB variant is used for ARB shaders,
while the proper one is for GLSL.