- if (task)
- {
- mpp_task_meta_get_frame(task, KEY_OUTPUT_FRAME, &frame);
- MppBuffer buffer = NULL;
- if (frame)
- {
- RK_U32 width = 0;
- RK_U32 height = 0;
- char *base = NULL;
- width = mpp_frame_get_width(frame);
- height = mpp_frame_get_height(frame);
- buffer = mpp_frame_get_buffer(frame);
- base = (char*)mpp_buffer_get_ptr(buffer);
- int src_format;
- int dst_format;
- char *dst_buf;
- int src_buf_size, dst_buf_size;
- rga_buffer_t src_img, dst_img;
- rga_buffer_handle_t src_handle, dst_handle;
- memset(&src_img, 0, sizeof(src_img));
- memset(&dst_img, 0, sizeof(dst_img));
- int src_width = MPP_ALIGN(width,16);
- int src_height = MPP_ALIGN(height,16);
- src_format = RK_FORMAT_YCbCr_420_SP;
- int dst_width = 640;
- int dst_height = 480;
- dst_format = RK_FORMAT_RGB_888;
- src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
- dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
- dst_buf = (char *)malloc(dst_buf_size);
- src_handle = importbuffer_virtualaddr(base, src_buf_size);
- dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
- if (src_handle == 0 || dst_handle == 0) {
- printf("importbuffer failed!\n");
- }
- src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
- dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
- ret = imcheck(src_img, dst_img, {}, {});
- if (IM_STATUS_NOERROR != ret) {
- printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
- return;
- }
- ret = imcvtcolor(src_img, dst_img,RK_FORMAT_YCbCr_420_SP,RK_FORMAT_RGB_888);
复制代码
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |