JPH05252535A - Picture data compressing device and method thereof - Google Patents

Picture data compressing device and method thereof

Info

Publication number
JPH05252535A
JPH05252535A JP8284792A JP8284792A JPH05252535A JP H05252535 A JPH05252535 A JP H05252535A JP 8284792 A JP8284792 A JP 8284792A JP 8284792 A JP8284792 A JP 8284792A JP H05252535 A JPH05252535 A JP H05252535A
Authority
JP
Japan
Prior art keywords
block
code amount
generated code
remainder
blocks
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
JP8284792A
Other languages
Japanese (ja)
Inventor
Toru Watanabe
亨 渡辺
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.)
Casio Computer Co Ltd
Original Assignee
Casio Computer 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 Casio Computer Co Ltd filed Critical Casio Computer Co Ltd
Priority to JP8284792A priority Critical patent/JPH05252535A/en
Publication of JPH05252535A publication Critical patent/JPH05252535A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • G06T9/004Predictors, e.g. intraframe, interframe coding

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Color Television Systems (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Image Processing (AREA)

Abstract

PURPOSE:To improve a picture quality by appropriately distributing the remainder of generated code amounts. CONSTITUTION:A difference between the total of calculated predicted values and the target generated code amounts is searched, the remainder is divided into the number of entire blocks, and equally distributed to each block. Moreover, the remainder is divided into the number of blocks of a Y, and equally distributed only to the blocks of the Y, the remainder is divided into the number four times as many as that of the blocks in a V direction, and distributed to the most left side blocks of Y, R-Y, and B-Y in the ratio of 2:1:1, the remainder is equally distributed to the most left side blocks of the Y and the remainder is added to the left-and-up edge side block of the Y. Thus, the predicted generated code amounts of each block can be obtained.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、画像データの圧縮処理
等に用いられるデータ圧縮装置に係り、詳細には、発生
符号量を制御する発生符号量制御機能を有する画像デー
タ圧縮装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a data compression apparatus used for image data compression processing, and more particularly to an image data compression apparatus having a generated code amount control function for controlling a generated code amount.

【0002】[0002]

【従来の技術】画像圧縮の国際標準としてJPEG(Jo
int Photographic Expert Group)やMPEG(Moving
Picture Expert Group)がある。JPEGは、静止画像
を圧縮することを目的としており、すでにカラー静止画
像の符号化手法が決定し、国際標準規格として承認され
る予定である。JPEGについては、チップも製品化さ
れており、このチップを用いたボードも市場に出始めて
いる。JPEGアルゴリズムは、大きく2つの圧縮方式
に分けられる。第1の方式はDCT(Discrete Cosine
Transform:離散コサイン変換)を基本とした方式であ
り、第2の方式は2次元空間でDPCM(Differntial
PCM)を行なうSpatial(空間関数)方式である。DCT
方式は量子化を含むため一般には完全に元の画像は再現
されない非可逆符号化であるが、少ないビット数におい
ても十分な復号画像品質を得ることができ、本アルゴリ
ズムの基本となる方式である。一方、Spatial方式は、
圧縮率は小さいが元の画像を完全に再現する可逆符号化
であり、この特性を実現するために標準方式として付加
された方式である。
2. Description of the Related Art As an international standard for image compression, JPEG (Jo
int Photographic Expert Group) and MPEG (Moving
Picture Expert Group). JPEG is intended to compress still images, and a color still image encoding method has already been determined and will be approved as an international standard. Regarding JPEG, a chip has been commercialized, and boards using this chip are beginning to appear on the market. The JPEG algorithm is roughly divided into two compression methods. The first method is DCT (Discrete Cosine).
Transform: A method based on Discrete Cosine Transform. The second method is DPCM (Differntial) in a two-dimensional space.
PCM) is a Spatial (spatial function) method. DCT
The method is lossy encoding that does not completely reproduce the original image because it includes quantization, but it is the basic method of this algorithm that can obtain sufficient decoded image quality even with a small number of bits. .. On the other hand, the Spatial method
It is a reversible encoding that has a small compression rate but completely reproduces the original image, and is a method added as a standard method to realize this characteristic.

【0003】DCT方式はさらに必須機能であるベース
ライン・プロセス(Baseline System)とオプション機
能である拡張DCTプロセス(Extended System)の2
つに分類される。これらの方式と別に、上記の方式を組
み合わせてプログレッシブ・ビルドアップを実現するハ
イアラーキカル・プロセスがある。ベースライン・プロ
セスは、DCT方式を実現するすべての符号器/復号器
がもたなければならない最小限の機能で、ADCT方式
(Adaptive Descrete Cosine Transform Coding:適応
型離散コサイン変換)を基礎としたアルゴリズムであ
る。上記ベースライン・プロセスにおける画像圧縮では
画像データを8×8ピクセル単位のブロックで処理をす
る。処理プロセスは、以下の通りである。 (1)2次元DCT変換処理 (2)DCT係数の量子化処理 (3)エントロピー符号化処理 2次元DCT変換処理では、空間データを周波数データ
に変換し、64個のDCT係数を出力する。このとき、
色成分は、(Y,CB,CR)としている。この係数のう
ち行列の中の左上の係数はDC成分と呼ばれ、ブロック
・データの平均値である。また、残りの63個の係数
は、AC成分と呼ばれる。
The DCT method further includes a baseline process (Baseline System) which is an essential function and an extended DCT process (Extended System) which is an optional function.
Classified into one. In addition to these methods, there is a hierarchical process that combines the above methods to achieve progressive buildup. The baseline process is a minimum function that all encoders / decoders that implement the DCT method must have, and is an algorithm based on the ADCT method (Adaptive Descrete Cosine Transform Coding). Is. In the image compression in the baseline process, image data is processed in blocks of 8 × 8 pixels. The treatment process is as follows. (1) Two-dimensional DCT conversion process (2) DCT coefficient quantization process (3) Entropy coding process In the two-dimensional DCT conversion process, spatial data is converted into frequency data, and 64 DCT coefficients are output. At this time,
The color components are (Y, CB, CR). Of these coefficients, the coefficient at the upper left of the matrix is called the DC component and is the average value of the block data. The remaining 63 coefficients are called AC components.

【0004】DC成分の量子化処理では、量子化器で各
係数ごとに大きさの異なった量子化ステップ・サイズを
設定した量子化マトリスクを用いて、DCT係数を線形
量子化する。但し、符号量あるいは復号画品質を制御可
能とするために、外部から指定する係数(スケーリング
・ファクタ)を量子化マトリクスに乗じた値を実際のマ
トリクス値として使用し、量子化を行なう。このよう
に、テーブルを参照しながら64個のDCT係数を整数
値に量子化する。この量子化処理によって非可逆圧縮と
なる。また、使用される参照テーブルの内容については
JPEGでは規定していない。量子化のテーブルは、人
間の視覚特性を考慮して作成する。人間は、高周波数成
分の視覚情報には鈍いので、この高周波成分は粗く量子
化する。
In the quantization processing of the DC component, the DCT coefficient is linearly quantized by using a quantization matrix having a quantization step size of different magnitude set for each coefficient by a quantizer. However, in order to control the code amount or the decoded image quality, a value obtained by multiplying a quantization matrix by a coefficient (scaling factor) specified from the outside is used as an actual matrix value for quantization. In this way, the 64 DCT coefficients are quantized into integer values with reference to the table. This quantization process results in lossy compression. The contents of the reference table used are not specified in JPEG. The quantization table is created in consideration of human visual characteristics. Since humans are not sensitive to visual information of high frequency components, this high frequency component is roughly quantized.

【0005】エントロピー符号化処理では、まずDC成
分と左隣ブロックにおける量子化されたDC成分との差
分を計算し、符号化する。この方法は、DPCMと呼ば
れる。また、AC成分はジクザグ・スキャンにより1次
元配列に変換される。ベースラインプロセスのエントロ
ピー符号化では、ハフマン符号化方式を用いる。ハフマ
ン符号化処理では各係数がゼロであるかどうかを判定
し、連続するゼロの係数は、その長さがランレングスと
して勘定される。ゼロでない係数が来ると、その量子化
結果とそれまでのゼロ係数のランレングスを組み合わせ
て、2次元ハフマン符号化される。DC/AC係数のハ
フマン符号化は、与えられたハフマン符号テーブルに基
づくが、量子化マトリクスおよびハフマン符号テーブル
は、使用する状況において最適なものになるようにする
ためデフォルト値はなく、必要に応じて符号器から復号
器へ転送して使用する。
In the entropy coding process, first, the difference between the DC component and the quantized DC component in the left adjacent block is calculated and coded. This method is called DPCM. The AC component is converted into a one-dimensional array by zigzag scanning. The Huffman coding method is used in the entropy coding of the baseline process. The Huffman coding process determines whether each coefficient is zero, and the coefficient of consecutive zeros is counted as a run length in its length. When a non-zero coefficient comes, two-dimensional Huffman coding is performed by combining the quantization result and the run length of the zero coefficient up to that point. The Huffman coding of the DC / AC coefficients is based on the given Huffman code table, but the quantization matrix and Huffman code table have no default values in order to be optimal in the situation in which they are used, if necessary. It is transferred from the encoder to the decoder for use.

【0006】図10は上記JPEGアルゴリズムに基づ
く従来の画像データ圧縮装置10のブロック図である。
図10において、11はフレームメモリであり、原画像
のデータを保持してある。フレームメモリ11に蓄えら
れている画像データは、DCT演算部12に出力され、
データを読み込んでブロック単位のDCT演算を行ない
量子化部13に出力する。DCT演算の出力データは、
量子化装置13(図11)に読込まれ、量子化装置13
は、量子化テーブルRAM14の量子化テーブル(図1
2及び図13参照)の値に従って量子化演算を行なう。
ハフマン符号化部14は、量子化装置13から出力され
たデータに対してDC符号量メモリ15及びAC符号量
メモリ16を用いてハフマン符号化を施し、総発生符号
量を総発生符号量記憶メモリ17に記憶する。CPU1
8は、これら装置全体の制御、及び後述する最適な量子
化テーブル作成と各ブロックの発生符号量を予測する制
御を行なう。上記ハフマン符号化器14は、量子化装置
13から出力されたデータに対してハフマン符号化を行
なう。このハフマン符号化器14の動作には、以下のよ
うな2種類のモードmode1,mode2がある。 (mode1)入力データに対してハフマン符号化を行
ない、その際に、各ブロックのDC成分によって発生し
たビット数を、DC符号量メモリ15に書込む。また、
AC成分によって発生したビット数をAC符号量メモリ
16に書込む。 (mode2)入力データに対してハフマン符号化を行
ない、その際に事前にAC符号量メモリ16に書き込ま
れている各ブロックのDC成分とAC成分の両方による
発生符号量の予測値と実際に発生した符号量とを比較
し、もし発生符号量が予測よりも多く発生するのであれ
ば、そこである値以降は全て0とするEOB(End of
Block)を発生させ、そのブロックの符号化を終了す
る。また、余ったビット数は次ブロックの予測値に加え
られる。
FIG. 10 is a block diagram of a conventional image data compression apparatus 10 based on the JPEG algorithm.
In FIG. 10, reference numeral 11 denotes a frame memory, which holds original image data. The image data stored in the frame memory 11 is output to the DCT calculation unit 12,
The data is read, a DCT operation is performed in block units, and the result is output to the quantizer 13. The output data of the DCT operation is
The quantizer 13 is read by the quantizer 13 (FIG. 11).
Is a quantization table of the quantization table RAM 14 (see FIG.
2 and FIG. 13), the quantization operation is performed according to the value.
The Huffman coding unit 14 performs Huffman coding on the data output from the quantizer 13 using the DC code amount memory 15 and the AC code amount memory 16, and stores the total generated code amount in the total generated code amount storage memory. Store in 17. CPU1
Reference numeral 8 controls the entire apparatus, and also controls the generation of an optimum quantization table, which will be described later, and the prediction of the generated code amount of each block. The Huffman encoder 14 performs Huffman encoding on the data output from the quantizer 13. The operation of the Huffman encoder 14 has the following two types of modes, mode1 and mode2. (Mode 1) Huffman coding is performed on the input data, and the number of bits generated by the DC component of each block is written in the DC code amount memory 15. Also,
The number of bits generated by the AC component is written in the AC code amount memory 16. (Mode2) Huffman coding is performed on the input data, and at that time, the predicted value of the generated code amount due to both the DC component and the AC component of each block written in advance in the AC code amount memory 16 and the actual generation are generated. If the generated code amount is larger than the predicted amount, the EOB (End of
Block) is generated and the coding of the block is completed. The surplus number of bits is added to the predicted value of the next block.

