diff --git a/plugins/preprocess/preprocess_node.cpp b/plugins/preprocess/preprocess_node.cpp index e5244da..25c6039 100644 --- a/plugins/preprocess/preprocess_node.cpp +++ b/plugins/preprocess/preprocess_node.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -211,13 +212,23 @@ private: rga_buffer_t src_buf{}; rga_buffer_t dst_buf{}; + DmaBufferPtr src_dma_buf; // Keep alive if we allocate if (frame->dma_fd >= 0) { src_buf = wrapbuffer_fd_t(frame->dma_fd, frame->width, frame->height, src_wstride, src_hstride, src_fmt_rga); } else if (frame->data) { - src_buf = wrapbuffer_virtualaddr_t(frame->data, frame->width, frame->height, - src_wstride, src_hstride, src_fmt_rga); + // Source doesn't have DMA fd, copy to DMA buffer first to avoid >4GB address issue + size_t src_size = CalcImageSize(frame->width, frame->height, frame->format); + src_dma_buf = DmaAlloc(src_size); + if (!src_dma_buf || !src_dma_buf->valid()) { + std::cerr << "[preprocess] DMA alloc for src failed\n"; + PushToDownstream(frame); + continue; + } + memcpy(src_dma_buf->data(), frame->data, std::min(src_size, frame->data_size)); + src_buf = wrapbuffer_fd_t(src_dma_buf->fd, frame->width, frame->height, + src_wstride, src_hstride, src_fmt_rga); } else { PushToDownstream(frame); continue;