Hi,Nvidia team:
When I run jetson_mutimedia_api sample 12_v4l2_camera_cuda. the image will be abnormal, it will be OK if I don’t use dmabuf.
My cameara resolution is 1600X1300, it should be the bytes alignment issue.
How can I padding the image to walk around this issue? Could you provide a demo?
BR//
ekeechg
November 3, 2025, 10:54am
4
Hi, DaneLLL
Where can I find the documents about NvBufSurfaceMapEglImage, NvBufSurfaceFromFd…
are these functions open source?
BR//
Hi,
Source code of NvBufSurface is private. Please check the document:
NVIDIA DeepStream SDK API Reference: Buffer Management API module | NVIDIA Docs
And please check the related code in the samples:
/usr/src/jetson_multimedia_api/samples/
Hi,DaneLLL:
I have port the code to my H265 encoder, it works.
But after run a few minute, it will crash, and print following log.
What is the problem?
BR
Hi,
You may be missing some map/unmap functions in the integration. Please check if any function calls are missing, or duplicated.
ekeechg
November 11, 2025, 1:39pm
9
Is the following code in the patch thread safe? can I call it in two thread??
"
static bool
cuda_mapping(context_t * ctx, int index)
{
NvBufSurface *srcSurf = NULL;
NvBufSurface *dstSurf = NULL;
/* Create EGLImage from dmabuf fd */
if (-1 == NvBufSurfaceFromFd(ctx->g_buff[index].dmabuff_fd, (void**)(&srcSurf)))
ERROR_RETURN("Failed to get NvBufSurface from FD");
/* Create Render buffer */
if(ctx->remap_fd == -1)
{
NvBufSurf::NvCommonAllocateParams params = {0};
params.memType = NVBUF_MEM_SURFACE_ARRAY;
params.width = srcSurf->surfaceList[0].width;
params.height = srcSurf->surfaceList[0].height;
params.layout = NVBUF_LAYOUT_PITCH;
params.colorFormat = srcSurf->surfaceList[0].colorFormat;
params.memtag = NvBufSurfaceTag_NONE;
if (NvBufSurf::NvAllocate(¶ms, 1, &ctx->remap_fd))
ERROR_RETURN("Failed to create NvBuffer");
}
if (-1 == NvBufSurfaceFromFd(ctx->remap_fd, (void**)(&dstSurf)))
ERROR_RETURN("Failed to get NvBufSurface from FD");
if (-1 == NvBufSurfaceMapEglImage(srcSurf, 0))
ERROR_RETURN("Failed to register the Egl");
if (-1 == NvBufSurfaceMapEglImage(dstSurf, 0))
ERROR_RETURN("Failed to register the Egl");
HandleEGLImageMapping(srcSurf->surfaceList[0].mappedAddr.eglImage,
dstSurf->surfaceList[0].mappedAddr.eglImage,
srcSurf->surfaceList[0].width,
srcSurf->surfaceList[0].height,
srcSurf->surfaceList[0].planeParams.bytesPerPix[0]);
/* Destroy EGLImage */
NvBufSurfaceUnMapEglImage(srcSurf, 0);
NvBufSurfaceUnMapEglImage(dstSurf, 0);
return true;
}
"
DaneLLL
November 12, 2025, 2:08am
10
Hi,
If you would like to access the same NvBufSurface in multiple threads, we would suggest add mutex lock.
ekeechg
November 13, 2025, 4:44am
11
Hi,
Is there anyway to crop the image without memcpy? I see the padding image way need memcpy.
DaneLLL
November 13, 2025, 6:47am
12
Hi,
Data alignment is hardware constraint. You can check if your camera source can generate frame data to fit the alignment. If the camera source cannot be adapted, re-mapping data through GPU is required.