Revert unsafe DMA inference handoff

This commit is contained in:
tian 2026-03-14 21:22:11 +08:00
parent 7d5bec8040
commit b5dc20f7bf
2 changed files with 10 additions and 15 deletions

View File

@ -571,7 +571,6 @@ private:
const uint8_t* model_input_data = nullptr;
size_t model_input_size = 0;
int model_input_dma_fd = -1;
if (image_processor_ && win_w > 0 && win_h > 0) {
Frame crop_frame;
@ -596,11 +595,7 @@ private:
? resized_frame.planes[0].stride
: (resized_frame.stride > 0 ? resized_frame.stride : model_w_ * 3);
const size_t packed_size = static_cast<size_t>(model_w_) * static_cast<size_t>(model_h_) * 3;
if (resized_frame.DmaFd() >= 0 && resized_data) {
model_input_data = resized_data;
model_input_size = resized_frame.data_size > 0 ? resized_frame.data_size : packed_size;
model_input_dma_fd = resized_frame.DmaFd();
} else if (resized_data && resized_stride > 0) {
if (resized_data && resized_stride > 0) {
if (packed_size > input_buf_.size()) input_buf_.resize(packed_size);
for (int row = 0; row < model_h_; ++row) {
memcpy(input_buf_.data() + static_cast<size_t>(row) * static_cast<size_t>(model_w_) * 3,
@ -627,7 +622,6 @@ private:
input.is_nhwc = true;
input.data = model_input_data;
input.size = model_input_size;
input.dma_fd = model_input_dma_fd;
input.type = RKNN_TENSOR_UINT8;
auto r = infer_backend_->InferBorrowed(model_handle_, input);

View File

@ -929,14 +929,7 @@ private:
const int resized_stride = resized_frame.planes[0].stride > 0
? resized_frame.planes[0].stride
: (resized_frame.stride > 0 ? resized_frame.stride : static_cast<int>(input_row));
if (resized_frame.DmaFd() >= 0 && resized_data) {
input.data = resized_data;
input.size = resized_frame.data_size > 0 ? resized_frame.data_size : input_size;
input.width = model_input_w_;
input.height = model_input_h_;
input.dma_fd = resized_frame.DmaFd();
input.dma_offset = 0;
} else if (resized_data && resized_stride > 0) {
if (resized_data && resized_stride > 0) {
for (int y = 0; y < model_input_h_; ++y) {
memcpy(resized_input_.data() + static_cast<size_t>(y) * input_row,
resized_data + static_cast<size_t>(y) * static_cast<size_t>(resized_stride),
@ -946,6 +939,8 @@ private:
input.size = input_size;
input.width = model_input_w_;
input.height = model_input_h_;
input.dma_fd = -1;
input.dma_offset = 0;
} else {
ResizeRgbBilinear(src, w, h, src_stride,
resized_input_.data(), model_input_w_, model_input_h_,
@ -954,6 +949,8 @@ private:
input.size = input_size;
input.width = model_input_w_;
input.height = model_input_h_;
input.dma_fd = -1;
input.dma_offset = 0;
}
} else {
ResizeRgbBilinear(src, w, h, src_stride,
@ -963,6 +960,8 @@ private:
input.size = input_size;
input.width = model_input_w_;
input.height = model_input_h_;
input.dma_fd = -1;
input.dma_offset = 0;
}
} else {
ResizeRgbBilinear(src, w, h, src_stride,
@ -972,6 +971,8 @@ private:
input.size = input_size;
input.width = model_input_w_;
input.height = model_input_h_;
input.dma_fd = -1;
input.dma_offset = 0;
}
}
input.is_nhwc = true;