NvMedia SIPL API, correct time to release the buffer reference

Please provide the following info (check/uncheck the boxes after clicking “+ Create Topic”):
Software Version
DRIVE OS Linux 5.2.0
DRIVE OS Linux 5.2.0 and DriveWorks 3.5
NVIDIA DRIVE™ Software 10.0 (Linux)
NVIDIA DRIVE™ Software 9.0 (Linux)
other DRIVE OS version
other

Target Operating System
Linux
QNX
other

Hardware Platform
NVIDIA DRIVE™ AGX Xavier DevKit (E3550)
NVIDIA DRIVE™ AGX Pegasus DevKit (E3550)
other

SDK Manager Version
1.6.0.8170
1.5.1.7815
1.5.0.7774
other

Host Machine Version
native Ubuntu 18.04
other

Hi,
When using the NvMedia SIPL API, inside the callback function implemented by my app and registered with SIPL, I’m feeding the buffer into a queue and adding a ref count via

INvSIPLBuffer->AddRef()

In another consumer thread, I’m popping from this queue and using the GetImage() API to feed the image pointer obtained from the buffer to an encoder.

My question is, what is the correct instance to release the buffer? Is it right after feeding the NvMediaImage* to the encoder, or do I need to wait for the encoder to be done to release the buffer?

Thanks

Hi @goksani,

Please refer to nvsipl::INvSIPLClient::INvMCallback::OnFrameAvailable(). The consumer must release it.

The consumer must use INvSIPLBuffer::AddRef and INvSIPLBuffer::Release on the buffer if it intends to consume the buffer asynchronously in a different thread.

Yes I am aware of the fact that consumer must release it.

What I’m asking is, if the consumer is the encoder, should it be release right after feeding it to the encoder, or after the encoder is done. This would depend on inner workings of the encoder, based on if its copying the frame and how its reading the memory, etc. which we as users do not have access to.

What encoder are you referring to? NvMedia?
May I know what APIs you are using?

I’m using NvMediaIEPFeedFrame() and NvMediaIJPEFeedFrame()

https://docs.nvidia.com/drive/drive-os-5.2.0.0L/drive-os/DRIVE_OS_Linux_SDK_Development_Guide/baggage/group__image__encode__api.html#gaa9e51f6cce9137ad64699069bb912168

https://docs.nvidia.com/drive/drive-os-5.2.0.0L/drive-os/DRIVE_OS_Linux_SDK_Development_Guide/baggage/group__image__jpeg__encode__api.html#ga090ea2e5798da14e4527316a5bab82b8

There are internal buffers for the APIs so you should be able to release them right away.
Below is from NvMediaIEPFeedFrame().

Thank you for pointing this out. However, the buffering being explained above is for the output of the encoder. The more relevant parameter maxInputBuffering, which is the maximum number of allowed frames in the encode pipeline, is said to be deprecated.

After double-checking with our team, applications need to wait for the encoding to complete (by calling NvMediaIEPBitsAvailable()) before releasing the encoder input buffer.

Thank you for the correction.