Commit Graph

47918 Commits

Author SHA1 Message Date
wm4 3cabd11f9b vo_gpu: hwdec_vaapi_gl: add missing PLANE3 defines as well
On systems whose EGL headers do not define these extensions, the build
still failed due to missing ..._PLANE3_... defines. Although we supplied
missing EGL_LINUX_DMA_BUF_EXT defines manually, the PLANE3 ones are
actually from a separate extension, which explains why they were not
added to the fallback defines in the first place.

Add them, now it builds without the eglext.h include.

See #6838.
2019-12-07 14:01:10 +01:00
wm4 23289a452f command: fix unintended reset of filters
Since the recent option changes (probably b16cea750f), using the "vf"
or "af" commands to change the filter chain did not write the option
value correctly. This led to the option value being reset the next time
an option changed.

This happened because the new option value was not copied to the
m_config_cache's internal storage. So on the next option update, it
looked like the option value changed, because the user-side value was
different from the internal value. It was copied back, which meant the
original option value was reinstated, and the previous "vf"/"af" command
was undone.

Fix this by using the correct way to store the option value. This also
takes care of property change notification (because the function is
specifically separate from m_config_cache_write_opt() to do that), so
remove the old call.

Fixes: #7220
2019-12-06 19:27:45 +01:00
wm4 b0c9f582ad player: loadfile overrides previous stop command
Both the "stop" and "loadfile" commands are asynchronous. "stop" starts
terminating playback, which used to be done in the same playloop
iteration, but now it may take longer, so a "loadfile" command can be
received while this is going on. (Possible that it used to work if the
second command was issued at least in the next playloop iteration.)

Make the "loadfile" override the "stop" mode, so the next file will be
played, instead of quitting or going into idle mode.

Unlike the referenced bug report claims, this has nothing to do with
IPC.

Fixes: #7225
2019-12-06 19:21:14 +01:00
wm4 13fe87f66b build: fix zimg message in configure output
It's useful as software scaler in general, not just that video filter.
2019-12-06 19:16:30 +01:00
ekisu 02d8d4e3ef f_lavfi: mp_lavfi_is_usable: check for "lavfi-" prefix
Without this, adding filters with the prefix would fail, and some
filters that have conflicting names with mpv ones were unusable.
2019-12-06 19:12:57 +01:00
dudemanguy 122bbb9ff4 DOCS: fix wayland-frame-wait offset value range
It actually goes down to -500 not -100.
2019-12-05 14:35:23 -06:00
wm4 000c045aa8 vo: redraw dropped frame if paused between queuing and drawing frame
When frame-stepping with display-sync mode enabled in high framerate
video, the frame was sometimes not redrawn correctly. Only the first OSD
interaction (or something similar) made it visible.

In this case, the core schedules many frames as dropped (because it's
ignorant of pausing/frame-stepping, as in theory the player is _not_
paused during frame-stepping, only at the end of it). There's a race
between the VO rendering the queued frame, and the core calling
vo_set_paused() after it has queued the frame. If the latter happens
first, the existing logic to redraw the previous dropped frame does
things correctly. If the former happens, the frame is not redrawn
automatically, but will be redrawn on the next user input (or if OSD is
enabled, and the pause state change updates it, which leads to an
immediate redraw).

Fix this by never actually dropping a frame in paused mode. The request
by the core to drop it is simply ignored.

Maybe this could be done slightly nicer by updating the pause state with
the VO atomically. Then we wouldn't have the frame drop counter going up
either (it's actually dropped, but then redrawn; but I doubt any user,
or me in a few weeks, would understand this). But I'm not really
interested in polishing this by increasing the complexity of the
frame-step code.
2019-12-04 23:55:42 +01:00
Remita Amine c23b3ac53a README: fix typo 2019-12-04 16:20:40 +01:00
Philip Langdale 353e4efdef osc: rework window control configuration to add auto mode
To aid in discoverability, and to address the most common case
directly, I'm adding an 'auto' mode for the window controls. In
this case, we will show the controls if there is no window border
and hide them if there are borders. This also respects the option
being toggled at runtime.

To ensure that it works in the wayland case, I've also made sure
that the wayland code explicitly forces the option to false if
decoration support is missing.

Based on feedback, I've split the config in two, with one option
for whether controls are active, and one for alignment. These are
new enough that we can get away with ignoring compatibility.
2019-12-04 09:32:25 +08:00
Philip Langdale f8689eff6d osc: ensure that window control show/hide zone is handled dynamically
As preparation for adding the auto mode for window controls, we need
to make sure that the controls can be successfully toggled at runtime,
rather than only being able to configure them once at startup. Right
now, there is a problem with the handling of the show/hide zone for
the window controls.

The previous fix for #7212 was to avoid registering the input mapping
for the window control show/hide zone. If there is no input mapping,
then there is no input, and the zone is a no-op, even if it exists.
But this only happens at startup. After that point, the input mapping
doesn't exist and cannot be turned on.

In this change, I'm switching the approach; we now go back to always
registering the input mapping, and instead, we zero out the show/hide
zone if window controls are disabled, and set its size appropriately
if they are enabled.
2019-12-04 09:32:25 +08:00
dudemanguy 7f300a00e9 wayland: fix cursor behavior on an edge case
This small regression was introduced by #7216. Previously, the wayland
backend used a trick which kept track of the previous fullscreen state
and used that logic for showing the cursor. Since vo_opts now keeps
track of the current fullscreen state, most of this stopped being
neccessary.

However, there was one edge case where the cursor didn't
behave the same: passing a fullscreen flag for the inital window. The
cursor would initially be visible here which is not desirable. This can
be remedied pretty easily by just setting the cursor visiblity to false
if the pointer entry event occurs on fullscreen. The only thing we need
to do is to make sure that the autohide delay isn't completely disabled
(i.e. the cursor is always visible). Hence the need for the previous
commit.
2019-12-04 00:47:05 +00:00
dudemanguy 65a317436d options: move cursor autohiding opts to mp_vo_opts
Certain backends (i.e. wayland) will need to do special things with the
mouse. It makes sense to expose the values of these options to them, so
they can behave correctly.
2019-12-04 00:47:05 +00:00
wm4 fd28be400c sd_lavc: add a hack ontop of another hack to fix completely fucked file
Do what we do best in multimedia: add conflicting hacks on top of other
hacks, that fix a single sample, and may break other ones.

In this case, it only happens if the file is most likely already broken
(subtitle bounding boxes go outside of the subtitle "canvas"), so it's
OK. The file still looks broken (and, in fact, the file is completely
fucking broken), but you can see the subtitles.

But in summary, this is not actually something I should have bothered
about.

I noticed that MPlayer shows the subtitles "correctly", but this is only
because they have a hack that extends subtitles with small resolution to
a larger hardcoded resolution. This hack was removed from mpv, because
it broke some completely legitimate files. As another really funny fact,
MPlayer's default video output (vdpau) appears to display this file
correctly, but only because it handles narrow aspect ratios (that extend
the height instead of the width) incorrectly. It extends the height, but
leaves the video with 1:1 aspect ratio at the top. It seems to repeat
the last video line. (-vo xv and -vo gl show it correctly, i.e.
stretched like mpv, by the way.) For some reason, the sample file at
hand is extended with black, so the subtitles are rendered into a black
area below the video, which is almost reasonable. So, MPlayer may
display this file "correctly", but in fact it only happens to do so
because of 1 hack that breaks legitimate files, and 1 bug. What the
fuck.

Fixes: #7218 (sort of)
2019-12-03 22:33:45 +01:00
wm4 e5b016b7bf player: don't apply weird timestamp tolerance on backstep
Hr-seek has some sort of tolerance against timestamps, where it allows
for up to 5ms deviation. This means it can work only for videos with up
to 200 FPS framerate. There were complains about how it doesn't work
with videos beyond some high fps. (1000 was mentioned, although that
sounds more like it's about the limit that .mkv has.)

I suspect this is because otherwise, it might be hard to hit a timestamp
with --start, which specifies timestamps as integer, and thus will most
likely never represent a timestamp exactly. Another part of the problem
is that mpv uses 64 bit floats for timestamps, so fractional parts are
never represented exactly. (Both the "tolerance" and using floats for
timestamps were things introduced before my time.)

Anyway, in the backstep case, we can be relatively sure that the
timestamp will be exact (as in, the same unmodified value that was
returned by the filter chain), so we can make an exception for that, in
order to fix backstep.

Untested. (For that you have users.)

May help with #7208.
2019-12-03 21:43:32 +01:00
wm4 d60bbd86e3 demux_lavf: export demuxer_id for more formats which have it
See previous commit. libavformat exports this information as AVStream.id
field.

The big problem is that the libavformat field is simply 0 if it's
unknown (i.e. the demuxer never sets it). So it needs to remain a
whitelist. Just add more formats which are known to have a meaningful
ID.

I considered exporting IDs for all formats, and then either leaving the
values as they are, or filtering duplicate values (and choosing
arbitrary but unique different IDs). But then again, I think it's sort
of mpv's job to filter FFmpeg's absurd bullshit API, and it should make
an effort to hide it rather than to reflect it.

See: #7211
2019-12-03 21:15:40 +01:00
wm4 370ed5777c demux: do not make up demuxer_id
The demuxer_id (exported in as "src-id" property) is supposed to be the
native stream ID, as it exists in the file, or -1 if that does not exist
(actually any negative value), or if it is unknown.

Until now, an ID was made up if it was missing. That seems like strange
non-sense, and I can't find the reason why it was done. But it was
probably for convenience by the EDL stuff or so.

Stop doing this. Fortunately, the src-id property was documented as
being unavailable if the ID is not known. Even the code for this was
present, it was just inactive until now. Extend input.rst with some
explanations.

Also fixing 3 other places where negative demuxer_id was ignored or
avoided.
2019-12-03 21:04:53 +01:00
Philip Langdale b6f605285c wayland: update remaining legacy VOCTRL usage to options
The remaining legacy VOCTRLs are for the fullscreen and border
properties. For fullscreen this largely just replacing the private
state field with the vo option but there are small semantic
differences that we need to be careful of.

For the border setting, it's trivial as we don't have external
mechanisms for changing the state, but I also can't test it as
I'm not using a compositor that supports it.
2019-12-02 14:14:09 +00:00
Philip Langdale 193b6fd8dd osc: don't show error if windowcontrols=yes
I always intended for this to be accepted and mean "right" but I
made it show an error for any value that's not explicitly
recognised (while considering all unrecognised values to mean "right").

So let's explicitly recognise "yes".
2019-12-02 11:04:43 +08:00
Dudemanguy 7da15ca9bd osc: don't always set window control keybindings
Only set the window control keybindings if the window control option is
actually enabled. Fixes #7212.
2019-12-01 17:23:02 -06:00
Philip Langdale 61b8e1d436 wayland: update Maximize and Minimize handling to use new options
I wanted to get this done quickly as I introduced the new VOCTRL
behaviour for minimize and maximize and it was immediately made
legacy, so best to purge it before anyone gets confused.

I did not sort out fullscreen as that's more involved and not something
I've educated myself about yet. But I did replace the VOCTRL_FULLSCREEN
usage with the new option change mechanism as that seemed simple
enough.
2019-12-01 09:39:51 +08:00
wm4 78f1629a53 vf_gpu: render subtitles
Pretty annoying affair. The vo_gpu code could of course not trigger
rendering from filters yet, so it needed to be extended. Also, this uses
some icky stuff made for vf_sub (and this was the reason I marked vf_sub
as deprecated), so everything is terrible.
2019-11-30 18:09:31 +01:00
wm4 6a88e7463e build: require at least GL 2.0 headers for GLX
The previous hack for fixing #7201 requires this, but it wasn't checked.
It's easy to check, so do it. (Yes, we could just have required OpenGL
3.2 headers and skipped the earlier fix.)

