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

4348 Commits

Author SHA1 Message Date
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
llyyr
f5ca11e12b meson: make libplacebo a required dependency
Make it not possible to build mpv without the latest libplacebo anymore.
This will allow for less code duplication between mpv and libplacebo,
and in the future also let us delete legacy ifdefs and track libplacebo
better.
2023-10-23 13:03:29 +02:00
Kacper Michajłow
0a799547aa vo: define <= 0 as unsupported for last_queue_display_time
Also sanitize vsync values, just in case.
2023-10-23 00:10:49 +00:00
Kacper Michajłow
ed8b3cef5f vo: change spammy log to trace 2023-10-23 00:10:49 +00:00
Kacper Michajłow
8c7c878255 vo: average more vsync samples
Improves averaging on high refresh rate displays.
2023-10-23 00:10:49 +00:00
Kacper Michajłow
f27767f59e d3d11: calc vsync interval on real stats, not just last interval 2023-10-23 00:10:49 +00:00
NRK
a1f465b582 aspect: remove unused multiplication
the variable `w` is unused as a whole.
2023-10-23 00:10:42 +00:00
NRK
d05ef7fdc4 various: sort some standard headers
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
2023-10-20 21:31:09 +02:00
NRK
450a69b1d6 various: remove ATOMIC_VAR_INIT
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then made obsolete in C17 and removed in C23.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
2023-10-20 21:31:09 +02:00
NRK
2070331f64 osdep: remove atomic.h
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
2023-10-20 21:31:09 +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
Niklas Haas
f369e65261 vd_lavc: align buffers to multiple of image size
Fixes: https://github.com/mpv-player/mpv/issues/12672
2023-10-19 18:26:05 +02:00
Kacper Michajłow
1ea1359a82 win32: suppress pointer cast warning 2023-10-19 14:03:23 +00:00
Kacper Michajłow
cb48b40bb3 vo_gpu_next: cast const away to suppress warning 2023-10-19 14:03:23 +00:00
Kacper Michajłow
7e18a46ec2 d3d11: don't skip last char in buffer
Both buffers have the same size (32) and if the source is not null
terminated it should be fixed there. Copy whole buffer.
2023-10-19 14:03:23 +00:00
Kacper Michajłow
94b7584972 win32: clear background only on first paint
Some users report visible black frames during window resize, this should
not happen in most cases. Let's just keep stale content as it is less
distracting. While still clearing on first window paint to avoid white
background.

Fixes: #12642
2023-10-18 15:22:22 +00:00
Dudemanguy
11bbb49bdf wayland: use ppoll if possible
Since the previous commit unbreaks the timeout, this now actually works.
Imagine that.
2023-10-17 15:05:33 +00:00
Dudemanguy
917bdf1b5c dither: removed some unused code
Added in 58a7d81dc5. Nobody touched it
since then, so it's probably useless. libplacebo has its own dithering
stuff anyways.
2023-10-16 15:38:59 +00:00
Dudemanguy
39b9635305 vo: convert some final low-hanging things to nanoseconds 2023-10-16 15:38:59 +00:00
Dudemanguy
de9b800879 timer: add convenience time unit conversion macros
There's a lot of wild 1e6, 1000, etc. lying around in the code. A macro
is much easier to read and understand at a glance. Add some helpers for
this. We don't need to convert everything now but there's some simple
things that can be done so they are included in this commit.
2023-10-16 15:38:59 +00:00
der richter
78d43740f5 vo_gpu/vo_gpu_next: add vulkan support for macOS
add support for vulkan through metal and a translation layer like
MoltenVK. also add the possibility to use different render timing modes
for testing.

i still consider this experimental atm.
2023-10-14 18:39:56 +02:00
der richter
bc66de2834 mac: add a window animation lock to wait for animations to finish
add an animation lock to the window to prevent the window from closing
while animating. if this is done while the fs animation is running the
dock will stay hidden. this is not used yet, because it's unnecessary
for cocoa-cb but will be for new vo backends.
2023-10-14 18:39:56 +02:00
Kacper Michajłow
fd46070490 hwdec_dxva2egl: fix log value type
Fixes type mismatch after recent changes.

Fixes: 59dd7d94af
2023-10-14 14:02:54 +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
NRK
e41add29d4 drm_common: don't spoil errno in signal handler
same rationale as last commit
2023-10-13 11:36:01 +02:00
sunpenghao
1dd71a6093 win32: improve window snapping behavior
Several window resizing operations (i.e., --auto-window-resize,
border dragging with --keep-aspect-window, Alt+0/1/2) cause the
window to detach from the snapped borders. This patch resolves
this by recording to which borders the window is snapped, and
using this info to determine how the window should be placed after
resizing.

Closes https://github.com/mpv-player/mpv/issues/6588
2023-10-10 19:41:08 +00:00
Dudemanguy
59dd7d94af timer: change mp_sleep_us to mp_sleep_ns
Linux and macOS already use nanosecond resolution for their sleep
functions. It was just being converted from microseconds before. Since
we have mp_time_ns now, go ahead and bump the precision here. The timer
for windows uses some timeBeginPeriod thing which I'm not sure what it
does really but whatever just convert the units to ms like they were
doing before. There's really no reason to keep the mp_sleep_us helper
around. A multiplication by 1000 is trivial and underlying OS clocks
have nanosecond precision.
2023-10-10 19:10:55 +00:00
Dudemanguy
5d44cf93df vo: use mp_poll wrapper in wait_events when applicable
On linux, several platforms poll for events over a fd. This has ms
accuracy, but mpv's timer is in ns now so lots of precision is lost. We
can use an mp_poll wrapper to use ppoll instead which takes a timespec
directly with nanosecond precision. On systems without ppoll this falls
back to old poll behavior. On wayland, we don't actually use this
because ppoll completely messes up the event loop for some unknown
reason.
2023-10-10 19:10:55 +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
c82c55b4b9 vo: use nanoseconds for frame duration and pts 2023-10-10 19:10:55 +00:00
Dudemanguy
ae335ef155 vo: remove vo_get_estimated_vsync_interval conversion to seconds
This is weird. The caller should be responsible for converting the value
if desired. Move the conversion to player/command.c instead.
2023-10-10 19:10:55 +00:00
Kacper Michajłow
ef11d31c3a vo: remove frame timing check from vo_still_displaying()
This timing dependency does not guarantee that we will wake up in the
future, depending on processing times.
2023-10-07 17:50:50 +00:00
Kacper Michajłow
44c398c3e1 Revert "video: remove another redundant wakeup"
vo_still_displaying() is racey with vo_request_wakeup_on_done() and above
that it doesn't work as expected. VO can run out of work and go to sleep
for 1000s, while the play thread still returns on vo_still_displaying()
check, because of a check `now < frame_end` so it never advances and go
to sleep itself.

This fixes dead lock that we have when image parameters changes during
playback.

This reverts commit 0c9ac5835b.

Fixes: #12575
2023-10-07 17:50:50 +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
Dudemanguy
61aecfabfd vo_dmabuf_wayland: correct full window size calculation
The current calculation makes the implicit assumption that the margins
on both sides are always equal (the 2 times multiplication). This isn't
true though. For example, a 720p video fullscreened on a 1680x1050
display will have a top margin of 52 but a bottom margin of 53. The
current calculation just multiplies 52 by 2, so it's off by one. Fix
this by adding together all the margins together (left + right or top +
bottom) then adding that to the dst window size (width or height). This
way, we get the full size of the window for the viewport. Fixes #12554.
2023-10-05 22:28:37 +00:00
Kacper Michajłow
d17db1367a win32: clear client area to black early
This fixes white background appearing for short period of time before
first frame is drawn. Clear to black as this is way less distracting
than bright white flash.

Borderless window and fullscreen seems to be initially not
drawn/transparent, so no need to clear it to black. Only when
decorations are enabled (--border) the issue happens.

Fixes: #12549
2023-10-05 17:10:23 +02:00
Dudemanguy
8641cbaab6 vo_dmabuf_wayland: free frame if the visibility check fails
Forgotten in 7b8a30fc81. Every other case
either is either a dummy frame (no allocated memory) or we manage it as
part of the usual wayland buffer release.
2023-10-04 16:21:47 -05:00
Dudemanguy
7b8a30fc81 vo_dmabuf_wayland: eliminate an extra frame copy
When implementing vo_dmabuf_wayland, it always did a copy of the image
from the current frame and worked with that. The reason was because
mpv's core held onto the frame and caused some timing issues and
rendering glitches depending on when it freed the image. This is pretty
easy to fix: just make vo_dmabuf_wayland manage the the frames. In vo.h,
we add a boolean that a VO can set to make them manage freeing frames
directly. After doing this, change the buffers in vo_dmabuf_wayland to
store the whole vo_frame instead of just the image. Then, just modify
some things a bit so frame is freed instead of the image. Now, we should
truly have zero-copy playback. Well as long as you don't use libass to
render anything (that's still a copy from system memory).
2023-10-03 23:45:20 +00:00
Kacper Michajłow
01c5346d1a win32: adjust WM_NCACTIVATE for better compatibility with window state
We have to support all changing states, not only borderless.
2023-10-02 21:51:47 +00:00
Dudemanguy
47dec1c7c2 vo_dmabuf_wayland: attach solid buffer when using force window
e125da2096 changed the z order of the
surfaces a bit, but it turns out this has a side effect. If the aspect
ratio of the actual video doesn't match your display, the osd surface
doesn't scale properly and gets clipped. Put the z ordering back where
it used to be. Instead when we have the force window case, simply attach
the already existing solid buffer to the video surface. This allows the
osd surface to actually draw over it instead of always being obscured so
it satisfies the case of not having any real video frames but still
wanting to draw the osd. Also don't mess with any of the viewport source
setting stuff with force window. Weston complains about it, and it's
nonsensical anyway. Fixes #12547.
2023-10-02 15:58:03 -05:00
Kacper Michajłow
a98641cf45 win32: add WS_THICKFRAME style in borderless mode
Fixes window resizing in borderless mode after adding WS_SYSMENU.

Fixes: 172d9be300
2023-10-01 15:57:31 +00:00
Dudemanguy
0b70598358 vo: fully replace draw_image with draw_frame
0739cfc209 added the draw_frame API
deprecated draw_image internally. VOs that still used draw_image were
around, but really there's no reason to not just "upgrade" them anyway.
draw_frame is what the "real" VOs that people care about (gpu/gpu-next)
use. So we can just simplfy the code a bit now. VOCTRL_REDRAW_FRAME is
also no longer needed so that can be completely deleted as well. Note
that several of these VOs are legacy crap anyway (e.g. vaapi) and maybe
should just be deleted but whatever. vo_direct3d was also completely
untested (not that anyone should ever use it).
2023-10-01 14:48:38 +00:00
Kacper Michajłow
172d9be300 win32: set WS_SYSMENU style always
Fixes missing icon when initial window is created without caption.

Fixes: #12472
2023-10-01 14:05:10 +00:00
Kacper Michajłow
0ba6ca6f76 vo: don't invoke wait, when not needed
This causes only problems, because we convert mp_time to realtime, which
is not atomic, so we introduce error. And even though on sane platforms
it should work fine, after all the sleep time is in the past.
winpthreads like to sleep for like over 10ms when the time is less than
current time, but not more than 1s.
2023-09-29 20:48:58 +00:00
Kacper Michajłow
7035debddf vo: increase display refresh rate estimation limit from 99 Hz to 400 Hz
High refresh rate displays exists...
2023-09-29 20:48:58 +00:00
Kacper Michajłow
df764bc0c3 vo: change vsync base to nanoseconds
There is no reason to use microseconds precision. We have precise timers
all all relevant platforms.
2023-09-29 20:48:58 +00:00
Kacper Michajłow
40e0fea6eb timer: rename mp_add_timeout to reflect what it actually does 2023-09-29 20:48:58 +00:00
Kacper Michajłow
da4c4d2ebd timer: rename mp_time_us_to_timespec to reflect what it actually does 2023-09-29 20:48:58 +00:00
Dudemanguy
27ef1725e7 vo_dmabuf_wayland: assume counter-clockwise rotations
In practice, most compositors implement the rotation clockwise which
matches mpv's option, but amusingly this is actually incorrect.
According to the spec*, wayland buffer rotations are counter-clockwise.
So with this assumption in mind, in order for the rotation to match
mpv's usual semantics, the 90 degree and 270 degree positions need to be
flipped. Of course, this will make the VO rotate the wrong way on most
compositors, but this is what the spec says (sway master is known to
currently be correct). Fixes #12508 (sort of but will break the rotation
direction on other compositors. Oh well).

*: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
2023-09-29 17:00:05 +02:00
hbiyik
c19115c8da hwdec_drmprime: add nv16 support
NV16 is the half subsampled version of NV12 format. Decoders which
support High 4:2:2 of h264 provide the frame in NV16 format to establish
richer colorspace. Similar profiles are also available in HEVC and other
popular codecs. This commit allows NV16 frames to be displayed over
drmprime layers.

Signed-off-by: hbiyik <boogiepop@gmx.com>
2023-09-29 12:10:59 +02:00