Commit Graph

34839 Commits

Author SHA1 Message Date
wm4 c6037982fd options: untangle track range parsing for stream_cdda
Remove the "object settings" based track range parsing (needed by
stream_cdda only), and make stream_cdda use CONF_TYPE_INT_PAIR.

This makes the -vf parsing code completely independent from other
options. A bit of that code was used by the mechanism removed with
this commit.
2013-04-21 03:48:30 +02:00
wm4 6526162bc0 m_option: split out sub-config parsing 2013-04-21 03:48:30 +02:00
wm4 4d8b740247 bstr: add bstrto0() 2013-04-21 03:47:05 +02:00
wm4 5bc7e4d6eb bstr: add bstrspn() 2013-04-21 03:47:05 +02:00
wm4 465ccd2c93 x11_common: minor simplification 2013-04-21 00:39:54 +02:00
wm4 1bae5641ab demux_lavf: fix subtitle seeking before start of the file
When trying to seek before the start of the file, which usually happens
when using the arrow keys to seek to the start of the file, external
libavformat demuxed subtitles will be invisible. This is because seeking
in the external subtitle file fails, so the subtitle demuxer is left in
a random state.

This is actually similar to the normal seeking path, which has some
fallback code to handle this situation. Add such code to the subtitle
seeking path too.

(Normally, all demuxer support av_seek_frame(), except subtitles, which
support avformat_seek_file() only. The latter was meant to be the "new"
seeking API, but this never really took off, and using it normally seems
to cause worse seeking behavior. Or maybe we just use it incorrectly,
nobody really knows.)
2013-04-21 00:21:23 +02:00
wm4 c768a00dfe mplayer: prefer -sub/-subfile subs over auto-loaded subs
Before this commit, it was more or less random which subtitle was
preferred if there was both an auto-loaded external subtitle, and a
subtitle loaded via -sub or -subfile. -sub subtitles happened to be
preferred over auto-loaded subs, while -subfile didn't. Fix the -subfile
case, and make the behavior consistent by making the selection behavior
explicit.
2013-04-20 23:48:26 +02:00
wm4 963c9aa3d5 demux_mkv: always set track->codec_id to a string
Otherwise audio/video/sub track handling code would dereference the NULL
pointer.
2013-04-20 23:40:41 +02:00
wm4 6627cf81cc subassconvert: add more web colors
Now includes the complete list from [1] at this time.

Switch from BGR to RGB to match with that list.

[1] http://www.w3.org/TR/css3-color/#svg-color
2013-04-20 23:28:27 +02:00
wm4 c6b03be894 core: display subtitle codec in track listing
Also switch the subrip and subviewer names, which obviously have been
confused.
2013-04-20 23:28:27 +02:00
wm4 018530cb74 demux_mkv: always add subtitle tracks
Even if the codec is unknown.
2013-04-20 23:28:27 +02:00
wm4 15ff7a5719 demux: remove some unused sh_video_t fields
Completely mysterious, and its values were never actually used.
2013-04-20 23:28:27 +02:00
wm4 c12b5ffc33 demux: get rid of sh_common_t
The only reason this existed was the parsing code. Even though it
could have been used for video, it's audio-only, so just move this
to sh_audio_t.
2013-04-20 23:28:27 +02:00
wm4 331982b99c sub, demux: identify subtitle types with the codec name
Get rid of the 1-char subtitle type field. Use sh_stream->codec instead
just like audio and video do. Use codec names as defined by libavcodec
for simplicity, even if they're somewhat verbose and annoying.

Note that ffmpeg might switch to "ass" as codec name for ASS, so we
don't bother with the current silly "ssa" name.
2013-04-20 23:28:27 +02:00
wm4 5ac50f88c9 av_common: allow calling mp_codec_to_av_codec_id() with NULL
Helps reducing special cases.
2013-04-20 23:28:26 +02:00
wm4 2adb1aaa5d demux: remove useless vid/aid/sid fields
Only demux_ts.c used sid in one case, replace that by reading the same
value from another location.
2013-04-20 23:28:25 +02:00
wm4 afd8d7f2db demux: fix clearing of input padding
MP_INPUT_BUFFER_PADDING_SIZE and FF_INPUT_BUFFER_PADDING_SIZE are both
16. The doxygen for FF_INPUT_BUFFER_PADDING_SIZE says only the first 23
bits must to be 0, but this is probably a lie.
2013-04-20 23:28:25 +02:00
wm4 23da9e68e8 demux_mkv: introduce new_demux_packet_from() and use it 2013-04-20 23:28:25 +02:00
wm4 eb27e14622 demux: remove some unused things 2013-04-20 23:28:25 +02:00
wm4 6d938f4838 command: try to switch subs too for program property
Untested, but why not.
2013-04-20 23:28:25 +02:00
wm4 1e53b78b32 demux_lavf: simplify
This removes the stream handling mess by using a single list for all
stream types.

