1. Field of the Invention
The present invention relates to a method for looking up table for data transferring in the circuit, and more particularly, to a look-up table that is required during looking up table for data transferring and a method for looking up table thereof.
2. Description of the Related Art
For obtaining a higher precision, it is common that a very complicated and time consuming calculation is required for both the look-up table during looking up table for data transferring in the digital circuit and the method for looking up table thereof. In order to accomplish such complicated and time consuming calculation, it is required to use a hardware of very high cost or a grate amount of the system resources. In addition to the precision requirement, efficiency with reasonable cost is also required, thus it is inadequate in the physical circuit design. Therefore, the complicated and time consuming calculation may be replaced with the method for looking up table. In such case, if the variant range extended, a larger size of the look-up table is required. For the application which has memory limitation or has higher workload for accessing the memory, if the size of the look-up table used in the method for looking up table is too big, it causes more trouble. An example of this is the quantization and de-quantization processes in the digital signal coder/decoder (CODEC).
In the decoder configuration of “An Optimized Software Solution for an ARM Powered™ MP3 Decoder” proposed by ARM (Advanced RISC Machines) Inc., an improved method of de-quantization in the decoder of the digital music format MP3 is provided. However, it cannot eliminate the high error problem.
Therefore, it is an object of the present invention to provide a look-up table that is required during looking up table for data transferring. The size of the look-up table used in the method for looking up table is reduced by simplifying the calculations.
It is another object of the present invention to provide a look-up table that is required during looking up table for data transferring. A reasonable error range is obtained by properly adjusting the modifiers.
The present invention provides a method for looking up table for data transferring in the circuit. In such method, a main table function having a main table is created first, the size of the main table is determined by a predetermined value, and obtains the result of the main table function by querying the main table. In addition, a fixed table function having a fixed table is further created, and the fixed table function is determined by the quantity of the modifiers. Here, the size of the fixed table is determined by the size of the main table and the predetermined value. In addition, a rest table function having a rest table is further created. The size of the rest table is determined by the operation range of the data transferring, the size of the main table, and the predetermined value. In such data transferring, the result of the data transferring is obtained by selecting a function among the main table function, the fixed table function, and the rest table function, and performing a process of looking up table on one of the main table, the fixed table, and the rest table corresponding to the selected function based on the size of data to be transferred.
In the method for looking up table mentioned above, when the data transferring is Q(x)=x^{A/B}, where 0≦x<X_{max}, Q(x) is the result of the data transferring, x is an input value, A and B are integers, X_{max }is the maximum value of the data transferring, the setup value is d=2^{N·A}, where d is a setup value, N is an integer, and
that is d≦X_{max}.
In the method for looking up table mentioned above, the size of the main table
and INT(a) represents obtaining integer for a, if the size x of the data to be transferred is in the range of 0≦x<C_{main}, the main table function Tab_{main}(x) is selected for generating the result of the data transferring.
In the method for looking up table mentioned above, the size of the fixed table for the M^{th }modifier is C_{fixed,M}=[C_{main}−(C_{main}/d)], and the total size of all fixed tables is C_{all}_{—}^{fixed}=M·C_{fixed,M}, and the size x of the data to be transferred is in the range of C_{main}≦x<C_{main}·d.
In the method for looking up table mentioned above, the size of the rest table is C_{rest}=X_{max}−C_{main}·d, the size x of the data to be transferred is in the range of C_{main}·d≦x<X_{max}, and the rest table is created based on the size of the rest table, such that the rest table function obtains the values corresponding to the size x of the data to be transferred in the range of C_{main}·d≦x<X_{max}.
In the method for looking up table mentioned above, the result of the data transferring is obtained by performing the main table function, the fixed table function, and the rest table function on the main table, the fixed table, and the rest table respectively based on the condition that the size x of the data to be transferred is in the range of 0≦x<C_{main}, C_{main}≦x<C_{main}·d, or C_{main}·d≦x<X_{max}.
In another embodiment of the present invention, the present invention provides a method for looking up table for data transferring in the circuit. In the method, a main table function having a main table is created, the size of the main table is determined by a predetermined value, and obtains the result of the main table function by querying the main table. In addition, a fixed table function having a fixed table is further created, and the fixed table function is determined by the quantity of the modifiers and the main table. Here, the size of the fixed table is determined by the size of the main table and the predetermined value. In addition, a rest table function having a rest table is further created. The size of the rest table is determined by the operation range of the data transferring, the size of the main table, and the predetermined value. In such data transferring, the result of the data transferring is obtained by selecting a function among the main table function, the fixed table function, and the rest table function, and performing a process of looking up table on one of the main table, the fixed table, and the rest table corresponding to the selected function based on the size of data to be transferred.
The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the invention, and together with the description, serve to explain the principles of the invention.
FIGS. 1-4 schematically shows a method for looking up table for data transferring in a circuit of prefer embodiments of the present invention.
FIG. 5 schematically shows a distribution diagram of the error values obtained from a method for looking up table according to an embodiment of the present invention.
The present invention provides a look-up table required during the quantization and de-quantization processes in a digital signal coder/decoder (CODEC) and a method for looking up table thereof. The method reduces the size of the look-up table used in the method for looking up table by simplifying the calculations. A reasonable error range is obtained for the required look-up table by adjusting appropriate modifiers. In an embodiment of the present invention, the method is applied in the method for looking up table similar to the
calculation in the digital signal coder/decoder (CODEC) suitable for the present invention, and the calculation is more efficient if B/A is close to 1 or smaller than 1.
For example, if the look-up table and the method for looking up table thereof mentioned above are applied on an audio-type CODEC, it is suitable for the quantization and de-quantization algorithms performed in the decoder supporting the digital music format MP3 and in the decoder supporting the AAC (Advanced Audio Coding) format.
The method for looking up table provided by the present invention is characterized in that the size of the look-up table is reduced by commonly sharing the look-up table with simplifying calculations in the look-up tables of different ranges. In addition, in order to sustain good precision, some modifiers may be appropriately further added. Moreover, even in some specific condition, the looking up table with the modifiers may be eliminated.
In one embodiment, as shown in FIG. 1, the present invention provides a method for looking up table for data transferring in a circuit. In the embodiment, as shown in Step 110, a main table function having a main table is created. The size of the main table is determined by a predetermined value, and the result of the main table function is obtained by querying the main table. As shown in Step 120, a fixed table function having a fixed table is created, where the fixed table function is determined by the quantity of a plurality of modifiers. The size of the fixed table is determined by the size of the main table and the predetermined value. As shown in Step 130, a rest table function having a rest table is also created, where the size of the rest table is determined by the operation range of the data transferring, the size of the main table, and the predetermined value. As shown in Step 140, the result of data transferring is obtained by selecting a function from one of the main table function, the fixed table function, and the rest table function, and performing a process of looking up table on one of the main table, the fixed table, and the rest table corresponding to the selected function based on the size of data to be transferred.
In a further embodiment, as shown in FIG. 2, the present invention provides a method for looking up table for data transferring in a circuit. In the embodiment, a main table function having a main table is created first, as shown in Step 210, where the size of the main table is determined by a predetermined value, and the result of the main table function is obtained by querying the main table. As shown in Step 220, a fixed table function is also created, where the fixed table function is determined by the quantity of a plurality of modifiers and the main table, and the size of the fixed table is determined by the size of the main table and the predetermined value. As shown in Step 230, a rest table function having a rest table is also created, where the size of the rest table is determined by the operation range of the data transferring, the size of the main table, and the predetermined value. As shown in Step 240, the result of data transferring is obtained by selecting a function among the main table function, the fixed table function, and the rest table function, and performing a process of looking up table on one of the main table, the fixed table, and the rest table corresponding to the selected function based on the size of data to be transferred.
In another embodiment, as shown in FIG. 3, the present invention provides a method for looking up table for data transferring in a circuit. In the embodiment, as shown in Step 310, the range of the data transferring into a first range, a second range, and a third range is configured. When the data to be transferred is in the first range, as shown in Step 320, looking up table with a main table function which has a main table and corresponds to the first range is performed accordingly. When the data to be transferred is in the second range, , as shown in Step 330, looking up table with a fixed table function is performed. The fixed table function has a fixed table and corresponds to the second range, where the fixed table function is determined by the quantity of a plurality of modifiers, and the size of the fixed table is determined by the size of the main table and a predetermined value. When the data to be transferred is in the third range, as shown in Step 340, looking up table with a rest table function is performed. The rest table function has a rest table and corresponds to the third range, where the size of the rest table is determined by the operation range of the data transferring, the size of the main table, and the predetermined value.
In another further embodiment, as shown in FIG. 4, the present invention provides a method for looking up table for data transferring in a circuit. In the embodiment, as shown in Step 410, the range of the data transferring into a first range, a second range, and a third range is configured. When the data to be transferred is in the first range, as shown in Step 420, looking up table with a main table function which has a main table and corresponds to the first range is performed. When the data to be transferred is in the second range, as shown in Step 430, looking up table with a fixed table function corresponding to the second range is performed. The fixed table function is determined by the quantity of a plurality of modifiers and the main table. When the data to be transferred is in the third range, as shown in Step 440, looking up table with a rest table function is performed. The rest table function has a rest table and corresponds to the third range, where the size of the rest table is determined by the operation range of the data transferring, the size of the main table, and the predetermined value. Followings are descriptions for illustrating embodiments of the invention, serve to explain the principles of the invention.
Following is a first embodiment for describing the method for looking up table provided by the present invention.
It is assumed that the de-quantization algorithm to be processed is:
where 0≦x<X_{max}.
Where, x is a value to be de-quantization, Q(x) is the result of the calculation, and X_{max }is the maximum value of x. The smaller the value of B/A, the higher efficiency the method for looking up table provided by the present invention. Therefore, it is recommended that B/A should be close to 1 or smaller than 1.
First, following steps are performed in a pre-processing operation.
I. Performing a Division Operation
A divider is used first, and the operation performed by the divider is:
d=2^{N·A}, where N is an integer, and
that is d≦X_{max}.
A rule is obtained from above equation, that is the bigger the value of N, the smaller the size of the look-up table. However, more modifiers are required to be added for acquiring a reasonable precision.
II. Create a Main Table Function
Then, a main table function Tab_{main}(x) for the main table is created. The method for creating the main table function is described in an embodiment below.
First, the size x of the look-up table and the range corresponding to x are obtained, here the size of the main table is:
where INT(x) represents performing a process to obtain the integer for x, and x is in the range of 0≦x<C_{main}.
Then, a main table is created based on the size of the main table, such that the main table function can use it for looking up table. The content of the main table is the values corresponding to x with function
where x is in the range of 0≦x<C_{main}. Here, performing the main table function Tab_{main}(x) represents obtaining a value by looking up table for x.
III. Create a Fixed Table Function
A fixed table function Tab_{fixed,M }(x) having a fixed table is created, where M is the quantity of the modifiers. The quantity of the modifiers may be adjusted based on various conditions for achieving the reasonable error value.
First, the size of the fixed table with respect to the M^{th }modifier and the corresponding range thereof are configured. The size of the fixed table with respect to the M^{th }modifier is:
C_{fixed,M}=[C_{main}−(C_{main}/d)]
The total size of all tables is C_{all}_{—}^{fixed}=M·C_{fixed,M}. Where x is in the range of C_{main}≦x<C_{main}·d.
Then, the fixed table function Tab_{fixed,M }(x) for the M^{th }modifier is created:
The modifiers are created based on the Binomial function, that is when −1<x<1
The Binomial function is suitable for all modifiers described hereinafter.
That is the M^{th }modifier is represented as:
It is assumed that y=x%d and
The quantity of the modifiers depends on the different precision requirements.
A rest table function Tab_{rest}(x) having a rest table is created. First, the size x of the rest table and the range corresponding to x are obtained. The size of the rest table is C_{rest}=X_{max}−C_{main}·d, and x is in the range of C_{main}·d≦x<X_{max}.
Then, a rest table is created based on the size of the rest table, such that the rest table function Tab_{rest}(x) can use it for looking up table. The content of the rest table is the values corresponding to x with the function
where x is in the range of C_{main}·d≦x<X_{max}.
After the pre-processing operation, the algorithm used in the method for looking up table in the first embodiment is described in detail hereinafter. The description is based on three conditions where x is in the range of 0≦x<C_{main}, C_{main}≦x<C_{main}·d, and C_{main}·d≦x<X_{max}.
I. First, when 0≦x<C_{main}, the result of O=Tab_{main}(x) is obtained by looking up table with the main table function.
II. When C_{main}≦x<C_{main}·d, following steps are performed:
(1) Let x′=x/d (or x′=x>>(N·A) for the fixed point operation), and a value of R=Tab_{main}(x′) is obtained from looking up table with the main table function.
(2) After multiplying R by
a rough result
is obtained.
If the value of d is appropriately selected, such that
is an integer, the fixed point operation can be used, such that the multiplication is replaced by the shift operation, and the result is represented as:
(3) In order to obtain a more precise result, the modifier is further added. The modifier is obtained from the method for looking up table with the fixed table function. The M_{th }modifier is represented as:
After reorganizing all processes mentioned above, the result is obtained:
or for the fixed point operation:
III. When C_{main}·d≦x<X_{max}, the result O=Tab_{rest}(x) is obtained from looking up table with the rest table function.
The total size of the look-up tables based on the methods of I, II, and III mentioned above is:
Compared to the conventional method for looking up table, the reduced size of the look-up table is:
The de-quantization process of the decoder supporting the digital music format MP3 is exemplified hereinafter for describing the method for looking up table according to an embodiment of the present invention. First, the operation to be process is:
First, a divider is used, and the operation performed in the divider is d=2^{N·A}, where N is an integer, and
that is d≦X_{max}. Assuming d is equal to 8. In the present invention, the value of d is determined based on the real precision requirement, and not necessarily limited by the value used in the present embodiment.
Then, when 0≦x<1024, a main table function
is created.
When 1024≦x<8192, a fixed table function
is created by using a modifier. The selection of the modifier has great impact on the real precision, thus it is designed based on the real precision requirement, and not necessarily limited by the value used in the present embodiment. Of course, the higher the precision, the more complicated the circuit design is.
When 8192≦x<8207, a rest table function
is created.
When 0≦x<1024, the result O=Tab_{main}(x) is obtained from looking up table with the main table function
When 1024≦x<8192, the result is obtained:
or for the fixed point operation,
O=[Tab_{main}(x>>3)<<4]+Tab_{fixed,1}(x)·(x& 7).
When 8192≦x<8207, the result O=Tab_{rest}(x) is obtained from looking up table with the rest table function.
In the method for looking up table in the present embodiment, the total size of all look-up tables is C_{all}=1935 , and the reduced size of the look-up tables is C_{reduced}=6272. With such method, the size of the look-up table required for the method for looking up table is significantly reduced by the simple calculations. In addition, a reasonable error range is obtained by appropriately adjusting the modifiers in the required look-up table.
For example, if Q12 (i.e. the decimal is represented by 12 bits) precision is used in the fixed point operation, originally it requires 32828 bytes of look-up table, now it only needs 5948 bytes, so the error value is significantly reduced.
In the method for looking up table according to the first embodiment of the present invention, if there is only one modifier, the fixed table in the first embodiment is obtained from the main table, thus the size of the look-up table is further reduced. The algorithm is described below (when there is only one modifier).
I. When 0≦x<C_{main}, the result O=Tab_{main}(x) is obtained from looking up table with the main table function.
II. When C_{main}≦x<C_{main}·d, let x′=x/d (or x′=x>>(N·A) for the fixed operation), and a value R=Tab_{main}(x′) is obtained by further looking up table with the main table function.
A rough result
for the fixed point operation) is obtained from multiplying R by
or by left shifting
for the fixed point operation.
A more precise result is obtained by adding the modifier, The modifier is obtained from looking up table with the main table. The modifier is represented as:
or for the fixed point operation:
where y=x%d.
After reorganizing all processes mentioned above, the result is obtained:
or for the fixed point operation:
III. When C_{main}·d≦x<X_{max}, the result O=Tab_{rest}(x) is obtained from looking up table with the rest table.
The total size of the required look-up tables based on the method mentioned above is:
Compared to the conventional method for looking up table, the reduced size of the look-up table is:
The de-quantization process for the decoder supporting the digital music format MP3 is exemplified hereinafter for describing the method for looking up table according to the embodiment of the present invention. First, the operation to be process is:
where 0≦x<8207.
First, a divider is used, and the operation performed in the divider is d=2^{N·A}, where N is an integer, and
that is d≦X_{max}. Assuming d is equal to 8. In the present invention, the value of d is determined based on the real precision requirement, and not necessarily limited by the value used in the present embodiment.
Then, when 0≦x<1024, a main table function
is created.
When 8192≦x<8207, a rest table function
is created
(1) When 0≦x<1024, the result O=Tab_{main}(x) is obtained from looking up table with the main table function
When 1024≦x<8192, the result is obtained:
or for the fixed point operation,
O=[Tab_{main}(x>>3)<<4]+{[Tab_{main}(x>>3)+1−Tab_{main}((x>>3)−1)]<<1}·(x& 7).
When 8192≦x<8207, the result O=Tab_{rest}(x) is obtained from looking up table with the rest table function.
In the method for looking up table in the present embodiment, the total size of all look-up tables is C_{all}=1039 , and the reduced size of the look-up tables is C_{reduced}=7168. With such method, the size of the look-up table required for the method for looking up table is significantly reduced by the simple calculations. In addition, a reasonable error range is obtained by appropriately adjusting the modifiers in the required look-up table.
For example, if Q12 (i.e. the decimal is represented by 12 bits) precision is used in the fixed point operation, originally it requires 32828 bytes of look-up table (each element uses 32 bytes), now it only needs 4156 bytes (each element uses 32 bytes), which is only ⅛ of the original size, so the error value is significantly reduced. In the physical application, the maximum error is 0.033, and RMS is 0.0012. In the case of the digital music format MP3, since the possibility of x>1024 is very small, and there is no error in such range, the average error for this operation is very small, which is close to 0.
Referring to FIG. 1, which schematically shows a distribution diagram of the error values obtained from a method for looking up table according to an embodiment of the present invention. As shown in the diagram, since d is configured as 8, eight errors are combined as one group, and the value is gradually increased from a small value. In addition, it is also observed from the diagram that the total error is gradually decreased.
The quantization process for the encoder supporting the digital music format MP3 is exemplified hereinafter for describing the method for looking up table according to the embodiment of the present invention. First, the operation to be process is:
where 0≦x<16384.
First, a divider is used, and the operation performed in the divider is d=2^{N·A}, where N is an integer, and
that is d≦X_{max}. Assuming d is equal to 16. In the present invention, the value of d is determined based on the real precision requirement, and not necessarily limited by the value used in the present embodiment.
Then, when 0≦x<1024, a main table function
is created.
(1) When 0≦x<1024, the result O=Tab_{main}(x) is obtained from looking up table with the main table function
When 1024≦x<16384, the result is obtained:
or for the fixed point operation,
O=[Tab_{main}(x>>4)<<3]+{[Tab_{main}((x>>4)+1)−Tab_{main}((x>>4)−1)]>>1}·(x& 15)
In the method for looking up table in the present embodiment, the total size of all look-up tables is C_{all}=1024, and the reduced size of the look-up tables is C_{reduced}=15360, which is only 1/16 of the original size. With such method, the size of the look-up table required for the method for looking up table is significantly reduced by simplifying the calculations. In addition, if Q9 (i.e. the decimal is represented by 9 bits) precision is used in the fixed point operation, an error free quantization process is achieved.
Although the invention has been described with reference to a particular embodiment thereof, it will be apparent to one of the ordinary skill in the art that modifications to the described embodiment may be made without departing from the spirit of the invention. Accordingly, the scope of the invention will be defined by the attached claims not by the above detailed description.