RK3568评估板应用:视频编码、解码、播放-rk3568处理器属于什么档次

RK3568评估板应用:视频编码、解码、播放-rk3568处理器属于什么档次

一、解码器 demo:mpi_dec_test

解 码 器 demo 为 mpi_dec_test 系 列 程 序 , 包 括 使 用 decode_put_packet 和decode_get_frame 接口的单线程 mpi_dec_test,多线程的 mpi_dec_mt_test 以及多实例的 mpi_dec_multi_test。

以 下 以 Buildroot 平 台 上 的 mpi_dec_test 为 例 进 行 使 用 说 明 。 首 先 直 接 运 行mpi_dec_test,输入输出如下:

[root@RK356X:~]# mpi_dec_test mpp[1043]: mpi_dec_utils: usage: mpi_dec_test [options] mpp[1043]: utils: -i input_file input bitstream file mpp[1043]: utils: -o output_file output bitstream file, mpp[1043]: utils: -c ops_file input operation config file mpp[1043]: utils: -w width the width of input bitstream mpp[1043]: utils: -h height the height of input bitstream mpp[1043]: utils: -t type input stream coding type mpp[1043]: utils: -f format output frame format type mpp[1043]: utils: -d debug debug flag mpp[1043]: utils: -x timeout output timeout interval mpp[1043]: utils: -n frame_number max output frame number mpp[1043]: utils: -s instance_nb number of instances mpp[1043]: mpi: mpp coding type support list: mpp[1043]: mpi: type: dec id 0 coding: mpeg2 id 2 mpp[1043]: mpi: type: dec id 0 coding: mpeg4 id 4 mpp[1043]: mpi: type: dec id 0 coding: h.263 id 3 mpp[1043]: mpi: type: dec id 0 coding: h.264/AVC id 7 mpp[1043]: mpi: type: dec id 0 coding: h.265/HEVC id 16777220 mpp[1043]: mpi: type: dec id 0 coding: vp8 id 9 mpp[1043]: mpi: type: dec id 0 coding: VP9 id 10 mpp[1043]: mpi: type: dec id 0 coding: avs+ id 16777221 mpp[1043]: mpi: type: dec id 0 coding: jpeg id 8 mpp[1043]: mpi: type: enc id 1 coding: h.264/AVC id 7 mpp[1043]: mpi: type: enc id 1 coding: jpeg id 8 mpp[1043]: mpi: type: enc id 1 coding: h265 id 16777220 mpp[1043]: mpi: type: enc id 1 coding: vp8 id 9 [root@RK356X:~]#
<

mpi_dec_test 的命令参数中,输入文件(i),码流类型(t)为强制要求的参数,其他参数如输出文件(o),图像宽度(w)图像高度(h),解码帧数(n)等为可选参数,影响不大。

后面的打印显示了 MPP 库支持的 coding 格式,支持 MPEG2/4,H.263/4/5,VP8/9 的解码,id 后的数字为格式对应的-t 项后的参数值。参数值来源于 OMX 的定义,HEVC 和 AVS 的格式参数值与其他的格式参数值区别较大,需要留意。

以/mnt/sdcard/下的 200frames_count.h264 文件解码 10 帧为例,对 demo 和输出进行说明。运行的命令为:

mpi_dec_test -t 7 -i /mnt/sdcard/200frames_count.h264 -n 10

-t 7 表示是 H.264 码流,-i 表示输入文件,-n 10 表示解码 10 帧,如果一切正常,会得到如下的结果:

[root@RK356X:~]# mpi_dec_test -t 7 -i /mnt/sdcard/200frames_count.h264 -n 10 mpp[1051]: mpi_dec_utils: cmd parse result: mpp[1051]: mpi_dec_utils: input file name: /mnt/sdcard/200frames_count.h264 mpp[1051]: mpi_dec_utils: output file name: mpp[1051]: mpi_dec_utils: config file name: mpp[1051]: mpi_dec_utils: width : 0 mpp[1051]: mpi_dec_utils: height : 0 mpp[1051]: mpi_dec_utils: type : 7 mpp[1051]: mpi_dec_utils: debug flag : 0 mpp[1051]: mpi_dec_utils: max frames : 10 mpp[1051]: mpi_dec_test: mpi_dec_test start mpp[1051]: mpi_dec_test: input file size 87402 mpp[1051]: mpp_info: mpp version: 31814aea author: Herman Chen 2021-09-30 [vepu]: Add offset_x offset_y support for vepu mpp[1051]: mpi_dec_test: 0xc04b520 mpi_dec_test decoder test start w 0 h 0 type 7 mpp[1051]: mpp_rt: NOT found ion allocator mpp[1051]: mpp_rt: found drm allocator mpp[1051]: mpi_dec_test: 0xc04b520 decode_get_frame get info changed found mpp[1051]: mpi_dec_test: 0xc04b520 decoder require buffer w:h [640:480] stride [640:480] buf_size 614400 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 0 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 1 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 2 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 3 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 4 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 5 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 6 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 7 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 8 mpp[1051]: mpi_dec_test: 0xc04b520 decode get frame 9 mpp[1051]: mpi_dec_test: 0xc04b520 reach max frame number 10 mpp[1051]: mpi_dec_test: 0xc04b520 input 2 pkt output 11 frm decode 11 frames mpp[1051]: mpi_dec_test: test success max memory 3.52 MB [root@RK356X:~]#
<

打印的信息里包含了 MPP 库的版本信息:

mpp version: 70d330b2 author: Ding Wei           2021-09-23

mpp_rt 的内核分配器检测信息:

mpp[1051]: mpp_rt: NOT found ion allocator mpp[1051]: mpp_rt: found drm allocator

表示没找到 ion 分配器,找到了 drm 分配器。

mpp[1051]: mpi_dec_test: 0x5583b309e0 decode_get_frame get info changed found

为mpi_dec_test 本身的打印,表示发现 MPP 解码器上报了 info change 事件。

mpp[1051]: mpi_dec_test: 0x5583b309e0 decoder require buffer w:h [640:480] stride [640:480] buf_size 614400

为 mpi_dec_test 本身的打印,表示 MPP 解码器请求的图像内存情况。

mpp[11051]: mpi_dec_test: 0x5583b309e0 decode get frame 0

为 mpi_dec_test 本身打印,表示解码器在正常解码和输出图像。

mpp[1051]: mpi_dec_test: test success max memory 3.52 MB

为 mpi_dec_test 本身打印,表示解码器完成了解码 10 帧的功能。

解码器的 demo 代码具体参见 test/mpi_dec_test.c。

二、编码器 demo:mpi_enc_test

编码器 demo 为 mpi_enc_test 系列程序,包括单线程的 mpi_enc_test,及多实例的mpi_enc_multi_test。

以 下 以 Buildroot 平 台 上 的 mpi_enc_test 为 例 进 行 使 用 说 明 。 首 先 直 接 运 行mpi_enc_test,输出如下:

[root@RK356X:~]# mpi_enc_test mpp[1055]: mpi_enc_utils: usage: mpi_enc_test [options] mpp[1055]: utils: -i input_file input bitstream file mpp[1055]: utils: -o output_file output bitstream file, mpp[1055]: utils: -w width the width of input picture mpp[1055]: utils: -h height the height of input picture mpp[1055]: utils: -f format the format of input picture mpp[1055]: utils: -t type output stream coding type mpp[1055]: utils: -n max frame number max encoding frame number mpp[1055]: utils: -g gop_mode gop reference mode mpp[1055]: utils: -d debug debug flag mpp[1055]: utils: -b bps target:min:max set tareget bps mpp[1055]: utils: -r in/output fps set input and output frame rate mpp[1055]: utils: -l loop count loop encoding times for each frame mpp[1055]: mpi: mpp coding type support list: mpp[1055]: mpi: type: dec id 0 coding: mpeg2 id 2 mpp[1055]: mpi: type: dec id 0 coding: mpeg4 id 4 mpp[1055]: mpi: type: dec id 0 coding: h.263 id 3 mpp[1055]: mpi: type: dec id 0 coding: h.264/AVC id 7 mpp[1055]: mpi: type: dec id 0 coding: h.265/HEVC id 16777220 mpp[1055]: mpi: type: dec id 0 coding: vp8 id 9 mpp[1055]: mpi: type: dec id 0 coding: VP9 id 10 mpp[1055]: mpi: type: dec id 0 coding: avs+ id 16777221 mpp[1055]: mpi: type: dec id 0 coding: jpeg id 8 mpp[1055]: mpi: type: enc id 1 coding: h.264/AVC id 7 mpp[1055]: mpi: type: enc id 1 coding: jpeg id 8 mpp[1055]: mpi: type: enc id 1 coding: h265 id 16777220 mpp[1055]: mpi: type: enc id 1 coding: vp8 id 9 mpp[1055]: mpi: mpp color support list: mpp[1055]: mpi: color: id 0 0x00000 YUV420SP, NV12 mpp[1055]: mpi: color: id 1 0x00001 YUV420SP-10bit mpp[1055]: mpi: color: id 2 0x00002 YUV422SP, NV24 mpp[1055]: mpi: color: id 3 0x00003 YUV422SP-10bit mpp[1055]: mpi: color: id 4 0x00004 YUV420P, I420 mpp[1055]: mpi: color: id 5 0x00005 YUV420SP, NV21 mpp[1055]: mpi: color: id 6 0x00006 YUV422P, 422P mpp[1055]: mpi: color: id 7 0x00007 YUV422SP, NV42 mpp[1055]: mpi: color: id 8 0x00008 YUV422-YUYV, YUY2 mpp[1055]: mpi: color: id 10 0x0000a YUV422-UYVY, UYVY mpp[1055]: mpi: color: id 12 0x0000c YUV400-Y8, Y800 mpp[1055]: mpi: color: id 65536 0x10000 RGB565 mpp[1055]: mpi: color: id 65537 0x10001 BGR565 mpp[1055]: mpi: color: id 65538 0x10002 RGB555 mpp[1055]: mpi: color: id 65539 0x10003 BGR555 mpp[1055]: mpi: color: id 65542 0x10006 RGB888 mpp[1055]: mpi: color: id 65543 0x10007 BGR888 mpp[1055]: mpi: color: id 65546 0x1000a ARGB8888 mpp[1055]: mpi: color: id 65547 0x1000b ABGR8888 mpp[1055]: mpi: color: id 65548 0x1000c BGRA8888 mpp[1055]: mpi: color: id 65549 0x1000d RGBA8888 [root@RK356X:~]#
<

mpi_enc_test 的命令参数中,图像宽度(w)图像高度(h),码流类型(t)为强制要求参数,其他参数如输入文件(i),输出文件(o),编码帧数(n)等为可选参数。如果没有指定输入文件,mpi_enc_test 会生成默认彩条图像进行编码。

以编码/mnt/sdcard 下的 soccer_720x480_30fps.yuv 文件 10 帧为例,对 demo 和输出进行说明。运行的命 令为:

mpi_enc_test -w 640 -h 480 -t 7 \ -i /mnt/sdcard/ir.yuv \ -o /mnt/sdcard/out.h264 -n 10

然后使用 ls –l 查看输出的码流文件:

[root@RK356X:~]# mpi_enc_test -w 640 -h 480 -t 7 -i /mnt/sdcard/ir.yuv -o /mnt/sdcard/out.h264 -n 10 mpp[1079]: mpi_enc_utils: cmd parse result: mpp[1079]: mpi_enc_utils: input file name: /mnt/sdcard/ir.yuv mpp[1079]: mpi_enc_utils: output file name: /mnt/sdcard/out.h264 mpp[1079]: mpi_enc_utils: width : 640 mpp[1079]: mpi_enc_utils: height : 480 mpp[1079]: mpi_enc_utils: format : 0 mpp[1079]: mpi_enc_utils: type : 7 mpp[1079]: mpi_enc_test: mpi_enc_test start mpp[1079]: mpp_rt: NOT found ion allocator mpp[1079]: mpp_rt: found drm allocator mpp[1079]: mpp_info: mpp version: 31814aea author: Herman Chen 2021-09-30 [vepu]: Add offset_x offset_y support for vepu mpp[1079]: mpi_enc_test: 0x19509440 mpi_enc_test encoder test start w 640 h 480 type 7 mpp[1079]: mpp_enc: MPP_ENC_SET_RC_CFG bps 1152000 [72000 : 1224000] fps [30:30] gop 60 mpp[1079]: h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [640:480] stride [640:480] mpp[1079]: mpp_enc: send header for set cfg change input/format mpp[1079]: mpp_enc: mode vbr bps [72000:1152000:1224000] fps fix [30/1] -> fix [30/1] gop i [60] v [0] mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 0 size 65497 qp 29 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 1 size 22195 qp 41 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 2 size 122 qp 31 mpp[1079]: mpi_enc_test: 0x19509440 loop times 1 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 3 size 25087 qp 42 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 4 size 6970 qp 50 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 5 size 122 qp 37 mpp[1079]: mpi_enc_test: 0x19509440 loop times 2 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 6 size 18336 qp 47 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 7 size 6485 qp 50 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 8 size 123 qp 41 mpp[1079]: mpi_enc_test: 0x19509440 loop times 3 mpp[1079]: mpi_enc_test: 0x19509440 encoded frame 9 size 16033 qp 49 mpp[1079]: mpi_enc_test: 0x19509440 encode max 10 frames mpp[1079]: mpi_enc_test: 0x19509440 mpi_enc_test success total frame 10 bps 3863280 [root@RK356X:~]#
<

库以及环境相关的 log 同 mpi_dec_test。

mpp[1079]: mpp_enc: MPP_ENC_SET_RC_CFG bps 1152000 [72000 : 1224000] fps [30:30] gop 60

编码器的码率控制参数配置,目标比特率为 1.2Mbps。

mpp[1079]: mpi_enc_test: 0x55a4f128c0 encoded frame 0 size 65498 qp 29

编码器运行编码一帧,以及输出的一帧码流大小情况。

mpp[1079]: mpi_enc_test: 0x55a4f128c0 mpi_enc_test success total frame 10 bps 3863304

编码器完成了 10 帧的编码,这 10 帧的码率为 3.9Mbps。注,这里编码不足 30帧,码率有偏差,如果编码 30 帧,实际码率为 1.3Mbps。

编码器的 demo 具体代码参见 test/mpi_enc_test.c 。目前编码器 demo 使用的是 enqueue/dequeue 接口模式,后续会进行修改。

三、MPP 实用工具

MPP 提供了一些单元测试用的工具程序,这种程序可以对软硬件平台以及 MPP 库本身进行测试:

mpp_info_test

用于读取和打印 MPP 库的版本信息,在反馈问题时,可以把打印出来信息附上。

[root@RK356X:~]# mpp_info_test mpp[1082]: mpp_info_test: normal version log: mpp[1082]: mpp_info: mpp version: 31814aea author: Herman Chen 2021-09-30 [vepu]: Add offset_x offset_y support for vepu mpp[1082]: mpp_info_test: history version log: mpp[1082]: mpp_info: mpp version history 10: mpp[1082]: mpp_info: 31814aea author: Herman Chen 2021-09-30 [vepu]: Add offset_x offset_y support for vepu (HEAD, m/linux) mpp[1082]: mpp_info: 70d330b2 author: Ding Wei 2021-09-23 [vproc]: missing set mode, when 2 in 1 out case mpp[1082]: mpp_info: 6cc2ef5f author: Herman Chen 2021-09-17 [mpp_list]: Add list_mode and list_move_tail mpp[1082]: mpp_info: c5cd650f author: Herman Chen 2021-09-17 [mpi]: Add start / stop / pause / resume ctrl cmd mpp[1082]: mpp_info: db487e5d author: Herman Chen 2021-09-17 [mpp_dec]: Add MPP_DEC_GET_CFG cmd implement mpp[1082]: mpp_info: 8aa7415f author: Yandong Lin 2021-09-17 [hal_h264d]: Add h264d hw_type config implement mpp[1082]: mpp_info: 3364f770 author: Johnson Ding 2021-09-17 [vepu541]: Fix hfill and wfill config mpp[1082]: mpp_info: 43620922 author: Herman Chen 2021-09-15 [mpp]: Add jpeg hw_type config implement mpp[1082]: mpp_info: 6eac8bf4 author: Herman Chen 2021-09-15 [mpp_dec_cfg]: Add type, coding and hw_type config mpp[1082]: mpp_info: baf1efa9 author: Yandong Lin 2021-09-14 [mpp_dec_vproc]: fix err frame output issue [root@RK356X:~]#
<
四、gst-play 视频播放

单窗口视频播放:

gst-play-1.0 /mnt/sdcard/SampleVideo_1280x720_5mb.mp4

多窗口视频播放: 先找到多窗口的脚本再执行:

cd rockchip_test/video/ sh test_gst_multivideo.sh test #pro,有可能名称不是这个,可能是 test_multivideo.sh killall videowidget etc/init.d/S50launcher stop etc/init.d/S50launcher start五、qplayer 编译

编译之前执行命令:

~/rk3568/rk356x_linux_release$ source envsetup.sh … Which would you like? [0]: 69

编译 qplayer:

~/rk3568/rk356x_linux_release$ make qplayer umask 0022 && make -C /home/rk3568/rk356x_linux_release/buildroot O=/home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568 qplayer /usr/bin/make -j1 O=/home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568 HOSTCC=”/usr/bin/gcc” HOSTCXX=”/usr/bin/g++” silentoldconfig GEN /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/Makefile

重新编译 qplayer:

~/rk3568/rk356x_linux_release$ make qplayer-rebuild umask 0022 && make -C /home/rk3568/rk356x_linux_release/buildroot O=/home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568 qplayer-rebuild rm -f /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ rsynced rm -f /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ staging_installed rm -f /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ target_installed rm -f /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ images_installed rm -f /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ host_installed touch /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ built || true rm -f /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/.stamp_ built >>> qplayer 1.0 Syncing from source dir /home/rk3568/rk356x_linux_release/buildroot/../app/qplayer rsync -au –chmod=u=rwX,go=rX –exclude .svn –exclude .git –exclude .hg –exclude .bzr –exclude CVS /home/rk3568/rk356x_linux_release/buildroot/../app/qplayer/ /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0 M qplayer.cpp WARN: /home/rk3568/rk356x_linux_release/buildroot/../app/qplayer is dirty! >>> qplayer 1.0 Building PATH=”/home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/host/bin:/home/rk35 68/rk356x_linux_release/buildroot/output/rockchip_rk3568/host/sbin:/home/.local/bin:/usr/loc al/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin” /usr/bin/make -j9 -C /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0 make[2]: Nothing to be done for first. >>> qplayer 1.0 Installing to target mkdir -p /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/target/usr/share/applicat ions /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/target/usr/share/icon /usr/bin/install -D -m 0644 /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/icon_pl ayer.png /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/target/usr/share/icon/ /usr/bin/install -D -m 0755 /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/qplayer /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/target/usr/bin/ /usr/bin/install -D -m 0755 /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0/qplayer. desktop /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/target/usr/share/applicat ions/
<

 删除 qplayer:

~/rk3568/rk356x_linux_release$ make qplayer-dirclean umask 0022 && make -C /home/rk3568/rk356x_linux_release/buildroot O=/home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568 qplayer-dirclean rm -Rf /home/rk3568/rk356x_linux_release/buildroot/output/rockchip_rk3568/build/qplayer-1.0

Buildroot 固 件 已 经 默 认 安 装 了 qplayer , 播 放 器 默 认 播 放/oem/SampleVideo_1280x720_5mb.mp4 文件,可以从/mnt/sdcard 里面拷贝到/oem 目录下:

cp /mnt/sdcard/SampleVideo_1280x720_5mb.mp4 /oem/

在桌面上点击 qplayer 图标即可运行,在桌面上也可点击 multivideoplayer 图标运行。

免责声明:文章内容来自互联网,本站不对其真实性负责,也不承担任何法律责任,如有侵权等情况,请与本站联系删除。
转载请注明出处:RK3568评估板应用:视频编码、解码、播放-rk3568处理器属于什么档次 https://www.yhzz.com.cn/a/9784.html

上一篇 2023-04-20 18:54:31
下一篇 2023-04-20 18:57:20

相关推荐

联系云恒

在线留言: 我要留言
客服热线:400-600-0310
工作时间:周一至周六,08:30-17:30,节假日休息。