mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
1ef13dda12
Previously, we would create a new GstMemory per write operation and then append them to the GstBuffer. This would cause a reallocation every 16 Memories which is an issue since the png encoder will usually do write in a pattern of 4, 8 and 8k bytes repeating until the frame is done. Instead allocate a single GstMemory and keep writting it into it with a manual index. Much like the jpegenc does. Doing some basic testing With a testsrc snow pattern at 4k and 8k the same pipeline would take ~3.30s to encode a 4k frame and ~23s for an 8k. At 4k 0.70s/33% is taken by memory allocations, while at 8k its ~10.5s/45%. With this patch, at 4k the pipeline takes ~2.40s and at 8k only 9.60s making this 28% and 58% faster accordingly on my laptop, and allocation runtime is dropped to subsecond times. Here's the test pipeline used, increase num-buffers in image freeze to gather more samples. ``` gst-launch-1.0 videotestsrc num-buffers=1 pattern=snow ! imagefreeze num-buffers=1 ! \ video/x-raw,width=7680,height=4320 ! pngenc ! fakesink ``` Close #2717 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4944> |
||
---|---|---|
.. | ||
gstpng.c | ||
gstpng.h | ||
gstpngdec.c | ||
gstpngdec.h | ||
gstpngenc.c | ||
gstpngenc.h | ||
meson.build |