Skip to content

Commit f4e98ba

Browse files
committed
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
1 parent d24a8f7 commit f4e98ba

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Word16 WriteBits(HANDLE_BIT_BUF hBitBuf,
152152

153153
wBitPos = hBitBuf->wBitPos;
154154
wBitPos += noBitsToWrite;
155+
writeValue &= ~(0xffffffff << noBitsToWrite); // Mask out everything except the lowest noBitsToWrite bits
155156
writeValue <<= 32 - wBitPos;
156157
writeValue |= hBitBuf->cache;
157158

0 commit comments

Comments
 (0)