Commit Graph

49184 Commits

Author SHA1 Message Date
Dudemanguy 560e6c8709 wayland: report correct window size when maximized
In wayland_common, wl->window_size keeps track of the window's size when
it is not in the fullscreen or maximized state. GET_UNFS_WINDOW_SIZE is
meant to report the size except for when it is fullscreen (hence UNFS).
However, the actual function was merely returning the wl->window_size so
it was wrong for maximized windows. Workaround this by returning
wl->geometry instead when we have the maximized case. Fixes #9207.
2021-09-13 20:49:07 +00:00
Jan Ekström 62b2c5db98 build: enable strict FFmpeg ABI compatibility by default
Its define (HAVE_FFMPEG_STRICT_ABI) is now utilized in a single
location, where an internal libavformat struct member is utilized.
This struct member is now (after around 10 years) finally removed
from public visibility in FFmpeg's master.

After a review of functionality, the information in bytes_read is
passed onto the demuxer layer, and then utilized for
{cache,hack}_unbuffered_read_bytes. This information is then utilized
for:

1. Calculation of bytes_per_second in demux/demux.c::update_cache,
   which fills the information for properties "cache-speed" as well as
   "raw-input-rate" (of which stats.lua is the most prominent user).
2. bytes_per_second also affects how often update_cache is called in
   addition to the two locations it is called unconditionally in
   (read_packet, demux_update).

In other words, the information provided does not appear to control
crucial mpv functionality, but rather its lack would seem to mostly
affect the speed of certain properties updating, or having valid
values. For the former, stream size as well as timed metadata get
updated in update_cache - although the demux layer does throttle
the update of certain things to once per second in that function.
For the latter, "cache-speed" and "raw-input-rate" lose read data
statistics from AVIOContexts opened by the opened FFmpeg AVFormatContext
itself, as opposed to the primary one - which goes through mpv's
stream reading implementation.

By enabling this feature, and disabling this abuse of private API
lets users build mpv by default with the latest master FFmpeg, thus
giving us the breathing room to look into some of the details of
this case, and either decide to:

1. Post a patch to add this information back to FFmpeg proper.
2. Remove or replace this functionality in another manner.

End user impact:
Any IO not handled by mpv itself - but rather by IO contexts newly
opened by the input format - is not visible through the properties
"cache-speed" and "raw-input-rate". Examples of such input formats
are the HLS and DASH readers in FFmpeg.

Historical git references:
- Addition of unbuffered_read_bytes: 4dfaa37384
- Rework to have the reporting function: ebf183eeec

Fixes #9159
2021-09-08 22:28:02 +03:00
Guido Cella c2dec023b7 input.conf: remove redundant comments 2021-09-06 10:16:45 +03:00
Avi Halachmi (:avih) 3405f814fb demux_playlist: extend maximum line size (again) to 2M
Last time it was extended was de3ecc60 from 8K to 512K two years ago.

The issue currently is that youtube EDL files can get very big.
Size of about 520K (one line), was observed, at the time of writing:
  mpv https://youtube.com/watch?v=DBzFQgSMHdQ --ytdl-format=299

ytdl_hook.lua is unaffected by this because EDL lists don't go through
the file reader at demux_playlist.c (where each line was limited to
512K before this commit), however, EDL files on disk which are
loaded with --playlist=file.edl do.

Increase the limit to 2M so that such EDL files can also be loaded
from disk.

Fixes #9186
2021-09-06 10:16:25 +03:00
Avi Halachmi (:avih) 8fb4fd9a18 win32: initial position: center with borders
Previously, the initial positioning and fit ignored the borders, and
centered the content (the video itself) at the working area.

Now, the initial positioning centers the window, by subtracting the
borders (if needed) from the target area for the initial fit/position.

While this does mean that the initial maximum content area is now
smaller than before, ultimately this has no impact on the window size,
because fit_on_screen is called later and, if needed, further shrinks
the window to fit the borders too - but without centering the window.

So the net impact of this commit is only the initial positioning (same
size as before), which now centers the window instead of the content.

Note that on Windows 10 the borders include invisible areas at the
sides and bottom of the window (for mouse edge-drag), so visibly the
window is nearer to the top than to the bottom, but these are the
metrics we have (fit_on_screen uses the same border size values).

On Windows 7 it looks perfectly centered.
2021-09-06 10:16:10 +03:00
Avi Halachmi (:avih) 73f16b5431 win32: fix incorrect application of --monitoraspect
The --monitoraspect value is calculated at vo_calc_window_geometry2
(VCWG2) or VCWG3, and applied via vo_apply_window_geometry.

Before this commit, the screen size which the win32 VO used with
VCWG2 was the working area (screen minus taskbar). This allows better
fitting, but breaks the pixelaspect calculation which is derived from
the --monitoraspect value and this rectangle.

VCWG3 allows an independent size for the aspect calculations, and now
we use it independently of the fit size.
2021-09-06 10:16:10 +03:00
Avi Halachmi (:avih) 2b1579b1c8 win_state: add vo_calc_window_geometry3
vo_calc_window_geometry2 (VCWG2) calculates both the pixelaspect and
the autofit sizes based on one "screen" rectangle.

However, these two calculations might need two different "screen"
rects if the fit should take into account decorations and/or taskbar
etc, while pixelaspect should be based on the full (monitor) rect.

VCWG3 does just that. It's the same as VCWG2, but with an additional
monitor rect which is used exclussively to calculate pixelaspect,
while the "screen" argument is used for fitting (like before).

VCWG2 now uses/calls VCWG3 with the same screen and monitor rects.

Currently yet unused.
2021-09-06 10:16:10 +03:00
Arthur Williams 6f23aa0d3e bash completion: Allow completions to work without external functions
If bash_completion wasn't installed, _filedir wouldn't be defined which
led to all filename-based completions to error out. Specifically
autocompletion would fail when a filename was expected and when
bash_completion wasn't installed. Now we fall back to `compgen -f` if
_filedir fails. According to _filedir's comments, compgen doesn't
handle files with spaces well, but it is still better to complete most
files than none.
2021-09-05 16:51:38 -07:00
Nicolas F 8aef22e45d DOCS/options: fix minor typo in compute shaders
This "bw" should most likely be a "be".
2021-08-29 18:31:55 +03:00
Ivan dffb94f94d wayland: set default cursor size to 24
Set it to 24 if it couldn't be read frome $XCURSOR_SIZE for some reason.
Since it seems to be the default value for most distros/DE.
2021-08-28 01:12:38 +00:00
Ivan d092170bf8 wayland: read XCURSOR_THEME to get cursor theme
Read $XCURSOR_THEME environment variable if set and if not then fall
back to "default" (/usr/share/icons/default and ~/.icons/default)
2021-08-28 01:12:38 +00:00
Cloud11665 f3a2275c24 vo_tct: add resize capability
No performance penalty added by getting the terminal size every frame.
2021-08-26 11:29:07 -07:00
a1346054 91b6757875 vo_drm: fix typo in error message 2021-08-26 20:35:13 +03:00
a1346054 7314253180 DOCS: use upstream license files
The current files contain weird formatting characters, new files
obtained from:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
2021-08-25 15:56:58 +02:00
a1346054 88460b6f86 DOCS: fix spelling 2021-08-24 20:44:52 +03:00
a1346054 b3d41e8286 DOCS: fix spelling in github issue templates 2021-08-24 20:44:52 +03:00
Guido Cella 0b56e1c00a input.conf: remove bindings of removed properties
angle was removed in a9d83eac40, and program in a75b249b0b.
2021-08-19 15:56:25 +03:00
Guido Cella ed26e8dcd5 input.conf: add comments
These will be shown in the new keybinding list.
2021-08-19 15:56:25 +03:00
Avi Halachmi (:avih) 21d434d2db terminal-unix: identify and ignore unknown CSI sequences
If an unknown ESC sequence is detected where an ASCII char <X> follows
the ESC, mpv interprets it as ALT+<X>, which is the traditional
terminal encoding of ALT+letter.

