RK3566 MPPJPEG 编码初入门 mpi_enc_test

一、导览

本文介绍了使用rk mpp 库的demo 程序,对一帧 nv12的yuv 图像进行jpeg 编码,最后输出jpeg图像的过程。作为学习mpp 入门的教程。

rk mpp 的源码仓库地址是:https://github.com/rockchip-linux/mpp/

参考文档在:https://github.com/rockchip-linux/mpp/blob/develop/doc/Rockchip_Developer_Guide_MPP_CN.md

二、编译程序

下载源码后,mpp 框架是使用CMake 进行编译的,首先需要配置好交叉编译工具,我是在linux 平台,aarch64 架构下使用的,所以编辑 mpp/build/linux/aarch64/arm.linux.cross.cmake

CMAKE_C_COMPILER、CMAKE_CXX_COMPILER 设置成项目所使用的工具链

然后执行 make-Makefiles.bash ,将自动调用cmake 生成makefile 文件,最后直接make 就能编译整个mpp 以及demo

编译生成的文件如下:

  • librockchip_mpp.so:mpp的运行时动态库
  • test/* :test 目录下存放所有的demo app

三、执行

首先将librockchip_mpp.so 添加到链接路径,准备好一张yuv图像,以及mpi_enc_test 程序

bash 复制代码
# 将ov5648.yuv 编码成jpeg图像,-t 表示编码类型为jpeg
root@RK356X:/mnt/nfs/output# ./mpi_enc_test -w 800 -h 600 -t 8 -i ./ov5648.yuv -o tmp.jpeg

demo输出的log需要通过 /var/sys/message 查看:

bash 复制代码
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: cmd parse result:
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: input  file name: ./ov5648.yuv
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: output file name: tmp.jpeg
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: width      : 800
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: height     : 600
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: format     : 0
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_utils: type       : 8
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_test: ./mpi_enc_test start
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_test: jpege default encode only one frame. Use -n [num] for rc case
Dec  9 03:02:08 RK356X user.info mpp[392]: mpp_info: mpp version: unknown mpp version for missing VCS info
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_test: 0x7fac001e20 encoder test start w 800 h 600 type 8
Dec  9 03:02:08 RK356X user.info mpp[392]: mpp_enc: MPP_ENC_SET_RC_CFG bps 1800000 [112500 : 1912500] fps [30:30] gop 60
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_test: chn 0 encoded frame 0    size 41650  
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_test: chn 0 encode 1 frames time 11 ms delay   6 ms fps 89.27 bps 9996000
Dec  9 03:02:08 RK356X user.info mpp[392]: mpi_enc_test: ./mpi_enc_test average frame rate 89.27

可以看到编码了一帧图像,耗时11ms+6ms

直接运行/mpi_enc_test可以打印help信息:

bash 复制代码
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: usage: ./mpi_enc_test [options]
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -i       input_file         input frame file                      
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -o       output_file        output encoded bitstream file         
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -w       width              the width of input picture            
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -h       height             the height of input picture           
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -hstride hor_stride         the horizontal stride of input picture
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -vstride ver_stride         the vertical stride of input picture  
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -f       format             the format of input picture           
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -t       type               output stream coding type             
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -tsrc    source type        input file source coding type         
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -n       max frame number   max encoding frame number             
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -g       gop reference mode gop_mode:gop_len:vi_len               
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -rc      rate control mode  set rc_mode                           
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -bps     bps target:min:max set tareget/min/max bps and rc_mode   
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -fps     in/output fps      set input and output frame rate       
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -qc      quality control    set qp_init/min/max/min_i/max_i       
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -s       instance_nb        number of instances                   
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -v       trace option       q - quiet f - show fps                
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -l       loop count         loop encoding times for each frame    
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -ini     ini file           encoder extra ini config file         
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi_enc_utils: -slt     slt file           slt verify data file                  
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: mpp coding type support list:
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: mpeg2            id 2
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: mpeg4            id 4
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: h.263            id 3
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: h.264/AVC        id 7
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: h.265/HEVC       id 16777220
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: vp8              id 9
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: VP9              id 10
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: avs+             id 16777221
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: jpeg             id 8
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: dec id 0 coding: av1              id 16777224
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: enc id 1 coding: h.264/AVC        id 7
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: enc id 1 coding: jpeg             id 8
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: enc id 1 coding: h265             id 16777220
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: type: enc id 1 coding: vp8              id 9
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: mpp color support list:
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 0     0x00000 YUV420SP,      NV12
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 1     0x00001 YUV420SP-10bit
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 2     0x00002 YUV422SP,      NV24
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 3     0x00003 YUV422SP-10bit
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 4     0x00004 YUV420P,       I420
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 5     0x00005 YUV420SP,      NV21
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 6     0x00006 YUV422P,       422P
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 7     0x00007 YUV422SP,      NV42
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 8     0x00008 YUV422-YUYV,   YUY2
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 10    0x0000a YUV422-UYVY,   UYVY
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 12    0x0000c YUV400-Y8,     Y800
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 15    0x0000f YUV444SP
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 16    0x00010 YUV444P
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65536 0x10000 RGB565
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65537 0x10001 BGR565
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65538 0x10002 RGB555
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65539 0x10003 BGR555
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65542 0x10006 RGB888
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65543 0x10007 BGR888
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65546 0x1000a ARGB8888
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65547 0x1000b ABGR8888
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65548 0x1000c BGRA8888
Dec  9 03:06:05 RK356X user.info mpp[399]: mpi: color: id 65549 0x1000d RGBA8888
相关推荐
内核程序员kevin1 小时前
TCP Listen 队列详解与优化指南
linux·网络·tcp/ip
朝九晚五ฺ5 小时前
【Linux探索学习】第十四弹——进程优先级:深入理解操作系统中的进程优先级
linux·运维·学习
自由的dream6 小时前
Linux的桌面
linux
xiaozhiwise6 小时前
Makefile 之 自动化变量
linux
意疏8 小时前
【Linux 篇】Docker 的容器之海与镜像之岛:于 Linux 系统内探索容器化的奇妙航行
linux·docker
BLEACH-heiqiyihu8 小时前
RedHat7—Linux中kickstart自动安装脚本制作
linux·运维·服务器
一只爱撸猫的程序猿8 小时前
一个简单的Linux 服务器性能优化案例
linux·mysql·nginx
我的K840910 小时前
Flink整合Hudi及使用
linux·服务器·flink
19004310 小时前
linux6:常见命令介绍
linux·运维·服务器