Commit Graph

4911 Commits

Author SHA1 Message Date
Niklas Haas 6265724f33 vo_gpu: placebo: keep track of texture sample mode
This fixes an issue where dithering was effectively broken on libplacebo
versions >= 103 because the dither texture was being sampled with
edge-clamped rather than repeating semantics.
2021-03-21 17:18:20 +01:00
Dudemanguy 99968e1ce5 wayland: no mouse dragging in fullscreen/maximized
The wayland code takes mouse dragging into account in order to trigger a
client-side request for a window move or window resize. According to the
xdg-shell spec*, "[t]he server may ignore move[/resize] requests
depending on the state of the surface (e.g. fullscreen or maximized)".
Since it is not actually a hard requirement, that means the compositor
could actually respond to a clientside move/resize request even if the
mpv window was fullscreen. For example, it was pointed out that in sway,
if mpv is a floating window, you could drag it around off screen even
though the window is fullscreen.

This kind of behavior does not really have any practical use. A user can
should pan a video if he/she wishes to move its orientation while
fullscreen (or maximized for that manner). Naturally, a maximized or
fullscreened window should never be manually resized (every compositor
likely ignores this anyway). The fix is to simply just not trigger the
smecial mouse dragging case if the wayland surface is fullscreened or
maximized.

*:https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/master/stable/xdg-shell/xdg-shell.xml
2021-03-02 16:40:13 -06:00
sfan5 bbbf3571ed vd_lavc: wrap use of deprecated AVCodecContext.thread_safe_callbacks in #if
For compatibility once FFmpeg removes it entirely.
2021-03-02 15:00:37 +01:00
der richter d1be8bb606 mac: fix traditional fullscreen on macOS 11
the fullscreen style mask is not supported on macOS 11 anymore outside
of the native fullscreen animation. this can lead to a none working fs
or in the worst case a crash.

to fix this we will simulate a fullscreen window with a borderless
window with the size of the whole screen, though only on macOS 11.

Fixes #8490
2021-02-27 13:12:46 +01:00
der richter c2868bdd39 mac: remove an unused variable 2021-02-27 13:12:46 +01:00
Niklas Haas 09d7c75bfe vo_gpu: libplacebo: require v2.72.0
It's about a year old, and packaged pretty much everywhere that bothers
to package libplacebo at all. Older versions are only a thing on LTS,
which will probably also use older mpv so it works out.

Starting with v2.72.0, libplacebo validates all of its parameters
internally and turns them into function failures. Doing it twice is
awfully redundant, so we can drop the parameter validation.

Also allows us to drop some preprocessor macros.
2021-02-23 12:44:04 +02:00
Evgeny Zinoviev f913570aad mac: support --on-all-workspaces option 2021-02-21 13:38:53 +01:00
Niklas Haas c766e47b70 vo_gpu: don't abort() if plane tex creation fails
In this case, we just treat all uploads as automatically failing. That
error path already exists and is already handled correctly.

Fixes #8566
2021-02-16 14:22:29 +01:00
Niklas Haas 968faef867 vo_gpu: vaapi: export plane pitch properly 2021-02-12 23:31:46 +01:00
Mia Herkt 12ffce0f22
vo_gpu: lower default deband threshold
The previous default was found to be too aggressive for most video.
Change to a lower value to prevent destroying too much detail.
2021-02-05 15:15:55 +01:00
Emmanuel Gil Peyrot f8a9654873 vo_wlshm: support big endian systems
The video was otherwise blue, and that’s not how it should be. :)
2021-02-04 21:13:09 +02:00
der richter dae9ea3fa7 mac: fix dangling pointers
initialising UnsafeMutableRawPointer the way we did won't free those
pointers and we get dangling pointers. explicitly define a scope those
pointers are alive and auto freed.
2021-01-13 16:23:47 +01:00
Niklas Haas 3e175dff4a vo_gpu: don't segfault if 3DLUT texture fails uploading
This failure path was never properly checked.
2021-01-01 17:14:57 +01:00
Jan Ekström f02ab2aabb csputils: add mappings for DCI-P3 (ST.431-2) and P3-D65 (ST.432-1) 2020-12-30 20:03:54 +02:00
Emmanuel Gil Peyrot 5f2b60a645 vd_lavc: add VP8 to the default allowed hwdec codec list
It is supported at least on Intel, from gen8 to gen11, and still gives a
pretty welcome reduction of CPU usage on my gen9.
2020-12-30 17:30:01 +02:00
Niklas Haas be167c227b vo_gpu: cast bvecN to vecN for mix() on older GLSL
Fixes https://github.com/mpv-player/mpv/issues/8415, among others
2020-12-28 19:39:41 +01:00
Dudemanguy 1ba5dc84ca wayland: support multiple modifiers
Oversight when the modifier checking was split out to a separate
function. Instead of immediately returning on a match, be sure to loop
through all modifiers and catch every single one that is pressed before
we return them.
2020-12-20 10:57:48 -06:00
der richter dde0189279 mac: fix type mismatch Int instead of Int32 2020-12-19 21:47:19 +01:00
der richter af26402948 mac: use visible frame rectangle for window geometry calculation
currently we use the whole screen rectangle to calculate the window
geometry. this doesn't take the menu bar or the Dock into account.

by default use the visible screen rectangle instead. this is also a
change in behaviour, since the window can't be placed outside of this
rectangle anymore. also add an option to change to the old behaviour,
because it can still be useful in certain cases, like placing the window
directly underneath the menu bar when used a desktop background.

Fixes #8272
2020-12-19 21:37:55 +02:00
der richter 93d071dbd8 mac: fix a window positioning bug when exiting fullscreen
when exiting fullscreen we set the window frame to a aspect fit frame of
the fullscreen frame to prevent aspect ration problems when animating.
though that intermediate frame was set too early and before the system
knew we already exited the fullscreen. because of that the frame we set
could not be properly set and its origin was defaulted to the bottom
left corner for exactly one display refresh and only after that the
wanted frame was set. this led to a (dark) grey area on the right or
top depending on the aspect ratio difference of the screen and video.

to prevent this set the intermediate frame in the animation group to
make it sync with the system's fullscreen behaviour.

Fixes #8371
2020-12-19 15:44:59 +01:00
Dudemanguy 4029a695b5 vo_wlshm: support presentation time
We get presentation feedback for free thanks to the last commit.
Implementing it in wlshm is pretty straightfoward from there.
2020-12-14 22:44:43 +00:00
Dudemanguy b59eaf57fe wayland: unify frame/presentation callback code
Originally when presentation time was implemented, the frame callback
and presentation feedback functions were called in each rendering api's
separate backend (egl and vulkan). This meant that their respective
structs were basically copy and pasted across both files. Plus later
vo_wlshm started using frame callbacks too. Things got refactored a few
times and it turns out there's actually no need to have these things
separate anymore. The frame callback can just be initialized in
vo_wayland_init and then everything else will follow from there. Just
move all of this code to wayland_common and get rid of the duplication.

Sidenote: This means that vo_wlshm can actually receive presentation
feedback now. It's really simple to do so might as well. See the next
commit.
2020-12-14 22:44:43 +00:00
Dudemanguy 8e793bde78 x11: update geometry/autofit opts on runtime
If the window is maximized, we can't change the size immediately. In
that case, we set a bool and wait for the state to change before
triggering the resize.
2020-12-14 22:44:05 +00:00
Dudemanguy 04018c3061 wayland: update geometry/autofit opts on runtime
Additionally, do some cleanups in the resize/autofitting code to make
sure we don't do any wasteful VO_EVENT_RESIZE calls. Note that if
set_geometry is called, we must always perform a resize.
2020-12-14 22:44:05 +00:00
Dudemanguy bff5416dae wayland: remove unused function declaration
It looks this line was added over 3 years ago, but said function never
actually existed or was used. Funny stuff.
2020-12-13 18:30:19 -06:00
Dudemanguy 7db17e627c wayland: handle multiple outputs more correctly
There's a bit of a catch-22 in the wayland backend. mpv needs to know
several things about the wl_output the surface is on (geometry, scale,
etc.) for lots of its options. You still have to render something
somewhere before you can know what wl_output the surface is actually on.
So this means that when initializing the player, it is entirely possible
to calculate initial parameters using the wrong wl_output. The surface
listener is what will eventually correct this and pick the correct
output. However not everything was technically working correctly in a
multi-output setup.

