mpp编译,测试代码运行

mpp编译,运行测试案例

使用的mpp源码git 提交id为 a26d0fad 2020.5.29 10:43:40 版本,toybrick tb-96ai 的板子;主要介绍了再接在开发板编译mpp源码的过程。
规避了:
自己编译生成的测试程序如何正确运行:
./mpi_enc_test: symbol lookup error: ./mpi_enc_test: undefine symbol: mpp_spinlock_unlock

RK3288 mpp硬件解码报错VPU_IOC_SET_REG failed。

直接放在板子上编译,非交叉编译

cd build/linux/aarch64

make-Makefiles.bash 讲解

#!/bin/bash
# Run this from within a bash shell

set +e

MPP_PWD=`pwd`
MPP_TOP=${MPP_PWD}/../../..

# toolchain detection
check_cmd(){
    "$@" >> /dev/null 2>&1
}
check_system_arm_linux_gcc(){
    check_cmd aarch64-linux-gnu-gcc -v
}

check_system_arm_linux_gcc
if [ $? -eq 127 ];then
    MPP_TOOLCHAIN=/usr/bin
    export PATH=$PATH:${MPP_TOOLCHAIN}
fi

# generate Makefile
cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_TOOLCHAIN_FILE=./arm.linux.cross.cmake \
      -DRKPLATFORM=ON \
      -DHAVE_DRM=ON \
      -G "Unix Makefiles" \
      ${MPP_TOP}

  1. set +e:禁用脚本中的错误检查,意味着脚本将继续执行,即使有某些命令失败。

  2. MPP_PWD=pwd``:获取当前目录的绝对路径,并将其存储在变量MPP_PWD中。

  3. MPP_TOP=${MPP_PWD}/../../..:根据当前目录的绝对路径,定义变量MPP_TOP为当前目录的上上级目录路径。

  4. check_cmd()函数:检查给定的命令是否存在。它通过将命令执行的输出重定向到/dev/null来静默输出,并忽略任何错误。这个函数在后面用于检查aarch64-linux-gnu-gcc命令是否存在。

  5. check_system_arm_linux_gcc函数:检查系统是否安装了aarch64-linux-gnu-gcc命令。如果该命令不存在,将需要设置MPP_TOOLCHAIN变量为/usr/bin,并将其添加到PATH环境变量中。

  6. cmake命令:使用CMake生成Makefile文件。它使用不同的选项和参数进行配置:

    • -DCMAKE_BUILD_TYPE=Release:设置构建类型为Release模式。
    • -DCMAKE_TOOLCHAIN_FILE=./arm.linux.cross.cmake:指定交叉编译的工具链文件为当前目录下的arm.linux.cross.cmake文件。
    • -DRKPLATFORM=ON:开启对RK平台的支持。
    • -DHAVE_DRM=ON:开启对DRM(Direct Rendering Manager)的支持。
    • -G "Unix Makefiles":生成Makefile文件。
    • ${MPP_TOP}:设置项目的根目录路径。

以上脚本设置了编译和构建环境,并调用CMake来生成Makefile文件,以便在后续使用make命令进行编译和构建。根据您的需求,您可以根据具体情况进行修改和定制。

arm.linux.cross.cmake 注意 此文件进行了修改

注意本教程使用的是直接在板子上编译,注释了#SET(CMAKE_C_COMPILER “aarch64-linux-gnu-gcc”)
#SET(CMAKE_CXX_COMPILER “aarch64-linux-gnu-g++”)

cmake_minimum_required( VERSION 2.6.3 )

SET(CMAKE_SYSTEM_NAME Linux)
#SET(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
#SET(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
#SET(CMAKE_SYSTEM_PROCESSOR "armv7-a")
SET(CMAKE_SYSTEM_PROCESSOR "armv8-a")

