55632 Commits

Author SHA1 Message Date
Link Mauve a2cd83c56d vo_drm: add support for RGB565
This image format is quite legacy, but uses half as much bandwidth as
the closest XRGB8888, at 16bpp instead of 32bpp, so it is useful to
support on the slowest/oldest display controllers.
2026-10-16 00:28:47 +02:00
rlauuzo b6cab8fa0c vo_gpu_next: only re-upload OSD textures when they change
update_overlays() uploaded every sub_bitmaps item to its texture on
every call, and draw_frame() calls it unconditionally, so an OSD that
was not changing got re-uploaded at the display refresh rate rather
than at the rate it actually changed.

vo_gpu already avoids this: gen_osd_cb() compares sub_bitmaps.change_id
against a cached copy and skips upload_osd() when they match.
osd_render() computes that change_id for both VOs, so vo_gpu_next had
the information and did not read it. Cache the id next to the texture
and skip pl_tex_upload() when it matches.

Also restrict pl_tex_recreate() to the cases where the size or format
has to change. The cache requires this, because pl_tex_recreate()
invalidates the texture even when it keeps it, and the cached id would
then describe contents that are no longer defined.
2026-10-16 00:26:53 +02:00
Kacper Michajłow 5757d69708 d3d11/context: resize buffers when DXGI leaves exclusive fullscreen
DXGI leaves exclusive fullscreen by itself during Present() when the window
loses the focus or a native menu covers it, and the next Present() fails
until the buffers are resized. Check the fullscreen state when Present()
doesn't return S_OK, resize the buffers if DXGI changed it, and enter
exclusive fullscreen again on focus events, which w32_common now also
sends when a menu loop ends.
2026-10-15 20:37:15 +02:00
Kacper Michajłow 2ddd0f027c select.lua: open context_menu.lua in d3d11 exclusive fullscreen
Load context_menu.lua when --d3d11-exclusive-fs is enabled and open it
instead of the native context menu. Native context menu cannot be
displayed over the exlusive window.

Fixes: #18181
2026-10-15 20:37:15 +02:00
Fabian Mildner 867990d949 autoload.lua: use efficient file_info call 2026-10-15 19:17:52 +02:00
Fabian Mildner 157cef43d3 autoload.lua: exit early when path is a directory
Before this change, autoload would split a directory path into two,
using the parent directory as the autoload directory. This lead to the
addition of unexpected files to the playlist.

Now, the effective behavior when a directory is given falls back to the
configured mpv directory-mode.
2026-10-15 19:17:52 +02:00
Kacper Michajłow e9aac03ab8 vf_d3d11vpp: allocate the output after setting up the video processor
recreate_video_proc() sets the output format and colorspace for
nvidia-true-hdr. Allocate the output image and copy out_params after it,
so the first frame has correct params.
2026-10-15 16:32:40 +02:00
Kacper Michajłow 4255130de4 libmpv: add D3D11 render API backend
Adds a new render API backend that lets libmpv embedders render directly
into an application-owned ID3D11Texture2D.

The backend is selected with MPV_RENDER_API_TYPE_D3D11. The embedder
supplies the ID3D11Device via MPV_RENDER_PARAM_D3D11_INIT_PARAMS at
context creation, and the target texture via MPV_RENDER_PARAM_D3D11_FBO
on each mpv_render_context_render() call. Swapchain creation and
presentation stay entirely on the caller side.

