Commit Graph

49249 Commits

Author SHA1 Message Date
sfan5 9ca9066d05
Release 0.34.0 2021-11-01 15:44:39 +01:00
Avi Halachmi (:avih) f6b834a2fc js: ~~/init.js: use mp.find_config_file
The problem with the previous code - which used mp.get_user_path, is
that it returns a path even with --no-config, and even if the file
doesn't exist.

This is why we tested the "config" property, and also used
mp.utils.file_info to check that the file exists.

mp.find_config_file doesn't return a path with no-cofig and doesn't
return a path if the file doesn't exists. It's simpler and better.
2021-11-01 14:31:18 +01:00
sfan5 3ea1f8e80a DOCS: clarify what the ~~/ path means
As it turns out the manual was very wrong about this.
2021-11-01 14:30:59 +01:00
Guido Cella 87c9eefb29 console.lua: define remaining emacs keybindings 2021-11-01 23:42:16 +11:00
Niklas Haas c82ffb6670 vo_gpu: libplacebo: simplify tex transfers for libplacebo 168+
Upstream libplacebo got refactored to use byte-sized strides rather than
texel-sized strides. This commit makes mpv's ra_pl wrapper take
advantage of that, rather than forcing a stride-fixing memcpy.

Note that, technically, we would still need a stride fixing memcpy in
cases when the true stride is not a multiple of the format's texel
*alignment*, however this is a much rarer case and extremely unlikely to
occur in practice, since all relevant formats use power-of-two texel
alignments.
2021-10-31 19:39:58 +01:00
Guido Cella 4a80de90d2 DOCS/input: fix subprocess typo 2021-10-26 20:29:18 +00:00
Guido Cella 8778c296b4 DOCS/options: clarify watch-later-options examples
Make it clearer that watch-later-options controls which options are not saved
and not which ones are restored.
2021-10-26 20:27:49 +00:00
Dudemanguy e4ee0c6ebc wayland: remove incorrect keepaspect check
In the reconfig event, the keepaspect option was checked before setting
the window_size geometry to the new params obtained from the vo. This is
incorrect. If a user disabled keepaspect on wayland, the video's size
would not change on a reconfigure event (i.e. loading a new video in the
playlist with a different size). No other windowing backend (x11, win32,
etc.) behaves like this or uses keepaspect in its code like wayland did
in this case. Clearly, this is not correct. Such functionality should be
handled by a separate option entirely. Just remove this if statement.
2021-10-26 13:21:08 -05:00
Noralf Trønnes e6ab676d20 drm_common: add connector types USB, SPI and Writeback
Add support for the newly added USB connector type and also SPI and Writeback.
2021-10-26 17:44:54 +00:00
Noralf Trønnes 9cf95baaf3 drm_common: support unknown connector types
Avoid 'Segmentation fault' by using the connector type name UNKNOWN if
the connector type is not known to mpv.
2021-10-26 17:44:54 +00:00
Jan Ekström 78cfeee2b9 {wscript,demux_lavf}: clean up last bits of !FFMPEG_STRICT_ABI
The bytes_read struct member in AVIOContext is now officially public,
so its usage no longer has to be specified as non-compliance with
FFmpeg's ABI/API rules.

That said, unfortunately there was a short period of time between
August 2021 and October 2021 where the struct member did not exist
in FFmpeg's git master, so keep a feature check for it alive for
now to enable building with those versions. Thankfully, no release
version of FFmpeg will be without this field, so it should be
possible to drop this check with time.

Finally, simplify the function in case the struct member is not
found. After all, there is zero reason to iterate through the AVIO
contexts if we cannot get the information we require.
2021-10-26 01:21:56 +03:00
Jan Ekström f560437594 drm_common: enable specific device selection by means of path 2021-10-25 20:37:03 +02:00
Jan Ekström e6cf918eb8 drm_common: utilize drmGetDevices when iterating over cards
Based on the idea behind emersion's change to drm_info
(869e789a64).

Lets us by default skip devices which are not capable of doing what
the DRM master output requires (not primary devices), as some devices
have card0 actually not be such.

Negative part is that the number given to drm-connector is no
longer a direct mapping against a file name.
2021-10-25 20:37:03 +02:00
Dudemanguy 12056fdcd4 version.sh: bump copyright year
It's been 2021 for a while now.
2021-10-25 10:20:54 -05:00
Niklas Haas 254730d891 vo_gpu: fix rotated compute shader vertex simulation
Upon re-examination I have no idea why this code was ever written or
what problem it was trying to solve. But, getting rid of it fixes #9291.

