Commit Graph

34860 Commits

Author SHA1 Message Date
wm4 4873c798b6 manpage: document --native-keyrepeat
Forgotten in commit d853aba.
2013-04-24 21:37:10 +02:00
wm4 2337bc9d9b demux_mkv: cosmetics 2013-04-24 21:33:33 +02:00
wm4 ff549a2f6a core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.

This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.

This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.

There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)

Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 20:27:12 +02:00
wm4 40f822782d mplayer: apply hrseek framedrop only when doing hrseek
It's not sure if there's anything that could trigger this accidentally.
Normally this can't happen, because hrseek ends always if the PTS is
large enough, the same condition which disables framedrop. Seeking
resets hrseek framedrop anyway.

On the other hand, this change makes the code easier to understand,
and might be more robust against weird corner cases.
2013-04-24 20:25:04 +02:00
wm4 d853abafc3 x11: use mpv internal key auto-repeat handling if possible
Block X11's native key repeat, and use mpv's key repeat handling in
input.c instead.

No configure check for XKB. Even though it's an extension, it has been
part of most (all?) xlibs since 1996. If XKB appears to be missing,
just refuse enabling x11.

This is a potentially controversial change. mpv will use its own key
repeat rate, instead of X11's. This should be better, because seeking
will have a standardized "speed" (seek events per seconds when keeping
a seek key held down). It will also allow disabling key repears for
certain commands, though this is not done anywhere yet.

The new behavior can be disabled with the --native-keyrepeat option.
2013-04-24 18:07:01 +02:00
wm4 97be5ead14 input: don't reset time on each key repeat
Key repeats were skipped when playloop iterations took too long. Fix
this by using the total times for key repeat calculation, instead of the
time difference to the last key repeat event.
2013-04-24 18:07:01 +02:00
wm4 003a930285 input: adjust wait time for key-repeat
Basically, these are additional timers that can expire without making
the central select() exit.
2013-04-24 17:46:40 +02:00
wm4 040f95d0f1 input: change default auto-repeat settings
Rather arbitrary, but reasonable.
2013-04-24 17:46:40 +02:00
wm4 6ca7b80750 input: don't let multi-key bindings block simple key bindings
Key bindings can include mutiple keys at once (additional to key
modifiers like ctrl etc.). This becomes annoying when quickly switching
between two bound keys, e.g. when seeking back and forth, you might end
up hitting the "left" and "right" keys at once. The user doesn't expect
to invoke the key binding "left-right", but would prefer a key stroke to
invoke the binding it was supposed to invoke.

So if there's no binding for a multi-key combination, try to find a
binding for the key last held down. This preserves the ability to define
multi-key combinations, while the common case works as expected.
2013-04-24 17:46:40 +02:00
wm4 4ab283efe6 input: reduce amount of tracked keys per binding
There's no need for key bindings that consist of 32 keys held down. It's
ridiculous and wastes memory.
2013-04-24 17:46:40 +02:00
wm4 274af12694 input: fix handling of MP_KEY_STATE_DOWN
VOs can use the MP_KEY_STATE_DOWN modifier to pass key up/down events to
input.c, instead of just simple key presses. This allows doing key auto-
repeat handling in input.c, if the VO doesn't want to do that.

One issue is that so far, this code has been used only for mouse events,
even though the code was originally written with keyboard keys in mind.
One difference between mouse keys and keyboard keys is that the initial
key down should not generate an input command with mouse buttons
(input.c did that), while keyboard events should (input.c didn't do
that). Likewise, releasing a key should generate input commands for
mouse buttons releases, but not for the keyboard.

Change the code so mouse buttons (recognized via the MP_NO_REPEAT_KEY
flag) follow the old hehavior, while other keys generate input commands
on key down, but not on key release.

Note that a key release event is posted either using
MP_INPUT_RELEASE_ALL, or a normal key press event after having sent a an
event with MP_KEY_STATE_DOWN. This is probably a bit confusing, and a
MP_KEY_STATE_RELEASE should be added.

Fix shift-handling with MP_KEY_STATE_DOWN as well.
2013-04-24 17:46:40 +02:00
wm4 36c31f47b2 demux_mkv: fix out of range comparison
This check was always false:

    if (num == EBML_UINT_INVALID)

Fix it by using the proper type for the num variable.

This case actually doesn't really matter, and this is just for hiding
the warning and for being 100% correct.
2013-04-24 16:19:18 +02:00
wm4 50ce2bd6c8 m_option: fix positional sub-option skipping
Empty sub-option parameters mean the sub-option should be skipped,
e.g. -vf gradfun=:10 sets the second option (by position) to 10. This
was broken in commit 04f1e2d.
2013-04-23 14:21:08 +02:00
wm4 355b980a72 vo_opengl_old: remove nomanyfmts warning
The VO warns by default that the nomanyfmts option should be used if
video display fails. This is almost completely useless, but people
keep asking what it means.
2013-04-23 14:18:23 +02:00
wm4 d638a8eda8 manpage: remove references to --no-slices
Background: slice support has been completely removed, because it
doesn't work with multithreading, and provides a rather bad complexity
to performance tradeoff otherwise.
2013-04-23 14:16:06 +02:00
wm4 7bb3929a5d configure: enable libavdevice by default
Used to be disabled by default, because libavdevice depends on
libavfilter, and earlier versions of libavfilter exports symbols that
clash with mpv's due to its MPlayer filter wrapper. Our configure script
explicitly detects these symbols now, and we can use that to safely
auto-detect libavdevice too. If we detect that libavfilter can't be
safely used, libavdevice is disabled as well.
2013-04-23 14:11:43 +02:00
wm4 c8df1799d9 m_option: allow quoted positional parameters for -vf
This allows things like:

    '--vf=lavfi="gradfun=20:30"'

Adjust the documentation for vf_lavfi to make the example less verbose.
As an unrelated change, add a general description to vf_lavfi.
2013-04-23 14:10:43 +02:00
wm4 7979718159 vf_lavfi: add libavfilter bridge
Requires recent FFmpeg/Libav git versions. Earlier versions will not
be supported, as the API is different. (A libavfilter version that
uses AVFrame instead of AVFilterBuffer is needed.)

Note that this is sort of useless, because the option parser prevents
you from making use of the full libavfilter graph syntax. This has to be
fixed later.

Most of the filter creation code (half of the config() function) has
been taken from avplay.c.

This code is not based on MPlayer's vf_lavfi. The MPlayer code doesn't
compile as it hasn't been updated through multiple libavfilter API
changes, making it completely useless as a starting point.
2013-04-21 04:39:58 +02:00
wm4 778e9c0633 mp_image: provide function to convert mp_image to AVFrame
Note that this does not pass through QP information (qscale field).
The only filter for which this matters is vf_pp, and we have this
natively.
2013-04-21 04:39:58 +02:00
wm4 04f1e2dc43 m_option: redo code for parsing -vf to accept quotes
Parsing sub-configs (like --rawvideo=subopts or the suboptions for
--vo=opengl:subopts) was completely different from the -vf parsing code
for a variety of reasons. This change at least makes -vf use the same
splitter code as sub-config options.

The main improvement is that -vf now accepts quotes, so you can write
things like:

     -vf 'lavfi=graph="gradfun=10:20"'

(The '' quotes are for shell escaping.)

This is a rather big and intrusive change. Trying some -vf lines from
etc/encoding-example-profiles.conf seems to confirm it still works.

This also attempts to unify one subtle difference in handling of
positional arguments. One consequence is that a minor detail changes.
Sub-configs don't know positional arguments, and something like "--
opt=sub1=val1:sub2" means that sub2 has to be a flag option. In -vf
parsing, sub2 would be a positional option value. To remove this
conflict and to facilitate actual unification of the parsers in the
future, the sub2 will be considered a flag option if and only if such a
flag option exists. Otherwise, it's considered a value for a positional
option.

E.g. if there's a filter "foo" with a string option "sopt" and a flag
option "fopt", the behavior of the following changes:

   -vf foo=fopt

Before this commit, this would set "sopt=fopt" in the filter. Now, it
enables the fopt flag, and the sopt option remains unset. This is not an
actual problem to my knowledge.
2013-04-21 04:39:57 +02:00
wm4 9fd2e449de m_option: add function to check whether parameters are required
To avoid that it will be duplicated with m_option.c and m_config.c.
2013-04-21 03:48:30 +02:00
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