CN106788451A - A kind of Hafman decoding method and its device - Google Patents
A kind of Hafman decoding method and its device Download PDFInfo
- Publication number
- CN106788451A CN106788451A CN201611080671.9A CN201611080671A CN106788451A CN 106788451 A CN106788451 A CN 106788451A CN 201611080671 A CN201611080671 A CN 201611080671A CN 106788451 A CN106788451 A CN 106788451A
- Authority
- CN
- China
- Prior art keywords
- decoded
- code
- binary
- decoding
- character
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 88
- 229910002056 binary alloy Inorganic materials 0.000 claims abstract description 101
- 230000000052 comparative effect Effects 0.000 claims description 9
- 235000013399 edible fruits Nutrition 0.000 claims description 2
- 230000000694 effects Effects 0.000 description 4
- 230000008901 benefit Effects 0.000 description 2
- 239000007795 chemical reaction product Substances 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 230000006835 compression Effects 0.000 description 2
- 238000013144 data compression Methods 0.000 description 2
- 235000013405 beer Nutrition 0.000 description 1
- 238000005265 energy consumption Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M7/00—Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
- H03M7/30—Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
- H03M7/40—Conversion to or from variable length codes, e.g. Shannon-Fano code, Huffman code, Morse code
- H03M7/4006—Conversion to or from arithmetic code
- H03M7/4012—Binary arithmetic codes
Abstract
The invention discloses a kind of Hafman decoding method and its device, including some groups of binary system code characters are successively read from bit stream to be decoded;The binary code number included in every group of binary system code character is more than 1;Hafman decoding is carried out to every group of binary system code character successively respectively, obtain the corresponding decoded result of binary code on bit stream to be decoded, decoded result includes decoding character and decoded length, and decoded length is the digit for decoding character corresponding binary code in default Huffman code table;After reading the corresponding decoding character of decoded positions, decoded positions are moved into corresponding digit afterwards successively according to itself corresponding decoded length, and corresponding position, as decoded positions, repeats after shifting by after;Until decoding is completed, initial decoded positions are the initial binary code of bit stream to be decoded.The present invention is read multidigit binary code in units of group and is decoded, and decoding efficiency is high.And reading process is non-interference with decoding process, the speed of decoding is fast.
Description
Technical field
The present invention relates to encoding and decoding technique field, more particularly to a kind of Hafman decoding method and its device.
Background technology
Currently, as internet, Internet of Things are developed rapidly, data file scale is increasing.To save carrying cost,
Each data center is compressed out to data.Substantial amounts of data compression takes cpu resource higher, not only reduces service
Device performance, and server energy consumption is improved, increased energy cost.
At present, frequently with Hafman decoding method in data compression.Huffman (Huffman) coding is that a kind of uniformity is compiled
Code method (also known as " entropy code method "), for the lossless compression of data.It sets up according to the probability that each character occurs
Coding schedule, probability of occurrence character high uses shorter coding, on the contrary probability of occurrence it is low then use coding more long so that compile
The average expectation length reduction of the character string after code, so as to reach the purpose of Lossless Compression data.Because Huffman encoding is one
Variable-length encoding, each character code indefinite length are planted, therefore can only serially be performed during Hafman decoding, it is impossible to be enough in advance by ratio to be decoded
The binary system sequence that spy's stream is divided into length-specific in advance is processed again, and is first to read a binary system in decoding process
Code, after comparing with Huffman code table, then reads next bit binary code, until the match is successful with Huffman code table, efficiency is low, solution
Code speed is slow.
Therefore, the Hafman decoding method and its device for how providing a kind of efficiency high are that those skilled in the art need at present
The problem to be solved.
The content of the invention
It is an object of the invention to provide a kind of Hafman decoding method and its device, multidigit binary system is read in units of group
Code is decoded, and decoding efficiency is high;And reading process is non-interference with decoding process, continuous productive process, Huffman solution can be realized
The speed of code is fast.
In order to solve the above technical problems, the invention provides a kind of Hafman decoding method, including:
Step s1:Some groups of binary system code characters are successively read from bit stream to be decoded;In binary system code character described in every group
Comprising binary code number be more than 1;
Step s2:Hafman decoding is carried out to every group of binary system code character successively respectively, is obtained on the bit stream to be decoded
The corresponding decoded result of binary code, the decoded result include decoding character and decoded length, the decoded length is institute
State the digit of decoding character corresponding binary code in default Huffman code table;
Step s3:The corresponding decoding character of the decoded positions is read, by the decoded positions according to itself corresponding solution
Code length moves corresponding digit afterwards successively, and will after move after corresponding position as decoded positions, repeat step s3;Until decoding
Complete;Wherein, initial decoded positions are the initial binary code of the bit stream to be decoded.
Preferably, the process of step s1 is specially:
Since the reading original position on the bit stream to be decoded, L binary code is successively read, obtains binary system
Code character;L≥m+n-1;M is the number of decoder, and n is the most long codes length of the Huffman code table;Make the reading starting
M is moved behind position, as new reading original position, read operation is repeated;
Accordingly, the process of step s2 is specially:
The m decoder carries out Hafman decoding to binary system code character described in every group successively respectively;Wherein, i-th institute
State decoder and proceed by Hafman decoding from the i-th bit of the binary system code character, obtain at the i-th bit of the binary system code character
Decoded result;1≤i≤m and i are positive integer.
Preferably, the process of step s1 is specially:
Each binary code on the bit stream to be decoded is successively read n two as original position is read respectively
Ary codes, obtain some groups of binary system code characters.
Preferably, the process of step s2 is specially:
The first binary code from binary system code character every described proceeds by Hafman decoding respectively, obtains described two and enters
The corresponding decoded result of the first binary code of code character processed.
Preferably, the Huffman code table is normal form Huffman code table, and the process of step s2 is specially:
To the binary system code character right side zero padding less than n, n binary system code character is extended for;
By the corresponding coding right side zero padding of each character in the Huffman code table, n coding is extended for;
Calculate the numerical value encoded after each expansion, and the coding of several codings of record original coding length identical respectively
Minimum value in numerical value, obtains k minimum value as threshold value, k≤n;
Calculate the numerical value D of binary system code character described in every group;By D respectively according to order from small to large and the k threshold value
It is compared, if D is less than the threshold value for currently comparing, record comparative result is 0, conversely, record comparative result is 1, and will be compared
Relatively result is ranked up from left to right according to the priority of comparative sequence, obtains k bitmasks;If k<N, then adjust according to preset rules
It is n bitmasks;
Make the binary system code character and n bitmasks step-by-step carry out with operation, obtain n result code, calculate described n
The numerical value I of result code;The corresponding decoded result of the first binary code of the binary system code character is obtained according to I.
Preferably, the decoded result also includes effect identifier, after decoding character is obtained, the decoded result correspondence
Effective identifier be true, conversely, being false.
In order to solve the above technical problems, present invention also offers a kind of Hafman decoding device, including:
Read module, for being successively read some groups of binary system code characters from bit stream to be decoded;Binary system described in every group
The binary code number included in code character is more than 1;
Decoder module, for carrying out Hafman decoding to every group of binary system code character successively respectively, obtains the ratio to be decoded
The corresponding decoded result of binary code on spy's stream, the decoded result includes decoding character and decoded length, the solution code length
It is the digit of decoding character corresponding binary code in default Huffman code table to spend;
Merging module, after reading the corresponding decoding character of the decoded positions, by the decoded positions according to itself
Corresponding decoded length moves corresponding digit afterwards successively, and corresponding position, as decoded positions, repeats itself behaviour after shifting by after
Make;Until decoding is completed;Wherein, initial decoded positions are the initial binary code of the bit stream to be decoded.
Preferably, the decoder module includes m decoder;
The read module specifically for:
Since the reading original position on the bit stream to be decoded, L binary code is successively read, obtains binary system
Code character;L≥m+n-1;M is the number of decoder, and n is the most long codes length of the Huffman code table;Make the reading starting
M is moved behind position, as new reading original position, read operation is repeated;
The m decoder, for carrying out Hafman decoding to binary system code character described in every group successively respectively;Wherein, i-th
The individual decoder proceeds by Hafman decoding from the i-th bit of the binary system code character, obtains the i-th of the binary system code character
Decoded result at position;1≤i≤m and i are positive integer;When the m decoder completes the solution to binary system code character described in a group
After code, the one group of binary code that will be obtained sends to the merging module and is processed.
Preferably, the read module specifically for:
Each binary code on the bit stream to be decoded is successively read m two as original position is read respectively
Ary codes, obtain some groups of binary system code characters.
The invention provides a kind of Hafman decoding method and its device, one group two is read from bit stream to be decoded every time
System code character, then carries out Hafman decoding to each group binary system code character for reading respectively, obtains on bit stream to be decoded
The corresponding decoded result of binary code, and then obtain decoding character.It can be seen that, the present invention is not to read a binary code every time,
But read multidigit binary code parallel and decoded as one group, substantially increase the speed of Hafman decoding, decoding efficiency
It is high.Also, binary system code character is successively read during reading process of the invention from bit stream to be decoded, i.e., after often having read one group
Continue to read next group;And be that each group binary system code character is decoded successively respectively in decoding process, then according to decoding
Result merges operation, obtains final decoded result.It can be seen that, the present invention realizes continuous productive process, reading process with decoded
Journey is non-interference, can carry out side by side simultaneously, compared to the serial operation for being only capable of being read again after the completion of decoding at present next time,
Decoding speed of the invention is greatly improved.
Brief description of the drawings
Technical scheme in order to illustrate more clearly the embodiments of the present invention, below will be to institute in prior art and embodiment
The accompanying drawing for needing to use is briefly described, it should be apparent that, drawings in the following description are only some implementations of the invention
Example, for those of ordinary skill in the art, on the premise of not paying creative work, can also obtain according to these accompanying drawings
Obtain other accompanying drawings.
A kind of flow chart of the process of Hafman decoding method that Fig. 1 is provided for the present invention;
The flow chart of the process of another Hafman decoding method that Fig. 2 is provided for the present invention;
The flow chart of the process of another Hafman decoding method that Fig. 3 is provided for the present invention;
A kind of structural representation of Hafman decoding device that Fig. 4 is provided for the present invention.
Specific embodiment
Core of the invention is to provide a kind of Hafman decoding method and its device, and multidigit binary system is read in units of group
Code is decoded, and decoding efficiency is high;And reading process is non-interference with decoding process, continuous productive process, Huffman solution can be realized
The speed of code is fast.
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
A part of embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
Embodiment one
It is shown in Figure 1 the invention provides a kind of Hafman decoding method, a kind of Hough that Fig. 1 is provided for the present invention
The flow chart of the process of graceful coding/decoding method;The method includes:
Step s1:Some groups of binary system code characters are successively read from bit stream to be decoded;Included in every group of binary system code character
Binary code number be more than 1;
Step s2:Hafman decoding is carried out to every group of binary system code character successively respectively, two on bit stream to be decoded are obtained
The corresponding decoded result of ary codes, decoded result includes decoding character and decoded length, and decoded length is decoding character default
Huffman code table in corresponding binary code digit;
Step s3:After reading the corresponding decoding character of decoded positions, by decoded positions according to itself corresponding decoded length
Move corresponding digit afterwards successively, and will after move after corresponding position as decoded positions, repeat step s3;Until decoding is completed;
Wherein, initial decoded positions are the initial binary code of bit stream to be decoded.
It is understood that a string of binary system sequences of each character correspondence in Huffman code table, include in binary system sequence
The digit of binary code be the corresponding decoded length of the character.Because the present invention can obtain each in bit stream to be decoded
(the corresponding decoded result of binary code is referred to using binary code as decoding the corresponding decoded result of position binary code here
The decoded result obtained after beginning position decoding), and include multidigit binary code one character of correspondence in bit stream to be decoded
Situation, therefore include invalid decoded result in the decoded result for obtaining, the specific corresponding decoded result of which binary code without
Effect, then recognized by way of step s4.
For example, if bit stream to be decoded is 10, in Huffman code table b be encoded to 10, e be encoded to 0, then by step
The corresponding result obtained after s2 should be first 1 corresponding b, and decoded length is 2;Second 0 corresponding e, decoded length is 1;But it is real
10 should represent a character b on border, therefore the position of only first 1 is decoded positions, and second 0 should skip, and be invalid
Decoded positions.
The invention provides a kind of Hafman decoding method, one group of binary code is read from bit stream to be decoded every time
Group, then carries out Hafman decoding to each group binary system code character for reading respectively, obtains the binary system on bit stream to be decoded
The corresponding decoded result of code, and then obtain decoding character.It can be seen that, the present invention is not to read a binary code every time, but simultaneously
Row reads multidigit binary code and is decoded as one group, substantially increases the speed of Hafman decoding, and decoding efficiency is high.And
And, binary system code character is successively read during reading process of the invention from bit stream to be decoded, i.e., after often having read one group i.e. after
Resume studies and remove one group;And be that each group binary system code character is decoded successively respectively in decoding process, then according to decoded result
Operation is merged, final decoded result is obtained.It can be seen that, the present invention realizes continuous productive process, and reading process is mutual with decoding process
Do not interfere, can carry out side by side simultaneously, compared to the serial operation for being only capable of being read again after the completion of decoding at present, this hair next time
Bright decoding speed is greatly improved.
Embodiment two
On the basis of based on embodiment one, present invention also offers another Hafman decoding method.
Wherein, it is shown in Figure 2, the flow chart of the process of another Hafman decoding method that Fig. 2 is provided for the present invention.
The process of step s1 is specially:
Since the reading original position on bit stream to be decoded, L binary code is successively read, obtains binary code
Group;L≥m+n-1;M is the number of decoder, and n is the most long codes length of Huffman code table;Order moves m after reading original position
Position, as new reading original position, repeats read operation;
Accordingly, the process of step s2 is specially:
M decoder carries out Hafman decoding to every group of binary system code character successively respectively;Wherein, i-th decoder is from two
The i-th bit of system code character proceeds by Hafman decoding, obtains the decoded result at the i-th bit of binary system code character;1≤i≤m and
I is positive integer.
It is understood that due to the characteristics of Hafman decoding is serially decoded, needing first to complete decoding every time, just can determine that
It is next to start the position of decoding, therefore decoding speed can only be carried out to a character every time slowly, efficiency is low;By m decoder
Preceding m binary code is decoded from every group of binary system code character respectively, can obtain on bit stream to be decoded with each two
The decoded result that ary codes are obtained after being decoded as original position, then removes wherein invalid decoding knot by step s4 again
Really, you can obtain final decoding character.That is the present embodiment, can every time to m binary code by the way of parallel decoding
Decoded, obtained multiple decoding characters, substantially increased decoding speed and efficiency.
Also, in step s4, after the one group of decoded result for obtaining can be decoded often to obtain one group of binary system code character, that is, start
Processed, and now m decoder can be decoded to next group of binary system code character.It can be seen that, now reading process, decoding
Character merging process in process and step s4 is carried out simultaneously, between it is non-interference, it is achieved thereby that the streamlined of whole flow process
Treatment, substantially increases decoding speed.
Further, since m decoder is needed, and preceding m binary code is decoded from every group of binary system code character respectively, therefore
In order to ensure last decoder also can normal work, therefore every group of binary system code character can not only include m, but add n-
1 because the most long codes length needed for decoding is n, therefore plus last decoder to decoding original position
Binary code, last decoder can have the n binary code to carry out decoding operate for it.Wherein, m should be not less than 1, m and n
Size be determined on a case-by-case basis.
For convenience of understanding, a specific example is explained to above-described embodiment below.
Assuming that bit stream to be decoded is " 1000111011111000110 ", totally 8 (m) individual decoder, Huffman code used
Table such as table 1;Table 1 is the Huffman code table in this;
The Huffman code table of table 1
12 (m+n=8+4=12) is read from bit stream to be decoded every time, when reading every time later, 8 is moved to right, directly
To stop bits.Read altogether in the present embodiment three times, binary code result such as table 2 is read every time.
Each reading binary code result of table 2
Since 8 decoders decode (i is decoder number) the i-th bit of binary system code character is read in when previous group respectively.
Each corresponding decoded result of the binary system code character such as table 3 of reading.
The each decoded result of table 3
Result to table 1 carries out efficient decoding character reading according to step s4, obtains decoding character string " beep beer ".
It is shown in Table 4, table 4 is decoding end product.
Table 4 decodes end product
Bit stream | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 |
Decoding character | b | e | e | p | Space | b | e | e | r | ||||||||||
Decoded length | 2 | 1 | 1 | 4 | 4 | 2 | 1 | 1 | 3 | ||||||||||
Decoded positions | 0 | 2 | 3 | 4 | 8 | 12 | 14 | 15 | 16 | ||||||||||
Decoder | 0 | 2 | 3 | 4 | 0 | 4 | 6 | 7 | 0 |
In another embodiment, the process of step s1 is specially:
Each binary code on bit stream to be decoded is successively read n binary system as original position is read respectively
Code, obtains some groups of binary system code characters.
It is further known that, it is shown in Figure 3, the process of another Hafman decoding method that Fig. 3 is provided for the present invention
Flow chart.The process of step s2 is specially:
The first binary code from every binary system code character proceeds by Hafman decoding respectively, obtains binary system code character
The corresponding decoded result of the first binary code.
It is understood that because the most long codes length in Huffman code table is n, therefore every group includes n binary code
If, except original position is not external, after being generally possible to decode the first original position as decoding obtained the binary system code character
Decoded result, so as to obtain the corresponding decoded result of each binary code in bit stream to be decoded.
Wherein, the step can make multiple decoders while carrying out decoding operate to a binary system code character respectively, so that
Realize the purpose of parallel decoding.
It is further known that, Huffman code table is normal form Huffman code table, and the process of step s2 is specially:
Step s201:To the binary system code character right side zero padding less than n, n binary system code character is extended for;
It is understood that respectively using each binary code on bit stream to be decoded as read original position successively
Read n binary code, the binary system yardage included in last n-1 groups binary system code character less than n, so when need to carry out benefit 0.
Step s202:By the corresponding coding right side zero padding of each character in Huffman code table, n coding is extended for;
So cause in Huffman code table that each character corresponds to one n to encode, due in normal form Huffman encoding,
The coding of equal length is the binary system description of continuous integral number, and the corresponding code length of even two characters is identical, then the two
It is continuous during the numerical value that the corresponding binary coding of character is obtained after calculating, such as 0011,0100.Therefore in normal form Huffman encoding
In, the n numerical value of coding obtained after character corresponding coding zero padding is arranged according to order from small to large.
Step s203:Calculate the numerical value encoded after each expansion, and respectively record original coding length identical several
Minimum value in the encoding value of coding, obtains k minimum value as threshold value, k≤n;
Wherein, the corresponding code length of character before original coding length here refers to non-zero padding, for example, b and e are equal
Corresponding 2 codings, it is 4 codings 1100 and 0100 to be mended after zero padding, and its numerical value is respectively 12 and 4, therefore records 4.
Step s204:Calculate every group of numerical value D of binary system code character;By D respectively according to order from small to large and k threshold value
It is compared, if D is less than the threshold value for currently comparing, record comparative result is 0, conversely, record comparative result is 1, and will be compared
Relatively result is ranked up from left to right according to the priority of comparative sequence, obtains k bitmasks;If k<N, then adjust according to preset rules
It is n bitmasks;
Wherein, there is the original coding of several length in Huffman code table, then can obtain several threshold values, k here is not necessarily
N can be equal to, if k<N, can be in the k for obtaining for the foremost of mask mends 1.
Step s205:Make binary system code character and the step-by-step of n bitmasks carry out with operation, obtain n result code, calculate n and tie
The numerical value I of fruit code;The corresponding decoded result of the first binary code of binary system code character is obtained according to I.
Wherein, by the numeric ratio of the corresponding n coding of each character after the numerical value of result code therewith leading zero compared with if phase
Deng then the first corresponding decoding character of the binary system code character is above-mentioned equal n and encodes corresponding character, and then is solved
Code length (the corresponding original coding length of the decoding character).
Preferably, decoded result also includes effect identifier, and after decoding character is obtained, decoded result is corresponding to be had
Effect identifier is true, conversely, being false.
It is understood that in step s4, when not obtaining decoded result at decoded positions, typically showing the decoding at this
Not yet complete, it is necessary to wait;But, even if sometimes having there is decoded result at decoded positions, but the decoded result is
In system mistake operation generation or decoded result and not comprising decoded word symbol, so when can be vacation by effective identifier judge
Skip the decoded positions.Wherein, the corresponding effective identifier of decoded result is true after the completion of normal decoding, if current decoded positions
Original position not to causing to decode character, in decoded result effective identifier be it is false, certainly, system mistake
Words, effective identifier is false.
In addition, more than in each embodiment, step s3 and step s4 can be whole two in bit stream to be decoded be obtained
Carried out again after the corresponding decoded result of ary codes, it is also possible to start after the corresponding decoded result of one group of binary code is obtained into
OK, or often obtaining the corresponding decoded result of binary code is carried out.Using the second way, can decode next
Enter line character screening during group binary code to upper one group of binary code simultaneously to read, carry out realizing improving decoding speed
Purpose.Which kind of certainly, specifically it is not construed as limiting using the mode present invention.
Compared with embodiment one, the present embodiment can realize multiple decoder parallel decodings, improve Hafman decoding
Speed, efficiency high;Also, the present invention also increased effective identifier in decoded result, it is to avoid read decoding during system mistake
Decoded in error character at position, improves the accuracy of decoding.
It is shown in Figure 4 present invention also offers a kind of Hafman decoding device, a kind of Kazakhstan that Fig. 4 is provided for the present invention
The structural representation of the graceful decoding apparatus of husband.The device includes:
Read module 1, for being successively read some groups of binary system code characters from bit stream to be decoded;Every group of binary system code character
The binary code number for inside including is more than 1;
Decoder module 2, for carrying out Hafman decoding to every group of binary system code character successively respectively, obtains bit stream to be decoded
On the corresponding decoded result of binary code, decoded result include decoding character and decoded length, decoded length for decoding character
The digit of corresponding binary code in default Huffman code table;
Merging module 3, after reading the corresponding decoding character of decoded positions, by decoded positions according to itself corresponding solution
Code length moves corresponding digit afterwards successively, and corresponding position, as decoded positions, repeats itself operation after shifting by after;Until solution
Code is completed;Wherein, initial decoded positions are the initial binary code of bit stream to be decoded.
Preferably, decoder module 2 includes m decoder;
Read module 1 specifically for:
Since the reading original position on bit stream to be decoded, L binary code is successively read, obtains binary code
Group;L≥m+n-1;M is the number of decoder, and n is the most long codes length of Huffman code table;Order moves m after reading original position
Position, as new reading original position, repeats read operation;
M decoder, for carrying out Hafman decoding to every group of binary system code character successively respectively;Wherein, i-th decoder
Hafman decoding is proceeded by from the i-th bit of binary system code character, the decoded result at the i-th bit of binary system code character is obtained;1≤i
≤ m and i are positive integer;And the one group of binary code that will be obtained sends to merging module 3 and is processed.
Processed it is understood that often obtaining one group of decoded result and sending to merging module 3, can realize reading
Process, decoding process and merging process are carried out simultaneously, that is, realize that streamlined is processed, and greatly improve decoding speed.
In another embodiment, read module 1 specifically for:
Each binary code on bit stream to be decoded is successively read m binary system as original position is read respectively
Code, obtains some groups of binary system code characters.
The invention provides a kind of Hafman decoding device, one group of binary code is read from bit stream to be decoded every time
Group, then carries out Hafman decoding to each group binary system code character for reading respectively, obtains the binary system on bit stream to be decoded
The corresponding decoded result of code, and then obtain decoding character.It can be seen that, the present invention is not to read a binary code every time, but simultaneously
Row reads multidigit binary code and is decoded as one group, substantially increases the speed of Hafman decoding, and decoding efficiency is high.And
And, binary system code character is successively read during reading process of the invention from bit stream to be decoded, i.e., after often having read one group i.e. after
Resume studies and remove one group;And be that each group binary system code character is decoded successively respectively in decoding process, then according to decoded result
Operation is merged, final decoded result is obtained.It can be seen that, the present invention realizes continuous productive process, and reading process is mutual with decoding process
Do not interfere, can carry out side by side simultaneously, compared to the serial operation for being only capable of being read again after the completion of decoding at present, this hair next time
Bright decoding speed is greatly improved.
Each embodiment is described by the way of progressive in this specification, and what each embodiment was stressed is and other
The difference of embodiment, between each embodiment identical similar portion mutually referring to.For device disclosed in embodiment
For, because it is corresponded to the method disclosed in Example, so description is fairly simple, related part is said referring to method part
It is bright.
Also, it should be noted that in this manual, such as first and second or the like relational terms be used merely to by
One entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operation
Between there is any this actual relation or order.And, term " including ", "comprising" or its any other variant meaning
Covering including for nonexcludability, so that process, method, article or equipment including a series of key elements not only include that
A little key elements, but also other key elements including being not expressly set out, or also include for this process, method, article or
The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence "including a ...", does not arrange
Except also there is other identical element in the process including the key element, method, article or equipment.
The foregoing description of the disclosed embodiments, enables professional and technical personnel in the field to realize or uses the present invention.
Various modifications to these embodiments will be apparent for those skilled in the art, as defined herein
General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, the present invention
The embodiments shown herein is not intended to be limited to, and is to fit to and principles disclosed herein and features of novelty phase one
The scope most wide for causing.
Claims (9)
1. a kind of Hafman decoding method, it is characterised in that including:
Step s1:Some groups of binary system code characters are successively read from bit stream to be decoded;Included in binary system code character described in every group
Binary code number be more than 1;
Step s2:Hafman decoding is carried out to every group of binary system code character successively respectively, two on the bit stream to be decoded are obtained
The corresponding decoded result of ary codes, the decoded result includes decoding character and decoded length, and the decoded length is the solution
The digit of code character corresponding binary code in default Huffman code table;
Step s3:The corresponding decoding character of the decoded positions is read, by the decoded positions according to itself corresponding solution code length
Degree moves corresponding digit afterwards successively, and will after move after corresponding position as decoded positions, repeat step s3;Until having decoded
Into;Wherein, initial decoded positions are the initial binary code of the bit stream to be decoded.
2. method according to claim 1, it is characterised in that the process of step s1 is specially:
Since the reading original position on the bit stream to be decoded, L binary code is successively read, obtains binary code
Group;L≥m+n-1;M is the number of decoder, and n is the most long codes length of the Huffman code table;Make the reading start bit
Shifting m is postponed, as new reading original position, read operation is repeated;
Accordingly, the process of step s2 is specially:
The m decoder carries out Hafman decoding to binary system code character described in every group successively respectively;Wherein, solved described in i-th
Code device proceeds by Hafman decoding from the i-th bit of the binary system code character, obtains the solution at the i-th bit of the binary system code character
Code result;1≤i≤m and i are positive integer.
3. method according to claim 1, it is characterised in that the process of step s1 is specially:
Each binary code on the bit stream to be decoded is successively read n binary system as original position is read respectively
Code, obtains some groups of binary system code characters.
4. method according to claim 3, it is characterised in that the process of step s2 is specially:
The first binary code from binary system code character every described proceeds by Hafman decoding respectively, obtains the binary code
The corresponding decoded result of the first binary code of group.
5. method according to claim 3, it is characterised in that the Huffman code table is normal form Huffman code table, step
The process of s2 is specially:
To the binary system code character right side zero padding less than n, n binary system code character is extended for;
By the corresponding coding right side zero padding of each character in the Huffman code table, n coding is extended for;
Calculate the numerical value encoded after each expansion, and the encoding value of several codings of record original coding length identical respectively
In minimum value, obtain k minimum value as threshold value, k≤n;
Calculate the numerical value D of binary system code character described in every group;D is carried out according to order from small to large with the k threshold value respectively
Compare, if D is less than the threshold value for currently comparing, record comparative result is 0, conversely, record comparative result is 1, and will compare knot
Fruit is ranked up from left to right according to the priority of comparative sequence, obtains k bitmasks;If k<N, then be adjusted to n according to preset rules
Bitmask;
Make the binary system code character and n bitmasks step-by-step carry out with operation, obtain n result code, calculate the n result
The numerical value I of code;The corresponding decoded result of the first binary code of the binary system code character is obtained according to I.
6. the method according to claim any one of 1-5, it is characterised in that the decoded result also includes criterion knowledge
Symbol, after decoding character is obtained, the corresponding effective identifier of the decoded result is true, conversely, being false.
7. a kind of Hafman decoding device, it is characterised in that including:
Read module, for being successively read some groups of binary system code characters from bit stream to be decoded;Binary system code character described in every group
The binary code number for inside including is more than 1;
Decoder module, for carrying out Hafman decoding to every group of binary system code character successively respectively, obtains the bit stream to be decoded
On the corresponding decoded result of binary code, the decoded result includes decoding character and decoded length, and the decoded length is
The digit of decoding character corresponding binary code in default Huffman code table;
Merging module, after reading the corresponding decoding character of the decoded positions, by the decoded positions according to itself correspondence
Decoded length move corresponding digit afterwards successively, and will after move after corresponding position as decoded positions, repeat itself operation;Directly
Completed to decoding;Wherein, initial decoded positions are the initial binary code of the bit stream to be decoded.
8. device according to claim 7, it is characterised in that the decoder module includes m decoder;
The read module specifically for:
Since the reading original position on the bit stream to be decoded, L binary code is successively read, obtains binary code
Group;L≥m+n-1;M is the number of decoder, and n is the most long codes length of the Huffman code table;Make the reading start bit
Shifting m is postponed, as new reading original position, read operation is repeated;
The m decoder, for carrying out Hafman decoding to binary system code character described in every group successively respectively;Wherein, i-th institute
State decoder and proceed by Hafman decoding from the i-th bit of the binary system code character, obtain at the i-th bit of the binary system code character
Decoded result;1≤i≤m and i are positive integer;When the m decoder completes the decoding to binary system code character described in a group
Afterwards, the one group of binary code that will be obtained sends to the merging module and is processed.
9. device according to claim 7, it is characterised in that the read module specifically for:
Each binary code on the bit stream to be decoded is successively read m binary system as original position is read respectively
Code, obtains some groups of binary system code characters.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611080671.9A CN106788451B (en) | 2016-11-30 | 2016-11-30 | Huffman decoding method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611080671.9A CN106788451B (en) | 2016-11-30 | 2016-11-30 | Huffman decoding method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106788451A true CN106788451A (en) | 2017-05-31 |
CN106788451B CN106788451B (en) | 2021-03-09 |
Family
ID=58901436
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611080671.9A Active CN106788451B (en) | 2016-11-30 | 2016-11-30 | Huffman decoding method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106788451B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111970007A (en) * | 2020-08-13 | 2020-11-20 | 山东云海国创云计算装备产业创新中心有限公司 | Decoding method, decoder, device and medium |
Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA1156764A (en) * | 1979-02-22 | 1983-11-08 | Amitabh Saran | Circuit for compacting variable length into fixed word length data |
JPH0410716A (en) * | 1990-04-27 | 1992-01-14 | Ricoh Co Ltd | Decoding circuit for huffman code |
CN1124889A (en) * | 1993-12-23 | 1996-06-19 | 株式会社理光 | Method and apparatus for parallel encoding and decoding of data |
US20040190635A1 (en) * | 2003-03-28 | 2004-09-30 | Ruehle Michael D. | Parallelized dynamic Huffman decoder |
CN1889366A (en) * | 2006-07-13 | 2007-01-03 | 浙江大学 | Hafman decoding method |
CN101017574A (en) * | 2007-02-16 | 2007-08-15 | 上海广电集成电路有限公司 | Huffman decoding method suitable for JPEG code stream |
CN101060337A (en) * | 2007-05-22 | 2007-10-24 | 北京中星微电子有限公司 | An optimized Huffman decoding method and device |
US20110170791A1 (en) * | 2003-04-04 | 2011-07-14 | Michel Rynderman | Bitstream format for compressed image data |
CN103326730A (en) * | 2013-06-06 | 2013-09-25 | 清华大学 | Data parallelism compression method |
CN104300990A (en) * | 2013-03-15 | 2015-01-21 | 英特尔公司 | Parallel apparatus for high-speed, highly compressed LZ77 tokenization and Huffman encoding for deflate compression |
CN104980161A (en) * | 2015-04-02 | 2015-10-14 | 深圳市腾讯计算机系统有限公司 | Huffman decoding method and device |
CN106027066A (en) * | 2015-03-28 | 2016-10-12 | 国际商业机器公司 | Parallel huffman decoder for decoding, design structure and method |
CN106100641A (en) * | 2016-06-12 | 2016-11-09 | 深圳大学 | Multithreading quick storage lossless compression method and system thereof for FASTQ data |
-
2016
- 2016-11-30 CN CN201611080671.9A patent/CN106788451B/en active Active
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA1156764A (en) * | 1979-02-22 | 1983-11-08 | Amitabh Saran | Circuit for compacting variable length into fixed word length data |
JPH0410716A (en) * | 1990-04-27 | 1992-01-14 | Ricoh Co Ltd | Decoding circuit for huffman code |
CN1124889A (en) * | 1993-12-23 | 1996-06-19 | 株式会社理光 | Method and apparatus for parallel encoding and decoding of data |
US20040190635A1 (en) * | 2003-03-28 | 2004-09-30 | Ruehle Michael D. | Parallelized dynamic Huffman decoder |
US20110170791A1 (en) * | 2003-04-04 | 2011-07-14 | Michel Rynderman | Bitstream format for compressed image data |
CN1889366A (en) * | 2006-07-13 | 2007-01-03 | 浙江大学 | Hafman decoding method |
CN101017574A (en) * | 2007-02-16 | 2007-08-15 | 上海广电集成电路有限公司 | Huffman decoding method suitable for JPEG code stream |
CN101060337A (en) * | 2007-05-22 | 2007-10-24 | 北京中星微电子有限公司 | An optimized Huffman decoding method and device |
CN104300990A (en) * | 2013-03-15 | 2015-01-21 | 英特尔公司 | Parallel apparatus for high-speed, highly compressed LZ77 tokenization and Huffman encoding for deflate compression |
CN103326730A (en) * | 2013-06-06 | 2013-09-25 | 清华大学 | Data parallelism compression method |
CN106027066A (en) * | 2015-03-28 | 2016-10-12 | 国际商业机器公司 | Parallel huffman decoder for decoding, design structure and method |
CN104980161A (en) * | 2015-04-02 | 2015-10-14 | 深圳市腾讯计算机系统有限公司 | Huffman decoding method and device |
CN106100641A (en) * | 2016-06-12 | 2016-11-09 | 深圳大学 | Multithreading quick storage lossless compression method and system thereof for FASTQ data |
Non-Patent Citations (1)
Title |
---|
SEYYED MAHDI NAJMABADI 等: "High throughput hardware architectures for asymmetric numeral systems entropy coding", 《2015 9TH INTERNATIONAL SYMPOSIUM ON IMAGE AND SIGNAL PROCESSING AND ANALYSIS (ISPA)》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111970007A (en) * | 2020-08-13 | 2020-11-20 | 山东云海国创云计算装备产业创新中心有限公司 | Decoding method, decoder, device and medium |
CN111970007B (en) * | 2020-08-13 | 2022-03-22 | 山东云海国创云计算装备产业创新中心有限公司 | Decoding method, decoder, device and medium |
Also Published As
Publication number | Publication date |
---|---|
CN106788451B (en) | 2021-03-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9998145B2 (en) | Data processing method and device | |
CN105515590B (en) | A kind of effective low complex degree serially offsets list polarization code coding method | |
CN101022552A (en) | Method and device for realizing Hoffman decodeng | |
CN112994703B (en) | Hardware friendly data decompression | |
CN101325418B (en) | Haffman quick decoding method based on probability table look-up | |
Yang et al. | Universal lossless data compression with side information by using a conditional MPM grammar transform | |
CN106788451A (en) | A kind of Hafman decoding method and its device | |
CN110602498A (en) | Self-adaptive finite state entropy coding method | |
KR101023536B1 (en) | Lossless data compression method | |
CN102740066A (en) | CAVLC decoding method and system | |
CN106559179A (en) | Variable-length symbol-level reversible coding and decoding method for joint information source channel | |
CN104349165B (en) | The elongated decoding method of high-performance and device | |
CN113839678B (en) | Huffman decoding system, method, equipment and computer readable storage medium | |
CN106559085A (en) | A kind of normal form Hafman decoding method and its device | |
CN110958025B (en) | Short frame length coding and decoding method based on superposition | |
CN106533628B (en) | A kind of Huffman parallel decoding method and device thereof | |
CN1182657C (en) | Method used to reduce storage content needed and complexity by product code decode | |
CN101707484B (en) | Fast exp-Golomb decoding method suitable to be implemented by hardware | |
CN113346913A (en) | Data compression using reduced number of occurrences | |
CN102545910A (en) | Joint photographic experts group (JPEG) Huffman decoding circuit and method | |
CN104717499B (en) | A kind of storage method of huffman table and the Hofmann decoding method for JPEG | |
CN113708887B (en) | Polar code encoding and decoding method and device and information transmission system | |
Doshi et al. | “Quad-Byte Transformation as a Pre-processing to Arithmetic Coding | |
CN113315523B (en) | Hardware friendly data decompression | |
KR20130043962A (en) | Method of high speed turbo product code decoding algorithm |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20210203 Address after: Building 9, No.1, guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Wuzhong District, Suzhou City, Jiangsu Province Applicant after: SUZHOU LANGCHAO INTELLIGENT TECHNOLOGY Co.,Ltd. Address before: Room 1601, floor 16, 278 Xinyi Road, Zhengdong New District, Zhengzhou City, Henan Province Applicant before: ZHENGZHOU YUNHAI INFORMATION TECHNOLOGY Co.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |