summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
* drm_prime: fix newline in error messageHo Ming Shun2022-07-051-1/+1
|
* context_x11egl: remove supposed transparency fixDudemanguy2022-07-011-3/+0
| | | | | | | | | | | | | | | | This was introduced in 7fb972fd3997bfa389caa7c1eb899ea4b8444083 and later revised in f5a094db047ee0162774301a2ce4ed685ca9d539. Transparency in EGL/X11 has been broken upstream for years in Mesa unfortunately. However, the first commit claimed to have found a way to preserve transparency by doing a trick with picking EGLConfigs (the second commit revises this but keeps the logic in place). However, it doesn't appear that the first commit actually fixes anything (transparency doesn't work on my machine) and no one else seems to have reported it working. On the other hand, if Mesa does ever actually fix this, transparency would immediately be broken since mpv would always set the EGL_ALPHA_SIZE to 0. Go ahead and remove this since it doesn't seem to have any actual utility and is technically a bit of a timebomb (not that deleting two lines is a lot of work but still) if upstream ever does fix this.
* vo_gpu_next: implement --cscaleNiklas Haas2022-06-241-0/+3
| | | | Fixes #9451
* x11: avoid XPresent API calls when it's not neededDudemanguy2022-06-227-23/+52
| | | | | | | | | | | This commit kind of mixes several related things together. The main thing is to avoid calling any XPresent functions or internal functions related to presentation when the feature is not auto-whitelisted or enabled by the user. Internally rework this so it all works off of a use_present bool (have_present is eliminated because having a non-zero present_code covers exactly the same thing) and make sure it updates on runtime. Finally, put some actual logging in here whenever XPresent is enabled/disabled. Fixes #10326.
* x11: add --x11-present optionDudemanguy2022-06-221-3/+5
| | | | | | | | | | | With the recent addition of the libxpresent, it should improve frame timings for most users. However, there were known cases of bad behavior (Nvidia) which lead to a construction of a whitelist instead of just enabling this all the time. Since there's no way to predict whatever combination of hardware/drivers/etc. may work correctly, just give users an option to switch the usage of xorg's presentation statistics on/off. The default value, auto, works like before (basically, Mesa drivers and no Nvidia are allowed), but now one can force it on/off if needed.
* x11: add nouveau to the xpresent whitelistDudemanguy2022-06-221-1/+3
| | | | | A user noted that this worked correctly (i.e. vsync jitter of 0) so go ahead and add it here as a safe driver for xpresent to use.
* x11: correct provider detection logicDudemanguy2022-06-211-2/+2
| | | | | | | | | | | | The old logic always reset the x11->has_mesa/has_nvidia values on every loop through the provider. This meant that it would always just match whatever the last provider happened to be. So in the case of a dual GPU system, if nvidia was the very first provider and the integrated intel/amd card was the second (in practice, this is probably mostly the other way around), then mpv would set has_mesa to true and has_nvidia to false and thus try to use presentation. This is not the intended behavior. Just rework this by also checking x11->has_mesa/has_nvidia in the loop so a true value from the previous iteration is preserved.
* vo_vaapi_wayland: remove vaapi format query as formats are never usedAaron Boxer2022-06-211-25/+2
| | | | | | | | This code was taken from the older vo_vaapi driver, which does use the vaapi format list, but the new driver has no use for these formats, as it is only interested in va surfaces that can be mapped to wl buffers. The format doesn't enter into it at all.
* x11: replace strcasestr usage with bstrDudemanguy2022-06-191-6/+8
| | | | | strcasestr is a GNU extension, but we can just use bstr instead to do the same thing.
* x11: support xorg present extensionDudemanguy2022-06-1910-191/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This builds off of present_sync which was introduced in a previous commit to support xorg's present extension in all of the X11 backends (sans vdpau) in mpv. It turns out there is an Xpresent library that integrates the xorg present extention with Xlib (which barely anyone seems to use), so this can be added without too much trouble. The workflow is to first setup the event by telling Xorg we would like to receive PresentCompleteNotify (there are others in the extension but this is the only one we really care about). After that, just call XPresentNotifyMSC after every buffer swap with a target_msc of 0. Xorg then returns the last presentation through its usual event loop and we go ahead and use that information to update mpv's values for vsync timing purposes. One theoretical weakness of this approach is that the present event is put on the same queue as the rest of the XEvents. It would be nicer for it be placed somewhere else so we could just wait on that queue without having to deal with other possible events in there. In theory, xcb could do that with special events, but it doesn't really matter in practice. Unsurprisingly, this doesn't work on NVIDIA. Well NVIDIA does actually receive presentation events, but for whatever the calculations used make timings worse which defeats the purpose. This works perfectly fine on Mesa however. Utilizing the previous commit that detects Xrandr providers, we can enable this mechanism for users that have both Mesa and not NVIDIA (to avoid messing up anyone that has a switchable graphics system or such). Patches welcome if anyone figures out how to fix this on NVIDIA. Unlike the EGL/GLX sync extensions, the present extension works with any graphics API (good for vulkan since its timing extension has been in development hell). NVIDIA also happens to have zero support for the EGL/GLX sync extensions, so we can just remove it with no loss. Only Xorg ever used it and other backends already have their own present methods. vo_vdpau VO is a special case that has its own fancying timing code in its flip_page. This presumably works well, and I have no way of testing it so just leave it as it is.
* x11: use xrandr providers for driver detectionDudemanguy2022-06-192-0/+27
| | | | | | | | | | | | | | Unfortunately there's a certain company that makes graphics drivers that are harder to deal with. The next commit aims to implement presentation, but some empirical testing from users show that it's actually broken. Give up and just tap into Xrandr so we can figure what drivers (or well, providers by the extension terminology) are driving the screen. Basically if we find intel, amd, or radeon, assume it's a Mesa driver. If we find nvidia, then it must be nvidia. This detection requires randr 1.4 (which means using presentation in mpv secretly depends on randr 1.4), but this protocol version is nearly a decade old anyway so probably 99.9% of users are fine. Do the version query check and all that anyway just to be on the safe side.
* vo: move wayland presentation to separate filesDudemanguy2022-06-198-120/+158
| | | | | | | | | | | | | | | | | | | | | | | | | Wayland had some specific code that it used for implementing the presentation time protocol. It turns out that xorg's present extension is extremely similar, so it would be silly to duplicate this whole mess again. Factor this out to separate, independent code and introduce the mp_present struct which is used for handling the ust/msc values and some other associated values. Also, add in some helper functions so all the dirty details live specifically in present_sync. The only wayland-specific part is actually obtaining ust/msc values. Since only wayland or xorg are expected to use this, add a conditional to the build that only adds this file when either one of those are present. You may observe that sbc is completely omitted. This field existed in wayland, but was completely unused (presentation time doesn't return this). Xorg's present extension also doesn't use this so just get rid of it all together. The actual calculation is slightly altered so it is correct for our purposes. We want to get the presentation event of the last frame that was just occured (this function executes right after the buffer swap). The adjustment is to just remove the vsync_duration subtraction. Also, The overly-complicated queue approach is removed. This has no actual use in practice (on wayland or xorg). Presentation statistics are only ever used after the immediate preceding swap to update vsync timings or thrown away.
* vo_vaapi_wayland: only attach solid buffer once to main surface, on creationAaron Boxer2022-06-151-1/+1
| | | | There's no need to attach it with each frame.
* vo_vaapi_wayland: remove unnecessary subsurface sync/desync in resizeAaron Boxer2022-06-151-2/+0
| | | | | | | | resize only changes subsurface position, which is always synchronized with the parent surface. For reference, see : https://wayland-book.com/surfaces-in-depth/subsurfaces.html
* wayland: set appid before initial surface commitDudemanguy2022-06-111-3/+3
| | | | | | | | | This shouldn't have mattered but apparently qtile is unable to get the app id if you set it after the initial surface commit. Wayland is a mess anyway so just shuffle this around so that the frame callback and surface commit are the last things registered in vo_wayland_init. This works around qtile and, in theory, doesn't appear to break anything else. Fixes #10280.
* wayland_gl: fix a typoDudemanguy2022-06-111-1/+1
| | | | | Somehow in commit 661b5542de21d46d4d7c4693e564f4eec0526812, my editor snuck in a ¥ sign in here. Oops.
* wayland_gl: wait until resize to create egl_windowDudemanguy2022-06-101-34/+32
| | | | | | | | | | | | | Some wayland compositors (i.e. weston) get extremely picky about committed buffer sizes not matching the configured state. In particular, weston throws an error on you if you attempt to launch with --window-maximized and use opengl (vo_vaapi_wayland actually errors as well in this case, but that's a different issue). The culprit here is actually wl_egl_window_create. This creates an initial buffer at the sizes passed in the arguments which is what weston doesn't like. Instead, move the egl_window creation call to the resize function. This ensures that mpv is using the size obtained via the toplevel event, and it should always be the buffer size we want.
* wayland_gl: use wl->scaling when creating egl_windowDudemanguy2022-06-071-2/+3
| | | | | | | | | | | | | This was actually always bugged, but we just got lucky that compositors ignored it. The egl window was created only using wl->geometry's coordinates but those do not include the scale factor. So technically, the initial window creation always had the wrong size (off by whatever the scaling factor is). The resize call later fixes it because that correctly uses wl->scaling so in practice nothing bad was seen. wlroots's master branch has started sending an error in this case however and this is what trips it. Fix it correctly by using the scale factor. This is what cd3b4edea06dec659d9676f2649cc1b1be2e8565 tried to fix (but was incorrect).
* wayland: rearrange initialization logicDudemanguy2022-06-071-10/+8
| | | | | | | | | cd3b4edea06dec659d9676f2649cc1b1be2e8565 is not correct and had some unexpected breakage with geometry/resizing. Rather than completely revert it, this commit restores the set_surface_scaling call as well as rearranges some other things in the wayland init/reconfig process to make it simplier. The next commit properly fixes what cd3b4edea06dec659d9676f2649cc1b1be2e8565 tried to fix.
* wayland: remove some unneeded lines from reconfigDudemanguy2022-06-061-2/+0
| | | | | | | | | | | | | | | | | | | | | | | Just a couple of small changes. First, the obvious one is to remove the bogus wl->window_size = wl->vdparams; line in the configure conditional. The reconfig always unconditionally sets the window_size here so there's no need to duplicate it. The more important change is to remove the usage of set_surface_scaling. This function is just to handle when scaling changes and for setting the initial scale, it was called in the reconfig. This, however, causes some weird issues in the latest sway/wlroots where it can try to divide a buffer by an inappropriate scale factor. This is possibly due to some weird ordering of events and only occured in opengl for some reason. Luckily, it turns it out it's not neccessary to set the scaling here at all. The surface enter event is already setup to handle scale changes. On an HIDPI display, mpv will initially assume a scale of 1 but the surface actually enters the wl_output, it will automatically readjust and resize itself to the appropriate scale value. This works on the initial launch of the mpv window as well, so there's no need to special case this in the reconfig event. This has the nice bonus of avoiding that sway/wlroots issue as well since the buffer_scale is set much later. Fixes #10263.
* vo_gpu_next: fix OSD rendering of screenshotsNiklas Haas2022-06-061-5/+6
| | | | | | | | | | | | | | One downside of this approach is that it bypasses the mixer cache, but while this is not ideal for performance reasons, the status quo is also simply broken so I'd rather have a slower implementation that works than a faster implementation that does not. And as it turns out, updating the OSD state and invalidating the mixer cache correctly is sufficiently nontrivial to do in a clean way, so I'd rather have this code that I can be reasonably certain does the right thing. Fixes #9923 as discussed. Also fixes #9928.
* video/out/dither: remove custom index_t typedefWessel Dankers2022-06-041-26/+24
| | | | | | | | Apparently _t names are reserved, and in this case it wasn't very useful anymore (it was useful while developing it, but this code is almost 10 years old now). Fixes a compilation error on Solaris.
* wayland: force vo_vaapi_wayland scaling to 1Dudemanguy2022-05-301-1/+2
| | | | | | | | | | | | | The wayland stuff is designed to update/rescale itself whenever the wl_output scale changes. This is great, but vo_vaapi_wayland should not actually attempt to handle any hidpi stuff. The point of this VO is to hand off as much to the compositor as possible, so we do want the compositor to do the scaling here (enjoy your bilinear). This fixes some incorrect rendering that could occur with scaling values not equal 1 due to mismatches between buffer coordinates and the surface local coordinates. It also eliminates the need to specify --no-hidpi-window-scale on hidpi displays (has the same practical effect).
* vo: move allocate_memfd method to wayland_commonAaron Boxer2022-05-304-36/+26
|
* vo_vaapi_wayland/wayland_common: code style fixesDudemanguy2022-05-303-138/+177
| | | | | | | | A bad person (AKA me) merged this stuff without paying close enough attention to the code style. Reformat this to be in-line with the rest of the wayland code and general mpv style (braces for functions on the next line, horizontally aligning arguments, some cosmetic cleanups for wayland_common.h, etc.).
* wayland: use mp_tag_str not drm_format_stringDudemanguy2022-05-304-455/+3
| | | | | | | | | | | So it turns out that mpv already has an mp_tag_str which makes a readable string out of fourccs (drm formats are these). drm_format_string, on the other hand, has a ton of baggage with having to check different libdrm versions for certain headers, adding compile-time defines (because there are no version defines in the libdrm headers), etc. It's a lot simpler to just use what mpv already has and it returns what you actually care about: i.e. is this format supported or not. Fixes https://github.com/mpv-player/mpv-build/issues/184
* vo: allow vaapi_wayland and vaapi_x11 to coexistAaron Boxer2022-05-301-2/+3
|
* wayland: don't depend on the order of global announcementsJulian Orth2022-05-281-4/+10
| | | | E.g. wl_subcompositor could be announced before wl_compositor.
* vo: add new vaapi-wayland driverAaron Boxer2022-05-246-1/+953
| | | | | | | This driver makes use of dmabuffer and viewporter interfaces to enable efficient display of vaapi surfaces, avoiding any unnecessary colour space conversion, and avoiding scaling or colour conversion using GPU shader resources.
* various: remove trailing whitespaceGuido Cella2022-05-142-2/+2
|
* wayland: use wl_output v4 for display-namesDudemanguy2022-05-131-2/+4
| | | | | | | | 5774ce759a6c7fe0727cfbd4458957abfd96a7b7 added the new output name event and used them for the --fs-screen-name option. It turns out that the display-names property could also make use of these names, so go ahead and use output->name in this case if we have them. If not, fallback to output->model like before.
* context_drm_egl: support monitor parDudemanguy2022-05-051-0/+9
| | | | | | These values and options were simply never looked at in the drm egl context. This pretty much is just a copy and paste of what is in vo_drm. Fixes #10157.
* video/image_writer: tag colorspace in AVCodecContextLeo Izen2022-05-041-2/+4
| | | | | If screenshot-tag-colorspace=yes, then set the corresponding fields in AVCodecContext, not just in AVFrame.
* video/image_writer: fix high-depth JPEG XL screenshotsLeo Izen2022-04-291-1/+5
| | | | | | | Allow screenshot-high-bit-depth=yes to work with JPEG XL screenshots when screenshot-sw=no is set. They already work as expected when screenshot-sw=yes is set, but this allows the hardware screenshots to work this way too.
* build: add avcodec jpegxl dependency versionsLeo Izen2022-04-281-5/+3
| | | | | Add the libavcodec version check for AV_CODEC_ID_JPEGXL to the build system rather than to any file that references it.
* wayland: use wl_surface_damage_bufferDudemanguy2022-04-272-5/+5
| | | | | | | | | | | | | | | | Since 2018, wl_surface_damage_buffer has been explicitly preferred and recommended over wl_surface_damage*. mpv was still using the old function in a couple of spots. The only difference is that we need to pass buffer coordinates instead of surface coordinates. In vo_wlshm, this is done by using vo->dwidth/vo->dheight since that is always used whenever wl_buffers are created. In the case of the cursor surfaace, we actually already passed buffer coordinates to it (img->width/height) which was probablly technically wrong with wl_surface_damage, but it doesn't really matter in practice. This requires bumping wl_compositor to version 4 which is no problem since this dates back to 2015*. https://gitlab.freedesktop.org/wayland/wayland/-/commit/921d0548035673a1bf6aeb9396b9bc728133411e https://gitlab.freedesktop.org/wayland/wayland/-/commit/3384f69ecf043d62a4e036c0353c2daa01d7c4d0
* video/image_writer: add Jpeg XL screenshotsLeo Izen2022-04-262-0/+20
| | | | | | | Add Jpeg XL as a possible output format for screenshots, which should make it possible to take fast screenshots with much better quality than JPEG, or take lossless high-bit-depth screenshots with lower file sizes than PNG.
* various: fix typosCœur2022-04-2514-19/+19
|
* vo_gpu_next: avoid 0x0 resizesDudemanguy2022-04-241-2/+4
| | | | | | | | | | | It is possible for vo_gpu_next to attempt a resize before the windowing backend is fully initialized. In practice, this can happen on wayland which means libplacebo attempts a 0x0 resize. Depending on the API, a 0x0 resize may be allowed (vulkan or d3d11), but libplacebo just returns a 0 in this case which mpv doesn't do anything with anyway. In the case of opengl, this usage is explictly forbidden and will result in a warning which may confuse users. Solve this by just not trying a resize if dwidth and dheight in the vo are not available. Fixes #10083.
* vo_wlshm: use draw_frame instead of draw_imageDudemanguy2022-04-211-3/+3
| | | | | | | | draw_image is an old API that was deprecated long ago. However when wlshm was originally added, it used draw_image. There's no particular reason for this and it can trivially be switched to draw_frame instead. This has some real advantages (notably --vo=wlshm --idle --force-window actually works).
* vd_lavc: fixup unchecked usage of AV_CODEC_EXPORT_DATA_FILM_GRAINJan Ekström2022-04-131-0/+7
| | | | | | | | | | | | | | This fixes build failures with avcodec 58.113.100 or before, matching FFmpeg release versions 4.0 to 4.3. This flag was added in between avcodec 58.113.100 and 58.114.100 during the FFmpeg 4.4 development cycle. It lacks its own version bump, so instead a check for the define is utilized instead. Additionally, warn the user if they request GPU film grain with too old of an FFmpeg. Fixes #10088
* vd_lavc: fix decoder initialization when no VO is availableJan Ekström2022-04-111-6/+20
| | | | | | | | | | | | | | | | | The VO is available during decoder initialization mostly for direct rendering purposes, so if f.ex. a complex filter chain is utilized, there is no video renderer information available via mp_filter_find_stream_info during creation of the decoder filter. Thus, check for whether the VO is available before attempting to check the capabilities flag from it. Additionally - to simplify logic - makes explicitly requesting GPU film grain to always disable decoder film grain functionality. The warning is still shown if the VO is available and no support for film grain application is available. Fixes #10079
* vd_lavc: remove duplicate vd_ffmpeg_ctx pointer from init_avctxJan Ekström2022-04-111-2/+1
| | | | | Seems like in some functions this was called p and in others ctx, and thus it was added as the `p` pointer was not available.
* wayland: use wl_output v4 for --fs-screen-nameDudemanguy2022-04-111-3/+30
| | | | | | | | | | In wayland 1.20.0, a couple of new events, name and description, were added to the interface. Description is not particularly useful, but name returns back nice names for the output like "DP-1" and so on. It makes sense to use these for fs-screen-name and prefer them over the model name (old way of doing it) if they are available. The only problem is that 1.20.0 is pretty new so old distros aren't going to have it anytime soon. Deal with this by adding some defines.
* x11: avoid wasteful rendering when possibleDudemanguy2022-04-117-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because wayland is a special snowflake, mpv wound up incorporating a lot of logic into its render loop where visibilty checks are performed before rendering anything (in the name of efficiency of course). Only wayland actually uses this, but there's no reason why other backends (x11 in this commit) can't be smarter. It's far easier on xorg since we can just query _NET_WM_STATE_HIDDEN directly and not have to do silly callback dances. The function, vo_x11_check_net_wm_state_change, already tracks net wm changes, including _NET_WM_STATE_HIDDEN. There is an already existing window_hidden variable but that is actually just for checking if the window was mapped and has nothing to do with this particular atom. mpv also currently assumes that a _NET_WM_STATE_HIDDEN is exactly the same as being minimized but according to the spec, that's not neccesarily true (in practice, it's likely that these are the same though). Anyways, just keep track of this state in a new variable (hidden) and use that for determing if mpv should render or not. There is one catch though: this cannot work if a display sync mode is used. This is why the previous commit is needed. The display sync modes in mpv require a blocking vsync implementation since its render loop is directly driven by vsync. In xorg, if nothing is actually rendered, then there's nothing for eglSwapBuffers (or FIFO for vulkan) to block on so it returns immediately. This, of course, results in completely broken video. We just need to check to make sure that we aren't in a display sync mode before trying to be smart about rendering. Display sync is power inefficient anyways, so no one is really being hurt here. As an aside, this happens to work in wayland because there's basically a custom (and ugly) vsync blocking function + timeout but that's off topic.
* wayland: unify visibility checking codeDudemanguy2022-04-117-23/+33
| | | | | | | | | | | A bit of a personal pet peeve. vulkan, opengl, and wlshm all had different methods for doing wayland's "check for visibility before drawing" thing. The specific backend doesn't matter in this case and the logic should all be shared. Additionally, the external swapchain that the opengl code on wayland uses is done away with and it instead copies vulkan by using a param. This keeps things looking more uniform across backends and also makes it easier to extend to other platforms (see the next couple of commits).
* vo_gpu/d3d11: add message ID based log level mappingJan Ekström2022-04-111-6/+64
| | | | | | | | | | | | | This lets us remap various messages which might now be happening at each frame onto the trace level, thus unaffecting the initial debug log level. Additionally - thanks to this ability - the previously globally denied message queue abandonment messages can now be handled and mapped to trace log level, as on that log level they may be of use. Recommended by rossy and based on his libplacebo commit 6d72f6445566eddb0493447d0bda72d98a99d40c .
* vo_gpu/d3d11: mimic libplacebo backbuffer usageJan Ekström2022-04-111-7/+10
| | | | | | Instead of always having the reference outside of calling resize, request a backbuffer at start and relieve the backbuffer at submission for presentation.
* vo_gpu/d3d11: enable receival of color depth without active backbufferJan Ekström2022-04-111-2/+12
| | | | | | |