The first rule here is to rework find_output so that it returns a
vo_wayland_output instead of internally setting wl->current_output. The
reason is simply because the output found here is not guaranteed to be
the output the surface is actually on. Note that for initialization of
the player, we must set the output returned from this function as the
wl->current_output even if it is not technically correct. The surface
listener will fix it later.

vo_wayland_reconfig has to confusingly serve two roles. It must ensure
some wayland-related things are configured as well as setup things for
mpv's vo. The various functions are shuffled around and some things are
removed here which has subtle implications. For instance, there's no
reason to always set the buffer scale. It only needs to be done once
(when the wl->current_output is being created). A roundtrip needs to be
done once after a wl_surface_commit to ensure there are no configuration
errors.

surface_handle_enter is now handles two different things: scaling as
well as mpv's autofit/geometry options. When a surface enters a new
output, the new scaling value is applied to all of the geometry-related
structs (previously, this wasn't done). This ensures, in a multi-monitor
case with mixed scale values, the surface is rescaled correctly to the
actual output it is on if the initial selection of wl->current_output is
incorrect.

Additionally, autofit/geometry values are recalculated if they exist.
This means that dragging a surface across different outputs will autofit
correctly to the new output and not always be "stuck" on the old one.

A very astute observer may notice that set_buffer_scale isn't set when
the surface enters a new output. The API doesn't really indicate this,
but a WAYLAND_DEBUG log reveals that the compositor (well at least
sway/wlroots anyway) magically sets this for you. That's quite fortunate
because setting in the surface handler caused all sorts of problems.
2020-12-08 17:20:51 +00:00
der richter b8156a9a86 vo_gpu: revert 8a09299 and conditionally clear framebuffer again
in the original commit, that removed the conditional clearing, an
incorrect assumption was made that clearing "should be practically free"
and can be done always. though, at least on macOS + intel this can have
a performance impact of up to 50% increased usage. it might have an
impact on other platforms and setups as well, but this is unconfirmed.

the reason for removing the conditional clearing was to partially work
around a driver bug on very specific setups, X11 with amdgpu and OpenGL,
to clear garbled frames on start. though it still has issues with
garbled frames in other situation like fullscreening. there is also an
open bug report on the mesa bug tracker about this. setting the
radeonsi_zerovram flag works around all of those issues.

since the flag works around all these issues and the original fix
doesn't work completely we revert it and keep our optimisation.

Fixes #8273
2020-12-06 21:46:29 +02:00
der richter 96bcf51c39 mac: support screen-name and fs-screen-name opts
the screen-name and fs-screen-name option allow for specifying screens
based on their name. this is the name of the NSScreen and also reported
by the VOCTRL_GET_DISPLAY_NAMES event. the old screen and fs-screen
options by id, respectively, are preferred over these new ones.
2020-12-06 17:36:43 +00:00
Dudemanguy a700b8130b wayland: support fs-screen-name option
In wayland, setting the surface on a specific monitor only works in
fullscreen so only --fs-screen-name can be implemented. Like with x11,
we prefer --fs-screen over --fs-screen-name if it is set. This may be
more useful than setting by ids because there's no guaranteed order in
which screens are added in wayland. In wayland, the name used here is
the model name detected by the output_listener.
2020-12-06 17:36:43 +00:00
Dudemanguy 9a7b2015e1 x11: support screen-name and fs-screen-name opts
The --screen-name and --fs-screen-name options allow for specifying
screens based on their name. For x11, this is the display name reported
by xrandr. --screen-name and --fs-screen-name mimic the --screen and
--fs-screen options respectively. If --screen is set, then --screen-name
will always do nothing. Likewise, --fs-screen-name does nothing if
--fs-screen is set.
2020-12-06 17:36:43 +00:00
Niklas Haas 7c4465cefb vo_gpu: placebo: update for upstream API changes
The concept of sample/address modes was moved from `pl_tex` to
`pl_desc_binding`.

The `pl_tex_blit()` function also underwent an API change.
2020-12-04 23:49:31 +01:00
Avi Halachmi (:avih) 84d0930fa1 vo_sixel: don't divide by zero on small terminal
Our canvas size calculation is affected by few factors, and rounded
down more than once - which can result in 0 width or (more typically)
height - e.g. when terminal height is one row.

If the width or height are 0 then all bets are off, so simply skip
the setups and rendering on this case. We can still recover
automatically if the terminal is resized to become bigger.
2020-12-02 17:06:11 +02:00
Shreesh Adiga da48bb6709 vo_sixel: re-fit image on terminal resize
The obvious approach would be SIGWINCH, however, integrating it would
be tricky, so instead we simply poll the size on draw_frame.

This means the image won't resize automatically when still - e.g.
cover art or when paused, though it would re-fit on OSD changes.
2020-12-02 17:06:11 +02:00
Shreesh Adiga 3fd656ee7b vo_sixel: refactor of resize, reconfig (no-op)
More granular functionality - will be used by the the next commit.
2020-12-02 17:06:11 +02:00
Shreesh Adiga bd8faa8519 vo_sixel: Update description string of vo driver 2020-12-02 17:06:11 +02:00
Niklas Haas a74b6619f2 csputils: add MP_CHROMA_TOPLEFT
This is commonly used by UHD/HDR sources, and mpv hilariously ignores it
up until now, just blindly mapping it to MP_CHROMA_AUTO without even so
much as a warning message.

It would be justified to add all the other chroma locations as well, but
I'm lazy and just wanted to quickly fix this bug.
2020-12-02 01:36:29 +01:00
Avi Halachmi (:avih) aba77c64ff vo_sixel: don't leak the frame reference
The reference is allocated at reconfig and happens at least once (and
leaked at least once), but can also be called more, e.g. on zoom or
pan-and-scan changes.
2020-11-29 14:15:51 +02:00
Avi Halachmi (:avih) 824e569fb5 vo_tct: don't leak the frame reference
The reference is allocated at reconfig (and leaked at least once), but
could theoretically be called more than once by mpv, or in the future
when the tct code is enhanced to hande e.g. pan-and-scan changes.
2020-11-29 14:15:51 +02:00
Avi Halachmi (:avih) d4233021c7 vo_tct: remove unused variable 2020-11-29 14:15:51 +02:00
Shreesh Adiga 4d80314c5c vo_sixel: use draw_frame instead of draw_image
draw_image is deprecated, and draw_frame allows better
behavior, like rendering the osd without image.
e.g. `mpv --vo=sixel --idle --force-window`.
2020-11-27 15:31:24 +02:00
Shreesh Adiga 4dd5fdc087 vo_sixel: skip testdither init in fixed palette
testdither was being created irrespective of whether
opt_fixedpal is set or not. In case of opt_fixedpal=1,
testdither is not used in the `prepare_static_palette`
code. Hence only initialize it when opt_fixedpal is 0.
2020-11-27 15:31:24 +02:00
Shreesh Adiga 24525e4ef9 vo_sixel: Update libsixel constant values
In sixel_dither_initialize, replace 3 with the libsixel
SIXEL_PIXELFORMAT_RGB888. Also in sixel_encode, the 4th
parameter is supposed to be depth, which also happens
to be the value of PIXELFORMAT_RGB888, so replacing that
constant with the depth value.
2020-11-27 15:31:24 +02:00
Avi Halachmi (:avih) 62fb374349 vo_sixel: change default dither to "auto"
For two reasons:
1. It was counter intuitive that there's an "auto" value (which is
   actually a libsixel value and not an mpv one), but it's not the
   default value - our default was Atkinson.
