Creating NvBuffer for 21:9 image

Hi,

I’m using the Jetson Multimedia API (32.6.1) on an AGX Xavier to work with some cameras. After some processing, my output image needs to be of the size 1720x720 (21:9 ultrawide).

I create an NvBuffer for the output as follows:

    int dmabuf_fd;
    NvBufferCreateParams params = {0};
    params.width = 1720;
    params.height = 720;
    params.layout = NvBufferLayout_Pitch;
    params.nvbuf_tag = NvBufferTag_VIDEO_CONVERT;
    params.colorFormat = NvBufferColorFormat_ABGR32;
    if (-1 == NvBufferCreateEx(&dmabuf_fd, &params)) {
        std::cout << "Failed to create output NvBuffer.\n";
        return 0;
    }

However, this creates a buffer with the wrong pitch. When I read the params of this NvBuffer, I get the pitch as 6912, when expected value should be 6880 (4x 1720). This is causing my output to look fragmented and weird.

Appreciate any help to create an NvBuffer with the correct parameters.

(additional info: I am getting the output image from some OpenCV CUDA processing and copying it to the output NvBuffer. If I create an output buffer with standard sizes, I can see the image properly as the buffer gets created with correct pitch).

Hi,
This is expected since NvBuffer is hardware DMA buffer. For some resolutions, pitch is not equivalent to width and you would need to consider data alignment. Please call NvBufferGetParams() to get pitch, width, and height.

Hi,

For my output buffer, I get the following with NvBufferGetParams when I have created it using NvBufferCreateEx:

W=1720, H=720, Pitch=6912, Nvbufsize=1008

So do I need to use a memory copy operation to get my data into this buffer? I am already using a copy operation to get data from an OpenCV GpuMat of size 1720x720 into this NvBuffer.

Hi,
You would need to copy the data line by line like:

  1. At offset 0, copy 1720*4 bytes
  2. Go to offset 6912, copy 1720*4 bytes
  3. Go to offset 6912*2, copy 1720*4 bytes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.