Variable-length coding device and memory system

JP2025035337APending Publication Date: 2025-03-13KIOXIA CORP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
JP2023142321
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-09-01
Publication Date
2025-03-13

Smart Images

  • Figure 2025035337000001_ABST
    Figure 2025035337000001_ABST
Patent Text Reader

Abstract

To realize a variable-length coding device which has a coding length equal to or less than an upper limit value, and can reduce a processing time and a processing resource when a coding language as a completion coding is allocated to a symbol.SOLUTION: According to an embodiment, a variable-length coding device comprises: a coding length determination part; and a coding length restriction part. The coding length determination part determines N coding lengths corresponding to each of N symbols on the basis of a Huffman tree. The coding length restriction part selects at least one first symbol corresponding to a first coding length from the N symbols in the case where the N coding lengths includes the first coding length that is longer than the maximum coding length, selects at least one second symbol corresponded to a second coding length that is less than the maximum coding length from the N symbols, changes the second coding length corresponding to the second symbol into the coding length obtained by adding 1 to the second coding length, and changes the first coding length corresponding to the first symbol to a coding length that is equal to the changed second coding length.SELECTED DRAWING: Figure 18
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] An embodiment of the present invention relates to a variable length coding device and a memory system. [Background technology]

[0002] Dynamic Huffman coding is a variable-length coding method that dynamically generates a code table based on the frequency of occurrence of the symbol to be coded. The code table shows the correspondence between the symbol and the codeword assigned to that symbol. In dynamic Huffman coding, short codewords are assigned to symbols that occur frequently, and long codewords are assigned to symbols that occur infrequently. The codewords (variable-length codes) assigned to the symbols are also called Huffman codes.

[0003] Some data compression standards and data compression software (e.g., gzip) may require that the length (code length) of a codeword assigned to a symbol must not exceed an upper limit. In such cases, in the stage of generating a code table using the occurrence frequency of each symbol, it is necessary to generate a code table so that the length of the codeword assigned to a symbol is equal to or less than the upper limit.

[0004] Furthermore, data compression standards and data compression software may specify that the codewords assigned to symbols in dynamic Huffman coding are perfect codes. A perfect code means that the dynamic Huffman coding is based on a Huffman tree in which every intermediate node has two child nodes. In other words, a perfect code means that there is no waste in the code length of the assigned codeword. [Prior art documents] [Patent documents]

[0005] [Patent Document 1] US Patent Application Publication No. 2022 / 0294469 [Non-patent literature]

[0006] [Non-Patent Document 1] L. Peter Deutsch, “DEFLATE Compressed Data Format Specification version 1.3”, [online], RFC1951, May 1996, [Retrieved May 24, 2023], Internet<URL:https: / / dl.acm.org / doi / pdf / 10.17487 / RFC1951> Summary of the Invention [Problem to be solved by the invention]

[0007] The problem to be solved by the present invention is to provide a variable-length coding device and a memory system that can reduce processing time and processing resources when a codeword that has a code length equal to or less than an upper limit and is a perfect code is assigned to a symbol. [Means for solving the problem]

[0008] According to an embodiment, a variable length coding device includes a frequency table generating unit, a Huffman tree generating unit, a code length determining unit, a code length constraining unit, a code assigning unit, and a coding unit. The frequency table generating unit generates a frequency table indicating N symbols and N occurrence frequencies associated with the N symbols based on the occurrence frequency of each of the input symbols. The Huffman tree generating unit generates a Huffman tree based on the frequency table. The code length determining unit determines N code lengths corresponding to the N symbols based on the Huffman tree. When the N code lengths include a first code length longer than the maximum code length, the code length constraining unit selects at least one first symbol corresponding to the first code length from the N symbols, selects at least one second symbol corresponding to a second code length less than the maximum code length from the N symbols, changes the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length, and changes the first code length corresponding to the first symbol to a code length equal to the changed second code length. The code assignment unit determines N variable length codes to be assigned to the N symbols, respectively, based on the N code lengths. The encoding unit converts each of the input symbols into a variable length code, based on the N variable length codes assigned to the N symbols, respectively. N is an integer equal to or greater than 2. The variable length codes into which the input symbols are converted have bit lengths ranging from 1 bit length to the maximum code length. [Brief description of the drawings]

[0009] [Figure 1] 1 is a block diagram showing an example of the configuration of an information processing system including a variable-length coding device according to a first embodiment. [Diagram 2] FIG. 13 is a block diagram showing an example of the configuration of a code table generation unit according to a comparative example. [Diagram 3] 11 is a flowchart showing the procedure of a Huffman tree generation process executed in a code table generation unit according to a comparative example. [Figure 4] FIG. 13 is a diagram showing an example of the configuration of a frequency table used in a code table generating unit according to a comparative example. [Diagram 5] 11 is a diagram showing an example of a Huffman tree generated in a code table generation unit according to a comparative example. [Figure 6] 11 is a diagram showing an example of a code length determined in a code table generation unit according to a comparative example. [Figure 7] 11 is a flowchart showing a procedure of a maximum code length constraint process executed in a code table generation unit according to a comparative example. [Figure 8] 6 is a diagram showing a modification of the Huffman tree in FIG. 5 in a code table generation unit according to a comparative example. [Figure 9] 9 is a diagram showing a modification of the Huffman tree in FIG. 8 in a code table generation unit according to a comparative example. [Figure 10] 10 is a diagram showing a modification of the Huffman tree in FIG. 9 in a code table generation unit according to a comparative example. [Figure 11] 11 is a diagram showing a modification of the Huffman tree in FIG. 10 in a code table generation unit according to a comparative example. [Figure 12] 1 is a block diagram showing an example of the configuration of a variable-length coding device according to a first embodiment. [Figure 13] FIG. 2 is a diagram showing an example of a frequency table (0th frequency table) generated in the variable-length coding device according to the first embodiment. [Figure 14] FIG. 4 is a diagram showing an example of a sorted frequency table (first frequency table) in the variable-length coding device according to the first embodiment. [Figure 15] FIG. 1 shows an example of (A) a first frequency table, and (B) an example of a first partial table and (C) an example of a second partial table into which the first frequency table is divided, used in a variable-length coding device according to a first embodiment. [Figure 16] 2 is a diagram showing an example of a Huffman tree constructed in the variable-length coding device according to the first embodiment; [Figure 17] 3 is a diagram showing an example of a subtree of merge symbols used in the variable-length coding device according to the first embodiment; FIG. [Figure 18] 2 is a block diagram showing an example of the configuration of a maximum code length constraint unit included in the variable-length coding device according to the first embodiment. FIG. [Figure 19] 3A and 3B are diagrams showing examples of non-representative symbols and representative symbols used in the variable-length coding device according to the first embodiment. [Figure 20]2 is a diagram showing an example of a Huffman tree generated in the variable-length coding device according to the first embodiment; [Figure 21] 21 is a diagram showing a modification of the Huffman tree in FIG. 20 in the variable-length coding device according to the first embodiment. [Figure 22] 22 is a diagram showing a modification of the Huffman tree in FIG. 21 in the variable-length coding device according to the first embodiment. [Diagram 23] 23 is a diagram showing a modification of the Huffman tree in FIG. 22 in the variable-length coding device according to the first embodiment. [Figure 24] 5 is a flowchart showing an example of a procedure of maximum code length constraint processing executed in the variable length coding device according to the first embodiment. [Diagram 25] 5 is a flowchart showing an example of a procedure of a first code length change process executed in the variable length coding device according to the first embodiment. [Figure 26] 3 is a diagram showing an example of a pseudo program for allocating code bit strings to symbols, which is executed in the variable-length coding device according to the first embodiment. FIG. [Figure 27] 3A and 3B are diagrams showing examples of non-representative symbols and representative symbols used in the variable-length coding device according to the first embodiment. [Figure 28] FIG. 11 is a diagram showing an example of a Huffman tree generated in the variable-length coding device according to the second embodiment. [Figure 29] FIG. 11 is a block diagram showing an example of the configuration of a maximum code length constraint unit included in a variable-length coding device according to a second embodiment. [Diagram 30] FIG. 11 is a diagram showing another example of a Huffman tree generated in the variable-length coding device according to the second embodiment. [Diagram 31] 31 is a diagram showing a modification of the Huffman tree in FIG. 30 in the variable-length coding device according to the second embodiment. [Diagram 32] 32 is a diagram showing a modification of the Huffman tree in FIG. 31 in the variable-length coding device according to the second embodiment. [Diagram 33] 33 is a diagram showing a modification of the Huffman tree in FIG. 32 in the variable-length coding device according to the second embodiment. [Diagram 34]34 is a diagram showing a modification of the Huffman tree in FIG. 33 in the variable-length coding device according to the second embodiment. [Diagram 35] 10 is a flowchart showing an example of a procedure of maximum code length constraint processing executed in a variable length coding device according to the second embodiment. [Diagram 36] 10 is a flowchart showing an example of a procedure of swapping and code length changing processing executed in a variable-length coding device according to a second embodiment. [Figure 37] FIG. 13 is a block diagram showing an example of the configuration of a maximum code length constraint unit included in a variable-length coding device according to a third embodiment. [Figure 38] FIG. 11 is a diagram showing an example of a Huffman tree generated in the variable-length coding device according to the third embodiment. [Figure 39] 39 is a diagram showing a modification of the Huffman tree in FIG. 38 in the variable-length coding device according to the third embodiment. [Diagram 40] 40 is a diagram showing a modification of the Huffman tree in FIG. 39 in the variable-length coding device according to the third embodiment. [Diagram 41] 13 is a flowchart showing an example of a procedure of maximum code length constraint processing executed in the variable-length coding device according to the third embodiment. [Diagram 42] 13 is a flowchart showing an example of a procedure of a second code length change process executed in the variable length coding device according to the third embodiment. [Diagram 43] FIG. 13 is a diagram showing a first pattern of a Huffman tree assumed in a specific case in the variable-length coding device according to the third embodiment. [Diagram 44] FIG. 13 is a diagram showing a second pattern of a Huffman tree assumed in a specific case in the variable-length coding device according to the third embodiment. [Diagram 45] FIG. 13 is a diagram showing a third pattern of a Huffman tree assumed in a specific case in the variable-length coding device according to the third embodiment. [Figure 46] FIG. 13 is a diagram showing a fourth pattern of a Huffman tree assumed in a specific case in the variable-length coding device according to the third embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0010] Hereinafter, an embodiment will be described with reference to the drawings.

[0011] (First embodiment) 1 shows an example of the configuration of an information processing system including a code table generating device according to the first embodiment. The information processing system 1 includes a host device 2 (hereinafter, referred to as a host 2) and a memory system 3.

[0012] 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).

[0013] 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.

[0014] 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.

[0015] The interface for connecting the host 2 and the memory system 3 is SCSI, Serial Attached SCSI (SAS), ATA (AT Attachment), Serial ATA (SATA), PCI Express TM (PCIe TM ), Ethernet TM , Fiber channel, NVM Express TM (NVMe TM ) etc.

[0016] 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).

[0017] The memory system 3 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.

[0018] The DRAM 6 is a volatile memory. In a RAM such as the DRAM 6, for example, a storage area for firmware (FW) and a cache area for a logical-physical address conversion table are provided.

[0019] 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.

[0020] 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.

[0021] The controller 4 includes, for example, 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 variable length coding device 15. The host I / F 11, the CPU 12, the NAND I / F 13, the DRAM I / F 14, and the variable length coding device 15 may be interconnected via a bus 10.

[0022] 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.

[0023] The controller 4 functions as a memory controller configured to control the NAND flash memory 5 .

[0024] 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, and (2) processing for concealing the difference between page-based data read / write operations and block-based data erase operations. The block management includes bad block management, wear leveling, and garbage collection.

[0025] A logical address is an address used by the host 2 to address a storage area of ​​the memory system 3. 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 storage location in the NAND flash memory 5 where the 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.

[0026] 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.

[0027] 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 includes a circuit that receives various commands from the host 2, such as input / output (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 includes a circuit that transmits responses and data according to the commands to the host 2.

[0028] The DRAM I / F 14 functions as a DRAM control circuit configured to control access to the DRAM 6 .

[0029] The CPU 12 is a processor configured to control the host I / F 11, the NAND I / F 13, the DRAM I / F 14, and the variable length coding device 15. 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.

[0030] The variable length coding device 15 is a dynamic Huffman coding unit that compresses data to be written to the NAND flash memory 5 by coding the data. For example, the CPU 12 inputs write data received in response to a write command received from the host 2 as plain text data to the variable length coding device 15. The variable length coding device 15 encodes the plain text data input from the CPU 12. The variable length coding device 15 has a configuration for implementing, for example, dynamic Huffman coding in order to compress data.

[0031] Dynamic Huffman coding is a variable-length coding method that dynamically generates a code table (encoding table) using the frequency of occurrence of symbols to be coded. The code table includes information indicating N types of symbols and N variable-length codes (codewords) respectively associated with the N types of symbols. N is, for example, an integer equal to or greater than 2. In dynamic Huffman coding, short codewords are assigned to symbols that occur frequently, and long codewords are assigned to symbols that occur infrequently. The variable-length coding device 15 converts the input symbols into codewords according to this assignment. In other words, the codewords obtained by the conversion are variable-length codes. The symbols are, for example, fixed-length data.

[0032] The symbol to be encoded is one of N types of symbols. In the following, the case where N is 256 will be mainly illustrated.

[0033] Each of the 256 types of symbols is, for example, 1 byte of data. In this case, the 256 types of symbols correspond to values ​​from 0 to 255, respectively. Any value from 0 to 255 corresponding to each of the 256 types of symbols is also called a symbol number. Note that the number of types of symbols and the values ​​corresponding to the symbols are merely examples, and may be changed according to the characteristics of the data including the symbols to be encoded.

[0034] The variable-length coding device 15 includes a code table generator 32. The code table generator 32 is a module that generates a code table for converting symbols into variable-length codes. The code table generator 32 may be a device provided within the variable-length coding device 15, or may be a part of a circuit that realizes the variable-length coding device 15.

[0035] Now, generation of a code table in the code table generation unit 32A according to a comparative example will be described with reference to FIGS.

[0036] 2 is a block diagram showing a configuration of a code table generation unit 32A according to a comparative example. The code table generation unit 32A includes, for example, a frequency table generation unit 321A, a frequency sorting unit 322A, a Huffman tree generation unit 324A, a code length determination unit 325A, a maximum code length constraint unit 326A, and a code assignment unit 328A.

[0037] The frequency table generating unit 321A generates a frequency table 40A (hereinafter referred to as the 0th frequency table 40A) using the input symbols. The 0th frequency table 40A is a table showing a plurality of symbols and the occurrence frequency of each of the plurality of symbols. The frequency table generating unit 321A sends the 0th frequency table 40A to the frequency sorting unit 322A.

[0038] The frequency sorting unit 322A sorts the entries in the 0th frequency table 40A in descending order of appearance frequency. The frequency table obtained by sorting is called the first frequency table 41A. The frequency sorting unit 322A sends the first frequency table 41A to the Huffman tree generation unit 324A.

[0039] The Huffman tree generator 324A generates a Huffman tree using the first frequency table 41A.

[0040] FIG. 3 is a flowchart showing an example of a procedure for a Huffman tree generation process executed by the Huffman tree generation unit 324A.

[0041] First, the Huffman tree generator 324A adds all symbols whose occurrence frequency in the first frequency table 41A is greater than 0 as leaf nodes on the Huffman tree (step S11). That is, the Huffman tree generator 324A generates a Huffman tree including leaf nodes corresponding to the number of symbols whose occurrence frequency in the first frequency table 41A is greater than 0. The number of symbols that are the subject of Huffman tree generation by the Huffman tree generator 324A (i.e., the number of leaf nodes of the generated Huffman tree) is a maximum of N.

[0042] Next, the Huffman tree generator 324A selects node A with the lowest occurrence frequency and node B with the next lowest occurrence frequency from among all leaf nodes and intermediate nodes that do not have a parent node in the Huffman tree (step S12). The Huffman tree generator 324A adds an intermediate node having the selected node A and node B as its children to the Huffman tree (step S13). Then, the Huffman tree generator 324A sets the sum of the occurrence frequencies of node A and node B as the occurrence frequency of the added intermediate node (step S14).

[0043] The Huffman tree generator 324A determines whether 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 Huffman tree generator 324A proceeds to step S12. That is, the Huffman tree generator 324A 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.

[0044] If the total number of leaf nodes and intermediate nodes that do not have a parent node in the Huffman tree is less than two (No in step S15), Huffman tree generator 324A ends the Huffman tree generation process.

[0045] By the above Huffman tree generation process, the Huffman tree generation unit 324A can generate a Huffman tree. The generated Huffman tree includes multiple leaf nodes corresponding to multiple symbols whose occurrence frequency is greater than 0. The Huffman tree generation unit 324A builds the Huffman tree from the bottom up, starting from the leaf nodes corresponding to symbols whose occurrence frequency is low.

[0046] Returning to Fig. 2, the Huffman tree generating unit 324A sends the generated Huffman tree to the code length determining unit 325A.

[0047] The code length determination unit 325A uses the Huffman tree received from the Huffman tree generation unit 324A to determine the code length of each of the multiple symbols. The depth of a leaf node starting from the root node (i.e., the number of edges traced from the root node to the leaf node) corresponds to the code length of the corresponding symbol. The further away from the root node, the deeper the depth of each node is, and the longer the code length of the corresponding symbol is. Thus, the code length determination unit 325A can determine the code length of the symbol using the Huffman tree. The code length determination unit 325A sends the determined code length of each of the multiple symbols to the maximum code length constraint unit 326A.

[0048] In some data compression standards, it is specified that the code length is restricted so as not to exceed an upper limit. In such a case, the maximum code length restricting unit 326A performs a process of restricting the code length to an upper limit or less (hereinafter also referred to as a maximum code length restricting process). Specifically, the maximum code length restricting unit 326A restricts the code length of each of the multiple symbols determined by the code length determining unit 325A to an upper limit or less. The maximum code length restricting unit 326A sends the code length of each of the multiple symbols restricted to an upper limit or less to the code assigning unit 328A. Hereinafter, the upper limit of the code length is also referred to as a maximum code length. A specific example of the maximum code length restricting process will be described later with reference to FIG. 7 to FIG. 11.

[0049] The code allocation unit 328A generates a code table using the code lengths of the multiple symbols received from the maximum code length constraint unit 326A. The code allocation unit 328A generates the code table, for example, by the canonical Huffman method. 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. A specific example of generating a code table by the canonical Huffman method will be described later with reference to FIG. 26.

[0050] A specific example in which the code length is determined using the first frequency table 41A will be described with reference to FIGS.

[0051] 4 shows an example of the configuration of a first frequency table 41A generated by the frequency table generating unit 321A and sorted by the frequency sorting unit 322. The first frequency table 41A 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.

[0052] 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.

[0053] 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 first frequency table 41A and the values ​​shown in the other fields of the other tables.

[0054] In the example shown in FIG. 4, the frequency of occurrence of symbol “a” is 120. The frequency of occurrence of symbol “b” is 60. The frequency of occurrence of symbol “c” is 29. The frequency of occurrence of symbol “d” is 14. The frequency of occurrence of symbol “e” is 4. The frequencies of occurrence of symbols “f” and “g” are 3. The frequency of occurrence of symbol “h” is 2. The frequencies of occurrence of symbols “i” and “j” are 0.

[0055] 5 shows an example of a Huffman tree 50 generated by the Huffman tree generator 324A. Here, a case is illustrated in which the Huffman tree generator 324A generates the Huffman tree 50 using the first frequency table 41A shown in FIG.

[0056] First, the Huffman tree generator 324A selects eight symbols "a", "b", "c", "d", "e", "f", "g", and "h" whose occurrence frequencies are greater than 0 from the first frequency table 41A. The Huffman tree generator 324A 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.

[0057] Huffman tree generator 324A selects leaf node 564 of symbol "h" with the lowest occurrence frequency and leaf node 563 of symbol "g" with the next lowest occurrence frequency from all leaf nodes and all intermediate nodes that do not have a parent node in Huffman tree 50. Huffman tree generator 324A then adds intermediate node 552, which has selected leaf node 564 and leaf node 563 as its children, to Huffman tree 50. Huffman tree generator 324A sets the sum of the occurrence frequency of leaf node 564 and the occurrence frequency of leaf node 563 (=2+3=5) as the occurrence frequency of intermediate node 552.

[0058] Next, Huffman tree generator 324A selects leaf node 562 of symbol "f" with the lowest occurrence frequency and leaf node 561 of symbol "e" with the next lowest occurrence frequency from all leaf nodes and all intermediate nodes that do not have a parent node in Huffman tree 50. Then, Huffman tree generator 324A adds intermediate node 551 having selected leaf node 562 and leaf node 561 as children to Huffman tree 50. Huffman tree generator 324A sets the occurrence frequency of 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).

[0059] Next, the Huffman tree generator 324A selects intermediate node 552 with the lowest occurrence frequency and intermediate node 551 with the next lowest occurrence frequency from among all leaf nodes and all intermediate nodes that do not have a parent node in the Huffman tree 50. Then, the Huffman tree generator 324A adds intermediate node 542, which has the selected intermediate node 552 and intermediate node 551 as its children, to the Huffman tree 50. The Huffman tree generator 324A sets the occurrence frequency of the added intermediate node 542 to the sum of the occurrence frequency of intermediate node 552 and the occurrence frequency of intermediate node 551 (=5+7=12).

[0060] In the same manner, Huffman tree generator 324A repeatedly adds intermediate nodes until the total number of leaf nodes and intermediate nodes without parent nodes in Huffman tree 50 is reduced to one or less (i.e., until root node 501 is the only node without a parent node), thereby constructing Huffman tree 50 shown in FIG.

[0061] The code length determination unit 325A uses the constructed Huffman tree 50 to determine a plurality of code lengths associated with a plurality of symbols, respectively. Specifically, the code length determination unit 325A 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 a 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. Thus, 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. Thus, the code length of the symbol "h" is 6 bits.

[0062] FIG. 6 shows an example of the code length for each symbol determined by the code length determination unit 325A using the Huffman tree 50 shown in FIG.

[0063] Specifically, the code length of symbol "a" is 1 bit. The code length of symbol "b" is 2 bits. The code length of symbol "c" is 3 bits. The code length of symbol "d" is 4 bits. Also, the code length of symbols "e", "f", "g", and "h" are each 6 bits.

[0064] 7 is a flowchart showing an example of the procedure of the maximum code length constraint process executed by the maximum code length constraint unit 326 A. The maximum code length constraint process is a process for constraining the code length for each symbol determined by the code length determination unit 325 A to be equal to or less than the maximum code length.

[0065] First, the maximum code length constraint unit 326A changes the code length of all symbols longer than the maximum code length to the maximum code length (step S21). The maximum code length constraint unit 326A selects P symbols whose code lengths are less than the maximum code length, starting from the symbol with the longest code length (step S22). P is an integer equal to or greater than 1. Then, the maximum code length constraint unit 326A changes the code lengths of the selected P symbols to the maximum code length in parallel (step S23). The larger P is, the more symbols the code length of which is changed to the maximum code length at one time. Hereinafter, P is also referred to as the degree of parallelism.

[0066] Next, the maximum code length constraint unit 326A calculates the value K of the left side of the Kraft inequality using the code lengths of all symbols including the changed code length (step S24). The Kraft inequality is expressed by the following equation (1).

[0067]

number

[0068] If the code length l(s) of the symbol s∈AllSymbol satisfies the Kraft inequality, it is guaranteed that a valid code table exists. In other words, encoding and decoding can be performed correctly using a code table generated based on the code length l(s) of the symbol s∈AllSymbol.

[0069] On the other hand, if the code length l(s) of the symbol s∈AllSymbol does not satisfy the Kraft inequality, there is no valid code table. Therefore, encoding and decoding cannot be performed correctly using a code table generated based on the code length l(s) of the symbol s∈AllSymbol.

[0070] The maximum code length constraint unit 326A determines whether the value K of the left side of the calculated Kraft inequality is less than or equal to 1 (step S25). In other words, the maximum code length constraint unit 326A determines whether the code length l(s) of the symbol s∈AllSymbol satisfies the Kraft inequality.

[0071] If the value K of the left side of the Kraft inequality is greater than 1 (No in step S25), the process by the maximum code length constraining unit 326A returns to step S22. That is, the maximum code length constraining unit 326A selects P symbols having code lengths shorter than the maximum code length that have not yet been selected, in order from the longest corresponding code length, changes the code lengths of the selected P symbols to the maximum code length, and calculates the value K of the left side of the Kraft inequality, repeatedly performing the process until the code length l(s) of the symbol s∈AllSymbol satisfies the Kraft inequality (that is, until the value of the left side of the Kraft inequality becomes 1 or less).

[0072] If the value K of the left side of the Kraft inequality is equal to or less than 1 (Yes in step S25), the maximum code length constraining unit 326A ends the maximum code length constraining process.

[0073] By the above maximum code length constraint process, the maximum code length constraint unit 326A can change the code length longer than the maximum code length associated with the symbol to the maximum code length. The code lengths of all symbols including the changed code length no longer satisfy the Kraft inequality. Therefore, the maximum code length constraint unit 326A further selects P symbols corresponding to code lengths shorter than the maximum code length, and repeats the process of changing the code lengths of the selected P symbols to the maximum code length until the Kraft inequality is satisfied. In this way, the maximum code length constraint unit 326A can associate all symbols with code lengths that are equal to or shorter than the maximum code length and that satisfy the Kraft inequality.

[0074] 8 to 10, the operation of the maximum code length constraint unit 326A constraining the code length of a symbol to the maximum code length will be described using a modified example of the Huffman tree 50 in FIG. 5. The Huffman tree 50 in FIG. 5 is a Huffman tree constructed by the Huffman tree generation unit 324A based on the frequency of occurrence of the symbol without considering the maximum code length. The maximum code length constraint unit 326A modifies the Huffman tree 50 in FIG. 5 so as to satisfy the maximum code length constraint and the Kraft inequality. Here, it is assumed that the maximum code length is 4 bits. Also, for ease of understanding, it is assumed that the parallelism P is 1.

[0075] FIG. 8 shows an example in which the maximum code length constraint unit 326A determines symbols whose code length is longer than the maximum code length and symbols whose code length is extended to the maximum code length.

[0076] Specifically, the maximum code length constraining unit 326A determines four symbols "e", "f", "g", and "h" (i.e., leaf nodes 561, 562, 563, and 564) whose code lengths are longer than 4. The maximum code length constraining unit 326A changes the code lengths of the determined four symbols "e", "f", "g", and "h" from 6 bits to 4 bits.

[0077] Furthermore, the maximum code length constraint unit 326A 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 maximum code length constraint unit 326A changes the code length of the determined symbol “c” from 3 bits to 4 bits.

[0078] FIG. 9 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 modifications described above.

[0079] 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.

[0080] 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).

[0081] Therefore, the maximum code length constraining unit 326A further determines a leaf node that extends the code length to the maximum code length. Specifically, the maximum code length constraining unit 326A 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 maximum code length constraining unit 326A changes the code length of the determined symbol "b" from 2 bits to 4 bits.

[0082] FIG. 10 shows a Huffman tree 50 in which the code length of the symbol "b" has been changed.

[0083] 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 521 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).

[0084] The Huffman tree 50 obtained by the maximum code length constraint unit 326A may include a redundant leaf node 548 to which no symbol is assigned. In this case, the maximum code length constraint unit 326A further removes the redundant leaf node 548 to which no symbol is assigned.

[0085] FIG. 11 shows the Huffman tree 50 with the redundant leaf nodes 548 removed. A binary tree consisting of redundant leaf node 548, leaf node 547, and intermediate node 533 is merged to become leaf node 533. The process of merging binary trees having redundant leaf nodes is also simply referred to as a merge process. 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.

[0086] This Huffman tree 50 is a valid Huffman tree. 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). In other words, since the Huffman tree 50 is a Huffman tree in which all intermediate nodes have two child nodes, a Huffman code determined based on the Huffman tree 50 is a complete code.

[0087] Thus, in the code table generating unit 32A of the comparative example, a merge process may be required to construct the Huffman tree 50, determine the code length of each symbol, and constrain the code length to the maximum code length. This merge process may be required not only to increase the coding efficiency of the Huffman code, but also to ensure that the Huffman code is a perfect code. For example, this is the case when the compression standard or compression software requires that the Huffman code used is a perfect code. In the maximum code length constraining unit 326A, at the time when the maximum code length constraining process shown in FIG. 7 is completed, it is not possible to guarantee that the Huffman code assigned based on the code length of each symbol is a perfect code, and an additional merge process may be required. Therefore, the code table generating unit 32A of the comparative example may require additional processing time and additional processing resources (for example, hardware costs).

[0088] In contrast, the variable-length coding device 15 according to the present embodiment realizes maximum code length constraint processing that guarantees perfect codes. In the maximum code length constraint processing, the code table generation unit 32 of the variable-length coding device 15 restricts the code length of a symbol to be equal to or less than the maximum code length, and guarantees that the Huffman code assigned based on the code length of each symbol is a perfect code.

[0089] For example, when the N code lengths corresponding to the N symbols determined based on the Huffman tree include a first code length longer than the maximum code length, the code table generation unit 32 constrains the first code length to be equal to or less than the maximum code length in the maximum code length constraint process. Specifically, the code table generation unit 32 selects at least one first symbol corresponding to the first code length from the N symbols. The code table generation unit 32 selects at least one second symbol corresponding to a second code length less than the maximum code length from the N symbols. The code table generation unit 32 changes the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length. Then, the code table generation unit 32 changes the first code length corresponding to the first symbol to a code length equal to the changed second code length.

[0090] That is, the code table generator 32 selects a first symbol that does not satisfy the code length constraint that the first symbol is equal to or less than the maximum code length, and selects another second symbol that satisfies the code length constraint. The code table generator 32 then sets the leaf node on the Huffman tree corresponding to the second symbol as an intermediate node, and connects the leaf nodes to which the first and second symbols are respectively assigned as child nodes of the intermediate node. This makes it possible to proceed with the process of satisfying the code length constraint while maintaining the Huffman code assigned based on the Huffman tree as a perfect code.

[0091] Therefore, when the maximum code length constraint process is completed, the code table generator 32 can guarantee that the Huffman code assigned based on the code length of each symbol is a perfect code. Therefore, the code table generator 32 of this embodiment can reduce processing time and processing resources compared to the code table generator 32A of the comparative example that additionally performs a merge process.

[0092] 12 shows an example of the configuration of the variable-length coding device 15 of this embodiment. The variable-length coding device 15 includes, for example, a buffer unit 31, a code table generation unit 32, and a variable-length coding unit 33.

[0093] The buffer unit 31 stores (buffers) symbols input to the variable-length coding device 15. The buffer unit 31 delays the stored symbols, for example, until a specific timing, and sends them to the variable-length coding unit 33. The specific timing is, for example, the timing when the generation of the code table by the code table generation unit 32 is completed.

[0094] The code table generator 32 generates a code table by using the symbols input to the variable-length coding device 15. The code table 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.

[0095] More specifically, the code table generator 32 generates a code table based on the occurrence frequency of a plurality of symbols included in a specific unit of input data. The specific unit may be a specific amount of data, or a specific group such as a file. When a specific group is used as a unit, the code table generator 32 recognizes the specific unit of input data by detecting data indicating the end of the input data. The code table generator 32 sends the generated code table to the variable-length encoder 33.

[0096] The variable-length coding unit 33 converts the symbols sent by the buffer unit 31 into a variable-length code (code bit string) by using the code table sent by the code table generation unit 32. The variable-length coding unit 33 outputs the variable-length code obtained by the conversion as compressed data.

[0097] With the above configuration, the variable-length coding device 15 can convert the input symbol into a variable-length code by dynamic Huffman coding. For example, when the input symbol is data requested by the host 2 to be written to the NAND flash memory 5, the CPU 12 writes compressed data including one or more variable-length codes and a compressed code table to the NAND flash memory 5 via the NAND I / F 13.

[0098] 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 variable length coding unit 33, 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. That is, the CPU 12 is configured to write data based on the compressed data output from the variable length coding device 15 to the NAND flash memory 5 via the NAND I / F 13. When the CPU 12 receives a read command from the host 2 via the host I / F 11, for example, the CPU 12 reads data based on the read command from the NAND flash memory 5 via the NAND I / F 13. The ECC decoder executes an error correction process on the read data. The read data on which the error correction process has been executed is input to the expander by the CPU 12 as compressed data, and the expander expands the input compressed data. In response to a read command from the host 2, the CPU 12 transmits the decompressed data to the host 2. That is, in response to a read command from the host 2, the CPU 12 is configured to decompress data based on the data read from the NAND flash memory 5, and transmit the decompressed data to the host 2.

[0099] Note that part or all of the variable length coding device 15 may be realized as hardware such as a circuit, or may be realized as a program (that is, software) executed by at least one processor.

[0100] Next, a specific configuration of the code table generation unit 32 will be described. The code table generation unit 32 includes, for example, a frequency table generation unit 321, a frequency sorting unit 322, a symbol merging unit 323, a Huffman tree generation unit 324, a code length determination unit 325, a maximum code length constraint unit 326, a representative symbol expansion unit 327, and a code assignment unit 328.

[0101] The frequency table generating unit 321 generates a frequency table 40 (hereinafter referred to as the 0th frequency table 40) based on the occurrence frequency of each input symbol. For example, the frequency table generating unit 321 counts the occurrence frequency of each input symbol to generate the 0th frequency table 40. For example, the frequency table generating unit 321 generates the 0th frequency table 40 every time 4096 symbols are input. The 0th frequency table 40 is a table indicating a plurality of symbols and a plurality of occurrence frequencies (for example, the number of occurrences) associated with each of the plurality of symbols. The frequency table generating unit 321 sends the 0th frequency table 40 to the frequency sorting unit 322.

[0102] The frequency sorting unit 322 sorts the entries in the 0th frequency table 40 in descending order of appearance frequency. The frequency table obtained by sorting is called a first frequency table 41. The frequency sorting unit 322 sends the first frequency table 41 to the symbol merging unit 323.

[0103] Fig. 13 shows an example of the 0th frequency table 40 generated by the frequency table generating unit 321. The 0th frequency table 40 includes N entries corresponding to N types of symbols. The N entries are assigned indexes from 0 to N-1 in order from the top. Thus, each of the N entries can be identified by its index. In the example shown in Fig. 13, N is 256. Each entry includes a symbol number field and an occurrence frequency field.

[0104] In an entry corresponding to a certain symbol, the symbol number field indicates the symbol number corresponding to that symbol, and the occurrence frequency field indicates the frequency (e.g., the number of times) that the corresponding symbol occurs in one or more symbols included in the input data.