2. "auto" provides better dithering than Atkinson with libsixel, which
   is especially noticeable with smooth gradients - where Atkinson has
   visible banding.

In libsixel 1.8.2 the "auto" value maps to Atkinson if the output
palette has up to 16 colors, or to Floyd-Steinberg otherwise (e.g.
using fixed palette with 256 colors chooses Floyd-Steinberg).
2020-11-27 00:25:32 +02:00
Avi Halachmi (:avih) 59c32a04b0 vo_sixel: fix the image corruption with mlterm
The issue was that we only uploaded the palette to the terminal when it
changed (once on init with fixed palette, every frame with dynamic
palette with trheshold=-1, only on scene change with threshold >= 0).

Now we upload it on every frame, and it seems to fix the mlterm image
corruption both with fixed palette and also with dynamic palette with
threshold (i.e. at frames which did not upload a palette).

It's not entirely clear why it's required with mlterm.

It would seem that the palette which libsixel uses with fixed palette
matches the built in default palette in xterm, but not in mlterm.
With dynamic palette we can guess that mlterm resets the palette after a
sixel image, but that's not confirmed.

Uploading the palette on every frame doesn't seem to slow down xterm
when using fixed palette - not clear yet why uploading a different
palette (when using fixedpalette=no) slows it down while same palette
on every frame doesn't.

