From f4e98bac0ff1e43cf2f789f717ea903e9e2a3511 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Thu, 21 Apr 2011 12:59:07 +0300 Subject: 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 --- media/libstagefright/codecs/aacenc/src/bitbuffer.c | 1 + 1 file changed, 1 insertion(+) 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; -- cgit v1.2.3-59-g8ed1b