CN108900196A - A kind of data decoding method based on lzw algorithm, device, equipment and medium - Google Patents
A kind of data decoding method based on lzw algorithm, device, equipment and medium Download PDFInfo
- Publication number
- CN108900196A CN108900196A CN201810690646.5A CN201810690646A CN108900196A CN 108900196 A CN108900196 A CN 108900196A CN 201810690646 A CN201810690646 A CN 201810690646A CN 108900196 A CN108900196 A CN 108900196A
- Authority
- CN
- China
- Prior art keywords
- coding
- character information
- mapping relations
- coding schedule
- code
- 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.)
- Withdrawn
Links
- 238000000034 method Methods 0.000 title claims abstract description 67
- 238000004422 calculation algorithm Methods 0.000 title claims abstract description 50
- 238000013507 mapping Methods 0.000 claims abstract description 80
- 239000013589 supplement Substances 0.000 claims description 14
- 238000004590 computer program Methods 0.000 claims description 11
- 238000012423 maintenance Methods 0.000 abstract description 5
- 230000000694 effects Effects 0.000 abstract description 2
- 230000008569 process Effects 0.000 description 16
- 230000006837 decompression Effects 0.000 description 6
- 238000013144 data compression Methods 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012804 iterative process Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 239000000047 product Substances 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000009469 supplementation Effects 0.000 description 1
- 230000001502 supplementing effect Effects 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/3084—Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction using adaptive string matching, e.g. the Lempel-Ziv method
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
The invention discloses a kind of data decoding method based on lzw algorithm, device, equipment and media, including remove code by reading in encoding stream to obtain root coding and end code;It include the coding schedule about the mapping relations of coding and character information according to code, root coding and end code foundation is removed;The mapping relations lacked are successively supplemented or are updated until end code, according to the obtained mapping relations output corresponding character information of each coding using as data flow.The mapping relations of character information are encoded to by coding schedule maintenance, coding schedule is stored in the form of tables of data, effectively promote access efficiency, simultaneously because successively being supplemented in mapping relations, as the number for reading coding increases, mapping relations are also being increasing, so that the probability that present encoding is present in coding schedule greatly improves, it does not need to repeat and calculates its corresponding character information, improve decoding efficiency.Data deciphering device, equipment and medium based on lzw algorithm have said effect.
Description
Technical field
The present invention relates to lzw algorithm technical fields, more particularly to a kind of data decoding method based on lzw algorithm, dress
It sets, equipment and medium.
Background technique
Lzw algorithm is called " string list compression algorithm ", by establishing a string table, is indicated with shorter code longer
Character string come, to realize data compression.Lzw algorithm includes three important objects:Data flow, encoding stream and coding schedule.
In carrying out data compression process, data flow (initial data) is input object, and encoding stream (data through overcompression) is output
Object;In contrast, during carrying out data decompression, encoding stream is input object, and data flow is then output object.Coding
Table be required in data compression and data decompression process by object, for indicating longer character string to shorter generation
The mapping of code.
The actual characters string representated by each coding in dynamic acquisition data flow by the way of data base in the prior art.
Comprising two arrays prefix and suffix, the size of each array is 4096 (that is, it can store 4096 data value).
Wherein, the last character of character (string) representated by array value suffix [i] presentation code i, array value prefix [i] table
Show the prefix code of coding i.Data i itself, i.e. prefix [i]=i are indicated for root entry i, prefix [i].Assuming that coding
The corresponding character string of the list item that index value is i in table is that the corresponding character of p (string) and character k are formed by index value, then prefix
The value of [i] is p, i.e. prefix [i]=p.Temporary variable table_len is set, indicates the index value of new coding schedule list item,
Initial value is the value+1 for removing code.The interim array stack that can store 4096 array values is set, idx indicates array indexing,
The initial value of idx is 0.
The decompression process of lzw algorithm is as follows:
First coding is read, to remove code, setting OLD value (coding that the last time reads) is to remove code;For reading
Each coding, perform the following operations:The value that prefix [table_len] is arranged is [[OLD]];Suffix is according to circumstances set
The value of [table_len]:If present encoding value [code] is less than table_len, the value of suffix [table_len] is set
The initial character of character string is corresponded to for present encoding;Otherwise, setting suffix [table_len] is right for [OLD] corresponding character string
The first character answered.Change the value cur of present encoding:If present encoding value is less than table_len, present encoding value is not
Become;Otherwise setting present encoding value is [OLD].Iteration obtains the represented data flow of coding:It is removed if present encoding is greater than
Code, the value for being circularly set stack [idx] is the value of suffix [cur], and by idx value+1, while the value that cur is arranged is
prefix[cur];The value that stack [idx] is arranged is the value of cur;The value of table_len adds 1, and the value of setting [OLD] is to read
Present encoding value [code].Finally, backward exports the value in stack to data flow.
In conclusion traditional coding/decoding method, using each coding institute's generation in the scheme dynamic acquisition data flow of data base
The actual characters string of table causes to be required to call primary this iterative process to each coding in decoding process, leads to data solution
Code efficiency is lower.
Summary of the invention
The object of the present invention is to provide a kind of data decoding method based on lzw algorithm, device, equipment and media, are used for
Overcome the problems, such as that decoding efficiency is lower in decoding process.
In order to solve the above technical problems, the present invention provides a kind of data decoding method based on lzw algorithm, including:
Code is removed by reading in encoding stream to obtain root coding and end code;
Coding schedule is established according to the removing code, described coding and the end code;Wherein, comprising related in coding schedule
In the mapping relations of coding and character information, the character information specifically includes character or character string;
The mapping relations lacked in coding schedule are successively supplemented according to default decoding rule or update until
Until the end code, while according to the obtained mapping relations output corresponding character information of each coding using as data
Stream.
Preferably, described that the mapping relations lacked in coding schedule are successively supplemented according to default decoding rule
Or it updates until the end code, while according to the obtained corresponding character information of each coding of mapping relations output
To be specifically included as data flow:
Present encoding is read, determines the corresponding character information of present encoding to export as data flow according to coding schedule;
It is present encoding that current OLD value, which is arranged,;
It regard next coding as present encoding, and reads present encoding;
Judge whether present encoding is the removing code, if it is, removing coding schedule, and returns described according to described clear
The step of establishing coding schedule except code, described coding and the end code is to realize the updates of the mapping relations;
If it is not, then judging whether present encoding is the end code, if it is, terminating;
If it is not, then judging in coding schedule with the presence or absence of present encoding;
If it is present being exported the corresponding character information of present encoding as data flow, and according to the first default update
Policy Updates coding schedule is to carry out the supplements of the mapping relations;It returns and the step of current OLD value is present encoding is set;
If it does not exist, then it is described to carry out to obtain the corresponding character information of present encoding according to the second default update rule
The supplement of mapping relations, and exported the corresponding character information of present encoding as data flow;It returns and current OLD value is set to work as
The step of preceding coding.
Preferably, described to be specially according to the described first default Policy Updates coding schedule that updates:
By the initial character of the corresponding character information of present encoding and the corresponding character information composition fresh character letter of current OLD value
Breath sequence, which is added in coding schedule, obtains one group of new mapping relations.
Preferably, described to obtain the corresponding character information of present encoding according to the second default rule that updates to carry out described reflect
The supplement of relationship is penetrated, and is specifically included the corresponding character information of present encoding as data flow output:
The initial character of the corresponding character information of current OLD value and the corresponding character information of current OLD value is formed into fresh character
Character information of the information as present encoding, and exported as data flow;
Present encoding and obtained fresh character information sequence are added in the coding schedule and obtain one group of new mapping pass
System;It returns and the step of current OLD value is present encoding is set.
Preferably, the initial value of coding is 0, and the upper limit value of coding is 4095.
Preferably, further include:Save finally obtained coding schedule.
In order to solve the above technical problems, the present invention provides a kind of data deciphering device based on lzw algorithm, including:
Coding schedule read module, for removing code by reading in encoding stream to obtain root coding and end code;
Coding schedule establishes module, for establishing coding schedule according to the removing code, described coding and the end code;Its
In, it include the mapping relations about coding and character information in coding schedule, the character information specifically includes character or character
String;
Coding schedule operation module, for being carried out according to default decoding rule to the mapping relations lacked in coding schedule
It successively supplements or updates until the end code;
Coding schedule output module, for according to the obtained mapping relations output corresponding character information of each coding with
As data flow.
In order to solve the above technical problems, the present invention provides a kind of data decoding apparatus based on lzw algorithm, including storage
Device, for storing computer program;
Processor realizes the data decoding as described above based on lzw algorithm when for executing the computer program
The step of method.
It is described computer-readable to deposit in order to solve the above technical problems, the present invention provides a kind of computer readable storage medium
Computer program is stored on storage media, the computer program is realized as described above based on LZW when being executed by processor
The step of data decoding method of algorithm.
Data decoding method provided by the present invention based on lzw algorithm, including code is removed by reading in encoding stream to obtain
Take root coding and end code;Coding schedule is established according to code, root coding and end code is removed;Wherein, include in coding schedule about
The mapping relations of coding and character information, character information specifically include character or character string;According to default decoding rule to coding
The mapping relations lacked in table are successively supplemented or are updated until end code, while according to obtained mapping relations
The corresponding character information of each coding is exported using as data flow.It can be seen that being encoded to it by coding schedule maintenance in this method
The mapping relations of representative actual characters information store coding schedule in the form of tables of data, to effectively promote the access of data
Efficiency, it is even more important that due to successively being supplemented in the mapping relations in coding schedule, as the number for reading coding increases
Add, mapping relations are also being increasing, so that the probability that present encoding is present in coding schedule greatly improves, as long as present encoding
In coding schedule, does not then need to repeat its corresponding character information of calculating, be greatly lowered the process of iteration yet, improve
Decoding efficiency.
In addition, the data deciphering device based on lzw algorithm, equipment and medium provided by the present invention with the above method pair
It answers, therefore, also there is above-mentioned beneficial effect.
Detailed description of the invention
In order to illustrate the embodiments of the present invention more clearly, attached drawing needed in the embodiment will be done simply below
It introduces, it should be apparent that, drawings in the following description are only some embodiments of the invention, for ordinary skill people
For member, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow chart of the data decoding method based on lzw algorithm provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another data decoding method based on lzw algorithm provided in an embodiment of the present invention;
Fig. 3 is the flow chart of another data decoding method based on lzw algorithm provided in an embodiment of the present invention;
Fig. 4 is a kind of structure chart of the data deciphering device based on lzw algorithm provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, rather than whole embodiments.Based on this
Embodiment in invention, those of ordinary skill in the art are without making creative work, obtained every other
Embodiment belongs to the scope of the present invention.
Core of the invention is to provide a kind of data decoding method based on lzw algorithm, device, equipment and medium, is used for
Overcome the problems, such as that decoding efficiency is lower in decoding process.
In order to enable those skilled in the art to better understand the solution of the present invention, with reference to the accompanying drawings and detailed description
The present invention is described in further detail.
Fig. 1 is a kind of flow chart of the data decoding method based on lzw algorithm provided in an embodiment of the present invention.Such as Fig. 1 institute
Show, this method includes:
S1:Code is removed by reading in encoding stream to obtain root coding and end code.
It should be noted that the encoding stream mentioned in the embodiment of the present invention is encoding stream to be decompressed, include in encoding stream
There are the multiple codings compressed by lzw algorithm.It include to remove code, root coding, end code and common in multiple codings
Coding.It is understood that for an encoding stream, it is generally the case that first is encoded to removing code, removes code
Encoded radio+1 is exactly end code, and the encoded radio before removing the encoded radio of code is root coding.
For ease of description, it is illustrated in the present invention with a specific encoding stream, which is specially:#4#1#
6#6#2#9#9#7#8#10#2#12#1#14#15#6#0#21#0#10#7#22#23#18#26#7#10#29#13#24#12#18#
16#36#12#5, wherein " # " indicates numerical value, is indicated between every two adjacent coding with space, is intended merely to distinguish two volumes
Code, has no physical meaning.For the encoding stream, first is encoded to #4, i.e., removing code is #4, end code #5, root volume
Code is #0-#3.
S2:Coding schedule is established according to code, root coding and end code is removed;Wherein, include in coding schedule about coding and
The mapping relations of character information, character information specifically include character or character string.
It should be noted that coding schedule can change with the process of decompression.Coding for S2, in the step
Table is initial code table in fact, but no matter how to be changed in coding schedule, all includes the mapping of each coding and character information
Relationship, that is to say, that the corresponding character information of a coding.Due to the variation of coding, corresponding character information variation, thus
Lead to the variation of coding schedule.Due to the coding having character information be single character, abbreviation character, and the character of some codings believe
Breath is character string, i.e., multiple characters are constituted, and therefore, the present invention is unified to be indicated with character information.It is understood that character information
In, it at least include a character.
It under normal conditions, after obtaining removing code, root coding and end code, is made according to these three yard of corresponding numerical value
For the list item value in coding schedule, respectively encoding corresponding character information at this time is exactly coding itself, and the corresponding table of each list item value
Entry index (specific coding) is also identical as list item value.It is understood that encoding stream is read due to substantive not yet,
For each list item value before end code, be it is fixed, not as data flow export, after really reading coding, list item
It is exactly to encode corresponding character information, and table item index is incremented by successively in one column of value.Here table item index is only used for showing
Example explanation, does not need to store the index value in actual storage.Table 1 is the structure of the coding schedule in step S2.
Table 1
Table item index | List item value |
#0 | #0 |
#1 | #1 |
#2 | #2 |
#3 | #3 |
#4 | #4 |
#5 | #5 |
S3:The mapping relations lacked in coding schedule are successively supplemented according to default decoding rule or are updated until knot
Until beam code, while according to the obtained mapping relations output corresponding character information of each coding using as data flow.
As first be encoded to remove code, second coding for obtaining OLD value used in next coding,
Since third coding, every to read a coding, then the table item index in corresponding coding schedule will be incremented by one, therefore,
The mapping relations of coding and character information in coding schedule can be continuously increased, and until reading end code, or read removing
When code, entire coding schedule is removed, then mapping relations present in coding schedule just will be updated.
Fig. 2 is the flow chart of another data decoding method based on lzw algorithm provided in an embodiment of the present invention.As excellent
Selection of land embodiment, step S3 are specifically included:
S30:Present encoding is read, determines the corresponding character information of present encoding using defeated as data flow according to coding schedule
Out.
It should be noted that second coding of encoding stream is removed between code in #0-, such as above in lzw algorithm
The encoding stream of middle citing, second is encoded to #1, since coding #4 has been read, the present encoding in this step is exactly #
1.Due to having existed the corresponding character information of the coding in present encoding table, that is, #1 is remained as, therefore, the data flow of the coding
It is exactly #1, and output stream for the first time.
S31:It is present encoding that current OLD value, which is arranged,.
Present encoding or #1 in this step, therefore, current OLD value are exactly that current OLD value is exactly #1.
S32:It regard next coding as present encoding, and reads present encoding.
The encoding stream above illustrated, third are encoded to present encoding described in #6 and this step.
S33:Judge whether present encoding is to remove code, if it is, coding schedule is removed, into S2;If it is not, then into
S34。
It is not to remove code according to the encoding stream in example it is found that present encoding signified in this step is #6.
S34:Judge whether present encoding is end code, if it is, terminating;If it is not, then into S35.
It is not end code according to the encoding stream in example it is found that present encoding signified in this step is #6.
S35:Judge in coding schedule with the presence or absence of present encoding;If it is present into S36, otherwise, into S37.
Coding in coding schedule in table item index be from #0-#5, and be not present #6, therefore enter S37.
S37:The corresponding character information of present encoding is obtained according to the second default rule that updates to carry out the benefit of mapping relations
It fills, and is exported the corresponding character information of present encoding as data flow;Return to the step for being arranged that current OLD value is present encoding
Suddenly.
In coding schedule, present encoding is not present, requires supplementation with one group of mapping relations, as mentioned in step S3, mapping is closed
System needs successively to supplement, that is to say, that the table item index needs in coding schedule successively increase, and current entry index is #5, increase
One is exactly #6, i.e. present encoding table is as shown in table 2.According to default update Policy Updates coding schedule, then present encoding is corresponding
Character information determine that, it should be noted that how to determine that the corresponding character information of present encoding can be according to such as lower section
Formula carries out.Fig. 3 is the flow chart of another data decoding method based on lzw algorithm provided in an embodiment of the present invention.
Step S37 is specifically divided into sub-step S370 and S371, respectively:
S370:The initial character of the corresponding character information of current OLD value and the corresponding character information of current OLD value composition is new
Character information of the character information as present encoding, and exported as data flow.
S371:Present encoding and obtained fresh character information sequence are added in coding schedule and obtain one group of new mapping pass
System;It returns and the step of current OLD value is present encoding is set.
In step S370, current OLD value is #1, and the initial character of the corresponding character information of current OLD value is also #1, the two group
Conjunction is exactly #1#1, and therefore, the corresponding character information of coding #6 is exactly #1#1.On the basis of upper primary data flow, this data
Stream output is exactly #1#1, is second of output stream.
Table 2
Table item index | List item value |
#0 | #0 |
#1 | #1 |
#2 | #2 |
#3 | #3 |
#4 | #4 |
#5 | #5 |
#6 | #1#1 |
Return step S31 is needed after above-mentioned steps S37, that is, repeats S31-S35.
S31:It is present encoding that current OLD value, which is arranged,.
According to the encoding stream in example it is found that present encoding signified in this step is #6, therefore, current OLD value is exactly
Current OLD value is exactly #6.
S32:It regard next coding as present encoding, and reads present encoding.
The encoding stream above illustrated, the 4th is encoded to present encoding described in #6 and this step.
S33:Judge whether present encoding is to remove code, if it is, coding schedule is removed, into S2;If it is not, then into
S34。
It is not to remove code according to the encoding stream in example it is found that present encoding signified in this step is #6.
S34:Judge whether present encoding is end code, if it is, terminating;If it is not, then into S35.
It is not end code according to the encoding stream in example it is found that present encoding signified in this step is #6.
S35:Judge in coding schedule with the presence or absence of present encoding;If it is present into S36, otherwise, into S37.
Since third coding is also #6, for present encoding #6, there are the codings in coding schedule, enter
To step S36.
S36:It is exported the corresponding character information of present encoding as data flow, and according to the first default update Policy Updates
Coding schedule is to carry out the supplements of mapping relations;It returns and the step of current OLD value is present encoding is set.
It should be noted that the corresponding character information of the coding is not if having existed present encoding in coding schedule
Become, i.e., the corresponding character information of coding #6 in step is still #1#1.On the basis of upper primary data flow, this data
Stream output is exactly #1#1, is third time output stream.
As mentioned in step S3, mapping relations need successively to supplement or update, that is to say, that if in encoding stream only
One removing code, then the table item index needs in coding schedule successively increase.S35 is specifically divided into two sub-steps, respectively S360
And S361.
S360:It is exported the corresponding character information of present encoding as data flow;
S361:The initial character of the corresponding character information of present encoding and the corresponding character information composition of current OLD value is new
Character information sequence, which is added in coding schedule, obtains one group of new mapping relations.It returns and current OLD value is set for present encoding
Step.
The corresponding character information of present encoding is #1#1, and initial character #1, current OLD value is #6, corresponding character letter
Breath is #1#1, and therefore, fresh character information obtained in this step is exactly #1#1#1.Current entry index is #6, increases by one just
It is #7, i.e. present encoding table is as shown in table 3.That is, obtaining one group of new mapping relations in table 3, that is, encode 7 corresponding words
Symbol information is #1#1#1.
Table 3
Table item index | List item value |
#0 | #0 |
#1 | #1 |
#2 | #2 |
#3 | #3 |
#4 | #4 |
#5 | #5 |
#6 | #1#1 |
#7 | #1#1#1 |
Return step S31 is needed after above-mentioned steps S36, that is, repeats S31-S35.Next reading is encoded to #
2, it is present in coding schedule, corresponding character information is #2, on the basis of upper primary data flow, the data flow of this output
For #2, and the step of according to S36, one group of new mapping relations of addition are exactly to encode #8 and corresponding character information #2#1#1
(the corresponding character information #1#1 of the initial character #2 of the corresponding character information of present encoding #2 and current OLD value #6 is formed into new word
Accord with information).According to above-mentioned steps, each coding in the coding schedule provided is read, constantly update coding schedule, part mapping relationship,
As shown in table 4.
Table 4
Table item index | List item value |
#0 | #0 |
#1 | #1 |
#2 | #2 |
#3 | #3 |
#4 | #4 |
#5 | #5 |
#6 | #1#1 |
#7 | #1#1#1 |
#8 | #2#1#1 |
#9 | #2#2 |
#10 | #2#2#2 |
#11 | #1#1#1#1 |
Data decoding method provided in an embodiment of the present invention based on lzw algorithm, including code is removed by reading in encoding stream
To obtain root coding and end code;Coding schedule is established according to code, root coding and end code is removed;Wherein, include in coding schedule
About the mapping relations of coding and character information, character information specifically includes character or character string;It is right according to default decoding rule
The mapping relations lacked in coding schedule are successively supplemented or are updated until end code, while according to obtained mapping
The relationship output corresponding character information of each coding is using as data flow.It is encoded it can be seen that being safeguarded in this method by coding schedule
To the mapping relations of actual characters information representated by it, coding schedule is stored in the form of tables of data, to effectively promote data
Access efficiency, it is even more important that due to successively being supplemented in the mapping relations in coding schedule, with the number for reading coding
Increase, mapping relations are also being increasing, so that the probability that present encoding is present in coding schedule greatly improves, as long as current compile
Code does not need then to repeat its corresponding character information of calculating, is greatly lowered the process of iteration yet, improves in coding schedule
Decoding efficiency.
It is preferably carried out mode as one kind, the initial value of coding is 0, and the upper limit value of coding is 4095.
The size of each single item character string is no more than 12 in coding schedule, and such coding schedule has 212=4096, be worth for 0~
4095.In specific implementation, although the mapping relations in coding schedule are to supplement after reading coding, but have no effect on pre-
First establish coding schedule, that is to say, that a maximum coding schedule, table item index can be can establish when establishing coding schedule
From 0 to 4095, it is subsequent as reading coding adds corresponding character information again.
It is preferably carried out mode as one kind, further includes:Save finally obtained coding schedule.
In view of being related to some calculating in the renewal process of coding schedule, if next encoding stream and this encoding stream
If identical, then the coding schedule that this encoding stream obtains is called directly, is realized under by the character information in coding schedule
The decoding of one encoding stream.In specific implementation, identical label can be arranged in identical encoding stream, obtaining one in this way
When encoding stream, by label can quick-searching go out to whether there is identical encoding stream decompression has been carried out, if there is
Words, can directly acquire corresponding data stream, thus rapid decompression.
It is described in detail above for the embodiment of the data decoding method based on lzw algorithm, the present invention also mentions
For the data deciphering device based on lzw algorithm corresponding with this method.The device is specifically to be said from the angle of functional module
It is bright.Fig. 4 is a kind of structure chart of the data deciphering device based on lzw algorithm provided in an embodiment of the present invention.As shown in figure 4, should
Device specifically includes:
Coding schedule read module 10, for removing code by reading in encoding stream to obtain root coding and end code;
Coding schedule establishes module 11, for establishing coding schedule according to removing code, root coding and end code;Wherein, coding schedule
In include mapping relations about coding and character information, character information specifically includes character or character string;
Coding schedule operation module 12, for according to default decoding rule to the mapping relations of lacking in coding schedule carry out according to
Secondary supplement or update are until end code;
Coding schedule output module 13, for exporting the corresponding character information of each coding according to obtained mapping relations to make
For data flow.
Since the embodiment of device part is corresponded to each other with the embodiment of method part, the embodiment of device part is asked
Referring to the description of the embodiment of method part, wouldn't repeat here.
Data deciphering device provided in this embodiment based on lzw algorithm, including:Coding schedule read module is by encoding stream
It reads and removes code to obtain root coding and end code;Coding schedule establishes module and establishes and compile according to code, root coding and end code is removed
Code table;It wherein, include about the mapping relations encoded with character information in coding schedule, character information specifically includes character or word
Symbol string;Coding schedule operation module according to default decoding rule to the mapping relations lacked in coding schedule successively supplemented until
Until end code, coding schedule output module is according to the obtained corresponding character information of each coding of mapping relations output using as number
According to stream.It can be seen that being encoded to the mapping relations of its representative actual characters information in the present apparatus, by coding schedule maintenance with number
Coding schedule is stored according to the form of table, to effectively promote the access efficiency of data, it is even more important that due to reflecting in coding schedule
It penetrates in relationship and successively supplements, as the number for reading coding increases, mapping relations are also being increasing, so that present encoding
The probability being present in coding schedule greatly improves, as long as present encoding in coding schedule, does not need to repeat its correspondence of calculating
Character information, be also greatly lowered the process of iteration, improve decoding efficiency.
In addition, the present invention also provides a kind of data decoding apparatus based on lzw algorithm corresponding with the above method, and it is based on
Unlike the data deciphering device of lzw algorithm, the present embodiment mainly illustrates from hardware point of view.The equipment includes memory, is used
In storage computer program;
Processor realizes the data solution based on lzw algorithm as described in above-described embodiment when for executing computer program
The step of code method.
It is understood that the memory and processor in the present embodiment can be separately added to server, it is also possible to
The memory and processor of server itself.In specific implementation, processor and memory can be by buses or other means even
It connects.
Since the embodiment of device part is corresponded to each other with the embodiment of method part, the embodiment of device part is asked
Referring to the description of the embodiment of method part, wouldn't repeat here.
Data decoding apparatus provided in this embodiment based on lzw algorithm includes memory and processor, and processor is being held
It can be realized following method during row, remove code by reading in encoding stream to obtain root coding and end code;According to remove code,
Root coding and end code establish coding schedule;It wherein, include about the mapping relations encoded with character information, character in coding schedule
Information specifically includes character or character string;The mapping relations lacked in coding schedule are successively mended according to default decoding rule
Fill or update until end code, at the same according to the obtained mapping relations output corresponding character information of each coding using as
Data flow.It can be seen that the mapping relations of its representative actual characters information are encoded in this method by coding schedule maintenance, with
The form of tables of data stores coding schedule, to effectively promote the access efficiency of data, it is even more important that due in coding schedule
It is successively supplemented in mapping relations, as the number for reading coding increases, mapping relations are also being increasing, so that current compile
The probability that is present in coding schedule of code greatly improves, as long as present encoding in coding schedule, does not need to repeat calculating, its is right
The character information answered also is greatly lowered the process of iteration, improves decoding efficiency.
On the basis of the above embodiments, the present invention also provides a kind of computer readable storage medium, the media storage has meter
Calculation machine program realizes the data decoding based on lzw algorithm as described in above-described embodiment when computer program is executed by processor
The step of method.
The functional units in various embodiments of the present invention may be integrated into one processing unit, is also possible to each
Unit physically exists alone, and can also be integrated in one unit with two or more units.Above-mentioned integrated unit both may be used
To use formal implementation of hardware, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product
When, it can store in a computer readable storage medium.Based on this understanding, the technical solution essence of the present embodiment
On all or part of the part that contributes to existing technology or the technical solution can be with the shape of software product in other words
Formula embodies, which is stored in a storage medium, and it is each that the present invention is executed when reading the medium
The all or part of the steps of embodiment the method.And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory
(Read-OnlyMemory, ROM), random access memory (Random Access Memory, RAM), magnetic or disk etc.
The various media that can store program code.
Computer storage medium provided in this embodiment, being stored with corresponding computer program can be realized above-described embodiment
The data decoding method based on lzw algorithm.Its representative actual characters is encoded to by coding schedule maintenance in this method
The mapping relations of information store coding schedule in the form of tables of data, so that the access efficiency of data is effectively promoted, it is even more important
It is that, due to successively supplementing in the mapping relations in coding schedule, as the number for reading coding increases, mapping relations are not yet
It is disconnected to increase, so that the probability that present encoding is present in coding schedule greatly improves, as long as present encoding in coding schedule, is not required to
It repeats and calculates its corresponding character information, be also greatly lowered the process of iteration, improve decoding efficiency.
The data decoding method based on lzw algorithm, device, equipment and medium provided by the present invention have been carried out in detail above
It is thin to introduce.Each embodiment is described in a progressive manner in specification, the highlights of each of the examples are with other realities
The difference of example is applied, the same or similar parts in each embodiment may refer to each other.For device disclosed in embodiment
Speech, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part illustration
?.It should be pointed out that for those skilled in the art, without departing from the principle of the present invention, also
Can be with several improvements and modifications are made to the present invention, these improvement and modification also fall into the protection scope of the claims in the present invention
It is interior.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that
A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged
Except there is also other identical elements in the process, method, article or apparatus that includes the element.
Claims (9)
1. a kind of data decoding method based on lzw algorithm, which is characterized in that including:
Code is removed by reading in encoding stream to obtain root coding and end code;
Coding schedule is established according to the removing code, described coding and the end code;It wherein, include about volume in coding schedule
The mapping relations of code and character information, the character information specifically include character or character string;
The mapping relations lacked in coding schedule are successively supplemented according to default decoding rule or are updated until described
Until end code, while according to the obtained mapping relations output corresponding character information of each coding using as data flow.
2. the data decoding method according to claim 1 based on lzw algorithm, which is characterized in that described according to default solution
Code rule is successively supplemented or is updated until the end code to the mapping relations lacked in coding schedule, simultaneously
According to the obtained corresponding character information of each coding of mapping relations output to be specifically included as data flow:
Present encoding is read, determines the corresponding character information of present encoding to export as data flow according to coding schedule;
It is present encoding that current OLD value, which is arranged,;
It regard next coding as present encoding, and reads present encoding;
Judge whether present encoding is the removing code, if it is, removing coding schedule, and returns described according to the removing
Code, described coding and end code the step of establishing coding schedule, are to realize the updates of the mapping relations;
If it is not, then judging whether present encoding is the end code, if it is, terminating;
If it is not, then judging in coding schedule with the presence or absence of present encoding;
If it is present being exported the corresponding character information of present encoding as data flow, and according to the first default update rule
Coding schedule is updated to carry out the supplement of the mapping relations;It returns and the step of current OLD value is present encoding is set;
If it does not exist, then obtaining the corresponding character information of present encoding according to the second default rule that updates to carry out the mapping
The supplement of relationship, and exported the corresponding character information of present encoding as data flow;It returns and current OLD value is set for current volume
The step of code.
3. the data decoding method according to claim 2 based on lzw algorithm, which is characterized in that described according to described
One, which presets update Policy Updates coding schedule, is specially:
The initial character of the corresponding character information of present encoding and the corresponding character information composition fresh character information of current OLD value is suitable
Sequence, which is added in coding schedule, obtains one group of new mapping relations.
4. the data decoding method according to claim 2 based on lzw algorithm, which is characterized in that described pre- according to second
If updating rule obtains the corresponding character information of present encoding to carry out the supplement of the mapping relations, and present encoding is corresponding
Character information as data flow output specifically include:
The initial character of the corresponding character information of current OLD value and the corresponding character information of current OLD value is formed into fresh character information
It is exported as the character information of present encoding, and as data flow;
Present encoding and obtained fresh character information sequence are added in the coding schedule and obtain one group of new mapping relations;It returns
Return the step of current OLD value of setting is present encoding.
5. the data decoding method according to any one of claims 1-4 based on lzw algorithm, which is characterized in that coding
Initial value be 0, the upper limit value of coding is 4095.
6. according to claim 5 based on the data decoding method of lzw algorithm, which is characterized in that further include:Save final obtain
The coding schedule arrived.
7. a kind of data deciphering device based on lzw algorithm, which is characterized in that including:
Coding schedule read module, for removing code by reading in encoding stream to obtain root coding and end code;
Coding schedule establishes module, for establishing coding schedule according to the removing code, described coding and the end code;Wherein,
It include the mapping relations about coding and character information in coding schedule, the character information specifically includes character or character string;
Coding schedule operation module, for being carried out successively according to default decoding rule to the mapping relations lacked in coding schedule
Supplement updates until the end code;
Coding schedule output module, for according to the obtained mapping relations output corresponding character information of each coding using as
Data flow.
8. a kind of data decoding apparatus based on lzw algorithm, which is characterized in that including memory, for storing computer program;
Processor is realized when for executing the computer program and is based on lzw algorithm as claimed in any one of claims 1 to 6
Data decoding method the step of.
9. a kind of computer readable storage medium, which is characterized in that be stored with computer on the computer readable storage medium
Program, when the computer program is executed by processor realize as it is as claimed in any one of claims 1 to 6 based on lzw algorithm
The step of data decoding method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810690646.5A CN108900196A (en) | 2018-06-28 | 2018-06-28 | A kind of data decoding method based on lzw algorithm, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810690646.5A CN108900196A (en) | 2018-06-28 | 2018-06-28 | A kind of data decoding method based on lzw algorithm, device, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108900196A true CN108900196A (en) | 2018-11-27 |
Family
ID=64346731
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810690646.5A Withdrawn CN108900196A (en) | 2018-06-28 | 2018-06-28 | A kind of data decoding method based on lzw algorithm, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108900196A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110518917A (en) * | 2019-07-17 | 2019-11-29 | 华东计算技术研究所(中国电子科技集团公司第三十二研究所) | LZW data compression method and system based on Huffman coding |
CN111262587A (en) * | 2018-11-30 | 2020-06-09 | 康泰医学系统(秦皇岛)股份有限公司 | Data compression method, device, equipment and computer readable storage medium |
CN112199922A (en) * | 2020-08-25 | 2021-01-08 | 中国物品编码中心 | Encoding method, apparatus, device and computer readable storage medium |
CN114970454A (en) * | 2021-02-20 | 2022-08-30 | 北京同邦卓益科技有限公司 | Encoding processing method and device, electronic equipment and storage medium |
-
2018
- 2018-06-28 CN CN201810690646.5A patent/CN108900196A/en not_active Withdrawn
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111262587A (en) * | 2018-11-30 | 2020-06-09 | 康泰医学系统(秦皇岛)股份有限公司 | Data compression method, device, equipment and computer readable storage medium |
CN111262587B (en) * | 2018-11-30 | 2023-06-06 | 康泰医学系统(秦皇岛)股份有限公司 | Data compression method, device, equipment and computer readable storage medium |
CN110518917A (en) * | 2019-07-17 | 2019-11-29 | 华东计算技术研究所(中国电子科技集团公司第三十二研究所) | LZW data compression method and system based on Huffman coding |
CN110518917B (en) * | 2019-07-17 | 2023-01-03 | 华东计算技术研究所(中国电子科技集团公司第三十二研究所) | LZW data compression method and system based on Huffman coding |
CN112199922A (en) * | 2020-08-25 | 2021-01-08 | 中国物品编码中心 | Encoding method, apparatus, device and computer readable storage medium |
CN112199922B (en) * | 2020-08-25 | 2023-08-22 | 中国物品编码中心 | Encoding method, apparatus, device, and computer-readable storage medium |
CN114970454A (en) * | 2021-02-20 | 2022-08-30 | 北京同邦卓益科技有限公司 | Encoding processing method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108900196A (en) | A kind of data decoding method based on lzw algorithm, device, equipment and medium | |
EP0732812B1 (en) | Data compressing apparatus, data restoring apparatus and data compressing/restoring system | |
CN105426413B (en) | A kind of coding method and device | |
CN104021123B (en) | method and system for data migration | |
CN108540141A (en) | Polar code coding/decoding methods and device | |
CN105260354A (en) | Chinese AC (Aho-Corasick) automaton working method based on keyword dictionary tree structure | |
CN106788891A (en) | A kind of optimal partial suitable for distributed storage repairs code constructing method | |
US20080162517A1 (en) | Method and system for creating an in-memory physical dictionary for data compression | |
CN116016606B (en) | Sewage treatment operation and maintenance data efficient management system based on intelligent cloud | |
CN103746706B (en) | Test data compression based on double distance of swimming alternate coded and decompression method | |
CN108712232A (en) | A kind of multi-code word parallel decoding method in continuous variable quantum key distribution system | |
CN110868223B (en) | Numerical operation implementation method and circuit for Huffman coding | |
CN116805537B (en) | Data processing method for heart-lung rehabilitation management system | |
US9236881B2 (en) | Compression of bitmaps and values | |
CN106067824A (en) | A kind of sequencing data compression method based on bigeminy codon | |
CN103425669A (en) | Number segment and attribution encoding method, number segment and attribution encoding system, attribution query method and attribution query system | |
CN114254748A (en) | Extended coding method, system and related device for storage channel | |
CN108288966A (en) | The rate-matched processing method and processing device of polarity Polar codes | |
CN115276666B (en) | Efficient data transmission method for equipment training simulator | |
CN108880559A (en) | Data compression method, uncompressing data, compression device and decompression apparatus | |
CN105320609A (en) | Mobile terminal based data storage method and system | |
CN103746704A (en) | Chip testing data transmission method based on dual-run-length alternative coding | |
CN100474781C (en) | Compression method of two-byte character data | |
CN117040542A (en) | Intelligent comprehensive distribution box energy consumption data processing method | |
CN110209598A (en) | A kind of cache memory, a kind of data read-write control method and system |
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 | ||
WW01 | Invention patent application withdrawn after publication | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20181127 |