[gst-devel] RE : Re: aligned(16) GstBuffer Payload ?

SP GLE spglegle at yahoo.fr
Sun Oct 14 17:32:55 CEST 2007


Hi,
thanks for all answers.

- I had seen the problem with posix_memalign/memalign requesting free
to be used and probably incompatible with g_free(), so some parts of my
code rely on posix_memalign + free(), but most of the processing is
done outside of this code ::

I'm writing a server handling a lot of buffers and adding,
substracting, multiplicating all samples in each buffer (160 samples
each 20ms, for each member (it's a conference server, with a total of
>100 members)). Even if liboil is able to handle unaligned buffers it
seems to use raw loops to compute (remaining) unaligned data. So any
improvement is interesting .....

But switching GstBuffer to posix_memalign is not a good thing (IMHO), :
- GstBuffers are often allocated for a limited time, there are groups
of GstBuffers with the same size (eg before decoding, before encoding,
after...etc), so relying on g_slice dramatticaly improves performances
over malloc and posix_memalign. 

- Aligned buffers are interesting if the compute time gain is over
posix_memalign cost (so if GstBuffer payload is often used with
SSE/liboil).

Regards.

--- Stefan Kost <ensonic at hora-obscura.de> a écrit :

> hi,
> 
> David Schleef wrote:
> > On Fri, Oct 12, 2007 at 05:05:58PM +0200, SP GLE wrote:
> >> is there a way to get a GstBuffer with a configurable memaligned
> >> payload (aligned(16)), in order to use payload with SSE2 and other
> >> liboil methods (even if liboil can work on not aligned data, using
> >> aligned could speed up some processing).
> > 
> > There are very few situations where allocating aligned buffers to
> > use with liboil will result in faster performance.  Liboil was
> designed
> > to allow you to use it without thinking of such things.
> > 
> > In any case, you can create aligned buffers by allocating a normal
> > buffer with extra padding, and creating an appropriate subbuffer.
> > Alternately, you could create a subclass of GstBuffer similar to
> > the efence element in -good.  Or you could patch gstbuffer.c and
> > add a function similar to gst_buffer_new_and_alloc() that allocates
> > memory using posix_memalign() instead of mallc().
> > 
> I was recently looking at it. Unfortunately gst_buffer_new_and_malloc
> uses
> g_malloc and g_free (we need to fix the docs regarding this). data
> allocated
> using posix_memalign() should be free'ed with free(). It could
> confuse glib if
> its free'ed with g_free(). So a subclass shoudl override the
> GstMiniObjectFinalizeFunction and properly release the memory. On the
> other hand
> I wonder if we should perhaps switch GstBuffer to use
> posix_memalign() and free().
> 
> Stefan
> 
> > 
> > 
> > dave...
> >
> 



      ____________________________________________________________________________________________
Découvrez le blog Yahoo! Mail : dernières nouveautés, astuces, conseils.. et vos réactions !
http://blog.mail.yahoo.fr




More information about the gstreamer-devel mailing list