Commit Graph

5341 Commits

Author SHA1 Message Date
sfan5 1201d59f0b various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriate
In debug mode the macro causes an assertion failure.
In release mode it works differently and tells the compiler that it can
assume the codepath will never execute. For this reason I was conversative
in replacing it, e.g. in mpv-internal code that exhausts all valid values
of an enum or when a condition is clear from directly preceding code.
2023-01-12 22:02:07 +01:00
sfan5 7b03cd367d various: replace if + abort() with MP_HANDLE_OOM()
MP_HANDLE_OOM also aborts but calls assert() first, which
will result in an useful message if compiled in debug mode.
2023-01-12 22:02:07 +01:00
sfan5 833bff8738 {video,audio}: adjust unsafe strncpy usages 2023-01-12 22:02:07 +01:00
sfan5 f4280e5238 video/x11: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5 2703a2c8ff video: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5 356096b954 ra_d3d11: fix incorrect type
As it happens, `SIZE_T` and `size_t` are not the same length on 32-bit Windows
2023-01-12 22:02:07 +01:00
Dudemanguy a5b9d529ee vo_dmabuf_wayland: drop support for linux-dmabuf-v2
The only real reason this was ever supported is because it was
dramatically simpler than v4, so it was put in as an initial
implementation. Later, v4 support was added and we left v2 for
compatibility, but let's just drop it. Compositors all use v4 nowadays,
and v2 is significantly limited (no modifier support for example). It's
better to just remove this dead code for simplicity.
2023-01-12 17:42:35 +00:00
Aaron Boxer 865a159244 vo_dmabuf_wayland: support panscan and panning 2023-01-11 18:10:40 +00:00
Dudemanguy 4beb1bcae7 vo_wlshm: properly support video panscan
Turns out it was already doing this under the hood the entire time. The
only catch is that the vo just needed a resize.
2023-01-09 19:30:26 -06:00
Dudemanguy 8439c084e1 wayland: make vo_wayland_reconfig a bool
This was already returning true/false but the type was int. Also
simplify a few places in the wayland contexts where we can just return
the value of this function instead of doing redundant checks.
2023-01-08 20:42:42 +00:00
Dudemanguy d73fc7912a wayland: cleanup on vo_wayland_init error
Instead of just returning true/false, it's better to have this function
cleanup itself. We can eliminate some redundant uninit calls elsewhere
in the code as well.
2023-01-08 20:42:42 +00:00
Dudemanguy e4e0e7dfcf vo: change vo_platform_init to bool
There's several functions that are used for initializing mpv on a
certain platform (x11, wayland, etc.). These currently are all int, but
they actually return 1 and 0 like a boolean. This gets a bit confusing
because actual vo preinit functions return 0 and -1 instead. Just make
these all bool instead and return true/false to make it clearer.
2023-01-08 20:42:42 +00:00
Dudemanguy e43393c4da vo_wlshm: cleanup on failure
If failure occurs during preinit, vo_wlshm should goto an error and
cleaup itself like the other VOs.
2023-01-08 12:39:50 -06:00
Dudemanguy c5af54eb35 vo_dmabuf_wayland: goto err instead of returning
Returning early is clearly wrong. It should use to goto to cleanup after
itself. Also renamed from error_out to err for purely comestic reasons.
2023-01-08 12:19:14 -06:00
Christoph Reiter 96773f39e1 vulkan: fix build error for 32bit builds with clang
vk->surface is a handle and not a pointer, so assign VK_NULL_HANDLE.
This fixes the following build error on 32bit Windows when using clang for example,
which errors out when assigning a 32bit pointer to a 64bit integer:

  ../mpv-0.35.0/video/out/vulkan/utils.c:37:21:
    error: incompatible pointer to integer conversion assigning to 'VkSurfaceKHR' (aka 'unsigned long long') from 'void *' [-Wint-conversion]
          vk->surface = NULL;
                      ^ ~~~~
2023-01-08 16:09:01 +01:00
Dudemanguy aa8ddfcdf3 wayland: dispatch and wait for compositor events in uninit
Similar to some other issues we've had with unprocessed compositor
events. When quitting mpv, there's two things we should be doing:
dispatching any last minute wayland events and then waiting for a
compositor reply. Luckily, there's already an internal helper for this
(renamed to wayland_dispatch_events for consistency) that we can use.
All of the special casing of wl->feedback becomes unneccesary and we can
remove this from vo_wayland_state with this method. Fixes #110022.
2023-01-03 20:45:39 +00:00
Dudemanguy 4bbb1ccfd7 wayland: initalize display_fd as -1
In the event of a failed wayland initalization, the display_fd is
actually 0 instead of -1 which would correctly indicate it doesn't
exist. Also move the fd check inside vo_wayland_dispatch_events since
that function shouldn't ever do anything if we don't actually have a
display fd.
2023-01-03 20:45:39 +00:00
Dudemanguy 24e2251b73 wayland: consistently employ use_present
We have a use_present bool that keeps track of whether or not to use
presentation time. However, the creation of the feedback listener
actually wasn't checking this and was instead checking for the existence
of wl->presentation. There's no point in always creating the
listener and feedback if mpv isn't actually going to use it. Just change
it to use_present instead.
2023-01-03 20:45:39 +00:00
repojohnray fee6847aa7 vo: hwdec: fix drmGetDeviceNameFromFd2() related memory leak
This commit fixes a minor memory leak related to drmGetDeviceNameFromFd2().
This function returns a string allocated with strdup().
2023-01-02 16:48:24 -08:00
repojohnray 2e9c43f931 hwdec_drmprime: fix memory leak 2023-01-02 19:46:07 +01:00
Kacper Michajłow ad65c8855b vo_opengl: do not blindly reject all Microsoft's OpenGL implementations
This change enables mpv to work in the WSL2 (WSLg) environment where
OpenGL is implemented on top of D3D12.

This reverts commit 149d98d244.

Mentioned OpenGL implementation (GDI Generic) in the original change
will be rejected by version check, so there is no need to handle it
manually.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2022-12-30 11:02:52 -05:00
Sultan Alsawaf 4a2aa36674 x11: add modesetting to the xpresent whitelist
Since the modesetting driver now has TearFree support with integration into
xpresent, it's important that xpresent is used with the modesetting driver
to get the correct vsync timing when a frame is delayed by one vblank
interval due to a pending page-flip enqueued by a different entity. The
modesetting driver ensures that the xpresent extension reports the correct
presentation timing when TearFree is used; mpv just needs to listen to it.

Add the modesetting driver to the xpresent whitelist so mpv can get the
correct presentation completion timing when modesetting TearFree is used.

This is also helpful for when xpresent performs page flips directly in the
modesetting driver and a natural delay in the display pipeline causes a
page flip to be delayed by one vblank interval or more.
2022-12-27 13:07:33 +01:00
sfan5 d8ae14653a build: add configure test for POSIX shm for the sake of vo_kitty
Android's POSIX coverage is pretty sketchy but not like we have a choice.
2022-12-26 15:08:07 +01:00
Mia Herkt 874e28f4a4
vo_kitty: Introduce modern sixel alternative
See https://sw.kovidgoyal.net/kitty/graphics-protocol/

This makes no attempt at querying terminal features or handling
terminal errors, as it would require mpv to pass the response codes
from the terminal to the vo instead of interpreting them as
keystrokes made by the user and acting very unpredictably.

Tested with kitty and konsole.