However, if <X> is '[' then it's a CSI sequence which continues after
the '[', and has its own termination rules (can be many chars).

Previously, mpv interpreted unknown CSI sequences as (incorrect) ALT+[
followed by (incorrect) "keys" from the rest of the sequence.

In this commit, if a unknown CSI sequence is detected, mpv ignores
exactly the complete sequence.
2021-08-19 15:39:42 +03:00
Avi Halachmi (:avih) 007c728ad2 command: cycle: respect the prefix "repeatable"
The "cycle" command _declaration_ enables repeatability by default,
however, the command handler applies additional logic to augment it,
based on the property which is being cycled - using some guesswork.

Specifically, properties with discrete values are not repeatable
(like sub or osd-level), while continuous properties are repeatable
(like volume).

Previously, the "repeatable" prefix could not override this additional
logic.

This commit changes the behavior so that the logic affects only the
default repeatability (still based on the property like before),
however, the "repeatable" prefix is now allowed to override it.
2021-08-19 15:39:19 +03:00
Avi Halachmi (:avih) 8489249af9 osd_libass: --osd-back-color: apply to the progress bar
This is an artificial background box with the original colors,
rendered as a plain rectangle instead of libass's opaque-box.

Fixes #9134 (together with the previous commit)
2021-08-19 15:39:07 +03:00
Avi Halachmi (:avih) c7cdd38ac9 osd_libass: disable --osd-back-color for the progress bar
This breaks the rendering in various ways, so first workaround is to
simply disable the opaque box for the bar.

Next commit will add an artificial background box.
2021-08-19 15:39:07 +03:00
Avi Halachmi (:avih) 6193f723b0 win32: support the property display-hidpi-scale
This read-only property reflects the VO's dpi-scale value, and wasn't
supported on win32 until now (it is supported on wayland/x11/osx).

Currently in mpv it's only used by the builtin script console.lua,
and assumed 1 if unavailable.
2021-08-18 02:21:33 +03:00
Avi Halachmi (:avih) 052220d1c7 win32: apply dpi-scale with [current]-window-scale
When --window-scale=NUM is set from CLI, the dpi_scale value was/is
taken into account when the win32 VO calls vo_calc_window_geometry2.

However, when [current]-window-scale is read or set at runtime, it uses
the VOCTRL_{GET,SET}_UNFS_WINDOW_SIZE interface, where other VOs apply
the dpi_scale value internally (wayland, x11, osx), but the win32 VO
didn't before this commit.

Fixes two issues when --hidpi-window-scale=yes and dpi_scale != 1 :
- Incorrect window-size when setting [current-]window-scale at runtime.
- Incorrect current-window-scale value when reading it.
2021-08-18 02:21:33 +03:00
Avi Halachmi (:avih) 19e24bbe86 win32: ensure initial dpi-scale value
vo_calc_window_geometry2(...) is called to initialize the window
size with the dpi_scale value as one of the arguments.

dpi_scale is 0 initially, and set to a valid value at update_dpi(),
which is called from [force_]update_display_info().

However, no measures were taken to ensure that dpi_scale is set
correctly before vo_calc_window_geometry2() is called, which could
result in incorrect window size if it's not initialized.

It did happen to get initialized on time, by luck, because
VOCTRL_GET_DISPLAY_FPS is used early, which happens to call
update_display_info to read the fps value (other update_display_info()
calls are after the first vo_calc_window_geometry2() call).

This commit ensures that dpi_scale is initialized on time if needed.
Also, update_dpi() now ensures that dpi_scale is never 0.
2021-08-18 02:21:33 +03:00
Avi Halachmi (:avih) 3abb23d70f command: don't hardcode commands list to be repeatable
Previously, a list of commands was always considered repeatable.

This behavior was added at 6710527a (and moved around since then),
in order to fix #807 (impossible to make a repeatable list).

The problem was that a list doesn't have the normal repeatability
flags and so it was never repeatable, so it was hardcoded to be
repeatable instead. Presumably it was deemed good enough.

However, this made it impossible to have a non-repeatable list.

This commit changes the behavior so that a list repeatability is
that of the first command at the list.

This way, any list can be made either repeatable or non-repeatable
using the following idiom (e.g. at input.conf), based on the fact
that the "ignore" command is not repeatable by default:

  x            ignore; cmd1...; cmd2...   # non-repeatable
  y repeatable ignore; cmd1...; cmd2...   # repeatable

Fixes #7841
2021-08-17 22:45:39 +03:00
LaserEyess 4c7d7a8001 DOCS: replace dead waf book link with working one 2021-08-17 13:42:21 +00:00
LaserEyess 9aa5cd6f45 DOCS: convert 3rd party http links to https
Discovered with:

find . -type f \( -name '*.md' -o -name '*.rst' \)  -exec grep -n 'http://' {} +

All real, i.e. non-example, links found were moved to https. There are
some dead links and websites with no https available which were not
converted.
2021-08-17 13:42:21 +00:00
LaserEyess b7afac3248 DOCS: convert mpv.io and github links to https
Discovered with:

find . -type f \( -name '*.md' -o -name '*.rst' \)  -exec grep -n 'http://' {} +

All links to mpv.io or github.com/mpv-player that were http were
converted to https.
2021-08-17 13:42:21 +00:00
Avi Halachmi (:avih) 36de2efebd vo_tct: fix --vo-tct-256
This is a regression from cbbd81bb (the previous commit):

print_seq1 (which prints a sequence with 1 parametric byte value) is
used with 256 colors output, and apparently was never tested.
Two issues were introduced at the offending commit:

1. The ";5" part was incorrectly removed from the strings
   ESC_COLOR256_{BG,FG} (affects both *nix and Windows).

2. On windows only - a semicolon was not used after the prefix.

Both issues resulted in an invalid 256 colors sequences and output.
2021-08-16 11:06:43 +03:00
Cloud11665 cbbd81bb4f vo_tct: optimize print function on non-windows platforms
Using fwrite on non-windows platforms yields a ~25% performance increase.
2021-08-16 02:29:25 +03:00
Guido Cella 013985b872 DOCS/input: update osd-ass-cc documentation
- Replace the legacy --osd-status-msg with the newer --osd-msg3.
- Escape \b in show-text "This is ${osd-ass-cc/0}{\b1}bold text".
- Link the Flat command syntax section because it's no longer true that
  you always need to escape \, since C escape sequences are not
  interpreted with single and custom quotes.
2021-08-16 01:33:11 +03:00
Avi Halachmi (:avih) 2b5c2c8e44 vo_tct: fix half-block on windows
On windows the UTF-8 strings are translated to wchar_t when printed to
the console, and some escape sequences are also translated, however,
this only works when printf is mapped to mp_printf, and for that to
happen we need to include osdep/io.h .
2021-08-16 01:16:34 +03:00
Avi Halachmi (:avih) 2780bf32d0 DOCS/contrinute: add commit title example prefixes 2021-08-15 22:15:27 +03:00
Dudemanguy e0df7688f6 wayland: check for xkb state in handle modifiers
Normally in wayland, you receive a keymap event from the compositor
which is what allows the client to setup what is needed for xkb.
However, it turns out that this doesn't occur in the case of virtual
keyboards, such as from wtype, that come from the custom
virtual-keyboard protocol. What happens in this case is that mpv only
receives a keyboard entrance event. According to the wayland protocol
documentation [1], "the compositor must send wl_keyboard.modifiers event
after [the wl_keyboard.enter] event". It is possible for this to occur
before the physical keyboard is properly mapped (i.e: using a virtual
keyboard to start mpv). What this results in is a segfault once
xkb_state_update_mask is called in the modifiers event. The fix is to
simply not always assume we have created the xkb state if we get this
event and check for its existence first. Closes #9119.

https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_keyboard
2021-08-15 09:45:23 -05:00
Stefan de Konink 0c9e1e34fd stats.lua: typo lavfi-complex
Fix typo lavi-complex to lavfi-complex.
2021-08-15 12:27:40 +03:00
Guido Cella d8e5f6ff3a sub: show subs without duration on vid change
When changing video track with subtitles with unknown duration, they
aren't shown until you seek, cycle sub back and forth, or apply a video
filter. This is caused by reinit_video_chain_src() calling
reset_subtitle_state() -> sub/sd_ass.c:reset() -> ass_flush_events()
when ctx->duration_unknown is true.

The ass_flush_events() call was added in a714f8e so subs with unknown
duration wouldn't multiply on seek, i.e. when reset_subtitle_state() is
called from reset_playback_state(). So keep calling it from there, and
in reinit_video_chain_src() use just term_osd_set_subs(mpctx, NULL)
instead to clear any subtitles printed to the terminal. The
reset_subtitle_state() call was added in c1ac97b to "reset the state
correctly when switching between video/no-video", but with it removed I
no longer notice any issue doing that.
2021-08-13 17:16:43 +00:00
Ho Ming Shun 312e29cf7f vo_rpi: restore fullscreen handling
Previous fullscreen handling code was removed in 59cdfe50b2 during
deprecation of VOCTRL_FULLSCREEN. Lack of this code caused the OSD layer
to be to be not resized along with the video layer when fullscreen is
toggled.
2021-08-13 17:14:31 +00:00
Dudemanguy f4ceea9b8a x11: handle maximized windows with window-scale
If a user attempted to change the window scale of a maximized window on
x11, nothing would happen since the window manager holds the size of the
window constant. Just do an unmaximize first before performing the
resize.
2021-08-12 19:35:40 +00:00
sjambekar b692c6599a vo_vdpau: Don't treat preemption as an error when reconfiguring
When the VT switch out is triggered, the decode thread (VD) falls back
to sw decoding. However, on the VO thread, which is responsible for
handling display preemption and presentation, vo_vdpau.c:reconfig() is
called. The reconfig() function returned -1 when the check_preemption()
returned 0. The vo_reconfig2() (which calls reconfig()) returned -1 in
turn which entered into an error handling path. This led to a series of
functions calls that ultimately set the in_terminate flag to TRUE.
This led the vo_thread to exit which ultimately led to the
MPV application exit.

The fix is to return 0 instead of -1 after the check_preemption() in
the vo_vpdau.c:reconfig(). Returning 0 instead of -1 is not fatal and
does not have any side effects. This is confirmed by testing the VT
switching behaviour. And as far as the frames that are going to the
display are concerned, they are now dropped. Since the display is
preempted, it is okay to drop the frames and continue.
2021-08-12 11:14:37 -07:00
Stan Janssen acf7ef86d6 desktop entry: fix duplication of the app icon in a dock like Plank
Without this entry, when starting mpv as a flatpak application on
elementaryOS, the Dock icon would get duplicated, as if the application
was detached from its launcher. This entry fixes that by allowing the
dock to associate the app's window with the desktop entry.

Fixes #9109
2021-08-12 18:01:35 +02:00
Guido Cella b6ebd1a15e sub: align ytdl-hook secondary subs to the top
29e15e6248 prefixed youtube-dl's subs url with an edl prefix to not
download them until they're selected, which is useful when there are
many sub languages. But this prefix broke the alignment of secondary
subs, which would overlap the primary subs instead of always being
placed at the top. This can be tested with
--sub-file='edl://!no_clip;!delay_open,media_type=sub;secondary_sub.srt'

When a sub is added, sub.c:reinit_sub() is called. This calls in
init_subdec() -> dec_sub.c:sub_create() -> init_decoder() ->
sd_ass:init(). Then reinit_sub() calls
sub_control(track->d_sub, SD_CTRL_SET_TOP, &(bool){!!order}) which sets
sd_ass_priv.on_top = true for secondary subs.

But for EDL subs the real sub is initialized again when in
dec_sub.c:sub_read_packets() is_new_segment() returns true and
update_segment() is called, or when sub_get_bitmaps() calls
update_segment(). update_segment() then calls init_decoder(), which
calls sd_ass:init(), so sd_ass_priv is reinitialized, and its on_top
property is left false. This commit sets it to true again.

For URLs that need to be downloaded it seems that the update_segment()
call that reinitializes sd_ass_priv is always the one in
sub_read_packets(), but with local subs sub_get_bitmaps() is usually
called earlier (though there shouldn't be a reason to use the EDL URL
for local subs), so I added the order parameter to sub_create(), rather
than adding it to all of update_segment(), sub_read_packets() and
sub_get_bitmaps().

Also removes the cast to bool in the other sub_control call, since
sub/sd_ass.c:control already casts arg to bool when cmd is
SD_CTRL_SET_TOP.
2021-08-11 18:15:35 +00:00
Dudemanguy f25d446b03 wayland: fix wrong opts struct 2021-08-10 15:46:25 -05:00
Dudemanguy 577ca780b4 wayland: request xdg-decoration mode on startup
Right after the listener is constructed, request a mode based on the
value of the border option. If border, then request SSD. If no border,
request CSD. The decoration listener handles it from there.
2021-08-10 15:37:49 -05:00
Avi Halachmi (:avih) 8a597a484b lua: read_options: quote values at error messages
This makes it easier to understand the error in cases of incorrect
syntax or formatting at .conf files. (js already has this quoting).

Fixes #9105
2021-08-10 11:00:18 +03:00
Dudemanguy e9e1c41060 vo_wlshm: remove empty options struct
This doesn't do anything and isn't needed as there are no wlshm-specific
options.
2021-08-09 16:39:08 -05:00
Avi Halachmi (:avih) 21ab1df014 DOCS/stats.rst: fix quoting 2021-08-09 23:57:04 +03:00
Dudemanguy 162044ade9 wayland: check for xdg-decoration on border update
Oversight in 69c64f5. If there is no xdg_toplevel_decoration, don't
attempt to set the mode.
2021-08-09 15:07:58 -05:00
LaserEyess ec9083d0d8 options: clarify OS support for media keys
The previous wording gave the false impression that there was no media
key support for OSes besides Windows and macOS. This is untrue, the
option may only exist on those two platforms but it simply means that
media keys will always be enabled on other OSes as long as they are
supported.
2021-08-09 21:14:51 +03:00
Dudemanguy 69c64f5fc4 wayland: handle xdg-decoration protocol better
The current usage of the xdg-decoration protocol is quite a bit crude.
There's a specific listener struct for this like with most wayland
things, but mpv wasn't even using it. It also made no attempt to detect
if the compositor was telling mpv to use client side decorations. To
implement this correctly, first of all we need to create the decoration
listener object and add it like how most wayland things work. Secondly,
set_border_decorations needs to be changed to accept the uint32_t mode
given by the compositor. When we get the decoration event, pass the mode
obtained from the compositor to set_border_decorations. Update the mpv
border option, based on whether or not we have server side decorations
(yes if we have them; no if we don't). mpv can actually request either
client side or server side decorations with this protocol. This function
doesn't belong in set_border_decorations but rather it should be called
when the border option changes. Whether or not this request actually
works depends on the compositor (Plasma appears to allow it; sway does
not). If the compositor allows this request, then it gets handled by
configure_decorations. Note that the enum strangely starts at 1 hence
why there is an extra +1.
2021-08-09 12:55:52 -05:00