Hi,
Currently I have constructed a custom element that separate one video source to 2 video. For example, one 800x1200 video separate to two 800x600 video. I use memcpy method to copy video data to 2 new GstBuffer and then push it to src pad. So it costs much more cpu usage. I further check the tee element, which also branch a new pipeline, a new GstBuffer and low cpu usage. But I could not find what I want, it seems using gst_pad_push_list(), I didn't find out where it copies the data. Could someone give any example or reference for the DMA copy? Many thanks. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
That depends on what you want to do. If the buffers you push to
downstream will not be changed, then you can just add ref to the Gstbuffer and no need to copy it. If they will be changed/written, you need to do the copy. The GstAllocator has a mem_copy function to let you provide your own memcpy function for GstMemory. It will be called when the GstBuffer really needs a copy. On Mon, 2021-05-31 at 06:58 -0500, ChrisLiuv via gstreamer-devel wrote: > Hi, > > Currently I have constructed a custom element that separate one video > source > to 2 video. > For example, one 800x1200 video separate to two 800x600 video. > I use memcpy method to copy video data to 2 new GstBuffer and then > push it > to src pad. > So it costs much more cpu usage. > > I further check the tee element, which also branch a new pipeline, a > new > GstBuffer and low cpu usage. > But I could not find what I want, it seems using gst_pad_push_list(), > I > didn't find out where it copies the data. > > Could someone give any example or reference for the DMA copy? > Many thanks. > > > > > -- > Sent from: http://gstreamer-devel.966125.n4.nabble.com/ > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by GStreamer-devel mailing list
El lunes, 31 de mayo de 2021 13:58:32 (CEST) ChrisLiuv via gstreamer-devel
escribiĆ³: > Currently I have constructed a custom element that separate one video source > to 2 video. > For example, one 800x1200 video separate to two 800x600 video. > I use memcpy method to copy video data to 2 new GstBuffer and then push it > to src pad. > So it costs much more cpu usage. > > I further check the tee element, which also branch a new pipeline, a new > GstBuffer and low cpu usage. > But I could not find what I want, it seems using gst_pad_push_list(), I > didn't find out where it copies the data. Looking at the loop where gst_tee_handle_data() iterates over all the pads[1] and to the code that actually pushes the buffers[2], it looks like the original GstBuffer isn't actually copied, just having its reference count increased (because it's going to be used from each of the downstream pipeline branches) and pushed to all the pads. So, apparently, it's effectively the same buffer. If you add probes on each of the downstream branches, you should see that the same GstBuffer* pointer values appears on all the branches. Cheers. [1] https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/master/plugins/ elements/gsttee.c#L941 [2] https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/master/plugins/ elements/gsttee.c#L856 -- Enrique OcaƱa _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by GStreamer-devel mailing list
Hi,
Thanks for your reply. My video data is form 2 image sensor, and is line interleaved, so I need to deinterleave it first. The gstdmabuf.html <https://gstreamer.freedesktop.org/documentation/allocators/gstdmabuf.html?gi-language=c> only explains allocate and check, don't know the difference between gstallocator.html <https://gstreamer.freedesktop.org/documentation/gstreamer/gstallocator.html?gi-language=c> Seems that I need to implement it myself? I searched the current gst-plugin-good, only v4l2 uses gst_dmabuf_allocator_new (); sys/v4l2/gstv4l2bufferpool.c:517: pool->allocator = gst_dmabuf_allocator_new (); I'll further check how it work. Any suggestions would be greatly appreciated. Thanks. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |