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, ¶ms);
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