测试环境:
一、编译rockit/mpi
1. 准备工作
将 rockit
源代码复制到开发板的 /home/neardi
目录:
cp -r SDK/external/rockit /home/neardi/
2. 修改 CMakeLists.txt
为了避免在编译过程中出现错误,需要替换 rockit/mpi/CMakeLists.txt 文件,内容如下:
cmake_minimum_required(VERSION 2.8.8)
project(rockit)
include_directories(sdk/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
set(ROCKIT_DEP_COMMON_LIBS
${CMAKE_CURRENT_LIST_DIR}/../lib/lib64/librockit.so
)
set(ROCKIT_FILE_LIBS
${ROCKIT_DEP_COMMON_LIBS}
${CMAKE_CURRENT_LIST_DIR}/sdk/lib64/libgraphic_lsf.so
${CMAKE_CURRENT_LIST_DIR}/sdk/lib64/librkgfx_avs.so
)
set(ROCKIT_DUMPSYS_FILE ${CMAKE_CURRENT_LIST_DIR}/example/bin/bin64/dumpsys)
add_subdirectory(sdk)
add_subdirectory(example)
注意: 必须添加 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread"),否则可能会遇到 undefined reference to symbol 'pthread_create@@GLIBC_2.17' 的链接错误。
3. 编译步骤
neardi@LPA3588:~/rockit/mpi$ cmake .
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build WITH linker libs for Linux
-- Configuring done
-- Generating done
-- Build files have been written to: /home/neardi/rockit/mpi
neardi@LPA3588:~/sdk/rockit/mpi$ make -j8
Scanning dependencies of target rt_test_comm
[ 3%] Building CXX object example/common/CMakeFiles/rt_test_comm.dir/test_comm_imgproc.cpp.o
[ 5%] Building CXX object example/common/CMakeFiles/rt_test_comm.dir/test_comm_sys.cpp.o
[ 7%] Building CXX object example/common/CMakeFiles/rt_test_comm.dir/test_comm_argparse.cpp.o
......
[ 94%] Built target rk_mpi_adec_test
[ 96%] Building CXX object example/mod/CMakeFiles/rk_mpi_rgn_test.dir/test_mpi_rgn.cpp.o
[ 98%] Linking CXX executable rk_mpi_tde_test
[100%] Linking CXX executable rk_mpi_rgn_test
[100%] Built target rk_mpi_tde_test
[100%] Built target rk_mpi_rgn_test
将会生成多个目标文件,编译完成后,生成的文件位于 rockit/mpi/example
目录下。
4. 测试编译结果
在 example/mod
目录下执行测试:
cd /home/neardi/rockit/mpi/example/mod
./rk_mpi_vi_test -t 1 -w 1920 -h 1080 -m 1 -n /dev/video22
测试输出示例,开发板重新打开一个终端,执行 journalctl -f
查看日志:
vi 09:54:03-390 {main :1381} test running enter!
vi 09:54:03-390 {main :1487} test running enter ctx->aEntityName=/dev/video22!
cmd parse result:
output file open : 0
yuv output file name : /
enc0 output file path : //
enc1 output file path : //
loop count : 100
enMode : 1
dev : 0
pipe : 0
channel : 1
width : 1920
height : 1080
enCompressMode : 0
enMemoryType : 1
aEntityName : /dev/video22
.....
vi 09:54:53-143 {test_vi_bind_venc_:999} chn:0, loopCount:97 enc->seq:97 wd:69 pts=1758285506 delay=63061us
vi 09:54:53-200 {test_vi_bind_venc_:999} chn:0, loopCount:98 enc->seq:98 wd:69 pts=1758345853 delay=58999us
RTScheduler 09:54:53-264 {pause :332} calling pause
vi 09:54:53-264 {test_vi_bind_venc_:999} chn:0, loopCount:99 enc->seq:99 wd:69 pts=1758406155 delay=63416us
RTScheduler 09:54:53-275 {stop :371} calling stop
RTDeviceV4L2 09:54:53-275 {invoke :975} unsupport command interrupt
RTScheduler 09:54:53-319 {checkScheduleDone :221} quit scheduler, error/limit is found!
RTScheduler 09:54:53-320 {quit :393} Signaling scheduler termination
RTDeviceV4L2 09:54:53-320 {invoke :975} unsupport command interrupt
vi 09:54:53-370 {test_vi_bind_venc_:1024} RK_MPI_VI_DisableChn 0
RTScheduler 09:54:53-370 {pause :332} calling pause
vi 09:54:53-370 {test_vi_bind_venc_:1031} destroy enc chn:0
RTScheduler 09:54:53-370 {stop :371} calling stop
RTScheduler 09:54:53-370 {checkScheduleDone :221} quit scheduler, error/limit is found!
RTScheduler 09:54:53-370 {quit :393} Signaling scheduler termination
vi 09:54:53-392 {test_vi_bind_venc_:1040} RK_MPI_VI_DisableDev 0
vi 09:54:53-392 {main :1526} test running exit:0
RKSockServer 09:54:53-466 {start :163} accept failed
rk-debug call distortionByGpuDeinit mInitSucee=1,threadId=547729088944
rk-debug GpuManage.refcnt=2
rk-debug call distortionByGpuDeinit mInitSucee=1,threadId=547608326576
rk-debug GpuManage.refcnt=1
rk-debug call destroyEGL
RTAllocatorStore 09:54:53-509 {commFinalize :200} release common allocator[0x55afa66e30]
如果出现缺少库的提示,请手动将编译出的 .so 文件复制到 /usr/lib64
目录。
5. 查看使用手册
随SDK一起申请的文档查看:Linux->Multimedia->Rockchip_User_Guide_Linux_Rockit_CN.pdf
,也可在百度网盘下载。
二、编译mpp
1. 准备工作
将 mpp
源代码复制到开发板的 /home/neardi
目录:
cp -r SDK/external/mpp /home/neardi/
2. 编译步骤
neardi@LPA3588:~/mpp$ cmake .
-- cmake version 3.16.3
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
......
-- compile without drm support
-- Configuring done
-- Generating done
-- Build files have been written to: /home/neardi/mpp
neardi@LPA3588:~/mpp$ make -j8
Scanning dependencies of target vproc_iep2
Scanning dependencies of target vproc_iep
Scanning dependencies of target hal_dummy
Scanning dependencies of target mpp_rc
Scanning dependencies of target vdpu34x_com
Scanning dependencies of target codec_dummy_dec
Scanning dependencies of target osal
Scanning dependencies of target codec_dummy_enc
[ 1%] Building C object mpp/vproc/iep2/CMakeFiles/vproc_iep2.dir/iep2.c.o
[ 1%] Building C object mpp/codec/enc/dummy/CMakeFiles/codec_dummy_enc.dir/dummy_enc_api.c.o
[ 1%] Building CXX object mpp/vproc/iep/CMakeFiles/vproc_iep.dir/iep.cpp.o
[ 1%] Building CXX object mpp/codec/CMakeFiles/mpp_rc.dir/mpp_rc.cpp.o
[ 2%] Building C object mpp/codec/dec/dummy/CMakeFiles/codec_dummy_dec.dir/dummy_dec_api.c.o
.....
[ 97%] Built target mpp_info_test
[ 97%] Linking CXX executable mpi_enc_test
[ 98%] Building C object test/CMakeFiles/mpi_dec_mt_test.dir/mpp_event_trigger.c.o
[ 98%] Linking CXX executable mpi_dec_test
[ 98%] Linking CXX executable mpi_rc2_test
[ 98%] Building C object test/CMakeFiles/mpi_dec_multi_test.dir/mpp_parse_cfg.c.o
[ 98%] Building CXX object mpp/legacy/CMakeFiles/rockchip_vpu.dir/rk_list.cpp.o
[ 99%] Building CXX object mpp/legacy/CMakeFiles/rockchip_vpu.dir/ppOp.cpp.o
[ 99%] Built target mpi_enc_test
[100%] Building C object test/CMakeFiles/mpi_enc_mt_test.dir/mpp_event_trigger.c.o
[100%] Building C object test/CMakeFiles/mpi_dec_mt_test.dir/mpp_parse_cfg.c.o
[100%] Building C object test/CMakeFiles/mpi_enc_mt_test.dir/mpp_parse_cfg.c.o
[100%] Building CXX object mpp/legacy/CMakeFiles/rockchip_vpu.dir/__/mpp_info.cpp.o
[100%] Built target mpi_rc2_test
[100%] Linking CXX executable mpi_dec_mt_test
[100%] Linking CXX executable mpi_dec_multi_test
[100%] Linking CXX executable mpi_enc_mt_test
[100%] Built target mpi_dec_test
[100%] Linking CXX shared library librockchip_vpu.so
[100%] Built target mpi_dec_mt_test
[100%] Built target mpi_dec_multi_test
[100%] Built target mpi_enc_mt_test
[100%] Built target rockchip_vpu
将会生成多个目标文件,编译完成后,生成的文件位于 mpp/test
目录下。
4. 测试编译结果
在 example/mod
目录下执行测试:
cd /home/neardi/mpp/test
./mpi_enc_test -i test.yuv -t 7 -n 200 -o encode.h264 -w 1280 -h 720 -fps 30
测试输出示例,开发板重新打开一个终端,执行 journalctl -f
查看日志:
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: cmd parse result:
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: input file name: test.yuv
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: output file name: encode.h264
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: width : 1280
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: height : 720
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: format : 0
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_utils: type : 7
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: /usr/bin/mpi_enc_test start
Oct 11 12:46:25 LPA3588 mpp[12464]: mpp_info: mpp version: d63affb7 author: Grey Li 2022-10-20 [jpegd]: fix overflow in copy mode
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: 0x7f8c001f40 encoder test start w 1280 h 720 type 7
Oct 11 12:46:25 LPA3588 mpp[12464]: mpp_enc: MPP_ENC_SET_RC_CFG bps 3456000 [216000 : 3672000] fps [30:30] gop 60
Oct 11 12:46:25 LPA3588 mpp[12464]: mpp_enc: mode vbr bps [216000:3456000:3672000] fps fix [30/1] -> fix [30/1] gop i [60] v [0]
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 0 size 188563 qp 33
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 1 size 48665 qp 36
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: chn 0 loop times 1
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 2 size 71619 qp 46
Oct 11 12:46:25 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 3 size 10123 qp 47
......
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 loop times 98
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 196 size 51844 qp 50
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 197 size 7036 qp 50
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 loop times 99
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 198 size 51844 qp 50
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encoded frame 199 size 7036 qp 50
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: chn 0 encode 200 frames time 1746 ms delay 5 ms fps 114.54 bps 7363508
Oct 11 12:46:27 LPA3588 mpp[12464]: mpi_enc_test: /usr/bin/mpi_enc_test average frame rate 114.54
5. 查看使用手册
随SDK一起申请的文档查看:Linux->Multimedia->Rockchip_Developer_Guide_MPP_CN.pdf
,也可在百度网盘下载。