Data compressing method and data decompressing method

Abstract: A data compressing method and a data decompressing method, and a data compressing apparatus and a data decompressing apparatus employ a splay coding instead of an arithmetic coding to achieve a high speed code entering process. The data compressing apparatus encoding input data according to a history of occurrence of the input data in the past to compress it, includes a pre-data retaining unit (100) retaining a context, a history retaining unit (101) retaining a combination of input data and a context, a code tree retaining unit (102) retaining code trees each independent for each context, a code tree determining unit (103) determining a code tree, a code outputting unit (104) outputting unique data according to bifurcation from a node on the code tree, a code tree rearrangement unit (105) exchanging an encoded leaf with another leaf or an internal node, and a pre-data updating unit entering the data in the pre-data retaining unit (100).

Description: BACKGROUND OF THE INVENTION (1) Field of the Invention The present invention relates to a data compressing method and a data decompressing method, and a data compressing apparatus and a data decompressing apparatus therefor. (2) Description of Related Art Recent computers tend to deal various types of data such as graphic character codes, vector information, image pictures, etc. and a volume of the data dealt in. the computer rapidly increases. When a large volume of data is dealt with, redundant portions in the data are omitted to compress the volume of data so as to decrease a required storage capacity or transmit the data faster. A universal coding is proposed as a method being capable of compressing various data in one manner. Incidentally, this invention is applicable to various data, not limited to a field of character code compression. In this specification, one word unit is called a character, and data composed of the voluntary number of words is called a character string. There are a dictionary coding utilizing analogy of data sequences, and a statistical coding utilizing frequency of occurrence of a data string. The above-mentioned universal coding is a representative method of the statistical coding. As a representative manner of the universal coding, there is also an arithmetic coding. The arithmetic coding is to generate a code adaptable to an occurrence probability of each character without using a code table, considered to be able to compress at a maximum efficiency if an occurrence probability of each character of information source is known. The arithmetic coding is classified into a binary arithmetic coding and a multi-value arithmetic coding of more than binary value. Hereinafter, the multi-value arithmetic coding will be described. In the multi-value arithmetic coding, a number line of 0 ≤ P < 1 (described as [0,1] hereinafter) is , to begin with, divided by the number of events of characters having appeared (referred as a symbol, hereinafter). A width of each section is taken as in proportion to a ratio of an occurrence probability of each symbol, and the sections are arranged in the order of high occurrence probability. Next, a section corresponding to an occurring symbol is selected, the selected section is divided into sections corresponding to the number of all symbols when the next symbol occurs, and a section corresponding to the next symbol is selected so that the selected section is divided recursively. The above process will be described in more detail by reference to illustrations showing a principle of the multi-value arithmetic coding in FIGS. 70(a) and 70(b). FIG. 32(a) shows an example of frequencies of occurrence of symbols, while FIG. 32(b) showing an example of how to divide the section of a symbol. By way of an example where a section of a graphic character string "abe" is obtained in the dividing. Now, a number line (0, 1) is divided into five sections of characters a, b, c, d and e as shown in FIG. 70(a). First, a section (0, 0.2) of a symbol "a" which occurs first is selected. Then, the selected section (0, 0.2) is further divided into five sections of all the symbols "a" through "e". A section (0.04, 0.06) of the symbol "b" which occurs secondary is selected, then divided into five sections of all the symbols "a" through "e". A section of the symbol "e" which occurs last is selected so that a section [0.05, 0.06) of a character string "a b e" is finally obtained. As above, by repeating the above process on all input data, it is possible to determine a section of a character string to be encoded. An arbitrary point in the section of the character string that is finally determined is represented in a binary notation, then outputted as a compressed code. A term "arithmetic coding" is derived from that a code word is expressed in a binary numerical value after the decimal point as [0.11011..], which can be obtained in calculation. As a method to divide a section according to a frequency of occurrence as above, there are a static coding in which a section is divided according to a predetermined frequency of occurrence, not depending on an actual frequency of occurrence of a character string, a semi-adaptive coding in which a section is divided according to a frequency of occurrence obtained by scanning in advance all character strings, and an adaptive coding in which a frequency is calculated whenever a character occurs to reset the section for each character. Meanwhile, a method to compress data into a unit of bite (character) using the above multi-value arithmetic coding for file compression is described in, for example, the following two documents (1) and (2). (1) "Arithemtic Coding for Data Compression," Commun. of ACM. Vol.30, No.6, PP.520-540 (1986) (2) "An Adaptive Dependency Source Model for Data Compression Scheme," Commun. of ACM, Vol.32, No.1, PP.77-83 The document (1) teaches an actual algorithm of the multi-value arithmetic coding. The multi-value coding in document (1) is one of the methods, which is called as an entropy coding which codes and compresses data by a single character unit. In the entropy coding, a probability of occurrence of a focused character is encoded in the multi-value coding and the probability of occurrence of each character is sequentially updated whenever a character occurs so that the entropy coding can code various data dynamically and adaptively. A detailed process of the multi-value coding is as shown in a flowchart in FIG. 33(a). The document (2) teaches a method to express a focused character with a conditional probability using an immediately preceding character, encode the conditional probability in the multi-value coding so as to obtain a high compression rate. In the method in the document (2), each of the conditional probability is sequentially updated so as to be able to encoded various data dynamically and adaptively various data. In such the multi-value coding, the process shown in a flowchart in FIG. 32(b) is performed. There is proposed, instead of the multi-value coding, a Dynamic Huffman Coding which is a modification of Huffman coding (refer to "Variations on a Theme by Huffman", IEEE Trans. Inform. Theory, Vol.24, No.6, 1978, or "Design and Analysis of Dynamic Huffman Codes", Journal of ACM, Vol.34, No.4, 1987). The Dynamic Huffman Coding has a coding efficiency inferior to the multi-value coding, which requires a longer processing time. For this, there is no actual application of a method to encode a conditional probability in the dynamic Huffman coding. FIG. 34 shows an example of an algorithm of the multi-value arithmetic encoding and decoding. Different from the arithmetic coding, there is a Splay-Tree coding (refer to "Application of Splay Tree to Data Compression" by Douglas W. Jones, Commun. of ACM, Vol.31, No.8, P.996-1007, for example). The splay coding uses a code table in a tree structure (referred as a code tree, hereinafter) as shown in FIG. 35(a), where a symbol is entered at an end of the code tree (called a leaf, in general) and a distance from a top of the code tree (called a root, in general) to a leaf at which input data is stored is outputted as a code word. More specifically, assuming the path goes down from the root to the leaf of the code tree, "1" is allocated to the code word when the path branches to the right, and "0" is allocated when the path branches to the left. In the example shown in FIG. 35(a), the code of a symbol A becomes [10110] and a symbol B becomes [001]. If the code length is changed (that is, if the code is updated), a coded leaf is exchanged with other leaf or a contact on the code tree (called as a node). FIG. 35(b) shows an example of the above-mentioned code updating. As shown in FIG. 35(b), as input data, symbols A, B, C and D are initially stored in leaves of the code tree. A node of the symbol A and a node of the symbol C are exchanged, a higher degree node D of the symbol A and a node of a symbol E are exchanged as shown in FIG. 35(C). As a result, the code of the symbol A becomes [110] from [10110] so that the code is updated. The above case is to dynamically encode a probability of occurrence of each word in a variable length coding. To more increase a compression rate, a conditional probability of occurrence introduced a relationship of dependency between an input signal and the immediately preceding character therein is encoded in a dynamic variable-length coding. This method is a statistical coding using a statistical characteristic of data. As shown in FIG. 36, this coding is performed in a process made up of two stages, that is, a context collecting step 511 and a dynamic variable-length coding step 512, as shown in FIG. 36. A context in a front and behind relation with a character string is collected from input data at a context collecting step, a tree structure of a context as shown in FIG. 37(b) is generated and it is encoded in a dynamic variable-length coding to determine a conditional probability. The above conditional probability is determined by counting the number of occurrence every time a character string crosses over a character in each node on a context tree in a tree structure shown in FIG. 75(b). A context collecting method to determine a conditional probability is chiefly classified into the following two methods. Incidentally, the number of character of a condition (a context) will be hereinafter referred as degree (refer to "Data Compression Using Adaptive Coding and Partial String Matching", JOHN G. CLEARY et al., IEEE, Vol.COM-32, No.4, APRIL 1984, PP.396-402). (1) Fixed-degree context collecting method This method expresses a condition of a conditional probability with a fixed character number. For instance, in an degree-2 context, a context of a character following two immediately preceding characters is collected to encode a conditional probability p(y | x 1 , x 2 ), wherein y is a focused character to be encoded, x 1 and x 2 are the first character and the second character followed by the focused character, respectively. (2) Blending Context Collecting Method In the above fixed-degree context collecting method, if the immediately preceding conditional character string rarely occurs, an estimation of a conditional probability tends to be inaccurate. To the contrary, if the immediately preceding conditional character string frequently occurs, an estimation of the conditional probability tends to be accurate, where there still remains a possibility to increase the degree. In general, data coming to have a stronger correlation between characters when the degree used is more increased can provide a high compression rate. However, data coming to have a weaker correlation between characters as the degree used is more increased provides a poor compression rate. What can solve the above problem is to blend the context (blending of the degree). In this method, the degree of the immediately preceding character string is not fixed. The degree is increased if the occurrence is frequent, and if the occurrence is rare, the degree is kept in the lower number. As this, the degree is increased adaptively to input data. However, the statistical coding employing an arithmetic coding to a dynamic variable-length code needs to compute once more an accumulated frequency of all data having been inputted every time data is inputted and to divide a number line of [0, 1) once more. There is required an enormous volume of arithmetic process so that it is impossible to increase the processing rate. THE COMPUTER JOURNAL, vol. 33, No. 4, August 1990, CAMBRIDGE (GB), pages 308-313, XP000159501; BAILEY ET AL: 'pipelining data compression algorithms' discloses a data compressing method for compressing input data encoding the input data according to a history of occurrence of the input data in the past. It further teaches to combine string parsing encoding with variable length code words. COMMUNICATIONS OF THE ASSOCIATION FOR COMPUTING MACHINERY, vol. 31, no. 8, August 1988, NEW YORK US, pages 996-1007, XP 002007511; JONES: 'application of splay trees to data compression' discloses a combination of splay-coding algorithm with the use of Markov models. JACOBSSON, M.: Compression of Character Strings by an Adaptive Dictionary, Bit 25, (4) pp. 593-603 (1985), XP-000746842 describes the "forest of trees" method and the collecting of characters and of generating a context tree. SUMMARY OF THE INVENTION To solve the above problems, an object of this invention is to provide a data compressing method and a data decompressing method, and a data compressing apparatus and a data decompressing apparatus therefor, which enable a high-speed code entering process by entering new data into a code tree while rearranging the code tree, instead of comploying a computation of sections in an arithmetic coding. In accordance with the present invention, a data compressing method for compressing input data by encoding the input data according to a history of occurrence of the input data in the past, comprising performing a context collecting step for collecting character strings of said input data, and performing a coding step for generating and updating a code tree while rearranging the code tree according to the character strings of said input data obtained in said context collecting step. A data compressing method for compressing input data by encoding the input data according to a history of occurrence of the input data in the past comprising collecting the character strings of said input data, numbering them, and entering them in a dictionary, corresponding a code to each of the character strings, encoding and updating the code corresponding to a dictionary number of a longest coinciding character string, entering an elongated character string of said character string to be encoded until said elongated character string reaches a predetermined maximum character string length, entering a code corresponding to said elongated character string. A data decompressing method for decompressing encoded data obtained by encoding input data according to a history of the input data in the past, comprising performing context collecting step for collecting character strings of decoded data, performing a coding step for generating and updating a code tree while rearranging the code tree according to said character strings of the decoded data obtained at said context collecting step. A data decompressing method for decompressing encoded data obtained by encoding input data according to a history of the input data in the past, comprising collecting character strings of decoded data, numbering them, and entering them in a dictionary, and corresponding a code to each of the character strings of said decoded data, decoding a character string corresponding to a dictionary number as a code and updating it, entering an elongated character string of said encoded character string until said elongated character string reaches a predetermined maximum character string length, entering a code corresponding to said elongated character string. BRIEF DESCRIPTION OF THE DRAWINGS FIGS. 1 through 14 are block diagrams showing aspects of this invention; FIG. 15 is a block diagram of a data compressing apparatus and a data decompressing apparatus according to a first embodiment of this invention; FIG. 16(a) shows an example of a storing form of a context tree; FIG. 16(b) shows a parental relationship of a dictionary; FIG. 17 depicts an initial state of a code tree; FIG. 18 shows an example of arrangement to store a code tree; FIGS. 19(a) and 19(b) illustrate an example of a basic operation for code updating of splay codes and code updating operation on the splay codes; FIG. 20 is a flowchart illustrating a procedure of encoding according to the first embodiment of this invention; FIGS. 21(a) and 21(b) depict procedures for updating a context tree and a code tree, respectively, according to the first embodiment of this invention; FIGS. 22(a) and 22(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIGS. 23(a) and 23(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIGS. 24(a) and 24(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIGS. 25(a) and 25(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIGS. 26(a) and 26(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIGS. 27(a) and 27(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIGS. 28(a) and 28(b) depict procedures for updating the context tree and the code tree, respectively, according to the first embodiment of this invention; FIG. 29 illustrates a character string after encoding according to the first embodiment of this invention; FIGS. 30(a) and 30(b) show algorithms for generating a context tree; FIG. 31 is a flowchart for illustrating a procedure for decoding according to the first embodiment of this invention; FIGS. 32(a) and 32(b) illustrate a principle of a multi-value arithmetic coding; FIGS. 33(a) and 33(b) are flowcharts illustrating procedures in the multi-value arithmetic coding to compress data by a character, respectively; FIG. 34 shows an example of algorithm of the multi-value arithmetic coding; FIGS. 35(a) and 73(b) illustrate a principle of a splay coding; FIG. 36 illustrates a principle of a statistic encoding; and FIGS. 37(a) and 37(b) show an example of entry to a context tree. DESCRIPTION OF THE PREFERRED EMBODIMENT (a) Description of Aspects of the Invention A data compression method according to this invention is to encode input data according to a history of occurrence of the data occurring in the past, which takes the following steps: (1) a context collecting step to collect character strings of input data; and (2) a coding step to generate and update a code tree while rearranging the code tree according to a data string of the input data having been obtained at the context collecting step. In the above-mentioned data compression method according to this embodiment, character strings of input data are collected, and a code tree is generated and updated while the data is processed in the splay operation according to the character strings of the input data obtained at the context collecting step. Accordingly, it is possible to perform a process in two stages simultaneously, that is, a stage to determine a frequency of occurrence of occurring input data to establish a probability model to make a code table, and a stage to assign a code to each input data by reference to this code table, whereby a processing rate in the data compression may be largely increased. In the data compression method of this invention, character strings of the above input data are collected, numbered respectively, and entered in a dictionary. Each character string corresponds to a code. The code corresponding to a dictionary number of the longest coinciding character string is encoded and updated while an elongated character string of a character string to be encoded is entered until it reaches a predetermined maximum character string length so as to enter the code corresponding to the elongated character string. As above, according to the data compressing method of this invention, an extended character string of a character string to be encoded may be entered until it reaches a predetermined maximum character string length so as to enter a code corresponding to the extended character string. Accordingly, it is possible to encode input data as a character string not in a unit of one character, but in a unit of a plurality of characters, thereby increasing largely a processing rate in the data compression. The above character string may be entered in the dictionary in such a manner that the immediately preceding character that has been already encoded is first entered and a character string following the immediately preceding character is then encoded. Alternatively, a code may be assigned to each single character and, if a character string following the immediately preceding character is not included in character strings in the dictionary that have been already collected, a code for the single character is encoded and outputted. After that, the encoded character following the immediately preceding character is entered in the dictionary. through the above process, the character string to be entered in the dictionary is entered from the immediately preceding character that has been already encoded, then a character string following the immediately preceding character is encoded. If the character string following the immediately preceding character is not included in character strings in the dictionary that have been already collected, a code for the single character is encoded, outputted and updated. After that, the encoded character following the immediately preceding character is entered in the dictionary. Therefore, it is unnecessary to enter a character string that is not contained in the dictionary every occasion so that a processing rate in the data compression may be largely increased. On the other hand, a data decompressing method of this invention is to decode encoded data that have been encoded according to a history of input data in the past, which takes the following step: (1) a context collecting step to collect character strings of decoded data; and (2) a splay coding step to generate and update a code tree while rearranging the code tree according to a character string of the decoded data obtained at the context collecting step. In the above data decompressing method according to this invention, character strings of decoded data are collected at the context collecting step, and a code tree is generated and updated while being rearranged according to the character string of the decoded data obtained at the context collecting process. Therefore, according to the above-mentioned data decompressing method of this invention, it is possible to perform a process in two stages simultaneously, that is, a stage to determine a frequency of occurrence of a code of the character string to be decoded, establish a probability mode to make a code table, and a stage to decode the code of the character string to be decoded by reference to this code table, whereby a processing rate in the data decompressing may be largely increased. The data decompressing method of this invention is to decode input data that have been encoded according to a history of input data in the past, in which a character strings of decoded data are collected, numbered respectively, and entered in the dictionary, a code is corresponded to each of the decoded character strings, a character string corresponding to a dictionary number is encoded and updated, an elongated character string of the character string to be encoded is entered until it reaches a predetermined maximum character string length, and a code corresponding to the extended character string is then entered. In the above-mentioned data decompressing method of this invention, it is possible to enter an elongated character string of a character string to be encoded until it reaches a predetermined maximum character string length so as to enter a code corresponding to the extended character string. It is therefore possible to decompress the input data not in a unit of one character but as a character string in a unit of a plurality of characters. This may largely increase a processing rate in the data decompression. Further, in the data decompressing method of this invention, it is possible to enter a character string in the dictionary in such a manner that the immediately preceding character that has been decoded is entered, then a character string following the immediately preceding character is decoded. It is alternatively possible to assign a splay code to every single character, and if a code of single character in a character string following the immediately preceding character is not included in collected character strings in the dictionary is encoded, the code is updated, then the decoded character following the immediately preceding character is entered in the dictionary. According to the data decompressing method of this invention, a character string is entered in the dictionary in such a manner that the immediately preceding character that has been decoded is first entered, then a character string following the immediately preceding character is decoded. In practice, a code is assigned to every single character, to begin with, if a code of a single character in a character string following the immediately preceding character being not included in collected character strings in the dictionary is decoded, the code is updated and the decoded character following the immediately preceding character is entered in the dictionary. Therefore, according to the data decompressing method of this invention, it is unnecessary to enter a code of a character string not included in the dictionary every occasion so that a processing rate in the data decompression may be further increased to a large extent. (b) Description of First Embodiment of the Invention FIG. 15 is a block diagram of a data compressing apparatus and a data decompressing apparatus according to a first embodiment of this invention. In FIG. 15, reference numeral 1 denotes the data compressing apparatus encoding an inputted character according to a history of occurrence of it in the past to compress it, 2 denotes the data decompressing apparatus decompressing the character having been encoded in the data compressing apparatus 1. The data compressing apparatus takes a context collecting step 11 to collect contexts of inputted character string data to generate a context tree, and a splay coding step 12 to generate and update a code tree in splay operation according to the character strings of the input data obtained in the context collecting step 11. On the other hand, the data decompressing apparatus 2 takes a splay coding step 21 to generate and update a code tree in the splay operation according to the character strings of the decompressed data having been encoded in the data compression apparatus 1, and a context collecting step 22 to collect character strings as the decompressed data. Hereinafter, the data compressing apparatus will be referred as an encoder and the data decompressing apparatus as a decoder. (1) Description of Encoder FIGS. 16(a) and 16(b) depicts an example of a context tree generated in the context collecting step 11. FIG. 16(a) shows an example in which character strings are stored in a storage in the form of a list in order to search the context tree within a short period of time in a Hashing Method. FIG. 16(b) shows a dictionary (list) in a tree structure in which the character strings are stored as in a relationship of parentage. Address shown in FIG. 16(a) is expressed in a hexadecimal notation. In the example shown in FIG. 16(a), the maximum size of the context tree is 4K nodes (4KW). As this, if all characters are entered in advance, a position of a brother node in the first level connecting to the root is known previously so that a direct access is capable without an operation on the list in the search. In the second level and below, there are stored addresses of child nodes and right brother nodes. In a search, a character string is accessed by operating the list while being collated stored characters in the form of a list until the character string coincides with the stored characters. When the context tree is initialized, the addresses are set to up to 100. At this time, End of File code (EOF) is entered in an address 100 in the first level, and a storage below an address 101 are served for new entry. FIG. 17 shows an example of a code tree generated at the splay coding step 12 above-mentioned. The code tree is set at the initialization, as shown in FIG. 17, basically in the same manner as in the splay-tree coding. If the maximum size of the code tree is up to 4K nodes (4KW) correspondingly to FIG. 16(B), the nodes in the code tree are classified into two types, an interior node (with a child node) and an exterior node (an end of each code without a leaf or child node). In the splay coding, there are used three arrays, that is, Up, Left and Right, in order to access to the code tree, as shown in FIG. 18. In the Up array, an address from each node to its parent node is stored. In the Left array, an address from each node to its left child node is stored . In the Right array, addresses from each node to the right child node. In the Up array, interior nodes are stored in the leading 4 KW [address (hexadecimal) 000-FFF], and exterior nodes are stored in the remaining 4 KW [address (hexadecimal) 1000-1FFF]. As in the above fashion, it is possible to correspond a code for each node in the context tree with an address of the code tree; a node pointer (number) of a context tree + 4K. Incidentally, the Up array has a 13 bit width, the Left and Right arrays each has a 12 bit width. Basic operation of the code tree having the above structure at the time of updating will be next described by reference to FIGS. 19(a) and 19(b). FIG. 19(a) depicts a basic operation of the splay code at the time of updating. As shown in FIG. 19(a), when a character A is accessed, a node A is exchanged with a node C on a branch which is in opposite to and two stage above a branch to which the node A attaches. If a character C among characters A through E is accessed, the code tree is reshaped as, for example, shown in FIG. 19(b). Namely, the above-mentioned basic operation is repeated twice to update the code tree. The basic operation in the second time is to update a length of the parent node of the node which has been updated in the first time. As above, if a depth of the code tree becomes deeper, repetition of the above basic operation allows a distance from the root to the accessed node C (code 0110) to be reduced to a half (code 10). This dynamic recombination of the code tree from the root to the accessed node allows the code table to be adaptable to input data. In other words, the code updating of the splay codes is as the Move-To-Front operation in the linear list is performed in a Binary-Tree. A process for generating a context tree at the context collecting step 11 and process for generating and updating the code tree at the splay-coding step 12 as above will be next described in more detail by reference to Steps E1 through E31 in a flowchart shown in FIG. 20. Here, an input character is designated as K (K is an arbitrary character) and a character inputted immediately before the input of the character K is designated as P (P is an arbitrary character). A context tree, a code tree and the immediately preceding character P are initialized (Step E1). A check is made on whether all characters having been inputted are encoded or not (Step E2). If any input character is left unencoded, a length L of a character string is set to zero (Step E3), and the character K is inputted (Step E4). Then, a check is made on whether the immediately preceding character P on the context tree has a child node therebelow (Step E5). If the character P does not have a child node, a degree-0 code of the input character K is outputted (Step E6), and the input character K is entered in the context tree as a child node below the immediately preceding character P (Step E7). On the side of the code tree, a node used to enter the character K and an escape code is generated below the immediately preceding character P, the character K is then entered (Step E8). An example of an algorithm to generate a node is shown in FIG. 30. The immediately preceding character is altered to the input character K (Step E16). A check is made on whether a length L' of the immediately preceding character string is equal to a maximum length Lmax of the character string or not (Step E24). If the length L' of the immediately preceding character string is not equal to the character string maximum length Lmax, a check is made on whether the immediately preceding character string has been encoded with the degree-1 code and outputted or not (Step E25). If the immediately preceding character string has not been encoded with the primary code, a length L of a focused character string is shifted to the length L' of the immediately preceding character string (Step E28). A check is made on whether the character K has been encoded or not (Step E9). If the character K has been encoded, the above process from Step E2 is repeated (YES route at Step E9). If the character K has not been encoded, the above process from Step E3 is repeated (NO route at Step E9). If a character stored in the child node is in coincidence with the input character K at the above-mentioned Step E10, a length of the character string is increased by 1 (Step E17). A check is made on whether a length of this character string is equal to the maximum code length Lmax set in advance or not (Step E18). If not equal, a check is made on whether all the characters of the input data have been encoded or not (Step E19). If there remains any character that has not been encoded, the input characters up to now are shifted to the immediately preceding character P (Step E20), and a character K is further inputted (Step E21). The procedure then goes back to the process at the above-mentioned Step E10, where a check is made on whether a character stored in the child node is in coincidence with the character K or not. If not in coincidence, a check is made on whether a length of the character string is 0 or not (Step E11). If the length L is equal to 1 or more, in other words, the immediately preceding character P has a child node but the corresponding character K is not yet attached, an escape code below the immediately preceding character P is outputted and a degree-0 code of the character K is outputted (Step E12). Further, the character K is entered as a brother node of the child node below the immediately preceding 'character P on the code tree (Step E13). The escape code below the immediately preceding character P on the code tree is divided into an escape code and a code of the character K, and the code of the character K is added (Step E14). Code lengths of the escape code and the degree-0 code K on the code tree are updated as splay codes (Step E15). As above, it is possible to enter an elongated character string of an encoded character string until the elongated character string reaches a predetermined maximum character string length. Thereafter, via the above-mentioned Steps E16 and E24, check is again made on whether the immediately preceding character string is outputted as a degree-1 code or not (Step E25). More specifically, if the immediately preceding character string is encoded as a degree-1 the primary code and outputted, an elongated character string that is the immediately preceding character string attached a leading character of the elongated character (string) thereto is entered in the context tree (Step E26). A code of the elongated character string having been encoded is entered in the code tree (Step E27). Then, the process from the Step E28 is repeated. The above manner to enter the code is such conducted as to branch the code of the immediately preceding character and add the degree-1 code of the character string added the character K thereto. In the branching of the character string, the escape code is branched as being regarded as a code of the encoded character string to generate a code of the original character string and a code of the character string attached the character K thereto. As above, the immediately preceding character having been encoded is first entered as a dictionary entered character string, and a character string following this immediately preceding character is then encoded. If the length L of the character string is equal to the maximum code length Lmax set in advance at the above Step E18, or if the length L of the character string is equal to 0 at Step E11, a degree-1 code corresponding to a reference number of a character (string) of the context tree is outputted (Step E22). A code length of the degree-1 code outputted from the code tree is updated as a splay code (Step E23), thereafter the process from the above-mentioned Step E24 is performed. The above closed loop process is to elongate the number of entered characters (a length of a character string) if a combination of the immediately preceding character P and the input character K has been entered in the context tree so as to enter it by a unit of a character string. If all the input characters have been encoded at the above-mentioned Step E2, a check is made on whether the immediately preceding character P on the context tree has a child node therebelow or not (Step E29). If the immediately preceding character P has a child node, an escape code below the immediately preceding character P is outputted (from NO route at Step E29 to Step E30). Then, a degree-0 code of an EOF representing End Of File is outputted (Step E31), then the process is terminated (from NO route at Step E29 to Step E31). If the immediately preceding character P does not have a child node, a degree-1 code of EOF is outputted, and the process is terminated. In the data compressing method for encoding a character string as input data according to a history of its occurrence in the past to compress it, character strings of input data are given respective numbers and entered in the dictionary, while the splay codes are encoded and updated correspondingly to each of the character strings in the above process. The updating and generating the context tree and the code tree will be next described in more detail by reference to FIGS. 21 through 28, by way of example where the above input character K is limited to any of alphabets a, b and c, and characters "abc, abc, ab and b" are successively inputted. As shown in FIGS. 21(a) and 21(b), characters a, b and c, and an end code EOF which is outputted after all input data have been encoded are in advance given respective numbers and entered as a 1 , b 2 , c 3 , EOF 4 in both the context tree and the code tree. By initializing the context tree as above, any of the characters a, b and c which have been entered in the first place becomes an immediately preceding character. If there is no context following the immediately character, the immediately character also serves as an independent sole reference number. In the following description, the character c is assumed to be a first immediately preceding character. As shown in FIG. 21(b), the code tree is a binary tree where a code "0" is assigned to the entered character when a path goes down leftward at the node from the root to a node, while "1" is assigned to the entered character when the path goes down rightward at the node from the root to a node. At the time of encoding, a path of the reference number of a corresponding character from the node to the root is stacked, the path is reversed, and a code "0" or "1" is assigned depending on whether the path descends to the left or to the right, whereby a code word corresponding to the reference number of that character may be obtained. As degree-0 codes of the characters, a 1 , b 2 , c 3 and EOF4, become "00, 01, 10, and 11", respectively. When a character string "abc" is inputted in a state shown in FIGS. 21(a) and 21(b), a new node is generated below "c" (c 3 ) on the context tree since the character c (c 3 ) having been entered is assumed to be an immediately preceding character, and the first character "a 5 " of the character string "abc" and an escape code (ESC 6 ) representing no entry of the character "a 5 " are entered. On a side of the code tree, since "a" has been entered in the code tree as shown in FIG. 22(b), a node in which "a" has been entered is exchanged with a higher degree node of "c" which is the immediately preceding character, "a" and an escape code (ESC) are entered with this "c" regarded as a new root (degree-1 encoding). The above process is performed on the characters "b" and "c" in the character string "abc". Thereby, the context tree and the code tree when "b" is inputted become as shown in FIGS, 23(a) and 23(b), respectively. When "c" is next inputted, the context tree and the code tree become as shown in FIGS. 24(a) and 24(b), respectively. This process corresponds to the above-mentioned closed loop process performed via the YES route at the Step E5, the NO route at Step E10 and the NO route at Step E25 shown in FIG. 20. Namely, if there exists no child node below an immediately preceding character on the context tree, a nodes used to enter an input character and an escape code therein are newly generated below the immediately preceding character to enter them therein. On the code tree, if the same character as a character having been entered in the past is again inputted, a node in which the character having been enter in the past is exchanged with a higher degree node of a node in which an immediately preceding character of the inputted character is entered, the node in which the character has been entered in the past is shifted to the higher degree, thereby decreasing a distance from the root to the node of that character to a half so as to shorten a code length. When a character string "abc" is inputted successively, only a character "a" in the character string "abc" is tried to be entered below "c 9 " that is the last character "c" in the character string "abc" having been inputted in the first place and is considered to be an immediately preceding character. However, "a 5 " has been already entered below "c 3 " in the code tree as shown in FIG. 24(a), so that a character to be entered is elongated from one character "a" to two characters "ab", and "b 11 " is entered below "a 5 " as shown in FIG. 25(a). At this time, an escape code (ESC) stored below "c" along with "a" is branched to generate a new node, in which the entered "ab" obtained by elongating is entered in the context tree. Successively, if "b" of the character string "abc" is tried to be entered in the context tree, a character to be entered is elongated from one character "b" to two characters "bc", "c 12 " is then entered below "b 7 " as shown in FIG. 26(a), since "b 11 " has been already entered below "a 5 " as shown in FIG. 25(a). At this time, on the code tree, a node of an escape code (ESC) stored below "a" along with "b" is branched to generate a new node, and the "bc" entered by elongating by one character on the context tree is entered therein, as shown in FIG. 26(b). If the last character "c" of the next character string "abc" is entered, the above process is performed. A resulting states of the context tree and the code tree are shown in FIGS. 27(a) and 27(b), respectively (up to this point, "abc abc" have been inputted). If a character string "ab" is further entered, on the context tree, one character "a" is tried to be entered below an immediately preceding character "c 12 ". However, "a 13 " is already stored below "c 9 " as stated above, so the number of characters to be entered is increased by one to yield "ab", "b" is then tried to be entered below "a 13 ". However, "b 11 " is already stored below "a 5 " as shown in FIG. 27(a), so the number of characters to be entered is increased by one to yield "abb", "b" is then entered below "b 11 ". At this time, on the code tree, a node in which "ab" is stored is branched so as to enter "abb" therein. The above process corresponds to the above-mentioned closed loop process performed via the YES route at Step E5, the YES route at Step E10 and the NO route at Step E25. Namely, if, when a character string is inputted, a combination of an immediately preceding character and one character in the character string has already stored in the context tree, the number of characters to be entered is increased by one, and one character that has not been entered is entered. At this time, on the code tree, a node of an escape code (ESC) that has been stored along with the immediately preceding character is branched to generated a new node, and this character string is entered therein. As above, an input of character "abc abc ab b" is completed, a code assigned to each of the characters is as shown in FIG. 29. As shown in FIG. 29, the characters "abc" that has been inputted in the first place are encoded one character by one character. codes corresponding to which are "00", "01" and "10" each of two bits, respectively. Code words corresponding to a character string '"abc" that has been inputted secondary are "0", "0" and "0" each of one bit, respectively, because of relationships with the respective immediate preceding characters. A code is further assigned to a character string of two characters "ab" that has been next inputted. As shown in FIG. 30, a character string made up of two characters is expressed with a code word of only two bits. A character "b" that has been inputted last is a case where there is no character corresponding to a connection of the existing immediately preceding characters. The character "b" is thus expressed with a combination of three bits of an ESC and a code word of one sole character. According to the data compressing method of this invention, a character (string) to be compressed is entered with a number given thereto in the context tree in a tree structure, a code tree corresponding to the context tree is generated and updated while splay coding is performed. It is therefore possible to perform a process in two stages, that is, a stage to construct a probability model to determine a frequency of occurrence of an occurring character and a stage to assign a code to each character, so that a processing rate in the data compression may be largely increased. The above probability mode is constructed by generating and updating nodes of the code tree (splay process) every time a character is inputted. This manner may reduce a burden of an enormous volume of arithmetic calculation to reconstruct a probability mode that has already been constructed every time a character is inputted, increasing a processing rate in the data compression. In the data compression method of this invention, whenever the same character as a character that has been compresses (encoded) in the past occurs, a node of the code tree of the same character that has been entered in the past is exchanged with a node in a higher degree (in the splay process) so as to decrease a length of the code to a half. It is therefore possible to express a code of that character (string) with the fewer number of bits as the frequency of occurrence of the same character (string) increases so that an effect of the compression may be largely improved. In the data compression method of this invention, a character is not encoded character by character as in the case where the above-mentioned character string "ab" is encoded, but the character is encoded as a character string in a unit of a plurality of characters, thereby increasing a processing rate in the variable-length coding. According to this invention, a unit to be encoded is a character string so that information source may be expanded and an encoding efficiency in the splay coding may be largely improved. (2) Description of Decoder Next description will be of a process to decompress data in the context collecting step 21 and the splay encoding step 22 in the above-mentioned data decompressing apparatus 2 shown in FIG. 17, into which encoded (compressed) data are inputted as input codes, by reference to Steps D1 through D24 in a flowchart in FIG. 31. This data decompression is basically a reverse of the encoding process having been described in terms of the encoder. More specifically, a context tree and a code tree are initialized, and an immediately preceding character P is initialized to be set to "0" (Step D1). A length of string L is set to "0" (Step D2). A check is made on whether there is a child node below the immediately preceding character on the context tree (Step D3). If there is no child node, a character "K" is decoded with an input code being a null code (from NO route at Step D3 to Step D4). A check is made on whether the encoded character "K" is an EOF code or not (Step D5). If the encoded character "K" is not an EOF code, the procedure proceeds along the NO route, the encoded character "K" is outputted (Step D6), and the character is entered in the context tree (Step D7). The Step D7 is conducted in the same manner as the Step E7 in the encoding process having been described hereinbefore by reference to FIG. 17. As same as at the Step E8 in the encoding process, nodes for the character "K" and an escape code are generated below the immediately preceding character "P" on the code tree (Step D8), and the immediately preceding character "P" is entered to the character "K" (Step D17). The following Steps D20 through D23 are conducted in the same manner as at the Steps E20 through E23 in the encoding process. A length L' of the immediately preceding character string is replaced with a length L of a focused character string (Step D24), the the procedure goes back to the above Step D2. At Step D3, if there is a child node below the immediately preceding character "P" on the context tree, an inputted code is encoded as being regarded as a degree-1 code from the code tree to obtain a reference number of a character (string) on the context tree (from YES route at Step D3 to Step D9). A check is made on whether the encoded reference number is an escape code or not (Step D10). If not an escape code, the procedure takes the NO route, the next code is encoded as the input character is regarded as a degree-0 code to obtain a character "K" (from NO route at Step D10 to Step D11). As same as at the above Step D5, a check is made on whether the decoded character "K" is an EOF code or not (Step D12). If the decoded character "K" is not an EOF code, the procedure takes the NO route and a character "K" is outputted (Step D13). As same as at the Steps E13 through E15 in the coding process, the character "K" is entered in the context tree (Step D14). The character "K" is added below the immediately preceding character "P" (Step D15). An escape code and a code length of the degree-0 code "K" of the code tree are updated as splay codes (Step D16). Thereafter, a process from Step D17 is performed. As above, a splay code is assigned to every one character. If a splay code of a character whose character string following an immediately preceding character string is not included in character strings having been collected in the dictionary, the code is allowed to be updated and the encoded character following the above-mentioned immediately preceding character is allowed to be entered in the context tree. At Step D10, if the encoded reference number is an escape code, the procedure takes the YES route to decompress a character string corresponding to the reference number on the context tree to output it (Step D18). The last letter in the character (string) is replaced with the immediately preceding character "P" (Step D19). Thereafter, a process from the above Step D20 is performed. As above, the immediately preceding character having been decoded may first entered in the dictionary as a character string to be entered in the dictionary, the character string following the immediately preceding character may be decoded. At Step D4 or Step D12, if the decoded character is an EOF code, the procedure takes the YES route and terminates the decompressing process. As stated above, character strings of decompressed data are collected in the context tree and entered with respective numbers. Along with this, a splay code is correlated to each of the decoded character strings, and a character string corresponding to a dictionary number is decoded and updated with a splay code. An elongated character string of an encoded character string is entered until it reaches a predetermined maximum length of a character string, and a splay code corresponding to this elongated character string is entered. As above, the character "K" that has been compressed and encoded at the context collecting step 11 and the splay coding step 12 in the data compressing apparatus 1 is decompressed. In the data decompressing method according to this invention, a decoded character (string) given a number thereto is entered in the context tree and a code tree that is a code table corresponding to the context tree is structured, whereby it is possible to perform a process of two stages, that is, a stage to search a code in coincidence with an encoded code in the code table, and a stage to output a character corresponding to a coinciding code as a decoded character. As this, the data restoring method of this invention is effective to increase a processing rate in the data decompression. The above probability model is constructed by generating and updating nodes on the code tree (in the splay process) whenever a character is inputted. This manner may reduce a burden of an enormous volume of computation to reconstruct a code table that has been already constructed every time a character is inputted, more increasing a processing rate in the data decompression. In the data decompressing method of this invention, every time the same code as a code that has been decoded in the past occurs, a node on the code tree in which the same code has been entered in the past is exchanged with a higher degree node (in the splay process) to decrease a code length to a half. As a result, it is possible to express a code with bits of the fewer number as the same code occurs more frequently. In the case where the same code is repeatedly encoded, a processing rate in the data decompression may be largely increased. In the data decompressing method of this invention, a character is not decoded character by character, but decoded as a character string in a unit consisting of a plurality of characters. This manner may expand decompressible information source and improve largely an efficiency in the data decompression. In this embodiment, the description has been made by way of an example where a character string following an immediately preceding character is collected as a context, and encoded and decoded. There is, however, no necessity to stick to the immediately preceding character, but it is possible to collect a context following previous two characters, and encode and decode it. In this embodiment, description has been-made by way of an example where the contexts are dynamically collected, and encoded and decoded in a splay process. However, this invention is not limited to the dynamic collection of the contexts, but it is also possible to use static contexts collected in advance from representative samples, and encode and decode them in the splay process. In this embodiment, description has been made by way of an example where all inputted data are dynamically encoded in a variable-length coding (a splay coding). It is, however, possible to encode data of a considerable volume, then stop the updating operation of the splay coding and encode the data in a static variable-length coding. In which case, it is only necessary to make an arrangement between the decoder and encoder so that the decoder and encoder operate in synchronization with each other. In this embodiment, description has been made by way of an example where data to be compressed are characters or character strings. The data compressing method and data decompressing method according to this invention is, however, applicable to all data such as image data, audio data, etc.

Claims: A data compressing method for compressing input data by encoding the input data according to a history of occurrence of the input data in the past, said data compressing method comprising the steps of: (a) collecting characters of said input data and generating and updating a context tree; and (b) generating and updating a code tree while rearranging the code tree according to the context tree obtained in said collecting step (a); and wherein said collecting step (a) includes: (a1) collecting the characters of said input data; and (a2) numbering each of the characters, and entering each of the characters in the context tree as a dictionary, and said generating and updating step (b) includes: (b1) encoding said input data by using a code for plural characters having been entered in said code tree coinciding as long as possible with said input data and outputting said encoded input data; and (b2) if the number of characters of said plural characters coinciding as long as possible with said input data does not reach a maximum number of characters, adding a character to said plural characters and additionally, when a character or a character string is entered in said context tree, entering said plural characters in a single leaf of said code tree, wherein step (b2) is performed each time step (b1) is performed. The data compressing method according to claim 1, further comprising the steps of: setting plural code trees each for a different encoded immediately preceding character; and encoding, updating and registering plural characters following said immediately preceding character in a corresponding code tree. The data compressing method according to claim 1 or 2, further comprising the steps of registering every single character appearing in an independent code tree which is different from said plural code tree each for a different immediately preceding character; if plural characters following said immediately preceding character corresponding to said input data do not exist in said code trees each for a different immediately preceding character, encoding an effect that said plural input characters do not exist in said code trees each for a different immediately preceding character and encoding single character corresponding to said input data existing in said independent code tree; and registering said encoded single character following said immediately preceding character in said code tree corresponding to said immediately preceding character. A data decompressing method for decompressing encoded data obtained by encoding input data according to a history of the input data in the past, said data decompressing method comprising the steps of: (a) collecting characters of said encoded data and generating and updating a context tree; and (b) generating and updating a code tree while rearranging the code tree according to the context tree obtained at said collecting step (a); and wherein said collecting step (a) includes: (a1) collecting characters of decoded data; and (a2) numbering each of the characters and entering each of the characters in the context tree as a dictionary and said collecting step (b) includes: (b1) searching and decoding plural characters having been entered in the code tree and outputting said decoded plural characters; and (b2) if said plural characters do not exist in the code tree, adding a character to said plural characters and additionally, when a character or a character string is entered in said context tree, entering said plural characters in a single leaf of said code tree, wherein step (b2) is performed each time when step (b1) is performed. The data decompressing method according to claim 4, further comprising the steps of: setting plural code trees each for a different decoded immediately preceding character, decoding plural characters following said immediately preceding character from a corresponding code tree, and updating and registering said plural characters in said code tree. The data decompressing method according to claim 5, further comprising the steps of: registering every single character appearing in an independent code tree which is different from said plural code trees each for a different immediately preceding character; if plural characters following said immediately preceding character corresponding to said encoded data do not exist in said code tree each for a different immediately preceding character, decoding a code representing that said plural characters do not exist in said code trees for a different immediately preceding character; decoding said single character existing in said independent code tree corresponding to said encoded data; and registering said decoded single character following said immediately preceding character in said code tree corresponding to said immediately preceding character.

Inventors: MURASHITA KIMITAKA, OKADA YOSHIYUKI, YOSHIDA SHIGERU, MURASHITA, KIMITAKA, OKADA, YOSHIYUKI, YOSHIDA, SHIGERU, MURASHITA, KIMITAKA, C/O FUJITSU LIMITED, OKADA, YOSHIYUKI, C/O FUJITSU LIMITED, YOSHIDA, SHIGERU, C/O FUJITSU LIMITED
Applicants: FUJITSU LTD, FUJITSU LIMITED
Application year: 1995
Main classification: H03M7
IPC codes: H03M7, G06T9, G06F5