[go: up one dir, main page]

JP2019047154A - Image coding apparatus and control method thereof - Google Patents

Image coding apparatus and control method thereof Download PDF

Info

Publication number
JP2019047154A
JP2019047154A JP2017164596A JP2017164596A JP2019047154A JP 2019047154 A JP2019047154 A JP 2019047154A JP 2017164596 A JP2017164596 A JP 2017164596A JP 2017164596 A JP2017164596 A JP 2017164596A JP 2019047154 A JP2019047154 A JP 2019047154A
Authority
JP
Japan
Prior art keywords
block
encoding
encoded data
data
image
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
JP2017164596A
Other languages
Japanese (ja)
Inventor
友希 白石
Yuki Shiraishi
友希 白石
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.)
Canon Inc
Original Assignee
Canon Inc
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 Canon Inc filed Critical Canon Inc
Priority to JP2017164596A priority Critical patent/JP2019047154A/en
Publication of JP2019047154A publication Critical patent/JP2019047154A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

【課題】1ブロック当たりの符号化データ量を目標符号量以下になることを保証しつつ、一定画質の画像の生成を保証した符号化データを生成する。【解決手段】画像データを複数画素で構成されるブロックに分割して可逆符号化データを生成し、可逆符号化データの符号量が目標符号量を超える場合には、超過したデータを除いて得た非可逆符号化データを着目ブロックの符号化データとして生成し、可逆符号化データの符号量が目標符号量以下の場合には、可逆符号化データを着目ブロックの符号化データとして生成する第1の符号化部と、第1の符号化部によるブロックの符号化にて、目標符号量に満たない符号化データが発生するたびに、目標符号量に対する余剰データ容量をカウントし、画像データに対する第1の符号化部による符号化を終えた場合、余剰データ容量に対応する符号化データを、第1の符号化部で得た符号化データに付加して出力する符号量制御部とを有する。【選択図】図1Encoded data that guarantees the generation of an image with a constant image quality while ensuring that the amount of encoded data per block is equal to or less than the target code amount. Image data is divided into blocks composed of a plurality of pixels to generate lossless encoded data, and when the code amount of lossless encoded data exceeds a target code amount, the excess data is excluded. First lossy encoded data is generated as encoded data of the target block, and when the code amount of the lossless encoded data is equal to or smaller than the target code amount, the lossless encoded data is generated as encoded data of the target block. Each time encoded data less than the target code amount is generated in the block encoding by the encoding unit and the first encoding unit, the surplus data capacity for the target code amount is counted, and A code amount control unit that outputs the encoded data corresponding to the surplus data capacity in addition to the encoded data obtained by the first encoding unit when encoding by the first encoding unit is completed. [Selection] Figure 1

Description

本発明は画像データの符号化技術に関するものである。   The present invention relates to an image data encoding technique.

従来、画像データを画像全面、又は、所定単位毎に決まった符号量(またはそれ以下)になるよう符号化する、固定長符号化技術が知られている。固定長符号化の方法として、ブロック毎に画像特徴IDと、画像特徴に応じた量子化値を持つことで、各ブロックに対して固定長符号化を実現する方法がある(特許文献1)。この方法によれば、高解像度で低階調なブロックや低解像度で高階調なブロックが混在している画像に対しても、各ブロックに対して適切な量子化が行われ、画質良く固定長符号化できる。   2. Description of the Related Art Conventionally, a fixed-length encoding technique is known that encodes image data so that the entire image or a predetermined code amount (or less) is determined for each predetermined unit. As a fixed-length encoding method, there is a method for realizing fixed-length encoding for each block by having an image feature ID for each block and a quantization value corresponding to the image feature (Patent Document 1). According to this method, appropriate quantization is performed on each block even for images with both high-resolution, low-gradation blocks and low-resolution, high-gradation blocks. Can be encoded.

また、所定単位毎に可逆符号化で目標符号量に収まる場合には可逆符号化データを出力し、目標符号量を超える場合には、量子化や符号化データの打ち切りを行うことで符号量制御を行うような方法もある(特許文献2)。この方法によれば、所定単位毎に、適切な符号長を割り当てつつ、符号量制御が可能である。   In addition, when the lossless encoding is within the target code amount for each predetermined unit, the lossless encoded data is output, and when the target code amount is exceeded, the code amount control is performed by performing quantization or truncation of the encoded data. There is also a method of performing (Patent Document 2). According to this method, code amount control can be performed while assigning an appropriate code length for each predetermined unit.

特開2016−63282号公報Japanese Patent Laid-Open No. 2006-63282 特開2001−86502号公報JP 2001-86502 A

しかしながら、特許文献1では、画像内の全ブロックについて、同じ符号長で符号化する。そのため、ブロック内が1色で構成されているようなエントロピーの低いブロックの場合には、余分に符号を割り当ててしまうことになる。逆に、複雑なテクスチャーなど、エントロピーの高いブロックに対しては、過剰に画質を劣化させている可能性がある。特許文献2では、符号量の少ない所定単位に対して、必要以上に符号が削減されないような機構や、画質に大きな影響を与える係数については削減しないなど言及しているが、一定以上の画質を保証できるような機構は保持していない。   However, in patent document 1, it encodes with the same code length about all the blocks in an image. Therefore, in the case of a block with low entropy such that the block is composed of one color, an extra code is allocated. Conversely, for high entropy blocks such as complex textures, there is a possibility that image quality is excessively degraded. Patent Document 2 mentions a mechanism that does not reduce the code more than necessary for a predetermined unit with a small code amount, and a coefficient that greatly affects the image quality. It does not have a mechanism that can be guaranteed.

本発明は上記問題に鑑みなされたものであり、ブロック単位の符号化を行う符号化であって、1ブロック当たりの符号化データ量が目標符号量以下になることを保証しつつ、且つ、一定画質の画像の生成を保証した符号化データを生成する技術を提供しようとするものである。   The present invention has been made in view of the above problems, and is encoding that performs encoding in units of blocks, and ensures that the amount of encoded data per block is equal to or less than the target code amount and is constant. An object of the present invention is to provide a technique for generating encoded data that guarantees the generation of an image of high image quality.

この課題を解決するため、例えば本発明の画像符号化装置は以下の構成を備える。すなわち、
画像を符号化する画像符号化装置であって、
画像データを複数画素で構成されるブロックに分割する分割手段と、
該分割手段で得た着目ブロックから可逆符号化データを生成し、当該可逆符号化データの符号量が目標符号量を超える場合には、超過したデータをメモリに記憶すると共に前記超過したデータを除いて得た非可逆符号化データを前記着目ブロックの符号化データとして生成し、前記可逆符号化データの符号量が前記目標符号量以下の場合には、当該可逆符号化データを前記着目ブロックの符号化データとして生成する第1の符号化手段と、
前記メモリに格納された前記超過したデータを符号化する第2の符号化手段と、
前記第1の符号化手段によるブロックの符号化にて、前記目標符号量に満たない符号化データが発生するたびに、前記目標符号量に対する余剰データ容量をカウントするカウント手段と、
前記画像データに対する前記第1の符号化手段による符号化を終えた場合、前記第2の符号化手段で生成された符号化データのうち前記カウント手段でカウントした余剰データ容量に対応する符号化データを、前記第1の符号化手段で得た符号化データに付加して出力する符号量制御手段とを有する。
In order to solve this problem, for example, an image encoding device of the present invention has the following configuration. That is,
An image encoding device for encoding an image, comprising:
A dividing means for dividing the image data into blocks composed of a plurality of pixels;
When lossless encoded data is generated from the block of interest obtained by the dividing means and the code amount of the lossless encoded data exceeds the target code amount, the excess data is stored in the memory and the excess data is removed. When the lossless encoded data is generated as encoded data of the block of interest and the code amount of the lossless encoded data is less than or equal to the target code amount, the lossless encoded data is converted to the code of the block of interest. First encoding means for generating as encoded data;
Second encoding means for encoding the excess data stored in the memory;
Counting means for counting an excess data capacity with respect to the target code amount each time encoded data less than the target code amount is generated in the block encoding by the first encoding unit;
Encoded data corresponding to the surplus data capacity counted by the counting unit among the encoded data generated by the second encoding unit when the encoding by the first encoding unit is completed for the image data Is added to the encoded data obtained by the first encoding means and output.

本発明によれば、ブロック単位の符号化を行う符号化であって、1ブロック当たりの符号化データ量を目標符号量以下になることを保証しつつ、且つ、一定画質の画像の生成を保証した符号化データを生成することができる。   According to the present invention, encoding is performed in units of blocks, and the amount of encoded data per block is ensured to be equal to or less than the target code amount, and the generation of an image with a constant image quality is guaranteed. Encoded data can be generated.

第1の実施形態に係る画像符号化装置の構成を示すブロック図。1 is a block diagram showing a configuration of an image encoding device according to a first embodiment. 第1の実施形態に係る固定長符号化部の処理を示すフローチャート。The flowchart which shows the process of the fixed length encoding part which concerns on 1st Embodiment. 第1の実施形態に係るオーバービット符号化部の処理を示すフローチャート。The flowchart which shows the process of the overbit encoding part which concerns on 1st Embodiment. 符号化対象ブロックの例を示す図。The figure which shows the example of an encoding object block. 符号化対象ブロックの符号化データの例を示す図。The figure which shows the example of the encoding data of an encoding object block. 符号化対象ブロックと符号化データのデータ長の関係を示す図。The figure which shows the relationship between the encoding object block and the data length of encoding data. オーバーブロックとオーバービット符号化データの関係を示す図。The figure which shows the relationship between an overblock and overbit coding data. 符号化対象の画像データとブロックの関係を示す図。The figure which shows the relationship between the image data of encoding object, and a block. 第1の実施形態に係る符号化データの構造を示す図。The figure which shows the structure of the encoding data which concern on 1st Embodiment. 第2の実施形態に係る符号化データの構造を示す図。The figure which shows the structure of the coding data which concern on 2nd Embodiment. 第2の実施形態に係る画像符号化装置の処理を示すフローチャート。The flowchart which shows the process of the image coding apparatus which concerns on 2nd Embodiment. 第3の実施形態に係る符号化データの構造を示す図。The figure which shows the structure of the coding data which concern on 3rd Embodiment. 第4の実施形態に係る画像符号化装置の構成を示すブロック図。The block diagram which shows the structure of the image coding apparatus which concerns on 4th Embodiment. 第4の実施形態に係る符号化処理の流れを示すフローチャート。The flowchart which shows the flow of the encoding process which concerns on 4th Embodiment. サブサンプリングの一例を示す図。The figure which shows an example of subsampling. 複雑度の変動が平坦な例を示す図。The figure which shows the example whose fluctuation | variation of complexity is flat. 複雑度に対するブロック毎の固定長の設定値の例を示す図。The figure which shows the example of the setting value of the fixed length for every block with respect to complexity. ROIとブロックの関係を示す図。The figure which shows the relationship between ROI and a block. 第5の実施形態の固定長の設定値の例を示す図。The figure which shows the example of the setting value of the fixed length of 5th Embodiment.

以下添付図面に従って本発明に係る実施形態を詳細に説明する。なお、以下の実施形態は本発明を限定するものではなく、また、本実施形態で説明されている特徴の組み合わせの全てが本発明の解決手段に必須のものとは限らない。なお、同一の構成については、同じ符号を付して説明する。   Embodiments according to the present invention will be described below in detail with reference to the accompanying drawings. The following embodiments do not limit the present invention, and all the combinations of features described in the present embodiment are not necessarily essential to the solution means of the present invention. In addition, about the same structure, the same code | symbol is attached | subjected and demonstrated.

[第1の実施形態]
本第1の実施形態では、画像符号化の際に、ブロック単位の固定長以下の符号化と、固定長を超えるビットの符号化を分けて行う。固定長以下の符号化の際には、ビット単位での処理を必要とせず、簡易な方法で符号化が可能となる。また、固定長を超えるビットの符号化については、非圧縮でデータを保持しておき、符号量制御時にビット単位での制御を行う。これにより、所定単位毎に符号長が固定長以下になるよう符号量制御することを可能としつつ、一定以上の画質を保証する。以下、その具体的な例を説明する。
[First Embodiment]
In the first embodiment, when encoding an image, encoding that is not more than a fixed length in units of blocks and encoding of bits that exceed the fixed length are performed separately. When encoding at a fixed length or less, processing in bit units is not required, and encoding can be performed with a simple method. For encoding of bits exceeding the fixed length, the data is held without compression, and control is performed in units of bits at the time of code amount control. As a result, it is possible to control the amount of code so that the code length becomes a fixed length or less for each predetermined unit, while ensuring a certain level of image quality. A specific example will be described below.

実施形態における画像符号化装置はデジタルカメラ等の撮像装置に内蔵されるものとして説明する。つまり、符号化対像は、撮像装置が有する撮像部で得た画像とする。なお、撮像装置以外の装置に適用しても構わない。また、符号化対象の画像は記憶媒体に記憶されていても良いし、ネットワーク上のファイルサーバに格納されていても構わない。撮像装置に適用するのは、具現化することで実施形態の技術の理解を容易にするためであり、あくまで例示であると理解されたい。   The image encoding apparatus in the embodiment will be described as being built in an imaging apparatus such as a digital camera. That is, the encoded counter image is an image obtained by the imaging unit included in the imaging device. In addition, you may apply to apparatuses other than an imaging device. Also, the image to be encoded may be stored in a storage medium or stored in a file server on the network. It is to be understood that the present invention is applied to the imaging apparatus in order to facilitate the understanding of the technology of the embodiment by being embodied, and is merely an example.

図1は本第1の実施形態にかかる符号化処理の構成を示すブロック図である。図1に示すように、本実施形態の符号化装置は、入力部101、符号化部100、符号量制御部106、符号列形成部107、出力部108を有する。また、符号化部100は、ブロック分割部102、ブロック符号化部103、オーバービット符号化部104、バッファ(メモリ)105を有する。   FIG. 1 is a block diagram showing a configuration of an encoding process according to the first embodiment. As illustrated in FIG. 1, the encoding apparatus according to the present exemplary embodiment includes an input unit 101, an encoding unit 100, a code amount control unit 106, a code string forming unit 107, and an output unit 108. The encoding unit 100 includes a block dividing unit 102, a block encoding unit 103, an overbit encoding unit 104, and a buffer (memory) 105.

入力部101は、デジタルカメラが有する不図示の撮像素子で撮影された画像データを入力する。入力される画像は、R、G0、G1、Bのベイヤ配列の画素で構成されるRAW画像データであり、1画素(1成分)は14ビットで表されるものとする。また、入力部101は、入力したRAW画像データから、R成分の画素のみで構成されるRプレーン、G0成分の画素のみで構成されるG0プレーン、G1成分の画素のみで構成されるG1プレーン、そして、B成分の画素のみで構成されるBプレーンを生成する。そして、入力部101は、生成した各プレーンを符号化部100に供給する。つまり、入力部101は、撮像素子で得られた1枚のRAW画像データから、4回に分けて生成した各プレーンを符号化部100に供給する。なお、生成するプレーンの順番は特に問わないが、R,G0,G1,Bのプレーンの順とする。   The input unit 101 inputs image data captured by an image sensor (not shown) included in the digital camera. The input image is RAW image data composed of pixels in a Bayer array of R, G0, G1, and B, and one pixel (one component) is represented by 14 bits. Further, the input unit 101, from the input RAW image data, R plane composed only of R component pixels, G0 plane composed only of G0 component pixels, G1 plane composed only of G1 component pixels, Then, a B plane composed only of B component pixels is generated. The input unit 101 supplies the generated planes to the encoding unit 100. That is, the input unit 101 supplies each plane generated in four steps from one piece of RAW image data obtained by the image sensor to the encoding unit 100. The order of the planes to be generated is not particularly limited, but the order of R, G0, G1, and B planes is used.

上記の通りなので、実施形態における符号化部100は、入力部101から供給される画像データが1画素1成分のモノクロ画像データであるものとして符号化することになる。   As described above, the encoding unit 100 according to the embodiment encodes the image data supplied from the input unit 101 as monochrome image data of one pixel and one component.

なお、本実施形態では、符号化対象の画像データがベイヤ配列の画素で構成されるRAW画像データとしているが、1画素がRGB成分で各成分がNビットの画像データや、他の色表現を用いた画像データに対しても適用できる。例えば、RGB各成分が8ビットで表現される画像データに対しては、R,G,Bの各色成分毎に、1画素8ビットのモノクロ画像として符号化すれば良い。また、1画素がY、Cb、Crで各成分が8ビットで表現される輝度色差成分に対しては、Y,Cb,Crの各成分の8ビットのモノクロ画像として符号化すれば良い。上記はあくまで例である。   In this embodiment, the image data to be encoded is RAW image data composed of pixels in a Bayer array. However, one pixel is an RGB component and each component is N-bit image data or other color representation. It can also be applied to the used image data. For example, for image data in which each RGB component is represented by 8 bits, it is only necessary to encode each color component of R, G, B as a monochrome image of 8 bits per pixel. A luminance / color difference component in which one pixel is represented by Y, Cb, and Cr and each component is represented by 8 bits may be encoded as an 8-bit monochrome image of each component of Y, Cb, and Cr. The above are only examples.

符号化部100におけるブロック分割部102は、入力部101から入力された画像データ(R、G0、G1,Bプレーンのいずれか)を、水平方向Bw画素、垂直方向Bh画素の矩形ブロックに分割する。説明の便宜上、符号化対象の画像の水平方向に並ぶ画素数WはBwの整数倍であるものとする。同様に、垂直方向に並ぶ画素値HについてもBhの整数倍であるとし、矩形ブロックに分割した場合に不完全なブロックが発生しないものとする。この水平方向Bw画素、垂直方向Bh画素で構成される矩形ブロック(着目ブロック)をこれ以降、ブロックデータもしくは単にブロックと呼ぶ。   The block division unit 102 in the encoding unit 100 divides the image data (any one of R, G0, G1, and B planes) input from the input unit 101 into rectangular blocks of horizontal Bw pixels and vertical Bh pixels. . For convenience of explanation, it is assumed that the number W of pixels arranged in the horizontal direction of the image to be encoded is an integer multiple of Bw. Similarly, pixel values H arranged in the vertical direction are also integer multiples of Bh, and incomplete blocks do not occur when divided into rectangular blocks. Hereinafter, the rectangular block (block of interest) composed of the horizontal Bw pixels and the vertical Bh pixels is referred to as block data or simply a block.

本実施形態では、1つのブロックのサイズを4×4画素として説明する。図8に符号化対象の画像データとブロックの関係を図示する。図示のように符号化対象の画像の左上隅を原点とする。そして、水平右方向i番目、垂直下方向j番目のブロックをB(i,j)と記す。また、ブロックB(i,j)内の座標(m,n)の画素値をBi,j(m,n)と記す。例えば、ブロックB(2,3)の左上隅の画素はB2,3(0,0)と記す。 In the present embodiment, description will be made assuming that the size of one block is 4 × 4 pixels. FIG. 8 illustrates the relationship between image data to be encoded and blocks. As shown, the upper left corner of the image to be encoded is the origin. The horizontal i-th block and the vertical j-th block are denoted as B (i, j). Further, the pixel value at the coordinates (m, n) in the block B (i, j) is denoted as B i, j (m, n). For example, the pixel at the upper left corner of block B (2, 3) is denoted as B 2,3 (0, 0).

ブロック符号化部103は、ブロック分割部102から供給された1ブロック分の画素データから、予め設定された固定符号長以下の符号化データを生成する符号化処理を行う。このブロック符号化部103の説明をするにあたり、まずは予め設定された固定長FLについて説明する。   The block encoding unit 103 performs an encoding process for generating encoded data having a predetermined fixed code length or less from the pixel data for one block supplied from the block dividing unit 102. In describing the block encoding unit 103, a preset fixed length FL will be described first.

ここに示す固定長FLは、ブロック単位の最大符号長を制御するためのパラメータであると言える。本実施形態におけるブロックの符号化データは、非圧縮でそのまま保持される画素データと、固定長以下で可変長符号で表される画素データの混在を許容する。そして、ブロック内の可変長符号化される画素データの符号長の上限を示すのが「固定長FL」と定める。   The fixed length FL shown here can be said to be a parameter for controlling the maximum code length in block units. The encoded data of the block in the present embodiment allows a mixture of pixel data that is retained without being compressed and pixel data that is less than a fixed length and is represented by a variable length code. Then, the “fixed length FL” is defined to indicate the upper limit of the code length of the pixel data to be variable length encoded in the block.

本実施形態においては、固定長FLは全てのブロックに対して同じ値を持つものとするが、これに限らず、ブロック単位に変更しても構わない。ただし、画像全面に対する目標符号量を超えないように各ブロックに対する固定長FLを設定する必要がある。固定長FLは、不図示の装置外部からユーザが入力しても構わないし、装置に予め値を設定しておいてもよい。   In the present embodiment, the fixed length FL is assumed to have the same value for all blocks. However, the fixed length FL is not limited to this and may be changed in units of blocks. However, it is necessary to set a fixed length FL for each block so as not to exceed the target code amount for the entire image. The fixed length FL may be input by a user from outside the apparatus (not shown), or a value may be set in the apparatus in advance.

図2は、実施形態における、符号化部100から符号量制御部106までの処理内容を示すフローチャートである。以下、同図に従って符号化部100、符号量制御部106の処理手順を説明する。なお、同図はブロックを単位とするラスタースキャン順の符号化処理である。故に、最初のブロックは画像データの左上隅のブロックB(0,0)となる。以下は、その符号化過程における着目ブロックB(i,j)についての説明である。また、最初のブロックB(0、0)の処理に先立って、変数SD(詳細後述)はゼロクリアされるものとする。   FIG. 2 is a flowchart illustrating processing contents from the encoding unit 100 to the code amount control unit 106 in the embodiment. Hereinafter, the processing procedure of the encoding unit 100 and the code amount control unit 106 will be described with reference to FIG. The figure shows a raster scan order encoding process in units of blocks. Therefore, the first block is block B (0, 0) in the upper left corner of the image data. The following is a description of the block of interest B (i, j) in the encoding process. In addition, prior to the processing of the first block B (0, 0), the variable SD (detailed later) is cleared to zero.

ステップS201において、符号化部100のブロック符号化部103は、符号化対象の画像データから着目ブロックB(i,j)を入力し、その中の最小画素Pminと最大画素Pmaxを探索する。図4(a)に示すように、ブロック内の画素を所定のスキャン順序(例えばラスタースキャン)で0番からn番まで順位付けし先頭画素から順にその画素値をP0,P1,…,Pnと表現する。なお、実施形態では1ブロックが4×4画素としているので、n=15である。   In step S201, the block encoding unit 103 of the encoding unit 100 inputs the block of interest B (i, j) from the image data to be encoded, and searches for the minimum pixel Pmin and the maximum pixel Pmax therein. As shown in FIG. 4A, the pixels in the block are ranked from 0 to n in a predetermined scan order (for example, raster scan), and the pixel values are sequentially set to P0, P1,. Express. In the embodiment, since 1 block is 4 × 4 pixels, n = 15.

図4(b)は、画素P1乃至P15の画素値の具体例を示している。同図の場合、最小画素Pminの画素位置(順位)は0であり、その画素値はP0(=12)となる。また、同図において、最大Pmaxの画素位置は7であり、画素値はP7(=298)となる。ちなみに、最小画素値を持つ画素が複数存在した場合には、スキャンの最初に出現した画素をPminとする。最大画素値Pmaxも同様である。また、最小最大画素以外の各画素を、図4(b)に示すように、OPmと表現する。実施形態の場合、1ブロック内には16画素が含まれ、そのうち2つが最小画素Pminと最大画素Pmaxとなるので、画素OPmの個数は14個である(mの取り得る値は1なしい14である)。   FIG. 4B shows a specific example of pixel values of the pixels P1 to P15. In the case of the figure, the pixel position (order) of the minimum pixel Pmin is 0, and the pixel value is P0 (= 12). Further, in the same figure, the maximum Pmax pixel position is 7, and the pixel value is P7 (= 298). Incidentally, when there are a plurality of pixels having the minimum pixel value, the pixel that appears at the beginning of the scan is defined as Pmin. The same applies to the maximum pixel value Pmax. Further, each pixel other than the minimum maximum pixel is expressed as OPm as shown in FIG. In the embodiment, since 16 pixels are included in one block, and two of them are the minimum pixel Pmin and the maximum pixel Pmax, the number of pixels OPm is 14 (the value m can take is not 1) Is).

次に、ステップS202にて、ブロック符号化部103は、着目ブロックB(i,j)の最小画素Pminと最大画素Pmaxを符号化する。本実施形態においては、最小画素Pminの画素位置と画素値、最大画素Pmaxの画素位置と画素値をそれぞれ固定長の符号データとして保持するものとする。実施形態では、1ブロックが4×4画素(=16画素)としているので、「画素位置」は4ビットで表現できる。なお、ここでは自然二進数表現を用いるものとするが、一意に復号できるものであれば、交番二進など、別の二値表現を用いても構わない。   Next, in step S202, the block encoding unit 103 encodes the minimum pixel Pmin and the maximum pixel Pmax of the block of interest B (i, j). In the present embodiment, the pixel position and pixel value of the minimum pixel Pmin, and the pixel position and pixel value of the maximum pixel Pmax are held as fixed-length code data. In the embodiment, since one block has 4 × 4 pixels (= 16 pixels), the “pixel position” can be expressed by 4 bits. Here, natural binary representation is used, but another binary representation such as alternating binary may be used as long as it can be uniquely decoded.

図4(b)の例では、Pminの位置情報は0なので、その位置は“0000”、Pmaxの位置情報は7なのでその位置は“0111”(いずれも二進表現)と表現される。画素値については、非圧縮のままで14ビットである。但し、最大画素Pmin、最大画素Pmaxの画素値を非圧縮とするが、多少の劣化を許容しても良いのであれば、入力画素のビット数よりも少ないビットで最小画素値、最大画素値を表現しても構わない。ブロック符号化部103は、着目ブロックB(i,j)から得た最小画素Pminと最大画素Pmaxの符号化データを図1に示したバッファ105へ格納される。   In the example of FIG. 4B, since the position information of Pmin is 0, the position is “0000”, and the position information of Pmax is 7, so the position is expressed as “0111” (both are expressed in binary). The pixel value is 14 bits with no compression. However, although the pixel values of the maximum pixel Pmin and the maximum pixel Pmax are uncompressed, the minimum pixel value and the maximum pixel value can be set with less bits than the number of bits of the input pixel if some deterioration may be allowed. You can express it. The block encoding unit 103 stores the encoded data of the minimum pixel Pmin and the maximum pixel Pmax obtained from the block of interest B (i, j) in the buffer 105 shown in FIG.

ステップS203にて、ブロック符号化部103は、符号化対象の着目ブロックB(i,j)のブロックレンジBRを算出する。ブロックレンジBRとは、ブロック内の最小画素Pminと最大画素Pmaxの差分値のビットレンジのことを示すものと定義する。つまり、ブロック符号化部103は、最大画素Pmaxから最小画素Pminの値を引いて得た差分値DIFFを表現する最小ビット数を求める。   In step S203, the block encoding unit 103 calculates the block range BR of the target block B (i, j) to be encoded. The block range BR is defined as indicating the bit range of the difference value between the minimum pixel Pmin and the maximum pixel Pmax in the block. That is, the block encoding unit 103 obtains the minimum number of bits representing the difference value DIFF obtained by subtracting the value of the minimum pixel Pmin from the maximum pixel Pmax.

例えば、図4(b)の場合、Pmin=12,Pmax=298であるので、その差分値DIFFは“286”となる。値“286”を表す最小ビット数は“9”である。この意味は、着目ブロックB(i,j)の最小画素Pmin、最大画素Pmaxを除く画素OPmは、最小画素Pmin(或いは最大画素Pmax)に対して9ビットの差分値で表現できることを意味する。なお、実施形態では、1画素が14ビットとし、固定長FLは7としているので、ブロックレンジBRの最大値は“14”である。   For example, in the case of FIG. 4B, since Pmin = 12, Pmax = 298, the difference value DIFF is “286”. The minimum number of bits representing the value “286” is “9”. This means that the pixel OPm excluding the minimum pixel Pmin and the maximum pixel Pmax of the block of interest B (i, j) can be expressed by a 9-bit difference value with respect to the minimum pixel Pmin (or the maximum pixel Pmax). In the embodiment, since one pixel is 14 bits and the fixed length FL is 7, the maximum value of the block range BR is “14”.

図6を用いてブロックレンジBRと固定長FLの関係を以下に説明する。図6の符号61乃至63は、特徴の異なる3つのブロックの例を示している。ブロック61、62、63の順番に、ブロック内の画素間の最大差分DIFFが大きくなっていくものとする。ここで、ブロック61のブロックレンジBRが“2”、ブロック62のブロックレンジBRが“7”、ブロック63のブロックのブロックレンジが“14”であるものとする。そして、今、固定長FL=7とすると、ブロック61、62、63それぞれのブロックレンジBRと固定長FLの関係は、同図の下部に示す参照符号61’,62’、63’となる。   The relationship between the block range BR and the fixed length FL will be described below with reference to FIG. Reference numerals 61 to 63 in FIG. 6 indicate examples of three blocks having different characteristics. It is assumed that the maximum difference DIFF between the pixels in the block increases in the order of the blocks 61, 62, and 63. Here, it is assumed that the block range BR of the block 61 is “2”, the block range BR of the block 62 is “7”, and the block range of the block 63 is “14”. Now, assuming that the fixed length FL = 7, the relationship between the block range BR of each of the blocks 61, 62, and 63 and the fixed length FL is the reference numerals 61 ', 62', and 63 'shown at the bottom of the figure.

ブロック61について着目すると、ブロック61の最小画素Pminと最大画素Pmaxを除く画素OPmは、最小画素Pminに対する2ビットの差分で表現できることになる。従って、固定長FL=7のうち5ビットは余剰ビットであり、その分だけ符号量を発生せずに済む。画素OPmは全部で14画素存在するわけであるから。ブロック61の場合には、ブロック61の画素OPmの目標符号量よりも5×14ビット少ない符号化データで表現できることを意味する。   Focusing on the block 61, the pixel OPm excluding the minimum pixel Pmin and the maximum pixel Pmax in the block 61 can be expressed by a 2-bit difference with respect to the minimum pixel Pmin. Therefore, 5 bits of the fixed length FL = 7 are surplus bits, and it is not necessary to generate a code amount correspondingly. This is because there are 14 pixels OPm in total. In the case of the block 61, this means that it can be expressed by encoded data that is 5 × 14 bits less than the target code amount of the pixel OPm of the block 61.

ブロック62について着目すると、ブロックレンジBRと固定長FLは同じであるので、ブロック62内の画素OPmは、最小画素Pminに対する固定長FLビットによる差分で表されることになる。つまり、ブロック62の場合は、画素OPmは目標符号量の符号化データで表現できることになる。   Focusing on the block 62, since the block range BR and the fixed length FL are the same, the pixel OPm in the block 62 is represented by a difference by a fixed length FL bit with respect to the minimum pixel Pmin. That is, in the case of the block 62, the pixel OPm can be expressed by encoded data of the target code amount.

一方、ブロック63の場合、ブロックレンジBR=14となる。つまり、ブロックレンジBRは固定長FLより大きい。それ故、ブロック符号化部103は、画素OPmの画素値として支配的な上位FLビットの符号化データを生成する。そして、ブロック符号化部103は、FLビットを超過した下位BP(=BR−FL)ビット(正確にはBP×14ビット)を、オーバービット符号化部104に供給し、そこで符号化させる(後述)。   On the other hand, in the case of the block 63, the block range BR = 14. That is, the block range BR is larger than the fixed length FL. Therefore, the block encoding unit 103 generates encoded data of upper FL bits that are dominant as the pixel value of the pixel OPm. Then, the block encoding unit 103 supplies the low-order BP (= BR-FL) bits (exactly BP × 14 bits) exceeding the FL bits to the overbit encoding unit 104 and encodes them (described later). ).

後述する説明から明らかになるが,BRとFLとを比較することは、ブロック符号化部103が、着目ブロックに対して目標符号量以下の可逆符号化データを生成できるか否かを判定することと等価である。   As will be apparent from the description below, comparing BR and FL determines whether the block encoding unit 103 can generate lossless encoded data having a target code amount or less for the block of interest. Is equivalent to

図2のフローチャートの説明に戻る。ステップS204にて、ブロック符号化部103はステップS203で算出された着目ブロックB(i,j)のブロックレンジBRと“0”と比較する。ブロックレンジBRの値が0よりも大きい場合(Yes)は、ブロック符号化部103は、処理をステップS205へ遷移し、最小・最大画素以外の画素OPmの符号化を行う。一方、ブロックレンジBRの値が0の場合(No)には、着目ブロック内の全ての画素が同じ画素値を持つことを意味する。そのため、ブロック符号化部103は、最小画素Pmin、最大画素Pmax以外の画素OPmを符号化する必要がない。それ故、ブロック符号化部103は画素OPmの符号化処理(ステップS205〜S206)をスキップして、処理をステップS207へ遷移する。   Returning to the flowchart of FIG. In step S204, the block encoding unit 103 compares the block range BR of the block of interest B (i, j) calculated in step S203 with “0”. When the value of the block range BR is larger than 0 (Yes), the block encoding unit 103 shifts the process to step S205 and encodes the pixels OPm other than the minimum / maximum pixels. On the other hand, when the value of the block range BR is 0 (No), it means that all the pixels in the block of interest have the same pixel value. Therefore, the block encoding unit 103 does not need to encode the pixels OPm other than the minimum pixel Pmin and the maximum pixel Pmax. Therefore, the block encoding unit 103 skips the encoding process (steps S205 to S206) of the pixel OPm, and proceeds to step S207.

ステップS205にて、ブロック符号化部103は、最小画素Pmin、最大画素Pmix以外の画素OPm(=OP1,OP2、…,OP14)を固定長FL以下で符号化する。以下はその符号化の説明である。   In step S205, the block encoding unit 103 encodes pixels OPm (= OP1, OP2,..., OP14) other than the minimum pixel Pmin and the maximum pixel Pmix with a fixed length FL or less. The following is a description of the encoding.

符号化対象の着目ブロックB(i,j)のブロックレンジBRが固定長FL以下の場合、ブロック符号化部103は、画素OPm(OP1〜OP14)の値から最小画素Pminの画素値を引いた値Qm(Q1〜Q14)を符号化データとして出力する。勿論、各値Qmは、ブロックレンジBRが表すビット数である。   When the block range BR of the target block B (i, j) to be encoded is equal to or less than the fixed length FL, the block encoding unit 103 subtracts the pixel value of the minimum pixel Pmin from the value of the pixel OPm (OP1 to OP14). The value Qm (Q1 to Q14) is output as encoded data. Of course, each value Qm is the number of bits represented by the block range BR.

一方、着目ブロックのブロックレンジBRが固定長FLよりも大きい場合、ブロック符号化部103は、画素OPm(OP1〜OP14)の値から、最小画素の画素値Pminで引いた値Qm(Q1〜Q14)を、ビット数BRの精度で生成する。このQmを固定長FLで表現できるように、下位ビットを切り捨て、各画素OPmの固定長FLの符号化データを生成する。換言すれば、ブロック符号化部103は、ビット数BRの精度で演算した値Qmの上位FLビットを、着目画素OPmの符号化データとして出力する。ここで、理解を容易にするため、着目ブロックが図4(b)に示すブロックの場合の具体例を以下に示す。   On the other hand, when the block range BR of the block of interest is larger than the fixed length FL, the block encoding unit 103 subtracts the value Qm (Q1 to Q14) from the value of the pixel OPm (OP1 to OP14) by the pixel value Pmin of the minimum pixel. ) Is generated with an accuracy of the bit number BR. The lower bits are discarded so that this Qm can be expressed by a fixed length FL, and encoded data of a fixed length FL of each pixel OPm is generated. In other words, the block encoding unit 103 outputs the upper FL bits of the value Qm calculated with the accuracy of the bit number BR as encoded data of the pixel of interest OPm. Here, for easy understanding, a specific example in which the block of interest is the block shown in FIG.

本実施形態において固定長FL=7である。図4(b)に示すブロックのブロックレンジBRは“9”である。つまり、オーバービット数が“2”となる。そのため、ブロック符号化部103は、画素OPmから最小画素の画素値Pminを減算して得たQm(9ビット)の上位7ビットを、着目ブロック内の画素OPmを固定長符号化データとして生成する。つまり、ブロック符号化部103が、Qm(9ビット)の下位2ビットを切り捨てて残った7ビットを固定長符号化データとして生成する。   In the present embodiment, the fixed length FL = 7. The block range BR of the block shown in FIG. 4B is “9”. That is, the number of over bits is “2”. Therefore, the block encoding unit 103 generates the upper 7 bits of Qm (9 bits) obtained by subtracting the pixel value Pmin of the minimum pixel from the pixel OPm as the pixel OPm in the block of interest as fixed-length encoded data. . That is, the block encoding unit 103 generates the remaining 7 bits as fixed-length encoded data by truncating the lower 2 bits of Qm (9 bits).

例えば、図4(b)における画素OP1の値は“64”である。最小画素の画素値Pminは“12”であるから、画素OP1の最小画素の画素値に対する差分を表す値Q1は“52”となる。したがって、ブロック符号化部103は、値Q1を2ビット右シフトして“13”(自然二進表記で“0001101”)が生成される。他のQ2〜Q14についても、最小画素の画素値との差分を2ビット右シフトして、符号化データが生成できる。   For example, the value of the pixel OP1 in FIG. 4B is “64”. Since the pixel value Pmin of the minimum pixel is “12”, the value Q1 representing the difference of the pixel OP1 with respect to the pixel value of the minimum pixel is “52”. Therefore, the block encoding unit 103 shifts the value Q1 to the right by 2 bits to generate “13” (“0001101” in natural binary notation). For other Q2 to Q14, the difference from the pixel value of the minimum pixel can be shifted to the right by 2 bits to generate encoded data.

ここで、図4(b)に示すブロックの最小画素Pmin、最大画素Pmaxを除く画素OPmの符号化データの各値は図5に示す通りである。   Here, each value of the encoded data of the pixel OPm excluding the minimum pixel Pmin and the maximum pixel Pmax of the block shown in FIG. 4B is as shown in FIG.

ステップS206において、ブロック符号化部103は、着目ブロックB(i,j)のブロックレンジBRと、予め設定された固定長FLの比較を行う。比較した結果、BRがFL以下の場合(Yes)は、処理をステップS207へ進める。一方、BRがFLよりも大きな値の場合(No)、ブロック符号化部103は処理をステップS208へ遷移する。   In step S206, the block encoding unit 103 compares the block range BR of the block of interest B (i, j) with a preset fixed length FL. As a result of the comparison, if BR is equal to or less than FL (Yes), the process proceeds to step S207. On the other hand, when BR is a value larger than FL (No), the block coding unit 103 shifts the process to step S208.

ステップS207にて、ブロック符号化部103は、最初のブロックB(0、0)から着目ブロックB(i,j)までの余剰データ容量SDを更新する。余剰データ容量SDとは、ブロックレンジBRが固定長FLよりも小さい場合に発生する未利用の容量を表す指標値である。着目ブロックB(i,j)の余剰データ容量はFL−BRとして算出できる。図6のブロック61の場合には余剰データ容量はFL−BR=7−2=5の値を持つ。   In step S207, the block encoding unit 103 updates the surplus data capacity SD from the first block B (0, 0) to the target block B (i, j). The surplus data capacity SD is an index value that represents an unused capacity that occurs when the block range BR is smaller than the fixed length FL. The surplus data capacity of the block of interest B (i, j) can be calculated as FL-BR. In the case of the block 61 in FIG. 6, the surplus data capacity has a value of FL−BR = 7−2 = 5.

ステップS207で処理される着目ブロックB(i,j)は、ブロックレンジBR≦固定長FLであるため、固定長FL以下で可逆符号化できるブロックであると言える。更に、BR<FLの場合にはFL分すべてを利用しないで、可逆符号化が可能なブロックを意味する。そのため、余剰データ容量SDが0以上となるブロックが存在する場合には、固定長FLを超えてしまうような他のブロックの符号化データを割り当てることができる。   Since the block of interest B (i, j) processed in step S207 has a block range BR ≦ fixed length FL, it can be said that it is a block that can be losslessly encoded with a fixed length FL or less. Further, in the case of BR <FL, it means a block that can be losslessly encoded without using all of FL. Therefore, when there is a block whose surplus data capacity SD is 0 or more, encoded data of another block that exceeds the fixed length FL can be allocated.

符号化対象の着目画像における最初のブロックB(0、0)から着目ブロックB(i,j)までの余剰データ容量SDの合計を、これ以降、プール容量SDと呼ぶ。このプール容量SDは、先頭のブロックB(0,0)から着目ブロックB(i,j)までの全ブロックのうち、ブロックレンジBRが固定長FL以下の場合のビット長FL−BRで算出される値の合計である。   The total surplus data capacity SD from the first block B (0, 0) to the target block B (i, j) in the target image to be encoded is hereinafter referred to as a pool capacity SD. This pool capacity SD is calculated by the bit length FL-BR when the block range BR is equal to or less than the fixed length FL among all the blocks from the first block B (0, 0) to the target block B (i, j). Is the sum of the values.

本実施形態においては、1つのブロックにおけるオーバービット数が何ビットあったかがわかればよいので、前述のようなプール容量SDを定義したが、これに限るものではない。例えば、実際のブロックに対する余剰データ容量は、最小画素と最大画素以外の画素14画素について各(FL−BR)ビットの余剰があることになる。それ故、1つのブロックの余剰データ量は、正確には(FL−BR)×14ビットである。それ故、最初のブロックB(0、0)から着目ブロックB(i,j)までの、かかる余剰データ容量の合計をプール容量SDとしても構わない。   In the present embodiment, it is only necessary to know how many overbits there are in one block. Therefore, the pool capacity SD as described above is defined, but the present invention is not limited to this. For example, the surplus data capacity for an actual block has a surplus of (FL-BR) bits for 14 pixels other than the minimum pixel and the maximum pixel. Therefore, the surplus data amount of one block is exactly (FL-BR) × 14 bits. Therefore, the total of the surplus data capacity from the first block B (0, 0) to the target block B (i, j) may be used as the pool capacity SD.

ステップS208は、BR>FLである着目ブロックについて、オーバービット符号化部104が、固定長FLを超えたビットデータ(オーバービットと呼ぶ)の符号化を行う。このオーバービット符号化部104の符号化処理を図3のフローチャートを用いて説明する。同図は、実施形態のオーバービット符号化部103の符号化処理の流れを示すフローチャートである。   In step S208, the overbit encoding unit 104 encodes bit data exceeding the fixed length FL (referred to as overbits) for the target block for which BR> FL. The encoding process of the overbit encoding unit 104 will be described with reference to the flowchart of FIG. This figure is a flowchart showing the flow of the encoding process of the overbit encoding unit 103 of the embodiment.

まず、ステップS301は、オーバービット符号化部103は、符号化対象ブロックを入力する。この符号化対象ブロックは、ブロックレンジBRが固定長FLよりも大きなブロックであることに注意されたい。本実施形態においては、ステップS301にて入力されるブロックをオーバーブロックOBとし、着目画像の符号化を開始してからのオーバーブロックの総数をbnと表す。   First, in step S301, the overbit encoding unit 103 inputs an encoding target block. Note that this encoding target block is a block having a block range BR larger than the fixed length FL. In the present embodiment, the block input in step S301 is overblock OB, and the total number of overblocks after the start of encoding of the image of interest is represented as bn.

続いて、オーバービット符号化部103は、ステップS302にて、処理対象ブロックOBの、オーバーフローするビット数BP(以下、オーバービット数BPという)を次式(1)により算出する。
BP=BR−FL・・・(1)
そして、オーバービット符号化部103は、ステップS303にて、カウンタCをゼロで初期化する。このカウンタCの取り得る範囲は、0〜「BP−1」である。そして、オーバービット符号化部103は、カウンタCを参照して、処理対象のオーバーブロックOBに対し、このオーバービット数BP分、以下に説明するステップS304乃至306の処理を繰り返す。
Subsequently, in step S302, the overbit encoding unit 103 calculates the overflowing bit number BP (hereinafter referred to as the overbit number BP) of the processing target block OB by the following equation (1).
BP = BR-FL (1)
Then, the overbit encoding unit 103 initializes the counter C with zero in step S303. The possible range of the counter C is 0 to “BP-1”. Then, the overbit encoding unit 103 refers to the counter C, and repeats the processes of steps S304 to S306 described below for the overblock OB to be processed by the number of overbits BP.

ステップS304乃至S306の処理は、簡単に説明すると、オーバーブロックにおける画素OPmの値Qm(Q1〜Q14)の下位のBPビット(BP=BR−FL)を、1以上のビットレイヤに分けて記憶保持する処理である。   The processing in steps S304 to S306 will be briefly described. The lower BP bits (BP = BR-FL) of the value Qm (Q1 to Q14) of the pixel OPm in the overblock are divided and stored in one or more bit layers. It is processing to do.

