CN100403801C - A context-based adaptive entropy encoding/decoding method - Google Patents

A context-based adaptive entropy encoding/decoding method Download PDF

Info

Publication number
CN100403801C
CN100403801C CNB2005101048530A CN200510104853A CN100403801C CN 100403801 C CN100403801 C CN 100403801C CN B2005101048530 A CNB2005101048530 A CN B2005101048530A CN 200510104853 A CN200510104853 A CN 200510104853A CN 100403801 C CN100403801 C CN 100403801C
Authority
CN
China
Prior art keywords
context
level
run
zero
pairs
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.)
Expired - Fee Related
Application number
CNB2005101048530A
Other languages
Chinese (zh)
Other versions
CN1741616A (en
Inventor
高文
张宁
武筱林
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.)
National Source Coding Center Digital Audio And Video Frequency Technology (beijing) Co Ltd
Original Assignee
National Source Coding Center Digital Audio And Video Frequency Technology (beijing) Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by National Source Coding Center Digital Audio And Video Frequency Technology (beijing) Co Ltd filed Critical National Source Coding Center Digital Audio And Video Frequency Technology (beijing) Co Ltd
Priority to CNB2005101048530A priority Critical patent/CN100403801C/en
Publication of CN1741616A publication Critical patent/CN1741616A/en
Application granted granted Critical
Publication of CN100403801C publication Critical patent/CN100403801C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

一种基于上下文的自适应熵编/解码方法,编码时:扫描当前变换块中已被量化的DCT系数,由此形成(level,run)数对序列;然后按扫描的逆向顺序对数对序列中每一数对进行熵编码,在编码中,利用已被编码块中已完成编码的数对的值动态自适应构造上下文统计模型,同时,也提出一个上下文模型加权融合技术来进一步提高模型的压缩性能;用上一步骤所获得的上下文统计模型来驱动熵编码。基于上下文的自适应熵解码方法是编码方法的逆。本发明实现了利用不多的上下文状态数刻画长记忆马尔可夫模型,具有较高的压缩性能。

A context-based adaptive entropy encoding/decoding method, when encoding: scan the quantized DCT coefficients in the current transform block, thereby forming a (level, run) pair sequence; and then log the pair sequence in the reverse order of scanning Entropy encoding is performed on each pair of numbers in the coded block. In the encoding process, the value of the encoded number pair in the encoded block is used to dynamically and adaptively construct the context statistical model. At the same time, a context model weighted fusion technology is also proposed to further improve the model. Compression performance; entropy coding is driven by the context statistical model obtained in the previous step. The context-based adaptive entropy decoding method is the inverse of the encoding method. The invention realizes the description of the long-memory Markov model with a small number of context states, and has higher compression performance.

Description

一种基于上下文的自适应熵编/解码方法 A context-based adaptive entropy encoding/decoding method

技术领域 technical field

本发明涉及的技术领域是多媒体(图像,视频,音频)压缩及传输,特别是一种基于上下文建模的用于信号压缩的DCT系数自适应熵编/解码方法。本发明的目的在于改进DCT系数自适应熵编码时统计上下文模型的质量。在所有数据压缩技术和系统中,自适应熵编码起至关重要的作用,而自适应熵编码必须由统计上下文模型所驱动。统计上下文模型的好坏将最终决定整个系统的压缩性能。The technical field that the present invention relates to is multimedia (image, video, audio frequency) compression and transmission, especially a kind of DCT coefficient self-adaptive entropy encoding/decoding method for signal compression based on context modeling. The object of the present invention is to improve the quality of the statistical context model in adaptive entropy coding of DCT coefficients. In all data compression techniques and systems, adaptive entropy coding plays a crucial role, and adaptive entropy coding must be driven by statistical context models. The quality of the statistical context model will ultimately determine the compression performance of the entire system.

背景技术 Background technique

离散余弦变换(Discrete Cosine Transform,简称DCT)被广泛地应用于视频/图像/音频信号的压缩中。经过DCT变换,信号的统计和主观冗余性可以更好地被理解、利用和去除。因此,变换后的信号也更适于压缩。当前大多数的国际、国内信号压缩标准(如JPEG、MPEG、H.264、中国音频/视频标准(Audio video standard,简称AVS))均采用了在DCT变换域中进行编码的方式,这充分体现了DCT变换的有效性。然而DCT变换自身并不会产生任何数据量的减少,这是因为变换后系数的数目与信号原采样数是相同的。真正实现压缩效果的是DCT系数的熵编码过程。任何DCT系数的熵编码方法,如哈夫曼(Huffman)码、算术码,都必须利用对DCT系数概率分布的估计。Discrete Cosine Transform (DCT for short) is widely used in the compression of video/image/audio signals. After DCT transformation, the statistical and subjective redundancy of the signal can be better understood, utilized and removed. Therefore, the transformed signal is also more suitable for compression. Most of the current international and domestic signal compression standards (such as JPEG, MPEG, H.264, China Audio/Video Standard (AVS for short)) adopt the method of encoding in the DCT transform domain, which fully reflects the The effectiveness of the DCT transformation. However, the DCT transformation itself does not produce any reduction in the amount of data, because the number of transformed coefficients is the same as the original number of samples of the signal. What really achieves the compression effect is the entropy coding process of the DCT coefficients. Any entropy coding method of DCT coefficients, such as Huffman (Huffman) codes, arithmetic codes, must utilize the estimation of the probability distribution of DCT coefficients.

在一个实用的基于DCT的信号压缩系统中,DCT系数将按照某种约定的扫描顺序依次进行熵编码。最流行的扫描顺序之一是JPEG和MPEG标准中所采用的zigzag扫描。本发明中的方法具有通用性,可以适用于任何DCT系数的扫描顺序。In a practical DCT-based signal compression system, the DCT coefficients will be entropy-encoded sequentially according to a certain agreed scanning order. One of the most popular scan sequences is the zigzag scan employed in the JPEG and MPEG standards. The method in the present invention is universal and can be applied to any scanning order of DCT coefficients.

如果用x1,x2,…,xN代表扫描后的DCT系数序列,其中N反映DCT变换所采用的块的大小,那么编码该序列所需的最小码长为:If x 1 , x 2 ,..., x N represent the scanned DCT coefficient sequence, where N reflects the size of the block used for DCT transformation, then the minimum code length required to encode the sequence is:

LL minmin == -- loglog 22 ΠΠ ii == 11 NN PP (( xx ii || xx ii -- 11 )) ..

其中,xi-1代表当前系数xi之前所有系数构成的序列{xi-1,xi-1,...x1}。如果条件概率P(xi|xi-1)已知,自适应算术编码可以趋近理想最小码长Lmin。在条件概率估计

Figure C20051010485300052
下,算术编码可以实现编码长度 - log 2 Π i = 1 N P ^ ( x i | x ~ i - 1 ) 。问题的关键在于如何进行概率估计以使
Figure C20051010485300054
成为条件概率P(xi|xi-1)的良好估计。表示序列xi-1中对当前系数xi的统计特性有重要意义的某个子序列,称为模型上下文(Context)。所估计的条件概率
Figure C20051010485300056
用作信源的统计模型。Wherein, x i-1 represents a sequence {xi -1 , x i-1 , . . . x 1 } formed by all coefficients before the current coefficient x i . If the conditional probability P( xi |xi -1 ) is known, adaptive arithmetic coding can approach the ideal minimum code length L min . In conditional probability estimation
Figure C20051010485300052
Under, arithmetic coding can realize code length - log 2 Π i = 1 N P ^ ( x i | x ~ i - 1 ) . The key to the problem is how to estimate the probability so that
Figure C20051010485300054
becomes a good estimate of the conditional probability P( xi |xi -1 ). Represents a certain subsequence in the sequence xi -1 that is significant to the statistical properties of the current coefficient xi , called the model context (Context). Estimated conditional probability
Figure C20051010485300056
Statistical models used as sources.

以概率估计形式为体现的统计上下文模型是所有信号压缩系统的核心。模型质量即概率估计的精确度将最终决定压缩性能。Statistical context models in the form of probability estimates are at the heart of all signal compression systems. The quality of the model, i.e. the accuracy of the probability estimates, will ultimately determine the compression performance.

诺基亚(Nokia)于2001年针对H264标准参考模型TML85提出了一个对DCT系数块的(run,level)(level是非零残差系数,run代表当前非零系数与前一个非零系数之间的零系数个数)数对序列进行自适应二值算术编码的方法。该方法按照与数对扫描生成时“相同”的顺序依次对各数对进行编码,编码时仅用本系数块中最临近的level值构造上下文(一阶Markov模型)。针对该方法的公开号为US2004112683的专利公布了一种编码变换系数的方法,通过正、反两次扫描完成对DCT系数块的编码。在首次正向扫描中根据系数的物理频率位置构造上下文对系数的第一位面(即Significant Map)进行编码。在二次逆扫描中完成对非零系数其它位面的编码。但此方法没有刻画长记忆马尔可夫(Markov)模型,压缩性能相对较低.Nokia (Nokia) proposed a (run, level) for the DCT coefficient block in 2001 for the H264 standard reference model TML85 (level is a non-zero residual coefficient, run represents the zero between the current non-zero coefficient and the previous non-zero coefficient The number of coefficients) is a method for adaptive binary arithmetic coding of sequences. This method encodes each number pair sequentially in the "same" order as when the number pair is scanned and generated, and only uses the nearest level value in the coefficient block to construct the context (first-order Markov model) during encoding. The patent publication No. US2004112683 for this method discloses a method for encoding transform coefficients. The encoding of the DCT coefficient block is completed through two forward and reverse scans. In the first forward scan, the context is constructed according to the physical frequency position of the coefficient to encode the first bit plane (ie Significant Map) of the coefficient. The encoding of other bit-planes with non-zero coefficients is completed in the second inverse scan. However, this method does not describe the long-memory Markov model, and the compression performance is relatively low.

发明内容 Contents of the invention

本发明的目的在于针对上述现有编码技术存在的不足,提供一种基于上下文建模的用于信号压缩的DCT系数自适应熵编/解码方法,改进了现有DCT系数熵编/解码技术,为中国AVS提供一个高性能熵编码模块,使得中国AVS系统的整体性能达到甚至超过当前世界最先进视频压缩技术的水平。The purpose of the present invention is to address the shortcomings of the above-mentioned existing coding technology, provide a DCT coefficient adaptive entropy coding/decoding method for signal compression based on context modeling, improve the existing DCT coefficient entropy coding/decoding technology, Provide a high-performance entropy coding module for China AVS, making the overall performance of China AVS system reach or even exceed the level of the most advanced video compression technology in the world.

为实现上述目的,本发明采用了一种基于上下文建模的用于信号压缩的DCT系数自适应熵编/解码方法,其中,编码时,执行以下步骤:In order to achieve the above object, the present invention adopts a DCT coefficient adaptive entropy encoding/decoding method for signal compression based on context modeling, wherein, during encoding, the following steps are performed:

步骤1、扫描当前经过DCT变换和量化后的系数块,形成(level,run)数对序列,得到非零系数的个数值;初始化所述系数块的上下文模型;Step 1. Scan the current DCT-transformed and quantized coefficient block to form a sequence of (level, run) pairs to obtain the number of non-zero coefficients; initialize the context model of the coefficient block;

步骤2、如果所述非零系数的个数值为零,则得到EOB信息(EOB为块结束标记End of Block),即一个(0,0)数对;如果所述非零系数的个数值不为零,则在扫描结果中查找所述非零系数个数位置上的(level,run)数对;Step 2, if the value of the non-zero coefficient is zero, then obtain the EOB information (EOB is the block end mark End of Block), i.e. a (0, 0) number pair; if the value of the non-zero coefficient is not is zero, then search the (level, run) number pairs on the position of the number of non-zero coefficients in the scan result;