One consequence is that new streams are always set to AVDISCARD_ALL,
which could be an issue if packets are read before initializing other
streams. However, this doesn't seem to an issue for various reasons,
so we don't do anything about it.

The new code strictly assumes that libavformat never removes or
reorders streams once added to AVFormatContext->streams. Undefined
behavior will result if it does.
2013-04-20 23:28:25 +02:00
wm4 7f304a72a9 demux_mkv: simplify use of demuxer API
mkv_track_t now references sh_stream directly, instead of using an ID.
Also remove all accesses to demux_stream (demuxer->video etc.).

Remove some slave-mode things on the way, like "ID_SID_..." messages.
2013-04-20 23:28:25 +02:00
wm4 654c34f771 demux: add functions to simplify demuxers
Some preparations to simplify demux_mkv and demux_lavf.

struct demux_stream manages state for each stream type that is being
demuxed (audio/video/sub). demux_stream is rather annoying, especially
the id and sh members, which are often used by the demuxers to determine
current stream and so on. Demuxers don't really have to access this,
except for testing whether a stream is selected and to add packets.

Add a new_sh_stream(), which allows creating streams without having the
caller specify any kind of stream ID. Demuxers should just use sh_stream
pointers, instead of multiple kinds of IDs and indexes.
2013-04-20 23:28:24 +02:00
eng 06eee1b675 demux_mkv: code cleanup
Cleanup based on results from cppcheck-1.59
Reduce the scope of several variables
Replace 2 calloc/realloc calls with a single malloc
2013-04-20 23:28:24 +02:00
wm4 5dabaaf093 demux_mkv: use new way of track switching
Since demux_mkv queries the demuxer state when reading packets, track
switching is completely passive. Cycling etc. is done by the frontend.
As result, all track switching code can be removed.
2013-04-20 23:28:24 +02:00
wm4 69258b2c71 demux: simpler way to notify demuxers about track switches
This interfaces assumes track switching is always successful.
2013-04-20 23:28:24 +02:00
wm4 cb15d9c24a demux_mkv: remove pointless video track selection
Possibly once needed, now it's just redundant code.
2013-04-20 23:28:24 +02:00
wm4 1d7b289e48 matroska: update dead link 2013-04-20 23:28:24 +02:00
wm4 80d0ab1058 demux_mkv: support vp9
Note that ffmpeg doesn't provide a decoder by default yet.
2013-04-20 23:28:24 +02:00
wm4 8b017c73c4 core: matroska: support concatenated segments
Matroska files can contain multiple segments, which are literally
further Matroska files appended to the main file. They can be referenced
by segment linking.

While this is an extraordinarily useless and dumb feature, we support it
for the hell of it.

This is implemented by adding a further demuxer parameter for skipping
segments. When scanning for linked segments, each file is opened
multiple times, until there are no further segments found. Each segment
will have a separate demuxer instance (with a separate file handle
etc.).

It appears the Matroska spec. has an even worse feature for segments:
live streaming can completely reconfigure the stream by starting a new
segment. We won't add support for it, because there are 0 people on this
earth who think Matroska life streaming is a good idea. (As opposed to
serving Matroska/WebM files via HTTP.)
2013-04-20 23:28:23 +02:00
wm4 f989b6081b demux_mkv: don't terminate if there are no clusters
Matroska segment linking allows abusing Matroska files as playlists
without any actual video/audio/sub data, making files without any
clusters still useful for the frontend.
2013-04-20 23:28:23 +02:00
wm4 5d562c5ef2 mplayer: take tracks from first segment if main file is empty
With Matroska ordered chapters, the main file (i.e. the file you're
playing) can be empty, while all video/audio data is in linked files.
Some files don't even contain the track list, only chapter information.
mpv refused to play these, because normally, the main file dictates the
track layout.

Fix this by using the first segment for track data if no part of the
timeline is sourced from the main file.
2013-04-20 23:28:23 +02:00
wm4 8133aa4d8a demux_mkv: simplify handle_block() logic a bit 2013-04-20 23:28:23 +02:00
wm4 59eaa8ed7e demux_mkv: verify laces separately, and in all cases 2013-04-20 23:28:23 +02:00
wm4 1d6558d9c8 demux_mkv: get rid of the duplicated lace case labels
Also change the extracting of the lace type bitfield from flags to
make it more apparent that the value range is 0-3.
2013-04-20 23:28:22 +02:00
wm4 4b562bdf20 demux_mkv: there can be 256 laces
The lace number is stored with an offset of 1, so the maximum number
of laces is 255+1=256.
2013-04-20 23:28:22 +02:00
wm4 6ef855069f demux_mkv: check block malloc() result 2013-04-20 23:28:22 +02:00
wm4 9f21c81633 demux_mkv: use a bounded buffer for block data
Should help avoiding out-of-bounds reads.
2013-04-20 23:28:22 +02:00
wm4 c951010a26 demux_mkv: static allocation for lace sizes buffer
Avoid messy memory management and error handling.

remove tmp_lace_buffer non-sense

Not sure how my mind got 8k, or how this made sense at all.
2013-04-20 23:28:22 +02:00
wm4 6da399caeb demux_mkv: remove redundant check 2013-04-20 23:28:22 +02:00
wm4 b3d12c3d54 demux_mkv: fix seeking with index generation
Relative seeks backwards didn't work too well with incomplete files, or
other files that are missing the seek index. The problem was that the
on-the-fly seek index generation simply added cluster positions as seek
entries. While this is perfectly fine, the seek code had no information
about the location of video key frames. For example, a 5 second long
cluster can have only 1 video key frame, which is located 4 seconds into
the cluster. Seeking backwards by one second while still located in the
same cluster would select this cluster as seek target again. Decoding
would resume with the key frame, giving the impression that seeking is
"stuck" at this frame.

Make the generated index aware of key frame and track information, so
that video can always be seeked in an idea way. This also uses the
normal block parsing code for indexing the clusters, instead of the
suspicious looking special code. (This code didn't parse the Matroska
elements correctly, but was fine for files with normal structure. Files
with corrupted clusters or clusters formatted for streaming were not
handled properly.)

Skipping is now quite a bit slower (takes about twice as long as
before), but it removes the special cased skipping code, and it's still
much faster (at least twice as fast) than libavformat. It needs to do
more I/O (no more skipping entire clusters, all data is read), and has
more CPU usage (more data needs to be parsed).
2013-04-20 23:28:22 +02:00
wm4 9b4d15af18 demux_mkv: move Block header parsing code
Move parts of the Block element parsing to read_block(). This way
read_block() can return block time and track information in
struct block_info.
2013-04-20 23:28:22 +02:00
wm4 3fbd6d4e9c demux_mkv: split reading blocks and reading packets
Move most code from demux_mkv_fill_buffer() to read_next_block(). The
former is supposed to read raw blocks, while ..fill_buffer() reads
blocks and turns them into packets.
2013-04-20 23:28:21 +02:00
wm4 9afe9d7061 demux_mkv: move BlockGroup reading code to a separate function
Somehow this was setup such that a BlockGroup can be incrementally
read (at least in theory). This makes no sense, as BlockGroup can
contain only one Block (despite its name). There's no need to read
this incrementally, and makes the code confusing for no gain.

Read all the BlockGroup sub-elements with a single function call,
without keeping global state for BlockGroup parsing.
2013-04-20 23:28:21 +02:00
wm4 4e531d0f2a demux_mkv: factor block reading
The code for reading block data was duplicated. Move it into a function.

Instead of returning on error (possibly due to corrupt data) and
signalling EOF, continue by trying to find the next block. This makes
error handling slightly simpler too, because you don't have to care
about freeing the current block. We could still signal EOF in this case,
but trying to resync sounds better for dealing with corrupted files.
2013-04-20 23:28:21 +02:00
wm4 75178af8b4 demux_mkv: fix streaming clusters
Matroska files prepared for streaming have clusters with unknown size.
These files are pretty rare, see e.g. test4.mkv from the official
Matroska test file collection.
2013-04-20 23:28:21 +02:00
wm4 c2bf06f63e demux_mkv: simplify cluster reading code
The end positions of the current cluster and block were managed by
tracking their size and how much of them were read, instead of just
using the absolute end positions.

I'm not sure about the reasons why this code was originally written
this way. One obvious concern is reading from pipes and such, but the
stream layers hides this. stream_tell(s) works even when reading from
pipes. It's also a fast call, and doesn't involve the stream
implementation or syscalls. Keeping track of the cluster/block end is
simpler and there's no reason why this wouldn't work.
2013-04-20 23:28:21 +02:00
wm4 c4e43aaf89 demux_mkv: use normal index data structure even for incomplete files
Incomplete files don't have a valid index, because the index is usually
located near the end of a file. In this case, an index is created on the
fly during demuxing, or when seeks are done.

This used a completely different code path, which leads to unnecessary
complications and code duplication. Use the normal index data structure
instead. The seeking code at the end of seek_creating_index() (in this
commit renamed to create_index_until()) is removed. The normal seek code
does the same thing instead.
2013-04-20 23:28:21 +02:00
wm4 6d66a547a4 manpage: clarify --cache behavior 2013-04-20 23:25:55 +02:00
wm4 2d3f525cdf Merge pull request #62 from maletor/patch-1
Fix typo for opengl dither-depth default
2013-04-18 14:48:43 -07:00