Commit Graph

6410 Commits

Author SHA1 Message Date
Kacper Michajłow f8cbe7b6a6 vo_gpu_next: allow to disable error diffusion when changing --dither
error_diffusion was not disabled even if --dither were changed.
2025-02-14 21:13:18 +01:00
sfan5 bfa3e90867 video/out/android: don't assert-fail if WinID is not set
This matches the behavior of every other GPU context and is the only
behavior that makes sense.
2025-02-11 19:19:36 +01:00
Kacper Michajłow f14660b446 Revert "vo_gpu_next: set --target-colorspace-hint to yes by default"
HDR or any color-space pass-through should be opt-in, as we cannot
control the user's compositor or display. Allowing HDR signals to be
pushed by default may lead to surprising results for some users.
Additionally, for an optimal experience, this option should be paired
with the target-peak of the display.

Make the pass-through opt-in and let the user decide if they want or
need it. By default, mpv should render a safe and consistent sRGB
output. mpv's tone mapping is generally of higher quality than any
external solution.

This reverts commit 23843b4aa5.
2025-02-08 06:15:32 +01:00
Kacper Michajłow 038d66549d demux: reclaim demux_packets to reduce memory allocator pressure
This update introduces a demux_packet_pool, allowing for the reuse of
previously allocated packets when needed.

sizeof(AVPacket) is not a part of the lavc public ABI, which prevents us
to allocate memory in larger blocks. However, we can substantially
decrease the amount of alloc/free operations during playback by reusing
both mpv's demux_packet and AVPacket.

This adjustment addresses the root cause of issue #12076, which,
although resolved upstream, did not fully tackle the persistent problem
of allocating small blocks of aligned memory. This issue largely stems
from the FFmpeg design of the AVPacket API. After this change memory
will no longer be allocated once cache limits is reached.

The demux_packet_pool is shared as a global pool of packets for a given
MPContext.

This change significantly speeds up the demuxer deinitialization,
benefiting file switching scenarios, especially when a large demuxer
cache is used.

See: #12294
See: #12563
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-02-05 05:09:33 +01:00
Sami Farin fa9c2a35dd video/out/kitty: make kitty vo ten times faster by avoiding strlen
When playing a video, 55% of CPU used in strlen, callgraph flip_page: ta_talloc_strdup_append ,
ta_talloc_asprintf_append and ta_talloc_strndup_append .

Before the fix: 2 fps when playing 1080p 24 fps video (--vo-kitty-use-shm=no),
24 fps after the fix.

video/out/kitty: move bstr cmd to priv
2025-02-05 04:53:42 +01:00
Dudemanguy 8c4ca44e24 vd_lavc: separate opts to two structs and reorganize
The options in vd_lavc are all related, but they don't all require the
same thing for runtime changes. To avoid having to manually add UPDATE_*
to every single option flag, the options can be split into two separate
structs. The vd_lavc_conf becomes a catch all for all the --vd-lavc
options that require the full UPDATE_VD flag. The rest of the options
are split off into the new hwdec_conf instead. Additionally,
--vd-lavc-software-fallback is renamed to --hwdec-software-fallback and
moved to the hwdec_conf as well. The new name better reflects what it
does and it logically fits with those more. UPDATE_* flags are added on
everything now so these should all now be changeable on runtime.
2025-01-29 15:07:42 +00:00
Dudemanguy be15be3a83 various: expand paths for all file/directory related options
There's several path-related options that do not handle common shortcuts
(like ~/). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes #15598.
2025-01-29 14:49:06 +00:00
Kacper Michajłow 9251411627 vo_kitty: unlink shared memory only on vo close
We don't want to unlink on flip_page().

As a bonus fix leaked mpi image.

