JP2007324971A - Encoder, encoding method, and program - Google Patents
Encoder, encoding method, and program Download PDFInfo
- Publication number
- JP2007324971A JP2007324971A JP2006153232A JP2006153232A JP2007324971A JP 2007324971 A JP2007324971 A JP 2007324971A JP 2006153232 A JP2006153232 A JP 2006153232A JP 2006153232 A JP2006153232 A JP 2006153232A JP 2007324971 A JP2007324971 A JP 2007324971A
- Authority
- JP
- Japan
- Prior art keywords
- code
- encoding
- variable
- unit
- data file
- 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
Links
Images
Abstract
Description
本発明は、データファイルを符号化する符号化方法に関する。 The present invention relates to an encoding method for encoding a data file.
例えば、特許文献1には、求める限定色の色数を指定して、カラー画像の色分布より目的の数の限定色を抽出し、カラー画像より各限定色に割り当てられる画素数の頻度分布を計数し、頻度分布を使って生起確率を求め限定色の各々にハフマン符号を割り当て、画素ごとに、画素の限定色が隣接画素の限定色と同一であれば位置関係の符号を、それ以外は限定色の符号を割り当て、圧縮データとして保存し、最後に圧縮データの付加情報の保存処理を行う方法が開示されている。
本発明は、上述した背景からなされたものであり、より効率的な符号化処理を実現する符号化装置を提供することを目的とする。 The present invention has been made from the above-described background, and an object thereof is to provide an encoding device that realizes more efficient encoding processing.
[符号化装置]
上記目的を達成するために、本発明にかかる符号化装置は、未処理のデータに依存しないエントロピー符号化方式を用いて、入力されたデータファイルを符号化し、中間符号を生成する第1の符号生成手段と、前記第1の符号生成手段により生成された中間符号に基づいて、入力されたデータファイルの出力符号を生成する第2の符号生成手段とを有する。
[Encoding device]
In order to achieve the above object, an encoding apparatus according to the present invention encodes an input data file using an entropy encoding method that does not depend on unprocessed data, and generates an intermediate code. Generating means and second code generating means for generating an output code of the input data file based on the intermediate code generated by the first code generating means.
好適には、前記第2の符号生成手段は、未処理のデータに依存する符号化方式を用いて、前記出力符号を生成する。 Preferably, the second code generation means generates the output code using an encoding method depending on unprocessed data.
好適には、前記第2の符号生成手段は、データファイル全体に対する統計処理に基づいて、前記出力符号を生成する。 Preferably, the second code generation means generates the output code based on statistical processing for the entire data file.
好適には、前記第1の符号生成手段による符号化処理の少なくとも一部と並行して、前記統計処理を行う統計処理手段をさらに有し、前記第2の符号生成手段は、前記統計処理手段による統計処理の結果に基づいて、前記出力符号を生成する。 Preferably, it further includes statistical processing means for performing the statistical processing in parallel with at least a part of the encoding processing by the first code generating means, and the second code generating means includes the statistical processing means. The output code is generated based on the result of the statistical processing according to the above.
好適には、前記第1の符号生成手段は、前記第2の符号生成手段よりも大きなデータ単位で、符号化処理を行う。 Preferably, the first code generation unit performs an encoding process in a larger data unit than the second code generation unit.
好適には、前記第1の符号生成手段は、予め設計された固定符号表を用いて、入力されたデータファイルを符号化し、前記第2の符号生成手段は、入力されたデータファイルそれぞれに応じて設計される可変符号表を用いて、前記出力符号を生成する。 Preferably, the first code generation means encodes the input data file using a pre-designed fixed code table, and the second code generation means responds to each of the input data files. The output code is generated using a variable code table designed in this way.
好適には、前記第1の符号生成手段により生成された中間符号を記憶する記憶手段をさらに有し、前記第2の符号生成手段は、前記記憶手段に記憶された中間符号を符号化して、前記出力符号を生成する。 Preferably, the apparatus further comprises storage means for storing the intermediate code generated by the first code generation means, and the second code generation means encodes the intermediate code stored in the storage means, The output code is generated.
[符号化方法]
また、本発明にかかる符号化方法は、未処理のデータに依存しないエントロピー符号化方式を用いて、入力されたデータファイルを符号化し、中間符号を生成し、生成された前記中間符号に基づいて、入力されたデータファイルの出力符号を生成する。
[Encoding method]
In addition, the encoding method according to the present invention encodes an input data file using an entropy encoding method that does not depend on unprocessed data, generates an intermediate code, and based on the generated intermediate code The output code of the input data file is generated.
[プログラム]
また、本発明にかかるプログラムは、未処理のデータに依存しないエントロピー符号化方式を用いて、入力されたデータファイルを符号化し、中間符号を生成するステップと、生成された前記中間符号に基づいて、入力されたデータファイルの出力符号を生成するステップとをコンピュータに実行させる。
[program]
In addition, the program according to the present invention encodes an input data file using an entropy encoding method that does not depend on unprocessed data, generates an intermediate code, and based on the generated intermediate code And causing the computer to generate an output code of the input data file.
本発明の符号化装置によれば、より効率的な符号化処理を実現することができる。 According to the encoding apparatus of the present invention, more efficient encoding processing can be realized.
まず、本発明の理解を助けるために、その背景及び概略を説明する。
ハフマン符号は、実現構成が簡単なので、広く使われている符号化方式である。本来は、入力されたデータファイル毎に、各入力シンボルの出現頻度分布を求め、その分布に応じた符号表(可変符号表)を設計する(以下、これを可変的ハフマン符号という)。
しかし、国際標準JPEGをはじめ、一般によく使われているハフマン符号では、事前に想定された出現頻度分布に対して設計した符号表(固定符号表)を、固定的に適用することが多い(以下、これを固定的ハフマン符号という)。
First, in order to help understanding of the present invention, its background and outline will be described.
The Huffman code is a widely used coding method because of its simple implementation configuration. Originally, an appearance frequency distribution of each input symbol is obtained for each input data file, and a code table (variable code table) corresponding to the distribution is designed (hereinafter referred to as a variable Huffman code).
However, in Huffman codes that are commonly used, including the international standard JPEG, a code table (fixed code table) designed for the frequency distribution assumed in advance is often applied fixedly (below) This is called the fixed Huffman code).
画像圧縮にハフマン符号を適用する場合には、前段でソースコーディングと呼ぶ変換処理をかけて、符号化対象となるシンボルを生成する。このとき後段の符号化処理が固定的ハフマン符号を適用すると、ソースコーダの出力(シンボル)が想定出現頻度に合わない場合に圧縮率が低下する。
そのため、例えば、CG画像に対しては効率的であるが、写真画像に対しては比較的効率が悪い、といった偏ったソースコーダは使いづらいという問題があった。
一方、可変的ハフマン符号化処理では、1パス目でシンボルの統計をとり、2パス目で符号化するため、処理速度が固定的ハフマン符号を適用する場合よりも遅い。また、可変的ハフマン符号を適用する場合には、2パス処理のためには入力データを丸ごとバッファリングすることが必要となり、処理時間とメモリコストがネックになる。
When the Huffman code is applied to image compression, a conversion process called source coding is performed in the previous stage to generate a symbol to be encoded. At this time, if the encoding process in the subsequent stage applies a fixed Huffman code, the compression rate decreases when the output (symbol) of the source coder does not match the expected appearance frequency.
Therefore, for example, there is a problem that it is difficult to use a biased source coder that is efficient for a CG image but relatively inefficient for a photographic image.
On the other hand, in the variable Huffman coding process, since the statistics of the symbols are taken in the first pass and coding is done in the second pass, the processing speed is slower than the case where the fixed Huffman code is applied. In addition, when the variable Huffman code is applied, it is necessary to buffer the entire input data for the two-pass processing, and processing time and memory cost become a bottleneck.
図1は、可変的ハフマン符号を適用する符号化プログラム9の機能構成を例示する図である。
可変的ハフマン符号化の処理を遅くする原因のひとつは、バッファリング処理にある。特に画像圧縮に可変的ハフマン符号を適用する場合、ソースコーダ900によるソースコーディングをかけてシンボルを生成することが多いが、画像とは別にこのシンボルをシンボルバッファ910に記憶しておく必要がある。
例えば、予測符号化方式のソースコーディングを行い場合、ソースコーダ900は、入力された画像データの画素値を予測誤差値に変換し、この予測誤差値をシンボルとする。この予測誤差値は、符号表が作成されるまでの間、シンボルバッファ910にバッファリングされる。すなわち、シンボル計数部920は、ソースコーダ900から出力されるシンボルを計数し、符号表生成部930は、シンボル計数部920による計数結果(出現頻度)に基づいて可変符号表を生成し、ハフマン符号化部940は、符号表生成部930により符号表が生成されたことを条件として、シンボルバッファ910からシンボルを読み出し、読み出されたシンボルを符号化していく。
バッファリングされる予測誤差値は、画素数分だけあるので、シンボルバッファ910は画像1ページ分のメモリを要し、このメモリの書込み及び読出しも1ページ分丸ごと必要になる。特に、予測符号化の場合、ソースコーダ900の処理は軽く、並列化も比較的容易なので、バッファリングの相対的処理負荷が高くなる。
FIG. 1 is a diagram illustrating a functional configuration of an encoding program 9 to which a variable Huffman code is applied.
One of the causes for delaying the variable Huffman coding process is the buffering process. In particular, when a variable Huffman code is applied to image compression, symbols are often generated by performing source coding by the
For example, when performing source coding using a predictive coding method, the
Since there are as many prediction error values as the number of pixels to be buffered, the
そこで、本実施形態における符号化装置2は、バッファリングの負荷を削減するために、入力されたデータファイルに依存しない固定的符号化処理(例えば、固定的ハフマン符号化処理)と、入力されたデータファイルに依存する可変的符号化処理(例えば、入力画像に適応した可変的ハフマン符号化処理)とを直列に組み合わせる。このうち固定的符号化処理は、バッファリング処理の前段で実行することにより、バッファリングすべきデータのデータサイズを小さくして、バッファリングの負荷を削減する。そして、バッファリングされたシンボル(固定的符号化処理で符号化された符号)に対しては、可変的符号化処理を追加的に行うことにより、可変的符号化処理と同様の圧縮率を実現する。なお、以下の説明では、固定的符号化処理で符号化された符号(バッファリングされる符号)を中間符号という。
Therefore, in order to reduce the buffering load, the
なお、固定的符号化処理は以下の条件を満たすことが望ましい。
[条件1]
データファイル(本例では画像データ)の大局的性質によらない処理であること。より具体的には、少なくとも、未処理のデータ(符号化されていない部分データ)に依存しない符号化処理であること。換言すると、1パスで処理できるような局所的性質の限度で、他のデータに依存関係を有する符号化処理であること。
[条件2]
可変的符号化処理と比較して、比較的高速であること。
[条件3]
固定的符号化処理と可変的符号化処理とを組み合わせることによるオーバーヘッドが少ないこと。
The fixed encoding process preferably satisfies the following conditions.
[Condition 1]
Processing that does not depend on the global nature of the data file (image data in this example). More specifically, it is an encoding process that does not depend on at least unprocessed data (unencoded partial data). In other words, it is an encoding process having a dependency relationship with other data within the limit of local properties that can be processed in one pass.
[Condition 2]
It must be relatively fast compared to variable encoding.
[Condition 3]
Less overhead due to combining fixed encoding processing and variable encoding processing.
例えば、条件1に関して、可変的ハフマン符号の生成に必要なページ全体の統計処理は大局的性質である。逆に、コンテクストモデリングは後続のデータ(すなわち、未処理のデータ)に依存しないため局所的性質である。
条件2に関して、バッファリングの負荷削減という目的から要請されるものであり、可変的符号化処理は、ビットシフトなどの処理で重くならざるを得ないので、固定的符号化処理は、軽いほうが望ましい。ただし、固定的符号化処理と可変的符号化処理の負荷の和が、もとのエントロピー符号化の処理負荷と同程度であれば、多少固定的符号化処理がバランス的に重くなっても構わない。
条件3に関して、処理単位を揃えることなどがこの条件を満たす手段として考えられる。例えば、可変的符号化処理で可変的ハフマン符号を適用するのに、固定的符号化処理で算術符号を適用する場合に、可変的符号化処理の前に算術符号化の復号化処理が必要となり、オーバーヘッドが大きくなりすぎる。
上記条件を満たす固定的符号化処理及び可変的符号化処理を組み合わせることにより、バッファリングすべきデータ量が削減できるので、バッファリングの処理時間が減り、メモリサイズも統計的に削減することができるようになる。
For example, regarding the
As for
By combining fixed encoding processing and variable encoding processing satisfying the above conditions, the amount of data to be buffered can be reduced, so the buffering processing time can be reduced and the memory size can also be reduced statistically. It becomes like this.
[ハードウェア構成]
まず、本実施形態における符号化装置2のハードウェア構成を説明する。
図2は、本発明にかかる符号化方法が適応される符号化装置2のハードウェア構成を、制御装置20を中心に例示する図である。
図2に例示するように、符号化装置2は、CPU202及びメモリ204などを含む制御装置20、通信装置22、HDD・CD装置などの記録装置24、並びに、LCD表示装置あるいはCRT表示装置及びキーボード・タッチパネルなどを含むユーザインターフェース装置(UI装置)26から構成される。
符号化装置2は、例えば、プリンタ装置10に設けられた処理装置であり、通信装置22又は記録装置24などを介して画像データを取得し、取得された画像データを符号化する。
[Hardware configuration]
First, the hardware configuration of the
FIG. 2 is a diagram illustrating a hardware configuration of the
As illustrated in FIG. 2, the
The
[符号化プログラム]
図3は、制御装置20(図2)により実行され、本発明にかかる符号化方法を実現する符号化プログラム5の機能構成を例示する図である。
図3に例示するように、符号化プログラム5は、ソースコーダ500、第1符号部510、シンボル計数部520、中間符号記憶部530、符号表生成部540、及び第2符号部550を有する。
符号化プログラム5は、例えば、図2に例示した記録媒体240に記録され、この記録媒体240を介して、制御装置20(図2)に供給される。
なお、本例では、画像データを符号化する場合を具体例として説明する。
[Encoding program]
FIG. 3 is a diagram illustrating a functional configuration of the encoding program 5 which is executed by the control device 20 (FIG. 2) and implements the encoding method according to the present invention.
As illustrated in FIG. 3, the encoding program 5 includes a
The encoding program 5 is recorded on, for example, the
In this example, a case where image data is encoded will be described as a specific example.
符号化プログラム5において、ソースコーダ500は、入力されたデータファイルに基づいて、エントロピー符号化処理の対象となるシンボルを生成し、生成されたシンボルを第1符号部510及びシンボル計数部520に出力する。
本例のソースコーダ500は、既定の予測方法を用いて注目画素の画素値を予測し、この予測値と注目画素値との差分値(以下、予測誤差値)を算出し、算出された予測誤差値をシンボルとする。なお、本例のソースコーダ500は、算出された予測誤差値が0である場合(すなわち、予測が的中した場合)には、予測的中の連続数(ラン)を計数し、計数された連続数(予測誤差値が連続して0となる回数)をシンボルとする。
In the encoding program 5, the
The source coder 500 in this example predicts the pixel value of the target pixel using a predetermined prediction method, calculates a difference value between the predicted value and the target pixel value (hereinafter, prediction error value), and calculates the calculated prediction. The error value is a symbol. Note that the
第1符号部510は、ソースコーダ500から入力されたシンボルを、未処理のデータに依存しないエントロピー符号化方式(例えば、予め設計された固定符号表を用いた符号化方式)を用いて符号化し、生成された符号(すなわち、中間符号)を中間符号記憶部530に出力する。
本例の第1符号部510は、ソースコーダ500から入力されたシンボルを、固定的ハフマン符号で符号化して、中間符号を生成する。
The
The
シンボル計数部520は、ソースコーダ500から入力されたシンボルを計数し、計数結果に基づいて既定の統計処理を行い、統計処理の結果を符号表生成部540に出力する。シンボル計数部520は、本発明にかかる統計処理手段の一例であり、符号表生成に要する統計処理を行う。
本例のシンボル計数部520は、ソースコーダ500から入力される全シンボルの出現頻度を計数して、各シンボル値の出現頻度分布を生成する。
The
The
中間符号記憶部530は、第1符号部510から入力された中間符号をメモリに記憶し、記憶された中間符号を第2符号部550に供給する。
本例の中間符号記憶部530は、少なくとも、符号表生成部540により可変的ハフマン符号の符号表が生成されるまでの間、第1符号部510により符号化された中間符号をバッファリングし、第2符号部550が可変的符号化処理を実行可能になったことを条件として、バッファリングしている中間符号を第2符号部550に出力する。
The intermediate
The intermediate
符号表生成部540は、シンボル計数部520による統計処理の結果に基づいて、可変的符号化処理に用いる符号表を生成し、生成された符号表を第2符号部550に出力する。符号表生成部540により生成される符号表は、入力されるデータファイルそれぞれに応じて設計されるものであり、可変符号表とよぶ。
本例の符号表生成部540は、各シンボルの出現頻度分布に応じて、可変的ハフマン符号の符号表を生成する。
The code
The code
第2符号部550は、符号表生成部540から入力された可変符号表と、中間符号記憶部550に記憶されている中間符号とに基づいて、入力されたデータファイルの出力符号を生成する。
本例の第2符号部550は、符号表生成部540から入力された可変的ハフマン符号の符号表を用いて、中間符号記憶部530にバッファリングされている中間符号を順に符号化して、出力符号を生成する。
The
The
図4は、ソースコーダ500(図3)によるソースコーディングを説明する図である。
図4(A)に例示するように、ソースコーダ500は、注目画素Xのシンボルを生成する場合に、走査方向上流の画素A〜Cのいずれか(すなわち、既処理の画素)を参照して、予測誤差値を算出する。
例えば、ソースコーダ500は、図4(B)に例示する(式1)を用いて、予測誤差(シンボル)を算出する。すなわち、注目画素Xの画素値と、主走査方向直前の画素Aの画素値との差分値が、予測誤差値(シンボル)となる。
また、ソースコーダ500は、図4(B)に例示する(式2)を用いて、予測誤差(シンボル)を算出してもよい。この場合、画素A及び画素B(副走査方向直上画素)の画素値の合算値から画素Cの画素値をひいた値が予測値となり、この予測値と注目画素Xの画素値との差分がシンボルとなる。
また、ソースコーダ500は、図4(B)に例示する(式3)を用いて、予測誤差を算出してもよい。この場合、画素A及び画素Bの平均画素値が予測値となり、この予測値と注目画素Xの画素値との差分がシンボルとなる。
FIG. 4 is a diagram for explaining source coding by the source coder 500 (FIG. 3).
As illustrated in FIG. 4A, when generating the symbol of the target pixel X, the
For example, the
Further, the
Further, the
さらに、ソースコーダ500は、予測誤差が0となる場合に、その連続数(ラン)を計数し、連続数(ラン)をシンボルとする。これにより、図4(C)に例示するように、予測が的中した画素群については、予測的中の連続数(ラン)がシンボルとなり、予測が外れた画素群については、予測誤差値がシンボルとなる。
画像データをソースコーディングした場合、予測誤差値の出現頻度分布が0の近傍に偏ることが期待できる。
Furthermore, when the prediction error becomes 0, the
When image data is source-coded, it can be expected that the appearance frequency distribution of prediction error values is biased to be close to zero.
図5(A)は、第1符号部510(図3)による固定的ハフマン符号を例示し、図5(B)は、中間符号記憶部530(図3)に記憶される中間符号のフォーマットを例示する図である。
本例の第1符号部510は、図5(A)に例示する固定符号表512を用いて、シンボルを符号化する。
すなわち、シンボルが連続数(ラン)である場合に、識別子「00」と8ビット表現された連続数とを組み合わせたビット列が、中間符号となる。本例では、連続数を8ビットで表現するため、最大ラン長256でランが分割される。
シンボルが−8から7までの間の予測誤差値である場合に、識別子「01」と4ビット表現された予測誤差値(すなわち、予測誤差値の下位4ビット)とを組み合わせたビット列が、中間符号となる。
シンボルが−8よりも小さい予測誤差値又は7よりも大きな予測誤差値である場合に、識別子「10」と8ビット表現された予測誤差値とを組み合わせたビット列が、中間符号となる。
この中間符号は、非常に単純だが、−8から7の予測誤差値の出現確率が高いことを想定した固定的ハフマン符号である。
5A illustrates the fixed Huffman code by the first encoding unit 510 (FIG. 3), and FIG. 5B illustrates the format of the intermediate code stored in the intermediate code storage unit 530 (FIG. 3). It is a figure illustrated.
The
That is, when a symbol is a continuous number (run), a bit string combining an identifier “00” and a continuous number expressed in 8 bits is an intermediate code. In this example, since the continuous number is expressed by 8 bits, the run is divided by the maximum run length 256.
When the symbol is a prediction error value between −8 and 7, a bit string obtained by combining the identifier “01” and the prediction error value represented by 4 bits (that is, the lower 4 bits of the prediction error value) is intermediate. Sign.
When the symbol is a prediction error value smaller than −8 or a prediction error value larger than 7, a bit string obtained by combining the identifier “10” and the prediction error value expressed in 8 bits is an intermediate code.
Although this intermediate code is very simple, it is a fixed Huffman code that assumes a high probability of occurrence of prediction error values from -8 to 7.
この固定符号表512は、予め設計されたものであり、入力される画像データに依存しないため、上記条件1を満たす。なお、本例の固定符号表512は、符号量を最小化するものではないが、バッファリングすべきデータ量が減少すれば十分であり、必ずしも符号量を最小化する必要はないので、目的に適っている。
また、本例の第2符号部550は、可変ハフマン符号を適用し、この固定符号表512は、予測誤差値が0付近に多くなるという特性に基づいて予め設計された固定ハフマン符号であり、共にハフマン符号であるから、上記条件3を満たす。
The fixed code table 512 is designed in advance and does not depend on input image data, and therefore satisfies the
Further, the
本例の中間符号記憶部530は、上記条件2を満たすために中間符号を4ビット単位で管理する。すなわち、本例の中間符号記憶部530は、図5(B)に例示するバッファリング符号フォーマット514を用いて、中間符号をバッファリングする。
具体的には、図5(A)に例示する中間符号は、識別子(2ビット)と属性値(4ビット又は8ビット)とからなるので、そのままでは4ビット単位で管理できない。そこで、本例の中間符号記憶部530は、4つの中間符号を1つのフォーマットに統合する。すなわち、中間符号記憶部530は、図5(B)に例示するように、4つの中間符号の識別子(#0〜#3)をまとめ、4つの中間符号の属性値(#0〜#3)をまとめることにより、4ビット単位での管理を実現する。
これにより、過度なビットシフト処理が避けられ、上記条件2が満たしやすくなる。
The intermediate
Specifically, since the intermediate code illustrated in FIG. 5A includes an identifier (2 bits) and an attribute value (4 bits or 8 bits), it cannot be managed in units of 4 bits. Therefore, the intermediate
As a result, excessive bit shift processing is avoided and the
[全体動作]
次に、符号化装置2(符号化プログラム5)の全体動作を説明する。
図6は、符号化プログラム5(図3)による符号化処理(S10)のフローチャートである。
図6に示すように、ステップ100(S100)において、符号化プログラム5(図3)は、外部から、画像データが入力されると、入力された画像データにおいて走査順に注目画素Xを設定する。注目画素とは、処理対象となる画素である。
ソースコーダ500(図3)は、注目画素Xの画素値と画素A(図4)の画素値との差分を算出し、算出された差分値(予測誤差値)に基づいてシンボルを生成する。
符号化プログラム5は、注目画素Xの位置を走査順に移動させて、全画素についてシンボルを生成する。生成されたシンボルは、第1符号部510及びシンボル計数部520に出力される。
[Overall operation]
Next, the overall operation of the encoding device 2 (encoding program 5) will be described.
FIG. 6 is a flowchart of the encoding process (S10) by the encoding program 5 (FIG. 3).
As shown in FIG. 6, in step 100 (S100), when image data is input from the outside, the encoding program 5 (FIG. 3) sets a target pixel X in the input image data in the scanning order. A target pixel is a pixel to be processed.
The source coder 500 (FIG. 3) calculates the difference between the pixel value of the target pixel X and the pixel value of the pixel A (FIG. 4), and generates a symbol based on the calculated difference value (prediction error value).
The encoding program 5 moves the position of the target pixel X in the scanning order to generate symbols for all the pixels. The generated symbols are output to the
ステップ110(S110)において、符号化プログラム5は、生成されたシンボル群の中から、順に注目シンボル(すなわち、符号化対象となるシンボル)を設定する。 In step 110 (S110), the encoding program 5 sets attention symbols (that is, symbols to be encoded) in order from the generated symbol group.
ステップ120(S120)において、第1符号部510は、図5(A)の固定符号表512を用いて、注目シンボルを符号化する。
In step 120 (S120), the
ステップ130(S130)において、中間符号記憶部530は、第1符号部510により符号化された注目シンボル(すなわち、中間符号)を、図5(B)のバッファリング符号フォーマット514に従ってバッファリングする。
In step 130 (S130), the intermediate
ステップ140(S140)において、シンボル計数部520は、第1符号部510の符号化処理(S120)と並行して、ソースコーダ500により生成されるシンボルを計数して、各シンボル値の出現頻度分布を生成する。
In step 140 (S140), the
ステップ150(S150)において、符号化プログラム5は、全シンボルが処理されたか否かを判断し、全シンボルが処理された場合に、S160の処理に移行し、未処理のシンボルが存在する場合に、S110の処理に戻る。 In step 150 (S150), the encoding program 5 determines whether or not all symbols have been processed. If all symbols have been processed, the process proceeds to S160, and there is an unprocessed symbol. , The process returns to S110.
ステップ160(S160)において、符号表生成部540は、シンボル計数部520により生成されたシンボル値の出現頻度分布に応じて、可変ハフマン符号の符号表(可変符号表)を生成し、生成された可変符号表を第2符号部550に出力する。
In step 160 (S160), the code
ステップ170(S170)において、第2符号部550は、中間符号記憶部530によりバッファリングされている中間符号の属性値を、符号表生成部540により生成された可変符号表を用いて符号化し、符号化された属性値を出力符号とする。
In Step 170 (S170), the
以上説明したように、本実施形態における符号化装置2は、固定的符号化処理と可変的符号化処理とを直列に組み合わせることにより、シンボルのバッファリングに要する負荷を軽減することができる。これにより、高速なエントロピー符号化処理が実現される。
As described above, the
[変形例1]
次に、上記実施形態の変形例1を説明する。
上記実施形態では、第1符号部510及び第2符号部550は、同じ最大ラン長を適用して、ランを符号化しているが、これに限定されるものではない。すなわち、第1符号部510による符号化処理と、第2符号化部550による符号化処理とが、多少相違してもよい。
例えば、固定的符号化処理(すなわち、第1符号部510による符号化処理)で適用される最大ラン長は、可変的符号化処理(すなわち、第2符号部550による符号化処理)で適用される最大ラン長と異なってもよい。
ランレングス化では、最大ラン長をいくつにするかがパラメータとなる。上記実施形態では、可変的ハフマン符号を適用する関係上、シンボル計数部520は、可変的処理での最大ラン長Rに合わせて、ラン長1〜ラン長Rの出現頻度を計数する必要がある。したがって、固定的符号化処理で最大ラン長Rのランレングス化をすることは合理的である。
しかし、固定的符号化処理で最大ラン長をもっと大きくとってもよいケースが存在する。例えば、予測誤差値0のランが、長く続くような画像データを対象とする場合である。そのような場合には、固定的符号化処理における最大ラン長をなるべく長くとることで、バッファリングするデータ量を減らすことができる。
このとき、第2符号部550は、長いランを最大ラン長R単位に切り離す必要があり、これがオーバーヘッドとなる。したがって、そのオーバーヘッドと上記の効果が引き合うようであれば、ラン長を長くとってもよい。このとき固定的符号化処理で適用する最大ラン長が、可変的符号化処理で適用する最大ラン長の倍数になっていると、可変的処理が簡略化できるため好ましい。
[Modification 1]
Next, the
In the above embodiment, the
For example, the maximum run length applied in the fixed encoding process (that is, the encoding process by the first encoding unit 510) is applied in the variable encoding process (that is, the encoding process by the second encoding unit 550). It may be different from the maximum run length.
In run length conversion, the maximum run length is a parameter. In the embodiment described above, the
However, there is a case where the maximum run length may be increased by fixed encoding processing. For example, this is a case where image data whose prediction error value is 0 continues for a long time. In such a case, the data amount to be buffered can be reduced by setting the maximum run length in the fixed encoding process as long as possible.
At this time, the
図7は、固定的符号化処理で最大ラン長256を適用し、可変的符号化処理で32の最大ラン長32を適用する場合の処理を説明する図である。
例えば、図7(A)に例示する300のランが第1符号部510に入力されると、第1符号部510は、図7(B)に例示するように、300のランを256のランと44のランに分割し、それぞれをシンボルとして符号化する。
そして、第2符号部550は、256のランを8分割して32のランを生成し、44のランを32のランと12のランに分割して、分割された各ランをそれぞれシンボルとして符号化する。この場合に、符号表生成部540は、ラン1からラン32までの出現頻度分布に応じて符号表を生成し、第2符号部550は、この符号表を用いて、ランを可変ハフマン符号で符号化する。
FIG. 7 is a diagram for explaining processing when the maximum run length 256 is applied in the fixed encoding process and the
For example, when 300 runs illustrated in FIG. 7A are input to the
Then, the
[変形例2]
次に、上記実施形態の変形例2を説明する。
上記実施形態では、第1符号部510及び第2符号部550は、同じデータ単位(シンボル単位)で符号化処理を行っているが、これに限定されるものではなく、例えば、第1の符号部510の処理単位(データ単位)は、第2の符号部550の処理単位(データ単位)よりも大きくてもよい。
そこで、変形例2では、第1符号部510は、複数の画素からなるブロックを処理単位として符号化し、第2符号部550は、1画素を処理単位として符号化する形態を説明する。すなわち、上記実施形態では、固定的符号化処理で識別子を画素ごとに付与するため、例えば全白の画像でも2ビット/画素が必要となる。また画素単位の識別子は、画素単位での処理切替えを意味するため、固定的符号化処理及び可変的符号化処理で分岐処理を多発させ処理速度を低下させる可能性がある。
そこで、本変形例2の第1符号部510は、複数画素を集めたブロック単位に識別子を付与する。近年のCPU(中央演算装置)は、幅の広いレジスタを分割して並列処理を行うことができるので、そのような手法の適用が可能なソースコーダとのマッチングもよい。
[Modification 2]
Next, a second modification of the above embodiment will be described.
In the above embodiment, the
In the second modification, the
Therefore, the
図8(A)は、ブロック単位で符号化する場合の固定符号表513を例示し、図8(B)及び(C)は、ブロック単位で生成された中間符号を符号化するときに適用される可変符号表を例示する図である。なお、本変形例では、32画素を1ブロックとする形態を具体例とする。
本変形例の第1符号部510は、ブロック内の画素に対応する全シンボルがランである場合、識別子「00」とラン長(本例では、32)とのセットを、このブロックの中間符号とする。
また、第1符号部510は、ブロック内の画素に対応する全シンボルが−8から7までの予測誤差値である場合に、識別子「01」と、ブロック内の全予測誤差値(4ビット表現)とのセットを、このブロックの中間符号とする。この中間符号に含まれる予測誤差値(4ビット)の中には、予測誤差値0(4ビット表現)も含まれうる。
また、第1符号部510は、ブロック内の画素に対応するシンボルのいずれかが−8よりも小さい予測誤差値又は7よりも大きな予測誤差値である場合に、識別子「10」と、このブロック内の全予測誤差値(8ビット表現)とのセットを、このブロックの中間符号とする。この中間符号に含まれる予測誤差値(8ビット表現)の中には、−8から7までの予測誤差値(8ビット表現)も含まれうる。
FIG. 8A illustrates a fixed code table 513 in the case of encoding in block units, and FIGS. 8B and 8C are applied when encoding an intermediate code generated in block units. It is a figure which illustrates the variable code table. In addition, in this modification, the form which makes 32
When all symbols corresponding to the pixels in the block are runs, the
In addition, when all symbols corresponding to the pixels in the block have prediction error values from −8 to 7, the
Further, the
次に、可変的符号化処理に用いる符号表であるが、上記のように、予測誤差値0は、ラン表現、4ビット表現、及び8ビット表現の3種類で表現される可能性があり、−8〜7の予測誤差値(0を除く)は、4ビット表現及び8ビット表現の2種類で表現される可能性がある。
そこで、本変形例の符号表生成部540は、図8(B)に例示するように、−8から7までの予測誤差値をシンボルとして含む8ビット入力可変符号表552と、予測誤差値0をシンボルとして含む4ビット入力可変符号表554とを生成する。8ビット入力可変符号表552では、−8から7までの予測誤差値(0も含む)が8ビットのシンボルとして表現されており、4ビット入力可変符号表554は、予測誤差値0も4ビットのシンボルとして表現されている。
この8ビット入力可変符号表552及び4ビット入力可変符号表554は、それぞれ8ビットシンボル又は4ビットシンボルをエントリとするルックアップテーブルである。例えば、8ビット入力可変符号表552として、256個のシンボルに対して256エントリのルックアップテーブルを用意し、4ビット入力可変符号表554として、16エントリのルックアップテーブルを用意すればよい。このように本変形例では2つのルックアップテーブルが必要になるが、4ビット入力可変符号表554のエントリ数が小さいため、影響は小さい。
Next, it is a code table used for variable encoding processing. As described above, the
Therefore, as illustrated in FIG. 8B, the code
The 8-bit input variable code table 552 and the 4-bit input variable code table 554 are look-up tables having 8-bit symbols or 4-bit symbols as entries, respectively. For example, a 256-entry lookup table may be prepared for 256 symbols as the 8-bit input variable code table 552, and a 16-entry lookup table may be prepared as the 4-bit input variable code table 554. As described above, in this modification, two lookup tables are required, but the influence is small because the number of entries in the 4-bit input variable code table 554 is small.
なお、固定的符号化処理では、ブロック単位で識別子が付与され、属性値は画素単位である。すなわち、1ブロックの属性値の中に32画素の属性値が含まれている。
したがって、処理単位はブロックであってもデータの粒度は画素単位であって、このため可変的符号化処理との処理単位のミスマッチは生じない。
In the fixed encoding process, identifiers are assigned in units of blocks, and attribute values are in units of pixels. That is, an attribute value of 32 pixels is included in one block attribute value.
Therefore, even if the processing unit is a block, the data granularity is a pixel unit, and therefore, there is no mismatch between the processing unit and the variable encoding process.
[その他の変形例]
また、符号化装置2は、複数のシンボルをエントリとする可変符号表を生成し、この可変符号表を用いて可変的符号化処理を行うことにより、符号化処理を高速化してもよい。
図9は、2シンボルをエントリとする2シンボル可変符号表556を例示する図である。
第2符号部550は、図9に例示する2シンボル可変符号表556を用いて、2シンボルを同時に符号化することにより、符号化処理の高速化を図れる。本例の2シンボル可変符号表556は、−8から7までの予測誤差値(シンボル値0〜15)をエントリとしている。画像データを対象とする場合に、シンボル(予測誤差値)は0近辺に集中する、つまり出現頻度が高いので、このような高速化は効果的である。
[Other variations]
The
FIG. 9 is a diagram illustrating a 2-symbol variable code table 556 having 2 symbols as entries.
The
[実験結果]
図10は、実験結果のグラフである。なお、本図におけるグラフの横軸は、符号化処理に要した時間(処理時間)であり、縦軸は、符号量である。
図10に示すように、固定的ハフマン符号のみを適用した場合には、処理時間が短いが、符号量が大きくなってしまう。一方、可変的ハフマン符号のみを適用した場合には、符号量を小さくすることができるが、処理時間が長くなってしまう。
上記変形例2のように、ブロック単位で固定的ハフマン符号化処理を行い、中間符号を可変的ハフマン符号化すると、比較的短い処理時間で、高い圧縮率を実現することができる。
[Experimental result]
FIG. 10 is a graph of experimental results. The horizontal axis of the graph in this figure is the time (processing time) required for the encoding process, and the vertical axis is the code amount.
As shown in FIG. 10, when only the fixed Huffman code is applied, the processing time is short, but the code amount becomes large. On the other hand, when only the variable Huffman code is applied, the code amount can be reduced, but the processing time becomes longer.
When the fixed Huffman coding process is performed in units of blocks and the intermediate code is variable Huffman coded as in the second modification, a high compression rate can be realized in a relatively short processing time.
2・・・符号化装置
5・・・符号化プログラム
500・・・ソースコーダ
510・・・第1符号部
520・・・シンボル計数部
530・・・中間符号記憶部
540・・・符号表生成部
550・・・第2符号部
DESCRIPTION OF
Claims (9)
前記第1の符号生成手段により生成された中間符号に基づいて、入力されたデータファイルの出力符号を生成する第2の符号生成手段と
を有する符号化装置。 First code generation means for encoding an input data file and generating an intermediate code using an entropy encoding method independent of unprocessed data;
And a second code generation unit configured to generate an output code of the input data file based on the intermediate code generated by the first code generation unit.
請求項1に記載の符号化装置。 The encoding apparatus according to claim 1, wherein the second code generation means generates the output code using an encoding method that depends on unprocessed data.
請求項1に記載の符号化装置。 The encoding apparatus according to claim 1, wherein the second code generation means generates the output code based on statistical processing for the entire data file.
をさらに有し、
前記第2の符号生成手段は、前記統計処理手段による統計処理の結果に基づいて、前記出力符号を生成する
請求項3に記載の符号化装置。 Statistical processing means for performing the statistical processing in parallel with at least part of the encoding processing by the first code generation means;
The encoding apparatus according to claim 3, wherein the second code generation means generates the output code based on a result of statistical processing by the statistical processing means.
請求項1に記載の符号化装置。 The encoding apparatus according to claim 1, wherein the first code generation unit performs an encoding process in a data unit larger than the second code generation unit.
前記第2の符号生成手段は、入力されたデータファイルそれぞれに応じて設計される可変符号表を用いて、前記出力符号を生成する
請求項1に記載の符号化装置。 The first code generation means encodes the input data file using a pre-designed fixed code table,
The encoding apparatus according to claim 1, wherein the second code generation means generates the output code using a variable code table designed in accordance with each input data file.
をさらに有し、
前記第2の符号生成手段は、前記記憶手段に記憶された中間符号を符号化して、前記出力符号を生成する
請求項1又は4に記載の符号化装置。 Storage means for storing the intermediate code generated by the first code generation means;
The encoding apparatus according to claim 1, wherein the second code generation unit generates the output code by encoding an intermediate code stored in the storage unit.
生成された前記中間符号に基づいて、入力されたデータファイルの出力符号を生成する
符号化方法。 Encode the input data file using an entropy encoding scheme that does not depend on raw data, generate an intermediate code,
An encoding method for generating an output code of an input data file based on the generated intermediate code.
生成された前記中間符号に基づいて、入力されたデータファイルの出力符号を生成するステップと
をコンピュータに実行させるプログラム。 Encoding an input data file using an entropy encoding scheme independent of raw data to generate an intermediate code;
A program for causing a computer to execute an output code of an input data file based on the generated intermediate code.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006153232A JP2007324971A (en) | 2006-06-01 | 2006-06-01 | Encoder, encoding method, and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006153232A JP2007324971A (en) | 2006-06-01 | 2006-06-01 | Encoder, encoding method, and program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2007324971A true JP2007324971A (en) | 2007-12-13 |
Family
ID=38857365
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2006153232A Pending JP2007324971A (en) | 2006-06-01 | 2006-06-01 | Encoder, encoding method, and program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2007324971A (en) |
-
2006
- 2006-06-01 JP JP2006153232A patent/JP2007324971A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP0777386B1 (en) | Method and apparatus for encoding and decoding an image | |
KR100894002B1 (en) | Device and data method for selective compression and decompression and data format for compressed data | |
US20070217703A1 (en) | Image encoding apparatus, image decoding apparatus and control method therefor | |
JP2008113374A (en) | Entropy coding apparatus | |
JP4893957B2 (en) | Encoding device, decoding device, encoding method and program | |
JP5995864B2 (en) | Display data encoding method and system | |
JP4893956B2 (en) | Encoding device, decoding device, encoding method and program | |
JP2007214998A (en) | Coding apparatus, decoding apparatus, coding method, decoding method, and program | |
US20090080786A1 (en) | Image encoding apparatus and method of controlling same | |
Al-Bahadili et al. | An adaptive character wordlength algorithm for data compression | |
KR20180067956A (en) | Apparatus and method for data compression | |
JP5842357B2 (en) | Image processing apparatus and image processing program | |
JP2007324971A (en) | Encoder, encoding method, and program | |
JP4377351B2 (en) | Data compression apparatus and data compression program | |
JP2008109478A (en) | Image encoding device, method, program and storage medium | |
JP2009171134A (en) | Video format converter | |
JP2006352547A (en) | Data compression apparatus and data compression program | |
JP4131969B2 (en) | Data compression apparatus and data compression program | |
JP4131970B2 (en) | Data compression apparatus and data compression program | |
JP2005260408A (en) | Data compression apparatus and data compression program | |
JP4435586B2 (en) | Data compression apparatus and data compression program | |
JP4377352B2 (en) | Data compression apparatus and data compression program | |
JP2005252531A (en) | Device and program for compressing data | |
JPH10261966A (en) | Coding and decoding device | |
JP2006060490A (en) | Image compressor and image compression program |