It might be a remnant from before 2af2fa7a27. Who knows. This code will
be replaced soon(tm) anyways.
2021-10-22 19:08:13 +02:00
Jan Ekström a76527772e github/workflows: use xcode 13.1 if image defaults to xcode 13.0
I find it both hilarious and sad that Github decided that defaulting
to XCode 13.0 was a good idea... At least they added 13.1 quickly.

Ref actions/virtual-environments#4180
Ref actions/virtual-environments#4300
2021-10-21 21:29:08 +03:00
Aman Karmani 06392e7ec1 ao_audiotrack: change buffer sizing logic
Previously number of channels was being ignored.

The buffer will now be between 75ms and 150ms

Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-10-21 17:20:51 +02:00
Aman Karmani fa691e0f69 ao_audiotrack: allocate chunk buffer based on negotiated size
Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-10-21 17:20:51 +02:00
Aman Karmani 6473711dce ao_audiotrack: support delay up to 2s as normal
Fixes issues streaming to echo speaker pair from firetv devices.

Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-10-21 17:20:51 +02:00
Aman Karmani 432c0255bc ao_audiotrack: set device_buffer based on underlying buffer size when available
Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-10-21 17:20:51 +02:00
Aman Karmani 7356ee5339 ao_audiotrack: use new style initializer for AudioTrack when available
Fixes deprecation warnings printed when using this driver.

Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-10-21 17:20:51 +02:00
Dudemanguy 7ad5ad4098 egl_helpers: ensure debug context attrs/bit exist
Regression from e13fe1299d. Apparently,
Broadcom's EGL does not support the EGL_CONTEXT_FLAGS_KHR attribute nor
EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR. Just define these as EGL_NONE and 0
respectively if we do not have them.
2021-10-21 03:16:33 +00:00
Emil Velikov ef301893a5 editorconfig: add initial file/config
editorconfig configuration files hold editor style hints, and
is supported by many popular editors. See https://editorconfig.org/ .

The vast majority of the mpv source/text files are already styled as
4 space indentation, trailing newline at EOF, and UTF-8 encoding.

This commit adds a single .editorconfig root file which applies these
rules to all files using the glob "[*]".

If it turns out to be too inclusive then we can narrow it down later.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-20 12:26:20 +03:00
Avi Halachmi (:avih) 32e851d2bc lua: makenode: prevent lua stack corruption
Normally there was no issue, but when the code converted a deeply
nested table into an mpv node - it didn't ensure the stack has room.

Lua doesn't check stack overflow when invoking lua_push* functions,
and leaves this responsibility to the (c) user via lua_checkstack.

Normally that's not an issue because when a lua (or autofree) function
is called, it's guaranteed at least LUA_MINSTACK (20) pushes.

However, pushnode and makenode are recursive, and each iteration can
add few values at the stack (which are popped when the recursion
unwinds), so checkstack must be used on (recursive) entry.

pushnode already checked the stack, makenode did not.

This commit checks the stack at makenode as well. The value of 6
(stack places to reserve) is with some room to spare, and in pratice
each iteration needs 2-3 at most (pushnode also leaves room).

