2 2

4kp30 video on Orange Pi Lite and mainline hardware acceleration

Recommended Posts

I‘m using an OrangePi Lite with the intent to display a 4kp30 video to a 4k TV over hdmi.


from reading through the forums I saw that mainline kernel does not support video acceleration - is this information current?


after installing the Xenial Image with 3.4 kernel I manage to play 1440p video smoothly two ways with mpv:


- windowed if display resolution is set to 4k

-fullscreen if display resolution is set to 1080p


if I try to run the 1440p video at 4k display resolution in fullscreen, the app crashes with messages about ‚not enough resources to create surface‘ and the framebuffer stays corrupted after that and I have to reboot.


The same happens if I try to play the 4k30p video (independently of whether I run it fullscreen or windowed, 4k or 1080p display res. I also tried both h264 and h265).


I Played around with extraargs=cma=... sunxi_ve_mem_reserve=... in ArmbianEnv.txt but it didn‘t seem to have effect. The docs state that in the 3.4 kernel the video memory is hardcoded to 80MB (not sure if I understood that correctly though) which probably would prevent 4k playback with that kernel.


on https://linux-sunxi.org/Cedrus/libvdpau-sunxi it's stated that:

This can be set by the following kernel argument.

NOTE: This kernel parameter is ignored in recent linux-sunxi 3.4 kernels, if CMA is enabled in kernel configuration. If CONFIG_CMA=y, ve_size is hardcoded to 80MB in sunxi_cedar kernel module.

For A33 or H3, if you use the kernel from official SDK, you should modify the memory reservation configuration of ion memory allocator. 32 MB seems to be enough for 720p H.264 decoding, and 64MB is enough for 1080p H.264 decoding.

But I don't know what it means to modify the memory reservation configuration of ion memory allocator and how to do that?


Is there any kernel available which can playback hardware accelerated 4k30p video on Orange Pi Lite (H3) and if so, how do I need to go about to setup my Xenial installation to make use of it?

Share this post

Link to post
Share on other sites



HW video decoding on mainline kernel is possible, but in most cases you have to do some kernel patching yourself and use special library which provides VAAPI or use modified ffmpeg libraries. MPEG2 decoding is possible with kernel 5.0 or 5.1 (not sure), basic H264 decoding will be possible with kernel 5.3 and HEVC decoding will probably come with kernel 5.5 (patches already exist). Note that H264 and HEVC codecs are feature incomplete currently. However, I did some improvements for LibreELEC and there most H264 and HEVC videos work. Patches are available on LibreELEC github but are incompatible with VAAPI library, so only option is to use modified ffmpeg.


Regarding memory consumption, please note that with OrangePi Lite you have only 512 MiB of RAM which is a bit low. LibreELEC for that reason doesn't support devices with less than 1 GiB of RAM. Consider following calculations for memory requirements, no matter which kernel you use:

1. Multiple variants of 4K and 1440p resolutions exist, so I'll assume that 4K means 4096x2160 (same as on my LG TV) and 1440p means 2560x1440

2. kernel allocates one XRGB (4 bytes per pixel) buffer for user interface (no matter if you're using window manager or not), so for that you need 4096*2160*4 ~ 34 MiB of CMA memory

3. video is decoded to NV12 or NV21 formats and both take 1.5 byte per pixel, that means 2560*1440*1.5 = 5.27 MiB of CMA memory per single frame

4. worst case for H264 and HEVC is that you need 16 reference frames to properly decode current frame, which means additional 5.27 * 16 ~ 84 MiB of CMA memory

5. VPU needs additional scratch buffers per frame. Size of those buffers depends on codec features used, but for H264 is typically about 1/4th of multiplied width and height, so in worst case (1 + 16)*2560*1440/4  ~ 15 MiB of CMA memory

6. VPU needs some other scratch buffers, but they are small, about 1 MiB in total

7. you also need additional CMA memory for providing encoded data to VPU, but memory consumption for that heavily depends on userspace library/player implementation. Hard to give any estimation, so let's use 20 MiB.


Final estimation for worst case display + VPU CMA consumption for 4K display and 1440p video: 34 + 5.27 + 84 + 15 + 1 + 20 ~ 160 MiB. You also have to consider that other devices may use CMA memory at the same time. In LibreELEC, CMA memory size is set to 256 MiB because so much is needed for decoding 4K videos.


Hopefully that gives you perspective how much memory is needed for H264/HEVC video decoding.


I won't touch (use) 3.4 kernel anymore, but I can help you with patching mainline kernel for better H264 and/or HEVC support and bring up ffmpeg based solutions (that includes mpv), if you want.

Share this post

Link to post
Share on other sites

Thank you for all the input. Really the only thing I want to do on this device is to playback this single video file in an infinite loop on 4k. So I really don't bother how old the kernel is or what other features there are, so long as it plays the video. It doesn't even need sound and there are no other processes running that I'd need. Is there any old (older than 3.4) image available that had hardware acceleration and for which video memory was not hardcoded to 80MB?

Share this post

Link to post
Share on other sites

In the old days, I provided OpenELEC images with 3.4 kernel (https://github.com/jernejsk/OpenELEC-OPi2) and it worked with 4K videos on 1080p display. Sadly, images don't exist anymore and source doesn't build anymore. Be aware, I used CedarX library instead of libvdpau-sunxi.


I don't think I ever make it work with 4K screens, mostly because I didn't have such screen at the time.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

2 2