[Cin] HEVC hw encoding on AMD Polaris cards

Andrew Randrianasulu randrianasulu at gmail.com
Mon May 13 12:09:58 CEST 2019

Not sure if I send this bunch of links to list or only to my friend...

Few days ago I compiled Cin-GG snapshot from git for my friend with AMD machine (AMD phenom x4 as cpu, and  RX470 as GPU). Initially hw decoding/encoding was not working for him, but after some tries he was able to set Cin-GG to 'vdpau decode, vaapi h264 encode" and this mdoe worked, while not ultrafast.

Still, I was puzzled at his vainfo:

vainfo: VA-API version: 1.4 (libva 2.4.0)
vainfo: Driver version: Mesa Gallium driver 18.3.6 for AMD Radeon (TM) RX 470 Graphics (POLARIS10, DRM 3.8.0, 4.9.155-nrj-desktop-1rosa-x86_64, LLVM 7.0.1)
vainfo: Supported profile and entrypoints
EE ../src/gallium/drivers/radeonsi/si_get.c:642 si_get_video_param UVD - No MJPEG support for the kernel version
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

No HEVC encoding, as you can see!

After some digging I found possible reason - too old kernel!



    Written by Michael Larabel in Radeon on 24 February 2018 at 03:09 PM EST. 14 Comments
    Earlier this month AMD developers landed VCN-powered video encode support for the HEVC main format while now this has come to the UVD engine so it will work with pre-Raven GPUs.

    VCN "Video Core Next" is the new unified video encode/decode block found so far just on Raven Ridge APUs. That VCN support has been getting into Mesa while AMD's James Zhu this week enabled UVD-based encode for the HEVC main profile.

    The patches had been floating around on the Mesa mailing list for a few weeks but have now been merged and flipped on for those interested in GPU-based HEVC/H.265 main profile encoding using the UVD block.

    Hardware-wise, it appears this implementation should work with Carrizo APUs. Fiji GPUs and newer. If you try it out, make sure you are also using the latest firmware files for your GPU.

    These Mesa changes will be present for next quarter's Mesa 18.1 release along with a whole lot more for advancing the open-source Radeon Linux graphics driver stack.





    2017-10-09	Merge branch 'drm-next-4.15' of git://people.freedesktop.org/~agd5f/linux int...
    	Dave Airlie	88	-22439/+6754
    2017-10-06	drm/amdgpu: add uvd enc irq
    	James Zhu	1	-2/+38
    2017-10-06	drm/amdgpu: add uvd enc ib test
    	James Zhu	1	-0/+172
    2017-10-06	drm/amdgpu: add uvd enc ring test
    	James Zhu	1	-1/+54
    2017-10-06	drm/amdgpu: add uvd enc vm functions (v2)
    	James Zhu	1	-2/+44
    2017-10-06	drm/amdgpu: add uvd enc into run queue
    	James Zhu	1	-0/+14
    2017-10-06	drm/amdgpu: add uvd enc rings
    	James Zhu	1	-2/+52
    2017-10-06	drm/amdgpu: add new uvd enc ring methods
    	James Zhu	1	-0/+117
    2017-10-06	drm/amdgpu: add uvd enc command in header
    	James Zhu	1	-0/+10
    2017-10-06	drm/amdgpu: add uvd enc registers in header


    so, it seems you need kernel 4.15 + mesa 18.1+ and also probably new enough firmware....



+ some windows tests from 2016:

+ some ffmpeg-users correspondence from 2018:

[FFmpeg-user] Using a AMD Radeon RX5xx with ffmpeg

In theory, hevc encoder on Polaris should be faster than h264, but not very good at high bit rates (from forum link at videohelp).

Some speed figures for VCE 3.4:


Hardware VCE3.4
Jump to bottom 
 Michael Fabian Dirks edited this page May 6, 2017 ·  21 revisions  
Version 3.4 added support for H265/HEVC encoding at the cost of reduced throughput in H264/AVC and H264/SVC encoding and also losing the ability to encode B-Frames.
Acceleration: Hardware
Profiles: High, Main, Baseline
Maximum Level: 5.2
B-Pictures Supported: No
Maximum Simultaneous Streams: 16
Resolution: 64x64 - 4096x2160
Formats: NV12, YUV420P, YV12, BGRA, RGBA, ARGB
Memory Types: DX11, OpenCL, OpenGL, Host
Interlaced Supported: No
Resolution: 64x64 - 4096x2160
Formats: NV12
Memory Types: DX11, OpenCL, OpenGL, Host
Interlaced Supported: No
All FPS values are to be read as "up to <x> FPS". There are no guarantees that you will achieve this value.
RX 460
RX 470
RX 480
RX 460
160x120  2871 FPS  2723 FPS  2356 FPS
  240x160  2457 FPS  2237 FPS  1762 FPS
  256x160  2431 FPS  2186 FPS  1705 FPS
  320x240  1864 FPS  1605 FPS  1134 FPS
  480x320  1269 FPS  1037 FPS  651 FPS
  640x460  790 FPS  613 FPS  361 FPS
  640x480  767 FPS  595 FPS  349 FPS
  800x600  519 FPS  400 FPS  229 FPS
  854x480  525 FPS  454 FPS  272 FPS
  960x540  490 FPS  376 FPS  215 FPS
  1024x768  342 FPS  259 FPS  146 FPS
  1152x864  276 FPS  209 FPS  116 FPS
  1280x720  297 FPS  224 FPS  125 FPS
  1280x800  269 FPS  203 FPS  113 FPS
  1280x1024  217 FPS  162 FPS  89 FPS
  1366x768  261 FPS  199 FPS  111 FPS
  1440x900  216 FPS  162 FPS  89 FPS
  1600x1200  152 FPS  113 FPS  61 FPS
  1920x1080  140 FPS  104 FPS  56 FPS
  1920x1200  128 FPS  95 FPS  51 FPS
  1920x1440  107 FPS  79 FPS  43 FPS
  1920x1920  81 FPS  60 FPS  32 FPS
  2048x1080  132 FPS  98 FPS  53 FPS
  2560x1440  81 FPS  60 FPS  32 FPS
  3440x1440  61 FPS  45 FPS  24 FPS
  3840x2160  36 FPS  27 FPS  18 FPS
  4096x2160  34 FPS  25 FPS  17 FPS

and two more tables below this one

More information about the Cin mailing list