This patch set adds 2 enhancements to put_bits.  First bounds checking
the destination buffer to prevent invalid writes.  Second uint64_t
internal bit cache for a small, but measurable, performance increase
on 64bit systems.

I discussed this series of patches with Luca on IRC.  I started looking
at put_bits because of a buffer overflow problem in aacenc.c.  The
solution to aacenc.c was to either allocate an over-sized buffer for
it to encode into or to bounds check put_bits.

Bounds checking put_bits has a couple of advantages.  It is a security
enhancement since it prevents buffer overflow conditions.  And it adds
the capability to measure the size of a buffer without pre-allocating
an oversized buffer to render into.

I did some basic performance measurements after adding bounds checking
and any loss of performance was indetectable. My "benchmark" was to
create a 1 hour pcm audio file (so decoding wasn't a factor) and
transcode to wmav2.  This results in a 22 second encode where the
difference in encode times was not measureable.  Run to run variation
exceeded any difference there might be.

After doing the above performance tests, I was curious if put_bits
performance could be improved by using uint64_t for it's cache.  This
resulted in a small, but measurable improvement on x86_64.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to