【0007】図11は上記量子化装置13のブロック図
である。図11において、量子化装置13は、Y(輝度
情報)用量子化テーブル(図12)を記憶する量子化テ
ーブルRAM21と、C(色情報)用量子化テーブル
(図13)を記憶する量子化テーブルRAM22と、D
CT演算された各周波数成分に量子化テーブルの値を掛
ける(すなわち、逆数を掛けて除算する)ことによって
重み付けを変える量子化を行なう乗算器23とにより構
成されている。また、量子化テーブルRAM21,22
は、Y及びR−Y,B−Yの各コンポーネントそれぞれ
に対応している。
FIG. 11 is a block diagram of the quantizing device 13. 11, the quantization device 13 includes a quantization table RAM 21 for storing a Y (luminance information) quantization table (FIG. 12) and a quantization table RAM 21 for storing a C (color information) quantization table (FIG. 13). Table RAM22 and D
Each frequency component calculated by CT is multiplied by a value in a quantization table (that is, multiplied by an inverse number and divided) to perform quantization for changing the weighting. In addition, the quantization table RAMs 21 and 22
Corresponds to each of the Y, RY, and BY components.

【0008】図12はY用量子化テーブル、図13はC
用量子化テーブルを示す図であり、上記量子化テーブル
RAM21,22内には、実際には、量子化テーブルの
逆数が書込まれている。量子化装置13は、この乗算結
果を出力する。以上の構成において、上記画像データ圧
縮装置10は以下のような動作により最適な量子化テー
ブルと各ブロックにおける発生符号量の予測を行なう。 i)先ず、適当な量子化テーブルを作成し、量子化テー
ブルRAM21,22に書込む。 ii)次いで、DCT→量子化→ハフマン符号化(mo
de1)を行なう。 iii)AC符号量メモリ16に保持されている総発生
符号量を参照し、その値を基に新たに適当な量子化テー
ブルを作成し、作成した量子化テーブルを量子化テーブ
ルRAM21,22に書込む。 iv)次いで、DCT→量子化→ハフマン符号化(mo
de 1)を行なう。 v)上記ii)で得られた総発生符号量と、今回得られ
た総発生符号量から目標とする符号量を発生させる量子
化テーブルを作成し、量子化テーブルRAM21,22
に書込む。また、目標とする符号量からDC成分によっ
て発生した総符号量及び各ブロックのEOB長を減算
し、減算した値とAC成分によって発生した総符号量と
の比率を求める。そして、上記比率に各ブロックのAC
成分によって発生した符号量からEOB長を減算した値
を乗じ、その値に各ブロックのDC成分によって発生し
た符号量にEOB長を加えた値を各ブロックの発生符号
量の予測値としてAC符号量メモリ15に書込む。 vi)そして、DCT→量子化→ハフマン符号化(mo
de 2)を行なう。
FIG. 12 is a Y quantization table, and FIG. 13 is C.
It is a figure which shows the quantization table for use, and the reciprocal of a quantization table is actually written in said quantization table RAM21,22. The quantizer 13 outputs this multiplication result. With the above configuration, the image data compression apparatus 10 performs the following operations to predict the optimum quantization table and the generated code amount in each block. i) First, an appropriate quantization table is created and written in the quantization table RAMs 21 and 22. ii) Next, DCT → quantization → Huffman coding (mo
Perform de1). iii) The total generated code amount held in the AC code amount memory 16 is referred to, a new appropriate quantization table is created based on the value, and the created quantization table is written in the quantization table RAMs 21 and 22. To be crowded. iv) Then, DCT → quantization → Huffman coding (mo
Perform de 1). v) A quantization table that generates a target code amount is created from the total generated code amount obtained in ii) above and the total generated code amount obtained this time, and the quantization table RAMs 21 and 22 are generated.
Write to. Further, the total code amount generated by the DC component and the EOB length of each block are subtracted from the target code amount, and the ratio between the subtracted value and the total code amount generated by the AC component is obtained. The AC of each block is added to the above ratio.
The value obtained by subtracting the EOB length from the code amount generated by the component is multiplied, and the value obtained by adding the EOB length to the code amount generated by the DC component of each block is used as the predicted value of the generated code amount of each block. Write to memory 15. vi) and DCT → quantization → Huffman coding (mo
Perform de 2).

【0009】[0009]

【発明が解決しようとする課題】ところで、このような
従来の画像データ圧縮装置10にあっては、上述した方
法で得られた予測値と目標とする発生符号量とに差(余
りビット)が生じる。余りが生じる理由は次のような理
由からである。すなわち、実際には上記の計算をすると
完全には割り切れずどうしても余りが生じることにな
る。このビットの余りを四捨五入して丸めると、四捨五
入による誤差で何ビットかオーバーしてしまう場合があ
り、結果的には全体で何ビット(あるいは何バイト)分
もオーバーすることがある。目標値からのオーバーは許
されないので、実際には四捨五入はせず、演算は基本的
に切捨てで行っている。このように切捨てで行った場
合、ブロック数が1万以上あるから、例えば1ブロック
あたり平均5ビットづつ余りが出たとしても全体では5
千ビットもの余りが発生することになる。従来画像デー
タ圧縮装置10は、余りビットを捨てるかあるいは一括
して左上のブロックにまとめる構成となっていたため、
上記余りビットを捨てるものでは画質の向上を図ること
ができず、また、左上のブロックにまとめてしまうもの
では予測より発生符号量が少ないときには余りビットを
捨ててしまうものよりは画質は向上するものの、予測よ
り発生符号量が多かったときには各ブロックに割振られ
る符号量が減少してしまうので画質が著しく劣化すると
いう欠点があった。そこで本発明は、発生符号量の余り
を適切に分配して画質を高めることが可能な画像データ
圧縮装置を提供することを目的とする。
By the way, in such a conventional image data compression apparatus 10, there is a difference (remainder bit) between the predicted value obtained by the above method and the target generated code amount. Occurs. The reason for the surplus is as follows. In other words, in reality, the above calculation does not completely divide it, but there is always a remainder. When the remainder of this bit is rounded and rounded, an error due to the rounding may cause some bits to be over, and as a result, some bits (or many bytes) may be exceeded as a whole. Since it is not allowed to exceed the target value, the rounding is not actually performed, and the calculation is basically performed by rounding down. When the data is truncated in this way, the number of blocks is 10,000 or more. Therefore, for example, even if each block has an average of 5 bits, the total is 5 blocks.
Thousands of bits will be left. Since the conventional image data compression device 10 has a configuration in which the excess bits are discarded or they are collectively put in the upper left block,
Although it is not possible to improve the image quality by discarding the surplus bits, the image quality is improved by consolidating the blocks in the upper left block over discarding the surplus bits when the generated code amount is smaller than the prediction. However, when the generated code amount is larger than the predicted amount, the code amount allocated to each block is reduced, and thus there is a drawback that the image quality is significantly deteriorated. Therefore, an object of the present invention is to provide an image data compression apparatus capable of appropriately distributing the remainder of the generated code amount and improving the image quality.

【0010】[0010]

【課題を解決するための手段】請求項1記載の発明は、
上記目的達成のため、画像データを変換符号化する変換
符号化手段と、量子化演算に用いる量子化テーブルを記
憶する量子化テーブル記憶手段と、前記変換符号化手段
から出力された信号を前記量子化テーブルに基づいて量
子化する量子化手段と、前記量子化手段により量子化さ
れた成分を各ブロックの予測発生符号量に従って符号化
する符号化手段と、符号化時に各ブロックにおいて発生
したDC成分及びAC成分の符号量を記憶する符号量記
憶手段と、前記DC成分及びAD成分の符号量の総和を
算出する総発生符号量算出手段と、前記総発生符号量算
出手段により算出された総発生符号量を記憶する総発生
符号量記憶手段とを備えた画像データ圧縮装置であっ
て、前記総発生符号量算出手段により算出された予測値
の総和と目標とする発生符号量の差を余りとして求め、
該余りを全体のブロック数で割り各ブロックに分配する
各ブロック分配手段と、前記余りを輝度情報(Y)のブ
ロックに分配するYブロック分配手段と、前記余りを輝
度情報(Y)及び色情報(R−Y,B−Y)の左端のブ
ロックに所定の割合で分配するY,R−Y,B−Yブロ
ック分配手段と、前記余りを輝度情報(Y)の左端のブ
ロックに分配するY左端ブロック分配手段と、前記余り
を輝度情報(Y)の左上端のブロックに分配するY左上
端ブロック分配手段と、の各ブロック分配手段のうち、
少なくとも何れか1つ以上のブロック分配手段を備えて
いる。請求項2記載の発明は、画像データを変換符号化
する変換符号化手段と、量子化演算に用いる量子化テー
ブルを記憶する量子化テーブル記憶手段と、前記変換符
号化手段から出力された信号を前記量子化テーブルに基
づいて量子化する量子化手段と、前記量子化手段により
量子化された成分を各ブロックの予測発生符号量に従っ
て符号化する符号化手段と、符号化時に各ブロックにお
いて発生したDC成分及びAC成分の符号量を記憶する
符号量記憶手段と、前記DC成分及びAD成分の符号量
の総和を算出する総発生符号量算出手段と、前記総発生
符号量算出手段により算出された総発生符号量を記憶す
る総発生符号量記憶手段とを備えた画像データ圧縮装置
であって、先ず、前記総発生符号量算出手段により算出
された予測値の総和と目標とする発生符号量の差を余り
として求め、該余りを全体のブロック数で割り各ブロッ
クに分配し、その余りを輝度情報(Y)のブロックに分
配し、さらにその余りを輝度情報(Y)及び色情報(R
−Y,B−Y)の左端のブロックに所定の割合で分配
し、さらにその余りを輝度情報(Y)の左端のブロック
に分配し、さらにその余りを輝度情報(Y)の左上端の
ブロックに分配するようにする。前記変換符号化手段
は、例えば請求項3に記載されているように画像データ
に対して離散コサイン変換を実行する離散コサイン変換
演算であってもよく、また、前記符号化手段は、例えば
請求項4に記載されているように確率分布が与えられた
情報源に対してコンパクト符号を構成するハフマン符号
化を行なうものであってもよい。
The invention according to claim 1 is
In order to achieve the above object, transform coding means for transform coding image data, quantization table storage means for storing a quantization table used in a quantization operation, and a signal output from the transform coding means for quantizing Quantizing means for quantizing based on a coding table, coding means for coding the components quantized by the quantizing means in accordance with the predicted generated code amount of each block, and DC component generated in each block at the time of coding. And a code amount storage means for storing the code amount of the AC component, a total generated code amount calculation means for calculating the sum of the code amounts of the DC component and the AD component, and a total generated code calculated by the total generated code amount calculation means. An image data compression apparatus comprising a total generated code amount storage means for storing the code amount, wherein a total of predicted values calculated by the total generated code amount calculation means and a target are set. Determined as the remainder of the difference between the raw code amount,
Each block distributing means for dividing the remainder by the total number of blocks to distribute to each block, Y block distributing means for distributing the remainder to a block of luminance information (Y), and the remainder to luminance information (Y) and color information. Y, RY, BY block distributing means for distributing at a predetermined ratio to the leftmost block of (RY, BY) and Y for distributing the remainder to the leftmost block of luminance information (Y). Of the respective block distributing means of the leftmost block distributing means and the Y upper leftmost block distributing means for distributing the remainder to the upper leftmost block of the luminance information (Y),
At least any one or more block distribution means are provided. According to a second aspect of the present invention, a transform coding means for transform coding the image data, a quantization table storage means for storing a quantization table used in the quantization operation, and a signal output from the transform coding means. Quantizing means for quantizing based on the quantization table, coding means for coding the components quantized by the quantizing means according to the predicted generated code amount of each block, and the coding means generated in each block at the time of coding. Code amount storage means for storing the code amounts of the DC component and AC component, total generated code amount calculation means for calculating the sum of the code amounts of the DC component and AD component, and the total generated code amount calculation means An image data compression device comprising a total generated code amount storage means for storing the total generated code amount, wherein first, a sum of the predicted values calculated by the total generated code amount calculating means and an index The difference between the generated code amounts is calculated as a remainder, the remainder is divided by the total number of blocks and distributed to each block, the remainder is distributed to the blocks of the luminance information (Y), and the remainder is the luminance information (Y). And color information (R
-Y, BY) is distributed to the leftmost block of the luminance information (Y) at a predetermined ratio, the remainder is distributed to the leftmost block of the luminance information (Y), and the remainder is the leftmost block of the luminance information (Y). To be distributed to. The transform coding means may be, for example, a discrete cosine transform operation for performing a discrete cosine transform on image data as described in claim 3, and the coding means may be, for example, As described in 4, the Huffman coding that constitutes a compact code may be performed on an information source given a probability distribution.

