Here’s my code to get the RGB Buffer
const int aDstOrder[3] = { 0, 1, 2 };
Npp8u *rgb_buf_gpu;
NppiSize oSrcSize = { DEFAULT_PROCESSING_WIDTH, DEFAULT_PROCESSING_HEIGHT };
memset (&in_map_info, 0, sizeof (in_map_info));
if (!gst_buffer_map (buf, &in_map_info, GST_MAP_READ)) {
g_print ("Error: Failed to map gst buffer\n");
}
surface = (NvBufSurface *) in_map_info.data;
CHECK_CUDA_STATUS (cudaMalloc ((void **) (&rgb_buf_gpu),
DEFAULT_PROCESSING_WIDTH * DEFAULT_PROCESSING_HEIGHT *
RGB_BYTES_PER_PIXEL), "Could not allocate cuda device buffer");
CHECK_NPP_STATUS (nppiSwapChannels_8u_C4C3R ((const Npp8u *) surface->buf_data[eventMsg->batch_id],
DEFAULT_PROCESSING_WIDTH * RGBA_BYTES_PER_PIXEL, (Npp8u *) rgb_buf_gpu,
DEFAULT_PROCESSING_WIDTH * RGB_BYTES_PER_PIXEL, oSrcSize, aDstOrder),
"Failed to convert RGBA to RGB");
I use buf_data of surface to get the frame and swap the channel from RGBA to RGB and it works well. Now I want to encode my RGB buffer as jpeg using NPP, I know there’s a sample code like NPPJpeg to do jpeg encoding, but I still can’t find out how to use it. Does anyone know how to do the encoding?
Thanks in advance