NvBufferCreateEx with NvBufferColorFormat_NV12

When I create NvBuffer with NvBufferColorFormat_NV12, created buffer has 3 planes.
NV12 is semi-planer format. So I think num_planes should be 2. Is this behavior correct?

Environments

  • Jetson AGX Xavier
  • Jetpack 4.6.1
#include "nvbuf_utils.h"
#include <iostream>

void CheckNvBufferCreate(){
  NvBufferCreateParams input_params = {0};
  input_params.payloadType = NvBufferPayload_SurfArray;
  input_params.width = 1920;
  input_params.height = 1080;
  input_params.layout = NvBufferLayout_Pitch;
  input_params.nvbuf_tag = NvBufferTag_NONE;
  input_params.colorFormat = NvBufferColorFormat_NV12;

  int fd;
  auto ret = NvBufferCreateEx(&fd, &input_params);

  NvBufferParams params = {0};
  ret = NvBufferGetParams(fd, &params);

  std::cout << "NumPlanes: " << params.num_planes << std::endl;
  for (int i = 0; i < params.num_planes; i++) {
    std::cout << "Plane[" << i << "]" << std::endl;
    std::cout << "  Size: " << params.width[i] << "x" << params.height[i] << std::endl
              << "  Pitch: " << params.pitch[i] << std::endl;
  }
  NvBufferDestroy(fd);
}

int main(){
  CheckNvBufferCreate(NvBufferColorFormat_NV12);
}

This code output following.

NumPlanes: 3
Plane[0]
  Resolution: 1920x1080
  Pitch: 2048
Plane[1]
  Resolution: 960x540
  Pitch: 1024
Plane[2]
  Resolution: 960x540
  Pitch: 1024

Hi,
It seems like the header file nvbuf_utils.h may not fit the release. Please install jetson_multimedia_api samples and use the header files in

/usr/src/jetson_multimedia_api/include/

to build the sample and try again.

Hi DaneLLL.

I had used old api.
I got correct result using nvbuf_utils.h in /usr/src/jetson_multimedia_api/include.

Thanks a lot for help.

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