ao_pcm: fix references to -novideo

The option is -no-video. Remove the deprecated "fast" suboption, which
did nothing and instructed the user to use "-novideo" instead.

Fix a reference to -novideo in encoding.rst.

Add a "generic" entry about -no-* to the list of renamed options. The
change is already explicitly mentioned in the text above the table, but
even if it's redundant, it makes it harder to overlook.
configure: remove unused libpng detection
configure: don't check for inttypes.h, it always exists

The presence of inttypes.h is guaranteed by POSIX. We don't need to
check for it. We don't need to provide a compatibility header either.

Apparently libc5 systems didn't provide inttypes.h. libc5 is ancient,
unmaintained, and not used by modern Linux systems.
vo_xv: try harder to get correctly aligned pointers/strides

To get guaranteed alignment for the chroma planes with typical YV12
playback, we have to double the alignment on the image width, as the
chroma planes have half the image width.

Clear the image with black instead of green to hide scaling artifacts
on the right border of the screen.

(It might be possible to create the image layout ourselves by not
calling XvShmCreateImage(), and filling in our own image width and exact
strides, but that's probably too risky: the Xv client library sends an
X protocol request to query the real image dimension and strides. It is
unknown to me whether X servers or drivers would generally accept an
image with mismatching parameters, even if the image is conceptually
valid.)

Allocate the image with av_malloc() in the non-SHM case. I suspect the
non-SHM case doesn't matter much, though.
demux_lavf: do not prefix filename passed to libavformat with "mp:"

Opening files with the libavformat AVISynth demuxer ("avs"/avisynth.c)
fails, because the filename we pass to avformat_open_input() is prefixed
with "mp:". Normally, this doesn't matter, because data is read with the
stream interface. The AVISynth demuxer can't use this, because the
Avisynth API (apparently) can't read scripts from memory, and requires
a filename.

The "mp:" prefix used to be required when mplayer's stream layer was
made available as protocol to ffmpeg. This was replaced by setting
custom stream callbacks in de4908 (svn commit 25499), but the prefix
wasn't removed. Since this prefix doesn't have any purpose anymore and
prevents AVS playback from functioning, remove it. Fixes #5.
demux_lavf: add support for libavdevice

libavdevice supports various "special" video and audio inputs, such
as screen-capture or libavfilter filter graphs.

libavdevice inputs are implemented as demuxers. They don't use the
custom stream callbacks (in AVFormatContext.pb). Instead, input
parameters are passed as filename. This means the mpv stream layer has
to be disabled. Do this by adding the pseudo stream handler avdevice://,
whose only purpose is passing the filename to demux_lavf, without
actually doing anything.

Change the logic how the filename is passed to libavformat. Remove
handling of the filename from demux_open_lavf() and move it to
lavf_check_file(). (This also fixes a possible bug when skipping the
"lavf://" prefix.)

libavdevice now can be invoked by specifying demuxer and args as in:

    mpv avdevice://demuxer:args

The args are passed as filename to libavformat. When using libavdevice
demuxers, their actual meaning is highly implementation specific. They
don't refer to actual filenames.

Note:

libavdevice is disabled by default. There is one problem: libavdevice
pulls in libavfilter, which in turn causes symbol clashes with mpv
internals. The problem is that libavfilter includes a mplayer filter
bridge, which is used to interface with a set of nearly unmodified
mplayer filters copied into libavfilter. This filter bridge uses the
same symbol names as mplayer/mpv's filter chain, which results in symbol
clashes at link-time.

This can be prevented by building ffmpeg with --disable-filter=mp, but
unfortunately this is not the default.

This means linking to libavdevice (which in turn forces linking with
libavfilter by default) must be disabled. We try doing this by compiling
a test file that defines one of the clashing symbols (vf_mpi_clear).

To enable libavdevice input, ffmpeg should be built with the options:

    --disable-filter=mp

and mpv with:

    --enable-libavdevice

Originally, I tried to auto-detect it. But the resulting complications
in configure did't seem worth the trouble.
demux_gif: remove this demuxer in favor of libavformat

The gif support in libavformat/libavcodec as of ffmpeg commit 5603b2
can handle animated gif. The internal demuxer is not needed anymore.
build: identify the build time of the binary in the versioning output

Based on a patch by qyot27. Add export LC_ALL=C on top of version.sh to
make the output locale independent.

Note that the build time will not be updated on every "make" invocation,
but only when the git revision is updated. This is a good thing, as
repeated make invocations should not rebuild the binary. (This would
break "sudo make install" too.)
video: add support for 12 and 14 bit YUV pixel formats

Based on a patch by qyot27. Add the missing parts in mp_get_chroma_shift(),
which allow allocation of such images, and which make vo_opengl
automatically accept the new formats. Change the IMGFMT_IS_YUVP16_LE/BE
macros to properly report IMGFMT_444P14 as supported: this pixel format
has the highest numerical bit width identifier (0x55), which is not
covered by the mask ~0xfc. Remove 1 bit from the mask (makes it 0xf8) so
that IMGFMT_IS_YUVP16(IMGFMT_444P14) is 1. This is slightly risky, as
the organization of the image format IDs (actually FourCCs + mplayer
internal IDs) is messy at best, but it should be ok.
cache: refactor how cache enabling is done

Code enabling the cache by default for network streams did that by
modifying the value of the "cache" option. This wasn't sane, as
multiple streams may be created and all share the same options. Change
the code to not modify options but store data in the stream instance
instead.

Conflicts:
	core/mplayer.c
	demux/demux.c
	stream/cache2.c
	stream/network.c
	stream/network.h
	stream/pnm.c
	stream/stream.c
	stream/stream_rtp.c

Merged from mplayer2 commit e26070. Note that this doesn't solve any
actual bug, as the playlist crashing bug has been fixed before.

Since the global cache size option value is not overwritten anymore, the
option doesn't need to be restored on end of playback (M_OPT_LOCAL).
cache: simplify further

This commit is separate from the previous one to separate our own
changes from changes merged from mplayer2 (as far as that was possible).

Make it easier for stream implementations to request being cached. Set
a default cache size in stream.c, and remove them from various stream
implementations. Only MS streaming support sets a meaningful cache size.

Make querying cache size saner. This reduces the amount of #ifdefs
needed.
stream_lavf: use ffmpeg for http/https streaming

The internal mplayer http implementation is terrible and old. Try to use
ffmpeg instead. Enable ffmpeg https as well (we don't have native
support for it and never will).

Enable the cache for ffmpeg streams. In theory, we want to enable the
cache for network streams only (or at least, not enable it for files),
but there doesn't seem to be any way to query this. ffmpeg has its own
read-cache, but apparently it doesn't get filled asynchronously (only
to the degree internal socket/kernel buffers do).

Should it turn out that the mplayer implementation is better than
ffmpeg's in some way (unlikely), this commit might be reverted until
ffmpeg is ready. So far, the ffmpeg implementation seems to work very
well though.

The original mplayer stream implementation is made available under
"mp_http://" and "mp_http_proxy://". This is for testing, until the
http implementation is completely removed. Note that this is unlikely
to happen soon: ffmpeg doesn't support Microsoft streaming, while
mplayer has some support. This code has dependencies on http.

Note: "http_proxy://" doesn't work anymore. Use "httpproxy://" to get
the ffmpeg implementation of it.

Using https requires enabling OpenSSL in ffmpeg by adding
the --enable-openssl switch to ffmpeg's configure.
core: automatically pause on low cache

When the cache fill status goes below a certain threshold, automatically
pause the player. When the cache is filled again, unpause again.

This is intended to help with streaming from http. It's better to pause
a while, rather than exposing extremely crappy behavior when packet
reads during decoding block the entire player.

In theory, we should try to increase the cache if underruns happen too
often. Unfortunately, changing the cache implementation would be very
hard, because it's insane code (forks, uses shared memory and "volatile"
etc.). So for now, this just reduces the frequency of the stuttering if
the network is absolutely too slow to play the stream in realtime.
subs: remove --utf8, simplify code