add_definitions(-fPIC)
add_definitions(-DARMLINUX)
add_definitions(-D__gnu_linux__)

  • SET(CMAKE_SYSTEM_NAME Linux):设置目标操作系统为Linux。

  • SET(CMAKE_SYSTEM_PROCESSOR "armv8-a"):设置目标处理器为ARMv8架构。

  • SET(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")SET(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++"):设置使用aarch64-linux-gnu-gcc和aarch64-linux-gnu-g++作为C和C++编译器。但请注意,这两行目前被注释掉了,因此系统将使用默认的编译器。

  • add_definitions(-fPIC):将 -fPIC 选项添加到编译器选项中,以生成位置无关代码。

  • add_definitions(-DARMLINUX):添加 ARMLINUX 宏定义,用于条件编译。

  • add_definitions(-D__gnu_linux__):添加 __gnu_linux__ 宏定义,用于条件编译。

./make-Makefiles.bash
make

编译完成以后目录结构

[toybrick@toybrick aarch64]$ tree -L 2
.
├── arm.linux.cross.cmake
├── CMakeCache.txt
├── CMakeFiles
├── cmake_install.cmake
├── CTestTestfile.cmake
├── Makefile
├── make-Makefiles.bash
├── mpp  此文件中为生成的动态库
│   ├── librockchip_mpp.so -> librockchip_mpp.so.1
│   ├── librockchip_mpp.so.0
│   ├── librockchip_mpp.so.1 -> librockchip_mpp.so.0
├── osal
├── rockchip_mpp.pc
├── rockchip_vpu.pc
├── test  此文件中为生成的测试文件
│   ├── CMakeFiles
│   ├── cmake_install.cmake
│   ├── CTestTestfile.cmake
│   ├── Makefile
│   ├── mpi_dec_mt_test
│   ├── mpi_dec_multi_test
│   ├── mpi_dec_test
│   ├── mpi_enc_multi_test
│   ├── mpi_enc_test
│   ├── mpi_rc2_test
│   ├── mpi_rc_test
│   ├── mpi_test
│   ├── mpp_info_test
│   └── vpu_api_test

看到上面的文件说明编译成功了,

运行测试程序

cd test
LD_LIBRARY_PATH=../mpp/  ./mpi_enc_test -i /home/toybrick/352.288.yuv -w 352 -h 288 -f 0 -t  7 -o b.h264

[toybrick@toybrick aarch64]$ cd test/
[toybrick@toybrick test]$ LD_LIBRARY_PATH=../mpp/  ./mpi_enc_test -i /home/toybrick/352.288.yuv -w 352 -h 288 -f 0 -t  7 -o b.h264
mpp[3957]: mpi_enc_utils: cmd parse result:
mpp[3957]: mpi_enc_utils: input  file name: /home/toybrick/352.288.yuv
mpp[3957]: mpi_enc_utils: output file name: b.h264
mpp[3957]: mpi_enc_utils: width      : 352
mpp[3957]: mpi_enc_utils: height     : 288
mpp[3957]: mpi_enc_utils: format     : 0
mpp[3957]: mpi_enc_utils: type       : 7
mpp[3957]: mpi_enc_test: mpi_enc_test start
mpp[3957]: mpp_rt: NOT found ion allocator
mpp[3957]: mpp_rt: found drm allocator
mpp[3957]: mpi_enc_test: mpi_enc_test encoder test start w 352 h 288 type 7
mpp[3957]: mpp_info: mpp version: a26d0fad author: Ding Wei      2020-05-29 [h265d]: fix issue for pps header
mpp[3957]: mpp_enc_cfg: MppEncCfgService create info 59 with node 771 -> 767 info
mpp[3957]: h264e_api_v2: h264e_proc_prep_cfg MPP_ENC_SET_PREP_CFG w:h [352:288] stride [352:288]
mpp[3957]: h264e_api_v2: h264e_proc_rc_cfg MPP_ENC_SET_RC_CFG bps 380160 [356400 : 403920] fps [30:30] gop 60
mpp[3957]: h264e_sps: set level to 1.1
mpp[3957]: mpp_enc_v2: Please use MPP_ENC_GET_HDR_SYNC instead of unsafe MPP_ENC_GET_EXTRA_INFO
mpp[3957]: mpp_enc_v2: NOTE: MPP_ENC_GET_HDR_SYNC needs MppPacket input
mpp[3957]: rc: rc_init using rc impl default
mpp[3957]: mpp_enc_v2: mode cbr bps [356400:380160:403920] fps fix [30/1] -> fix [30/1] gop i [60] v [0]
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 0 size 13280
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 1 size 762
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 2 size 771
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 3 size 597
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 4 size 454
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 5 size 710
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 6 size 607
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 7 size 580
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 8 size 780
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 9 size 924
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 10 size 908
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 11 size 1002
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 12 size 1065
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 13 size 1060
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 14 size 1165
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 15 size 1302
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 16 size 1361
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 17 size 1324
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 18 size 1425
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 19 size 1337
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 20 size 1307
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 21 size 1421
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 22 size 1223
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 23 size 1424
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 24 size 1325
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 25 size 1369
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 26 size 1356
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 27 size 1466
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 28 size 1512
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 29 size 1416
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 30 size 1462
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 31 size 1489
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 32 size 1344
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 33 size 1264
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 34 size 1234
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 35 size 1506
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 36 size 1422
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 37 size 1571
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 38 size 1654
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 39 size 1485
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 40 size 1392
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 41 size 1485
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 42 size 1358
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 43 size 1174
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 44 size 1334
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 45 size 1302
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 46 size 1460
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 47 size 1633
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 48 size 1290
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 49 size 1421
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 50 size 1507
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 51 size 1572
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 52 size 1565
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 53 size 1342
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 54 size 1457
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 55 size 1433
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 56 size 1326
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 57 size 1272
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 58 size 1428
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 59 size 1517
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 60 size 6301
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 61 size 3502
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 62 size 2541
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 63 size 2333
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 64 size 1793
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 65 size 1499
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 66 size 1223
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 67 size 1198
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 68 size 1164
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 69 size 1264
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 70 size 1285
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 71 size 1511
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 72 size 1517
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 73 size 1414
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 74 size 1380
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 75 size 1249
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 76 size 1244
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 77 size 1264
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 78 size 1455
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 79 size 1450
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 80 size 1408
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 81 size 1329
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 82 size 1491
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 83 size 1159
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 84 size 1383
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 85 size 1590
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 86 size 1425
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 87 size 1577
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 88 size 1242
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 89 size 1188
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 90 size 1302
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 91 size 1481
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 92 size 1638
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 93 size 1557
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 94 size 1551
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 95 size 1497
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 96 size 1541
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 97 size 1643
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 98 size 1617
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 99 size 1684
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 100 size 1559
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 101 size 1329
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 102 size 1316
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 103 size 1403
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 104 size 1577
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 105 size 1677
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 106 size 1697
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 107 size 1427
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 108 size 1501
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 109 size 1424
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 110 size 1452
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 111 size 1344
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 112 size 1484
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 113 size 1476
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 114 size 1562
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 115 size 1436
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 116 size 1448
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 117 size 1429
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 118 size 1465
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 119 size 1596
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 120 size 7631
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 121 size 3461
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 122 size 2480
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 123 size 2052
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 124 size 1865
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 125 size 1640
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 126 size 1388
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 127 size 1223
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 128 size 1234
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 129 size 1078
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 130 size 989
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 131 size 1189
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 132 size 1214
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 133 size 1157
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 134 size 1255
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 135 size 1552
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 136 size 1363
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 137 size 1514
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 138 size 1480
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 139 size 1273
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 140 size 1377
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 141 size 1341
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 142 size 1263
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 143 size 1082
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 144 size 1108
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 145 size 1212
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 146 size 1160
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 147 size 1255
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 148 size 1140
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 149 size 1163
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 150 size 1260
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 151 size 1535
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 152 size 1700
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 153 size 1786
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 154 size 1430
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 155 size 1757
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 156 size 1573
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 157 size 1570
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 158 size 1566
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 159 size 1531
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 160 size 1680
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 161 size 1655
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 162 size 1582
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 163 size 1563
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 164 size 1542
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 165 size 1199
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 166 size 1158
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 167 size 1359
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 168 size 1327
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 169 size 1603
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 170 size 1573
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 171 size 1341
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 172 size 1646
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 173 size 1155
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 174 size 1285
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 175 size 1293
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 176 size 1327
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 177 size 1421
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 178 size 1768
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 179 size 1377
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 180 size 8181
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 181 size 3219
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 182 size 2405
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 183 size 2326
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 184 size 1877
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 185 size 1623
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 186 size 1441
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 187 size 983
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 188 size 1129
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 189 size 951
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 190 size 1115
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 191 size 1175
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 192 size 992
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 193 size 1053
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 194 size 1097
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 195 size 1071
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 196 size 1014
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 197 size 1122
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 198 size 1304
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 199 size 1090
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 200 size 1138
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 201 size 1300
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 202 size 1308
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 203 size 1227
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 204 size 1296
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 205 size 1556
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 206 size 1388
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 207 size 1623
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 208 size 1495
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 209 size 1559
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 210 size 1509
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 211 size 1752
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 212 size 1680
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 213 size 1739
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 214 size 1914
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 215 size 2131
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 216 size 1624
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 217 size 1692
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 218 size 1575
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 219 size 1523
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 220 size 1665
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 221 size 1577
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 222 size 1556
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 223 size 1603
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 224 size 1625
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 225 size 1414
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 226 size 1357
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 227 size 1519
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 228 size 1319
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 229 size 1572
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 230 size 1618
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 231 size 1435
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 232 size 1220
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 233 size 1341
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 234 size 1460
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 235 size 1438
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 236 size 1549
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 237 size 1517
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 238 size 1566
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 239 size 1478
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 240 size 8450
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 241 size 3010
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 242 size 2102
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 243 size 1693
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 244 size 1544
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 245 size 1513
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 246 size 1396
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 247 size 1418
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 248 size 1121
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 249 size 1406
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 250 size 1478
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 251 size 1243
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 252 size 1497
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 253 size 1601
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 254 size 1518
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 255 size 1572
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 256 size 1626
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 257 size 1136
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 258 size 1267
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 259 size 1223
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 260 size 1269
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 261 size 1338
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 262 size 1412
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 263 size 1399
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 264 size 1256
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 265 size 1357
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 266 size 1164
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 267 size 1110
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 268 size 1179
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 269 size 1031
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 270 size 1325
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 271 size 1262
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 272 size 1432
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 273 size 1419
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 274 size 1337
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 275 size 1487
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 276 size 1846
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 277 size 1614
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 278 size 1604
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 279 size 1682
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 280 size 1771
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 281 size 1678
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 282 size 1412
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 283 size 1408
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 284 size 1277
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 285 size 1470
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 286 size 1605
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 287 size 1436
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 288 size 1287
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 289 size 1207
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 290 size 1550
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 291 size 1366
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 292 size 1356
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 293 size 1472
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 294 size 1588
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 295 size 1587
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 296 size 1284
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 297 size 1621
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 298 size 1511
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 299 size 1434
mpp[3957]: utils: read_image read ori yuv file luma failed
mpp[3957]: mpi_enc_test: found last frame. feof 1
mpp[3957]: mpi_enc_test: test_mpp_run encoded frame 300 size 0
mpp[3957]: mpi_enc_test: found last packet
mpp[3957]: mpi_enc_test: mpi_enc_test success total frame 301 bps 373003
mpp[3957]: mpp_buffer: ~MppBufferService cleaning misc group

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