For #7201.
2019-11-30 17:37:56 +01:00
wm4 cd9fe3a843 m_config: remove change callback before unintialization
We don't want m_config uninitialization to call random change callbacks.
This happens at the end of mp_destroy(), when almost everything else is
already destroyed, and the change callbacks would probably trigger UB
all over the place.

The change callbacks could be trigger by m_config_restore_backups(),
which is just used as a cheap way to free the remaining state. The worst
is that this depends on which options may still have been part of this
"backup" state, which depends on user input.

Probably never a practical problem, since the backup state is most
likely guaranteed to be empty before uninit is performed, but still.
2019-11-30 17:33:29 +01:00
wm4 fa9a1ff0a0 vo_gpu: opengl: add hack for ancient Mesa/GLX
glx.h recursively includes gl.h, and there is no way to prevent this.
Old Mesa defines some GL symbols, but not all which mpv needs. In
particular, one user who was too lazy to update his ancient Ubuntu and
preferred to bother us with obscure bug reports, had Mesa headers which
did not define GL 3.2, so GLsync was not defined.

All in all I still think the idea of providing the GL API definitions
ourselves was a good idea; just GLX should have been isolated better.
But isolating GLX now is too much effort.

Not sure why I'm bothering with this at all.

Fixes: #7201 (unconfirmed)
2019-11-30 13:38:28 +01:00
Philip Langdale 8614cb38d9 osc: ensure the window-controls mouse area is initially zero sized
This is necessary to avoid breaking input behaviour in the 'idle'
state when not playing a video. Otherwise, the mouse area starts off
covering the whole window and blocks normal input.
2019-11-30 19:56:30 +08:00
Avi Halachmi (:avih) b67d124dc0 js: mp.add_key_binding: allow false-y name (match 311cc5b)
This is in addition to the allowed omission of name and/or flags (as
documented).
2019-11-30 12:23:47 +02:00
Avi Halachmi (:avih) abf6b22abd lua: unbreak mp.add_key_binding(key, fn)
Commit 311cc5b6 added the ability use flags while omitting name, but
broke the case where both name and flags are omitted.

Now omitting either name or flags or both works as documented.
2019-11-30 12:06:22 +02:00
Philip Langdale 2750ca597c osc: fix typo wsc_geo -> wc_geo 2019-11-30 09:14:49 +08:00
Philip Langdale 971dbcc21c osc: apply boxvideo margins to the window controls
It seems logical to account for the window controls if `boxvideo`
is in use (which has the effect of reducing the size of the video
so that the osc is not covering the video).
2019-11-30 08:56:29 +08:00
wm4 cb7048700f filters: fix incorrect #if for vf_gpu
This didn't match what is in wscript_build.py. Also, it should work on
non-X11 platforms... probably. (The condition is convoluted and almost
nonsensical, but the offscreen context creation needs to be cleaned up
anyway as soon as other backends, e.g. for win32, are added.)
2019-11-30 01:13:37 +01:00
wm4 0e376150a6 command: remove property change notification from property dispatcher
Properties should handle this themselves. This basically sent redundant
notifications. I found only two places where the "proper" notification
was missing.
2019-11-30 01:07:24 +01:00
wm4 464a045ed8 command: merge two functions
Due to recent changes, it makes no sense anymore to keep them separate.
2019-11-30 00:56:23 +01:00
wm4 56b06907a6 command: remove another unneeded hack
Now that the option-to-property bridge is gone, this is not needed
anymore. It always took the "silent" path.

Also, at least as of before this commit, this didn't correctly print a
warning when accessing a deprecated option as property. This was because
m_config_get_co_raw() was used, which intentionally does not print any
warnings, so switch to the non-raw one. (Affects only options that have
.deprecation_message set.)
2019-11-30 00:50:31 +01:00
wm4 90df6c79c9 vf_gpu: add video filter using vo_gpu's renderer
Probably pretty useless in this form (see: the wall of warnings), but
someone wanted this.

I think this should be useful to perform some automated tests, maybe.

Fixes: #7194
2019-11-29 20:37:11 +01:00
wm4 053297b1ca vo_gpu: opengl: do not free "GL" sub-allocations
This function always expects the GL struct pointer to be a talloc
allocation. So far so bad. But the terrible thing is that _lots_ of code
in mpv didn't quite get this (including the code which introduced the
way it is used this way). For example, in context_glx.c you see this:

struct priv {
    GL gl;
    ...

GL is not a talloc allocation, but since it's at the start of a talloc
allocation, it works anyway. So far so bad. But the really terrible
thing is that mpgl_load_functions2() calls talloc_free_children() on the
GL pointer, which means that all of priv's. This would be unintentional
and could create dangling pointers. And this happens at the about 1
dozen of callers. I'm amazed it didn't broke yet anywhere.

Removing this anti-pattern with making GL "implicitly" a talloc
allocation would be too much effort at this point. So just manually free
the only allocation that the function attached to GL.
2019-11-29 20:23:27 +01:00
wm4 1ccb049d3b osc: fix operation when window controls are disabled
It seems this area is simply not defined when window controls are
disabled, so ipairs() will crash on it.
2019-11-29 16:00:21 +01:00
wm4 3f7556baef x11: implement unminimization
This appears to work with IceWM.
2019-11-29 14:27:27 +01:00
Philip Langdale 2b4c867505 osc: handle deadzone and barmargin for window controls
I missed these due to only testing with my personal osc config.

The deadzone needs to be correctly handled for the window controls,
or they will fail to appear when the mouse is close to or over them.

In the process of doing that, I realised that the controls should
respect the barmargin, if set. This is because the controls should
remain aligned when layout=topbar and as the control bar is top
aligned, it should be equally affected if the user needs to set
the barmargin.

I also fixed a mistake in trying to the use the mpv-osd-symbols font
for the window controls.
2019-11-29 13:56:58 +01:00
wm4 d520258ffb x11: handle maximize/minimize with new option stuff
Should restore full functionality.

The initial state setting is a bit shoddy (instead of setting the
properties before map, we use the WM commands to change it after, so you
will see the normal window state for a moment; the WM commands do not
work on unmapped windows, so fixing this would require more code).
2019-11-29 13:56:58 +01:00
wm4 40c2f2eeb0 command: change window-minimized/window-maximized to options
Unfortunately, this breaks window state reporting for all VOs which
supported it. This can be fixed later (for x11 in the next commit).
2019-11-29 13:56:58 +01:00
wm4 d37e461eab x11: add change notification for --on-all-workspaces
Not particularly important and nobody asked for this, but demonstrates
how such things can be easily done now.
2019-11-29 13:56:58 +01:00
wm4 893f76045f x11: handle some more options with new option stuff 2019-11-29 13:56:58 +01:00
wm4 4e4252f916 x11: use new option stuff to implement fullscreen
- remove VOCTRL_FULLSCREEN and VOCTRL_GET_FULLSCREEN
- have your own m_config_cache for the fullscreen option
  (vo->opts_cache cannot be used because you lose per-option change
  notifications, and it'd be a mess anyway)
- use VOCTRL_VO_OPTS_CHANGED to update it
  (it's used for convenience)
- when updating it, check for the fullscreen option
  (wasn't sure how to do it best; currently, it compares the raw
  option pointers, but this could be changed)
- do not send VO_EVENT_FULLSCREEN_STATE on FS change
- instead write the option on FS change
  (assign in opt. struct + m_config_cache_write_opt)
2019-11-29 13:56:58 +01:00
wm4 b16cea750f player: change m_config to use new option handling mechanisms
Instead of making m_config a special-case, it more or less uses the
underlying m_config_cache/m_config_shadow APIs properly. This makes the
player core a (relatively) equivalent user of the core option API. In
particular, this means that other threads can change core options with
m_config_cache_write_opt() calls (before this commit, this merely led to
diverging option values).

An important change is that before this commit, mpctx->opts contained
the "master copy" of all option data. Now it's just another copy of the
option data, and the shadow copy is considered the master. This is why
whenever mpctx->opts is written, the change needs to be copied to the
master (thus why this commits add a bunch of m_config_notify... calls).

If another thread (e.g. a VO) changes an option, async_change_cb is now
invoked, which funnels the change notification through the player's
layers.

The new self_notification parameter on mp_option_change_callback is so
that m_config_notify... doesn't trigger recursion, and it's used in
cases where the change was already "processed". It's still needed to
trigger libmpv property updates. (I considered using an extra
m_config_cache for that, but it'd only cause problems with no
advantages.)

I think the recent changes actually forgot to send libmpv property
updates in some cases. This should fix this anyway. In some cases,
property updates are reworked, and the potential for bugs should be
lower (probably).

The primary point of this change is to allow external updates, for
example by a VO writing the fullscreen option if the window state is
changed by the window manager (rather than mpv changing it). This is not
used yet, but the following commits will.
2019-11-29 12:49:15 +01:00
wm4 5e2658c981 m_config: make m_config_cache_write_opt() check/return changes
Goes in line with the recent changes to always checking for option value
changes. The player core will use this to determine whether it should
send additional change events.
2019-11-29 12:37:41 +01:00
wm4 1cb085a82e options: get rid of GLOBAL_CONFIG hack
Just an implementation detail that can be cleaned up now. Internally,
m_config maintains a tree of m_sub_options structs, except for the root
it was not defined explicitly. GLOBAL_CONFIG was a hack to get access to
it anyway. Define it explicitly instead.
2019-11-29 12:14:43 +01:00
wm4 5083db91eb m_config: untangle new and old code somewhat
The original MPlayer m_config was essentially only responsible for
handling some command line parsing details, handling profiles, and
file-local options. And then there's the new mpv stuff (that stuff was
regretfully written by me), which is mostly associated with making
things thread-safe (includes things like making it all library-safe,
instead of stuffing all option data into global variables).

This commit tries to separate them some more. For example,
m_config_shadow (the thread-safe thing) now does not need access to
m_config anymore. m_config can hopefully be reduced to handling only the
"old" mplayer-derived mechanisms.
2019-11-29 12:14:43 +01:00
wm4 f73881fa10 m_config: allow writing options through m_config_cache
This will allow any other threads to write to the global option data in
a safe way.

The typical example for this is the fullscreen option, which needs to be
written by VO (or even some other thing running completely separate from
the main thread). We have a complicated and annoying contraption which
gets the value updated on the main thread, and this function will help
get rid of it.

As of this commit, this doesn't really work yet, because he main thread
uses its own weird copy of the option data.
2019-11-29 12:14:43 +01:00
wm4 591494b271 m_config: add fine-grained option reporting mechanism
This adds m_config_cache_get_next_changed() and the change_flags field
in m_config_cache. Both can be used to determine whether specific
options changed (rather than the entire sub-group).

Not sure if I'm very happy with that. The former rather compact
update_options() is now a bit of a mess, because it needs to be
incremental. m_config_cache_get_next_changed() will not be too nice to
use, and change_flags still relies on global "allocation" of change
flags (see UPDATE_* defines in m_option.h). If C weren't such a
primitive language that smells like grandpa, it would be nice to define
per-option change callbacks or so.

This compares options by value to determine whether they have changed.
This makes it slower in theory, but in practice it probably doesn't
matter (options are rarely changed after initialization). The
alternative would have been per-option change counters (wastes too much
memory; not a practical problem but too ugly), or keep all
m_config_caches in a global list and have bitmaps with per-option change
bits (sounds complicated). I guess the current way is OK.

Technically, this changes semantics slightly by ignoring setting an
option to the same value. Technically this wasn't a no-op, although the
effect was almost almost no-op. Some code would actually become cleaner
by ignoring such redundant change events, and them being no-op is
probably also what the user would normally assume.
2019-11-29 12:14:43 +01:00
wm4 1e6c57d4e4 m_config: move stuff around
Create a separate struct for internal fields of m_config_cache, so API
users can't just mess with stuff they shouldn't access.

Move the ts field out of m_config_data, so we don't need unnecessary
atomics in one case.

This is just preparation, and shouldn't change any behavior.
2019-11-29 12:14:43 +01:00