Example which could previously corrupt the stack:
  utils.format_json({d1={d2={<8 more times>}}}

This uses makenode to convert the lua table into an mpv node which
the json writer uses as input, and if the depth is 10 or more then
corruption could occur. mp.command_native is also affected, as well as
any other mp/utils command which takes a lua table as input.

While at it, fix the error string which pushnode used (luaL_checkstack
uses the provided string with "Stack overflow (%s)", so the user
message only needs to be additional info).
2021-10-20 12:07:30 +03:00
Avi Halachmi (:avih) 2249f3f81a lua: autofree infrastructure: x2 faster
The speedup is due to moving big part of the autofree runtime overhead
(new lua c closure) to happen once on init at af_pushcclosure, instead
of on every call. This also allows supporting upvalues trivially, even
if mpv doesn't use it currently, and is more consistent with lua APIs.

While x2 infrastructure speedup is meaningful - and similar between
lua 5.1/5.2/jit, in practice it's a much smaller improvement because
the autofree overhead is typically small compared to the "real" work
(the actual functionality, and talloc+free which is needed anyway).

So with this commit, fast functions improve more in percentage.
E.g. utils.parse_json("0") is relatively fast and is now about 25%
faster, while a slower call like mp.command_native("ignore") is now
about 10% faster than before. If we had mp.noop() which does nothing
(but still "needs" alloc/free) - it would now be about 50% faster.

Overall, it's a mild performance improvements, the API is now more
consistent with lua, and without increasing code size or complexity.
2021-10-19 15:45:16 +03:00
Avi Halachmi (:avih) 4703b74e6c js: custom-init: use ~~/init.js instead of ~~/.init.js (dot)
mpv doesn't have other dot files in its config dir, and it also
shouldn't be "invisible".

The new name ~~/init.js now replaces ~~/.init.js

While mpv usually deprecates things before outright removing them,
in this case the old (dot) name is replaced without deprecation:
- It's a bad idea to execute hidden scripts, even if at a config dir,
  and we don't want to do that for the next release cycle too.
- We warn if the old (dot) name exists and the new name doesn't,
  which should be reasonably visible for affected users.
- It's likely niche enough to not cause too much pain.

If for some reason both names are needed, e.g. when using also an old
mpv versions, then the old name could be symlinked to the new one, or
simply have one line: `require("~~/init")` to load the new name, while
a new mpv version will load (only) the new name without warning.
2021-10-19 15:43:39 +03:00
Emil Velikov e13fe1299d egl_helpers: add support for debug contexts
With the recent refactor and quick look against the GLX code path, it's
fairly obvious, and trivial, how to add support for debug contexts.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov 6354540cf8 vo_gpu: context_glx: cleanup create_context_x11_gl3 code path
Drop the gl3 suffix from the function name - it's no longer needed, with
the _old function gone.

Push the mpgl_min_required_gl_versions[] looping within the function,
reducing the identical glXGetProcAddress/glXQueryExtensionsString calls
while making the code neater.

v2:
 - tabs -> spaces indentation
 - mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
 - 320 -> 300 (in glx code path)

v3:
 - legacy code path is gone \o/

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov e869d519ba vo_gpu: context_glx: remove legacy create_context_x11_old()
The old/legacy code-path isn't really needed for mpv use-cases.

In particular:

All Mesa drivers (even GL 2.1 ones like lima/vc4) work fine with the
"non-legacy" path.

From proprietary/binary drivers - the vendor either does not support
desktop GL or the drivers/HW is not actively supported.

Looking at the Nvidia HW - anything GeForce 7 and older is GL 2.1 and
lacks decent video acceleration. The latest official drivers are from
2017.

All newer Nvidia HW is GL 3.3+ thus must have GLX_ARB_create_context as
in the non-legacy path, while also good acceleration albeit via VDPAU
in some cases.

With the old path gone, provide meaningful error message in the very
unlikely case that GLX_ARB_create_context is missing.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov 20e9c66fa9 egl_helpers: fixup the EGL_KHR_create_context-less codepath
With earlier commit f8e62d3d82 ("egl_helpers: fix create_context
fallback behavior") we added a fallback for creating OpenGL context
while EGL_KHR_create_context is missing.

While it looked correct at first, it is missing the eglMakeCurrent()
call after creating the EGL context. Thus calling glGetString() fails.

Instead of doing that we can just remove some code - simply pass the
CLIENT_VERSION 2, as attributes which is honoured by EGL regardless of
the client API. This allows us to remove the special case and drop some
code.

v2:
 - mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov 538fb6541e video: opengl: rework and remove ra_gl_ctx_test_version()
The ra_gl_ctx_test_version() helper is quite clunky, in that it pushes a
simple check too deep into the call chain. As such it makes it hard to
reason, let alone have the GLX and EGL code paths symmetrical.

Introduce a simple helper ra_gl_ctx_get_glesmode() which returns the
current glesmode, so the platforms can clearly reason about should and
should not be executed.

v2:
 - mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
 - 320 -> 300 (in glx code path)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov e3883512b1 vo_gpu: opengl: remove --opengl-restrict
As the documentation of the toggle says - the implementation can (and
will actually if they follow the GLX/EGL spec) return context version
greater than the one requested.

This happens with all Mesa drivers that I've tested as well as the
Nvidia binary drivers.

This toggle seems like a workaround for buggy drivers, yet it's lacking
context about the vendor and version.

Remove it for now - I'll be happy to reinstate it (partially or in full)
as we get concrete details.

This allows us to simplify ra_gl_ctx_test_version() making the whole
context creation business easier to follow by mere mortals.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov e992ebe128 egl_helpers: remove explicit GLES 3 request
Alike the GL commit earlier - the EGL spec essentially mandates that
implementation will return GLES 3.0+ (if supported by the driver), even
though only GLES 2 is requested.

The only thing we should watch out is - we should add both ES2_BIT and
ES3_BIT as EGL_RENDERABLE_TYPE.

This has been verified against the Mesa drivers (i965, iris, swrast) and
Nvidia binary drivers.

v2:
 - int es_version -> bool es
 - unloop create_context() execution

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov 0b918edfb5 vo_gpu: opengl: reduce versions in mpgl_preferred_gl_versions
Currently mpv requires a bare minimum of GL 2.1, although it tries to
use 3.2+ core contexts when possible.

The GLX and EGL spec effectively guarantee that the implementation will
give you the highest compatible version possible. In other words:

Requesting 3.2 core profile will always give you core profile and the
version will be in the 3.2 .. 4.6 range - as supported by the drivers.

Similarly for 2.1 - implementation will give you either:
 - 2.1 .. 3.1, or
 - 3.2 .. 4.6 compat profile

This has been verified against the Mesa drivers (i965, iris, swrast) and
Nvidia binary drivers.

As such, drop the list to 320, 210 and terminating 0.

v2:
 - mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
 - update ^^ comment

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-16 20:33:53 +00:00
Emil Velikov 0282196f4a drm: re-enable drmSet/DropMaster calls
The ioctls were disabled a while back since they error out and allegedly
cause problem with X running in another VT.

Omitting the ioctls is not cool, even as a workaround.

If they fail, the user is supposed to fallback appropriately - use a suid
wrapper, logind-like daemon or otherwise.

As of kernel 5.10, they should just work in nearly all cases, so let's
just reinstate the calls.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-15 19:00:34 +02:00
Emil Velikov 899dae41f3 context_drm_egl: re-enable drmSet/DropMaster calls
The ioctls were disabled a while back since they error out and allegedly
cause problem with X running in another VT.

Omitting the ioctls is not cool, even as a workaround.

If they fail, the user is supposed to fallback appropriately - use a suid
wrapper, logind-like daemon or otherwise.

As of kernel 5.10, they should just work in nearly all cases, so let's
just reinstate the calls.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-15 19:00:34 +02:00
Guido Cella e16d0dd15d command: with lavfi-complex, make current-tracks return the first one
This behavior is more convenient and allows profile conditions like:

[video]
profile-cond=get('current-tracks/video/image') == false

[image]
profile-cond=get('current-tracks/video/image')

Otherwise, these profiles have to be manually applied and restored in a
script.

The note about discouraging the use of current-tracks in scripts is
removed, because it makes people avoid using this convenient property.
It was added in 720bcd79d0 without leaving an explanation of why you
shouldn't use it, and the only reason seems to be that it doesn't work
with lavfi-complex, but this commit changes that.
2021-10-15 15:11:00 +00:00
Guido Cella 9954fe01a9 player: add track-list/N/image sub-property
This exposes whether a video track is detected as an image, which is
useful for profile conditions, property expansion and lavfi-complex.

The lavf demuxer sets image to true when the existing check detects an
image.

When the lavf demuxer fails, the mf one guesses if the file is an image
by its extension, so sh->image is set to true when the mf demuxer
succeds and there's only one file.

The mkv demuxer just sets image to true for any attached picture.

The timeline demuxer just copies the value of image from source to
destination. This sets image to true for attached pictures, standalone
images and images added with !new_stream in EDL playlists, but it is
imperfect since you could concatenate multiple images in an EDL playlist
(which should be done with the mf demuxer anyway). This is good enough
anyway since the comment of the modified function already says it is
"Imperfect and arbitrary".
2021-10-14 15:39:07 +00:00
Guido Cella 00669dabd3 demux_lavf: improve image detection
This moves the image check to where the number of frames is available of
comparison, which allows not detecting jpg and png videos as images, and
detecting 1-frame gifs as images. This works with the mjpeg and png
videos in the FATE suite, though unfortunately the bmp video is still
detected as an image since it has nb_frames = 0.

aliaspix streams are also now considered images.

Attached pictures are now treated like standalone images, so audio with
attached pictures now has mf-fps as container-fps instead of
unavailable, which makes it consistent with external cover art, which
was already being assigned mf-fps.

Unfortunately images in a codec commonly used for videos are never
detected, and detection was inaccurate even using the now private
codec_info_nb_frames field in AVStream, and mediainfo gets them wrong
too, so I guess it's just a lost cause.
2021-10-14 15:39:07 +00:00
Avi Halachmi (:avih) f386fd79b2 js: custom init: ignore ~~/.init.js with --no-config
The custom init script should be considered a configuration file, and
as such it should be ignored when the user wants vanilla mpv - and now
it is ignored with --no-config.
2021-10-12 14:12:24 +03:00
Avi Halachmi (:avih) a3ef4c62fc DOCS/options: refine --no-input-default-bindings 2021-10-11 22:16:51 +03:00
Avi Halachmi (:avih) 2a183c5ca7 input: new option: --no-input-builtin-bindings
This is similar to [no-]input-default-bindings, but affects only
builtin bindings (while input-default-bindings affects anything which
config files can override, like scripting mp.add_key_binding).

Arguably, this is what input-default-binding should have always done,
however, it does not.

The reason we add a new option rather than repurpose/modify the
existing option is that it behaves differently enough to raise
concerns that it will break some use cases for existing users:
- The new option is only applied once on startup, while
  input-default-bindings can be modified effectively at runtime.
- They affects different sets of bindings, and it's possible that
  the set of input-default-bindings is useful enough to keep.

Implementation-wise, both options are trivial, so keeping one or the
other or both doesn't affect code complexity.

It could be argued that it would be useful to make the new option
also effective for runtime changes, however, this opens a can of
worms of how the bindings are stored beyond the initial setup.

TL;DR: it's impossible to differentiate correctly at runtime between
builtin bindings, and those added with mp.add_key_bindings.

The gist is that technically mpv needs/uses two binding "classes":
- weak/builtin bindings - lower priority than config files.
- "user" bindings - config files and "forced" runtime bindings.

input-default-bindings affects the first class trivially, but
input-builtin-bindings would not be able split this class further
at runtime without meaningful changes to a lot of delicate code.

So a new option it is. It should be useful to some libmpv clients
(players) which want to disable mpv's builtin bindings without
breaking mp.add_key_bindings for scripts.

Fixes #8809
(again. the previous fix 8edfe70b only improved the docs, while
now we're actually making the requested behavior possible)
2021-10-11 22:16:51 +03:00
sfan5 b3f3c3fec0 ci: update libs used by mingw build 2021-10-07 21:01:48 +03:00
Jan Ekström da58510a14 github/workflows: enable macOS 11.x CI
This image has finally become public.
2021-10-06 21:56:33 +03:00
Niklas Haas 564f3dba56 vo_gpu: libplacebo: add missing include
This was removed from common.h upstream since it was a cyclic
dependency. We need to re-import it into utils.h manually.
2021-10-04 12:09:58 +02:00
Niklas Haas 275c00974e vo_gpu: libplacebo: drop conditional code paths for old versions
No longer needed with the bump to v3.104.
2021-10-04 12:09:58 +02:00
Niklas Haas 48e8cb6a89 vo_gpu: libplacebo: drop code deprecated in libplacebo v3
This is only needed for back-compat with libplacebo v2, and will break
due to upstream removal starting with libplacebo v4.
2021-10-04 12:09:58 +02:00
Niklas Haas ef2cd3a663 wscript: bump libplacebo minimum version
Switching to v3 allows us to drop the use of deprecated/removed members.
2021-10-04 12:09:58 +02:00
Emil Velikov c27c17fcab options: add missing dash in msg-level help message
Currently using mpv --msg-level=help, shows an instance of --msglevel
(missing dash). Seems like the help message was only partially updated
with the -msglevel -> --msg-level transition.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-10-03 23:09:22 +03:00
Avi Halachmi (:avih) ca6108baf4 osc.lua: avoid infinite ticks loop on idle
Before this commit, animation-end was handled at render(), however,
it's not called on idle, which resulted in state.anitype ~= nil, with
nothing to reset it during idle, which caused in an infinite tick()
loop (starts on first mouse move).

Now tick resets the animation on idle, and also, as a safety measure,
if we're past 1s after the animation deadline.

The safety measure is because the osc states are complex, and it's
easier to detect a "we really shouldn't be animating now" at tick()
itself rather than detecting the exact states where animation should
be reset. Generally, the safety mmeasure is not needed.
2021-10-03 19:52:58 +03:00