0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

198 Commits

Author SHA1 Message Date
Kacper Michajłow
47be5ad4aa csputils: replace mp_chroma_location with pl_chroma_location 2024-01-22 14:54:55 +00:00
Kacper Michajłow
0ac7a40dac csputils: replace mp_alpha_type with pl_alpha_mode 2024-01-22 14:54:55 +00:00
Kacper Michajłow
66e451f4e6 csputils: replace mp_colorspace with pl_color_space 2024-01-22 14:54:55 +00:00
Kacper Michajłow
5220725ca5 vo: add params mutex
This mostly is added to resolve player command synchronization with VO
thread discussed in 477a0f83.

The current uses does not necessarily need this as they are all managed
by playloop. But for future use with other params that will be handy.

Those params are mostly to observe current state of VO and does not
necessarly need to be locked along with frame drawing, that changes the
params once at the end.
2023-11-22 11:51:46 +01:00
Kacper Michajłow
5a12015c4b vo_gpu_next: reduce number of requested frames from VO
Up to 2x playback rate is the most we can offer currently. Should work
fine for most kernels with radius <= 2.

This avoids limitation of hwdecs number of frames in-flight.

Fixes: #12927
2023-11-21 01:33:10 +00:00
Niklas Haas
d40e623fd5 vo_gpu_next: bump ICC cache size limit to 20 MB
These are less likely to be modified from run to run, and with the
avoidance of redundant re-saving we can get away with a larger size.

This is enough to save 10 3DLUTs at typical sizes.
2023-11-20 17:32:40 +01:00
Niklas Haas
70db887553 vo_gpu_next: don't re-save unmodified cache
Backwards compatibility wrapper can be bumped once sufficient libplacebo
version is a minimum dependency.

See-Also: https://github.com/mpv-player/mpv/pull/12902
2023-11-20 17:32:40 +01:00
Niklas Haas
e62dac8338 vo_gpu_next: dramatically simplify cache code
I have no idea why this code is such a convoluted mess of options and
possibilities. First of all, why is dumping both caches to a single file
even a supported use case? Why is the cache path generated multiple
times, once for saving and once for loading, instead of just generated
once and stored? Why even create a pl_cache if you're not going to
save/load it? Why so much code duplication?

I don't know. But I rewrote it in a way that makes far more sense to me.
2023-11-20 17:32:40 +01:00
Kacper Michajłow
4449f38c17 various: add some missing error checks 2023-11-18 23:55:28 +00:00
Kacper Michajłow
8dbc84dc16 vo_gpu_next: disable drift compensation for screenshots
This change prevents unwanted adjustments. Generally, screenshots
shouldn't invoke pl_queue_update, as this action could cull the already
mapped frames in the queue.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
ba5071a7ef vo_gpu_next: add validation for invalid pl_queue usage
This is mainly for debugging purposes, as it should't happen in normal
use. If it does, it needs fixing.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
fe748e54f1 vo_gpu_next: set frame duration if provided by VO 2023-11-18 22:54:29 +00:00
Kacper Michajłow
bd1ac498bb vo_gpu_next: interpolate only if display_synced or a still frame
If !display_synced, some values may not be correct or zeroed. Therefore,
it makes no sense to interpolate in this case.

For a non-moving frame, we always want to show an uninterpolated frame.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
4dcf2d1385 vo_gpu_next: request more frames to account for anti aliasing
libplacebo requires additional frames when VPS is lower than FPS and
anti-aliasing is enabled. Supports up to a 1/4 ratio. VO has a limit of
10 frames, so in practice, not many more can fit.

Note that the internal libplacebo mixing limit is 16 frames.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
c8a2f8eb7f vo_gpu_next: make the first frame check less ominous
It is valid to disable interpolation on resets and when the vsync error
exceeds the duration of the frames that we have available.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
dc2d58b514 vo_gpu_next: remove incorrect interpolation disabling
We can possibly have all the frames needed for interpolation, even after
a reset, so there's no need to prevent that.
2023-11-18 22:54:29 +00:00
Kacper Michajłow
faed191397 vo_gpu_next: fix pl_queue refill on reset
On reset, we would ignore all the frames that were seen before. This is
incorrect and would drop valid frames that should be rendered.
2023-11-18 22:54:29 +00:00
Dudemanguy
4b0f03d455 vo_gpu_next: set max cache size back down to 10 MiB
It turns out that mpv will rewrite the entire cache file on every single
quit. It's not so great since after viewing a ton of files, your cache
can grow to massive sizes and slow down quitting the player to a
noticeable amount. Turn down the max size of both caches to 10 MiB for
now as a workaround until this gets improved later.
2023-11-18 18:33:21 +00:00
Kacper Michajłow
ff7f105c85 vo_gpu_next: guard from cache save conflict
If multiple instances of mpv are closed at the same time, they will
write to the same temporary file. Fix that by using unique temporary
file.
2023-11-14 15:00:00 +00:00
Kacper Michajłow
5b4a119267 vo_gpu_next: disable libplacebo drift_compensation
In commit de6d57f0 libplacebo enabled drift compensation by default.

mpv already tracks error and adjust the speed by itself.

This commit fixes judder visible when slowing video a lot, ex. playing
back at 10% speed.

Set ideal vsync duration also when dropping frames, libplacebo estimate
currently own values anyway, will be useful later...

See: de6d57f021
2023-11-12 20:22:26 +00:00
Dudemanguy
ca6ae6fb5f vo_gpu_next: update overlays for blend subtitles on frame redraws
The commit subject sounds reasonable except that frame redraws get
spammed in certain cases (still image with subtitles) all the time
regardless if the subtitle actually has changed or not. So this is
stupid and wasteful, but you'll always see subtitles. vo_gpu currently
has this behavior as well, so we're just matching it but later mpv's
core should be fixed so this works reasonably. Fixes #11335.
2023-11-12 17:18:04 +00:00
Kacper Michajłow
7cab30cec7 vo_gpu_next: fix interpolation
Fixes gpu-next completely ignoring any speed adjustment, either DS or
playback.

Frames in pl_queue have raw PTS values, so when querying them we have to
use the same time base. There was misunderstanding between mpv and
libplacebo, where the former was querying the frames based on display
vblank timeline, but this cannot work if the playback speed is adjusted
and display timeline is not aligned with video timelien. In which case
we have to schedule "video vsync" points that we want to display.

Previous code was working only when playback speed was 1.0x, but since
DS almost always changes the speed the interpolation was mostly not
timied correctly.
2023-11-11 20:44:01 +00:00
Dudemanguy
332619042f vo_gpu_next: improve PTS clamping
Originally suggested by @haasn. Instead of awkwardly using a pts from
the previous render loop, we can just peek into pl_queue and use the pts
of the first frame instead. This eliminates a lot of weird artifacts
that can happen on discontinuities like seeking. Fixes #12355.
2023-11-11 20:44:01 +00:00
Dudemanguy
9199afc405 vo_gpu_next: add some additional sanity checking for interpolation
Several related things in regards to interpolation. Essentially this
adds more general sanity checking to bring it more in line with what
vo_gpu does.

- Add a can_interpolate bool which determines whether or not this frame
  is allowed to interpolate.
- p->is_interpolated was sometimes lying and because you can have a mix
  frames greater than 1 depending on the video and settings. Make sure
  that vsync_offset is not 0 so we know if it's actually interpolated or
  not. This prevents a redundant redraw for those edge cases when
  pausing.
- When the vo wants a reset, i.e. some sort of discontinuity, don't try
  to interpolate the frame. Interpolation is only valid for
  monotonically increasing times.

This fixes #11519 because of the additional check to make sure that we
have more than 1 frame. The PTS clamping part is still not great. That
is for the next commit.
2023-11-11 20:44:01 +00:00
sfan5
b4e14b9420 vo_gpu_next: overwrite cache files atomically 2023-11-10 11:26:10 +01:00
sfan5
cad24deea1 vo_gpu_next: refactor cache saving code
No functional change.
2023-11-10 11:26:10 +01:00
Kacper Michajłow
477a0f8318 vo: replace VOCTRL_HDR_METADATA with direct VO params read
Currently VOCTRL are completely unusable for frequent data query. Since
the HDR parameter addition to video-params, the parameters can change
each frame. In which case observe on those parameter would be triggered
constantly. The problem is that quering those parameters involves VOCTRL
which in turn involves whole render cycle of delay.

Instead update VO params on each draw_frame. This requires changes to VO
reconfiguration condition, but in practice it should only be triggered
when image size or data layout changes. In other cases it will be
handled internal by VO driver.

I'm not quite happy with this solution, but don't see better one without
changing observe/notify logic significantly. There is no good way
currently to handle VOCTRL that are constantly queried.

This adds unfortunate synchronization of player command with VO thread,
but there is not way around that and if too frequent queries of this
param becomes a problem we can thing of other solutions.

Changes the way to get data from VO driver added by a98c5328dc

Fixes: 84de84b
Fixes: #12825
2023-11-08 21:45:07 +00:00
Niklas Haas
293fe9d74a vo_gpu_next: add --target-gamut option
Fixes: https://github.com/mpv-player/mpv/issues/12777
2023-11-08 00:55:39 +01:00
sfan5
ff521dfbd1 vo_gpu_next: drop alpha channel from screenshots if unneeded 2023-11-07 16:15:19 +01:00
Kacper Michajłow
73fbe09a49 ALL: use pl_hdr_metadata and nuke sig_peak
This commit replaces all uses of sig_peak and maps all HDR metadata.

Form notable changes mixed usage of maxCLL and max_luma is resolved and
not always max_luma is used which makes vo_gpu and vo_gpu_next behave
the same way.
2023-11-05 18:57:36 +01:00
Kacper Michajłow
468feb863b csputils: change mp_hdr_metadata to pl_hdr_metadata 2023-11-05 18:57:36 +01:00
Kacper Michajłow
174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
Dudemanguy
6f8d98f812 vo_gpu_next: update to newer cache API
The old one would actually crash if the libplacebo.cache file was
invalid. Additionally, set a max size of 1 GiB for icc cache and 50 MiB
for gpu shader cache. The per object size limit is removed which puts
mpv in line with plplay. Finally, a few memory leaks are also fixed
since several objects previously were not freed on uninit.
2023-11-05 01:00:02 +00:00
Dudemanguy
ed4d21d401 vo_gpu_next: remove unneeded PL_API_VER guarding and defines
Since the minimum required libplacebo version is 6.338, all of these
checks are unneeded.
2023-11-05 01:00:02 +00:00
Niklas Haas
f537378d90 vo_gpu_next: use pl_queue_params() macro
In case new default parameters are added later.
2023-10-31 20:42:04 +01:00
Kacper Michajłow
869faadc68 options: disable --allow-delayed-peak-detect by default
Peak detection greatly increases HDR experience. Performance hit of
non-delayed detection is not that significant and is in line with
current default settings.
2023-10-25 11:55:56 +02:00
Niklas Haas
bd1ba99ab2 vo_gpu_next: optimally align DR buffers
May increase performance, especially when using DR with a dedicated
transfer queue.
2023-10-19 18:26:05 +02:00
Kacper Michajłow
cb48b40bb3 vo_gpu_next: cast const away to suppress warning 2023-10-19 14:03:23 +00:00
Dudemanguy
273906490d vo_gpu_next: only increment osd_sync in update_overlays if paused
While the video playing, it's not actually needed and can cause
unnecessary redraws. Fixes #12623.
2023-10-13 14:00:22 +00:00
Dudemanguy
a899e14bcc vo: change vo->driver->wait_events to nanoseconds
In many cases, this is purely cosmetic because poll still only accepts
microseconds. There's still a gain here however since
pthread_cond_timedwait can take a realtime ts now.

