[x264-devel] x264_malloc/x264_free reduction patch

kemuri-_9 kemuri9 at gmail.com
Sun Dec 28 22:03:47 CET 2008


as there's been a small discussion going on doom9 about the number of
x264_malloc and x264_free calls that x264 performs and how to handle it.
here's a patch that reduces the number by removing some repetitive calls,

in hpel_filter: 1 call to each removed by changing method signature to
provide 1 buffer.
in pixel_ssim_wxh: 2 calls to each removed by changing method signature to
provide 2 buffers.

allocation buffers are added to the x264_t definition in the "thread-local"
section so each thread can have its own.
the buffers are allocated in encoder_open()  in the thread specific section,
so each thread has its own set of buffers (though ssim buffers aren't
allocated if not being calculated)
the buffers are free'd in encoder_close() in the thread specific section.
(which confirms no heap corrupts or seg faults at run time)

from some very small scale testing on a video w/ 1000 640x480-sized frames,
the number of x264_malloc/x264_free calls is reduced 97+% on default
settings w/o ssim calculation
and reduced 99+% w/ ssim calculation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.videolan.org/pipermail/x264-devel/attachments/20081228/c836d539/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x264_malloc_reduce.diff
Type: application/force-download
Size: 7656 bytes
Desc: not available
Url : http://mailman.videolan.org/pipermail/x264-devel/attachments/20081228/c836d539/attachment.bin 


More information about the x264-devel mailing list