[0105] In this way, each entry indicates a combination of a symbol number and an occurrence frequency, which is also referred to as a <symbol number, occurrence frequency> pair.

[0106] 13, for example, an entry with an index of 0 indicates that the occurrence frequency of a symbol with a symbol number of 0 is 3. For example, an entry with an index of 1 indicates that the occurrence frequency of a symbol with a symbol number of 1 is 16. Also, for example, an entry with an index of 253 indicates that the occurrence frequency of a symbol with a symbol number of 253 is 30.

[0107] 14 shows an example of the first frequency table 41 acquired by the frequency sorting unit 322. The first frequency table 41 is a table in which the 256 entries in the 0th frequency table 40 are rearranged in descending order of appearance frequency. The 256 entries in the first frequency table 41 are assigned indexes from 0 to 255 in order from the top.

[0108] 14, for example, an entry with an index of 0 indicates that the occurrence frequency of a symbol with symbol number 64 is 50. For example, an entry with an index of 1 indicates that the occurrence frequency of a symbol with symbol number 253 is 30. Also, for example, an entry with an index of 255 indicates that the occurrence frequency of a symbol with symbol number 8 is 0.

[0109] In this way, in the first frequency table 41, the 256 entries are arranged in descending order of appearance frequency.

[0110] Return to Figure 12.

[0111] When constructing a Huffman tree, the symbol merging unit 323 divides L symbols among all symbols (i.e., N symbols) included in the first frequency table 41 into M symbol sets, and performs processing for regarding each of the M symbol sets as one symbol (hereinafter referred to as a representative symbol). The symbol merging unit 323 generates M representative symbols representing each of the M symbol sets. L is an integer equal to or greater than 1. M is an integer equal to or greater than 1. In the following, for ease of explanation, the case where M is 1 will be mainly described. In this case, the symbol merging unit 323 performs processing for regarding L symbols among all symbols included in the first frequency table 41 as one representative symbol. Note that, when M is 2 or greater, the processing for one representative symbol described below is performed on each of the M representative symbols. The symbol merging unit 323 includes, for example, a symbol distributing unit 351, a representative symbol frequency estimating unit 352, a merge symbol number counting unit 353, and a merge symbol addition code length determining unit 354.

[0112] The symbol distribution unit 351 divides the first frequency table 41 into a first partial table 431 and a second partial table 432. The first partial table 431 includes, for example, top H entries in descending order of frequency of occurrence among the N entries included in the first frequency table 41. H is an integer equal to or greater than 1. The sum of H and L is N. The H entries are entries of H symbols with high frequency of occurrence. The H symbols with high frequency of occurrence are also referred to as top symbols. The second partial table 432 includes, for example, the remaining L (=NH) entries obtained by excluding the top H entries from the N entries included in the first frequency table 41. The L entries are entries of L symbols with low frequency of occurrence. The L entries are more likely to include a symbol with a frequency of 0 than the top H entries. The L symbols with low frequency of occurrence are also referred to as bottom symbols. The L bottom symbols are considered as one representative symbol when constructing a Huffman tree. In other words, the representative symbol is a symbol that represents the L lower symbols. In contrast, each of the H upper symbols represents the upper symbol itself and does not represent any of the other symbols. For this reason, the upper symbols are also called non-representative symbols.

[0113] For example, the symbol distribution unit 351 may determine to include in the second partial table 432 the bottom L entries when the N entries included in the first frequency table 41 are sorted in descending order of frequency of occurrence, and then determine to include in the first partial table 431 the remaining entries obtained by excluding the L entries from the N entries. Alternatively, the symbol distribution unit 351 may determine to include in the first partial table 431 the top H entries when the N entries included in the first frequency table 41 are sorted in descending order of frequency of occurrence, and then determine to include in the second partial table 432 the remaining entries obtained by excluding the H entries from the N entries. In other words, it is possible to arbitrarily set whether to give priority to the entries to be included in the second partial table 432 or the entries to be included in the first partial table 431.

[0114] The symbol distributor 351 sends the first partial table 431 to the Huffman tree generator 324. The symbol distributor 351 sends the second partial table 432 to the representative symbol frequency estimator 352, the merging symbol number counter 353, and the merging symbol addition code length determiner 354.

[0115] 15 shows (A) an example of a first frequency table 41, and (B) an example of a first partial table 431 and (C) an example of a second partial table 432 into which the first frequency table 41 is divided. In the example shown in FIG.

[0116] The first frequency table 41 shown in Fig. 15(A) is a table in which N entries are arranged in descending order of appearance frequency, similar to the first frequency table 41 shown in Fig. 14. The first frequency table 41 is divided into a first partial table 431 and a second partial table 432.

[0117] 15(B), the first partial table 431 includes the top H entries (i.e., the first H entries) of the entries included in the first frequency table 41. The H entries in the first partial table 431 are assigned indexes from 0 to H-1, in order from the top.

[0118] 15C, the second partial table 432 includes the lowest L entries among the entries included in the first frequency table 41. The L entries in the second partial table 432 are assigned indexes from 0 to L-1 in order from the top.

[0119] Return to Figure 12.

[0120] When constructing a Huffman tree, the representative symbol frequency estimation unit 352 determines the occurrence frequency of the representative symbol in order to regard the L lower order symbols included in the second sub-table 432 as one representative symbol. The representative symbol frequency estimation unit 352 determines the occurrence frequency of the representative symbol based on the occurrence frequency of the L lower order symbols. Specifically, the representative symbol frequency estimation unit 352 estimates the occurrence frequency of the representative symbol by, for example, estimating the sum of the occurrence frequencies of the L lower order symbols.

[0121] Here, an example of calculating an estimate of the sum of the occurrence frequencies of the 224 lower order symbols will be described. The representative symbol frequency estimation unit 352 calculates an estimate S of the sum of the occurrence frequencies of the lower order symbols by the following formula (2), using the occurrence frequency F(i) of the symbol indicated in the entry identified by index i in the second sub-table 432.

[0122]

number

[0123] In the calculation using formula (2), the 224 entries included in the second sub-table 432 are divided into 16 indexes from the top, and 14 ranges (hereinafter referred to as index ranges) are set. Of the 14 index ranges, the kth index range from the top is referred to as the kth index range. k is any value from 0 to 13.

[0124] The representative symbol frequency estimation unit 352 calculates an estimate of the occurrence frequency for each of the index ranges from 0th to 13th. Specifically, the representative symbol frequency estimation unit 352 calculates an estimate of the occurrence frequency corresponding to the kth index range by multiplying the average of the occurrence frequency F(k×16) indicated in the first entry of the kth index range and the occurrence frequency F(k×16+15) indicated in the last entry by the number of symbols included in one index range (16 in this case). Then, the representative symbol frequency estimation unit 352 calculates the sum of the estimates of the occurrence frequency corresponding to each of the index ranges from 0th to 13th to obtain an estimate S of the sum of the occurrence frequencies of the lower order symbols.

[0125] In the calculation using formula (2), the number of additions required to calculate the estimated value S is reduced by assuming that the occurrence frequency corresponding to the index changes linearly from the first entry to the last entry of each index range. Note that this method of calculating the estimated value S is just one example, and other methods may be used. For example, the number of index ranges set by dividing the 224 entries included in the second partial table 432 may be appropriately changed in consideration of the amount of calculation required to calculate the estimated value S and the accuracy of the calculated estimated value S.

[0126] The representative symbol frequency estimation unit 352 sends the estimated value S of the sum of the occurrence frequencies of the lower order symbols to the Huffman tree generation unit 324 as the occurrence frequency of the representative symbol.

[0127] The Huffman tree generating unit 324 generates a Huffman tree using the frequency of occurrence of each of the H non-representative symbols included in the first partial table 431 and the frequency of occurrence of the representative symbol. Specifically, among the H non-representative symbols and the representative symbols included in the first partial table 431, each symbol having an occurrence frequency greater than 0 is arranged as a leaf node, and a Huffman tree generating process is performed. This Huffman tree generating process is the same as the Huffman tree generating process described above with reference to FIG. 3. Specifically, this Huffman tree generating process is a process in which the procedure of step S11 in the Huffman tree generating process described above with reference to FIG. 3 is replaced with a procedure of adding, as a leaf node on the Huffman tree, the symbol having an occurrence frequency greater than 0 among the H non-representative symbols and the representative symbols included in the first partial table 431. The Huffman tree generating unit 324 sends the generated Huffman tree to the code length determining unit 325. When the number of representative symbols is M, the Huffman tree generator 324 generates a Huffman tree based on the occurrence frequency of symbols having an occurrence frequency greater than 0 among the H non-representative symbols and the M representative symbols.

[0128] 16 shows an example of a Huffman tree 60 generated by the Huffman tree generator 324. The Huffman tree 60 includes a root node 600, intermediate nodes 610, 611, 621, and 631, first type leaf nodes 641, 642, 643, and 644, and a second type leaf node 645.

[0129] Each of the first type leaf nodes 641, 642, 643, and 644 corresponds to a symbol having an occurrence frequency greater than 0 among the symbols (non-representative symbols) included in the first partial table 431. The number of first type leaf nodes is H at most.

[0130] The second type leaf node 645 corresponds to a representative symbol whose occurrence frequency is greater than 0. The number of the second type leaf nodes is up to M (here, M=1).

[0131] Therefore, the number of symbols that are the targets of Huffman tree generation by the Huffman tree generation unit 324 (i.e., the number of leaf nodes of the generated Huffman tree) is at most (H+M). In contrast, as described above, the number of symbols that are the targets of Huffman tree generation by the Huffman tree generation unit 324A of the code table generation unit 32A according to the comparative example is at most N. For example, when N is 256, H is 32, and M is 1, in the code table generation unit 32 of this embodiment, the number of symbols that are the targets of Huffman tree generation by the Huffman tree generation unit 324 is significantly reduced from a maximum of 256 to a maximum of 33 (=32+1) compared to the Huffman tree generation unit 324A of the comparative example. As a result, in the code table generation unit 32 of this embodiment, it is possible to reduce the time required for the process of code table generation, or reduce the circuit size (e.g., the number of gates) for completing code table generation within a specific time.

[0132] On the other hand, there is a concern that the coding efficiency of the dynamic Huffman coding may decrease by treating all symbols included in the second partial table 432 as one representative symbol. To address this, the H upper symbols (non-representative symbols) that are included in the first partial table 431 and account for the majority of the occurrence frequency are treated as H symbols (i.e., H leaf nodes) on the Huffman tree as well, thereby ensuring the accuracy of the dynamic Huffman coding. In other words, the number H of symbols included in the first partial table 431 is reduced within a range that allows the accuracy of the dynamic Huffman coding to be ensured. Also, the L lower symbols included in the second partial table 432 often have a low occurrence frequency. Therefore, even if a non-optimal code length is set for the lower symbols, the effect on the coding efficiency is small.

[0133] Therefore, the code table generation unit 32 of this embodiment can reduce the time required for the code table generation process while keeping the decrease in encoding efficiency within a range that is not problematic for practical use, or can reduce the circuit size required to complete code table generation within a specific time.

[0134] Merge symbol number counting unit 353 counts the number C of symbols included in second partial table 432 and having an occurrence frequency greater than 0. C is an integer equal to or greater than 0. If second partial table 432 does not include any symbol having an occurrence frequency greater than 0, C is 0. A symbol included in second partial table 432 and having an occurrence frequency greater than 0 is called a merge symbol. A merge symbol is a symbol included in second partial table 432 that needs to be assigned a variable length code. The number C of merge symbols counted by merge symbol number counting unit 353 is the number of merge symbols represented by the representative symbol. Merge symbol number counting unit 353 sends merge symbol number C to merge symbol addition code length determination unit 354.

[0135] The merge symbol addition code length determination unit 354 determines, for each merge symbol, a code length to be added to the code length of the representative symbol (hereinafter referred to as added code length) by using a subtree based on the second sub-table 432 and the number of merge symbols C. The merge symbol addition code length determination unit 354 sends the added code lengths of the C merge symbols to the representative symbol expansion unit 327. The merge symbol addition code length determination unit 354 also sends the maximum value of the added code lengths of the C merge symbols to the maximum code length constraint unit 326.

[0136] The code length of each merge symbol is obtained by adding the added code length to the code length of the representative symbol. This is equivalent to determining the structure of a subtree having leaf nodes to which each merge symbol is assigned, and determining the position on the Huffman tree 60 for the root node of that subtree by the Huffman tree generation process.

[0137] 17 shows an example of a subtree 65 of merging symbols used by the merging symbol addition code length determination unit 354. The subtree 65 is a binary tree with one leaf node 645 of the Huffman tree 60 as the root node. Here, the case where the number of merging symbols C is 5 is illustrated as an example.

[0138] The Huffman tree 60, similar to the Huffman tree 60 described above with reference to FIG. 16, includes a root node 600, intermediate nodes 611, 621, 630, and 631, first type leaf nodes 640, 641, 642, 643, and 644, and a second type leaf node 645.

[0139] Each of the first type leaf nodes 641, 642, 643, and 644 corresponds to a symbol having an occurrence frequency greater than 0 among the symbols (non-representative symbols) included in the first partial table 431.

[0140] The second type leaf node 645 corresponds to a representative symbol whose occurrence frequency is greater than 0. The second type leaf node 645 is a root node of the subtree 65. The occurrence frequency associated with the second type leaf node 645 is an estimate S of the sum of the occurrence frequencies of the merge symbols.

[0141] The subtree 65 has the leaf node 645 of the Huffman tree 60 as the root node, and includes intermediate nodes 650, 651, and 660, and leaf nodes 661, 662, 663, 670, and 671. The leaf nodes 661, 662, 663, 670, and 671 correspond to the five merge symbols, respectively.

[0142] Therefore, the code length of each merge symbol is determined by adding the depth (number of edges) of each leaf node 661, 662, 663, 670, 671 starting from the root node (i.e., leaf node 645) in the subtree 65 as the added code length to the code length of the representative symbol corresponding to the leaf node 645.

[0143] From the viewpoint of reducing the amount of processing, it is desirable that the subtree 65 including C leaf nodes corresponding to the C merge symbols has a structure that allows the addition code length of each merge symbol to be easily obtained using the number C of merge symbols.

[0144] Therefore, the merging symbol addition code length determination unit 354 uses, for example, a balanced binary tree as the structure of the subtree 65. A balanced binary tree is a binary tree in which the difference in depth between all leaf nodes is at most 1. A balanced binary tree is also called a balanced binary tree. Note that a structure other than a balanced binary tree may be used as the subtree 65. The merging symbol addition code length determination unit 354 may determine the structure of the subtree 65 based on the occurrence frequency of the C merging symbols. Furthermore, the merging symbol addition code length determination unit 354 may determine the structure of the subtree 65 by selecting from a tree structure (for example, a template tree structure) prepared in advance.

[0145] When a balanced binary tree is used as the structure of the subtree 65, the merging symbol addition code length determination unit 354 determines the addition code length of each merging symbol according to the following procedures (A1) and (A2).

[0146] (A1)2 X Find the smallest integer X that satisfies ≧C. (A2) Among the C merge symbols, the indexes on the second sub-table 432 are sorted in ascending order (i.e., in descending order of frequency of occurrence) (2 X -C) merge symbols are added together to (X-1) bits, and the remaining (2C-2 X ) merging symbols to X bits, where X is the maximum value of the added code length of the C merging symbols.

