4K60 Kodi 17 Media Center feat RX 460 & Xbuntu 16.04

there are some quirks on HDMI 2.0 but they arnt that bad and their seems to be pretty complete support with the amdgpu-pro drivers

am using a Samsung UE55HU7505 55" 4K television using HDMI 2.0, you might not need amdgpu-pro but for my television i needed the pro drivers

  • You must use Ubuntu 16.04 LTS or Linux 4.4 (i used xubuntu)
  • You must use AMDGPU-PRO Drivers! (if you using HDMI 2.0 4K television)
  • 4K AVC works fine
  • 4k HEVC Main works fine
  • 4k HEVC Main10 (vpau nope, not implemented currently in libvdpau?)
  • 4k HEVC Main10 (vaapi works with mpv, we lose quality due to outdated surfaces and stuff but will play in hardware)
  • also HEVC Main10 migh work in kodi 16 using older render engine
  • Rant: wtf is it with DPI and Linux? its stupidly small by default :/
  • You can ignore DISPLAY=:0 if you are not using ssh in this guide
  • FYI: all those screenshots are in all their 4k glory if you right click and open image in new tab

But first we need to some background music for our work

GUNSHIP by GUNSHIP

Install amdgpu-pro, mpv & Kodi

First we install the latest beta/rc builds of kodi/mpv and the amd-gpu-pro driver ofc

  • sudo add-apt-repository ppa:team-xbmc/unstable -y
  • sudo add-apt-repository ppa:mc3man/mpv-tests -y
  • sudo apt-get update && sudo apt-get upgrade
  • sudo apt-get install kodi mpv vdpauinfo p7zip-full ppa-purge
  • wget --referer="http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Install.aspx" https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-16.50-362463.tar.xz
  • 7z x amdgpu-pro-16.50-362463.tar.xz && 7z x amdgpu-pro-16.50-362463.tar
  • chmod +x amdgpu-pro-16.50-362463/amdgpu-pro-install
  • sudo amdgpu-pro-16.50-362463/amdgpu-pro-install

Fixing vdpau & vaapi

  • sudo mkdir -p /usr/lib/x86_64-linux-gnu/vdpau/
  • sudo mkdir -p /usr/lib/i386-linux-gnu/vdpau/
  • sudo ln -s /opt/amdgpu-pro/lib/x86_64-linux-gnu/vdpau/libvdpau_amdgpu.so.* /usr/lib/x86_64-linux-gnu/vdpau/
  • sudo ln -s /opt/amdgpu-pro/lib/i386-linux-gnu/vdpau/libvdpau_amdgpu.so.* /usr/lib/i386-linux-gnu/vdpau/
  • sudo ln -s /opt/amdgpu-pro/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so /usr/lib/x86_64-linux-gnu/dri/amdgpu_drv_video.so

Fixing Tearing

  • sudo nano /usr/share/X11/xorg.conf.d/10-amdgpu-pro.conf
Section "OutputClass"
        Identifier "amdgpu-pro"
        MatchDriver "amdgpu"
        Driver "amdgpu"
EndSection

Section "Files"
        ModulePath "/opt/amdgpu-pro/lib/xorg/modules"
        ModulePath "/usr/lib/xorg/modules"
EndSection

Section "Device"
Identifier  "Card0"
Driver      "amdgpu"
BusID       "PCI:1:0:0"
Option      "DRI3" "1"
Option "TearFree" "on"
EndSection

Kodi 17

adding amdgpu temperature to kodi

nano $HOME/.kodi/userdata/advancedsettings.xml

<advancedsettings>
<gputempcommand>sensors amdgpu-pci-0100 | sed -ne "s/temp1: \+[-+]\([0-9]\+\).*/\1 C/p"</gputempcommand>
</advancedsettings>

Use mpv for HEVC Main10 Content (seem to work but we lose quality due to outdated surfaces and stuff but it will play in hardware on a underpowered system)

nano $HOME/.kodi/userdata/playercorefactory.xml

<playercorefactory>
 <players>
   <player name="mpv" type="ExternalPlayer" audio="false" video="true">
     <filename>mpv</filename>
     <args>--hwdec=vaapi --fs</args>
     <hidexbmc>false</hidexbmc>
     <hideconsole>false</hideconsole>
     <warpcursor>none</warpcursor>
   </player>
 </players>
 <rules action="prepend">
   <rule filetypes="mkv|mp4" filename=".*hevc.*" player="mpv"/>
 </rules>
</playercorefactory>

now we need to add kodi to autostart
Xfce Menu -> Settings (-> Xfce 4 Settings Manager) -> Session and Startup -> Application Autostart tab

Uninstall

  • ./amdgpu-pro-install -u (Uninstall amdgpu-pro)
  • ppa-purge team-xbmc/unstable (remove kodi betas)
  • ppa-purge mc3man/mpv-tests (remove mpv betas

### below is just testing and vainfo/vdpauinfo logs ###

mpv vdpau testing (thanks jell.yfish.us for samples, missing a HEVC Main 4k sample? )

wget http://jell.yfish.us/media/jellyfish-100-mbps-hd-h264.mkv
wget http://jell.yfish.us/media/jellyfish-100-mbps-hd-hevc.mkv
wget http://jell.yfish.us/media/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv
wget http://jell.yfish.us/media/jellyfish-120-mbps-4k-uhd-h264.mkv
wget http://download.tsi.telecom-paristech.fr/gpac/dataset/dash/uhd/mux_sources/hevcds_2160p60_20M.mp4
wget http://download.tsi.telecom-paristech.fr/gpac/dataset/dash/uhd/mux_sources/hevcds_2160p60_Main10_20M.mp4
DISPLAY=:0 mpv --hwdec=vdpau --fs jellyfish-* hevcds_2160p60_*
Playing: jellyfish-100-mbps-hd-h264.mkv
 (+) Video --vid=1 (*) (h264)
Warning: LLVM emitted unknown config register: 0x4
Using hardware decoding (vdpau).
VO: [opengl] 1920x1080 vdpau
V: 00:00:30 / 00:00:30 (100%)
Playing: jellyfish-100-mbps-hd-hevc.mkv
 (+) Video --vid=1 (*) (hevc)

Using hardware decoding (vdpau).
VO: [opengl] 1920x1080 vdpau
V: 00:00:29 / 00:00:30 (99%)
Playing: jellyfish-120-mbps-4k-uhd-h264.mkv
 (+) Video --vid=1 (*) (h264)

Using hardware decoding (vdpau).
VO: [opengl] 3840x2160 vdpau
V: 00:00:29 / 00:00:30 (99%)
Playing: jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv
 (+) Video --vid=1 (*) (hevc)

Using software decoding.
VO: [opengl] 3840x2160 yuv420p10
V: 00:00:28 / 00:00:30 (94%)

rx 460 vdpauinfo report

vdpauinfo --display :0 > vdpau_rx460.txt

display: :0   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      --- not supported ---
H264_EXTENDED                  --- not supported ---
H264_PROGRESSIVE_HIGH          --- not supported ---
H264_CONSTRAINED_HIGH          --- not supported ---
H264_HIGH_444_PREDICTIVE       --- 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                         -
HIGH QUALITY SCALING - L1        -
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  

mpv vaapi testing

DISPLAY=:0 mpv --hwdec=vaapi --fs jellyfish-* hevcds_2160p60_*
Playing: Videos/jellyfish-100-mbps-hd-h264.mkv
 (+) Video --vid=1 (*) (h264)
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/amdgpu_drv_video.so
libva info: Found init function __vaDriverInit_0_39
Warning: LLVM emitted unknown config register: 0x4
libva info: va_openDriver() returns 0
Using hardware decoding (vaapi).
VO: [opengl] 1920x1080 vaapi
V: 00:00:29 / 00:00:30 (99%)

Playing: Videos/jellyfish-100-mbps-hd-hevc.mkv
 (+) Video --vid=1 (*) (hevc)
Using hardware decoding (vaapi).
VO: [opengl] 1920x1080 vaapi
V: 00:00:29 / 00:00:30 (99%)

Playing: Videos/jellyfish-120-mbps-4k-uhd-h264.mkv
 (+) Video --vid=1 (*) (h264)
Using hardware decoding (vaapi).
VO: [opengl] 3840x2160 vaapi
V: 00:00:29 / 00:00:30 (99%)

Playing: Videos/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv
 (+) Video --vid=1 (*) (hevc)
Using hardware decoding (vaapi).
VO: [opengl] 3840x2160 vaapi
V: 00:00:29 / 00:00:30 (99%)

Playing: Videos/hevcds_2160p60_20M.mp4
 (+) Video --vid=1 (*) (hevc)
 (+) Audio --aid=1 --alang=und (*) (aac)
AO: [pulse] 48000Hz stereo 2ch float
Using hardware decoding (vaapi).
AV: 00:02:31 / 00:02:31 (99%) A-V:  0.000

Playing: Videos/hevcds_2160p60_Main10_20M.mp4
 (+) Video --vid=1 (*) (hevc)
 (+) Audio --aid=1 --alang=und (*) (aac)
Using hardware decoding (vaapi).
AV: 00:02:31 / 00:02:31 (99%) A-V:  0.000 Dropped: 4


Exiting... (End of file)

VaInfo Report

DISPLAY=:0 vainfo
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/amdgpu_drv_video.so
libva info: Found init function __vaDriverInit_0_39
Warning: LLVM emitted unknown config register: 0x4
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.3)
vainfo: Driver version: mesa gallium vaapi
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264Baseline           :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

Sources (thank you all)