You are not logged in.

#1 2020-02-28 22:56:03

gkun
Member
Registered: 2016-06-11
Posts: 91

Hardware acceleration in MPV and VLC

Good morning,

I finished configuring a new system with an AMD Radeon RX590 video card, and I was trying to enable hardware acceleration for video playing. I installed the amdgpu open source drivers and following the wiki both libva-mesa-driver and  mesa-vdpau. I then switched my chromium install for the chromium-vaapi package and downloaded the enhanced-h264ify extension.
This are the outputs of the vainfo and vdpauinfo commands:

[gian@Giankun-PC ~]$ vainfo
vainfo: VA-API version: 1.6 (libva 2.6.0)
vainfo: Driver version: Mesa Gallium driver 19.3.4 for Radeon RX 590 Series (POLARIS10, DRM 3.36.0, 5.5.6-arch1-1, LLVM 9.0.1)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc


display: :1   screen: 0
API version: 1
Information string: G3DVL VDPAU Driver Shared Library version 1.0

Video surface:

name   width height types
-------------------------------------------
420    16384 16384  NV12 YV12 
422    16384 16384  UYVY YUYV 
444    16384 16384  Y8U8V8A8 V8U8Y8A8 

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
MPEG1                          --- not supported ---
MPEG2_SIMPLE                    3 65536  4096  4096
MPEG2_MAIN                      3 65536  4096  4096
H264_BASELINE                  52 65536  4096  4096
H264_MAIN                      52 65536  4096  4096
H264_HIGH                      52 65536  4096  4096
VC1_SIMPLE                      1 65536  4096  4096
VC1_MAIN                        2 65536  4096  4096
VC1_ADVANCED                    4 65536  4096  4096
MPEG4_PART2_SP                  3 65536  4096  4096
MPEG4_PART2_ASP                 5 65536  4096  4096
DIVX4_QMOBILE                  --- not supported ---
DIVX4_MOBILE                   --- not supported ---
DIVX4_HOME_THEATER             --- not supported ---
DIVX4_HD_1080P                 --- not supported ---
DIVX5_QMOBILE                  --- not supported ---
DIVX5_MOBILE                   --- not supported ---
DIVX5_HOME_THEATER             --- not supported ---
DIVX5_HD_1080P                 --- not supported ---
H264_CONSTRAINED_BASELINE       0 65536  4096  4096
H264_EXTENDED                  --- not supported ---
H264_PROGRESSIVE_HIGH          --- not supported ---
H264_CONSTRAINED_HIGH          --- not supported ---
H264_HIGH_444_PREDICTIVE       --- not supported ---
VP9_PROFILE_0                  --- not supported ---
VP9_PROFILE_1                  --- not supported ---
VP9_PROFILE_2                  --- not supported ---
VP9_PROFILE_3                  --- not supported ---
HEVC_MAIN                      186 65536  4096  4096
HEVC_MAIN_10                   186 65536  4096  4096
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   --- not supported ---
HEVC_MAIN_444                  --- not supported ---

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8         16384 16384    y  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A8I8 I8A8 
R8G8B8A8         16384 16384    y  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A8I8 I8A8 
R10G10B10A2      16384 16384    y  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A8I8 I8A8 
B10G10R10A2      16384 16384    y  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A8I8 I8A8 

Bitmap surface:

name              width height
------------------------------
B8G8R8A8         16384 16384
R8G8B8A8         16384 16384
R10G10B10A2      16384 16384
B10G10R10A2      16384 16384
A8               16384 16384

Video mixer:

feature name                    sup
------------------------------------
DEINTERLACE_TEMPORAL             y
DEINTERLACE_TEMPORAL_SPATIAL     -
INVERSE_TELECINE                 -
NOISE_REDUCTION                  y
SHARPNESS                        y
LUMA_KEY                         y
HIGH QUALITY SCALING - L1        y
HIGH QUALITY SCALING - L2        -
HIGH QUALITY SCALING - L3        -
HIGH QUALITY SCALING - L4        -
HIGH QUALITY SCALING - L5        -
HIGH QUALITY SCALING - L6        -
HIGH QUALITY SCALING - L7        -
HIGH QUALITY SCALING - L8        -
HIGH QUALITY SCALING - L9        -

parameter name                  sup      min      max
-----------------------------------------------------
VIDEO_SURFACE_WIDTH              y        48     4096
VIDEO_SURFACE_HEIGHT             y        48     4096
CHROMA_TYPE                      y  
LAYERS                           y         0        4

attribute name                  sup      min      max
-----------------------------------------------------
BACKGROUND_COLOR                 y  
CSC_MATRIX                       y  
NOISE_REDUCTION_LEVEL            y      0.00     1.00
SHARPNESS_LEVEL                  y     -1.00     1.00
LUMA_KEY_MIN_LUMA                y  
LUMA_KEY_MAX_LUMA                y  

Now, I am checking the video card usage quite constantly by the

sudo watch -n 0.5  cat /sys/kernel/debug/dri/0/amdgpu_pm_info

Chromium works correctly in most videos. For example when I play a youtube video, this is what the video card monitoring says:

Clock Gating Flags Mask: 0x3fbcf
        Graphics Medium Grain Clock Gating: On
        Graphics Medium Grain memory Light Sleep: On
        Graphics Coarse Grain Clock Gating: On
        Graphics Coarse Grain memory Light Sleep: On
        Graphics Coarse Grain Tree Shader Clock Gating: Off
        Graphics Coarse Grain Tree Shader Light Sleep: Off
        Graphics Command Processor Light Sleep: On
        Graphics Run List Controller Light Sleep: On
        Graphics 3D Coarse Grain Clock Gating: Off
        Graphics 3D Coarse Grain memory Light Sleep: Off
        Memory Controller Light Sleep: On
        Memory Controller Medium Grain Clock Gating: On
        System Direct Memory Access Light Sleep: Off
        System Direct Memory Access Medium Grain Clock Gating: On
        Bus Interface Medium Grain Clock Gating: Off
        Bus Interface Light Sleep: On
        Unified Video Decoder Medium Grain Clock Gating: On
        Video Compression Engine Medium Grain Clock Gating: On
        Host Data Path Light Sleep: On
        Host Data Path Medium Grain Clock Gating: On
        Digital Right Management Medium Grain Clock Gating: Off
        Digital Right Management Light Sleep: Off
        Rom Medium Grain Clock Gating: On
        Data Fabric Medium Grain Clock Gating: Off
        Address Translation Hub Medium Grain Clock Gating: Off
        Address Translation Hub Light Sleep: Off

GFX Clocks and Power:
        2000 MHz (MCLK)
        910 MHz (SCLK)
        300 MHz (PSTATE_SCLK)
        1000 MHz (PSTATE_MCLK)
        950 mV (VDDGFX)
        43.177 W (average GPU)

GPU Temperature: 39 C
GPU Load: 0 %
MEM Load: 0 %

UVD: Enabled

VCE: Disabled

Now, I tried to use MPV, with --hwdec=vaapi --vo=gpu or =vdpau options. UVD is always disabled.

When I use VLC I can force the use or vaapi or vdpau. This strande issue is that if I choose vaapi, the video will play correctly, but checking the card status says the UVD is disabled. If I choose vdpau in VLC rthe video will be played from the GPU, but the video quality will be quite bad (horizontal lines). What can I check? Is this a common issue?

Last edited by gkun (2020-02-29 08:45:56)

Offline

#2 2020-02-29 18:15:25

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,910

Re: Hardware acceleration in MPV and VLC

https://mpv.io/manual/stable/#options-hwdec wrote:

Hardware decoding is not enabled by default, because it is typically an additional source of errors. It is worth using only if your CPU is too slow to decode a specific video.

Are you sure you need HW acceleration ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2020-03-01 10:53:32

gkun
Member
Registered: 2016-06-11
Posts: 91

Re: Hardware acceleration in MPV and VLC

Well I don't strictly need it, but I could do better with it. Like, CPU intensive tasks while the second screen projects a movie?

Offline

#4 2020-03-01 11:35:39

Gosi
Member
From: Vienna, Austria
Registered: 2010-02-25
Posts: 100

Re: Hardware acceleration in MPV and VLC

I have similar hardware (RX570) and hardware acceleration is working for me if I set hardware decoding to automatic for vlc or hwdec=auto for mpv.

vlc seems to use vdpau and mpv prefers va-api. Both enable UVD when playing a video.

Offline

#5 2020-03-01 14:25:44

gkun
Member
Registered: 2016-06-11
Posts: 91

Re: Hardware acceleration in MPV and VLC

Ok, I rechecked everything, and saved my MPV configuration in my

~/.config/mpv/mpv.conf

Now it works using vaapi. Mysteriously it was not working when I only used the option from the command line.

Now one problem remains. VLC's use of VDPAU has a very poor quality. Since you manage to use it and have a very similar hardware, did you need to do anything to make VLC work with VDPAU? Is the video quality the same with and without hardware acceleration (I noticed the problem when I was watching a movie where scrolling text was flowing upwards the screen introducing the story: the text would be readable but the contour of the letters was not sharp.. it would have been difficult to notice this problem in a different kind of scene).

Last edited by gkun (2020-03-01 14:26:17)

Offline

#6 2020-03-02 19:15:26

Gosi
Member
From: Vienna, Austria
Registered: 2010-02-25
Posts: 100

Re: Hardware acceleration in MPV and VLC

You are right, video quality with vdpau is not optimal in vlc and va-api doesn't seem to work.

I don't know how to solve this though.

Edit:
This (closed) bugreport looks familiar https://gitlab.freedesktop.org/mesa/mesa/issues/1193
The fix made it not into mesa 19.3. unfortunately.

Last edited by Gosi (2020-03-02 20:07:26)

Offline

#7 2020-03-08 14:06:23

gkun
Member
Registered: 2016-06-11
Posts: 91

Re: Hardware acceleration in MPV and VLC

So the fact the bug is closed means the next mesa update will hopefully make vaapi work with VLC... well let's wait.

Offline

#8 2020-04-05 07:08:23

Gosi
Member
From: Vienna, Austria
Registered: 2010-02-25
Posts: 100

Re: Hardware acceleration in MPV and VLC

vlc with va-api works for me now (mesa 20.x). Although not for every video I tested with.

Offline

#9 2020-12-09 23:16:48

SupKurtJ
Member
Registered: 2015-07-18
Posts: 46

Re: Hardware acceleration in MPV and VLC

Hi,

I have the same trouble with VA API and VDPAU on VLC.

Look the poor quality :

WM4o0Dj.png

My GPU : AMD RX 5700 XT

Last version of mesa (20.3.0-3).

If I disable the hardware acceleration, the video work fine.

Offline

Board footer

Powered by FluxBB