pngenc: Copies way too much data
The way pngenc
handles data provided by the library is as follows:
- Create an "output"
GstBuffer
- In the write callback (
user_write_data()
):- Allocate a
GstMemory
- Copy the provided data into that
GstMemory
- Append that
GstMemory
to the output buffer
- Allocate a
While the copy above can't be avoided, there are a lot more copies going on because ... of the limit of GstMemory
that a GstBuffer
can handle (16). And the png library will call the write callback even for very small memory (4-8 bytes).
So what happens in the last step is that every 16 calls, the existing GstMemory
in the buffer will all be copied to a single GstMemory
!
Issue can be clearly seen with GST_DEBUG=2,*PERF*:9,*MEM*:8 gst-launch-1.0 videotestsrc num-buffers=1 ! video/x-raw,width=1024,height=2464 ! pngenc ! fakesink