Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct-downscaling causes ewa_lanczossharp to introduce a half-pixel shift when downsampling sometimes #13405

Closed
Artoriuz opened this issue Feb 3, 2024 · 4 comments

Comments

@Artoriuz
Copy link

Artoriuz commented Feb 3, 2024

Important Information

  • mpv version: mpv v0.37.0-234-g57d68262
  • Platform and Version: Windows 11 Pro 22H2
  • Source of the mpv binary: Shinchiro
  • If known which version of mpv introduced the problem: No idea
  • GPU model, driver and version: 6600XT Adrenalin 24.1.1
  • Possible screenshot or video of visual glitches: All below

Reproduction steps

magick convert rei.png -filter lanczossharp -distort resize 75% im_ewa_lanczossharp.png
im_ewa_lanczossharp

mpv --no-config --vo=gpu-next --gpu-api=vulkan --no-hidpi-window-scale --pause=yes --screenshot-format=png --deband=no --dither-depth=no --screenshot-high-bit-depth=no --dscale=ewa_lanczossharp --linear-downscaling=no --window-scale=0.75 rei.png
mpv_ewa_lanczossharp

mpv --no-config --vo=gpu-next --gpu-api=vulkan --no-hidpi-window-scale --pause=yes --screenshot-format=png --deband=no --dither-depth=no --screenshot-high-bit-depth=no --dscale=ewa_lanczossharp --linear-downscaling=no --window-scale=0.75 --correct-downscaling=no rei.png
mpv_ewa_lanczossharp_incorrect

Expected behavior

mpv's output should probably roughly match whatever ImageMagick is doing.

Actual behavior

mpv's output with correct-downscaling turned on appears to have a half-pixel shift towards the top-left corner (rounding issue somewhere?). Screenshot with it turned off also provided to show that there's no shift in this case, so the problem seems related to turning it on. Filters with integer supports seem fine as well.

Log file

output.txt

Sample files

rei

@Artoriuz
Copy link
Author

Artoriuz commented Mar 3, 2024

Update: After talking to @llyyr about this he couldn't reproduce it on his system and I couldn't reproduce it with gpu-api=opengl either (tested on both AMD and Intel), so it's likely a driver windows-only problem.

Edit: Can confirm both Vulkan and OpenGL are working as intended on Linux.

@llyyr
Copy link
Contributor

llyyr commented Mar 3, 2024

I couldn't reproduce this on X11/Wayland or with a Windows build running through wine. Seems to be driver/Windows related since Artoriuz can only reproduce it with d3d11/vulkan as well.

@kasper93
Copy link
Contributor

kasper93 commented Mar 3, 2024

I haven't tested myself, but I've seen recently similar issue. That could be related and explain on px offset.

See:
Blinue/Magpie#803
bjin/mpv-prescalers@bfcf48a

Maybe @bjin remembers more detail about it. But since it has 0.49 workaround, I think he didn't get to the root cause of it?

If we really have rounding issues around half values, well it should be fixed somehow, because it may produce weird issues here and there.

~EDIT:

Interesting. The gather version of polar sampling is indeed broken. Works fine with compute and direct sampling. Here is good read about gather issues with 16.8 fixed point conversion https://www.reedbeta.com/blog/texture-gathers-and-coordinate-precision/ but I must say, I couldn't make it work correctly even with this knowledge, still missing something. (edit: still interesting, but not really important in our case)

Also probably on some systems the gather version is not used, that's why it works. I don't see why it would behave differently on different platforms, with similar hardware.

@kasper93
Copy link
Contributor

kasper93 commented Mar 4, 2024

haasn added a commit to haasn/libplacebo that referenced this issue Mar 5, 2024
To fit with reduced hardware limits on some devices.

See-Also: mpv-player/mpv#13405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants