This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MPP: low level API for video codecs (VPU1 and HEVC)
#1
Information 
Hello.

I prepared and tested some application to test low level access video decoders (attached) for everyone interested Big Grin

Decoder results first (and @end) witch CPU load <20%:
Code:
                   hevc(h265)   h264
2k (1080p, FHD)    240 FPS      69 FPS
4k (2160p, UHD)     71 FPS      32 FPS


This demo is for lowlevel API rockchip MPI/MPP with zero copy output to DRM and display as DRM FB overlay plane with ASUS Tinker (and other) without Xserver directly from console. MPP is low level API for ffmpeg/OpenMax/gstreamer/libva.

TinkerBoard/RK3288 has two video coprocessors VPU1 (for h264 and other decoders and encoders) (/dev/vpu-service) and HEVC_DEC (for HEVC decoder) (/dev/hevc-service).
MPP is https://github.com/rockchip-linux/mpp works on [https://github.com/rockchip-linux/mpp/bl...ard/RK3288[/url].
This demo uses MPP buffers (frames) "Mode 3: Pure external mode" with zero copy DRM buffers. DRM (/dev/dri/card0) is used with some problems (see patch).
DRM buffers works in "Commit flow group" DRM buffes mode.
The demo use "Split standard mode". Warning - do not use "advanced mode" works only with MJPEG now.

0) prepare board / download os

I used ASUS Tinker Board with TinkerOS_Debian V1.4 (https://www.asus.com/uk/Single-board-Com..._Download/).
Many build dependencies like autoconf automake libdrm-dev libtool cmake git ...

1) build MPP not needed in most newer distributions, already installed

Code:
# git clone https://github.com/rockchip-linux/mpp.git
# cd mpp
# ### partch not neede now ## git apply ../mpp_for_tinkeros_drm.patch
# cmake -DRKPLATFORM=ON -DHAVE_DRM=ON -DCMAKE_BUILD_TYPE=Debug .
# make -j4
# make install

(installed in /usr/local/...)

2) build application (mpi_dec)

Code:
make

3) prepare h264 and/or hevc(h265) raw streams

Code:
ffmpeg -i bbb_sunflower_2160p_30fps_normal.mp4  -c:v copy -an -bsf:v h264_mp4toannexb 4k.h264
ffmpeg -i bbb-1920x1080-cfg06.mkv -c:v copy -an -bsf:v hevc_mp4toannexb 2k.hevc
ffmpeg -i bbb-3840x2160-cfg02.mkv -c:v copy -an -bsf:v hevc_mp4toannexb 4k.hevc

4) test it

Code:
./mpi_dec
./mpi_dec "filename" "type"
./mpi_dec 4k.h264 7
./mpi_dec 2k.hevc 16777220

NOTES:

CPU:

- RK CPU power management is active (interactive mode) and CPU very slow reacts to load it leads to drops frame due to high CPU loads peaks.
  SEE:
     grep ''  /sys/devices/system/cpu/cpufreq/policy0/*
  TEST:
     echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
     echo 216000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
     ./mpi_dec 4k.hevc 16777220
  and compute frame rate "FRAME 57157.321400 first 43613795 previous   1253 frid 2024" == frameid/first(usec) = 2024/43.613795 = 46 FPS
 
RESULTS (4k.hevc):
Code:
   freqency GHz   0.1   0.2   0.4   0.8   1.0   1.2
   CPU load %     <65   <60   <30   <20   <16   <14
   FPS             36    46    62    68    71    72
   TEMPERATURE C  ~55               ~60         ~62

   
Be aware of CPU power management, it has negative impact on FPS (scaling_min_freq is 0.1GHz by default).
Fix CPU to 0.4GHz or higher like:
     echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
     echo 1008000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
OR:
     echo interactive > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
     echo 1008000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq

DECODER:

- decoder running at maximum realtime speed (eg. no clock synchronization from sources) and DRM FB displays at vsync rate (eg. some decoded frames are dropped/skipped).

RESULTS (with fixed 1GHz CPU):
Code:
                   hevc(h265)   h264
2k (1080p, FHD)    240 FPS      69 FPS
4k (2160p, UHD)     71 FPS      32 FPS


Happy hacking,

M.C>


Attached Files
.tar   mpp_dec_20170329b.tar (Size: 26 KB / Downloads: 54)
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#2
Thank you for your instructions ! Will give a try when I have time.
Reply
#3
Hi CP,

I tried to run this script - but I am having trouble compiling ffmpeg on Tinker. Sad  
I use this script on Pi3 without any problem:
https://retroresolution.com/compiling-ff...ne-script/

How do you compile the latest ffmpeg with hardware GPU encoder/decoder enabled?
Reply
#4
(03-30-2017, 06:40 AM)hblanke Wrote: I tried to run this script - but I am having trouble compiling ffmpeg on Tinker. Sad  
How do you compile the latest ffmpeg with hardware GPU encoder/decoder enabled?

MPP is low level API and someone must write bridge to upper API (ffmpeg/OpenMax/gstreamer/libva).
The usage ffmpeg in this thread is only for prepare h264/hevc raw streams (eg. copy data from multiplex without decoding or any need of rk-based acceleration) simple get it from "apt-get install ffmpeg".

As I known only one bridge is developed by rockchip for now - gstreamer - https://github.com/rockchip-linux/gstreamer-rockchip (requires gstreamer1.0 version >=1.8.2. There is only 1.4.4 in debian "jessie". Debian testing("stretch") is needed with version 1.10.4).
All players that uses gstreamer should work (eg. not mplayer,vlcplayer,ffmpeg,omxplay). There is "Rockchip Video Player" ( vpu -> mpp -> gstreamer-rk -> qtmultimedia -> player ) see repository https://github.com/rockchip-linux/rk-qt-video

(other repositories/API are deprecated https://github.com/rockchip-linux/libvdpau-rockchip and https://github.com/rockchip-linux/rockchip-va-driver)
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#5
Currently trying to do real-time h264 decoding and encoding with ffmpeg. Do you know any bridge to ffmpeg?
Are there no supported hardware decoders and encoders like with the Raspberry where you have MMAL and OpenMax?
Reply
#6
(03-30-2017, 12:37 PM)Arnstein Wrote: Currently trying to do real-time h264 decoding and encoding with ffmpeg. Do you know any bridge to ffmpeg?
Are there no supported hardware decoders and encoders like with the Raspberry where you have MMAL and OpenMax?

As you see https://trac.ffmpeg.org/wiki/HWAccelIntro there is no bridge to MPP/MPI supported now. Ask ffmpeg forums or you can write it or sponsor some opensource programmer to write it (like for MMAL https://github.com/FFmpeg/FFmpeg/blob/ma.../mmaldec.c).

The MPP/MPI seems to be prepared for OpenMAX infrastructure and there is small probability that RockChip (or some softwarehouse that uses RockChip) can do it because OpenMAX is standardized (https://www.khronos.org/openmax/).

MPP API is there for many years and is still actively developed. You can try ask directly authors/maintainers of this code for other opinion (http://opensource.rock-chips.com/wiki_Main_Page or https://github.com/rockchip-linux/mpp/gr...ntributors).


OR

You can use ffmpeg as parser/multiplexer/demultiplexer and learn new low level MPP/MPI API as decoder/encoder (I learn it in few days). There are few examples/tests in MPP (without graphical output) https://github.com/rockchip-linux/mpp/tree/develop/test . I recommend start with "for_linux" branch ( https://github.com/rockchip-linux/mpp/tree/for_linux ) or you can download/build packages directly or build docker (see https://github.com/rockchip-linux/docker...erfile#L45 ).



There is far more supported encoders/decoders than RPI. TinkerBoard (rk3288) supports (without need to install license) but not all tested/supported with MPP due to https://github.com/rockchip-linux/mpp/bl...me.txt#L27


Code:
mpi: type: dec id 0 coding: mpeg2            id 2
mpi: type: dec id 0 coding: mpeg4            id 4
mpi: type: dec id 0 coding: h.263            id 3
mpi: type: dec id 0 coding: h.264/AVC        id 7
mpi: type: dec id 0 coding: h.265/HEVC       id 16777220
mpi: type: dec id 0 coding: vp8              id 9
mpi: type: dec id 0 coding: VP9              id 10
mpi: type: dec id 0 coding: avs+             id 16777221
mpi: type: dec id 0 coding: jpeg             id 8

mpi: type: enc id 1 coding: h.264/AVC        id 7
mpi: type: enc id 1 coding: jpeg             id 8


For full specification read TRM from page 14 http://rockchip.fr/Rockchip%20RK3288%20T...ontrol.pdf
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply
#7
Thank you very much!
Reply
#8
@Arnstein - you helped me compile ffmpeg by taking mmal and omx out of the configuration. Now ffmpeg works well on my Tinker board.
However, now I am kind of disappointed as I cannot use h264_omx on Tinkerboard anymore and the decoding/encoding is really limited for real time.

What alternatives are there to have increased performance ?
Reply
#9
(03-31-2017, 07:44 AM)hblanken Wrote: @Arnstein - you helped me compile ffmpeg by taking mmal and omx out of the configuration. Now ffmpeg works well on my Tinker board.
However, now I am kind of disappointed as I cannot use h264_omx on Tinkerboard anymore and the decoding/encoding is really limited for real time.

What alternatives are there to have increased performance ?

You can go for an Yocto OS. Check my post in software section. The yocto distribution does real justice for me as the VPU, GPU, WiFi are all functional but remember yocto is a bit low level and it is expected you will develop applications to run on the OS rather than it being a kodi type box!! It really is a good board and just needs a bit of uplift from the community for software support. Rockchip team are helpful which is a good sign.
Reply
#10
(03-30-2017, 02:19 PM)mcerveny Wrote:
(03-30-2017, 12:37 PM)Arnstein Wrote: Currently trying to do real-time h264 decoding and encoding with ffmpeg. Do you know any bridge to ffmpeg?
Are there no supported hardware decoders and encoders like with the Raspberry where you have MMAL and OpenMax?

As you see https://trac.ffmpeg.org/wiki/HWAccelIntro there is no bridge to MPP/MPI supported now. Ask ffmpeg forums or you can write it or sponsor some opensource programmer to write it (like for MMAL https://github.com/FFmpeg/FFmpeg/blob/ma.../mmaldec.c).

I think that FFmpeg is done (or work in progress) for now (decoder only):
https://github.com/LongChair/FFmpeg/tree/rockchip (try with --enable-rkmpp)

Also LibreELEC with MPV player (mplayer):
https://github.com/LongChair/LibreELEC.t...inkerboard
https://github.com/LongChair/mpv/tree/rockchip (try with --enable-rkmpp and other see https://github.com/LongChair/LibreELEC.t...ckages/mpv)
I left this community in Aug 2017 due to ASUS bad product quality and ASUS community support that did not match my expectation.  Sad
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)