Query about tegra_multimedia/samples/frontend

Hi Folks,

I am looking to understand optimality of code in aforesaid example. Specifically, could someone please exlain -

  1. whether entire frame is being copied in memory in copyToNvBuffer() call below ?
  2. 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

Hi,

Yes.

// Create buffers
    for (unsigned i = 0; i < MAX_QUEUE_SIZE; i++)
    {
        int dmabuf_fd;

        if (NvBufferCreateEx(&dmabuf_fd, &input_params) < 0)
            ORIGINATE_ERROR("Failed to create NvBuffer.");

        m_emptyBufferQueue.push(dmabuf_fd);
    }

NvBuffers are created

iNativeBuffer->copyToNvBuffer(dmabuf_fd);

Copy Argus frames to NvBuffer

Argus frames are EGLStream::Image. For encoding, you need it to be NvBuffer