摘要 |
PURPOSE:To provide a method and device for encoding variable length code which can limit the code length of a code at the time of variable length encoding. CONSTITUTION:An encoding device 1 is provided with an encoding part 12 for encoding quantized data, code table preparing part 18 for preparing a code table for encoding, and memory 20 for storing the prepared code table. The code table preparing part 18 is provided with a function for calculating the appearance frequency of symbols in the quantized data, sort function for rearranging the calculated appearance frequency in the order of that appearance frequency, and function for preparing a Huffman code by allocating the codes to the sorted symbols. Further, the code table preparing part 18 is provided with a function for deciding whether the prepared Huffman code is within a prescribed code length or not. When it exceeds the prescribed code length, the value of the appearance frequency calculated up to that time is replaced with the other value by an appearance frequency replacing function and based on the new replaced appearance frequency, the code table preparing part 18 conducts processing again so that the Huffman code can be prepared within the prescribed code length. |