【0011】[0011]

【作用】本発明の手段の作用は次の通りである。請求項
1及び請求項2記載の発明では、画像データは変換符号
化手段で離散コサイン変換された後、量子化手段に送ら
れる。量子化手段では、DCT演算出力に対して量子化
テーブルを参照して量子化演算が行われ、その演算結果
が符号化手段に出力される。符号化手段では量子化デー
タが各ブロックの予測発生符号量に従って符号化され、
符号化時は各ブロックにおいて発生したDC成分及びA
C成分の符号量が符号量記憶手段に記憶される。また、
総発生符号量算出手段によってDC成分及びAC成分の
符号量の総和が算出され総発生符号量記憶手段に記憶さ
れる。そして、算出された予測値の総和と目標とする発
生符号量の差が余りとして求められ、先ず、その余りは
各ブロックに分配され、各ブロックに分配して残った余
りは輝度情報(Y)のブロックに分配される。また、そ
の余りは輝度情報(Y)及び色情報(R−Y,B−Y)
の左端のブロックに所定の割合で分配され、そのさらに
余りは輝度情報(Y)の左上端のブロックに分配され
る。最後に残った余りは輝度情報(Y)の左上端のブロ
ックに分配される。従って、発生符号量の余りが適切に
分配され、画質の向上を図ることができる。
The operation of the means of the present invention is as follows. According to the first and second aspects of the present invention, the image data is discrete cosine transformed by the transform coding means and then sent to the quantizing means. The quantization means performs a quantization operation on the DCT operation output by referring to the quantization table, and outputs the operation result to the encoding means. In the coding means, the quantized data is coded in accordance with the predicted generated code amount of each block,
At the time of encoding, the DC component and A generated in each block
The code amount of the C component is stored in the code amount storage means. Also,
The total generated code amount calculation means calculates the sum of the code amounts of the DC component and the AC component and stores the sum in the total generated code amount storage means. Then, the difference between the total sum of the calculated prediction values and the target generated code amount is obtained as a remainder, and first, the remainder is distributed to each block, and the remainder remaining after distribution to each block is luminance information (Y). Distributed in blocks. In addition, the remainder is luminance information (Y) and color information (RY, BY).
Of the luminance information (Y) is distributed at a predetermined ratio to the leftmost block of the luminance information (Y). The remaining residue at the end is distributed to the upper left block of the luminance information (Y). Therefore, the remainder of the generated code amount is appropriately distributed, and the image quality can be improved.

【0012】[0012]

【実施例】以下、本発明を図面に基づいて説明する。図
1〜図9は本発明に係る画像データ圧縮装置の一実施例
を示す図であり、本実施例は複数種の量子化テーブルを
用いる方法として各ブロックに市松状に2種類の量子化
テーブルを使用するようにした例である。先ず、構成を
説明する。図1は画像データ圧縮装置30のブロック図
であり、この図において、画像データ圧縮装置30は、
データ圧縮すべき原画像データを記憶するフレームメモ
リ31と、フレームメモリ31から読出した画像データ
を2次元DCTを施してDCT係数を求めるDCT演算
を行なうDCT装置32と、DCT演算の出力データを
量子化テーブルRAM(後述)の値に従って量子化演算
する量子化装置33と、後述する各メモリ35〜39を
用いて従来例と同様の2つの動作モードmode1,m
ode2に従って量子化装置33の出力に対してハフマ
ン符号化を行なうハフマン符号化器34と、DC成分に
よって発生したDC符号量を記憶するDC符号量メモリ
35と、AC成分によって発生したAC符号量を記憶す
るAC符号量メモリ36と、全てのブロックのDC成分
によって発生した符号量の総和を記憶するDC総発生符
号量記憶メモリ37と、Y用、C用夫々2種類の量子化
テーブルを用いて量子化したブロックのAC成分によっ
て発生した符号量の総和を記憶するACテーブル別総発
生符号量記憶メモリ38,39と、これら全体の制御及
び最適と思われる量子化テーブル及び、その時の各ブロ
ックの発生符号量の予測値の算出を行なうCPU40と
により構成されている。
DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will be described below with reference to the drawings. 1 to 9 are diagrams showing an embodiment of an image data compression apparatus according to the present invention. In this embodiment, as a method of using a plurality of types of quantization tables, each block has a checkered two types of quantization tables. This is an example of using. First, the configuration will be described. FIG. 1 is a block diagram of the image data compression apparatus 30. In this figure, the image data compression apparatus 30 is
A frame memory 31 for storing original image data to be data-compressed, a DCT device 32 for performing a DCT operation to obtain a DCT coefficient by subjecting the image data read from the frame memory 31 to a two-dimensional DCT, and output data of the DCT operation are quantized. A quantization device 33 for performing a quantization operation according to a value in a quantization table RAM (described later) and two operation modes mode1 and m similar to the conventional example using each of the memories 35 to 39 described later.
The Huffman encoder 34 that performs Huffman coding on the output of the quantizer 33 according to node 2, the DC code amount memory 35 that stores the DC code amount generated by the DC component, and the AC code amount generated by the AC component. Using an AC code amount memory 36 for storing, a DC total generated code amount storage memory 37 for storing the sum of code amounts generated by DC components of all blocks, and two types of quantization tables for Y and C respectively. AC table-based total generated code amount storage memories 38 and 39 for storing the sum total of the code amounts generated by the AC components of the quantized blocks, a quantization table that is considered to be optimal and control of the whole, and a block of each block at that time. It is configured by a CPU 40 that calculates a predicted value of the generated code amount.

【0013】上記ハフマン符号化器34は、量子化装置
33から出力されたデータに対してDC符号量メモリ3
5及びAC符号量メモリ36を用いてハフマン符号化を
施し、全てのブロックのDC成分によって発生した符号
量の総和をDC総発生符号量記憶メモリ37に記憶する
とともに、市松状(図3及び図4参照)に切換えられた
後述する2種類の量子化テーブル51〜54毎のAC成
分によって発生した符号量の総和をテーブル別AC総発
生符号量記憶メモリ38,39に記憶する。
The Huffman encoder 34 uses the DC code amount memory 3 for the data output from the quantizer 33.
5 and the AC code amount memory 36, Huffman coding is performed, the sum of the code amounts generated by the DC components of all blocks is stored in the DC total generated code amount storage memory 37, and the checkered pattern (FIG. 3 and FIG. The total sum of the code amounts generated by the AC components of each of the two types of quantization tables 51 to 54, which will be described later, is stored in the table-specific AC total generated code amount storage memories 38 and 39.

【0014】また、上記テーブル別AC総発生符号量記
憶メモリ38,39のうち、AC総発生符号量記憶メモ
リ38には、量子化テーブル51,52を、またAC総
発生符号量記憶メモリ39には、量子化テーブル53,
54を用いて量子化したブロックのAC成分によって発
生した符号量の総和が記憶保持される。また、後述する
(mode b)の時には、AC総発生符号量記憶メモ
リ38にのみ値が書込まれ、AC総発生符号量記憶メモ
リ39は、0である。
Of the table-based AC total generated code amount storage memories 38 and 39, the AC total generated code amount storage memory 38 includes the quantization tables 51 and 52, and the AC total generated code amount storage memory 39. Is the quantization table 53,
The sum of the code amounts generated by the AC components of the block quantized by using 54 is stored and held. At the time of (mode b) described later, the value is written only in the AC total generated code amount storage memory 38, and the value in the AC total generated code amount storage memory 39 is zero.

【0015】図2は上記量子化装置33のブロック図で
ある。図2において、量子化装置33は、C用の各ブロ
ックに対して市松状としたときの市松模様の一方のブロ
ックにおけるY用量子化テーブル51を記憶する量子化
テーブルRAM41と、C用の各ブロックに対して市松
状としたときの市松模様の他方のブロックにおけるY用
量子化テーブル53を記憶する量子化テーブルRAM4
3と、R−Y,B−Y用の各ブロックに対して市松状と
したときの市松模様の一方のブロックにおけるR−Y,
B−Y用量子化テーブル52を記憶する量子化テーブル
RAM42と、R−Y,B−Y用の各ブロックに対して
市松状としたときの市松模様の他方のブロックにおける
R−Y,B−Y用量子化テーブル54を記憶する量子化
テーブルRAM44と、DCT演算の結果と上記量子化
テーブル51〜54の値を乗算する(逆数を掛けて除算
する)ことによって重み付けを変える量子化を行なう乗
算器45とにより構成されている。
FIG. 2 is a block diagram of the quantizer 33. In FIG. 2, the quantizing device 33 includes a quantizing table RAM 41 for storing a Y quantizing table 51 in one block of a checkered pattern when each block for C is checkered, and a quantizing table RAM 41 for each C. Quantization table RAM4 for storing the Y quantization table 53 in the other block having a checkered pattern when the block is made checkered.
3 and RY in one block of a checkered pattern when each block for RY and BY is checkered,
A quantization table RAM 42 that stores a BY quantization table 52, and RY and B- in the other block of the checkerboard pattern when each of the RY and BY blocks is checkered. A quantization table RAM 44 that stores the Y quantization table 54, and a multiplication that changes the weighting by multiplying the result of the DCT operation and the values of the quantization tables 51 to 54 (multiplication and division). And a container 45.

【0016】図3は量子化テーブルRAM41,43に
記憶されたY用量子化テーブル51,53、図54は量
子化テーブルRAM42,54に記憶された量子化テー
ブル52,54を示す図である。図3に示すようにY用
量子化テーブル51,53は、各ブロックに対して市松
状にY用量子化テーブル51とY用量子化テーブル53
(図3ハッチング部参照)とにより構成される。すなわ
ち、従来例では図15に示すように各ブロックが全体と
して1つのY用量子化テーブルを構成していたが、本Y
用量子化テーブル51,53は各ブロックを図3のよう
な市松模様状とし、図3ハッチング部に示すブロックに
は量子化テーブル53を、非ハッチング部に示すブロッ
クには量子化テーブル51を割当てるようにする。同様
に、R−Y,B−Y用量子化テーブル52,54は、各
ブロックに対して市松状にR−Y,B−Y用量子化テー
ブル52とR−Y,B−Y用量子化テーブル54(図4
ハッチング部参照)とにより構成され、各ブロックを図
4のような市松模様状とし、図4ハッチング部に示すブ
ロックには量子化テーブル54を、非ハッチング部に示
すブロックには量子化テーブル52を割当てるようにす
る。
FIG. 3 is a diagram showing the Y quantization tables 51 and 53 stored in the quantization table RAMs 41 and 43, and FIG. 54 is a diagram showing the quantization tables 52 and 54 stored in the quantization table RAMs 42 and 54. As shown in FIG. 3, the Y quantization tables 51 and 53 are arranged in a checkered pattern for each block in the Y quantization table 51 and the Y quantization table 53.
(Refer to the hatched portion in FIG. 3). That is, in the conventional example, each block constitutes one Y quantization table as a whole as shown in FIG.
For the quantization tables 51 and 53 for use, each block is in a checkered pattern as shown in FIG. 3, and the quantization table 53 is assigned to the block shown in the hatched portion in FIG. 3 and the quantization table 51 is assigned to the block shown in the non-hatched portion. To do so. Similarly, the RY and BY quantization tables 52 and 54 are in a checkered pattern for each block, and the RY and BY quantization tables 52 and the RY and BY quantization tables are arranged in a checkered pattern. Table 54 (Fig. 4
4), each block is in a checkered pattern as shown in FIG. 4, the quantization table 54 is shown for the blocks shown in the hatched part in FIG. 4, and the quantization table 52 is shown for the blocks shown in the non-hatched part. Try to allocate.

【0017】ここで、実際には市松模様にすると割り当
てられるブロック数が半分になるので算出される発生符
号量も約半分になる。そこで、本実施例では算出された
発生符号量を2倍して使うようにする。このように、量
子化テーブル51と53、52と54を切換えることに
よって2つのテーブルに基づく2点の発生符号量の傾向
(リニアの場合にあってはその傾き)が求まるので、算
出された発生符号量に対応するスケーリング値を1回目
の量子化で求めることができるようになる。
Here, when the checkerboard pattern is actually used, the number of allocated blocks is halved, so the generated code amount is also halved. Therefore, in the present embodiment, the calculated generated code amount is doubled and used. In this way, by switching the quantization tables 51 and 53, 52 and 54, the tendency of the generated code amount at two points (in the case of a linear case, the inclination) can be obtained based on the two tables. The scaling value corresponding to the code amount can be obtained by the first quantization.

【0018】また、テーブル1として用いられるY用量
子化テーブル51及びR−Y,B−Y用量子化テーブル
52と、テーブル2として用いられるY用量子化テーブ
ル53及びR−Y,B−Y用量子化テーブル54は、例
えば図5に示すような値のものが使用される。
Further, a Y quantization table 51 and RY, BY quantization table 52 used as Table 1, and a Y quantization table 53 and RY, BY used as Table 2. For the quantization table for use 54, for example, those having values as shown in FIG. 5 are used.

【0019】上記量子化テーブルRAM41〜44に記
憶される量子化テーブル51〜54はコンポーネント及
びブロックに対して以下のように切換えて用いられる。 (mode a) Yに対してはY用量子化テーブル5
1,53を用いる。また、このY用量子化テーブル5
1,53を図4に示すような市松状に各ブロック毎に切
換える。R−Y,B−Yについては、R−Y,B−Y用
量子化テーブル52,54を用いる。切換え方法はYと
同様に市松状に切換える。 (mode b) Yに対してY用量子化テーブル51
を、R−Y,B−Yに対してR−Y,B−Y用量子化テ
ーブル52を用いる。この場合、ブロック毎の切換えは
行われない。
The quantization tables 51 to 54 stored in the quantization table RAMs 41 to 44 are used by switching the components and blocks as follows. (Mode a) Y quantization table 5 for Y
1,53 are used. Also, this Y quantization table 5
1, 53 are switched for each block in a checkered pattern as shown in FIG. For RY and BY, the RY and BY quantization tables 52 and 54 are used. The switching method is switched in a checkered pattern similar to Y. (Mode b) Y quantization table 51 for Y
, The RY and BY quantization tables 52 are used for RY and BY. In this case, switching for each block is not performed.

【0020】次に、本実施例の動作を説明する。全体動作 先ず、フレームメモリ31には、原画像のデータが保持
されているものとする。DCT演算部32はフレームメ
モリ31から画像データを読込んでDCT演算を行な
い、そのDCT演算出力は、量子化装置33に送られ
る。また、量子化装置33では、DCT演算装置32か
らの入力に対して量子化テーブルRAM41〜44の値
に従って量子化演算を行ない、演算結果をハフマン符号
化器34に出力する。ハフマン符号化器34は、量子化
されたデータに対してDC符号量メモリ35及びAC符
号量メモリ36を用いてハフマン符号化を施し、全ての
ブロックのDC成分によって発生した符号量の総和をD
C総発生符号量記憶メモリ37に記憶するとともに、市
松状に切換えられた2種類の量子化テーブル51〜54
毎のAC成分によって発生した符号量の総和をテーブル
別AC総発生符号量記憶メモリ38,39に書込む。こ
の場合、Y用量子化テーブル51(図3の非ハッチング
部参照)を使ったブロックの発生符号量の総和はACテ
ーブル別総発生符号量記憶メモリ38に書込まれ、Y用
量子化テーブル51(図3のハッチング部参照)を使っ
たブロックの発生符号量の総和はACテーブル別総発生
符号量記憶メモリ39に書込まれる。
Next, the operation of this embodiment will be described. Overall Operation First, it is assumed that the frame memory 31 holds original image data. The DCT calculation unit 32 reads the image data from the frame memory 31 and performs DCT calculation, and the DCT calculation output is sent to the quantizer 33. Further, the quantizing device 33 performs a quantizing operation on the input from the DCT operating device 32 according to the values of the quantization table RAMs 41 to 44, and outputs the operation result to the Huffman encoder 34. The Huffman encoder 34 performs Huffman coding on the quantized data by using the DC code amount memory 35 and the AC code amount memory 36, and D is the sum of the code amounts generated by the DC components of all blocks.
C two kinds of quantization tables 51 to 54 which are stored in the C total generated code amount storage memory 37 and are switched in a checkered pattern
The sum of the code amount generated by each AC component is written in the table-specific AC total generated code amount storage memories 38 and 39. In this case, the sum of the generated code amounts of the blocks using the Y quantization table 51 (see the non-hatched portion in FIG. 3) is written in the AC table-based total generated code amount storage memory 38, and the Y quantization table 51 is used. The total sum of the generated code amounts of the blocks using (see the hatched portion in FIG. 3) is written in the total generated code amount storage memory 39 for each AC table.

【0021】CPU40は、上記各装置を以下のように
動作させ、発生符号量の制御を行なう。 i)先ず、目標とする総発生符号量に合わせて量子化テ
ーブルを作成し、量子化テーブル51,52,53,5
4にその逆数を書込む。図5は1bppの場合の量 子化
テーブル51〜54の一例である。 ii)DCT→量子化(mode a)→ハフマン符号
化(mode 1)を行なう。 iii)後述のアルゴリズムに従って目標とする符号量
を発生させるのに最適と思われる量子化テーブルと、そ
の時の各ブロックのAC成分及びDC成分の発生符号量
を予測し、その値を量子化テーブル51,52、DC符
号量メモリ35及びAC符号量メモリ36に書込む。 iv)次いで、DCT→量子化(mode b)→ハフ
マン符号化(mode2)を行なう。
The CPU 40 operates each of the above devices as follows to control the generated code amount. i) First, a quantization table is created in accordance with the target total generated code amount, and the quantization tables 51, 52, 53, 5 are created.
Write the reciprocal to 4. FIG. 5 shows an example of the quantization tables 51 to 54 for 1 bpp. ii) DCT → quantization (mode a) → Huffman coding (mode 1) is performed. iii) A quantization table that is considered to be optimal for generating a target code amount according to an algorithm described later, the generated code amount of the AC component and the DC component of each block at that time are predicted, and the value is quantized by the quantization table 51. , 52, the DC code amount memory 35, and the AC code amount memory 36. iv) Next, DCT-> quantization (mode b)-> Huffman coding (mode 2) is performed.

【0022】発生符号量予測アルゴリズム 先ず、量子化テーブル作成アルゴリズムについて述べ
る。 事前に発生符号量がリニアとなるような量子化テーブ
ルの作成方法を決めて番号付けをしておく。この番号を
スケーリングと呼ぶことにする。例えば、0〜255の
256通りとし、0から255へ向かってリニアに発生
符号量が増加するものとする。 目標とする発生符号量(CDN)に対して適当なスケ
ーリングを2つ選択し、量子化テーブルを作成し、量子
化テーブル51,52,53,54にその逆数を書込
み、量子化(mode a)及びハフマン符号化(mo
de 1)を行なう。図5は、このようにして作成され
る量子化テーブル例である。 最初に選択したスケーリング値をSb,Shとする。
また、DC総発生符号量記憶メモリ37のDC総発生符
号量の値をDCall、上記Sb,Shに対応するAC
テーブル別総発生符号量記憶メモリ38,39のテーブ
ル別AC総発生符号量の値をそれぞれACsb,ACs
hとすると、求めるスケーリングは、例えば数1によっ
て得ることができる。
Generation Code Prediction Algorithm First, the quantization table creation algorithm will be described. A method of creating a quantization table that makes the generated code amount linear is determined and numbered in advance. This number will be called scaling. For example, it is assumed that there are 256 ways from 0 to 255, and the generated code amount increases linearly from 0 to 255. Two appropriate scalings are selected for the target generated code amount (CDN), a quantization table is created, the reciprocal numbers are written in the quantization tables 51, 52, 53, 54, and quantization (mode a) is performed. And Huffman coding (mo
Perform de 1). FIG. 5 is an example of the quantization table created in this way. The scaling values selected first are Sb and Sh.
Further, the value of the total DC generated code amount in the total DC generated code amount storage memory 37 is DCall, and the AC corresponding to the above Sb and Sh.
The values of the AC total generated code amount for each table in the table total generated code amount storage memories 38 and 39 are respectively ACsb and ACs.
If h is set, the required scaling can be obtained by, for example, Equation 1.

【数1】 [Equation 1]

【0023】次に、以下のようなアルゴリズムによって
各ブロックの発生符号量の予測を行なう。図6〜図8は
各ブロックの発生符号量の予測処理を示すフローチャー
トであり、図6〜図8のフローチャートで使用される変
数の対応を以下に示す。 CDN:目標とするbit数 RN:未配分のbit数 RAT[0],RAT[1]:目標とするbit数におけ
るAC成分の発生符号量と、量子化テーブル51,52
及び53,54を用いた時の総発生符号量の2倍との比
率予測値の16倍 EOB[0],EOB[1]:0:YのEOB長 1:CのEOB長 AC[i][j][k]:i→0/1=Y/C j=k,j行k列のブロックのAC発生符号量 DC[i][j][k]:i→0/1=Y/C j=k,j行k列のブロックのDC発生符号量 F[i][j][k]:i→0/1=Y/C j=k,j行k列のブロックの発生符号量予測値 RA:全てのブロックに分配するbit数 YA:Yのブロックに分配するbit数 RB:全ての左端のブロックに分配するbit数 YB:Yの左端のブロックに分配するbit数
Next, the generated code amount of each block is predicted by the following algorithm. 6 to 8 are flowcharts showing the prediction processing of the generated code amount of each block, and the correspondence of the variables used in the flowcharts of FIGS. 6 to 8 is shown below. CDN: Target number of bits RN: Unallocated number of bits RAT [0], RAT [1]: Generated code amount of AC component in target number of bits, and quantization tables 51, 52
16 times the ratio predicted value with double the total generated code amount when 53 and 54 are used. EOB [0], EOB [1]: 0: Y EOB length 1: C EOB length AC [i] [J] [k]: i → 0/1 = Y / C j = k, AC generated code amount of the block at row j and column DC [i] [j] [k]: i → 0/1 = Y / Cj = k, DC generated code amount of block of j row and k column F [i] [j] [k]: i → 0/1 = Y / C j = k, generated code amount of block of j row and k column Prediction value RA: Number of bits distributed to all blocks YA: Number of bits distributed to Y blocks RB: Number of bits distributed to all left blocks YB: Number of bits distributed to Y left blocks