Fixes: af384df219
2025-01-29 06:47:35 +01:00
Christoph Heinrich 4fd9893f28 player/command: reinit video decoder when it's options change 2025-01-28 21:16:39 +00:00
Kacper Michajłow af384df219 vo_kitty: unlink shared memory on vo close 2025-01-28 07:59:47 +01:00
nanahi 9f2ac08851 clipboard-wayland: add Wayland clipboard backend
This adds a "native" Wayland clipboard backend based on the
ext-data-control-v1 protocol.
This backend overcomes the limitation of the VO (Wayland core protocol)
backend, and does not require the presence of the VO window to receive clipboard
updates.
This backend also supports primary selection if supported by the compositor.

The backend runs in a separate thread, so clipboard reading
does not stall the player like the VO backend.
2025-01-27 18:51:31 +01:00
Attila Fidan fbf366d124 video/out/wayland_common: create per-seat objects on seat hotplug
This is to allow data device and text input to be used on seats that are
hotplugged after vo init.
2025-01-27 18:51:10 +01:00
verygoodlee 57a8105f1a win32: fix menu click failure caused by excessive menu-data updates
basically a copy of tsl0922/mpv-menu-plugin#77

if you have 200+ menu items and update `menu-data` about 400 times,
clicking menu item will not execute any command, the reason is that the
menu identifier greater than the max value of 16-bit unsigned integer.

1. make menu id always less than 0xF000 as mpv-player/mpv@861908c7 said
2. old menu items are never reused, should delete by DeleteMenu()
   instead of RemoveMenu(), destroys the handle and frees the memory
2025-01-26 22:19:26 +01:00
nanahi c776f5f2c9 various: use mp_poll instead of poll
mp_poll supports higher time resolution than poll, so use it
when the timeout is not 0 or infinite. Also use time conversion
macros.
2025-01-26 22:15:30 +01:00
nanahi 88ee25da12 video/out/wayland_common: remove useless flag
POLLHUP is only returned in revents and ignored in events,
so there is no need for it to be here.
2025-01-26 22:15:30 +01:00
Attila Fidan 98627b027d video/out/wayland_common: fix crash with multi-seat drag and drop
If you have two seats connected, both with the pointer capability, and
use two hands to start a drag and drop operation with each pointer, then
move one pointer to the mpv window, then the other, mpv fails the
!wl->dnd_offer->offer assert in device.enter, because it expects that
the compositor wouldn't just call device.enter again before device.leave
or offer.finish.

The data device is per-seat, so this commit makes mpv track the data
device's offers per-seat rather than in vo_wayland_state, which makes
more sense and is easier to reason about when multi-seat is involved.
2025-01-26 16:32:30 +00:00
Attila Fidan 51dc6286b6 video/out/wayland_common: support IME usage via text-input-v3
This is useful for text input in, for example, console.lua. Each
character in the commit string gets turned into an mpv key press.
Pre-edit strings are not handled, since there's currently no good way to
handle that or make it useful to text input scripts. Like win32, which I
tested in wine, another limitation is that the composition window is
always positioned at the top left of the window, since we cannot get
useful positioning hints from mpv scripts. It allows the composition
window to be within the window and avoids obstructing the console
prompt.

This can be enabled/disabled with --input-ime=<yes|no> (default: yes).
2025-01-25 03:14:44 +00:00
Attila Fidan c9412b4721 video/out/wayland_common: ignore clipboard offers w/o wanted MIME type
Some Wayland clients not offering text/plain will send their non-text
data regardless of the MIME type requested in wl_data_offer.receive. We
should just not call receive if they haven't offered a MIME type we
want.
2025-01-18 12:51:05 +01:00
nanahi c42b19b806 video/out/gpu/video: allow taking transparent screenshots
Use RGBA format to take transparent screenshots when the video has
an alpha channel.
2025-01-05 21:32:55 +01:00
Filip Hejsek 0a0ceb7439 vulkan/context_display: implement display fps and resolution info
Implement VOCTRL_GET_DISPLAY_FPS and VOCTRL_GET_DISPLAY_RES by returning
values obtained from Vulkan.

Currently, display fps and resolution info is not available in the
displayvk context. Display fps is needed for display sync to work
properly. The information is also used as the value of a few properties.

This slightly improves parity with the drm context.
2025-01-04 22:40:03 +00:00
Kacper Michajłow 59d1dc43b9 various: fix typos 2025-01-04 15:59:49 +02:00
Kacper Michajłow efcee92d0e various: remove double new line at the end of file 2025-01-04 15:59:49 +02:00
Neko Asakura 50042f5ee0 mac: add support for --force-window-position 2024-12-31 14:49:39 +01:00
Dudemanguy 3218e74aaa x11: allow display sync modes to report no visibility
When this was originally implemented, I lazily skipped the optimization
when using display sync because mpv would rip through all the frames
without waiting since there was no blocking. With the previous commits,
we now fall back on the audio sync logic when the window is not visible,
so the extra condition can be removed.
2024-12-28 16:51:28 +00:00
Dudemanguy a2fe5ee900 player/video: fallback to audio sync logic if VO is not visible
The previous commit put all the pieces in place so now this can be
implemented. Scheduling frames is already written with the assumption
that display sync maybe turn on/off at any time. So all that needs to be
done is check if the VO reports that it is not visible. If so, simply
flip mpctx->display_sync_active to false for that frame and skip the
display sync frame handling. It will become true again when the mpv
window comes back into view.
2024-12-28 16:51:28 +00:00
Dudemanguy 91c1b65de0 vo: change draw_frame API to a boolean
x11 and wayland VOs + backends all have logic that skips drawing frames
when the mpv isn't visible for efficiency reasons. This is implemented
in each individual VO, but it is useful for the core to be aware of this
as well. Currently, the display-sync modes on x11 do not try to be
efficient and always render anyways because there is no blocking on the
graphics API level if you skip rendering a frame (wayland works here by
accident). This means mpv would otherwise blaze through frames which is
not what anyone wants. We can instead improve this by implementing the
blocking mechanism in the core and using that when appropriate. This
commit does not implement that yet, but simply switches the draw_frame
to a boolean. Receiving false means that the VO is not drawing frames
and it should be treated as if the surface was hidden.
2024-12-28 16:51:28 +00:00
der richter 4dbf81c94c mac/title: use enum for material values instead of generic integers 2024-12-28 14:30:41 +01:00
der richter 4063cdf20b mac/title: use enum for appearance values instead of generic integers 2024-12-28 14:30:41 +01:00
der richter cd9fa6daf0 mac/title: remove old libmpv color setter fallback 2024-12-28 01:46:41 +01:00
der richter 51af3caa77 mac/title: remove old libmpv material setter fallback 2024-12-28 01:46:41 +01:00
der richter 11a9f355c7 mac/title: remove old libmpv appearance setter fallback 2024-12-28 01:46:41 +01:00
der richter bba198a713 mac: use isBundle function instead of manually checking bundle usage 2024-12-26 15:00:57 +01:00
Kacper Michajłow d9eb9ed844 video/sws_utils: remove unused mp_image_swscale
This has been used before 2c43d2b75a. Now
that we have also zimg support, using swscale directly may not be wanted
depending on the user options.
2024-12-25 18:01:56 +01:00
der richter d82701962f libmpv: deprecate MPV_RENDER_PARAM_AMBIENT_LIGHT render parameter
the equivalent options have been deprecated since mpv 0.35 in ac39661
and 2207236.

also bumping the MPV_CLIENT_API_VERSION to 2.5, since 2.4 was forgotten
in 6f619d5.
2024-12-21 16:15:44 +01:00
der richter e785296a1c cocoa-cb: use new ambient-light property and remove old libmpv usage 2024-12-21 16:15:44 +01:00
der richter e0f82b1a77 gamma-auto.lua: add this script as replacement for --gamma-auto
also mention this replacement for --gamma-auto.
2024-12-21 16:15:44 +01:00
der richter 2b06728df9 command: add ambient-light property
make it observable to make it usable as a replacement for --gamma-auto.
2024-12-21 16:15:44 +01:00
der richter 811062279e vo: change VOCTRL_GET_AMBIENT_LUX from int to double 2024-12-21 16:15:44 +01:00
Dudemanguy 96bebf0935 x11: simplify --geometry and --auto-window-resize logic
There were a few pitfalls with the way this was previously implemented
because --geometry implicitly depended on --auto-window-resize being
enabled to operate in a few cases. Instead, let's change the logic a bit
so that instead we choose whether or not to reuse the old rc (i.e. don't
resize) and use the wh_valid and xy_valid fields within the m_geometry
struct instead of using x11->geometry_change. This fixes several edge
cases involving setting the position with --geometry when using
--auto-window-resize=no.
2024-12-20 18:03:30 +00:00
nanahi b174d98042 video/out/wayland_common: make all XF86 special keys mappable
Forgotten in 417869f845.
2024-12-20 14:54:35 +00:00
llyyr 7fffaf8557 vo: update base_vsync even for initial samples
This is still used for caclulating a/v sync and delay remaining even
for initial samples, so we should always update it to the actual vsync
for those initial samples so we have something to work with at least.

And if we receive bogus values, also reset it to 0 along with
prev_vsync.

Not having base_vsync set to _some_ value completely breaks
vsync_skip_detection, and mpv stays stuck in a permanent mistimed state
where every frame is marked as delayed and never recovers from it.
2024-12-11 16:42:13 +01:00
llyyr bd915439d0 vo: use display clock to determine frame_end in display synced case 2024-12-11 16:42:13 +01:00
llyyr 84728fb5e9 vo: extract display synced frame end calculation
into get_display_synced_frame_end. Used in next commit.
2024-12-11 16:42:13 +01:00
Kacper Michajłow 3df8b0b297 video/out/gpu/video: don't pass big structs by value when not needed 2024-12-10 14:14:09 +01:00
Kacper Michajłow db70ae6fa2 hwdec_vaapi: don't jump over variable init in try_format_upload 2024-12-10 10:17:34 +01:00
Kacper Michajłow fe546c1841 w32_common: guard recursive call to mp_dispatch_queue_process
This is already done in WndProc, but the flag was not set if we exited
event loop and were processing mpv dispatch messages in fallback loop.

This fixes the case when Window is destroyed externally or otherwise
event loop fails for whatever reason. Calling vo_w32_uninit does call
DestroyWindow() through dispatch, which in turn calls WndProc, so we
need to guard recursive call.
2024-12-09 19:20:52 +01:00
Kacper Michajłow 8eea5902ba options/m_option: restore m_geometry_apply centering ability
This fixes geometry uses where it is expected to be centered. For
example this fixes video-crop option.

Fixes: e01eab4385
Fixes: #15398
2024-12-08 18:14:04 +01:00
Guido Cella f7e6e30a49 aspect: add --video-recenter
This ignores --video-align-{x,y} when the video is smaller than the
window in the respective direction.

After zooming in, panning and zooming out, this is useful to recenter
the video in the window.

Unlike doing this by observing osd-dimensions in a script, this is done
before rerendering, so you don't see the image being rendered uncentered
for an instant after zooming out, before being rerendered centered.

Also update --video-align docs while at it.

This doesn't work well with --video-pan-{x,y} because you can move the
output rectangle far away from the image, and when zooming out pan is
abruptly reset to the center. It doesn't feel like natural like zooming
out after changing --video-align-{x,y}. So this commit doesn't set pan
to 0. Also this leaves a way to move scaled images within the window
even with --video-recenter.
2024-12-02 22:31:14 +01:00
llyyr 1a03d6ab84 vulkan/context: propagate --gpu-sw on vulkan contexts 2024-12-01 12:22:15 +01:00
der richter dec0d02f9f vo_gpu: undeprecate --gamma-factor
deprecated since 0.35 in ac39661 and 2207236.
2024-11-30 02:32:39 +01:00