设置环境变量 LD_LIBRARY_PATH 的值为 …/mpp/,该变量指定了可执行文件在
运行时搜索动态链接库(共享库)的路径

visual studio 2023编译

# ----------------------------------------------------------------------------
#  Root CMake file for Rockchip Media Process Platform (MPP)
#
#   - 10:34 2015/7/27: Initial version 
#
# ----------------------------------------------------------------------------

# vim: syntax=cmake
if(NOT CMAKE_BUILD_TYPE)
    # default to Release build for GCC builds
    set(CMAKE_BUILD_TYPE Debug CACHE STRING
        "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
        FORCE)
endif()
message(STATUS "cmake version ${CMAKE_VERSION}")

# Search packages for host system instead of packages for target system
# in case of cross compilation these macro should be defined by toolchain file
if(NOT COMMAND find_host_package)
    macro(find_host_package)
        find_package(${ARGN})
    endmacro()
endif()
if(NOT COMMAND find_host_program)
    macro(find_host_program)
        find_program(${ARGN})
    endmacro()
endif()

project (rk_mpp)

cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckCXXCompilerFlag)

# setup output library name
# Linux   default name - rockchip_mpp and rockchip_vpu
# Android default name - mpp and vpu
# For historical reason libraries on Android is named as mpp and vpu. But for
# better naming rule on Linux it should add vendor prefix.
# So we use this ugly method to avoid massive maintain issue.
if (NOT MPP_PROJECT_NAME)
    set(MPP_PROJECT_NAME rockchip_mpp)