【0024】図6〜図8のフローチャートを説明するに
あたり、先ずフロー全体のアルゴリズムを簡単に述べ
る。 (I) 目標とする発生符号量から、一度目で発生したD
C成分の符号量を減じた値と、各テーブルによって発生
したAC成分の総和(ACsb,ACsh)との比率を
求める。 (II) 各ブロックで実際に発生したAC発生符号量から
各コンポーネントに対応するEOB長(EOB[0],
EOB[1])を減じ、それに上記(I)で求めた比率
を、一度に用いた量子化テーブルに従って乗じ、その値
にEOBと一度目で求めたDC発生符号量を加えた値を
仮の予測値とする。 (III) 上記(II)で求めた予測値の総和と目標とする発
生符号量との差を求めて、各ブロックに対して以下のよ
うに割振る。 a)余りを全体のブロック数で割り、各ブロックに均等
に分配する。 b)さらに、その余りをYのブロック数で割り、Yのブ
ロックのみに均等に分配する。 c)また、そのさらに余りをV方向のブロック数の4倍
で割り、Y,R−Y,B−Yの一番左側のブロックに
2:1:1の割合で分配する。 d)その余りを、Yの一番左側のブロックに均等に分配
する。 e)さらにその余りは、Yの左上端のブロックに加え
る。 以上のようなアルゴリズムによって各ブロックの予測発
生符号量を得る。
In explaining the flowcharts of FIGS. 6 to 8, first, the algorithm of the entire flow will be briefly described. (I) D generated at the first time from the target generated code amount
The ratio of the value obtained by subtracting the code amount of the C component and the total sum (ACsb, ACsh) of the AC components generated by each table is obtained. (II) From the AC generated code amount actually generated in each block, the EOB length (EOB [0],
EOB [1]) is subtracted, the ratio obtained in (I) above is multiplied according to the quantization table used at one time, and the value obtained by adding EOB and the DC generated code amount obtained at the first time to a temporary value Use as a predicted value. (III) The difference between the sum of the prediction values obtained in (II) above and the target generated code amount is obtained, and each block is allocated as follows. a) Divide the remainder by the total number of blocks and distribute evenly to each block. b) Furthermore, the remainder is divided by the number of Y blocks, and is evenly distributed only to the Y blocks. c) Further, the remainder is divided by 4 times the number of blocks in the V direction, and distributed to the leftmost block of Y, RY and BY at a ratio of 2: 1: 1. d) Evenly distribute the remainder to the leftmost block in Y. e) Furthermore, the remainder is added to the upper left block of Y. The predicted generated code amount of each block is obtained by the above algorithm.

【0025】より詳しく説明すると、図6〜図8におい
て、先ず、ステップS1で未配分のビット数RNを目標
とするビット数CDNとし(RN=CDN)、目標とす
るビット数CDNから一度目で発生したDC成分の総発
生符号量DC allを減じた値と各テーブルによって
発生したAC成分の総和(AC sb,AC sh)との
比率RAT[0],RAT[1]を算出する(RAT
[0]=(CDN−DCall)×8/AC ch,R
AT[1]=(CDN−DC all)×8/AC c
h)。ここで、値(CDN−DC all)を×8して
いるのはバイナリポイントをシフトさせて演算精度を保
つためものであり必ずしも必須のものではない。例え
ば、C言語で圧縮/伸長プログラムを作成した場合、C
言語の除算は少数部分は切捨てとなるのでここで適当な
倍数を掛けておくようにする。
More specifically, in FIGS. 6 to 8, first, in step S1, the unallocated number of bits RN is set as the target number of bits CDN (RN = CDN), and the target number of bits CDN is first calculated. Ratios RAT [0] and RAT [1] of a value obtained by subtracting the total generated code amount DC all of the generated DC components and the total sum (AC sb, AC sh) of the AC components generated by each table are calculated (RAT
[0] = (CDN-DCall) × 8 / AC ch, R
AT [1] = (CDN-DC all) × 8 / AC c
h). Here, the value (CDN-DC all) is set to x8 in order to shift the binary point to maintain the calculation accuracy and is not necessarily essential. For example, if you create a compression / decompression program in C,
Since the decimal part of language division is truncated, multiply it by an appropriate multiple here.

【0026】次いで、ステップS2でYあるいはCのブ
ロックを示すバンク(bank)iを0にし(i=
0)、ステップS3でバンクiが2より小さいか(i<
2か)否かを判別する。すなわち、色(C)については
横方向に2倍にサンプリングするので、バンク1とバン
ク2の2つ合わせてYと同じ大きさになる。そのため、
バンク1とバンク2で配列を使ってバンクiが2になる
まで以降の処理を繰返す。図9はY,B−Y,R−Yの
ブロックの構造を示す図であり、各ブロックはj行k列
で示される。バンクiが2より小さいときはステップS
4で縦方向のブロック数jを0にし(j=0)、ステッ
プS5で縦方向のブロック数jが縦方向の所定ブロック
数Vより小さいか(j<Vか)否かを判別する。縦方向
のブロック数jが縦方向の所定ブロック数V以上のとき
はステップS6でバンクiをインクリメント(i=i+
0)してステップS3に戻る。縦方向のブロック数jが
Vより小さいときはステップS7で横方向のブロック数
kを0にし(k=0)、ステップS8で横方向のブロッ
ク数kが横方向の所定ブロック数Hより小さいか(k<
Hか)否かを判別する。横方向のブロック数kが横方向
の所定ブロック数H以上のときはステップS9で縦方向
のブロック数jをインクリメント(j=j+1)してス
テップS5に戻る。例えば、縦方向のブロック数Vが6
0であれば、縦方向のブロック数jは0でイニシャライ
ズされているからj=0からカウントしj=60になる
と、ステップS7以降で同様の判断を横方向について行
なう。これによって、次のステップS10に示す処理が
縦方向、横方向規定のブロック数になるまで繰り返し実
行され、バンクiが2になると図6のフローを抜けて図
7のフローのステップS11に進む。
Next, in step S2, a bank i indicating a Y or C block is set to 0 (i =
0), whether the bank i is smaller than 2 in step S3 (i <
2) or not. That is, since the color (C) is sampled twice in the horizontal direction, the two of bank 1 and bank 2 have the same size as Y. for that reason,
The subsequent processing is repeated until the bank i becomes 2 using the arrays in the banks 1 and 2. FIG. 9 is a diagram showing the structure of Y, BY, and RY blocks, and each block is shown in j rows and k columns. When bank i is smaller than 2, step S
In step 4, the number j of blocks in the vertical direction is set to 0 (j = 0), and in step S5, it is determined whether or not the number j of blocks in the vertical direction is smaller than a predetermined number V of blocks in the vertical direction (j <V). When the number j of blocks in the vertical direction is equal to or larger than the predetermined number V of blocks in the vertical direction, the bank i is incremented (i = i +) in step S6.
0) and returns to step S3. When the number j of blocks in the vertical direction is smaller than V, the number k of blocks in the horizontal direction is set to 0 in step S7 (k = 0), and the number k of blocks in the horizontal direction is smaller than the predetermined number H of blocks in the horizontal direction in step S8. (K <
H)) or not. When the horizontal block number k is equal to or larger than the predetermined horizontal block number H, the vertical block number j is incremented (j = j + 1) in step S9, and the process returns to step S5. For example, the number V of blocks in the vertical direction is 6
If it is 0, the number of blocks j in the vertical direction is initialized to 0. Therefore, when counting from j = 0 to j = 60, the same determination is made in the horizontal direction at step S7 and thereafter. As a result, the process shown in the next step S10 is repeatedly executed until the number of blocks specified in the vertical and horizontal directions is reached, and when the bank i becomes 2, the flow of FIG. 6 is skipped and the process proceeds to step S11 of the flow of FIG.

【0027】ステップS10では以下のような各処理を
行なう。先ず、各ブロックで実際の発生したAC発生符
号量AC[i][j][k]から各コンポーネントに対
応するEOB長EOB[i]を減じてテンポラリtempに
格納する(temp=AC[i][j][k]−EOB
[i])。ここで、各ブロックで発生したAC発生符号
量AC[i][j][k]からEOB[i]を減算して
いるのは、後の処理でオーバーフローを防止するために
EOBを加えるようにすることになるため予めこのEO
B長分を減算しておくものである。また、上記テンポラ
リtempに所定の起立RATを乗じたものを新しいテンポ
ラリtempの値とする(temp=temp*RAT[(j+k)
%2])。ここで、(j+k)%2とは、各ブロックに
おいて市松状(図3及び図4参照)に0と1とが切換え
るためのものであり、上記%2は2で割った余り(0か
1のどちらかになる)を示している。これによって、市
松状のどちらの比率RATを使うのかが決定される。ま
た、このテンポラリtempの値を4bit左にシフトさせる
(temp=(temp≫4)。ここで、4bit左シフトするの
は上記ステップS1で×8倍したものを元に戻すためで
ある。また、このテンポラリtempの値に一度目で求めた
DC発生符号量DC[i][j][k]とコンポーネン
トに対応するEOB[i]を足して新しいテンポラリte
mpの値とし(temp=DC[i][j][k]+EOB
[i])、このテンポラリtempの値を該当ブロックの発
生符号量F[i][j][k]とする(F[i][j]
[k]=temp)。このF[i][j][k]が実際の予
測発生符号量となる。また、未配分のビット数(残りの
ビット数)RNは、それまでの未配分のビット数RNか
ら上記求めたテンポラリtempの値を減算したものとなる
(RN=RN−temp)。そして、横方向のブロック数k
をインクリメント(k=k+1)してステップS10の
処理を終えステップS8に戻る。上記図6のフローによ
り各ブロックの予測発生符号量F[i][j][k]を
得ることができる。
In step S10, the following processes are performed. First, the EOB length EOB [i] corresponding to each component is subtracted from the AC generated code amount AC [i] [j] [k] actually generated in each block and stored in the temporary temp (temp = AC [i]). [J] [k] -EOB
[I]). Here, EOB [i] is subtracted from the AC generated code amount AC [i] [j] [k] generated in each block because EOB is added in order to prevent overflow in later processing. This EO will be done in advance.
The B length is subtracted. Further, a value obtained by multiplying the temporary temp by a predetermined standing RAT is set as a new temporary temp value (temp = temp * RAT [(j + k)).
% 2]). Here, (j + k)% 2 is for switching 0 and 1 in a checkered pattern (see FIGS. 3 and 4) in each block, and the above% 2 is the remainder divided by 2 (0 or 1). Either will be shown). This determines which checkered ratio RAT to use. Further, the value of this temporary temp is shifted to the left by 4 bits (temp = (temp >> 4). Here, shifting to the left by 4 bits is to restore the value multiplied by × 8 in step S1 to the original value. A DC temporary code amount DC [i] [j] [k] obtained at the first time and EOB [i] corresponding to the component are added to the value of the temporary temp to obtain a new temporary te.
As the value of mp (temp = DC [i] [j] [k] + EOB
[I]), and the value of the temporary temp is defined as the generated code amount F [i] [j] [k] of the block (F [i] [j]).
[K] = temp). This F [i] [j] [k] becomes the actual predicted code amount. Further, the unallocated bit number (remaining bit number) RN is obtained by subtracting the value of the temporary temp obtained above from the previously unallocated bit number RN (RN = RN-temp). Then, the number of blocks in the horizontal direction k
Is incremented (k = k + 1) to end the process of step S10 and return to step S8. The predicted generated code amount F [i] [j] [k] of each block can be obtained by the flow of FIG.

【0028】ところで、演算精度が非常に高い装置(例
えば、FPUを使用した画像データ圧縮装置)であれば
図6のアルゴリズムだけで十分な場合もあるが、本実施
例では以下図7及び図8のフローに示すようなアルゴリ
ズムによって余り部分の割振りを行ってより精度の高い
予測発生符号量を求め、画質情報を大幅に向上させるよ
うにしている。
By the way, there is a case where the algorithm shown in FIG. 6 is sufficient for a device having a very high calculation accuracy (for example, an image data compression device using an FPU). The surplus portion is allocated by the algorithm as shown in the flow of (1) to obtain a more accurate predicted code amount, and the image quality information is greatly improved.

【0029】図7において、ステップS11では以下の
ような各処理を行なう。先ず、未配分の残りビット数R
Nを全体のブロック数(V×H×2)で割り全てのブロ
ックに配分するビット数RAを求める(RA=RN/
(V×H×2))。例えば、図9に示すYのブロックに
100ビット、B−Y,R−Yのブロックに夫々50ビ
ット、余りのビット数が380とすると、式2に示すよ
うに余り380を全体のブロック数(100+50+5
0)で割る切り捨ての除算を行って各ブロックに例えば
1ビットずつ分配するビット数RAを求める。 380/(100+50+50)=1=RA…(式2) そして、元の未配分のビット数RNから各ブロックに分
配するビット数(RA×V×H×2)を減算して上記均
等分配で分配しきれなかった余りのビット数RNを求め
る(RN=RN−RA×V×H×2)。
In FIG. 7, in step S11, the following processes are performed. First, the unallocated remaining bit number R
N is divided by the total number of blocks (V × H × 2) to obtain the number of bits RA to be distributed to all blocks (RA = RN /
(V × H × 2)). For example, assuming that the Y block shown in FIG. 9 has 100 bits, the BY and RY blocks each have 50 bits, and the number of remaining bits is 380, the remainder 380 is represented by Equation 2 as a whole block number ( 100 + 50 + 5
The number of bits RA to be distributed to each block, for example, by 1 bit, is obtained by performing division by dividing by 0). 380 / (100 + 50 + 50) = 1 = RA (Equation 2) Then, the number of bits (RA × V × H × 2) to be distributed to each block is subtracted from the original unallocated number of bits RN, and distribution is performed by the above-mentioned equal distribution. A surplus number of bits RN that cannot be completely obtained is obtained (RN = RN−RA × V × H × 2).

【0030】さらに、上記均等分配で分配しきれなかっ
た余りのビット数RNをYのブロック数(V×H)で割
り、Yのブロックのみに均等に分配するビット数YAを
求める(YA=RN/(V×H))。すなわち、Yと色
(C)とは同じ重みがあるのではなくYの方により多く
の符号を割り振ったほうが画質は綺麗になる。従って、
上記余りのビット数RNをYのブロックにだけ分配す
る。上述の例では、YA=RN/(V×H)=180/
100となる。そして、各ブロックに均等に分配した余
りのビット数RNからYのブロックのみに分配するビッ
ト数(YA×V×H)を減算して上記Yのブロックのみ
に均等分配しても分配しきれなかった余りのビット数R
Nを求める(RN=RN−YAV×H)。上述の例で
は、RN=180−100となる。
Further, the surplus number of bits RN that could not be distributed by the above-mentioned even distribution is divided by the number of Y blocks (V × H) to obtain the number of bits YA which is evenly distributed only to the Y blocks (YA = RN). / (VxH)). That is, the image quality becomes better when Y and color (C) do not have the same weight and more codes are assigned to Y. Therefore,
The surplus number of bits RN is distributed only to Y blocks. In the above example, YA = RN / (V × H) = 180 /
It becomes 100. Then, even if the number of bits (YA × V × H) to be distributed only to the Y block is subtracted from the surplus number of bits RN to be uniformly distributed to each block and evenly distributed to only the Y block, the distribution cannot be completed. Remaining number of bits R
Find N (RN = RN-YAV * H). In the above example, RN = 180-100.

【0031】上述したようにYのブロックのみに均等に
分配しているが、それでもまだ余りが生ずる場合があ
る。そこで、上記Yの分配で分配しきれなかった余りの
ビット数RNをV方向のブロック数の4倍で割り、Y,
R−Y,B−Yの一番左側のブロックに2:1:1の割
合で分配するビット数RBを求める(RB=RN/(V
×4)。すなわち、通常は左上のブロックから横方向の
ブロックについて処理を行なうが、右下のブロックに来
たとき余りが多くあってももはや適当な分配を行うこと
はできない。そこで、本実施例では一番左側のブロック
に分配するようにする。このときも、Yの方に多くの符
号を与えるため例えばYはR−Y,B−Yの2倍を与え
るようにし、Y,R−Y,B−Yの一番左側のブロック
に夫々2:1:1の割合で分配する。これを実現するた
め上記RNを(V×4)で割るようにしている。上述の
例で、V=10とすると、RB=80/(10×2+1
0+10)=2となる。そして、Yのブロックで分配し
た余りのビット数RNから全ての左側のブロックに分配
するビット数(RB×4×4)を減算して上記一番左側
のブロックに分配しても分配しきれなかった余りのビッ
ト数RNを求める(RN=RN−RB×V×4)。
As described above, the blocks are evenly distributed only to the Y blocks, but there is still a case that the remainder still occurs. Therefore, the surplus bit number RN that could not be distributed by the above Y distribution is divided by 4 times the number of blocks in the V direction, and Y,
The number of bits RB to be distributed to the leftmost block of RY and BY is calculated at a ratio of 2: 1: 1 (RB = RN / (V
× 4). That is, normally, processing is performed for blocks in the horizontal direction from the upper left block, but appropriate distribution can no longer be performed even if there is a large amount of excess when it comes to the lower right block. Therefore, in this embodiment, the blocks are distributed to the leftmost block. Also in this case, since Y is given a larger number of codes, for example, Y is given twice as much as RY and BY, and the leftmost block of Y, RY, and BY has 2 blocks, respectively. Distribute at a ratio of 1: 1. In order to realize this, the above RN is divided by (V × 4). In the above example, if V = 10, RB = 80 / (10 × 2 + 1
0 + 10) = 2. Then, even if the number of bits (RB × 4 × 4) to be distributed to all left blocks is subtracted from the surplus number of bits RN to be distributed in the Y block and distribution is made to the leftmost block, the distribution cannot be completed. The number of remaining bits RN is obtained (RN = RN-RB * V * 4).

【0032】上述したY,R−Y,B−Yの一番左側の
ブロックに2:1:1の割合で分配する分配によっても
まだ余りが生ずる場合がある。そこで、分配しきれなか
った余りのビット数RNをV方向のブロック数で割り、
Yの一番左側のブロックに均等に分配するビット数YB
を求める(YB=RN/V)。そして、Y,R−Y,B
−Yの一番左側のブロックに分配した余りのビット数R
NからYの一番左側のブロックに分配するビット数(Y
B×V)を減算してYの一番左側のブロックに均等に分
配してもまだ分配しきれなかった余りのビット数RNを
求める(RN=RN−YB×V)。上述したYの一番左
側のブロックに均等に分配してもまだ余りが生ずる場
合、後述するステップS15でその余りはYの左上端の
ブロックに加えてしまうようにする。
Even if the above-mentioned distribution of 2: 1: 1 to the leftmost block of Y, RY, and BY, the remainder may still occur. Therefore, the remaining bit number RN that could not be distributed is divided by the number of blocks in the V direction,
Number of bits YB evenly distributed to the leftmost block of Y
Is calculated (YB = RN / V). And Y, RY, B
-The number of surplus bits R distributed to the leftmost block of Y
Number of bits to distribute to the leftmost block from N to Y (Y
(B × V) is subtracted and evenly distributed to the leftmost block of Y, the remaining bit number RN that cannot be distributed is obtained (RN = RN−YB × V). If there is still a remainder even if it is evenly distributed to the leftmost block of Y described above, the remainder is added to the block at the upper left end of Y in step S15 described later.

【0033】以上によりステップS11の処理を終え、
ステップS12に進む。ステップS12では先ず縦方向
について処理を行うために縦方向のブロック数jを0に
し(j=0)、ステップS13で縦方向のブロック数j
が縦方向の所定ブロック数Vより小さいか(j<Vか)
否かを判別する。縦方向のブロック数jが縦方向の所定
ブロック数V以上のときはステップS14で所定ブロッ
ク数V以上のときはステップS14で発生符号量予測値
F[i][j][k]を求め、縦方向のブロック数jを
インクリメント(j=j+1)してステップS13に戻
る。ここで、上記予測発生符号量F[i][j][k]
のうち[i]がバンク(bank)でありi=0のとき
がY、i=1のときがB−Y,R−Yである。また、
[i]がV(垂直)、[k]がH(水平)方向である。
この場合において、Yの予測発生符号量F[0][j]
[0]は、一度目で求めた予測発生符号量F[0]
[j][0]に、余り分として全ての左端のブロックに
分配するビット数RBを2倍にした値とYの左端のブロ
ックに分配するビット数を加算した値となる(F[0]
[j][0]=F[0][j][0]+RB×2+Y
B)。また、B−Yの予測発生符号量F[1][j]
[0]は、一度目で求めた予測発生符号量F[1]
[j][0]に、余り分として全ての左端のブロックに
分配するビット数RBを加算した値となり(F[1]
[j][1]=F[1][j][0]+RB)、また、
R−Yの予測発生符号量F[1][j][H/2]は、
一度目で求めた予測発生符号量F[1][j][H/
2]に、余り分として全ての左端のブロックに分配する
ビット数RBを加算した値となる(F[1][j]
[0]=F[1][j][H/2])。ここで、図9に
示すようにB−Y,B−Yは2つ合わせてYとなるから
上記R−Yの予測発生符号量の水平[k]は[H/2]
で表される。このようにして、上記ステップS13及び
S14のループで予測発生符号量F[i][j][k]
が縦方向のブロック数Vとなるまで繰り返し算出され、
余りが左端のブロックに全部割り振られることになる。
縦方向のブロック数jが縦方向の所定ブロック数V以上
になると縦方向の全てのブロックの処理が終了したと判
断してステップS15で最終段階の余りRNを左端のブ
ロックの予測発生符号量F[0][0][0]に加えて
(F[0][0][0]=F[0][0][0]+R
N)図8のステップS16に進む。
With the above, the processing of step S11 is completed,
Go to step S12. In step S12, the number of blocks in the vertical direction j is set to 0 (j = 0) in order to perform processing in the vertical direction, and in step S13, the number of blocks in the vertical direction j
Is smaller than the predetermined number of blocks V in the vertical direction (j <V)
Determine whether or not. If the number j of blocks in the vertical direction is greater than or equal to the predetermined number V of blocks in the vertical direction, and in step S14 if the number of blocks in the vertical direction is greater than or equal to the predetermined block number V, the generated code amount prediction value F [i] [j] [k] is obtained. The number of blocks j in the vertical direction is incremented (j = j + 1) and the process returns to step S13. Here, the predicted generated code amount F [i] [j] [k]
Among them, [i] is a bank, and Y is i when i = 0, and BY and RY when i = 1. Also,
[I] is the V (vertical) direction, and [k] is the H (horizontal) direction.
In this case, the predicted generation code amount F [0] [j] of Y
[0] is the predicted generated code amount F [0] obtained at the first time.
[J] [0] is a value obtained by adding a value obtained by doubling the number of bits RB to be distributed to all the leftmost blocks as a remainder and the number of bits to be distributed to the leftmost block of Y (F [0]
[J] [0] = F [0] [j] [0] + RB × 2 + Y
B). In addition, the prediction generated code amount F [1] [j] of BY is used.
[0] is the predicted generated code amount F [1] obtained at the first time.
It becomes a value obtained by adding the number of bits RB to be distributed to all the leftmost blocks as a remainder to [j] [0] (F [1]
[J] [1] = F [1] [j] [0] + RB), and
The predicted generated code amount F [1] [j] [H / 2] of RY is
Predicted code amount F [1] [j] [H /
2] is added with the number of bits RB to be distributed to all leftmost blocks as a remainder (F [1] [j]
[0] = F [1] [j] [H / 2]). Here, as shown in FIG. 9, two BY and BY are combined to be Y, so that the horizontal [k] of the predicted generated code amount of RY is [H / 2].
It is represented by. In this way, the predicted generated code amount F [i] [j] [k] in the loop of steps S13 and S14 described above.
Is repeatedly calculated until V becomes the number of blocks in the vertical direction,
The remainder will be allotted to the leftmost block.
When the number j of blocks in the vertical direction becomes equal to or larger than the predetermined number V of blocks in the vertical direction, it is determined that processing of all blocks in the vertical direction has been completed, and in step S15, the remainder RN at the final stage is set to the prediction generation code amount F of the leftmost block. In addition to [0] [0] [0], (F [0] [0] [0] = F [0] [0] [0] + R
N) Proceed to step S16 in FIG.

【0034】図8のフローでは、前述した余りを全体の
ブロックに均等に分配する処理と、Yのブロックのみに
均等に分配する処理を行なう。すなわち、ステップS1
6で縦方向のブロック数jを0にし(j=0)、ステッ
プS17で縦方向のブロック数jがVより小さいか(j
<Vか)否かを判別する。縦方向のブロック数jが縦方
向の所定ブロック数Vより小さいときはステップS18
で横方向のブロック数kを0にし(k=0)、ステップ
S20で横方向のブロック数kが横方向の所定ブロック
数Hより小さいか(k<Hか)否かを判別する。横方向
のブロック数kが横方向の所定ブロック数H以上のとき
はステップS19で縦方向のブロック数jをインクリメ
ント(j=j+1)してステップS17に戻り、横方向
のブロック数KがHより小さいときはステップS21に
進む。
In the flow shown in FIG. 8, the above-mentioned remainder is equally distributed to all blocks and the Y-block is equally distributed. That is, step S1
In step 6, the vertical block number j is set to 0 (j = 0), and in step S17, the vertical block number j is smaller than V (j
<V)) or not. If the number j of blocks in the vertical direction is smaller than the predetermined number V of blocks in the vertical direction, step S18.
The number k of horizontal blocks is set to 0 (k = 0), and it is determined in step S20 whether the number k of horizontal blocks is smaller than a predetermined number H of horizontal blocks (k <H). When the number k of blocks in the horizontal direction is equal to or greater than the predetermined number H of blocks in the horizontal direction, the number j of blocks in the vertical direction is incremented (j = j + 1) in step S19, and the process returns to step S17. If it is smaller, the process proceeds to step S21.

【0035】ステップS21では、前段の処理で既に算
出されているYの予測発生符号量F[0][j][k]
に、全てのブロックに分配するビット数RAとYのブロ
ックに分配するビット数YAを加算しYの予測発生符号
量F[0][j][k]を求めるとともに(F[0]
[j][k]=F[0][j][k]+RA+YA)、
前段のステップで既に算出されているCの予測発生符号
量F[1][j][k]に、全てのブロックに分配する
ビット数RAを加算しCのブロックに分配するビット数
YAを加算してYの予測発生符号量F[1][j]
[k]を求め(F[1][j][k]=F[1][j]
[k]+RA+YA)、横方向のブロック数kをインク
リメント(k=k+1)してステップS20に戻る。
In step S21, the predicted generated code amount F [0] [j] [k] of Y which has already been calculated in the preceding process.
And the number of bits RA to be distributed to all blocks and the number of bits YA to be distributed to blocks of Y are added to obtain the predicted generation code amount F [0] [j] [k] of Y and (F [0]
[J] [k] = F [0] [j] [k] + RA + YA),
The number of bits RA to be distributed to all blocks is added to the prediction generated code amount F [1] [j] [k] of C already calculated in the previous step, and the number of bits YA to be distributed to the block of C is added. Then, the predicted generated code amount F [1] [j] of Y
[K] is calculated (F [1] [j] [k] = F [1] [j]
[K] + RA + YA), the horizontal block number k is incremented (k = k + 1), and the process returns to step S20.

【0036】上記各ステップを繰り返し処理し、ステッ
プS17で縦方向のブロック数jがV以上になるとY,
Cの全てのブロックについての予測発生符号量の算出が
済んだと判断して本フローの処理を終了する。
Each of the above steps is repeatedly processed, and when the number of blocks j in the vertical direction becomes V or more in step S17, Y,
When it is determined that the predicted generated code amount has been calculated for all blocks of C, the process of this flow ends.

【0037】以上説明したように、本画像データ圧縮装
置30は、算出した予測値の総和と目標とする発生符号
量との差を求め、余りを全体のブロック数で割り、各ブ
ロックに均等に分配し、さらに、その余りをYのブロッ
ク数で割り、Yのブロックのみに均等に分配し、また、
そのさらに余りをV方向のブロック数の4倍で割り、
Y,R−Y,B−Yの一番左側のブロックに2:1:1
の割合で分配するとともに、その余りを、Yの一番左側
のブロックに均等に分配し、さらにその余りは、Yの左
上端のブロックに加えるようにして各ブロックの予測発
生符号量を得ているので、予測より発生符号量が多かっ
たときに画質が著しく劣化する不具合を防止することが
でき、余りを適切に分配して画質を高めることができ
る。
As described above, the image data compressing apparatus 30 obtains the difference between the sum of the calculated predicted values and the target generated code amount, divides the remainder by the total number of blocks, and evenly distributes each block. And further divide the remainder by the number of Y blocks to evenly distribute only to the Y blocks, and
Divide the remainder by 4 times the number of blocks in the V direction,
2: 1: 1 in the leftmost block of Y, RY, BY
And the remainder is evenly distributed to the leftmost block of Y, and the remainder is added to the block at the upper left corner of Y to obtain the predicted generated code amount of each block. Therefore, it is possible to prevent the problem that the image quality is significantly deteriorated when the generated code amount is larger than the prediction, and it is possible to appropriately distribute the surplus to enhance the image quality.

【0038】また、本実施例では、一度目の圧縮時に2
つの量子化テーブル51と53,52と54を用いるこ
とによって量子化テーブルの変更による発生符号量の変
化の予測を行ない目標とする発生する符号量に最適な量
子化テーブルを作成し、二度目の圧縮によって目標とす
る符号量に圧縮するようにしているので、従来3度の
“DCT→量子化→符号化”シーケンスにより符号化制
御を行っていたものを、二度の動作で済ますことができ
処理の大幅な高速化を図ることができる。なお、本実施
例では、図6〜図8に示したアルゴリズムによって余り
を分配するようにしているが、必ずしも本実施例で述べ
た全ての分配方法を開示した順番で行うものでなくても
よい。例えば、余りを各ブロックに均等に分配した後、
その余りをYの一番左側のブロックに加えるだけの態様
でもよい。
Further, in this embodiment, when the first compression is performed, 2
By using one of the quantization tables 51 and 53 and 52 and 54, the change in the generated code amount due to the change of the quantization table is predicted, and the optimum quantization table for the target generated code amount is created. Since it is designed to compress to the target code amount by compression, it is possible to do the operation that was previously performed with the "DCT → quantization → encoding" sequence of 3 times in 2 operations. The processing speed can be significantly increased. Although the remainder is distributed by the algorithm shown in FIGS. 6 to 8 in this embodiment, it is not always necessary to perform all the distribution methods described in this embodiment in the disclosed order. .. For example, after evenly distributing the remainder to each block,
A mode in which the remainder is simply added to the leftmost block of Y may be used.

【0039】なお、本実施例では複数種の量子化テーブ
ルを用いているが、余りの割振りを行なうものであれば
複数種の量子化テーブルを使用するものに限定されない
ことは勿論である。
Although a plurality of types of quantization tables are used in the present embodiment, it goes without saying that a plurality of types of quantization tables are used as long as the remainder is allocated.

【0040】また、本実施例では画像データ圧縮装置を
JPEGアルゴリズムに基づく画像データ圧縮装置に適
用した例であるが、勿論これには限定されず、発生符号
量の制御を行なうものであれば全ての装置に適用可能で
あることは言うまでもない。また、量子化テーブルを用
いるものであれば何でもよく、その作成の仕方も本実施
例に限定されない。
In the present embodiment, the image data compression apparatus is applied to the image data compression apparatus based on the JPEG algorithm, but the present invention is not limited to this, and any apparatus can be used as long as it controls the generated code amount. Needless to say, it can be applied to the above device. Further, any method may be used as long as it uses a quantization table, and the method of creating the quantization table is not limited to that in this embodiment.

【0041】また、本実施例は符号化部にハフマン符号
化方法を用いているが、これに限らず、例えばハフマン
符号のようなブロック符号に代えてエントロピー符号化
として算術符号を用いるようにしてもよく、算術符号の
一種であるQ−Coderを用いてもよい。
In the present embodiment, the Huffman coding method is used in the coding unit. However, the present invention is not limited to this. For example, an arithmetic code may be used as entropy coding instead of a block code such as Huffman code. Alternatively, Q-Coder, which is a type of arithmetic code, may be used.

【0042】また、本実施例では、変換符号化方式にD
CTを適用しているが、このDCT方式には限定され
ず、例えば、アダマール変換、ハール(Harr)変換、傾
斜変換(スラント変換)、対称性サイン変換などを用い
た画像データ圧縮装置に適用することができる。
Further, in this embodiment, the conversion coding method is set to D.
Although CT is applied, the present invention is not limited to this DCT method, and is applied to, for example, an image data compression device using Hadamard transform, Harr transform, gradient transform (slant transform), symmetric sine transform, or the like. be able to.

【0043】さらに、上記画像データ圧縮装置30や量
子化装置33等を構成する回路や部材の数、種類などは
前述した実施例に限られないことは言うまでもない。
Further, it goes without saying that the numbers and types of circuits and members constituting the image data compression device 30 and the quantization device 33 are not limited to those in the above-mentioned embodiment.

【0044】[0044]

【発明の効果】請求項1、2、3及び4記載の発明によ
れば、算出された予測値の総和と目標とする発生符号量
の差の余りを各ブロックに分配する各ブロック分配手段
と、前記余りを輝度情報(Y)のブロックに分配するY
ブロック分配手段と、前記余りを輝度情報(Y)及び色
情報(R−Y,B−Y)の左端のブロックに所定の割合
で分配するY,R−Y,B−Yブロック分配手段と、前
記余りを輝度情報(Y)の左端のブロックに分配するY
左端ブロック分配手段と、前記余りを輝度情報(Y)の
左上端のブロックに分配するY左上端ブロック分配手段
と、の各ブロック分配手段のうち、少なくとも何れか1
つ以上のブロック分配手段を備えているので、発生符号
量の余りを適切に分配することができ、符号量制御にお
ける画質を高めることができる。
According to the invention described in claims 1, 2, 3 and 4, each block distributing means distributes the remainder of the difference between the sum of the calculated predicted values and the target generated code amount to each block. , Y for distributing the remainder to blocks of luminance information (Y)
Block distribution means, and Y, RY, BY block distribution means for distributing the remainder to the leftmost block of luminance information (Y) and color information (RY, BY) at a predetermined ratio. Y to distribute the remainder to the leftmost block of luminance information (Y)
At least one of the leftmost block distributing means and the left uppermost block distributing means for distributing the remainder to the upper leftmost block of the luminance information (Y).
Since one or more block distributing means are provided, the remainder of the generated code amount can be appropriately distributed, and the image quality in the code amount control can be improved.

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

【図1】画像データ圧縮装置のブロック構成図である。FIG. 1 is a block configuration diagram of an image data compression device.

【図2】画像データ圧縮装置の量子化装置のブロック構
成図である。
FIG. 2 is a block configuration diagram of a quantization device of an image data compression device.

【図3】画像データ圧縮装置のY用量子化テーブルを示
す図である。
FIG. 3 is a diagram showing a Y quantization table of the image data compression apparatus.

【図4】画像データ圧縮装置のR−Y,B−Y用テーブ
ルを示す図である。
FIG. 4 is a diagram showing RY and BY tables of the image data compression apparatus.

【図5】画像データ圧縮装置の量子化テーブルの一例で
ある。
FIG. 5 is an example of a quantization table of the image data compression device.

【図6】画像データ圧縮装置の発生符号量の予測処理を
示すフローチャートである。
FIG. 6 is a flowchart showing a prediction process of a generated code amount of the image data compression device.

【図7】画像データ圧縮装置の発生符号量の予測処理を
示すフローチャートである。
FIG. 7 is a flowchart showing a prediction process of a generated code amount of the image data compression device.

【図8】画像データ圧縮装置の発生符号量の予測処理を
示すフローチャートである。
FIG. 8 is a flowchart showing a prediction process of a generated code amount of the image data compression device.

【図9】画像データ圧縮装置のY,B−Y,R−Yのブ
ロックの構造を示す図である。
FIG. 9 is a diagram showing a structure of Y, BY, and RY blocks of the image data compression device.

【図10】従来の画像データ圧縮装置のブロック構成図
である。
FIG. 10 is a block diagram of a conventional image data compression device.

【図11】従来の画像データ圧縮装置の量子化装置のブ
ロック構成図である。
FIG. 11 is a block configuration diagram of a quantization device of a conventional image data compression device.

【図12】従来の画像データ圧縮装置のY用量子化テー
ブルを示す図である。
FIG. 12 is a diagram showing a Y quantization table of a conventional image data compression apparatus.

【図13】従来の画像データ圧縮装置のR−Y,B−Y
用量子化テーブルを示す図である。
FIG. 13 shows RY and BY of a conventional image data compression device.
It is a figure which shows the quantization table for.

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

30 画像データ圧縮装置 31 フレームメモリ 32 DCT演算装置 33 量子化装置 34 ハフマン符号化器 35 DC符号量メモリ 36 AC符号量メモリ 37 DC総発生符号量記憶メモリ 38,39 ACテーブル別総発生符号量記憶メモリ 40 CPU 41〜44 量子化テーブルRAM 45 乗算器 51〜54 量子化テーブル 30 image data compression device 31 frame memory 32 DCT operation device 33 quantizer 34 Huffman encoder 35 DC code amount memory 36 AC code amount memory 37 DC total generated code amount storage memory 38, 39 total generated code amount by AC table Memory 40 CPU 41-44 Quantization table RAM 45 Multiplier 51-54 Quantization table

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 画像データを変換符号化する変換符号化
手段と、 量子化演算に用いる量子化テーブルを記憶する量子化テ
ーブル記憶手段と、 前記変換符号化手段から出力された信号を前記量子化テ
ーブルに基づいて量子化する量子化手段と、 前記量子化手段により量子化された成分を各ブロックの
予測発生符号量に従って符号化する符号化手段と、 符号化時に各ブロックにおいて発生したDC成分及びA
C成分の符号量を記憶する符号量記憶手段と、 前記DC成分及びAD成分の符号量の総和を算出する総
発生符号量算出手段と、 前記総発生符号量算出手段により算出された総発生符号
量を記憶する総発生符号量記憶手段とを備えた画像デー
タ圧縮装置であって、 前記総発生符号量算出手段により算出された予測値の総
和と目標とする発生符号量の差を余りとして求め、該余
りを全体のブロック数で割り各ブロックに分配する各ブ
ロック分配手段と、 前記余りを輝度情報(Y)のブロックに分配するYブロ
ック分配手段と、 前記余りを輝度情報(Y)及び色情報(R−Y,B−
Y)の左端のブロックに所定の割合で分配するY,R−
Y,B−Yブロック分配手段と、 前記余りを輝度情報(Y)の左端のブロックに分配する
Y左端ブロック分配手段と、 前記余りを輝度情報(Y)の左上端のブロックに分配す
るY左上端ブロック分配手段と、の各ブロック分配手段
のうち、少なくとも何れか1つ以上のブロック分配手段
を具備したことを特徴とする画像データ圧縮装置。
1. A transform coding means for transform coding image data, a quantization table storage means for storing a quantization table used in a quantization operation, and a signal output from the transform coding means for quantizing the signal. Quantizing means for quantizing based on a table, coding means for coding the components quantized by the quantizing means according to the predicted generated code amount of each block, DC component generated in each block at the time of coding, and A
A code amount storage unit that stores the code amount of the C component, a total generated code amount calculation unit that calculates the sum of the code amounts of the DC component and the AD component, and a total generated code amount calculated by the total generated code amount calculation unit. An image data compression apparatus comprising a total generated code amount storage means for storing an amount, wherein a difference between a total sum of predicted values calculated by the total generated code amount calculation means and a target generated code amount is obtained as a remainder. , Each block distributing means for dividing the remainder by the total number of blocks and distributing it to each block, Y block distributing means for distributing the remainder to blocks of luminance information (Y), and the remainder for luminance information (Y) and color Information (RY, B-
Y), which is distributed to the leftmost block of Y) at a predetermined ratio,
Y, BY block distributing means, Y left end block distributing means for distributing the remainder to the leftmost block of luminance information (Y), and Y upper left for distributing the remainder to the upper left block of luminance information (Y) An image data compression apparatus comprising at least one or more block distributing means among the end block distributing means and the block distributing means.
【請求項2】 画像データを変換符号化する変換符号化
手段と、 量子化演算に用いる量子化テーブルを記憶する量子化テ
ーブル記憶手段と、 前記変換符号化手段から出力された信号を前記量子化テ
ーブルに基づいて量子化する量子化手段と、 前記量子化手段により量子化された成分を各ブロックの
予測発生符号量に従って符号化する符号化手段と、 符号化時に各ブロックにおいて発生したDC成分及びA
C成分の符号量を記憶する符号量記憶手段と、 前記DC成分及びAD成分の符号量の総和を算出する総
発生符号量算出手段と、 前記総発生符号量算出手段により算出された総発生符号
量を記憶する総発生符号量記憶手段とを備えた画像デー
タ圧縮装置であって、 先ず、前記総発生符号量算出手段により算出された予測
値の総和と目標とする発生符号量の差を余りとして求
め、該余りを全体のブロック数で割り各ブロックに分配
し、その余りを輝度情報(Y)のブロックに分配し、さ
らにその余りを輝度情報(Y)及び色情報(R−Y,B
−Y)の左端のブロックに所定の割合で分配し、さらに
その余りを輝度情報(Y)の左端のブロックに分配し、
さらにその余りを輝度情報(Y)の左上端のブロックに
分配するようにしたことを特徴とする画像データ圧縮方
法。
2. A transform coding means for transform coding image data, a quantization table storage means for storing a quantization table used for a quantization operation, and a signal output from the transform coding means for the quantization. Quantizing means for quantizing based on a table, coding means for coding the components quantized by the quantizing means according to the predicted generated code amount of each block, DC component generated in each block at the time of coding, and A
A code amount storage unit that stores the code amount of the C component, a total generated code amount calculation unit that calculates the sum of the code amounts of the DC component and the AD component, and a total generated code amount calculated by the total generated code amount calculation unit. An image data compression apparatus comprising a total generated code amount storage means for storing an amount, wherein a difference between a total sum of predicted values calculated by the total generated code amount calculation means and a target generated code amount is left over. Then, the remainder is divided by the total number of blocks and distributed to each block, the remainder is distributed to blocks of luminance information (Y), and the remainder is further divided into luminance information (Y) and color information (RY, B).
-Y) is distributed to the left end block of the luminance information (Y) at a predetermined ratio, and the remainder is distributed to the left end block of the luminance information (Y),
Further, the image data compression method is characterized in that the remainder is distributed to the upper left block of the luminance information (Y).
【請求項3】 前記変換符号化手段は、画像データに対
して離散コサイン変換を実行する離散コサイン変換演算
であることを特徴とする請求項1又は請求項2の何れか
に記載の画像データ圧縮装置。
3. The image data compression method according to claim 1, wherein the transform coding means is a discrete cosine transform operation for performing a discrete cosine transform on the image data. apparatus.
【請求項4】 前記符号化手段は、確率分布が与えられ
た情報源に対してコンパクト符号を構成するハフマン符
号化を行なうことを特徴とする請求項1又は請求項2の
何れかに記載の画像データ圧縮装置及び画像データ圧縮
方法。
4. The encoding device according to claim 1, wherein the encoding means performs Huffman encoding forming a compact code on an information source given a probability distribution. Image data compression apparatus and image data compression method.
JP8284792A 1992-03-03 1992-03-03 Picture data compressing device and method thereof Pending JPH05252535A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP8284792A JPH05252535A (en) 1992-03-03 1992-03-03 Picture data compressing device and method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP8284792A JPH05252535A (en) 1992-03-03 1992-03-03 Picture data compressing device and method thereof

