Why is the image data in the GstBuffer(NVMM) abnormal?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
XAVIER NX
• DeepStream Version
DEEPSTREAM 6.0
• JetPack Version (valid for Jetson only)
JetPack 4.6
• TensorRT Version
8.0.1.6
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
questions
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
I installed a probe function on the source pad of the plugin Queue after the plugin nvv4l2decoder. In the probe function, I tried to operate the image data in the GstBuffer and found that there was a problem. Then I tried to save the image data in the GstBuffer. But the saved data was incorrect - not a normal image.
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
1.First I mapped the GstBuffer as the following:
GstMapInfo info;
if (!gst_buffer_map (buffer, &info, GST_MAP_READ)) {
TS_ERR_MSG_V (“Failed to map the gstreamer buffer”);
return;
}

2.Then I get the NvBufSurface object and map it again:
NvBufSurface* surface = (NvBufSurface*) info.data;
if (NvBufSurfaceMap (surface, -1, -1, NVBUF_MAP_READ_WRITE) != 0) {
TS_ERR_MSG_V (“Failed to map the surface buffer”);
gst_buffer_unmap(buffer, &info);
return;
}

NvBufSurfaceSyncForCpu(surface, -1, -1);

3.And finally, I saved the Y in the image data:
FILE file = fopen(“/home/nvidia/work/app/build/y.data”, “wb”);
fwrite(surface->surfaceList[0].mappedAddr.addr[0], 1,
surface->surfaceList[0].planeParams.pitch[0]

surface->surfaceList[0].planeParams.height[0], file
);
fflush(file);
fclose(file);

4.I try to display the y.data in a tool, but I get a invalid picture.

At the same time, I print the members in the NvBufSurface:
NVSURFACE:
batchSize-1, numFilled-1, isContiguous-N, memType-4
surfaceList[0]:
width-1920, height-1080, pitch-1920
colorFormat-6, layout-1
bufferDesc-1205, dataSize-3538944
dataPtr-0x7f200b1470
planeParams: num_planes-2
planeParams[0]:
width-1920, height-1080, pitch-1920
offset-0, psize-2228224, bytesPerPix-1
planeParams[1]:
width-960, height-540, pitch-1920
offset-2228224, psize-1310720, bytesPerPix-2
mappedAddr: NVBUF_MAX_PLANES=4
addr[0]-0x7f81f46000
addr[1]-0x7f81ba3000
addr[2]-(nil)
addr[3]-(nil)

This is a hardware buffer which has special alignment layout.

You can refer to struct NvBufSurfaceParams to know the layout.

There is no update from you for a period, assuming this is not an issue anymore.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.