matroska: speed up ordered chapters scanning with improved heuristics

Try to be a bit more clever when scanning for linked mkv files (ordered
chapters feature). Instead of just preferring filenames with a closer
prefix match, consider file sizes as well. The assumption is that it is
better to scan small files first. Achieve this by sorting by prefix
first, and then by file size.

In order to make this new behavior trigger more often, be a more "fuzzy"
about the prefix matching: consider all matches in a certain range as
equal.

This will speed up the following case:
   title_01.mkv
   title_02.mkv
   title_03.mkv
   title_op.mkv (title0*.mkv link to it)
Playing title_01.mkv, the old code would first scan title_0*, and then
title_op.mkv, as "title_0" is the largest prefix. The new code would
reduce the common prefix to "title", and then sort the resulting files
by size, causing title_op.mkv to be scanned first. The total number of
scanned files is reduced.
mplayer: remove ---help option

mplayer used to follow the convention of using a single dash ("-help") for
each option. For some reason "--help" was allowed as special case.

mplayer2 introduced a change to allow the more common convention with two
dashes ("--help"). This means that in combination with the old special
case for "--help", "---help" would suddenly be allowed.

Remove this special case.
core: uninit video output when audio file is played

Playing a video and then an audio file only left the VO window on screen.
libvo, vo_vdpau: make the EOSD packer code from vo_vdpau generic

The code in eosd_packer.c/.h is taken from vo_vdpau.c and has been made
independent from vdpau API specifics. This allows other VOs, which need
to pack the small EOSD images into a large surface for efficiency, to use
this code.
vo_gl: use generic eosd code

This is an experiment.

The change probably doesn't matter much.

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.
On the other hand, the old code could be fixed by tuning the texture sizes
for "modern" work loads.

Also, the new code 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 (it's enlarged
  on demand, but restricted by driver texture size limitations)

It has been reported that this is faster on OSX with ATI GPUs than the old
code.
mixer: reindent/cosmetic changes

There should be no real semantic changes.

Remove the mixer_setbothvolume macro, as it was unused.
mixer: keep user volume setting when --softvol is used

When --softvol is enabled, the volume set by the "volume" property is
reset when changing to a new file or crossing ordered chapter boundaries.

Fix this by explicitly restoring the volume on audio reinitialization.
Now the behavior with --softvol should be the same as if a system mixer
is used, and the volume should be persistent across file changes.

This also works around an inconsistency with the mute flag. The frontend
assumed the mute flag is persistent across file changes, which was not
true with --softvol.

If not resetting the volume on playing new files is undesired, it can
be avoided by putting volume=100 in the mplayer config file.
mixer: keep balance setting

Similarly to the last commit, restore the balance setting when switching
to a new file. Unlike the volume setting, balance is always implemented
as filter, so this affects usage without --softvol too.
vf_gradfun: use option parser
vf_gradfun: add size parameter, which sets radius according to movie diagonal

This patch adds a "size" parameter, which scales the filter radius
according to movie diagonal, the unit being percent of diagonal.
This makes the effect far more predictable across movies of different
resolutions.

Usage example (with possibly useless values):
-vf gradfun=strength=1.2:size=2.3

Based on a patch by Radosław Szkodziński <astralstorm@gmail.com>
vf_gradfun: change default parameters
bstr: add function for UTF-8 parsing (taken from libav)

Parts taken from libavutil's GET_UTF8 and slightly modified.
input: fix crashes with libmenu

Note: now that libmenu has been removed, the related code in input.c has
been removed. If libmenu is ever added back, a queue_remove() function
that can remove any item in the input queue will be required.

libmenu triggered some special case that caused crashes by double frees.
In particular the queue_pop function is used, expecting to remove an element
that is not necessarily always the one that queue_pop removes. Fix by
adding a queue_remove functions. Rewrite the other queue functions, since
these are probably buggy as well. queue_pop didn't even attempt to
maintain the doubly linked list.
input: simplify previous commit a bit more

Less mutable state = better.
subtitles: create only one instance of ASS_Render instead of two

This simplifies the code. It also can make loading of mkv files faster, as
initializing two ASS_Render instances required scanning mkv font
attachments twice.
playtree: --shuffle shouldn't make playlist navigation useless

When --shuffle was used, the pt_step -1 jumped to the next file, instead
of the previously played file. This was because the playtree entries were
never actually shuffled, but instead a random unplayed file was picked.
Fix this by actually shuffling the playtree in advance. I couldn't see any
clear location where exactly this should happen, so it's done when a
playtree iterator is created.

Not removing the old code, since new playtree entries could be added while
an iterator is active.
x11: simplify setting unicode text properties
screenshot: improve quality by using additional swscale flags

Adding these flags improves the quality of the YUV->RGB conversion when
screenshots are taken. It trades precision for performance.

This doesn't affect any other swscale uses, such as vf_scale or vo_x11.

Based on a patch by cantabile. Fixes #140.
input: allow unicode keys and reassign internal key codes

This moves all key codes above the highest valid unicode code point (which
is 0x10FFFF). All key codes below MP_KEY_BASE now directly map to unicode.
Configuration files (input.conf) can contain unicode characters in UTF-8
to map non-ASCII characters/keys.

This shouldn't change anything user visible, except that "direct key codes"
(as used in input.conf) will change their meaning.
x11: allow unicode input

This change allows using non-ASCII keys with X11. These keys were ingored
before.

Technically, this creates an invisible, non-interactive input method
context. If creation fails, the code falls back to the old method, which
allows a subset of ASCII only.