GNOME Bugzilla – Bug 796499
Changing the returned data from the buffer so that it can be modified and read without copying
Last modified: 2018-11-03 15:37:31 UTC
The map function of the buffer element has returned a copy of the c buffer as an bytes object as MapInfo.data. This is bad when you want to edit the video buffer in an gst-python element because teh bytes element always copies the Data. Therefor i changed the Buffer functions map and unmap and the class MapInfo to return the data as an memory-view on the c buffer The MapInfo class has the same attributes as before and should be compatible
Created attachment 372554 [details] [review] The Patch
Created attachment 372555 [details] A gst-python element that uses the patch gst-launch-1.0 videotestsrc ! videoconvert ! numpye ! videoconvert ! xvimagesink
I'm guessing this is for version 1.14.1 not 1.4.1?
Would it be possible to a) make sure that the buffer can't go out of scope (and get destroyed) while there's a map, and b) to unmap the mapinfo if it was not unmapped explicitly once it goes out of scope?
As far as my understanding of python goes both a and b are handled automatically by the python garbage collector.
The issue is that the Gst.MapInfo returned by Gst.Buffer.map would have a bytes() object as .data member, not a memoryview(). And the original pointer would get lost when the GstMemoryInfo c structure was recreated from the python object to be passed to gst_buffer_unmap. https://paste.debian.net/1049985/ This would be a dirty fix https://pastebin.com/NmUw1F3A
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-python/issues/13.