[vlc-devel] [vlc-commits] avcodec: avoid unneeded memcpy in?EncodeVideo/Audio

Ilkka Ollakka ileoo at videolan.org
Thu Feb 16 11:57:47 CET 2012


On Tue, Feb 14, 2012 at 09:29:33AM +0100, Rémi Denis-Courmont wrote:
> On Tue, 14 Feb 2012 09:34:08 +0200, Ilkka Ollakka <ileoo at videolan.org>
> wrote:
> > I was thinking that with somewhat modern systems, having 1 megabyte
> > (seems to be case with 720x576 resolution) block would not really show
> > up anywhere? There is big change that I'm wrong with this ofcourse.

> Allocating a large block of memory can be slower than copying a small
> block... This is not (only) a memory consumption problem.

Yes, I actually tested it littlebit now. Attached small testcode what I
used. Basicly I simulate mallocing one big buffer and in loop mallocing
small block and memcpy it into buffer, similar that avcodec did earlier.
Also left out in measurement time the time it takes to malloc that big
buffer.

Next loop allocates only big buffer simulating that we don't need to
memcpy from buffer to block.

With that test I get much faster performance in just one large malloc
which is same size always. Real world performance probably is not that
dramatically. I'm all ears if there is something wrong of this line of
thought.

Those buffer values and smaller block sizes I took as estimate from
avcodec buffer calculator and encode size returned. Didn't check how
much gcc optimizes stuff out from those loops, so it can be one possible
cause of results.

-- 
Ilkka Ollakka
Some programming languages manage to absorb change, but withstand
progress.
		-- Epigrams in Programming, ACM SIGPLAN Sept. 1982
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testi.c
Type: text/x-c++src
Size: 1109 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120216/d7bc36c7/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120216/d7bc36c7/attachment.sig>


More information about the vlc-devel mailing list