一种视频宏块模式编码方法 技术领域 Video macroblock mode encoding method TECHNICAL FIELD
本发明涉及多媒体通信领域, 尤其涉及一种视频宏块模式编码方法。 技术背景 The present invention relates to the field of multimedia communications, and in particular, to a video macroblock mode encoding method. technical background
现有的视频图像压缩标准 MPEG - 1、 MPEG - 2. MPEG - 4, H.26K Existing video image compression standards MPEG-1, MPEG-2. MPEG-4, H.26K
H.263、 H.264都是基于 DCT变换的, 其中 H.264和 MPEG-4 AVC采用的是性 能逼近于 DCT的整数变换方法, 其一般处理框架如图 1所示。 H.263 and H.264 are based on DCT transformation. Among them, H.264 and MPEG-4 AVC use integer conversion methods with performance close to DCT. The general processing framework is shown in Figure 1.
其中的熵编码方法主要包括变长编码和算术编码方法, 例如, 在 H.264 中, 采用的熵编码方法有三种: 通用变长编码方法 UVLC、 基于上下文关系 ( context-based )的变长编码方法 CAVLC和基于上下文关系的算术编码方法 CABAC。 The entropy coding methods mainly include variable-length coding and arithmetic coding methods. For example, in H.264, there are three types of entropy coding methods: universal variable-length coding method UVLC, and context-based variable-length coding. Methods CAVLC and context-based arithmetic coding method CABAC.
H.264所采用的 UVLC 熵编码方法为 Exp-Golomb熵编码方法 [ll, 基本思 想为: 用 "1" 作为识别符, "1" 前面的 "0" 的个数和 "1" 后面的信息位 数相同。 The UVLC entropy coding method used by H.264 is the Exp-Golomb entropy coding method [ll , the basic idea is: use "1" as the identifier, the number of "0" before "1" and the information after "1" The number of digits is the same.
码字 "Codeword" 的结构形式为: The structure of the codeword "Codeword" is:
[M zeros][l][INFO] [M zeros] [l] [INFO]
在编码端, 对于给定的码字序号 Codenum值, 通过以下方法来计算识别 符 "1" 前面的 "0" 的个数 M和识别符 "1" 后面的信息 INFO值: At the encoding end, for a given codeword number Codenum value, the following methods are used to calculate the number of "0" M before the identifier "1" and the information INFO value after the identifier "1":
M = \og 2(Codenum + 1) M = \ og 2 (Codenum + 1)
Length = 2M + 1 Length = 2M + 1
INFO = Codenum + l - 2M INFO = Codenum + l-2 M
在解码端, 通过以下方法解码出码字序号 Codenum值: On the decoding side, the codeword sequence Codenum value is decoded by the following methods:
(1)读出识别符 " 及前面的 "0" 符号, 设读出的符号 "0" '的个数
(2)读出识别符 " 后面的 Μ位信息, 令其值为 /NFO。 (1) Read the identifier "and the preceding" 0 "symbol, and set the number of the read symbol" 0 "' (2) The M-bit information following the identifier "is read, and its value is / NFO.
(3) Codenum = 2M + INFO - 1。 不管是编码端还是解码端, 如果码字序号 Codenum为 0, 则 INFO和 M都 为 0, 反之亦然。 (3) Codenum = 2 M + INFO-1. Regardless of the encoding side or the decoding side, if the codeword sequence number Codenum is 0, both INFO and M are 0, and vice versa.
码字序号 Codenum与码字 Codeword的对应关系如表 1所示。 The corresponding relationship between the codeword serial number Codenum and the codeword Codeword is shown in Table 1.
表 1 H.264中码字序号 Codenum与码字 Codeword对应关系 Table 1 Correspondence between Codenum and Codeword in H.264
在采用 UVLC方法对 CBP进行编码时, 首先要确定 CBP到 Codenum的映 射关系。 H.264中 CBP与 Codenum的映射关系如表 2所示。 When using the UVLC method to encode CBP, we must first determine the mapping relationship between CBP and Codenum. The mapping relationship between CBP and Codenum in H.264 is shown in Table 2.
表 2 H.264中 CBP与 Codenum的映射关系 Table 2 Mapping relationship between CBP and Codenum in H.264
Codenum coded_block— pattern Codenum coded_block— pattern
Intra— 4x4 Inter Intra— 4x4 Inter
0 47 0 0 47 0
1 31 16 1 31 16
2 15 1 2 15 1
3 0 2 3 0 2
4 23 4 4 23 4
5 27 8 5 27 8
6 29 32
ε 6 29 32 ε
0M100/^00ZN3/X3d
在 H.264采用的 UVLC熵编码方法中, CBP到 Codenum的映射方法是基于 4x4变换进行考虑的。 对于其他变换, 并没有充分的考虑。 0M100 / ^ 00ZN3 / X3d In the UVLC entropy coding method used in H.264, the CBP to Codenum mapping method is considered based on the 4x4 transform. For other transformations, not enough consideration has been given.
发明内容 Summary of the invention
本发明的目的就是提出一种新的编码方式,可以基于通用变长编码进行 基于 8x8或 4x4变换的宏块模式编码 CBP编码。 The purpose of the present invention is to propose a new encoding method that can perform macroblock mode encoding CBP encoding based on 8x8 or 4x4 transform based on universal variable-length encoding.
为此, 本发明采用如下技术方案。 Therefore, the present invention adopts the following technical solutions.
一种视频宏块模式编码方法,其特征在于所述的宏块模式编码 CBP的取 值为 6位非负整数, 其中高两位对应于色度块, 低四位对应于亮度块; 所述方法包括: A video macroblock mode encoding method, characterized in that the value of the macroblock mode encoding CBP is a 6-bit non-negative integer, in which the upper two bits correspond to a chroma block and the lower four bits correspond to a luma block; said Methods include:
将视频图像进行分块, 分成若干宏块; Divide the video image into several macroblocks;
确定宏块模式编码到码字序号的变换方式,该变换方式包括码字序号与 帧内编码模式及帧间编码模式的对应关系; Determining a transformation mode of the macroblock mode encoding to a codeword sequence number, the transformation mode including a correspondence between the codeword sequence number and an intra-frame encoding mode and an inter-frame encoding mode;
按照该对应关系完成通用变长编码的宏块模式编码 CBP的编码。 According to the corresponding relationship, the coding of the general variable length coding macroblock mode coding CBP is completed.
所述的变换方式为基于 8x8或 4x4的变换。 The transformation method is based on 8x8 or 4x4 transformation.
所述的变换对应关系为: The transformation correspondence is:
Codenum CBP Codenum CBP
xxxxxx xxxxxx
(543210) (543210)
帧内编码模式 帧间编码模式 Intra coding mode Inter coding mode
0 63 0 0 63 0
1 15 15 1 15 15
2 31 63 2 31 63
3 47 31 3 47 31
4 0 16 4 0 16
5 14 32 5 14 32
6 13 47 6 13 47
7 11 13 7 11 13
8 7 14 8 7 14
9 5 11 9 5 11
o oo請 工:) a 舊 sooz ΟΛ\
49 48 46 o oo please work :) a old sooz ΟΛ \ 49 48 46
50 22 36 50 22 36
51 33 33 51 33 33
52 25 34 52 25 34
53 49 40 53 49 40
54 40 52 54 40 52
55 36 49 55 36 49
56 34 50 56 34 50
57 50 56 57 50 56
58 52 25 58 52 25
59 54 22 59 54 22
60 41 54 60 41 54
61 56 57 61 56 57
62 38 41 62 38 41
63 57 38 或者所述的变换对应关系为: 63 57 38 or the transformation correspondence is:
Codenum CBP Codenum CBP
xxxxx xxxxx
(543210) (543210)
帧内编码模式 帧间编码模式 Intra coding mode Inter coding mode
0 63 00 63 0
1 31 41 31 4
2 15 82 15 8
3 47 13 47 1
4 0 24 0 2
5 61 155 61 15
6 55 126 55 12
7 59 57 59 5
8 51 108 51 10
9 62 39 62 3
10 14 1610 14 16
1 1 12 131 1 12 13
12 13 1412 13 14
13 7 3213 7 32
14 60 714 60 7
15 1 1 1 1
18 16 6315 1 1 1 1 18 16 63
19 30 3119 30 31
20 23 4720 23 47
21 53 4821 53 48
22 10 2022 10 20
23 27 1723 27 17
24 32 2424 32 24
25 28 1825 28 18
26 8 2126 8 21
27 1 3627 1 36
28 48 3328 48 33
29 4 4029 4 40
30 2 3430 2 34
31 5 2631 5 26
32 19 3732 19 37
33 58 1933 58 19
34 46 2834 46 28
35 21 4235 21 42
36 39 2936 39 29
37 43 2337 43 23
38 26 2738 26 27
39 49 3039 49 30
40 45 4440 45 44
41 17 5341 17 53
42 44 4642 44 46
43 35 6243 35 62
44 6 3544 6 35
45 9 5845 9 58
46 52 6146 52 61
47 24 4547 24 45
48 50 3948 50 39
49 56 4349 56 43
50 18 5550 18 55
51 20 59 51 20 59
6A
52 42 49 6A 52 42 49
53 37 60 53 37 60
54 25 52 54 25 52
55 36 50 55 36 50
56 33 56 56 33 56
57 57 51 57 57 51
58 22 25 58 22 25
59 54 22 59 54 22
60 40 38 60 40 38
61 34 41 61 34 41
62 38 57 62 38 57
63 41 54 63 41 54
本发明所述的编码方法, 是基于一些典型视频序列的 CBP特性得出的, 因而能比较好地反映 CBP的统计特性, 具有较好的编码性能。 The coding method according to the present invention is obtained based on the CBP characteristics of some typical video sequences, and therefore can better reflect the statistical characteristics of CBP, and has better coding performance.
附图说明 BRIEF DESCRIPTION OF THE DRAWINGS
图 1是现有技术中基于 DCT的视频压缩框架示意图; 1 is a schematic diagram of a DCT-based video compression framework in the prior art;
图 2是本发明实施例中 16x16宏块中 8x8块的排列顺序示意图。 FIG. 2 is a schematic diagram of an arrangement sequence of 8x8 blocks in a 16x16 macroblock according to an embodiment of the present invention.
具体实施方式 detailed description
下面结合说明书附图来说明本发明的具体实施方式。 The following describes specific embodiments of the present invention with reference to the accompanying drawings.
本发明给出了一种基于 UVLC编码的 CBP到 Codenum映射方法, 适合于 基于 8x8或 4x4变换的视频压缩方法。 其中宏块模式编码 CBP的取值 XXXXXX (543210)为 6位非负整数, 是按照图 2所示的 16χ 16宏块中 8><8块 排列顺序进行计算的, 高两位对应于色度块, 低四位对应于亮度块。 若第 η 位为 1, 则说明该位所对应的 8x8块具有至少一个非零 DCT变换系数, 若第 η 位为 0, 则说明该位所对应的 8x8块的所有 DCT变换系数都为零。 The present invention provides a CBP-to-Codenum mapping method based on UVLC coding, which is suitable for a video compression method based on 8x8 or 4x4 transform. The value of the macroblock mode code CBP XXXXXX (543210) is a 6-bit non-negative integer, which is calculated according to the arrangement order of 8> <8 blocks in the 16 × 16 macroblock shown in FIG. 2. The upper two bits correspond to the chroma. Block, the lower four bits correspond to the luminance block. If the n-th bit is 1, it means that the 8x8 block corresponding to the bit has at least one non-zero DCT transform coefficient. If the n-th bit is 0, it means that all the DCT transform coefficients of the 8x8 block corresponding to the bit are zero.
下面给出两种 CBP到 Codenum映射方法 Here are two CBP to Codenum mapping methods
6B
CBP与 CodeNum的映射关系 6B Mapping relationship between CBP and CodeNum
Codenum CBP Codenum CBP
xxxxxx xxxxxx
(543210) (543210)
帧内编码模式 帧间编码模式 Intra coding mode Inter coding mode
0 63 0 0 63 0
1 15 15 1 15 15
2 31 63 2 31 63
3 47 31 3 47 31
4 0 16 4 0 16
5 14 32 5 14 32
6 13 47 6 13 47
7 11 13 7 11 13
8 7 14 8 7 14
9 5 11 9 5 11
10 10 12 10 10 12
11 8 5 11 8 5
12 12 10 12 12 10
13 61 7 13 61 7
14 4 48 14 4 48
15 55 3 15 55 3
16 1 2 16 1 2
17 2 8 17 2 8
18 59 4 18 59 4
19 3 1 19 3 1
20 62 61 20 62 61
21 9 55 21 9 55
22 6 59 22 6 59
23 29 62 23 29 62
24 45 29 24 45 29
25 51 27 25 51 27
26 23 23 26 23 23
27 39 19 27 39 19
28 27 30 28 27 30
29 46 28 29 46 28
30 53 9 30 53 9
31 30 6 31 30 6
32 43 60
38 19 1832 43 60 38 19 18
39 35 2039 35 20
40 42 2440 42 24
41 26 5341 26 53
42 44 1742 44 17
43 32 3743 32 37
44 58 3944 58 39
45 24 4545 24 45
46 20 5846 20 58
47 17 4347 17 43
48 18 4248 18 42
49 48 4649 48 46
50 22 3650 22 36
51 33 3351 33 33
52 25 3452 25 34
53 49 4053 49 40
54 40 5254 40 52
55 36 4955 36 49
56 34 5056 34 50
57 50 5657 50 56
58 52 2558 52 25
59 54 2259 54 22
60 41 5460 41 54
61 56 5761 56 57
62 38 4162 38 41
63 57 3863 57 38
CBP与 CodeNum的映射关系 Mapping relationship between CBP and CodeNum
8
6 55 128 6 55 12
7 59 57 59 5
8 51 108 51 10
9 62 39 62 3
10 14 1610 14 16
1 1 12 131 1 12 13
12 13 1412 13 14
13 7 3213 7 32
14 60 714 60 7
15 1 1 1 115 1 1 1 1
16 29 916 29 9
17 3 617 3 6
18 16 6318 16 63
19 30 3119 30 31
20 23 4720 23 47
21 53 4821 53 48
22 10 2022 10 20
23 27 1723 27 17
24 32 2424 32 24
25 28 1825 28 18
26 8 2126 8 21
27 1 3627 1 36
28 48 3328 48 33
29 4 4029 4 40
30 2 3430 2 34
31 5 2631 5 26
32 19 3732 19 37
33 58 1933 58 19
34 46 2834 46 28
35 21 4235 21 42
36 39 2936 39 29
37 43 2337 43 23
38 26 2738 26 27
39 49 3039 49 30
40 45 44 40 45 44
8A
41 17 53 8A 41 17 53
42 44 46 42 44 46
43 35 62 43 35 62
44 6 35 44 6 35
45 9 58 45 9 58
46 52 61 46 52 61
47 24 45 47 24 45
48 50 39 48 50 39
49 56 43 49 56 43
50 18 55 50 18 55
51 20 59 51 20 59
52 42 49 52 42 49
53 37 60 53 37 60
54 25 52 54 25 52
55 36 50 55 36 50
56 33 56 56 33 56
57 57 51 57 57 51
58 22 25 58 22 25
59 54 22 59 54 22
60 40 38 60 40 38
61 34 41 61 34 41
62 38 57 62 38 57
63 41 54 63 41 54
本发明所给出的 CBP到 Codenum映射方法不局限于表 1所对应的 UVLC编 码方法, 也可以应用于其它 UVLC编码方法, 如标志位 1的前后信息位数非对 称的 UVLC编码方法。 The CBP to Codenum mapping method provided by the present invention is not limited to the UVLC coding method corresponding to Table 1, but can also be applied to other UVLC coding methods, such as asymmetric UVLC coding methods in which the number of information bits before and after the flag bit 1 is asymmetric.
8B
8 x 8或 4 x 4变换方法的 CB P编码问题。 8B CB P coding problem for 8 x 8 or 4 x 4 transform methods.
本发明所述的基于 UVLC编码的 CBP到 Codenum映射方法, 是基于一些典 型视频序列的 CBP特性得出的, 因而能比较好地反映 CBP的统计特性, 具有较 好的编码性能。 The CBP-to-Codenum mapping method based on UVLC coding according to the present invention is derived based on the CBP characteristics of some typical video sequences, and therefore can better reflect the statistical characteristics of CBP, and has better coding performance.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不 局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可 轻易想到的变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明 的保护范围应该以权利要求书的保护范围为准。 The above are only the preferred embodiments of the present invention, but the scope of protection of the present invention is not limited to this. Any person skilled in the art can easily think of changes or changes within the technical scope disclosed by the present invention. Replacement should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
9
9