値Qmにおける下位のBPビットのうち、1番上位のビットのビット列(実施形態では14ビット)が追加データEL(0)に記憶管理される。また、下位のBPビットのうち、上位から2番目のビットのビット列が追加データEL(1)として記憶管理される。以下、同様である。   Of the lower BP bits in the value Qm, the bit string of the highest bit (14 bits in the embodiment) is stored and managed in the additional data EL (0). Of the lower BP bits, the bit string of the second highest bit is stored and managed as additional data EL (1). The same applies hereinafter.

上記を別な表現で言うと、値Qmの最上位のビット位置からFL+1ビット目(最上位ビットから8ビット目)のビット列が、追加データEL(0)に記憶管理される。そして、値Qmの最上位のビット位置からFL+2ビット目(最上位ビットから9ビット目)のビット列が、追加データEL(1)に記憶管理される、ということもできる。   In other words, the bit string of the FL + 1th bit (the 8th bit from the most significant bit) from the most significant bit position of the value Qm is stored and managed in the additional data EL (0). It can also be said that the FL + 2 bit (9th bit from the most significant bit) bit string from the most significant bit position of the value Qm is stored and managed in the additional data EL (1).

このように、各オーバーブロックのオーバーフローしたビットを、追加データEL(C)としてビット列のレイヤとして記憶管理することで、それぞれのオーバーブロックの復号した際の画素値の再現精度が向上する。そして、符号化しようとする着目画像の全オーバーブロックが、全追加データEL(C)として保持できれば、着目画像が完全に復号可能となる。つまり、ロスレス符号化が実現できる。なお、着目画像の符号化に先立って、追加データEL()は何も記憶されていない状態で初期化されるものとする。   Thus, by storing and managing the overflowed bits of each overblock as a bit string layer as additional data EL (C), the reproduction accuracy of the pixel value when each overblock is decoded is improved. If all overblocks of the target image to be encoded can be held as all additional data EL (C), the target image can be completely decoded. That is, lossless encoding can be realized. It is assumed that the additional data EL () is initialized in a state where nothing is stored prior to the encoding of the image of interest.

ステップS304にて、オーバービット符号化部104は、追加データEL(C)を更新する。   In step S304, overbit encoding section 104 updates additional data EL (C).

図5の場合で、且つ、C=0であるとする。この場合、オーバービット符号化部104は、Qmの下位2ビット中の上位に位置するビット列(14ビット)“01011110011111”を追加データEL(0)に追加記憶する。
EL(0)←EL(0)+“01011110011111”
これにより、先に説明した固定長符号化の処理にて切り捨てた2ビットのうちの1ビットのビット列が、追加データEL(0)に保持されることになる。
In the case of FIG. 5, it is assumed that C = 0. In this case, the overbit encoding unit 104 additionally stores the bit string (14 bits) “010111110011111” positioned in the upper two of the lower two bits of Qm in the additional data EL (0).
EL (0) ← EL (0) + “010111110011111”
As a result, a bit string of 1 bit out of 2 bits rounded down in the above-described fixed length encoding process is held in the additional data EL (0).

このステップS304の処理を終えると、オーバービット符号化部104は、処理をステップS305に進め、カウンタCを“1”だけ増加させる。そして、オーバービット符号化部104は、ステップS306にて、カウンタCと、着目オーバーブロックのオーバービット数BPとの比較をする。比較の結果、CがBPよりも小さい場合(YES)には、処理をステップS304へ戻す。   When the process of step S304 is completed, the overbit encoding unit 104 advances the process to step S305, and increments the counter C by “1”. In step S306, the overbit encoding unit 104 compares the counter C with the overbit number BP of the target overblock. If C is smaller than BP as a result of the comparison (YES), the process returns to step S304.

ここで、図5の場合で、且つ、カウンタCが“1”であるとする。BP=2であるので、C<BPであると判断され、オーバービット符号化部104は処理をステップS304に戻すことになる。   Here, in the case of FIG. 5, it is assumed that the counter C is “1”. Since BP = 2, it is determined that C <BP, and the overbit encoding unit 104 returns the process to step S304.

そして、オーバービット符号化部104は、2回目のステップS304にて、Qmの下位2ビット中の上位から2つ目のビット列(14ビット)“01010010001111”を追加データEL(1)に追加記憶する。
EL(1)←EL(1)+“01010010001111”
そして、ステップS305でカウンタCが“1”だけ増加して“2”になり、ステップS306の不等式が成立しないので、本処理を終える。
Then, overbit encoding section 104 additionally stores the second highest bit string (14 bits) “0101010010001111” in the lower 2 bits of Qm in additional data EL (1) in the second step S304. .
EL (1) ← EL (1) + “010100100001111”
Then, in step S305, the counter C is incremented by “1” to become “2”, and the inequality in step S306 is not satisfied, so this processing ends.

上記のように、着目ブロックが図4(b)の場合、BP=2となるので、更新される追加データはEL(0)、(1)であり、それ以外のEL(2)乃至(6)は更新されない。そして、上記処理をオーバーブロックが発生するたびに行うことで、追加データEL(0)乃至(6)が更新されていく。   As described above, when the block of interest is FIG. 4B, BP = 2, so the additional data to be updated is EL (0), (1), and the other EL (2) to (6) ) Is not updated. The additional data EL (0) to (6) is updated by performing the above process every time an overblock occurs.

図7は、オーバーブロックOBnと、オーバービット符号化データの関係を示す図である。オーバーブロックOB0からOB7の各オーバーブロックについて、BPが順に1,2,3,4,5,5,4である場合を例示している。図示のマス目内の数字は、各オーバーブロックの値Qの最上位ビットから何番目のビットのビット列を格納するかを示している。例えば、追加データEL(0)には、オーバーブロックにおける値Qの最上位ビットから8ビット目のビット列が格納されることを示している。また、追加データEL(1)には、オーバーブロックにおける値Qの最上位ビットから9ビット目のビット列が格納されることを示している。ただし、この格納方法についてはこれに限るものではない。例えば、各ブロックの固定長符号化データに続いて、オーバービット符号化データを格納してもよい。本実施形態においては、オーバービット符号化データをレイヤ単位で管理する方法を説明したが、各ブロックに対するレイヤ毎に管理しても構わない。その場合には、上記方法に限定されず、画素値の再現精度の高い付加データから順に追加すればよい。   FIG. 7 is a diagram illustrating the relationship between the overblock OBn and the overbit encoded data. For each of the overblocks OB0 to OB7, BP is 1, 2, 3, 4, 5, 5, 4 in order. The numbers in the squares in the figure indicate how many bits from the most significant bit of the value Q of each overblock are stored. For example, the additional data EL (0) indicates that the bit string of the eighth bit from the most significant bit of the value Q in the overblock is stored. Further, the additional data EL (1) indicates that the 9th bit string from the most significant bit of the value Q in the overblock is stored. However, this storage method is not limited to this. For example, overbit encoded data may be stored following the fixed length encoded data of each block. In the present embodiment, the method of managing overbit encoded data in units of layers has been described, but it may be managed for each layer for each block. In this case, the method is not limited to the above method, and it is sufficient to add the data in order from the additional data with high pixel value reproduction accuracy.

図7における右端のLD()は、追加データEL()に格納されたデータ量を示している。例えばLD(0)=7は、追加データEL(0)には7個のオーバーブロックのビット列(=14×7ビット)が格納されていることを表している。   The rightmost LD () in FIG. 7 indicates the amount of data stored in the additional data EL (). For example, LD (0) = 7 indicates that the additional data EL (0) stores 7 overblock bit strings (= 14 × 7 bits).

上記の方法により、オーバービット符号化部104は、オーバーブロックのオーバービット符号化データを生成する。   With the above method, the overbit coding unit 104 generates overblock overbit coded data.

図2のフローチャートの説明に戻る。ステップS207、或いは、ステップS208の処理が終了すると、符号化部100は処理をステップS209へ進める。ステップS209にて、符号化部100は、符号化対象の着目ブロックが最終ブロックであるかどうかの判断を行う。着目ブロックが最終ブロックである場合(Yes)、処理をS210へ進める。また、最終ブロックでない場合(No)には、符号化部100は処理をステップS201へ戻し、次のブロックの符号化処理を行う。   Returning to the flowchart of FIG. When the process of step S207 or step S208 ends, the encoding unit 100 advances the process to step S209. In step S209, the encoding unit 100 determines whether or not the target block to be encoded is the last block. If the target block is the last block (Yes), the process proceeds to S210. If the block is not the last block (No), the encoding unit 100 returns the process to step S201 and performs the encoding process for the next block.

ステップS210以降は、符号量制御部106の処理である。この時点で、バッファ105には、符号化対象の着目画像に対するブロック符号化部103が生成した符号化データ、並びに、オーバービット符号化部104が生成した符号化データが格納されている点に注意されたい。   Step S210 and subsequent steps are processing of the code amount control unit 106. At this point, note that the buffer 105 stores the encoded data generated by the block encoding unit 103 for the target image to be encoded and the encoded data generated by the overbit encoding unit 104. I want to be.

また、説明が前後するが、ブロック符号化部103が生成する1ブロックの符号化データは、最小画素とその位置、最大画素とその位置、及び、画素OPmの符号化データである。このうち、最小画素とその位置、及び、最大画素とのその位置は固定長で、14+4+14+4=36ビットである。また、画素OPmは固定長FL(=7)を超えることはなく、画素OPmの個数は14個である。   In addition, although the description is around, the encoded data of one block generated by the block encoding unit 103 is encoded data of the minimum pixel and its position, the maximum pixel and its position, and the pixel OPm. Among these, the minimum pixel and its position, and the position of the maximum pixel have a fixed length of 14 + 4 + 14 + 4 = 36 bits. The pixel OPm does not exceed the fixed length FL (= 7), and the number of pixels OPm is 14.

故に、1ブロックのブロック目標符号量Bmaxは、次式の如く134ビットである。
Bmax=14+4+14+4+7×14=134
着目画像に含まれるブロックの総数をBNとしたとき、実施形態における着目画像の目標符号量Tは、
T=134×BN
とする。なお、このBmaxは、ブロック符号化部103が生成する1ブロックの最大符号化サイズであるので、以降、ブロック最大符号量という。
Therefore, the block target code amount Bmax for one block is 134 bits as shown in the following equation.
Bmax = 14 + 4 + 14 + 4 + 7 × 14 = 134
When the total number of blocks included in the target image is B N , the target code amount T of the target image in the embodiment is
T = 134 × B N
And Since Bmax is the maximum encoding size of one block generated by the block encoding unit 103, it is hereinafter referred to as a block maximum code amount.

ステップS210にて、符号量制御部106は、カウンタCを0に初期化する。カウンタCは、追加データEL()を特定するための変数である。   In step S210, the code amount control unit 106 initializes the counter C to zero. The counter C is a variable for specifying the additional data EL ().

続いて、ステップS211にて、符号量制御部106は、追加データEL(C)のデータ量LD(C)がプール容量SD以下であるか否かの判断を行う。追加データEL(C)のデータ量LD(C)とは、先に図7を用いて説明したように、追加データEL(C)に、幾つのブロックから抽出したビット列を格納したのかを表す値を示している。再度、図7を用いて説明すると、「LD(0)=7」は、「追加データEL(0)には7個のオーバーブロックのビット列が格納されている」ことを表している。同様に「LD(1)=6」は、「追加データEL(1)には6個のオーバーブロックのビット列が格納されている」ことを表す。   Subsequently, in step S211, the code amount control unit 106 determines whether or not the data amount LD (C) of the additional data EL (C) is equal to or less than the pool capacity SD. The data amount LD (C) of the additional data EL (C) is a value representing the number of blocks extracted from the number of blocks stored in the additional data EL (C) as described above with reference to FIG. Is shown. Referring again to FIG. 7, “LD (0) = 7” indicates that “additional data EL (0) contains 7 overblock bit strings”. Similarly, “LD (1) = 6” indicates that “additional data EL (1) stores six overblock bit strings”.

さて、LD(C)≦SDの場合(Yes)は、追加データEL(C)を、ブロック符号化データに加えたとしても、そのトータルの符号量が目標符号量T以下になること意味する。それ故、符号量制御部106は、追加データEL(C)を符号化データに含めるとして判定する。そして、符号量制御部106は、ステップS212にて、プール容量SDからLD(C)を減じる。そして、符号量制御部106は、ステップS213にて、カウンタCを“1”増加させる。   If LD (C) ≦ SD (Yes), it means that even if the additional data EL (C) is added to the block encoded data, the total code amount is equal to or less than the target code amount T. Therefore, the code amount control unit 106 determines that the additional data EL (C) is included in the encoded data. In step S212, the code amount control unit 106 subtracts LD (C) from the pool capacity SD. Then, in step S213, the code amount control unit 106 increases the counter C by “1”.

この後、符号量制御部106は、ステップS215に進み、カウンタCと、「N−FL」とを比較する。ここでNは、着目画像の1画素が表すビット数であり、実施形態では“14”である。   Thereafter, the code amount control unit 106 proceeds to step S215, and compares the counter C with “N-FL”. Here, N is the number of bits represented by one pixel of the image of interest, and is “14” in the embodiment.

従って、ステップS215にて、C<「N−FL」であると判断した場合、処理はステップS211に戻す。こうして、ステップS211、或いは、ステップS215のいずれかの判断がNoとなるまで、符号量制御部106は、ステップS211−S213の処理を繰り返す。   Therefore, if it is determined in step S215 that C <“N-FL”, the process returns to step S211. In this way, the code amount control unit 106 repeats the processes in steps S211 to S213 until the determination in step S211 or step S215 is No.

さて、ステップS211にて、符号量制御部106が、LD(C)≦SDを満たさないと判断したとする。これは、追加データEL(C)を符号化データとして出力すると目標符号量Tを超えてしまうことを意味する。それ故、符号量制御部106は、処理をステップS214に進め、追加データEL(C)以降を破棄する。つまり、符号量制御部106は追加データEL(0)乃至EL(C−1)が有効なデータとして決定する。生成される符号化データは非可逆符号化データとなるが、破棄されるデータは画素値を再現する際の下位のビットであるので、画質に与える影響は少なくできる。以降、この有効な追加データのレイヤ数をAnumと定義する。符号量制御部106は、「ブロック符号化部103が生成した符号化データ」、「オーバービット符号化部104が生成した追加データEL(0)〜(Anum−1)」を、着目画像(着目色成分の画像)の符号化データとして決定し、符号列形成部107に供給する。   Now, in step S211, the code amount control unit 106 determines that LD (C) ≦ SD is not satisfied. This means that if the additional data EL (C) is output as encoded data, the target code amount T is exceeded. Therefore, the code amount control unit 106 advances the processing to step S214 and discards the additional data EL (C) and subsequent data. That is, the code amount control unit 106 determines the additional data EL (0) to EL (C-1) as valid data. The generated encoded data is irreversible encoded data. However, since the discarded data is a low-order bit used when reproducing the pixel value, the influence on the image quality can be reduced. Hereinafter, the number of effective additional data layers is defined as Anum. The code amount control unit 106 converts the “encoded data generated by the block encoding unit 103” and the “additional data EL (0) to (Anum-1) generated by the overbit encoding unit 104” into the target image (attention (Color component image) is determined as encoded data and supplied to the code string forming unit 107.

この結果、着目画像のトータル符号量が、目標符号量T以下になることが約束される。符号列形成部107は、画像復号に必要な情報(各色成分のAnumを含む)を含むヘッダを生成し、そのヘッダに後続して、各色成分毎の符号化データを予め設定されたフォーマットにして出力部108に出力する。出力部108は、ファイルとして、不図示の記憶媒体に格納する処理を行う。   As a result, it is promised that the total code amount of the image of interest is equal to or less than the target code amount T. The code string forming unit 107 generates a header including information necessary for image decoding (including the Anum of each color component), and subsequently converts the encoded data for each color component into a preset format. Output to the output unit 108. The output unit 108 performs processing for storing the file as a file in a storage medium (not shown).

一方、ステップS215にて、符号量制御部106が、C<「N−FL」を満たさないと判断したとする。これは、ブロック符号化部103が生成した符号化データと、全追加データEL()が表す符号化データを足し合わせても、目標符号量T以下となることを意味する。よって、符号量制御部106は、オーバービット符号化部104が生成した追加データEL()の全レイヤ数をAnumとして決定する。そして、符号量制御部106はバッファ105に格納された、ブロック符号化部103が生成した符号化データ、及び、追加データEL(0)乃至(Anum−1)を符号列形成部107に供給する。ここで、注目したい点は、このS215でNoとなった場合の符号列形成部107に渡される符号化データは、着目画像を完全に復元できる符号化データであることを意味する。換言すれば、目標符号量以下の可逆符号化データの生成に成功したことを意味する。   On the other hand, it is assumed that the code amount control unit 106 determines in step S215 that C <“N−FL” is not satisfied. This means that even if the encoded data generated by the block encoding unit 103 and the encoded data represented by all the additional data EL () are added, the target code amount T or less is obtained. Therefore, the code amount control unit 106 determines the total number of layers of the additional data EL () generated by the overbit encoding unit 104 as Anum. The code amount control unit 106 supplies the encoded data generated by the block encoding unit 103 and the additional data EL (0) to (Anum-1) stored in the buffer 105 to the code string forming unit 107. . Here, the point of interest means that the encoded data delivered to the code string forming unit 107 when No in S215 is encoded data that can completely restore the image of interest. In other words, it means that the lossless encoded data having the target code amount or less has been successfully generated.

先に説明したように、上記実施形態によれば、1ブロック当たりの最大符号量は134ビットである。無圧縮の場合は1ブロックのデータ量は、16画素×14ビット=224ビットである。故に、上記実施形態によれば、オリジナルの画像に対して5/8以下の符号量を生成することが可能になることを意味する。   As described above, according to the above embodiment, the maximum code amount per block is 134 bits. In the case of no compression, the data amount of one block is 16 pixels × 14 bits = 224 bits. Therefore, according to the above embodiment, it means that it becomes possible to generate a code amount of 5/8 or less with respect to the original image.

図9は本実施形態の出力符号列の構成を示す図である。出力符号列の先頭には、画像を復号するために必要となる情報、例えば、画像の水平方向画素数、垂直方向画素数、コンポーネント数、各コンポーネントのビット数やブロックの幅、高さなどの付加情報がヘッダとして付けられる。ヘッダに続いて、色成分の符号化データが続く。そして、1つの色成分の符号化データは、ラスタースキャン順の各ブロックの固定長以下の符号化データが付加される。その後、オーバービット符号化データの追加データEL(0)乃至EL(Anum−1)が追加されるという構成で符号列が形成される。   FIG. 9 is a diagram showing the configuration of the output code string of this embodiment. At the beginning of the output code string, information necessary for decoding the image, such as the number of pixels in the horizontal direction, the number of pixels in the vertical direction, the number of components, the number of bits of each component, the width of the block, the height, etc. Additional information is attached as a header. Following the header is encoded data of color components. The encoded data of one color component is added with encoded data of a fixed length or less of each block in the raster scan order. Thereafter, a code string is formed with a configuration in which additional data EL (0) to EL (Anum-1) of overbit encoded data is added.

図9に示すように、本実施形態においては、1つのブロックの符号化データは、先頭から、最小画素位置、最小画素の画素値、最大画素位置、最大画素の画素値を配置する。続いて、最小最大画素以外の画素OPmについて固定長以下の符号化データを配置する。このとき、最小画素と最大画素の差分が0の場合には、そのブロック内全ての画素が同じ値を持つことを意味するため、その他の画素値OPmの符号化データは生成しないし、付加されない。固定長以下の符号化データに後続して、オーバービット符号化データ(追加データEL())が付加される。本実施形態において、オーバービット符号化データは、追加データEL(0)から追加データEL(Anum−1)までの符号化データを持つ。この構成によれば、復号装置が、固定長以下の符号化データを復号した時点で、画像内の全ブロックのブロックレンジは特定できる。それ故、復号装置は、オーバーブロックの位置と、それに対応するオーバービット符号化データのデータ位置を特定できる。そのため、追加データについては、付加情報を必要とせず、復号が可能となる。ただし、符号列についてはこれに限るものではない。例えば、ブロック単位に固定長符号化データとオーバービット符号化データを保持してもよい。この場合には、ブロック毎の復号が可能になるが、ブロックを順次復号する時点では何ビット分の追加データがあるか特定できない。そのため、オーバーブロックそれぞれについて、追加したデータ量がわかるように情報を付加する必要がある。   As shown in FIG. 9, in the present embodiment, the encoded data of one block is arranged with the minimum pixel position, the minimum pixel value, the maximum pixel position, and the maximum pixel value from the top. Subsequently, encoded data having a fixed length or less is arranged for the pixels OPm other than the minimum maximum pixel. At this time, if the difference between the minimum pixel and the maximum pixel is 0, it means that all the pixels in the block have the same value, and therefore encoded data of other pixel values OPm is not generated or added. . Following the encoded data having a fixed length or less, overbit encoded data (additional data EL ()) is added. In the present embodiment, the overbit encoded data has encoded data from additional data EL (0) to additional data EL (Anum-1). According to this configuration, the block range of all blocks in the image can be specified when the decoding apparatus decodes the encoded data having a fixed length or less. Therefore, the decoding apparatus can specify the position of the overblock and the corresponding data position of the overbit encoded data. Therefore, additional data can be decoded without requiring additional information. However, the code string is not limited to this. For example, fixed-length encoded data and overbit encoded data may be held in units of blocks. In this case, decoding can be performed for each block, but it is not possible to specify how many bits of additional data are present when the blocks are sequentially decoded. Therefore, it is necessary to add information for each overblock so that the added data amount can be known.

上記実施形態では、1ブロックの符号化データに、そのブロック内の最小画素Pminと最大画素Pmaxそれぞれの値と位置を示す情報を符号化せず含めるものとして説明した。しかし、これによって本発明が限定されるものではない。例えば、処理対象ブロックのブロックレンジBRがわかっていれば、最小画素Pminもしくは最大画素Pmaxのいずれか一方を代表画素値として決定し、その代表画素の画素値と位置とを、符号化データに含めるようにしてもよい。実施形態の場合、ブロックレンジBRは0乃至14の値を取り得るので、4ビットあれば十分である。この場合、1つのブロックの符号化データは、代表画素(最小画素Pmin、最大画素Pmaxのいずれか)の画素値、その画素位置、ブロックレンジBR、画素OPの固定長以下の符号化データとなる。   In the above-described embodiment, it has been described that the encoded data of one block includes information indicating the values and positions of the minimum pixel Pmin and the maximum pixel Pmax in the block without encoding. However, this does not limit the present invention. For example, if the block range BR of the processing target block is known, either the minimum pixel Pmin or the maximum pixel Pmax is determined as the representative pixel value, and the pixel value and position of the representative pixel are included in the encoded data. You may do it. In the case of the embodiment, the block range BR can take values from 0 to 14, so that 4 bits are sufficient. In this case, the encoded data of one block is encoded data of the pixel value of the representative pixel (either the minimum pixel Pmin or the maximum pixel Pmax), the pixel position, the block range BR, and the fixed length of the pixel OP. .

したがって、ブロック最大符号量Bmaxは、
Bmax=14+4+4+7×15=127ビット
となり、上記実施形態と比較して、1ブロックあたり7ビット削減できることになる。なお、上記にて、固定長FL(=7)に“14”ではなく“15”を乗算したのは、最大画素Pmax(又は最小画素Pmin)が固定長以下の符号化対象となるからである。
Therefore, the block maximum code amount Bmax is
Bmax = 14 + 4 + 4 + 7 × 15 = 127 bits, and 7 bits can be reduced per block as compared with the above embodiment. In the above, the reason why the fixed length FL (= 7) is multiplied by “15” instead of “14” is that the maximum pixel Pmax (or the minimum pixel Pmin) is an encoding target having a fixed length or less. .

以上のような構成により、本実施形態の画像符号化装置では、画質良く目標符号量以下の符号化データを生成することが可能になる。   With the configuration as described above, the image encoding apparatus of the present embodiment can generate encoded data with a high image quality and less than or equal to the target code amount.

なお、上記実施形態では、符号化単位のブロックのサイズを4×4画素とし、1画素が14ビット、固定長FL=7とする例を説明したが、これらの数値で本発明が限定されるものではないし、これらの数値はユーザが適宜設定できるようにしても良い。   In the above embodiment, an example in which the block size of the encoding unit is 4 × 4 pixels, one pixel is 14 bits, and the fixed length FL = 7 has been described, but the present invention is limited by these numerical values. These values are not intended, and these numerical values may be appropriately set by the user.

[第2の実施形態]
上記の第1の実施形態では、4×4画素、つまり、16画素からなるブロックを単位として、固定長以下の符号と、固定長を超える符号を生成しつつ、画像全面で固定長符号化(目標符号量T)以下の符号化データを生成する例について説明した。出力符号列を形成するために内部で一時保持するバッファ容量に制限がある場合などでは、画像全面ではなく、ある限られた領域で固定長符号化を行う構成としても良い。本第2の実施形態においては、画像を複数のブロックからなる小領域に分割し、この小領域を単位として固定長以下の符号化する例について説明する。以下、この固定長以下の符号化処理対象となる複数ブロックで構成される領域を“TR”と表現する。
[Second Embodiment]
In the first embodiment described above, fixed-length encoding is performed on the entire surface of the image while generating a code having a fixed length or less and a code exceeding the fixed length in units of 4 × 4 pixels, that is, 16 pixels. An example of generating encoded data equal to or less than the target code amount T) has been described. In the case where there is a limit to the buffer capacity that is temporarily held in order to form an output code string, a configuration may be adopted in which fixed-length encoding is performed not on the entire image but on a limited area. In the second embodiment, an example will be described in which an image is divided into small areas composed of a plurality of blocks, and encoding is performed with a fixed length or less in units of the small areas. Hereinafter, an area composed of a plurality of blocks to be encoded with a fixed length or less is expressed as “TR”.

本第2の実施形態の処理について、第1の実施形態と動作が異なる点を中心に簡潔に説明する。なお、本第2の実施形態においても、符号化対象の画像は、ベイヤ配列の画素で構成される画像であり、R,G0,G1,Bの各成分が14ビットで構成されるものとする。ただし、符号化対象の画像は1画素が、R、G、B等の複数成分で構成される画像であっても構なわい。入力部101は、第1の実施形態と同様に、入力した画像データから、1つの色成分の画素のみで構成されるモノクロ画像データを生成し、符号化部100に供給するものとする。従って、符号化部100は、1画素が14ビットで表されるモノクロ画像を符号化するものとする。   The processing of the second embodiment will be briefly described with a focus on differences in operation from the first embodiment. Also in the second embodiment, it is assumed that the image to be encoded is an image composed of pixels of a Bayer array, and each component of R, G0, G1, and B is composed of 14 bits. . However, the encoding target image may be an image in which one pixel is composed of a plurality of components such as R, G, and B. As in the first embodiment, the input unit 101 generates monochrome image data including only pixels of one color component from input image data and supplies the monochrome image data to the encoding unit 100. Therefore, the encoding unit 100 encodes a monochrome image in which one pixel is represented by 14 bits.

図11は、本実施形態における符号化処理の流れを示すフローチャートである。以下、図11に示したフローチャートを参照して、符号化部100から符号量制御部106の処理について説明する。   FIG. 11 is a flowchart showing the flow of the encoding process in the present embodiment. Hereinafter, the processing from the encoding unit 100 to the code amount control unit 106 will be described with reference to the flowchart shown in FIG.

まず、ステップS1101にて、符号化部100は、指定のバッファ容量に収まるように固定長化の処理対象の領域TRに含まれるブロック数bnを設定する。TRに含まれるブロック数bnは少なくとも1以上の値を取るものとする。また、本実施形態において、説明を簡易にするため、画像全面に対する総ブロック数は、TR内のブロック数bnの整数倍であるものとする。   First, in step S1101, the encoding unit 100 sets the number of blocks bn included in the region TR to be fixed-length processed so as to be within the specified buffer capacity. It is assumed that the number of blocks bn included in TR takes at least one value. Further, in this embodiment, to simplify the description, it is assumed that the total number of blocks for the entire image is an integral multiple of the number of blocks bn in TR.

ステップS1102にて、符号化部100は、領域TRの数RMを、次式に従って算出する。
RM=画像の総ブロック数/bn
また、符号化部100、処理した領域TRの数をカウントするためのカウンタkを0で初期化する。
In step S1102, encoding unit 100 calculates number RM of regions TR according to the following equation.
RM = total number of blocks in image / bn
In addition, the encoding unit 100 initializes a counter k for counting the number of processed regions TR with 0.

ステップS1103にて、符号化部100は着目領域TRの符号化を行う。この符号化処理は、図2のステップS201乃至209と同じである。異なるのは、図2の処理対象が領域TRになる点と、図2に示すフローチャートのステップS209における着目ブロックが領域内の最終ブロックであるか否かを判定する点である。つまり、ここで言う最終ブロックとは、領域TR内のbn個目のブロックを意味する。領域TR内の全てのブロックについて符号化処理(ステップS1103)が終了したと判断された場合(図2、ステップS209YES)、ステップS1104へ処理を進める。   In step S1103, encoding unit 100 encodes region of interest TR. This encoding process is the same as steps S201 to S209 in FIG. The difference is that the processing target in FIG. 2 is the region TR, and whether or not the block of interest in step S209 in the flowchart shown in FIG. 2 is the last block in the region. That is, the final block here means the bn-th block in the region TR. If it is determined that the encoding process (step S1103) has been completed for all the blocks in the region TR (YES in FIG. 2, step S209), the process proceeds to step S1104.

