GNOME Bugzilla – Bug 751241
vtdec: handle non-consecutive GstBuffer input without copying
Last modified: 2015-08-16 13:40:28 UTC
CMBlockBuffer offers a model similar to GstBuffer, whereas it can consist of multiple non-consecutive memory blocks. Instead of using gst_buffer_map, we should: - iterate over the GstBuffer's memories - map the GstMemory objects individually - create a CMBlockBufferCustomBlockSource { .AllocateBlock = nil, .FreeBlock = { wrapper function that does gst_memory_unmap + unref }, .refCon = gst_mem } for each memory - call CMBlockBufferAppendMemoryBlock, passing the mapped pointer and the custom block source This complements bug 751071. Possibly, this function should be moved out into the applemedia library.
Created attachment 306272 [details] [review] vtdec: handle non-consecutive GstBuffer input without copying This patch implements non-contiguous CMBlockBuffers. In the process, I've realised we were using CMBlockBufferCreateWithMemoryBlock improperly. It does NOT copy its input buffer, so gst_buffer_unmap-ing immediately is incorrect. In the new implementation, its the CMBlockBuffer's responsibility to unmap. P.S. Once bug 747707 lands, I think cm_block_buffer_from_gst_buffer should move into the library.
Review of attachment 306272 [details] [review]: Looks good to me except for one comment. Can this be merged right away or does it depend on something else ? ::: sys/applemedia/vtdec.c @@ +585,3 @@ + GstMapInfo *info; + + mem = gst_memory_ref (gst_buffer_peek_memory (buf, i)); Use gst_buffer_get_memory(buf, i);
Depends on nothing else, please merge.
Created attachment 307354 [details] [review] vtdec: handle non-consecutive GstBuffer input without copying CMBlockBuffer offers a model similar to GstBuffer, as it can consist of multiple non-consecutive memory blocks. Prior to this change, what we were doing was: 1) Incorrect: CMBlockBufferCreateWithMemoryBlock does not copy the data, but we gst_buffer_unmap'd right away. 2) Inefficient: If the GstBuffer consisted of non-contiguous memory blocks, gst_buffer_map resulted in malloc / memcpy. With this change, we construct a CMBlockBuffer out of individual mapped GstMemory objects. CMBlockBuffer is made to retain the GstMemory objects (through the use of CMBlockBufferCustomBlockSource), so the original GstBuffer can be unref'd.
Changes: - gst_buffer_peek_memory -> gst_buffer_get_memory - removed function free_map_info_slice - added missing gst_memory_unref (mem) - added comment
Attachment 307354 [details] pushed as bfa054a - vtdec: handle non-consecutive GstBuffer input without copying