After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796499 - (GstBuffer.memoryview) Changing the returned data from the buffer so that it can be modified and read without copying
(GstBuffer.memoryview)
Changing the returned data from the buffer so that it can be modified and rea...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-python
1.14.1
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-06-05 12:20 UTC by Daniel Klamt
Modified: 2018-11-03 15:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The Patch (2.48 KB, patch)
2018-06-05 12:21 UTC, Daniel Klamt
none Details | Review
A gst-python element that uses the patch (1.82 KB, text/x-python)
2018-06-05 12:23 UTC, Daniel Klamt
  Details

Description Daniel Klamt 2018-06-05 12:20:30 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
Comment 1 Daniel Klamt 2018-06-05 12:21:30 UTC
Created attachment 372554 [details] [review]
The Patch
Comment 2 Daniel Klamt 2018-06-05 12:23:53 UTC
Created attachment 372555 [details]
A gst-python element that uses the patch

gst-launch-1.0 videotestsrc ! videoconvert ! numpye ! videoconvert ! xvimagesink
Comment 3 Tim-Philipp Müller 2018-06-05 12:45:03 UTC
I'm guessing this is for version 1.14.1 not 1.4.1?
Comment 4 Sebastian Dröge (slomo) 2018-06-06 06:34:15 UTC
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?
Comment 5 Daniel Klamt 2018-07-11 13:35:01 UTC
As far as my understanding of python goes both a and b are handled automatically by the python garbage collector.
Comment 6 Daniel Klamt 2018-11-02 13:26:13 UTC
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
Comment 7 GStreamer system administrator 2018-11-03 15:37:31 UTC
-- 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.