In mlterm there's no slowdown either way - and now also no corruption.
2020-11-27 00:25:32 +02:00
Avi Halachmi (:avih) 1bb2665e3d vo_sixel: support --vo-sixel-exit-clear[=yes]
By default we still clear the screen, but now it's possible to leave the
last sixel image on screen.

Allows mpv to be used as img2sixel of sorts, but with our auto-fit and
various mpv scaling/filters etc.
2020-11-27 00:25:32 +02:00
Shreesh Adiga 959097c880 vo_sixel: draw osd on the output frame 2020-11-22 13:34:25 +02:00
Shreesh Adiga 8a278c2ddd vo_sixel: return -1 instead of SIXELSTATUS on failure
Currently in mpv functions sixel failures return the
value status which is of type SIXELSTATUS. So changing
it to -1 which is explicit and compatible with mpv.
Also log the errors using MP_ERR/MP_LOG with the
error string returned by libsixel to have more info.
2020-11-22 13:34:25 +02:00
Shreesh Adiga b48e0b11d9 vo_sixel: set --vo-sixel-fixedpalette=yes by default
fixedpalette seems to be slightly faster than dynamic
palette, and also in mlterm it avoids corruption of
too bright values overflowing to black. Hence setting
it to be default choice instead of dynamic palette.
2020-11-22 13:34:25 +02:00
Shreesh Adiga 6ad3e2bfbd vo_sixel: Add aspect ratio based output centering
Resize the image based on the dimensions reported by
vo_get_src_dst_rects to correctly handle aspect ratio
that might be set/ignored.

Added pad-x and pad-y options for padding.
These options will be used to remove the extra padding.
Some terminals report the padding of 2px in the ioctl
dimensions which can't be used for displaying sixel
output. These options can be used for fine tuning
the output video resolution.

Now all the terminal size detection and calculation logic
is done in a single function at resize. Also top and left
values are computed from the dst_rect parameters to simplify
the logic for the aspect ratio based centering.

Additionally vo-sixel-rows and vo-sixel-cols options
have been added to enable the user to override the values
in case of failures with get_terminal_size2.

This commit also adds ability to handle video zoom correctly.
Whenever video-zoom is triggered, the src and dst rects
will be updated. Scaling seems to work well now.
2020-11-22 13:34:25 +02:00
Shreesh Adiga c615e51051 vo_sixel: rename all user options with opt_ prefix
This has no changes to mpv sixel playback behaviour.
This is required because currently the offset values
and the resolutions are being overwritten and not
remembered.
2020-11-22 13:34:25 +02:00