[0147] In the example shown in FIG. 17, C=5. Therefore, when X is obtained according to the above procedure, the merge symbol addition code length determination unit 354 obtains 2 3 >5, so the merging symbol addition code length determination unit 354 calculates X=3. Then, of the five merging symbols, the merging symbol addition code length determination unit 354 selects the merging symbols with the smallest index on the second sub-table 432 in ascending order (3 (=2 3The merge symbol addition code length determination unit 354 sets the addition code length of the remaining 2 (=2×5−2) merge symbols (corresponding to the leaf nodes 661, 662, and 663) to 2 (=3−1) bits. 3 ) merge symbols (corresponding to leaf nodes 670 and 671) are set to have an additive code length of 3 bits. The maximum additive code length of 5 merge symbols is 3.

[0148] Here, let r be the representative symbol, and let K(r) be the number of symbols (i.e., merge symbols) whose occurrence frequency is greater than 0 among the symbols included in the symbol set represented by the representative symbol r. Let us consider a function f(K(r)) that derives the maximum value of the addition code length corresponding to the symbol set. f is a function of K(r). f(K(r)) is defined by the following equation (3).

[0149]

number

[0150] Return to Figure 12.

[0151] The code length determination unit 325 uses the Huffman tree 60 generated by the Huffman tree generation unit 324 to determine the code length of each symbol having an occurrence frequency greater than 0 among the H non-representative symbols (higher order symbols) included in the first partial table 431, and the code length of the representative symbol. In the following, for ease of explanation, a case in which the occurrence frequencies of all of the H non-representative symbols are greater than 0 will be illustrated. Note that, in practice, the H non-representative symbols may include a symbol having an occurrence frequency of 0. In that case, the code length determination unit 325 does not calculate the code length of the symbol having an occurrence frequency of 0 among the H non-representative symbols.

[0152] Specifically, the code length determination unit 325 determines the number of edges passed from the leaf nodes corresponding to each of the H non-representative symbols and the representative symbol in the Huffman tree 60 to the root node 600 as the code length of the symbol. In the example shown in Fig. 17, for example, the code length of the non-representative symbol corresponding to the leaf node 640 is 1 bit. For example, the code length of the non-representative symbol corresponding to the leaf node 643 is 4 bits. Also, for example, the code length of the representative symbol corresponding to the leaf node 645 is 3 bits.

[0153] The code length determination unit 325 sends the determined H combinations of non-representative symbols and code lengths and combinations of representative symbols and code lengths to the maximum code length constraint unit 326. Hereinafter, combinations of non-representative symbols and code lengths are also referred to as <non-representative symbol, code length> pairs. Combinations of representative symbols and code lengths are also referred to as <representative symbol, code length> pairs.

[0154] The maximum code length constraint unit 326 performs processing (maximum code length constraint processing) to constrain the code length corresponding to the symbol to be equal to or less than the maximum code length, using the maximum value of the added code length sent from the merge symbol added code length determination unit 354, H <non-representative symbol, code length> pairs and one <representative symbol, code length> pair sent from the code length determination unit 325. The maximum code length constraint unit 326 obtains one combination of the representative symbol, the code length, and the maximum value of the added code length from the maximum value of the added code length sent from the merge symbol added code length determination unit 354 and one <representative symbol, code length> pair sent from the code length determination unit 325. Hereinafter, the combination of the representative symbol, the code length, and the maximum value of the added code length is also referred to as a <representative symbol, code length, maximum value of the added code length> pair.

[0155] 18 is a block diagram showing an example of the configuration of the maximum code length constraining unit 326. The maximum code length constraining unit 326 includes, for example, a code length sorting unit 371, a code length clipping unit 372, a representative symbol swapping unit 373, a violation symbol number calculating unit 374, an end determining unit 375, a code length changing unit 376, and a violation symbol number decrementing unit 377.

[0156] First, the code length sorting unit 371 sorts the H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum value of added code length> pair in descending order of code length.

[0157] Next, the code length clipping unit 372 changes (i.e., clips) the code lengths longer than the maximum code length included in the H <non-representative symbol, code length> pairs to the maximum code length. Specifically, the code length clipping unit 372 identifies all combinations including a code length longer than the maximum code length among the H <non-representative symbol, code length> pairs. The code length clipping unit 372 changes the code length included in each of the identified combinations to the maximum code length. As a result of this change, the H <non-representative symbol, code length> pairs include a non-representative symbol corresponding to an unreasonably short code length. In other words, the variable length code assigned based on these H <non-representative symbol, code length> pairs is an invalid Huffman code. Such unreasonably short code lengths are corrected by the code length change unit 376, which will be described later.

[0158] In addition, if the H <non-representative symbol, code length> pairs do not include a combination that includes a code length longer than the maximum code length, the code length clipping unit 372 does not process the H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum value of added code length> pair.

[0159] Next, if the code length of the representative symbol violates the maximum code length constraint, the representative symbol swap unit 373 performs a process of swapping the code length of the representative symbol with a non-representative symbol that satisfies a specific condition (swap process). The representative symbol swap unit 373 uses the following equation (4) to determine whether the code length of the representative symbol violates the maximum code length constraint. Representative symbol code length + maximum value of added code length > maximum code length Equation (4) The code length of the merge symbol represented by the representative symbol is at most the sum of the code length of the representative symbol and the maximum value of the added code length. Therefore, if the code length of the representative symbol does not satisfy this inequality, it is guaranteed that the code lengths of all merge symbols represented by the representative symbol are equal to or less than the maximum code length.

[0160] On the other hand, if the code length of the representative symbol satisfies this inequality, the representative symbol swap unit 373 performs a process of swapping the code length of the representative symbol with a non-representative symbol that satisfies a specific condition. The non-representative symbol that satisfies the specific condition is the non-representative symbol with the longest code length that satisfies the following formula (5). Code length ≦ Maximum code length - Maximum value of added code length Equation (5)

[0161] In other words, the representative symbol swap unit 373 performs swap processing when the code length of the representative symbol is longer than the maximum code length of the representative symbol.

[0162] The representative symbol maximum code length indicates the upper limit of the code length of the representative symbol. The representative symbol maximum code length is set so that the code lengths of all merge symbols represented by the representative symbol are restricted to be equal to or less than the maximum code length. Therefore, the representative symbol maximum code length is obtained by subtracting the maximum value of the added code length from the maximum code length, as shown in the following equation (6). Note that the number of merge symbols represented by the representative symbol is denoted as C.

[0163]

number

[0164] When the code length of the representative symbol is equal to or less than the maximum code length of the representative symbol, it is guaranteed that the code lengths of all merge symbols represented by the representative symbol are equal to or less than the maximum code length.

[0165] On the other hand, if the code length of the representative symbol is longer than the maximum code length of the representative symbol, the code length of at least one of the merge symbols represented by the representative symbol will be longer than the maximum code length. Therefore, the representative symbol swap unit 373 exchanges the code length of the representative symbol with the longest code length among the code lengths of the non-representative symbols that are less than the maximum code length of the representative symbol.

[0166] More specifically, when the code length of the representative symbol is longer than the maximum code length of the representative symbol, the representative symbol swap unit 373 uses H <non-representative symbol, code length> pairs to identify a non-representative symbol whose code length is equal to or shorter than the maximum code length of the representative symbol. The representative symbol swap unit 373 further identifies a non-representative symbol whose code length is the longest (hereinafter referred to as a non-representative symbol to be swapped) among the non-representative symbols whose code length is equal to or shorter than the maximum code length of the representative symbol. The representative symbol swap unit 373 exchanges the code length indicated in the <representative symbol, code length> pair with the code length indicated in the <non-representative symbol to be swapped, code length> pair.

[0167] In addition, if the code length of the representative symbol is less than or equal to the maximum code length of the representative symbol, the representative symbol swap unit 373 does not process H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum value of added code length> pair.

[0168] Next, violation symbol number calculation unit 374 calculates the violation symbol number I based on H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum added code length> pair. The violation symbol number I represents the number of symbols to which a variable length code cannot be assigned. If the violation symbol number I is greater than 0, the Huffman code determined based on H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum added code length> pair is an invalid Huffman code. Violation symbol number calculation unit 374 calculates the violation symbol number I by the following equation (7).

[0169]

number

[0170] Here, the symbol set AllSymbol includes H non-representative symbols and one representative symbol, and lmax is the maximum code length.

[0171] Violation symbol number calculation section 374 may calculate the number of violation symbols I according to the following equation (8).

[0172]

number

[0173] Equation (8) shows an equation for deriving the number of violation symbols I, including clipping of the code length of non-representative symbols by the code length clipping unit 372. clip(l(s)) is a function for clipping the code length (l(s)) of symbol s to the maximum code length lmax. If the code length l(s) is longer than the maximum code length lmax, clip(l(s)) is the maximum code length lmax (i.e., clip(l(s))=lmax). If the code length l(s) is equal to or shorter than the maximum code length lmax, clip(l(s)) is the code length l(s) (i.e., clip(l(s))=l(s)).

[0174] The end determination unit 375 determines whether to end the maximum code length constraint processing in the maximum code length constraint unit 326 based on the violation symbol number I. Specifically, when the violation symbol number I is 0, the end determination unit 375 determines to end the maximum code length constraint processing. When the violation symbol number I is greater than 0, the end determination unit 375 determines to continue the maximum code length constraint processing.

[0175] When the end determination unit 375 determines to continue the maximum code length constraint processing, the following processing is performed by the code length change unit 376 and the violating symbol number decrement unit 377 .

[0176] The code length modification unit 376 uses H <non-representative symbol, code length> pairs to modify the code lengths of the non-representative symbols so as to reduce the number of violation symbols I. Specifically, the code length modification unit 376 modifies the code lengths of the non-representative symbols by the following procedures (B1) to (B4).

[0177] (B1) One violation symbol s is selected using H <non-representative symbol, code length> pairs. The violation symbol s is a non-representative symbol corresponding to a code length equal to the maximum code length. For example, the violation symbol s is a symbol corresponding to a code length longer than the maximum code length, and the code length is changed to the maximum code length by the code length clipping unit 372. (B2) Using H <non-representative symbol, code length> pairs, a non-representative symbol s' having a code length less than the maximum code length and longer than the maximum code length is selected. (B3) The code length l(s) of the violation symbol s is changed to the code length l(s') of the non-representative symbol s' plus 1. (B4) The code length l(s') of the non-representative symbol s' is changed to a length incremented by 1.

[0178] Note that steps (B3) and (B4) may be replaced with other steps that provide similar results regarding code length changes. For example, steps (B3) and (B4) may be replaced with steps (B3') and (B4') below.

[0179] (B3') The code length l(s') of the non-representative symbol s' is changed to a length incremented by 1. (B4') The code length l(s) of the violation symbol s is changed to a length equal to the code length l(s') of the changed non-representative symbol s'.

[0180] After code length changing unit 376 changes code length l(s) of violation symbol s and code length l(s') of non-representative symbol s', violation symbol number decrement unit 377 updates violation symbol number I by decrementing it by one.

[0181] The end determination unit 375 determines whether or not to end the maximum code length constraint process in the maximum code length constraint unit 326 based on the updated number of violation symbols I. Therefore, the code length change unit 376 and the violation symbol number decrement unit 377 repeat the process until the number of violation symbols I becomes 0. When the number of violation symbols I becomes 0, H <non-representative symbol, code length> pairs and one <representative symbol, code length> pair are acquired, in which the code length has been changed to a code length that can obtain a valid Huffman code. The maximum code length constraint unit 326 sends the acquired H <non-representative symbol, code length> pairs and one <representative symbol, code length> pair to the representative symbol expansion unit 327.

[0182] 19 to 23, a specific example will be described in which the code length is restricted to be equal to or less than the maximum code length in the maximum code length restricting unit 326. Here, it is assumed that the maximum code length is 4 bits.

[0183] FIG. 19 shows an example of non-representative symbols and representative symbols determined based on the frequency of occurrence. In the example shown in FIG. 19, in a plurality of symbols arranged in descending order of frequency of occurrence, four symbols "h", "i", "j", and "k" are represented by one representative symbol R in ascending order of frequency of occurrence. That is, the four symbols "h", "i", "j", and "k" are merge symbols. The frequency of occurrence of the representative symbol "R" is set to 4, which is the sum of the frequencies of occurrence of the four merge symbols "h", "i", "j", and "k". The remaining seven symbols "a", "b", "c", "d", "e", "f", and "g" (hereinafter referred to as non-representative symbols "a" to "g") are non-representative symbols.

[0184] Fig. 20 shows an example of a Huffman tree 70 corresponding to the non-representative symbols and representative symbols shown in Fig. 19. The Huffman tree 70 is generated based on the frequency of occurrence of each of the seven non-representative symbols "a" to "g" and the frequency of occurrence of one representative symbol "R". Specifically, the Huffman tree 70 is generated by, for example, replacing the procedure of step S11 in the Huffman tree generation process described above with reference to Fig. 3 with a procedure of adding the seven non-representative symbols "a" to "g" and one representative symbol "R" as leaf nodes on the Huffman tree.

[0185] In the explanation of the processing in the maximum code length constraining unit 326, the example in which the structure of a Huffman tree and symbols are assigned to leaf nodes is illustrated to make the change of the code length easier to understand. Even when the example in which the structure of a Huffman tree and symbols are assigned to leaf nodes is shown, the maximum code length constraining unit 326 does not need to actually hold the structure of the Huffman tree and the correspondence between the leaf nodes and the symbols. The maximum code length constraining unit 326 can select symbols and change the code length by holding, for example, a list of <representative symbol, code length> pairs and <non-representative symbol, code length> pairs.

[0186] In the generated Huffman tree 70, non-representative symbol "a" is assigned to leaf node 712. Non-representative symbol "b" is assigned to leaf node 722. Non-representative symbols "c" and "d" are assigned to leaf nodes 742 and 743, respectively. Non-representative symbol "e" is assigned to leaf node 753. Non-representative symbols "f" and "g" are assigned to leaf nodes 765 and 766, respectively. Representative symbol "R" is assigned to leaf node 741.

[0187] The code length of the non-representative symbol "a" is 1. The code length of the non-representative symbol "b" is 2 bits. The code length of the representative symbol "R" and the two non-representative symbols "c" and "d" is 4 bits. The code length of the non-representative symbol "e" is 5 bits. The code length of the two non-representative symbols "f" and "g" is 6 bits.

[0188] The edges and nodes indicated by dotted lines represent subtree 75 corresponding to merge symbols "h", "i", "j", and "k" (hereinafter, merge symbols "h" to "k"). Subtree 75 is a subtree with representative symbol "R" as the root node and each of merge symbols "h" to "k" as a leaf node. Merge symbols "h" to "k" are assigned to leaf nodes 761, 762, 763, and 764, respectively. The code length of merge symbols "h" to "k" is 6 bits. Therefore, for these merge symbols "h" to "k", the maximum code length to be added to the code length of representative symbol "R" (additional code length) is 2 (=6-4).

[0189] In the Huffman tree 70, the code lengths of the non-representative symbols "e", "f", and "g" are longer than the maximum code length. Therefore, the code length clipping unit 372 changes the code lengths of the non-representative symbols "e", "f", and "g" to the maximum code length.

[0190] Furthermore, in the Huffman tree 70, the length obtained by adding the code length of the representative symbol "R" to the maximum value of the added code length is longer than the maximum code length (i.e., 4+2>4). Therefore, the representative symbol swap unit 373 selects the non-representative symbol "b" with the longest code length from the non-representative symbols "a" and "b" whose code lengths are equal to or shorter than the representative symbol maximum code length (=4-2=2) obtained by subtracting the maximum value of the added code length from the maximum code length. The representative symbol swap unit 373 exchanges the code lengths of the representative symbol "R" and the selected non-representative symbol "b".

[0191] Fig. 21 shows a modification of the Huffman tree 70 shown in Fig. 20. This modification shows the Huffman tree 70 in which the code lengths of the non-representative symbols "e", "f", and "g" have been changed to the maximum code length by the code length clipping unit 372, and the representative symbol swap unit 373 has exchanged the code lengths of the representative symbol "R" and the non-representative symbol "b".

[0192] That is, in the transformed Huffman tree 70, the code lengths of the non-representative symbols "e", "f", and "g" (leaf nodes 744, 745, and 746) are set to the maximum code length (=4). The code length of the representative symbol "R" is set to the original code length of the non-representative symbol "b" (=2). The code length of the non-representative symbol "b" is set to the original code length of the representative symbol "R" (=4). As a result, the code lengths of the merge symbols "h" to "k" represented by the representative symbol "R" are less than the maximum code length, and the maximum code length constraint is satisfied.

[0193] Note that leaf nodes 745 and 746 are nodes that cannot be traced back from root node 701. Therefore, non-representative symbols "f" and "g" assigned to leaf nodes 745 and 746, respectively, are violation symbols.

[0194] In this case, violation symbol number calculation section 374 calculates the number of violation symbols I in accordance with the above-mentioned equation (7) (or equation (8)) as follows: I = (1 / 16 x 6 + 1 / 4 + 1 / 2 - 1) x 16 = 2

[0195] 21, the number of violating symbols I is 2. Because the calculated number of violating symbols I is greater than 0, code length modification section 376 modifies the code lengths of non-representative symbols until the number of violating symbols becomes 0.

[0196] Specifically, the code length change unit 376 selects, for example, a violation symbol "f." Then, the code length change unit 376 selects a non-representative symbol "a" whose code length is shorter than the maximum code length. Note that, when there are multiple non-representative symbols whose code length is shorter than the maximum code length, the code length change unit 376 selects one non-representative symbol from the multiple non-representative symbols in order of longest code length.

[0197] Code length modification unit 376 modifies the code length of violation symbol "f" to the code length of non-representative symbol "a" plus 1. Then, code length modification unit 376 increments the code length of non-representative symbol "a" by 1. As a result, the code length of violation symbol "f" and the code length of non-representative symbol "a" become 2 bits.

[0198] Next, violation symbol number decrement unit 377 updates violation symbol number I to 1 by decrementing it by 1. Since the updated violation symbol number I is greater than 0, end determination unit 375 determines to further change the code length of the non-representative symbols.

[0199] Fig. 22 shows a modification of the Huffman tree 70 shown in Fig. 21. This modification shows Huffman tree 70 in which the code lengths of non-representative symbol "a" and violation symbol "f" have been changed by the code length change unit 376 described above. That is, in the modified Huffman tree 70, the code length of non-representative symbol "a" and the code length of violation symbol "f" are set to 2 bits. Non-representative symbol "g" remains a violation symbol.

[0200] The code length change unit 376 selects the violation symbol "g" in response to the decision by the end determination unit 375 to further change the code length of the non-representative symbol. Then, the code length change unit 376 selects the non-representative symbol "f" with the longest code length among the non-representative symbols "a" and "f" with code lengths shorter than the maximum code length. Here, since the code lengths of the non-representative symbols "a" and "f" are both 2 bits, the code length change unit 376 may select the non-representative symbol "a". If there are multiple non-representative symbols with the longest code length among the non-representative symbols with code lengths shorter than the maximum code length, the code length change unit 376 selects any one of the non-representative symbols according to a specific rule. In the following, it is assumed that the code length change unit 376 selects the non-representative symbol "f".

[0201] Code length modification unit 376 modifies the code length of the selected violation symbol "g" to the code length of the selected non-representative symbol "f" plus 1. Then, code length modification unit 376 increments the code length of non-representative symbol "f" by 1. As a result, the code length of violation symbol "g" and the code length of non-representative symbol "f" become 3 bits.

[0202] Next, violation symbol number decrement unit 377 decrements violation symbol number I by 1, updating it to 0. Since the updated violation symbol number I is 0, end determination unit 375 determines to end changing the code lengths of non-representative symbols.

[0203] Fig. 23 shows a modification of the Huffman tree 70 shown in Fig. 22. This modification shows a Huffman tree 70 in which the code lengths of the non-representative symbol "f" and the violation symbol "g" have been changed by the code length change unit 376 described above. That is, in the modified Huffman tree 70, the code length of the non-representative symbol "f" and the code length of the violation symbol "g" are set to 3 bits. Furthermore, this Huffman tree 70 does not have any violation symbols.

[0204] This Huffman tree 70 is a valid Huffman tree, and every intermediate node has two child nodes. Therefore, a Huffman code determined based on the Huffman tree 70 satisfies the Kraft inequality and is a valid Huffman code with no redundant code assignments (i.e., K=1). In other words, a Huffman code determined based on the Huffman tree 70 is a perfect code.

[0205] An example of a procedure for maximum code length constraint processing will be described with reference to FIGS.

[0206] 24 is a flowchart showing an example of the procedure of maximum code length constraint processing executed in the maximum code length constraint unit 326. The maximum code length constraint unit 326 performs maximum code length constraint processing on H pairs of <non-representative symbol, code length> sent from the code length determination unit 325 and one pair of <representative symbol, code length>.

[0207] First, the maximum code length constraint unit 326 changes the code length of all non-representative symbols that is longer than the maximum code length to the maximum code length (step S301). Next, the maximum code length constraint unit 326 determines whether the code length of the representative symbol is longer than the representative symbol maximum code length (step S302). The representative symbol maximum code length is the maximum code length minus the maximum value of the added code length.

[0208] If the code length of the representative symbol is longer than the maximum code length of the representative symbol (Yes in step S302), the maximum code length constraint unit 326 selects the non-representative symbol with the longest code length among the non-representative symbols whose code lengths are equal to or shorter than the maximum code length of the representative symbol (step S303). The maximum code length constraint unit 326 replaces the code length of the selected non-representative symbol with the code length of the representative symbol (step S304), and proceeds to step S305.

[0209] If the code length of the representative symbol is equal to or less than the maximum code length of the representative symbol (No in step S302), the process by the maximum code length constraint unit 326 proceeds to step S305.

[0210] Next, the maximum code length constraint unit 326 calculates the number of violation symbols I according to the above-mentioned equation (7) (or equation (8)) (step S305).

[0211] The maximum code length constraint unit 326 determines whether the calculated number of violation symbols I is 0 (step S306). If the number of violation symbols I is greater than 0, this indicates that the Huffman code assigned based on the current code length of each symbol is an invalid Huffman code.

[0212] If the number I of violation symbols is greater than 0 (No in step S306), the maximum code length constraint unit 326 executes a first code length change process (step S307). The first code length change process is a process for changing the code length of one violation symbol to the maximum code length or less. A specific procedure of the first code length change process will be described later with reference to the flowchart in FIG.

[0213] Next, the maximum code length constraining unit 326 decrements the number of violation symbols I by 1 (step S308). That is, the maximum code length constraining unit 326 subtracts 1 from the number of violation symbols I. Then, the process by the maximum code length constraining unit 326 returns to the determination of whether the number of violation symbols I is 0 in step S306. Therefore, the maximum code length constraining unit 326 repeatedly performs the procedure of step S307 of executing the first code length change process and the procedure of step S308 of decrementing the number of violation symbols I until the number of violation symbols I becomes 0.

[0214] If the number I of violation symbols is 0 (Yes in step S306), the maximum code length constraining unit 326 ends the maximum code length constraining process.

[0215] By the above maximum code length constraint process, the maximum code length constraint unit 326 can constrain the code length of the non-representative symbol to the maximum code length or less, and can constrain the code length of the representative symbol to the representative symbol maximum code length or less. By constraining the code length of the representative symbol to the representative symbol maximum code length or less, the code length of the symbol represented by the representative symbol (i.e., the merge symbol) can be constrained to the maximum code length or less.

[0216] Fig. 25 is a flowchart showing an example of the procedure of the first code length change process executed in the maximum code length constraining unit 326. The first code length change process corresponds to step S307 of the maximum code length constraining process described above with reference to Fig. 24. The maximum code length constraining unit 326 executes the first code length change process when one or more violation symbols are included in the non-representative symbols.

[0217] First, the maximum code length constraint unit 326 selects a non-representative symbol s' having the longest code length among non-representative symbols having code lengths less than the maximum code length (step S41). The maximum code length constraint unit 326 selects one violation symbol from one or more violation symbols (step S42). Specifically, the maximum code length constraint unit 326 selects one non-representative symbol having a code length equal to the maximum code length as the violation symbol. The maximum code length constraint unit 326 changes the code length of the selected violation symbol to a length obtained by adding 1 to the code length l(s') of the non-representative symbol s' (step S43). Then, the maximum code length constraint unit 326 increments the code length l(s') of the non-representative symbol s' by 1 (step S44) and ends the first code length change process. That is, the maximum code length constraint unit 326 adds 1 to the code length l(s') of the non-representative symbol s' and ends the first code length change process.

[0218] The above first code length change process corresponds to an operation in which the maximum code length constraining unit 326 changes the leaf node corresponding to the non-representative symbol s' to an intermediate node, and assigns the non-representative symbol s' and the violation symbol to the two leaf nodes having the intermediate node as a parent. In this operation, no leaf node to which a symbol is not assigned is generated. In other words, no redundant leaf node is generated. Therefore, the maximum code length constraining unit 326 can guarantee that the Huffman code assigned based on the code length of each symbol is a complete code at the time when the maximum code length constraining process including the first code length change process is completed. Therefore, the maximum code length constraining unit 326 can reduce processing time and processing resources compared to, for example, the maximum code length constraining unit 326A of the comparative example that additionally performs a process of merging binary trees having redundant leaf nodes. Furthermore, since the maximum code length constraining process is performed on the representative symbol that represents the merged symbol, the number of symbols handled in the maximum code length constraining process can be significantly reduced. Therefore, the processing time and processing resources can also be reduced by such a reduction in the number of symbols.

[0219] Return to Figure 12.

[0220] The representative symbol expansion unit 327 receives H <non-representative symbol, code length> pairs for which maximum code length constraint processing has been completed, and one <representative symbol, code length> pair, from the maximum code length constraint unit 326. The representative symbol expansion unit 327 receives C <merge symbol, added code length> pairs from the merge symbol added code length determination unit 354. The representative symbol expansion unit 327 determines the code length of each of the C merge symbols using the received one <representative symbol, code length> pair and the C <merge symbol, added code length> pairs.

[0221] The representative symbol expansion unit 327 determines the code length of each of the C merge symbols using the code length of the representative symbol and C added code lengths corresponding to the C merge symbols. Specifically, the representative symbol expansion unit 327 determines the code length of each of the C merge symbols by adding the added code length corresponding to the merge symbol to the code length of the representative symbol. The representative symbol expansion unit 327 sends a list including H <non-representative symbol, code length> pairs and C <merge symbol, code length> pairs to the code allocation unit 328. The H <non-representative symbol, code length> pairs received from the maximum code length constraint unit 326 are sent to the code allocation unit 328 as is.

[0222] The code allocation unit 328 generates a code table, for example, by the canonical Huffman method, using a list including H <non-representative symbol, code length> pairs and C <merge symbol, code length> pairs sent by the representative symbol expansion unit 327. 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, the list is sorted using the code length as the first key and the symbol number as the second key, and then the code bit string is assigned to the symbol according to the following rules (C1) and (C2).

[0223] (C1) A code bit string assigned to a symbol having a shorter code length precedes, in lexicographical order, a code bit string assigned to a symbol having a longer code length. (C2) 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.

[0224] 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.

[0225] 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".

[0226] 26 shows an example of a pseudo program for the code assigning unit 328 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 a symbol.

[0227] First, the code assigning unit 328 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 code bit strings should be assigned.

[0228] Next, in one while loop, the code assigning unit 328 determines a code bit sequence 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.

[0229] For example, in the first while loop, the code assignment unit 328 selects a symbol that has the shortest code length and that comes first in a specific symbol order when there is another symbol with the same code length, as a target for assigning a code bit sequence. Then, the code assignment unit 328 assigns code (=1'b0) as the code bit sequence of the selected symbol. As described above, the number of bits of code to be assigned first depends on the minimum code length. In this example, it is assumed that the minimum code length is 1. Then, the code assignment unit 328 performs a shift operation to shift a 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, when the number of bits obtained by subtracting the code length of the current symbol from the code length of the next symbol is 1, a value 2'b10 obtained by shifting 1'b1, which is a value obtained by adding 1 to code (=1'b0) to the left, one bit is set to code.

[0230] Also, for example, in the second while loop, the code assignment unit 328 selects the symbol with the second shortest code length, or the symbol with the shortest code length and second in a specific symbol order when there is another symbol with the same code length, as a target for assigning a code bit sequence. The code assignment unit 328 assigns code (=2'b10) as the code bit sequence of the selected symbol. Then, the code assignment unit 328 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 3'b110 obtained by shifting 2'b11, which is the value obtained by adding 1 to code (=2'b10) to the left by 1 bit, is set to code.

[0231] By performing such loop processing, the code assigning unit 328 can assign a code bit sequence to each of the multiple symbols by using the order relationship between the symbols and the multiple code lengths corresponding to the multiple symbols, respectively. In other words, the code assigning unit 328 can uniquely determine the code bit sequence to be assigned to each symbol by determining the order relationship between the symbols and the code length of each symbol.

[0232] This indicates that it is possible to restore a code table (decoding table) used for decoding in the decompressor by encoding a plurality of code lengths arranged in a predetermined symbol order as a header in the compressed data output by the variable length encoding unit 33. By encoding a plurality of code lengths arranged in a symbol order, it is possible to significantly reduce the overhead of the amount of code in the compressed data compared to the case of encoding the code bit string itself.

[0233] The code allocation unit 328 sends a code table indicating the code bit strings allocated to each symbol to the variable-length coding unit 33 .

[0234] As described above, the variable-length coding unit 33 uses the code table sent by the code table generating unit 32 to convert the symbols sent by the buffer unit 31 into variable-length codes, and outputs them as compressed data.

[0235] With the above configuration, the variable length coding device 15 can reduce processing time and processing resources when assigning a variable length code that has a code length equal to or less than the maximum code length and is a complete code to a symbol. Specifically, the maximum code length constraint unit 326 constrains the code length of the symbol to be equal to or less than the maximum code length while maintaining that the Huffman code assigned based on the code length of each symbol is a complete code in the maximum code length constraint process. Therefore, the maximum code length constraint unit 326 can guarantee that the Huffman code assigned based on the code length of each symbol is a complete code when the maximum code length constraint process is completed. Therefore, the maximum code length constraint unit 326 can reduce processing time and processing resources compared to, for example, the maximum code length constraint unit 326A of the comparative example that additionally performs a process of merging binary trees having redundant leaf nodes.

[0236] Second embodiment When the code length of the representative symbol is longer than the maximum code length of the representative symbol, the maximum code length constraint unit 326 in the first embodiment replaces the code length of the representative symbol with the code length of a non-representative symbol that satisfies the condition of being equal to or shorter than the maximum code length of the representative symbol.

[0237] However, when the code length of the representative symbol is longer than the maximum code length of the representative symbol, there may be a case where there is no non-representative symbol that satisfies the condition that the code length is equal to or less than the maximum code length of the representative symbol. In such a case, the maximum code length constraint unit 326 of the second embodiment further includes a configuration for changing the code lengths of the representative symbol and the non-representative symbol to make the code length of the representative symbol equal to or less than the maximum code length of the representative symbol.

[0238] The configuration of the variable length coding device 15 according to the second embodiment is similar to that of the variable length coding device 15 according to the first embodiment. The variable length coding device 15 according to the second embodiment differs from the variable length coding device 15 according to the first embodiment in that a configuration for changing the code lengths of the representative symbols and non-representative symbols is added in order to restrict the code length of the representative symbol to the maximum code length of the representative symbol or less in the above-mentioned case. The following mainly describes the differences from the first embodiment.

[0239] 27 and 28, a specific description will be given of a case where, when the code length of the representative symbol is longer than the maximum code length of the representative symbol, there is no non-representative symbol that satisfies the condition that the code length is equal to or shorter than the maximum code length of the representative symbol.

[0240] Fig. 27 shows an example of non-representative symbols and representative symbols determined by the symbol merging unit 323 of the variable-length coding device 15 based on the frequency of occurrence. In the example shown in Fig. 27, multiple symbols are arranged in descending order of frequency of occurrence. Specifically, the frequency of occurrence of symbols "g" and "f" is 8. The frequency of occurrence of symbols "e" and "d" is 7. The frequency of occurrence of symbols "c" and "b" is 6. The frequency of occurrence of symbol "a" is 5. The frequency of occurrence of symbols "h", "i", "j", and "k" is 1.

[0241] In addition, the four symbols "h", "i", "j", and "k" are represented by one representative symbol R in order of decreasing frequency of occurrence. In other words, the four symbols "h", "i", "j", and "k" are merge symbols. The frequency of occurrence of the representative symbol "R" is set to 4, which is the sum of the frequencies of occurrence of the four merge symbols "h", "i", "j", and "k". The remaining seven symbols "a", "b", "c", "d", "e", "f", and "g" (hereinafter referred to as non-representative symbols "a" to "g") are non-representative symbols.

[0242] Fig. 28 shows an example of a Huffman tree 8A generated by the Huffman tree generation unit 324 of the variable length coding device 15. The Huffman tree 8A corresponds to the non-representative symbols and representative symbols shown in Fig. 27. Here, it is assumed that the maximum code length is 4 bits.

[0243] The Huffman tree 8A is generated based on the frequency of occurrence of each of the seven non-representative symbols "a" to "g" and the frequency of occurrence of one representative symbol "R." Specifically, the Huffman tree 8A is generated by, for example, replacing the procedure of step S11 in the Huffman tree generation process described above with reference to Fig. 3 with a procedure of adding the seven non-representative symbols "a" to "g" and one representative symbol "R" as leaf nodes on the Huffman tree.

[0244] In the generated Huffman tree 8A, the non-representative symbols "a" to "g" have a code length of 3 bits, and the representative symbol "R" has a code length of 3 bits.

[0245] The edges and nodes indicated by dotted lines represent subtree 8B corresponding to merge symbols "h", "i", "j", and "k" (hereinafter referred to as merge symbols "h" to "k"). Subtree 8B is a subtree with representative symbol "R" as the root node and each of merge symbols "h" to "k" as a leaf node. The code length of merge symbols "h" to "k" is 5 bits. Therefore, for these merge symbols "h" to "k", the maximum code length to be added to the code length of representative symbol "R" (additional code length) is 2.

[0246] In the Huffman tree 8A, the length obtained by adding the code length of the representative symbol "R" to the maximum added code length is longer than the maximum code length (i.e., 3+2>4). Therefore, the representative symbol swap unit 373 attempts to select a non-representative symbol with a code length that is equal to or shorter than the representative symbol maximum code length (=4-2=2) obtained by subtracting the maximum added code length from the maximum code length. However, the Huffman tree 8A does not have a non-representative symbol that satisfies the condition that the code length is equal to or shorter than the representative symbol maximum code length.

[0247] Therefore, this Huffman tree 8A corresponds to a case where, when the code length of the representative symbol is longer than the maximum code length of the representative symbol, there is no non-representative symbol that satisfies the condition that the code length is equal to or shorter than the maximum code length of the representative symbol.

[0248] The maximum code length constraint unit 326 of the variable length coding device 15 performs processing (maximum code length constraint processing) to constrain the code length corresponding to the symbol to be equal to or less than the maximum code length, using the maximum value of the added code length sent from the merge symbol added code length determination unit 354, and H <non-representative symbol, code length> pairs and one <representative symbol, code length> pair sent from the code length determination unit 325. In other words, the maximum code length constraint unit 326 performs maximum code length constraint processing, using H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum value of added code length> pair.

[0249] 29 is a block diagram showing an example of the configuration of the maximum code length constraining unit 326. The maximum code length constraining unit 326 includes, for example, a code length sorting unit 371, a code length clipping unit 372, a representative symbol swapping unit 373, a second representative symbol swapping unit 381, a sibling symbol code length changing unit 382, ​​a representative symbol code length changing unit 383, a representative symbol constraint processing termination determination unit 384, a violation symbol number calculation unit 374, a termination determination unit 375, a code length changing unit 376, and a violation symbol number decrementing unit 377.

[0250] The operations of the code length sorting unit 371, code length clipping unit 372, representative symbol swapping unit 373, violation symbol count calculation unit 374, termination determination unit 375, code length changing unit 376, and violation symbol count decrement unit 377 are as described above with reference to Fig. 18. More specifically, the operation when the representative symbol swapping unit 373 swaps the code length of the representative symbol with the code length of a non-representative symbol that is less than the maximum representative symbol code length is as described as the maximum code length constraint processing in the first embodiment.

[0251] When the code length of the representative symbol is longer than the maximum code length of the representative symbol, if there is no non-representative symbol whose code length is equal to or shorter than the maximum code length of the representative symbol, the representative symbol swap unit 373 does not swap the code length of the representative symbol with the code length of the non-representative symbol. Below, an operation of the case where the code length of the representative symbol is longer than the maximum code length of the representative symbol and there is no non-representative symbol whose code length is equal to or shorter than the maximum code length of the representative symbol will be described.

