OSDN Git Service

stagefright aacenc: Safeguard against overwriting bits
authorMartin Storsjo <martin@martin.st>
Thu, 21 Apr 2011 09:59:07 +0000 (12:59 +0300)
committerMartin Storsjo <martin@martin.st>
Tue, 31 Jan 2012 08:35:49 +0000 (10:35 +0200)
Previously, if bits above the lowest noBitsToWrite were
set, they would be ORed into the previous cache word,
setting unrelated bits erroneously.

This doesn't noticeably affect the performance of the
codec as a whole.

Change-Id: Ie9935533c4299b8f07cb14485f039a9be9c84016

media/libstagefright/codecs/aacenc/src/bitbuffer.c

index a706893..0ce93d3 100644 (file)
@@ -152,6 +152,7 @@ Word16 WriteBits(HANDLE_BIT_BUF hBitBuf,
 
   wBitPos = hBitBuf->wBitPos;
   wBitPos += noBitsToWrite;
+  writeValue &= ~(0xffffffff << noBitsToWrite); // Mask out everything except the lowest noBitsToWrite bits
   writeValue <<= 32 - wBitPos;
   writeValue |= hBitBuf->cache;