From 3989d5c21ce6d1f3492c9e5484d610d5d66abd9e 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(+) (limited to 'media/libstagefright/codecs/aacenc') diff --git a/media/libstagefright/codecs/aacenc/src/bitbuffer.c b/media/libstagefright/codecs/aacenc/src/bitbuffer.c index a706893..0ce93d3 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.1