Compression device and control method
By adjusting the encoding length and generating a new encoding table, the problem of encoding length exceeding the hardware limit in dynamic Huffman encoding is solved, and efficient encoding performance under restricted conditions is achieved.
Patent Information
- Application Number
- JP2021039512
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-03-11
- Publication Date
- 2024-10-07
- Estimated Expiration
- 2041-03-11
AI Technical Summary
In the prior art, in dynamic Huffman encoding, when the encoding length exceeds the hardware limit, it is impossible to effectively avoid the degradation of encoding performance.
By adjusting the encoding length, selecting and modifying the symbols of the shorter encoding length to reach hardware limits, and generating a new encoding table to ensure that the encoding length does not exceed the limit, while preferentially modifying the symbols of the longer encoding length to reduce performance losses.
It effectively suppresses the degradation of encoding performance, ensures that the encoding length does not exceed the hardware limit, while maintaining high compression performance.
Smart Images

Figure 0007562451000004 
Figure 0007562451000005 
Figure 0007562451000006
Abstract
Description
[Technical field]
[0001] FIELD OF THE DISCLOSURE The present invention relates to a compression apparatus and a control method. [Background technology]
[0002] Dynamic Huffman coding is a variable-length coding scheme that dynamically generates coding tables based on the frequency of occurrence of the symbols to be coded: short codewords are assigned to frequently occurring symbols and long codewords are assigned to infrequently occurring symbols.
[0003] Depending on the constraints set by the data compression standard or the constraints in the hardware implementation of the compression device and the decompression device, the length of the codeword (code length) assigned in the dynamic Huffman coding may have to be kept below the upper limit value based on the constraints. In such a case, in the stage of generating the coding table using the occurrence frequency of each symbol, it is necessary to generate the coding table so that the length of the codeword assigned to the symbol is equal to or less than the upper limit value. [Prior art documents] [Patent documents]
[0004] [Patent Document 1] US Patent Application Publication No. 2020 / 0099958 Summary of the Invention [Problem to be solved by the invention]
[0005] An object of the present invention is to provide a compression device and a control method capable of suppressing a decrease in compression performance when the code length is restricted to an upper limit value or less. [Means for solving the problem]
[0006] According to an embodiment, a compression device includes an encoding information generating unit and an encoding unit. The encoding information generating unit determines a plurality of code lengths associated with the plurality of symbols based on the occurrence frequency of each of the plurality of symbols. When the plurality of symbols includes one or more first symbols associated with one or more first code lengths exceeding an upper limit, the encoding information generating unit changes the one or more first code lengths to the upper limit, selects at least one third symbol from one or more second symbols associated with one or more second code lengths less than the upper limit in descending order of associated code length, changes at least one third code length associated with the at least one third symbol to the upper limit, and generates encoding information indicating the plurality of symbols and a plurality of variable length codes associated with the plurality of symbols using at least the changed one or more first code lengths and the at least one third code length. The encoding unit converts symbols into variable length codes using the encoding information. The code length of each of the plurality of variable length codes ranges from 1 bit to the upper limit value. [Brief description of the drawings]
[0007] [Figure 1] 1 is a block diagram showing an example of the configuration of an information processing system including a compression device according to a first embodiment. [Diagram 2] FIG. 2 is a block diagram showing an example of the configuration of a compression device according to the first embodiment. [Diagram 3] 2 is a block diagram showing an example of the configuration of a dynamic Huffman encoder provided in the compression device of the first embodiment; [Figure 4] 5 is a flowchart showing an example of a procedure of a code length determination process executed in the compression device of the first embodiment. [Diagram 5] FIG. 4 is a diagram showing an example of the configuration of a frequency table used in the compression device of the first embodiment. [Figure 6] FIG. 2 is a diagram showing an example of a Huffman tree generated in the compression device of the first embodiment. [Figure 7] FIG. 2 is a diagram showing an example of the configuration of a code length table used in the compression device of the first embodiment. [Figure 8] 10 is a flowchart illustrating an example of a procedure of an upper limit violation correction process executed in the compression device of the first embodiment. [Figure 9] 6 is a flowchart showing an example of a procedure for a redundant leaf removal process executed in the compression device of the first embodiment. [Figure 10] 7 is a diagram showing a modification of the Huffman tree in FIG. 6 in the compression device of the first embodiment. [Figure 11] 11 is a diagram showing a modification of the Huffman tree in FIG. 10 in the compression device of the first embodiment. [Figure 12] 12 is a diagram showing a modification of the Huffman tree in FIG. 11 in the compression device of the first embodiment. [Figure 13] 13 is a diagram showing a modification of the Huffman tree in FIG. 12 in the compression device of the first embodiment. [Figure 14] 8 is a diagram showing a modification of the code length table in FIG. 7 in the compression device of the first embodiment. [Figure 15] 15 is a diagram showing a modification of the code length table in FIG. 14 in the compression device of the first embodiment. [Figure 16] 16 is a diagram showing a modification of the code length table in FIG. 15 in the compression device of the first embodiment. [Figure 17] 17 is a diagram showing a modification of the code length table in FIG. 16 in the compression device of the first embodiment. [Figure 18] FIG. 4 is a diagram showing an example of a pseudo program for allocating code bit strings to symbols, which is executed in the compression device of the first embodiment. [Figure 19] 4 is a diagram showing an example of allocation of code bit strings to symbols in the compression device of the first embodiment. [Figure 20] 11 is a flowchart showing an example of a procedure of a code length constraint process executed in a compression device according to a comparative example. [Figure 21] 13A and 13B are diagrams illustrating modified examples of Huffman trees in a compression device according to a comparative example. [Figure 22] FIG. 23 is a diagram showing a modification of the Huffman tree of FIG. 22 in the compression device according to the comparative example. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0008] Hereinafter, an embodiment will be described with reference to the drawings.
[0009] (First embodiment) 1 shows an example of the configuration of an information processing system 1 including a compression device 15 according to the first embodiment. The information processing system 1 includes a host device 2 (hereinafter, referred to as the host 2) and a memory system 3.
[0010] The memory system 3 is a semiconductor storage device configured to write data to a nonvolatile memory such as a NAND flash memory 5 and read data from the nonvolatile memory. The memory system 3 is realized, for example, as a solid state drive (SSD) including a NAND flash memory 5. In the following, an example will be given in which the memory system 3 is realized as an SSD, but the memory system 3 may also be realized as a hard disk drive (HDD).
[0011] The host 2 may be a storage server that stores a large amount of diverse data in the memory system 3, or may be a personal computer.
[0012] The memory system 3 can be used as storage for the host 2. The memory system 3 may be built into the host 2, or may be connected to the host 2 via a cable or a network.
[0013] The interface for connecting the host 2 and the memory system 3 complies with SCSI, Serial Attached SCSI (SAS), ATA (AT Attachment), Serial ATA (SATA), PCI Express (PCIe) (registered trademark), Ethernet (registered trademark), Fibre channel, NVM Express (NVMe) (registered trademark), etc.
[0014] The memory system 3 includes a controller 4 and a NAND flash memory 5. The controller 4 can be realized by a circuit such as a System-on-a-chip (SoC).
[0015] The controller 4 may include a random access memory (RAM) that is a volatile memory, such as a dynamic random access memory (DRAM) 6. Alternatively, a RAM such as a static random access memory (SRAM) may be built into the controller 4. The DRAM 6 may be built into the controller 4.
[0016] In the RAM such as the DRAM 6, for example, a storage area for firmware (FW) loaded from the NAND type flash memory 5 is provided.
[0017] The NAND flash memory 5 includes a plurality of blocks. Each block includes a plurality of pages. A block functions as the smallest erase unit. A block may also be called an "erase block" or a "physical block." Each page includes a plurality of memory cells connected to the same word line. A page is the unit of data write operation and data read operation. Note that a word line may also be the unit of data write operation and data read operation.
[0018] There is an upper limit to the number of program / erase cycles that can be allowed for each block (maximum number of P / E cycles). One P / E cycle for a block includes an erase operation to put all memory cells in the block into the erased state, and a write operation to write data to each page of the block.
[0019] The controller 4 may include a host interface (host I / F) 11, a CPU 12, a NAND interface (NAND I / F) 13, a DRAM interface (DRAM I / F) 14, and a compression device 15. The host I / F 11, the CPU 12, the NAND I / F 13, the DRAM I / F 14, and the compression device 15 may be interconnected via a bus 10.
[0020] The controller 4 is electrically connected to the NAND flash memory 5 via a NAND I / F 13 that supports interface standards such as Toggle DDR and Open NAND Flash Interface (ONFI). The NAND I / F 13 functions as a NAND control circuit configured to control the NAND flash memory 5.
[0021] The controller 4 functions as a memory controller configured to control the NAND flash memory 5 .
[0022] The controller 4 may function as a flash translation layer (FTL) configured to perform data management and block management of the NAND flash memory 5. The data management performed by the FTL includes (1) management of mapping information indicating the correspondence between each logical address and each physical address of the NAND flash memory 5, (2) processing for concealing page-based read / write operations and block-based erase operations, etc. The logical address is an address used by the host 2 to address the memory system 3.
[0023] The management of the mapping between each logical address and each physical address is performed using a logical-physical address conversion table. The controller 4 uses the logical-physical address conversion table to manage the mapping between each logical address and each physical address in a specific management size unit. A physical address corresponding to a certain logical address indicates a physical memory location in the NAND flash memory 5 where data of this logical address is written. The logical-physical address conversion table may be loaded from the NAND flash memory 5 to the DRAM 6 when the memory system 3 is powered on.
[0024] Data can be written to one page only once per P / E cycle. Therefore, the controller 4 writes updated data corresponding to a logical address to a different physical storage location, not to the physical storage location where the previous data corresponding to this logical address is stored. The controller 4 then invalidates the previous data by updating the logical-physical address conversion table so as to associate this logical address with this different physical storage location.
[0025] Block management includes bad block management, wear leveling, garbage collection, and the like.
[0026] The host I / F 11 is a hardware interface that communicates between the memory system 3 and the host 2, which is an external device of the memory system 3. The host I / F 11 functions as a circuit that receives various commands from the host 2, such as I / O commands and various control commands. The I / O commands may include write commands and read commands. The control commands may include unmap commands (trim commands) and format commands. The host I / F 11 also functions as a circuit that transmits responses and data according to commands to the host 2.
[0027] The DRAM I / F 14 functions as a DRAM control circuit configured to control access to the DRAM 6. The storage area of the DRAM 6 is allocated to an area for storing the FW and a buffer area used as a read / write buffer or the like.
[0028] The CPU 12 is a processor configured to control the host I / F 11, the NAND I / F 13, and the DRAM I / F 14. The CPU 12 performs various processes by executing the FW loaded in the DRAM 6. In other words, the FW is a control program for controlling the operation of the CPU 12. In addition to the above-mentioned FTL process, the CPU 12 can execute command processes for processing various commands from the host 2. Note that a part or all of the FTL process and the command process may be executed by dedicated hardware in the controller 4.
[0029] The compression device 15 compresses data to be written to the NAND flash memory 5 by encoding the data. The compression device 15 encodes plaintext data received in response to a write command received from the host 2, for example. The compression device 15 has a configuration for implementing, for example, dynamic Huffman encoding in order to compress the data.
[0030] 2 shows an example of the configuration of the compression device 15. The compression device 15 includes, for example, a dynamic Huffman encoder 21 and a packing processor 22.
[0031] The dynamic Huffman encoder 21 performs dynamic Huffman coding on the input symbols. Dynamic Huffman coding is a variable-length coding method that dynamically generates a coding table using the frequency of occurrence of the symbol to be coded. The coding table includes information indicating a plurality of symbols and a plurality of variable-length codes (codewords) respectively associated with the plurality of symbols. In dynamic Huffman coding, short codewords are assigned to symbols that occur frequently, and long codewords are assigned to symbols that occur less frequently. The dynamic Huffman encoder 21 converts the input symbols into codewords according to such assignment. In other words, the codewords obtained by the conversion are variable-length codes. The symbols are, for example, fixed-length data.
[0032] The dynamic Huffman encoder 21 sends the variable length codes obtained by the dynamic Huffman encoding to the packing processor 22. The dynamic Huffman encoder 21 also sends the lengths of the variable length codes (i.e., the multiple code lengths) respectively assigned to the multiple symbols shown in the encoding table to the packing processor 22 in a specific symbol order. The specific symbol order is, for example, an order that follows the alphabetical order of the corresponding multiple symbols. In other words, the multiple code lengths arranged in the specific symbol order are, for example, multiple code lengths rearranged so as to correspond to the multiple symbols arranged in alphabetical order, respectively.
[0033] The packing unit 22 can collect one or more variable length codes output from the dynamic Huffman encoder 21 and output them as compressed data (compressed stream) for each specific data size. The packing unit 22 inserts a plurality of code lengths arranged in a specific symbol order as a header of this compressed data. The plurality of code lengths arranged in a specific symbol order are used to restore an encoding table (decoding table) when the decompressor 16 decodes the compressed data.
[0034] A part or all of the dynamic Huffman encoder 21 and the packing processor 22 may be realized as hardware such as a circuit, or as a program (that is, software) executed by at least one processor.
[0035] The controller 4 may include a decompression device 16. The decompression device 16 decompresses the compressed data read from the NAND flash memory 5 by decompressing the compressed data. For example, in response to the controller 4 receiving a read command from the host 2, the decompression device 16 decodes the compressed data read from the NAND flash memory 5. The controller 4 transmits the decoded data to the host 2 in response to the read command from the host 2. The decompression device 16 includes a configuration for decompressing (i.e., inversely converting) the compressed data in accordance with the configuration for compression by the compression device 15.
[0036] The controller 4 may further include an ECC encoder and an ECC decoder. In this case, the ECC encoder generates parity for error correction (ECC parity) for the compressed data output from the packing processor 22, and generates a codeword having the generated ECC parity and the compressed data. Then, the CPU 12 is configured to write the codeword to the NAND flash memory 5 via the NAND I / F 13. Also, in this case, when the controller 4 reads data from the NAND flash memory 5 based on a read command issued by the host 2, for example, the CPU 12 reads the codeword from the NAND flash memory 5 via the NAND I / F 13, and the ECC decoder executes an error detection process and an error correction process on the read codeword to generate compressed data. Then, the decompression device 16 is configured to decompress the generated compressed data. That is, the controller 4 may be configured to write data based on the compressed data output from the packing processor 22 to the NAND flash memory 5, generate compressed data based on the data read from the NAND flash memory 5, and decompress the generated compressed data.
[0037] 3 is a block diagram showing an example of the configuration of the dynamic Huffman encoder 21. The dynamic Huffman encoder 21 includes a delay buffer 31, a coding table generating unit 32, and a coding unit 33, for example.
[0038] The delay buffer 31 stores (buffers) the symbols input to the dynamic Huffman encoder 21. The delay buffer 31 delays the stored symbols, for example, until a specific timing, and sends them to the encoding unit 33.
[0039] The coding table generator 32 generates a coding table 43 using the symbols input to the dynamic Huffman encoder 21. The coding table 43 includes information indicating a plurality of symbols and a plurality of variable-length codes (i.e., a plurality of code bit strings) respectively associated with the plurality of symbols.
[0040] More specifically, the coding table generating unit 32 generates the coding table 43 based on the frequency of occurrence of a plurality of symbols included in the input data of a specific unit, taking into consideration the constraint of the upper limit of the code length. The specific unit may be a specific data amount unit, or a specific group such as a file. When the specific group is used as the unit, the coding table generating unit 32 recognizes the input data of the specific unit by detecting data indicating the end of the input data. The constraint of the upper limit of the code length is a constraint on the upper limit of the length (code length) of the variable-length code into which the symbol is converted by dynamic Huffman coding. The upper limit of the code length is determined based on, for example, constraints set by a data compression standard or constraints in the hardware implementation of the compression device 15 and the decompression device 16. The coding table generating unit 32 generates the coding table 43 in accordance with the constraint of the upper limit of the code length so that the length of the variable-length code assigned to each symbol shown in the coding table 43 does not exceed the upper limit based on the constraint.
[0041] The coding table generating unit 32 includes, for example, a frequency table generating unit 321, a code length determining unit 322, a code length upper limit violation correcting unit 323, and a canonical Huffman processing unit 324.
[0042] The frequency table generating unit 321 uses the input symbols to generate a frequency table 41. The frequency table 41 is a table that indicates a plurality of symbols and the occurrence frequency of each of the plurality of symbols. A specific configuration example of the frequency table 41 will be described later with reference to FIG.
[0043] The code length determination unit 322 uses the frequency table 41 to determine a plurality of code lengths associated with a plurality of symbols, respectively. For example, the code length determination unit 322 associates a short code length with a symbol that occurs frequently, and associates a long code length with a symbol that occurs less frequently. The code length associated with a symbol is the length of a variable-length code (i.e., a code bit string) assigned to that symbol. The code length is expressed, for example, in bits. Hereinafter, the code length associated with a symbol is also simply referred to as the code length of the symbol. When determining the code length of each of the plurality of symbols, the code length determination unit 322 does not consider the constraint of the upper limit value of the code length. A specific operation of the code length determination unit 322 will be described later with reference to FIG. 4.
[0044] When there is a restriction on the upper limit value of the code length and the multiple symbols shown in the code length table 42 include a symbol associated with a code length exceeding the upper limit value, the code length upper limit violation correction unit 323 changes (corrects) the code length of that symbol to the upper limit value. Furthermore, the code length upper limit violation correction unit 323 selects at least one symbol in order from the symbol with the longest associated code length among the multiple symbols shown in the code length table 42, from one or more symbols associated with a code length less than the upper limit value. The code length upper limit violation correction unit 323 changes the code length associated with the selected at least one symbol to the upper limit value.
[0045] Then, the code length upper limit violation correction unit 323 sends the code length table 42 including the corrected code length to the canonical Huffman processing unit 324. Also, the code length upper limit violation correction unit 323 sends the code lengths shown in the code length table 42 including the corrected code lengths in a specific symbol order to the packing processing unit 22. The specific symbol order is, for example, an alphabetical order of the corresponding symbols.
[0046] If the code length table 42 generated by the code length determination unit 322 does not contain a code length exceeding the upper limit, the code length upper limit violation correction unit 323 sends the code length table 42 as is to the canonical Huffman processing unit 324. Moreover, the code length upper limit violation correction unit 323 sends the code lengths of the symbols shown in the code length table 42 to the packing processing unit 22 in a specific symbol order.
[0047] The code length upper limit violation correction unit 323 includes, for example, a code length sorting unit 351, a code length clipping unit 352, a code length modification unit 353, a Kraft inequality left hand side calculation unit 354, a termination determination unit 355, and a redundant leaf removal unit 356. The operation of each of these units will be described later with reference to Figs. 8 and 9.
[0048] The canonical Huffman processing unit 324 generates the coding table 43, for example, by the canonical Huffman method, using the code length table 42 including the code length corrected by the code length upper limit violation correction unit 323. The code length table 42 including the corrected code length may include, for example, at least a code length changed from a value exceeding the upper limit to the upper limit, and a code length changed from a value less than the upper limit to the upper limit. The canonical Huffman method is a method that can determine a code bit string (variable length code) to be assigned to a symbol using only the code length of the symbol. The canonical Huffman processing unit 324 sends the generated coding table 43 to the coding unit 33. A specific operation of the canonical Huffman processing unit 324 will be described later with reference to FIG. 18 and FIG. 19.
[0049] The encoding unit 33 converts the symbols sent by the delay buffer 31 into a variable-length code (code bit string) using the encoding table 43 sent by the canonical Huffman processing unit 324. The encoding unit 33 sends the variable-length code obtained by the conversion to the packing processing unit 22.
[0050] With the above configuration, the dynamic Huffman encoder 21 can dynamically Huffman encode input symbols and convert them into variable-length codes.
[0051] Here, the operations of the code length determination unit 322, the code length upper limit violation correction unit 323, and the canonical Huffman processing unit 324 in the coding table generation unit 32 will be specifically described.
[0052] 4 is a flowchart showing an example of the procedure of the code length determination process executed by the code length determination unit 322. The code length determination process is a process for determining the code length of each of a plurality of symbols by using the frequency table 41. The code length determination unit 322 executes the code length determination process in response to, for example, generation of the frequency table 41 corresponding to a plurality of symbols included in input data of a specific unit.
[0053] First, the code length determination unit 322 adds all symbols whose occurrence frequency in the frequency table 41 is higher than 0 as leaf nodes on the Huffman tree (step S11). That is, the code length determination unit 322 generates a Huffman tree including leaf nodes corresponding to the number of symbols whose occurrence frequency in the frequency table 41 is higher than 0.
[0054] Next, the code length determination unit 322 selects node A with the lowest occurrence frequency and node B with the second lowest occurrence frequency from all leaf nodes and intermediate nodes that do not have a parent node in the Huffman tree (step S12). The code length determination unit 322 adds an intermediate node having the selected node A and node B as children to the Huffman tree (step S13). Then, the code length determination unit 322 sets the sum of the occurrence frequencies of node A and node B as the occurrence frequency of the added intermediate node (step S14).
[0055] The code length determination unit 322 determines whether or not the Huffman tree contains two or more leaf nodes and intermediate nodes that have no parent node (step S15). If the Huffman tree contains two or more leaf nodes and intermediate nodes that have no parent node (YES in step S15), the process by the code length determination unit 322 proceeds to step S12. That is, the code length determination unit 322 further performs a procedure for adding a leaf node that has no parent node and an intermediate node that has an intermediate node as a child.
[0056] If the Huffman tree has less than two leaf nodes and intermediate nodes in total that do not have a parent node (NO in step S15), the code length determination unit 322 ends the code length determination process.
[0057] By the above code length determination process, the code length determination unit 322 can construct a Huffman tree. The constructed Huffman tree includes a plurality of leaf nodes corresponding to a plurality of symbols each having an occurrence frequency of 1 or more. The code length determination unit 322 constructs the Huffman tree bottom-up starting from the leaf nodes corresponding to symbols having a low occurrence frequency. The code length determination unit 322 can determine the code length of each of the plurality of symbols using the constructed Huffman tree. The depth of the leaf node starting from the root node corresponds to the code length of the corresponding symbol. Therefore, the code length determination unit 322 can determine the code length of the symbol using the Huffman tree.
[0058] A specific example in which the code length table 42 is generated using the frequency table 41 will be described with reference to FIGS.
[0059] 5 shows an example of the configuration of the frequency table 41 generated by the frequency table generating unit 321. The frequency table 41 includes a plurality of entries corresponding to a plurality of symbols, respectively. Each of the plurality of entries includes, for example, a symbol field and an occurrence frequency field.
[0060] The symbol field indicates the corresponding symbol. The occurrence frequency field indicates the occurrence frequency of the corresponding symbol. More specifically, the occurrence frequency field indicates, for example, the number of times the corresponding symbol appears in the input data to be processed.
[0061] In the following description, the value shown in the symbol field is also simply referred to as a symbol. The same applies to the values shown in the other fields of the frequency table 41 and the values shown in the other fields of the other tables.
[0062] In the example shown in FIG. 5, the occurrence frequency of symbol “a” is 120. The occurrence frequency of symbol “b” is 60. The occurrence frequency of symbol “c” is 29. The occurrence frequency of symbol “d” is 14. The occurrence frequency of symbol “e” is 4. The occurrence frequencies of symbols “f” and “g” are 3. The occurrence frequency of symbol “h” is 2. The occurrence frequency of symbols “i” and “j” is 0.
[0063] 6 shows an example of a Huffman tree 50 generated by the code length determination unit 322. Here, an example is shown in which the code length determination unit 322 generates the Huffman tree 50 using the frequency table 41 shown in FIG.
[0064] First, the code length determination unit 322 selects eight symbols "a", "b", "c", "d", "e", "f", "g", and "h" with occurrence frequencies higher than 0 from the frequency table 41. The code length determination unit 322 generates a Huffman tree 50 including eight leaf nodes 511, 521, 531, 541, 561, 562, 563, and 564 to which the eight selected symbols are respectively assigned. In each leaf node, the occurrence frequency of the corresponding symbol is set. Hereinafter, the set of symbols to which the leaf nodes are assigned (i.e., the set of symbols with occurrence frequencies higher than 0) is also referred to as the set S of symbols.
[0065] The code length determination unit 322 selects leaf node 564 of the symbol "h" with the lowest occurrence frequency and leaf node 563 of the symbol "g" with the second lowest occurrence frequency from all leaf nodes and all intermediate nodes that do not have a parent node in the Huffman tree 50. Then, the code length determination unit 322 adds intermediate node 552 having the selected leaf node 564 and leaf node 563 as children to the Huffman tree 50. The code length determination unit 322 sets the occurrence frequency of intermediate node 552 to the sum of the occurrence frequency of leaf node 564 and the occurrence frequency of leaf node 563 (=2+3=5).
[0066] Next, the code length determination unit 322 selects leaf node 562 of the symbol "f" with the lowest occurrence frequency and leaf node 561 of the symbol "e" with the second lowest occurrence frequency from all leaf nodes and all intermediate nodes that do not have a parent node in the Huffman tree 50. Then, the code length determination unit 322 adds intermediate node 551 having the selected leaf node 562 and leaf node 561 as children to the Huffman tree 50. The code length determination unit 322 sets the occurrence frequency of the added intermediate node 551 to the sum of the occurrence frequency of leaf node 562 and the occurrence frequency of leaf node 561 (=3+4=7).
[0067] Next, the code length determination unit 322 selects the intermediate node 552 with the lowest occurrence frequency and the intermediate node 551 with the second lowest occurrence frequency from all leaf nodes and all intermediate nodes that do not have a parent node in the Huffman tree 50. Then, the code length determination unit 322 adds the intermediate node 542, which has the selected intermediate node 552 and intermediate node 551 as its children, to the Huffman tree 50. The code length determination unit 322 sets the occurrence frequency of the added intermediate node 542 to the sum of the occurrence frequency of the intermediate node 552 and the occurrence frequency of the intermediate node 551 (=5+7=12).
[0068] In the same manner, the code length determination unit 322 repeatedly performs the operation of adding intermediate nodes until the total number of leaf nodes and intermediate nodes without parent nodes in the Huffman tree 50 becomes one or less (i.e., until the only node without a parent node is the root node 501). In this way, the Huffman tree 50 shown in FIG. 6 can be constructed.
[0069] The code length determination unit 322 generates the code length table 42 using the constructed Huffman tree 50. The code length table 42 is a table for managing a plurality of symbols and a plurality of code lengths respectively associated with the plurality of symbols.
[0070] Specifically, the code length determination unit 322 uses the constructed Huffman tree 50 to determine the code length of each of the eight symbols "a", "b", "c", "d", "e", "f", "g", and "h". The depth of the leaf node corresponding to one symbol, starting from the root node 501, indicates the code length of that symbol. For example, the depth of the leaf node 511 of the symbol "a" starting from the root node 501 is 1. Therefore, the code length of the symbol "a" is 1 bit. Also, for example, the depth of the leaf node 564 of the symbol "h" starting from the root node 501 is 6. Therefore, the code length of the symbol "h" is 6 bits.
[0071] 7 shows an example of the configuration of the code length table 42 generated by the code length determination unit 322. The code length table 42 includes a plurality of entries corresponding to a plurality of symbols, respectively. Each of the plurality of entries includes, for example, a symbol field and a code length field.
[0072] The symbol field indicates the corresponding symbol. The code length field indicates the code length determined for the corresponding symbol by the code length determination unit 322. As described above, the code length is determined based on the depth of the leaf node of the corresponding symbol in the Huffman tree 50, starting from the root node 501. Hereinafter, the code length determined by the code length determination unit 322 may be referred to as the pre-constraint code length. In other words, the pre-constraint code length is a code length determined based on the frequency of occurrence of the symbol, without considering the constraint on the upper limit of the code length.
[0073] 7 illustrates a code length table 42 generated using the Huffman tree 50 illustrated in FIG. 6. Specifically, the code length table 42 indicates that the code length (pre-constraint code length) of the symbol "a" is 1 bit. The code length table 42 indicates that the code length of the symbol "b" is 2 bits. The code length table 42 indicates that the code length of the symbol "c" is 3 bits. The code length table 42 indicates that the code length of the symbol "d" is 4 bits. The code length table 42 also indicates that the code length of each of the symbols "e", "f", "g", and "h" is 6 bits.
[0074] Next, a description will be given of a specific operation example of the code length upper limit violation correcting unit 323. The code length upper limit violation correcting unit 323 corrects a code length that exceeds the upper limit to be equal to or less than the upper limit, using the code length table 42 generated by the code length determining unit 322.
[0075] Fig. 8 is a flowchart showing an example of the procedure of the upper limit violation correction process executed by the code length upper limit violation correction unit 323. The upper limit violation correction process is a process for correcting a code length that exceeds the upper limit to be equal to or less than the upper limit when an upper limit value of the code length associated with a symbol is set. The code length upper limit violation correction unit 323 starts the execution of the upper limit violation correction process after the execution of the code length determination process shown in Fig. 4 is completed, for example.
[0076] First, the code length sorting unit 351 of the code length upper limit violation correction unit 323 sorts the entries in the code length table 42 by code length (step S21). The code length sorting unit 351 sorts the entries in the code length table 42, for example, in ascending order of code length. Then, the code length clipping unit 352 changes the code lengths of all symbols in the code length table 42 that exceed the upper limit to the upper limit (step S22).
[0077] Next, the code length change unit 353 selects M symbols whose code lengths are smaller than the upper limit value in the code length table 42, starting from the symbol with the longest code length (step S23). Note that M is an integer equal to or greater than 1. The code length change unit 353 changes the code lengths of the selected M symbols in the code length table 42 to the upper limit value in parallel (step S24). In this manner, M indicates the number of symbols whose code lengths are changed in parallel. The larger M is, the more symbols whose code lengths are changed to the upper limit value at one time. Hereinafter, M is also referred to as the degree of parallelism.
[0078] The Kraft inequality left-hand side calculation unit 354 calculates the value K of the left-hand side of the Kraft inequality using the code lengths of the set S of symbols including the changed code length (step S25). The Kraft inequality is expressed by the following equation (1).
[0079]
number
[0080] When a set of symbols S and the code length l(s) of each symbol s∈S satisfy the Kraft inequality, it is guaranteed that there exists a valid encoding table 43. In other words, encoding and decoding can be performed correctly using the encoding table 43 generated based on the code length l(s) of each symbol s∈S.
[0081] On the other hand, if the set of symbols S and the code length l(s) of each symbol s∈S do not satisfy the Kraft inequality, there is no valid coding table 43. Therefore, encoding and decoding cannot be performed correctly using the coding table 43 generated based on the code length l(s) of each symbol s∈S.
[0082] The end determination unit 355 determines whether the value K of the left side of the calculated Kraft inequality is less than or equal to 1 (step S26). That is, the end determination unit 355 determines whether the code lengths l(s) of the multiple symbols s included in the set S of symbols shown in the current code length table 42 satisfy the Kraft inequality.
[0083] If the value K of the left side of the Kraft inequality is greater than 1 (NO in step S26), the process by the code length upper limit violation correction unit 323 returns to step S23. That is, the code length change unit 353 and the Kraft inequality left side calculation unit 354 select M symbols having code lengths smaller than the upper limit that have not yet been selected, in order from the longest associated code length, change the code lengths of the selected M symbols to the upper limit, and calculate the value K of the left side of the Kraft inequality, repeatedly performing the process until the code lengths l(s) of the multiple symbols s included in the set S of symbols shown in the code length table 42 satisfy the Kraft inequality (that is, until the value of the left side of the Kraft inequality becomes 1 or less).
[0084] As described above, the larger M is, the more symbols whose code length is changed to the upper limit at one time are increased. Therefore, by setting M to 2 or more, the number of cycles required to satisfy the Kraft inequality can be reduced compared to when M is 1. Here, the number of cycles refers to the number of times one cycle of processing is executed, with one execution of the procedure from step S23 to step S25 being one cycle. The code length upper limit violation correction unit 323 can set the value of M so as to satisfy the upper limit of latency required for the compression device 15, for example.
[0085] If the value K of the left side of the Kraft inequality is 1 or less (YES in step S26), the redundant leaf removal unit 356 executes a redundant leaf removal process (step S27) and ends the upper limit violation correction process. The redundant leaf removal process is a process for removing redundant leaf nodes that are generated by changing a code length smaller than the upper limit value to the upper limit value from the Huffman tree 50. The specific steps of the redundant leaf removal process will be described later with reference to the flowchart in FIG.
[0086] Through the above upper limit violation correction process, the code length upper limit violation correction unit 323 can change the code length that exceeds the upper limit associated with a symbol to the upper limit. Through this change, the code length l(s) of the multiple symbols s included in the set S of symbols shown in the code length table 42 no longer satisfies the Kraft inequality. Therefore, the code length upper limit violation correction unit 323 further selects M symbols whose code lengths are smaller than the upper limit, and repeats the process of changing the code lengths of the selected M symbols to the upper limit until the Kraft inequality is satisfied. Through this, the code length upper limit violation correction unit 323 can obtain the code length table 42 that includes the set S of symbols associated with code lengths that are equal to or smaller than the upper limit and that satisfy the Kraft inequality.
[0087] 9 is a flowchart showing an example of the procedure of the redundant leaf removal process executed by the redundant leaf removal unit 356. The redundant leaf removal process corresponds to step S27 of the upper limit violation correction process described above with reference to FIG.
[0088] First, the redundant leaf removal unit 356 determines whether or not the value K of the left side of the Kraft inequality is less than 1 (step S301). The value K of the left side of the Kraft inequality is the value calculated by the Kraft inequality left side calculation unit 354 in step S25 of the upper limit violation correction process described above with reference to Fig. 8 immediately before executing the redundant leaf removal process. Therefore, the value K of the left side of the Kraft inequality is less than or equal to 1.
[0089] If the value K of the left side of the Kraft inequality is not less than 1 (NO in step S301), that is, if it is 1, the redundant leaf removal unit 356 ends the redundant leaf removal process. In other words, if the value K of the left side of the Kraft inequality is 1, the redundant leaf removal unit 356 determines that no redundant leaf nodes exist in the Huffman tree 50. Therefore, the redundant leaf removal unit 356 ends the redundant leaf removal process.
[0090] If the value K of the left side of the Kraft inequality is less than 1 (YES in step S301), the redundant leaf removal unit 356 acquires a group of symbols whose pre-constraint code lengths are less than the upper limit and whose code lengths have been changed to the upper limit, in ascending order of pre-constraint code lengths (step S302). If the value K of the left side of the Kraft inequality is less than 1, the redundant leaf removal unit 356 determines that a redundant leaf node exists in the Huffman tree 50. The redundant leaf removal unit 356 sets a variable i to 1 (step S303). The variable i is used to identify one symbol included in the acquired group of symbols.
[0091] Next, the redundant leaf removal unit 356 selects the i-th symbol s from the acquired symbol group (step S304). The redundant leaf removal unit 356 reduces the code length of the symbol s by 1 bit (step S305). The redundant leaf removal unit 356 calculates the value K of the left side of the Kraft inequality using the code length of the symbol set S including the changed code length (step S306). The value K of the left side of the Kraft inequality may be calculated by the Kraft inequality left side calculation unit 354. Then, the redundant leaf removal unit 356 determines whether the calculated value K of the left side of the Kraft inequality is 1 or less (step S307). That is, the redundant leaf removal unit 356 determines whether the code length of the symbol set S including the changed code length satisfies the Kraft inequality.
[0092] If the value K of the left side of the Kraft inequality is greater than 1 (NO in step S307), the redundant leaf elimination unit 356 increases the code length of the symbol s by 1 bit (step S308). That is, the redundant leaf elimination unit 356 determines that the code length of the symbol set S no longer satisfies the Kraft inequality by reducing the code length of the symbol s by 1 bit in step S305. Therefore, the redundant leaf elimination unit 356 restores the code length of the symbol s to its original state. Then, the redundant leaf elimination unit 356 adds 1 to the variable i (step S309), and the process by the redundant leaf elimination unit 356 proceeds to step S304. As a result, the redundant leaf elimination unit 356 selects another subsequent symbol from the symbol group acquired in step S302, and performs a process to reduce the code length of the other symbol.
[0093] If the value K of the left side of the Kraft inequality is 1 or less (YES in step S307), the redundant leaf removal unit 356 determines whether the value K of the left side of the Kraft inequality is less than 1 (step S310).
[0094] If the value K of the left side of the Kraft inequality is less than 1 (YES in step S310), the process by the redundant leaf removal unit 356 proceeds to step S305. As a result, a process for further reducing the code length of the symbol s is performed. In other words, if the value K of the left side of the Kraft inequality is less than 1, the redundant leaf removal unit 356 determines that a redundant leaf node exists in the Huffman tree 50, and performs a process for further reducing the code length of the symbol s.
[0095] If the value K of the left side of the Kraft inequality is not less than 1 (NO in step S310), that is, if it is 1, the redundant leaf removal unit 356 ends the redundant leaf removal process. In other words, if the value K of the left side of the Kraft inequality is 1, the redundant leaf removal unit 356 determines that no redundant leaf nodes exist in the Huffman tree 50, and ends the redundant leaf removal process.
[0096] Through the above redundant leaf removal process, the redundant leaf removal unit 356 can remove redundant leaf nodes that are generated by changing a code length smaller than the upper limit value to the upper limit value in the upper limit violation correction process from the Huffman tree 50. More specifically, the redundant leaf removal unit 356 can repeatedly perform a process of decreasing the code length of a symbol whose pre-constraint code length was less than the upper limit value by one bit at a time until the value K of the left side of the Kraft inequality becomes 1. This allows the code length upper limit violation correction unit 323 to obtain a code length table 42 in which the value K of the left side of the Kraft inequality is 1.
[0097] 10 to 13, the operation of the code length upper limit violation correction unit 323 restricting the code length of the symbol set S to an upper limit value will be described using a modified example of the Huffman tree 50 in FIG. 6. The Huffman tree 50 in FIG. 6 is a Huffman tree constructed by the code length determination unit 322 based on the frequency of occurrence of the symbols without considering the upper limit value of the code length. The code length upper limit violation correction unit 323 modifies the Huffman tree 50 in FIG. 6 so as to satisfy the upper limit value constraint of the code length and the Kraft inequality. Here, it is assumed that the upper limit value of the code length is 4. Also, for ease of understanding, it is assumed that the parallelism M is 1.
[0098] FIG. 10 shows an example in which the code length upper limit violation correction unit 323 determines symbols whose code lengths exceed the upper limit and symbols whose code lengths are to be extended up to the upper limit.
[0099] Specifically, the code length upper limit violation correction unit 323 determines four symbols "e", "f", "g", and "h" (i.e., leaf nodes 561, 562, 563, and 564) whose code lengths exceed 4. The code length upper limit violation correction unit 323 changes the code lengths of the determined four symbols "e", "f", "g", and "h" from 6 bits to 4 bits.
[0100] Furthermore, the code length upper limit violation correction unit 323 determines the symbol “c” (i.e., the leaf node 531) with the longest code length among the symbols with a code length of less than 4 bits. The code length upper limit violation correction unit 323 changes the code length of the determined symbol “c” from 3 bits to 4 bits.
[0101] FIG. 11 shows a Huffman tree 50 in which the code lengths of the four symbols "e", "f", "g", and "h" and the code length of the symbol "c" have been changed due to the above-mentioned modifications.
[0102] By changing the code length of the symbol "c" from 3 bits to 4 bits, node 531 is changed from a leaf node to an intermediate node, and two leaf nodes 543 and 544, which have intermediate node 531 as their parent node, are added to the Huffman tree 50. The symbol "c" is assigned to leaf node 543. The symbol "e" is assigned to leaf node 544.
[0103] Furthermore, in Huffman tree 50, the code length of four symbols "e", "f", "g", and "h" has been changed from 6 bits to 4 bits, resulting in four leaf nodes 541, 545, 546, and 542 with intermediate node 532 as the parent node. Therefore, this Huffman tree 50 is an invalid Huffman tree. Therefore, a Huffman code determined based on this Huffman tree 50 is an invalid Huffman code that does not satisfy the Krafft inequality (i.e., K>1).
[0104] Therefore, the code length upper limit violation correction unit 323 further determines a leaf node that extends the code length to the upper limit. Specifically, the code length upper limit violation correction unit 323 determines the symbol "b" (i.e., the leaf node 521) that has the longest code length among the symbols whose code length is less than 4. The code length upper limit violation correction unit 323 changes the code length of the determined symbol "b" from 2 bits to 4 bits.
[0105] FIG. 12 shows a Huffman tree 50 in which the code length of the symbol "b" has been changed.
[0106] By changing the code length of the symbol "b" from 2 bits to 4 bits, node 521 is changed from a leaf node to an intermediate node, and two intermediate nodes 533 and 534 having intermediate node 531 as its parent node, two leaf nodes 547 and 548 having intermediate node 533 as its parent node, and two leaf nodes 545 and 546 having intermediate node 534 as its parent node are added to Huffman tree 50. This Huffman tree 50 is a valid Huffman tree 50. Therefore, a Huffman code determined based on this Huffman tree 50 is a valid Huffman code that satisfies the Kraft inequality (i.e., K<1).
[0107] The code length upper limit violation corrector 323 further removes redundant leaf nodes 548 that are not assigned any symbols.
[0108] FIG. 13 shows the Huffman tree 50 with the redundant leaf nodes 548 removed. The binary tree consisting of redundant leaf node 548, leaf node 547, and intermediate node 533 is merged to become leaf node 533. Symbol "b" that was assigned to leaf node 547 is assigned to leaf node 533. That is, the code length of symbol "b" is reduced by 1 bit, from 4 bits to 3 bits.
[0109] This Huffman tree 50 is a valid Huffman tree 50. Therefore, a Huffman code determined based on this Huffman tree 50 is a valid Huffman code that satisfies the Kraft inequality and has no redundant code assignments (i.e., K=1).
[0110] Next, with reference to Fig. 14 to Fig. 17, an operation of the code length upper limit violation correction unit 323 constraining the code length to an upper limit will be described using a modified example of the code length table 42. The code length table 42 shown in Fig. 14 to Fig. 17 manages the code length determined (corrected) by the code length upper limit violation correction unit 323 in addition to the pre-constraint code length determined by the code length determination unit 322. Hereinafter, the code length determined by the code length upper limit violation correction unit 323 may be referred to as the post-constraint code length. The post-constraint code length is a code length determined based on the frequency of occurrence of a symbol and the constraint of the upper limit value of the code length.
[0111] 14 shows an example of modification of the code length table 42 by the code length upper limit violation correction unit 323. Each entry of the code length table 42 includes a symbol field, a pre-constraint code length field, and a post-constraint code length field.
[0112] The symbol field indicates the corresponding symbol. The pre-constraint code length field indicates the pre-constraint code length of the corresponding symbol (i.e., the code length determined by the code length determination unit 322). The post-constraint code length field indicates the post-constraint code length of the corresponding symbol. The post-constraint code length is the pre-constraint code length of the corresponding symbol or is the code length changed from the pre-constraint code length by the code length upper limit violation correction unit 323.
[0113] In the example shown in Fig. 14, the value set in the symbol field is the same as the value set in the symbol field of the code length table 42 shown in Fig. 7. Also, in the example shown in Fig. 14, the value set in the pre-constraint code length field is the same as the value set in the pre-constraint code length field of the code length table 42 shown in Fig. 7.
[0114] The code length upper limit violation correction unit 323 sets, for example, the pre-constraint code length of the corresponding symbol as the initial value of the post-constraint code length field. If the code length indicated in the post-constraint code length field exceeds the upper limit, the code length upper limit violation correction unit 323 changes the code length to the upper limit.
[0115] In the example shown in Fig. 14, the upper limit is 4 bits. In this case, the code length upper limit violation correction unit 323 identifies four symbols "e", "f", "g", and "h" whose pre-constraint code lengths exceed the upper limit. Then, the code length upper limit violation correction unit 323 changes the post-constraint code length of each of the identified four symbols from 6 bits to 4 bits. Note that the post-constraint code lengths of the four symbols "a", "b", "c", and "d" whose pre-constraint code lengths do not exceed the upper limit match the pre-constraint code length.
[0116] The post-constraint code length of the set S of symbols shown in the code length table 42 does not satisfy the Kraft inequality. The set S of symbols is the eight symbols “a”, “b”, “c”, “d”, “e”, “f”, “g”, and “h” shown in the code length table 42. The post-constraint code lengths of the set S of symbols are the eight post-constraint code lengths associated with the eight symbols “a”, “b”, “c”, “d”, “e”, “f”, “g”, and “h” shown in the code length table 42, respectively. Therefore, the eight post-constraint code lengths associated with the eight symbols “a”, “b”, “c”, “d”, “e”, “f”, “g”, and “h” shown in the code length table 42, respectively, do not satisfy the Kraft inequality (i.e., K>1). Therefore, the code length upper limit violation correction unit 323 selects a symbol whose post-constraint code length is to be extended from among the symbols whose post-constraint code length is less than the upper limit value.
[0117] FIG. 15 shows an example in which the code length upper limit violation correction unit 323 selects a symbol whose post-constraint code length is to be extended from symbols whose post-constraint code length is less than the upper limit, and changes the post-constraint code length of the selected symbol to the upper limit.
[0118] The code length upper limit violation correction unit 323 selects M symbols in ascending order of the length of the post-constraint code length from among the symbols whose post-constraint code length is less than the upper limit. For ease of explanation, the case where M is 1 is illustrated here. Therefore, the code length upper limit violation correction unit 323 selects the symbol "c" whose post-constraint code length is the longest from among the symbols whose post-constraint code length is less than 4 bits.
[0119] The code length upper limit violation correction unit 323 changes the post-constraint code length of the selected symbol "c" from 3 bits to 4 bits. Then, the code length upper limit violation correction unit 323 calculates the value K of the left side of the Kraft inequality using the post-constraint code length of the set S of symbols. Since the value K of the left side of the Kraft inequality is greater than 1, the code length upper limit violation correction unit 323 determines that the post-constraint code length of the set S of symbols does not satisfy the Kraft inequality. Therefore, the code length upper limit violation correction unit 323 further selects M symbols in descending order of the post-constraint code length from among the symbols whose post-constraint code lengths are less than the upper limit value, and changes the post-constraint code lengths of the selected symbols to the upper limit value.
[0120] FIG. 16 shows an example in which the code length upper limit violation correction unit 323 further selects a symbol whose post-constraint code length is to be extended from the symbols whose post-constraint code length is less than the upper limit, and changes the post-constraint code length of the selected symbol to the upper limit.
[0121] Specifically, the code length upper limit violation correction unit 323 selects the symbol "b" having the longest post-constraint code length among the symbols whose post-constraint code length is less than 4. The code length upper limit violation correction unit 323 changes the post-constraint code length of the selected symbol "b" from 2 bits to 4 bits. Then, the code length upper limit violation correction unit 323 calculates the value K of the left side of the Kraft inequality using the post-constraint code length of the set S of symbols. Since the value K of the left side of the Kraft inequality is 1 or less, the code length upper limit violation correction unit 323 determines that the post-constraint code length of the set S of symbols satisfies the Kraft inequality.
[0122] Next, the code length upper limit violation correction unit 323 performs an operation to decrease the post-constraint code length that has been redundantly increased.
[0123] FIG. 17 shows an example in which the code length upper limit violation correction unit 323 reduces the post-constraint code length that has been redundantly increased.
[0124] The code length upper limit violation correction unit 323 selects symbols one by one in ascending order of pre-constraint code length from among symbols whose pre-constraint code length is less than the upper limit and whose post-constraint code length has been changed to the upper limit. Specifically, the code length upper limit violation correction unit 323 first selects the symbol "b" with the shortest pre-constraint code length from among two symbols "b" and "c" whose pre-constraint code length is less than the upper limit and whose post-constraint code length has been changed to the upper limit. The code length upper limit violation correction unit 323 reduces the post-constraint code length of the selected symbol "b" by 1 bit, changing it from 4 bits to 3 bits.
[0125] Then, the code length upper limit violation correction unit 323 calculates the value K of the left side of the Kraft inequality using the post-constraint code length of the symbol set S. Then, since the calculated value K of the left side of the Kraft inequality is 1, the code length upper limit violation correction unit 323 ends the change of the post-constraint code length.
[0126] If the calculated value K of the left side of the Kraft inequality is greater than 1, the code length upper limit violation correction unit 323 restores the post-constraint code length of the symbol "b" to its original value and decreases the post-constraint code length of another symbol (e.g., symbol "c") by 1 bit. More specifically, the post-constraint code length of the symbol "b" is increased by 1 bit to return it to 4 bits from 3 bits. Then, the code length upper limit violation correction unit 323 decreases by 1 bit the post-constraint code length of another symbol (e.g., symbol "c") whose pre-constraint code length is less than the upper limit and whose post-constraint code length has been changed to the upper limit. Then, the code length upper limit violation correction unit 323 recalculates the value K of the left side of the Kraft inequality using the post-constraint code length of the set S of symbols. If the calculated value K of the left side of the Kraft inequality is 1, the code length upper limit violation correction unit 323 ends the change of the post-constraint code length.
[0127] Furthermore, if the calculated value K of the left side of the Kraft inequality is smaller than 1, the code length upper limit violation correction unit 323 further decreases the post-constraint code length of the symbol "b" by 1 bit. Then, the code length upper limit violation correction unit 323 recalculates the value K of the left side of the Kraft inequality using the post-constraint code length of the symbol set S. If the calculated value K of the left side of the Kraft inequality is 1, the code length upper limit violation correction unit 323 ends the change of the post-constraint code length.
[0128] In this way, the code length upper limit violation correction unit 323 repeatedly performs an operation of decreasing the post-constraint code length by one bit for each symbol whose pre-constraint code length is less than the upper limit and whose post-constraint code length has been changed to the upper limit, in ascending order of pre-constraint code length, and determining whether the value K of the left-hand side of the Kraft inequality has become 1. Furthermore, if the value K of the left-hand side of the Kraft inequality is smaller than 1 after decreasing the post-constraint code length of one symbol by one bit, the code length upper limit violation correction unit 323 further decreases the post-constraint code length of that symbol by one bit.
[0129] When the value K of the left side of the Kraft inequality is 1, the Huffman code determined based on the constrained code length of the symbol set S satisfies the Kraft inequality and is a valid Huffman code with no redundant code assignments. In other words, the constrained code length of the symbol set S shown in Figure 17 satisfies the Kraft inequality and corresponds to the Huffman tree 50 in Figure 13 which has no redundant leaf nodes.
[0130] The code length upper limit violation correction unit 323 (more specifically, the redundant leaf removal unit 356) sends the code length table 42 to the canonical Huffman processing unit 324. Specifically, the code length upper limit violation correction unit 323 sends to the canonical Huffman processing unit 324 a plurality of symbols shown in the code length table 42 and a plurality of post-constraint code lengths respectively associated with the plurality of symbols.
[0131] Moreover, the code length upper limit violation correction unit 323 outputs the multiple post-constraint code lengths to the packing unit 22 in a specific symbol order. The specific symbol order is, for example, an alphabetical order of the multiple corresponding symbols. That is, the code length upper limit violation correction unit 323 outputs the corresponding post-constraint code lengths to the packing unit 22 in alphabetical order of the multiple symbols.
[0132] The canonical Huffman processing unit 324 generates an encoding table 43 by the canonical Huffman method using the code length table 42 sent by the code length upper limit violation correction unit 323. The encoding table 43 may include the code length corrected by the code length upper limit violation correction unit 323. The canonical Huffman method is a method that can determine a code bit string (variable length code) to be assigned to a symbol using only the code length of the symbol. In the canonical Huffman method, a code bit string is assigned to a symbol according to the following rules (1) and (2).
[0133] (1) A code bit sequence assigned to a symbol having a shorter code length precedes, in lexicographical order, a code bit sequence assigned to a symbol having a longer code length. (2) For any two symbols having the same code length, the code bit sequence assigned to the preceding symbol in the symbol order precedes, in lexicographical order, the code bit sequence assigned to the succeeding symbol in the symbol order.
[0134] For example, to determine the lexicographic order of code bit strings, the lexicographic order of the bit values "0" and "1" is defined as the order "0", "1". In this case, the lexicographic order of multiple code bit strings can be determined by comparing the orders (bit orders) of corresponding bit values contained in multiple code bit strings, starting from the most significant bit.
[0135] More specifically, for example, "1'b0", "2'b10", "3'b110", and "3'b111" are four code bit strings arranged in dictionary order. Note that a data string with a bit value of 0 or 1 following "X'b" indicates a bit data string of X bits. Therefore, in these four code bit strings, the most significant bit of the 1-bit code bit string "1'b0" precedes the 2-bit code bit string "2'b10". The next most significant bit of the 2-bit code bit string "2'b10" precedes the 3-bit code bit string "3'b110". The least significant bit of the 3-bit code bit string "3'b110" precedes the 3-bit code bit string "3'b111".
[0136] 18 shows an example of a pseudo program for the canonical Huffman processor 324 to assign code bit strings to symbols. In the pseudo program, a variable code is used to calculate the code bit string to be assigned to the symbol.
[0137] First, the canonical Huffman processor 324 sets 0 (=1'b0) to code. Note that the number of bits of this code is in accordance with the smallest code length among multiple code lengths associated with multiple symbols to which the code bit string should be assigned.
[0138] Next, the canonical Huffman processor 324 determines, in one while loop, a code bit string to be assigned to one symbol in ascending order of code length, and in a specific symbol order when the code lengths are the same.
[0139] For example, in the first while loop, the canonical Huffman processor 324 selects a symbol that has the shortest code length and that is first in a specific symbol order when there is another symbol with the same code length, as a target for allocating a code bit string. Then, the canonical Huffman processor 324 allocates code (=1'b0) as the code bit string of the selected symbol. As described above, the number of bits of code to be allocated first depends on the minimum code length. In this example, it is assumed that the minimum code length is 1. Then, the canonical Huffman processor 324 performs a shift operation to shift the value obtained by adding 1 to code to the left by the number of bits obtained by subtracting the code length of the current symbol from the code length of the next symbol, and sets the value obtained by this shift operation to code. For example, if the number of bits obtained by subtracting the code length of the current symbol from the code length of the next symbol is 1, the value 2'b10 obtained by shifting 1'b1, which is the value obtained by adding 1 to code (=1'b0) to the left, one bit is set to code.
[0140] Also, for example, in the second while loop, the canonical Huffman processor 324 selects the symbol with the second shortest code length, or the symbol with the shortest code length and second in a specific symbol order if there is another symbol with the same code length, as a target for assigning a code bit string. The canonical Huffman processor 324 assigns code (=2'b10) as the code bit string of the selected symbol. Then, the canonical Huffman processor 324 performs a shift operation to shift the value obtained by adding 1 to code to the left by the number of bits obtained by subtracting the code length of the current symbol from the code length of the next symbol, and sets the value obtained by this shift operation to code. For example, if the number of bits obtained by subtracting the code length of the current symbol from the code length of the next symbol is 1, the value 2'b11 obtained by adding 1 to code (=2'b10) to the left by 1 bit is set to code.
[0141] By performing such loop processing, the canonical Huffman processor 324 can assign code bit strings to each of the multiple symbols using the order relationship between the symbols and the multiple code lengths corresponding to the multiple symbols, respectively. In other words, the canonical Huffman processor 324 can uniquely determine the code bit string to be assigned to each symbol by determining the order relationship between the symbols and the code length of each symbol.
[0142] This indicates that the decompressor 16 can restore the decoding table by encoding a plurality of code lengths arranged in a predetermined symbol order as a header in the compressed data output by the packing unit 22. By encoding a plurality of code lengths arranged in a symbol order, the overhead of the coding amount of the compressed data can be significantly reduced compared to the case where the code bit string itself is encoded.
[0143] Therefore, as described above, the code length upper limit violation correction unit 323 (more specifically, the redundant leaf removal unit 356) sends the multiple code lengths (post-constraint code lengths) shown in the corrected code length table 42 in accordance with the symbol order of the corresponding multiple symbols to the packing unit 22. The packing unit 22 adds the multiple code lengths arranged in accordance with the symbol order to the beginning of the compressed data as a header.
[0144] Fig. 19 shows an example of allocation of code bit strings to symbols by the canonical Huffman processor 324. Here, an example will be described in which the canonical Huffman processor 324 executing the pseudo program shown in Fig. 18 allocates code bit strings to the four symbols "B", "A", "C", and "D" shown in Fig. 19 by using code lengths.
[0145] The four symbols "B", "A", "C", and "D" are sorted in ascending order of code length, and in a specific symbol order (here, alphabetical order) if there are multiple symbols with the same code length. Specifically, the code length of symbol "B" is 1, making it the shortest. The code length of symbol "A" is 2, making it the second shortest. The code lengths of symbols "C" and "D" are 3, making it the third shortest. Furthermore, symbol "C" precedes symbol "D" in alphabetical order.
[0146] First, the canonical Huffman processor 324 sets 0 (=1'b0) to code.
[0147] Next, in the first while loop, the canonical Huffman processor 324 selects the symbol "B" with the shortest code length as the target for assigning the code bit string. The canonical Huffman processor 324 assigns code (=1'b0) as the code bit string of the selected symbol "B". The number of bits of code to be assigned initially is based on the smallest code length (i.e., the code length of the symbol "B") among the code lengths of the four symbols "B", "A", "C", and "D". Therefore, the number of bits of this code is 1. Then, the canonical Huffman processor 324 performs a shift operation to shift the value obtained by adding 1 to code to the left by 1 bit (=2-1) obtained by subtracting the code length of the current symbol "B" from the code length of the next symbol "A", and sets the value 2'b10 obtained by this shift operation to code.
[0148] In the second while loop, the canonical Huffman processor 324 selects the symbol "A" with the second shortest code length as the symbol to which to assign the code bit string. The canonical Huffman processor 324 assigns code (=2'b10) as the code bit string of the selected symbol "A". The canonical Huffman processor 324 then performs a shift operation to shift the value obtained by adding 1 to code to the left by 1 bit (=3-2) calculated by subtracting the code length of the current symbol "A" from the code length of the next symbol "C", and sets the value 3'b110 obtained by this shift operation to code.
[0149] In the third while loop, the canonical Huffman processor 324 selects the symbol "C" which has the third shortest code length and precedes the symbol "D" of the same code length in the specific symbol order, as a target to which a code bit string is to be assigned. The canonical Huffman processor 324 assigns code (=3'b110) as the code bit string of the selected symbol "C". Then, the canonical Huffman processor 324 performs a shift operation to shift the value obtained by adding 1 to code to the left by 0 bits (=3-3) obtained by subtracting the code length of the current symbol "C" from the code length of the next symbol "D", and sets the value 3'b111 obtained by this shift operation to code. In other words, if the code lengths of the two symbols "C" and "D" are the same, the canonical Huffman processor 324 sets the value obtained by adding 1 to code as the new value of code.
[0150] In the fourth while loop, the canonical Huffman processor 324 selects the symbol "D" which has the third shortest code length and is placed after the symbol "C" of the same code length in the specific symbol order, as a symbol to which a code bit string is to be assigned. The canonical Huffman processor 324 assigns code (=3'b111) as the code bit string of the selected symbol "D".
[0151] As a result, the canonical Huffman processor 324 can uniquely determine the code bit sequence to be assigned to each of the multiple symbols based on the code length of each of the multiple symbols and a specific symbol order when there are multiple symbols of the same code length. The canonical Huffman processor 324 sends to the encoder 33 a coding table 43 indicating the multiple symbols and the multiple code bit sequences assigned to the multiple symbols, respectively.
[0152] This allows the encoding unit 33 to use the encoding table 43 to convert the symbols sent by the delay buffer 31 into a coded bit string (variable length code).
[0153] With the above configuration, the dynamic Huffman encoder 21 can suppress a decrease in compression performance when the code length is restricted to an upper limit value or less.
[0154] Here, we will explain, using a dynamic Huffman encoder provided in a compression device according to a comparative example, how the dynamic Huffman encoder 21 of this embodiment can suppress a decrease in compression performance when the code length is restricted to an upper limit value or less.
[0155] Fig. 20 is a flowchart showing an example of the procedure of the code length constraint process executed by the dynamic Huffman encoder of the comparative example. The dynamic Huffman encoder executes the code length constraint process after executing the code length determination process described above with reference to Fig. 4, for example. Here, a case is illustrated in which the dynamic Huffman encoder uses the code length table 42 generated by the code length determination unit 322. The code length table 42 includes information indicating a plurality of symbols and a plurality of code lengths respectively associated with the plurality of symbols. The plurality of code lengths are code lengths determined without considering the upper limit value of the code length.
[0156] First, the dynamic Huffman encoder of the comparative example selects a symbol s capable of providing coding space for all n symbols having code lengths exceeding the upper limit from among a plurality of symbols shown in the code length table 42 (step S41). Being able to provide coding space for all n symbols means that in the Huffman tree corresponding to the code length table 42, leaf nodes corresponding to code lengths equal to or less than the upper limit can be assigned to all n symbols.
[0157] Next, the dynamic Huffman encoder changes the code length of the symbol s to the upper limit (step S42). The dynamic Huffman encoder changes the code lengths of each of the n symbols to the upper limit (step S43). The dynamic Huffman encoder assigns the n symbols to vacant leaf nodes in the coding space that are created by changing the code length of the symbol s to the upper limit (step S44). The dynamic Huffman encoder then merges binary trees that include leaf nodes that are not assigned to any symbol (step S45), and ends the code length constraint process.
[0158] By the above code length constraint process, the dynamic Huffman encoder of the comparative example can change the code length associated with a symbol that exceeds the upper limit to the upper limit. The dynamic Huffman encoder changes the code length of n symbols to the upper limit by changing the code length of symbol s that can provide coding space for all n symbols having code lengths that exceed the upper limit to the upper limit.
[0159] However, if the code length of the symbol s is changed significantly, the compression performance of the dynamic Huffman coder may degrade significantly.
[0160] With reference to Figures 21 and 22, the degradation of compression performance will be described using an example in which a dynamic Huffman encoder of a comparative example modifies the Huffman tree 50 of Figure 6. The Huffman tree 50 of Figure 6 is a Huffman tree constructed by the code length determination unit 322 based on the frequency of occurrence of symbols without considering the upper limit of the code length. Here, the upper limit of the code length is assumed to be 4.
[0161] FIG. 21 shows an example in which a comparative dynamic Huffman encoder determines symbols whose code length exceeds the upper limit and symbols that can provide coding space for all symbols whose code length exceeds the upper limit.
[0162] Specifically, the dynamic Huffman encoder determines four symbols "e", "f", "g", and "h" (i.e., leaf nodes 661, 662, 663, and 664) in the Huffman tree 60 whose code length exceeds 4. The dynamic Huffman encoder changes the code length of the determined four symbols "e", "f", "g", and "h" from 6 bits to 4 bits. The dynamic Huffman encoder changes the parent nodes connecting the leaf nodes 661, 662, 663, and 664 corresponding to the four symbols "e", "f", "g", and "h" in the Huffman tree 60, thereby changing the code length (i.e., the depth of the leaf nodes) to 4 bits.
[0163] When changing the code length of four symbols "e", "f", "g", and "h" from 6 bits to 4 bits, the dynamic Huffman encoder selects a leaf node L (leaf node 611 in the example shown in FIG. 21) with a sufficiently short code length. Then, the dynamic Huffman encoder configures a subtree having five leaf nodes to which the symbol "a" corresponding to the selected leaf node L and the four symbols "e", "f", "g", and "h" with code lengths exceeding 4 are respectively assigned, and the node L is the parent node. The leaf node L with a sufficiently short code length refers to a leaf node in which the code lengths of all symbols are equal to or less than an upper limit value when this subtree is configured. The dynamic Huffman encoder selects the leaf node with the longest code length as the leaf node L among the leaf nodes that satisfy the following formula (2). 2 (符号長上限値-リーフノードLの符号長) ≧ 1 + number of symbols that violate the upper limit of the code length Equation (2)
[0164] The left side of equation (2) indicates the maximum number of leaf nodes in a subtree whose parent node is leaf node L and whose depth from root node 601 is equal to or less than the upper limit. In other words, the left side of equation (2) indicates the maximum number of symbols that a subtree can handle when a subtree is constructed whose parent node is leaf node L and all leaf nodes satisfy the constraint of the upper limit of the code length.
[0165] The right side of equation (2) indicates the sum of the number of symbols corresponding to leaf node L (ie, 1) and the number of symbols that violate the upper limit constraint of the code length and require a change in code length.
[0166] By performing a Huffman tree transformation process on leaf nodes that satisfy equation (2), it is possible to assign leaf nodes to the symbol corresponding to leaf node L and to the symbol that violates the upper code length constraint in the subtree having leaf node L as the parent node.
[0167] In the example shown in FIG. 21, the dynamic Huffman encoder determines a symbol "a" (i.e., leaf node 611) that can provide coding space for all four symbols "e", "f", "g", and "h". The code length of the symbol "a" is 1 bit. By changing the code length of the symbol "a" from 1 bit to 4 bits, seven leaf nodes are added to the Huffman tree 60. More specifically, by changing the code length of the symbol "a" from 1 to 4, eight leaf nodes (=2 (4-1) A subtree is created having eight leaf nodes 643, 644, 654, 646, 647, 648, 649, and 640. Of the eight leaf nodes 643, 644, 654, 646, 647, 648, 649, and 640, one leaf node 647 is assigned the symbol "a." Thus, by changing the code length of the symbol "a" from 1 bit to 4 bits, seven leaf nodes are added to the Huffman tree 60.
[0168] The number of leaf nodes to be added (=7) is equal to or greater than the number of symbols whose code length exceeds 4 (=4). Therefore, it can be said that the symbol "a" can provide coding space for all four symbols "e", "f", "g", and "h". In other words, the leaf node 611 corresponding to the symbol "a" satisfies the formula (2) (2 4-1 =8≧1+4).
[0169] The leaf node 621 corresponding to the symbol “b” having the next longest code length does not satisfy the formula (2). 4-2 =4<1+4). Therefore, the dynamic Huffman coder determines the symbol “a” that can provide coding space for all four symbols “e”, “f”, “g”, and “h”.
[0170] The dynamic Huffman encoder assigns the four symbols "e", "f", "g", and "h" to the added leaf nodes 647, 648, 649, and 640, for example, respectively.
[0171] The dynamic Huffman encoder may also remove three redundant leaf nodes 643, 644, and 645 that are not assigned any symbol. The dynamic Huffman encoder removes redundant leaf nodes by sequentially merging binary trees having the redundant leaf nodes 643, 644, and 645. By removing the three leaf nodes 643, 644, and 645, the intermediate node 623 becomes the leaf node 623 to which the symbol "a" is assigned. That is, the code length of the symbol "a" becomes 2 bits.
[0172] FIG. 22 shows the Huffman tree 60 after the code lengths of the four symbols "e", "f", "g", and "h" and the symbol "a" have been changed and the redundant leaf nodes have been removed.
[0173] In this Huffman tree 60, the code length of the four symbols "e", "f", "g", and "h" is 4 bits. Also, the code length of the symbol "a" is 2 bits. Therefore, the Huffman tree 60 is constructed such that the code length of all symbols is equal to or less than the upper limit (4 bits).
[0174] In the modified Huffman tree 60 shown in Figures 21 and 22, the dynamic Huffman encoder increases the code length of the symbol "a" that has the shortest original code length. The shorter the associated code length of a symbol, the more frequently it appears. Therefore, the variable length code corresponding to that symbol appears more frequently in the compressed data. Therefore, the shorter the associated original code length (pre-constraint code length) of a symbol, the greater the impact on compression performance caused by increasing the code length.
[0175] The comparative dynamic Huffman encoder doubles the shortest code length associated with the symbol "a," as shown in Huffman tree 60 of Figures 21 and 22. This significantly reduces the compression performance of the dynamic Huffman encoder.
[0176] In contrast, the dynamic Huffman encoder 21 of the compression device 15 according to the first embodiment increases the code length by giving priority to symbols associated with longer code lengths that are less than the upper limit. In other words, the dynamic Huffman encoder 21 selects symbols that appear less frequently with high priority as symbols for which the code length is to be increased. This makes it possible to suppress a decrease in compression performance even when the code length is restricted to be equal to or less than the upper limit.
[0177] It will be proved below that the Huffman tree 50 in Fig. 13 transformed by the dynamic Huffman encoder 21 of the first embodiment has better compression performance than the Huffman tree 60 in Fig. 22 transformed by the dynamic Huffman encoder of the comparative example. Here, the occurrence frequency of symbol x is denoted as F(x). The total code amount when the dynamic Huffman encoder of the comparative example encodes symbols based on the Huffman tree 60 in Fig. 22 is denoted as CodeBit1. Moreover, the total code amount when the dynamic Huffman encoder 21 of the first embodiment encodes symbols based on the Huffman tree 50 in Fig. 13 is denoted as CodeBit2.
[0178] CodeBit1 is calculated using the following formula (3). CodeBit1= 2×F(a)+2×F(b)+3×(F(c)+F(d)) +4×(F(e)+F(f)+F(g)+F(h)) Equation (3)
[0179] CodeBit2 is calculated using the following formula (4). CodeBit2= 1×F(a)+3×F(b)+4×(F(c)+F(d)) +4×(F(e)+F(f)+F(g)+F(h)) Equation (4)
[0180] The difference between CodeBit1 and CodeBit2 is calculated using the following formula (5). CodeBit1-CodeBit2= F(a)-(F(b)+F(c)+F(d)) Equation (5)
[0181] Furthermore, according to the Huffman tree 50 in FIG. 6 before transformation, the following three relationships hold for the frequency of occurrence of symbols. F(c)≧F(d)+F(e)+F(f)+F(g)+F(h) F(b)≧F(c)+F(d)+F(e)+F(f)+F(g)+F(h) F(a)≧F(b)+F(c)+F(d)+F(e)+F(f)+F(g)+F(h)
[0182] Therefore, the total coding amount CodeBit2 by the dynamic Huffman encoder 21 of the first embodiment is smaller than the total coding amount CodeBit1 by the dynamic Huffman encoder of the comparative example. Therefore, the compression performance based on the Huffman tree 50 of Fig. 13 transformed by the dynamic Huffman encoder 21 of the first embodiment is higher than the compression performance based on the Huffman tree 60 of Fig. 22 transformed by the dynamic Huffman encoder of the comparative example. In other words, the dynamic Huffman encoder 21 of the first embodiment can suppress the deterioration of compression performance compared to the dynamic Huffman encoder of the comparative example when the code length is restricted to be equal to or less than the upper limit value.
[0183] When the dynamic Huffman encoder 21 of the first embodiment restricts the code length of a symbol to be equal to or less than an upper limit, the dynamic Huffman encoder 21 increases the code length of one or more symbols in order from the symbol whose code length is less than the upper limit and is longer. Therefore, the dynamic Huffman encoder 21 of the first embodiment may increase the number of steps (i.e., the number of processing cycles) required to increase the code length of a symbol, compared to the dynamic Huffman encoder of the comparative example that increases the code length of one symbol.
[0184] To deal with the increase in the number of steps, the dynamic Huffman encoder 21 of the first embodiment increases the code length of each of the M symbols in parallel. This allows the dynamic Huffman encoder 21 of the first embodiment to suppress an increase in the number of steps required to increase the code length of the symbols.
[0185] Therefore, when the code length is restricted to be equal to or less than the upper limit, the dynamic Huffman encoder 21 of the first embodiment can suppress a decrease in compression performance while suppressing an increase in the number of steps for increasing the code length of the symbol.
[0186] Second embodiment In the first embodiment, the code length upper limit violation correction unit 323 of the dynamic Huffman encoder 21 selects M symbols whose code length is less than the upper limit in one cycle of processing, and changes the code lengths of the M symbols to the upper limit in parallel. In contrast, in the second embodiment, the code length upper limit violation correction unit 323 selects M symbols whose code length is less than the upper limit in one cycle of processing, and changes the code lengths of the M symbols to the upper limit in parallel, and in another cycle of processing after this cycle of processing, selects N symbols whose code length is less than the upper limit, and changes the code lengths of the N symbols to the upper limit in parallel. Here, N is an integer equal to or less than M.
[0187] The configuration of the compression device 15 according to the second embodiment is similar to that of the compression device 15 according to the first embodiment, and the second embodiment differs from the first embodiment only in the procedure of the process executed by the code length upper limit violation correction unit 323. The following mainly describes the points that differ from the first embodiment.
[0188] The procedure from step S23 to step S25 of the upper limit violation correction process shown in the flowchart of FIG.
[0189] Specifically, as described above, the code length change unit 353 selects M symbols whose code lengths are smaller than the upper limit value in the code length table 42 in ascending order of code length (step S23). The code length change unit 353 changes the code lengths of the selected M symbols to the upper limit value in parallel in the code length table 42 (step S24). Then, the Kraft inequality left-hand side calculation unit 354 calculates the value K of the left-hand side of the Kraft inequality using the code length of the set S of symbols including the changed code length (step S25).
[0190] Hereinafter, execution of the procedure from step S23 to step S25 once will be referred to as one cycle of processing.
[0191] The more times one cycle of processing is executed (i.e., the number of cycles), the more likely it is that redundant leaf nodes will be generated in the constructed Huffman tree 50. This is due to the following two reasons. (1) As the number of cycles increases, the code length of the changed symbol (the code length before the constraint) becomes shorter, so that the number of leaf nodes added by changing the code length to the upper limit value increases. (2) As the number of cycles increases, the value K of the left side of the Kraft inequality approaches 1 or less, so that the number of redundant leaf nodes added by changing the code length to the upper limit is likely to increase.
[0192] Therefore, the code length upper limit violation correction unit 323 may start the number of symbols (parallelism) M, whose code length is changed in parallel in one cycle of processing, from a specific initial value and decrease it as the number of cycles increases. For example, the code length upper limit violation correction unit 323 sets the initial value of M to 4 and executes two cycles of processing. Then, the code length upper limit violation correction unit 323 changes M from 4 to 2 and executes two cycles of processing. Furthermore, the code length upper limit violation correction unit 323 changes M from 2 to 1 and executes the subsequent cycle of processing.
[0193] In this way, the code length upper limit violation correction unit 323 reduces the number of symbols whose code length is changed to the upper limit value in one cycle of processing as the number of cycles increases. That is, in one cycle of processing, the code length upper limit violation correction unit 323 selects M (e.g., 4) symbols whose code length is less than the upper limit value, and changes the code lengths of the M symbols to the upper limit value in parallel. Then, in another cycle of processing after this one cycle of processing, the code length upper limit violation correction unit 323 selects N (e.g., 2) symbols whose code length is less than the upper limit value, and changes the code lengths of the N symbols to the upper limit value in parallel. M is, for example, an integer equal to or greater than 2. N is an integer equal to or less than M.
[0194] This allows the code length upper limit violation correction unit 323 to suppress the number of redundant leaf nodes that may occur in response to a change in code length, and therefore the code length upper limit violation correction unit 323 can reduce the amount of processing required to remove redundant leaf nodes.
[0195] As described above, according to the first and second embodiments, it is possible to suppress a decrease in compression performance when the code length is restricted to an upper limit value or less.
[0196] The coding table generating unit 32 determines a plurality of code lengths associated with the plurality of symbols based on the occurrence frequency of each of the plurality of symbols. When the plurality of symbols includes one or more first symbols associated with one or more first code lengths exceeding the upper limit, the coding table generating unit 32 changes the one or more first code lengths to the upper limit, selects at least one third symbol from one or more second symbols associated with one or more second code lengths less than the upper limit in descending order of associated code length, changes at least one third code length associated with the at least one third symbol to the upper limit, and generates a coding table 43 indicating the plurality of symbols and the plurality of variable length codes associated with the plurality of symbols, using at least the changed one or more first code lengths and at least one third code length. The coding unit 33 converts the symbols into variable length codes using the coding table 43. The code length of each of the plurality of variable length codes is a bit length from 1 to the upper limit.
[0197] In this way, the coding table generating unit 32 selects at least one third symbol from among the multiple symbols, in order of the longest associated code length, from among one or more second symbols associated with one or more second code lengths that are less than the upper limit, and changes at least one third code length associated with at least one third symbol to the upper limit. This makes it possible to suppress degradation of compression performance compared to, for example, selecting one symbol that can provide coding space for all symbols having code lengths that exceed the upper limit and changing the code length of the selected symbol to the upper limit.
[0198] Each of the various functions described in the first and second embodiments may be realized by a circuit (processing circuit). An example of a processing circuit includes a programmed processor, such as a central processing unit (CPU). The processor executes each of the described functions by executing a computer program (a set of instructions) stored in a memory. The processor may be a microprocessor including an electric circuit. Examples of the processing circuit include a digital signal processor (DSP), an application specific integrated circuit (ASIC), a microcontroller, a controller, and other electric circuit components. Each of the other components other than the CPU described in these embodiments may also be realized by a processing circuit.
[0199] Although some embodiments of the present invention have been described, these embodiments are presented as examples and are not intended to limit the scope of the invention. These novel embodiments can be implemented in various other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope and spirit of the invention, and are included in the scope of the invention and its equivalents described in the claims. [Explanation of symbols]
[0200] 1...information processing system, 2...host, 3...memory system, 4...controller, 5...NAND flash memory, 10...bus, 11...host I / F, 12...CPU, 13...NAND I / F, 14...DRAM I / F, 15...compressor, 16...decompressor, 21...dynamic Huffman encoder, 22...packing processor, 31...delay buffer, 32...encoding table generator, 33...encoding unit, 321...frequency table generator, 322...code length determination unit, 323...code length upper limit violation correction unit, 324...canonical Huffman processor, 351...code length sorter, 352...code length clipper, 353...code length change unit, 354...Craft inequality left side calculation unit, 355...termination determination unit, 356...redundant leaf removal unit, 41...frequency table, 42...code length table, 43...encoding table.
Claims
1. determining a plurality of code lengths respectively associated with the plurality of symbols based on the frequency of occurrence of each of the plurality of symbols; an encoding information generating unit that, when the plurality of symbols includes one or more first symbols respectively associated with one or more first code lengths exceeding an upper limit value, changes the one or more first code lengths to the upper limit value, selects at least one third symbol from one or more second symbols respectively associated with one or more second code lengths less than the upper limit value among the plurality of symbols in order of associated code length from the one or more second symbols, changes at least one third code length associated with the at least one third symbol to the upper limit value, and generates encoding information indicating the plurality of symbols and a plurality of variable length codes respectively associated with the plurality of symbols, using at least the changed one or more first code lengths and the at least one third code length; a coding unit that converts symbols into variable length codes using the coding information; A compression device, wherein each of the plurality of variable length codes has a bit length ranging from 1 to the upper limit value.
2. When the at least one third code length is changed to the upper limit value, the encoding information generating unit satisfies a Kraft inequality [0010] Calculate the value of the left hand side of the Kraft inequality based on S represents the plurality of symbols, s denotes a symbol belonging to the plurality of symbols, l(s) denotes the code length associated with symbol s; 2. The compression device according to claim 1, wherein, when the calculated value of the left side of the Kraft inequality is greater than 1, the encoding information generation unit selects at least one fourth symbol that has not yet been selected from the one or more second symbols in order of the longest associated code length, changes at least one fourth code length associated with the at least one fourth symbol to the upper limit value, and repeats the process of calculating the value of the left side of the Kraft inequality until the value of the left side of the Kraft inequality becomes 1 or less.
3. the at least one third symbol is M symbols; The M is an integer of 2 or more, The encoded information generation unit changing M code lengths associated with the M symbols in parallel to the upper limit value; The compression apparatus of claim 2 , further comprising: a step of calculating a value of the left hand side of the Kraft inequality.
4. the at least one fourth symbol is N symbols; N is an integer equal to or smaller than M, The encoded information generation unit changing N code lengths respectively associated with the N symbols to the upper limit in parallel; The compression apparatus of claim 3 , further comprising: a step of calculating a value of the left hand side of the Kraft inequality.
5. 1. A method for controlling a compression device, comprising: determining a plurality of code lengths associated with the plurality of symbols, respectively, based on the occurrence frequency of each of the plurality of symbols by an encoding information generating unit; when the plurality of symbols includes one or more first symbols respectively associated with one or more first code lengths exceeding an upper limit value, the encoding information generating unit changes the one or more first code lengths to the upper limit value, selects at least one third symbol from one or more second symbols respectively associated with one or more second code lengths less than the upper limit value among the plurality of symbols in order of associated code length from the one having the longest code length, changes at least one third code length associated with the at least one third symbol to the upper limit value, and generates encoding information indicating the plurality of symbols and a plurality of variable length codes respectively associated with the plurality of symbols by using at least the changed one or more first code lengths and the at least one third code length; A coding unit converts symbols into variable length codes using the coding information; A control method in which the code length of each of the plurality of variable length codes is a bit length ranging from 1 to the upper limit value.
6. When the at least one third code length is changed to the upper limit value, the coding information generating unit calculates a Craft inequality [0025] calculating a first value of the left hand side of the Kraft inequality based on S represents the plurality of symbols, s denotes a symbol belonging to the plurality of symbols, l(s) denotes the code length associated with symbol s; 6. The control method according to claim 5, wherein, when the calculated value of the left side of the Kraft inequality is greater than 1, the encoding information generation unit selects at least one fourth symbol that has not yet been selected from the one or more second symbols in order of the longest associated code length, changes at least one fourth code length associated with the at least one fourth symbol to the upper limit value, and repeats the process of calculating the value of the left side of the Kraft inequality until the value of the left side of the Kraft inequality becomes 1 or less.
7. the at least one third symbol is M symbols; The M is an integer of 2 or more, changing M code lengths respectively associated with the M symbols to the upper limit value in parallel by the encoding information generating unit; The control method according to claim 6 , further comprising the step of: calculating a value on the left side of the Kraft inequality by the encoded information generating unit.
8. the at least one fourth symbol is N symbols; N is an integer equal to or smaller than M, The encoding information generating unit changes N code lengths respectively associated with the N symbols to the upper limit value in parallel; The control method according to claim 7 , further comprising the step of: calculating a value on the left side of the Kraft inequality by the encoded information generating unit.
Citation Information
Patent Citations
Code generator
JP1993110450A
Method and device for encoding variable length code
JP1995212243A
Apparatus and method for efficient Huffman coding in vlsi
JP2017528015A
Efficient length limiting of compression codes
US20200099958A1
Method of generating a length-constrained huffman code
US6690306B1