Publications (1)

Publication Number Publication Date
JPH05252535A true JPH05252535A (en) 1993-09-28

Family

ID=13785778

Family Applications (1)

Application Number Title Priority Date Filing Date
JP8284792A Pending JPH05252535A (en) 1992-03-03 1992-03-03 Picture data compressing device and method thereof

Country Status (1)

Country Link
JP (1) JPH05252535A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0720379A2 (en) * 1994-12-28 1996-07-03 Canon Kabushiki Kaisha Encoding method and device therefor
US6389073B1 (en) 1998-04-07 2002-05-14 Matsushita Electric Industrial Co. Ltd Coding control method, coding control apparatus and storage medium containing coding control program
JP2013247683A (en) * 2012-05-24 2013-12-09 Fujitsu Ltd Method and device for compressing image

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0720379A2 (en) * 1994-12-28 1996-07-03 Canon Kabushiki Kaisha Encoding method and device therefor
EP0720379A3 (en) * 1994-12-28 1998-05-20 Canon Kabushiki Kaisha Encoding method and device therefor
US5883976A (en) * 1994-12-28 1999-03-16 Canon Kabushiki Kaisha Selectively utilizing multiple encoding methods
US6389073B1 (en) 1998-04-07 2002-05-14 Matsushita Electric Industrial Co. Ltd Coding control method, coding control apparatus and storage medium containing coding control program
JP2013247683A (en) * 2012-05-24 2013-12-09 Fujitsu Ltd Method and device for compressing image

Similar Documents

Publication Publication Date Title
JP2797159B2 (en) Image data compression apparatus and image data compression method
US7548583B2 (en) Generation and use of masks in MPEG video encoding to indicate non-zero entries in transformed macroblocks
EP0514663A2 (en) An apparatus and method for motion video encoding employing an adaptive quantizer
JPWO2009157580A1 (en) Image processing apparatus and image processing method
JPH11127355A (en) Device and method for encoding image and recording medium recording image encoding program
JP2003304404A (en) Image encoder
JPH10243399A (en) Code amount controller and moving image encoder provided with the same
JP2516082B2 (en) Data compression device
JPH05252535A (en) Picture data compressing device and method thereof
JP3681828B2 (en) Code amount control method and apparatus for image data
US6859562B2 (en) Coded data length detection apparatus, method of the same, and image coding apparatus
JP2000165861A (en) Moving image decoding device
JP3304998B2 (en) Image processing method and apparatus
JP3175324B2 (en) Image compression device
JPH05276391A (en) Method for compressing picture and device therefor
JP2820807B2 (en) Image data encoding method
JPH0310486A (en) Moving picture encoder
JPH04271664A (en) Picture data compressor and picture data decoder
JPH05276392A (en) Method for compressing picture and device therefor
JP3191950B2 (en) Image coding device
JPH06113142A (en) Method and device for processing picture
KR100202957B1 (en) Quantizatizer
JP3044877B2 (en) Encoding device
JP3032281B2 (en) Image encoding method and image decoding method
JP2003304401A (en) Image encoder