Remove the options --utf8 and --unicode which had no effect any more
(what they once did should be doable with --subcp). The only use of
corresponding variables left in code was subreader.c code using
sub_utf8 as a flag indicating whether iconv conversion was active.
Change the code to test the existence of iconv context instead.

Conflicts:
	DOCS/man/en/options.rst
	core/cfg-mplayer.h
	sub/sub.c
	sub/sub.h
	sub/subreader.c

Merged from mplayer2 commit ea7311.

Note: --unicode was already removed
subreader: fix some of ASS parser issues

The subreader.c ASS parser (used when playing an external ASS subtitle
file with --no-ass for "plaintext" display) hardcodes dialogue line
syntax instead of correctly reading it from the "Format: " line in the
file, but tried to support a varying amount of fields by guessing
where the text field (which should be last) begins. This guessing code
was buggy in many ways. Remove it and hardcode skipping 9 commas
before the text field, which should work for most files. I don't
consider the --no-ass case important enough to implement correct
parsing now. Also fix the code removing formatting tags, which failed
to remove the second in a pair of two consecutive tags.

Conflicts:
	sub/subreader.c

Merged from mplayer2 commit 91f516. Essentially reverts d5b964.
audio: improve decoder open failure handling

Reinitialize sh_audio->samplesize and sample_format before falling back
to another audio decoder (some decoders rely on default values). Remove
code setting these fields from demux_mkv and demux_lavf (no decoder
should depend on demuxer-set values for these fields).

Conflicts:
	audio/decode/ad_lavc.c

Merged from mplayer2 commit 6b9567. The changes to ad_lavc.c are not
merged, as they are very specific to the mplayer2 libavresample hack;
we deplanarize manually, so we can't get unsupported sample formats
yet (except on raw audio with "pcm_f64le", as we don't support
AV_SAMPLE_FMT_DBL in the audio chain).
stream_ftp: cleanups

stream ftp: Pass full buffer size to snprintf

Previously the buffer size was always passed as one less than
the underlying buffer's size. This is not using the underlying
buffer to its full potential according to the C99 standard. The
last byte of the buffers were never used.

No vulnerabilities should have been caused by this mistake because
the strings stored in the buffers were zero terminated at all
times. Neither were out-of-array writes nor reads possible.

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

stream ftp: open_f: Mark parameter file_format unused

We have nothing to say about it, so we do not set *file_format.
No need for compilers to emit a warning about it.

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

stream ftp: Set type to STREAMTYPE_STREAM

Previously this was not set at all from within the stream_ftp module.
This caused the run-time warning message "Streams need a type!".

The actual behaviour should not be affected by this change.

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

stream ftp: Use C99 designated initializers

Simplify the initialization of the stream private struct's defaults.

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

stream ftp: Remove unneeded cast

At worst these kind of casts can hide real errors. As it is, it is
just not needed at all, thus remove it.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35492 b3059339-0415-0410-9bf9-f77b7e298cf2
audio: make AC3 pass-through with ad_spdif work

Do not fall back to 0 for samplerate when parser is not initialized.

Might fix some issues with using -ac spdifenc with audio in MKV
or MP4.

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

Replace outdated list of unsupported formats by list of supported formats.

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

Do not call af_fmt2str on the same data over and over.

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

ad_spdif: use the more specific AF_FORMAT_AC3_LE when
we handle AC3.

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

Make AF_FORMAT_IS_IEC61937 include AF_FORMAT_IS_AC3.

Our AC3 "sample format" is also iec61937.

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

af_format: support endianness conversion also for iec61937
formats in general, not just AC3.

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

Conflicts:
	audio/filter/af_format.c

af_format: Fix check_format, non-special formats are of course supported.

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

Note: see mplayer bug #2110
sub: clear libavformat demuxed subtitles on seeking

libavformat demuxes ass subtitles in a broken way, that forces the
player to throw away all subtitle events received so far. See mplayer
svn commit 31293.
input: do not generate double clicks for mouse wheel

Button 3 and 4 are mapped to the mouse wheel. Double click events for
them annoying and not useful at all.

I don't know about buttons 5-19; for all I know these could be mapped
to wheels as well. Even if not, double click events are probably not
very important for these. Disable double clicks for these as well.