moonlight-stream / moonlight-qt

GameStream client for PCs (Windows, Mac, Linux, and Steam Link)
GNU General Public License v3.0
10.17k stars 594 forks source link

Hardware acceleration scales image incorrectly on AMD with VDPAU #171

Closed clee closed 5 years ago

clee commented 5 years ago

Describe the bug On an ultrawidescreen (21:9) client with a 16:9 source, the image is scaled correctly only when I choose "Force software decoding". Both "Automatic (Recommended)" and "Force hardware decoding" result in incorrect scaling, cropping off the sides of the image.

Steps to reproduce

Screenshots Broken scaling with hardware decoding: moonlight-scaling-broken

Correct scaling, with forced software decoding: moonlight-scaling-correct

Affected games All games

Moonlight settings (please complete the following information) Resolution and FPS: 1440p / 100fps, 80mbps bitrate Display mode: Full-screen (Recommended) V-Sync on, Frame pacing on

Advanced settings: Video decoder: broken scaling with "Force hardware decoding" and "Automatic (Recommended)", proper scaling with "Force software decoding" Video codec: Force H.264

Client PC details (please complete the following information)

Server PC details (please complete the following information)

Moonlight Logs (please attach) vd-automatic.log vd-hardware.log vd-software.log

clee commented 5 years ago

Update: after consulting with @cgutman on Discord and testing FORCE_VAAPI=1, this definitely seems to be a problem with VDPAU scaling on AMD. Luckily, the VAAPI memory leak seems to be fixed for me, so FORCE_VAAPI=1 is a useful workaround until VAAPI is either manually-selectable in the UI or enabled by default on AMD cards on Linux.

cgutman commented 5 years ago

Can you try with this change and see if it fixes VDPAU for you?

diff --git a/app/streaming/video/ffmpeg-renderers/vdpau.cpp b/app/streaming/video/ffmpeg-renderers/vdpau.cpp
index 53fc81a..b1b01c2 100644
--- a/app/streaming/video/ffmpeg-renderers/vdpau.cpp
+++ b/app/streaming/video/ffmpeg-renderers/vdpau.cpp
@@ -335,8 +335,8 @@ void VDPAURenderer::renderFrameAtVsync(AVFrame* frame)
                                    0, nullptr,
                                    &sourceRect,
                                    chosenSurface,
-                                   &outputRect,
                                    nullptr,
+                                   &outputRect,
                                    0,
                                    nullptr);
clee commented 5 years ago

Moving the &outputRect after the nullptr totally fixes the VDPAU scaling for me.