options: support chapters for --start and --end

The --start and --end switch now accept a chapter number. The chapter
number is prefixed with '#', e.g. "--start=#2" jumps to chapter 2.

The chapter support might be able to replace --chapter completely, but
for now I am not sure how well this works out with e.g. DVDs and BDs,
and a separate --chapter option is useful interface-wise.

(This was supposed to be added in 51503a, but apparently the fixup
commit adding it was lost in a rebase. This might also be the reason
for the mess-up fixed in 394285.)
Fix potential bugs and issues, general cleanups

Most of these are reimar fixing issues found by Coverity static
analyzer, and possibly some more cleanup commits independent from
this.

Since these commits are rather noisy, squash them all together.

Try to make code a bit clearer.

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

Conflicts:
	audio/out/ao_alsa.c

Check the correct variable for NULL.

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

Remove pointless unreachable code (the loop condition already checks
the 0xff case).

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

Fix typo that might have caused reading beyond the string end.

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

Do not needlessly use "long" types.

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

Use AV_RB32 to avoid sign extension issues and validate offset before using it.

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

Remove nonsense casts.

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

Fix crash in case sh_audio allocation failed.

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

Fix potential NULL dereference.

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

Conflicts:
	libmpcodecs/ad_ffmpeg.c

Note: Slightly modified.

Fix malloc failure check to check the correct variable.

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

Avoid code duplication and pointless casts.

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

Conflicts:
	stream/tv.c

Error out if an invalid channel list name was specified
instead of continuing and reading outside array bounds
all over the place.

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

Conflicts:
	stream/tv.c

Make array "static const".

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

Properly free resources even when encountering many
parse errors.

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

Conflicts:
	parser-cfg.c

Avoid leaks in error handling.

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

Do not do sign comparisons on "char" type which can be both signed or unsigned.

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

Free cookies file data after parsing it.

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

http_set_field only makes a copy of the string, so we still need to
free it.

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

check4proxies does not modify input URL, so mark it const.

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

Remove proxy "support" from stream_rtp and stream_upd, trying
to use a http proxy for UDP connections makes no sense.

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

Conflicts:
	stream/stream_rtp.c
	stream/stream_udp.c

Add url_new_with_proxy function to reduce code duplication and memleaks.

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

Conflicts:
	stream/pnm.c
	stream/stream_live555.c
	stream/stream_nemesi.c
	stream/stream_rtsp.c

Fix off-by-one errors in file descriptor validity checks.

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

Remove pointless cast.

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

Abort when opening the file failed instead of calling
"write" with an invalid descriptor.

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

Remove pointless local variable.

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

Conflicts:
	stream/http.c
asf_streaming: remove broken MMSU support code

Comment out unused code

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

Removing mmsu-related code

MMSU was never supported by MPlayer, and the protocol has been
deprecated. Since the code is not in use at all, Removing it
should not break anything.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35420 b3059339-0415-0410-9bf9-f77b7e298cf2
stream: change STREAM_CTRL_GET_SIZE argument type to uint64_t

Update endpos each time libavformat asks for it.

Fixes playback of still downloading files to not stop before we
really reached the end.

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

Conflicts:
	libmpdemux/demux_lavf.c

Change STREAM_CTRL_GET_SIZE argument type from off_t to
uint64_t.
Also fix the incorrect type of the uint64_res variable.

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

Conflicts:
	libmpdemux/demux_lavf.c
	libmpdemux/muxer_lavf.c

Note: also merges the "forgotten" cache support from r35107.
stream, demux: replace off_t with int64_t

On reasonable systems, these types were the same anyway. Even on
unreasonable systems (seriously, which?), this may reduce potential
breakage.
stream, demux_lavf: minor cleanup for stream size code
stream: fix dvd:// + cache crashing

The language string was dynamically allocated, which completely fails
if the cache is forked (which it usually is). Change it back to a fixed
length string, like the original code had it.
mplayer: fix potential issue when ao_play() fails

ao_play() can fail; in that case a negative error code is returned.
This error code will be returned by write_to_ao() in turn, which then
is in danger triggering "assert(played % unitsize == 0);" in
fill_audio_out_buffers(). Change write_to_ao() to return 0 on failure.
core: fix crash when video filter returns inf as PTS

When a video filter returned inf as PTS, the player crashed. One
reason for this was that decode_audio() was called with a negative
minlen parameter, which at some point caused it to call a memory
allocation function with a ridiculous value, triggering an out of
memory code path in talloc.c at line 971:

	if (unlikely(size >= MAX_TALLOC_SIZE)) {
		abort(); // return NULL;
	}

Fix this by sanity checking minlen in decode_audio(). (The check
against outbuf->len always succeeded, because it's an unsigned
comparison.)

Make the sanity check in mplayer.c more robust: check for NaN too,
which happens if the video PTS is inf.

This happened with "-vf pullup,softpulldown".
vf_softpulldown: fix possible regression

The line added with this commit was accidentally removed in commit
a0d759, which was a pure cleanup commit. The difference between
mplayer-svn and the mplayer2 base is that this filter has been made
PTS aware in mplayer2.

Also remove the redundant initialization of vf->priv->state.
m_option: add color option type

This accepts HTML-style hex colors in the form #RRGGBB. It's also
possible to provide an alpha component with #AARRGGBB. Each 2-digit
group is a hex number, which gives the color value from 0-255 (e.g.
#FF0080 is R=255, G=0, B=128).

I decided against reusing the code in subassconvert.c, which parses HTML-
style color values in SRT subs. It's probably better if option parsing
is completely separate from that, even if a little code is duplicated.
osd: make the OSD and sub font more customizable

Make more aspects of the OSD font customizable. This also affects the
styles of unstyled subtitles (such as SRT), or when using the --no-ass
option. This brings back some features that were lost with commit
74e7a1 (osd: use libass for OSD rendering).

Removed options:
--ass-border-color
--ass-color
--font
--subfont
--subfont-text-scale

Added options:
--osd-color
--osd-border
--osd-back-color
--osd-shadow-color
--osd-font
--osd-font-size
--osd-border-size
--osd-margin-x
--osd-margin-y
--osd-shadow-offset
--osd-spacing
--sub-scale

The font size is now specified in pixels. Since the OSD never uses
absolute font sizes, but scales them with the window height, the font
size is in pixels only at a certain window height. This height is
arbitrary. We select 720, meaning that if the window height is sized to
720, font sizes will be actually in pixels.

Such scaled pixel units are used to specify font border etc. as well.

The default settings should be about the same, with slight difference
due to rounding to the new scales.

Making OSD and subtitle fonts separately configurable would be easily
possible, but wasn't done: it's not very useful and would double the
number of newly added options.

Other small details that change:
- ASS_Style.Encoding is not set to -1 for subs anymore
  (assuming subs use VSFilter direction in -no-ass mode too)
- use a different WrapStyle for OSD
- ASS forced styles are not applied to OSD
m_option: on error, print valid integer range for choices