Patent ID: 7334116

Claim:
A method of performing bit manipulation on data in a bitstream that is stored in a memory having an address boundary length, said method comprising: (I) transferring the data in the bitstream from the memory into a buffer, the buffer having a bit length greater than the address boundary length of the memory; (II) locating a number of valid bits to get in a predetermined alignment in the buffer; and (III) when the number of valid bits in the transferred data of the buffer is less than or equal to a register address bit length plus the number of bits to get, manipulating the transferred data while it is stored in the buffer, including: (i) loading the contents of the memory containing the bits to get into the buffer and a register, the buffer and the register having a bit length greater than the memory address bit length, (ii) logically left-shifting the loaded data stored in the buffer by M bits, wherein M is the number of bits between the buffer boundary and the most significant bit of the address pointed to by a bitstream pointer, (iii) logically right-shifting the loaded data stored in the register by the difference of the buffer bit length and M, (iv) logically summing the left-shifted contents of the buffer with the right-shifted contents of the register, (v) storing the logical sum in the buffer, (vi) logically right-shifting the logical sum in the buffer by the bit capacity of the buffer minus the number of bits to get, and (vii) shifting the bitstream pointer past the memory address holding the number of bits to get.