使用 DMA-BUF 分配内存,修复功能bug
This commit is contained in:
parent
03465b6307
commit
79ce131bea
@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user