Commit Graph

50614 Commits

Author SHA1 Message Date
Kacper Michajłow ce64b5687b stats.lua: refactor video params display
- Move window scale to scaled resolution line
- add deinterlacing display
- rename "Gamma" to "Transfer"
- reorder to colormatrix/primaries/transfer as commonly used by
  ffmpeg/ffprobe
2023-08-28 21:14:26 +02:00
Kacper Michajłow 42f8c71aa0 stats.lua: remove dummy new lines from headers 2023-08-28 21:14:26 +02:00
Kacper Michajłow 52bf44d2e0 stats.lua: display actual output video size after anamorphic correction
This makes much more sens than frame size that is the same as native
one.
2023-08-28 21:14:26 +02:00
Dudemanguy 165f9e061f player: add always to --subs-fallback-forced
In general, forced tracks should only be shown if they match the
language of the audio. However some people do want them no matter what,
so add an always option to this so such tracks are always selected.
2023-08-28 18:43:46 +00:00
Dudemanguy 58ec0630f5 player: add --subs-match-os-language option
This is the replacement for the previous auto option for slang. It
behaves similar however it never overrides slang if that is set and will
instead try to pick the subtitle that matches the user's language if
appropriately flagged by the file.
2023-08-28 18:43:46 +00:00
Dudemanguy fbe8f99194 loadfile: simplify default track selection a bit
What was previously there is extremely complicated and really confusing.
Poorly named variables like "prefer_forced" that don't neccesarily have
anything to do with prefering forced tracks didn't help either. Try to
rewrite a few things to be saner. The idea is that after you loop
through the tracks, the special sub-specific options (like subs-fallback
and so on) should be handled and the track should be deselected if
appropriate. Another change is to remove the "prefered_forced" argument
in compare_track. This actually was both not neccessary and caused bad
behavior by always depriortizing forced tracks even when it didn't apply
(e.g. forced video tracks were never selected even though the flag
should simply be ignored for anything that's not a subtitle track).
2023-08-28 18:43:46 +00:00
Dudemanguy 53d032374d player: remove special auto option from alang/slang/vlang
This proved to be too problematic. Depending on the value of
--subs-with-matching-audio, you could either end up with cases where
--slang wasn't respected and users didn't get subtitles or alternatively
cases where subtitles were given and the user didn't ask for them.
Fundamentally, the OS language functionality doesn't really map well to
slang (and for alang/vlang it makes zero sense; not that anyone actually
used it). Instead of trying to shove it in an option where it doesn't
belong, we should split this off into something else. So for now, just
remove the special handling of "auto" and flip slang back to NULL.
2023-08-28 18:43:46 +00:00
Guido Cella e1f9444d4d playlist: remove unused code to track redirects
It turns out that the code to track redirects (playlists and
directories) never worked correctly, only the last redirect is
remembered and num_redirects is never greater than 1.

You can see this by doing quit-watch-later with the old watch later
system, before dbf244fd2f, on a m3u playlist of files and a m3u playlist
of directories. Only in the first case a redirect entry for the m3u file
is created, because in the second case the m3u redirect is replaced by
the directory one.

If you did mpv --directory-mode=lazy /foo it did create redirect entries
for all subdirectories e.g. /foo/bar, /foo/bar/baz, /foo/bar/baz/qux,
this made it seem like it worked correctly, but actually
/foo/bar/bar/qux was the only redirect entry and thus it was considered
as the first redirect, and mpv created redirect entries for each segment
of the first redirect only.

In the previous commit dbf244fd2f, rather than figuring out how to fix
the code to track redirects, and since creating redirect entries for
multiple redirects is overkill, I just used the new playlist-path
property which does the same thing but only for the last redirect.

By replacing the only other use of the old redirect code with
playlist-path, we can remove it.
2023-08-28 18:31:17 +00:00
Guido Cella 64959c450d player: always write redirect entries for resuming playback
35f43dfacb added a system to write resume files for redirects, i.e.
directories and playlists that mpv expands.

It creates a resume file for each redirect, and for the first redirect
only, it writes a resume file for each segment of its path, without even
converting it to an absolute path if it's relative. This is incomplete:

mpv 'Iron Maiden/1982 The Number of the Beast/8 Hallowed Be Thy Name.mp3'
This doesn't save any redirect entry.

mpv --directory-mode=recursive 'Iron Maiden', then quit-watch-later on
Hallowed Be Thy Name
This saves a redirect entry for "Iron Maiden", but not for "1982 The
Number of the Beast". It doesn't save redirect entries for the
directories above "Iron Maiden" either because "Iron Maiden" isn't
converted to an absolute path.

In both of these cases mpv --directory-mode=lazy 'Iron Maiden' won't
resume from "Hallowed Be Thy Name" because "1982 The Number of the
Beast" isn't the first subdirectory and there is no redirect entry for
it.

503dada42f made mpv recursively expand subdirectories precisely to fix
this, and f266eadf1e added back an option not to expand them. But if we
fix how redirect entries are stored, we can make the superior
--directory-mode=lazy (because it's faster and doesn't result in massive
playlists) the default, and also ensure that mpv will resume playback
even when you quit-watch-later a file without redirects and then play
the directories above it.

Fix this by always creating redirect entries for all segments of the absolute
path of the file, so that both

mpv 'Iron Maiden/1982 The Number of the Beast/8 Hallowed Be Thy Name.mp3'
and
mpv --directory-mode=lazy 'Iron Maiden'

will create redirect entries for

/$USER
/$USER/music
/$USER/music/Iron Maiden
/$USER/music/Iron Maiden/1982 The Number of the Beast

making mpv --directory-mode=lazy "Iron Maiden" resume from
"Hallowed Be Thy Name".

This commit also makes mpv delete the redirect entries of parent
directories when resuming playback, because if for example you have a
playlist with all the songs in a discography:

1980 Iron Maiden/1 Prowler.mp3
1980 Iron Maiden/2 Remember Tomorrow.mp3
...
1981 Killers/1 The Ides of March.mp3
1981 Killers/2 Wrathchild.mp3
...

Now mpv will eventually create redirect entries for every album. If you
later decide to play the directories instead and there are 20 albums,
you would have to do mpv * 20 times to clear all the redirect entries.
2023-08-28 18:31:17 +00:00
Robert Mader 5a690a168a vo_dmabuf_wayland: unmap osd surface when not needed
Attaching a NULL buffer unmaps the surface, allowing compositors to skip
blending the empty buffer.

Closes #12236
2023-08-28 18:16:10 +00:00
Niklas Haas 3e612c07f4 vo_gpu_next: fix --target-contrast=inf
Somehow this overrode max_luma instead of min_luma...

Fixes: 347fbd6fa3
2023-08-28 18:30:54 +02:00
Dudemanguy 3079ae5db3 README: replace outdated xinerama reference with xpresent
200992f90c stopped linking mpv to
libXinerama so this library isn't needed anymore. However, we do use
xpresent so mention that instead since all the other needed xorg
libraries are listed as well.
2023-08-27 20:43:45 -05:00
llyyr 8bf3fe7e2a f_lavfi: don't reject dynamic lavfi ins/outs
Ideally, users should be using lavfi-complex instead of lavfi-bridge
for such a use case, however currently lavfi-complex doesn't support
hwdec. So we can allow filters with dynamic inputs to work with
lavfi-bridge, at the cost of them only being able to take in
only one input. This should probably be reverted when/if lavfi-complex
has hwdec, but for now this allows us to use libplacebo
as a video filter with hwdec in mpv again.
2023-08-28 00:29:43 +02:00
llyyr a19aefac37 osc: fix margin for forced-only subs toggle in bar layout
This ensures the spacing between forced-only sub toggle button and the
volume button matches the spacing between the volume and the fullscreen
button on bottombar/topbar layouts
2023-08-27 16:28:24 +00:00
llyyr d0bc907806 osc: only add sub forced-only toggle to layout for DVD/PGS subs
Fixes: 945d7c1eda

Previously, we would have a button with empty string added to the layout
for non DVD/PGS subtitles. This would cause there to be an invisible
button present that would take up space and could still be clicked
despite being invisible when the current subtitle track was not DVD/PGS.
The idea was that the button would be invisible for regular subtitle
tracks, and be visible as "[ ]"/"[F]" for DVD/PGS subtitle tracks.

This commit modifies the bar and box layouts to only add this button if
the current subtitle track is DVD/PGS. This results in there no longer
being an invisible button, and also prevents it from taking up space.
The button is added to layout as before when the current subtitle track
is DVD/PGS, matching the same logic as before.
2023-08-27 16:28:24 +00:00
Christoph Heinrich 8301906218 input: add missing windows multimedia keys
x11 and wayland had a lot of multimedia keys mapped that were missing
on windows.
Now the only ones they map that windows doesn't are `MP_KEY_WWW`,
`MP_KEY_ZOOMIN` and `MP_KEY_ZOOMOUT`, which apparently don't have any
equivalent ones on windows.
2023-08-27 16:14:27 +00:00
llyyr f9918b5390 command: add `sub-ass-extradata` property 2023-08-27 16:14:18 +00:00
Niklas Haas 902bbdad35 vo_gpu_next: update tmp params before rendering frame
Gives the correct queue size value for the subsequent pl_queue_update()
calls, which avoids a bit of unnecessary overhead.
2023-08-27 14:39:45 +02:00
Niklas Haas 0fd357a416 vo_gpu_next: make option shim consistent with new API
Avoids some unnecessary #ifdef and allows us to isolate the shim to a
single location.
2023-08-27 14:39:45 +02:00
Niklas Haas 835fd7bdeb vo_gpu_next: avoid duplicate code (cosmetic)
Also avoids 80col violation.
2023-08-27 14:39:45 +02:00
Niklas Haas 6fb9d92b25 vo_gpu_next: correctly set params.frame_mixer
This was incorrectly adapted from the old options system, we forgot to
ever actually assign p->frame_mixer to params.frame_mixer.

Fixes: d2082841df
2023-08-27 14:39:45 +02:00
Niklas Haas 23e9b57791 vo_gpu_next: don't nuke main options state in video_screenshot
This actually fixes a bug that was present in this code even before the
new pl_options system, which is that `video_screenshot` would
permanently leave `peak_detect_params.allow_delayed` as false, until
something else forced options re-application due to options cache
change.
2023-08-27 14:39:45 +02:00
Niklas Haas 87aa65285b vo_gpu_next: don't override main options in draw_frame
Instead, take a stack copy of the relevant struct. Avoids leaving
temporary state dangling after this function returns.

Fixes: 40b6afcfca
2023-08-27 14:39:45 +02:00
Philip Langdale 83c0e98047 hwtransfer: check if the source format is accepted directly by the VO
This may seem obvious in retrospect, but we need to explicitly account
for the case where the source format is supported by the VO, but not
a valid target format for the conversion filter. In that situation, we
would conclude that conversion was necessary, because we relied solely
on the conversion filter to identify acceptable target formats.

To avoid that, we should go through the VO's reported set of supported
formats and if the source format is on the list, ensure that format is
also on the target list.

This is mostly a no-op as most VOs do not report supported formats
(instead assuming that all formats decoders can produce are supported)
and in the case where it matters (vaapi), there is only one format that
the VO supports which the conversion filter does not (yuv444p).
2023-08-26 10:07:55 -07:00
Philip Langdale 19ea8b31bd hwtransfer: use the right hardware config to find conversion targets
The last piece in the puzzle for doing hardware conversions
automatically is ensuring we only consider valid target formats for the
conversion. Although it is unintuitive, some vaapi drivers can expose a
different set of formats for uploads vs for conversions, and that is
the case on the Intel hardware I have here.

Before this change, we would use the upload target list, and our
selection algorithm would pick a format that doesn't work for
conversions, causing everything to fail. Whoops.

Successfully obtaining the conversion target format list is a bit of a
convoluted process, with only parts of it encapsulated by ffmpeg.
Specifically, ffmpeg understands the concept of hardware configurations
that can affect the constraints of a device, but does not define what
configurations are - that is left up to the specific hwdevice type.

In the case of vaapi, we need to create a config for the video
processing endpoint, and use that when querying for constraints.

I decided to encapsulate creation of the config as part of the hwdec
init process, so that the constraint query can be down in the
hwtransfer code in an opaque way. I don't know if any other hardware
will need this capability, but if so, we'll be able to account for it.

Then, when we look at probing, instead of checking for what formats
are supported for transfers, we use the results of the constraint query
with the conversion config. And as that config doesn't depend on the
source format, we only need to do it once.
2023-08-26 10:07:55 -07:00
Philip Langdale 7d7ef05f10 autoconvert: destroy sub filter immediately if reconfiguration is needed
I'm currently not convinced that the way the output_chain is handled as
part of reconfiguration is correct. If there is an event requiring
reconfiguration, such as toggling the use of hwdec, we currently do not
ensure that the filter chain is fully drained first. This creates a
situation where the filter chain is invalidated while the autoconvert's
sub filter (that does the real work) still has a frame to process and
pass on.

As the autoconvert code calls mp_subfilter_drain_destroy(), it returns
early to allow for draining before destroying the subfilter, but that
means the subfilter is still present in its original configuration, and
no actually draining is done before the existing filters reinitialise
themselves.

This leads to a situation where, if a hardware scaling filter is being
used by autoconvert, that filter is still present and responds when
told to reinitialise. But it cannot successfully reinitialise if the
triggering event is disabling hw decoding, as the input frame to the
filter will now be a software frame, so reinit fails, leading to total
failure of the filter chain, which is a fatal error, and we exit.

I think this was never noticed before, because I think it's not
possible for the hwtransfer filter to be active in a situation where
you can dynamically change the state such that the input or output
formats of the output chain are invalidated.

eg: If the autoconverter is activated because of `--vf=format=vaapi`,
it is actually not possible to toggle hwdec off, as the explicit user
filter ensure the hwdec is always present and active.

So, my solution here is to destroy the sub filter, regardless of
whether it needs draining or not. We simply have no opportunity to
drain and reconfigure in the correct order, and we must consider the
remaining frame in the filter as a casualty of the toggling process.

I'm sure there is a more substantial rework of the output_chain
reconfiguration process that could ensure draining before
reconfiguration begins, but my ambitions do not currently extend that
far.
2023-08-26 10:07:55 -07:00
Philip Langdale 05a4f57703 output_chain: don't reset autoconvert on changes to unrelated filters
This has been a standing behaviour for a long time, but I noticed it
while implementing the hw->hw autoconvert functionality. Today, the
output_chain will reset the autoconvert state when any output_chain
filter sees the input format change. This is wasteful as it leads to
the image converter having to be reinitialised each time it happens,
so we should only do it when the actual "convert" filter sees the
input format change. It doesn't matter if one of the other filters in
the chain sees a change (although in practice, a format change will
basically always propagate down the chain, so they all see a change
at the same time).

The practical effect of the old behaviour was that a format change
would always lead to the image converter being rebuilt twice - once
after the "convert" filter sees the format change, and then again
after the "out" filter (the end of the chain) sees the change.

In this commit, we check which filter is seeing the change, and only
reset the autoconvert state for the "convert" filter itself.
2023-08-26 10:07:55 -07:00
Philip Langdale 59478b0059 hwtransfer: implement support for hw->hw format conversion
Historically, we have not attempted to support hw->hw format conversion
in the autoconvert logic. If a user needed to do these kinds of
conversions, they needed to manually insert the hw format's conversion
filter manually (eg: scale_vaapi).

This was usually fine because the general rule is that any format
supported by the hardware can be used as well as any other. ie: You
would only need to do conversion if you have a specific goal in mind.

However, we now have two situations where we can find ourselves with a
hardware format being produced by a decoder that cannot be accepted by
a VO via hwdec-interop:
 * dmabuf-wayland can only accept formats that the Wayland compositor
   accepts. In the case of GNOME, it can only accept a handful of RGB
   formats.
 * When decoding via VAAPI on Intel hardware, some of the more unusual
   video encodings (4:2:2, 10bit 4:4:4) lead to packed frame formats
   which gpu-next cannot handle, causing rendering to fail.

In both these cases (at least when using VAAPI with dmabuf-wayland), if
we could detect the failure case and insert a `scale_vaapi` filter, we
could get successful output automatically. For `hwdec=drm`, there is
currently no conversion filter, so dmabuf-wayland is still out of luck
there.

The basic approach to implementing this is to detect the case where we
are evaluating a hardware format where the VO can accept the hardware
format itself, but may not accept the underlying sw format. In the
current code, we bypass autoconvert as soon as we see the hardware
format is compatible.

My first observation was that we actually have logic in autoconvert to
detect when the input sw format is not in the list of allowed sw
formats passed into the autoconverter. Unfortunately, we never populate
this list, and the way you would expect to do that is vo-query-format
returning sw format information, which it does not. We could define an
extended vo-query-format-2, but we'd still need to implement the
probing logic to fill it in.

On the other hand, we already have the probing logic in the hwupload
filter - and most recently I used that logic to implement conversion
on upload. So if we could leverage that, we could both detect when
hw->hw conversion is required, and pick the best target format.

This exercise is then primarily one of detecting when we are in this
case and letting that code run in a useful way. The hwupload filter is
a bit awkward to work with today, and so I refactored a bunch of the
set up code to actually make it more encapsulated. Now, instead of the
caller instantiating it and then triggering the probe, we probe on
creation and instantiate the correct underlying filter (hwupload vs
conversion) automatically.
2023-08-26 10:07:55 -07:00
Dudemanguy 32be72623b player: make all autoload extensions configurable
--audio-file-auto, --cover-art-auto, and --sub-auto all work by using an
internally hardcoded list that determine what file extensions get
recognized. This is fine and people periodically update it, but we can
actually expose this as a stringlist option instead. This way users can
add or remove any file extension for any type. For the most part, this
is pretty pretty easy and involves making sub_exts, etc. the defaults
for the new options (--audio-file-auto-exts, --cover-art-auto-exts, and
--sub-auto-exts). There's actually one slight complication however. The
input code uses mp_might_be_subtitle_file which guesses if the file drag
and dropped file is a subtitle. The input ctx has no access to mpctx so
we have to be clever here.

For this, the trick is to recognize that we can leverage the
m_option_change_callback. We add a new flag, UPDATE_SUB_EXTS, which
fires when the player starts up. Then in the callback, we can set the
value of sub_exts in external_files to opts->sub_auto_exts. Whenever the
option updates, the callback is fired again and sub_exts updates. That
way mp_might_be_subtitle_file can just operate off of this global
variable instead of trying to mess with the core mpv state directly.

Fixes #12000.
2023-08-26 00:33:00 +00:00
llyyr afdd2fa565 player: use audio pts corresponding to playing audio on EOF
We should account for ao queue when setting playback position on EOF,
previously we were using the pts value corresponding to the start of
the ao queue, rather than the currently playing audio.

This fixes time-remaining being a negative number when mpv seeks to EOF
while playback is paused.
2023-08-25 22:38:25 +00:00
Christoph Heinrich 0c9d8619e8 input: add missing keypad key defines
So far all the keypad keys except for `0` and `,` mapped to the same
MP_KEY_* independent of numlock state, even though different key codes
are received.
Now all the alternative functions map to appropriate MP_KEY_* defines,
with missing ones added.
2023-08-25 15:55:31 +00:00
llyyr c0fb9b4b83 sub/osd: signal osd_changed on resize
We should update the osd when the window is resized, previously we
weren't signalling for an update.
2023-08-25 09:34:53 +02:00
Kacper Michajłow ce79976498 win32: don't ignore --screen and --fs-screen
Fixes: 57ba77fc73
Fixes: #12220
2023-08-23 15:37:41 +02:00
James Cuzella 3916871101 DOCS/mpv: document ZOOMIN & ZOOMOUT multimedia keys
Document default key mappings for ZoomIn & ZoomOut:

    ZOOMIN    add video-zoom   0.1
    ZOOMOUT   add video-zoom  -0.1
2023-08-23 15:37:02 +02:00
James Cuzella fa378249dd input: add new keys: Back, Tools, ZoomIn, ZoomOut
These were the only keys missing to support mapping all keycodes on a
[popular RF Remote][1] used with Linux HTPC apps.

Note that X11/XWayland + xkbcomp still warns about keycodes > 255, due
to the 8-bit limit in Xorg but `mpv` on Wayland is able to handle these.
For X11 users, there are [a couple options][2]:

- [Gianni Ceccarelli's patched `xf86-input-evdev`][3]
- [Use udev hwdb to map scancodes to keycodes][4]

[1]: https://www.mythtv.org/wiki/Air_mouse_rf_remote
[2]: https://unix.stackexchange.com/a/436233/7688
[3]: https://www.thenautilus.net/SW/xf86-input-evdev/
[4]: https://wiki.archlinux.org/title/Map_scancodes_to_keycodes
2023-08-23 15:37:02 +02:00
Niklas Haas af9b53f3a3 vo_gpu_next: move line to correct location (cosmetic) 2023-08-21 19:50:20 +02:00
Niklas Haas 32ee937afa vo_gpu_next: correctly handle GAMUT_AUTO
Fixes: https://github.com/mpv-player/mpv/issues/12208
2023-08-21 19:49:59 +02:00
sfan5 76b1d282a5 ci/mingw: disable vulkan for 32-bit build
There's some cdecl / stdcall linking nonsense breaking the build
which I'm not inclined to debug this Sunday at all.
32-bit is not important anyway, so just disable it there.

On the plus side the new functional structure makes this very painless.
2023-08-21 16:43:38 +02:00
sfan5 c936377e34 ci/mingw: don't include useless DLLs in artifact 2023-08-21 16:43:38 +02:00
sfan5 b11b602312 ci/mingw: refactor build script into functions 2023-08-21 16:43:38 +02:00
sfan5 654ccb3c2c ci/mingw: enable more ffmpeg features
If someone wants to use the CI artifacts for day-to-day usage
or even for certain tests it can be useful to take screenshots
and use e.g. DShow (--disable-devices option), so enable those.
2023-08-21 16:43:38 +02:00
sfan5 aed8d6f552 ci/mingw: add necessary deps and enable vulkan 2023-08-21 16:43:38 +02:00
sfan5 9b9409196b ci/mingw: move functional test to workflow
Arguably the better place for this as it provides fine-grained feedback.
2023-08-21 16:43:38 +02:00
sfan5 c7342bbd5a ci/mingw: update dependency versions 2023-08-21 16:43:38 +02:00
Niklas Haas ef4c6dfcf5 vo_gpu_next: reword error message on empty screenshot
This can happen under perfectly legitimate circumstances if no file is
loaded yet.
2023-08-21 13:43:20 +02:00
Dudemanguy 3422e5e1e8 DOCS/options: clarify the video-pan-x/y example
1fa6669bc0 misinterpreted the example and
changed the pixel value from 128 to 168 (thinking that it meant pixels
after scaling), but likely the original calculation was correct because
the line specifically says "of the source video". This is just confusing
not really useful information so instead change the example to a more
common resolution (1920x1080) and remove any references to the source
video resolution. Also mention video-pan-y while we're at it.
2023-08-20 19:02:31 -05:00
Kacper Michajłow 7d6f9e3739 aspect: change --video-pan-x/y to be relative to the destination rect
It makes it more usable to virtually move dst rect instead of scaled
src.

The issue with the latter is that it is affected by video-zoom
paramters. For example if we do `--video-pan-x=-0.5` in normal case it
will move video -50%, but if we apply video-zoom/scale the video will
float towards the middle in unintuitive way. Extreme case is when one do
--video-zoom-x=0.01, now it is impossible to move video unless you
specify huge video-pan-x value, but it is limited to [-3, 3]. So you
cannot do anything.

With this changes regardless of video scale/zoom, video-pan will keep
center of scaled video in one place.
2023-08-20 23:15:48 +00:00
Kacper Michajłow 56ec3ea9f6 aspect: don't allow scaled_src_size be 0
It doesn't make sense to have zero here and it breaks, logic below.
Width was still campled to 1, but with broken offset.

This fixes things like video-scale-x=0
2023-08-20 23:15:48 +00:00
Kacper Michajłow 1fa6669bc0 DOCS/options: fix typo in video-pan-x example
Width of the video would fill fully display at this resolution, so
moving it 168px to the left, would hide also 168px.
2023-08-20 23:15:48 +00:00
sfan5 ecbaf34701 meson: rename all features with underscores
The convention is to use dashes.
2023-08-20 21:13:37 +00:00