Commit Graph

396 Commits

Author SHA1 Message Date
wm4 5b38a522f1 input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.

Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)

As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).

Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.

Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-06-29 22:58:13 +02:00
wm4 d4680aaecd command: make raw percent-pos property return fractions
percent-pos was an integer (0-100). Sometimes higher precision is
wanted, but the property is this way because fractional parts would
look silly with normal OSD usage. As a compromise, make percent-pos
double (i.e. includes fractional parts), but print it as integer.

So ${percent-pos} is like an integer, but not ${=percent-pos}.
2013-06-29 22:58:13 +02:00
wm4 a6a1f4b833 command: add properties for playlist position
playlist-pos can set/get the current playlist index. playlist-count
returns the number of entries in the playlist.
2013-06-29 22:58:12 +02:00
wm4 5f664d78e6 core: add libquvi 0.9 support
This adds support for libquvi 0.9.x, and these features:
- start time (part of youtube URL)
- youtube subtitles
- alternative source switching ('l' and 'L' keys)
- youtube playlists

Note that libquvi 0.9 is still in development. Although this seems to
be API stable now, it looks like there will be a 1.0 release, which is
supposed to be the next stable release and the actual successor of
libquvi 0.4.x.
2013-06-28 15:47:35 +02:00
wm4 ac79eb7337 core: rename mplayer.h and quvi.c
mplayer.h used to be used for much more stuff, but all what is left are
quvi related definitions. Rename quvi.c as well to make its purpose
clearer.
2013-06-28 15:40:28 +02:00
wm4 f296258de0 options: rename --mkv-subtitle-preroll, --dtshd
We still keep the old names as alias for short-time compatibility.
2013-06-28 15:26:30 +02:00
wm4 07131a9523 options: rename --rawvideo to --demuxer-rawvideo, same with --rawaudio 2013-06-28 15:14:51 +02:00
wm4 eb2b307788 options: rename -lavdopts to -vd-lavc, -lavfdopts to -demuxer-lavf
Also change manpage so that top-level options are documented instead
of suboptions. Suboptions still work, but might go away eventually.
2013-06-28 14:57:19 +02:00
wm4 0435ab7131 options: remove -lavdopts debug suboption
This can be set as avopt instead.
2013-06-28 14:42:06 +02:00
wm4 403a266d46 Merge branch 'sub_mess2'
...the return.
2013-06-25 00:43:04 +02:00
wm4 00de44eec9 options: add -sub-speed option
Should we actually get into trouble for unproper handling of
frame-based subtitle formats, this might be the simplest way to
work this around. Also is a bit more intuitive than -subfps, which
might use an unknown, misdetected, or non-sense video FPS.
Still pretty silly, though.
2013-06-25 00:34:58 +02:00
wm4 f48829b546 sub: libguess support for -subcp
Actually this is rather disappointing.
2013-06-25 00:11:57 +02:00
wm4 f735a03346 sub: add subtitle charset conversion
This code was once part of subreader.c, then traveled to libass, and now
made its way back to the fork of the fork of the original code, MPlayer.

It works pretty much the same as subreader.c, except that we have to
concatenate some packets to do auto-detection. This is rather annoying,
but for all we know the actual source file could be a binary format.

Unlike subreader.c, the iconv context is reopened on each packet. This
is simpler, and with respect to multibyte encodings, more robust.
Reopening is probably not a very fast, but I suspect subtitle charset
conversion is not an operation that happens often or has to be fast.

Also, this auto-detection is disabled for microdvd - this is the only
format we know that has binary data in its packets, but is actually
decoded to text. FFmpeg doesn't really allow us to solve this properly,
because a) the input packets can be binary, and b) the output will be
checked whether it's UTF-8, and if it's not, the output is thrown away
and an error message is printed. We could just recode the decoded
subtitles before sd_ass if it weren't for that.
2013-06-25 00:11:56 +02:00
wm4 cfa45c40dc sub: add demux_libass wrapper, drop old hacks
demux_libass.c allows us to make subtitle format detection part of the
normal file loading process. libass has no probe function, but trying to
load the start of a file (the first 4 KB) is good enough. Hope that
libass can even handle random binary input gracefully without printing
stupid log messages, and that the libass parser doesn't accept too many
non-ASS files as input.

This doesn't handle the -subcp option correctly yet. This will be fixed
later.
2013-06-25 00:11:56 +02:00
wm4 1bfae45a88 core: don't set correct-pts mode randomly
The default correct-pts mode depended on which demuxer was opened last.
Often this is the subtitle demuxer. The correct-pts mode should be
decided on the demuxer for video instead.
2013-06-25 00:11:56 +02:00
wm4 98388c0c07 subreader: turn into actual demuxer
subreader.c (before this commit renamed to demux_subreader.c) was
special cased to the -sub option. The plan is using the normal demuxer
codepath for all subtitle formats (so we can prefer libavformat demuxers
for most formats).

There are some subtle changes. The probe size is restricted to 32 KB
(instead of unlimitted + giving up after 100 lines of input). For
formats like MicroDVD, the video FPS isn't used anymore, because it's
not available on the subtitle demuxer level. Instead, hardcode it to
23.976 FPS (libavformat seems to do the same). The user can probably
still use -sub-fps to fix the timing. Checking the file extension for
".utf"/".utf8"/".utf-8" is simply removed (seems worthless, was in the
way, and I've never seen this anywhere).
2013-06-25 00:11:56 +02:00
wm4 db2e1ef4d2 Move/rename subreader.c 2013-06-25 00:11:54 +02:00
wm4 64b1374a44 sub: do some timing postprocessing on preloaded subs
This fixes the -subfps option (which unfortunately is still useful),
and fixes minor annoying timing errors (which unfortunately still
happen).

Note that none of these affect ASS or image subtitles. ASS is specially
handled: libass loads subtitles as ASS_Track. There are no actual
packets passed around, and sd_ass just uses the ASS_Track.

Disable the --sub-no-text-pp option. It's misleading now and always was
completely useless.
2013-06-23 22:33:59 +02:00
wm4 a70d575291 sub: preload external text subtitles
If a subtitle is external, read it completely and add all subtitle
events in advance when the subtitle track is selected. This is done
for text subtitles only. (Note that subreader.c and subtitles loaded
with libass are different and don't have anything to do with this
commit.)
2013-06-23 22:33:59 +02:00
wm4 a792f0d628 sub: remove redundant condition 2013-06-23 22:33:59 +02:00
wm4 4f5e12136d stream: remove padding parameter from stream_read_complete()
Seems like a completely unnecessary complication. Instead, always add a
1 byte padding (could be extended if a caller needs it), and clear it.

Also add some documentation. There was some, but it was outdated and
incomplete.
2013-06-23 22:33:59 +02:00
wm4 9a83d03c5d av_log: change how ffmpeg log messages are formatted
Don't print the ffmpeg context pointer as %p. This is usually useless
and confusing. Prefix all messages with "ffmpeg" to make clear that
ffmpeg is printing these messages, and not us.

If libavcodec is from Libav, use "libav" as prefix instead. (In theory,
FFmpeg/Libav libraries could be mixed, but I don't think that is
actually possible in practice.)
2013-06-22 20:34:47 +02:00
Rudolf Polzer 7e88dca2db encoding: use --start for ratios, etc.
Note: this currently only works for formats without pts resets. Other
formats will ignore this code.
2013-06-20 12:15:36 +02:00
Rudolf Polzer 1e58ccaaf0 command line: allow --o= to disable encoding (i.e. empty string file name) 2013-06-20 12:15:02 +02:00
Rudolf Polzer 011f54c68b encode_lavc: simplify encoding status output; remove percentage 2013-06-20 11:17:13 +02:00
wm4 d81b71c7f7 Merge branch 'cache_new' 2013-06-16 22:07:48 +02:00
wm4 236577af09 cache: use threads instead of fork()
Basically rewrite all the code supporting the cache (i.e. anything other
than the ringbuffer logic). The underlying design is untouched.

Note that the old cache2.c (on which this code is based) already had a
threading implementation. This was mostly unused on Linux, and had some
problems, such as using shared volatile variables for communication and
uninterruptible timeouts, instead of using locks for synchronization.

This commit does use proper locking, while still retaining the way the
old cache worked. It's basically a big refactor.

Simplify the code too. Since we don't need to copy stream ctrl args
anymore (we're always guaranteed a shared address space now), lots of
annoying code just goes away. Likewise, we don't need to care about
sector sizes. The cache uses the high-level stream API to read from
other streams, and sector sizes are handled transparently.
2013-06-16 22:05:09 +02:00
wm4 7c4202b863 cache: make the stream cache a proper stream that wraps other streams
Before this commit, the cache was franken-hacked on top of the stream
API. You had to use special functions (like cache_stream_fill_buffer()
instead of stream_fill_buffer()), which would access the stream in a
cached manner.

The whole idea about the previous design was that the cache runs in a
thread or in a forked process, while the cache awa functions made sure
the stream instance looked consistent to the user. If you used the
normal functions instead of the special ones while the cache was
running, you were out of luck.

Make it a bit more reasonable by turning the cache into a stream on its
own. This makes it behave exactly like a normal stream. The stream
callbacks call into the original (uncached) stream to do work. No
special cache functions or redirections are needed. The only different
thing about cache streams is that they are created by special functions,
instead of being part of the auto_open_streams[] array.

To make things simpler, remove the threading implementation, which was
messed into the code. The threading code could perhaps be kept, but I
don't really want to have to worry about this special case. A proper
threaded implementation will be added later.

Remove the cache enabling code from stream_radio.c. Since enabling the
cache involves replacing the old stream with a new one, the code as-is
can't be kept. It would be easily possible to enable the cache by
requesting a cache size (which is also much simpler). But nobody uses
stream_radio.c and I can't even test this thing, and the cache is
probably not really important for it either.
2013-06-16 22:05:09 +02:00
wm4 4d3a2c7e0d audio/out: remove ao->outburst/buffersize fields
The core didn't use these fields, and use of them was inconsistent
accross AOs. Some didn't use them at all. Some only set them; the values
were completely unused by the core. Some made full use of them.

Remove these fields. In places where they are still needed, make them
private AO state.

Remove the --abs option. It set the buffer size for ao_oss and ao_dsound
(being ignored by all other AOs), and was already marked as obsolete. If
it turns out that it's still needed for ao_oss or ao_dsound, their
default buffer sizes could be adjusted, and if even that doesn't help,
AO suboptions could be added in these cases.
2013-06-16 19:36:56 +02:00
Stefano Pigozzi bff03a181f core: add a spsc ringbuffer implementation
Currently every single AO was implementing it's own ringbuffer, many times
with slightly different semantics. This is an attempt to fix the problem.

I stole some good ideas from ao_portaudio's ringbuffer and went from there.
The main difference is this one stores wpos and rpos which are absolute
positions in an "infinite" buffer. To find the actual position for writing /
reading just apply modulo size.

The producer only modifies wpos while the consumer only modifies rpos. This
makes it pretty easy to reason about and make the operations thread safe by
using barriers (thread safety is guaranteed only in the Single-Producer/Single-
Consumer case).

Also adapted ao_coreaudio to use this ringbuffer.
2013-06-16 18:20:39 +02:00
Rudolf Polzer dcd36c79c7 encode_lavc strings: use new option syntax 2013-06-16 17:14:47 +02:00
John Hawthorn f2cd4a0e75 mplayer: update window title if its properties change
This allows having properties like time-pos in the window title update
properly. There is a danger of this causing significant CPU usage,
depending on the properties used and the window manager.
2013-06-16 06:17:44 +02:00
wm4 168a595bfe video/out: introduce VOCTRL_UPDATE_WINDOW_TITLE
Instead of implicitly changing the window title on config(), do it as
part of the new VOCTRL.

At first I wanted to make all VOs use the VOCTRL argument directly, but
on a second thought it appears vo_get_window_title() is much more useful
for some (namely, if the window is created lazily on first config()).

Not all VOs are changed. Wayland and OSX have to follow.
2013-06-15 19:07:21 +02:00
wm4 60a0c450eb command: use more standard time format for clock property
%k is not very standard. The manpage notes them as conforming to
"Olson's timezone package", and it's not standard C89, C99 or POSIX.
mingw doesn't provide it, and even some of the smaller Linux libcs
don't have support.

Use %H instead. This gives slightly different results, but I think
this is ok. Difference in behavior between these summarized:

  %k: "single digits are preceded by a blank"
  %H: "range 00 to 23"
2013-06-14 00:46:28 +02:00
wm4 f1d3ba0e33 x11: enable screensaver when paused, rename/change --stop-xscreensaver
Use the recently introduced screensaver VOCTRLs to control the
screensaver in the X11 backend. This means the behavior when paused
changes: the old code always kept the screensaver disabled, but now the
screensaver is reenabled on pausing.

Rename the --stop-xscreensaver option to --stop-screensaver and make it
more generic. Now it affects all backends that respond to the
screensaver VOCTRLs.
2013-06-14 00:37:39 +02:00
wm4 648c3d790a core: introduce separate VOCTRLs for screensaver stop/resume
This is slightly better because VOCTRL_RESUME/VOCTRL_PAUSE are usually
needed by VOs to know whether video is actually being played (for
whatever reason), and they wouldn't be passed to the backend's VOCTRL
handler, like vo_x11_control().

Also try to make sure that these flags (both pause state and screensaver
state) are set consistently in some corner cases. For example, it seems
enabling video in the middle of playing a file while the player is
paused would not set the paused flag.

If codec initialization fails, destroy the VO instead of keeping it
around to make sure the state is consistent.

Framestepping is implemented by unpausing the player for the duration of
a frame. Remove the special handling of VOCTRL_PAUSE/RESUME in these
cases. It was most likely needed because these VOCTRLs used to be
important for screen redrawing (blatant guess), which is now handled
completely differently. The only potentially bad side-effect is that the
screensaver will be disabled/reenabled for the duration of one frame.
2013-06-14 00:37:39 +02:00
Rudolf Polzer 297aad1f3b support "-" as file name when encoding
This workaround sucks. avio just does not support "-" - and ffmpeg's
command line binaries work around it. FOUR TIMES. DIFFERENTLY.

WHY DOESN'T AVIO DO THIS RIGHT TO BEGIN WITH?
2013-06-13 18:40:36 +02:00
wm4 a9bbe0a576 options: remove --stereo
Whatever this was supposed to be originally, it doesn't have much value
anymore. It just forced ad_mpg123 to upmix mono to stereo by default
(the audio chain can do that). As an option, it was mostly useless and
misleading, so get rid of it.
2013-06-13 00:59:27 +02:00
wm4 c7742e24f6 mplayer: save sub-visibility property 2013-06-13 00:58:08 +02:00
wm4 4a5d1f2d44 mplayer: try to handle PTS forward jumps
Raw MPEG streams can contain PTS discontinuities. While the playback
core  has obvious code for handling PTS going backward, PTS going
forward was as far as I can see not handled.

This can be an issue with DVD playback. This wasn't caught earlier,
because DVD playback was just recently switched to demux_lavf, which
implies -no-correct-pts mode. This mode doesn't use PTS in the same way
as the normal playback mode, and as such was too primitive to be
affected by this issue.

Use the following heuristic to handle PTS forward jumps: if the PTS
difference between two frames is higher than 10 seconds, consider it a
reset. (Also, use MSGL_WARN for the PTS discontinuity warnings.)

In this particular case, the MPEG stream was going from pts=304510857
to pts=8589959849 according to ffprobe (raw timestamps), which seems a
bit strange.

Note that this heuristic breaks if the source video has unusually high
frame times. For example Rooster_Teeth_Podcast_191.m4a, an audio file
with a slide show encoded as MJPEG video track.
2013-06-13 00:54:20 +02:00
wm4 ff832dd149 options: fix compilation on Windows
Closes github issue #107. (Hopefully.)
2013-06-11 12:24:11 +02:00
wm4 6c3a1f68ff command: fix empty metadata case
show_text "${metadata}" crashed if no metadata was set.
2013-06-11 12:24:11 +02:00
wm4 005375bb7d core: use STREAM_CTRL instead of accessing stream_dvd internals
Some code in mplayer.c did stuff like accessing (dvd_priv_t *)st->priv.
Do this indirectly by introducing STREAM_CTRL_GET_DVD_INFO. This is
extremely specific to DVD, so it's not worth abstracting this further.

This is a preparation for turning the cache into an actual stream, which
simply wraps the cached stream. There are other streams which are
accessed in the way DVD was, at least TV/radio/DVB. We assume these
can't be used with the cache. The code doesn't look thread-safe or fork
aware.
2013-06-09 22:06:02 +02:00
Rudolf Polzer 0cbc75c083 Option -omaxfps: limit fps when encoding
Lower-fps content is left alone (NOT aligned to this fps); higher fps
content is decimated to this frame rate.
2013-06-09 15:37:28 +02:00
wm4 667c8352f3 core: make options.c compile standalone
This also removes the split between "mplayer" and "common" opts (common
opts used to be shared between mencoder and mplayer).
2013-06-08 17:08:20 +02:00
wm4 96338c6c17 core: rename cfg-mplayer.h to options.c 2013-06-08 17:08:20 +02:00
wm4 757c6d0394 core: merge defaultopts.c into cfg-mplayer.h
There isn't really any reason why this should be in a separate source
file.
2013-06-08 17:08:20 +02:00
wm4 c185b0ba4a command: replace some show_ commands with properties
show_chapters, show_tracks, and show_playlist are killed and replaced
with the properties chapter-list, track-list, and playlist. The code
and the output of these stays the same, this is just moving a lot of
code around and reducing the number of properties.

The "old" commands will still be supported for a while (to avoid making
everyone angry), so handle them with the legacy layer. Add something to
suppress printing the legacy warnings for these commands.
2013-06-07 18:00:34 +02:00
wm4 b15143b7e0 command: human readable output for metadata property
Slightly better output when printing ${metadata}. Print each metadata
item as "name: value", instead of the raw list. It's still not very
great, though. The old format is still available through ${=metadata}
for things which dare to use the broken slave mode.
2013-06-07 17:49:35 +02:00
wm4 812798c5ac core: reset pause state by default when going to next file
Apparently this behavior is more intuitive/better to users.
2013-06-07 17:07:04 +02:00