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
相关推荐
TeYiToKu35 分钟前
笔记整理—linux驱动开发部分(9)framebuffer驱动框架
linux·c语言·arm开发·驱动开发·笔记·嵌入式硬件·arm
dsywws37 分钟前
Linux学习笔记之时间日期和查找和解压缩指令
linux·笔记·学习
yeyuningzi1 小时前
Debian 12环境里部署nginx步骤记录
linux·运维·服务器
上辈子杀猪这辈子学IT1 小时前
【Zookeeper集群搭建】安装zookeeper、zookeeper集群配置、zookeeper启动与关闭、zookeeper的shell命令操作
linux·hadoop·zookeeper·centos·debian
minihuabei1 小时前
linux centos 安装redis
linux·redis·centos
lldhsds2 小时前
书生大模型实战营第四期-入门岛-1. Linux前置基础
linux
wowocpp2 小时前
ubuntu 22.04 硬件配置 查看 显卡
linux·运维·ubuntu
山河君3 小时前
ubuntu使用DeepSpeech进行语音识别(包含交叉编译)
linux·ubuntu·语音识别
鹏大师运维3 小时前
【功能介绍】信创终端系统上各WPS版本的授权差异
linux·wps·授权·麒麟·国产操作系统·1024程序员节·统信uos
筱源源3 小时前
Elasticsearch-linux环境部署
linux·elasticsearch