Additionally, 37d6604d70 changed the value
added to timeout_ms in X11 and Wayland to ensure that it would never be
0 and rounded up. This was both incomplete, several other parts of the
player have this same problem like drm, and not really needed. Instead
the MPCLAMP is just adjusted to have a min of 1.
2023-10-10 19:10:55 +00:00
Dudemanguy
07995f5d5f vo_gpu_next: improve updating overlays
fbe154831a added a new VOCTRL to signal
when the OSD changed for gpu-next's handling of subtitles, but this is
both not necessary and actually incomplete. The VOCTRL would signal OSD
changes, but not all subtitle changes (like selecting another
non-external sub track for example). VOCTRL_OSD_CHANGED was used to
increment p->osd_sync which would then redraw the blended subtitles if
the player was paused.

But there's already a VOCTRL_PAUSE and VOCTRL_RESUME. Plus, the
sub_bitmap_list object will have items in it if it changed in any way,
so we don't need the VOCTRL_OSD_CHANGED method at all. That can be
removed.

The check that fp->osd_sync < p->osd_sync stays in place since that's an
optimization while the video is playing, but we also check the pause
state as well since the VO can know this. If we're paused, then always
do update_overlays since core must be signalling a redraw to us if we
get a draw_frame call here. Additionally in update_overlays itself, the
p->osd_sync counter is incremented if we have any items since the frame
signature will need that. As for the actual bug that is fixed, changing
subtitle tracks while paused with blended subtitles now correctly works.
Previously, it was never updated so the old subtitle stayed there
forever until you deselected it (since VOCTRL_OSD_CHANGED triggered
there).

Also include some cosmetic code fixes that were noticed.
2023-10-05 22:32:06 +00:00
Niklas Haas
44cf6288c7 vo_gpu: remove --scaler-lut-size
Pointless bloat option, hard-coded as 256 now in libplacebo and no
reason not to also hard-code in mpv.

See-Also: haasn/libplacebo@64d7c5aab0
2023-09-25 12:45:17 +02:00
Niklas Haas
57fad2d5f9 vo_gpu: remove --scale-cutoff etc
Pointless bloat option, hard-coded as 1e-3 now in libplacebo and no
reason not to also hard-code in mpv.

See-Also: haasn/libplacebo@64d7c5aab0
2023-09-25 12:45:17 +02:00
Kacper Michajłow
704afb8968 vo_gpu_next: use proper color for subtitles
All SUBBITMAP_LIBASS are converted to sRGB beforehand, for the rest we
need to use video color space.
2023-09-21 21:23:35 +02:00
Kacper Michajłow
66c92dc059 vo_gpu_next: fix unscaled screenshot with --blend-subtitles
Need to use correct adjusted dst.
2023-09-21 02:26:42 +02:00
Kacper Michajłow
4bedcd36f6 vo: make cscale follow scale by default 2023-09-19 22:26:56 +02:00
llyyr
5efc04006b vo_gpu_next: fix blur and taper values being zero
This would always apply the config blur and taper values to the kernel,
even if it was zero because the user didn't specify any.
2023-09-18 17:42:28 +02:00
Niklas Haas
818ef158e8 vo_gpu_next: remove ewa_lanczossharp nag
Upstream finally caved in to peer pressure and added this filter. Of
course, this also removes the fallback for people on older versions of
libplacebo, but people using mpv git master are probably using
libplacebo git master anyway. It's time to debloat this code.
2023-09-16 14:33:45 +02:00
Niklas Haas
400c12fe00 vo_gpu_next: update for new ICC profile API
Upstream has moved from passing struct pl_icc_profile to directly
attaching a managed pl_icc_object, plus providing a new function
pl_icc_update to update the ICC profile object parameters (if needed).

To facilitate this move, pull our ICC params back out of pl_options and
update the target ICC object directly.
2023-09-15 10:58:37 +02:00
Niklas Haas
c9d5b482c1 vo_gpu_next: map --scaler-resizes-only 2023-09-14 18:24:47 +02:00