Patent ID: 8031953

Claim:
An encoding method to encode image data comprising a sequence of blocks with a predetermined compression rate in one pass, wherein the blocks are divided into two sets, a first set and a second set and the first set is followed by the second set, a current block is one of the blocks and the encoded current block comprises a current bit length and a lending bit length and a left bit length are both zero at the start of encoding, the encoding method comprising the steps of: encoding the blocks in the first set within the sum of an available bit length and a predetermined lending bit length, wherein the available bit length is calculated according to the predetermined compression rate and the left bit length; encoding the blocks in the second set within the available bit length; updating the lending bit length according to the current bit length and the available bit length after encoding the current block when the current block is in the first set and the current bit length is larger than the available bit length; updating the left bit length when the current block is the first set and the current bit length is not larger than the available bit length; updating the left bit length when the current block is the second set; and adjusting the left bit length according to a compensating bit length and adjusting the lending bit length according to the compensating bit length after performing calculations on the left bit length when the current block is in the second set, the lending bit length is positive and the left bit length is larger than a predetermined threshold.