JP2002084198A - Method and device for decoding variable-length code, and decoding table - Google Patents

Method and device for decoding variable-length code, and decoding table

Info

Publication number
JP2002084198A
JP2002084198A JP2000274892A JP2000274892A JP2002084198A JP 2002084198 A JP2002084198 A JP 2002084198A JP 2000274892 A JP2000274892 A JP 2000274892A JP 2000274892 A JP2000274892 A JP 2000274892A JP 2002084198 A JP2002084198 A JP 2002084198A
Authority
JP
Japan
Prior art keywords
decoding
state
bit
code
decoded
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2000274892A
Other languages
Japanese (ja)
Inventor
Mitsuo Tamura
光雄 田村
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP2000274892A priority Critical patent/JP2002084198A/en
Publication of JP2002084198A publication Critical patent/JP2002084198A/en
Pending legal-status Critical Current

Links

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

PROBLEM TO BE SOLVED: To enable fast decoding process, using only a table without bit calculation, such as bit shifting with respect to a variable-length code. SOLUTION: With a table in accordance with a condition S of current where a data D is taken out of a variable-length code stream which is to be decoded for each single byte a record of a number indicated by the data D is referenced, so that a decoding data stream V and a next state S' are acquired. By repeating this, a variable-length code stream is decoded sequentially. If, for example, when a data 243 '11110011' is taken out in a normal state 22, remaining bit stream being '1100', a record number 243 on the table 22 is made reference to. The record decodes '11110011' after '1100' and a decoding data stream '11, 3, 0' indicating values provided by decoding codes 11001, 111, and 001 as well as next state 10 where a remaining bit streams is '1' are stored. Thus, the decoded data stream '11, 3, 0' is acquired, before shifting to the next state 10.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、テーブルを用いて
高速に復号を行う可変長符号の復号方法及び装置、並び
に復号テーブルに関し、特に、可変長符号を用いてエン
コードされた動画像や静止画像などのデータのデコード
をソフトウェアで行う際に適するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a decoding method and apparatus for a variable-length code for performing high-speed decoding using a table, and a decoding table, and more particularly to a moving image or a still image encoded using a variable-length code. This is suitable for decoding data such as data by software.

【0002】[0002]

【従来の技術】近年のコンピュータやインターネット等
のネットワーク環境の発展に伴い、動画像、静止画像な
どをデジタル化したデジタルデータの配布、伝送が盛ん
に行われている。これらのデジタルデータはデータ量を
削減するために、圧縮するのが一般的である。例えば動
画像の圧縮方式の一つであるMPEG(Moving Picture
Coding Experts Group)では、動画像のフレームデータ
を離散コサイン変換(DCT)で直交変換した後、DC
T係数の数値を可変長符号で符号化する。可変長符号
は、頻出する数値ほど短い符号長の符号語を割り当てる
ことで全体の符号量を減少させることができる。このよ
うな理由から可変長符号は、データ圧縮で広範に用いら
れている。
2. Description of the Related Art With the recent development of network environments such as computers and the Internet, distribution and transmission of digital data obtained by digitizing moving images, still images, and the like have been actively performed. Such digital data is generally compressed to reduce the amount of data. For example, MPEG (Moving Picture) which is one of the moving image compression methods
Coding Experts Group), after orthogonally transforming the frame data of a moving image by discrete cosine transform (DCT),
The numerical value of the T coefficient is encoded with a variable length code. The variable-length code can reduce the entire code amount by assigning a code word having a shorter code length to a more frequent numerical value. For this reason, variable length codes are widely used in data compression.

【0003】図34は可変長符号の一例を示したもので
ある。図34において、値及び符号語長は10進数で示
し、符号語は2進数で示している。この可変長符号で
は、例えば、値「0」は、符号語長3である符号語「00
1」に符号化し、値「10」は、符号語長5である符号
語「10001」に符号化する。
FIG. 34 shows an example of a variable length code. In FIG. 34, values and codeword lengths are shown in decimal numbers, and codewords are shown in binary numbers. In this variable length code, for example, a value “0” is a code word “00” having a code word length of 3.
The value "10" is encoded into a code word "10001" having a code word length of 5.

【0004】図35は、図34の可変長符号により可変
長符号化されたデータと、その可変長符号を復号したデ
ータを示したものである。可変長符号化されたデータは
20ビットのビット列で、「01100011010111100010」で
あり、この可変長符号を復号したデータは5個の10進
数で、「1,4,2,1,15」である。先頭の3ビッ
ト「011」は、図34で値「1」に対応しており、次は
4ビット「0001」が、値「4」に対応している。以下、
3,3,6ビットのビット列が、順に値「2,1,1
5」に対応している。
FIG. 35 shows data which is variable-length coded by the variable-length code shown in FIG. 34 and data which is obtained by decoding the variable-length code. The variable-length coded data is a 20-bit bit string of “01100011010111100010”, and the data obtained by decoding the variable-length code is five decimal numbers “1,4,2,1,15”. The first three bits “011” correspond to the value “1” in FIG. 34, and the next four bits “0001” correspond to the value “4”. Less than,
The bit strings of 3, 3, and 6 bits sequentially represent the values "2, 1, 1
5 ".

【0005】次に、テーブルを用いて復号を行う方法に
ついて説明する。図36は可変長符号の復号を行うため
のテーブルの一例を示したものである。このテーブル
は、0から63番までのレコードを持っている。それぞ
れのレコードは、レコード番号を6ビットの2進数で表
記したときに、最初に含まれる可変長符号語の値と、そ
の符号語長を使用ビット数として格納している。レコー
ド番号は()内に2進数での表記を示した。例えばレコ
ード番号8番から15番までは、最初の3ビットが「00
1」であり、図34の可変長符号において値0、符号語
長3ビットの符号に対応しており、値0、使用ビット数
3を格納している。このテーブルを用いて復号を行うに
は、まず第1に、ビット列を6ビット取り出し、それを
数値に直した番号のレコードを参照して、復号した値と
使用ビット数を得る。そして第2に、取り出し開始位置
を使用ビット数だけ進める。この手順を繰り返して可変
長符号の復号を行う。
Next, a method of performing decoding using a table will be described. FIG. 36 shows an example of a table for decoding a variable length code. This table has records from 0 to 63. In each record, when the record number is represented by a 6-bit binary number, the value of the variable length codeword included first and the codeword length are stored as the number of bits used. Record numbers are shown in binary notation in parentheses. For example, for record numbers 8 to 15, the first three bits are "00".
In the variable length code shown in FIG. 34, the value corresponds to a code having a value of 0 and a code word length of 3 bits, and stores a value of 0 and the number of used bits of 3. In order to perform decoding using this table, first, a 6-bit bit string is extracted, and a decoded value and the number of bits used are obtained by referring to a record having a number obtained by converting the bit string into a numerical value. Second, the extraction start position is advanced by the number of bits used. This procedure is repeated to decode the variable length code.

【0006】図35の可変長符号化されたデータを復号
する場合には、まず6ビット「011000」を取り出し、復
号対象として、それを数値にした24番のレコードを参
照する。24番のレコードには、値1、使用ビット数3
が格納されている。ここで復号した値として1を得る。
次に、取り出し開始位置を3ビット進めて、6ビット取
り出すと、復号対象は「000110」となる。次に、この復
号対象を数値にした6番のレコードを参照すると、値
4、使用ビット数4が格納されている。ここで復号した
値として4を得る。そして取り出し開始位置を4ビット
進めて、6ビット取り出すと、復号対象は「101011」と
なる。復号結果をテーブルを参照した順に(<値>,使
用ビット長)で表記すると、前述した(<1>,3),
(<4>,4)に続き(<2>,3),(<1>,
3),(<15>,6)となり、計5回テーブルを参照
して、復号した値として「1,4,2,1,15」を得
る。なお、図36の中で、値と使用ビット数に「−」が
記述されているレコードは、図34の可変長符号による
符号を復号する際には不要である。
When decoding the variable-length coded data shown in FIG. 35, first, the 6-bit "011000" is taken out, and the 24th record, which is a numerical value, is referred to as a decoding target. The 24th record has the value 1 and the number of used bits 3
Is stored. Here, 1 is obtained as the decoded value.
Next, when the extraction start position is advanced by 3 bits and 6 bits are extracted, the decoding target is “000110”. Next, referring to the sixth record in which the decoding target is set to a numerical value, a value 4 and a used bit number 4 are stored. Here, 4 is obtained as the decoded value. When the extraction start position is advanced by 4 bits and 6 bits are extracted, the decoding target is “101011”. If the decoding result is described in the order (<value>, used bit length) referring to the table, the above-mentioned (<1>, 3),
(<4>, 4) followed by (<2>, 3), (<1>,
3), (<15>, 6), and refer to the table a total of five times to obtain "1, 4, 2, 1, 15" as a decoded value. In FIG. 36, the record in which “-” is described in the value and the number of bits used is unnecessary when decoding the variable length code in FIG.

【0007】コンピュータ上で上記手順を実行するため
には、復号する可変長符号、復号のためのテーブル、及
び復号した値を順次格納する領域を、メモリ上に割り当
てる。また、8ビット以上を処理単位とする一般的なC
PUの場合、メモリへのアクセス単位は1バイト=8ビ
ット単位となる。
In order to execute the above procedure on a computer, a variable length code to be decoded, a table for decoding, and an area for sequentially storing decoded values are allocated on a memory. In addition, a general C that uses 8 bits or more as a processing unit
In the case of a PU, the unit of access to the memory is 1 byte = 8 bits.

【0008】図37はコンピュータを用いて上記の復号
を行う方法の処理フローの例を示したものであり、この
図37に基づいて従来の復号方法を以下に説明する。ま
ずステップ3701で、取り出し開始位置を初期化す
る。ここで、ReadPに取り出し開始位置のメモリ上のア
ドレスを格納し、ReadBにReadPのアドレスの何ビット目
であるかを格納する。例えば取り出し開始位置がメモリ
の先頭から86ビット目の場合、ReadP=10,ReadB=
6となる。次いでステップ3702で、ReadP及びReadB
が示す取り出し開始位置から6ビット取り出して復号対
象を得る。そしてステップ3703で、復号対象が示す
番号のレコードを参照し、復号された値と使用したビッ
ト数UBを得る。その後ステップ3704で、ReadP及
びReadBを更新し、取り出し開始位置をUBビット分進
める。例えば、ReadP=10,ReadB=6でUB=4が得
られた場合、更新後はReadP=11,ReadB=2となる。
そしてステップ3705で、復号終了したかを判断し、
復号終了でなければステップ3702に戻る。復号終了
であれば処理を終了する。
FIG. 37 shows an example of a processing flow of the above-described decoding method using a computer. A conventional decoding method will be described below with reference to FIG. First, in step 3701, a takeout start position is initialized. Here, the address on the memory of the extraction start position is stored in ReadP, and the bit number of the address of ReadP is stored in ReadB. For example, if the retrieval start position is the 86th bit from the beginning of the memory, ReadP = 10, ReadB =
It becomes 6. Next, in step 3702, ReadP and ReadB
6 bits are extracted from the extraction start position indicated by, to obtain a decoding target. Then, in step 3703, by referring to the record of the number indicated by the decoding target, the decoded value and the number of used bits UB are obtained. Thereafter, in step 3704, ReadP and ReadB are updated, and the extraction start position is advanced by UB bits. For example, if UB = 4 is obtained when ReadP = 10 and ReadB = 6, ReadP = 11 and ReadB = 2 after updating.
Then, in step 3705, it is determined whether or not decoding has been completed.
If the decoding is not completed, the process returns to step 3702. If the decoding is completed, the process is terminated.

【0009】図38は図37におけるステップ3702
の復号対象を得る処理フローの例を示したものであり、
この図38によって復号対象取得手順を以下に説明す
る。まずステップ3801で、メモリのReadPバイト目
から2バイトを16ビットのレジスタAにロードする。
ここで、ReadP及びReadBによって示される取り出し開始
位置から6ビット分の復号対象がレジスタA内に格納さ
れる。例えば、ReadB=6の場合、レジスタAの16ビ
ット分の内容は、復号対象をX、それ以外をxで示すと
「xxxxxXXXXXXxxxxx」となる。次いでステップ3802
で、レジスタAを右に(11−ReadB)ビットシフトす
る。ここで、復号対象がレジスタAの最下位ビットから
6ビットの位置に格納される。上記の例では、ReadB=
6の場合、レジスタAの16ビット分の内容は、「0000
0xxxxxXXXXXX」となる。そしてステップ3803で、レ
ジスタAの下位6ビット以外をマスクする。すなわちレ
ジスタAを「0000000000111111」でマスクして、下位6
ビットを有効にする。上記の例では、レジスタAは「00
00000000XXXXXX」となる。
FIG. 38 shows step 3702 in FIG.
Shows an example of a processing flow for obtaining the decryption target of
The decoding target acquisition procedure will be described below with reference to FIG. First, in step 3801, 2 bytes from the ReadP byte of the memory are loaded into the 16-bit register A.
Here, the decoding target for 6 bits from the extraction start position indicated by ReadP and ReadB is stored in the register A. For example, when ReadB = 6, the content of 16 bits of the register A is “xxxxxXXXXXXxxxxx” when the decoding target is indicated by X and the rest is indicated by x. Next, step 3802
Then, the register A is shifted to the right by (11-ReadB) bits. Here, the decoding target is stored at the position of 6 bits from the least significant bit of the register A. In the above example, ReadB =
In the case of 6, the contents of 16 bits of the register A are “0000
0xxxxxXXXXXX ". Then, in step 3803, the lower 6 bits of the register A are masked. That is, register A is masked with “0000000000111111” and the lower 6
Enable bits. In the above example, register A is "00
00000000XXXXXX ".

【0010】図39は図37におけるステップ3704
の取り出し開始位置を更新する処理フローの例を示した
ものであり、この図39によって取り出し開始位置更新
手順を以下に説明する。まずステップ3901で、Read
Bにステップ3703で得た使用バイト数UBを加え
る。次いでステップ3902で、ReadBが9以上か否か
を判定し、ReadB≧9の場合はステップ3903へ進
み、ReadBが8以下の場合は処理を終了する。ステップ
3903では、ReadPに1を加算し、ReadBから8を減算
する。
FIG. 39 shows a step 3704 in FIG.
FIG. 39 shows an example of a processing flow for updating the takeout start position of the program. The procedure for updating the takeout start position will be described below with reference to FIG. First, in step 3901, Read
The number of used bytes UB obtained in step 3703 is added to B. Next, in Step 3902, it is determined whether or not ReadB is 9 or more. If ReadB ≧ 9, the process proceeds to Step 3903, and if ReadB is 8 or less, the process ends. In step 3903, 1 is added to ReadP, and 8 is subtracted from ReadB.

【0011】以上説明した図37〜図39の処理フロー
により、可変長符号の復号を行うことができる。
The variable-length code can be decoded by the processing flow of FIGS. 37 to 39 described above.

【0012】可変長符号の復号を高速に行うための方法
としては、特開平9−261076号公報に記載の「テ
ーブル記憶方法、並びに、復号方法および装置」が知ら
れている。この方法では、復号された複数の値を持つレ
コードから構成されるテーブルを用いて復号を行うこと
で、テーブル参照の回数を削減でき、可変長符号の復号
を高速に行うことができる。
As a method for decoding variable-length codes at high speed, there is known a "table storage method and a decoding method and apparatus" described in JP-A-9-261076. In this method, decoding is performed using a table composed of decoded records having a plurality of values, so that the number of table references can be reduced, and variable-length codes can be decoded at high speed.

【0013】この従来技術を図34の可変長符号の復号
に用いる場合、図40に示すようなテーブルを用いれば
よい。このテーブルは、0から63番までのレコードを
持ち、それぞれのレコードは、レコード番号を6ビット
の2進数で表記したときに、最初に得られる値だけでは
なく、そのビット列を順次復号して得られる値の列とそ
こで復号したビット数を使用ビット数として格納する。
図40では、9番、11番、13番などのテーブルにお
いて、復号して得られる値が複数になり、図36のテー
ブルと異なっている。例えば、11番のレコードは、1
1の2進表記「001011」が値0の可変長符号「001」に
続いて値1の可変長符号「011」に復号できるので、値
として「0,1」、使用ビット数として「6」を格納し
ている。
When this prior art is used for decoding the variable length code shown in FIG. 34, a table as shown in FIG. 40 may be used. This table has records from 0 to 63. Each record is obtained by sequentially decoding not only the value obtained first but also its bit string when the record number is represented by a 6-bit binary number. The value sequence and the number of bits decoded there are stored as the number of bits used.
In FIG. 40, there are a plurality of values obtained by decoding in tables No. 9, 11, 13 and so on, which is different from the table of FIG. For example, the 11th record is 1
Since the binary notation “001011” of 1 can be decoded into the variable length code “011” of value 1 following the variable length code “001” of value 0, the value is “0, 1” and the number of bits used is “6”. Is stored.

【0014】この図40のテーブルを用いて復号を行う
処理のフローは、テーブルを参照したときに得られる値
が複数の場合がある以外は、図37〜図39で説明した
処理フローと同様である。例えば、図35の可変長符号
化されたデータの例を復号する場合には、テーブルを参
照した順に(<値>,使用ビット長)で表記すると、
(<1>,3),(<4>,4),(<2,1>,
6),(<15>,6)となり、計4回テーブルを参照
することで、復号した値「1,4,2,1,15」が得
られる。これは、図36のテーブルを用いた場合よりも
テーブルの参照回数が1回少なくなっている。このよう
に1回のテーブル参照で複数の値を得ることにより、テ
ーブル参照の回数を削減して可変長符号の復号を高速に
行うことができる。
The flow of processing for decoding using the table of FIG. 40 is the same as the processing flow described with reference to FIGS. is there. For example, when decoding the example of the variable-length-encoded data shown in FIG.
(<1>, 3), (<4>, 4), (<2, 1>,
6), (<15>, 6), and the decoded value “1, 4, 2, 1, 15” is obtained by referring to the table a total of four times. This is because the number of times the table is referred to is one less than when the table of FIG. 36 is used. By obtaining a plurality of values by one table reference in this way, the number of table references can be reduced and variable-length codes can be decoded at high speed.

【0015】[0015]

【発明が解決しようとする課題】上述したような図36
又は図40のテーブルを用いる従来の可変長符号の復号
方法では、1つの可変長符号を復号する毎、あるいはテ
ーブルを参照する毎に、前記のように可変長符号列から
所定のビット位置のビット列を取り出す必要があった。
しかしながら、一般的なCPU及びメモリで構成される
コンピュータでは、バイト単位でデータにアクセスする
ようになっており、このように所定位置のビット列を任
意に取り出す処理を直接行うことができないため、図3
8の処理フローで例示したようなビットシフトやビット
マスクなどのビット演算を行う必要がある。また、図3
9の処理フローで例示したように、復号対象の可変長符
号列の取り出し開始位置に対して、バイト単位とビット
単位の両方の管理が必要となる。
FIG. 36 described above.
Alternatively, in the conventional variable-length code decoding method using the table of FIG. 40, every time one variable-length code is decoded or each time the table is referred to, a bit string at a predetermined bit position is extracted from the variable-length code string as described above. Had to be taken out.
However, in a computer including a general CPU and a memory, data is accessed in byte units, and a process of arbitrarily extracting a bit string at a predetermined position cannot be directly performed.
It is necessary to perform a bit operation such as a bit shift or a bit mask as exemplified in the processing flow of No. 8. FIG.
As exemplified in the processing flow of No. 9, it is necessary to manage both the byte unit and the bit unit for the extraction start position of the variable-length code string to be decoded.

【0016】このように、従来の可変長符号の復号方法
では、所定位置のビット列取り出しのために毎回ビット
演算が必要であったり、ビット列の取り出し開始位置更
新のために処理時間を要するため、復号処理を高速に行
うことができないという問題点を有している。
As described above, in the conventional variable-length code decoding method, a bit operation is required every time to extract a bit string at a predetermined position, or a processing time is required to update a bit string extraction start position. There is a problem that processing cannot be performed at high speed.

【0017】本発明は、上記事情に鑑みてなされたもの
で、復号対象の可変長符号に対して、ビットシフトなど
のビット演算を行う必要がなく、バイト単位でビット列
を取り出してテーブルを参照するだけで復号することが
でき、高速に復号処理を行うことが可能な可変長符号の
復号方法及び装置、並びに復号テーブルを提供すること
を目的とする。
The present invention has been made in view of the above circumstances, and there is no need to perform a bit operation such as a bit shift on a variable-length code to be decoded. It is an object of the present invention to provide a decoding method and apparatus for a variable-length code and a decoding table, which can be decoded only by itself and can perform a decoding process at high speed.

【0018】[0018]

【課題を解決するための手段】本発明は、第1に、復号
対象の可変長符号列からNビット(Nは1以上の整数)
のビット列Bを取り出す手順と、現在の状態Sに対応し
たテーブルにおいて前記取り出したビット列Bに対応し
たレコードを参照し、このレコードから復号データ列V
と遷移する次の状態S′とを得る手順とを有し、これら
の手順を繰り返して順次可変長符号列の復号データを得
る可変長符号の復号方法を提供する。
According to the present invention, first, N bits (N is an integer of 1 or more) from a variable-length code string to be decoded are provided.
And the table corresponding to the current state S is referred to a record corresponding to the extracted bit string B, and the decoded data string V
And a procedure for obtaining a next state S ′ to transition to, and a procedure for repeating these procedures to sequentially obtain decoded data of a variable-length code sequence.

【0019】第2に、復号時の状態Sにそれぞれ対応し
た複数のテーブルを有し、各テーブルにおいて可変長符
号列からバイト単位で取り出したビット列Bにそれぞれ
対応した複数のレコードを設け、各レコードには、前記
ビット列Bを復号した場合に得られるデータを示す復号
データ列Vと当該レコードを参照してから次に遷移する
状態を示す次の状態S′とを少なくとも格納して構成さ
れる復号テーブルを用い、復号対象の可変長符号列から
Nバイト(Nは1以上の整数)のビット列Bを取り出す
手順と、前記復号テーブルにおいて、現在の状態Sに対
応したテーブルにおける前記取り出したビット列Bに対
応したレコードを参照し、このレコードから復号データ
列Vと次の状態S′とを得る手順とを有し、これらの手
順を繰り返して順次可変長符号列の復号データを得る可
変長符号の復号方法を提供する。
Second, there are a plurality of tables respectively corresponding to the state S at the time of decoding, and in each table, a plurality of records respectively corresponding to the bit string B extracted from the variable length code string in byte units are provided. Includes a decoded data string V indicating data obtained when the bit string B is decoded, and a next state S 'indicating a next transition state after referring to the record. Using a table to extract a bit string B of N bytes (N is an integer equal to or greater than 1) from a variable-length code string to be decoded; Referring to the corresponding record, and obtaining a decoded data string V and the next state S 'from this record. A method of decoding variable length code to obtain the decoded data of the variable length code sequence.

【0020】第3に、前記状態Sは、前記取り出したビ
ット列Bのiビット目(iは1以上の整数)から復号し
それ以前のビットは復号対象としない状態である複数の
初期状態SFiと、前回の復号の結果において復号でき
ない余りのビット列が生じた状態である複数の通常状態
SNxとを含むこととする。
Third, the state S is composed of a plurality of initial states SFi in which the i-th bit (i is an integer of 1 or more) of the extracted bit string B is decoded and the previous bits are not to be decoded. , And a plurality of normal states SNx in which a bit string that cannot be decoded occurs as a result of the previous decoding.

【0021】第4に、復号対象の可変長符号列からNビ
ット(Nは1以上の整数)毎にビット列を取り出して復
号していく復号方法であって、取り出したビット列Bの
iビット目(i=1〜N)から復号する状態である複数
の初期状態SFiと、前回の復号の結果において復号で
きない余りのビット列Rが生じた状態であって前記余り
のビット列Rが取り得る複数の通常状態SNxとのそれ
ぞれに対応した複数のテーブルを持ち、これらのテーブ
ルは、Nビットの2進数で表現可能な個数のレコードを
持ち、Nビットのビット列bにより示されるレコードに
は、前記初期状態SFiに対応したテーブルにおいては
前記ビット列bをiビット目から復号して得られる復号
データ列Vと次の余りのビット列rに対応した次の状態
S′とを格納し、前記通常状態SNxに対応したテーブ
ルにおいては前記余りのビット列Rと前記ビット列bと
を結合したビット列を復号して得られる復号データ列V
と次の余りのビット列rに対応した次の状態S′とを格
納して構成される復号テーブルを用い、復号対象の可変
長符号列からNビットのビット列Bを取り出す手順と、
現在の状態Sに対応した前記テーブルにおいて前記ビッ
ト列Bに対応したレコードを参照し、このレコードから
復号データ列Vと次の状態S′とを得る手順とを有し、
これらの手順を繰り返して順次可変長符号列の復号デー
タを得ることを特徴とする可変長符号の復号方法を提供
する。
Fourth, there is provided a decoding method for extracting and decoding a bit string for each N bits (N is an integer of 1 or more) from a variable-length code string to be decoded. i = 1 to N) and a plurality of initial states SFi in a state where decoding is performed, and a plurality of normal states in which the remaining bit strings R cannot be decoded in the previous decoding result and the remaining bit strings R can take. SNx and a plurality of tables corresponding to the respective SNx. These tables have a number of records that can be represented by an N-bit binary number. In a corresponding table, a decoded data string V obtained by decoding the bit string b from the i-th bit and a next state S ′ corresponding to the next remaining bit string r are stored. Serial decoded data sequence V in the table corresponding to the normal state SNx obtained by decoding the bit string obtained by coupling the bit string R of the odd bit sequence b
Extracting a N-bit bit string B from a variable-length code string to be decoded using a decoding table configured to store the next state S ′ corresponding to the next remaining bit string r;
Referring to a record corresponding to the bit string B in the table corresponding to the current state S, and obtaining a decoded data string V and a next state S ′ from the record;
A variable length code decoding method is characterized in that decoded data of a variable length code sequence is sequentially obtained by repeating these procedures.

【0022】第5に、復号対象の可変長符号列からNバ
イト(Nは1以上の整数)毎にビット列を取り出して復
号していく復号方法であって、取り出したビット列Bの
iビット目(i=1〜N×8)から復号する状態である
複数の初期状態SFiと、前回の復号の結果において復
号できない余りのビット列Rが生じた状態であって前記
余りのビット列Rが取り得る複数の通常状態SNxとの
それぞれに対応した複数のテーブルを持ち、これらのテ
ーブルは、N×8ビットの2進数で表現可能な個数のレ
コードを持ち、N×8ビットのビット列bにより示され
るレコードには、前記初期状態SFiに対応したテーブ
ルにおいては前記ビット列bをiビット目から復号して
得られる復号データ列Vと次の余りのビット列rに対応
した次の状態S′とを格納し、前記通常状態SNxに対
応したテーブルにおいては前記余りのビット列Rと前記
ビット列bとを結合したビット列を復号して得られる復
号データ列Vと次の余りのビット列rに対応した次の状
態S′とを格納して構成される復号テーブルを用い、復
号対象の可変長符号列からバイト単位でNバイトのビッ
ト列Bを取り出す手順と、現在の状態Sに対応した前記
テーブルにおいて前記ビット列Bに対応したレコードを
参照し、このレコードから復号データ列Vと次の状態
S′とを得る手順とを有し、これらの手順を繰り返して
順次可変長符号列の復号データを得ることを特徴とする
可変長符号の復号方法を提供する。
Fifth, there is a decoding method in which a bit string is extracted from the variable-length code string to be decoded every N bytes (N is an integer of 1 or more) and decoded. i = 1 to N × 8), and a plurality of initial states SFi in a state where decoding is performed from a previous decoding result and a plurality of possible bit strings R in a state where there is a surplus bit string R that cannot be decoded as a result of the previous decoding. It has a plurality of tables corresponding to each of the normal states SNx. These tables have a number of records that can be represented by an N × 8-bit binary number. In the table corresponding to the initial state SFi, the decoded data string V obtained by decoding the bit string b from the i-th bit and the next state S ′ corresponding to the next remaining bit string r In a table corresponding to the normal state SNx, a decoded data string V obtained by decoding a bit string obtained by combining the remaining bit string R and the bit string b and a next state corresponding to the next remaining bit string r are stored. A procedure for extracting a bit string B of N bytes in byte units from a variable-length code string to be decoded using a decoding table configured to store S ′ and S ′, and a step of extracting the bit string B in the table corresponding to the current state S Referring to a corresponding record and obtaining a decoded data string V and the next state S 'from this record, and repeating these steps to sequentially obtain decoded data of a variable-length code string. A method for decoding a variable length code is provided.

【0023】第6に、前記復号対象の可変長符号列に可
変長符号と固定長符号が混在し、固定長符号の開始を示
す符号として固定長識別符号CSがある場合、前記テー
ブルのそれぞれのビット列bに対応したレコードにおい
て、当該ビット列bに前記固定長識別符号CSの少なく
とも一部が含まれるレコードには、前記復号データ列V
として前記固定長識別符号CSの前までの符号列を復号
して得られるデータが格納され、前記次の状態S′とし
て固定長識別符号の検出を示しその余りのビットに対応
した状態が格納されており、このレコードを用いて固定
長符号部分の復号を行う可変長符号の復号方法を提供す
る。
Sixth, if the variable-length code sequence to be decoded contains both variable-length codes and fixed-length codes, and a fixed-length identification code CS is a code indicating the start of the fixed-length code, In a record corresponding to the bit string b, a record in which the bit string b includes at least a part of the fixed-length identification code CS includes the decoded data string V
The data obtained by decoding the code string up to the fixed-length identification code CS is stored, and the state corresponding to the remaining bits is stored as the next state S ', indicating the detection of the fixed-length identification code. A variable length code decoding method for decoding a fixed length code portion using the record is provided.

【0024】第7に、前記復号対象の可変長符号列に可
変長符号と固定長符号が混在し、固定長符号の開始を示
す符号として固定長識別符号CSがある場合、前記状態
Sは、固定長符号の復号を行う状態である複数の固定長
復号状態SCyを含み、この固定長復号状態SCyに対
応するテーブルを参照して固定長識別符号CS以降の固
定長符号の復号を行う可変長符号の復号方法を提供す
る。
Seventh, if the variable-length code sequence to be decoded contains variable-length codes and fixed-length codes, and a fixed-length identification code CS is a code indicating the start of the fixed-length codes, the state S A variable length that includes a plurality of fixed-length decoding states SCy in which decoding of fixed-length codes is performed, and decodes fixed-length codes subsequent to the fixed-length identification code CS with reference to a table corresponding to the fixed-length decoding states SCy. A code decoding method is provided.

【0025】第8に、前記復号対象の可変長符号列に可
変長符号と固定長符号が混在し、固定長符号の開始を示
す符号として固定長識別符号CSがある場合、前記通常
状態SNxに対応したテーブルにおいて、それぞれのビ
ット列bにより示されるレコードであって当該ビット列
bに前記固定長識別符号CSの少なくとも一部が含まれ
るレコードには、前記固定長識別符号CSの前までの符
号列を復号して得られる復号データ列Vと、前記ビット
列bにおける固定長識別符号CSの後の固定長符号部分
によって確定される数値v1と、次回の復号が固定長符
号の何ビット目からの復号であるかを示す固定長復号状
態SCyとを格納し、固定長符号のyビット目からの復
号を示す前記固定長復号状態SCyに対応したテーブル
におけるビット列bで示されるレコードには、このビッ
ト列bを固定長符号のyビット目として復号して得られ
る数値v2と、固定長符号以降の符号列を復号して得ら
れる復号データ列Vと、復号した後の状態を示す次の状
態S′とを格納して復号テーブルが構成されており、前
記固定長符号の復号を行う際には、前記数値v1及び数
値v2を得た後で、v1+v2を用いて固定長符号を復
号する可変長符号の復号方法を提供する。
Eighth, if the variable-length code sequence to be decoded contains variable-length codes and fixed-length codes, and a fixed-length identification code CS is a code indicating the start of the fixed-length code, the normal state SNx In the corresponding table, in the record indicated by each bit string b, and the record in which the bit string b includes at least a part of the fixed length identification code CS, the code string up to the fixed length identification code CS is described. A decoded data string V obtained by decoding, a numerical value v1 determined by a fixed-length code part after the fixed-length identification code CS in the bit string b, and a next decoding starting from a certain bit of the fixed-length code And a fixed-length decoding state SCy indicating whether there is a bit string in a table corresponding to the fixed-length decoding state SCy indicating decoding from the y-th bit of the fixed-length code. In the record indicated by, a numerical value v2 obtained by decoding the bit string b as the y-th bit of the fixed-length code, a decoded data string V obtained by decoding a code string after the fixed-length code, A decoding table is formed by storing the next state S 'indicating the state of (1), and when decoding the fixed-length code, after obtaining the numerical values v1 and v2, using v1 + v2. A variable length code decoding method for decoding a fixed length code is provided.

【0026】第9に、前記復号対象の可変長符号列にお
ける可変長符号及び固定長符号は、MPEGの画像圧縮
方式におけるDCT係数のラン及びレベルであり、MP
EGの可変長符号化されたDCT係数のラン、レベルを
復号する可変長符号の復号方法を提供する。
Ninth, the variable-length code and the fixed-length code in the variable-length code sequence to be decoded are the run and level of the DCT coefficient in the MPEG image compression method.
Provided is a variable length code decoding method for decoding the run and level of the variable length coded DCT coefficients of the EG.

【0027】第10に、復号時の状態Sにそれぞれ対応
した複数のテーブルを有し、各テーブルにおいて可変長
符号列からバイト単位で取り出したビット列Bにそれぞ
れ対応した複数のレコードを設け、各レコードには、前
記ビット列Bを復号した場合に得られるデータを示す復
号データ列Vと当該レコードを参照してから次に遷移す
る状態を示す次の状態S′とを少なくとも格納した可変
長符号の復号テーブルを提供する。
Tenth, there are a plurality of tables respectively corresponding to the state S at the time of decoding, and in each table, a plurality of records respectively corresponding to the bit string B extracted from the variable length code string in byte units are provided. The decoding of a variable-length code storing at least a decoded data string V indicating data obtained when the bit string B is decoded and a next state S 'indicating the next transition state after referring to the record Provide a table.

【0028】第11に、復号対象の可変長符号列から取
り出したNビット(Nは1以上の整数)のビット列Bの
iビット目(i=1〜N)から復号する状態である複数
の初期状態SFiと、前回の復号の結果において復号で
きない余りのビット列Rが生じた状態であって前記余り
のビット列Rが取り得る複数の通常状態SNxとのそれ
ぞれに対応した複数のテーブルを持ち、これらのテーブ
ルは、Nビットの2進数で表現可能な個数のレコードを
持ち、Nビットのビット列bにより示されるレコードに
は、前記初期状態SFiに対応したテーブルにおいては
前記ビット列bをiビット目から復号して得られる復号
データ列Vと次の余りのビット列rに対応した次の状態
S′とを格納し、前記通常状態SNxに対応したテーブ
ルにおいては前記余りのビット列Rと前記ビット列bと
を結合したビット列を復号して得られる復号データ列V
と次の余りのビット列rに対応した次の状態S′とを格
納したことを特徴とする可変長符号の復号テーブルを提
供する。
Eleventh, a plurality of initial states in which decoding is started from the ith bit (i = 1 to N) of a bit string B of N bits (N is an integer of 1 or more) extracted from the variable-length code string to be decoded. It has a plurality of tables respectively corresponding to a state SFi and a plurality of normal states SNx in which there is a surplus bit string R that cannot be decoded as a result of the previous decoding, and the surplus bit string R can take. The table has a number of records that can be represented by an N-bit binary number. In the record indicated by the N-bit bit string b, in the table corresponding to the initial state SFi, the bit string b is decoded from the i-th bit. And the next state S 'corresponding to the next remaining bit string r are stored in the table corresponding to the normal state SNx. Decoded data string V obtained by decoding the bit stream bound to Rino bit string R and the bit string b
And a next state S ′ corresponding to the next remaining bit string r.

【0029】第12に、復号対象の可変長符号列から取
り出したNバイト(Nは1以上の整数)のビット列Bの
iビット目(i=1〜N×8)から復号する状態である
複数の初期状態SFiと、前回の復号の結果において復
号できない余りのビット列Rが生じた状態であって前記
余りのビット列Rが取り得る複数の通常状態SNxとの
それぞれに対応した複数のテーブルを持ち、これらのテ
ーブルは、N×8ビットの2進数で表現可能な個数のレ
コードを持ち、N×8ビットのビット列bにより示され
るレコードには、前記初期状態SFiに対応したテーブ
ルにおいては前記ビット列bをiビット目から復号して
得られる復号データ列Vと次の余りのビット列rに対応
した次の状態S′とを格納し、前記通常状態SNxに対
応したテーブルにおいては前記余りのビット列Rと前記
ビット列bとを結合したビット列を復号して得られる復
号データ列Vと次の余りのビット列rに対応した次の状
態S′とを格納したことを特徴とする可変長符号の復号
テーブルを提供する。
Twelfth, a plurality of N-bit (N is an integer of 1 or more) bits extracted from a variable-length code string to be decoded is decoded from the ith bit (i = 1 to N × 8) of a bit string B. And a plurality of tables respectively corresponding to a plurality of normal states SNx in a state in which a surplus bit string R that cannot be decoded has occurred in the result of the previous decoding and the surplus bit string R can take, These tables have a number of records that can be represented by an N × 8-bit binary number, and a record indicated by an N × 8-bit bit string b includes the bit string b in the table corresponding to the initial state SFi. The decoded data string V obtained by decoding from the i-th bit and the next state S 'corresponding to the next remaining bit string r are stored in a table corresponding to the normal state SNx. A decoded data string V obtained by decoding a bit string obtained by combining the remaining bit string R and the bit string b, and a next state S 'corresponding to the next remaining bit string r. Provide a variable length decoding table.

【0030】第13に、上記いずれかに記載の復号テー
ブルを備えるとともに、復号対象の可変長符号列を格納
する可変長符号格納手段と、復号して得られたデータ列
を格納する復号データ格納手段と、前記可変長符号格納
手段に格納された可変長符号列から所定のビット数又は
所定のバイト単位でビット列を取り出し、前記復号テー
ブルを参照して前記ビット列に対応する復号を順次行
い、得られた復号データを前記復号データ格納手段に格
納する可変長符号復号手段とを備えた可変長符号の復号
装置を提供する。
Thirteenth, a variable-length code storage means for storing a variable-length code string to be decoded, comprising: a decoding table according to any one of the above, and a decoded data storage for storing a data string obtained by decoding. Means, extracting a bit string in a predetermined number of bits or a predetermined byte unit from the variable length code string stored in the variable length code storage means, sequentially performing decoding corresponding to the bit string with reference to the decoding table, And a variable-length code decoding means for storing the decoded data in the decoded data storage means.

【0031】上記のような復号方法及び装置では、復号
対象の可変長符号列からバイト単位など所定数(Nビッ
ト)のビット列を取り出し、現在の状態Sに対応したテ
ーブルの取り出したビット列に対応するレコードを参照
するのみで復号を行うことが可能になる。よって、ビッ
トシフトなどのビット演算をせずに可変長符号の復号処
理を行うことができる。特にNが8の倍数の場合に、可
変長符号列をバイト単位で取り出しながら、ビット演算
を行わずに復号することができる。また、可変長符号と
固定長符号が混在する可変長符号列においても、テーブ
ルを参照するのみでビット演算をせずに復号可能であ
る。これにより、可変長符号の復号処理の高速化を図れ
る。
In the decoding method and apparatus described above, a predetermined number (N bits) of bit strings, such as byte units, are extracted from the variable-length code string to be decoded and correspond to the extracted bit strings of the table corresponding to the current state S. Decoding can be performed only by referring to the record. Therefore, the decoding process of the variable length code can be performed without performing a bit operation such as a bit shift. In particular, when N is a multiple of 8, decoding can be performed without performing a bit operation while extracting a variable-length code string in byte units. Further, even in a variable length code string in which a variable length code and a fixed length code are mixed, decoding can be performed without referring to a table and without performing a bit operation. As a result, the speed of decoding the variable length code can be increased.

【0032】[0032]

【発明の実施の形態】以下、図面を参照して本発明の実
施の形態を説明する。本実施形態では、動画像のデータ
の圧縮方式の一つであるMPEGにおいて用いられる可
変長符号など、可変長符号と固定長符号とが混在する可
変長符号列の復号を例にして復号方法及び装置を説明す
る。
Embodiments of the present invention will be described below with reference to the drawings. In the present embodiment, a decoding method and a decoding method of a variable-length code string in which variable-length codes and fixed-length codes are mixed, such as a variable-length code used in MPEG, which is one of the video data compression methods, are described. The device will be described.

【0033】[第1実施形態]図1は本発明の実施形態
に係る可変長符号復号装置の構成を示すブロック図であ
る。本実施形態の可変長符号復号装置は、可変長符号に
よって符号化された符号列を格納する可変長符号格納手
段101と、可変長符号を復号する可変長符号復号手段
102と、可変長符号を復号するための復号テーブル1
03と、復号して得られたデータ列を格納する復号デー
タ格納手段104とを有して構成されている。
[First Embodiment] FIG. 1 is a block diagram showing a configuration of a variable length code decoding apparatus according to an embodiment of the present invention. The variable-length code decoding apparatus according to the present embodiment includes a variable-length code storage unit 101 that stores a code string encoded by a variable-length code, a variable-length code decoding unit 102 that decodes a variable-length code, Decryption table 1 for decryption
03, and a decoded data storage unit 104 for storing a data string obtained by decoding.

【0034】可変長符号復号手段102は、半導体メモ
リ等で実現される可変長符号格納手段101に対して、
1バイト=8ビット単位でアクセスを行うことができ
る。本実施形態では、1バイトの最上位ビットを1ビッ
ト目、最下位ビットを8ビット目と表記する。この可変
長符号復号手段102は、汎用または専用のプロセッサ
を含んで構成されるものであり、ソフトウェアプログラ
ムによって動作するもの、一部または全部が復号処理機
能を有するハードウェアにより構成されるもののいずれ
も含まれる。
The variable length code decoding means 102 is provided for the variable length code storage means 101 realized by a semiconductor memory or the like.
Access can be performed in units of 1 byte = 8 bits. In the present embodiment, the most significant bit of one byte is described as a first bit, and the least significant bit is described as an eighth bit. The variable-length code decoding means 102 includes a general-purpose or special-purpose processor, and operates either by a software program or partially or entirely by hardware having a decoding processing function. included.

【0035】本実施形態では、基本的な動作として、可
変長符号復号手段102により、可変長符号のデータ列
(可変長符号列)から1バイト毎にデータDを取り出
し、復号テーブル103として格納された複数のテーブ
ルの中から現在の状態Sに対応したテーブルのデータD
の番号のレコードを参照し、復号した結果と次の状態
S′とを得る。そして、この処理をデータ列の終わりま
で繰り返すことによって可変長符号の復号を行うように
なっている。ここで、状態Sは、直前のデータDにおい
て復号できない「余りのビット列」の状態を示す。
In the present embodiment, as a basic operation, the variable-length code decoding means 102 extracts data D for each byte from a variable-length code data sequence (variable-length code sequence) and stores the data D as a decoding table 103. Data D of the table corresponding to the current state S from the plurality of tables
With reference to the record having the number, the decoding result and the next state S 'are obtained. Then, the variable length code is decoded by repeating this process until the end of the data sequence. Here, the state S indicates a state of “remainder bit string” that cannot be decoded in the immediately preceding data D.

【0036】本実施形態で使用する可変長符号の例を図
2に示す。この可変長符号は、0から255までの数値
を表すことができ、また、可変長符号の終了を示すEO
B(End Of Block)符号「100001」を持つ。図2の
(A)は6ビット以下の可変長符号(符号語及び符号語
長)と値の対応を示したものである。ここには前述のE
OB符号と、escape符号「110001」とを含んでいる。エ
スケープシーケンスを示すescape符号(固定長識別符
号)は、6ビット以上の可変長符号で表される14から
255までの値の符号の開始を示す。この14から25
5までの値の符号は、escape符号6ビットと、それに続
く8ビットの固定長部とからなる計14ビットの符号長
となる。図2(B)はescape符号に続く8ビットの符号
(符号語及び符号語長)と値の対応を示したものであ
る。
FIG. 2 shows an example of a variable length code used in the present embodiment. This variable length code can represent a numerical value from 0 to 255, and EO indicating the end of the variable length code.
It has a B (End Of Block) code "100001". FIG. 2A shows correspondence between a variable length code (code word and code word length) of 6 bits or less and a value. Here, the E
An OB code and an escape code “110001” are included. An escape code (fixed length identification code) indicating an escape sequence indicates the start of a code having a value from 14 to 255 represented by a variable length code of 6 bits or more. This 14 to 25
Codes with values up to 5 have a code length of 14 bits in total consisting of 6 bits of escape code followed by a fixed length portion of 8 bits. FIG. 2B shows the correspondence between an 8-bit code (codeword and codeword length) following an escape code and a value.

【0037】本実施形態の復号テーブルでは、図2の
(A)の3ビットから6ビットまでの符号語長の可変長
符号(0〜13の値)の復号を、ビットシフトなどのビ
ット演算を行わずにバイト単位のアクセスのみで行うこ
とができるようになっている。14以上の値の復号に関
しては、復号テーブルを用いた復号処理によりescape符
号を検出し、次の8ビット(1バイト)を取り出して復
号テーブルを用いずに復号し、再び復号テーブルを用い
た復号処理に戻る。
In the decoding table of this embodiment, the decoding of the variable length code (value of 0 to 13) having a code word length of 3 to 6 bits in FIG. It can be performed only by accessing in byte units without performing it. As for decoding of a value of 14 or more, an escape code is detected by a decoding process using a decoding table, the next 8 bits (1 byte) are extracted, decoded without using the decoding table, and decoded again using the decoding table. Return to processing.

【0038】次に、可変長符号復号手段102が取る状
態Sについて説明する。状態Sには、初期状態、通常状
態、EOB検出状態、escape検出状態(固定長復号状
態)、エラー検出状態の大きく分けて5つの状態があ
る。
Next, the state S taken by the variable length code decoding means 102 will be described. The state S has five states roughly classified into an initial state, a normal state, an EOB detection state, an escape detection state (fixed length decoding state), and an error detection state.

【0039】初期状態は、取り出した1バイトのデータ
の中の、いずれかのビットから復号を行う状態である。
初期状態には「iビット目から復号」において、i=1
〜8の8種類がある。図3は初期状態における復号の様
子を示した説明図である。図3の(A)は、「1ビット
目から復号」の状態であり、取り出した1バイトの1ビ
ット目から復号を行う場合である。(B)は、「2ビッ
ト目から復号」の状態であり、取り出した1バイトの2
ビット目から復号を行う場合である。同様に(C)から
(H)に、「3ビット目から復号」から「8ビット目か
ら復号」までの各状態を示す。この初期状態は、復号を
開始したときに取り得る状態である。復号する可変長符
号が始まるビット位置は前処理において判定可能となっ
ている。ここで、可変長符号の先頭がバイト境界にある
とは限らない場合に、前記8種類の状態が必要となる。
また、escape符号に続く8ビットの符号を復号した後も
この初期状態となる。
The initial state is a state in which decoding is performed from any one of the extracted 1-byte data.
In the initial state, in “decoding from the ith bit”, i = 1
There are eight types of ~ 8. FIG. 3 is an explanatory diagram showing the state of decoding in the initial state. FIG. 3A shows a state of “decoding from the first bit”, in which decoding is performed from the first bit of the extracted one byte. (B) shows a state of “decoding from the second bit”, in which 1 byte 2
This is a case where decoding is performed from the bit number. Similarly, (C) to (H) show states from "decoding from the third bit" to "decoding from the eighth bit". This initial state is a state that can be taken when decoding is started. The bit position where the variable length code to be decoded starts can be determined in the preprocessing. Here, when the head of the variable length code is not always on a byte boundary, the above eight states are required.
This initial state is also obtained after decoding the 8-bit code following the escape code.

【0040】通常状態は、復号途中の「余りのビット
列」が生じている状態であり、「余りのビット列」が取
り得る組み合わせの個数の状態を持つ。図4を用いて
「余りのビット列」について説明する。
The normal state is a state in which a “remainder bit string” is being generated during decoding, and has a state of the number of possible combinations of the “remainder bit string”. The “remainder bit sequence” will be described with reference to FIG.

【0041】図4の(A)において、Nバイト目を復号
したときに、符号語、符号語までを復号できるが、
次の値「7」を示す符号語「1101」は、N+1バイト目
を処理するまでは復号できない。Nバイト目を処理した
時点では、Nバイト目の6ビット目から8ビット目まで
の「110」が「余りのビット列」となる。N+1バイト
目を処理する際には、通常状態で「余りのビット列:11
0」という状態に対応した処理を行う。(B)におい
て、Nバイト目を処理した時点では、「11」が「余りの
ビット列」となり、N+1バイト目を処理する際には、
通常状態で「余りのビット列:11」という状態に対応し
た処理を行う。(C)において、Nバイト目を処理した
時点では、「1」が「余りのビット列」となり、N+1
バイト目を処理する際には、通常状態で「余りのビット
列:1」という状態に対応した処理を行う。(D)にお
いて、Nバイト目を処理した時点で、丁度符号語、符
号語を復号することができ、N+1バイト目では「余
りのビット列」がなく、1ビット目から復号という状態
であるので、「初期状態:1ビット目から復号」にな
る。(E)において、Nバイト目を処理した時点で、8
ビットすべてを使って符号語、符号語、符号語「11
01」を復号することができ、N+1バイト目では「余り
のビット列」がなく、1ビット目から復号という状態で
あるので、「初期状態:1ビット目から復号」になる。
In FIG. 4A, when the N-th byte is decoded, the code word and the code word can be decoded.
The codeword “1101” indicating the next value “7” cannot be decoded until the (N + 1) th byte is processed. At the time of processing the N-th byte, “110” from the 6th bit to the 8th bit of the N-th byte becomes the “remaining bit string”. When processing the (N + 1) th byte, in the normal state, “the remaining bit string: 11
The processing corresponding to the state “0” is performed. In (B), when the N-th byte is processed, “11” becomes the “remainder bit string”, and when the (N + 1) -th byte is processed,
In the normal state, a process corresponding to the state of “remaining bit string: 11” is performed. In (C), when the N-th byte is processed, “1” becomes “remainder bit string”, and N + 1
When processing the byte, a process corresponding to the state of “remaining bit string: 1” is performed in the normal state. In (D), when the N-th byte is processed, the code word and the code word can be decoded exactly, and there is no “remainder bit sequence” in the N + 1-th byte, and the decoding is started from the first bit. "Initial state: decoding from the first bit". In (E), when the N-th byte is processed, 8
The codeword, codeword, codeword `` 11
01 "can be decoded, and since there is no" remaining bit string "in the (N + 1) th byte and decoding is started from the first bit," initial state: decoding from the first bit ".

【0042】上記のように、図4の(A)から(C)に
ついては、Nバイト目を処理した後に通常状態になり、
それぞれ「余りのビット列:110」「余りのビット列:1
1」「余りのビット列:1」となる。
As described above, in (A) to (C) of FIG. 4, the normal state is obtained after processing the N-th byte.
"Remainder bit string: 110""Remainder bit string: 1"
1 "and" Remainder bit sequence: 1. "

【0043】このように符号語長がMビットの符号語に
対しては、M−1通りの「余りのビット列」が発生す
る。図5に図2(A)の可変長符号に対応する「余りの
ビット列」の組み合わせを示す。
As described above, for a code word having a code word length of M bits, M-1 kinds of "remainder bit strings" are generated. FIG. 5 shows a combination of “remainder bit strings” corresponding to the variable-length code in FIG.

【0044】図5(A)は、符号語1つ1つについての
「余りのビット列」を列挙したものである。値0の符号
語「001」は符号語長が3であるから、「余りのビット
列」は、1ビット長の「0」と2ビット長の「00」にな
る。値5の符号語「0101」は符号語長が4であるから、
「余りのビット列」は、1ビット長の「0」と2ビット
長の「01」と3ビット長の「010」になる。(A)で
は、「余りのビット列」について、重複したものが存在
する。例えば、値0と値1に対する1ビット長の「余り
のビット列」は「0」であり重複している。図5(B)
は、重複したものを除いた「余りのビット列」を示した
ものである。16個の符号語に対し、1ビット長の「余
りのビット列」は「0」と「1」の2つであり、2ビット
長の「余りのビット列」は「00」、「01」、「10」、
「11」の4つである。3ビット長、4ビット長、5ビッ
ト長もそれぞれ4つの「余りのビット列」があり、「余
りのビット列」の組み合わせは全部で18個になる。
FIG. 5A enumerates the "remainder bit string" for each code word. Since the code word “001” having a value of 0 has a code word length of 3, the “remainder bit sequence” is “0” having a 1-bit length and “00” having a 2-bit length. Since the code word “0101” having the value 5 has a code word length of 4,
The “remaining bit string” is 1-bit length “0”, 2-bit length “01”, and 3-bit length “010”. In (A), there is an overlapped “remaining bit string”. For example, the 1-bit length “remainder bit string” for the value 0 and the value 1 is “0”, which is an overlap. FIG. 5 (B)
Indicates the "remaining bit string" excluding the overlapping ones. For the 16 code words, the 1-bit length “remainder bit sequence” is two of “0” and “1”, and the 2-bit length “remainder bit sequence” is “00”, “01”, “1”. Ten",
There are four "11". Each of the 3-bit length, 4-bit length, and 5-bit length has four “remaining bit strings”, and the total number of combinations of “remainder bit strings” is 18.

【0045】EOB検出状態は、EOB符号の検出を示
す状態であり、取り出した1バイトデータにおいてEO
B以降に何ビットのデータが残っているかで8種類の状
態(「EOB検出:残りビット数i」i=0〜7)を持
つ。
The EOB detection state is a state indicating the detection of an EOB code.
There are eight states (“EOB detection: remaining bit number i” i = 0 to 7) depending on how many bits of data remain after B.

【0046】図6はEOB検出状態の8種類のパターン
を示した説明図である。この場合、それぞれN+1バイ
ト目を処理した後で、EOB検出状態になる。図6の
(A)は、Nバイト目を処理した後、符号語による
「余りのビット列」が生じた状態であり、N+1バイト
目を処理した時点で、符号語を復号でき、EOBを3
〜8ビット目に検出する場合である。よって、EOBを
検出し残りのビット数が0ビットになった状態「EOB
検出:残りビット数0」になる。(B)は、Nバイト目
を処理した後、符号語による「余りのビット列」が生
じた状態であり、N+1バイト目を処理した時点で、符
号語を復号でき、EOBを2〜7ビット目に検出する
場合である。よって、EOB以降の残りのビット数が1
ビットになった状態「EOB検出:残りビット数1」に
なる。(C)は、Nバイト目を処理した後、「余りのビ
ット列」がなく「初期状態:1ビット目から復号」の状
態になり、N+1バイト目を処理した時点で、EOBを
1〜6ビット目に検出する場合である。よって、EOB
を検出し残りのビット数が2ビットになった状態「EO
B検出:残りビット数2」になる。(D)は、Nバイト
目を処理した後、EOBの先頭1ビットが「余りのビッ
ト列」になって「通常状態:余りのビット列:1」の状
態になり、N+1バイト目を処理した時点で、EOBの
残りの5ビットを検出する場合である。よって、EOB
を検出し残りのビット数が3ビットになった状態「EO
B検出:残りビット数3」になる。(E)〜(H)は、
(D)と同様にNバイト目を処理した後、EOBの先頭
の部分が「余りのビット列」になり、N+1バイト目を
処理した時点でEOBの残りの部分を検出する場合であ
る。よって、EOBを検出し残りのビット数が4から7
ビットの状態「EOB検出:残りビット数4〜7」にな
る。
FIG. 6 is an explanatory diagram showing eight types of patterns in the EOB detection state. In this case, after processing the (N + 1) th byte, the state becomes the EOB detection state. FIG. 6A shows a state in which a “remainder bit string” is generated by a codeword after processing the Nth byte. At the time when the (N + 1) th byte is processed, the codeword can be decoded and EOB is reduced to 3 bits.
This is a case where detection is performed at the 8th to 8th bits. Therefore, the state "EOB" in which the EOB is detected and the number of remaining bits becomes 0 bits
Detection: Remaining bit number 0 ”. (B) shows a state in which a “remainder bit string” is generated by a codeword after processing the Nth byte. When the (N + 1) th byte is processed, the codeword can be decoded. Is detected. Therefore, the number of remaining bits after EOB is 1
The state becomes the bit "EOB detection: remaining bit number 1". (C) shows that after processing the Nth byte, there is no “remaining bit string” and the state becomes “initial state: decoding from the first bit”, and when the (N + 1) th byte is processed, the EOB is 1 to 6 bits. This is the case when the eye is detected. Therefore, EOB
Is detected and the remaining number of bits becomes 2 bits “EO
B detection: remaining bit number 2 ”. (D) shows that at the time when the first one bit of the EOB becomes “remaining bit string” and becomes “normal state: surplus bit string: 1” after processing the N-th byte, the N + 1-th byte is processed. , EOB are detected. Therefore, EOB
Is detected and the remaining number of bits becomes 3 bits "EO
B detection: remaining bit number 3 ”. (E)-(H)
After processing the N-th byte in the same manner as in (D), the head portion of the EOB becomes a “remaining bit string”, and the remaining portion of the EOB is detected when the (N + 1) -th byte is processed. Therefore, EOB is detected and the number of remaining bits is 4 to 7
The state of the bit becomes “EOB detection: remaining bit number 4 to 7”.

【0047】escape検出状態は、escape符号の検出を示
す状態であり、取り出した1バイトデータにおいてesca
pe以降に固定長符号の何ビットのデータが残っているか
で8種類の状態(「escape検出:残りビット数i」i=
0〜7)を持つ。
The escape detection state indicates the detection of an escape code.
Eight states (“escape detection: number of remaining bits i” i =
0-7).

【0048】図7はescape検出状態の8種類のパターン
を示した説明図である。この場合、それぞれN+1バイ
ト目を処理した後で、escape検出状態になる。escape符
号の後には、8ビットの固定長部が続いている。図7の
(A)は、Nバイト目を処理した後、符号語による
「余りのビット列」が生じた状態であり、N+1バイト
目を処理した時点で、符号語を復号でき、escapeを3
〜8ビット目に検出する場合である。よって、escapeを
検出し残りのビット数が0ビットになった状態「escape
検出:残りビット数0」になる。(B)は、Nバイト目
を処理した後、符号語による「余りのビット列」が生
じた状態であり、N+1バイト目を処理した時点で、符
号語を復号でき、escapeを2〜7ビット目に検出する
場合である。よって、escape以降の残りのビット数が1
ビットになった状態「escape検出:残りビット数1」に
なる。(C)は、Nバイト目を処理した後、「余りのビ
ット列」がなく「初期状態:1ビット目から復号」の状
態になり、N+1バイト目を処理した時点で、escapeを
1〜6ビット目に検出する場合である。よって、escape
を検出し残りのビット数が2ビットになった状態「esca
pe検出:残りビット数2」になる。(D)は、Nバイト
目を処理した後、escapeの先頭1ビットが「余りのビッ
ト列」になって「通常状態:余りのビット列:1」の状
態になり、N+1バイト目を処理した時点で、escapeの
残りの5ビットを検出する場合である。よって、escape
を検出し残りのビット数が3ビットになった状態「esca
pe検出:残りビット数3」になる。(E)〜(H)は、
(D)と同様にNバイト目を処理した後、escapeの先頭
の部分が「余りのビット列」になり、N+1バイト目を
処理した時点でescapeの残りの部分を検出する場合であ
る。よって、escapeを検出し残りのビット数が4から7
ビットの状態「escape検出:残りビット数4〜7」にな
る。
FIG. 7 is an explanatory diagram showing eight types of patterns in the escape detection state. In this case, after processing the (N + 1) th byte, an escape detection state is set. The escape code is followed by an 8-bit fixed length part. FIG. 7A shows a state in which a “remainder bit string” is generated by a codeword after processing the Nth byte. At the time when the (N + 1) th byte is processed, the codeword can be decoded.
This is a case where detection is performed at the 8th to 8th bits. Therefore, the state where "escape" is detected and the number of remaining bits is 0 "escape
Detection: Remaining bit number 0 ”. (B) shows a state in which a “remainder bit string” is generated by the code word after processing the Nth byte. At the time when the (N + 1) th byte is processed, the codeword can be decoded, and escape is set to the 2nd to 7th bits. Is detected. Therefore, the number of remaining bits after escape is 1
The state becomes bit "escape detected: remaining bit number 1". (C) shows that after processing the N-th byte, there is no “remaining bit string” and the state is “initial state: decoding from the first bit”. When the (N + 1) -th byte is processed, escape is set to 1 to 6 bits. This is the case when the eye is detected. So escape
Is detected and the number of remaining bits becomes 2 bits "esca
pe detection: remaining bit number 2 ". (D) shows that, after processing the N-th byte, the first bit of escape becomes the “remaining bit string” and becomes “normal state: surplus bit string: 1”. , Escape are detected. So escape
Is detected and the remaining number of bits becomes 3 bits "esca
pe detection: remaining bit number 3 ". (E)-(H)
After processing the N-th byte in the same manner as in (D), the first part of the escape becomes the “remaining bit string”, and the remaining part of the escape is detected when the (N + 1) -th byte is processed. Therefore, escape is detected and the number of remaining bits is 4 to 7
The bit state becomes "escape detection: remaining bit number 4 to 7".

【0049】エラー検出状態は、取り込んだデータ中に
想定している可変長符号としてあり得ない符号を検出し
た状態である。例えば、ある符号語の後に「111xxxxxx
x」のようなビット列が続く場合は、そのようなビット
列に対応する可変長符号はないため、エラー検出状態に
なる。
The error detection state is a state in which a code which cannot be assumed as a variable length code assumed in the fetched data is detected. For example, after a codeword, "111xxxxxx
When a bit string such as “x” continues, there is no variable length code corresponding to such a bit string, and an error detection state is set.

【0050】図8は可変長符号復号手段102が取り得
る状態について割り当てた状態番号とその状態が示す意
味、各状態に対応して参照するテーブルの番号を示した
ものである。図8において、(A)は初期状態及び通常
状態を、(B)はEOB検出状態、escape検出状態、及
びエラー検出状態を示す。例えば、状態番号16の状態
は、「余りのビット列」が「010」であることを示し、
その状態に対応した復号テーブルは16番のテーブルで
あることを示している。また、状態番号1から26の状
態ではそれぞれ復号テーブル1番から26番を使用し、
状態番号27から43の状態では復号テーブルは使用し
ないことを示している。つまり、本実施形態で用いる復
号テーブル103は、初期状態8種類と通常状態18種
類に対応したテーブル1〜26により構成される。
FIG. 8 shows the state numbers assigned to the states that can be taken by the variable length code decoding means 102, the meanings indicated by the states, and the numbers of the tables to be referred to corresponding to each state. 8A shows an initial state and a normal state, and FIG. 8B shows an EOB detection state, an escape detection state, and an error detection state. For example, the state of the state number 16 indicates that the “remainder bit string” is “010”,
The decoding table corresponding to that state is the 16th table. In the states of state numbers 1 to 26, decoding tables 1 to 26 are used, respectively.
The states of state numbers 27 to 43 indicate that the decoding table is not used. That is, the decoding table 103 used in the present embodiment includes tables 1 to 26 corresponding to eight types of initial states and eighteen types of normal states.

【0051】図9は通常状態で取り得る「余りのビット
列」を列挙する処理フローの例を示したものであり、こ
の図9によって余りのビット列の列挙手順を以下に説明
する。
FIG. 9 shows an example of a processing flow for listing "remaining bit strings" that can be taken in a normal state. The procedure for listing remaining bit strings will be described below with reference to FIG.

【0052】まずステップ901で、すべての符号語を
取り出したか否かを判定し、すべての符号語の取り出し
が終了した場合はステップ908に進む。まだすべての
符号語を取り出していない場合はステップ902以降の
処理を行う。最初はステップ902に進むことになる。
ステップ902では、次の符号語Cを取り出す。ここで
は、図2(A)の値0から13とEOB、escapeを示す
16個の符号語を対象とし、このフローによって16個
の符号語のすべてに対して処理を行う。
First, in step 901, it is determined whether all codewords have been extracted. If all codewords have been extracted, the flow advances to step 908. If all codewords have not been extracted yet, the processing after step 902 is performed. Initially, the process proceeds to step 902.
In step 902, the next codeword C is extracted. Here, 16 code words indicating values 0 to 13 and EOB and escape in FIG. 2A are targeted, and the processing is performed on all 16 code words by this flow.

【0053】次にステップ903で、変数LENに取り
出した符号語Cの符号語長を代入する。続いてステップ
904で、変数iに1を代入する。そしてステップ90
5で、変数iと変数LENが等しいか否かを判定し、変
数iと変数LENが等しければ、符号語Cに対する処理
を終了し、ステップ901に戻る。変数iと変数LEN
が等しくない場合は、ステップ906に進む。ステップ
906では、符号語Cから先頭のiビットのビット列s
を取り出し、余りビット列集合RSに追加する。ここ
で、余りビット列集合RSにすでにビット列sがある場
合は追加しない。そしてステップ907で、変数iに1
を加算し、ステップ905に戻り、変数iが変数LEN
と等しくなるまでステップ906及び907を繰り返
す。
Next, in step 903, the codeword length of the extracted codeword C is substituted for the variable LEN. Subsequently, at step 904, 1 is substituted for a variable i. And step 90
In step 5, it is determined whether or not the variable i is equal to the variable LEN. Variable i and variable LEN
If are not equal, go to step 906. In step 906, the bit string s of the first i bits from the codeword C
And adds it to the remaining bit string set RS. Here, if there is already a bit string s in the remaining bit string set RS, it is not added. In step 907, the variable i is set to 1
And returns to step 905, where the variable i is set to the variable LEN
Steps 906 and 907 are repeated until is equal to

【0054】ステップ901に戻った場合にすべての符
号語の取り出しが終了したときは、ステップ908で、
余りビット列集合RSの各要素のビット列に状態番号を
対応させ、処理を終了する。
When the process returns to step 901 and all codewords have been extracted, in step 908,
The state number is made to correspond to the bit string of each element of the remaining bit string set RS, and the processing is ended.

【0055】図9の処理フローにおいて図2の可変長符
号を適用した具体例を示す。始めに、図2(A)の符号
語「001」を取り出し、この符号語についてLENが1
から2までの間、ビット列「0」「00」を取り出し、余
りビット列集合RSに追加する。ここで余りビット列集
合RSの内容は、{0,00}となる。次に符号語「010」
を取り出し、この符号語についてLENが1から2まで
の間、ビット列「0」「01」を取り出し、余りビット列
集合RSに追加するが、このとき「0」はすでに含まれ
るため「01」のみを追加する。ここで余りビット列集合
RSの内容は{0,00,01}となる。同様にして図2
(A)の16個の符号語すべてに対して処理を行うと、
余りビット列集合RSの内容は、{0,1,00,01,10,
11,000,010,100,110,0000,0100,1000,1100,00
000,01000,10000,11000}の18種類となる。なお、
余りビット列の要素の並びは、追加した順序ではなくソ
ートして示した。図9のステップ908において、各要
素のビット列に状態番号を対応させるが、ここでは、9
番から26番に対応させる。
A specific example in which the variable length code of FIG. 2 is applied to the processing flow of FIG. 9 will be described. First, the code word “001” in FIG. 2A is extracted, and LEN is set to 1 for this code word.
The bit strings “0” and “00” are extracted from to and 2, and are added to the remaining bit string set RS. Here, the content of the remainder bit string set RS is {0, 00}. Next, code word "010"
And the bit strings “0” and “01” are extracted for this codeword while LEN is between 1 and 2, and the remainder is added to the bit string set RS. At this time, since “0” is already included, only “01” is to add. Here, the content of the remainder bit string set RS is {0, 00, 01}. FIG. 2
When processing is performed on all 16 code words of (A),
The contents of the remainder bit string set RS are {0, 1, 00, 01, 10,
11,000,010,100,110,0000,0100,1000,1100,00
There are 18 types of 000, 01000, 10000, 11000}. In addition,
The arrangement of the remaining bit string elements is shown in a sorted order, not in the order of addition. In step 908 of FIG. 9, the state number is made to correspond to the bit string of each element.
No. to No. 26.

【0056】このようにして、通常状態で取りうる「余
りのビット列」を列挙し、状態9から状態26に対応さ
せることができる。これにより、図8に示すように、状
態番号とその状態が示す意味との対応を取ることができ
る。
In this way, the "remaining bit strings" that can be taken in the normal state can be enumerated and correspond to states 9 to 26. As a result, as shown in FIG. 8, the correspondence between the state number and the meaning indicated by the state can be obtained.

【0057】図10は復号テーブル103のテーブルの
例として、通常状態に対応するテーブルの一例を示した
ものである。通常状態で「余りのビット列」が「1100」
という状態である状態22に対応した22番のテーブル
である。このテーブルは、図10に示すように0番から
255番のレコードを持っている。レコード番号の括弧
内には、それぞれレコード番号を2進数で表記してい
る。各レコードは、「復号データ列」と「次の状態」を
格納している。例えば、243番のレコードは、Nバイ
ト目において「余りのビット列」が「1100」という状態
で、N+1バイト目においてレコード番号243を8ビ
ットの2進数で示したビット列「11110011」が現われた
場合に対応している。
FIG. 10 shows an example of a table corresponding to the normal state as an example of the decoding table 103. "Remaining bit string" is "1100" in normal state
No. 22 is a table corresponding to the state 22 which is the state described above. This table has records 0 to 255 as shown in FIG. In parentheses of the record numbers, the record numbers are represented in binary numbers. Each record stores a “decoded data string” and a “next state”. For example, the 243rd record is obtained when the “remainder bit string” is “1100” in the Nth byte, and the bit string “11110011” indicating the record number 243 by an 8-bit binary number appears in the N + 1th byte. Yes, it is.

【0058】この243番のレコードの詳細について、
図10に示すテーブルの右側の図を用いて説明する。こ
の場合、Nバイト目を取り出した時点では、符号語を
復号でき、「通常状態:余りのビット列:1100」の状態
になる。そして、N+1バイト目を取り出して復号する
際に、「通常状態:余りのビット列:1100」の状態22
に対応するテーブル22を参照する。この場合N+1バ
イト目のデータが243(2進数で「11110011」)であ
るから、レコード番号243のレコードを参照する。こ
こで、余りのビット列の「1100」とN+1バイト目のデ
ータ「11110011」とを連結した「110011110011」に対し
て復号を行うと、可変長符号語「11001」、「111」、
「100」が得られるから、復号されるデータは「11,
3,0」となる。そして最後にビット列「1」が余る。
よって、243番のレコードは、「復号データ列」に
「11,3,0」を格納し、「次の状態」には「通常状
態:余りのビット列:1」を示す状態10を格納する。
Regarding the details of the record of No. 243,
This will be described with reference to the right side of the table shown in FIG. In this case, when the N-th byte is extracted, the code word can be decoded, and the state becomes “normal state: surplus bit string: 1100”. Then, when extracting and decoding the (N + 1) th byte, the state 22 of “normal state: surplus bit string: 1100”
Is referred to the table 22 corresponding to. In this case, since the data of the (N + 1) th byte is 243 (“11110011” in binary), the record with the record number 243 is referred to. Here, when decoding is performed on “110011110011” obtained by concatenating the remaining bit string “1100” and the N + 1th byte data “11110011”, the variable-length codewords “11001”, “111”,
Since “100” is obtained, the data to be decoded is “11,
3,0 ". Finally, the bit string “1” remains.
Therefore, the record of No. 243 stores “11, 3, 0” in the “decoded data string”, and stores the state 10 indicating “normal state: surplus bit string: 1” in the “next state”.

【0059】なおこのテーブル22において、0番のレ
コードについては、復号データ列には復号されるデータ
がないことを示す「−」が格納され、次の状態にはエラ
ー検出状態である状態43が格納される。つまり、「11
00」と「00000000」を連結したビット列「11000000000
0」は、図2を参照すると、復号可能な対応する符号語
がなく、復号できないためにエラー検出としている。
In this table 22, for the record of No. 0, "-" indicating that there is no data to be decoded is stored in the decoded data string, and the next state is the state 43 of the error detection state. Is stored. In other words, "11
A bit string "11000000000" that connects "00" and "00000000"
With reference to FIG. 2, "0" indicates that there is no corresponding code word that can be decoded, and the error cannot be detected because the code word cannot be decoded.

【0060】また、初期状態に対応したテーブルにおい
ては、8種類のそれぞれの状態に応じて復号する対象の
ビット列を取り出し、上記の通常状態と同様の考え方で
「復号データ列」と「次の状態」とを決定する。このよ
うな初期状態と通常状態の各状態に対応するテーブルを
含む復号テーブルは、可変長符号の内容に対応させて予
め作成しておくものとする。
In the table corresponding to the initial state, the bit strings to be decoded are extracted according to each of the eight states, and the "decoded data string" and the "next state" Is determined. A decoding table including tables corresponding to each of the initial state and the normal state is created in advance so as to correspond to the content of the variable-length code.

【0061】ここで、図11を用いて復号テーブルを作
成する詳しい手順について説明する。図11は復号テー
ブルを作成する処理フローの例を示したものである。こ
の処理フローでは、状態Sとレコード番号RNが与えら
れたときに、「復号データ列」と「次の状態」を決定す
る処理を行う。この場合、状態Sは初期状態及び通常状
態における各状態を表す状態1から状態26までであ
る。
Here, a detailed procedure for creating a decoding table will be described with reference to FIG. FIG. 11 shows an example of a processing flow for creating a decoding table. In this processing flow, when a state S and a record number RN are given, a process of determining a “decoded data string” and a “next state” is performed. In this case, the state S is a state 1 to a state 26 representing each state in the initial state and the normal state.

【0062】まずステップ1101で、レコード番号R
Nを8ビットの2進数で表記したビット列を、BITに
代入する。そしてステップ1102で、状態Sが初期状
態か否かを判定し、初期状態の場合はステップ1103
へ、そうでない場合、すなわち通常状態の場合はステッ
プ1104へ進む。ステップ1103では、状態Sは初
期状態でNビット目からの復号に対応しているため、C
odeにBITのNビット目から最後までのビット列を
代入し、ステップ1106に進む。一方、ステップ11
04では、状態Sは通常状態であるため、その状態Sに
対応する余りビット列を得てRに代入する。そしてステ
ップ1105で、余りビット列RにBITを連結したビ
ット列をCodeに代入し、ステップ1106に進む。
First, in step 1101, the record number R
A bit string in which N is represented by an 8-bit binary number is substituted into BIT. Then, in step 1102, it is determined whether or not the state S is the initial state.
Otherwise, that is, in the case of the normal state, the process proceeds to step 1104. In step 1103, since the state S corresponds to decoding from the N-th bit in the initial state, C
The bit sequence from the Nth bit to the end of the BIT is substituted for mode, and the process proceeds to step 1106. On the other hand, step 11
In 04, since the state S is the normal state, a surplus bit string corresponding to the state S is obtained and substituted into R. Then, in step 1105, a bit string obtained by connecting BIT to the remaining bit string R is substituted for Code, and the flow advances to step 1106.

【0063】次にステップ1106で、Codeと一致
する符号語Cがあるか、あるいは、Codeの先頭部分
に一致する符号語Cがあるかを判定する。ここでは、図
2(A)の16個の符号語のすべてを対象に調べる。例
えば、符号語長が3の符号語であればCodeの先頭3
ビットと一致するかどうかを調べる。このステップ11
06においてCodeの先頭部分と一致する符号語Cが
検出された場合はステップ1107へ、そうでない場合
はステップ1113へ進む。
Next, in step 1106, it is determined whether there is a code word C that matches the code or a code word C that matches the head of the code. Here, all 16 code words in FIG. 2A are examined. For example, if the code word length is 3, the first 3
Checks for a match. This step 11
In step 06, if a codeword C that matches the head of the code is detected, the process proceeds to step 1107; otherwise, the process proceeds to step 1113.

【0064】ステップ1107では、ステップ1106
で一致した符合語CがescapeまたはEOBであるか否か
を判定する。符号語CがescapeまたはEOBである場合
はステップ1112へ進み、そうでない場合はステップ
1108以降の処理に進む。ステップ1108では、ス
テップ1106の処理でCodeの先頭部分が符号語C
に復号可能であることが判定されているため、この符号
語Cに対応するデータをレコードの復号データ列に追加
する。そしてステップ1109で、Codeの先頭か
ら、復号できた符号語Cの部分を取り除き、再びCod
eに代入する。
In step 1107, step 1106
It is determined whether or not the code word C that matches with is escape or EOB. If the codeword C is escape or EOB, the process proceeds to step 1112; otherwise, the process proceeds to step 1108 and subsequent steps. In step 1108, the codeword C
Therefore, the data corresponding to the codeword C is added to the decoded data string of the record. Then, in step 1109, the part of the decoded codeword C is removed from the beginning of the Code, and Code
Substitute for e.

【0065】次いでステップ1110で、Codeの長
さが0か否かを判定し、Codeの長さが0でない場合
はステップ1106に戻り、同様の処理を繰り返す。C
odeの長さが0になった場合はステップ1111に進
む。ステップ1111に進んだ場合、レコードRNは、
復号して「余りのビット列」がない状態になるため、レ
コードの「次の状態」に、「初期状態:1ビット目から
復号」の状態(すなわち状態1)を格納し、処理を終了
する。
Next, in step 1110, it is determined whether or not the length of the code is 0. If the length of the code is not 0, the process returns to step 1106 and the same processing is repeated. C
When the length of the mode becomes 0, the process proceeds to step 1111. When proceeding to Step 1111, the record RN
Since there is no "remaining bit string" after decoding, the state of "initial state: decoding from the first bit" (that is, state 1) is stored in the "next state" of the record, and the process ends.

【0066】また、ステップ1112に進んだ場合は、
escape符号またはEOB符号を検出した状態であり、次
の状態にescape検出状態またはEOB検出状態を格納
し、処理を終了する。ここで、escape符号を検出した場
合は、Codeからescape符号を除いたビット数に従っ
て、図8に示す状態35から状態42をレコードの「次
の状態」に格納する。また、EOB符号を検出した場合
は、CodeからEOB符号を除いたビット数に従っ
て、図8に示す状態27から状態34をレコードの「次
の状態」に格納する。
When the process proceeds to step 1112,
This is a state in which an escape code or an EOB code has been detected, the escape detection state or the EOB detection state is stored in the next state, and the process ends. Here, when an escape code is detected, states 35 to 42 shown in FIG. 8 are stored in the “next state” of the record according to the number of bits obtained by removing the escape code from Code. When an EOB code is detected, the state 27 to the state 34 shown in FIG. 8 are stored in the “next state” of the record according to the number of bits obtained by removing the EOB code from the Code.

【0067】また、ステップ1113では、符号語Cの
先頭部分にCodeが一致するかどうかを判定する。こ
こでは、図2(A)の16個の符号語のすべてを対象に
調べる。このステップ1113においてCodeが符号
語Cの先頭部分と一致することが検出された場合はステ
ップ1114へ、そうでない場合はステップ1115へ
進む。ステップ1114に進んだ場合は、Codeが余
りのビット列となる状態であり、通常状態で余りのビッ
ト列がCodeとなる状態をレコードの「次の状態」に
格納し、処理を終了する。ここで、図9の処理フローに
より求めた図8(A)に示す状態番号と余りのビット列
との対応を用いる。
In step 1113, it is determined whether Code matches the head of the code word C. Here, all 16 code words in FIG. 2A are examined. If it is detected in this step 1113 that the Code matches the head of the codeword C, the flow proceeds to step 1114; otherwise, the flow proceeds to step 1115. If the process proceeds to step 1114, the Code is in a state of remaining bits, and the state in which the remaining bits are Code in the normal state is stored in the “next state” of the record, and the process ends. Here, the correspondence between the state number shown in FIG. 8A and the remaining bit string obtained by the processing flow of FIG. 9 is used.

【0068】一方、ステップ1115に進んだ場合は、
Codeは後にどのようなビット列が続いても復号でき
ないため、エラーを検出した状態である。よって、レコ
ードの「次の状態」にエラー検出状態(状態43)を格
納し、処理を終了する。
On the other hand, when the process proceeds to step 1115,
Since Code cannot be decoded even if any subsequent bit string continues, an error is detected. Therefore, the error detection state (state 43) is stored in the “next state” of the record, and the process ends.

【0069】図12は復号テーブルの例を示したもので
あり、この図12と図11を用いて以下に復号テーブル
の作成手順の具体例を説明する。なお、テーブルの形式
は図10と同様である。図12(A)に示すテーブル1
は、状態1、すなわち「初期状態:1ビット目から復
号」という状態で使用するテーブルである。
FIG. 12 shows an example of the decoding table. A specific example of the procedure for creating the decoding table will be described below with reference to FIGS. 12 and 11. The format of the table is the same as in FIG. Table 1 shown in FIG.
Is a table used in state 1, that is, "initial state: decoding from bit 1".

【0070】このテーブル1において、レコード番号0
のレコード(レコード0)は、「00000000」という符号
が現れた場合に用いるものであり、そのような符号は図
2の可変長符号に該当する符号がなく正しい符号ではな
いので、「次の状態」には43(エラー検出状態)が格
納されている。このレコードを得る手順を図11に基づ
いて説明する。
In this table 1, record number 0
The record (record 0) is used when the code "00000000" appears. Since such a code does not have a code corresponding to the variable length code in FIG. 2 and is not a correct code, the "next state""43" is stored (error detection state). The procedure for obtaining this record will be described with reference to FIG.

【0071】この場合、まずBITに「00000000」を代
入し(ステップ1101)、状態1は初期状態であるの
でステップ1102からYesのステップ1103へ分
岐する。そして、状態Sが1ビット目からの復号である
のでBITの1ビット目から最後までをCodeに代入
すると、Codeは「00000000」になる(ステップ11
03)。次に、Codeの先頭部分に符号語Cが検出で
きないので、ステップ1106からNoのステップ11
13へ分岐する。さらに、Codeに符号語Cの先頭部
分を検出できないので、ステップ1113からNoのス
テップ1115へ分岐する。そして、「次の状態」にエ
ラー検出状態を格納し(ステップ1115)、処理を終
了する。
In this case, first, "00000000" is assigned to BIT (step 1101). Since state 1 is the initial state, the flow branches from step 1102 to step 1103 of Yes. Then, since the state S is decoding from the first bit, when the first to last bits of the BIT are substituted for Code, the Code becomes "00000000" (step 11).
03). Next, since the code word C cannot be detected at the head of the code, steps 1106 to 11
Branch to 13. Further, since the head of the code word C cannot be detected in the code, the process branches from step 1113 to step 1115 of No. Then, the error detection state is stored in the “next state” (step 1115), and the process ends.

【0072】テーブル1における44番のレコード(レ
コード44)は、「00101100」という符号が現れた場合
に用いるものである。この場合、値0を示す「001」
と、値1を示す「011」という符号を復号し、ビット列
「00」が余るので、「復号データ列」の値には「0,
1」、「次の状態」には11(「通常状態で余りのビッ
ト列:00」)が格納されている。このレコードを得る手
順を図11に基づいて説明する。
The record No. 44 in Table 1 (record 44) is used when the code “00101100” appears. In this case, "001" indicating the value 0
And the code “011” indicating the value 1 is decoded, and the bit string “00” remains, so the value of the “decoded data string” is “0,
In “1” and “next state”, 11 (“remaining bit string in normal state: 00”) is stored. The procedure for obtaining this record will be described with reference to FIG.

【0073】この場合、まずBITに「00101100」を代
入し(ステップ1101)、状態1は初期状態であるの
でステップ1102からYesのステップ1103へ分
岐する。そして、状態Sが1ビット目からの復号である
のでBITの1ビット目から最後までをCodeに代入
すると、Codeは「00101100」になる(ステップ11
03)。次に、Codeの先頭部分に符号語「001」が
検出できるので、ステップ1106からYesのステッ
プ1107に分岐する。続いて、検出された符号語はes
capeやEOBではないので、ステップ1107からNo
のステップ1108に分岐する。そして符号語「001」
に対応する値のデータ「0」を復号データ列に追加し
(ステップ1108)、Codeの先頭から符号語「00
1」を除くと、Codeは「01100」になる(ステップ1
109)。
In this case, first, “00101100” is assigned to BIT (step 1101). Since state 1 is an initial state, the process branches from step 1102 to step 1103 of Yes. Then, since the state S is decoding from the first bit, when the first to last bits of the BIT are substituted for Code, the Code becomes “00101100” (step 11).
03). Next, since the code word “001” can be detected at the head of the code, the process branches from step 1106 to step 1107 of Yes. Subsequently, the detected codeword is es
Since it is not cape or EOB, No from step 1107
Branch to step 1108. And the codeword "001"
Is added to the decoded data sequence (step 1108), and the codeword “00” is read from the beginning of the code.
Excluding “1”, Code becomes “01100” (step 1).
109).

【0074】次に、Codeの長さは0でないのでステ
ップ1110からNoのステップ1106に戻る。そし
て、Codeの先頭部分に符号語「011」が検出できる
ので、ステップ1106からYesのステップ1107
に分岐する。続いて、検出された符号語はescapeやEO
Bではないので、ステップ1107からNoのステップ
1108に分岐する。次に、符号語「011」に対応する
値のデータ「1」を復号データ列に追加し(ステップ1
108)、Codeの先頭から符号語「011」を除く
と、Codeは「00」になる(ステップ1109)。そ
して、Codeの長さは2であるのでステップ1110
からNoのステップ1106に戻る。
Next, since the length of the code is not 0, the process returns from step 1110 to step 1106 of No. Then, since the code word “011” can be detected at the beginning of the code, the steps 1106 to 1107 of Yes
Branch to Next, the detected code word is escape or EO
Since it is not B, the process branches from step 1107 to step 1108 of No. Next, data “1” corresponding to the code word “011” is added to the decoded data sequence (step 1).
108), excluding the code word “011” from the beginning of the code, the code becomes “00” (step 1109). Then, since the length of the code is 2, step 1110
The process returns to step 1106 of No.

【0075】このとき、Codeの先頭部分に符号語が
検出できないので、ステップ1106からNoのステッ
プ1113へ分岐する。そして、この場合Codeが
「00」であり、符号語「001」「0001」「00001」などの
先頭2ビットに一致するので、ステップ1113からY
esのステップ1114に分岐する。続いて、余りのビ
ット列がCode「00」となる状態、すなわち状態11
を「次の状態」に格納し(ステップ1114)、処理を
終了する。
At this time, since a codeword cannot be detected at the head of the code, the process branches from step 1106 to step 1113 of No. In this case, since the Code is “00” and matches the first two bits of the code words “001”, “0001”, “00001”, etc.
It branches to step 1114 of es. Subsequently, the state where the remaining bit string becomes Code “00”, that is, state 11
Is stored in the “next state” (step 1114), and the process ends.

【0076】テーブル1におけるレコード45は、「復
号データ列」はレコード44と同じ値「0,1」となる
が、この場合余りのビット列が「01」であるので、「次
の状態」には12が格納される。また、レコード92
は、値5を示す「0101」という符号を復号しビット列
「1100」が余る場合であるので、「復号データ列」の値
には「5」、「次の状態」には22が格納される。
In the record 45 in the table 1, the "decoded data string" has the same value "0, 1" as the record 44. In this case, since the remaining bit string is "01", the "next state" 12 is stored. Also, record 92
Is a case where the code “0101” indicating the value 5 is decoded and the bit string “1100” remains, so “5” is stored in the value of the “decoded data string” and 22 is stored in the “next state”. .

【0077】また、テーブル1におけるレコード93
は、値5を示す「0101」と値7を示す「1101」という符
号を復号し、余りのビット列がなくなる場合であり、1
ビット目から復号する初期状態と同じ状態となる。よっ
て、「復号データ列」の値には「5,7」、「次の状
態」には1(「初期状態:1ビット目から復号」)が格
納される。このレコードを得る手順を図11に基づいて
説明する。
The record 93 in the table 1
Is a case where the code “0101” indicating the value 5 and the code “1101” indicating the value 7 are decoded, and the remaining bit string is lost.
The state becomes the same as the initial state of decoding from the bit number. Therefore, “5, 7” is stored in the value of the “decoded data string”, and 1 (“initial state: decoding from the first bit”) is stored in the “next state”. The procedure for obtaining this record will be described with reference to FIG.

【0078】この場合、まずBITに「01011101」を代
入し(ステップ1101)、状態1は初期状態であるの
で、ステップ1102からYesのステップ1103へ
分岐する。次に、状態Sが1ビット目からの復号である
のでBITの1ビット目から最後までをCodeに代入
すると、Codeは「01011101」になる(ステップ11
03)。そして、Codeの先頭部分に符号語「0101」
が検出できるので、ステップ1106からYesのステ
ップ1107に分岐する。続いて、検出された符号語は
escapeやEOBではないので、ステップ1107からN
oのステップ1108に分岐する。次に、符号語「010
1」に対応する値のデータ「5」を復号データ列に追加
し(ステップ1108)、Codeの先頭から符号語
「0101」を除くと、Codeは「1101」になる(ステッ
プ1109)。
In this case, first, "01011101" is assigned to BIT (step 1101). Since state 1 is the initial state, the flow branches from step 1102 to step 1103 of Yes. Next, since the state S is decoding from the first bit, when the first bit to the last bit of the BIT are substituted into Code, the Code becomes “01011101” (step 11).
03). Then, the code word “0101” is added at the beginning of the code.
Can be detected, and the process branches from step 1106 to step 1107 of Yes. Subsequently, the detected codeword is
Since it is not escape or EOB, N from step 1107
Branch to step 1108 of o. Next, the codeword "010
Data “5” having a value corresponding to “1” is added to the decoded data string (step 1108), and the code becomes “1101” by removing the codeword “0101” from the beginning of the code (step 1109).

【0079】次に、Codeの長さは0でないので、ス
テップ1110からNoのステップ1106に戻る。そ
して、Codeの先頭部分に符号語「1101」が検出でき
るので、ステップ1106からYesのステップ110
7に分岐する。続いて、検出された符号語はescapeやE
OBではないので、ステップ1107からNoのステッ
プ1108に分岐する。そして、符号語「1101」に対応
する値のデータ「7」を復号データ列に追加すると、復
号データ列は「5,7」になる(ステップ1108)。
このとき、Codeの先頭から符号語「1101」を除く
と、Codeは「」(内容なし)になる(ステップ11
09)。次に、Codeの長さは0であるので、ステッ
プ1110からYesのステップ1111に分岐する。
そして、「次の状態」に「初期状態:1ビット目から復
号」を示す状態1を格納し(ステップ1111)、処理
を終了する。
Next, since the length of the code is not 0, the process returns from step 1110 to step 1106 of No. Then, since the code word “1101” can be detected at the head of the code, the steps 1106 to 110
Branch to 7. Subsequently, the detected codeword is escape or E
Since it is not OB, the process branches from step 1107 to step 1108 of No. Then, when the value data “7” corresponding to the code word “1101” is added to the decoded data sequence, the decoded data sequence becomes “5, 7” (step 1108).
At this time, if the codeword “1101” is removed from the beginning of the code, the code becomes “” (no content) (step 11).
09). Next, since the length of the code is 0, the process branches from step 1110 to step 1111 of Yes.
Then, the state 1 indicating "initial state: decoding from the first bit" is stored in the "next state" (step 1111), and the process ends.

【0080】また、テーブル1におけるレコード255
は、値3を示す「111」という符号を2つ復号し、余り
のビット列が「11」となる場合であり、「復号データ
列」の値には「3,3」、「次の状態」には14が格納
される。
The record 255 in the table 1
Is a case where two codes “111” indicating the value 3 are decoded and the remaining bit string becomes “11”. The values of the “decoded data string” are “3, 3”, Is stored in.

【0081】図12(B)に示すテーブル5は、状態
5、すなわち「初期状態:5ビット目から復号」という
状態で使用するテーブルである。このテーブル5におい
て、レコード番号0のレコード(レコード0)は、「00
000000」という符号が現れた場合に用いるものである
が、復号するのは5ビット目以降の「0000」となり、こ
こでは対応する符号が決まらないために、「復号データ
列」の値には何も格納しない。また、余りのビット列が
「0000」であるから「次の状態」は19となる。レコー
ド44とレコード92は、5ビット目以降の符号は同じ
く「1100」であり、1つ以上の値を復号できないので、
「復号データ列」の値には何も格納しない。また、余り
のビット列が「1100」であるから「次の状態」は22と
なる。レコード45とレコード93は、5ビット目以降
の符号は同じく「1101」であり、値7を復号し余りのビ
ット列がなくなる場合である。よって「復号データ列」
の値には「7」、「次の状態」には1が格納される。レ
コード255は、5ビット目以降の符号は「1111」であ
り、値3を復号しビット列「1」が余るので、「復号デ
ータ列」の値には「3」、「次の状態」には10が格納
される。
Table 5 shown in FIG. 12B is a table used in state 5, that is, "initial state: decoding from bit 5". In this table 5, the record of record number 0 (record 0) is "00
This code is used when the code “00000” appears. However, the code to be decoded is “0000” after the fifth bit. Since the corresponding code is not determined here, the value of the “decoded data string” is Is also not stored. Since the remaining bit string is “0000”, the “next state” is 19. In the record 44 and the record 92, the code after the fifth bit is also “1100” and one or more values cannot be decoded.
Nothing is stored in the value of the "decoded data string". The “next state” is 22 since the remaining bit string is “1100”. In the record 45 and the record 93, the code after the fifth bit is also “1101”, and the value 7 is decoded and there is no excess bit string. Therefore, "decrypted data string"
Is stored in the value of “7”, and 1 in the “next state”. In the record 255, the code after the fifth bit is “1111”, and the value 3 is decoded and the bit string “1” is left. Therefore, the value of the “decoded data string” is “3”, and the value of the “next state” is 10 is stored.

【0082】図12(C)に示すテーブル10は、状態
10、すなわち通常状態で「余りのビット列」が「1」
という状態で使用するテーブルである。このテーブル1
0において、レコード8は、「00001000」という符号が
現れた場合に用いるレコードであり、この場合余りのビ
ット列「1」を前に付けた「100001000」が復号対象とな
る。ここで、EOBを示す「100001」を復号でき、余り
のビット列が「000」の3ビットになるので、「復号デ
ータ列」の値は格納されず、「次の状態」は「EOB検
出:残りビット数3」を示す状態30となる。このレコ
ードを得る手順を図11に基づいて説明する。
Table 10 shown in FIG. 12 (C) shows that in state 10, that is, in the normal state, the "remaining bit string" is "1".
It is a table used in the state. This table 1
At 0, record 8 is a record used when the code "00001000" appears. In this case, "100001000" with the surplus bit string "1" prefixed is to be decoded. Here, “100001” indicating the EOB can be decoded, and the remaining bit string becomes 3 bits of “000”. Therefore, the value of the “decoded data string” is not stored, and the “next state” is “EOB detection: remaining. State 30 indicating "bit number 3" is reached. The procedure for obtaining this record will be described with reference to FIG.

【0083】この場合、まずBITに「00001000」を代
入し(ステップ1101)、状態Sは初期状態ではない
ので、ステップ1102からNoのステップ1104に
分岐する。次に、状態10に対応する「余りのビット
列」は「1」であるので、Rに「1」を代入する(ステッ
プ1104)。そして、RとBITを連結した「100001
000」をCodeに代入する(ステップ1105)。次
に、Codeの先頭部分にEOB符号「100001」が検出
できるので、ステップ1106からYesのステップ1
107に分岐する。そして、検出された符号語はEOB
であるので、ステップ1107からYesのステップ1
112に分岐する。このとき、CodeからEOBを除
いた余りのビット列は3ビットであるので、「次の状
態」にEOB検出状態で残りビット数が3ビットである
ことを示す状態30を格納し(ステップ1112)、処
理を終了する。また、レコード9もレコード8と同様で
あり、「復号データ列」の値には「−」、「次の状態」
には「EOB検出:残りビット数3」を示す状態30が
格納される。
In this case, first, "00001000" is assigned to BIT (step 1101). Since the state S is not the initial state, the process branches from step 1102 to step 1104 of No. Next, since the “remainder bit string” corresponding to the state 10 is “1”, “1” is substituted for R (step 1104). Then, R and BIT are linked to “100001
"000" is substituted for Code (step 1105). Next, since the EOB code “100001” can be detected at the beginning of the code, the steps 1106 to 1
Branch to 107. Then, the detected code word is EOB
Therefore, Step 1107 to Step 1 of Yes
Branch to 112. At this time, since the remaining bit string excluding EOB from the Code is 3 bits, a state 30 indicating that the number of remaining bits is 3 bits in the EOB detection state is stored in the “next state” (step 1112), The process ends. The record 9 is the same as the record 8, and the value of the “decoded data string” is “−”, and the “next state”
Stores a state 30 indicating "EOB detection: remaining bit number 3".

【0084】また、テーブル10におけるレコード44
は、「00101100」という符号が現れた場合に用いるレコ
ードであり、この場合余りのビット列「1」を前に付け
た「100101100」が復号対象となる。ここで、値6を示
す「1001」と値1を示す「011」を復号し、ビット列「0
0」が余るので、「復号データ列」の値には「6,
1」、「次の状態」には「通常状態で余りのビット列:
00」を示す状態11が格納される。また、レコード14
2は、「10001110」という符号が現れた場合に用いるレ
コードであり、この場合余りのビット列「1」を前に付
けた「110001110」が復号対象となる。ここで、まずesc
apeを示す「110001」が復号でき、余りのビット列が「1
10」の3ビットとなるので、「復号データ列」の値は格
納されず、「次の状態」には「escape検出:残りビット
数3」を示す状態38が格納される。
The record 44 in the table 10
Is a record used when the code “00101100” appears. In this case, “100101100” prefixed with the surplus bit string “1” is to be decoded. Here, “1001” indicating the value 6 and “011” indicating the value 1 are decoded, and the bit string “0” is decoded.
Since “0” remains, the value of “decoded data string” is “6,
"1" and "next state" include "bit string remaining in normal state:
00 is stored. Also, record 14
Reference numeral 2 denotes a record used when the code “10001110” appears. In this case, “110001110” with the surplus bit string “1” prefixed is to be decoded. Where first esc
"110001" indicating ape can be decoded, and the remaining bit string is "1
Since it is 3 bits of "10", the value of the "decoded data string" is not stored, and the "next state" stores the state 38 indicating "escape detection: remaining bit number 3".

【0085】また、図12の(D)にはテーブル6
(「初期状態:6ビット目から復号」)のレコード44
を、(E)にはテーブル17(「通常状態で余りのビッ
ト列:100」)のレコード195を示した。これらのテ
ーブルや図10のテーブル22は、上記と同様にして図
11の処理フローに基づいて各レコードが得られる。以
上述べたテーブルのレコード取得手順の説明によって、
図11の処理フローにおけるすべての動作についての具
体例を示した。
FIG. 12D shows a table 6
Record 44 of “(initial state: decoding from 6th bit)”
(E) shows the record 195 of the table 17 (“the remaining bit string in the normal state: 100”). In these tables and the table 22 in FIG. 10, each record is obtained based on the processing flow in FIG. 11 in the same manner as described above. By the explanation of the record acquisition procedure of the table mentioned above,
A specific example of all the operations in the processing flow of FIG. 11 has been described.

【0086】次に、本実施形態における可変長符号復号
手段102の動作について説明する。可変長符号復号手
段102は、復号を開始するビットの位置を、アドレス
(メモリの先頭からのバイト数)と、そのアドレスの中
の何ビット目かによって与えられると、(1)可変長符
号格納手段101に対して読み出しアドレスを指定する
ことによりそのアドレスの1バイトの符号を取り出し、
(2)復号テーブル103を参照して可変長符号の復号
を行い、(3)復号したデータを復号データ格納手段1
04に出力する、という処理を繰り返して可変長符号の
復号を行う。
Next, the operation of the variable length code decoding means 102 in the present embodiment will be described. The variable length code decoding means 102, when given the position of the bit to start decoding by the address (the number of bytes from the head of the memory) and the number of the bit in the address, (1) storing the variable length code By designating a read address to the means 101, the code of one byte of the address is extracted,
(2) decoding the variable length code with reference to the decoding table 103; and (3) storing the decoded data in the decoded data storage unit 1.
The decoding of the variable-length code is performed by repeating the process of outputting the variable-length code.

【0087】図13は可変長符号復号手段102の動作
の処理フローの例を示したものであり、この図13によ
って本実施形態の復号手順を以下に説明する。
FIG. 13 shows an example of the processing flow of the operation of the variable length code decoding means 102. The decoding procedure of this embodiment will be described below with reference to FIG.

【0088】まずステップ1301で、読み出しアドレ
スを示す変数ReadPに復号を開始するビット位置のアド
レス(メモリ上の復号開始アドレス)を格納し、最初は
初期状態であるため、状態Sに復号開始のビット位置に
対応した状態番号を代入する。上述したように、初期状
態の状態番号は、復号開始ビット位置1〜8に対してそ
れぞれ1〜8が割り当てられている。
First, in step 1301, the address of the bit position to start decoding (the decoding start address on the memory) is stored in the variable ReadP indicating the read address. Substitute the state number corresponding to the position. As described above, 1 to 8 are assigned to the decoding start bit positions 1 to 8, respectively, as the initial state numbers.

【0089】次にステップ1302で、可変長符号格納
手段101に対してアドレスReadPを指示し、可変長符
号格納手段101に格納された符号の中から対応するア
ドレスの1バイトのデータを取得し、変数Dに代入す
る。そしてステップ1303で、復号テーブル103に
おける状態Sに対応したテーブルのD番のレコードを参
照し、「復号データ列」に格納されている復号したデー
タの列と、「次の状態」Snextとを得る。ここで復号デ
ータ列があればそのデータを復号データ格納手段104
に出力する。次にステップ1304〜1306でSnext
を判定する。
Next, in step 1302, an address ReadP is instructed to the variable-length code storage means 101, and 1-byte data of the corresponding address is obtained from the codes stored in the variable-length code storage means 101. Assign to variable D. Then, in step 1303, by referring to the D-th record in the table corresponding to the state S in the decoding table 103, the column of the decoded data stored in the “decoded data column” and the “next state” Snext are obtained. . If there is a decoded data string, the data is stored in the decoded data storage unit 104.
Output to Next, in steps 1304 to 1306, Snext
Is determined.

【0090】ステップ1304では、SnextがEOB検
出であるか否かを判定し、Snextが27〜34の場合は
EOB検出であるので、処理を終了する。ステップ13
05では、Snextがescape検出であるか否かを判定し、
Snextが35〜42の場合はescape検出であるので、ス
テップ1308へ進む。ステップ1306では、Snext
がエラー検出であるか否かを判定し、Snextが43の場
合はエラー検出であるので、処理を終了する。
In step 1304, it is determined whether or not Snext is EOB detection. If Snext is 27 to 34, EOB detection is performed, and the process ends. Step 13
In 05, it is determined whether or not Snext is an escape detection,
If the value of Next is 35 to 42, escape detection is performed, and the process proceeds to step 1308. In step 1306, the Snext
Is determined to be an error detection. If Snext is 43, an error has been detected and the process is terminated.

【0091】次にステップ1307で、ReadPに1を加
算し、復号対象データの読み出し位置を1バイト進め
る。また、状態SにSnextを代入して状態を移行する。
その後、ステップ1302に戻って同様の処理を繰り返
す。
Next, at step 1307, 1 is added to ReadP, and the read position of the data to be decoded is advanced by one byte. Also, Snext is assigned to the state S, and the state is shifted.
Thereafter, the flow returns to step 1302 to repeat the same processing.

【0092】ステップ1308〜1309はescape検出
状態における処理であり、ステップ1308では、esca
pe符号に続く固定長部を復号し、復号データを復号デー
タ格納手段104に出力する。この場合、固定長部は8
ビットであるので、ReadP+1のアドレスを可変長符号
格納手段101に指示し、対応するアドレスの1バイト
のデータを取得する。そして既に得ている変数Dのesca
pe符号の後の部分と、新しく得た1バイトのデータから
8ビット分を取り出し、図2(B)のテーブルに従って
復号する。
Steps 1308 to 1309 are processing in the escape detection state. In step 1308, esca
The fixed length part following the pe code is decoded, and the decoded data is output to the decoded data storage unit 104. In this case, the fixed length is 8
Since it is a bit, the address of ReadP + 1 is instructed to the variable length code storage means 101, and 1-byte data of the corresponding address is obtained. And the esca of the variable D that we have already obtained
Eight bits are extracted from the part after the pe code and the newly obtained 1-byte data, and are decoded according to the table in FIG.

【0093】次いでステップ1309で、固定長部を復
号した後に対応する状態になるように、状態Sと読み出
しアドレスReadPを更新する。ここで、ステップ130
8において新しく得た1バイトのデータの固定長部分以
降に残りビットがある場合は、ReadPにReadP+1を代入
し、状態Sには、残りビットがn(1〜7)ビットのと
き、「初期状態:9−nビット目から復号」の状態2〜
8を設定する。一方、固定長部分以降に残りビットがな
い場合は、ReadPにReadP+2を代入し、状態Sには、
「初期状態:1ビット目から復号」の状態1を設定す
る。
Next, in step 1309, the state S and the read address ReadP are updated so that the state becomes the corresponding state after decoding the fixed length part. Here, step 130
If there are remaining bits after the fixed-length part of the newly obtained 1-byte data in step 8, ReadP + 1 is substituted for ReadP. : Decoding from the 9th-nth bit "
Set 8. On the other hand, if there are no remaining bits after the fixed length part, ReadP + 2 is substituted for ReadP, and
State 1 of "initial state: decoding from first bit" is set.

【0094】次に、可変長符号復号手段102の動作の
具体例として、図14に示す可変長符号を復号する場合
を例にとり図13に基づいて詳しく説明する。図14は
可変長符号格納手段101に格納されている可変長符号
の例であり、四角の枠の中に1バイト毎の符号内容を示
し、枠の上側にアドレス、枠の下側に復号した値を示し
ている。各バイトの内容について、四角の枠の中の上段
は10進数での数値を示し、下段には2進数でのビット
列を示している。ここで、復号を開始するビット位置
は、アドレス1001の5ビット目からとする。また、以降
の説明で参照するテーブル及びレコードはすべて図10
と図12に示されている。
Next, a specific example of the operation of the variable length code decoding means 102 will be described in detail with reference to FIG. 13 taking the case of decoding the variable length code shown in FIG. 14 as an example. FIG. 14 shows an example of the variable-length code stored in the variable-length code storage means 101. The code content of each byte is shown in a rectangular frame, and the address is above the frame, and the address is decoded below the frame. Indicates the value. Regarding the contents of each byte, the upper part in the square frame shows a numerical value in decimal number, and the lower part shows a bit string in binary number. Here, the bit position to start decoding is from the fifth bit of the address 1001. Further, all tables and records referred to in the following description are shown in FIG.
And FIG.

【0095】まずReadPに開始アドレス1001を代入し、
状態Sには、初期状態で5ビット目からの復号であるの
で5を代入する(ステップ1301)。そして、可変長
符号格納手段101からReadPのアドレス、すなわちア
ドレス1001の1バイトデータ「92(01011100)」を得
てDに代入する(ステップ1302)。次に、Sが5、
Dが92であるので、復号テーブル103におけるテー
ブル5のレコード92を参照する(ステップ130
3)。この場合は復号される値がなく、「次の状態」と
して状態22(「通常状態で余りのビット列:1100」)
が得られるので、Snextに22を代入する。ここで、S
next=22であるので、ステップ1304〜1306の
判定結果はすべてNoとなり、ステップ1307に進
む。そして、ReadPに1を加算して1002とするととも
に、SにSnextを代入して22とし(ステップ130
7)、ステップ1302に戻る。
First, the start address 1001 is substituted for ReadP,
In the state S, 5 is substituted because the decoding is from the fifth bit in the initial state (step 1301). Then, the address of ReadP, that is, 1-byte data “92 (01011100)” of the address 1001 is obtained from the variable-length code storage unit 101 and substituted into D (step 1302). Next, S is 5,
Since D is 92, the record 92 of the table 5 in the decoding table 103 is referred to (step 130).
3). In this case, there is no value to be decoded, and the state is set as the “next state” in state 22 (“bit string remaining in normal state: 1100”).
Is obtained, 22 is substituted for Snext. Where S
Since next = 22, the determination results in steps 1304 to 1306 are all No, and the process proceeds to step 1307. Then, 1 is added to ReadP to obtain 1002, and Snext is substituted for S to obtain 22 (step 130).
7) Return to step 1302.

【0096】2回目のステップ1302では、変数Dと
してReadP=1002のアドレスの1バイトデータ「243
(11110011)」を得る。そして、復号テーブル103に
おけるテーブル22のレコード243を参照する(ステ
ップ1303)。この場合は、復号データ列として値
「11,3,0」、「次の状態」として状態10(「通
常状態で余りのビット列:1」)が得られる。この復号
データ列の値「11,3,0」を復号データ格納手段1
04に出力し、Snextに10を代入する。ここで、Sne
xt=10であるので、ステップ1304〜1306の判
定結果はすべてNoとなり、ステップ1307に進む。
そして、ReadPに1を加算して1003とするとともに、S
にSnextを代入して10とし(ステップ1307)、ス
テップ1302に戻る。
In step 1302 for the second time, 1-byte data “243
(11110011) ". Then, the record 243 of the table 22 in the decoding table 103 is referred to (step 1303). In this case, a value “11,3,0” is obtained as a decoded data string, and a state 10 (“remaining bit string: 1 in normal state”) is obtained as a “next state”. The value “11,3,0” of the decoded data string is stored in the decoded data storage unit 1.
04 and substitute 10 for Snext. Where Sne
Since xt = 10, the determination results in steps 1304 to 1306 are all No, and the process proceeds to step 1307.
Then, 1 is added to ReadP to obtain 1003, and S
Is set to 10 (step 1307), and the process returns to step 1302.

【0097】3回目のステップ1302では、変数Dと
してReadP=1003のアドレスの1バイトデータ「142
(10001110)」を得る。そして、復号テーブル103に
おけるテーブル10のレコード142を参照する(ステ
ップ1303)。この場合は復号される値がなく、「次
の状態」として状態38(「escape検出:残りビット数
3」)が得られるので、Snextに38を代入する。ここ
で、Snext=38であるので、ステップ1305の判定
結果がYesとなり、escape検出状態であることが判別
され、ステップ1308に進む。そして、取り出したデ
ータのescape以降の固定長部を復号する(ステップ13
08)。このとき、まず次のReadP+1のアドレス1004
の1バイトデータ「44(00101100)」を得て、次にデ
ータD=142におけるescape符号以降の残りの3ビッ
トのビット列「110」と、次のデータ「44」の初めの
5ビット「00101」とを結合して、8ビットのビット列
「11000101」を得る。そして図2(B)のテーブルを参
照すると、この8ビットのデータは値「197」に対応
するため、復号データとして値「197」を復号データ
格納手段104に出力する。その後、次の状態を示す状
態Sと読み出しアドレスReadPを更新する(ステップ1
309)。この場合、次はアドレス1004の6ビット目か
ら復号を開始することになるので、ReadPに1004を代入
し、Sには「初期状態:6ビット目から復号」を示す状
態6を代入する。
In the third step 1302, as the variable D, 1-byte data “142” of the address of ReadP = 1003
(10001110) ". Then, reference is made to the record 142 of the table 10 in the decoding table 103 (step 1303). In this case, there is no value to be decoded, and a state 38 (“escape detection: remaining number of bits 3”) is obtained as the “next state”, so 38 is substituted for Snext. Here, since Snext = 38, the determination result of step 1305 is Yes, it is determined that the escape is being detected, and the process proceeds to step 1308. Then, the fixed length portion after the escape of the extracted data is decoded (step 13).
08). At this time, first, the address 1004 of the next ReadP + 1
Is obtained, then the remaining three-bit bit string “110” after the escape code in data D = 142 and the first five bits “00101” of the next data “44” are obtained. To obtain an 8-bit bit string "11000101". Then, referring to the table in FIG. 2B, since the 8-bit data corresponds to the value “197”, the value “197” is output to the decoded data storage unit 104 as the decoded data. Thereafter, the state S indicating the next state and the read address ReadP are updated (step 1).
309). In this case, the decoding starts next from the sixth bit of the address 1004. Therefore, 1004 is assigned to ReadP, and the state 6 indicating “initial state: decoding from the sixth bit” is assigned to S.

【0098】4回目のステップ1302では、変数Dと
してReadP=1004のアドレスの1バイトデータ「44(0
0101100)」を得る。そして、復号テーブル103にお
けるテーブル6のレコード44を参照する(ステップ1
303)。この場合は復号される値がなく、「次の状
態」として状態17(「通常状態で余りのビット列:10
0」)が得られるので、Snextに17を代入する。ここ
で、Snext=17であるので、ステップ1304〜13
06の判定結果はすべてNoとなり、ステップ1307
に進む。そして、ReadPに1を加算して1005とするとと
もに、SにSnextを代入して17とし(ステップ130
7)、ステップ1302に戻る。
In the fourth step 1302, 1-byte data “44 (0
0101100) ”. Then, the record 44 of the table 6 in the decoding table 103 is referred to (step 1).
303). In this case, there is no value to be decoded, and the next state is set to state 17 (“the remaining bit string: 10 in the normal state”).
0 ”) is obtained, so 17 is substituted for Snext. Here, since Snext = 17, steps 1304 to 13
All the judgment results of No. 06 are No, and step 1307
Proceed to. Then, 1 is added to ReadP to obtain 1005, and Snext is substituted for S to obtain 17 (step 130).
7) Return to step 1302.

【0099】5回目のステップ1302では、変数Dと
してReadP=1005のアドレスの1バイトデータ「195
(11000011)」を得る。そして、復号テーブル103に
おけるテーブル17のレコード195を参照する(ステ
ップ1303)。この場合は、復号データ列として値
「6」、「次の状態」として状態28(「EOB検出:
残りビット数:1」)が得られる。この復号データ列の
値「6」を復号データ格納手段104に出力し、Snext
に28を代入する。このとき、Snext=28であるの
で、ステップ1304の判定結果がYesとなり、可変
長符号の終了が検出されたことによって、処理を終了す
る。
In the fifth step 1302, as the variable D, 1-byte data “195” at the address of ReadP = 1005
(11000011) ". Then, the record 195 of the table 17 in the decoding table 103 is referred to (step 1303). In this case, the value “6” is set as the decoded data string, and the state 28 (“EOB detection:
The number of remaining bits: 1) is obtained. The value “6” of the decoded data string is output to the decoded data storage unit 104,
Is assigned to 28. At this time, since Snext = 28, the result of the determination in step 1304 is Yes, and the process ends when the end of the variable length code is detected.

【0100】以上の動作によって、復号データ格納手段
104には、アドレス1001から1005までを復号した値と
して「11,3,0,197,6」が出力され、またア
ドレス1005でEOB符号を検出し余りのビット数が1で
あるという状態を得ることができる。
By the above operation, "11, 3, 0, 197, 6" is output to the decoded data storage means 104 as a value obtained by decoding the addresses 1001 to 1005, and the EOB code is detected at the address 1005. A state in which the number of surplus bits is 1 can be obtained.

【0101】このようにして、可変長符号を復号する際
に、バイト単位でデータを扱い、ビット演算を行うこと
なくテーブルを参照するのみで復号を行うことができ
る。また、escape符号を伴った固定長符号を検出するこ
ともでき、固定長符号を復号した後は再び同様の手順で
可変長符号の復号を開始することができる。これによ
り、可変長符号の復号処理を容易かつ高速に行うことが
可能となるため、処理時間を短縮でき、復号処理を行う
プロセッサの負荷を軽減できる。
As described above, when decoding a variable length code, data can be handled in units of bytes, and decoding can be performed only by referring to a table without performing a bit operation. It is also possible to detect a fixed-length code accompanied by an escape code. After decoding the fixed-length code, decoding of the variable-length code can be started again in the same procedure. As a result, the decoding process of the variable length code can be performed easily and at high speed, so that the processing time can be reduced and the load on the processor that performs the decoding process can be reduced.

【0102】なお、上述した第1実施形態では、escape
符号以降に8ビットの固定長の符号を定義したが、図3
4に示したようなすべての符号が可変長符号である場合
には、図13の処理フローにおける固定長部の復号処理
(ステップ1305,1308,1309)を省略でき
る。
In the first embodiment described above, the escape
An 8-bit fixed-length code is defined after the code.
In the case where all the codes as shown in FIG. 4 are variable length codes, the decoding processing of the fixed length part (steps 1305, 1308, 1309) in the processing flow of FIG. 13 can be omitted.

【0103】また、本実施形態では、escape符号によっ
て始まる固定長符号を復号するために、データ中の固定
長部分を取り出すように構成しており、この処理のため
にビット演算が必要となる。これを回避するために、es
cape符号とそれ以降の8ビットの固定長部の計14ビッ
トからなる符号を通常の可変長符号と同じように扱って
復号テーブルを作成し、値14から255までを含むす
べての符号語をビットシフトを行わずに復号できるよう
に構成しても構わない。このように構成することによ
り、さらに処理時間を短縮できる。この場合、可変長符
号復号手段102で復号を行う際に生じる「余りのビッ
ト列」の組み合わせが多くなるため、より多くの状態と
それに対応したテーブルが必要となる。
Further, in the present embodiment, a fixed length part in data is taken out in order to decode a fixed length code starting with an escape code, and a bit operation is required for this processing. To avoid this, es
A decoding table is created by treating a cape code and a code consisting of a total of 14 bits of a fixed-length portion of 8 bits thereafter in the same manner as a normal variable-length code, and sets all codewords including the values 14 to 255 as bits. The decoding may be performed without performing the shift. With this configuration, the processing time can be further reduced. In this case, the number of combinations of “remaining bit strings” generated when decoding is performed by the variable-length code decoding unit 102 increases, so that more states and corresponding tables are required.

【0104】また、本実施形態では、図2に示したよう
な可変長符号を復号する構成例を示したが、どのような
可変長符号にも適用可能であり、復号対象とする可変長
符号の内容に応じて復号テーブルや復号手段を構成でき
る。例えば、MPEGを復号する構成では、復号テーブ
ルにおいて各テーブルの復号データ列に格納するものと
しては、MPEGのランと符号付きのレベルとからなる
データの組を列挙したものとなる。そして、EOB符号
のビット列は「10」であり、固定長符号の始まりを示す
escape符号のビット列は「000001」であり、また、固定
長符号の部分は6ビットのランに続き、8ビットまたは
16ビットの符号付きレベルとなるので、これらを復号
するように構成すればよい。
In this embodiment, an example of decoding a variable length code as shown in FIG. 2 has been described. However, the present invention can be applied to any variable length code, The decoding table and the decoding means can be configured according to the contents of. For example, in a configuration for decoding MPEG, a set of data including MPEG runs and signed levels is enumerated as what is stored in the decoded data string of each table in the decoding table. The bit string of the EOB code is “10”, indicating the beginning of the fixed-length code.
The bit sequence of the escape code is “000001”, and the fixed-length code portion has a signed level of 8 bits or 16 bits following a 6-bit run, so that these may be decoded.

【0105】以上説明したように、本実施形態では、復
号テーブルとして、復号処理時の各状態に対応した複数
のテーブルを持ち、各テーブルのレコードRNにその状
態においてRNが示すビット列を復号した「復号データ
列」と「次の状態」とをそれぞれ格納したものを使用
し、1バイト毎にデータを取り出しながらこの復号テー
ブルを参照することによって可変長符号を復号するよう
になっている。このような復号方法によって、可変長符
号をビット演算を行わずに復号することができるため、
復号の処理時間を短縮することができ、その実用的効果
は大きい。
As described above, in the present embodiment, the decoding table has a plurality of tables corresponding to each state at the time of decoding processing, and the record RN of each table decodes the bit string indicated by RN in that state. A variable-length code is decoded by referring to the decoding table while taking out data for each byte, using the data storing the "decoded data string" and the "next state", respectively. With such a decoding method, a variable-length code can be decoded without performing a bit operation.
The decoding processing time can be reduced, and the practical effect is great.

【0106】[第2実施形態]第2実施形態は、MPE
G1におけるDCT係数のランとレベルの可変長符号を
復号する構成及び方法の一例を示したものである。可変
長符号復号装置の構成は図1に示した第1実施形態と同
様である。可変長符号復号手段102は、半導体メモリ
等で実現される可変長符号格納手段101に対して、1
バイト=8ビット単位でアクセスを行うことができる。
本実施形態では、1バイトの最上位ビットを1ビット
目、最下位ビットを8ビット目と表記する。
[Second Embodiment] In the second embodiment, the MPE
FIG. 3 shows an example of a configuration and a method for decoding a variable length code of a run and a level of a DCT coefficient in G1. The configuration of the variable-length code decoding device is the same as that of the first embodiment shown in FIG. The variable-length code decoding unit 102 is provided with a variable-length code storage unit 101 implemented by a semiconductor memory or the like.
Access can be performed in units of bytes = 8 bits.
In the present embodiment, the most significant bit of one byte is described as a first bit, and the least significant bit is described as an eighth bit.

【0107】図15(A),(B)、図16(A),
(B)に、復号する可変長符号の例としてMPEG1に
おけるDCT係数のランとレベルの可変長符号を示す。
図15において、符号「10」は、可変長符号の終わりを
示すEOB(End Of Block)符号である。符号「00000
1」は、固定長符号によるラン、レベルの開始を示すesc
ape符号(固定長識別符号)である。その他の符号は、
1組のラン、レベルに対応し、符号の最後のビットsが
0ならばレベルは正の値であり、ビットsが1ならばレ
ベルは負の値となる。例えば符号「01000」はラン=
0、レベル=2であり、符号「01001」はラン=0、レ
ベル=−2である。また、符号「1s」は、DCT係数の
可変長符号の最初の符号としてのみ用いられる。すなわ
ちラン=0、レベル=±1を示す場合、最初の符号であ
れば符号「1s」を用いるが、2番目以降であれば符号
「11s」を用いる。図16は、escape符号に続くラン、
レベルの固定長符号を示す。ラン部分の符号長は6ビッ
トであり、レベル部分の符号長は8ビットの場合と16
ビットの場合とがある。
FIGS. 15A and 15B, FIGS.
(B) shows a variable length code of DCT coefficient run and level in MPEG1 as an example of a variable length code to be decoded.
In FIG. 15, the code “10” is an EOB (End Of Block) code indicating the end of the variable length code. The code `` 00000
"1" indicates run with fixed length code, esc indicating start of level
ape code (fixed-length identification code). Other signs are
Corresponding to one set of run and level, if the last bit s of the code is 0, the level is a positive value, and if the bit s is 1, the level is a negative value. For example, the code "01000" is run =
0, level = 2, and the code “01001” is run = 0, level = −2. The code “1s” is used only as the first code of the variable length code of the DCT coefficient. That is, when run = 0 and level = ± 1, the code “1s” is used for the first code, but the code “11s” is used for the second and subsequent codes. FIG. 16 shows the run following the escape code,
Indicates the fixed length code of the level. The code length of the run portion is 6 bits, and the code length of the level portion is 8 bits.
May be a bit.

【0108】本実施形態では、可変長符号復号手段10
2は、可変長符号のデータ列から1バイト毎にデータD
を取り出し、状態Sに対応したテーブルのデータDによ
る番号のレコードを参照して、「復号データ列」を取り
出して復号を行うとともに、「次の状態」を得ることを
繰り返しながら、復号処理を実行する。
In this embodiment, the variable length code decoding means 10
2 is the data D for each byte from the data string of the variable length code.
, And with reference to the record of the number corresponding to the data D of the table corresponding to the state S, the “decoded data sequence” is extracted and decoded, and the decoding process is executed while repeatedly obtaining the “next state”. I do.

【0109】可変長符号復号手段102が取りうる状態
Sには、初期状態SFn、EOB検出状態SEOB、エ
ラー検出状態SERR、ラン復号状態SRUNn、レベ
ル復号状態SLVLn、通常状態SNnの大きく分けて
6つの状態がある。第2実施形態では、固定長復号状態
としてラン復号状態SRUNnとレベル復号状態SLV
Lnの2つの状態を持つ。
The state S that can be taken by the variable-length code decoding means 102 is roughly divided into an initial state SFn, an EOB detection state SEOB, an error detection state SERR, a run decoding state SRRUNn, a level decoding state SLVLn, and a normal state SNn. There is a state. In the second embodiment, as the fixed-length decoding state, a run decoding state SRRUNn and a level decoding state SLV
Ln has two states.

【0110】図17は可変長符号復号手段102が取り
得る状態について、それぞれの状態とその状態が示す意
味、各状態に対応した復号テーブルを示したものであ
る。図17において、(A)は初期状態、EOB検出状
態、エラー検出状態、ラン復号状態、及びレベル復号状
態を、(B)は通常状態を示す。
FIG. 17 shows the states that the variable-length code decoding means 102 can take, the respective states, the meanings indicated by the states, and the decoding tables corresponding to the respective states. 17A shows an initial state, an EOB detection state, an error detection state, a run decoding state, and a level decoding state, and FIG. 17B shows a normal state.

【0111】初期状態SFnは、復号開始時の状態であ
り、1バイトデータの何ビット目から復号するかによっ
て8種類(SF1〜SF8)の状態を持つ。ここで「初
期状態:nビット目から復号」の状態を状態SFnとす
る。初期状態では、それぞれの状態に対応して復号テー
ブルTF1〜TF8のいずれかを参照する。初期状態に
おける復号の様子は図3に示した第1実施形態の場合と
同様である。ただし、復号開始位置にビット列「1x」が
ある場合は、MPEG1のDCTにおいて最初の符号に
のみ用いられる符号語「1s」として復号することが第1
実施形態と異なる。また、第1実施形態と異なり、第2
実施形態での初期状態は、復号を開始したときにのみ取
り得る状態である。
The initial state SFn is a state at the start of decoding, and has eight types of states (SF1 to SF8) depending on the bit number of 1-byte data to be decoded. Here, the state of “initial state: decoding from the n-th bit” is referred to as state SFn. In the initial state, one of the decoding tables TF1 to TF8 is referred to corresponding to each state. The state of decoding in the initial state is the same as in the case of the first embodiment shown in FIG. However, when there is a bit string “1x” at the decoding start position, decoding is performed as a codeword “1s” used only for the first code in the DCT of MPEG1.
Different from the embodiment. Also, unlike the first embodiment, the second
The initial state in the embodiment is a state that can be taken only when decoding is started.

【0112】EOB検出状態SEOBは、EOB符号の
検出を示す状態である。この場合復号テーブルは参照し
ない。このEOB検出状態は図6に示した第1実施形態
の場合と同様である。ただし、EOB符号が「10」の2
ビット長の符号であることが第1実施形態とは異なる。
The EOB detection state SEOB is a state indicating detection of an EOB code. In this case, the decoding table is not referred. This EOB detection state is the same as in the case of the first embodiment shown in FIG. However, the EOB code is "10"
The difference from the first embodiment is that the code has a bit length.

【0113】エラー検出状態SERRは、取り込んだデ
ータ中に想定している可変長符号としてあり得ない符号
を検出しエラーとなった状態である。この場合も復号テ
ーブルは参照しない。
The error detection state SERR is a state in which an error is detected when a code that cannot be assumed as a variable length code assumed in the fetched data is detected. Also in this case, the decoding table is not referred.

【0114】ラン復号状態SRUNnは、escape符号を
検出し、図16に示した固定長のランの復号を行う状態
である。ラン部分の固定長符号の符号長は6ビットある
ので、データDがラン符号のどのビット以降を含むかに
よって1ビット目から6ビット目までの6種類(SRU
N1〜SRUN6)の状態を持つ。このラン復号状態で
は、それぞれの状態に対応して復号テーブルTRUN1
〜TRUN6のいずれかを参照する。
The run decoding state SRUNn is a state in which an escape code is detected and the fixed-length run shown in FIG. 16 is decoded. Since the code length of the fixed-length code of the run portion is 6 bits, six types (SRU) from the first bit to the sixth bit depend on which bit of the data D includes the bit after the run code.
N1 to SRUN6). In this run decoding state, the decoding table TRUN1 corresponds to each state.
~ TRUN6.

【0115】レベル復号状態SLVLnは、escape符号
を検出し、図16に示した固定長のランを復号した後
に、固定長のレベルの復号を行う状態である。データD
がレベル符号のどのビット以降を含むかによって1ビッ
ト目から8ビット目までの8種類(SLVL1〜SLV
L8)の状態を持つ。このレベル復号状態では、それぞ
れの状態に対応して復号テーブルTLVL1〜TLVL
8のいずれかを参照する。レベル部分の固定長符号の符
号長は8ビットと16ビットの2種類があるが、16ビ
ットの場合でnビット(n>8)目の復号状態はn−8
ビット目の復号状態に割り当てる。
The level decoding state SLVLn is a state in which the escape code is detected, the fixed length run shown in FIG. 16 is decoded, and then the fixed length level decoding is performed. Data D
Include eight bits from the first bit to the eighth bit (SLVL1 to SLV
L8). In this level decoding state, the decoding tables TLVL1 to TLVL correspond to the respective states.
8 is referred to. There are two types of code lengths of the fixed length code of the level portion: 8 bits and 16 bits. In the case of 16 bits, the decoding state of the nth bit (n> 8) is n-8.
Assign to the decoding state of the bit.

【0116】図18はラン復号状態とレベル復号状態の
すべての状態を示した説明図である。図18の(A)
は、N+1バイト目の3ビット目から最後(8ビット
目)にescape符号「000001」がある場合である。この場
合、N+2バイト目を処理する際には、ラン部分の1ビ
ット目から復号を行うため「ラン復号:1ビット目か
ら」の状態になる。N+2バイト目には、レベル部分の
先頭2ビットを含むので、N+3バイト目を処理する際
には、レベルの3ビット目から復号を行うため「レベル
復号:3ビット目から」の状態になる。
FIG. 18 is an explanatory diagram showing all the states of the run decoding state and the level decoding state. (A) of FIG.
Is a case where the escape code “000001” is provided from the third bit to the last (eighth bit) of the (N + 1) th byte. In this case, when processing the (N + 2) th byte, the decoding is performed from the first bit of the run portion, so that the state is “run decoding: from the first bit”. Since the (N + 2) th byte includes the first two bits of the level portion, when processing the (N + 3) th byte, decoding is performed from the third bit of the level, so that the state is “level decoding: from the third bit”.

【0117】図18の(B)は、N+1バイト目におい
て、2ビット目から7ビット目にescape符号があり、ラ
ン部分の先頭1ビットを含む場合である。この場合、N
+2バイト目を処理する際には、ラン部分の2ビット目
から復号を行うため「ラン復号:2ビット目から」の状
態になる。N+2バイト目には、レベル部分の先頭3ビ
ットを含むので、N+3バイト目を処理する際には、レ
ベルの4ビット目から復号を行うため「レベル復号:4
ビット目から」の状態になる。(C)は、N+1バイト
目において、1ビット目から6ビット目にescape符号が
あり、ラン部分の先頭2ビットを含む場合である。この
場合、N+2バイト目を処理する際には、ラン部分の3
ビット目から復号を行うため「ラン復号:3ビット目か
ら」の状態になる。N+2バイト目には、レベル部分の
先頭4ビットを含むので、N+3バイト目を処理する際
には、レベルの5ビット目から復号を行うため「レベル
復号:5ビット目から」の状態になる。(D)は、Nバ
イト目の8ビット目からescape符号が始まっており、N
+1バイト目において、5ビット目までescape符号があ
り、6ビット目からラン部分の先頭3ビットを含む場合
である。この場合、N+2バイト目を処理する際には、
ラン部分の4ビット目から復号を行うため「ラン復号:
4ビット目から」の状態になる。N+2バイト目には、
レベル部分の先頭5ビットを含むので、N+3バイト目
を処理する際には、レベルの6ビット目から復号を行う
ため「レベル復号:6ビット目から」の状態になる。
FIG. 18B shows a case where an escape code is present in the second to seventh bits in the (N + 1) th byte and includes the first bit of the run portion. In this case, N
When processing the +2 byte, the decoding is performed from the second bit of the run portion, so that the state becomes “run decoding: from the second bit”. Since the (N + 2) th byte includes the first three bits of the level portion, when processing the (N + 3) th byte, decoding is performed from the fourth bit of the level.
From the bit position. " (C) is a case where the escape code is present in the first to sixth bits in the (N + 1) th byte and includes the first two bits of the run portion. In this case, when processing the (N + 2) th byte, the 3
Since decoding is performed from the bit, the state becomes “run decoding: from the third bit”. Since the (N + 2) th byte includes the first 4 bits of the level portion, when processing the (N + 3) th byte, decoding is performed from the 5th bit of the level, so that the state is “level decoding: from the 5th bit”. In (D), the escape code starts from the 8th bit of the Nth byte.
In the + 1st byte, there is an escape code up to the 5th bit, which includes the first 3 bits of the run portion from the 6th bit. In this case, when processing the (N + 2) th byte,
To perform decoding from the fourth bit of the run part, "Run decoding:
From the fourth bit ". In the N + 2 byte,
Since the first 5 bits of the level portion are included, when processing the (N + 3) th byte, decoding is performed from the 6th bit of the level, so that the state is “level decoding: from the 6th bit”.

【0118】図18の(E)は、Nバイト目の7ビット
目からescape符号が始まっており、N+1バイト目にお
いて、4ビット目までescape符号があり、ラン部分の先
頭4ビットを含む場合である。この場合、N+2バイト
目を処理する際には、「ラン復号:5ビット目から」の
状態となり、N+3バイト目を処理する際には、「レベ
ル復号:7ビット目から」の状態になる。(F)は、N
バイト目の6ビット目からescape符号が始まっており、
N+1バイト目において、3ビット目までescape符号が
あり、ラン部分の先頭5ビットを含む場合である。この
場合、N+2バイト目を処理する際には、「ラン復号:
6ビット目から」の状態となり、N+3バイト目を処理
する際には、「レベル復号:8ビット目から」の状態に
なる。(G)は、Nバイト目の5ビット目からescape符
号が始まる場合である。この場合、N+1バイト目は
「通常状態:余りのビット列:0000」の状態であり、こ
こではラン部分まで復号することができる。N+2バイ
ト目を処理する際には、レベルの1ビット目から復号を
行うため「レベル復号:1ビット目から」の状態にな
る。(H)は、Nバイト目の4ビット目からescape符号
が始まる場合である。この場合、N+1バイト目は「通
常状態:余りのビット列:00000」の状態であり、ここ
ではラン部分まで復号することができる。N+2バイト
目を処理する際には、レベルの2ビット目から復号を行
うため「レベル復号:2ビット目から」の状態になる。
FIG. 18E shows a case where the escape code starts from the 7th bit of the Nth byte, the escape code is up to the 4th bit in the N + 1th byte, and the first 4 bits of the run portion are included. is there. In this case, when the N + 2 byte is processed, the state becomes “run decoding: from the 5th bit”, and when the N + 3 byte is processed, the state becomes “level decoding: from the 7th bit”. (F) is N
The escape code starts from the 6th bit of the byte,
In the (N + 1) th byte, there is an escape code up to the third bit, which includes the first 5 bits of the run portion. In this case, when processing the (N + 2) th byte, “run decoding:
From the 6th bit, the state becomes "level decoding: from the 8th bit" when processing the (N + 3) th byte. (G) shows a case where the escape code starts from the fifth bit of the Nth byte. In this case, the (N + 1) th byte is in the state of “normal state: surplus bit string: 0000”, and in this case, it is possible to decode up to the run part. When processing the (N + 2) th byte, the decoding is performed from the first bit of the level, so that the state is “level decoding: from the first bit”. (H) is a case where the escape code starts from the fourth bit of the Nth byte. In this case, the (N + 1) th byte is in the state of “normal state: surplus bit string: 00000”, and in this case, even the run portion can be decoded. When processing the (N + 2) th byte, the decoding is performed from the second bit of the level, so that the state is “level decoding: from the second bit”.

【0119】通常状態SNnは、復号が行えない「余り
のビット列」が生じている場合の状態であり、「余りの
ビット列」が取り得る組み合わせの個数だけの状態を持
つ。この場合、第1実施形態の図9で示した処理フロー
と同様の方法で「余りのビット列」の組み合わせが決ま
る。なお第2実施形態では、「余りのビット列」が
「1」の場合には、通常のときのSN4以外に、復号開
始直後(初期)におけるSN3の状態があり、また、初
期状態とは別に通常状態に「余りのビット列」がない状
態SN1がある。
The normal state SNn is a state in which a “remainder bit string” that cannot be decoded occurs, and has a state of the number of possible combinations of the “remainder bit string”. In this case, a combination of “remainder bit strings” is determined by the same method as the processing flow shown in FIG. 9 of the first embodiment. In the second embodiment, when the "remaining bit string" is "1", there is a state of SN3 immediately after the start of decoding (initial), in addition to the normal SN4, and the normal state is different from the initial state. There is a state SN1 in which there is no “remaining bit string” in the state.

【0120】図19は状態SN1の例を示した説明図で
ある。この場合、N+1バイト目より前のデータから復
号を開始しており、Nバイト目の最後(8ビット目)ま
である符号を復号し、N+1バイト目の処理において
「余りのビット列」がなく、状態SN1になっている。
図19の(A)は、N+1バイト目の最初に、符号語
「10」(EOB符号)を復号する場合である。これに対
し、「初期状態:1ビット目から復号」の状態SF1で
は、符号語「1s」のs=0の場合を復号し、ラン=0、
レベル=1のデータを得る。(B)は、N+1バイト目
の最初に、符号語「11s」のs=0の場合を復号し、ラ
ン=0、レベル=1のデータを得る場合である。これに
対し、「初期状態:1ビット目から復号」の状態SF1
では、符号語「1s」のs=1の場合(2ビット分)を復
号し、ラン=0、レベル=−1のデータを得る。(C)
は、N+1バイト目の最初に、符号語「11s」のs=1
の場合を復号し、ラン=0、レベル=−1のデータを得
る場合である。これに対し、「初期状態:1ビット目か
ら復号」の状態SF1では、符号語「1s」のs=1の場
合(2ビット分)を復号し、ラン=0、レベル=−1の
データを得る。なお、図19の(A)〜(C)以外の場
合には、状態SF1と同様に復号を行う。
FIG. 19 is an explanatory diagram showing an example of the state SN1. In this case, the decoding is started from the data before the (N + 1) th byte, and the code up to the end (the 8th bit) of the Nth byte is decoded. It is SN1.
FIG. 19A shows a case where the codeword “10” (EOB code) is decoded at the beginning of the (N + 1) th byte. On the other hand, in the state SF1 of “initial state: decoding from the first bit”, the case where s = 0 of the codeword “1s” is decoded, and run = 0,
Obtain level = 1 data. (B) shows a case where, at the beginning of the (N + 1) th byte, the case where s = 0 of the codeword “11s” is decoded, and data of run = 0 and level = 1 are obtained. On the other hand, the state SF1 of the “initial state: decoding from the first bit”
Then, the case where s = 1 (for 2 bits) of the code word “1s” is decoded, and data of run = 0 and level = −1 are obtained. (C)
Is s = 1 of the code word “11s” at the beginning of the (N + 1) th byte.
Is decoded to obtain data of run = 0 and level = -1. On the other hand, in the state SF1 of “initial state: decoding from the first bit”, the case where the code word “1s” is s = 1 (for 2 bits) is decoded, and the data of run = 0 and level = −1 are decoded. obtain. In cases other than (A) to (C) in FIG. 19, decoding is performed in the same manner as in state SF1.

【0121】図20は状態SN3及びSN4の例を示し
た説明図である。図20の(A)に示す状態SN3は、
復号開始直後(初期)のみに取り得る状態であり、復号
開始位置があるアドレスの8ビット目であり、その8ビ
ット目が「1」であった場合に次に移行する状態であ
る。図の例では、Nバイト目の8ビット目から復号を開
始し、8ビット目が「1」であるので、N+1バイト目
を処理する際には、最初に、DCTの最初の係数でのみ
使用する符号語「1s」(ラン=0,レベル=±1)を復
号する。
FIG. 20 is an explanatory diagram showing an example of states SN3 and SN4. The state SN3 shown in FIG.
This is a state that can be taken only immediately after the start of decoding (initial), and is a state where the decoding start position is the 8th bit of an address, and if the 8th bit is “1”, the state shifts to the next. In the example of the figure, decoding starts from the 8th bit of the Nth byte, and since the 8th bit is “1”, when processing the (N + 1) th byte, first, only the first coefficient of the DCT is used. Is decoded (run = 0, level = ± 1).

【0122】図20の(B)に示す状態SN4は、通常
時に取り得る状態であり、1つ以上の符号を復号した後
で「1」が余った場合である。図の例では、Nバイト目
の8ビット目よりも前から復号を開始して、1つ以上の
符号語を復号しており、Nバイト目を復号して「余りの
ビット列」として「1」が発生した状態を示す。この場
合、N+1バイト目を処理する際には、最初に符号語
「10」(escape符号)、または符号語「11s」(ラン=
0,レベル=±1)を復号する。
The state SN4 shown in FIG. 20B is a state that can be taken in a normal state, and is a case where “1” remains after decoding one or more codes. In the example shown in the figure, decoding is started before the 8th bit of the Nth byte, and one or more codewords are decoded. The Nth byte is decoded and “1” is set as “the remaining bit string”. Indicates the state in which the error has occurred. In this case, when processing the (N + 1) th byte, first, the codeword “10” (escape code) or the codeword “11s” (run =
0, level = ± 1).

【0123】通常状態では、「余りのビット列」の組み
合わせにより、全部で225種類の状態(SN1〜SN
225)がある。これらの各状態において復号テーブル
TN1〜TN225をそれぞれ参照する。「余りのビッ
ト列」の取り得る組み合わせについては、第1実施形態
の図9で示した処理フローと同様の方法で求めた後に、
前述した特殊な状態である「余りのビット列:なし」
(SN1)と「余りのビット列:1(初期)」(SN
3)とを追加して、番号を振り直すことによって得るこ
とができる。
In the normal state, a total of 225 types of states (SN1 to SN
225). In each of these states, the decoding tables TN1 to TN225 are respectively referred to. The possible combinations of the “remaining bit strings” are obtained by the same method as the processing flow shown in FIG. 9 of the first embodiment, and then
The special state described above, "Remainder bit string: None"
(SN1) and “Remainder bit string: 1 (initial)” (SN
3) can be obtained by renumbering.

【0124】以上のように、可変長復号手段102が取
り得る状態には、図17に示すように、「初期状態」8
種類、「EOB検出状態」1種類、「エラー検出状態」
1種類、「ラン復号状態」6種類、「レベル復号状態」
8種類、「通常状態」255種類が存在する。
As described above, the states that the variable-length decoding means 102 can take include the “initial state” 8 as shown in FIG.
Type, EOB detection status 1 type, Error detection status
1 type, “Run decoding status” 6 types, “Level decoding status”
There are eight types and 255 types of “normal state”.

【0125】図21〜図23は第2実施形態における復
号テーブルの例を示したものである。それぞれのテーブ
ルは0番から255番までのレコードを持っているが、
図21〜図23には一部のレコードのみ示す。レコード
番号の括弧内には、それぞれレコード番号を2進数で表
記している。それぞれのレコードは、当該テーブルの状
態において、レコード番号に対応した8ビットの2進数
のビット列が出現した場合に、そのビット列に対応する
復号したデータ(ランとレベルの組)の列をレコードの
「データ」に格納し、次に移行する状態をレコードの
「次の状態」に格納している。また、escape符号に続く
ランとレベルにおいてレベルが8ビットの場合と16ビ
ットの場合があるために、16ビットの場合の状態およ
びレベルの値を、「次の状態2」と「レベル2」に格納
している。したがって、各レコードは、「レコード番
号」とこれに対応する「データ」「次の状態」「次の状
態2」「レベル2」とから構成される。これらのテーブ
ルは、可変長符号の内容に対応させて予め作成して復号
テーブル103に格納しておくものとする。
FIGS. 21 to 23 show examples of the decoding table in the second embodiment. Each table has records from 0 to 255,
21 to 23 show only some of the records. In parentheses of the record numbers, the record numbers are represented in binary numbers. In each record, when an 8-bit binary digit string corresponding to the record number appears in the state of the table, the row of the decoded data (a set of a run and a level) corresponding to the bit string is described in the record “ The next state is stored in the "next state" of the record. Also, in the run and the level following the escape code, there are cases where the level is 8 bits and there are cases where the level is 16 bits. Stored. Therefore, each record is composed of “record number” and corresponding “data”, “next state”, “next state 2”, and “level 2”. These tables are created in advance in correspondence with the contents of the variable length codes and stored in the decoding table 103.

【0126】第2実施形態では、第1実施形態で説明し
た可変長符号の復号に加え、escape符号に続く固定長符
号の復号についてもバイト単位のビット列を取り出して
テーブルを参照するだけで復号を行えるようになってい
る。
In the second embodiment, in addition to the decoding of the variable-length code described in the first embodiment, the decoding of the fixed-length code following the escape code is performed by merely extracting the bit string in byte units and referring to the table. You can do it.

【0127】ここで、図24にescape符号を含むビット
列の一例を示し、第2実施形態の可変長符号復号手段の
動作原理を簡単に説明する。アドレス2002のデータの処
理では、escapeの後のデータを復号する際に、ランとし
て1ビット目から3ビット目までが「010」で4ビット
目から6ビット目までが0である「010000」のビット列
の値16を得ておき、「次の状態」をラン4ビット目か
らの復号状態(「ラン復号:4ビット目から」)とす
る。そしてアドレス2003のデータの処理で、ランとして
「011」のビット列の値3を得て、前回得た16に3を
加えて完全なランの値19を得る。次に、レベルとして
1ビット目から5ビット目までが「00101」で6ビット
目から8ビット目までが0である「00101000」のビット
列の値40を得ておき、「次の状態」をレベル6ビット
からの復号状態(「レベル復号:6ビット目から」)と
する。そしてアドレス2004のデータの処理で、レベルと
して「010」のビット列の値2を得て、前回得た40に
2を加えて完全なレベルの値42を得る。このようにし
て復号データとしてラン=19、レベル=42を得るこ
とができる。
Here, FIG. 24 shows an example of a bit string including an escape code, and the operation principle of the variable length code decoding means of the second embodiment will be briefly described. In the processing of the data at the address 2002, when decoding the data after the escape, as the run, the first to third bits are "010" and the fourth to sixth bits are "010000". The value 16 of the bit string is obtained, and the “next state” is set as a decoding state from the fourth bit of the run (“run decoding: from the fourth bit”). Then, in the processing of the data at the address 2003, the value 3 of the bit string "011" is obtained as the run, and 3 is added to the previously obtained 16 to obtain the complete run value 19. Next, a value 40 of a bit string of “00101000” in which the first to fifth bits are “00101” and the sixth to eighth bits are 0 is obtained, and the “next state” is set to the level. The decoding state starts from 6 bits (“level decoding: from the 6th bit”). Then, in the processing of the data at the address 2004, the value 2 of the bit string of “010” is obtained as the level, and 2 is added to the previously obtained 40 to obtain the complete level value 42. Thus, run = 19 and level = 42 can be obtained as decoded data.

【0128】次に、図25〜図29を用いて復号テーブ
ルを作成する詳しい手順について説明する。あるテーブ
ルTのレコード番号RNのレコードの作成は、テーブル
Tに対応する状態Sから図25〜図29に示す処理フロ
ーによって求めることができる。ここでは状態Sの種別
によりそれぞれ異なる処理フローを用いる。
Next, a detailed procedure for creating a decoding table will be described with reference to FIGS. The creation of the record with the record number RN of a certain table T can be obtained from the state S corresponding to the table T by the processing flows shown in FIGS. Here, different processing flows are used depending on the type of the state S.

【0129】図25及び図26は初期状態SFnで参照
するテーブルTFnにおけるレコード番号RNのレコー
ドを作成する場合の処理フローであり、以下に手順を説
明する。
FIGS. 25 and 26 show a processing flow for creating a record with the record number RN in the table TFn referred to in the initial state SFn. The procedure will be described below.

【0130】まずステップ2501で、レコード番号R
Nを8ビットの2進数で表記したビット列を、BITに
代入する。そしてステップ2502で、状態Sが「初期
状態:Nビット目から復号」の場合、CodeにBIT
のNビット目から最後までを代入する。次にステップ2
503で、Codeの先頭に図15に示した可変長符号
の「10」「1s」以外の符号語Cを見つける。そしてステ
ップ2504で、上記の符号語Cが見つかったか否かを
判定し、見つかった場合はステップ2505へ、見つか
らない場合はステップ2515へ進む。ステップ250
5では、符号語Cがescape符号か否かを判定し、escape
符号である場合は図26のステップ2601に進む
(A)。escape符号でない場合は次のステップ2506
に進む。
First, at step 2501, the record number R
A bit string in which N is represented by an 8-bit binary number is substituted into BIT. If the state S is “initial state: decoding from the Nth bit” in step 2502, BIT is added to Code.
From the Nth bit to the end. Then step 2
At 503, a codeword C other than "10" and "1s" of the variable length code shown in FIG. In step 2504, it is determined whether or not the above codeword C is found. If found, the process proceeds to step 2505, and if not found, the process proceeds to step 2515. Step 250
In 5, it is determined whether or not the codeword C is an escape code.
If it is a sign, the process proceeds to step 2601 in FIG. 26 (A). If not the escape code, the next step 2506
Proceed to.

【0131】ステップ2506では、符号語Cに対応す
る復号データをレコードの「データ」の項目に追加す
る。そしてステップ2507で、Codeの先頭から符
号語Cを取り除き、ステップ2508で、Codeの長
さが0か否かを判定する。ここで、Codeの長さが0
である場合はステップ2525へ進み、そうでない場合
は次のステップ2509へ進む。ステップ2509で
は、Codeの先頭に図15に示した可変長符号の「1
s」以外の符号語Cを見つける。そしてステップ251
0で、上記の符号語Cが見つかったか否かを判定し、見
つかった場合はステップ2511へ、見つからない場合
はステップ2521へ進む。ステップ2511では、符
号語CがEOB符号か否かを判定し、EOB符号である
場合はステップ2526に進み、そうでない場合は次の
ステップ2512に進む。ステップ2512では、符号
語Cがescape符号か否かを判定し、escape符号である場
合は図26のステップ2601に進み(A)、そうでな
い場合は次のステップ2513に進む。ステップ251
3では、符号語Cに対応する復号データをレコードの
「データ」の項目に追加する。そしてステップ2514
で、Codeの先頭から符号語Cを取り除き、ステップ
2508に戻って同様の処理を繰り返す。
In step 2506, the decoded data corresponding to the code word C is added to the "data" item of the record. Then, in step 2507, the codeword C is removed from the beginning of the code, and in step 2508, it is determined whether the length of the code is 0 or not. Here, the length of Code is 0
If it is, the process proceeds to step 2525; otherwise, the process proceeds to the next step 2509. In step 2509, the variable length code “1” shown in FIG.
Find codeword C other than "s". And step 251
At 0, it is determined whether or not the above codeword C is found. If found, the process proceeds to step 2511; otherwise, the process proceeds to step 2521. In step 2511, it is determined whether or not the codeword C is an EOB code. If the code word C is an EOB code, the process proceeds to step 2526; otherwise, the process proceeds to the next step 2512. In step 2512, it is determined whether or not the code word C is an escape code. If the code word C is an escape code, the process proceeds to step 2601 in FIG. 26 (A); otherwise, the process proceeds to the next step 2513. Step 251
In 3, the decoded data corresponding to the code word C is added to the "data" item of the record. And step 2514
Then, the code word C is removed from the beginning of the code, and the process returns to step 2508 to repeat the same processing.

【0132】ステップ2504でCodeの先頭に「1
0」「1s」以外の符号語Cが見つからず、ステップ25
15に進んだ場合、状態SとCodeの内容を判定し、
状態SがSF8であり、かつCodeが「1」である場
合はステップ2519へ進み、そうでない場合は次のス
テップ2516へ進む。ステップ2516では、Cod
eに図15に示した符号語Cの先頭部分を見つける。そ
してステップ2517で、符号語Cの先頭部分が見つか
ったか否かを判定し、見つかった場合は次のステップ2
518へ、見つからない場合はステップ2520へ進
む。ステップ2518では、余りのビット列がCode
となる通常状態SNnをレコードの「次の状態」に格納
し、処理を終了する。
In step 2504, "1"
No code word C other than "0" and "1s" is found, and
When proceeding to 15, the contents of the state S and Code are determined,
If the state S is SF8 and the code is “1”, the process proceeds to step 2519; otherwise, the process proceeds to the next step 2516. In step 2516, Cod
In step e, the head of the codeword C shown in FIG. 15 is found. Then, in step 2517, it is determined whether or not the head of the codeword C has been found.
If not found, go to step 2520. In step 2518, the remaining bit sequence is Code
Is stored in the “next state” of the record, and the process is terminated.

【0133】ステップ2515で状態SがSF8かつC
odeが「1」であり、ステップ2319に進んだ場
合、レコードの「次の状態」に通常状態SN3を格納
し、処理を終了する。また、ステップ2517で符号語
Cの先頭部分が見つからず、ステップ2520に進んだ
場合、レコードの「次の状態」にエラー検出状態SER
Rを格納し、処理を終了する。
In step 2515, the state S is SF8 and C
When the mode is “1” and the process proceeds to step 2319, the normal state SN3 is stored in the “next state” of the record, and the process ends. If the head of the code word C is not found in step 2517 and the process proceeds to step 2520, the error detection state SER is displayed in the “next state” of the record.
R is stored, and the process ends.

【0134】ステップ2510でCodeの先頭に「1
s」以外の符号語Cが見つからず、ステップ2521に
進んだ場合、Codeに図15に示した「1s」以外の符
号語Cの先頭部分を見つける。そしてステップ2522
で、符号語Cの先頭部分が見つかったか否かを判定し、
見つかった場合は次のステップ2523へ、見つからな
い場合はステップ2524へ進む。ステップ2523で
は、余りのビット列がCodeとなる通常状態SNnを
レコードの「次の状態」に格納し、処理を終了する。た
だし、Codeが「1」の場合には、「次の状態」とし
て通常状態SN4を格納する。
In step 2510, “1” is added to the head of Code.
When the code word C other than "s" is not found and the process proceeds to step 2521, the head of the code word C other than "1s" shown in FIG. And step 2522
To determine whether the head of the codeword C has been found,
If found, go to the next step 2523; otherwise, go to step 2524. In step 2523, the normal state SNn in which the remaining bit string becomes Code is stored in the “next state” of the record, and the process ends. However, when the code is “1”, the normal state SN4 is stored as the “next state”.

【0135】ステップ2522で符号語Cの先頭部分が
見つからず、ステップ2524に進んだ場合、レコード
の「次の状態」にエラー検出状態SERRを格納し、処
理を終了する。また、ステップ2508でCodeの長
さが0であり、ステップ2525に進んだ場合、レコー
ドの「次の状態」に通常状態SN1を格納し、処理を終
了する。また、ステップ2511で符号語CがEOB符
号であり、ステップ2526に進んだ場合、レコードの
「次の状態」にEOB検出状態SEOBを格納し、処理
を終了する。
If the head of the code word C is not found in step 2522 and the process proceeds to step 2524, the error detection state SERR is stored in the "next state" of the record, and the process ends. If the length of the code is 0 in step 2508 and the process proceeds to step 2525, the normal state SN1 is stored in the “next state” of the record, and the process ends. If the codeword C is an EOB code in step 2511 and the process proceeds to step 2526, the EOB detection state SEOB is stored in the “next state” of the record, and the process ends.

【0136】ステップ2505またはステップ2512
で符号語Cがescape符号であり、図26のステップ26
01に進んだ場合、ラン(run)とレベル(level)にそ
れぞれ0を代入する。そしてステップ2602で、Co
deの先頭から符号語escapeを取り除き、ステップ26
03で、LenにCodeの長さを代入する。次いでス
テップ2604で、RUにCodeの先頭から6ビット
目までを代入する。なお、Codeの長さが6ビット未
満であれば、Code全体を代入する。そしてステップ
2605で、RUが6ビットになるまで、RUの後ろに
「0」を加えていく。例えば、RUが「101」である場
合、後ろに「0」を3つ加えて「101000」とする。
Step 2505 or step 2512
In FIG. 26, the code word C is an escape code.
When the process proceeds to 01, 0 is assigned to each of the run and the level. Then, in step 2602, Co
Step 26 removes the code word escape from the beginning of de.
In 03, the length of Code is substituted for Len. Next, in step 2604, the RU is substituted with the sixth bit from the beginning of the code. If the length of the code is less than 6 bits, the entire code is substituted. Then, in step 2605, “0” is added after the RU until the RU has 6 bits. For example, when the RU is “101”, three “0” s are added at the end to make “101000”.

【0137】次にステップ2606で、runにRUを2
進数とした場合に対応する10進数の値(≧0)を代入
する。そしてステップ2607で、Lenの値を判定
し、Lenが6よりも小さい場合は次のステップ260
8へ進み、そうでない場合はステップ2610へ進む。
ステップ2608では、このときの(run,level)を復
号データとしてレコードの「データ」に追加する。そし
てステップ2609で、レコードの「次の状態」にラン
復号状態SRUNnを格納し、処理を終了する。ただ
し、nはLen+1(1〜6)である。
Next, at step 2606, the RU is set to 2 in the run.
A decimal value (≧ 0) corresponding to the case of a decimal number is substituted. In step 2607, the value of Len is determined. If Len is smaller than 6, the next step 260
8; otherwise, to step 2610.
In step 2608, (run, level) at this time is added to the “data” of the record as decoded data. Then, in step 2609, the run decoding state SRUNn is stored in the “next state” of the record, and the processing is terminated. Here, n is Len + 1 (1 to 6).

【0138】ステップ2607でLenが6以上であ
り、ステップ2610に進んだ場合、Codeの先頭か
ら6ビットを取り除き、ステップ2611で、Lenに
Codeの長さを代入する。そしてステップ2612
で、LVにCodeを代入し、ステップ2613で、L
Vが8ビットになるまで、LVの後ろに「0」を加えて
いく。次にステップ2614で、levelにLVを2進数
とした場合に対応する10進数の値(≧0)を代入す
る。そしてステップ2615で、このときの(run,lev
el)を復号データとしてレコードの「データ」に追加す
る。続いてステップ2616で、レコードの「次の状
態」にレベル復号状態SLVLnを格納し、処理を終了
する。ただし、nはLen+1(1〜8)である。
When Len is 6 or more in step 2607 and the process proceeds to step 2610, 6 bits are removed from the head of the code, and in step 2611, the length of the code is substituted for Len. And step 2612
In step 2613, Code is substituted for LV.
“0” is added after LV until V becomes 8 bits. Next, in step 2614, a decimal value (≧ 0) corresponding to the case where LV is a binary number is substituted for level. Then, at step 2615, the (run, lev
el) is added to the “data” of the record as decrypted data. Subsequently, in step 2616, the level decoding state SLVLn is stored in the “next state” of the record, and the process ends. Here, n is Len + 1 (1 to 8).

【0139】図27は通常状態SNnで参照するテーブ
ルTNnにおけるレコード番号RNのレコードを作成す
る場合の処理フローであり、以下に手順を説明する。
FIG. 27 is a processing flow for creating a record with the record number RN in the table TNn referred to in the normal state SNn. The procedure will be described below.

【0140】この場合、まずステップ2701で、レコ
ード番号RNを8ビットの2進数で表記したビット列
を、BITに代入する。そしてステップ2702で、状
態Sが「通常状態:余りのビット列REM」の場合、C
odeにREMとBITを順番に連結したものを代入す
る。次にステップ2703で、状態SがSN3であるか
否かを判定し、状態SがSN3である場合は図25のス
テップ2503に進む(B)。ここで状態SがSN3で
ない場合は図25のステップ2509に進む(C)。
In this case, first, in step 2701, a bit string in which the record number RN is represented by an 8-bit binary number is substituted into BIT. In step 2702, if the state S is “normal state: remaining bit string REM”, C
A value obtained by connecting REM and BIT in order is substituted for "mode". Next, in step 2703, it is determined whether or not the state S is SN3. If the state S is SN3, the process proceeds to step 2503 in FIG. 25 (B). If the state S is not SN3, the process proceeds to step 2509 in FIG. 25 (C).

【0141】図28はラン復号状態SRUNnで参照す
るテーブルTRUNnにおけるレコード番号RNのレコ
ードを作成する場合の処理フローであり、以下に手順を
説明する。
FIG. 28 is a processing flow for creating a record of the record number RN in the table TRUNn referred to in the run decoding state SRUNn. The procedure will be described below.

【0142】この場合、まずステップ2801で、レコ
ード番号RNを8ビットの2進数で表記したビット列
を、BITに代入する。次いでステップ2802で、ラ
ン(run)とレベル(level)にそれぞれ0を代入する。
そしてステップ2803で、状態Sが「ラン復号:nビ
ット目から」の場合、RNにBITの先頭から(7−
n)ビット目までを代入し、CodeにBITの(8−
n)ビット目以降を代入する。次にステップ2804
で、runにRUを2進数とした場合に対応する10進数
の値(≧0)を代入し、図26のステップ2611に進
む(D)。
In this case, first, in step 2801, a bit string in which the record number RN is represented by an 8-bit binary number is substituted for BIT. Next, at step 2802, 0 is assigned to each of the run and the level.
Then, in step 2803, when the state S is “run decoding: from the n-th bit”, (7-
Substitute the bits up to the (n) th bit, and set (8-
n) Substitute the bits after the first. Next, step 2804
Then, a decimal value (≧ 0) corresponding to the case where the RU is a binary number is substituted for run, and the process proceeds to step 2611 in FIG. 26 (D).

【0143】図29はレベル復号状態SLVLnで参照
するテーブルTLVLnにおけるレコード番号RNのレ
コードを作成する場合の処理フローであり、以下に手順
を説明する。
FIG. 29 is a processing flow for creating a record with the record number RN in the table TLVLn referred to in the level decoding state SLVLn. The procedure will be described below.

【0144】この場合、まずステップ2901で、レコ
ード番号RNを8ビットの2進数で表記したビット列
を、BITに代入する。次いでステップ2902で、ラ
ン(run)とレベル(level)にそれぞれ0を代入する。
そしてステップ2903で、状態Sが「レベル復号:n
ビット目から」の場合、レコードの「次の状態2」にS
LVLnを格納し、LVにBITの先頭から(9−n)
ビット目までを代入し、CodeにBITの(10−
n)ビット目以降を代入する。次にステップ2904
で、levelにLVを2進数とした場合に対応する10進
数の値(≧0)を代入する。そしてステップ2905
で、このときの(run,level)を復号データとしてレコ
ードの「データ」に追加する。次にステップ2906
で、LV2にCodeを代入し、ステップ2907で、
LV2が8ビットになるまで、LV2の後ろに「0」を
加えていく。そしてステップ2908で、レコードの
「レベル2」にLV2を2進数とした場合に対応する1
0進数の値(≧0)を格納し、図25のステップ250
9に進む(C)。
In this case, first, in step 2901, a bit string in which the record number RN is represented by an 8-bit binary number is substituted for BIT. Next, in step 2902, 0 is assigned to each of the run and the level.
Then, in step 2903, the state S becomes “level decoding: n
In the case of “from the bit”, the record is changed to “next state 2”.
LVLn is stored, and (9-n) from the head of BIT is stored in LV.
The bits up to the bit are substituted, and (10-
n) Substitute the bits after the first. Next, step 2904
Then, a decimal value (≧ 0) corresponding to the case where LV is a binary number is substituted into level. And step 2905
Then, (run, level) at this time is added to the “data” of the record as decoded data. Next, step 2906
Then, Code is substituted into LV2, and in step 2907,
“0” is added after LV2 until LV2 has 8 bits. Then, in step 2908, “1” corresponding to the case where LV2 is a binary number in “level 2” of the record
The value of the decimal number (≧ 0) is stored, and step 250 in FIG.
Proceed to 9 (C).

【0145】上記のような手順により、図21〜図23
に示したような復号テーブルが作成される。
According to the procedure described above, FIGS.
Is generated as shown in FIG.

【0146】図21の(A)に示すテーブルTF5は、
状態SF5、すなわち初期状態で5ビット目から復号す
るという状態で使用するテーブルである。このテーブル
TF5のレコード番号8のレコードは、ビット列「0000
1000」が現れた場合に対応し、5ビット目から復号する
と、符号「10」(ラン=0,レベル=1)が得られ、
「00」が余るので、「データ」には(0,1)、「次の
状態」には余りのビット列「00」を示す通常状態SN5
を格納する。
A table TF5 shown in FIG.
This is a table used in a state SF5, that is, a state where decoding is performed from the fifth bit in the initial state. The record of record number 8 in the table TF5 has the bit string “0000”.
In response to the appearance of "1000", decoding from the fifth bit gives a code "10" (run = 0, level = 1),
Since “00” is left, the normal state SN5 indicating (0, 1) in “data” and the surplus bit string “00” in “next state”
Is stored.

【0147】図21の(B)に示すテーブルTF8は、
状態SF8、すなわち初期状態で8ビット目から復号す
るという状態で使用するテーブルである。このテーブル
TF8のレコード番号255のレコードは、ビット列
「11111111」が現れた場合に対応し、8ビット目から復
号すると、復号可能な対応する符号語がなく、「1」が
余る。この「1」は、可変長符号の最初に使われる符号
「1s」の可能性がある。したがって、「データ」には何
も格納せず、「次の状態」には余りのビット列が「1」
で符号「1s」を復号する通常状態SN1を格納する。
The table TF8 shown in FIG.
This is a table used in a state SF8, that is, a state where decoding is performed from the eighth bit in the initial state. The record with the record number 255 in the table TF8 corresponds to the case where the bit string “11111111” appears. When decoding from the eighth bit, there is no corresponding codeword that can be decoded, and “1” is left. This “1” may be the code “1s” used at the beginning of the variable length code. Therefore, nothing is stored in "data", and the remaining bit string is "1" in "next state".
Stores the normal state SN1 for decoding the code “1s”.

【0148】図21の(C)に示すテーブルTN1は、
状態SN1、すなわち通常状態で余りのビット列がない
状態で使用するテーブルである。このテーブルTN1の
レコード番号247のレコードは、ビット列「1111011
1」が現れた場合に対応し、これを復号すると、符号「1
11」(ラン=0,レベル=−1)、符号「10」(EO
B)が得られる。よって、「データ」にはまず(0,−
1)を格納し、さらにEOBが5ビットまでで次のビッ
ト列が6ビット目から始まるので、それを示す(−1,
6)を格納する。また「次の状態」にはEOB検出状態
SEOBを格納する。
The table TN1 shown in FIG.
This is a table used in a state SN1, that is, a state where there is no extra bit string in a normal state. The record of the record number 247 of the table TN1 has the bit string “1111011
In response to the appearance of "1", decoding this will result in the code "1"
11 "(run = 0, level = -1), code" 10 "(EO
B) is obtained. Therefore, "data" contains (0,-
1) is stored, and the EOB is up to 5 bits and the next bit string starts from the 6th bit.
6) is stored. In the “next state”, the EOB detection state SEOB is stored.

【0149】図21の(D)に示すテーブルTN2は、
状態SN2、すなわち通常状態で余りのビット列が
「0」という状態で使用するテーブルである。このテー
ブルTN2のレコード番号0のレコードは、ビット列
「00000000」が現れた場合に対応し、この場合復号可能
な対応する符号語がなく、復号できずに余りのビット列
が「000000000」という状態になるので、「データ」に
は何も格納せず、「次の状態」には通常状態SN57を
格納する。
The table TN2 shown in FIG.
This table is used in a state SN2, that is, a state where the remaining bit string is “0” in the normal state. The record of record number 0 in the table TN2 corresponds to the case where the bit string “00000000” appears. In this case, there is no corresponding code word that can be decoded, and the remaining bit string cannot be decoded and the remaining bit string is “000000000”. Therefore, nothing is stored in the "data", and the normal state SN57 is stored in the "next state".

【0150】図21の(E)に示すテーブルTN57
は、状態SN57、すなわち通常状態で余りのビット列
が「000000000」という状態で使用するテーブルであ
る。このテーブルTN57のレコード番号46のレコー
ドは、ビット列「00101110」が現れた場合に対応し、こ
れを復号すると、符号「00000000000101110」(ラン=
14,レベル=2)が得られ、「余りのビット列」が無
い状態になる。よって、「データ」には(14,2)、
「次の状態」には通常状態SN1を格納する。
Table TN57 shown in FIG.
Is a table used in a state SN57, that is, a state where the remaining bit string is “000000000” in the normal state. The record of the record number 46 in the table TN57 corresponds to the case where the bit string “00101110” appears, and when this is decoded, the code “00000000000101110” (run =
14, level = 2) is obtained, and there is no remaining bit string. Therefore, (14, 2)
The "next state" stores the normal state SN1.

【0151】図22の(F)に示すテーブルTN3は、
状態SN3、すなわち通常状態で余りのビット列が
「1」で、符号「1s」を最初に復号するという状態で使
用するテーブルである。このテーブルTN3のレコード
番号152のレコードは、ビット列「10011000」が現れ
た場合に対応し、これを復号すると、符号「11」(ラン
=0,レベル=−1)、符号「001100」(ラン=4,レ
ベル=1)が得られ、余りのビット列が「0」になる。
よって、「データ」に(0,−1)、(4,1)を格納
し、「次の状態」に通常状態SN2を格納する。
The table TN3 shown in FIG.
State SN3, that is, a table used in a state where the remaining bit string is “1” in the normal state and the code “1s” is decoded first. The record with the record number 152 in the table TN3 corresponds to the case where the bit string “10011000” appears. When this is decoded, the code “11” (run = 0, level = −1) and the code “001100” (run = 4, level = 1), and the remaining bit string becomes “0”.
Therefore, (0, −1) and (4, 1) are stored in “data”, and the normal state SN2 is stored in “next state”.

【0152】図22の(G)に示すテーブルTN4は、
状態SN4、すなわち通常状態で余りのビット列が
「1」という状態で使用するテーブルである。この状態
では、(F)の場合と異なり最初の復号ではないため符
号「1s」は復号しない。このテーブルTN4のレコード
番号152のレコードは、ビット列「10011000」が現れ
た場合に対応し、これを復号すると、符号「110」(ラ
ン=0,レベル=1)、符号「0110」(ラン=1,レベ
ル=1)が得られ、余りのビット列が「00」になる。よ
って、「データ」には(0,1)、(1,1)を格納
し、「次の状態」に通常状態SN5を格納する。
The table TN4 shown in FIG.
This is a table used in a state SN4, that is, a state where the remaining bit string is “1” in the normal state. In this state, the code “1s” is not decoded because it is not the first decoding unlike the case of (F). The record of the record number 152 in the table TN4 corresponds to the case where the bit string “10011000” appears, and when this is decoded, the code “110” (run = 0, level = 1) and the code “0110” (run = 1) , Level = 1), and the remaining bit string becomes “00”. Therefore, (0, 1) and (1, 1) are stored in the “data”, and the normal state SN5 is stored in the “next state”.

【0153】図22の(H)に示すテーブルTN5は、
状態SN5、すなわち通常状態で余りのビット列が「0
0」という状態で使用するテーブルである。このテーブ
ルTN5のレコード番号23のレコードは、ビット列
「00010111」が現れた場合に対応し、これを復号する
と、符号「000001」(escape)を得る。この後には6ビ
ットのランと、8ビットか16ビットのレベルが続く。
ここで処理するデータはランの最初の4ビット「0111」
であり、これに対応するランの値は、残りの2ビットを
0にした場合のビット列「011100」の値28となる。こ
のとき、レベルはまったく含まれないのでレベルの値は
0とする。「次の状態」としてはランの5ビット目から
の復号となるのでSRUN5である。よって、「デー
タ」には(28,0)を格納し、「次の状態」にラン復
号状態SRUN5を格納する。同様にレコード番号24
のレコードは、ランの最初の4ビット「1000」を含むの
で、ランの値はビット列「100000」に対応する値32と
なる。よって、「データ」に(32,0)を格納し、
「次の状態」にはラン復号状態SRUN5を格納する。
The table TN5 shown in FIG.
In the state SN5, that is, in the normal state, the surplus bit string is “0”.
This is a table used in a state of "0". The record of record number 23 in the table TN5 corresponds to the case where the bit string “00010111” appears, and when this is decoded, the code “000001” (escape) is obtained. This is followed by a 6-bit run and 8-bit or 16-bit levels.
The data processed here is the first 4 bits of the run "0111"
And the value of the run corresponding to this is the value 28 of the bit string “011100” when the remaining two bits are set to 0. At this time, since no level is included, the value of the level is set to 0. The “next state” is SRRUN5 because decoding starts from the fifth bit of the run. Therefore, (28, 0) is stored in the “data”, and the run decoding state SRUN5 is stored in the “next state”. Similarly, record number 24
Record includes the first four bits "1000" of the run, so the value of the run is the value 32 corresponding to the bit string "100000". Therefore, (32,0) is stored in "data",
The “next state” stores the run decoding state SRRUN5.

【0154】図22の(I)に示すテーブルTN18
は、状態SN18、すなわち通常状態で余りのビット列
が「00000」という状態で使用するテーブルである。こ
のテーブルTN18のレコード番号136のレコード
は、ビット列「10001000」が現れた場合に対応し、これ
を復号すると符号「000001」(escape)が得られ、続く
6ビットのランとしてビット列「000100」であるからラ
ンの値は4となる。この後の1ビット「0」は、8ビッ
トまたは16ビットのレベルの1ビット目である。レベ
ルは、8ビットのレベルとして残り7ビットが「0」で
あるビット列「00000000」であるからレベルの値は0と
なる。「次の状態」としてはレベルの2ビット目からの
復号となるのでSLVL2である。よって、「データ」
には(4,0)を格納し、「次の状態」にはレベル復号
状態SLVL2を格納する。
Table TN18 shown in FIG.
Is a table used in a state SN18, that is, a state where the remaining bit string is “00000” in the normal state. The record with the record number 136 of the table TN18 corresponds to the case where the bit string “10001000” appears. When this is decoded, the code “000001” (escape) is obtained, and the bit string “000100” is obtained as the run of the subsequent 6 bits. From this, the value of the run becomes 4. The subsequent one bit “0” is the first bit of the 8-bit or 16-bit level. The level is a bit string “00000000” in which the remaining 7 bits are “0” as an 8-bit level, so that the level value is 0. The “next state” is SLVL2 because decoding starts from the second bit of the level. Therefore, "data"
And (4, 0) are stored in the “next state”, and the level decoding state SLVL2 is stored in the “next state”.

【0155】図23の(J)に示すテーブルTRUN5
は、状態SRUN5、すなわちランを5ビット目から復
号するという状態で使用するテーブルである。このテー
ブルTRUN5のレコード番号160のレコードは、ビ
ット列「10100000」が現れた場合に対応し、最初の2ビ
ット「10」はランの5ビット目から6ビット目として、
ランの値2を得る。残りの6ビット「100000」はレベル
の1ビット目から6ビット目であり、8ビットのレベル
としてビット列「10000000」に対応するレベルの値12
8を得る。「次の状態」としてはレベルの7ビット目か
らの復号となるのでSLVL7である。よって、「デー
タ」には(2,128)を格納し、「次の状態」にはレ
ベル復号状態SLVL7を格納する。同様にレコード番
号190のレコードは、ビット列「10111110」が現れた
場合に対応し、ランの値は同様に2であり、レベルの値
はビット列「11111000」の値248となる。よって、
「データ」には(2,248)を格納し、「次の状態」
にはレベル復号状態SLVL7を格納する。
Table TRUN5 shown in FIG.
Is a table used in a state SRRUN5, that is, a state in which a run is decoded from the fifth bit. The record with the record number 160 of the table TRUN5 corresponds to the case where the bit string “10100000” appears. The first two bits “10” are the fifth to sixth bits of the run.
Get a value of 2 for the run. The remaining 6 bits “100000” are the first to sixth bits of the level, and the level value 12 corresponding to the bit string “10000000” is set as an 8-bit level.
Get 8. The "next state" is SLVL7 since decoding starts from the seventh bit of the level. Therefore, (2,128) is stored in “data”, and the level decoding state SLVL7 is stored in “next state”. Similarly, the record with the record number 190 corresponds to the case where the bit string “10111110” appears, the run value is also 2, and the level value is the value 248 of the bit string “11111000”. Therefore,
"Data" stores (2,248) and "Next state"
Stores the level decoding state SLVL7.

【0156】図23の(K)に示すテーブルTLVL2
は、状態SLVL2、すなわちレベルを2ビット目から
復号するという状態で使用するテーブルである。このテ
ーブルTLVL2のレコード番号1のレコードは、ビッ
ト列「00000001」が現れた場合に対応し、最初の7ビッ
ト「0000000」はレベルの2ビット目から8ビット目と
して、レベルの値0を得る。よって、「データ」に格納
する最初の復号データはラン=0、レベル=0で(0,
0)となる。残りの1ビット「1」は、2通りの解釈を
行う。一つは、レベルが8ビットの場合であり、通常の
可変長符号の復号を行う。この場合、ビット列「1」は
符号語が得られず、「次の状態」としては余りのビット
列が「1」である通常状態SN4になる。よって、「デ
ータ」には、(0,0)のみを格納し、「次の状態」に
は通常状態SN4を格納する。もう一つは、レベルが1
6ビットの場合であり、残りの1ビットをレベルの9ビ
ット目とみなす。そして「レベル2」には、レベルの9
ビット目から16ビット目までの値、すなわち9ビット
目が「1」であり、それ以降が「0」であるビット列「10
000000」の値128を格納する。また、「次の状態2」
はレベルの10ビット目から16ビット目までを解釈で
きるようにするために、レベルの2ビット目から復号の
状態を代用し、すなわちレベル復号状態SLVL2とし
て「次の状態2」に格納する。
Table TLVL2 shown in FIG.
Is a table used in a state SLVL2, that is, a state in which the level is decoded from the second bit. The record of record number 1 in the table TLVL2 corresponds to the case where the bit string “00000001” appears, and the first 7 bits “0000000” obtain the level value 0 from the second bit to the eighth bit of the level. Therefore, the first decoded data stored in “data” is run = 0, level = 0, and (0,
0). The remaining one bit “1” performs two interpretations. One is a case where the level is 8 bits, and decoding of a normal variable length code is performed. In this case, no codeword is obtained for the bit string “1”, and the “next state” is the normal state SN4 in which the remaining bit string is “1”. Therefore, only (0, 0) is stored in “data”, and the normal state SN4 is stored in “next state”. The other is level 1
This is the case of 6 bits, and the remaining 1 bit is regarded as the ninth bit of the level. And "level 2" has level 9
A bit string “10” in which the value from the bit to the 16th bit, that is, the ninth bit is “1” and the subsequent bits are “0”
The value 128 of “00000” is stored. Also, “Next state 2”
In order to be able to interpret the 10th to 16th bits of the level, the decoding state is substituted from the second bit of the level, that is, stored in the “next state 2” as the level decoding state SLVL2.

【0157】同様にテーブルTLVL2のレコード番号
6のレコードは、最初の7ビットが「0000011」である
から、レベルの値3が得られ、「データ」には(0,
3)を格納する。「次の状態」は余りのビット列「0」
が余るので通常状態SN2となる。「レベル2」は、余
りのビット列「0」に7つの「0」を付加したビット列
「00000000」に対応する値0となり、「次の状態2」
は、レベルの2ビット目から復号の状態を代用してレベ
ル復号状態SLVL2となる。
Similarly, in the record of record number 6 in the table TLVL2, since the first 7 bits are “0000011”, a level value 3 is obtained, and “0”,
3) is stored. "Next state" is the surplus bit string "0"
Is left, the normal state SN2 is set. “Level 2” is a value 0 corresponding to a bit string “00000000” obtained by adding seven “0” s to the remaining bit string “0”, and the “next state 2”
Becomes the level decoding state SLVL2 by substituting the decoding state from the second bit of the level.

【0158】図23の(L)に示すテーブルTLVL7
は、状態SLVL7、すなわちレベルを7ビット目から
復号するという状態で使用するテーブルである。このテ
ーブルTLVL7のレコード番号1のレコードは、ビッ
ト列「00000001」が現れた場合に対応し、最初の2ビッ
ト「00」はレベルの7ビット目から8ビット目として、
レベルの値0を得る。よって、「データ」に格納する最
初の復号データはラン=0、レベル=0で(0,0)と
なる。残りのビット列「000001」は、2通りの解釈を行
う。一つは、レベルが8ビットの場合であり、通常の可
変長符号の復号を行う。この場合、ビット列「000001」
はescape符号となるので、「次の状態」としてはラン復
号1ビット目からのSRUN1になる。また、ラン、レ
ベルの値として(0,0)を入れておく。これにより、
処理フローが単純になる。よって、「データ」には、
(0,0)、(0,0)を格納し、「次の状態」にはラ
ン復号状態SRUN1を格納する。もう一つは、レベル
が16ビットの場合であり、残りのビット列をレベルの
9ビット目から14ビット目とみなす。そして「レベル
2」には、レベルの9ビット目から16ビット目までの
値、すなわち残りの「000001」の後に「0」を付加した
8ビットのビット列「00000100」の値4を格納する。ま
た、「次の状態2」はレベルの15ビット目から16ビ
ット目までを解釈できるようにするために、レベルの7
ビット目から復号の状態を代用し、すなわちレベル復号
状態SLVL7として「次の状態2」に格納する。
A table TLVL7 shown in FIG.
Is a table used in a state SLVL7, that is, a state in which the level is decoded from the seventh bit. The record of record number 1 in the table TLVL7 corresponds to the case where the bit string “00000001” appears. The first two bits “00” are the seventh to eighth bits of the level.
Get level value 0. Therefore, the first decoded data stored in the “data” is (0, 0) at run = 0 and level = 0. The remaining bit string “000001” is interpreted in two ways. One is a case where the level is 8 bits, and decoding of a normal variable length code is performed. In this case, the bit string "000001"
Is an escape code, so the “next state” is SRRUN1 from the first bit of run decoding. Also, (0, 0) is entered as the run and level values. This allows
The processing flow is simplified. Therefore, "data"
(0, 0) and (0, 0) are stored, and the run decoding state SRRUN1 is stored in the “next state”. The other case is when the level is 16 bits, and the remaining bit strings are regarded as the ninth to 14th bits of the level. In the “level 2”, a value from the ninth bit to the 16th bit of the level, that is, a value 4 of an 8-bit bit string “00000100” obtained by adding “0” after the remaining “000001” is stored. The “next state 2” is a level 7 in order to be able to interpret the 15th to 16th bits of the level.
The decoding state is substituted from the bit number, that is, it is stored in the “next state 2” as the level decoding state SLVL7.

【0159】同様にテーブルTLVL7のレコード番号
112のレコードは、レベルとして初めの2ビット「0
1」を持つので、まず「データ」に(0,1)を格納
し、続く「110」は(0,1)を得てビット列「000」が
余る。よって、「データ」には(0,1)、(0,1)
を格納し、「次の状態」には通常状態SN8を格納す
る。「レベル2」は、3ビット目からの「110000」の後
に「0」を付加した8ビットのビット列「11000000」に
対応する値192となる。また、同様にレコード番号1
50のレコードは、レベルとして初めの2ビット「10」
を持つので、まず「データ」に(0,2)を格納し、続
く「01011」は(2,−1)を得てビット列「0」が余
る。よって、「データ」には(0,2)、(2,−1)
を格納し、「次の状態」には通常状態SN2を格納す
る。「レベル2」は、3ビット目からの「010110」の後
に「0」を付加した8ビットのビット列「01011000」に
対応する値88となる。
Similarly, the record of record number 112 in table TLVL7 has the first two bits “0” as the level.
Since “1” is stored, (0, 1) is first stored in “data”, and subsequent “110” obtains (0, 1), and the bit string “000” remains. Therefore, (0, 1), (0, 1)
And the normal state SN8 is stored in the “next state”. “Level 2” is a value 192 corresponding to an 8-bit bit string “11000000” obtained by adding “0” after “110000” from the third bit. Similarly, record number 1
50 records have the first two bits "10" as the level
Therefore, first, (0, 2) is stored in the “data”, and the subsequent “01011” obtains (2, −1), and the bit string “0” remains. Therefore, "data" includes (0, 2), (2, -1)
Is stored, and the normal state SN2 is stored in the “next state”. “Level 2” is a value 88 corresponding to an 8-bit bit string “01011000” obtained by adding “0” after “010110” from the third bit.

【0160】次に、図21〜図23に示したレコードの
うち6つを例にとり、図25〜図29の処理フローを用
いてテーブルのレコード取得手順の具体例を説明する。
Next, a specific example of a record acquisition procedure for a table will be described with reference to the processing flows of FIGS. 25 to 29, taking six of the records shown in FIGS. 21 to 23 as examples.

【0161】図21(A)のテーブルTF5、レコード
8(状態S=SF5、RN=8)の場合、まずBIT=
「00001000」を代入し(ステップ2501)、Code
=「1000」を代入する(ステップ2502)。そして、
Codeの先頭に符号語「1s」が見つかるので(ステッ
プ2503)、ステップ2504からステップ2505
に進み、ここで符号語はescapeでないのでステップ25
06に進む。この場合、符号語「1s」でs=0の場合で
あるから、「データ」に(0,1)を追加する(ステッ
プ2506)。次に、Codeの先頭から符号語「1s」
を除いてCode=「00」とし(ステップ2507)、
この場合Codeの長さが2であるのでステップ250
8からステップ2509に進み、Codeの先頭に「1
s」以外の符号語を見つける。ここで、符号語が見つか
らないので、ステップ2510からステップ2521に
進み、Codeに「1s」以外の符号語の先頭部分を見つ
ける。この場合、Code「00」は符号語「00101s」
「00100110s」などの先頭部分であるので、ステップ2
522からステップ2523に進み、「通常状態:余り
のビット列:00」であるSN5を「次の状態」に格納し
て終了する。
In the case of table TF5, record 8 (state S = SF5, RN = 8) in FIG.
“00001000” is substituted (step 2501), and Code
= “1000” is substituted (step 2502). And
Since the codeword "1s" is found at the beginning of the code (step 2503), steps 2504 to 2505 are performed.
To step 25 since the codeword is not escape.
Proceed to 06. In this case, since s = 0 in the code word “1s”, (0, 1) is added to “data” (step 2506). Next, the codeword “1s” from the beginning of the code
And set Code = “00” (step 2507),
In this case, since the length of the Code is 2, step 250
8 to step 2509, where "1"
Find codewords other than "s". Here, since the codeword is not found, the process proceeds from step 2510 to step 2521 to find the head of the codeword other than “1s” in Code. In this case, Code “00” is replaced with codeword “00101s”
Since it is the first part such as "00100110s", step 2
The process proceeds from step 522 to step 2523, where SN5 indicating "normal state: surplus bit string: 00" is stored in the "next state", and the processing ends.

【0162】図22(G)のテーブルTN4、レコード
152(状態S=SN4、RN=152)の場合、まず
BIT=「10011000」を代入し(ステップ2701)、
REM=「1」であるので、Code=「110011000」を
代入する(ステップ2702)。そして状態SはSN3
でないので、ステップ2703からステップ2509に
進む。この場合、Codeの先頭に符号語「11s」が見
つかるので(ステップ2509)、ステップ2510か
らステップ2511に進む。そして、符号語はEOBや
escapeでないので、ステップ2511からステップ25
12を経てステップ2513に進み、「データ」に「11
0」を復号した値(0,1)を追加する。次に、Cod
eの先頭から符号語「11」を除いてCode=「001100
0」とし(ステップ2514)、ステップ2508に進
む。
In the case of table TN4 and record 152 (state S = SN4, RN = 152) in FIG. 22G, BIT = “10011000” is substituted first (step 2701),
Since REM = “1”, Code = “110011000” is substituted (step 2702). And state S is SN3
Therefore, the process proceeds from step 2703 to step 2509. In this case, since the code word “11s” is found at the head of the code (step 2509), the process proceeds from step 2510 to step 2511. And the code word is EOB or
Since it is not escape, steps 2511 to 25
Then, the process proceeds to step 2513 via "12", and "11"
A value (0, 1) obtained by decoding "0" is added. Next, Cod
Code = “001100” excluding the code word “11” from the beginning of e
0 ”(step 2514), and the flow proceeds to step 2508.

【0163】このときCodeの長さが7であるのでス
テップ2508から再度ステップ2509に進む。2回
目のステップ2509では、Codeの先頭に「00110
s」が見つかるので、ステップ2510からステップ2
511に進む。そして、符号語はEOBやescapeでない
ので、ステップ2511からステップ2512を経てス
テップ2513に進み、「データ」に「001100」を復号
した値(1,1)を追加する。次に、Codeの先頭か
ら符号語「00110」を除いてCode=「00」とし(ス
テップ2514)、ステップ2508に戻る。このとき
Codeの長さが2であるのでステップ2508から再
度ステップ2509に進む。3回目のステップ2509
では、Codeの先頭に「1s」以外の符号語が見つから
ないので、ステップ2510からステップ2521に進
み、Codeに「1s」以外の符号語の先頭部分を見つけ
る。この場合、Code「00」は符号語「00101s」「00
100110s」などの先頭部分であるので、ステップ252
2からステップ2523に進み、「通常状態:余りのビ
ット列:00」であるSN5を「次の状態」に格納して終
了する。
At this time, since the length of the code is 7, the flow advances from step 2508 to step 2509 again. In the second step 2509, “00110” is added to the head of the Code.
s "is found, so steps 2510 to 2
Proceed to 511. Then, since the code word is not EOB or escape, the process proceeds from step 2511 to step 2513 via step 2512, and a value (1, 1) obtained by decoding "001100" is added to "data". Next, code = “00” is set by removing the code word “00110” from the head of the code (step 2514), and the process returns to step 2508. At this time, since the length of the code is 2, the process proceeds from step 2508 to step 2509 again. Third step 2509
Since no code word other than "1s" is found at the beginning of the code, the process advances from step 2510 to step 2521 to find the head of the code word other than "1s" in the code. In this case, Code “00” is replaced with codewords “00101s” and “00”.
100110s ”or the like, so step 252
From 2, the process proceeds to step 2523, where SN5 of “normal state: surplus bit string: 00” is stored in the “next state”, and the processing ends.

【0164】図22(H)のテーブルTN5、レコード
23(状態S=SN5、RN=23)の場合、まずBI
T=「00010111」を代入し(ステップ2701)、RE
M=「00」であるので、Code=「0000010111」を代
入する(ステップ2702)。そして状態SはSN3で
ないので、ステップ2703からステップ2509に進
む。この場合、Codeの先頭に符号語「000001」が見
つかるので(ステップ2509)、ステップ2510か
らステップ2511に進む。そして、この符号語はesca
peであるので、ステップ2511からステップ2512
を経てステップ2601に進む。
In the case of table TN5 and record 23 (state S = SN5, RN = 23) in FIG.
T = “00010111” is substituted (step 2701), and RE
Since M = “00”, Code = “0000010111” is substituted (step 2702). Since the state S is not SN3, the process proceeds from step 2703 to step 2509. In this case, since the code word “000001” is found at the head of the code (step 2509), the process proceeds from step 2510 to step 2511. And this codeword is esca
Since it is pe, steps 2511 to 2512
Then, the process proceeds to step 2601.

【0165】次に、run=0,level=0を代入し(ステ
ップ2601)、Codeの先頭からescapeを取り除い
てCode=「0111」とする(ステップ2602)。続
いて、Len=4とし(ステップ2603)、RU=
「0111」として(ステップ2604)、このRUの後に
6ビットとなるまで「0」を加えてRU=「011100」と
する(ステップ2605)。そして、このRUを2進数
とした場合に対応する10進数の値をrunに代入してrun
=28とする(ステップ2606)。この場合、Len
=4<6であるので、ステップ2607からステップ2
608に進み、このときのラン(run)とレベル(leve
l)の値(28,0)を「データ」に追加する。そし
て、n=Len+1→5であるので、「次の状態」にS
RUN5を格納して終了する(ステップ2609)。
Next, run = 0 and level = 0 are substituted (step 2601), and escape is removed from the head of the code to set Code = “0111” (step 2602). Subsequently, Len = 4 (step 2603), and RU =
As "0111" (step 2604), "0" is added after this RU until it becomes 6 bits, and RU = "011100" (step 2605). Then, a decimal value corresponding to the case where this RU is a binary number is substituted into run and
= 28 (step 2606). In this case, Len
= 4 <6, so steps 2607 to 2
Proceed to 608, and run and level at this time
The value (28, 0) of l) is added to “data”. Then, since n = Len + 1 → 5, S is changed to the “next state”.
RUN5 is stored and the process is terminated (step 2609).

【0166】図22(I)のテーブルTN18、レコー
ド136(状態S=SN18、RN=136)の場合、
まずBIT=「10001000」を代入し(ステップ270
1)、REM=「00000」であるので、Code=「000
0010001000」を代入する(ステップ2702)。そして
状態SはSN3でないので、ステップ2703からステ
ップ2509に進む。この場合、Codeの先頭に符号
語「000001」が見つかるので(ステップ2509)、ス
テップ2510からステップ2511に進む。そして、
この符号語はescapeであるので、ステップ2511から
ステップ2512を経てステップ2601に進む。次
に、run=0,level=0を代入し(ステップ260
1)、Codeの先頭からescapeを取り除いてCode
=「0001000」とする(ステップ2602)。続いて、
Len=7とし(ステップ2603)、RU=「00010
0」とする(ステップ2604,2605)。この場合
RUが6ビットなので「0」を加える必要はない。そし
て、このRUを2進数とした場合に対応する10進数の
値をrunに代入してrun=4とする(ステップ260
6)。
In the case of table TN18 and record 136 (state S = SN18, RN = 136) in FIG.
First, BIT = “10001000” is substituted (step 270
1) Since REM = “00000”, Code = “000”
0010001000 ”(step 2702). Since the state S is not SN3, the process proceeds from step 2703 to step 2509. In this case, since the code word “000001” is found at the head of the code (step 2509), the process proceeds from step 2510 to step 2511. And
Since this code word is escape, the process proceeds from step 2511 to step 2601 via step 2512. Next, run = 0 and level = 0 are substituted (step 260
1) Remove the escape from the beginning of the Code
= "0001000" (step 2602). continue,
Assuming that Len = 7 (step 2603), RU = “00010”
"0" (steps 2604 and 2605). In this case, since the RU has 6 bits, there is no need to add “0”. Then, a decimal value corresponding to the case where this RU is a binary number is substituted into run to make run = 4 (step 260).
6).

【0167】この場合、Len=7で6以上となるの
で、ステップ2607からステップ2610に進み、C
odeの先頭6ビットを取り除いてCode=「0」と
する。そして、Len=1とし(ステップ2611)、
LV=「0」として(ステップ2612)、このLVの
後に8ビットとなるまで「0」を加えてLV=「0000000
0」とする(ステップ2613)。そして、このLVを
2進数とした場合に対応する10進数の値をlevelに代
入してlevel=0とする(ステップ2614)。このと
きのラン(run)とレベル(level)の値(4,0)を
「データ」に追加し(ステップ2615)、n=Len
+1→2であるので、「次の状態」にSLVL2を格納
して終了する(ステップ2616)。
In this case, since Len = 7, the value becomes 6 or more, so that the process proceeds from step 2607 to step 2610, where C
Code = “0” by removing the first 6 bits of mode. Then, Len = 1 (step 2611),
Assuming that LV = “0” (step 2612), “0” is added after this LV until it becomes 8 bits, and LV = “0000000”
"0" (step 2613). Then, a decimal value corresponding to the case where this LV is a binary number is substituted into level to make level = 0 (step 2614). At this time, the value (4, 0) of the run and the level is added to “data” (step 2615), and n = Len
Since + 1 → 2, SLVL2 is stored in the “next state” and the processing is terminated (step 2616).

【0168】図23(J)のテーブルTRUN5、レコ
ード160(状態S=SRUN5、RN=160)の場
合、まずBIT=「10100000」を代入し(ステップ28
01)、run=0,level=0を代入する(ステップ28
02)。この場合、n=5であるので、RUにBITの
2ビット目までを代入してRU=「10」、CodeにB
ITの3ビット目以降を代入してCode=「100000」
とする(ステップ2803)。そして、RUを2進数と
した場合に対応する10進数の値をrunに代入してrun=
2とし(ステップ2804)、ステップ2611へ進
む。次に、Len=6とし(ステップ2611)、LV
=「100000」として(ステップ2612)、このLVの
後に8ビットとなるまで「0」を加えてLV=「1000000
0」とする(ステップ2613)。そして、このLVを
2進数とした場合に対応する10進数の値をlevelに代
入してlevel=128とする(ステップ2614)。こ
のときのラン(run)とレベル(level)の値(2,12
8)を「データ」に追加し(ステップ2615)、n=
Len+1→7であるので、「次の状態」にSLVL7
を格納して終了する(ステップ2616)。
In the case of table TRUN5, record 160 (state S = SRRUN5, RN = 160) in FIG. 23J, BIT = “10100000” is substituted first (step 28).
01), and assign run = 0 and level = 0 (step 28)
02). In this case, since n = 5, up to the second bit of the BIT is substituted for RU, RU = “10”, and B
Code = “100000” by substituting the third and subsequent bits of IT
(Step 2803). Then, a decimal value corresponding to a case where the RU is a binary number is substituted into run, and run =
2 (step 2804), and the process proceeds to step 2611. Next, Len = 6 (step 2611), and LV
= “100,000” (step 2612), and after this LV, “0” is added until it becomes 8 bits, and LV = “1000000”
"0" (step 2613). Then, a decimal value corresponding to the case where this LV is a binary number is substituted into level to make level = 128 (step 2614). The values of the run and the level at this time (2, 12
8) is added to “data” (step 2615), and n =
Since Len + 1 → 7, SLVL7 changes to the “next state”.
Is stored (step 2616).

【0169】図23(L)のテーブルTLVL7、レコ
ード150(状態S=SLVL7、RN=150)の場
合、まずBIT=「10010110」を代入し(ステップ29
01)、run=0,level=0を代入する(ステップ29
02)。この場合、n=7であるので、「次の状態2」
にSLVL7を格納し、LVにBITの先頭から2ビッ
ト目までの「10」を代入し、CodeにBITの3ビッ
ト目以降の「010110」を代入する(ステップ290
3)。そして、このLVを2進数とした場合に対応する
10進数の値をlevelに代入してlevel=2とする(ステ
ップ2904)。このときのラン(run)とレベル(lev
el)の値(0,2)を「データ」に追加する(ステップ
2905)。次に、LV2=「010110」として(ステッ
プ2906)、このLV2の後に8ビットとなるまで
「0」を加えてLV2=「01011000」とする(ステップ
2907)。そして、このLV2を2進数とした場合に
対応する10進数の値88を「レベル2」に格納し(ス
テップ2908)、ステップ2509に進む。
In the case of the table TLVL7, record 150 (state S = SLVL7, RN = 150) in FIG. 23L, BIT = “10010110” is first substituted (step 29).
01), and assign run = 0 and level = 0 (step 29)
02). In this case, since n = 7, “next state 2”
Is stored, and “10” from the first bit of the BIT is substituted for LV, and “010110” for the third and subsequent bits of the BIT is substituted for Code (step 290).
3). Then, a decimal value corresponding to the case where this LV is a binary number is substituted into level to make level = 2 (step 2904). Run and level (lev
The value (0, 2) of el) is added to “data” (step 2905). Next, LV2 = “010110” (step 2906), and “0” is added after this LV2 until the number of bits becomes 8 to make LV2 = “01011000” (step 2907). Then, a decimal value 88 corresponding to the case where LV2 is a binary number is stored in “level 2” (step 2908), and the flow proceeds to step 2509.

【0170】この場合、Codeの先頭に「0101s」が
見つかるので(ステップ2509)、ステップ2510
からステップ2511に進む。そして、符号語はEOB
やescapeでないので、ステップ2511からステップ2
512を経てステップ2513に進み、「データ」に
「01011」を復号した値(2,−1)を追加する。次
に、Codeの先頭から符号語「01011」を除いてCo
de=「0」とし(ステップ2514)、ステップ25
08に進む。このときCodeの長さが1であるのでス
テップ2508から再度ステップ2509に進む。2回
目のステップ2509では、Codeの先頭に「1s」以
外の符号語が見つからないので、ステップ2510から
ステップ2521に進み、Codeに「1s」以外の符号
語の先頭部分を見つける。この場合、Code「0」は
符号語「00101s」「00100110s」などの先頭部分である
ので、ステップ2522からステップ2523に進み、
「通常状態:余りのビット列:0」であるSN2を「次
の状態」に格納して終了する。
In this case, since "0101s" is found at the beginning of the code (step 2509), step 2510
To 2511. And the code word is EOB
Because it is not escape or step 2 from step 2511
The process proceeds to step 2513 via 512, and the value (2, −1) obtained by decoding “01011” is added to “data”. Next, remove Codeword “01011” from the beginning of Code
de = "0" (step 2514) and step 25
Proceed to 08. At this time, since the length of the code is 1, the process proceeds from step 2508 to step 2509 again. In the second step 2509, since a codeword other than "1s" is not found at the head of the code, the process proceeds from step 2510 to step 2521, and the head of the codeword other than "1s" is found in the code. In this case, since Code “0” is the leading part of the code words “00101s” and “00100110s”, the process proceeds from step 2522 to step 2523,
The SN2 that is “normal state: surplus bit string: 0” is stored in the “next state”, and the processing ends.

【0171】次に、第2実施形態における可変長符号復
号手段102の動作について説明する。可変長符号復号
手段102は、第1実施形態と同様に、復号を開始する
ビットの位置を、アドレス(メモリの先頭からのバイト
数)と、そのアドレスの中の何ビット目かによって与え
られると、可変長符号格納手段101に対して読み出し
アドレスを指定することによりそのアドレスの1バイト
の符号を取り出し、復号テーブル103を参照して可変
長符号の復号を行い、復号したデータを復号データ格納
手段104に出力する、という処理を繰り返して可変長
符号の復号を行う。
Next, the operation of the variable length code decoding means 102 according to the second embodiment will be described. As in the first embodiment, the variable-length code decoding unit 102 determines that the position of the bit at which decoding is started is given by the address (the number of bytes from the head of the memory) and the number of the bit in the address. By designating a read address to the variable-length code storage unit 101, a 1-byte code at that address is extracted, the variable-length code is decoded with reference to the decoding table 103, and the decoded data is stored in the decoded data storage unit. The variable length code is decoded by repeating the process of outputting the variable length code to the variable length code.

【0172】図30及び図31は可変長符号復号手段1
02の動作の処理フローの例を示したものであり、これ
らの処理フローに基づいて第2実施形態の復号手順を以
下に説明する。
FIGS. 30 and 31 show the variable length code decoding means 1.
02 shows an example of the processing flow of the operation No. 02, and the decoding procedure of the second embodiment will be described below based on these processing flows.

【0173】(初期状態及び通常状態の処理)まずステ
ップ3001で、読み出しアドレスを示す変数ReadPに
復号を開始するビット位置のアドレス(メモリ上の復号
開始アドレス)を格納し、最初は初期状態であるため、
状態Sに復号開始のビット位置に対応した状態番号SF
nを代入する。上述したように、初期状態の状態番号
は、復号開始ビット位置1〜8に対してそれぞれSF1
〜SF8が割り当てられている。
(Processing in Initial State and Normal State) First, in step 3001, the address of the bit position at which decoding is started (decoding start address on the memory) is stored in a variable ReadP indicating the read address. For,
State number SF corresponding to the bit position at which decoding starts in state S
Substitute n. As described above, the state numbers of the initial state are SF1 for the decoding start bit positions 1 to 8, respectively.
To SF8.

【0174】次にステップ3002で、可変長符号格納
手段101に対してアドレスReadPを指示し、可変長符
号格納手段101に格納された符号の中から対応するア
ドレスの1バイトのデータを取得し、変数Dに代入す
る。そしてステップ3003で、復号テーブル103に
おける状態Sに対応したテーブルのD番のレコードを参
照し、「データ」に格納されているラン、レベルの復号
データdataと、「次の状態」Snextとを得る。次いでス
テップ3004で、復号データdataを復号データ格納手
段104に出力する。ただし、状態SnextがSRUN
n、SLVLn、SEOB、SERRの場合には、復号
データdataの最後のデータは出力しない。
Next, in step 3002, an address ReadP is instructed to the variable-length code storage means 101, and 1-byte data of the corresponding address is acquired from the codes stored in the variable-length code storage means 101. Assign to variable D. Then, in step 3003, by referring to the D-th record of the table corresponding to the state S in the decoding table 103, the run and level decoded data data stored in the "data" and the "next state" Snext are obtained. . Next, in step 3004, the decoded data data is output to the decoded data storage unit 104. However, if the state Snext is SRUN
In the case of n, SLVLn, SEOB, and SERR, the last data of the decoded data data is not output.

【0175】その後ステップ3005で、状態SにSne
xtをセットし、状態を移行する。このとき、状態SがS
EOB、SERR以外であれば、ReadPに1を加算し、
復号対象データの読み出し位置を1バイト進める。ステ
ップ3006では、状態Sがラン復号状態SRUNnで
あるか否かを判定し、状態SがSRUNnの場合はラン
復号の処理を行うステップ3101へ進む(A)。ステ
ップ3007では、状態Sがレベル復号状態SLVLn
であるか否かを判定し、状態SがSLVLnの場合はレ
ベル復号の処理を行うステップ3110へ進む(B)。
ステップ3008では、状態SがEOB検出状態SEO
Bまたはエラー検出状態SERRであるか否かを判定
し、状態SがSEOBまたはSERRの場合は処理を終
了し、そうでない場合はステップ3002に戻って同様
の処理を繰り返す。このとき、復号データdataの最後の
データは、ランが−1であり、レベルには、SEOBの
場合にはEOBの後のビットの位置、SERRの場合に
はエラーを検出したビットの位置が示される。
Thereafter, at step 3005, Sne is set to state S.
Set xt and transition state. At this time, the state S is S
If it is not EOB or SERR, add 1 to ReadP,
The read position of the data to be decoded is advanced by one byte. In step 3006, it is determined whether or not the state S is the run decoding state SRUNn. If the state S is SRRUNn, the process proceeds to step 3101 for performing run decoding processing (A). In step 3007, the state S is set to the level decoding state SLVLn.
Then, if the state S is SLVLn, the process proceeds to step 3110 for performing level decoding processing (B).
In step 3008, the state S is changed to the EOB detection state SEO.
It is determined whether the state is B or the error detection state SERR. If the state S is SEOB or SERR, the process is terminated. If not, the process returns to step 3002 to repeat the same process. At this time, the last data of the decoded data data has a run of -1, and the level indicates the position of the bit after the EOB in the case of SEOB, and indicates the position of the bit in which an error is detected in the case of SERR. It is.

【0176】(ラン復号の処理)ステップ3101で
は、復号データdataの最後のデータのラン、レベルを、
それぞれrun、levelへ代入する。そしてステップ310
2で、可変長符号格納手段101に対してアドレスRead
Pを指示し、対応するアドレスの1バイトのデータを取
得して変数Dに代入する。次にステップ3103で、復
号テーブル103における状態Sに対応したテーブルの
D番のレコードを参照し、「データ」に格納されている
ラン、レベルの復号データdataと、「次の状態」Snext
とを得る。そしてステップ3104で、復号データdata
における最初のデータのラン、レベルをそれぞれrun、l
evelに加える。さらにステップ3105で、ReadPに1
を加算し、復号対象データの読み出し位置を1バイト進
める。また、状態SにSnextをセットし、状態を移行す
る。
(Run Decoding Process) In step 3101, the run and level of the last data of the decoded data
Assign to run and level respectively. And step 310
In step 2, the address is read from the variable-length code storage unit 101.
P is designated, and 1-byte data at the corresponding address is obtained and assigned to a variable D. Next, in step 3103, the D-th record of the table corresponding to the state S in the decoding table 103 is referred to, and the run and level decoded data data stored in the “data” and the “next state” Snext
And get Then, in step 3104, the decrypted data data
Run and level of the first data in
Add to evel. Further, in Step 3105, 1 is set to ReadP.
Is added, and the read position of the data to be decoded is advanced by one byte. Also, Snext is set in the state S, and the state is shifted.

【0177】次にステップ3106で、状態Sがレベル
復号状態SLVLnであるか否かを判定し、状態SがS
LVLnの場合はレベル復号の処理を行うステップ31
11へ進む。またステップ3107では、levelの値を
判定し、levelが0または128の場合は16ビットの
レベル復号の処理を行うステップ3115へ進む。そし
てステップ3108で、ラン、レベルを復号データ格納
手段104に出力する。このとき、図16に示したよう
な固定長符号の復号を行うように、ランはrunの値を出
力し、レベルは、level<128の場合にはlevelを出力
し、level>128の場合にはlevel−256を出力す
る。その後ステップ3109で、復号データdataの2番
目以降のデータを復号データ格納手段104に出力し、
ステップ3008に進む。
Next, in step 3106, it is determined whether or not the state S is the level decoding state SLVLn.
In the case of LVLn, step 31 for performing level decoding processing
Proceed to 11. In step 3107, the value of level is determined. If level is 0 or 128, the flow advances to step 3115 for performing 16-bit level decoding. Then, in step 3108, the run and level are output to the decoded data storage unit 104. At this time, the run outputs the value of run so that the fixed-length code as shown in FIG. 16 is decoded, and the level outputs the level when level <128, and outputs the level when level> 128. Outputs level-256. Then, in step 3109, the second and subsequent data of the decoded data data are output to the decoded data storage unit 104,
Proceed to step 3008.

【0178】(レベル復号の処理)ステップ3110で
は、復号データdataの最後のデータのラン、レベルを、
それぞれrun、levelへ代入する。そしてステップ311
1で、可変長符号格納手段101に対してアドレスRead
Pを指示し、対応するアドレスの1バイトのデータを取
得して変数Dに代入する。次にステップ3112で、復
号テーブル103における状態Sに対応したテーブルの
D番のレコードを参照し、「データ」に格納されている
ラン、レベルの復号データdata、「次の状態」Snext、
「次の状態2」Snext2、「レベル2」level2を得る。
そしてステップ3113で、復号データdataにおける最
初のデータのレベルをlevelに加える。さらにステップ
3114で、ReadPに1を加算し、復号対象データの読
み出し位置を1バイト進める。また、状態SにSnextを
セットし、状態を移行する。そしてステップ3107に
進む。
(Process of Level Decoding) In step 3110, the run and level of the last data of the decoded data data are
Assign to run and level respectively. And step 311
1, the address is read from the variable-length code storage
P is designated, and 1-byte data at the corresponding address is obtained and assigned to a variable D. Next, in step 3112, the D-th record of the table corresponding to the state S in the decoding table 103 is referred to, and the run and level decoding data data stored in the “data”, the “next state” Snext,
“Next state 2” Snext2 and “level 2” level2 are obtained.
Then, in step 3113, the level of the first data in the decoded data data is added to level. In step 3114, 1 is added to ReadP, and the read position of the data to be decoded is advanced by one byte. Also, Snext is set in the state S, and the state is shifted. Then, the process proceeds to step 3107.

【0179】(16ビットのレベル復号の処理)ステッ
プ3115では、level=128の場合は符号フラグF
に−1を、level=0の場合は符号フラグFに1を代入
する。次にステップ3116で、levelにlevel2を代入
し、ステップ3117で、状態SにSnext2をセットす
る。そしてステップ3118で、可変長符号格納手段1
01に対してアドレスReadPを指示し、対応するアドレ
スの1バイトのデータを取得して変数Dに代入する。次
にステップ3119で、復号テーブル103における状
態Sに対応したテーブルのD番のレコードを参照し、
「データ」に格納されているラン、レベルの復号データ
dataと、「次の状態」Snextとを得る。そしてステップ
3120で、復号データdataにおける最初のデータのレ
ベルをlevelに加える。さらにステップ3121で、Rea
dPに1を加算し、復号対象データの読み出し位置を1バ
イト進める。また、状態SにSnextをセットし、状態を
移行する。そしてステップ3122で、ラン、レベルを
復号データ格納手段104に出力する。このとき、図1
6に示したような固定長符号の復号を行うように、ラン
はrunの値を出力し、レベルは、F=1の場合にはlevel
を出力し、F=−1の場合にはlevel−256を出力す
る。その後ステップ3109に進む。
(Processing of 16-bit level decoding) In step 3115, if level = 128, the code flag F
Is substituted for −1, and 1 is substituted for the sign flag F when level = 0. Next, in step 3116, level2 is substituted for level, and in step 3117, the state S is set to Snext2. Then, in step 3118, the variable length code storage unit 1
01, an address ReadP is instructed, 1-byte data of the corresponding address is obtained, and is substituted for a variable D. Next, in step 3119, the D-th record of the table corresponding to the state S in the decoding table 103 is referred to,
Run and level decrypted data stored in "Data"
Data and the “next state” Snext are obtained. Then, in step 3120, the level of the first data in the decoded data data is added to level. Further, in step 3121, Rea
One is added to dP, and the read position of the data to be decoded is advanced by one byte. Also, Snext is set in the state S, and the state is shifted. Then, in step 3122, the run and the level are output to the decoded data storage unit 104. At this time, FIG.
The run outputs the value of run so that the fixed-length code as shown in FIG. 6 is decoded, and the level is level when F = 1.
Is output, and when F = -1, level-256 is output. Thereafter, the flow advances to step 3109.

【0180】次に、可変長符号復号手段102の動作の
具体例として、図32に示す可変長符号を復号する場合
を例にとり図30及び図31に基づいて詳しく説明す
る。図32は可変長符号格納手段101に格納されてい
る可変長符号の例であり、四角の枠の中に1バイト毎の
符号内容を示し、枠の上側にアドレス、枠の下側に復号
したデータを示している。復号データの括弧内の2つの
数値はラン、レベルである。各バイトの内容について、
四角の枠の中の上段は10進数での数値を示し、下段に
は2進数でのビット列を示している。ここで、復号を開
始するビット位置は、アドレス1001の5ビット目からと
する。この可変長符号を復号すると、ラン、レベルの組
は、(0,1)、(30,−6)、(2,−1)、(1
4,2)、(0,−1)となる。また、以降の説明で参
照するテーブル及びレコードはすべて図21〜図23に
示されている。
Next, a specific example of the operation of the variable length code decoding means 102 will be described in detail with reference to FIGS. 30 and 31, taking the case of decoding the variable length code shown in FIG. FIG. 32 shows an example of the variable-length code stored in the variable-length code storage means 101. Code contents of each byte are shown in a square frame, and the address is decoded above the frame and decoded at the bottom of the frame. Shows the data. Two numerical values in parentheses of the decoded data are a run and a level. For the contents of each byte,
The upper part in the square frame shows a numerical value in decimal number, and the lower part shows a bit string in binary number. Here, the bit position to start decoding is from the fifth bit of the address 1001. When this variable length code is decoded, the set of run and level is (0, 1), (30, -6), (2, -1), (1)
4, 2) and (0, -1). Tables and records referred to in the following description are all shown in FIGS.

【0181】まずReadPに開始アドレス1001を代入し、
状態Sには、初期状態で5ビット目からの復号であるの
でSF5を代入する(ステップ3001)。そして、可
変長符号格納手段101からReadPのアドレス、すなわ
ちアドレス1001の1バイトデータ「8(00001000)」を
得てDに代入する(ステップ3002)。次に、SがS
F5、Dが8であるので、復号テーブル103における
テーブルTF5のレコード8を参照する(ステップ30
03)。この場合は復号データdata=(0,1)、「次
の状態」Snext=SN5を得る。そして、Snext=SN
5であるので、復号データdata=(0,1)をすべて復
号データ格納手段104に出力する(ステップ300
4)。続いて、状態SにSnext=SN5をセットし、Re
adPに1を加算して、ReadP=1002とする(ステップ30
05)。
First, the start address 1001 is substituted for ReadP,
In the state S, SF5 is assigned because decoding is performed from the fifth bit in the initial state (step 3001). Then, the address of ReadP, that is, 1-byte data “8 (00001000)” of the address 1001 is obtained from the variable-length code storage unit 101 and substituted into D (step 3002). Next, S becomes S
Since F5 and D are 8, reference is made to record 8 of table TF5 in decoding table 103 (step 30).
03). In this case, decoded data data = (0, 1) and “next state” Snext = SN5 are obtained. And Snext = SN
5, all the decoded data data = (0, 1) is output to the decoded data storage unit 104 (step 300).
4). Subsequently, Snext = SN5 is set in the state S, and Re
Add 1 to adP to set ReadP = 1002 (step 30)
05).

【0182】この場合、状態Sは、ラン復号状態SRU
Nn、レベル復号状態SLVLn、EOB検出状態SE
OB、エラー検出状態SERRのいずれでもないので、
ステップ3006、3007、3008を経てステップ
3002に戻る。
In this case, the state S is the run decoding state SRU
Nn, level decoding state SLVLn, EOB detection state SE
Since it is neither OB nor error detection state SERR,
After steps 3006, 3007, and 3008, the process returns to step 3002.

【0183】2回目のステップ3002では、アドレス
1002の1バイトデータ「23(00010111)」を得てDに
代入する。次に、SがSN5、Dが23であるので、復
号テーブル103におけるテーブルTN5のレコード2
3を参照し、復号データdata=(28,0)、「次の状
態」Snext=SRUN5を得る(ステップ3003)。
この場合、Snext=SRUN5であるので、復号データ
dataの最後のデータを出力しない。すなわちデータの出
力は行わない(ステップ3004)。そして、状態Sに
Snext=SRUN5をセットし、ReadPに1を加算し
て、ReadP=1003とする(ステップ3005)。ここ
で、状態Sはラン復号状態SRUN5であるので、ステ
ップ3006からステップ3101に進む。
In the second step 3002, the address
The 1-byte data “23 (00010111)” of 1002 is obtained and substituted for D. Next, since S is SN5 and D is 23, record 2 of table TN5 in decoding table 103
3, the decoded data data = (28, 0) and the “next state” Snext = SRUN5 are obtained (step 3003).
In this case, since Snext = SRUN5, the decoded data
Do not output the last data of data. That is, data is not output (step 3004). Then, Snext = SRUN5 is set in the state S, 1 is added to ReadP, and ReadP = 1003 is set (step 3005). Since the state S is the run decoding state SRUN5, the process proceeds from step 3006 to step 3101.

【0184】次に、復号データdataの最後のデータ(2
8,0)をrun、levelに代入し、run=28,level=0
とする(ステップ3101)。そして、アドレスReadP
=1003の1バイトデータ「190(10111110)」を得て
Dに代入する(ステップ3102)。そして、SがSR
UN5、Dが190であるので、復号テーブル103に
おけるテーブルTRUN5のレコード190を参照し、
復号データdata=(2,248)、「次の状態」Snext
=SLVL7を得る(ステップ3103)。続いて、復
号データdata=(2,248)の最初のデータのラン、
レベルをそれぞれrun=28,level=0に加え、run=
30,level=248とする(ステップ3104)。さ
らに、状態SにSnext=SLVL7をセットし、ReadP
に1を加算して、ReadP=1004とする(ステップ310
5)。ここで、状態Sはレベル復号状態SLVL7であ
るので、ステップ3106からステップ3111に進
む。
Next, the last data (2
8,0) is assigned to run and level, and run = 28, level = 0
(Step 3101). And the address ReadP
1-byte data “190 (10111110)” of “1003” is obtained and substituted into D (step 3102). And S is SR
Since UN5 and D are 190, the record 190 of the table TRUN5 in the decoding table 103 is referred to, and
Decrypted data data = (2,248), “Next state” Snext
= SLVL7 is obtained (step 3103). Subsequently, a run of the first data of the decoded data data = (2,248),
The level is added to run = 28 and level = 0, respectively, and run =
30, level = 248 (step 3104). Further, Snext = SLVL7 is set in the state S, and ReadP is set.
Is added to 1 so that ReadP = 1004 (step 310)
5). Here, since the state S is the level decoding state SLVL7, the process proceeds from step 3106 to step 3111.

【0185】次に、アドレスReadP=1004の1バイトデ
ータ「150(10010110)」を得てDに代入する(ステ
ップ3111)。そして、SがSLVL7、Dが150
であるので、復号テーブル103におけるテーブルTL
VL7のレコード150を参照し、復号データdata=
(0,2)、(2,−1)、「次の状態」Snext=SN
2、「次の状態2」Snext2=SLVL7、「レベル
2」level2=88を得る(ステップ3112)。続い
て、復号データdataの最初のデータ(0,2)のレベル
をlevel=248に加え、level=250とする(ステッ
プ3113)。さらに、状態SにSnext=SN2をセッ
トし、ReadPに1を加算して、ReadP=1005とする(ステ
ップ3114)。
Next, 1-byte data "150 (10010110)" of address ReadP = 1004 is obtained and substituted for D (step 3111). S is SLVL7 and D is 150
Therefore, the table TL in the decoding table 103
With reference to the record 150 of the VL7, the decrypted data data =
(0, 2), (2, −1), “next state” Snext = SN
2. “Next state 2” Snext2 = SLVL7 and “level 2” level2 = 88 are obtained (step 3112). Subsequently, the level of the first data (0, 2) of the decoded data data is added to level = 248, and level = 250 (step 3113). Further, Snext = SN2 is set in the state S, 1 is added to ReadP, and ReadP = 1005 is set (Step 3114).

【0186】次に、levelの値を判定し(ステップ31
07)、levelは0または128ではないので、次のス
テップ3108に進む。そして、ラン、レベルの値を復
号データ格納手段104に出力する(ステップ310
8)。この場合、ランとしてはrun=30が出力され、
レベルについてはlevel=250でlevel>128である
ので、level−256の値すなわち−6が出力される。
その後、復号データdataの2番目以降のデータ、すなわ
ち(2,−1)を復号データ格納手段104に出力する
(ステップ3109)。
Next, the value of level is determined (step 31).
07), since the level is not 0 or 128, the process proceeds to the next step 3108. Then, the run and level values are output to the decoded data storage unit 104 (step 310).
8). In this case, run = 30 is output as the run,
Since the level is level = 250 and level> 128, the value of level-256, that is, -6 is output.
After that, the second and subsequent data of the decoded data, that is, (2, -1), are output to the decoded data storage unit 104 (step 3109).

【0187】そして、状態Sを判定し(ステップ300
8)、この場合状態SはEOB検出状態SEOBまたは
エラー検出状態SERRではないので、ステップ300
2に戻る。3回目のステップ3002では、アドレス10
05の1バイトデータ「0(00000000)」を得てDに代入
する。次に、SがSN2、Dが0であるので、復号テー
ブル103におけるテーブルTN2のレコード0を参照
し、復号データdata=なし、「次の状態」Snext=SN
57を得る(ステップ3003)。この場合、復号デー
タdataがないので、データの出力は行わない(ステップ
3004)。そして、状態SにSnext=SN57をセッ
トし、ReadPに1を加算して、ReadP=1006とする(ステ
ップ3005)。ここで、状態Sは、ラン復号状態SR
UNn、レベル復号状態SLVLn、EOB検出状態S
EOB、エラー検出状態SERRのいずれでもないの
で、ステップ3006、3007、3008を経てステ
ップ3002に戻る。
Then, the state S is determined (step 300).
8) In this case, since the state S is not the EOB detection state SEOB or the error detection state SERR, step 300
Return to 2. In the third step 3002, the address 10
The 1-byte data “0 (00000000)” of 05 is obtained and substituted into D. Next, since S is SN2 and D is 0, reference is made to record 0 of table TN2 in decoding table 103, and decoding data data = none, “next state” Snext = SN
57 are obtained (step 3003). In this case, there is no decoded data, so no data is output (step 3004). Then, Snext = SN57 is set in the state S, 1 is added to ReadP, and ReadP = 1006 is set (step 3005). Here, the state S is the run decoding state SR
UNn, level decoding state SLVLn, EOB detection state S
Since it is neither EOB nor error detection state SERR, the process returns to step 3002 via steps 3006, 3007 and 3008.

【0188】4回目のステップ3002では、アドレス
1006の1バイトデータ「46(00101110)」を得てDに
代入する。次に、SがSN57、Dが46であるので、
復号テーブル103におけるテーブルTN57のレコー
ド46を参照し、復号データdata=(14,2)、「次
の状態」Snext=SN1を得る(ステップ3003)。
そして、復号データdata=(14,2)をすべて復号デ
ータ格納手段104に出力する(ステップ3004)。
さらに、状態SにSnext=SN1をセットし、ReadPに
1を加算して、ReadP=1007とする(ステップ300
5)。ここで、状態Sは、ラン復号状態SRUNn、レ
ベル復号状態SLVLn、EOB検出状態SEOB、エ
ラー検出状態SERRのいずれでもないので、ステップ
3006、3007、3008を経てステップ3002
に戻る。
In the fourth step 3002, the address
The 1-byte data "46 (00101110)" of 1006 is obtained and substituted for D. Next, since S is SN57 and D is 46,
With reference to the record 46 of the table TN 57 in the decoding table 103, the decoding data data = (14, 2) and the “next state” Snext = SN1 are obtained (step 3003).
Then, all the decoded data data = (14, 2) is output to the decoded data storage unit 104 (step 3004).
Further, Snext = SN1 is set in the state S, and 1 is added to ReadP to make ReadP = 1007 (step 300).
5). Here, since the state S is not any of the run decoding state SRUNn, the level decoding state SLVLn, the EOB detection state SEOB, and the error detection state SERR, the state S goes through the steps 3006, 3007, and 3008 to the step 3002.
Return to

【0189】5回目のステップ3002では、アドレス
1007の1バイトデータ「247(11110111)」を得てD
に代入する。次に、SがSN1、Dが247であるの
で、復号テーブル103におけるテーブルTN1のレコ
ード247を参照し、復号データdata=(0,−1)、
(−1,6)、「次の状態」Snext=SEOBを得る
(ステップ3003)。この場合、Snext=SEOBで
あるので、復号データdataの最後のデータを除いて、す
なわち(0,−1)のみを復号データ格納手段104に
出力する(ステップ3004)。そして、状態SにSne
xt=SEOBをセットし、SEOBであるのでReadPは
加算しない(ステップ3005)。そして、状態Sは、
ラン復号状態SRUNn、レベル復号状態SLVLnの
いずれでもないので、ステップ3006、3007から
ステップ3008に進み、EOB検出状態SEOBであ
るので処理を終了する。ここで、EOB以降のビット列
は、アドレスはReadP=1007に示され、ビット位置は、
復号データdataの最後のデータのレベル=6に示され
る。
At the fifth step 3002, the address
Obtain 1 byte data "247 (11110111)" of 1007 and D
Substitute for Next, since S is SN1 and D is 247, the record 247 of the table TN1 in the decoding table 103 is referred to, and the decoded data data = (0, −1),
(−1, 6), “Next state” Snext = SEOB is obtained (step 3003). In this case, since Snext = SEOB, the last data of the decoded data data is removed, that is, only (0, -1) is output to the decoded data storage unit 104 (step 3004). Then, Sne changes to state S.
xt = SEOB is set, and ReadP is not added because it is SEOB (step 3005). And the state S is
Since it is neither the run decoding state SRUNn nor the level decoding state SLVLn, the process proceeds from steps 3006 and 3007 to step 3008, and the process ends because it is in the EOB detection state SEOB. Here, in the bit string after EOB, the address is indicated by ReadP = 1007, and the bit position is:
The level of the last data of the decoded data "data" is indicated by "6".

【0190】図32に示したビット列は、escapeに続く
固定長符号の復号について、ランの途中にバイト区切り
があり、レベルの符号長が8ビットの場合であり、この
場合の復号処理例を上記で説明した。図33にビット列
が異なる他の符号の例を示す。図33の(A)はランの
途中にバイト区切りがあり、レベルの符号長が16ビッ
トの場合のビット列の例、(B)はランの途中にバイト
区切りがなく、レベルの符号長が8ビットのビット列の
例、(C)はランの途中にバイト区切りがなく、レベル
の符号長が16ビットのビット列の例をそれぞれ示した
ものである。
The bit string shown in FIG. 32 is for decoding a fixed-length code following escape, where there is a byte break in the middle of the run and the code length of the level is 8 bits. It was explained in. FIG. 33 shows an example of another code having a different bit string. FIG. 33A shows an example of a bit string in the case where there is a byte break in the middle of the run and the level code length is 16 bits, and FIG. 33B shows no bit break in the middle of the run and the level code length is 8 bits. (C) shows an example of a bit string having a 16-bit level code length without a byte break in the middle of a run.

【0191】可変長符号復号手段102の動作の第2の
具体例として、図33の(A)に示す可変長符号を復号
する場合の動作を図30及び図31に基づいて詳しく説
明する。
As a second specific example of the operation of the variable length code decoding means 102, the operation for decoding the variable length code shown in FIG. 33A will be described in detail with reference to FIGS.

【0192】アドレス2002の復号を行う際には、状態S
=SN5(「通常状態:余りのビット列:00」)、アド
レスReadP=2002である。この場合、アドレス2002の1
バイトデータ「24(00011000)」を得てDに代入する
(ステップ3002)。次に、SがSN5、Dが24で
あるので、復号テーブル103におけるテーブルTN5
のレコード24を参照し、復号データdata=(32,
0)、「次の状態」Snext=SRUN5を得る(ステッ
プ3003)。ここで、Snext=SRUN5であるの
で、復号データdataの最後のデータを出力しない。すな
わちデータの出力は行わない(ステップ3004)。そ
して、状態SにSnext=SRUN5をセットし、ReadP
に1を加算して、ReadP=2003とする(ステップ300
5)。ここで、状態Sはラン復号状態SRUN5である
ので、ステップ3006からステップ3101に進む。
When decoding the address 2002, the state S
= SN5 (“normal state: surplus bit string: 00”) and address ReadP = 2002. In this case, 1 of address 2002
The byte data "24 (00011000)" is obtained and substituted for D (step 3002). Next, since S is SN5 and D is 24, the table TN5 in the decoding table 103 is set.
, The decrypted data data = (32,
0), “Next state” Snext = SRUN5 is obtained (step 3003). Here, since Snext = SRUN5, the last data of the decoded data data is not output. That is, data is not output (step 3004). Then, Snext = SRRUN5 is set in the state S, and ReadP is set.
Is added to 1 so that ReadP = 2003 (Step 300)
5). Since the state S is the run decoding state SRUN5, the process proceeds from step 3006 to step 3101.

【0193】次に、復号データdataの最後のデータ(3
2,0)をrun、levelに代入し、run=32,level=0
とする(ステップ3101)。そして、アドレスReadP
=2003の1バイトデータ「160(10100000)」を得て
Dに代入する(ステップ3102)。このとき、SがS
RUN5、Dが160であるので、復号テーブル103
におけるテーブルTRUN5のレコード160を参照
し、復号データdata=(2,128)、「次の状態」S
next=SLVL7を得る(ステップ3103)。続い
て、復号データdata=(2,128)の最初のデータの
ラン、レベルをそれぞれrun=32,level=0に加え、
run=34,level=128とする(ステップ310
4)。さらに、状態SにSnext=SLVL7をセット
し、ReadPに1を加算して、ReadP=2004とする(ステッ
プ3105)。ここで、状態Sはレベル復号状態SLV
L7であるので、ステップ3106からステップ311
1に進む。
Next, the last data (3
(2,0) is assigned to run and level, and run = 32, level = 0
(Step 3101). And the address ReadP
= 1-byte data "160 (10100000)" of 2003 is substituted into D (step 3102). At this time, S becomes S
Since RUN5 and D are 160, the decoding table 103
, The decrypted data data = (2, 128) and the “next state” S
Next = SLVL7 is obtained (step 3103). Subsequently, the run and level of the first data of the decoded data data = (2,128) are added to run = 32 and level = 0, respectively.
run = 34, level = 128 (step 310)
4). Further, Snext = SLVL7 is set in the state S, 1 is added to ReadP, and ReadP = 2004 is set (step 3105). Here, the state S is the level decoding state SLV
Since it is L7, steps 3106 to 311
Proceed to 1.

【0194】次に、アドレスReadP=2004の1バイトデ
ータ「1(00000001)」を得てDに代入する(ステップ
3111)。そして、SがSLVL7、Dが1であるの
で、復号テーブル103におけるテーブルTLVL7の
レコード1を参照し、復号データdata=(0,0)、
(0,0)、「次の状態」Snext=SRUN1、「次の
状態2」Snext2=SLVL7、「レベル2」level2=
4を得る(ステップ3112)。続いて、復号データda
taの最初のデータ(0,0)のレベルをlevel=128
に加え、level=128とする(ステップ3113)。
さらに、状態SにSnext=SRUN1をセットし、Read
Pに1を加算して、ReadP=2005とする(ステップ311
4)。
Next, 1-byte data "1 (00000001)" of address ReadP = 2004 is obtained and substituted into D (step 3111). Then, since S is SLVL7 and D is 1, reference is made to the record 1 of the table TLVL7 in the decoding table 103, and the decoded data data = (0, 0),
(0,0), "next state" Snext = SRUN1, "next state 2" Snext2 = SLVL7, "level 2" level2 =
4 is obtained (step 3112). Then, decrypted data da
The level of the first data (0,0) of ta is level = 128
Is set to level = 128 (step 3113).
Further, Snext = SRUN1 is set in the state S, and Read
Add 1 to P to make ReadP = 2005 (step 311
4).

【0195】次に、levelの値を判定し(ステップ31
07)、この場合levelは128であるので、ステップ
3115に進む。そして、level=128であるので符
号Fに−1を代入する(ステップ3115)。また、le
velにlevel2=4を代入し、level=4とする(ステップ
3116)。次に、状態SにSnext2=SLVL7をセ
ットし(ステップ3117)、アドレスReadP=2005の
1バイトデータ「112(01110000)」を得てDに代入
する(ステップ3118)。そして、SがSLVL7、
Dが112であるので、復号テーブル103におけるテ
ーブルTLVL7のレコード112を参照し、復号デー
タdata=(0,1)、(0,1)、「次の状態」Snext
=SN8を得る(ステップ3119)。続いて、復号デ
ータdataの最初のデータ(0,1)のレベルをlevel=
4に加え、level=5とする(ステップ3120)。さ
らに、状態SにSnext=SN8をセットし、ReadPに1
を加算して、ReadP=2006とする(ステップ312
1)。そして、ラン、レベルの値を復号データ格納手段
104に出力する(ステップ3122)。この場合、ラ
ンとしてはrun=34が出力され、レベルについては符
号F=−1であるので、level−256の値すなわち5
−256=−251が出力される。その後、復号データ
dataの2番目以降のデータ、すなわち(0,1)を復号
データ格納手段104に出力する(ステップ310
9)。
Next, the value of level is determined (step 31).
07) In this case, since the level is 128, the process proceeds to step 3115. Then, since level = 128, -1 is substituted for the code F (step 3115). Also, le
vel is substituted with level2 = 4 to make level = 4 (step 3116). Next, Snext2 = SLVL7 is set in the state S (step 3117), and 1-byte data “112 (01110000)” of the address ReadP = 2005 is obtained and substituted into D (step 3118). And S is SLVL7,
Since D is 112, reference is made to the record 112 of the table TLVL7 in the decoding table 103, and the decoded data data = (0, 1), (0, 1), "next state" Snext
= SN8 is obtained (step 3119). Subsequently, the level of the first data (0, 1) of the decoded data data is set to level =
In addition to level 4, level = 5 is set (step 3120). Further, Snext = SN8 is set in the state S, and 1 is set in ReadP.
Is added to make ReadP = 2006 (Step 312)
1). Then, the run and level values are output to the decoded data storage unit 104 (step 3122). In this case, run = 34 is output as the run, and the code of the level is F = −1.
-256 = -251 is output. Then decrypted data
The second and subsequent data of data, that is, (0, 1) is output to the decoded data storage unit 104 (step 310).
9).

【0196】可変長符号復号手段102の動作の第3の
具体例として、図33の(B)に示す可変長符号を復号
する場合の動作を図30及び図31に基づいて詳しく説
明する。
As a third specific example of the operation of the variable-length code decoding means 102, the operation for decoding the variable-length code shown in FIG. 33B will be described in detail with reference to FIGS.

【0197】アドレス2002の復号を行う際には、状態S
=SN18(「通常状態:余りのビット列:0000
0」)、アドレスReadP=2002である。この場合、アドレ
ス2002の1バイトデータ「136(10001000)」を得て
Dに代入する(ステップ3002)。次に、SがSN1
8、Dが136であるので、復号テーブル103におけ
るテーブルTN18のレコード136を参照し、復号デ
ータdata=(4,0)、「次の状態」Snext=SLVL
2を得る(ステップ3003)。ここで、Snext=SL
VL2であるので、復号データdataの最後のデータを出
力しない。すなわちデータの出力は行わない(ステップ
3004)。そして、状態SにSnext=SLVL2をセ
ットし、ReadPに1を加算して、ReadP=2003とする(ス
テップ3005)。ここで、状態Sはレベル復号状態S
LVL2であるので、ステップ3006、3007を経
てステップ3110に進む。
When decoding the address 2002, the state S
= SN18 (“normal state: surplus bit string: 0000
0 ”) and the address ReadP = 2002. In this case, 1-byte data "136 (10001000)" of the address 2002 is obtained and substituted into D (step 3002). Next, S is SN1
8, since D is 136, the record 136 of the table TN18 in the decoding table 103 is referred to, and the decoded data data = (4, 0) and the “next state” Snext = SLVL
2 is obtained (step 3003). Here, Snext = SL
Since it is VL2, the last data of the decoded data data is not output. That is, data is not output (step 3004). Then, Snext = SLVL2 is set in the state S, 1 is added to ReadP, and ReadP = 2003 is set (step 3005). Here, the state S is the level decoding state S
Since it is LVL2, the process proceeds to step 3110 via steps 3006 and 3007.

【0198】次に、復号データdataの最後のデータ
(4,0)をrun、levelに代入し、run=4,level=0
とする(ステップ3110)。そして、アドレスReadP
=2003の1バイトデータ「6(00000110)」を得てDに
代入する(ステップ3111)。このとき、SがSLV
L2、Dが6であるので、復号テーブル103における
テーブルTLVL2のレコード6を参照し、復号データ
data=(0,3)、「次の状態」Snext=SN2、「次
の状態2」Snext2=SLVL2、「レベル2」level2
=0を得る(ステップ3112)。続いて、復号データ
dataの最初のデータ(0,3)のレベルをlevel=0に
加え、level=3とする(ステップ3113)。さら
に、状態SにSnext=SN2をセットし、ReadPに1を
加算して、ReadP=2004とする(ステップ3114)。
Next, the last data (4, 0) of the decoded data data is substituted into run and level, and run = 4, level = 0
(Step 3110). And the address ReadP
= 1-byte data "6 (00000110)" of 2003 is substituted for D (step 3111). At this time, S is SLV
Since L2 and D are 6, reference is made to record 6 of table TLVL2 in decoding table 103, and the
data = (0,3), “next state” Snext = SN2, “next state 2” Snext2 = SLVL2, “level 2” level2
= 0 is obtained (step 3112). Then, decrypted data
The level of the first data (0, 3) of data is added to level = 0 to set level = 3 (step 3113). Further, Snext = SN2 is set in the state S, 1 is added to ReadP, and ReadP = 2004 is set (step 3114).

【0199】次に、levelの値を判定し(ステップ31
07)、この場合levelは0または128ではないの
で、次のステップ3108に進む。そして、ラン、レベ
ルの値を復号データ格納手段104に出力する(ステッ
プ3108)。この場合、ランとしてはrun=4が出力
され、レベルについてはlevel=3でlevel<128であ
るので、levelの値すなわち3が出力される。そして、
復号データdataの2番目以降のデータはないので、デー
タの出力は行わない(ステップ3109)。
Next, the value of level is determined (step 31).
07) In this case, since the level is not 0 or 128, the process proceeds to the next step 3108. Then, the run and level values are output to the decoded data storage unit 104 (step 3108). In this case, run = 4 is output as a run, and level = 3 and level <128 for the level. Therefore, the value of level, that is, 3 is output. And
Since there is no second or subsequent data in the decoded data data, no data is output (step 3109).

【0200】可変長符号復号手段102の動作の第4の
具体例として、図33の(C)に示す可変長符号を復号
する場合の動作を図30及び図31に基づいて詳しく説
明する。
As a fourth specific example of the operation of the variable-length code decoding means 102, the operation for decoding the variable-length code shown in FIG. 33C will be described in detail with reference to FIGS.

【0201】アドレス2002の復号を行う際には、状態S
=SN18(「通常状態:余りのビット列:0000
0」)、アドレスReadP=2002である。この場合、アドレ
ス2002の1バイトデータ「136(10001000)」を得て
Dに代入する(ステップ3002)。次に、SがSN1
8、Dが136であるので、復号テーブル103におけ
るテーブルTN18のレコード136を参照し、復号デ
ータdata=(4,0)、「次の状態」Snext=SLVL
2を得る(ステップ3003)。ここで、Snext=SL
VL2であるので、復号データdataの最後のデータを出
力しない。すなわちデータの出力は行わない(ステップ
3004)。そして、状態SにSnext=SLVL2をセ
ットし、ReadPに1を加算して、ReadP=2003とする(ス
テップ3005)。ここで、状態Sはレベル復号状態S
LVL2であるので、ステップ3006、3007を経
てステップ3110に進む。
When decoding the address 2002, the state S
= SN18 (“normal state: surplus bit string: 0000
0 ”) and the address ReadP = 2002. In this case, 1-byte data "136 (10001000)" of the address 2002 is obtained and substituted into D (step 3002). Next, S is SN1
8, since D is 136, the record 136 of the table TN18 in the decoding table 103 is referred to, and the decoded data data = (4, 0) and the “next state” Snext = SLVL
2 is obtained (step 3003). Here, Snext = SL
Since it is VL2, the last data of the decoded data data is not output. That is, data is not output (step 3004). Then, Snext = SLVL2 is set in the state S, 1 is added to ReadP, and ReadP = 2003 is set (step 3005). Here, the state S is the level decoding state S
Since it is LVL2, the process proceeds to step 3110 via steps 3006 and 3007.

【0202】次に、復号データdataの最後のデータ
(4,0)をrun、levelに代入し、run=4,level=0
とする(ステップ3110)。そして、アドレスReadP
=2003の1バイトデータ「1(00000001)」を得てDに
代入する(ステップ3111)。このとき、SがSLV
L2、Dが1であるので、復号テーブル103における
テーブルTLVL2のレコード1を参照し、復号データ
data=(0,0)、「次の状態」Snext=SN4、「次
の状態2」Snext2=SLVL2、「レベル2」level2
=128を得る(ステップ3112)。続いて、復号デ
ータdataの最初のデータ(0,0)のレベルをlevel=
0に加え、level=0とする(ステップ3113)。さ
らに、状態SにSnext=SN4をセットし、ReadPに1
を加算して、ReadP=2004とする(ステップ311
4)。
Next, the last data (4, 0) of the decoded data data is substituted into run and level, and run = 4, level = 0
(Step 3110). And the address ReadP
= 1-byte data "1 (00000001)" of 2003 is obtained and substituted into D (step 3111). At this time, S is SLV
Since L2 and D are 1, reference is made to record 1 of table TLVL2 in decoding table 103, and the
data = (0,0), “next state” Snext = SN4, “next state 2” Snext2 = SLVL2, “level 2” level2
= 128 (step 3112). Subsequently, the level of the first data (0, 0) of the decoded data data is set to level =
In addition to 0, level = 0 is set (step 3113). Further, Snext = SN4 is set in the state S, and 1 is set in ReadP.
Is added to make ReadP = 2004 (Step 311)
4).

【0203】次に、levelの値を判定し(ステップ31
07)、この場合levelは0であるので、ステップ31
15に進む。そして、level=0であるので符号Fに1
を代入する(ステップ3115)。また、levelにlevel
2=128を代入し、level=128とする(ステップ3
116)。次に、状態SにSnext2=SLVL2をセッ
トし(ステップ3117)、アドレスReadP=2004の1
バイトデータ「6(00000110)」を得てDに代入する
(ステップ3118)。そして、SがSLVL2、Dが
6であるので、復号テーブル103におけるテーブルT
LVL2のレコード6を参照し、復号データdata=
(0,3)、「次の状態」Snext=SN2を得る(ステ
ップ3119)。続いて、復号データdataの最初のデー
タ(0,3)のレベルをlevel=128に加え、level=
131とする(ステップ3120)。さらに、状態Sに
Snext=SN2をセットし、ReadPに1を加算して、Rea
dP=2005とする(ステップ3121)。そして、ラン、
レベルの値を復号データ格納手段104に出力する(ス
テップ3122)。この場合、ランとしてはrun=4が
出力され、レベルについては符号F=1であるので、le
velの値すなわち131が出力される。そして、復号デ
ータdataの2番目以降のデータはないので、データの出
力は行わない(ステップ3109)。
Next, the value of level is determined (step 31).
07) In this case, since level is 0, step 31
Proceed to 15. Since level = 0, the code F is 1
Is substituted (step 3115). Also, level to level
2 = 128, and level = 128 (step 3
116). Next, Snext2 = SLVL2 is set in the state S (step 3117), and 1 of the address ReadP = 2004 is set.
The byte data "6 (00000110)" is obtained and substituted for D (step 3118). Since S is SLVL2 and D is 6, the table T in the decoding table 103
Referring to record 6 of LVL2, decrypted data data =
(0, 3), “next state” Snext = SN2 is obtained (step 3119). Subsequently, the level of the first data (0, 3) of the decoded data data is added to level = 128, and level =
131 (step 3120). Further, Snext = SN2 is set in the state S, 1 is added to ReadP, and
dP is set to 2005 (step 3121). And run,
The value of the level is output to the decoded data storage unit 104 (Step 3122). In this case, run = 4 is output as the run and the code F = 1 for the level.
The value of vel, ie, 131, is output. Then, since there is no second or subsequent data in the decoded data data, no data is output (step 3109).

【0204】このようにして、MPEG1におけるDC
T係数のラン、レベルの可変長符号、およびescape符号
で始まる固定長符号を復号する際に、バイト単位でデー
タを扱い、ビット演算を行わずに復号を行うことができ
る。
Thus, the DC1 in MPEG1
When decoding a fixed-length code starting with a run of T coefficients, a variable-length code of a level, and an escape code, data can be handled in units of bytes, and decoding can be performed without performing a bit operation.

【0205】なお、第2実施形態では、図15及び図1
6に示したようなMPEGのDCT係数のラン、レベル
の可変長符号及び固定長符号を復号する構成例を示した
が、どのような可変長符号、あるいは固定長符号を含む
可変長符号にも適用可能であり、復号対象とする可変長
符号の内容に応じて復号テーブルや復号手段を構成でき
る。
In the second embodiment, FIGS. 15 and 1
Although the configuration example of decoding the run of the DCT coefficient of MPEG, the variable length code of the level as shown in FIG. 6, and the fixed length code has been shown, any variable length code or the variable length code including the fixed length code can be used. It is applicable, and a decoding table and decoding means can be configured according to the content of the variable length code to be decoded.

【0206】なお、上述した第1及び第2実施形態で
は、1バイトすなわち8ビット毎に符号を取り出して復
号するように構成しているが、任意のビット数で符号を
取り出して復号するように構成しても構わない。例え
ば、2バイト毎に符号を取り出して復号するように構成
した場合には、各テーブルは0番から65535番まで
のレコードが必要となり、大きなテーブルを必要とする
が、テーブルを参照する回数が2分の1になるため、復
号の処理時間を短縮することができる。また、4ビット
毎に符号を取り出して復号するように構成した場合に
は、各テーブルは0番から15番までのレコードが必要
となり、テーブルを小さくすることができる。この場
合、テーブルを参照する回数は2倍になり、また、4ビ
ット毎に取り出すという決まった処理ではあるがビット
演算が必要となる。
In the first and second embodiments described above, the code is extracted and decoded every one byte, that is, every 8 bits. However, the code is extracted and decoded with an arbitrary number of bits. It may be configured. For example, if a code is taken out and decoded every two bytes, each table requires records from 0 to 65535, and a large table is required. Since it is reduced by a factor of 1, the decoding processing time can be reduced. In the case where a code is extracted and decoded every four bits, each table requires records from No. 0 to No. 15, and the size of the table can be reduced. In this case, the number of times that the table is referred to is doubled, and a bit operation is required although it is a fixed process of extracting every four bits.

【0207】また、本実施形態では、EOB符号を検出
することにより、復号処理を終了したが、指定のアドレ
スまで復号したら処理を終了するなど、EOBを検出す
る以外の条件で復号処理を終了するように構成しても構
わない。
In this embodiment, the decoding process is terminated by detecting the EOB code. However, the decoding process is terminated under conditions other than the detection of the EOB, such as terminating the process after decoding to a specified address. Such a configuration may be adopted.

【0208】以上詳述したように、本実施形態では、復
号テーブルとして、復号処理中の現在の状態Sに対応し
た複数のテーブルを持ち、各テーブルのレコードRNに
その状態においてRNが示すビット列を復号した「デー
タ」と「次の状態」を格納し、さらに固定長部分の復号
に関しても、レコードRNに含まれる部分について評価
した値を格納したものを作成し、この復号テーブルを参
照することにより、1バイト毎にビット列を取り出しな
がら可変長符号、およびこれに含まれる固定長部分を復
号するようにしている。これによって、固定長符号を含
む可変長符号をビットシフトなどのビット演算を行わず
に復号することができるため、復号処理を高速に実行可
能であり、復号にかかる処理時間を短縮することがで
き、その実用的効果は大きい。
As described in detail above, in the present embodiment, a plurality of tables corresponding to the current state S during the decoding process are provided as the decoding table, and the bit string indicated by the RN in that state is recorded in the record RN of each table. By storing the decoded "data" and the "next state", and also for decoding the fixed length part, a value storing the value evaluated for the part included in the record RN is created, and by referring to this decoding table, A variable-length code and a fixed-length portion included in the variable-length code are decoded while extracting a bit string for each byte. As a result, a variable-length code including a fixed-length code can be decoded without performing a bit operation such as a bit shift, so that the decoding process can be executed at a high speed and the processing time required for decoding can be reduced. , Its practical effect is great.

【0209】[0209]

【発明の効果】以上説明したように本発明によれば、可
変長符号のみ、あるいは可変長符号と固定長符号が混在
する符号を復号する際に、復号対象の可変長符号に対し
て、ビットシフトなどのビット演算を行う必要がなく、
バイト単位でビット列を取り出してテーブルを参照する
だけで復号することができ、高速に復号処理を行うこと
が可能となるという効果が得られる。
As described above, according to the present invention, when decoding only a variable-length code or a code in which a variable-length code and a fixed-length code are mixed, a bit length is There is no need to perform bit operations such as shift,
The decoding can be performed only by taking out the bit string in byte units and referring to the table, so that the decoding processing can be performed at high speed.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の実施形態に係る可変長符号復号装置の
構成を示すブロック図である。
FIG. 1 is a block diagram illustrating a configuration of a variable-length code decoding device according to an embodiment of the present invention.

【図2】第1実施形態で使用する可変長符号の例を示す
図である。
FIG. 2 is a diagram illustrating an example of a variable length code used in the first embodiment.

【図3】初期状態における復号対象の符号パターンを示
した説明図である。
FIG. 3 is an explanatory diagram showing a code pattern to be decoded in an initial state.

【図4】通常状態における符号パターンと余りのビット
列を示した説明図である。
FIG. 4 is an explanatory diagram showing a code pattern and a surplus bit string in a normal state.

【図5】余りのビット列の組み合わせを示した図であ
る。
FIG. 5 is a diagram showing combinations of remaining bit strings.

【図6】EOB検出状態の8種類のパターンを示した説
明図である。
FIG. 6 is an explanatory diagram showing eight types of patterns in an EOB detection state.

【図7】escape検出状態の8種類のパターンを示した説
明図である。
FIG. 7 is an explanatory diagram showing eight types of patterns in an escape detection state.

【図8】第1実施形態において復号の際に取り得る状態
の状態番号とその意味、参照するテーブルの対応を示す
図である。
FIG. 8 is a diagram showing the correspondence between state numbers of states that can be taken at the time of decoding in the first embodiment, their meanings, and tables to be referred to.

【図9】通常状態で取り得る「余りのビット列」を列挙
する処理手順を示すフローチャートである。
FIG. 9 is a flowchart illustrating a processing procedure for listing “remaining bit strings” that can be taken in a normal state.

【図10】第1実施形態で使用する復号テーブルの例を
示す図である。
FIG. 10 is a diagram illustrating an example of a decoding table used in the first embodiment.

【図11】復号テーブルを作成する処理手順を示すフロ
ーチャートである。
FIG. 11 is a flowchart illustrating a processing procedure for creating a decoding table.

【図12】第1実施形態で使用する復号テーブルの一部
を示す図である。
FIG. 12 is a diagram showing a part of a decoding table used in the first embodiment.

【図13】第1実施形態における可変長符号復号手段の
動作による復号手順を示すフローチャートである。
FIG. 13 is a flowchart showing a decoding procedure based on the operation of the variable length code decoding means in the first embodiment.

【図14】可変長符号のビット列の例及びその復号処理
の具体例を示す説明図である。
FIG. 14 is an explanatory diagram showing an example of a bit string of a variable length code and a specific example of a decoding process thereof.

【図15】第2実施形態で使用する可変長符号の例とし
てMPEGのDCT係数のランとレベルの可変長符号を
示す図である。
FIG. 15 is a diagram illustrating a variable length code of a DCT coefficient run and level of MPEG as an example of a variable length code used in the second embodiment.

【図16】第2実施形態で使用する可変長符号の例とし
てMPEGのDCT係数のエスケープコードによるラン
とレベルの固定長符号を示す図である。
FIG. 16 is a diagram showing a run and level fixed-length code by an escape code of a DCT coefficient of MPEG as an example of a variable-length code used in the second embodiment.

【図17】第2実施形態において復号の際に取り得る状
態の状態番号とその意味、参照するテーブルの対応を示
す図である。
FIG. 17 is a diagram showing the correspondence between state numbers of states that can be taken at the time of decoding in the second embodiment, their meanings, and tables to be referred to.

【図18】ラン復号状態とレベル復号状態のすべての状
態を示した説明図である。
FIG. 18 is an explanatory diagram showing all states of a run decoding state and a level decoding state.

【図19】状態SN1の例を示した説明図である。FIG. 19 is an explanatory diagram showing an example of state SN1.

【図20】状態SN3及びSN4の例を示した説明図で
ある。
FIG. 20 is an explanatory diagram showing an example of states SN3 and SN4.

【図21】第2実施形態で使用する復号テーブルの例を
示す図である。
FIG. 21 is a diagram illustrating an example of a decoding table used in the second embodiment.

【図22】第2実施形態で使用する復号テーブルの例を
示す図である。
FIG. 22 is a diagram illustrating an example of a decoding table used in the second embodiment.

【図23】第2実施形態で使用する復号テーブルの例を
示す図である。
FIG. 23 is a diagram illustrating an example of a decoding table used in the second embodiment.

【図24】escape符号を含む可変長符号のビット列の一
例を示す説明図である。
FIG. 24 is an explanatory diagram showing an example of a bit string of a variable-length code including an escape code.

【図25】初期状態で参照するテーブルを作成する処理
手順を示すフローチャートである。
FIG. 25 is a flowchart illustrating a processing procedure for creating a table referred to in an initial state.

【図26】初期状態で参照するテーブルを作成する処理
手順を示すフローチャートである。
FIG. 26 is a flowchart illustrating a processing procedure for creating a table referred to in an initial state.

【図27】通常状態で参照するテーブルを作成する処理
手順を示すフローチャートである。
FIG. 27 is a flowchart illustrating a processing procedure for creating a table referred to in a normal state.

【図28】ラン復号状態で参照するテーブルを作成する
処理手順を示すフローチャートである。
FIG. 28 is a flowchart illustrating a processing procedure for creating a table to be referred to in the run decoding state.

【図29】レベル復号状態で参照するテーブルを作成す
る処理手順を示すフローチャートである。
FIG. 29 is a flowchart showing a processing procedure for creating a table referred to in the level decoding state.

【図30】第2実施形態における可変長符号復号手段の
動作による復号手順を示すフローチャートである。
FIG. 30 is a flowchart showing a decoding procedure by the operation of the variable length code decoding means in the second embodiment.

【図31】第2実施形態における可変長符号復号手段の
動作による復号手順を示すフローチャートである。
FIG. 31 is a flowchart showing a decoding procedure based on the operation of the variable length code decoding means in the second embodiment.

【図32】escape符号を含む可変長符号のビット列の例
及びその復号処理の具体例を示す説明図である。
FIG. 32 is an explanatory diagram illustrating an example of a bit string of a variable-length code including an escape code and a specific example of a decoding process thereof.

【図33】escape符号を含む可変長符号のビット列の例
及びその復号処理の他の具体例を示す説明図である。
FIG. 33 is an explanatory diagram showing an example of a bit string of a variable-length code including an escape code and another specific example of the decoding process.

【図34】可変長符号の一例を示す図である。FIG. 34 is a diagram illustrating an example of a variable length code.

【図35】図34の可変長符号によるビット列とその復
号データを示す説明図である。
FIG. 35 is an explanatory diagram showing a bit string by the variable length code of FIG. 34 and its decoded data.

【図36】図34の可変長符号に対応する復号テーブル
の一例を示す図である。
FIG. 36 is a diagram illustrating an example of a decoding table corresponding to the variable-length code in FIG. 34.

【図37】従来の復号方法による可変長符号の復号手順
を示すフローチャートである。
FIG. 37 is a flowchart showing a procedure for decoding a variable length code by a conventional decoding method.

【図38】所定位置のビット列を取り出す処理手順を示
すフローチャートである。
FIG. 38 is a flowchart showing a processing procedure for extracting a bit string at a predetermined position.

【図39】ビット列の取り出し開始位置を更新する処理
手順を示すフローチャートである。
FIG. 39 is a flowchart illustrating a processing procedure for updating a bit string extraction start position.

【図40】従来の復号方法で用いる復号テーブルの一例
を示す図である。
FIG. 40 is a diagram illustrating an example of a decoding table used in a conventional decoding method.

【符号の説明】[Explanation of symbols]

101 可変長符号格納手段 102 可変長符号復号手段 103 復号テーブル 104 復号データ格納手段 Reference Signs List 101 variable length code storage means 102 variable length code decoding means 103 decoding table 104 decoded data storage means

Claims (13)

【特許請求の範囲】[Claims] 【請求項1】 復号対象の可変長符号列からNビット
(Nは1以上の整数)のビット列Bを取り出す手順と、 現在の状態Sに対応したテーブルにおいて前記取り出し
たビット列Bに対応したレコードを参照し、このレコー
ドから復号データ列Vと遷移する次の状態S′とを得る
手順とを有し、 これらの手順を繰り返して順次可変長符号列の復号デー
タを得ることを特徴とする可変長符号の復号方法。
1. A procedure for extracting a bit string B of N bits (N is an integer equal to or greater than 1) from a variable-length code string to be decoded, and a table corresponding to a current state S, wherein a record corresponding to the extracted bit string B is stored. And obtaining a decoded data sequence V and the next state S 'to transition from this record, and obtaining decoded data of a variable-length code sequence by repeating these procedures. Code decoding method.
【請求項2】 復号時の状態Sにそれぞれ対応した複数
のテーブルを有し、各テーブルにおいて可変長符号列か
らバイト単位で取り出したビット列Bにそれぞれ対応し
た複数のレコードを設け、各レコードには、前記ビット
列Bを復号した場合に得られるデータを示す復号データ
列Vと当該レコードを参照してから次に遷移する状態を
示す次の状態S′とを少なくとも格納して構成される復
号テーブルを用い、 復号対象の可変長符号列からNバイト(Nは1以上の整
数)のビット列Bを取り出す手順と、 前記復号テーブルにおいて、現在の状態Sに対応したテ
ーブルにおける前記取り出したビット列Bに対応したレ
コードを参照し、このレコードから復号データ列Vと次
の状態S′とを得る手順とを有し、 これらの手順を繰り返して順次可変長符号列の復号デー
タを得ることを特徴とする可変長符号の復号方法。
2. A plurality of tables respectively corresponding to a state S at the time of decoding, and a plurality of records respectively corresponding to a bit string B extracted from a variable length code string in byte units in each table are provided. A decoding table configured to store at least a decoded data string V indicating data obtained when the bit string B is decoded and a next state S ′ indicating a next transition state after referring to the record A step of extracting a bit string B of N bytes (N is an integer of 1 or more) from a variable-length code string to be decoded; and a step of extracting the bit string B corresponding to the extracted bit string B in a table corresponding to a current state S in the decoding table. A procedure of referring to a record and obtaining a decoded data string V and the next state S 'from the record, and sequentially changing these procedures by repeating these procedures. A decoding method for a variable-length code, comprising obtaining decoded data of a long code string.
【請求項3】 前記状態Sは、前記取り出したビット列
Bのiビット目(iは1以上の整数)から復号しそれ以
前のビットは復号対象としない状態である複数の初期状
態SFiと、前回の復号の結果において復号できない余
りのビット列が生じた状態である複数の通常状態SNx
とを含むことを特徴とする請求項1又は2に記載の可変
長符号の復号方法。
3. The state S includes a plurality of initial states SFi in which a state is decoded from the i-th bit (i is an integer of 1 or more) of the extracted bit string B, and the preceding bits are not to be decoded. A plurality of normal states SNx in a state in which a surplus bit string that cannot be decoded occurs as a result of decoding
The decoding method for a variable-length code according to claim 1, comprising:
【請求項4】 復号対象の可変長符号列からNビット
(Nは1以上の整数)毎にビット列を取り出して復号し
ていく復号方法であって、 取り出したビット列Bのiビット目(i=1〜N)から
復号する状態である複数の初期状態SFiと、前回の復
号の結果において復号できない余りのビット列Rが生じ
た状態であって前記余りのビット列Rが取り得る複数の
通常状態SNxとのそれぞれに対応した複数のテーブル
を持ち、これらのテーブルは、Nビットの2進数で表現
可能な個数のレコードを持ち、Nビットのビット列bに
より示されるレコードには、前記初期状態SFiに対応
したテーブルにおいては前記ビット列bをiビット目か
ら復号して得られる復号データ列Vと次の余りのビット
列rに対応した次の状態S′とを格納し、前記通常状態
SNxに対応したテーブルにおいては前記余りのビット
列Rと前記ビット列bとを結合したビット列を復号して
得られる復号データ列Vと次の余りのビット列rに対応
した次の状態S′とを格納して構成される復号テーブル
を用い、 復号対象の可変長符号列からNビットのビット列Bを取
り出す手順と、 現在の状態Sに対応した前記テーブルにおいて前記ビッ
ト列Bに対応したレコードを参照し、このレコードから
復号データ列Vと次の状態S′とを得る手順とを有し、 これらの手順を繰り返して順次可変長符号列の復号デー
タを得ることを特徴とする可変長符号の復号方法。
4. A decoding method for extracting and decoding a bit string for each N bits (N is an integer of 1 or more) from a variable-length code string to be decoded, wherein the i-th bit (i = 1 to N), a plurality of initial states SFi in a state of decoding, and a plurality of normal states SNx in which there is a surplus bit string R that cannot be decoded in the previous decoding result and the surplus bit string R can take. Have a number of records that can be represented by an N-bit binary number, and the records indicated by the N-bit bit string b correspond to the initial state SFi. In the table, a decoded data string V obtained by decoding the bit string b from the i-th bit and a next state S 'corresponding to the next remaining bit string r are stored. The table corresponding to the state SNx stores a decoded data string V obtained by decoding a bit string obtained by combining the remaining bit string R and the bit string b, and a next state S 'corresponding to the next remaining bit string r. A procedure for extracting an N-bit bit string B from a variable-length code string to be decoded by using a decoding table configured as described above, and referring to a record corresponding to the bit string B in the table corresponding to the current state S. A method for obtaining a decoded data sequence V and a next state S 'from a record, and sequentially obtaining decoded data of a variable length code sequence by repeating these procedures.
【請求項5】 復号対象の可変長符号列からNバイト
(Nは1以上の整数)毎にビット列を取り出して復号し
ていく復号方法であって、 取り出したビット列Bのiビット目(i=1〜N×8)
から復号する状態である複数の初期状態SFiと、前回
の復号の結果において復号できない余りのビット列Rが
生じた状態であって前記余りのビット列Rが取り得る複
数の通常状態SNxとのそれぞれに対応した複数のテー
ブルを持ち、これらのテーブルは、N×8ビットの2進
数で表現可能な個数のレコードを持ち、N×8ビットの
ビット列bにより示されるレコードには、前記初期状態
SFiに対応したテーブルにおいては前記ビット列bを
iビット目から復号して得られる復号データ列Vと次の
余りのビット列rに対応した次の状態S′とを格納し、
前記通常状態SNxに対応したテーブルにおいては前記
余りのビット列Rと前記ビット列bとを結合したビット
列を復号して得られる復号データ列Vと次の余りのビッ
ト列rに対応した次の状態S′とを格納して構成される
復号テーブルを用い、 復号対象の可変長符号列からバイト単位でNバイトのビ
ット列Bを取り出す手順と、 現在の状態Sに対応した前記テーブルにおいて前記ビッ
ト列Bに対応したレコードを参照し、このレコードから
復号データ列Vと次の状態S′とを得る手順とを有し、 これらの手順を繰り返して順次可変長符号列の復号デー
タを得ることを特徴とする可変長符号の復号方法。
5. A decoding method for extracting and decoding a bit string every N bytes (N is an integer of 1 or more) from a variable-length code string to be decoded, wherein an i-th bit (i = 1 to N × 8)
, And a plurality of normal states SNx in which the remaining bit strings R that cannot be decoded occur as a result of the previous decoding and the remaining bit strings R can take. These tables have a number of records that can be represented by an N × 8-bit binary number, and records indicated by an N × 8-bit bit string b correspond to the initial state SFi. The table stores a decoded data string V obtained by decoding the bit string b from the i-th bit and a next state S 'corresponding to the next remaining bit string r,
In the table corresponding to the normal state SNx, a decoded data string V obtained by decoding a bit string obtained by combining the remaining bit string R and the bit string b, and a next state S ′ corresponding to the next remaining bit string r Using a decoding table configured to store a bit string B of N bytes in units of bytes from a variable-length code string to be decoded; and a record corresponding to the bit string B in the table corresponding to the current state S. And a procedure for obtaining a decoded data sequence V and the next state S 'from the record, and sequentially obtaining decoded data of a variable-length code sequence by repeating these procedures. Decryption method.
【請求項6】 前記復号対象の可変長符号列に可変長符
号と固定長符号が混在し、固定長符号の開始を示す符号
として固定長識別符号CSがある場合、前記テーブルの
それぞれのビット列bに対応したレコードにおいて、当
該ビット列bに前記固定長識別符号CSの少なくとも一
部が含まれるレコードには、前記復号データ列Vとして
前記固定長識別符号CSの前までの符号列を復号して得
られるデータが格納され、前記次の状態S′として固定
長識別符号の検出を示しその余りのビットに対応した状
態が格納されており、このレコードを用いて固定長符号
部分の復号を行うことを特徴とする請求項1〜5のいず
れかに記載の可変長符号の復号方法。
6. When a variable-length code and a fixed-length code are mixed in the variable-length code string to be decoded and a fixed-length identification code CS is provided as a code indicating the start of the fixed-length code, each bit string b in the table is set. In the record corresponding to the above, the record in which the bit sequence b includes at least a part of the fixed-length identification code CS is obtained by decoding the code sequence up to the fixed-length identification code CS as the decoded data sequence V. And the state corresponding to the remaining bits is stored as the next state S ', and decoding of the fixed-length code portion is performed using this record. The variable length code decoding method according to any one of claims 1 to 5, wherein:
【請求項7】 前記復号対象の可変長符号列に可変長符
号と固定長符号が混在し、固定長符号の開始を示す符号
として固定長識別符号CSがある場合、前記状態Sは、
固定長符号の復号を行う状態である複数の固定長復号状
態SCyを含み、この固定長復号状態SCyに対応する
テーブルを参照して固定長識別符号CS以降の固定長符
号の復号を行うことを特徴とする請求項1〜5のいずれ
かに記載の可変長符号の復号方法。
7. When a variable length code and a fixed length code are mixed in the variable length code string to be decoded and a fixed length identification code CS is provided as a code indicating the start of the fixed length code, the state S is as follows.
It includes a plurality of fixed-length decoding states SCy in which decoding of fixed-length codes is performed, and refers to a table corresponding to the fixed-length decoding states SCy to decode fixed-length codes after the fixed-length identification code CS. The variable length code decoding method according to any one of claims 1 to 5, wherein:
【請求項8】 前記復号対象の可変長符号列に可変長符
号と固定長符号が混在し、固定長符号の開始を示す符号
として固定長識別符号CSがある場合、 前記通常状態SNxに対応したテーブルにおいて、それ
ぞれのビット列bにより示されるレコードであって当該
ビット列bに前記固定長識別符号CSの少なくとも一部
が含まれるレコードには、前記固定長識別符号CSの前
までの符号列を復号して得られる復号データ列Vと、前
記ビット列bにおける固定長識別符号CSの後の固定長
符号部分によって確定される数値v1と、次回の復号が
固定長符号の何ビット目からの復号であるかを示す固定
長復号状態SCyとを格納し、 固定長符号のyビット目からの復号を示す前記固定長復
号状態SCyに対応したテーブルにおけるビット列bで
示されるレコードには、このビット列bを固定長符号の
yビット目として復号して得られる数値v2と、固定長
符号以降の符号列を復号して得られる復号データ列V
と、復号した後の状態を示す次の状態S′とを格納して
復号テーブルが構成されており、 前記固定長符号の復号を行う際には、前記数値v1及び
数値v2を得た後で、v1+v2を用いて固定長符号を
復号することを特徴とする請求項4〜7のいずれかに記
載の可変長符号の復号方法。
8. When a variable length code and a fixed length code are mixed in the variable length code string to be decoded, and a fixed length identification code CS is provided as a code indicating the start of the fixed length code, the variable length code string corresponds to the normal state SNx. In the table, in a record indicated by each bit string b, in which the bit string b includes at least a part of the fixed-length identification code CS, the code string up to the fixed-length identification code CS is decoded. The decoded data sequence V obtained by the above, the numerical value v1 determined by the fixed length code part after the fixed length identification code CS in the bit sequence b, and the number of bits of the fixed length code to be decoded next time And the fixed-length decoding state SCy indicating the decoding from the y-th bit of the fixed-length code is indicated by the bit string b in the table corresponding to the fixed-length decoding state SCy. The records, a numerical value v2 obtained by decoding the bit sequence b as y-th bit of the fixed-length code, the decoded data sequence V which is obtained by decoding the code sequence of the fixed length code after
And a next state S ′ indicating the state after decoding, a decoding table is configured. When decoding the fixed-length code, after decoding the numerical value v1 and the numerical value v2, 8. The method for decoding a variable-length code according to claim 4, wherein the fixed-length code is decoded using v1, v1 + v2.
【請求項9】 前記復号対象の可変長符号列における可
変長符号及び固定長符号は、MPEGの画像圧縮方式に
おけるDCT係数のラン及びレベルであり、MPEGの
可変長符号化されたDCT係数のラン、レベルを復号す
ることを特徴とする請求項6〜8のいずれかに記載の可
変長符号の復号方法。
9. The variable-length code and the fixed-length code in the variable-length code string to be decoded are a run and a level of a DCT coefficient in the MPEG image compression method, and a run of the MPEG variable-length coded DCT coefficient. The decoding method for a variable-length code according to any one of claims 6 to 8, wherein the level is decoded.
【請求項10】 復号時の状態Sにそれぞれ対応した複
数のテーブルを有し、各テーブルにおいて可変長符号列
からバイト単位で取り出したビット列Bにそれぞれ対応
した複数のレコードを設け、各レコードには、前記ビッ
ト列Bを復号した場合に得られるデータを示す復号デー
タ列Vと当該レコードを参照してから次に遷移する状態
を示す次の状態S′とを少なくとも格納したことを特徴
とする可変長符号の復号テーブル。
10. A plurality of tables each corresponding to a state S at the time of decoding, and a plurality of records respectively corresponding to a bit string B extracted from a variable length code string in byte units are provided in each table. Characterized in that at least a decoded data string V indicating data obtained when the bit string B is decoded and a next state S 'indicating a next transition state after referring to the record are stored. Code decoding table.
【請求項11】 復号対象の可変長符号列から取り出し
たNビット(Nは1以上の整数)のビット列Bのiビッ
ト目(i=1〜N)から復号する状態である複数の初期
状態SFiと、前回の復号の結果において復号できない
余りのビット列Rが生じた状態であって前記余りのビッ
ト列Rが取り得る複数の通常状態SNxとのそれぞれに
対応した複数のテーブルを持ち、 これらのテーブルは、Nビットの2進数で表現可能な個
数のレコードを持ち、Nビットのビット列bにより示さ
れるレコードには、前記初期状態SFiに対応したテー
ブルにおいては前記ビット列bをiビット目から復号し
て得られる復号データ列Vと次の余りのビット列rに対
応した次の状態S′とを格納し、前記通常状態SNxに
対応したテーブルにおいては前記余りのビット列Rと前
記ビット列bとを結合したビット列を復号して得られる
復号データ列Vと次の余りのビット列rに対応した次の
状態S′とを格納したことを特徴とする可変長符号の復
号テーブル。
11. A plurality of initial states SFi in which decoding is started from the i-th bit (i = 1 to N) of a bit string B of N bits (N is an integer of 1 or more) extracted from a variable-length code string to be decoded. And a plurality of tables respectively corresponding to a plurality of normal states SNx that can be taken by the surplus bit string R in a state where there is a surplus bit string R that cannot be decoded as a result of the previous decoding. , A record represented by an N-bit bit string b in the table corresponding to the initial state SFi, the bit string b is decoded from the i-th bit in a table corresponding to the initial state SFi. And the next state S 'corresponding to the next remaining bit string r, and the remaining state is stored in the table corresponding to the normal state SNx. A decoded data sequence V obtained by decoding a bit sequence obtained by combining the bit sequence R and the bit sequence b, and a next state S 'corresponding to the next remaining bit sequence r. Decryption table.
【請求項12】 復号対象の可変長符号列から取り出し
たNバイト(Nは1以上の整数)のビット列Bのiビッ
ト目(i=1〜N×8)から復号する状態である複数の
初期状態SFiと、前回の復号の結果において復号でき
ない余りのビット列Rが生じた状態であって前記余りの
ビット列Rが取り得る複数の通常状態SNxとのそれぞ
れに対応した複数のテーブルを持ち、 これらのテーブルは、N×8ビットの2進数で表現可能
な個数のレコードを持ち、N×8ビットのビット列bに
より示されるレコードには、前記初期状態SFiに対応
したテーブルにおいては前記ビット列bをiビット目か
ら復号して得られる復号データ列Vと次の余りのビット
列rに対応した次の状態S′とを格納し、前記通常状態
SNxに対応したテーブルにおいては前記余りのビット
列Rと前記ビット列bとを結合したビット列を復号して
得られる復号データ列Vと次の余りのビット列rに対応
した次の状態S′とを格納したことを特徴とする可変長
符号の復号テーブル。
12. A plurality of initial states in which decoding is performed from the i-th bit (i = 1 to N × 8) of a bit string B of N bytes (N is an integer of 1 or more) extracted from a variable-length code string to be decoded. It has a plurality of tables respectively corresponding to a state SFi and a plurality of normal states SNx in which there is a surplus bit string R that cannot be decoded as a result of the previous decoding and the surplus bit string R can take. The table has a number of records that can be represented by an N × 8-bit binary number, and a record indicated by an N × 8-bit bit string b includes i-bits in the table corresponding to the initial state SFi. In the table corresponding to the normal state SNx, a decoded data string V obtained by decoding from the eyes and a next state S ′ corresponding to the next remaining bit string r are stored. A variable length storing a decoded data string V obtained by decoding a bit string obtained by combining the remainder bit string R and the bit string b, and a next state S 'corresponding to the next remainder bit string r. Code decoding table.
【請求項13】 請求項10〜12のいずれかに記載の
復号テーブルを備えるとともに、 復号対象の可変長符号列を格納する可変長符号格納手段
と、 復号して得られたデータ列を格納する復号データ格納手
段と、 前記可変長符号格納手段に格納された可変長符号列から
所定のビット数又は所定のバイト単位でビット列を取り
出し、前記復号テーブルを参照して前記ビット列に対応
する復号を順次行い、得られた復号データを前記復号デ
ータ格納手段に格納する可変長符号復号手段とを備えた
ことを特徴とする可変長符号の復号装置。
13. A variable-length code storage unit for storing a variable-length code string to be decoded, comprising the decoding table according to claim 10 and storing a data string obtained by decoding. Decoding data storage means, extracting a bit string in a predetermined number of bits or a predetermined byte unit from the variable length code string stored in the variable length code storage means, and sequentially decoding the bit string with reference to the decoding table. And a variable-length code decoding means for storing the obtained decoded data in the decoded data storage means.
JP2000274892A 2000-09-11 2000-09-11 Method and device for decoding variable-length code, and decoding table Pending JP2002084198A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000274892A JP2002084198A (en) 2000-09-11 2000-09-11 Method and device for decoding variable-length code, and decoding table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000274892A JP2002084198A (en) 2000-09-11 2000-09-11 Method and device for decoding variable-length code, and decoding table

Publications (1)

Publication Number Publication Date
JP2002084198A true JP2002084198A (en) 2002-03-22

Family

ID=18760590

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000274892A Pending JP2002084198A (en) 2000-09-11 2000-09-11 Method and device for decoding variable-length code, and decoding table

Country Status (1)

Country Link
JP (1) JP2002084198A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100636370B1 (en) 2005-06-29 2006-10-19 한국전자통신연구원 Apparatus and method for coding using bit-precision, and apparatus and method for decoding according to the same
WO2008060040A1 (en) * 2006-11-17 2008-05-22 Humax Co., Ltd. Recorded medium having program for coding and decoding using bit-precision, and apparatus thereof
CN101873499A (en) * 2005-05-13 2010-10-27 高通股份有限公司 Method and apparatus for improved multimedia decoder

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101873499A (en) * 2005-05-13 2010-10-27 高通股份有限公司 Method and apparatus for improved multimedia decoder
JP2011109678A (en) * 2005-05-13 2011-06-02 Qualcomm Inc Method and apparatus for improved multimedia decoder
JP2013118656A (en) * 2005-05-13 2013-06-13 Qualcomm Inc Method and apparatus for improved multimedia decoder
KR100636370B1 (en) 2005-06-29 2006-10-19 한국전자통신연구원 Apparatus and method for coding using bit-precision, and apparatus and method for decoding according to the same
WO2008060040A1 (en) * 2006-11-17 2008-05-22 Humax Co., Ltd. Recorded medium having program for coding and decoding using bit-precision, and apparatus thereof
KR100858245B1 (en) 2006-11-17 2008-09-12 주식회사 휴맥스 Recorded medium having program for coding and decoding using bit-precision, and Apparatus there of
US8385405B2 (en) 2006-11-17 2013-02-26 Humax Co., Ltd. Recorded medium having program for coding and decoding using bit-precision, and apparatus thereof

Similar Documents

Publication Publication Date Title
US5999949A (en) Text file compression system utilizing word terminators
EP0593968B1 (en) Cache-based data compression/decompression
US5032838A (en) Variable length code parallel decoding apparatus and method
US5550542A (en) Variable length code look-up table having separate code length determination
US6445314B1 (en) System and method for the decoding of variable length codes
CN100417028C (en) Method of performing huffman decoding
US5587710A (en) Syntax based arithmetic coder and decoder
KR100486251B1 (en) Decoding apparatus for variable length code and method thereof
CN1139861A (en) Length changeable code and segment and device
US6304676B1 (en) Apparatus and method for successively refined competitive compression with redundant decompression
KR0163464B1 (en) Huffman code decoding circuit
JP2002500849A (en) Arithmetic encoding and decoding of information signals
JPH03503707A (en) A system for decoding statistically encoded digital data
EP0658982B1 (en) System for bi-level symbol coding-decoding with saved storage and method for the same
US5615020A (en) System and method for fast huffman decoding
JP3080149B2 (en) Pattern encoding method and decoding method, and encoding apparatus and decoding apparatus using the method
JP2002084198A (en) Method and device for decoding variable-length code, and decoding table
US7362909B2 (en) Coding device and method and decoding device and method
JPH07107303A (en) Decoding method for huffman code
JP2715871B2 (en) Variable length coding method
JP4120980B2 (en) Encoding apparatus and method, and decoding apparatus and method
CN1299561A (en) Method for encoding image information and method for decoding
JP3332630B2 (en) Decoding device and decoding table generation method
JP3167305B2 (en) Automatic creation of decoding table for variable length code
JP2000341134A (en) Decoder for variable length code

Legal Events

Date Code Title Description
RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20060324