步骤3、如果对第一个系数编码,则根据空序列构造第一上下文;否则,根据所述系数块中已完成编码的所有数对构造第一上下文,并利用上下文加权方式,对当前level的绝对值进行熵编码;Step 3. If the first coefficient is coded, construct the first context according to the empty sequence; otherwise, construct the first context according to all pairs of numbers that have been coded in the coefficient block, and use the context weighting method to calculate the current level The absolute value is entropy encoded;

步骤4、如果所述非零系数的个数为零则编码结束;否则,根据所述系数块中已完成编码的所有数对以及步骤3中所述已编码的level的绝对值,对level的符号位进行编码;Step 4. If the number of non-zero coefficients is zero, then the encoding ends; otherwise, according to the absolute value of all the encoded numbers in the coefficient block and the encoded level in step 3, the level The sign bit is encoded;

步骤5、根据所述系数块中已完成编码的所有数对以及步骤3与4中所述已编码的当前level的绝对值与符号位构造第二上下文,对run进行熵编码;Step 5. Constructing a second context according to all pairs of numbers that have been coded in the coefficient block and the absolute value and sign bit of the coded current level in steps 3 and 4, and performing entropy coding on run;

步骤6、对所述非零系数的数量值进行减1操作,执行步骤2。Step 6. Subtract 1 from the value of the non-zero coefficient, and execute step 2.

解码时,执行以下步骤:When decoding, perform the following steps:

步骤1、初始化第一、第二上下文模型;Step 1. Initialize the first and second context models;

步骤2、逆序扫描第一个(Level,Run)数对中Level幅值,根据第一上下文模型解码得到第一个Level幅值;Step 2. Scan the Level amplitude in the first (Level, Run) number pair in reverse order, and obtain the first Level amplitude by decoding according to the first context model;

步骤3、如果所得到的Level幅值为零,则得到EOB信息,即一个(0,0)数对,执行步骤7;否则,执行步骤4;Step 3, if the obtained Level amplitude is zero, then get the EOB information, that is, a (0,0) number pair, and execute step 7; otherwise, execute step 4;

步骤4、解码得到level的符号位;Step 4, decode to obtain the sign bit of level;

步骤5、根据已完成解码的所有数对以及步骤2与3中刚解码的当前level的值构造第二上下文,解码得到Run;Step 5. Construct a second context based on all the pairs of numbers that have been decoded and the value of the current level just decoded in steps 2 and 3, and decode to obtain Run;

步骤6、根据已完成解码的所有数对构造第一上下文,并利用上下文加权技术,解码得到下一个(Level,Run)数对中level的绝对值;执行步骤3;Step 6. Construct the first context according to all the pairs of numbers that have been decoded, and use context weighting technology to decode and obtain the absolute value of level in the next (Level, Run) number pair; perform step 3;

步骤7、根据所述解码得到的(Level,Run)数对序列恢复所述系数块。Step 7: Restoring the coefficient block according to the sequence of (Level, Run) pairs obtained through the decoding.

考虑到实用性和兼容性,本发明的技术细节向适于中国AVS基准版本的方向进行了细致调节,对现行中国AVS系统做出了自然而重大的改进扩展。Considering the practicability and compatibility, the technical details of the present invention have been carefully adjusted to the direction suitable for the Chinese AVS benchmark version, making a natural and significant improvement and extension to the current Chinese AVS system.

(1)本发明按照与数对扫描生成时“相反”的顺序依次对各数对进行编码,这一逆扫描序的编码顺序明显提高了上下文模型的有效性。(1) The present invention encodes each number pair sequentially according to the "reverse" order of the number pair scan generation, and the encoding order of this reverse scanning order obviously improves the effectiveness of the context model.

(2)同时,编码时利用本系数块中所有已完成编码的(level,run)数对构造上下文(高阶Markov模型),并创新性使用了上下文加权技术,该方法可以通过将多个上下文模型融合为一体来改进压缩性能。(2) At the same time, when encoding, use all the coded (level, run) pairs in this coefficient block to construct the context (higher-order Markov model), and innovatively use the context weighting technology. This method can combine multiple contexts The models are fused together to improve compression performance.

(3)本发明采用了一种创新的上下文量化方法,实现了利用不多的上下文状态数刻画长记忆马尔可夫模型,从而避免在刻画高阶马尔可夫模型时遭受上下文稀释问题的不良影响。(3) The present invention adopts an innovative context quantification method to realize the use of a small number of context states to describe the long-memory Markov model, thereby avoiding the adverse effects of the context dilution problem when describing the high-order Markov model .

本发明在实现上述目的时相对现有技术并没有增加计算复杂度,适合实时应用,并且与中国AVS基准视频编解码框架具有兼容性。Compared with the prior art, the present invention does not increase the computational complexity when realizing the above object, is suitable for real-time application, and has compatibility with the Chinese AVS benchmark video codec framework.

下面结合附图和实施例,对本发明的技术方案做进一步的详细描述。The technical solutions of the present invention will be described in further detail below in conjunction with the accompanying drawings and embodiments.

附图说明 Description of drawings

图1是本发明的编码流程图;Fig. 1 is the encoding flowchart of the present invention;

图2是本发明的解码流程图;Fig. 2 is the decoding flowchart of the present invention;

图3是zig-zag扫描示例;Figure 3 is an example of zig-zag scanning;

图4是本发明对块系数的编码顺序。Fig. 4 is the encoding order of block coefficients in the present invention.

具体实施方式 Detailed ways

如图1、2所示为本发明的实施例一,具体编码步骤为:As shown in Figures 1 and 2, it is Embodiment 1 of the present invention, and the specific encoding steps are:

步骤101、扫描当前经过DCT变换和量化后的系数块,形成(level,run)数对序列,得到非零系数的个数值;初始化所述系数块的上下文模型;Step 101, scan the current DCT-transformed and quantized coefficient block to form a sequence of (level, run) pairs to obtain the number of non-zero coefficients; initialize the context model of the coefficient block;

步骤102、如果所述非零系数的个数值为零,则得到EOB信息,即一个(0,0)数对;如果所述非零系数的个数值不为零,则在扫描结果中查找所述非零系数个数位置上的(level,run)数对;Step 102, if the value of the non-zero coefficient is zero, then obtain EOB information, that is, a (0,0) number pair; if the value of the non-zero coefficient is not zero, then search for the value of the non-zero coefficient in the scan result (level, run) number pairs at the position of the number of non-zero coefficients;

步骤103、如果对第一个系数编码,则根据空序列构造第一上下文;否则,根据所述系数块中已完成编码的所有数对构造第一上下文,并利用上下文加权方式,对当前level的绝对值进行熵编码;构造第一上下文包括:定义两个随机变量,第一个随机变量用于记录本系数块中已完成编码的所有数对中level的幅值变化信息,第二个随机变量记录在当前待编码level在逆扫描序中的位置;根据所述两个随机变量,通过上下文加权构造第一上下文,利用不多的上下文状态描述长记忆马尔可夫模型;Step 103, if the first coefficient is coded, construct the first context according to the empty sequence; otherwise, construct the first context according to all pairs of numbers that have been coded in the coefficient block, and use the context weighting method to calculate the current level The absolute value is entropy encoded; constructing the first context includes: defining two random variables, the first random variable is used to record the amplitude change information of the level in all pairs of numbers that have been coded in this coefficient block, and the second random variable Recording the position of the current to-be-encoded level in the reverse scanning order; according to the two random variables, constructing the first context through context weighting, and using a small number of context states to describe the long memory Markov model;

步骤104、如果所述非零系数的个数为零则编码结束;否则,根据所述系数块中已完成编码的所有数对以及步骤3中刚编码的level的绝对值,对level的符号位进行编码;Step 104, if the number of non-zero coefficients is zero, then the encoding ends; otherwise, according to the absolute value of all the number pairs that have been encoded in the coefficient block and the level just encoded in step 3, the sign bit of the level to encode;

步骤105、根据所述系数块中已完成编码的所有数对以及步骤3与4中刚编码的当前level的值构造第二上下文,对run进行熵编码;构造第二上下文包括:定义两个随机变量,第一个随机变量用于记录本系数块中已完成编码的所有数对中level的幅值变化信息,另一个记录步骤3中所述已编码的当前level的绝对值,通过这两个变量构造上下文对run进行编码;Step 105: Construct a second context according to all the pairs of numbers that have been encoded in the coefficient block and the value of the current level just encoded in steps 3 and 4, and entropy encode the run; constructing the second context includes: defining two random Variables, the first random variable is used to record the amplitude change information of the level in all pairs of numbers that have been coded in this coefficient block, and the other records the absolute value of the current level that has been coded in step 3. Through these two The variable construction context encodes the run;

步骤106、对所述非零系数的数量值进行减1操作,执行步骤2。Step 106: Subtract 1 from the value of the non-zero coefficient, and execute step 2.

解码时,执行以下步骤:When decoding, perform the following steps:

步骤201、初始化上下文模型;Step 201, initialize the context model;

步骤202、逆序扫描的第一个(Level,Run)数对中Level幅值,根据上下文模型解码得到第一个Level幅值;Step 202, the Level amplitude in the first (Level, Run) number pair scanned in reverse order, and decoded according to the context model to obtain the first Level amplitude;

步骤203、如果所得到的Level幅值为零,则得到EOB信息,即一个(0,0)数对,执行步骤7;否则,执行步骤4;Step 203, if the obtained Level amplitude is zero, then get the EOB information, that is, a (0,0) number pair, and execute step 7; otherwise, execute step 4;

步骤204、解码得到level的符号位;Step 204, decoding to obtain the sign bit of level;

步骤205、根据本系数块中已完成解码的所有数对以及步骤2与3中刚解码的当前level的值构造上下文,解码得到Run;Step 205, construct a context according to all the pairs of numbers that have been decoded in this coefficient block and the value of the current level just decoded in steps 2 and 3, and decode to obtain Run;

步骤206、根据本系数块中已完成解码的所有数对构造上下文,并利用上下文加权技术,解码得到下一个(Level,Run)数对中level的绝对值;执行步骤3;Step 206, construct context according to all the number pairs that have been decoded in this coefficient block, and use context weighting technology to decode to obtain the absolute value of level in the next (Level, Run) number pair; perform step 3;

步骤207、根据所述解码得到的(Level,Run)数对序列恢复所述系数块。Step 207: Restore the coefficient block according to the sequence of (Level, Run) pairs obtained through the decoding.

以下为本发明的实施例二,实施例2是本发明在中国AVS中的实施:The following is embodiment two of the present invention, and embodiment 2 is the implementation of the present invention in Chinese AVS:

对本实施例关键技术的描述:Description of the key technologies of this embodiment:

1、DCT系数块的扫描顺序与编码顺序:1. Scanning order and encoding order of DCT coefficient blocks:

DCT系数的扫描是一个将二维或多维DCT系数排列为一维序列的过程。所遵循的原则是使排列后系数为零的概率呈现递增规律。JPEG、MPEG中的经典zigzag扫描、中国AVS系数块的扫描以及H264中针对不同系数块大小、不同场/帧模式的扫描方式均遵循这一规律。Scanning of DCT coefficients is a process of arranging two-dimensional or multi-dimensional DCT coefficients into a one-dimensional sequence. The principle followed is to make the probability of the coefficients being zero after the arrangement show an increasing law. The classic zigzag scanning in JPEG and MPEG, the scanning of AVS coefficient blocks in China, and the scanning methods for different coefficient block sizes and different field/frame modes in H264 all follow this rule.

扫描后的一维系数随机序列近似满足为零概率递增的规律。转化为(level,run)数对后,我们按照扫描逆序及系数“非零”概率递增的顺序对每一数对进行编码。The scanned one-dimensional coefficient random sequence approximately satisfies the law of increasing probability of zero. After converting into (level, run) pairs, we encode each pair in the reverse order of scanning and in increasing order of coefficient "non-zero" probability.

2、待编码元素的二值化:2. Binarization of elements to be encoded:

在执行进行二值算术编码以前,首先需要把待编码元素:level和run的值转化为一系列的二值决定(Binary Decision)。Before performing binary arithmetic coding, it is first necessary to convert the values of the elements to be coded: level and run into a series of binary decisions (Binary Decision).

level为有符号整数。首先分离出符号位,用1比特“0/1”表示“+/-”;剩余的绝对值部分为非负整数,通过Unary表示实现二值化。如:-2的二值化为(1)001,+1的二值化为(0)01。level is a signed integer. Firstly, the sign bit is separated, and 1 bit "0/1" is used to represent "+/-"; the remaining absolute value part is a non-negative integer, and the binarization is realized through Unary representation. For example: the binarization of -2 is (1)001, and the binarization of +1 is (0)01.

run为无符号整数。直接通过Unary表示实现二值化。run is an unsigned integer. Binarization is realized directly through Unary representation.

Figure C20051010485300101
Figure C20051010485300101

表1:二值化实现Table 1: Binarization implementation

表1给出了对非负整数通过Unary表示进行二值化的结构。可以看到二值化的结果由前缀和后缀组成:前缀码为若干个0组成的字符串,后缀为末尾一个1;二值化后的字符串称为一个bin stfing,其中每个位置的0或1称为一个bin;Table 1 shows the structure of binarizing non-negative integers through Unary representation. It can be seen that the result of binarization is composed of a prefix and a suffix: the prefix code is a string composed of several 0s, and the suffix is a 1 at the end; the binarized string is called a bin stfing, in which 0 in each position Or 1 is called a bin;

3、上下文的定义和量化:3. Definition and quantification of context:

用非负整数变量Lmax纪录每一待编码(level,run)数对之前本系数块中已完成编码的最大level幅值。每一系数块编码前Lmax初始化为0。按表2所示将Lmax量化为5级选择Primary上下文序号。A non-negative integer variable Lmax is used to record the maximum level amplitude of each (level, run) number pair to be coded that has been coded in the previous coefficient block. Lmax is initialized to 0 before coding each coefficient block. As shown in Table 2, Lmax is quantized into 5 levels to select the Primary context number.

  LmaxLmax 00 11 22 [3,4][3, 4] [5,+∞)[5, +∞)   Primary ContextPrimary Context 00 11 22 33 44

表2:Primary上下文的量化Table 2: Quantification of Primary Context

Lmax起到纪录本系数块的编码历史并对当前(level,run)数对按不同统计特性分类的效果。编码当前level和run的具体二值化结果时,不同的bin将根据表3进一步选定Secondary上下文序号。Lmax has the effect of recording the encoding history of the coefficient block and classifying the current (level, run) number pairs according to different statistical characteristics. When encoding the specific binarization results of the current level and run, different bins will further select the Secondary context number according to Table 3.

  模型号model number  上下文模型编码内容Context model encoding content   00  用该上下文模型编码absLevel的第一个bin(比如,EOB)Encode the first bin of absLevel (e.g., EOB) with this context model   1 1  如果absLevel存在第二个bin,用该上下文模型编码该binIf there is a second bin for absLevel, encode that bin with the context model   2 2  如果absLevel存在第三个或者更多bin,用这个上下文模型编码这些binIf there is a third or more bins for absLevel, encode those bins with this context model   33  如果absLevel=1,用该上下文模型编码run的第一个bin.If absLevel=1, encode the first bin of the run with this context model.   44  如果absLevel=1且run存在第二个bin或者更多,用该上下文模型编码这些binIf absLevel=1 and the run has a second bin or more, use the context model to encode these bins   55  如果absLevel>1,用该上下文模型编码run的第一个binIf absLevel>1, use the context model to encode the first bin of the run   66  如果absLevel>1,且run存在第二个bin后者更多,用该上下文模型编码这些binIf absLevel>1, and there is a second bin in the run, the latter is more, use the context model to encode these bins

表3:Secondary上下文结构Table 3: Secondary context structure

编码每一个二值决定时,根据Primary上下文序号(0到4)和Secondary上下文序号(0到6)从共35个上下文中选择相应上下文,利用该上下文下的概率估计驱动算术编码器。When encoding each binary decision, select the corresponding context from a total of 35 contexts according to the primary context number (0 to 4) and the secondary context number (0 to 6), and use the probability estimation under the context to drive the arithmetic coder.

4、上下文加权方式:4. Context weighting method:

为进一步提高EOB信息的编码效率,ReverseP表示待编码的level在系数逆扫描顺序中的位置。每一系数块编码前Lmax初始化为0。对8×8DCT系数块,ReverseP限制于[0,63],均匀量化为32级作为伴随上下文序号。In order to further improve the coding efficiency of EOB information, ReverseP indicates the position of the level to be coded in the coefficient reverse scanning order. Lmax is initialized to 0 before coding each coefficient block. For 8×8 DCT coefficient blocks, ReverseP is limited to [0, 63], and uniformly quantized to 32 levels as the accompanying context sequence number.

对absLevel的第一个bin进行编码时,根据Primary上下文序号和Secondary上下序号(值为0)选择-个上下文,设该上下文下的概率估计为p1;根据ReverseP从32个伴随上下文中选择另一上下文,设该上下文下的概率估计为p2。以p1和p2的简单加权:(p1+p2)/2驱动二值算术编码器。When encoding the first bin of absLevel, select a context according to the Primary context number and the Secondary upper and lower numbers (value 0), and set the probability estimate under this context as p1; select another from 32 accompanying contexts according to ReverseP context, let the probability estimate under this context be p2. A binary arithmetic encoder is driven with a simple weighting of p1 and p2: (p1+p2)/2.

以下为实施例二的流程,具体编码流程为:The following is the process of Embodiment 2, and the specific encoding process is:

步骤1、扫描被编码DCT系数块,形成(level,run)数对序列,得到非零系数的个数,变量icoef表示非零系数的个数。对每个含有非零DCT系数的块,首先采用zigzag扫描,按照自左上到右下扫描顺序形成(level,run)数对序列,icoeff的值为7。编码时将按照数对序列形成的逆序依次编码每个数对的level和run,最后的(0,0)数对表示数据块编码的结束信息EOB;Step 1. Scan the encoded DCT coefficient block to form a sequence of (level, run) pairs to obtain the number of non-zero coefficients. The variable icoef represents the number of non-zero coefficients. For each block containing non-zero DCT coefficients, zigzag is used to scan first, and (level, run) pairs are formed according to the scanning order from upper left to lower right, and the value of icoeff is 7. When encoding, the level and run of each number pair will be encoded in reverse order formed by the number pair sequence, and the last (0, 0) number pair represents the end information EOB of the data block encoding;

图3是zigzag扫描示例,图4是本发明对块系数的编码顺序。Fig. 3 is an example of zigzag scanning, and Fig. 4 is an encoding sequence of block coefficients in the present invention.

步骤2、判断变量icoef的值是否为零,如果是,则给变量(level,run)赋值(0,0);如果变量icoef的值不为零,则查找扫描结果中第icoef位置上的(level,run)值;初始化上下文变量Lmax=0,ReverseP=0。icoeff的值减小为0时插入的(0,0)数对表示系数块结束信息EOB。Step 2. Determine whether the value of the variable icoef is zero, if so, assign (0, 0) to the variable (level, run); if the value of the variable icoef is not zero, then search for the ( level, run) value; initialize the context variable Lmax=0, ReverseP=0. The (0,0) pair inserted when the value of icoeff is reduced to 0 represents the coefficient block end information EOB.

步骤3、根据本系数块中已完成编码的所有(level,run)数对构造上下文,并利用上下文加权技术,编码level的绝对值。根据当前level的值获得其绝对值absLevel的二值化表示。absLevel的二值化过程详见表1:由absLevel表示的系数幅值采用Unary表示进行二值化,即:若干个“0”作为前缀和一个“1”作为后缀,0的个数等于absLevel。Step 3. Construct a context according to all (level, run) pairs that have been coded in this coefficient block, and use the context weighting technique to code the absolute value of the level. Obtain the binary representation of its absolute value absLevel according to the value of the current level. The binarization process of absLevel is detailed in Table 1: the coefficient amplitude represented by absLevel is binarized using Unary representation, that is: several "0"s as a prefix and a "1" as a suffix, and the number of 0s is equal to absLevel.

编码absLevel第一个bin的上下文模型:根据Lmax的值选择Primary上下文序号(表2),Secondary上下文序号为0;同时,根据ReverseP的值选择伴随上下文序号;应用上下文加权技术编码第一个bin。Encoding the context model of the first bin of absLevel: select the Primary context number according to the value of Lmax (Table 2), and the Secondary context number is 0; at the same time, select the accompanying context number according to the value of ReverseP; apply context weighting technology to encode the first bin.

编码absLevel其它bin的上下文模型:根据Lmax的值选择Primary上下文序号,再根据当前absLevel二值化后bin的位置选择Secondary上下文序号(见表3)进行编码。The context model for encoding other bins of absLevel: select the Primary context number according to the value of Lmax, and then select the Secondary context number (see Table 3) for encoding according to the position of the bin after the binarization of the current absLevel.

步骤4、如果变量icoef的值为零则编码结束。Step 4. If the value of the variable icoef is zero, the encoding ends.

步骤5、如果变量icoef的值不为零,则根据(level,run)值,对level的符号位进行编码;level的符号位采用等概率进行编码,若为负数,用二值算术编码器编码“1”,否则二值算术编码器编码“0”。Step 5. If the value of the variable icoef is not zero, encode the sign bit of level according to the (level, run) value; the sign bit of level is encoded with equal probability, if it is a negative number, encode with a binary arithmetic coder "1", otherwise the binary arithmetic coder encodes "0".

步骤6、根据本系数块中已完成编码的所有数对以及步骤104中刚编码的当前level的值构造上下文,对run进行编码。run的二值化过程见表l;根据Lmax的值选择Primary上下文序号,由当前编码的(level,run)数对中level的幅值以及当前编码的run的bin的位置选择Secondary上下文序号(见表3)进行编码;Step 6: Construct a context according to all the coded pairs in this coefficient block and the value of the current level just coded in step 104, and code the run. The binarization process of run is shown in Table 1; the Primary context sequence number is selected according to the value of Lmax, and the Secondary context sequence number is selected by the magnitude of the level in the current coded (level, run) number pair and the bin position of the currently coded run (see Table 3) is encoded;

步骤7、对变量icoef的值进行减1操作;执行步骤2。Step 7. Subtract 1 from the value of the variable icoef; execute step 2.

Figure C20051010485300131
Figure C20051010485300131

表4:一个上下文模型号选择的实例Table 4: An example of context model number selection

最后应说明的是:以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解:依然可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明技术方案的精神和范围,其均应涵盖在本发明请求保护的技术方案的范围当中。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention without limitation, although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that: the technology of the present invention can still be The schemes are modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and all of them shall be included in the scope of the technical solutions claimed in the present invention.

Claims (5)

1.一种基于上下文的自适应熵编码方法,其中,执行以下步骤:1. A context-based adaptive entropy coding method, wherein the following steps are performed: 步骤1、扫描当前经过DCT变换和量化后的系数块,形成“level,run”数对序列,得到非零系数的个数值;初始化所述系数块的上下文模型;Step 1. Scan the current DCT-transformed and quantized coefficient block to form a "level, run" pair sequence to obtain the number of non-zero coefficients; initialize the context model of the coefficient block; 步骤2、如果所述非零系数的个数值为零,则得到EOB信息;如果所述非零系数的个数值不为零,则在扫描结果中查找所述非零系数个数位置上的“level,run”数对;Step 2. If the value of the non-zero coefficient is zero, then obtain the EOB information; if the value of the non-zero coefficient is not zero, then search for the " level, run" pairs; 步骤3、如果对第一个系数编码,则根据空序列构造第一上下文;否则,根据所述系数块中已完成编码的所有数对构造第一上下文,并利用上下文加权方式,对当前level的绝对值进行熵编码;Step 3. If the first coefficient is coded, construct the first context according to the empty sequence; otherwise, construct the first context according to all pairs of numbers that have been coded in the coefficient block, and use the context weighting method to calculate the current level The absolute value is entropy encoded; 步骤4、如果所述非零系数的个数为零则编码结束;否则,根据所述系数块中已完成编码的所有数对以及步骤3中所述已编码的level的绝对值,对level的符号位进行编码;Step 4. If the number of non-zero coefficients is zero, then the encoding ends; otherwise, according to the absolute value of all the encoded numbers in the coefficient block and the encoded level in step 3, the level The sign bit is encoded; 步骤5、根据所述系数块中已完成编码的所有数对以及步骤3与4中所述已编码的当前level的绝对值与符号位构造第二上下文,对run进行熵编码;Step 5. Constructing a second context according to all pairs of numbers that have been encoded in the coefficient block and the absolute value and sign bit of the encoded current level in steps 3 and 4, and performing entropy encoding on run; 步骤6、对所述非零系数的数量值进行减1操作,执行步骤2。Step 6. Subtract 1 from the value of the non-zero coefficient, and execute step 2. 2.根据权利要求1所述的自适应熵编码方法,其特征在于:步骤1中所述扫描是按照编码“level,run”数对顺序的逆序进行的。2. The adaptive entropy coding method according to claim 1, characterized in that: said scanning in step 1 is carried out according to the reverse order of the coding "level, run" number pairs. 3.根据权利要求1或2所述的自适应熵编码方法,其特征在于:所述步骤3的构造第一上下文包括:定义两个随机变量,第一个随机变量用于记录本系数块中已完成编码的所有数对中level的幅值变化信息,第二个随机变量记录在当前待编码level在逆扫描序中的位置;根据所述两个随机变量,通过上下文加权构造第一上下文。3. The adaptive entropy coding method according to claim 1 or 2, characterized in that: the construction of the first context in the step 3 includes: defining two random variables, the first random variable is used to record the coefficient block For the amplitude change information of levels in all pairs of numbers that have been coded, the second random variable is recorded at the position of the current level to be coded in the reverse scanning order; according to the two random variables, the first context is constructed by context weighting. 4.根据权利要求l或2所述的自适应熵编码方法,其特征在于:所述步骤5中的构造第二上下文包括:定义两个随机变量,第一个随机变量用于记录本系数块中已完成编码的所有数对中level的幅值变化信息,另一个记录步骤3中所述已编码的当前level的绝对值,通过这两个变量构造上下文对run进行编码。4. The adaptive entropy coding method according to claim 1 or 2, characterized in that: the construction of the second context in the step 5 includes: defining two random variables, the first random variable is used to record the coefficient block The amplitude change information of the levels in all pairs of numbers that have been encoded in , and the other records the absolute value of the encoded current level described in step 3, and encodes the run by constructing a context with these two variables. 5.一种基于上下文的自适应熵解码方法,其中,执行以下步骤:5. A context-based adaptive entropy decoding method, wherein the following steps are performed: 步骤1、初始化第一、第二上下文模型;Step 1. Initialize the first and second context models; 步骤2、逆序扫描第一个“level,run”数对中Level幅值,根据第一上下文模型解码得到第一个Level幅值;Step 2. Scan the Level amplitude in the first "level, run" pair in reverse order, and decode the first Level amplitude according to the first context model; 步骤3、如果所得到的Level幅值为零,则得到EOB信息,执行步骤7;否则,执行步骤4;Step 3. If the obtained Level amplitude is zero, then get the EOB information, and go to step 7; otherwise, go to step 4; 步骤4、解码得到level的符号位;Step 4, decode to obtain the sign bit of level; 步骤5、根据已完成解码的所有数对以及步骤2与3中刚解码的当前level的值构造第二上下文,解码得到Run;Step 5. Construct a second context based on all the pairs of numbers that have been decoded and the value of the current level just decoded in steps 2 and 3, and decode to obtain Run; 步骤6、根据已完成解码的所有数对构造第一上下文,并利用上下文加权方式,解码得到下一个“level,run”数对中level的绝对值;执行步骤3;Step 6. Construct the first context according to all the pairs of numbers that have been decoded, and use the context weighting method to decode to obtain the absolute value of level in the next "level, run" number pair; perform step 3; 步骤7、根据所述解码得到的“level,run”数对序列恢复系数块。Step 7. Restore the coefficient block according to the sequence of "level, run" pairs obtained from the decoding.
CNB2005101048530A 2005-09-23 2005-09-23 A context-based adaptive entropy encoding/decoding method Expired - Fee Related CN100403801C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005101048530A CN100403801C (en) 2005-09-23 2005-09-23 A context-based adaptive entropy encoding/decoding method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005101048530A CN100403801C (en) 2005-09-23 2005-09-23 A context-based adaptive entropy encoding/decoding method

Publications (2)

Publication Number Publication Date
CN1741616A CN1741616A (en) 2006-03-01
CN100403801C true CN100403801C (en) 2008-07-16

Family

ID=36093813

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005101048530A Expired - Fee Related CN100403801C (en) 2005-09-23 2005-09-23 A context-based adaptive entropy encoding/decoding method

Country Status (1)

Country Link
CN (1) CN100403801C (en)

