Closed zjhellofss closed 2 years ago
// do CUDA conversion: RGBA packed@res#2 --> BGR planar@res#2
ctx->cuda_converter->convert(egl_frame,
ctx->resize_width,
ctx->resize_height,
COLOR_FORMAT_BGR,
(void *)ctx->frame_buffer[buf_index],
ctx->cuda_stream);
cudaStreamSynchronize(ctx->cuda_stream);
这个地方的缓冲区的指针(void *)ctx->frame_buffer[buf_index]就是GPU上的存储区域。
我看了一下代码,是不是可以这样理解 从
JMI_API int nvjmi_decoder_retrieve_frame_data(nvJmiCtx *ctx, nvFrameMeta *frame_meta, void *frame_data)
{
if (frame_data)
{
memcpy((unsigned char *)frame_data, ctx->frame_buffer[frame_meta->frame_index], frame_meta->payload_size);
frame_meta->got_data = 1;
}
while (!ctx->frame_pools->try_push(frame_meta->frame_index) && !ctx->capture_plane_stop)
{
std::this_thread::yield();
}
return NVJMI_OK;
}
中获取的void *frame_data
是一个既指向主存又指向显存的指针
是的,jetson如果使用特定的cuda接口分配内存,cpu和gpu的指针是一样的,实现了零拷贝。可以参考https://github.com/fan-chao/cuda_utils/blob/main/source/cuda/cudaMappedMemory.h 里面的内存分配方式。
我明白了,大佬
如题,非常感谢