[0252] When the code length of the representative symbol is longer than the maximum code length of the representative symbol, the second representative symbol swap unit 381 swaps the code length of the representative symbol with the shortest code length among the code lengths of the non-representative symbols that are shorter than the code length of the representative symbol (i.e., swaps the code lengths of the representative symbol and non-representative symbols).When the code length of the representative symbol is longer than the maximum code length of the representative symbol, the second representative symbol swap unit 381 does not swap the code length of the representative symbol with the code length of the non-representative symbol if there is no non-representative symbol with a code length shorter than the code length of the representative symbol.

[0253] After processing by the second representative symbol swap unit 381 is performed, the sibling symbol code length modification unit 382, ​​the representative symbol code length modification unit 383, and the representative symbol constraint processing completion determination unit 384 perform processing (representative symbol constraint processing) to constrain the code length of the representative symbol to be equal to or less than the maximum code length of the representative symbol.

[0254] First, the sibling symbol code length change unit 382 converts two symbols that have the same intermediate node as the representative symbol as a parent, or have the same intermediate node as the representative symbol as a transitive parent. Dnon-representative symbols s are selected. A non-representative symbol that has the same intermediate node as the representative symbol as its parent, or has the same intermediate node as the representative symbol as its transitive parent, is also called a sibling symbol. A transitive parent is a node that can be reached while tracing an edge from a symbol (leaf node) toward the root node. D is the difference between the code length of the selected sibling symbol and the code length of the representative symbol. In other words, the code length of the selected sibling symbol is the code length of the representative symbol + D. Specifically, the sibling symbol code length change unit 382 applies a 2 D When searching for sibling symbols s, from H pairs of <non-representative symbol, code length>, select 2 non-representative symbols with a code length equal to the representative symbol's code length plus D. D It is sufficient to select 1 (=2) symbols. Note that when selecting a non-representative symbol that has the same intermediate node as the representative symbol as its parent, there is no difference in the code length between the representative symbol and the non-representative symbol, so the maximum code length constraint unit 326 restricts the maximum code length to 1 (=2 0 ) sibling symbols s.

[0255] Next, the sibling symbol code length change unit 382 selects two non-representative symbols in ascending order of code length that is less than the maximum code length. D Then, the sibling symbol code length change unit 382 selects two non-representative symbols s'. D The code lengths of the sibling symbols s and 2 D The code length of each of the non-representative symbols s' is changed. For example, D The code length of the i-th sibling symbol s among the sibling symbols s, and D A case will be described where the code length of the i-th non-representative symbol s' among the i non-representative symbols s' is changed. i is any value from 1 to D. In this case, the sibling symbol code length change unit 382 changes the code length of the i-th sibling symbol s to the code length of the i-th non-representative symbol s' plus 1. Then, the sibling symbol code length change unit 382 increments the code length of the i-th non-representative symbol s' by 1.

[0256] Next, the representative symbol code length modification unit 383 decrements the code length of the representative symbol by 1. That is, the representative symbol code length modification unit 383 modifies the code length in the <representative symbol, code length, maximum value of added code length> pair to a length decremented by 1.

[0257] The representative symbol constraint processing end determination unit 384 determines whether or not to end the representative symbol constraint processing based on the decremented code length of the representative symbol. Specifically, the representative symbol constraint processing end determination unit 384 determines whether or not the decremented code length of the representative symbol is equal to or less than the maximum code length of the representative symbol.

[0258] If the decremented code length of the representative symbol is not equal to or less than the maximum code length of the representative symbol, the representative symbol constraint processing is performed again by the sibling symbol code length changing unit 382, ​​the representative symbol code length changing unit 383, and the representative symbol constraint processing end determining unit 384. That is, the representative symbol constraint processing is repeatedly performed until the code length of the representative symbol becomes equal to or less than the maximum code length of the representative symbol.

[0259] When the decremented code length of the representative symbol becomes equal to or less than the maximum code length of the representative symbol, the representative symbol constraint processing end determination unit 384 ends the representative symbol constraint processing.

[0260] The subsequent processing by violation symbol number calculation unit 374, termination determination unit 375, code length change unit 376, and violation symbol number decrement unit 377 is as described above in the maximum code length constraint processing of the first embodiment.

[0261] With the above configuration, even if there is no non-representative symbol that satisfies the condition that the code length is equal to or less than the representative symbol maximum code length, the maximum code length constraint unit 326 can constrain the code length of the representative symbol to be equal to or less than the representative symbol maximum code length. Furthermore, even if there is no non-representative symbol that corresponds to a code length shorter than the representative symbol code length, the maximum code length constraint unit 326 can constrain the code length of the representative symbol to be equal to or less than the representative symbol maximum code length.

[0262] 30 to 34, a specific example will be described in which the code length is restricted to be equal to or less than the maximum code length in the maximum code length restricting unit 326. Here, it is assumed that the maximum code length is 4 bits.

[0263] FIG. 30 shows an example of a Huffman tree generated in the maximum code length constraint unit 326.

[0264] Huffman tree 80 is generated based on the frequency of occurrence of each of seven non-representative symbols "a", "b", "c", "d", "e", "f", and "g" (hereinafter referred to as non-representative symbols "a" to "g") and the frequency of occurrence of one representative symbol "R". The non-representative symbols "a" to "g" are assigned to leaf nodes 832, 833, 834, 835, 836, 837, and 838, respectively. The representative symbol "R" is assigned to leaf node 831.

[0265] In the Huffman tree 80, the code length of the non-representative symbols "a" to "g" is 3 bits. Also, the code length of the representative symbol "R" is 3 bits.

[0266] The edges and nodes shown by dotted lines represent a subtree 85 corresponding to merge symbols "h", "i", "j", "k", "l", "m", "n", and "o" (hereinafter, referred to as merge symbols "h" to "o"). The subtree 85 is a subtree with the representative symbol "R" (leaf node 831) as the root node and each of the merge symbols "h" to "o" as a leaf node. The merge symbols "h" to "o" are assigned to leaf nodes 861, 862, 863, 864, 865, 866, 867, and 868, respectively. The code length of the merge symbols "h" to "o" is 6 bits. Therefore, for these merge symbols "h" to "o", the maximum code length to be added to the code length of the representative symbol "R" (additional code length) is 3.

[0267] In the Huffman tree 80, the length obtained by adding the code length of the representative symbol "R" to the maximum added code length is longer than the maximum code length (i.e., 3+3>4). Therefore, the representative symbol swap unit 373 attempts to select a non-representative symbol with a code length equal to or shorter than the representative symbol maximum code length (=4-3=1), which is obtained by subtracting the maximum added code length from the maximum code length. However, the Huffman tree 80 does not have a non-representative symbol that satisfies the condition that the code length is equal to or shorter than the representative symbol maximum code length.

[0268] In this case, the second representative symbol swap unit 381 attempts to select a non-representative symbol with a code length shorter than the code length of the representative symbol "R." However, the Huffman tree 80 does not contain a non-representative symbol that satisfies the condition that the code length is shorter than the code length of the representative symbol (for example, a non-representative symbol with a code length of 2 bits).

[0269] Therefore, the sibling symbol code length modification unit 382 selects a non-representative symbol that has the same intermediate node 821 as the representative symbol "R" as its parent. In the example shown in Fig. 30, the non-representative symbol "a" is selected. Then, the sibling symbol code length modification unit 382 selects, from among the non-representative symbols, the non-representative symbol that has the longest code length that is less than the maximum code length. In the example shown in Fig. 30, the non-representative symbol "g" is selected.

[0270] The sibling symbol code length modification unit 382 modifies the code length of non-representative symbol "a" to the code length of non-representative symbol "g" plus 1 (=3+1=4 bits). Then, the sibling symbol code length modification unit 382 increments the code length of non-representative symbol "g" by 1 to modify it to 4 bits.

[0271] Fig. 31 shows a modification of the Huffman tree 80 shown in Fig. 30. This modification shows a Huffman tree 80 in which the code lengths of the non-representative symbols "a" and "g" have been changed by the sibling symbol code length change unit 382 described above. That is, in the modified Huffman tree 80, the code lengths of the non-representative symbols "a" and "g" are set to 4 bits. The non-representative symbols "a" and "g" are assigned to leaf nodes 843 and 844, respectively, which have the same intermediate node 838 as their parent.

[0272] Since the code length of the non-representative symbol "a" has changed (i.e., the leaf node to which the non-representative symbol "a" is assigned has changed from leaf node 832 to leaf node 843), the only leaf node that has intermediate node 821 as a parent is leaf node 831 of representative symbol "R". In this case, intermediate node 821 and leaf node 831 can be merged. Therefore, representative symbol code length change unit 383 decrements the code length of representative symbol "R" by 1 and changes it to 2 bits.

[0273] Fig. 32 shows a modification of the Huffman tree 80 shown in Fig. 31. This modification shows a Huffman tree 80 in which the code length of the representative symbol "R" has been changed by the representative symbol code length change unit 383 described above. That is, in the modified Huffman tree 80, the code length of the representative symbol "R" is set to 2 bits. The representative symbol "R" is assigned to a leaf node 821 that has been changed from the intermediate node 821 that was its parent.

[0274] Next, the representative symbol constraint processing end determination unit 384 determines whether the code length of the representative symbol "R" is equal to or shorter than the maximum representative symbol code length. Since the code length of the representative symbol "R" (=2) is longer than the maximum representative symbol code length (=1), the representative symbol constraint processing end determination unit 384 determines to change the code lengths of the sibling symbols and the representative symbol again.

[0275] The sibling symbol code length change unit 382 attempts to select a non-representative symbol that has the same intermediate node as the representative symbol "R" as its parent. However, in the Huffman tree 80, there is no non-representative symbol that has the same intermediate node as the representative symbol "R" as its parent. In this case, the sibling symbol code length change unit 382 selects a non-representative symbol that transitively has the same intermediate node as the representative symbol "R" as its parent. In FIG. 32, two non-representative symbols "b" and "c" (leaf nodes 833 and 834) that transitively have the intermediate node 811, which is the parent of the representative symbol "R", as their parent are selected. In other words, 2 (=2 1 ) non-representative symbols “b” and “c” are selected.

[0276] Next, the sibling symbol code length change unit 382 selects two non-representative symbols from the non-representative symbols that are less than the maximum code length and in ascending order of code length. In Fig. 32, the non-representative symbols "f" and "e" are selected.

[0277] The sibling symbol code length modification unit 382 modifies the code length of the selected non-representative symbol "b" to the code length of the non-representative symbol "f" plus 1 (=3+1=4 bits). Then, the sibling symbol code length modification unit 382 increments the code length of the non-representative symbol "f" by 1 to modify it to 4 bits.

[0278] Furthermore, the sibling symbol code length modification unit 382 modifies the code length of the selected non-representative symbol "c" to the code length of the non-representative symbol "e" plus 1 (=3+1=4 bits).Then, the sibling symbol code length modification unit 382 increments the code length of the non-representative symbol "e" by 1 to modify it to 4 bits.

[0279] Fig. 33 shows a modification of the Huffman tree 80 shown in Fig. 32. This modification shows a Huffman tree 80 in which the code lengths of the non-representative symbols "b", "f", "c", and "e" have been changed by the sibling symbol code length change unit 382 described above. That is, in the modified Huffman tree 80, the code lengths of the non-representative symbols "b", "f", "c", and "e" are set to 4 bits. The non-representative symbols "f" and "b" are assigned to leaf nodes 849 and 84A, respectively, which have the same intermediate node 837 as a parent. The non-representative symbols "e" and "c" are assigned to leaf nodes 847 and 848, respectively, which have the same intermediate node 836 as a parent.

[0280] Since the code lengths of the non-representative symbols "b" and "c" have been changed (i.e., the leaf node to which the non-representative symbol "b" is assigned has been changed from leaf node 833 to leaf node 84A, and the leaf node to which the non-representative symbol "c" is assigned has been changed from leaf node 834 to leaf node 848), the leaf node having intermediate node 811 as a parent is only leaf node 821 of representative symbol "R". In this case, the binary tree consisting of redundant intermediate node 822, leaf node 821, and intermediate node 811 can be merged. Therefore, representative symbol code length change unit 383 decrements the code length of representative symbol "R" by 1 and changes it to 1 bit.

[0281] Fig. 34 shows a modification of the Huffman tree 80 shown in Fig. 33. This modification shows a Huffman tree 80 in which the code length of the representative symbol "R" has been changed by the representative symbol code length change unit 383 described above. That is, in the modified Huffman tree 80, the code length of the representative symbol "R" is set to 1 bit. The representative symbol "R" is assigned to a leaf node 811 that has been changed from the intermediate node 811 that was its parent.

[0282] Next, the representative symbol constraint processing end determination unit 384 determines whether the code length of the representative symbol "R" is equal to or less than the maximum representative symbol code length. Since the code length (=1) of the representative symbol "R" is equal to or less than the maximum representative symbol code length (=1), the representative symbol constraint processing end determination unit 384 determines to end the processing of changing the code lengths of the representative symbol and sibling symbols.

[0283] 34 is a valid Huffman tree, and all intermediate nodes have two child nodes. Therefore, a Huffman code determined based on the Huffman tree 80 satisfies the Kraft inequality and has no redundant code assignments. In other words, a Huffman code determined based on the Huffman tree 80 is a perfect code.

[0284] An example of a procedure for maximum code length constraint processing will be described with reference to FIGS.

[0285] 35 is a flowchart showing an example of the procedure of maximum code length constraint processing executed in the maximum code length constraint unit 326. The maximum code length constraint unit 326 performs maximum code length constraint processing on L pairs of <non-representative symbol, code length> sent from the code length determination unit 325 and one pair of <representative symbol, code length>.

[0286] First, the maximum code length constraint unit 326 changes the code length of the non-representative symbol, which is longer than the maximum code length, to the maximum code length (step S501). Next, the maximum code length constraint unit 326 determines whether the code length of the representative symbol is longer than the maximum representative symbol code length (step S502).

[0287] If the code length of the representative symbol is equal to or less than the maximum code length of the representative symbol (No in step S502), the process by the maximum code length constraint unit 326 proceeds to step S507.

[0288] If the code length of the representative symbol is longer than the maximum code length of the representative symbol (Yes in step S502), the maximum code length constraint unit 326 determines whether or not there is a non-representative symbol whose code length is equal to or shorter than the maximum code length of the representative symbol (step S503).

[0289] If there is a non-representative symbol whose code length is equal to or shorter than the maximum representative symbol code length (Yes in step S503), the maximum code length constraint unit 326 selects the non-representative symbol whose code length is equal to or shorter than the maximum representative symbol code length (step S505). The maximum code length constraint unit 326 replaces the code length of the selected non-representative symbol with the code length of the representative symbol (step S506) and proceeds to step S507.

[0290] If there is no non-representative symbol whose code length is equal to or less than the representative symbol maximum code length (No in step S503), the maximum code length constraint unit 326 performs swap and code length change processing (step S504) and proceeds to step S507. The swap and code length change processing is processing for constraining the code length of the representative symbol to be equal to or less than the representative symbol maximum code length by swapping the code lengths of the representative symbol and non-representative symbols, changing the code lengths of the sibling symbols of the representative symbol, and changing the code length of the representative symbol. Specific steps of the swap and code length change processing will be described later with reference to the flowchart in FIG.

[0291] The subsequent procedures from step S507 to step S510 are the same as the procedures from step S305 to step S308 of the maximum code length constraining process described above with reference to Fig. 24. That is, the maximum code length constraining unit 326 performs processing to change the code length of the violating symbol to be equal to or less than the maximum code length.

[0292] By the above maximum code length constraint process, the maximum code length constraint unit 326 can constrain the code length of the non-representative symbol to the maximum code length or less, and can also constrain the code length of the representative symbol to the representative symbol maximum code length or less. By constraining the code length of the representative symbol to the representative symbol maximum code length or less, the code length of the symbol represented by the representative symbol (i.e., the merge symbol) can be constrained to the maximum code length or less.

[0293] Fig. 36 is a flowchart showing an example of the procedure of swap and code length change processing executed in the maximum code length constraining unit 326. The swap and code length change processing corresponds to step S504 of the maximum code length constraining processing described above with reference to Fig. 35. The maximum code length constraining unit 326 executes swap and code length change processing when there is no non-representative symbol whose code length is equal to or less than the representative symbol maximum code length.

[0294] First, the maximum code length constraint unit 326 determines whether or not there is a non-representative symbol whose code length is shorter than the code length of the representative symbol (step S601).

[0295] If there is no non-representative symbol whose code length is shorter than the code length of the representative symbol (No in step S601), the process by the maximum code length constraint unit 326 proceeds to step S604.

[0296] If there is a non-representative symbol whose code length is shorter than that of the representative symbol (Yes in step S601), the maximum code length constraint unit 326 selects the non-representative symbol whose code length is the shortest among the non-representative symbols whose code length is shorter than that of the representative symbol (step S602).The maximum code length constraint unit 326 replaces the code length of the selected non-representative symbol with the code length of the representative symbol (step S603) and proceeds to step S604.

[0297] Next, the maximum code length constraint unit 326 determines whether or not a symbol having the same intermediate node as the representative symbol as a parent is a symbol having two intermediate nodes that transitively have the same intermediate node as the representative symbol as a parent. D Non-representative symbols s (i.e., 2 D sibling symbols s) are selected (step S604).

