Abstract:
In an apparatus for generating variable length codewords c(a i ) and c(a j ) responsive to corresponding fixed length codewords b(a i ) and b(a j ), where a i  and a j  are source alphabet characters, a i  ε A 1  and a j  ε A 2 , ambiguity arises whenever any fixed length character to be encoded can instantaneously represent source characters a i  and a j  drawn from two or more dissimilar alphabets i.e. A 1  or A 2 . This is resolved by the inclusion of a Markov processor in combination with the apparatus. The processor establishes the point in the sequence when transitions occur between fixed length characters in one alphabet to fixed length characters in another alphabet by the message context. The processor includes a map of state and transition paths. This map models certain statistical regularities of runs of fixed code elements and the relative likelihood that an ambiguous fixed code character appearing in a first run belongs to a given alphabet. The processor, starting from an arbitrary initial position, tracks any given run of fixed code characters applied to the encoder in terms of a succession of states and paths.

Description:
BACKGROUND OF THE INVENTION 
     This invention relates to fixed to variable length word encoding and to variable to fixed length word decoding. More particularly, the invention relates to mechanisms for resolving ambiguities when transitions between substrings of different alphabets occur. This enables the assignment of an optimum variable length word in encoding. It further enables the parsing of comma free bit streams of variable length code words and for resolving ambiguities between said variable length words and their fixed length representations in decoding. 
     Fixed to variable length encoding consists of assigning a variable length code word c(a) to the appearance of a fixed length codeword b(a). Each fixed length code word represents a character &#34;a&#34; in a source alphabet A. 
     Since b(a) can repreent both a character in A 1  and A 2 , ambiguity arises in both the encoding and decoding processes. 
     The encoder must determine when a transition from one alphabet to another has occurred to make an optimum variable length code assignment, c(a). The decoder must determine which alphabet was selected by the encoder to parse the comma free bit stream and to properly reassign the fixed length code word b(a) to the received variable length code word c(a). 
     There exists cost and performance advantages in the machine storage, transfer and manipulation of character alphabets using equal fixed length codewords. Among the advantages are uniformity and standardization of storage cell/register sizes, the number of conductors for data busing, and the reduced or non-existant informational overhead to track character boundaries. However, variable length representation is attractive for transmission and storage, where the average compressed codeword length may be less than the fixed code word length. 
     English text may be machine described by fixed length code words from several different alphabets. For example, there can exist an alphabet of upper case characters A, B, . . . , Z; an alphabet of lower case characters a, b, . . . , z; or an alphabet of numbers and symbols 1, 2, 3, . . . , %, +, etc. It is possible to construct a fixed length code of length L whose capacity are =2 L  ≧ T = the number of upper case characters plus the number of lower case characters, etc. However, where 2 L  ≦ T, then some fixed length codewords b(a) will be ambiguous. Indeed, the cost tradeoffs may be such that the increase in length L of b(a) may be far more expensive than the use of mechanisms for resolving the ambiguities. 
     As previously mentioned, fixed to variable length encoding becomes attractive where the variable length codeword representation is a compressed version of the former. Compression is achieved by employing certain statistical regularities connected with the source alphabet. The most often used regularity is the ordering of characters on a relative frequency of occurrence and assigning the shortest length codewords to the most frequently occurring characters. This can lead to the rarest occurring characters having very long codewords. The upper limit of codeword length is that of the register size. To avoid the necessity of long registers, those infrequent characters whose variable codewords require more than a fixed register&#39;s length would be transmitted with a specific variable length prefix followed by the character in the clear, i.e., not encoded. This means that the encoder output consists of frequent variable length codeword sequences and infrequent fixed length words with the special prefix. 
     The encoder output can be viewed as a serial, comma-free bit stream insofar as the variable length words are concerned. Placing commas, separations, between the variable words would sharply reduce compression advantage. 
     The prior art is replete with many examples of fixed and variable length encoders. For example, Blasbalg, U.S. Pat. No. 3,237,170, describes an adaptive compactor that in effect varies the variable length code word assignments as the statistics of the relative frequency of occurrence of the source alphabet change. Wernikoff, U.S. Pat. No. 3,394,352, applies each fixed length word in parallel to differently structured encoders. He uses the shortest codeword from among the plurality with a tag to permit decoding. 
     Although Blasbalg changes his output codewords, he still preserves a unique one-to-one relationship between each input and output character. The same can be said of Wernikoff. In the latter case, the output tag identifies the encoder/decoder to be used. In contrast, the problem addressed by this invention is that of resolving ambiguous terms, first at the encoder and then at the decoder. 
     SUMMARY OF THE INVENTION 
     The invention is based on the observation that a Markov processor possesses a &#34;remembrance&#34; property and that its state-to-state transitions can be modified to reflect empirically derived statistics concerning runs of fixed and variable length code words. This is used to establish context and identify the substring alphabet. For instance, the likelihood of occurrence that a present fixed length code word is an uppercase character given a run of K upper case characters is small. Another instance might be that the expectancy of b(a) is assignable to an upper case character after a run of any length of lower case characters might also be quite negligible. These observations yield a series of decision rules for treating ambiguous characters as belonging to the same or different alphabet as the run of preceding terms. The exact rules will vary as the empirically derived statistics and source alphabets vary. 
     The invention is embodied in an apparatus for generating variable length codewords c(a i ) and c(a j ) responsive to corresponding fixed length codewords b(a i ) and b(a j ), where a i  and a j  are source alphabet characters, a i  ε A 1  and a j  ε A 2 . The improvement includes a Markov processor coacting with selected means in the apparatus for resolving ambiguities by character sequence context recognition arising whenever ones of any sequence of fixed length characters to be encoded may be concurrently either b(a i ) or b(a j ) and are appended to sequences from a known alphabet. The processor includes an &#34;r&#34; state register, and state transition means responsive to a first control signal for changing a given present state of the register to one of a preselected number &lt;r next states, said means include means for generating a second control signal. The apparatus also includes means responsive to each fixed length codeword for generating an ordered m-tuple consisting of variable length codewords, length attributes, and the first control signal, and means for selecting and applying one of the variable length codewords from the m-tuple to the apparatus output according to the second control signal. To complete the control, there are provided means for applying the first control signal to the state transition means. 
     The state transition means includes a map of the Markov processor states and transition paths. This map models certain statistical regularities of runs of fixed code elements and the relative likelihood that one or more consecutive ambiguous terms appearing in a certain type of run belongs to a given alphabet and should be encoded/decoded accordingly. The processor starts from an arbitrary initial state and tracks any given run of b(a)&#39;s applied thereto in terms of a succession of states and paths. Thus, for any given b(a) and present machine state r, then the alphabet A, c(a), and path S can be obtained by table lookup. c(a) represents the instantaneous encoder output. Significantly, the state transition means causes the register to change from its present state to a next state according to the map and the table extracted value S applied to said means. 
     This invention takes advantage of the fact that the number of actual machine states can be mapped into a smaller number of states for representational purposes. This is due to the fact that a run of characters in the same alphabet will place a machine in one or another of the subset of machine states. This reduces the amount of memory and processing required to perform encoding/decoding. 
     In receiving a series of variable length codewords as a comma-free bit stream, the decoder includes encoding logic and a Markov processor for both parsing the characters in the stream and for resolving whether a given c(a) represents b(a i ) or b(a j ). In this regard, the Markov processor traverses the same sequence of states as the encoder Markov processor when encoding the fixed length word stream. 
    
    
     BRIEF DESCRIPTION OF THE DRAWING 
     FIG. 1A depicts runs of alphabetically designated fixed length code words with and without ambiguous terms together with rules of action. 
     FIGS. 1B and 1C show a finite state machine implementing the rules of 1A in both tabular (1B) and graphic (1C) forms. 
     FIG. 2 sets forth a register for storing the identity of the present machine state and a state-to-state tracking mechanism. 
     FIGS. 3A and 3B, respectively, represent the table contents of an encoding and decoding read only store (ROS). 
     FIG. 4 sets forth the fixed to variable length word encoder and decoder in system relation. 
     FIG. 5A is a logical depiction of the encoder emphasizing the register assignments and cycle definition of FIG. 5B. 
     FIG. 6A is a logical depiction of the decoder emphasizing the register and selector circuit assignments together with the cycle definition of FIG. 6B. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     It is well known that variable length codewords C may be assigned, one to one, to each member of a given alphabet. The length L of the codeword is inversely related to the relative frequency of occurrence P of the term in the alphabet. Indeed, algorithms for minimizing the average length of the variable length codewords assigned to the terms of an alphabet are well represented in the art. See Raviv, U.S. Pat. No. 3,675,211; U.S. Pat. No. 3,675,212; Cocke et al, U.S. Pat. No. 3,701,111. These are based in whole or in part on the work of Huffman, &#34;A Method for the Construction of Minimum Redundancy Codes&#34;, Proceedings of the IRE, September 1952, pages 1098-1111. 
     Referring now to Table 1, there are shown two arbitrary alphabets A 1  and A 2 . Each member a i  of A 1 , symbolized a i  εA 1  consists of a number 1, 2, 3, . . . , 7. Likewise, a j  εA 2  consists of a lower case Greek letter. The relative frequency P(a i ) is followed by an optimum length Huffman encoded variable length word c(a i ). The length L(a i ) of the codeword C(a i ) is listed in the next column for convenience. Finally, the expected length for each entry is formed from the product P(a i ) × L(a i ). Each Huffman code was independently calculated for each alphabet. Note, the minimum average Huffman codeword length L(a i )=0.34 bits per symbol while L(a j )=0.25 bits per symbol. It follows that codes optimized in respect of their source alphabets are not optimized when strings are concatenated. Also to be noted is the length of the infrequently occurring members. 
     
         __________________________________________________________________________a.sub.i εA.sub.1    P(a.sub.i)  c(a.sub.i)      L(a.sub.i)         P(a.sub.i)xL(a.sub.i)               a.sub.j ε A.sub.2                   P(a.sub.j)                      c(a.sub.i)                           L(a.sub.j)                              P(a.sub.i)xL(a.sub.j)__________________________________________________________________________1   0.20  10  2   0.40 t   .10                      000  3  .302   0.18  000 3   0.54 u   .09                      1010 4  .363   0.10  011 3   0.30 v   .09                      1011 4  .364   0.10  110 3   0.30 w   .07                      1001 4  .285   0.10  111 3   0.30 x   .06                      1000 4  .246   0.06  0101      4   0.24 y   .03                       11110                           5  .157   0.06  00100      5   0.30 z   .01                      11111110                           8  .08      ##STR1##                               ##STR2##__________________________________________________________________________ 
    
     TABLE I 
     Referring now to FIG. 1A, there is shown runs of alphabetically designated fixed length code words. For purposes of describing this invention, the runs, their statistics, and the source alphabets are wholly arbitrary. In the figure, each character a i  is a member of alphabet A 1  and each character a j  is a member of alphabet A 2 . 
     In the figure, runs of fixed length codewords representing characters in the same alphabet b(a i ), b(a i ), . . . ,b(a i ) imply that a machine should stay in the same alphabet for encoding/decoding the next character. Where a run is interrupted by a single &#34;ambiguous character ?&#34;, the machine stays in the same alphabet. In this regard, an &#34;ambiguous character&#34; may be indicative of a change of alphabet. For runs in alphabet A 1  interrupted by two ambiguous terms ? ? , then the machine changes to the other alphabet A 2  for encoding/decoding the next character. For runs in A 2  interrupted by four successive ambiguous terms ? ? ? ? , terms, then transfer must be made to the other alphabet A 1 . 
     Referring now to FIGS. 1B and 1C, there is shown a state transition table and map of a finite machine suitable for recognizing the runs of interest. The machine must have a sufficient number of states to &#34;remember&#34; to a depth of four. This is to take into account the transition rule governing runs of characters in alphabet A 2  interrupted by four ambiguous terms. The state transition table is formulated by assuming the apparatus exists in some initial internal state and then for each combination of runs, a new state is defined to which the apparatus should go from the initial state. Now, for each of the states into which the apparatus could have gone from the first state, this process of defining new states is repeated. A graphical version of the table is that of a map depicted along side thereof. The table and map may be read as follows. 
     Assume the apparatus is in initial state 1 and a character b(a i ) is received for encoding, the machine would then move to state 2 over the path designated &#34;i&#34;. If, instead, b(a j ) had been received for encoding, the apparatus would stay in the same state 1. 
     Starting in state 1, if the apparatus received a succession of terms b(a i ), b(a i ) . , , , .b(a i ), then it would move through successive internal states 1, 2, 3, 4 to and remain in state 5. Likewise, if the apparatus were in any other internal state and subject to a run of b(a j ), . . . , b(a j ), the apparatus would migrate back to state 1. 
     The paths connecting successive machine states are designated s i  or s j . Because a run of terms in the same alphabet will cause the apparatus to migrate to either state 1 or state 5, the internal machine states are connected. This aspect wil be discussed in connection with the description of FIG. 2. 
     Referring now to FIG. 2, there is shown the Markov processor 23 which coacts with selected means in the apparatus for resolving ambiguities by character sequence context recognition whenever ones of any sequence of fixed length characters to be encoded may be concurrently either b(a i ) or b(a j ) and append characters from a known alphabet. The processor includes an &#34;r&#34; state register 7 for storing the identity of the present state of the apparatus encoder and a state-to-state tracking mechanism (state transition means 23). In this regard, the contents of register 7, in addition to designating the internal state of the encoding/decoding apparatus, also serve to access the contents of a read only store 9. The read only store contents include the state transition table of FIG. 1B correlated with a second control signal &#34;g&#34;. When ROS 9 is accessed by the contents of register 7, the data stored at the address is transferred to register 11. As is apparent from FIGS. 1B and 1C the next state is one of two possible states. Coded indication of the next two possible states are sent over respective paths 13 and 15 while the second control signal &#34;g&#34; is conducted over path 17 through state register 19 to path 21. This second control signal &#34;g&#34; is used in FIGS. 4 and 5a in selecting a given variable length codeword i.e. either c(a i ) or c(a j ) contained in the encoder data register 35 for transfer to the output register 47. 
     For example, suppose the present state of register 7 were 4. There would be transferred to data register 11 the binary equivalent of 5 and 2 and the &#34;g&#34; value of 1. The binary 5 value and the binary 2 value would be respectively applied to paths 13 and 15 and then to selector 3. The actual value of the next state for register 7 is determined by the S i  or S j  value on path 1. This causes selector 3 to connect either path 15 or path 13 to path 5 coupling register 7. As previously mentioned, the binary indication on path 1 represents the path selection for controlling the next state address to be transmitted from register 11 into register 7. If S is 0 on line 1, then the appropriate lefthand column entry from path 13 i.e. binary 5, is entered. If the 1 appears on line 1 then the appropriate righthand column entry i.e. binary 2 is selected. 
     Referring now to FIG. 4, there is shown an overall block diagram of a fixed to variable length encoder 51 coupled to a variable to fixed length decoder 53 over path 49. The encoder broadly comprises an encoding ROS 33 and associate accessing means, a state register and controller 23 to provide the state to state tracking and an output shift register 47 for placing the variable length codewords c(a) on line 49. Decoder 53 includes a decoding ROS 65, shifting and accessing circuits, together with selection networks 68 and encoder logic and state control element 51&#39;. Each fixed length decoded word b(a) is gated through the selection network 68 and applied simultaneously to output path 25&#39; and element 51&#39;. 
     The contents of encoding ROS 33 and decoding ROS 65 are representively set forth in FIGS. 3A and 3B. The details of register and state controller 23 are found in FIG. 2, while the selection networks 68 and 51&#39; may be seen in FIG. 6A. 
     Referring now to FIG. 3A, there is shown a set of concordance tables in which for each b(a i ), there is to be found a corresponding c(a i ), a length L and path S. The same holds for each b(a j ) and c(a j ), L and S. Ambiguity may be found, for example, between b(a i ) = 7 and b(a j ) = 3 in that both c(a) = 110. Additionally, certain of the fixed code words such as b(a i ) = 4, 5, 6 and b(a j ) = 0, 1, 2, 4, 7 have c(a i ) or c(a j ) = 111. The prefix 111 does not indicate ambiguity, but is a prefix denoting that the fixed code word b(a) immediately follows and has not been encoded. 
     A reciprocal situation is represented in the decoder ROS contents of FIG. 3B. Here the sequence 111 is immediately denoted as being in fixed code. An additional column designates whether the c(a), b(a) of interest represents clear or compressed text. 
     Referring now to FIG. 5A taken together with FIG. 5B, there is shown the detail for the fixed to variable length encoder 51 with register and cycle definition. In this embodiment, the bits representing each fixed length word b(a) are assumed to be applied parallel by bit and serially by word. Upon detecting the pulse leading edges on path 25, a signal is provided by leading edge detector 26 to initiate the clocking actions of clocking and distribution network 28. The major cycles provided by network 28 are shown in FIG. 5B. In this regard, cycle A causes data to be gated into address register 31 and a preselected portion of output register 47 over paths 29 through AND gate 27. The time between energizing gate 27 defines the encoding cycle. As soon as the data is loaded in register 31, the read cycle of the encoding ROS 33 begins. That is, the data stored at location defined by b(a) is accessed and transmitted to data register 35 during load ROS data cycle B. Register 35 is partitioned so as to reflect one-to-one the variable length field c(a i ), the length attribute L, the preferred path s i   or s j  and the corresponding fields with regard to c(a j ). 
     Encoder 51 includes selection registers 37, 39, and 41. Selection register 37 responsive to the g signal on line 21 selects which one of the two variable length words will be placed in output register 47 over path 45. If g = 0, then c(a i ) is inserted. If g = 1, then c(a j ) in register 35 are transferred to register 47. 
     Selection register 39 selects that length attribute for controlling shift counter 43 corresponding to the selected C(A) in register 35. The same can be said for selection register 41 with respect to path S. After data register 35 has been loaded during cycle B and the appropriate variable length word and associated parameters have been selected, the output register 47 is loaded during the load cycle C. The contents of register 47 are serially applied to line 49 by shifting a predetermined number of stages out by decrementing the contents of shift counter 43 and providing a shifting signal over path 44 to register 47. 
     Referring now to FIG. 6A and 6B, there is shown a logic diagram of the decoder emphasizing register and selected circuit assignments together with the cycle definition in FIG. 6B. The variable length words c(a), or less frequently, the fixed length b(a) prefixed by 111, are serially received on path 49 and shifted into register 55. The contents of the predetermined number of positions in register 55 are loaded into address register 63 over path 61, while the remaining contents terminate in selector 77 in selection network 68 over path 59. Parenthetically, the amount of shifts during each decoding cycle is determined by the contents in register 39&#39; located in encoder logic in state control 51&#39;. The register passes a count which resides in shift control 57 as communicated over path 40&#39;. The count is decremented to 0, each decrement resulting in a shift in the contents of register 55 from left to right by 1 position. As a consequence, the contents of register 63 are governed by those predetermined bit positions of register 55 that have been shifted under control of L. The contents of register 63 then access the decoding ROS 65. The contents at the location defined by the address register include b(a i ), C/C, b(a j ) and C/C. As may be recalled, there is a one bit indication accompanying each b(a) indicating whether it represents a character transmitted in the clear or compressed, i.e., C/C. 
     Selection networks 68 consist of registers and selectors for insuring that a preselected one of the two b(a)&#39;s contained in register 67 is placed on path 25&#39;. This, in turn, is dependent upon the binary value of state signal &#34;g&#34; obtained from controller 51&#39; over path 21&#39;. 
     Each derived fixed length word b(a) is applied to an encoding ROS 33&#39; in logic and state controller 51&#39;. This permits the decoder 53 to be in the same state as that of the encoder when a given variable length c(a) or transmitted fixed length character was applied to path 49. Consequently, the state g on path 21&#39; should be identical to that of the encoder at the point in time when c(a) was selected to represent a corresponding fixed length code word b(a). 
     
         ______________________________________ENCODINGInitialState=1    1     2     3     4     5     6     7   8b(a)     5     6     0     1     0     1     1   1Next State    1     1     2     3     4     5     5   5Alphabet A.sub.2          A.sub.2                A.sub.2                      A.sub.2                            A.sub.2                                  A.sub.2                                        A.sub.1                                            A.sub.1c(a)     0     10    111000                      111001                            111000                                  111001                                        01  01______________________________________DECODINGInitialState=1c(a)     0     10    111000                      111001                            111000                                  111001                                        01  01Alphabet A.sub.2          A.sub.2                A.sub.2                      A.sub.2                            A.sub.2                                  A.sub.2                                        A.sub.1                                            A.sub.1Next State    1     1     2     3     4     5     5   5b(a)     5     6     0     1     0     1     1   1______________________________________ 
    
     TABLE 2 
     The above table 2 illustrates the operation of encoder 51 and decoder 53. 
     Referring now to all of the drawings, let us first examine encoding action and assume that state controller 23 is in initial state 1 with b(a) = 5. From FIG. 3A, the corresponding path is j. This, in turn, means that the next state as shown in FIG. 1B is state 1 with the character being encoded in alphabet A 2  where c(a j ) = 0. For the new character b(a) = 6 and the present state being 1 with g = 1, then the path from FIG. 3A is s j  which from FIGS. 1B and 2 means that the next state is 1. Also, from FIG. 3A, the alphabet is A2 with c(a j ) = 10 with a length of L = 2. 
     The third fixed word b(a) = 0 with g = 1 means that from encoding table in FIG. 3A, the path to the next state is S i  and that the text will be transmitted in the clear with a prefix 111 followed by 000 . From FIGS. 1B and 2 given a present state of 1 with S i , then the next state is 2. The remainder of the encoding table can be verified by the same procedure. 
     Referring now to the decoding table in table 2, assuming that the decoder 53 has received on path 49, c(a) = 0. From the decoder ROS contents shown in FIG. 3B, it may be observed that three bits are used to address the ROS. Thus, for 000 n, then b(a) = 0 or 5. This ambiguity can be resolved by recourse to the fact that the output from controller 23&#39; is state g which we will assume = 1. This yields b(a j ) = 5 and the path to the next state is j. Referring now to FIGS. 1B and 2, the next state is 1, the state value g = 1, and the alphabet is A2. The remaining portions of the decode table can be confirmed by repeating the above procedure. 
     While the invention has been particularly shown and described with reference to a preferred embodiment thereof, it will be understood by those skilled in the art that changes in form and details may be made therein without departing from the spirit and scope of the invention.