haasn / libplacebo

Official mirror of libplacebo
http://libplacebo.org/
GNU Lesser General Public License v2.1
570 stars 73 forks source link

Sinc filter does not work with videos #248

Closed lextra2 closed 2 months ago

lextra2 commented 8 months ago

Command used to test: ffmpeg -y -benchmark -init_hw_device vulkan -i "input" -vf "libplacebo=w=iw*2:h=ih*2:upscaler=sinc" -c:v libx264 -preset ultrafast -qp 0 -g 1 -an test123.mkv

Some comparisons:

Spline36 (Avisynth) spline36

Sinc (Avisynth) How it is supposed to look sinc

Bilinear (Avisynth) bilinear

Sinc (libplacebo) Looks blurrier then Bilinear placebo_sinc

The same thing happens with gpu-next in MPV: https://github.com/mpv-player/mpv/issues/13672

Chipcraft commented 8 months ago

Can you provide the same source frame you used, as a reference?

Avisynth is using four taps for Sinc, whereas libplacebo uses three taps however, that is unlikely to cause the difference. Within libplacebo itself, Sinc is clearly superior to bilinear.

lextra2 commented 8 months ago

Can you provide the same source frame you used, as a reference?

mpv-shot0001

Within libplacebo itself, Sinc is clearly superior to bilinear.

I've only included bilinear for sharpness comparison

Chipcraft commented 8 months ago

Cannot replicate the output with libplacebo e987124b and ffmpeg master ab2173c0a5.

ffmpeg -init_hw_device vulkan -i 313426824-3cc2ca8e-7c87-44b7-978d-e7531ea335e3.png -vf libplacebo=upscaler=sinc:w=iw*2:h=ih*2 -pix_fmt rgb24 Sinc_Out.png

https://nle-chipcraft.com/Git/Sinc_Out.png

lextra2 commented 8 months ago

Cannot replicate the output with libplacebo e987124 and ffmpeg master ab2173c0a5.

ffmpeg -init_hw_device vulkan -i 313426824-3cc2ca8e-7c87-44b7-978d-e7531ea335e3.png -vf libplacebo=upscaler=sinc:w=iw*2:h=ih*2 -pix_fmt rgb24 Sinc_Out.png

https://nle-chipcraft.com/Git/Sinc_Out.png

Yeah weird. That works. And ffmpeg -loop 1 -init_hw_device vulkan -i input.png -c:v libx264 -qp 0 -t 15 -vf libplacebo=upscaler=sinc:w=iw*2:h=ih*2 -pix_fmt yuv420p test.mp4 works too.

But this code ffmpeg -init_hw_device vulkan -i input.mkv -vf "libplacebo=w=iw*2:h=ih*2:upscaler=sinc" -c:v libx264 -preset ultrafast -qp 0 -an test567.mkv does not work.

lextra2 commented 8 months ago

Here, try this 30 seconds snippet. Reference frame is at 0:25.025 (Frame 600)

And this time, encode it as video.

Edit: My guess is it only works with RGB inputs, and YUV fails. Pure speculation. Can't test right now.

lextra2 commented 2 months ago

fixed in https://github.com/haasn/libplacebo/commit/76bb971847a5c7f5a40596edcb071de5ab8b7446