I want to convert an image from RGBA to YUV420 on the Orin. According to various threads on this forum this should be possible using the NvBufferTransform
method. Somehow I cannot get this to work, I get a Segmentation fault
no matter what.
I put together a minimal example. In this example I don’t try to do color conversion but just any transformation at all but it still fails with a Segmentation fault
:
int dmaFd1;
int dmaFd2;
unsigned long out_buf_size;
unsigned char *out_buf;
int width = 100;
int height = 100;
NvBufferCreateParams paramsCreate1 = {.width = width,
.height = height,
.payloadType = NvBufferPayload_SurfArray,
.layout = NvBufferLayout_BlockLinear,
.colorFormat = NvBufferColorFormat_GRAY8,
.nvbuf_tag = NvBufferTag_NONE};
NvBufferCreateParams paramsCreate2 = {.width = width,
.height = height,
.payloadType = NvBufferPayload_SurfArray,
.layout = NvBufferLayout_BlockLinear,
.colorFormat = NvBufferColorFormat_GRAY8,
.nvbuf_tag = NvBufferTag_NONE};
NvBufferCreateEx(&dmaFd1, ¶msCreate1);
NvBufferCreateEx(&dmaFd2, ¶msCreate2);
unsigned char *dummy_data = new unsigned char[width * height];
for (int i = 0; i < width * height; i++){
dummy_data[i] = 42;
}
Raw2NvBuffer(dummy_data, 0, width, height, dmaFd1);
NvBufferTransformParams paramsTransform;
paramsTransform.transform_flag = NVBUFFER_TRANSFORM_FLIP;
paramsTransform.transform_flip = NvBufferTransform_None;
int retNv = NvBufferTransform(dmaFd1, dmaFd2, ¶msTransform);
Any ideas what’s wrong here?