ステップS1104にて、処理対象の領域TRについて、符号量制御部106による符号量制御処理が行われる。この符号量制御処理については、図2のステップS210乃至215と実質的に同じである。つまり、符号量制御部106は、ブロック数bn分の固定長符号化結果から算出されたプール容量SDと、オーバービット符号化データ量との比較を行って、処理対象TRについて、目標符号量以下の符号量になるように符号量制御が行われる。本実施形態において、TRに対する目標符号量は、画像全体の目標符号量をTRの領域数kで割った値を設定する。TRに対する目標符号量はこれに限らず、画像の特徴量などによって、領域ごとに変化させるなどしてもかまわない。ただし、画像全面に対する目標符号量を超えないように設定する必要がある。また、TRを構成するブロック数は、本実施形態において全てのTRで同じブロック数を割り当てるものとしたが、これに限らず、領域ごとにブロック数を変更しても構わない。   In step S1104, the code amount control processing by the code amount control unit 106 is performed for the region TR to be processed. This code amount control process is substantially the same as steps S210 to S215 in FIG. That is, the code amount control unit 106 compares the pool capacity SD calculated from the fixed-length encoding result for the number of blocks bn and the overbit encoded data amount, and the processing target TR is equal to or less than the target code amount. The code amount control is performed so that the code amount becomes. In the present embodiment, the target code amount for TR is set to a value obtained by dividing the target code amount of the entire image by the number of TR regions k. The target code amount for TR is not limited to this, and may be changed for each region depending on the feature amount of the image. However, it is necessary to set so as not to exceed the target code amount for the entire image. In addition, in this embodiment, the same number of blocks is assigned to all TRs in the present embodiment. However, the number of blocks is not limited to this, and the number of blocks may be changed for each region.

ステップS1105にて、符号化部100は、カウンタkと、領域数RMとの比較を行う。k<RMの場合(YES)は、領域TRの符号化処理を繰り返すため、ステップS1106にて、カウンタkをインクリメントし、次の領域TRを処理対象とする。一方、了以域数RM分の符号化処理を行った場合(No)は、処理を終了する。   In step S1105, the encoding unit 100 compares the counter k with the number of regions RM. If k <RM (YES), in order to repeat the encoding process of region TR, in step S1106, counter k is incremented, and the next region TR is set as the processing target. On the other hand, when the encoding process for the number of RMs after completion is performed (No), the process ends.

全ての領域TRについて、符号化処理と符号量制御の処理を終了すると、符号列形成部107にて符号列が形成される。図10に本第2の実施形態における出力符号列の構成を示す図である。第1の実施形態と同様に、符号列の先頭には復号に必要な画像情報などを含むヘッダと、それに後続して各色成分の符号化データが配置される。1つの色成分の符号化データは、領域TR毎に固定長符号化データとオーバービット符号化データを持つ。ただし、符号列についてはこれに限るものではない。本実施形態において、画像内の所定の複数ブロックを固定長化単位として符号化を行っているため、処理対象の領域TRを符号化するごとに符号列を形成し、出力しても構わない。この場合には、ヘッダ情報は、符号化データとは別に出力してもよいし、各TRの符号化データにヘッダとして付加しても構わない。各TRの符号化データを個別で出力することにより、画像全面に対して固定長符号化した場合と比較して、低遅延での符号化データの出力が可能となる。   When the encoding process and the code amount control process are completed for all regions TR, the code string forming unit 107 forms a code string. FIG. 10 is a diagram illustrating a configuration of an output code string in the second embodiment. Similar to the first embodiment, a header including image information necessary for decoding and the subsequent encoded data of each color component are arranged at the head of the code string. The encoded data of one color component has fixed length encoded data and overbit encoded data for each region TR. However, the code string is not limited to this. In the present embodiment, since encoding is performed using a predetermined plurality of blocks in the image as a fixed length unit, a code string may be formed and output each time the region TR to be processed is encoded. In this case, the header information may be output separately from the encoded data, or may be added as a header to the encoded data of each TR. By outputting the encoded data of each TR individually, it is possible to output the encoded data with a low delay compared to the case where the fixed length encoding is performed on the entire image.

なお、本実施形態において、バッファ容量に応じて、固定長化する単位を所定の複数ブロックとする方法について説明を行ったが、これに限るものではない。予め定められたバッファ容量を全て利用できるように、固定長以下の符号化データとオーバービット符号化データの管理を行って符号量制御してもよい。ただし、その場合には、符号量制御単位に付加情報が必要になり、復号時の制御も複雑になる可能性がある。   In the present embodiment, the method of setting the fixed length unit to a plurality of predetermined blocks according to the buffer capacity has been described, but the present invention is not limited to this. The code amount may be controlled by managing encoded data having a fixed length or less and overbit encoded data so that all predetermined buffer capacities can be used. However, in that case, additional information is required for the code amount control unit, and control during decoding may be complicated.

以上、説明した処理制御を行うことで、所定単位に固定長化を行うことで、画像全体で固定長符号化する場合と比較して、低遅延で固定長符号化データの出力が可能となる。   As described above, by performing the processing control described above, it is possible to output fixed-length encoded data with low delay compared to the case where fixed-length encoding is performed on the entire image by performing fixed length in a predetermined unit. .

[第3の実施形態]
第1の実施形態や第2の実施形態においては、符号列形成の際に、符号量制御単位の領域内全ての固定長符号化データを符号列として並べ、その固定長符号化データの末尾にオーバービット符号化データを追加する形で符号列を形成する例であった。この場合、固定長符号化データとオーバービット符号化データが、符号量制御単位分揃った時点で、固定長のデータのまとまりが完成し、符号化データの伝送が開始できことになる。言い換えれば、固定長符号化データとオーバービット符号化データが揃わない限りに、符号化データの伝送が行えない。
[Third Embodiment]
In the first embodiment and the second embodiment, when the code string is formed, all the fixed-length encoded data in the area of the code amount control unit are arranged as a code string, and at the end of the fixed-length encoded data. In this example, the code string is formed by adding overbit encoded data. In this case, when the fixed-length encoded data and the overbit encoded data are arranged for the code amount control unit, the fixed-length data group is completed and transmission of the encoded data can be started. In other words, the encoded data cannot be transmitted unless the fixed-length encoded data and the overbit encoded data are prepared.

本実施形態では、より短い処理時間ごとに符号化データの伝送が可能となる符号列形成の方法について説明する。   In the present embodiment, a method for forming a code string that enables transmission of encoded data at shorter processing times will be described.

符号化処理そのものについては、第1、第2の実施形態と同様の処理であるため、その説明は省略する。そして、本実施形態におけるメインとなる処理は、符号列形成部107にある。この符号列形成部107により生成される符号列の例を図12に示し、以下にその符号列形成の方法を説明する。   Since the encoding process itself is the same process as in the first and second embodiments, the description thereof is omitted. The main process in the present embodiment is in the code string forming unit 107. An example of a code string generated by the code string forming unit 107 is shown in FIG. 12, and a method for forming the code string will be described below.

まず、本実施形態において、一定のタイミングで符号化データを伝送するための固定長の符号化データの単位を固定長パケットと呼ぶものとする。固定長パケットのデータ長は、固定長符号化データの符号長の上限と同じか、それよりも大きな値を設定すればよい。   First, in the present embodiment, a unit of fixed-length encoded data for transmitting encoded data at a fixed timing is referred to as a fixed-length packet. The data length of the fixed-length packet may be set to a value equal to or larger than the upper limit of the code length of the fixed-length encoded data.

本第3の実施形態において、符号列形成部107は、最初に処理される符号量制御単位の領域TR0については、生成された各ブロックの固定長符号化データについて、固定長パケットを生成し、出力部108を介して伝送を行わせる。図12は、出力符号列の例である。ここで、先頭ブロックB(0,0)はオーバービットが発生したブロック、続く、B(1,0)はオーバービットなしに固定長以下で符号化されたブロックとする。図12に示すように、符号列形成部107は、画像の先頭ブロックB(0,0)の符号化データはそのまま固定長パケットを生成し、出力部108を介して伝送する。続いて、符号列形成部107は、ブロックB(1,0)の符号化データについては、固定長パケットのデータ長よりも短いために、固定長パケットのデータ長となるようにダミーデータを付加し。出力部108を介して伝送する。なお、領域TR0の固定長符号化データと並行して生成された、領域TR0のオーバービット符号化データは、符号化パケットの生成を行っている最中にバッファ105に格納されていくが、この段階では出力されない。   In the third embodiment, the code string forming unit 107 generates a fixed-length packet for the fixed-length encoded data of each block generated for the region TR0 of the code amount control unit to be processed first, Transmission is performed via the output unit 108. FIG. 12 is an example of an output code string. Here, the head block B (0, 0) is a block in which an overbit is generated, and the subsequent B (1, 0) is a block encoded with a fixed length or less without an overbit. As shown in FIG. 12, the code string forming unit 107 generates a fixed-length packet as it is from the encoded data of the head block B (0, 0) of the image and transmits it through the output unit 108. Subsequently, since the encoded data of block B (1, 0) is shorter than the data length of the fixed-length packet, the code string forming unit 107 adds dummy data so as to be the data length of the fixed-length packet. Yes. The data is transmitted via the output unit 108. Note that the overbit encoded data in the region TR0, generated in parallel with the fixed length encoded data in the region TR0, is stored in the buffer 105 during the generation of the encoded packet. It is not output at the stage.

続いて、領域TR1の固定長符号化が行われる。TR1内の符号化対象ブロックB(i,j)について固定長符号化データを生成後、固定長パケットを生成するために、対象ブロックの固定長符号化データに、1つ前の領域TR0のオーバービット符号化データの中から、追加可能なデータ長分の符号化データを付加する。復号時には、固定長パケットのデータ長がわかっていれば、B(i,j)の固定長符号化データを復号した時点で、復号対象の固定長パケットに追加されているデータ長が特定できる。符号化対象ブロックに対する固定長パケットが生成されると伝送が開始される。なお、符号化対象ブロックB(i,j)の固定長符号化データと領域TR0の追加データを合わせたデータ長が、固定長パケットのデータ長に満たない場合には、ダミーデータを付加するなどして、固定長パケットとなるように調整すればよい。並行して、領域TR1のオーバービット符号化データを生成し、格納しておく。   Subsequently, fixed length coding of the region TR1 is performed. After generating fixed length encoded data for the encoding target block B (i, j) in TR1, in order to generate a fixed length packet, the fixed length encoded data of the target block is overwritten with the previous region TR0. Encoded data for an additional data length is added from the bit encoded data. At the time of decoding, if the data length of the fixed-length packet is known, the data length added to the fixed-length packet to be decoded can be specified when the fixed-length encoded data of B (i, j) is decoded. Transmission is started when a fixed-length packet for the encoding target block is generated. If the data length of the fixed-length encoded data of the encoding target block B (i, j) and the additional data of the area TR0 is less than the data length of the fixed-length packet, dummy data is added. Then, it may be adjusted so as to be a fixed-length packet. In parallel, the overbit encoded data of the region TR1 is generated and stored.

画像内の最後に処理される符号量制御領域TR(RM−1)のオーバービット符号化データについては、全てのデータを追加できるように、固定長パケットを生成して伝送してもよい。また、予めさだめられた固定長パケット数分のオーバービット符号化データを追加して送信してもよいものとする。   As for the overbit encoded data of the code amount control region TR (RM-1) to be processed last in the image, a fixed-length packet may be generated and transmitted so that all data can be added. In addition, it is assumed that overbit encoded data corresponding to the number of fixed-length packets stored in advance may be added and transmitted.

以上、説明した処理制御を行うことで、ブロック単位に固定長符号化を行うよりも広い範囲での符号量制御を実現しつつ、ブロックの符号化毎に固定長パケットを生成できることで、一定のタイミングで符号化データの伝送が可能となる。   As described above, by performing the processing control described above, it is possible to generate a fixed-length packet for each block encoding while realizing code amount control in a wider range than performing fixed-length encoding in units of blocks. The encoded data can be transmitted at the timing.

[第4の実施形態]
これまでの実施形態では、画像について1つの固定長FLを設定して符号化を行う方法について説明を行った。固定長FLは画像の領域ごとの特徴を表す情報(以下、認識情報と呼ぶ)を取得して、それに基づいてブロックごとに独立して固定長FL値を設定してもよい。本第4の実施形態においては、符号化対象画像の複雑度を認識情報として利用して、ブロック毎に固定長FLを設定する方法について説明する。なお、符号化対象画像データがモノクロ画像であり、1画素14ビットで表されるなどの条件はこれまでと同じとする。
[Fourth Embodiment]
In the embodiments described so far, the method of performing encoding by setting one fixed length FL for an image has been described. The fixed length FL may acquire information (hereinafter referred to as recognition information) representing characteristics for each region of the image, and set a fixed length FL value independently for each block based on the information. In the fourth embodiment, a method of setting a fixed length FL for each block using the complexity of the encoding target image as recognition information will be described. It is assumed that the encoding target image data is a monochrome image and is represented by 14 bits per pixel, for example.

図13は、本第4の実施形態に係る画像処理装置の機能構成を示すブロック図である。図13に示すように、本第4の実施形態の装置は、図1の機能構成に、認識情報取得部1301と固定長設定部1302を追加した構成となる。それ故、以下では、主に認識情報取得部1301と固定長設定部1302の処理の流れについて、以下に説明を行う。   FIG. 13 is a block diagram illustrating a functional configuration of the image processing apparatus according to the fourth embodiment. As shown in FIG. 13, the apparatus according to the fourth embodiment has a configuration in which a recognition information acquisition unit 1301 and a fixed length setting unit 1302 are added to the functional configuration of FIG. Therefore, hereinafter, the flow of processing of the recognition information acquisition unit 1301 and the fixed length setting unit 1302 will be mainly described below.

本実施形態では、認識情報取得部1301による符号化対象画像からの認識情報の取得処理と、符号化処理の2パスで処理する。   In the present embodiment, the recognition information acquisition unit 1301 performs processing in two passes: recognition information acquisition processing from an encoding target image and encoding processing.

図14は、2パス目の符号化処理、すなわち、1パス目で取得した認識情報に基づく固定長FLを設定する場合の処理フローを表す。   FIG. 14 shows a processing flow in the case of setting the fixed length FL based on the second pass encoding process, that is, the recognition information acquired in the first pass.

まず、ステップS1401にて、入力部101が符号化対象の画像データを入力する。図14に示す処理フローでは、画像入力とは別のタイミングで認識情報を取得するような処理フローとしているが、これに限らず、画像入力と同時に認識情報を入力しても構わない。   First, in step S1401, the input unit 101 inputs image data to be encoded. In the processing flow shown in FIG. 14, the processing flow is such that the recognition information is acquired at a timing different from the image input. However, the present invention is not limited to this, and the recognition information may be input simultaneously with the image input.

ステップS1402にて、ブロック分割部102が、入力された符号化対象の画像からブロックに分割する。   In step S1402, the block dividing unit 102 divides the input encoding target image into blocks.

続いて、ステップS1403にて、認識情報取得部1301が、認識情報を取得する(詳細後述)。   Subsequently, in step S1403, the recognition information acquisition unit 1301 acquires the recognition information (details will be described later).

ステップS1404にて、固定長設定部1302は、取得した認識情報から、符号化対象の着目ブロックの固定長FLを決定する。認識情報に応じた固定長FLの設定方法の詳細については、後述する。   In step S1404, the fixed length setting unit 1302 determines the fixed length FL of the target block to be encoded from the acquired recognition information. Details of the method of setting the fixed length FL according to the recognition information will be described later.

ステップS1405では、符号化部100は、ステップS1404にて設定した固定長FLを用いて、着目ブロックの符号化を行う。全ブロックについて符号化処理を終了すると、ステップS1406にて符号量制御部106による符号量制御処理を行い、符号列形成部107が符号列を形成する。形成された符号化データは、ステップS1407にて、出力部108により出力され、符号化処理を終了する。   In step S1405, the encoding unit 100 encodes the block of interest using the fixed length FL set in step S1404. When the encoding process is completed for all the blocks, the code amount control unit 106 performs code amount control processing in step S1406, and the code string forming unit 107 forms a code string. The formed encoded data is output by the output unit 108 in step S1407, and the encoding process ends.

