Skip to content

Commit a923f96

Browse files
author
sliver.chen
committed
[base]: commit a base verison for project
base version offer a simple process from mpp decode to drm disaply. Signed-off-by: sliver.chen <[email protected]>
0 parents  commit a923f96

16 files changed

+1895
-0
lines changed

CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
project(mpp_linux_demo)
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
7+
set(SOURCE_FILES main.cpp
8+
mpp/Codec.cpp
9+
thread/Thread.cpp
10+
rkrga/RGA.cpp
11+
rkdrm/bo.c
12+
rkdrm/dev.c
13+
rkdrm/modeset.c)
14+
15+
add_executable(mpp_linux_demo ${SOURCE_FILES})
16+
target_link_libraries(mpp_linux_demo mpp pthread drm)

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# MPP_LINUX_C++
2+
a demo shows that how to use mpp on linux
3+
4+
project architecture
5+
6+
├── build --build directory
7+
├── CMakeLists.txt --cmake script
8+
├── main.cpp --main program
9+
├── mpp --mpp abstract interface
10+
├── README.md --doc
11+
├── res --res directory
12+
├── rkdrm --drm interface(abount display)
13+
├── rkrga --rga interface(about format and resolution conversion)
14+
└── thread --thread abstract interface(use posix)
15+
16+
## make & test
17+
first please modify CMakeLists.txt to specified c and c++ compiler.
18+
just do that
19+
set(CMAKE_C_COMPILER "enter your toolchain gcc path)
20+
set(CMAKE_CXX_coMPILER "enter your toolchain g++ path")
21+
22+
cmake version >= 2.8 is required
23+
root:cd build
24+
root:make
25+
root:./mpp_linux_demo
26+
27+
## how you will see
28+
on your device screen,you will see that local avc file
29+
is displayed.
30+

main.cpp

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* linux mpp c++ performance avaluation.
3+
* base in mpp & rga & sdl.
4+
* cfg info writed in params[6].
5+
*/
6+
7+
#include <iostream>
8+
#include "rkrga/RGA.h"
9+
#include "mpp/Codec.h"
10+
#include "thread/Thread.h"
11+
12+
extern "C" {
13+
#include <stdlib.h>
14+
#include <signal.h>
15+
#include "rk_mpi.h"
16+
}
17+
18+
#define dbg(fmt,...)\
19+
do {\
20+
printf(fmt,##__VA_ARGS__);\
21+
} while(0)
22+
23+
using namespace std;
24+
25+
struct param {
26+
int display;
27+
int width;
28+
int height;
29+
string input;
30+
string output;
31+
MppCodingType type;
32+
};
33+
34+
/*
35+
* specified res file info here
36+
*/
37+
param params[1] = {
38+
{1, 1920, 1080, "../res/Tennis1080p.h264", "../res/Tennis1080p.yuv", MPP_VIDEO_CodingAVC},
39+
};
40+
41+
void *thread_exec(void *args) {
42+
int ret = 0;
43+
param *arg = (param *)args;
44+
double *retRate = new double;
45+
46+
Codec *ctx = new Codec();
47+
ret = ctx->init(arg->input.c_str(), arg->output.c_str(), arg->type,
48+
arg->width, arg->height, arg->display);
49+
if (ret < 0) {
50+
cout << "failed to init codec" << endl;
51+
return NULL;
52+
}
53+
54+
ret = ctx->decode();
55+
if (ret <0)
56+
cout << "codec decode exec failed" << endl;
57+
else
58+
cout << "codec decode exec success id:" << endl;
59+
60+
ctx->deinit();
61+
delete ctx;
62+
63+
return NULL;
64+
}
65+
66+
void stop(int signo) {
67+
cout << "mpp_linux_demo exit";
68+
_exit(0);
69+
}
70+
71+
int main() {
72+
int ret = 0;
73+
signal(SIGINT, stop);
74+
75+
Thread *tFirst = new Thread(thread_exec, &params[0], NULL);
76+
tFirst->init();
77+
78+
tFirst->run();
79+
80+
delete(tFirst);
81+
return 0;
82+
}

0 commit comments

Comments
 (0)