CN102572437B - Hardware realization method for rapidly decoding CAVLC (context-adaptive variable-length coding) run_before code - Google Patents
Hardware realization method for rapidly decoding CAVLC (context-adaptive variable-length coding) run_before code Download PDFInfo
- Publication number
- CN102572437B CN102572437B CN201210034976.1A CN201210034976A CN102572437B CN 102572437 B CN102572437 B CN 102572437B CN 201210034976 A CN201210034976 A CN 201210034976A CN 102572437 B CN102572437 B CN 102572437B
- Authority
- CN
- China
- Prior art keywords
- run
- zerosleft
- code
- value
- decoding
- 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
Links
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
- Compression Of Band Width Or Redundancy In Fax (AREA)
Abstract
本发明属于数字视频信号编解码技术领域,具体为一种快速解码CAVLCrun_before码字的硬件实现方法。本方法采用码表分拆和码字合并这两种方法,在一个时钟周期内最多可以解码14个值为0的run_before码字,或两个值不等于0的run_before码字。输入的视频码流首先经过前导1检测器来检测带解码的run_before码字是否为零,前导1检测器最多一次可以检测14位前导1。当前run_before码字的值不为零,如果我们将当前解码位置之前所包含的0的总个数记为zerosLeft,根据zerosLeft的值可以将run_before码字分为7种类型,将原标准中规定的run_before码表分解为7个子码表,针对每一种类型分别进行解码。本发明可以大大提高硬件解码器的数据处理能力。
The invention belongs to the technical field of digital video signal encoding and decoding, in particular to a hardware implementation method for quickly decoding a CAVLCrun_before codeword. This method adopts two methods of code table splitting and codeword merging, and can decode up to 14 run_before codewords whose value is 0, or two run_before codewords whose value is not equal to 0 in one clock cycle. The input video code stream first passes through the leading 1 detector to detect whether the decoded run_before codeword is zero. The leading 1 detector can detect 14 leading 1 bits at a time. The value of the current run_before codeword is not zero. If we record the total number of 0s contained before the current decoding position as zerosLeft, the run_before codeword can be divided into 7 types according to the value of zerosLeft, and the original standard specifies The run_before code table is decomposed into 7 sub-code tables, which are decoded for each type. The invention can greatly improve the data processing capability of the hardware decoder.
Description
技术领域 technical field
本发明属于数字视频信号编解码技术领域,具体涉及一种解码CAVLC run_before码字的硬件实现方法。 The invention belongs to the technical field of digital video signal encoding and decoding, and in particular relates to a hardware implementation method for decoding a CAVLC run_before codeword.
背景技术 Background technique
H.264/AVC(Advanced Video Coding)由国际电信组织(ITU)和运动图像专家组(MPEG)联合制定而成的国际视频编码标准,目前已经在多媒体音视频领域得到了广泛的应用。H.264/AVC中规定其熵编码可以采用两种方式:下文自适应可变长编码(CAVLC)和上下文自适应算术编码(CABAC)。CABAC具有较高的编码效率,但是编解码的复杂度也大大增加,而CAVLC在编码效率和复杂度上有着较好的均衡。与前一代视频标准如MPEG-1,MPEG-2相比,CAVLC的编码效率有着显著提升。 H.264/AVC (Advanced Video Coding) is an international video coding standard jointly formulated by the International Telecommunications Organization (ITU) and the Moving Picture Experts Group (MPEG), and has been widely used in the field of multimedia audio and video. H.264/AVC stipulates that its entropy coding can adopt two methods: Context Adaptive Variable Length Coding (CAVLC) and Context Adaptive Arithmetic Coding (CABAC). CABAC has higher encoding efficiency, but the complexity of encoding and decoding is also greatly increased, while CAVLC has a better balance between encoding efficiency and complexity. Compared with the previous generation of video standards such as MPEG-1 and MPEG-2, the coding efficiency of CAVLC has been significantly improved.
视频码流中的视频头信息和预测信息一般采用较低复杂度的定长码或指数哥伦布码,而残差系数的信息占据了视频码流的绝大部分,这部分信息的编码需要采用更高效的CAVLC编码方式。CAVLC的码字总共有5类: The video header information and prediction information in the video code stream generally use fixed-length codes or exponential Golomb codes with lower complexity, while the residual coefficient information occupies the vast majority of the video code stream, and the encoding of this part of information needs to use more Efficient CAVLC encoding method. There are 5 types of codewords in CAVLC:
1. Coeff_token:本码字代表非零系数的数目和拖尾1的个数(TrailingOnes)。 1. Coeff_token: This codeword represents the number of non-zero coefficients and the number of trailing ones (TrailingOnes).
2. Sign_trail:本码字是拖尾1的符号。每一个符号编码为一比特,0表示正1,1表示负1。 2. Sign_trail: This codeword is a trailing 1 symbol. Each symbol is encoded as one bit, with 0 representing a positive 1 and 1 representing a negative 1.
3. Levels:本码字是指TrailingOnes外的其它的非零系数的幅值。 3. Levels: This codeword refers to the amplitude of other non-zero coefficients other than TrailingOnes.
4. Total_zeros:它编码在以反Zig-Zag扫描顺序时第一个非零系数后的总的零系数的个数。 4. Total_zeros: It encodes the number of total zero coefficients after the first non-zero coefficient in reverse Zig-Zag scanning order.
5. Run_before:本码字是指每一个非零系数前的零的个数。 5. Run_before: This codeword refers to the number of zeros before each non-zero coefficient.
对于硬件解码而言,计算非零系数的幅值和run_before码字是整个CAVLC解码过程中最耗费时间的过程。对于一个长度和高度都为4个像素的图形块,如果采用CAVLC编码方式,有些码字如Coeff_token、sign_trial和Total_zero在解码过程中只需要一次解码,而run_before码字最多可以达14个。为了加快硬件处理的速度,有必要针对run_before码字提出一种快速的解码方法。 For hardware decoding, calculating the magnitude of non-zero coefficients and the run_before codeword is the most time-consuming process in the entire CAVLC decoding process. For a graphic block with a length and height of 4 pixels, if the CAVLC encoding method is used, some codewords such as Coeff_token, sign_trial and Total_zero only need to be decoded once in the decoding process, while run_before codewords can be up to 14. In order to speed up hardware processing, it is necessary to propose a fast decoding method for the run_before codeword.
发明内容 Contents of the invention
本发明的目的在于提出一种适用于H.264视频规范所规定的CAVLC解码过程的快速解码run_before码字的硬件实现方法。 The object of the present invention is to propose a hardware implementation method for fast decoding run_before code words suitable for the CAVLC decoding process specified by the H.264 video specification.
本发明提出的快速解码run_before码字的硬件实现方法,可以在一个时钟周期内最多完成两个run_before码字的解码。整个码字解码的硬件框图如图1所示。本方法采用了码表分拆和码字合并这两种方法,在一个时钟周期内最多可以解码14个值为0的run_before码字,或两个值不等于0的run_before码字。输入的视频码流首先经过前导1检测器来检测带解码的run_before码字是否为零,前导1检测器最多一次可以检测14位前导1。如果当前run_before码字的值不为零,我们将当前解码位置之前所包含的0的总个数记为zerosLeft,根据zerosLeft的值可以将run_before码字分为7种类型,即将原标准中规定的run_before码表分解为7个子码表,针对每一种类型分别进行解码。每个时钟周期内最多可以解码2个run_before码字。 The hardware implementation method for quickly decoding run_before codewords proposed by the present invention can complete the decoding of at most two run_before codewords within one clock cycle. The hardware block diagram of the entire codeword decoding is shown in Figure 1. This method adopts the two methods of code table splitting and codeword merging, and can decode up to 14 run_before codewords whose value is 0, or two run_before codewords whose value is not equal to 0 in one clock cycle. The input video code stream first passes through the leading 1 detector to detect whether the decoded run_before codeword is zero. The leading 1 detector can detect 14 leading 1 bits at a time. If the value of the current run_before codeword is not zero, we record the total number of 0s contained before the current decoding position as zerosLeft. According to the value of zerosLeft, the run_before codeword can be divided into 7 types, that is, the original standard The run_before code table is decomposed into 7 sub-code tables, which are decoded for each type. Up to 2 run_before codewords can be decoded in each clock cycle.
CAVLC定义了多种码字,在编码一个4x4残差数据块时,run_before码字最多可出现14次,因此这一硬件实现方法可以大大提高了硬件解码器的数据处理能力。 CAVLC defines a variety of codewords. When encoding a 4x4 residual data block, the run_before codeword can appear up to 14 times. Therefore, this hardware implementation method can greatly improve the data processing capability of the hardware decoder.
具体的解码过程分为如下四个步骤: The specific decoding process is divided into the following four steps:
(1)码表分拆和码字合并。 (1) Code table splitting and codeword merging.
(2)检测前导1的个数。 (2) Detect the number of leading 1s.
(3)根据zerosLeft的值从7个码表的输出选择出正确的值。 (3) Select the correct value from the output of 7 code tables according to the value of zerosLeft.
(4)更新zerosLeft变量。每次解码完run_before码字后对zerosLeft变量进行更新,在下次解码时需要使用更新后的值。 (4) Update the zerosLeft variable. The zerosLeft variable is updated after each run_before codeword is decoded, and the updated value needs to be used in the next decoding.
H.264视频规范中指定了一个用于解码run_before码字的码表,此码表如表1所示。本发明将此码表分解为7个较小的码表,如表2—表8所示,并对其中的5个码表(表3、表4、表5、表6、表7)进行码字合并,使得其能够在一个时钟周期内完成两个码字的解码。 A code table for decoding the run_before codeword is specified in the H.264 video specification, and the code table is shown in Table 1. The present invention decomposes this code table into 7 smaller code tables, as shown in table 2-table 8, and carries out 5 code tables (table 3, table 4, table 5, table 6, table 7) wherein The codewords are combined so that it can complete the decoding of two codewords in one clock cycle.
CAVLC定义了6种码字,其中非零系数幅值的码字和run_before码字出现的频率最高,在编码一个4x4残差数据块时run_before码字最多可出现14次,因此这一硬件实现方法可以大大提高硬件解码器的数据处理能力。 CAVLC defines 6 codewords, among which the codeword with non-zero coefficient amplitude and the run_before codeword appear most frequently, and the run_before codeword can appear up to 14 times when encoding a 4x4 residual data block, so this hardware implementation method The data processing capability of the hardware decoder can be greatly improved.
本发明的有益效果: Beneficial effects of the present invention:
现有方法在一个时钟周期内只能解码一个run_before码字,而本发明中描述的方法可以将速度加倍,在一个时钟周期内可以解码得到多个run_before码字的值,从而提高了CAVLC整体的解码速度。适用于各种具有H.264视频解码功能的电子设备。 The existing method can only decode one run_before codeword in one clock cycle, but the method described in the present invention can double the speed, and can decode the values of multiple run_before codewords in one clock cycle, thereby improving the overall performance of CAVLC decoding speed. Applicable to various electronic devices with H.264 video decoding function.
附图说明 Description of drawings
图1:run_before码字的硬件解码框图。 Figure 1: Block diagram of hardware decoding of the run_before codeword.
具体实施方式 Detailed ways
下面结合附图对本发明做进一步的描述。 The present invention will be further described below in conjunction with the accompanying drawings.
本发明所述的快速解码run_before码字的具体实施方式如下: The specific implementation of the fast decoding run_before codeword of the present invention is as follows:
(1)码表分拆和码字合并。 (1) Code table splitting and codeword merging.
H.264视频标准中规定用于解码run_before码字的码表如表1所示。查询一次此码表只能得到一个run_before码字的值。为了加速此解码过程,我们将此码表按照zerosLeft的值分拆成7个码表。表2是针对zerosLeft>6时的码表。表3是针对zerosLeft=6时的码表。表4是针对zerosLeft=5时的码表。表5是针对zerosLeft=4时的码表。表6是针对zerosLeft=3时的码表。表7是针对zerosLeft=2时的码表。表8针对zerosLeft=1时的码表。其中表3、表4、表5、表6、表7采用了码字合并的技巧,每次查询这5个表可以得到2个run_before码字。而表2和表8,则是从表1中直接分拆得到,每次查询表2和表8,只能得到1个run_before码字。 The code table for decoding the run_before codeword specified in the H.264 video standard is shown in Table 1. Only one run_before codeword value can be obtained by querying this code table once. In order to speed up the decoding process, we split this code table into 7 code tables according to the value of zerosLeft. Table 2 is the code table for zerosLeft>6. Table 3 is the code table for zerosLeft=6. Table 4 is the code table for zerosLeft=5. Table 5 is the code table for zerosLeft=4. Table 6 is the code table for zerosLeft=3. Table 7 is the code table for zerosLeft=2. Table 8 is for the code table when zerosLeft=1. Among them, Table 3, Table 4, Table 5, Table 6, and Table 7 adopt the technique of combining codewords, and each time these 5 tables are queried, 2 run_before codewords can be obtained. Table 2 and Table 8 are obtained directly from Table 1, and each time Table 2 and Table 8 are queried, only one run_before codeword can be obtained.
(2)检测前导1的个数。 (2) Detect the number of leading 1s.
在解码run_before码字时,首先检测当前码流中前导1的个数。本发明中的前导1检测器最多可以一次检测14个前导1。如果输入的视频码流第一个比特为0,那么前导1的个数为零,说明当前run_before的值大于零,此过程结束,进入步骤(3)。否则,根据前导1的个数可同时解码多个run_before码字,这些run_before码字的解码值都是0。我们将前导1的个数记为N,如果zerosLeft>6且N≥3,那么包括当前码字在内的连续N/3个run_before码字的值都是0;如果2<zerosLeft<6且N≥2,那么包括当前码字在内的连续N/2个run_before码字的值都是0; 如果zerosLeft≤2,那么包括当前码字在内的连续N个run_before码字的值都是0。上述计算中,如果N不是3或2的整数倍,N/3和N/2取其运算结果的整数部分。本发明中N最大值为14,所以前导1检测器最多一次可以解码14个值为零的run_before码字。 When decoding the run_before codeword, first detect the number of leading 1s in the current code stream. The preamble 1 detector in the present invention can detect up to 14 preamble 1s at a time. If the first bit of the input video code stream is 0, then the number of leading 1s is zero, indicating that the current value of run_before is greater than zero, and this process ends and enters step (3). Otherwise, multiple run_before codewords can be decoded simultaneously according to the number of leading 1s, and the decoded values of these run_before codewords are all 0. We record the number of leading 1s as N, if zerosLeft>6 and N≥3, then the values of consecutive N/3 run_before codewords including the current codeword are all 0; if 2<zerosLeft<6 and N ≥2, then the values of N/2 consecutive run_before codewords including the current codeword are all 0; if zerosLeft≤2, then the values of N consecutive run_before codewords including the current codeword are all 0. In the above calculation, if N is not an integer multiple of 3 or 2, N/3 and N/2 take the integer part of the operation result. In the present invention, the maximum value of N is 14, so the leading 1 detector can decode at most 14 run_before codewords whose value is zero at one time.
(3)根据zerosLeft的值从7个码表的输出选择出正确的值。 (3) Select the correct value from the output of 7 code tables according to the value of zerosLeft.
zerosLeft的取值范围可以分为7种:大于6, 6, 5, 4, 3, 2, 1。此时对应的码表分别为表2、表3、表4、表5、表6、表7、表8。根据当前zerosLeft的值,选择相应的码表输出作为最终的解码结果。每查询一次表2或表8,可以得到一个run_before码字的值,而每查询一次表3、表4、表5、表6或表7,可以得到两个run_before码字的值。 The value range of zerosLeft can be divided into 7 types: greater than 6, 6, 5, 4, 3, 2, 1. At this time, the corresponding code tables are Table 2, Table 3, Table 4, Table 5, Table 6, Table 7, and Table 8 respectively. According to the current value of zerosLeft, select the corresponding code table output as the final decoding result. Every time Table 2 or Table 8 is queried, one run_before codeword value can be obtained, and every time Table 3, Table 4, Table 5, Table 6 or Table 7 is queried, two run_before codeword values can be obtained.
(4)更新zerosLeft变量。 (4) Update the zerosLeft variable.
如果当前zerosLeft等于1或者大于6,根据步骤(3)中解码得到当前run_before码字的值,zerosLeft变量减去当前run_before码字在解码后得到的值,即为新的zerosLeft变量;如果当前zerosLeft等于2、3、4、5、6中任意一个值,根据步骤(3)中得出的两个run_before码字解码后的值,zerosLeft变量减去这两个码字值的和,即为新的zerosLeft变量。 If the current zerosLeft is equal to 1 or greater than 6, according to the value of the current run_before codeword decoded in step (3), the zerosLeft variable minus the value obtained after decoding the current run_before codeword is the new zerosLeft variable; if the current zerosLeft is equal to For any value in 2, 3, 4, 5, or 6, according to the decoded values of the two run_before codewords obtained in step (3), the zerosLeft variable minus the sum of the two codeword values is the new zerosLeft variable.
经过上述四个步骤,即可在一个时钟周期内解码两个run_before码字。此发明中提出的硬件架构可以大大加快H.264 CAVLC的解码速度。 After the above four steps, two run_before codewords can be decoded within one clock cycle. The hardware architecture proposed in this invention can greatly accelerate the decoding speed of H.264 CAVLC.
表1:H.264标准中规定用于解码run_before码字码表 Table 1: Code table for decoding run_before code specified in the H.264 standard
表2:针对zerosLeft>6时的码表(Table 1) Table 2: Code table for zerosLeft>6 (Table 1)
表3:针对zerosLeft=6时的码表(Table 2) Table 3: Code table for zerosLeft=6 (Table 2)
表4:针对zerosLeft=5时的码表(Table 3) Table 4: Code table for zerosLeft=5 (Table 3)
表5:针对zerosLeft=4时的码表(Table 4) Table 5: Code table for zerosLeft=4 (Table 4)
表6:针对zerosLeft=3时的码表(Table 5) Table 6: Code table for zerosLeft=3 (Table 5)
表7:针对zerosLeft=2时的码表(Table 6) Table 7: Code table for zerosLeft=2 (Table 6)
表8:针对zerosLeft=1时的码表(Table 7) Table 8: Code table for zerosLeft=1 (Table 7)
。 .
Claims (2)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201210034976.1A CN102572437B (en) | 2012-02-16 | 2012-02-16 | Hardware realization method for rapidly decoding CAVLC (context-adaptive variable-length coding) run_before code |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201210034976.1A CN102572437B (en) | 2012-02-16 | 2012-02-16 | Hardware realization method for rapidly decoding CAVLC (context-adaptive variable-length coding) run_before code |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN102572437A CN102572437A (en) | 2012-07-11 |
| CN102572437B true CN102572437B (en) | 2014-08-06 |
Family
ID=46416744
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201210034976.1A Expired - Fee Related CN102572437B (en) | 2012-02-16 | 2012-02-16 | Hardware realization method for rapidly decoding CAVLC (context-adaptive variable-length coding) run_before code |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN102572437B (en) |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1913638A (en) * | 2005-08-09 | 2007-02-14 | C&S技术有限公司 | H.264 decoding method for fast CAVLC |
| CN101267561A (en) * | 2007-03-13 | 2008-09-17 | 株式会社东芝 | Image decoding apparatus and image decoding method |
| CN101873496A (en) * | 2010-05-24 | 2010-10-27 | 杭州海康威视软件有限公司 | Context-based self-adaption variable length decoding method and device of H.264 |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7773004B2 (en) * | 2008-07-08 | 2010-08-10 | Qualcomm Incorporated | CAVLC run-before decoding scheme |
-
2012
- 2012-02-16 CN CN201210034976.1A patent/CN102572437B/en not_active Expired - Fee Related
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1913638A (en) * | 2005-08-09 | 2007-02-14 | C&S技术有限公司 | H.264 decoding method for fast CAVLC |
| CN101267561A (en) * | 2007-03-13 | 2008-09-17 | 株式会社东芝 | Image decoding apparatus and image decoding method |
| CN101873496A (en) * | 2010-05-24 | 2010-10-27 | 杭州海康威视软件有限公司 | Context-based self-adaption variable length decoding method and device of H.264 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN102572437A (en) | 2012-07-11 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20200304795A1 (en) | Context and bypass encoding video | |
| CN106101727B (en) | Method and device for context-adaptive binary arithmetic coding | |
| CN103004195B (en) | A variety of variable length decoding methods are used for the video compress of polytype transformation coefficient block | |
| CN101167366B (en) | A binarization method and device | |
| US20030085822A1 (en) | High performance memory efficient variable-length coding decoder | |
| CN102868882B (en) | Apparatus and method for performing video encoding | |
| US7982641B1 (en) | Context-based adaptive binary arithmetic coding engine | |
| CN101878651B (en) | Variable-length coding of coefficient families for image and video compression | |
| WO2009029797A1 (en) | Architecture for multi-stage decoding of a cabac bitstream | |
| WO2013107230A1 (en) | Method and apparatus for context-adaptive binary arithmetic coding of syntax elements | |
| CN103227924B (en) | A kind of arithmetic encoder and coded method | |
| CN101557517A (en) | Decoder, decoding device and decoding method | |
| CN102752592B (en) | Entropy coding method of video transformation coefficient | |
| CN101370138A (en) | A Decoding Method of H.264 Standard CAVLC Residual Coefficients | |
| CN102740066B (en) | CAVLC decoding method and system | |
| CN104980749B (en) | Decoding device and method for arithmetic coding | |
| Wen et al. | Multiple-symbol parallel CAVLC decoder for H. 264/AVC | |
| CN101198056A (en) | Variable length encoding method and device | |
| CN102572437B (en) | Hardware realization method for rapidly decoding CAVLC (context-adaptive variable-length coding) run_before code | |
| CN104349165B (en) | The elongated decoding method of high-performance and device | |
| CN110545437A (en) | Coefficient encoding, decoding method, electronic device and medium | |
| CN101267559A (en) | General entropy decoding method and device for video decoder | |
| CN107277518B (en) | CABAC decoding method | |
| CN102263960B (en) | A Fast Method for Decoding CAVLC Non-zero Coefficient Amplitude | |
| CN1331360C (en) | Method for decoding codes in variable lengths |
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: 20140806 |
|
| CF01 | Termination of patent right due to non-payment of annual fee |