endif()
set(MPP_STATIC ${MPP_PROJECT_NAME}_static)
set(MPP_SHARED ${MPP_PROJECT_NAME})
set(HAVE_DRM ON CACHE BOOL "Enable DRM support")
if (NOT VPU_PROJECT_NAME)
    set(VPU_PROJECT_NAME rockchip_vpu)
endif()
set(VPU_STATIC ${VPU_PROJECT_NAME}_static)
set(VPU_SHARED ${VPU_PROJECT_NAME})

# ----------------------------------------------------------------------------
# set property to classify library kinds
# ----------------------------------------------------------------------------
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
# ----------------------------------------------------------------------------
# enable test in this project
# ----------------------------------------------------------------------------
enable_testing()

# ----------------------------------------------------------------------------
# System architecture detection
# ----------------------------------------------------------------------------
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
set(X86_ALIASES x86 i386 i686 x86_64 amd64)
list(FIND X86_ALIASES "${SYSPROC}" X86MATCH)
if("${CMAKE_C_COMPILER}" MATCHES "-buildroot-[^/]+$")
    message(STATUS "Detected Buildroot toolchain")
    # Use buildroot toolchain's default architecture settings
elseif("${SYSPROC}" STREQUAL "" OR X86MATCH GREATER "-1")
    message(STATUS "Detected x86 system processor")
    set(X86 true)
    add_definitions(-DARCH_X86=1)
    if("${CMAKE_SIZEOF_VOID_P}" MATCHES 8)
        set(X64 true)
        add_definitions(-DARCH_X64=1)
        message(STATUS "Define X86_64 to 1")
    endif()
elseif(${SYSPROC} STREQUAL "armv6l")
    message(STATUS "Detected ARMv6 system processor")
    set(ARM true)
    set(ARMEABI_V6 true)
elseif(${SYSPROC} STREQUAL "armv7-a")
    message(STATUS "Detected ARMv7 system processor")
    set(ARM true)
    set(ARMEABI_V7A true)
elseif(${SYSPROC} STREQUAL "armv7-a_hardfp" OR ${SYSPROC} STREQUAL "armv7l")
    message(STATUS "Detected ARMv7 system processor")
    set(ARM true)
    set(ARMEABI_V7A_HARDFP true)
elseif(${SYSPROC} STREQUAL "aarch64")
    message(STATUS "Detected ARMv8 system processor")
    set(ARM true)
    set(ARMEABI_V8 true)
else()
    message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
    message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}")
endif()

if(UNIX)
    SET(PLATFORM_LIBS pthread)
    if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        SET(PLATFORM_LIBS ${PLATFORM_LIBS} rt)
    endif()
endif(UNIX)

# ----------------------------------------------------------------------------
# Compiler detection
# ----------------------------------------------------------------------------
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    set(CLANG true)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
    set(INTEL_CXX true)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    set(GCC true)
endif()

if(INTEL_CXX AND UNIX)
    # treat icpc roughly like gcc
    set(GCC true)
    add_definitions(-Wall -Wextra -Wshadow)
elseif(CLANG)
    # treat clang roughly like gcc
    set(GCC true)
    add_definitions(-Wall -Wextra -Wshadow -ffast-math)
elseif(CMAKE_COMPILER_IS_GNUCXX)
    add_definitions(-Wall -Wextra -Wshadow -ffast-math)
    check_cxx_compiler_flag(-Wno-narrowing GCC_HAS_NO_NARROWING)
    check_cxx_compiler_flag(-mstackrealign GCC_HAS_STACK_REALIGN)
    if (GCC_HAS_STACK_REALIGN)
        add_definitions(-mstackrealign)
    endif()
    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
endif()

if(GCC)
    if(ARM)
        if(ARMEABI_V6)
            add_definitions(-march=armv6 -mfloat-abi=hard -mfpu=vfp)
        elseif(ARMEABI_V7A)
            add_definitions(-march=armv7-a -mfloat-abi=softfp -mfpu=neon)
        elseif(ARMEABI_V7A_HARDFP)
            add_definitions(-march=armv7-a -mfloat-abi=hard -mfpu=neon)
        elseif(ARMEABI_V8)
            add_definitions(-march=armv8-a)
        endif()
    else()
        if(X86 AND NOT X64)
            add_definitions(-march=i686)
        endif()
    endif()

    if($(CMAKE_BUILD_TYPE) MATCHES "Release")
        set(CMAKE_C_VISIBILITY_PRESET hidden)
        set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    endif()

    # disable multichar warning
    add_definitions(-Wno-multichar)
    # add PIC flag
    add_definitions(-fPIC)
    # disable exception for C++
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")

    # for libary linking
    set(BEGIN_WHOLE_ARCHIVE -Wl,--whole-archive)
    set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
endif(GCC)

# ----------------------------------------------------------------------------
# Create git version information
# ----------------------------------------------------------------------------
set(VERSION_CNT         0)
set(VERSION_MAX_CNT     10)
set(VERSION_INFO        "\"unknown mpp version for missing VCS info\"")
foreach (CNT RANGE ${VERSION_MAX_CNT})
    set(VERSION_HISTORY_${CNT} "NULL")
endforeach(CNT)

if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
    find_host_package(Git)
    if(GIT_FOUND)
        # get current version info
        set(GIT_LOG_FORMAT "%h author: %<|(30)%an %cd %s")

        execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --date=short --pretty=format:${GIT_LOG_FORMAT}
            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
            OUTPUT_VARIABLE EXEC_OUT
            ERROR_VARIABLE EXEC_ERROR
            RESULT_VARIABLE EXEC_RET
            OUTPUT_STRIP_TRAILING_WHITESPACE
            ERROR_STRIP_TRAILING_WHITESPACE)

        if (NOT EXEC_RET)
            set(VERSION_INFO ${EXEC_OUT})
            message(STATUS "current version:")
            message(STATUS "${VERSION_INFO}")
            string(REPLACE "\"" "\\\"" VERSION_INFO ${VERSION_INFO})
            set(VERSION_INFO "\"${VERSION_INFO}\"")
        else()
            message(STATUS "git ret ${EXEC_RET}")
            message(STATUS "${EXEC_ERROR}")
        endif()

        set(GIT_LOG_FORMAT "%h author: %<|(30)%an %cd %s %d")

        # get history version information
        execute_process(COMMAND ${GIT_EXECUTABLE} log -${VERSION_MAX_CNT} --oneline --date=short --pretty=format:${GIT_LOG_FORMAT}
            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
            OUTPUT_VARIABLE EXEC_OUT
            ERROR_VARIABLE EXEC_ERROR
            RESULT_VARIABLE EXEC_RET
            OUTPUT_STRIP_TRAILING_WHITESPACE
            ERROR_STRIP_TRAILING_WHITESPACE)

        if (NOT EXEC_RET)
            set(VERSION_HISTORY ${EXEC_OUT})
            string(REPLACE "\n" ";" VERSION_HISTORY ${VERSION_HISTORY})

            list(LENGTH VERSION_HISTORY VERSION_CNT)
            message(STATUS "${VERSION_CNT} git history:")

            # setup logs
            set(CNT 0)
            foreach(VERSION_LOG ${VERSION_HISTORY})
                message(STATUS ${VERSION_LOG})
                string(REPLACE "\"" "\\\"" VERSION_LOG ${VERSION_LOG})
                set(VERSION_HISTORY_${CNT} "\"${VERSION_LOG}\"")
                math(EXPR CNT "${CNT}+1")
            endforeach(VERSION_LOG)
        else()
            message(STATUS "git ret ${EXEC_RET}")
            message(STATUS "${EXEC_ERROR}")
        endif()
    endif()

    # add git hooks
    if (EXISTS "${PROJECT_SOURCE_DIR}/tools/hooks/")
        set(GIT_HOOK_SRC "${PROJECT_SOURCE_DIR}/tools/hooks/")
        if(EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks")
            set(GIT_HOOK_DST "${PROJECT_SOURCE_DIR}/.git/hooks/")
            file(COPY ${GIT_HOOK_SRC} DESTINATION ${GIT_HOOK_DST})
            message(STATUS "Install git hooks done")
        endif(EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks")
    endif(EXISTS "${PROJECT_SOURCE_DIR}/tools/hooks/")
endif(EXISTS "${PROJECT_SOURCE_DIR}/.git")

configure_file(
    "${PROJECT_SOURCE_DIR}/build/cmake/version.in"
    "${PROJECT_SOURCE_DIR}/mpp/version.h"
)

# ----------------------------------------------------------------------------
# Build options
# ----------------------------------------------------------------------------
find_package(PkgConfig)
INCLUDE(GNUInstallDirs)
pkg_search_module(PTHREAD pthread)

# ----------------------------------------------------------------------------
# Set Warning as Error
# ----------------------------------------------------------------------------
option(WARNINGS_AS_ERRORS "Stop compiles on first warning" OFF)
if(WARNINGS_AS_ERRORS)
    if(GCC)
        add_definitions(-Werror)
    elseif(MSVC)
        add_definitions(/WX)
    endif()
endif(WARNINGS_AS_ERRORS)

# ----------------------------------------------------------------------------
# look for stdint.h
# ----------------------------------------------------------------------------
if(MSVC)
    check_include_files(stdint.h HAVE_STDINT_H)
    if(NOT HAVE_STDINT_H)
        include_directories(osal/windows)
    endif(NOT HAVE_STDINT_H)
endif(MSVC)

# ----------------------------------------------------------------------------
# Share library option
# ----------------------------------------------------------------------------
option(ENABLE_STATIC "Build shared library" ON)
option(ENABLE_SHARED "Build shared library" OFF)

# ----------------------------------------------------------------------------
# scan all LOG_TAG for log information and generate module header file
# ----------------------------------------------------------------------------
set( module_list "" )
file ( GLOB_RECURSE ALL_SRC . *.c;*.cpp )
foreach( files ${ALL_SRC} )
    file( STRINGS ${files} module_tag_line REGEX "MODULE_TAG( )+\".+\"" )
    if(module_tag_line)
        string( REGEX REPLACE "^(.)* MODULE_TAG( )+\"(.*)\"" \\3 module_tag ${module_tag_line} )
        list( APPEND module_list ${module_tag} )
    endif()
endforeach()
list( SORT module_list )
list( LENGTH module_list module_size )
#message(STATUS "module_list: ${module_list}")
#message(STATUS "module_size: ${module_size}")

# ----------------------------------------------------------------------------
#  Start module definition
# ----------------------------------------------------------------------------
# project overall include file
include_directories(inc)
# small utile functions for test case
include_directories(utils)

# ----------------------------------------------------------------------------
#  osal library
# ----------------------------------------------------------------------------
# Operation System Abstract Layer (OSAL) include
include_directories(osal/inc)
# OSAL is needed on all platform, do not need option
add_subdirectory(osal)

# ----------------------------------------------------------------------------
#  utils for test case
# ----------------------------------------------------------------------------
add_subdirectory(utils)

# ----------------------------------------------------------------------------
#  Media Process Platform library
# ----------------------------------------------------------------------------
# Media Process Platform include
include_directories(mpp/inc)
add_subdirectory(mpp)

# ----------------------------------------------------------------------------
#  test / demo
# ----------------------------------------------------------------------------
add_subdirectory(test)

# ----------------------------------------------------------------------------
#  install headers
# ----------------------------------------------------------------------------
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/
        DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rockchip"
        FILES_MATCHING PATTERN "*.h"
        )

# ----------------------------------------------------------------------------
#  pkgconfig
# ----------------------------------------------------------------------------
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/rockchip_mpp.pc.cmake"
                "${CMAKE_BINARY_DIR}/rockchip_mpp.pc" @ONLY)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/rockchip_vpu.pc.cmake"
                "${CMAKE_BINARY_DIR}/rockchip_vpu.pc" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/rockchip_mpp.pc"
        DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
