Hi,In my gstreamer pipeline,If I use the gst_buffer_map interface to map the GstBuffer in appsink_sink_pad_buffer_probe function and get the pointer to NvBufSurface,I can get the bufferdesc param through the NvBufSurface pointer.my simple code is as follows:
static GstPadProbeReturn appsink_sink_pad_buffer_probe(
GstPad *pad, GstPadProbeInfo *info, gpointer u_data) {
GstBuffer *buf = (GstBuffer *)info->data;
GstMapInfo in_map_info;
NvBufSurface *in_surf = NULL;
memset(&in_map_info, 0, sizeof(in_map_info));
/* Map the buffer contents and get the pointer to NvBufSurface. */
if (!gst_buffer_map(buf, &in_map_info, GST_MAP_READ)) {
GST_ERROR("gst_buffer_map failed\n");
return GST_PAD_PROBE_OK;
}
in_surf = (NvBufSurface *)in_map_info.data;
printf("NvSurface:batchSize=%d,numFilled=%d,isContiguous=%d,memtype=%d\n",
in_surf->batchSize,
in_surf->numFilled,
in_surf->isContiguous,
in_surf->memType);
printf("NvBufSurfaceParams:w=%d,h=%d,pitch=%d,colorformat=%d,layout=%d,bufferDesc=%ld,dataSize=%d,dataPtr=%p\n",
in_surf->surfaceList[0].width, in_surf->surfaceList[0].height,
in_surf->surfaceList[0].pitch,in_surf->surfaceList[0].colorFormat,
in_surf->surfaceList[0].layout,
in_surf->surfaceList[0].bufferDesc,in_surf->surfaceList[0].dataSize,
in_surf->surfaceList[0].dataPtr);
for(int i = 0;i < in_surf->surfaceList[0].planeParams.num_planes;i++)
{
printf("planeParams:plane[%d],w=%d,h=%d,pitch=%d,offset=%d,psize=%d,bytesPerPix=%d\n",i,
in_surf->surfaceList[0].planeParams.width[i],
in_surf->surfaceList[0].planeParams.height[i],
in_surf->surfaceList[0].planeParams.pitch[i],
in_surf->surfaceList[0].planeParams.offset[i],
in_surf->surfaceList[0].planeParams.psize[i],
in_surf->surfaceList[0].planeParams.bytesPerPix[i]);
}
gst_buffer_unmap(buf, &in_map_info);
return GST_PAD_PROBE_OK;
}
my pipeline: filesrc location=sample_1080p.jpg ! jpegparse ! nvv4l2decoder ! nvstreammux ! nvinfer ! nvvideoconvert ! ‘video/x-raw(memory:NVMM),format=I420’ ! appsink
After completing the pipeline construction,I added probe callback function on sink pad of appsink.The simple code is as follows:
app_sink_pad = gst_element_get_static_pad(appsink, “sink”);
if (! app_sink_pad)
g_print(“Unable to get sink pad\n”);
else
gst_pad_add_probe(app_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
appsink_sink_pad_buffer_probe, NULL, NULL);
gst_object_unref(pgie_src_pad);
When I run my pipeline,The output parameters in callback function are printed as follows:
NvSurface:batchSize=1,numFilled=1,isContiguous=0,memtype=0
NvBufSurfaceParams:w=1920,h=1080,pitch=2048,colorformat=31,layout=0,bufferDesc=1324,dataSize=3538944,dataPtr=0x7f4c00b3b0
planeParams:plane[0],w=1920,h=1080,pitch=2048,offset=0,psize=2228224,bytesPerPix=1
planeParams:plane[1],w=960,h=540,pitch=1024,offset=2228224,psize=655360,bytesPerPix=1
planeParams:plane[2],w=960,h=540,pitch=1024,offset=2883584,psize=655360,bytesPerPix=1
I want to know if the buffer corresponding to the bufferDesc param is a dma buffer or a cpu buffer.Because the dma buffer output width and height param must be 32 bytes aligned according to the information you have given, the output width end height should be 1920*1088.But the print above is the actual width and height, so I have questions about the properties of the buffer。Hope to give me a clear answer.