使用 DMA-BUF 分配内存,修复功能bug

This commit is contained in:
sladro 2025-12-26 16:14:28 +08:00
parent 79ce131bea
commit c747942855

View File

@ -204,12 +204,23 @@ private:
}
// Calculate proper strides (RGA requires aligned strides)
int src_wstride = frame->planes[0].stride > 0 ? frame->planes[0].stride
: (frame->stride > 0 ? frame->stride : Align16(frame->width));
// For YUV formats, wstride is the width of Y plane
// For RGB/BGR formats, wstride is width (not width*3)
int src_wstride = Align16(frame->width);
int src_hstride = Align16(frame->height);
int dst_wstride = Align16(out_w);
int dst_hstride = Align16(out_h);
if (processed_ < 3) {
std::cout << "[preprocess] src: " << frame->width << "x" << frame->height
<< " fmt=" << static_cast<int>(frame->format) << " rga_fmt=" << src_fmt_rga
<< " wstride=" << src_wstride << " hstride=" << src_hstride
<< " data_size=" << frame->data_size << "\n";
std::cout << "[preprocess] dst: " << out_w << "x" << out_h
<< " fmt=" << static_cast<int>(out_fmt) << " rga_fmt=" << dst_fmt_rga
<< " wstride=" << dst_wstride << " hstride=" << dst_hstride << "\n";
}
rga_buffer_t src_buf{};
rga_buffer_t dst_buf{};
DmaBufferPtr src_dma_buf; // Keep alive if we allocate