Co-authored-by: dragonflylee <dragonflylee@outlook.com>
2026-10-15 15:36:37 +02:00
Kacper Michajłow b1b03bd347 d3d11: move the live object report to the VO context
The VO context owns its device. ra_d3d11 also runs on devices owned by
the libmpv API user, where the report lists their objects too.
2026-10-15 15:36:37 +02:00
Kacper Michajłow 0b3d2ab525 ra_d3d11: set the rasterizer state for every draw
The immediate context is shared with the API user of the libmpv render
API, who may change its state between frames.
2026-10-15 15:36:37 +02:00
Kacper Michajłow 5deaba46b2 vo_gpu: fix dither quantization for > 31 bit depths
Compute it as UINT32_MAX >> (32 - depth) instead of (1 << depth) - 1,
which overflowed int.
2026-10-15 15:36:37 +02:00
Kacper Michajłow 492bae0768 meson: prefer LuaJIT over PUC Lua
LuaJIT is the only relevant target in practice, PUC lua 5.1/5.2 is not
maintained. We should remove support for it at some point, but that's
for another day.
2026-10-14 20:25:17 +02:00
Vasily Khoruzhick 7c4f662c08 vo_gpu: opengl: use R8/RG8 formats on GLES 2.0 and GL 2.1
GLES 2.0 contexts with GL_EXT_texture_rg never used single- and
two-component R/RG textures, because the format table only listed
them for GL 3.0/ES 3.0, or for GL 2.1 with texture_rg + texture_float
+ FBOs all present (F_GL2F). Video planes were uploaded as LUMINANCE/
LUMINANCE_ALPHA instead, which needs a swizzle hack and mismatches
the .rg layout produced by dmabuf imports of DRM_FORMAT_R8/GR88
(NV12 via drm-prime), and forced dumb mode due to the have_texrg
check.

Add format classes for ES2 with GL_EXT_texture_rg (unsized internal
formats, as ES2 requires) and for GL 2.1 with ARB/EXT_texture_rg
alone, without the float/FBO requirements of F_GL2F. The entries are
placed before the legacy LUMINANCE ones so format lookups prefer
them; F_GL2RG is suppressed when F_GL2F is active to avoid duplicate
entries.
2026-10-14 18:29:41 +02:00
Vasily Khoruzhick 37eb6a0de0 vo_gpu: opengl: support GL_EXT_framebuffer_object
Some GL 2.1 drivers (e.g. Mesa lima) expose GL_EXT_framebuffer_object
but not GL_ARB_framebuffer_object, leaving MPGL_CAP_FB unset even
though FBOs are usable. Load the EXT entrypoints as an alternative
provider of MPGL_CAP_FB; mpv's FBO usage (Gen'd names, GL_FRAMEBUFFER
target, single color attachment, runtime completeness checks) is
within the subset EXT and ARB share. The section is placed before the
ARB/core one so the latter overwrites the function pointers whenever
it is available.

Querying attachment parameters of the default framebuffer is an
ARB/GL 3.0 addition, so skip that query in ra_gl_ctx_color_depth()
when only the EXT extension is present.
2026-10-14 18:29:41 +02:00
Kacper Michajłow e6887ed972 test/libmpv_common: add temp_path() and wait_event() 2026-10-14 18:09:16 +02:00
Kacper Michajłow 33b2093b32 test: add aes-ctr stream test 2026-10-14 18:09:16 +02:00
Kacper Michajłow c92f8b4b3a stream_aes_ctr: add aes-ctr:// protocol
Decrypts a stream that was encrypted as a whole with AES in CTR mode,
with a key of 128, 192 or 256 bits. The counter block is the IV plus
the index of the block as a 128 bit big endian number, so the stream
seeks wherever the inner stream does.
2026-10-14 18:09:16 +02:00
Kacper Michajłow ad9e2b3307 demux_playlist: resolve relative entries against the url after redirects 2026-10-14 18:05:24 +02:00
Kacper Michajłow 3c1e06e0bf demux_lavf: expose the url after redirects as the location option
Give the AVIOContext wrapping the stream an AVClass with a child that
carries the location option, as libavformat's own protocols do, so the
hls and dash demuxers resolve relative references against the url the
manifest was received from.

Fixes: #18608
2026-10-14 18:05:24 +02:00
Kacper Michajłow a6ba614e68 stream: add effective_url, the url after redirects
stream_lavf takes it from the location option of the protocol and
stream_curl from CURLINFO_EFFECTIVE_URL.
2026-10-14 18:05:24 +02:00
Kacper Michajłow b3c2fde411 context_angle: enable the D3D11 debug layer with --gpu-debug
Print the debug layer messages after every swap and report live objects
after the device is released.
2026-10-14 18:04:44 +02:00
Kacper Michajłow d802fab36a d3d11: don't map fence messages by ID
Windows SDK 10.0.22621 inserted a message ID at the end of the D3D11.1
range, which moved CREATE_FENCE and DESTROY_FENCE up by one. The debug
layer uses the numbering of its Windows version, so no fixed value is
right everywhere. Avoid hardcoding them.

Fence creation and destruction are now logged at debug level, a few
messages at init.
2026-10-14 18:04:44 +02:00
Kacper Michajłow 44be29945b d3d11: move debug layer message printing to d3d11_helpers 2026-10-14 18:04:44 +02:00
llyyr 270367e8af ta_talloc: fix assert in MP_TARRAY_REMOVE_AT
The index must be strictly less than the number of elements.
2026-10-14 04:33:53 +02:00
Kacper Michajłow b413ad0258 context_angle: fix D3D11 device leak
Release the immediate context, which holds a reference to the device.
2026-10-14 02:30:16 +02:00
wallpap 40c998a1ca hwdec_d3d11egl: release the FFmpeg hardware device reference
init() wraps the ANGLE D3D11 device in an AVBufferRef. Removing the
hwdec entry does not release that reference, so the device survives
render-context teardown.

Unref it before releasing the driver's own device reference, matching
the native D3D11 interop and the fix in 3447463008.
2026-10-14 02:30:16 +02:00
Kacper Michajłow 19aaa33a86 sd_ass: keep the seen and animated state on the original packet
Free the filtered packet right after libass took it and run the
bookkeeping on the original packet, which carries the seen and animated
state.
2026-10-14 02:22:05 +02:00
Kacper Michajłow e9961b6014 test: add SDH filter tests for events with a null byte
ffmpeg cannot write a null byte from a text subtitle, so the muxed
samples get one patched in.
2026-10-14 02:22:05 +02:00
Kacper Michajłow b995943c75 filter_sdh: detect an unchanged event by its length 2026-10-14 02:22:05 +02:00
Kacper Michajłow fbc992bb74 filter_sdh: fix heap over-read on events with a null byte
Filter a null-terminated copy of the Text field alone and build the new
packet from the unchanged event fields and the filtered text.

Fixes: #18586
2026-10-14 02:22:05 +02:00
Kacper Michajłow cecffff7a9 filter_sdh: use size_t for lengths and buffer positions 2026-10-14 02:22:05 +02:00
Kacper Michajłow 49bcdd6c77 filter_sdh: get the event format offset once at init 2026-10-14 02:22:05 +02:00
wallpap ec38361c56 osdep/language-win: advance through preferred UI languages 2026-10-14 01:16:37 +02:00
Kacper Michajłow c3ac7f3951 ci/msys2: remove deprecated mingw64 build 2026-10-13 02:22:10 +02:00
Kacper Michajłow 745c0bdb11 demux_lavf: replace deprecated AVStreamGroup.streams with entries
libavformat deprecated AVStreamGroup.streams and nb_streams in
8b577f90f3676cd5540e135e974dbdb1462ec4bf.
2026-10-13 02:22:10 +02:00
shbernal 9d144e57b6 bash-completion: complete aliases and list actions like their target
Options like --sub-file are aliases for list actions like
--sub-files-append, which --list-options shows without a type, so
nothing was completed after them. Follow aliases to their target, and
complete typeless list actions like the list option they act on.

This makes --sub-file=, --audio-file=, --glsl-shader=, --script= etc.
complete files, --sub-files-append= etc. complete files when typed
directly, and other aliases like --fs= and --audio= complete the values
of their target.

Fixes #7955.
2026-10-12 15:54:56 -07:00
Kacper Michajłow 88eb9f2e73 vo_tct: take the cell aspect from the terminal
The cells were taken as twice as tall as wide. Fit the video to the cell
size the terminal reports instead, and keep 2:1 for a terminal that
reports none.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 197fa00448 vo_tct: place the image from row 1 and park the cursor below it
The indexing suppose to be from 1,1, not 0,0. So we were off by one and
clamped by the terminal to the edge, but that left empty row and column,
and also cleared status line.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 16fb1523fb DOCS/man/vo: drop the removed --vo-sixel-exit-clear alias
The option was removed in 6e3d90d72a.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 4ffe099190 vo_sixel: park the cursor on the bottom row after a frame
The canvas leaves the bottom row free, ensure that we write status line
there. Some terminal emulators does not move cursor after the sixel
image.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 21bae81ac3 ci: enable sixel 2026-10-11 16:45:32 +02:00
Kacper Michajłow 5ce308b573 sws_utils,zimg: keep the scalers across frames with dynamic HDR metadata
mp_sws and mp_zimg compared the whole image parameters to decide whether
the scaler could be kept, so dynamic HDR metadata were invalidating the
scaler. This metadata is not used by SWS or ZIMG, except for peak
luminance by the later.

Fixes playback performance of HDR video with software scaling.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 6bd80b06f9 terminal-win: ask the terminal for its cell size under ConPTY
ConPTY has no font, GetCurrentConsoleFont() reports 0x16, so the
terminal VOs fell back to a 320 pixel wide canvas and the mouse position
had no horizontal component. Send XTWINOPS 16 and parse it's reply, from
its key events, which carry no virtual key unlike a pressed key.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 30a31b77d1 terminal: redraw the terminal VOs when the terminal is resized
The terminal VOs only noticed a resize when they drew the next frame, so
a paused image kept its old size. The terminal input thread already
receives resizes, as a window buffer size event on Windows, which the
console reports with ENABLE_WINDOW_INPUT set, and as SIGWINCH on POSIX,
which now goes through the signal pipe like SIGTSTP. It passes them to a
callback the terminal swapchain registers, which wakes the VO thread. VO
then can react to size changes and redraw the image.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 8e566099cb vo_kitty: present frames through the terminal swapchain
Build the command of each frame in a buffer acquired from the terminal
swapchain and present it, so it is written while the next frame is
rendered.
2026-10-11 16:45:32 +02:00
Kacper Michajłow ad69233d93 vo_tct: present frames through the terminal swapchain
Build the whole frame, including the synchronized update sequences, in
a buffer acquired from the terminal swapchain and present it, so it is
written while the next frame is rendered.
2026-10-11 16:45:32 +02:00
Kacper Michajłow 2c98919b66 vo_sixel: present frames through the terminal swapchain
The console write of a frame blocks until the terminal has consumed it,
which at large sizes takes as long as encoding the next frame. Present
each frame through the terminal swapchain instead, so the write overlaps
with scaling and encoding the next one.
2026-10-11 16:45:32 +02:00
Kacper Michajłow d8b06f94a1 video/out: add a swapchain for terminal VOs
The terminal VOs write each frame to the terminal from the VO thread,
and the write blocks until the terminal has taken the data, so nothing
is rendered meanwhile. The terminal swapchain writes from a thread of
its own, out of a ring of buffers. A VO acquires the next one, builds
the frame in it and presents it, and the swapchain queues it and writes
it under the terminal output lock, in order, with up to
--swapchain-depth frames in flight before acquiring waits.

Output that belongs with the next frame rather than in a write of its
own, such as clearing the screen after a reconfig, goes into a buffer
that the next acquire prepends.
2026-10-11 16:45:32 +02:00
Kacper Michajłow ee2e920963 vo_sixel: encode the canvas as slices on the thread pool
libsixel encodes on one thread, and a 3810x1020 canvas took about 150 ms
per frame. Split the canvas into slices that start on a cell row and
hold whole sixel bands, encode them on the thread pool with an output
and a dither each, and place every slice with its own cursor move.

The slices take their rows from the scaled image, and a packed copy of
the frame is only kept for the dynamic palette, whose histogram wants
the whole frame in one piece. Its median cut runs once, on the frame:
libsixel sorts the colours with a static variable in its comparator, so
the slices cannot run it at the same time.

A slice's dither is initialized from an image with one pixel per colour
in distinct 5-bit histogram buckets, which libsixel keeps as it is and
which gives the dither the colour cache of its fast lookup, and then
gets the frame's palette set.

A slice dithered on its own would not have a context, so each slice is
dithered together with twelve rows above it and one band below it, taken
from a copy since the diffusion writes into the image, with
sixel_dither_apply_palette(), and only its own rows of the indices are
encoded, through a second dither that takes the indices as they are. A
slice is at least three times as tall as the rows around it.
2026-10-11 16:45:32 +02:00
Kacper Michajłow ce2fe8d678 vo_sixel: size the canvas from the terminal's cells
--vo-sixel-rows and --vo-sixel-cols replaced the terminal's cell counts
while the canvas kept the terminal's pixel size, and --vo-sixel-top and
--vo-sixel-left kept it too, so the image ran past the bottom and
scrolled the terminal. Take the cell size from what the terminal
reports, and size the canvas in those cells from where the image
starts, or as the options say.
2026-10-11 16:45:32 +02:00