Hi Folks,
I am looking to understand optimality of code in aforesaid example. Specifically, could someone please exlain -
- whether entire frame is being copied in memory in copyToNvBuffer() call below ?
- It seems that encoder is encoding from dmabuf_fd, then why is copy in #1 needed ?
bool VideoEncodeStreamConsumer::processFrame(Frame *frame)
{
IFrame *iFrame = interface_cast<IFrame>(frame);
if (iFrame == NULL)
{
m_VideoEncoder.encodeFromFd(-1); // EOS
return false;
}
if (g_bVerbose)
Log("%s: frame %d\n", __func__, iFrame->getNumber());
int dmabuf_fd = m_emptyBufferQueue.pop();
// Get the IImageNativeBuffer extension interface and copy to NvBuffer.
NV::IImageNativeBuffer *iNativeBuffer =
interface_cast<NV::IImageNativeBuffer>(iFrame->getImage());
if (!iNativeBuffer)
ORIGINATE_ERROR("IImageNativeBuffer not supported by Image.");
iNativeBuffer->copyToNvBuffer(dmabuf_fd);
m_VideoEncoder.encodeFromFd(dmabuf_fd);
return true;
}
Thanks