summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
* wayland: dispatch and wait for compositor events in uninitDudemanguy2023-01-032-30/+25
| | | | | | | | | | 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.
* wayland: initalize display_fd as -1Dudemanguy2023-01-031-3/+4
| | | | | | | | 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.
* wayland: consistently employ use_presentDudemanguy2023-01-031-4/+1
| | | | | | | | | 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.
* vo: hwdec: fix drmGetDeviceNameFromFd2() related memory leakrepojohnray2023-01-021-1/+5
| | | | | This commit fixes a minor memory leak related to drmGetDeviceNameFromFd2(). This function returns a string allocated with strdup().
* hwdec_drmprime: fix memory leakrepojohnray2023-01-021-0/+1
|
* vo_opengl: do not blindly reject all Microsoft's OpenGL implementationsKacper Michajłow2022-12-301-3/+3
| | | | | | | | | | | | | 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>
* x11: add modesetting to the xpresent whitelistSultan Alsawaf2022-12-271-1/+2
| | | | | | | | | | | | | | | | 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.
* build: add configure test for POSIX shm for the sake of vo_kittysfan52022-12-261-4/+5
| | | | Android's POSIX coverage is pretty sketchy but not like we have a choice.
* vo_kitty: Introduce modern sixel alternativeMia Herkt2022-12-212-0/+434
| | | | | | | | | | | | | 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
* hwdec/d3d11va: fix a possible memory leakchen702022-12-211-0/+1
|
* filter_kernels: fix kaisergaramond132022-12-201-1/+1
| | | | Seems to me that params[1] is set to NAN and here should be the same value as in params[0].
* vo_sixel: Implement write() loopMia Herkt2022-12-201-4/+16
| | | | | Not all systems are Linux. Also update the comment to better reflect POSIX documentation.
* vo_sixel: Rename draw-clear -> config-clearMia Herkt2022-12-201-5/+5
|
* osdep/terminal.h: Rename screen buffer controlsMia Herkt2022-12-202-4/+4
| | | | SAVE/RESTORE were a bit misleading.
* vo_sixel: Alias/deprecate exit-clear -> alt-screenMia Herkt2022-12-201-5/+7
| | | | Also update documentation to reflect actual behavior.
* vo_sixel: Make buffering optionalMia Herkt2022-12-201-7/+21
| | | | It can be slower than unbuffered.
* vo_sixel: Buffer full output sequenceMia Herkt2022-12-191-19/+27
| | | | | This allows the VO to write its output without interference from other processes or threads.
* vo_sixel: Use write(2) on POSIX platformsMia Herkt2022-12-191-14/+35
|
* vo_tct: Use newer options APIMia Herkt2022-12-191-28/+24
|
* vo_sixel: Move user options to structMia Herkt2022-12-191-69/+66
|
* vo_sixel: Add option to skip clear while drawingMia Herkt2022-12-191-7/+12
|
* osdep/terminal: Move common esc codes to terminal.hMia Herkt2022-12-192-42/+32
|
* vo_sixel: Use the alternate buffer to restore termMia Herkt2022-12-191-4/+6
|
* vo_tct: Use the alternate buffer to restore termMia Herkt2022-12-191-3/+7
|
* vd_lavc: Set AV_HWACCEL_FLAG_UNSAFE_OUTPUT flagPhilip Langdale2022-12-121-0/+11
| | | | | | | | | | 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.
* hwdec_drmprime: support yuv420p formatEmperorPenguin182022-12-102-0/+6
| | | | | | | | | | | 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>
* player: add window-id propertyNRK2022-12-052-0/+7
| | | | | | | | | | | | | | | | | | | | | 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
* ffmpeg: update to handle deprecation of `av_init_packet`Philip Langdale2022-12-031-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sws_utils: update to handle deprecation of `avcodec_enum_to_chroma_pos`Philip Langdale2022-12-011-0/+14
| | | | This has been replaced by `av_chroma_location_enum_to_pos`.
* vd_lavc: update to handle deprecation of `pkt_duration`Philip Langdale2022-12-011-0/+5
| | | | This has been replaced by `duration`.
* ffmpeg: increase minimum required version to 4.4Philip Langdale2022-12-011-2/+0
| | | | | | | | | 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.
* wayland: check for resize/move in touch event firstDudemanguy2022-12-011-8/+9
| | | | | | | | | | | | | | | 8300830951e2b0b90b22fc7d33b7556ed05e139c 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.
* vo_gpu_next: don't flush cache on OSD updateNiklas Haas2022-11-251-2/+9
| | | | | | | | | | | | | | | | | | | 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.
* lcms: fix validate_3dlut_size_optNiklas Haas2022-11-211-4/+1
| | | | | Not only was this function needlessly convoluted, it was also broken - since it returned a bool value where an error code was expected.
* lcms: always parse lcms2-related optionsNiklas Haas2022-11-211-40/+34
| | | | | | | | | | | | | | 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
* vo_dmabuf_wayland: use single-pixel-buffer-v1LaserEyess2022-11-203-18/+49
| | | | | | | The new single-pixel-buffer protocol is designed to optimize the case for using a solid color as an underlay wl_surface. It works the same as the wl_shm 1x1 pixel trick currently used, but it allows the compositor to make optimizations with more certainty than the wl_shm trick.
* wlbuf_pool.h: add headers for forward declarationsLaserEyess2022-11-202-1/+4
| | | | | | This was previously implicitly included by the order of headers in vo_dmabuf_wayland.c, but it is better to make it an explicit and reorder the headers properly.
* vo_gpu_next: fix undefined behavior on alpha-first formatsNiklas Haas2022-11-191-1/+4
| | | | | | | When the alpha channel is the first component, this code block gets skipped by the continue, meaning the check for c==0 never passes. Fix it by explicitly keeping track of whether bits have been set.
* wayland: also log refresh rate on surface entranceDudemanguy2022-11-181-2/+2
| | | | | Never bothered to log this for some reason, but it's pretty convenient when debugging.
* drm: remove legacy APILaserEyess2022-11-164-119/+54
| | | | | | | | | | | | | The legacy DRM API adds some complexity to the DRM code. There are only 4 drivers that do not support the DRM Atomic API: 1. radeon (early GCN amd cards) 2. gma500 (ancient intel GPUs) 3. ast (ASPEED SoCs) 4. nouveau Going forward, new DRM drivers will be guaranteed to support the atomic API so this is a safe removal.
* wayland: add support for content-type protocolDudemanguy2022-11-152-0/+57
| | | | | | | | | | | | | | | | | | | | The content-type protocol allows mpv to send compositor a hint about the type of content being displayed on its surface so it could potentially make some sort of optimization. Fundamentally, this is pretty simple but since this requires a very new wayland-protocols version (1.27), we have to mess with the build to add a new define and add a bunch of if's in here. The protocol itself exposes 4 different types of content: none, photo, video, and game. To do that, let's add a new option (wayland-content-type) that lets users control what hint to send to the compossitor. Since the previous commit adds a VOCTRL that notifies us about the content being displayed, we can also add an auto value to this option. As you'd expect, the compositor hint would be set to photo if mpv's core detects an image, video for other things, and it is set to none for the special case of forcing a window when there is not a video track. For completion's sake, game is also allowed as a value for this option, but in practice there shouldn't be a reason to use that.
* player/video: add VOCTRL_CONTENT_TYPEDudemanguy2022-11-151-0/+9
| | | | | | | | | | | | mpv's core already keeps track of whether or not it thinks a track is an image. Some VOs (i.e. wayland) would benefit from knowing if what is currently being displayed is an image or not so add a new VOCTRL that signals this anytime we load a new file with a VO. Additionally, let's add a helper enum for signaling the kind of content that is being displayed. There is now MP_CONTENT_NONE (strictly for force window being used on a track with no image/video), MP_CONTENT_IMAGE, and MP_CONTENT_VIDEO. See the next commit for the actual usage of this (with wayland).
* vo: hwdec: remove legacy_namesPhilip Langdale2022-11-155-16/+0
| | | | | These were introduced for configuration compatibility in 0.35 but we don't want to retain them past that point.
* player: add --force-render optionDudemanguy2022-11-152-2/+3
| | | | | | | | mpv has an internal optimization on a couple of platforms where it will not render any frames if the window is minimized or hidden. There's at least once possible use case for wanting to force a render anyway (screensharing with pipeware) so let's just add a simple switch for this that always forces mpv to render. Closes #10846.
* wayland: error out if essential protocol support is missingDudemanguy2022-11-153-0/+36
| | | | | | | | | | | | | | Related issue: #10868. While most protocols are in theory optional, a small amount of them are absolutely essential and nothing will work without them. We should make sure to error out in those cases and not try to actually do anything. For wayland support in general, wl_compositor support is obviously required. If there is no wl_surface, you can't do anything. Additionally, vo_wlshm quite obviously requires wl_shm so mark that one as well. vo_dmabuf_wayland needs linux_dmabuf, viewporter, wl_shm, and wl_subcompositor. In practice, these are all very standard protocols and shouldn't be missing but the linked issue above is at least one example where a compositor was stuck on an ancient version of a wayland interface.
* vo_gpu_next: add tunable shader parametersNiklas Haas2022-11-113-1/+61
| | | | | | | | | | | This is a very simple but easy way of doing it. Ideally, it would be nice if we could also add some sort of introspection about shader parameters at runtime, ideally exposing the entire list of parameters as a custom property dict. But that is a lot of effort for dubious gain. It's worth noting that, as currently implemented, re-setting `glsl-shader-opts` to a new value doesn't reset back previously mutated values to their defaults.
* vo_gpu: mark --gamma-factor and --gamma-auto with deprecation warningssfan52022-11-101-2/+4
| | | | This was forgotten in commit 2207236aaae54f32c1861c6fd77219e28139dc78.
* wayland, x11: fix possibly unsafe bstr usagesfan52022-11-102-3/+3
| | | | | | In practice this never led to any issues due to implementation details of bstr_sanitize_utf8_latin1, but there's no guarantee that a bstr is correctly null-terminated.
* vo_dmabuf_wayland: improve error handling exporting VA surfaceAaron Boxer2022-11-071-23/+25
| | | | | 1. check for all error conditions when calling vaExportSurfaceHandle 2. only clean up valid descriptors
* hwdec_vaapi: only set VADisplay resource if entire init process has succeededAaron Boxer2022-11-071-4/+4
| | | | | This resource is used by dmabuf_waland to decide if it should manage vaapi buffers, so it should not be set if vaapi init has failed
* gpu/context: properly guard wldmabuf contextDudemanguy2022-11-031-1/+1
| | | | | This should only be added if the build has dmabuf-wayland enabled. This fixes #10828.
* vo_gpu_next: set background transparencyNiklas Haas2022-11-011-0/+1
| | | | Fixes: https://github.com/mpv-player/mpv/issues/10815
* wayland_common: always zero out presentation context when destroying itLynne2022-10-311-1/+3
| | | | | A desync between the feedback and the feedback in the context still happens when closing a hidden surface.
* wayland: correct braindead comment (no-op)Dudemanguy2022-10-311-5/+4
| | | | | | | | | | | | | I was confused in d3a28f12c9ced29982fc831722075bd0c73fb821 why it actually even worked, but after not being stupid, it's quite obviously just a dangling pointer. The reason it only happens with wp_presentation_feedback is because the object and listener actually created in frame_callback not the presentation events itself (for vsync timing reasons). So it is possible to free the object, but not immediately recreate it again before quitting (unlike with the frame callback). The actual comment is moved into feedback_presented (which is first) but as of this commit it doesn't have the NULL setting logic (that's the next one).
* wayland: hack around presentation_feedback weirdnessDudemanguy2022-10-301-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 964692ad4cec90888bb437064c53d8844db9f590 added some code to destroy presentation_feedback we get in the presentation_discarded event. This is the correct thing to do since the compositor could send us this instead of feedback_presented. Without that change, mutter could potentially leak memory on every frame. Unfortunately, life is not so simple and wlroots and weston act differently. These compositors only send one presentation_discarded event if the mpv window is hidden. Not on every single missed frame like mutter. Now in theory this shouldn't matter, but it also turns out that mpv attempts to free the presentation feedback twice if you quit it while it is hidden away (on weston and wlroots compositors only). The inital wp_presentation_feedback_destroy in feedback_discarded fires, but then the function goes off again in vo_wayland_uninit because wl->feedback is apparently not NULL for some reason. Possibly, this is some race condition but we can't just get rid of what's in feedback_discarded since mutter needs this line. Instead, just hack it by explicitly setting wl->feedback to NULL in feedback_discarded after we destroy the presentation feedback. Some valgrind testing in mutter, sway, and weston shows that this works correctly on all of those compositors with various combinations of mpv being visible or not while quitting. feedback_presented doesn't appear to exhibit this behavior so we just leave that as-is.
* wayland: free dmabuf_feedback objectDudemanguy2022-10-301-4/+9
| | | | | | | 666cb91cf12a4f8b42087530104513b0fc4ba16d added dmabuf_feedback, but it was never actually free'd on uninit. Because this function requires wayland protocols 1.24, we have to wrap it in an #if. Also throw in some minor cosmetic changes in here.
* filters/f_hwtransfer: remove VAAPI <-> Vulkan mapping for nowPhilip Langdale2022-10-292-2/+0
| | | | | | | | | This mapping isn't actually relevant until we have the Vulkan interop merged, and it requires a newer version of libavutil than our minimum requirement. So I'm going to remove it from master and put it in the interop PR. Fixes #10813
* build: add an additional check for wayland-protocols 1.24Dudemanguy2022-10-292-3/+7
| | | | | | | | | | | | | | | | | 666cb91cf12a4f8b42087530104513b0fc4ba16d added support for v4 of the dmabuf protocol. This was meant to be optional and the fallback support for the old v2 (dates back to 2017[0] well before the 1.15 wayland-protocol version we depend on) was maintained. However, v4 added several new functions and structs that of course aren't defined in old protocol versions so naturally this breaks the build on those systems. Since this is just a niche feature and not really critical to overall wayland support in mpv, just give in and add another check in the build system and #if out the newer stuff in wayland_common. v4 of linux-dmabuf depends on wayland protocols 1-24[1], so go ahead and make that our new check. Fixes #10807. [0]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/commit/a840b3634ad637b23