stream_ftp: support longer filenames, general fixes

stream ftp: readline: Fix off-by-one error

Even if max bytes are available read at most max - 1 bytes.

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

stream ftp: readline: Always initialize output parameter buf

Only exception if passed parameter max is less than or equal
to zero. That cannot happen with the current code.

Additionally change readresp function to always copy the first
response line if the parameter rsp is non-NULL. This fixes some
error reporting that used uninitialized stack arrays.

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

stream ftp: readline: Always try to read complete lines

If there is not enough space in the provided line buffer just
skip the remaining bytes until reaching EOL.

Usually we are only interested in the first 5 characters and
for everything else the (on-stack) response buffer should still
be big enough.

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

stream ftp: Revise file descriptor usage

* Set unbound descriptor variables to -1
* Always test >= 0 to see if a variable refers to a valid descriptor

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

stream ftp: Only send QUIT command if connected

Do not attempt to send commands without control connections.

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

stream ftp: Create buffers before opening control connection

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

stream ftp: Allocate command buffer on-heap

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

stream ftp: Increase command buffer size

Allow for more longish file names (be it because of length or more
lengthy characters).

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

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: 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
subs: remove --utf8 and --unicode, 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.
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.
audio: improve decoder open failure handling

Fix handling of unsupported lavc output format to prevent an endless
stream of errors on init. Print a more informative error message if
the problem is due to lack of libavresample support. 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).
subassconvert: support 5 more CSS color names

Add support for color names cyan, grey (alias for already supported
"gray"), magenta, orange, pink.

Patch by Federico Kereki, fkereki@gmail.com
subassconvert: improve malformed/unrecognized color handling

When parsing SRT color values, treat font tags specifying unrecognized
color values as valid tags and never show them as text; just use the
default subtitle color as the color specified. Try to parse color
values as hex codes even if they do not have a leading '#'.
demux_lavf: drop "mp:" prefix from filename given to lavf

Opening files with the libavformat AVISynth demuxer ("avs"/avisynth.c)
failed, because the filename we pass to avformat_open_input() was
prefixed with "mp:". Normally, the name doesn't matter, because lavf
reads data 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 de4908b644 (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.
subs: remove pointless --disable-sortsub configure option
core: timeline: prevent inaccurate seeks outside timeline

Ensure that even if a seek is inaccurate it will not show video from
outside the defined timeline. Previously, seeking to the beginning of
a segment could show frames from before the start of the segment if
the seek was done in inaccurate mode and the demuxer seeked to an
earlier position. Now hr-seek machinery is used to skip at least the
frames that should not be part of playback timeline at all.
subs: fix memory leak with external subtitle tracks

Commit 5639702953 ("subs: always use sub decoder framework for libass
rendering") was missing code to free libass tracks allocated for
external subtitle files in the main post-playback code path (while it
did have correct code in the rarely used remove_subtitle_range()
function). Fix.
demux_mkv: work around bad OutputSamplingFrequency values

Something produces corrupt Matroska files with audio tracks that have
SamplingFrequency set to 44100 and OutputSamplingFrequency to 96000,
when the correct playback rate is 44100. Add a special case for this
44100/96000 combination and override it to 44100/44100; it's unlikely
that anyone would ever want to use this 44100/96000 combination for
real in valid files.
af_volnorm: fix output range with float input

af_volnorm can process either int16_t or float audio data. The float
version used 0 to INT_MAX as full value range, when it should be 0 to
1. This effectively disabled the filter (due to all input being
considered to fall in the silence range). Fix.

Reported by Tobias Jacobi <liquid.acid@gmx.net>.
subs: fix vf_ass --subdelay, remove sub_step slave command

Commit 5639702953 ("subs: always use sub decoder framework for libass
rendering") broke --subdelay with vf_ass (it had no effect). Fix.

Remove sub_step slave command (was bound to keys 'g'/'y' by default).
This command allowed displaying the previous/next subtitle, but was
fairly useless as it was implemented by adjusting sub delay by an
amount that made the correct subtitle appear. This changed the delay
setting permanently, and there was no easy way to change it back to
the previous value.

Move the sub_delay variable to the option struct.
win32: add missing include for static pthreads compilation

Commit 5c731e2ea669bb ("configure, Windows: support static pthreads on
Windows") did not add required <pthread.h> include to mplayer.c. Fix.

Reported by "SpOeK".
vf_stereo3d: add new input and output formats

Add new input formats:
side_by_side_half_width_left_first
side_by_side_half_width_right_first.

Add new output formats:
anaglyph_green_magenta_dubois
anaglyph_yellow_blue_dubois
mixer: keep fractional part of volume setting

mixer_setvolume() accepts float values for volume, but used the
integer function av_clip() to limit range, losing the fractional part
as a side effect. Change the code to use av_clipf() instead. For most
uses this shouldn't make any real difference; actual AO volume
settings may not have that much precision anyway.
configure: remove --datadir and other obsolete things

After OSD rendering was switched over to libass, nothing uses the
--datadir setting (font search in old code was last user). Remove the
switch. Also remove --enable-xshape (unused since internal GUI
removal) and some code remaining from ao_nas which was removed earlier.
build: clean up remnants from internal FFmpeg build

Clean up some obsolete configure tests and other things left over from
the time years ago when MPlayer used hacks to build FFmpeg inside the
same source tree.

Remove the configure switches --as, --ar, --ranlib. --ar and --ranlib
were useless since nothing is built as a library. --as wasn't directly
used; removing it means removing some sanity checks though (the
default assembler selected was tested to see that it could compile SSE
opcodes, which may be used in inline asm).

It's unlikely that anyone would try to make the filters depending on
Libavcodec internals build any more. Remove the undocumented configure
option --fmpeg-source-dir and remove the mcdeint and spp filters from
the source tree (they were already not built).

Remove some configure tests which were added for the sake of FFmpeg
build and whose results are not used by mplayer2 now.

Removing the memalign checks actually required removing two remaining
uses in the code. Also remove the malloc.h check and includes in code
(I guess the reason to add malloc.h includes at some point was
memalign use, though most of the files in question did not actually
use memalign now, if ever).
windows support: fix _wstat misusage

I have no idea when or how this broke, but _wstati64() is the function
we want anyway (64 bit filesize). Possibly this was a mingw-w64 bug.
It's unknown why "wstat()" just doesn't work in this case, as it's not
defined by MSDN and could be defined by mingw as it needs.
configure: change libcaca test to pkg-config