basler / gst-plugin-pylon

The official GStreamer plug-in for Basler cameras
BSD 3-Clause "New" or "Revised" License
42 stars 10 forks source link

Fix buffer size for non-NVMM buffer when chunk enabled #101

Closed AdminXVII closed 6 months ago

AdminXVII commented 6 months ago

When chunk data is active, GetBufferSize() returns the size of the image itself plus the chunk data. However, the GstBuffer should only contain the image data since the metadata is already parsed and put into the buffer's "Meta"s.

Tested using the pipeline pylonsrc user-set=UserSet1 | bayer2rgb | filesink location=<...> where UserSet1 has chunk data enabled. Previous behaviour was for bayer2rgb to fail because the buffer size did not match the expected size (width * height), now it works as expected.

thiesmoeller commented 6 months ago

Thanks for providing the PR.

In chunked mode the image will always start at byte 0 of the buffer.

Checking the NVMM path, we don't have the problem here, as we simply transfer base buffer pointer and the shape/type. So memory size will fit.

AdminXVII commented 6 months ago

Yes, this only changes the non-NVMM path. The offset is 0 and is correct, however the problem is with the buffer passed to GStreamer. The pipeline expects only the image data in the buffer (GetImageSize()), but currently the plugin passes the framegrabber buffer size (GetBufferSize()), which is GetImageSize() + the size of the chunks (the latter being already passed as metas).