jefferyzhang 发表于 2023-9-5 16:31
但凡看到代码里有对图片每帧做memcpy就是错误的写法。
所有图片的memcpy都可以用RGA或者openGL替代 ...
雁南飞 发表于 2023-9-5 16:40
您好!用RGA具体怎么处理
jefferyzhang 发表于 2023-9-5 17:13
请自行参看 https://github.com/airockchip/librga
rga库的sample
jefferyzhang 发表于 2023-9-5 17:13
请自行参看 https://github.com/airockchip/librga
rga库的sample
- rga_buffer_t g_src_img;
- rga_buffer_t g_dst_img;
- rga_buffer_handle_t g_src_handle;
- rga_buffer_handle_t g_dst_handle;
- g_src_handle = 0;
- g_dst_handle = 0;
- memset(&g_src_img, 0, sizeof(g_src_img));
- memset(&g_dst_img, 0, sizeof(g_dst_img));
- memset(g_dst_buf, 0x80, width*height*3);
-
- g_src_handle = importbuffer_virtualaddr((char*)mpp_buffer_get_ptr(buffer), width*height*3);
- g_dst_handle = importbuffer_virtualaddr(g_dst_buf, width*height*3);
- if (g_src_handle == 0 || g_dst_handle == 0)
- {
- printf("importbuffer failed!\n");
- return ;
- }
- g_src_img = wrapbuffer_handle(g_src_handle, width, height, RK_FORMAT_RGB_888);
- g_dst_img = wrapbuffer_handle(g_dst_handle, width, height, RK_FORMAT_RGB_888);
- IM_STATUS checkRet = imcheck(g_src_img, g_dst_img, {}, {});
- if (IM_STATUS_NOERROR != checkRet)
- {
- printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)checkRet));
- return;
- }
- printf("dest handle:%d handle:%d fd:%d vir:%x phy:%x\n", g_dst_handle, g_dst_img.handle, g_dst_img.fd, g_dst_img.vir_addr, g_dst_img.phy_addr);
- printf("src handle:%d handle:%d fd:%d vir:%x phy:%x\n", g_src_handle, g_src_img.handle, g_src_img.fd, g_src_img.vir_addr, g_src_img.phy_addr);
- IM_STATUS retStatus = imcopy(g_src_img, g_dst_img);
- if (retStatus == IM_STATUS_SUCCESS)
- {
- printf("imcopy running success!\n");
- }
- else
- {
- printf("imcopy running failed, %s\n", imStrError((IM_STATUS)retStatus));
- }
- //这里对g_dst_buf进行操作,写文件之类
- //......
- if (g_src_handle)
- releasebuffer_handle(g_src_handle);
- if (g_dst_handle)
- releasebuffer_handle(g_dst_handle);
复制代码
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |