this is my code
bool convertNV12ToRGB(uint8_t* nv12Buf, int width, int height, int pitch, uint8_t* rgbBuf) {
VPIImage nv12Image = nullptr;
VPIImage bgraImage = nullptr;
VPIStream stream = nullptr;
if (vpiStreamCreate(VPI_BACKEND_CUDA, &stream) != VPI_SUCCESS) {
AIMRTE_ERROR(“Failed to create VPI stream”);
return false;
}
VPIImageData nv12Data{};
nv12Data.bufferType = VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR;
nv12Data.buffer.pitch.format = VPI_IMAGE_FORMAT_NV12;
nv12Data.buffer.pitch.numPlanes = 2;
nv12Data.buffer.pitch.planes[0].data = nv12Buf;
nv12Data.buffer.pitch.planes[0].width = width;
nv12Data.buffer.pitch.planes[0].height = height;
nv12Data.buffer.pitch.planes[0].pitchBytes = pitch;
nv12Data.buffer.pitch.planes[1].data = nv12Buf + pitch * height;
nv12Data.buffer.pitch.planes[1].width = width / 2;
nv12Data.buffer.pitch.planes[1].height = height / 2;
nv12Data.buffer.pitch.planes[1].pitchBytes = pitch;
if (vpiImageCreateWrapper(&nv12Data, nullptr, VPI_BACKEND_CUDA, &nv12Image) != VPI_SUCCESS) {
AIMRTE_ERROR(“Failed to create NV12 VPIImage”);
vpiStreamDestroy(stream);
return false;
}
if (vpiImageCreate(width, height, VPI_IMAGE_FORMAT_BGRA8, 0, &bgraImage) != VPI_SUCCESS) {
AIMRTE_ERROR(“Failed to create BGRA8 VPIImage”);
vpiImageDestroy(nv12Image);
vpiStreamDestroy(stream);
return false;
}
VPIConvertImageFormatParams params{};
vpiInitConvertImageFormatParams(¶ms);
if (vpiSubmitConvertImageFormat(stream, VPI_BACKEND_CUDA, nv12Image, bgraImage, ¶ms) != VPI_SUCCESS) {
char err[256];
vpiGetLastStatusMessage(err, sizeof(err));
AIMRTE_ERROR(“Failed to submit NV12→BGRA conversion: {}”, err);
vpiImageDestroy(nv12Image);
vpiImageDestroy(bgraImage);
vpiStreamDestroy(stream);
return false;
}
but will be error
NV12→BGRA conversion: CUDA: Conversion not implemented between VPI_IMAGE_FORMAT_NV12 and VPI_IMAGE_FORMAT_BGRA8