-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportable_test.cc
47 lines (35 loc) · 1.2 KB
/
portable_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
#include <nvmpi_portable.h>
using namespace std;
int main(int argc, char **argv)
{
double st, et;
int res = 0;
int width=1920, height=1080;
nvmpictx* encoder = nvpInitEncoder(NV_VIDEO_CodingH264, width, height, 4000000, 0, 24, 12, 60, 77, 50, 1, 10, 0, 10, 0, 0, 0);
nvmpictx* decoder = nvpInitDecoder(NV_VIDEO_CodingH264);
int dec = 0;
for(int i = 0; i < 100; i++)
{
cv::Mat origFrame, yuvFrame = cv::Mat::zeros(height*1.5, width, CV_8UC1);
origFrame = cv::imread("/home/jin/Downloads/video_000001.png");
cv::cvtColor(origFrame, yuvFrame, cv::COLOR_RGB2YUV_YV12);
nvPacket pkt = nvpEncodeYuvFrame(encoder, yuvFrame, width, height);
nvpPutPktToDecoder(decoder, &pkt);
cv::Mat decodedYuv = nvpGetDecodedYuvFrame(decoder, width, height);
if(decodedYuv.rows != 1 && decodedYuv.cols != 1)
{
printf("decode: %d:%d\n", i, dec++);
cv::Mat finalFrame;
cv::cvtColor(decodedYuv, finalFrame, cv::COLOR_YUV420p2RGB);
cv::imshow("test", finalFrame);
cv::waitKey(0);
}
delete pkt.payload;
}
nvpCloseEncoder(encoder);
nvpCloseDecoder(decoder);
/* Decoder Close */
nvmpi_decoder_close(decoder);
return 0;
}