Fixes #9605
2022-12-21 19:39:30 +01:00
chen70 3447463008 hwdec/d3d11va: fix a possible memory leak 2022-12-21 19:03:38 +01:00
garamond13 27dab30209 filter_kernels: fix kaiser
Seems to me that params[1] is set to NAN and here should be the same value as in params[0].
2022-12-20 13:53:25 +01:00
Mia Herkt 56f0ba22f1
vo_sixel: Implement write() loop
Not all systems are Linux. Also update the comment to better reflect
POSIX documentation.
2022-12-20 10:45:36 +01:00
Mia Herkt 125fd4c2f9
vo_sixel: Rename draw-clear -> config-clear 2022-12-20 10:29:49 +01:00
Mia Herkt 08747c4965
osdep/terminal.h: Rename screen buffer controls
SAVE/RESTORE were a bit misleading.
2022-12-20 10:26:53 +01:00
Mia Herkt a4cac2ddc6
vo_sixel: Alias/deprecate exit-clear -> alt-screen
Also update documentation to reflect actual behavior.
2022-12-20 10:22:51 +01:00
Mia Herkt 12c3203e98
vo_sixel: Make buffering optional
It can be slower than unbuffered.
2022-12-20 10:06:49 +01:00
Mia Herkt fe21553637 vo_sixel: Buffer full output sequence
This allows the VO to write its output without interference from other
processes or threads.
2022-12-19 13:48:49 +01:00
Mia Herkt 3ca31b6cf4 vo_sixel: Use write(2) on POSIX platforms 2022-12-19 13:48:49 +01:00
Mia Herkt 0f721ab51c vo_tct: Use newer options API 2022-12-19 13:48:49 +01:00
Mia Herkt 85f1fa0715 vo_sixel: Move user options to struct 2022-12-19 13:48:49 +01:00
Mia Herkt 68ae603e75 vo_sixel: Add option to skip clear while drawing 2022-12-19 13:48:49 +01:00
Mia Herkt f1957ce911 osdep/terminal: Move common esc codes to terminal.h 2022-12-19 13:48:49 +01:00
Mia Herkt 4e1626a21c vo_sixel: Use the alternate buffer to restore term 2022-12-19 13:48:49 +01:00
Mia Herkt 1564e4f29f vo_tct: Use the alternate buffer to restore term 2022-12-19 13:48:49 +01:00
Philip Langdale eeefa8aec0 vd_lavc: Set AV_HWACCEL_FLAG_UNSAFE_OUTPUT flag
This new hwaccel flag was added to allow us to request that an hwaccel
decode not implicitly copy output frames before passing them out. The
only hwaccel that would implicitly copy frames is nvdec due to how it
has a small output pool that cannot be grown very much. However, we
already copy frames as soon as we get our hands on them (in our hwdec)
so we're already safe from pool exhaustion, and the extra copy doesn't
help us.
2022-12-12 10:07:43 -08:00
EmperorPenguin18 cf349d68e3 hwdec_drmprime: support yuv420p format
H264 hardware decode with v4l2m2m wasn't working on the RPi 4. Mpv would
report the image format (yuv420p) wasn't supported. The change to
hwdec_drmprime.c is to explicitly say that the format now is supported.
The change to dmabuf_interop_gl.c is to specify the colour format of the
planes before generating egl images. These changes were tested on a Pi 4
with this fork of ffmpeg: https://github.com/jc-kynesim/rpi-ffmpeg.

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
2022-12-10 15:57:09 -08:00
NRK 25b66256d7 player: add window-id property
currently only supported on x11.

one practical use-case of this is wanting to embed something (such as
dmenu) into the mpv window to use as a menu/selection. there might be
other use-cases as well (e.g doing some shenanigans with `xdotool` or
whatnot).

it's currently possible to:

* listen for 'current-window-scale' change (to check if the
  window has been created or not)
* call an external tool like `xdo` or `xdotool` and grab the xid
  from mpv's pid.

however it adds unnecessary dependency on external tools when mpv is
fully capable of easily providing this information.

closes: #10918
2022-12-05 02:03:25 +00:00
Philip Langdale 4574dd5dc6 ffmpeg: update to handle deprecation of `av_init_packet`
This has been a long standing annoyance - ffmpeg is removing
sizeof(AVPacket) from the API which means you cannot stack-allocate
AVPacket anymore. However, that is something we take advantage of
because we use short-lived AVPackets to bridge from native mpv packets
in our main decoding paths.

We don't think that switching these to `av_packet_alloc` is desirable,
given the cost of heap allocation, so this change takes a different
approach - allocating a single packet in the relevant context and
reusing it over and over.

That's fairly straight-forward, with the main caveat being that
re-initialising the packet is unintuitive. There is no function that
does exactly what we need (what `av_init_packet` did). The closest is
`av_packet_unref`, which additionally frees buffers and side-data.
However, we don't copy those things - we just assign them in from our
own packet, so we have to explicitly clear the pointers before calling
`av_packet_unref`. But at least we can make a wrapper function for
that.

The weirdest part of the change is the handling of the vtt subtitle
conversion. This requires two packets, so I had to pre-allocate two in
the context struct. That sounds excessive, but if allocating the
primary packet is too expensive, then allocating the secondary one for
vtt subtitles must also be too expensive.

This change is not conditional as heap allocated AVPackets were
available for years and years before the deprecation.
2022-12-03 14:44:18 -08:00
Philip Langdale 77e7f5de2c sws_utils: update to handle deprecation of `avcodec_enum_to_chroma_pos`
This has been replaced by `av_chroma_location_enum_to_pos`.
2022-12-01 10:45:47 -08:00
Philip Langdale 83257be693 vd_lavc: update to handle deprecation of `pkt_duration`
This has been replaced by `duration`.
2022-12-01 10:45:47 -08:00
Philip Langdale 70683b8916 ffmpeg: increase minimum required version to 4.4
Now that 0.35 has been released, we can consider increasing our minimum
required ffmpeg version. Currently, we think 4.4 is the most recent
version we can move to (from the current requirement of 4.0).

This allows us to remove a few conditionals. There are more that we
won't be able to remove unless we move further up to 5.1.
2022-12-01 10:45:47 -08:00
Dudemanguy 11229e7f71 wayland: check for resize/move in touch event first
8300830951 rearranged/simplified some of
the wayland touch code mainly because what was there before was
completely broken on my machine in those days (dragging was unreliable,
resizing was really buggy, etc.). However, one user said that touch
input no longer worked for him after that change. I could not ever
reproduce it, but it seems the issue was putting down the key before
testing for resize/move in the code. Now who knows why this actually
matters, but apparently it works for the user in question and I don't
observe any unexpected behavior on my end when swapping the order. Like
the mouse/pointer code, we also now do a test for dragging before
actually trying a resize/move which is a little more consistent than
before. Fixes #9771.
2022-12-01 11:14:03 -06:00
Niklas Haas e97e0e4d92 vo_gpu_next: don't flush cache on OSD update
Flushing the cache is a hammer-for-a-screw operation, because it nukes
*all* renderer state, including the HDR peak detection state. When
enabling e.g. --hdr-compute-peak, or any other future methods of dynamic
tone mapping, this would lead to bad results (e.g. brightness
fluctuations) whenever the OSD state is updated.

Instead of flushing the cache to force an OSD re-render, instead just
update the frame signature directly whenever its osd_sync value changes.
This accomplishes effectively the same thing but without touching the
HDR state.

This is slightly violating the libplacebo abstraction in a way that
isn't publicly documented. To be on the safe side we could make a carbon
copy of the array before modifying it, but given that this is unlikely
to change upstream I'll probably just end up explicitly documenting it
instead of forcing the copy in mpv.
2022-11-25 02:15:05 +01:00
Niklas Haas e1a04cd8ac lcms: fix validate_3dlut_size_opt
Not only was this function needlessly convoluted, it was also broken -
since it returned a bool value where an error code was expected.
2022-11-21 17:39:37 +01:00
Niklas Haas b9b3342369 lcms: always parse lcms2-related options
Currently, the lcms-related options are only defined when lcms2 is
enabled at build time. However, this causes issues (e.g. segfault) for
vo_gpu_next, which relies on the presence of these options (to forward
them to libplacebo).

(That libplacebo internally depends on lcms2 as well is an
implementation detail - compiling mpv *without* lcms against libplacebo
*with* lcms should be possible in principle)

Fixes: #10891
Closes: #10856
2022-11-21 17:39:37 +01:00