-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUntitled-1.txt
121 lines (93 loc) · 2.91 KB
/
Untitled-1.txt
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "rgaProcess.h"
#include "common.h"
#include <sys/time.h>
static RockchipRga *rkRga = new RockchipRga();
static int srcWidth,srcHeight,srcFormat;
static int dstWidth,dstHeight,dstFormat;
static bo_t bo_src, bo_dst;
static rga_info_t src;
static rga_info_t dst;
void rga_init()
{
rkRga->RkRgaInit();
int ret = 0;
srcWidth = _image_width;
srcHeight = _image_height;
srcFormat = RK_FORMAT_YCrCb_420_SP;
dstWidth = _image_width;
dstHeight = _image_height;
dstFormat = RK_FORMAT_YCbCr_420_P;
ret = rkRga->RkRgaGetAllocBuffer(&bo_src, srcWidth, srcHeight, 32);
ret = rkRga->RkRgaGetAllocBuffer(&bo_dst, dstWidth, dstHeight, 32);
/********** map buffer_address to userspace **********/
rkRga->RkRgaGetMmap(&bo_src);
rkRga->RkRgaGetMmap(&bo_dst);
memset(&src, 0, sizeof(rga_info_t));
src.fd = -1;
src.mmuFlag = 1;
// src.virAddr = psrc;
memset(&dst, 0, sizeof(rga_info_t));
dst.fd = -1;
dst.mmuFlag = 1;
// dst.virAddr = pdst;
/********** get src_Fd **********/
ret = rkRga->RkRgaGetBufferFd(&bo_src, &src.fd);
printf("src.fd =%d \n",src.fd);
if (ret) {
printf("rgaGetsrcFd fail : %s\n", strerror(errno));
}
/********** get dst_Fd **********/
ret = rkRga->RkRgaGetBufferFd(&bo_dst, &dst.fd);
printf("dst.fd =%d \n",dst.fd);
if (ret) {
printf("rgaGetdstFd error : %s\n", strerror(errno));
}
}
void rga_deinit()
{
delete rkRga;
}
int rga_convert(unsigned char* psrc, unsigned char* pdst)
{
int ret=0;
struct timeval tpend1, tpend2;
// long usec1 = 0;
// gettimeofday(&tpend1, NULL);
memcpy(bo_src.ptr, psrc, _image_width*_image_height*3/2);
rga_set_rect(&src.rect, 0,0,srcWidth,srcHeight,srcWidth/*stride*/,srcHeight,srcFormat);
rga_set_rect(&dst.rect, 0,0,dstWidth,dstHeight,dstWidth/*stride*/,dstHeight,dstFormat);
ret = rkRga->RkRgaBlit(&src, &dst, NULL);
if (ret) {
printf("rkRga->RkRgaBlit error : %s\n",strerror(errno));
}
//*pdst=(unsigned char *)bo_dst.ptr;
memcpy(pdst, (unsigned char *)bo_dst.ptr, _image_width*_image_height*3/2);
// gettimeofday(&tpend2, NULL);
// usec1 = 1000 * (tpend2.tv_sec - tpend1.tv_sec) + (tpend2.tv_usec - tpend1.tv_usec) / 1000;
// printf("cost_time=%ld ms\n", usec1);
// ret = rkRga->RkRgaFree(&bo_src);
// ret = rkRga->RkRgaFree(&bo_dst);
return ret;
}
/*
int rga_zoom(unsigned char* src, unsigned char*dst, int zoom)
{
if(zoom == RGA_ZOOM_1x0){
dst = src;
return 0;
}
int ret = 0;
int imgWidth,imgHeight;
int imgCenterX,imgCenterY;
int x,y; //zoom x,y
int zoomWidth,zoomHeight;
int imgFormat;
bo_t bo_src, bo_zoom, bo_dst;
imgWidth = _image_width;
imgHeight = _image_height;
imgCenterX = _image_width / 2 -1;
imgCenterY = _image_height / 2 -1;
zoomWidth
srcWidth = 1280;
srcHeight = 720;
}*/