Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RK1808解码后的mppframe使用rga转换NV21到RGB888过程中,目标图片的fd应该怎么定义? #81

Open
dao027 opened this issue May 28, 2024 · 2 comments

Comments

@dao027
Copy link

dao027 commented May 28, 2024

因为缺乏经验,请教一下各位大佬
目前有解码后的mppframe,根据rga文档中的效率建议,希望使用fd来进行操作,根据官方demo的程序稍作修改如下:

    int ret = 0;
    int src_width, src_height, src_format;
    int dst_width, dst_height, dst_format;
    int src_dma_fd = mpp_buffer_get_fd(buffer);
    int dst_dma_fd;
    char *src_buf, *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));

    src_width = h_stride;
    src_height = v_stride;
    src_format = RK_FORMAT_YCrCb_420_SP;

    dst_width = width;
    dst_height = height;
    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);

    std::chrono::_V2::system_clock::time_point now;
    int64_t milliseconds;

    ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHED_PATH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf);

    memset(dst_buf, 0x80, dst_buf_size);

    src_handle = importbuffer_fd(src_dma_fd, src_buf_size);
    dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size);

    src_img = wrapbuffer_handle(src_handle, width, height, src_format, h_stride, v_stride);
    dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);

    ret = imcvtcolor(src_img, dst_img, src_format, dst_format);

但是报错没有DMA_HEAP_DMA32_UNCACHED_PATH变量,即/dev/dma_heap/system-uncached-dma32
请教两个问题:
1、是否只能用dma来申请目标图片的fd呢?
2、不用dma的话,是同样在mppbuffer中去申请转换后的目标图片fd就行吗?哪种效率更高呢?

@Cerf-Yu
Copy link
Collaborator

Cerf-Yu commented Jul 5, 2024

  1. 没有这个设备节点则说明当前的固件是不支持该分配器的
  2. 只要是dma-buf的fd就可以,并不仅限于示例代码中提供的内存分配器,你说mpp_buffer的fd也是可以使用的。

@LeoD218
Copy link

LeoD218 commented Jul 29, 2024

  1. 没有这个设备节点则说明当前的固件是不支持该分配器的
  2. 只要是dma-buf的fd就可以,并不仅限于示例代码中提供的内存分配器,你说mpp_buffer的fd也是可以使用的。

他这样的写法对吗,因为我也是这样写的,然后报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants