Jpeg decodeToFd conflict with the NvBufferCreateEx

hi,now i decode the jpeg with the decodeToFd (int &fd…) in a thread,and another thread use the NvBufferCreateEx create fd and use NvBufferDestroy distroy the fd ,but i found that may happen when NvBufferCreateEx fd value is equal with the fd of decodeToFd (int &fd…),so i want to know whether the two functions not lock the fd value so cause the same fd value will be used

Hi,
It seems impossible because it allocates an NvBuffer in decodeToFd(). It is an individual buffer and should have a unique fd.

We suggest check code about MJPG decoding in 12_camera_v4l2_cuda. Once you get decoded data by calling decodeToFd(), copy the data to other NvBuffers by calling NvBufferTransform().

hi DaneLLL,i have do it like you say copy the data to other NvBuffers by calling NvBufferTransform() at a thead ,but if i use the NvBufferCreateEx create fd and use NvBufferDestroy destroy the fd,it will happen error ,because i will create the same fd value with the decodeToFd ,if i destroy it ,the decodeToFd thread will happen error,so i want to know why the fd not lock in the decodeToFd function?

Hi,
Generally we create NvBuffer in initialization and destroy the buffers at termination. Are you able to try this? And please not destroy the NvBuffer returned by decodeToFd(). the buffer will be destroyed in deleting NvJPEGDecoder.

hi DaneLLL,thanks for your help,now i do it just like this to avoid the error happen,i just want to know the reason conflict or next jetpack will fix the problem

Hi,
We think the suggestion of allocating buffers at initialization and releasing buffers at termination is good. Would suggest you apply it to your application.