ここで、ステップS1404の認識情報に応じた固定長の設定方法について、以下に説明を行う。本第4の実施形態において、画像の複雑度を認識情報として入力する。ここで、画像の複雑度とは、実施形態で説明した符号化処理により生成される符号量が多く発生するか否かを予測できる情報である。これまでの説明からわかるように、ブロック符号化部103において、ブロック内の最小画素と最大画素を探索し、最小画素と最大画素以外の画素について、固定長FL以下で符号化する。この場合、最小画素と最大画素の差分DIFFの値が大きいほど、固定長FLを超えるデータが増えることになる。一方、最小画素と最大画素の差分値DIFFが小さいほど、固定長FLよりも短い符号長で符号化できる。この特性から、画像の領域毎の画素値の差分の大小が複雑度を表す指標値として利用できる。たとえば、複雑度の取得方法として、認識処理を簡易に実現するために、符号化対象画像の縮小画像に対して、処理を行うものとする。縮小画像の生成方法は、一定間隔置きに画素値を間引いてサブサンプリング画像を生成しても良いし、複数画素の平均値を取るなどして生成しても構わない。本実施形態においては、1ブロックが4×4画素であるので、4×4画素の1画素を取ってきて、縮小画像を生成した場合の複雑度の取得する方法について説明する。   Here, the fixed length setting method corresponding to the recognition information in step S1404 will be described below. In the fourth embodiment, the complexity of the image is input as recognition information. Here, the complexity of an image is information that can predict whether or not a large amount of code is generated by the encoding process described in the embodiment. As can be understood from the above description, the block encoding unit 103 searches for the minimum pixel and the maximum pixel in the block, and encodes pixels other than the minimum pixel and the maximum pixel with a fixed length FL or less. In this case, the larger the value of the difference DIFF between the minimum pixel and the maximum pixel, the more data that exceeds the fixed length FL. On the other hand, the smaller the difference value DIFF between the minimum pixel and the maximum pixel, the shorter the code length than the fixed length FL. From this characteristic, the magnitude of the difference in pixel value for each area of the image can be used as an index value representing complexity. For example, as a method for obtaining complexity, it is assumed that processing is performed on a reduced image of an encoding target image in order to easily realize recognition processing. As a generation method of the reduced image, the sub-sampled image may be generated by thinning out the pixel values at regular intervals, or may be generated by taking an average value of a plurality of pixels. In the present embodiment, since one block is 4 × 4 pixels, a method of acquiring complexity when a reduced image is generated by taking one pixel of 4 × 4 pixels will be described.

図15に示すように、4×4画素のうちの左上画素を縮小画像の画素(以下、縮小画素という)とする場合には、ブロックが4×4の16画素で構成されている場合に、正しいブロックレンジを特定することはできない。そのため、隣接する縮小画素との差分を算出して、その差分値を表現するために必要なビット数を、ブロックレンジの予測値とする。ブロックレンジの予測値を、ブロック単位の複雑度Cpとして取得するものとする。例えば、着目する縮小画素と、隣接縮小画素との差分値を算出した結果、0であった場合には複雑度Cpを0とする。画素が14ビットの場合、画素値は0〜16383の値を取り得るので、これを表現可能なビット数は、0〜14ビットであるため、複雑度Cpは0〜14で良いであろう。複雑度Cpの算出方法や、取り得る値については、これに限るものではなく、ブロックレンジの予測をして、ブロック毎の固定長を設定できるようなデータが取得できれば良い。   As shown in FIG. 15, when the upper left pixel of 4 × 4 pixels is a pixel of a reduced image (hereinafter referred to as a reduced pixel), when the block is composed of 16 pixels of 4 × 4, The correct block range cannot be specified. Therefore, the difference between adjacent reduced pixels is calculated, and the number of bits necessary to express the difference value is set as the predicted value of the block range. The predicted value of the block range is acquired as the complexity Cp in units of blocks. For example, if the difference value between the reduced pixel of interest and the adjacent reduced pixel is 0, the complexity Cp is set to 0. When the pixel is 14 bits, the pixel value can take a value of 0 to 16383. Therefore, since the number of bits that can represent this is 0 to 14 bits, the complexity Cp may be 0 to 14. The calculation method of the complexity Cp and possible values are not limited to this, and it is only necessary to obtain data that can set a fixed length for each block by predicting the block range.

取得した複雑度Cpと、画像全面に対する目標符号量とから、各ブロックに対する固定長FLを設定することができる。   The fixed length FL for each block can be set from the acquired complexity Cp and the target code amount for the entire image.

画像全面に対する目標符号量と基本的な固定長FLは予め定められているものとする。本実施形態においては、基本の固定長をFL、ブロック毎に設定する固定長をVFLと表現し、予め定められた基本の固定長FLは7とする。この時、図16(a)、(b)、(c)に示す例のように、画像内の全ブロックに対する複雑度Cpの値の変動が小さく、ほぼ一定値である場合には、ブロック毎の固定長VFLの設定処理は省略し、基本の固定長FLをそのまま利用して符号化処理を行う。   It is assumed that the target code amount and the basic fixed length FL for the entire image are determined in advance. In this embodiment, the basic fixed length is expressed as FL, the fixed length set for each block is expressed as VFL, and the predetermined basic fixed length FL is 7. At this time, as in the examples shown in FIGS. 16A, 16B, and 16C, when the variation in the value of the complexity Cp for all the blocks in the image is small and almost constant, The fixed length VFL setting process is omitted, and the encoding process is performed using the basic fixed length FL as it is.

一方、各ブロックに対する複雑度Cpの値の変動が大きい場合に、ブロック毎に固定長VFLを設定する。本実施形態において、VFLは、複雑度Cpに対して、一定のビット数を引いた値を設定する。ただし、基本の固定長FLを全ブロックに適用した場合のデータ長が上限となるように各ブロックの固定長VFLを設定する必要がある。つまり、画像全面としての目標符号量以下になるように、各ブロックに対する固定長VFLを設定する。   On the other hand, when the variation of the complexity Cp value for each block is large, a fixed length VFL is set for each block. In the present embodiment, the VFL sets a value obtained by subtracting a certain number of bits from the complexity Cp. However, it is necessary to set the fixed length VFL of each block so that the upper limit is the data length when the basic fixed length FL is applied to all blocks. That is, the fixed length VFL for each block is set so as to be equal to or less than the target code amount for the entire image.

図17(a),(b)に、ブロック毎の固定長VFLの設定値の推移のイメージ図を示す。図17(b)の斜線部分の面積が、図17(a)の斜線部分の面積以下となるように、ブロック毎の固定長VFLを設定する。以上の方法で設定したブロック毎の固定長VFLで、各ブロックの符号化処理を行う。   FIGS. 17 (a) and 17 (b) show conceptual diagrams of changes in the set value of the fixed length VFL for each block. The fixed length VFL for each block is set so that the area of the shaded portion in FIG. 17B is equal to or smaller than the area of the shaded portion in FIG. Each block is encoded with the fixed length VFL for each block set by the above method.

符号化時に、実際のブロックレンジBRが予測値よりも大きな値である場合には、予測値との差分の分だけ、対象ブロックのオーバービット符号化データの優先度を高くするなど、補正処理を行うことで、さらに精度良く画質劣化の度合いを制御することが可能となる。また、ブロックレンジBRの小さなブロックに対しても、オーバーブロック符号化データの優先度を高く設定しておくことで、符号量制御時にロスレスにできる可能性が高くなる。   When the actual block range BR is larger than the predicted value at the time of encoding, correction processing such as increasing the priority of the overbit encoded data of the target block by the difference from the predicted value is performed. By doing so, it is possible to control the degree of image quality degradation with higher accuracy. In addition, by setting the priority of the overblock encoded data high even for a block having a small block range BR, there is a high possibility that losslessness can be achieved during code amount control.

なお、第4の実施形態を実施する際には、ブロックの符号化データにブロックヘッダを設け、その中でブロック符号化部103が利用した固定長FLを記述されることになる。   When the fourth embodiment is implemented, a block header is provided in the encoded data of the block, and the fixed length FL used by the block encoding unit 103 is described therein.

以上説明したように、本第4の実施形態によれば、ブロック毎の固定長FLを可変に設定することで、符号量制御単位の範囲内での画質劣化の度合いを一定に保つことが可能である。更に、固定長以下の符号化データをブロック毎に順次、装置外部へ出力する場合には、符号化処理時に保持しておくデータはオーバービット符号化データのみとなるため、固定長FLが一定の場合と比較して、バッファ容量を小さくできる。   As described above, according to the fourth embodiment, by setting the fixed length FL for each block variably, it is possible to keep the degree of image quality deterioration within the range of the code amount control unit constant. It is. Furthermore, when the encoded data of a fixed length or less is output to the outside of the apparatus sequentially for each block, the data to be retained during the encoding process is only the overbit encoded data, so the fixed length FL is constant. Compared to the case, the buffer capacity can be reduced.

[第5の実施形態]
上記第4の実施形態では、認識情報として、複雑度を取得し、ブロック毎の固定長を変動させて符号化する方法について説明を行った。本第5の実施形態においては、認識情報として関心領域(以下、ROIとも呼ぶ)を取得した場合の固定長の設定方法について説明を行う。
[Fifth Embodiment]
In the fourth embodiment, the method has been described in which the complexity is acquired as the recognition information, and the encoding is performed by changing the fixed length for each block. In the fifth embodiment, a method for setting a fixed length when a region of interest (hereinafter also referred to as ROI) is acquired as recognition information will be described.

処理の流れは、第4の実施形態と同様で、図14に示す通りであるため、詳細な説明は省略する。本第5の実施形態では、取得する認識情報の内容と、認識情報に応じた固定長の設定(図14のステップS1404)方法に特徴があるため、かかる点について以下に説明する。   The processing flow is the same as that of the fourth embodiment and is as shown in FIG. Since the fifth embodiment is characterized by the content of the recognition information to be acquired and the method of setting a fixed length according to the recognition information (step S1404 in FIG. 14), this point will be described below.

本実施形態においては、認識情報として、装置外部で特定されたROIの位置情報やサイズなどを取得するものとする。ROIの位置情報とサイズを取得することで、画像内の各ブロックについて、ROIを含むか否かを特定することができる。図18に、ROIと、ROIを含むブロックとの関係の例を示す。図18の太枠で囲われた領域がROIであり、斜線で示した領域がROIを含むブロックを示している。   In this embodiment, it is assumed that the position information and size of the ROI specified outside the apparatus are acquired as the recognition information. By acquiring the position information and the size of the ROI, it is possible to specify whether or not the ROI is included for each block in the image. FIG. 18 shows an example of the relationship between the ROI and the block including the ROI. A region surrounded by a thick frame in FIG. 18 is an ROI, and a region indicated by diagonal lines indicates a block including the ROI.

ROIを含むブロックを符号化する際には、固定長設定部1302は、予め定められたROI用の固定長HFLをブロック符号化部103に設定する。一方、ROIを含まないブロックを符号化する際、固定長設定部1302は、予め定められたROI以外用の固定長LFLをブロック符号化部103に設定する。ROI用の固定長HFLと、ROI以外の固定長LFLの値は、基本の固定長FLと、画像全面に対する目標符号量から決定する。第4の実施形態と同様に、基本の固定長FLを全ブロックに適用した場合のデータ長が上限となるように、HFLとLFLの値を決める必要がある。ROI用の固定長HFLについては、画像の属性や、ROIの個数などによって、予め一定以上の値となるように決定しておいて、目標符号量との関係から、ROI以外用の固定長LFLを算出するような方法でも構わない。ブロック毎の固定長の変動について図19に一例を示す。   When encoding a block including an ROI, the fixed length setting unit 1302 sets a predetermined fixed length HFL for ROI in the block encoding unit 103. On the other hand, when encoding a block that does not include an ROI, the fixed length setting unit 1302 sets a predetermined fixed length LFL other than the ROI in the block encoding unit 103. The values of the fixed length HFL for ROI and the fixed length LFL other than ROI are determined from the basic fixed length FL and the target code amount for the entire image. As in the fourth embodiment, it is necessary to determine the values of HFL and LFL so that the data length becomes the upper limit when the basic fixed length FL is applied to all blocks. The fixed length HFL for ROI is determined to be a predetermined value or more in advance according to the attribute of the image, the number of ROIs, and the like. From the relationship with the target code amount, the fixed length LFL for non-ROI is used. It is also possible to use a method for calculating. An example of the variation of the fixed length for each block is shown in FIG.

以上の方法により、ROIを含むブロックに対して、一定値以上の固定長を設定することで、ROIを高画質に保ちつつ、符号量制御を行うことができる。   With the above method, by setting a fixed length of a certain value or more for a block including the ROI, the code amount control can be performed while maintaining the ROI with high image quality.

なお、認識情報として、複雑度とROIを取得した場合について、個別に説明を行ったが、この2つの情報を組み合わせて、固定長を設定しても構わない。例えば、ブロック毎の固定長VFLをベースとして設定するが、ROIを含むブロックについては、予め定めた一定値以上のデータ長を持つように固定長HFLを設定しても良い。この場合についても、ブロック毎に変動する固定長は、基本の固定長FLを全ブロックに適用した場合のデータ長が上限となるように設定する必要がある。   In addition, although the case where complexity and ROI were acquired as recognition information was demonstrated separately, you may set fixed length combining these two information. For example, although the fixed length VFL for each block is set as a base, the fixed length HFL may be set so that the block including the ROI has a data length equal to or greater than a predetermined value. Also in this case, the fixed length that varies for each block needs to be set so that the data length when the basic fixed length FL is applied to all the blocks becomes the upper limit.

また、ROIを含むブロックを特定する情報は、符号化データのヘッダに格納しておけば良い。   Information for specifying a block including the ROI may be stored in the header of the encoded data.

(その他の実施例)
本発明は、上述の実施形態の1以上の機能を実現するプログラムを、ネットワーク又は記憶媒体を介してシステム又は装置に供給し、そのシステム又は装置のコンピュータにおける1つ以上のプロセッサーがプログラムを読出し実行する処理でも実現可能である。また、1以上の機能を実現する回路(例えば、ASIC)によっても実現可能である。
(Other examples)
The present invention supplies a program that realizes one or more functions of the above-described embodiments to a system or apparatus via a network or a storage medium, and one or more processors in a computer of the system or apparatus read and execute the program This process can be realized. It can also be realized by a circuit (for example, ASIC) that realizes one or more functions.

101…入力部、102…ブロック分割部、103…ブロック符号化部、104…オーバービット符号化部、105…バッファ、106…符号量制御部、107…符号列形成部、108…出力部   DESCRIPTION OF SYMBOLS 101 ... Input part, 102 ... Block division part, 103 ... Block encoding part, 104 ... Overbit encoding part, 105 ... Buffer, 106 ... Code amount control part, 107 ... Code sequence formation part, 108 ... Output part

Claims (12)

