Fix resetting border style with \rSTYLE

With \rSTYLE, it is possible to change the border style within the same
subtitle event. You can do this by setting a different BorderStyle value
in the newly requested style. VSFilter handles this as expected, while
libass uses a single border style for the whole subtitle event.

This fixes libass issue #56.
Terminate drawings immediately on a \p0 tag

The parsing code allowed override tags after \p0 to affect the drawing.
This is incorrect. Finish the drawing object as soon as \p0 is
encountered instead.

This requires moving the code executing the style overrides from
get_next_char() in ass_parse.c to the main render loop in
ass_renderer.c, because we have to re-enter the rendering loop
inside of a tag. The old code was simply executing all tags until
a new character could be returned to the renderer loop, mutating up
the state (RenderContext fields) for the drawing after the drawing
was closed, but before it was rendered.

This fixes libass issue #47.
Fix issues with shearing in combination with scaling

There are two problems.

First, the shearing tags (\fay and \fax) misbehave when used with
scaling tags (\fscx and \fscy). We have to compensate for the scaling
in either direction when shearing, because the shearing is applied
after scaling. VSFilter, which by definition has the correct behavior,
does it the other way around.

Second, libass doesn't scale smoothly when small font sizes are
involved. These can come either from downscaling (e.g. make the mplayer
window smaller than the video with a video output like gl or vdpau), or
from setting the font size manually. In these cases, the font size
passed to freetype get very low, so that rounding errors or size
adjustments due to hinting or other pixel grid fitting add up. The
result is text rendered in the wrong size, or "pulsating" text if the
font size depends on animated parameters. This is worsened by the
practice found in subtitle scripts to use tag combinations like
"\fscy2500\fs2" to get more precision for controlling font size (needed
because VSFilter doesn't read fractional scale values).

We solve the second issue by always requesting a constant font size
from freetype, and then scaling the resulting glyph to the desired
size. This seems to disable freetype's glyph fitting issue. The caveat
is that it (obviously) also disables hinting, which may result in worse
text quality. However, the combination of applying \fs and \fscx tags,
and animating them, seems to leave no other choice.

This fixes libass issue #46 (hopefully).
Fix \fay when used with multiline subs

When \fay tag is applied to a multiline sub, it causes subsequent lines
of the sub to be offset vertically as if it was rendered next to the
previous line (not below).

Patch by Hector Martin <hector@marcansoft.com>, with an additional
correction related to libass issue #46.
Add ass_set_line_position() API function for subtitle position

This allows users to change the vertical position of normal subtitles.
MPlayer has such a feature as -sub-pos option using its internal
subtitle renderer.

The LIBASS_HAVE_LINE_POSITION define indicates presence of this
function. Possibly this should be replaced by a version-bump.
Fix change detection when cache is cleared

check_cache_limits() clears the image list. If all subtitles disappear
right in the frame the cache has been cleared, ass_detect_change() will
see two empty image lists (old - not empty, but cleared, new - empty),
and signal to the application that there was no change. As result,
media players which rely on the change detection will keep displaying
the last subtitle until the next subtitle event.

This bug was found by uau and has been reported on IRC in February.
style overrides: subtitle styling override
style overrides: do not use user font scale coefficient for positioned events
style overrides: scale borders with user font coefficient
style overrides: make font size style override independent of script resolution

This comes into effect only when enabling selective style overrides.
This isn't used when using forced styles, or when playing SRT subs with
mplayer.

To solve: don't require the user to enable selective style overrides when
rendering SRT subs with mplayer to get the same font size as with
ASS subs + selective style overriding. (The point of selective style
overrides is to make ASS subtitles look like SRT ones in the first place.)
style overrides: use user style's margin values when doing selective style overrides
style overrides: selective style override doesn't apply to events with margins
style overrides: don't apply line position user setting to events with no style overriding

A previous commit added the possibility that a normal (unpositioned) event
is considered as not suitable for selective style overriding. This makes it
necessary to add a special case to the user line position code to leave
these events unaffected.
Revert "style overrides: use user style's margin values when doing selective style overrides"

This reverts commit 0a07dfe28c16d9ae975d0a3b2898bfbbfcc653a9.