I use 14_multivideo_decode in mmapi.
My decided data format is YUV420.
I need to get the data and convert into ABGR format.
Then I tried to use NvBufferTransform, but an error occured with “NvMapMemCacheMaint Bad parameter”.
What shoud I do ?
A part of my code is as below.
//declaration
input_params.payloadType = NvBufferPayload_SurfArray;
input_params.width = crop.c.width;
input_params.height = crop.c.height;
input_params.layout = NvBufferLayout_Pitch;
input_params.colorFormat = NvBufferColorFormat_ABGR32;
input_params.nvbuf_tag = NvBufferTag_NONE;
ret = NvBufferCreateEx(&ctx->transform_fd, &input_params);
//process
NvBufferTransformParams transParams;
memset(&transParams, 0, sizeof(NvBufferTransformParams));
transParams.transform_flag = NVBUFFER_TRANSFORM_FILTER;
transParams.transform_filter = NvBufferTransform_Filter_Smart;
transParams.src_rect.width = ctx->display_width;
transParams.src_rect.height = ctx->display_height;
transParams.dst_rect.width = ctx->display_width;
transParams.dst_rect.height = ctx->display_height;
cv::Mat src = cv::Mat::zeros(ctx->display_height, ctx->display_width, CV_8UC4);
cv::Mat image;
void * ptr_top;
uint8_t *ptr_cur;
if (-1 == NvBufferTransform(ctx->dmabuff_fd[v4l2_buf.index], ctx->transform_fd, &transParams))
NvBufferMemMap(ctx->transform_fd, 0, NvBufferMem_Read_Write, &ptr_top); //ptr_top is void*
NvBufferMemSyncForCpu(ctx->transform_fd, 0, &ptr_top);
memcpy(src.data, ptr_top, ctx->display_height * ctx->display_width * 4);
cv::cvtColor(src, image, cv::COLOR_BGRA2BGR);