画像を符号化する画像符号化装置であって、
画像データを複数画素で構成されるブロックに分割する分割手段と、
該分割手段で得た着目ブロックから可逆符号化データを生成し、当該可逆符号化データの符号量が目標符号量を超える場合には、超過したデータをメモリに記憶すると共に前記超過したデータを除いて得た非可逆符号化データを前記着目ブロックの符号化データとして生成し、前記可逆符号化データの符号量が前記目標符号量以下の場合には、当該可逆符号化データを前記着目ブロックの符号化データとして生成する第1の符号化手段と、
前記メモリに格納された前記超過したデータを符号化する第2の符号化手段と、
前記第1の符号化手段によるブロックの符号化にて、前記目標符号量に満たない符号化データが発生するたびに、前記目標符号量に対する余剰データ容量をカウントするカウント手段と、
前記画像データに対する前記第1の符号化手段による符号化を終えた場合、前記第2の符号化手段で生成された符号化データのうち前記カウント手段でカウントした余剰データ容量に対応する符号化データを、前記第1の符号化手段で得た符号化データに付加して出力する符号量制御手段と
を有することを特徴とする画像符号化装置。
An image encoding device for encoding an image, comprising:
A dividing means for dividing the image data into blocks composed of a plurality of pixels;
When lossless encoded data is generated from the block of interest obtained by the dividing means and the code amount of the lossless encoded data exceeds the target code amount, the excess data is stored in the memory and the excess data is removed. When the lossless encoded data is generated as encoded data of the block of interest and the code amount of the lossless encoded data is less than or equal to the target code amount, the lossless encoded data is converted to the code of the block of interest. First encoding means for generating as encoded data;
Second encoding means for encoding the excess data stored in the memory;
Counting means for counting an excess data capacity with respect to the target code amount each time encoded data less than the target code amount is generated in the block encoding by the first encoding unit;
Encoded data corresponding to the surplus data capacity counted by the counting unit among the encoded data generated by the second encoding unit when the encoding by the first encoding unit is completed for the image data And an amount of code control means for adding to the encoded data obtained by the first encoding means and outputting the encoded data.
前記第1の符号化手段は、
前記着目ブロック内の最小の値を持つ最小画素Pmin、最大の値を持つ最大画素Pmax、及び、前記最小画素Pmin及び最大画素Pmaxそれぞれの位置を抽出する抽出手段と、
前記最小画素Pminと前記最大画素Pmaxとから前記着目ブロック内の画素値の取り得る範囲を表すための最小ビット数を表すBRを求め、前記最小画素Pmin、最大画素Pmaxを除く他の画素については、前記最小画素Pmin又は最大画素Pmaxの値との差を、前記BRが示すビット数の精度で算出する算出手段と、
前記BRと前記目標符号量となるための固定長さを表すFLとを比較する比較手段と、
該比較手段の比較の結果がBR≦FLを示す場合、前記抽出手段で得た情報、及び、前記算出手段で得た情報を、前記着目ブロックの符号化データとして生成し、
該比較手段の比較の結果がBR>FLを示す場合、前記抽出手段で得た情報、及び、前記算出手段で得た差分を示すビット数BRのうち、上位のFLが示すビット数の情報を前記着目ブロックの符号化データとして生成すると共に、前記差分を示すビット数BRのうち、下位の「BR−FL」のビット数のデータを前記メモリに格納する生成手段と、
を含むことを特徴とする請求項1に記載の画像符号化装置。
The first encoding means includes:
Extraction means for extracting the minimum pixel Pmin having the minimum value in the block of interest, the maximum pixel Pmax having the maximum value, and the positions of the minimum pixel Pmin and the maximum pixel Pmax;
From the minimum pixel Pmin and the maximum pixel Pmax, BR representing the minimum number of bits for representing a possible range of pixel values in the block of interest is obtained, and other pixels excluding the minimum pixel Pmin and the maximum pixel Pmax are obtained. Calculating means for calculating the difference from the value of the minimum pixel Pmin or the maximum pixel Pmax with the accuracy of the number of bits indicated by the BR;
Comparing means for comparing the BR and FL representing a fixed length for achieving the target code amount;
When the comparison result of the comparison means indicates BR ≦ FL, the information obtained by the extraction means and the information obtained by the calculation means are generated as encoded data of the block of interest,
When the comparison result of the comparison means indicates BR> FL, information on the number of bits indicated by the higher order FL among the information obtained by the extraction means and the bit number BR indicating the difference obtained by the calculation means Generating means for generating the encoded data of the block of interest, and storing data of the lower number of bits “BR-FL” in the memory among the number of bits BR indicating the difference;
The image encoding apparatus according to claim 1, further comprising:
前記第1の符号化手段は、
前記着目ブロック内の最小又は最大の値を持つ代表画素、当該代表画素の位置、及び、前記着目ブロック内の画素の値の取り得る範囲を表す最小ビット数を表すBRを抽出する抽出手段と、
前記代表画素を除く他の画素については、前記代表画素の値との差を、前記BRが示すビット数の精度で算出する算出手段と、
前記BRと前記目標符号量となるための固定長さを表すFLとを比較する比較手段と、
該比較手段の比較の結果がBR≦FLを示す場合、前記抽出手段で得た情報、及び、前記算出手段で得た情報を、前記着目ブロックの符号化データとして生成し、
該比較手段の比較の結果がBR>FLを示す場合、前記抽出手段で得た情報、及び、前記算出手段で得た差分を示すビット数BRのうち、上位のFLが示すビット数の情報を前記着目ブロックの符号化データとして生成すると共に、前記差分を示すビット数BRのうち、下位の「BR−FL」のビット数のデータを前記メモリに格納する生成手段と、
を含むことを特徴とする請求項1に記載の画像符号化装置。
The first encoding means includes:
Extraction means for extracting a representative pixel having a minimum or maximum value in the block of interest, a position of the representative pixel, and a BR representing a minimum number of bits representing a possible range of the value of the pixel in the block of interest;
For other pixels excluding the representative pixel, calculation means for calculating the difference from the value of the representative pixel with the accuracy of the number of bits indicated by the BR;
Comparing means for comparing the BR and FL representing a fixed length for achieving the target code amount;
When the comparison result of the comparison means indicates BR ≦ FL, the information obtained by the extraction means and the information obtained by the calculation means are generated as encoded data of the block of interest,
When the comparison result of the comparison means indicates BR> FL, information on the number of bits indicated by the higher order FL among the information obtained by the extraction means and the bit number BR indicating the difference obtained by the calculation means Generating means for generating the encoded data of the block of interest, and storing data of the lower number of bits “BR-FL” in the memory among the number of bits BR indicating the difference;
The image encoding apparatus according to claim 1, further comprising:
前記カウンタ手段は、BR<FLの関係を有する場合のFL−BRの値を前記余剰データ容量としてカウントすることを特徴とする請求項2又は3に記載の画像符号化装置。   4. The image coding apparatus according to claim 2, wherein the counter unit counts the value of FL-BR when the relation BR <FL is satisfied as the surplus data capacity. 前記第2の符号化手段は、前記第1の符号化手段が前記メモリに格納する、前記差分を示すビット数BRのうち下位の「BR−FL」のビット数のデータのうち、上位から下位の各ビット位置のビット列に分けて記憶する手段を含む
ことを特徴とする請求項2乃至4のいずれか1項に記載の画像符号化装置。
The second encoding means stores the first encoding means in the memory from the higher order to the lower order among the data of the lower number of bits “BR-FL” of the number of bits BR indicating the difference. 5. The image encoding device according to claim 2, further comprising: a unit that stores the bit sequence in each bit position.
前記符号量制御手段は、前記第2の符号化手段が記憶する上位のビット列を優先して、前記第1の符号化手段で得た符号化データに付加する
ことを特徴とする請求項5に記載の画像符号化装置。
The code amount control means preferentially adds the higher-order bit string stored in the second encoding means to the encoded data obtained by the first encoding means. The image encoding device described.
符号化対象の画像データから予め設定されたサイズの領域の画像を入力する入力手段を有し、
前記分割手段は、前記入力手段で入力した前記領域の画像を分割することを特徴とする請求項1乃至6のいずれか1項に記載の画像符号化装置。
Input means for inputting an image of a region of a preset size from the image data to be encoded;
The image coding apparatus according to claim 1, wherein the dividing unit divides the image of the region input by the input unit.
前記符号量制御手段は、
前記第1の符号化手段によって、前記入力した領域内の着目ブロックを符号化したときに得られた符号化データのデータ量が前記目標符号量に至らず余剰データ容量が発生した場合、
前記領域よりも前に入力した領域までを含む、前記着目ブロックより前に符号化を行ったブロックについて前記第2の符号化手段が生成した符号化データにおける、前記余剰データ容量に対応する符号化データを、前記着目ブロックの第1の符号化データが生成した符号化データに付加する
ことを特徴とする請求項7に記載の画像符号化装置。
The code amount control means includes:
When the data amount of the encoded data obtained when the target block in the input area is encoded by the first encoding means does not reach the target code amount, and surplus data capacity is generated,
Encoding corresponding to the surplus data capacity in the encoded data generated by the second encoding means for a block that has been encoded before the target block, including up to an area input before the area The image encoding apparatus according to claim 7, wherein the data is added to encoded data generated by the first encoded data of the block of interest.
画像データのブロックごとの複雑度を表す情報を取得する取得手段と、
該取得手段で取得した情報に基づき、ブロック単位に、前記目標符号量を設定する設定手段を更に有する
ことを特徴とする請求項1乃至8のいずれか1項に記載の画像符号化装置。
Acquisition means for acquiring information representing the complexity of each block of image data;
The image coding apparatus according to any one of claims 1 to 8, further comprising setting means for setting the target code amount for each block based on information obtained by the obtaining means.
画像データが表す画像に対するROIを示す情報を取得手段と、
該取得手段で取得した前記ROIを含むブロックには第1の目標符号量、前記ROIを含まないブロックに対しては前記第1の目標符号量より低い第2の目標符号量を設定する設定手段を更に有する
ことを特徴とする請求項1乃至8のいずれか1項に記載の画像符号化装置。
Information indicating ROI for the image represented by the image data;
Setting means for setting a first target code amount for a block including the ROI acquired by the acquiring means, and a second target code amount lower than the first target code amount for a block not including the ROI. The image encoding device according to claim 1, further comprising:
画像を符号化する画像符号化装置の制御方法であって、
分割手段が、画像データを複数画素で構成されるブロックに分割する分割工程と、
第1の符号化手段が、前記分割工程で得た着目ブロックから可逆符号化データを生成し、当該可逆符号化データの符号量が目標符号量を超える場合には、超過したデータをメモリに記憶すると共に前記超過したデータを除いて得た非可逆符号化データを前記着目ブロックの符号化データとして生成し、前記可逆符号化データの符号量が前記目標符号量以下の場合には、当該可逆符号化データを前記着目ブロックの符号化データとして生成する第1の符号化工程と、
第2の符号化手段が、前記メモリに格納された前記超過したデータを符号化する第2の符号化工程と、
カウント手段が、前記第1の符号化工程によるブロックの符号化にて、前記目標符号量に満たない符号化データが発生するたびに、前記目標符号量に対する余剰データ容量をカウントするカウント工程と、
符号量制御手段が、前記画像データに対する前記第1の符号化工程による符号化を終えた場合、前記第2の符号化工程で生成された符号化データのうち前記カウント工程でカウントした余剰データ容量に対応する符号化データを、前記第1の符号化工程で得た符号化データに付加して出力する符号量制御工程と
を有することを特徴とする画像符号化装置の制御方法。
A control method for an image encoding device for encoding an image, comprising:
A dividing step in which the dividing unit divides the image data into blocks composed of a plurality of pixels;
The first encoding means generates lossless encoded data from the block of interest obtained in the dividing step, and stores the excess data in the memory when the code amount of the lossless encoded data exceeds the target code amount. When the lossy encoded data obtained by removing the excess data is generated as the encoded data of the block of interest, and the code amount of the lossless encoded data is equal to or less than the target code amount, the lossless code A first encoding step of generating encoded data as encoded data of the block of interest;
A second encoding step, wherein a second encoding means encodes the excess data stored in the memory;
A counting step of counting surplus data capacity with respect to the target code amount each time encoded data less than the target code amount is generated in the block encoding in the first encoding step;
When the code amount control means finishes encoding the image data in the first encoding step, the surplus data capacity counted in the counting step among the encoded data generated in the second encoding step A coding amount control step of adding and outputting the coding data corresponding to the coding data obtained in the first coding step, and a control method for the image coding device.
コンピュータが読み込み実行することで、前記コンピュータに、請求項11に記載の方法が有する各工程を実行させるためのプログラム。   The program for making the said computer perform each process which the method of Claim 11 has, when a computer reads and executes.
JP2017164596A 2017-08-29 2017-08-29 Image coding apparatus and control method thereof Pending JP2019047154A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2017164596A JP2019047154A (en) 2017-08-29 2017-08-29 Image coding apparatus and control method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2017164596A JP2019047154A (en) 2017-08-29 2017-08-29 Image coding apparatus and control method thereof

Publications (1)

Publication Number Publication Date
JP2019047154A true JP2019047154A (en) 2019-03-22

Family

ID=65814665

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2017164596A Pending JP2019047154A (en) 2017-08-29 2017-08-29 Image coding apparatus and control method thereof

Country Status (1)

Country Link
JP (1) JP2019047154A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119172544A (en) * 2024-11-20 2024-12-20 深圳市欧冶半导体有限公司 Image coding method, device, computer equipment, storage medium and program product

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119172544A (en) * 2024-11-20 2024-12-20 深圳市欧冶半导体有限公司 Image coding method, device, computer equipment, storage medium and program product

Similar Documents

Publication Publication Date Title
JP7529348B2 (en) Encoder, decoder and corresponding intra prediction method - Patents.com
US8260072B2 (en) Image encoding apparatus and method of controlling the same
US11838519B2 (en) Image encoding/decoding method and apparatus for signaling image feature information, and method for transmitting bitstream
JP3356663B2 (en) Image encoding device, image encoding method, and recording medium recording image encoding program
JP7566116B2 (en) Palette-mode based image or video coding
JP7693914B2 (en) Encoder, decoder and corresponding method for simplifying signaling slice header syntax elements - Patents.com
WO2017051358A1 (en) Methods and apparatuses for encoding and decoding digital images through superpixels
JP2016213528A (en) Image encoder, image processing apparatus, image coding method
JP2022176940A (en) Method and apparatus for color conversion in VVC
KR20020077093A (en) Image coding equipment and image coding program
US9832465B2 (en) Image encoding device and image decoding device
JP6502739B2 (en) Image coding apparatus, image processing apparatus, image coding method
KR20220038725A (en) Image or video coding based on palette escape coding
JP7193929B2 (en) Image processing device, image processing method, and program
CN110024383B (en) Image compression technology
JP2017216630A (en) Image coding apparatus and control method thereof
JP2020102704A (en) Image encoding device, control method of the same, and program
CN110418133B (en) Method and apparatus for encoding image data
CN110087074B (en) Image processing device and method for operating the same
JP2016092589A (en) Encoder and control method therefor
JP2019047154A (en) Image coding apparatus and control method thereof
US8463057B2 (en) Image encoding apparatus and control method therefor
KR101268588B1 (en) Apparatus and method for lossless image compression
WO2012128209A1 (en) Image encoding device, image decoding device, program, and encoded data
JP2020092327A (en) Image encoding device, image encoding method, and program