Families Citing this family (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101137047B (en) * 2006-08-29 2010-09-15 昆山杰得微电子有限公司 Method for analyzing and enhancing coding efficiency through effective residual error coefficient
CN101290771B (en) * 2007-04-20 2011-07-13 中兴通讯股份有限公司 Bit consumption controlling method based on advanced audio decoder
CA2871252C (en) * 2008-07-11 2015-11-03 Nikolaus Rettelbach Audio encoder, audio decoder, methods for encoding and decoding an audio signal, audio stream and computer program
WO2010063883A1 (en) * 2008-12-03 2010-06-10 Nokia Corporation Switching between dct coefficient coding modes
CN101646086B (en) * 2009-08-21 2011-07-20 香港应用科技研究院有限公司 Method and apparatus for context reference modeling for 4 x 4 block transform coefficient labeling
WO2011130854A1 (en) * 2010-04-19 2011-10-27 Research In Motion Limited Methods and devices for reordered parallel entropy coding and decoding
CN104796711B (en) 2011-01-06 2018-03-09 三星电子株式会社 The coding method of video and the coding/decoding method and device of device and video
CN104093018B (en) * 2011-03-10 2017-08-04 华为技术有限公司 Coding method of transform coefficient, decoding method of transform coefficient, and device
CN102685503B (en) * 2011-03-10 2014-06-25 华为技术有限公司 Encoding method of conversion coefficients, decoding method of conversion coefficients and device
CN104093020B (en) * 2011-03-10 2017-11-17 华为技术有限公司 The coding method of conversion coefficient, the coding/decoding method of conversion coefficient, and device
WO2012149904A1 (en) * 2011-05-04 2012-11-08 Wu Xiaolin Modeling method and system based on context in transform domain of image/video
RS63053B1 (en) * 2011-06-16 2022-04-29 Ge Video Compression Llc CONTEXT INITIALIZATION IN ENTHROPIC CODING
MY193611A (en) 2011-07-01 2022-10-20 Samsung Electronics Co Ltd Method and apparatus for entropy encoding using hierarchical data unit, and method and apparatus for decoding
CN102256125B (en) * 2011-07-14 2013-06-05 北京工业大学 Context adaptive arithmetic coding method for HEVC (High Efficiency Video Coding)
US9035807B2 (en) 2011-08-25 2015-05-19 Thomson Licensing Hierarchical entropy encoding and decoding
PT3145197T (en) * 2011-10-31 2018-08-10 Samsung Electronics Co Ltd Method for determining a context model for transform coefficient level entropy decoding
US9247257B1 (en) * 2011-11-30 2016-01-26 Google Inc. Segmentation based entropy encoding and decoding
KR101760438B1 (en) * 2012-01-20 2017-07-31 지이 비디오 컴프레션, 엘엘씨 Transform coefficient coding
US9774856B1 (en) 2012-07-02 2017-09-26 Google Inc. Adaptive stochastic entropy coding
US9538175B2 (en) * 2012-09-26 2017-01-03 Qualcomm Incorporated Context derivation for context-adaptive, multi-level significance coding
US9509998B1 (en) 2013-04-04 2016-11-29 Google Inc. Conditional predictive multi-symbol run-length coding
US9392288B2 (en) 2013-10-17 2016-07-12 Google Inc. Video coding using scatter-based scan tables
CN105141966B (en) * 2015-08-31 2018-04-24 哈尔滨工业大学 The context modeling method of conversion coefficient in video compress
EP4307683A4 (en) * 2021-03-17 2025-03-05 Guangdong Oppo Mobile Telecommunications Corp Ltd METHOD FOR ENCODING/DECODING COEFFICIENTS, ENCODER, DECODER AND COMPUTER STORAGE MEDIUM

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1224978A (en) * 1998-01-26 1999-08-04 大宇电子株式会社 Context-based arithmetic encoding/decoding method and apparatus
WO2003026307A2 (en) * 2001-09-14 2003-03-27 Siemens Aktiengesellschaft Method for producing video coding and programme-product
WO2003027940A1 (en) * 2001-09-14 2003-04-03 Nokia Corporation Method and system for context-based adaptive binary arithmetic coding

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1224978A (en) * 1998-01-26 1999-08-04 大宇电子株式会社 Context-based arithmetic encoding/decoding method and apparatus
WO2003026307A2 (en) * 2001-09-14 2003-03-27 Siemens Aktiengesellschaft Method for producing video coding and programme-product
WO2003027940A1 (en) * 2001-09-14 2003-04-03 Nokia Corporation Method and system for context-based adaptive binary arithmetic coding

Also Published As

Publication number Publication date
CN1741616A (en) 2006-03-01

Similar Documents

Publication Publication Date Title
CN100403801C (en) A context-based adaptive entropy encoding/decoding method
KR101356733B1 (en) Method and apparatus for Context Adaptive Binary Arithmetic Coding and decoding
CN101243611B (en) Efficient coding and decoding of transform blocks
JP2023040013A (en) Method and Apparatus for Video Encoding and Video Decoding Binary Sets Using Adaptive Tree Selection
US8483500B2 (en) Run length coding with context model for image compression using sparse dictionaries
JP4313771B2 (en) Method and apparatus for encoding transform coefficients in image and / or video encoder and decoder and corresponding computer program and corresponding computer readable storage medium
CN100488254C (en) Entropy coding method and decoding method based on text
US7501964B2 (en) Entropy coding for digital codecs
Le et al. Mobilecodec: neural inter-frame video compression on mobile devices
US8576915B2 (en) Position coding for context-based adaptive variable length coding
CN107710759A (en) Method and device for the conversion coefficient encoding and decoding of non-square block
US20110033126A1 (en) Method for improving the performance of embedded graphics coding
CN102473315A (en) Method and apparatus for reusing tree structures to encode and decode binary sets
Arora et al. Review of image compression techniques
KR20100089546A (en) Method and apparatus for successively encoding/decoding image
Jain et al. Image compression using discrete cosine transform and adaptive Huffman coding
CN100450181C (en) An Embedded Image Compression Technology Based on Wavelet Transform
CN114731446A (en) Coding concepts for sequences of information values
CN103607588A (en) Residual error transformation coefficient significance map coding method based on template
WO2022193386A1 (en) Coefficient encoding method and device, coefficient decoding method and device, terminal and storage medium
Chen et al. Highly efficient entropy coding of multilevel images using a modified arithmetic code
CN100413343C (en) A method and device for binarization decoding to obtain decoded data value
Bhosale et al. A Modified Image Template for FELICS Algorithm for Lossless Image Compression
HK1227583A1 (en) Methods and apparatus for video encoding and decoding binary sets using adaptive tree selection
HK1227583B (en) Methods and apparatus for video encoding and decoding binary sets using adaptive tree selection

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20080716

Termination date: 20210923

CF01 Termination of patent right due to non-payment of annual fee