install(FILES "${CMAKE_BINARY_DIR}/rockchip_vpu.pc"
        DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")

特别注意 set(HAVE_DRM ON CACHE BOOL “Enable DRM support”) 是新添加的
注意需要将build文件复制到 cd /home/toybrick/.vs/mpp/build/
才能编译成功

[toybrick@toybrick linux-release]$ ll
总用量 804
-rw-rw-r-- 1 toybrick toybrick 701163 8月   5 16:55 build.ninja
-rw-rw-r-- 1 toybrick toybrick  24522 8月   5 16:53 CMakeCache.txt
drwxrwxr-x 4 toybrick toybrick   4096 8月   5 16:55 CMakeFiles
-rw-rw-r-- 1 toybrick toybrick   2755 8月   5 12:19 cmake_install.cmake
-rw-rw-r-- 1 toybrick toybrick    345 8月   5 12:19 CTestTestfile.cmake
-rw-rw-r-- 1 toybrick toybrick   2527 8月   5 16:58 install_manifest.txt
drwxrwxr-x 8 toybrick toybrick   4096 8月   5 16:55 mpp
drwxrwxr-x 4 toybrick toybrick   4096 8月   5 16:55 osal
-rw-r--r-- 1 toybrick toybrick    255 8月   5 12:08 rockchip_mpp.pc
-rw-r--r-- 1 toybrick toybrick    264 8月   5 12:08 rockchip_vpu.pc
-rw-rw-r-- 1 toybrick toybrick  50079 8月   5 16:55 rules.ninja
drwxrwxr-x 3 toybrick toybrick   4096 8月   5 16:55 test
drwxrwxr-x 3 toybrick toybrick   4096 8月   5 16:55 utils
[toybrick@toybrick linux-release]$ pwd
/home/toybrick/.vs/mpp/out/build/linux-release
[toybrick@toybrick linux-release]$

你可能感兴趣的:(toybrick,mpp,c++,物联网,视频编解码)