From 79ce131beafb77fe35b4e7993fdb104c8d2e70b1 Mon Sep 17 00:00:00 2001 From: sladro Date: Fri, 26 Dec 2025 16:11:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20DMA-BUF=20=E5=88=86?= =?UTF-8?q?=E9=85=8D=E5=86=85=E5=AD=98=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=8A=9F?= =?UTF-8?q?=E8=83=BDbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/preprocess/preprocess_node.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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;