[0298] The maximum code length constraint unit 326 selects two non-representative symbols in ascending order of code length that are less than the maximum code length. D The non-representative symbols s' are selected (step S605). Then, the maximum code length constraint unit 326 sets the variable i to 1 (step S606). The variable i is D The i-th sibling symbol s from the beginning of the sibling symbols s and 2 D This is a variable for identifying the i-th non-representative symbol s' from the beginning of the non-representative symbols s'.

[0299] The maximum code length constraining unit 326 changes the code length of the i-th sibling symbol s to the code length of the i-th non-representative symbol s' plus 1 (step S607). The maximum code length constraining unit 326 increments the code length of the i-th non-representative symbol s' by 1 (step S608). The maximum code length constraining unit 326 increments the variable i by 1 (step S609). Then, when the variable i is 2 D It is determined whether it is greater than or equal to (step S610).

[0300] Variable i is 2 D If it is equal to or less than the selected 2 (No in step S610), the maximum code length constraining unit 326 returns to step S607 and performs a further procedure to change the code length of the i-th sibling symbol s and the code length of the i-th non-representative symbol s'. D The code length of the sibling symbols s and 2 D The procedures from step S607 to step S609 are repeated until the code lengths of all the non-representative symbols s' have been changed.

[0301] Variable i is 2 D If it is greater (Yes in step S610), the maximum code length constraint unit 326 decrements the code length of the representative symbol by 1 (step S611). Then, the maximum code length constraint unit 326 determines whether the code length of the representative symbol is equal to or less than the maximum code length of the representative symbol (step S612).

[0302] If the code length of the representative symbol is longer than the maximum code length of the representative symbol (No in step S612), the process by the maximum code length constraining unit 326 returns to step S604. That is, the maximum code length constraining unit 326 further performs a procedure of changing the code length of the sibling symbol of the representative symbol in order to shorten the code length of the representative symbol.

[0303] If the code length of the representative symbol is equal to or less than the maximum code length of the representative symbol (Yes in step S612), the maximum code length constraint unit 326 ends the swap and code length change process.

[0304] By the above swap / code length changing process, even if there is no non-representative symbol whose code length is equal to or less than the representative symbol maximum code length, the maximum code length constraint unit 326 can constrain the code length of the representative symbol to equal to or less than the representative symbol maximum code length. Furthermore, even if there is no non-representative symbol whose code length is shorter than the representative symbol code length, the maximum code length constraint unit 326 can constrain the code length of the representative symbol to equal to or less than the representative symbol maximum code length.

[0305] Third embodiment The maximum code length constraining unit 326 of the third embodiment, like the maximum code length constraining unit 326 of the second embodiment, has a configuration for changing the code lengths of the representative symbol and non-representative symbols to make the code length of the representative symbol equal to or shorter than the maximum code length of the representative symbol in a case where the code length of the representative symbol is longer than the maximum code length of the representative symbol and there is no non-representative symbol that satisfies the condition that the code length is equal to or shorter than the maximum code length of the representative symbol.

[0306] The configuration of the variable length coding device 15 according to the third embodiment is similar to that of the variable length coding device 15 according to the first and second embodiments. The variable length coding device 15 according to the third embodiment is different from the variable length coding device 15 according to the first and second embodiments in the procedure for changing the code lengths of the representative symbols and non-representative symbols in the above-mentioned case in order to restrict the code length of the representative symbol to be equal to or less than the maximum code length of the representative symbol. The following mainly describes the points that are different from the second embodiment.

[0307] The maximum code length constraint unit 326 of the variable length coding device 15 performs processing (maximum code length constraint processing) to constrain the code length corresponding to the symbol to be equal to or less than the maximum code length, using the maximum value of the added code length sent from the merge symbol added code length determination unit 354, and H <non-representative symbol, code length> pairs and one <representative symbol, code length> pair sent from the code length determination unit 325. In other words, the maximum code length constraint unit 326 performs maximum code length constraint processing, using H <non-representative symbol, code length> pairs and one <representative symbol, code length, maximum value of added code length> pair.

[0308] 37 is a block diagram showing an example of the configuration of the maximum code length constraining unit 326. The maximum code length constraining unit 326 includes, for example, a code length sorting unit 371, a code length clipping unit 372, a representative symbol swapping unit 373, an intermediate node selecting unit 391, a transitive leaf code length changing unit 392, a representative symbol code length changing unit 393, a violation symbol number calculating unit 374, an end determining unit 375, a code length changing unit 376, and a violation symbol number decrementing unit 377.

[0309] The operations of the code length sorting unit 371, code length clipping unit 372, representative symbol swapping unit 373, violation symbol count calculation unit 374, termination determination unit 375, code length changing unit 376, and violation symbol count decrement unit 377 are as described above with reference to Fig. 18. More specifically, the operation when the representative symbol swapping unit 373 swaps the code length of the representative symbol with the code length of a non-representative symbol that is less than the maximum representative symbol code length is as described in the maximum code length constraint processing of the first embodiment.

[0310] When the code length of the representative symbol is longer than the maximum code length of the representative symbol, if there is no code length of the non-representative symbol that is equal to or shorter than the maximum code length of the representative symbol, the representative symbol swap unit 373 does not swap the code length of the representative symbol with the code length of the non-representative symbol. Below, an operation of the case where the code length of the representative symbol is longer than the maximum code length of the representative symbol and there is no code length of the non-representative symbol that is equal to or shorter than the maximum code length of the representative symbol will be described.

[0311] After processing by the representative symbol swap unit 373, the intermediate node selection unit 391, the transitive leaf code length modification unit 392, and the representative symbol code length modification unit 393 perform processing (representative symbol constraint processing) to constrain the code length of the representative symbol to be equal to or less than the maximum code length of the representative symbol.

[0312] First, the intermediate node selection unit 391 selects one intermediate node in the Huffman tree generated by the Huffman tree generation unit 324, the depth from the root node being equal to the maximum code length of the representative symbol.

[0313] The transitive leaf code length modification unit 392 identifies all leaf nodes that can be reached by tracing from the selected intermediate node in the child node direction. A leaf node that can be reached by tracing from an intermediate node in the child node direction is called a transitive leaf node. The child node direction is a deeper direction.

[0314] The transitive leaf code length modification unit 392 modifies the code length of one of the non-representative symbols assigned to the identified transitive leaf node to the code length of the representative symbol. The transitive leaf code length modification unit 392 modifies the code lengths of the remaining non-representative symbols assigned to the transitive leaf node to the maximum code length.

[0315] Then, the representative symbol code length change unit 393 changes the code length of the representative symbol to the maximum representative symbol code length.

[0316] The subsequent operations of violation symbol number calculation unit 374, termination determination unit 375, code length change unit 376, and violation symbol number decrement unit 377 are the same as those described above as the maximum code length constraint processing in the first embodiment.

[0317] With the above configuration, the maximum code length constraint unit 326 can constraint the code length of the representative symbol to be equal to or less than the representative symbol maximum code length even in cases where there is no non-representative symbol that satisfies the condition that the code length is equal to or less than the representative symbol maximum code length.

[0318] 38 to 40, a specific example will be described in which the code length is restricted to be equal to or less than the maximum code length in the maximum code length restricting unit 326. Here, it is assumed that the maximum code length is 4 bits.

[0319] FIG. 38 shows an example of a Huffman tree generated in the maximum code length constraint unit 326.

[0320] The Huffman tree 90 is generated based on the frequency of occurrence of each of the seven non-representative symbols "a", "b", "c", "d", "e", "f", and "g" (hereinafter referred to as non-representative symbols "a" to "g") and the frequency of occurrence of one representative symbol "R". The non-representative symbols "a" to "g" are assigned to leaf nodes 932, 933, 934, 935, 936, 937, and 938, respectively. The representative symbol "R" is assigned to leaf node 931. In the Huffman tree 90, the code length of the non-representative symbols "a" to "g" is 3 bits. The code length of the representative symbol "R" is also 3 bits.

[0321] The edges and nodes indicated by dotted lines represent a subtree 95 corresponding to merge symbols "h", "i", "j", and "k" (hereinafter, merge symbols "h" to "k"). Subtree 95 is a subtree having representative symbol "R" (leaf node 931) as a root node and each of merge symbols "h" to "k" as a leaf node. Merge symbols "h" to "k" are assigned to leaf nodes 951, 952, 953, and 954, respectively. The code length of merge symbols "h" to "k" is 5 bits. Therefore, for these merge symbols "h" to "k", the maximum code length to be added to the code length of representative symbol "R" (additional code length) is 2 (=5-3).

[0322] In the Huffman tree 90, the length obtained by adding the code length of the representative symbol "R" to the maximum added code length is longer than the maximum code length (i.e., 3+2>4). Therefore, the representative symbol swap unit 373 attempts to select a non-representative symbol with a code length equal to or less than the representative symbol maximum code length (=4-2=2) obtained by subtracting the maximum added code length from the maximum code length. However, the Huffman tree 90 does not have a non-representative symbol that satisfies the condition that the code length is equal to or less than the representative symbol maximum code length.

[0323] Therefore, the intermediate node selection unit 391 selects an intermediate node whose depth from the root node 901 is equal to the maximum code length of the representative symbol. In Fig. 38, intermediate node 924 whose depth from the root node 901 is 2 is selected. Note that the intermediate node selection unit 391 excludes from the selection targets the intermediate node that is the parent or transitive parent of leaf node 931 to which the representative symbol "R" is assigned. In Fig. 38, intermediate nodes 911, 921, and 922 are excluded from the selection targets of the intermediate node selection unit 391.

[0324] The transitive leaf codelength modification unit 392 identifies all leaf nodes (i.e., transitive leaf nodes) that can be reached by tracing from the selected intermediate node 924 toward the child nodes. In FIG. 38, leaf node 937 and leaf node 938 are identified.

[0325] The transitive leaf codelength modification unit 392 selects one non-representative symbol from the non-representative symbols "f" and "g" respectively assigned to the identified leaf node 937 and leaf node 938. In Fig. 38, the non-representative symbol "f" is selected.

[0326] The transitive leaf code length modification unit 392 modifies the code length of the selected non-representative symbol "f" to the code length (=3 bits) of the representative symbol "R." The transitive leaf code length modification unit 392 also modifies the code lengths of all remaining non-representative symbols (here, non-representative symbol "g") assigned to the transitive leaf nodes to the maximum code length.

[0327] Then, the representative symbol code length change unit 393 changes the code length of the representative symbol "R" to the representative symbol maximum code length (that is, the depth of the selected intermediate node 924).

[0328] Fig. 39 shows a modification of the Huffman tree 90 shown in Fig. 38. This modification shows a Huffman tree 90 in which the code lengths of the non-representative symbols "f" and "g" have been changed by the transitive leaf code length change unit 392, and the code length of the representative symbol "R" has been changed by the representative symbol code length change unit 393, as described above.

[0329] In the transformed Huffman tree 90, the code length of the non-representative symbol "f" is set to the original code length (=3 bits) of the representative symbol "R". The code length of the representative symbol "R" is set to the maximum representative symbol code length (=2 bits). The code length of the non-representative symbol "g" is set to the maximum code length (=4 bits).

[0330] Since the code length of representative symbol "R" is set to the maximum code length of the representative symbol, the code lengths of merge symbols "h" to "k" respectively assigned to leaf nodes 943, 944, 945, and 946 of subtree 95 are less than or equal to the maximum code length. However, since leaf node 947 is a node that cannot be traced back from root node 901, non-representative symbol "g" assigned to leaf node 947 is a violation symbol.

[0331] In this case, violation symbol number calculation section 374 calculates the number of violation symbols I in accordance with the above-mentioned equation (7) (or equation (8)) as follows: I = (1 / 4 + 1 / 8 x 6 + 1 / 16 - 1) x 16 = 1

[0332] Since the calculated number of violation symbols I is greater than 0, code length modification section 376 modifies the code lengths of non-representative symbols until the number of violation symbols becomes zero.

[0333] Specifically, the code length modification unit 376 selects the violation symbol "g". Then, the code length modification unit 376 selects the non-representative symbol "f" whose code length is shorter than the maximum code length. Note that, when there are multiple non-representative symbols whose code length is shorter than the maximum code length, the code length modification unit 376 selects the non-representative symbol from the multiple non-representative symbols in order of longest code length.

[0334] The code length modification unit 376 modifies the code length of the selected violation symbol "g" to a length obtained by adding 1 to the code length of the selected non-representative symbol "f" (=3+1=4 bits). Then, the code length modification unit 376 increments the code length of the non-representative symbol "f" by 1 to modify it to 4 bits.

[0335] Next, violation symbol number decrement unit 377 decrements violation symbol number I by 1, updating it to 0. Since the updated violation symbol number I is 0, end determination unit 375 determines to end changing the code lengths of non-representative symbols.

[0336] Fig. 40 shows a modification of the Huffman tree 90 shown in Fig. 39. This modification shows a Huffman tree 90 in which the code lengths of the non-representative symbol "f" and the violation symbol "g" have been changed by the code length change unit 376 described above. That is, in the modified Huffman tree 90, the code length of the non-representative symbol "f" and the code length of the violation symbol "g" are set to 4 bits. Furthermore, this Huffman tree 90 does not have any violation symbols.

[0337] This Huffman tree 90 is a valid Huffman tree, and every intermediate node has two child nodes. Therefore, a Huffman code determined based on the Huffman tree 90 satisfies the Kraft inequality and has no redundant code assignments (i.e., K=1). In other words, a Huffman code determined based on the Huffman tree 90 is a perfect code.

[0338] An example of a procedure for maximum code length constraint processing will be described with reference to Figs.

[0339] 41 is a flowchart showing an example of the procedure of maximum code length constraint processing executed in the maximum code length constraint unit 326. The maximum code length constraint unit 326 performs maximum code length constraint processing on L pairs of <non-representative symbol, code length> sent from the code length determination unit 325 and one pair of <representative symbol, code length>.

[0340] First, the maximum code length constraint unit 326 changes the code length of the non-representative symbol, which is longer than the maximum code length, to the maximum code length (step S701). Next, the maximum code length constraint unit 326 determines whether the code length of the representative symbol is longer than the maximum representative symbol code length (step S702).

[0341] If the code length of the representative symbol is equal to or less than the maximum code length of the representative symbol (No in step S702), the process by the maximum code length constraint unit 326 proceeds to step S707.

[0342] If the code length of the representative symbol is longer than the maximum code length of the representative symbol (Yes in step S702), the maximum code length constraint unit 326 determines whether or not there is a non-representative symbol whose code length is equal to or shorter than the maximum code length of the representative symbol (step S703).

[0343] If there is a non-representative symbol whose code length is equal to or shorter than the representative symbol maximum code length (Yes in step S703), the maximum code length constraint unit 326 selects the non-representative symbol whose code length is equal to or shorter than the representative symbol maximum code length (step S705). The maximum code length constraint unit 326 replaces the code length of the selected non-representative symbol with the code length of the representative symbol (step S706) and proceeds to step S707.

[0344] If there is no non-representative symbol whose code length is equal to or less than the representative symbol maximum code length (No in step S703), the maximum code length constraint unit 326 performs a second code length change process (step S704) and proceeds to step S707. The second code length change process is a process for identifying an intermediate node having a depth from the root node equivalent to the representative symbol maximum code length, and changing the code length of the non-representative symbol assigned to the transitive leaf node of this intermediate node and the code length of the representative symbol to change the code length of the representative symbol to or less than the representative symbol maximum code length. A specific procedure for the second code length change process will be described later with reference to the flowchart in FIG.

[0345] The subsequent procedures from step S707 to step S710 are the same as the procedures from step S305 to step S308 of the maximum code length constraining process described above with reference to Fig. 24. That is, the maximum code length constraining unit 326 performs a process for changing the code length of the violation symbol to be equal to or less than the maximum code length.

[0346] By the above maximum code length constraint process, the maximum code length constraint unit 326 can constrain the code length of the non-representative symbol to the maximum code length or less, and can constrain the code length of the representative symbol to the representative symbol maximum code length or less. By constraining the code length of the representative symbol to the representative symbol maximum code length or less, the code length of the symbol represented by the representative symbol (i.e., the merge symbol) can be constrained to the maximum code length or less.

[0347] Fig. 42 is a flowchart showing an example of the procedure of the second code length change process executed in the maximum code length constraining unit 326. The second code length change process corresponds to step S704 of the maximum code length constraining process described above with reference to Fig. 41. The maximum code length constraining unit 326 executes the second code length change process when there is no non-representative symbol whose code length is equal to or less than the representative symbol maximum code length.

[0348] First, the maximum code length constraint unit 326 selects an intermediate node whose depth from the root node is equal to the representative symbol maximum code length (step S801). The maximum code length constraint unit 326 identifies non-representative symbols assigned to all leaf nodes (transitive leaf nodes) that can be reached by tracing from the selected intermediate node toward the child node (step S802). The maximum code length constraint unit 326 selects one non-representative symbol from the identified non-representative symbols (step S803).

[0349] The maximum code length constraint unit 326 changes the code length of the selected non-representative symbol to the code length of the representative symbol (step S804). The maximum code length constraint unit 326 changes the code lengths of the remaining non-representative symbols, excluding the non-representative symbol selected in step S803, from all non-representative symbols assigned to the transitive leaf node, to the maximum code length (step S805). Then, the maximum code length constraint unit 326 changes the code length of the representative symbol to the maximum representative symbol code length (step S806), and ends the second code length change process.

[0350] By the above second code length change process, the maximum code length constraint unit 326 can constraint the code length of the representative symbol to be equal to or shorter than the representative symbol maximum code length even when there is no non-representative symbol whose code length is equal to or shorter than the representative symbol maximum code length.

[0351] Identifying the non-representative symbols assigned to the transitive leaf nodes in step S802 of the second code length change process shown in Fig. 42 may require a large amount of calculations when performed for any Huffman tree. However, in cases where a specific combination of the maximum code length, the number of non-representative symbols, the code length of the representative symbol, and the maximum value of the added code length is used, the pattern of the Huffman tree structure is limited, so that the non-representative symbols assigned to the transitive leaf nodes can be identified with a small amount of calculations.

[0352] With reference to Fig. 43 to Fig. 46, an example will be described in which the pattern of the Huffman tree structure is limited in a case where a specific combination of the maximum code length, the number of non-representative symbols, the code length of the representative symbol, and the maximum value of the added code length is used. Here, a case is assumed in which the maximum code length is 3, the number of non-representative symbols is 8, the code length of the representative symbol is 3, and the maximum value of the added code length is 2. The maximum code length is generally fixed to a value specified by a compression standard or the like. Also, the number of non-representative symbols when a Huffman tree is generated using a representative symbol is a predetermined fixed value. Therefore, the assumption that the maximum code length and the number of non-representative symbols are fixed is valid. That is, in Fig. 43 to Fig. 46, under this assumption, a case is assumed in which the code length of the representative symbol in the generated Huffman tree is 3, and the maximum value of the added code length is 2. In this case, the maximum code length of the representative symbol is 1 (=3-2) obtained by subtracting the maximum value of the added code length from the maximum code length. Therefore, the code length of the representative symbol is longer than the maximum code length of the representative symbol (3>1), violating the constraint of the maximum code length of the representative symbol. In other words, the code length of the merge symbol represented by the representative symbol violates the constraint of the maximum code length.

[0353] In such a case, consider that after clipping the code length of the non-representative symbol, there is no non-representative symbol that can be swapped with the representative symbol, and the violation of the constraint on the maximum code length of the representative symbol is not resolved. A non-representative symbol that can be swapped with the representative symbol is a non-representative symbol whose code length is equal to or less than the maximum code length of the representative symbol. In other words, in this case, there is no non-representative symbol whose code length is equal to or less than the maximum code length of the representative symbol (i.e., a non-representative symbol whose code length is 1). Furthermore, since the maximum code length is 3, the minimum value of the code length of a non-representative symbol is either 2 or 3. Therefore, the Huffman tree structure assumed in this case is limited to the four patterns shown in Figures 43 to 46.

[0354] 43 shows a first pattern of the Huffman tree assumed in the above case. The first pattern corresponds to the case where the minimum code length of the non-representative symbol is 3.

[0355] In this case, by selecting any four non-representative symbols from the non-representative symbols shown in the Huffman tree 90, it is possible to select non-representative symbols corresponding to all leaf nodes reachable by tracing from the selected intermediate node (e.g., intermediate node 912) in the direction of the child nodes. In the example shown in Fig. 43, non-representative symbols "d", "e", "f", and "g" are selected. Note that intermediate nodes that are transitive parents of the representative symbol "R" (intermediate nodes 911 and 921 in Fig. 43) are excluded from the intermediate nodes selected by the intermediate node selection unit 391.

[0356] 44 shows the second pattern of the Huffman tree assumed in the above case. The second pattern corresponds to the case where the minimum code length of the non-representative symbol is 2 and there is one non-representative symbol with a code length of 2.

[0357] In this case, by selecting one non-representative symbol with a code length of 2 and any two non-representative symbols with a code length of 3 from the non-representative symbols shown in the Huffman tree 90, it is possible to select non-representative symbols corresponding to all leaf nodes that can be reached by tracing from the selected intermediate node in the direction of the child nodes. In the example shown in Figure 44, the non-representative symbols "d", "e", and "f" are selected.

[0358] 45 shows a third pattern of the Huffman tree that is assumed in the above case. The third pattern corresponds to the case where the minimum code length of the non-representative symbol is 2, and there are two non-representative symbols with a code length of 2.

[0359] In this case, by selecting two non-representative symbols with a code length of 2 from the non-representative symbols shown in the Huffman tree 90, it is possible to select non-representative symbols corresponding to all leaf nodes that can be reached by tracing from the selected intermediate node in the direction of the child nodes. In the example shown in Figure 45, the non-representative symbols "d" and "f" are selected.

[0360] 46 shows a fourth pattern of the Huffman tree assumed in the above case. The fourth pattern corresponds to the case where the minimum code length of the non-representative symbol is 2 and there are two non-representative symbols with a code length of 2, but is a pattern different from the third pattern.

[0361] In the example shown in Figure 46, non-representative symbols "d" and "f" are also selected. In the fourth pattern, the nodes to which the non-representative symbols "b" and "c" are assigned are different from those in the third pattern.

[0362] In this way, the maximum code length constraining unit 326 of the third embodiment can specify non-representative symbols corresponding to all leaf nodes reachable by tracing from the selected intermediate node toward the child node with a small amount of calculation in a case where a specific combination of the maximum code length, the number of non-representative symbols, the code length of the representative symbol, and the maximum value of the added code length is used. As described above, even in the case of an example in which a Huffman tree structure is shown and symbols are assigned to leaf nodes, the maximum code length constraining unit 326 does not need to actually hold the Huffman tree structure and the correspondence between the leaf nodes and the symbols. If the maximum code length constraining unit 326 holds, for example, a list of a <representative symbol, code length> pair and a <non-representative symbol, code length> pair, it can select symbols in the maximum code length constraining unit 326 and change the code length.

[0363] As described above, according to the first to third embodiments, when a codeword having a code length equal to or less than an upper limit and being a perfect code is assigned to a symbol, the processing time and processing resources can be reduced. The frequency table generating unit 321 generates a frequency table indicating N symbols and N occurrence frequencies associated with the N symbols, based on the occurrence frequency of each of the input symbols. The Huffman tree generating unit 324 generates a Huffman tree based on the frequency table. The code length determining unit 325 determines N code lengths corresponding to the N symbols, respectively, based on the Huffman tree. When the N code lengths include a first code length longer than the maximum code length, the maximum code length constraint unit 326 selects at least one first symbol corresponding to the first code length from the N symbols, selects at least one second symbol corresponding to a second code length less than the maximum code length from the N symbols, changes the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length, and changes the first code length corresponding to the first symbol to a code length equal to the changed second code length. The code assignment unit 328 determines N variable length codes to be assigned to the N symbols, respectively, based on the N code lengths. The variable length coding unit 33 converts each of the input symbols into a variable length code, based on the N variable length codes assigned to the N symbols, respectively. N is an integer equal to or greater than 2. The variable length code into which the input symbols are converted has a bit length ranging from 1 bit length to the maximum code length.

[0364] This allows the variable-length coding device 15 to proceed with the maximum code length constraint process while maintaining that the assigned variable-length code is a perfect code. Therefore, the variable-length coding device 15 can guarantee that the variable-length code assigned based on the code length of each symbol is a perfect code at the time when the maximum code length constraint process is completed. Therefore, the code table generation unit 32 of the variable-length coding device 15 can reduce processing time and processing resources compared to, for example, the code table generation unit 32A of the comparative example that additionally performs a merge process.

[0365] Each of the various functions described in the first to third 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 components other than the CPU described in these embodiments may also be realized by a processing circuit.

[0366] 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]

[0367] 1...information processing system, 2...host, 3...memory system, 4...controller, 5...NAND type flash memory, 10...bus, 11...host I / F, 12...CPU, 13...NAND I / F, 14...DRAM I / F, 15...variable length coding device (dynamic Huffman coding unit), 31...buffer unit, 32...code table generation unit, 33...variable length coding unit, 321...frequency table generation unit, 322...frequency sorting unit, 323...symbol merging unit, 324...Huffman tree generation unit, 325...code length determination unit, 326...maximum code length constraint unit, 327...representative symbol expansion unit, 328...code assignment unit, 351...symbol distribution unit, 352...representative symbol frequency estimation unit, 353...merged symbol number counting unit, 354...merged symbol addition code length determination unit, 40...0th frequency table, 41...1st frequency table 431...first partial table, 432...second partial table, 371...code length sorting unit, 372...code length clipping unit, 373...representative symbol swap unit, 374...violating symbol number calculation unit, 375...termination determination unit, 376...code length change unit, 377...violating symbol number decrement unit, 381...second representative symbol swap unit, 382...sibling symbol code length change unit, 383...representative symbol code length change unit, 384...representative symbol constraint processing termination determination unit, 391...intermediate node selection unit, 392...transitive leaf code length change unit, 393...representative symbol code length change unit.

Claims

1. a frequency table generating unit that generates a frequency table indicating N symbols and N occurrence frequencies associated with the N symbols, based on the occurrence frequency of each of the input symbols; a Huffman tree generator for generating a Huffman tree based on the frequency table; a code length determination unit that determines N code lengths corresponding to the N symbols, respectively, based on the Huffman tree; If the N code lengths include a first code length that is longer than the maximum code length, selecting at least one first symbol from the N symbols corresponding to the first code length; selecting at least one second symbol from the N symbols corresponding to a second code length less than the maximum code length; changing the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length; a code length constraint unit that changes the first code length corresponding to the first symbol to a code length equal to the changed second code length; a code assignment unit that determines N variable length codes to be assigned to the N symbols, respectively, based on the N code lengths; a coding unit that converts each of the input symbols into a variable length code based on the N variable length codes respectively assigned to the N symbols, The N is an integer of 2 or more, the variable length code into which the input symbols are converted has a bit length ranging from 1 bit to the maximum code length; Variable length coding device.

2. Dividing L symbols of the N symbols into M symbol sets; A representative symbol generating unit generates M representative symbols each representing the M symbol sets, the Huffman tree generator generates the Huffman tree based on the frequency of occurrence of each of H symbols remaining after excluding the L symbols from the N symbols and the frequency of occurrence of each of the M representative symbols; the code length determination unit determines, based on the Huffman tree, H code lengths respectively corresponding to the H symbols and M code lengths respectively corresponding to the M representative symbols; The code length constraint unit When a third code length corresponding to a first representative symbol among the M representative symbols is longer than a representative symbol maximum code length and the H symbols include a third symbol corresponding to a fourth code length equal to or shorter than the representative symbol maximum code length, the first representative symbol is changed to correspond to the fourth code length and the third symbol is changed to correspond to the third code length; when the H code lengths include the first code length longer than the maximum code length, selecting the at least one first symbol corresponding to the first code length from the H symbols, selecting the at least one second symbol corresponding to the second code length less than the maximum code length from the H symbols, changing the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length, and changing the first code length corresponding to the first symbol to a code length equal to the changed second code length; The L is an integer of 1 or more, The M is an integer of 1 or more, The H is an integer of 1 or more.

2. A variable length coding device according to claim 1.

3. Dividing L symbols of the N symbols into M symbol sets; A representative symbol generating unit generates M representative symbols each representing the M symbol sets, the Huffman tree generator generates the Huffman tree based on the frequency of occurrence of each of H symbols remaining after excluding the L symbols from the N symbols and the frequency of occurrence of each of the M representative symbols; the code length determination unit determines, based on the Huffman tree, H code lengths respectively corresponding to the H symbols and M code lengths respectively corresponding to the M representative symbols; The code length constraint unit When a third code length corresponding to a first representative symbol among the M representative symbols is longer than a representative symbol maximum code length and the H symbols do not include a symbol corresponding to a code length equal to or shorter than the representative symbol maximum code length, a third symbol corresponding to a fourth code length equal to the third code length is selected from the H symbols, the third code length corresponding to the first representative symbol is changed to a code length decreased by 1, and the fourth code length corresponding to the third symbol is changed to a longer code length; If the changed third code length is longer than the maximum code length of the representative symbol, selecting two symbols from the H symbols, each of which corresponds to a fifth code length equal to a code length obtained by adding 1 to the changed third code length, further changing the changed third code length corresponding to the first representative symbol to a code length decreased by 1, and changing the fifth code length corresponding to each of the selected two symbols to a longer code length; If the further changed third code length is longer than the maximum code length of the representative symbol, selecting four symbols from the H symbols, each corresponding to a sixth code length equal to a code length obtained by adding 2 to the further changed third code length, changing the further changed third code length corresponding to the first representative symbol to a code length decreased by 1, and changing the sixth code length corresponding to each of the selected four symbols to a longer code length; when the H code lengths include the first code length longer than the maximum code length, selecting the at least one first symbol corresponding to the first code length from the H symbols, selecting the at least one second symbol corresponding to the second code length less than the maximum code length from the H symbols, changing the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length, and changing the first code length corresponding to the first symbol to a code length equal to the changed second code length; The L is an integer of 1 or more, The M is an integer of 1 or more, The H is an integer of 1 or more.

2. A variable length coding device according to claim 1.

4. Dividing L symbols of the N symbols into M symbol sets; A representative symbol generating unit generates M representative symbols each representing the M symbol sets, the Huffman tree generator generates the Huffman tree based on the frequency of occurrence of each of H symbols remaining after excluding the L symbols from the N symbols and the frequency of occurrence of each of the M representative symbols; the code length determination unit determines, based on the Huffman tree, H code lengths respectively corresponding to the H symbols and M code lengths respectively corresponding to the M representative symbols; The code length constraint unit if a third code length corresponding to a first representative symbol among the M representative symbols is longer than a maximum representative symbol code length and the H symbols do not include a symbol corresponding to a code length equal to or shorter than the maximum representative symbol code length, select an intermediate node in the Huffman tree whose depth from a root node is equal to or shorter than the maximum representative symbol code length, select a third symbol assigned to each of all leaf nodes reachable by tracing deeper from the selected intermediate node, change the code length corresponding to the third symbol to a longer code length, and change the third code length corresponding to the first representative symbol to the maximum representative symbol code length; when the H code lengths include the first code length longer than the maximum code length, selecting the at least one first symbol corresponding to the first code length from the H symbols, selecting the at least one second symbol corresponding to the second code length less than the maximum code length from the H symbols, changing the second code length corresponding to the second symbol to a code length obtained by adding 1 to the second code length, and changing the first code length corresponding to the first symbol to a code length equal to the changed second code length; The L is an integer of 1 or more, The M is an integer of 1 or more, The H is an integer of 1 or more.

2. A variable length coding device according to claim 1.

5. The M symbol sets include a first symbol set represented by the first representative symbol, The representative symbol maximum code length is obtained by subtracting f(K(r)) from the maximum code length, where r is the first representative symbol and K(r) is the number of symbols included in the first symbol set. The f is a function of the number K(r) of symbols included in the first symbol set.

5. A variable length coding device according to claim 2.

6. The f(K(r)) is [0010] is defined as 6. A variable length coding device according to claim 5.

7. a code length clipping unit that changes the code lengths of all symbols, among the N symbols, that correspond to code lengths longer than the maximum code length to the maximum code length; a violation symbol number calculation unit for calculating a number I of violation symbols among the N symbols, the code length constraining unit repeats a process of selecting a fourth symbol corresponding to a code length equal to the maximum code length from the N symbols, selecting a fifth symbol corresponding to a code length less than the maximum code length from the N symbols, incrementing the code length corresponding to the fifth symbol by 1, and changing the code length corresponding to the fourth symbol to a code length equal to the increased code length a number of times corresponding to the calculated number I of violation symbols.

5. A variable length coding device according to claim 1.

8. The violation symbol number calculation unit [0025] Calculate the number I of violation symbols according to AllSymbol is a symbol set including the N symbols, s is a symbol that is an element of the symbol set AllSymbol, l(s) is the code length corresponding to symbol s, clip(l(s)) is the maximum code length if the code length l(s) is greater than the maximum code length, and is the code length l(s) if the code length l(s) is less than or equal to the maximum code length; lmax is the maximum code length, 8. A variable length coding device according to claim 7.

9. The L symbols are the lowest L symbols when the N symbols are sorted in descending order of frequency of occurrence.

5. A variable length coding device according to claim 2.

10. The L symbols are symbols obtained by excluding the top H symbols when the N symbols are sorted in descending order of frequency of occurrence from the N symbols.

5. A variable length coding device according to claim 2.

11. The M symbol sets include a first symbol set represented by the first representative symbol, the representative symbol generation unit determines an occurrence frequency of the first representative symbol based on an occurrence frequency of one or more symbols included in the first symbol set.

5. A variable length coding device according to claim 2.

12. The M symbol sets include a first symbol set represented by the first representative symbol, the representative symbol generation unit determines a structure of a subtree including leaf nodes to which all symbols included in the first symbol set are respectively assigned; a code length of the fourth symbol included in the first symbol set is obtained by adding a depth from a root node of the subtree to the leaf node to which the fourth symbol is assigned to a code length corresponding to the first representative symbol.

5. A variable length coding device according to claim 2.

13. The structure of the subtree is a balanced binary tree.

13. A variable length coding device according to claim 12.

14. the representative symbol generation unit determines a structure of the subtree based on an appearance frequency of symbols included in the first symbol set.

13. A variable length coding device according to claim 12.

15. the representative symbol generation unit determines the structure of the subtree by selecting from a tree structure prepared in advance; 13. A variable length coding device according to claim 12.

16. A non-volatile memory; and a controller including the variable length coding device according to any one of claims 1 to 4, the controller writes data including the variable-length codes obtained by converting each of the input symbols into the non-volatile memory; Memory system.

Citation Information

Patent Citations

  • Compression device and control method

    US20220294469A1