This application claims the benefit of Taiwan application Serial No. 102111971, filed Apr. 2, 2013, the subject matter of which is incorporated herein by reference.
1. Field of the Invention
The invention relates in general to a decompression circuit, and more particularly to a Lempel-Ziv-Markov chain-Algorithm (LZMA) decompression circuit and associated decompression method.
2. Description of the Related Art
In a compression operation using the Lempel-Ziv-Markov chain-Algorithm (LZMA), a repeating string is compressed into a distance-length pair. For example, a string “ABCDABCE” is compressed into “A, B, C D (4, 3), E”, where (4, 3) is referred to as a distance-length pair that represents three literals (i.e., A, B, and C) (length) of four previous literals (distance). Another compression operation is then performed to generate compressed data. In a decompression process, the compressed data is decompressed, by binary arithmetic coding (BAC), into “A, B, C, D, (4, 3), E”, which is then restored into “ABCDABCE” using an LZ77 decompression operation. When decompressing a next literal (commonly referred to as “delta literal”, which is “E” in this example) of the length-distance pair using the BAC, a previous literal (the seventh literal “C” in this example) and the next literal (the fourth literal “D” in this example) of the string corresponding to the distance-length pair are used. Therefore, when decompressing “E” using the BAC, “C” and “D” can only be provided to a front-end for the BAC decompression after the distance-length pair (4, 3) is decompressed by the LZ77 operation, leading to reduced decompression efficiency. Further, compression/decompression utilizing the LZMA is all implemented through software.
The invention is directed to a decompression circuit and associated decompression and compression method for effective decompression that solves issues of the prior art.
According to an embodiment of the present invention, a compression method for compressing a string is provided. The compression method comprises generating a distance-length pair according to a plurality of literals in the string, and compressing a next literal following the literals. Data associated with the distance-length pair is not used when compressing the next literal.
According to another embodiment of the present invention, a decompression circuit for decompressing data is provided. The decompression circuit includes a first decompression unit and a second decompression unit. The data sequentially comprises a compressed first string, a compressed distance-length pair, and a compressed second string. The first decompressed performs a first decompression operation on the data to sequentially obtain a first string, a distance-length pair and a second string. The second decompression unit receives and decompresses the first string, the distance-length pair and the second string. The first decompression unit does not utilize data associated with the length-distance pair when decompressing the second string.
According to yet another embodiment of the present invention, a decompression method for decompressing data is provided. The data sequentially comprises a compressed first string, a compressed distance-length pair, and a compressed second string. The decompression method comprises: performing a first decompression operation on the data to sequentially obtain a first string, a distance-length pair, and a second string; and receiving and decompressing the first string, the distance-length pair, and the second string. The step of performing the first decompression operation on the data to sequentially obtain the first string, the distance-length pair and the second string comprises: not utilizing data associated with the distance-length pair when performing the first decompression data on the second string.
The above and other aspects of the invention will become better understood with regard to the following detailed description of the preferred but non-limiting embodiments. The following description is made with reference to the accompanying drawings.
In a BAC compression technique, binary strings are compressed. During a BAC compression process, each bit is categorized by the BAC compression as a distance or a literal, or that the bit is a first bit of a literal. Each category has an independent probability value, which is constantly updated in the compression process. When compressing the bit, the probability value corresponding to the bit is first referred, and the probability value is then updated according to whether a value of the bit is “0” or “1”. In a conventional BAC compression process, when compressing a next literal of a distance-length pair, a literal associated with the distance-length pair is usually utilized. For example, to compress a string “ABCDABCE” into “A, B, C, D, (4, 3), E”, the compression for “E” usually requires the use of data associated with the distance-length pair (4, 3). As such, a decompression process of “E” also requires the use of the literals “C” and “D” associated with the distance-length pair (4, 3), leading to reduced decompression efficiency.
The compression method beings in step 100.
In step 102, literals of a string are sequentially compressed to generate a compressed string. When a length-distance pair is generated during the compression process of the literals of the string, the compression process of a next literal following the literals does not require the use of the literals associated with the distance-length pair.
An example is described for illustrating the above compression process. Assuming that a string to be compressed is “ABCDABCE”, the literals A, B, C, D, A, B and C are sequentially compressed into “ABCD(4, 3)”, where (4, 3) indicates that, three literals starting from this position are identical to three literals (i.e., A, B, and C) starting from four previous literals. When compressing the next literal “E” following the distance-length pair (4, 3), the use of the literals associated with the length-distance pair (4, 3) is not required. In an embodiment, an approach for compressing “E” is the same as that for compressing the first literal “A”.
Implementation details of the above compression method according to an embodiment of the present invention are as below.
In equation (1) above, “offs” may have two values—“0x100” and “0”, for representing whether a bit comparison value is correct or incorrect; “symbol” and “matchByte” are 8-bit values, respectively. Further, in equation (1), in the second line, a most significant bit (MSB) of “symbol” is set as “1”; in the sixth line, “EncodeBit(P, S) indicates an encoding result S, and P is utilized as an entry of the probability value; in the seventh to eight lines, “symbol” is shifted to the left by one bit, and compared for an MSB with “matchByte”; in the last line, it is stated that the steps are iterated until all the eight bits of “symbol” have been compared.
In equation (2), “LZMA_LIT_SIZE” is a fixed value (768 in this example), “processedPos” indicates the number of bits that have been written, and “IpMask” represents a basis for determining the number of bit values of “processedPos” to be utilized as an entry for the probability value. Further, in equation (2), the second line is originally intended to utilize “prob” added with “dic[ ]” as the entry of the probability value. However, since the description of “dic[ ]” in the equation (2) allows “prob”, without adding “dic[ ]”, to be directly utilized as the entry of the probability value, the compression method of the present invention is allowed not to involve data associated with the distance-length pair when compressing the next literal following the distance-length pair.
The above equations describe the concept of the core operation, and other details of the compression method are similar to those of the BAC compression technique. That is, the compression method of the present invention is performed on a binary string (i.e., the string is consisted of bit values “0” and “1”), and a probability table utilized is adaptively updated during the compression process of the string to accordingly compute and encode the bit values.
Therefore, in the compression method of the present invention, as the data associated with the distance-length pair is not involved when compressing the next literal following the distance-length pair, efficiency in a subsequent decompression process is enhanced. A decompression circuit and associated decompression method of the present invention are described below.
To perform a decompression operation by the decompression circuit 200, the improved BAC decompression 210 first receives a data stream from the DRAM 250, and decompresses the data stream to obtain first decompressed data. The first decompressed data comprises a plurality of literals and a distance-length pair. The first decompressed data is transmitted via the FIFO buffer 220 to the LZ77 decompression unit 230. The LZ77 decompression unit 230 decompresses the first decompressed data to obtain second decompressed data, and transmits the second decompressed data to another circuit. More specifically, in the embodiment, the data stream is the compressed data obtained from the compression method in
Further, a decompression concept of the improved BAC decompression unit 210 is similar to that of a BAC decompression operation. That is, each bit value of the data is compared with a reference value, and which probability table to be utilized for decompression is determined according to a comparison result. For example, when the first bit is the same as a reference value, values in the first probability table are utilized; when the first bit is different from the reference value, values in the second probability table are utilized.
More specifically, assuming that the improved BAC decompression unit 210 receives a data stream from the DRAM 250, wherein the data stream is the string “ABCDABCE” in a compressed form, the improved BAC decompression unit 210 first sequentially decompresses the data stream to obtain “A, B, C, D, (4, 3), E”, where (4, 3) is a distance-length pair for representing three literals (i.e., ABC) of four previous literals. In the decompression process performed on the previous four literals “A, B, C, D”, the decompression of the latter three literals requires data of a previous literal, respectively. That is to say, the decompression of “B” requires data of “A”, and the decompression of “C” requires “B”. Thus, the improved BAC decompression unit 210 is provided with a small buffer therein for temporarily storing data of a previous literal for the subsequent decompression. The improved BAC decompression unit 210 sequentially transmits the four sequentially decompressed literals “A, B, C, D”, via the FIFO buffer 220, to the LZ77 decompression unit 230. The LZ77 decompression unit 230 directly transmits “A, B, C, D” to the DRAM 250 and/or another circuit that requires the data.
After decompressing the distance-length pair (4, 3), the improved BAC decompression unit 210 transmits the distance-length pair (4, 3), via the FIFO buffer 220, to the LZ77 decompression unit 230 for decompression, so as to obtain A, B, C represented by the distance-length pair (4, 3). Meanwhile, in the process that the improved BAC decompression unit 210 continues to decompress the data stream to obtain “E”, the improved BAC decompression unit 210 is capable of directly decompressing the data stream without involving data associated with the distance-length pair (4, 3). That is, the improved BAC decompression unit 210 does not need to use the data replied from the LZ77 decompression data 230, or the LZ77 decompression unit 210 is not required to reply data associated with the length-distance pair (4, 3) to the BAC decompression unit 210. As illustrated, the improved BAC decompression unit 210 is capable of directly decompressing “E” without having to wait for other data, and so an overall decompression time can be shortened to enhance decompression efficiency.
In the embodiment in
In step 300, a first decompression operation is performed on a first data stream to obtain first decompressed data. The first decompressed data comprises a plurality of literals and at least one distance-length pair. Data associated with the distance-length pair is not required when decompressing a next literal following the distance-length pair.
In step 302, the first decompressed data is received, and a second decompression operation is sequentially performed on the first decompressed data to obtain second decompressed data.
In conclusion, in the decompression circuit and associated decompression method of the present invention, when decompressing a next literal following a distance-length pair, the improved BAC decompression unit 210 is not required to use data associated with the distance-length pair. Therefore, the improved BAC decompression unit 210 is capable of continuously decompressing without waiting for data replied from the LZ77 decompression unit 230, thereby enhancing decompression efficiency.
While the invention has been described by way of example and in terms of the preferred embodiments, it is to be understood that the invention is not limited thereto. On the contrary, it is intended to cover various modifications and similar arrangements and procedures, and the scope of the appended claims therefore should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements and procedures.
Number | Date | Country | Kind |
---|---|---|---|
102111971 | Apr 2013 | TW | national |