This application is based upon and claims the benefit of priority from prior Japanese Patent Application P2005-069795 filed on Mar. 11, 2005; the entire contents of which are incorporated by reference herein.
1. Field of the Invention
The present invention relates to a system for decoding a variable-length codeword and a method for the same.
2. Description of the Related Art
In data transmission, a variable-length codeword having a prefix portion and a suffix portion is used. The code length of the suffix portion is determined by the number of bits of the prefix portion. For example, with regard to an exp-golomb codeword, the decoding result is determined by the number of zeros in the prefix portion and the codeword of the suffix portion.
In the related art, a variable-length codeword is decoded by use of a general-purpose processor having a zero detection command. The processor executes the following steps:
Each of the steps listed above requires an execution time corresponding to at least one cycle of the processor. Moreover, also in the case of a short codeword within the capacity of the buffer circuit, the codeword is decoded using the above steps. Accordingly, in the case of the short codeword, a period of approximately 5 to 10 cycles is required to decode the exp-golomb codeword.
There is a method for decoding a variable-length codeword in which the codeword is divided into halves having a half-length of the maximum code length when the number of bits of the variable-length codeword is larger than the number of bits which can be stored in the buffer circuit. However, in this method, a buffer circuit which can store the codeword having a half-length of the maximum code length is required.
An aspect of the present invention inheres in a system for decoding a variable-length codeword. The system includes a buffer circuit configured to store at least a part of the variable-length codeword; a detection circuit configured to detect the number of bits of a prefix portion of the variable-length codeword by use of a detection table while updating the variable-length codeword; an extraction circuit configured to extract a codeword of a suffix portion of the variable-length codeword based on the number of bits of the prefix portion while updating the variable-length codeword; and a first decoding circuit configured to decode the variable-length codeword based on the number of bits of the prefix portion and the codeword of the suffix portion.
Another aspect of the present invention inheres in a computer implemented method for decoding a variable-length codeword. The method includes storing at least a part of the variable-length codeword in a buffer circuit; detecting the number of bits of a prefix portion of the variable-length codeword by use of a detection table while updating the variable-length codeword; extracting a codeword of a suffix portion of the variable-length codeword based on the number of bits of the prefix portion while updating the variable-length codeword; and decoding the variable-length codeword based on the number of bits of the prefix portion and the codeword of the suffix portion.
Various embodiments of the present invention will be described with reference to the accompanying drawings. It is to be noted that the same or similar reference numerals are applied to the same or similar parts and elements throughout the drawings, and the description of the same or similar parts and elements will be omitted or simplified.
In the following descriptions, numerous specific details are set forth such as specific signal values, etc., to provide a thorough understanding of the present invention. However, it will be obvious to those skilled in the art that the present invention may be practiced without such specific details. In other instances, well-known circuits have been shown in block diagram form in order not to obscure the present invention in unnecessary detail.
As shown in
The variable-length codeword decoded by the system shown in
An example of the codeword SA is shown in
On the basis of the number of bits Ra of the prefix portion and the codeword Rb of the suffix portion of the exp-golomb codeword, the decoding result SB is obtained by use of an expression (1):
SB=([1<<Ra]−1)+Rb (1)
In the expression (1), [1<<Ra] represents a bit string having the number of bits Ra of “0”s after “1”. For example, if the codeword SA is the bit string “00110”, the number of bits Ra is two, and the codeword Rb is the bit string “10”. Accordingly, [1<<Ra] is the bit string “100”. The decoding result SB is the bit string “101”, which is obtained as follows: “1” is subtracted from the bit string “100” to obtain the bit string “011”; the bit string “10”, which is the codeword Rb of the suffix portion, is added to the bit string “011” to obtain the bit string “101”. That is, SB=5. The decoding results similarly obtained from various codewords by use of the expression (1) are shown in
The detection circuit 20 includes a bit-number detection circuit 21, a detection shifting circuit 22, a detection register 23, and an adder 24. The buffer circuit 10, the detection shifting circuit 22, and the adder 24 are connected to the bit-number detection circuit 21. The bit-number detection circuit 21 detects the number of zeros in a line from the top of the codeword SA stored in the buffer circuit 10 with reference to the detection table Ta. The detection register 23 stores the number of bits Ra of the prefix portion of the codeword SA. The bit-number detection circuit 21 and an adder 50 are connected to the detection shifting circuit 22. The detection shifting circuit 22 updates the buffer circuit 10 by the number of zeros detected by the bit-number detection circuit 21.
The detection table Ta is a table for looking up the number of zeros in a line from the top of a codeword, as shown in
If the number of bits Ra of the prefix portion of the codeword SA is larger than the number of bits B1 which can be stored in the buffer circuit 10, only “0” is stored in the buffer circuit 10. In this case, the bit-number detection circuit 21 transmits the number of bits B1 to the detection shifting circuit 22. Then, the detection shifting circuit 22 update uses the adder 50 to the codeword SA, stored in the buffer circuit 10, by the number of bits B1. That is, the following bits of the prefix portion of the codeword SA are stored in the buffer circuit 10. In addition, the number of bits B1 is stored in the detection register 23. If the codeword newly stored in the buffer circuit 10 includes “0”s only, the above steps are repeated. That is, until the boundary bit “1” of the codeword SA is detected, the buffer circuit 10 is updated by the number of bits B1. Then, the number of bits B1 is added to the detection register 23. When the boundary bit “1” of the codeword SA is detected, the bit-number detection circuit 21 detects the number of zeros in a line from the top of the codeword stored in the buffer circuit 10 by use of the detection table Ta. The detected number of zeros is added to the detection register 23.
As described above, the number of 0 in the prefix portion of the codeword SA detected by the bit-number detection circuit 21 is added to the detection register 23 by the adder 24. Therefore, even if the number of bits Ra of the prefix portion of the codeword SA is larger than the number of bits B1 which can be stored in the buffer circuit 10, the number of bits Ra is stored in the detection register 23.
The extraction circuit 30 shown in
The extraction circuit 30 extracts the codeword Rb of the suffix portion of the codeword SA from the buffer circuit 10. The extracted codeword Rb is stored in the extraction register 32. As described above, the code length of the codeword Rb of the suffix portion is the number of bits Ra of the prefix portion. Therefore, the extraction circuit 30 extracts the codeword Rb of the suffix portion as the bit string of the bit length of Ra. If the number of bits of the codeword Rb is larger than the number of bits B1, the entire codeword Rb cannot be stored in the buffer circuit 10. In this case, the extraction circuit 31 updates the buffer circuit 10 and sequentially extracts the codeword Rb. Then, the extraction circuit 30 stores the codeword Rb of the suffix portion in the extraction register 32. The bit-number register 34 stores the number of bits Ra.
The detection register 23 and the extraction register 32 are connected to the first decoding circuit 40. The first decoding circuit 40 obtains the decoding result SB by use of the expression (1) on the basis of the number of bits Ra of the prefix portion received from the detection resistor 23, and the codeword Rb of the suffix portion received from the extraction register 32.
A description will be given below of a method for decoding a variable-length codeword by use of the decoding system shown in
On the basis of the number of zeros detected from the bit string “01010010”, the detection shifting circuit 22 updates the buffer circuit 10 by one bit. Accordingly, as shown in
After the number of bits Ra are detected, the extraction circuit 30 acquires the codeword Rb of the suffix portion of the codeword SA from the buffer circuit 10 with reference to the number of bits Ra stored in the bit-number register 34. As is shown in the above example, if the number of bits of the codeword Rb is larger than the number of bits B1, the entire codeword Rb cannot be stored in the buffer circuit 10. In this case, the extraction circuit 31 updates the buffer circuit 10 and acquires the codeword Rb.
A description will be given by use of the above-described example. The extraction circuit 30 acquires the bit string “01001011”, that is, “75”, stored in the buffer circuit 10 with reference to the number of bits Ra stored in the bit-number register 34. Next, the extraction shifting circuit 31 updates the buffer circuit 10 by the number of bits of the acquired bit string, that is, by eight bits. As a result, as shown in
Next, the extraction circuit 30 acquires “0”, which is the first one bit of the bit string “0xxxxxxx” stored in the buffer circuit 10 with reference to the one bit stored in the bit-number register 34. Then, “0” acquired by the extraction circuit 30 and the value obtained by updating the previously acquired “75” by one bit are added by the adder 33, and the addition result is stored in the extraction register 32. As a result, the codeword Rb=150 of the suffix portion of the codeword SA is stored in the extraction register 32.
Next, the first decoding circuit 40 decodes the codeword SA by use of the expression (1) on the basis of the number of bits Ra of the prefix portion and the codeword Rb of the suffix portion, and transmits the decoding result SB. In the above-described example, the decoding result SB=661. Thereafter, the detection shifting circuit 22 updates the buffer circuit 10 on the basis of the number of bits Ra, and stores the next codeword to be decoded in the buffer circuit 10 from the first bit thereof.
As described above, the system for decoding a variable-length codeword according to the first embodiment of the present invention detects the number of bits Ra of the prefix portion of the received codeword SA while updating the buffer circuit 10. In addition, the system extracts the codeword Rb of the suffix portion while updating the buffer circuit 10. Accordingly, even if the number of bits of the codeword SA is larger than the number of bits B1 which can be stored in the buffer circuit 10, it is possible to perform decoding. In addition, the system detects the number of bits Ra of the prefix portion of the codeword SA by comparing the codeword stored in the buffer circuit 10 and the detection table Ta. Accordingly, it is possible to reduce the number of cycles required to decode the codeword SA, as compared to the case where the number of bits Ra are detected by use of a zero detection command of a general purpose processor.
As shown in
The decoding table Tb is a table for looking up the decoding result of the codeword stored in the buffer circuit 10 as shown in
With reference to the decoding system shown in
A bit-number detection circuit 21 detects the code length of the codeword stored in the buffer circuit 10 with reference to the codeword length table Tc. The codeword length table Tc is a table for looking up the code length of the codeword stored in the buffer circuit 10 as shown in
On the other hand, if there is no bit string matching the codeword stored in the buffer circuit 10 among the bit strings in the decoding table Tb, the codeword is decoded by the method described in the first embodiment. Specifically, a detection circuit 20 detects the number of bits Ra of the prefix portion of the codeword SA. Next, an extraction circuit 30 extracts the codeword Rb of the suffix portion. Then, the first decoding circuit 40 acquires the decoding result SBa by use of the expression (1) on the basis of the number of bits Ra of the prefix portion and the codeword Rb of the suffix portion. The acquired decoding result SBa is transmitted to the selector 60.
One of the decoding result SBa and the decoding result SBb is transmitted to the selector 60. The selector 60 transmits one of the decoding result SBa and the decoding result SBb as the decoding result SB of the codeword SA.
In the system for decoding a variable-length codeword according to the second embodiment of the present invention, the decoding table Tb for looking up the decoding result of the codeword stored in the buffer circuit 10 is used. Accordingly, if the number of bits of the codeword SA is smaller than the number of bits B1 which can be stored in the buffer circuit 10, it is possible to decode the codeword SA in one cycle. In the decoding system shown in
As shown in
The second codeword decoding table Td is a table for looking up the decoding result of the second codeword stored in the buffer circuit 10, as shown in
A bit-number detection circuit 21 detects the code length of the second codeword stored in the buffer circuit 10, with reference to the second codeword length table Te. The second codeword length table Te is a table for looking up the code length of the second codeword stored in the buffer circuit 10, as shown in
With reference to the decoding system shown in
The codewords SA1 and SA2 to be decoded are fed to the decoding system shown in
If the code length of the codeword SA2 detected by use of the second codeword length table Te is not zero, the third decoding circuit 42 acquires the decoding result of the second codeword SA2 stored in the buffer circuit 10, with reference to the second codeword decoding table Td shown in
As in the method described in the second embodiment, a second decoding circuit 41 decodes the codeword SA stored in the buffer circuit 10 by use of the decoding table Tb. Specifically, the second decoding circuit 41 acquires the detection result “2” corresponding to the bit string “011” which matches the codeword SA1 by use of the decoding table Tb shown in
The second and third decoding circuits 41 and 42 can operate simultaneously. That is, decoding the codeword SA1 and the codeword SA2 can be performed in the same cycle.
Thereafter, the detection circuit 20 updates the bit string stored in the buffer circuit 10 by a total of eight bits, which results from three bits of the code length of the codeword SA1, and five bits of the code length of the codeword SA2. As a result, the next codeword to be decoded is stored in the buffer circuit 10 from the first bit thereof.
On the other hand, if the code length of the codeword SA2 detected by use of the second codeword length table Te is zero, and the code length of the codeword SA1 detected by use of the codeword length table Tc is not zero, one codeword SA1 is stored in the buffer circuit 10. In this case, as in the method described in the second embodiment, the second decoding circuit 41 decodes the codeword SA1 by use of the decoding table Tb. The decoding system shown in
The case where the code length of the codeword SA1 detected by use of the codeword length table Tc is zero corresponds to the case where the number of bits of the codeword SA1 is larger than the number of bits B1 which can be stored in the buffer circuit 10. In this case, the codeword SA1 is decoded by the method described in the first embodiment. Specifically, the detection circuit 20 detects the number of bits Ra of the prefix portion of the codeword SA1. Next, an extraction circuit 30 extracts the codeword Rb of the suffix portion. Then, a first decoding circuit 40 acquires the decoding result SBa by use of the expression (1) on the basis of the number of bits Ra of the prefix portion and the codeword Rb of the suffix portion. The decoding system shown in
If a setting to decode one codeword is chosen, the decoding system shown in
The system for decoding a variable-length codeword according to the third embodiment of the present invention performs decoding by use of the decoding table Tb for looking up the decoding result of the first codeword stored in the buffer circuit 10, and the second codeword decoding table Td for looking up the decoding result of the second codeword stored in the buffer circuit 10. Accordingly, when a plurality of codewords are stored in the buffer circuit 10, decoding two codewords can be performed in one cycle simultaneously. Therefore, with the system for decoding a variable-length codeword according to the third embodiment, it is possible to reduce the number of cycles required to decode a codeword. Otherwise, the third embodiment is substantially similar to the second embodiment, and a redundant description is omitted.
In the above description of the third embodiment, a decoding system for decoding two codewords stored in the buffer circuit 10 in the same cycle uses the decoding table Tb and the second codeword decoding table Td. It is also possible to provide a decoding system which includes a decoding circuit for decoding a third codeword stored in the buffer circuit 10, a decoding circuit for decoding a fourth codeword stored in the buffer circuit 10, and the like, so that the system decodes at least three codewords in the same cycle.
Various modifications will become possible for those skilled in the art after receiving the teachings of the present disclosure without departing from the scope thereof.
Number | Date | Country | Kind |
---|---|---|---|
P2005-069795 | Mar 2005 | JP | national |