Commit Graph

34922 Commits

Author SHA1 Message Date
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
Ellis Berner 4beedec44d Fix typo for opengl dither-depth default 2013-04-18 14:41:32 -07:00
Stefano Pigozzi 9a6e6b2fc2 cocoa_common: keep aspect ratio when clipping window
With commit 33ffc283 resizing to double size would cause the window to lose
aspect ratio. This commit fixes this bug.
2013-04-17 21:22:22 +02:00
Stefano Pigozzi 22d53fb97c change reverse DNS strings to io.mpv.*
fixes #60
2013-04-16 23:34:58 +02:00
Stefano Pigozzi 33ffc28373 cocoa_common: refactor centered resize
This refactor makes the code easier to understand. Also corrects a bug that
caused the window to move to the left when the new size was bigger than the
visible frame.
2013-04-16 22:51:01 +02:00
Rudolf Polzer 0c1d95e81b encoding: when output is pipe: or pipe:1, avoid mp_msg to stdout
I am aware this detection may occur too late, depending on other
settings, but at least it usually works and is portable.

Where the output fd can be changed, though, it'd be better to force a
similar behaviour via file descriptor use: use pipe:3 as output to FD 3,
and change the calling program to expect the stream on FD 3.
2013-04-15 13:30:21 +02:00
wm4 df8a481eba sub: add --osd-blur and --sub-text-blur options
These require bleeding edge libass (latest git version), and will be
ignored otherwise.

I'm not sure about the blur factor and scaling. The ASS/VSFilter
semantics for blur scaling are a bad mess. Might require further
investigation.
2013-04-13 18:53:03 +02:00
wm4 3097176ff1 audio/decode: remove vararg from ad_control()
This was unused and dumb. Ancient MPlayer used varargs instead of void*
arguments for control() functions, and this was the last leftover.
2013-04-12 20:35:59 +02:00
wm4 ad3dfa145b osd_libass: actually free ASS_Tracks
Not a real leak, just for getting clean valgrind reports on exit.
2013-04-12 19:02:58 +02:00
wm4 203b57d863 demux: simplify chapter appending code
This pre-allocation looked tricky and awkward. Use MP_TARRAY_APPEND(),
which makes the code simpler. This even keeps the pre-allocation.
2013-04-12 14:38:22 +02:00
wm4 6f28c061b4 demux: always sort chapters
The condition that checked whether the chapters are out of order and
should be sorted was inverted. This likely wasn't noticed in testing,
because even if the chapters are unsorted, if the last two chapters
were sorted, the rest got sorted too.

Instead of doing this silly check, always sort the chapters after
demuxer initialization. Also make sure the sort order is stable in case
chapter start times are the same (original_index check).
2013-04-12 14:38:04 +02:00
wm4 a5916f5d1d core: remove dead --vsync leftovers 2013-04-12 14:36:26 +02:00
wm4 90e57fc266 command: fix deref before NULL check
Was accidentally broken in the last global variable removal round.
2013-04-12 14:34:46 +02:00
Stefano Pigozzi ed48c657ee ao_jack: fix deprecation warning
jack_port_get_total_latency is deprecated: use the "new" API based on
jack_port_get_latency_range instead.
2013-04-12 00:10:39 +02:00
wm4 37a424ed10 mplayer: remove unnecessary variable 2013-04-10 21:32:46 +02:00
wm4 9df2260506 core: add --reset-on-next-file option
This option can be used to selectively reset settings when playing the
next file in the playlist (i.e. restore mplayer and mplayer2 behavior).

Might remove this option again should it turn out that nobody uses it.
2013-04-10 21:32:46 +02:00
wm4 62daa08d3b mplayer: keep volume persistent, even when using --volume
Consider:

    mpv --volume 10 file1.mkv file2.mkv

Before this commit, the volume was reset to 10 when playing file2.mkv.
This was inconsistent to most other options. E.g. --brightness is a
rather similar case.

In general, settings should never be reset when playing the next file,
unless the option was explicitly marked file-local. This commit
corrects the behavior of the --volume and --mute options.

File local --volume still works as expected:

    mpv --{ --volume 10 file1.mkv file2.mkv --}

This sets the volume always to 10 on playback start.

Move the m_config_leave_file_local() call down so that the mixer code
in uninit_player() can set the option volume and mute variables without
overwriting the global option values.

Another subtle issue is that we don't want to set volume if there's no
need to, which is why the user_set_volume/mute fields are introduced.
This is important because setting the volume might change the system
volume depending on other options.
2013-04-10 21:29:04 +02:00
wm4 2c3e5428c2 mplayer: move DVB channel skip code
Try not to cause unnecessary special cases.
2013-04-10 18:50:19 +02:00