summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martin Storsjo <martin@martin.st> 2011-04-21 12:59:07 +0300
committer Martin Storsjo <martin@martin.st> 2012-01-31 10:35:49 +0200
commitf4e98bac0ff1e43cf2f789f717ea903e9e2a3511 (patch)
tree7a6d1b69ce8965cdc0d72d6032fdf07c10026a0e
parentd24a8f7c0a833fcb4aa7d794ad4656e662e91be9 (diff)
stagefright aacenc: Safeguard against overwriting bits
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
-rw-r--r--media/libstagefright/codecs/aacenc/src/bitbuffer.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/aacenc/src/bitbuffer.c b/media/libstagefright/codecs/aacenc/src/bitbuffer.c
index a706893d54e9..0ce93d395444 100644
--- a/media/libstagefright/codecs/aacenc/src/bitbuffer.c
+++ b/media/libstagefright/codecs/aacenc/src/bitbuffer.c
@@ -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;