1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 
21 /**
22 ******************************************************************************
23 * @file ih264_cavlc_tables.h
24 *
25 * @brief
26 *  This file contains enumerations, macros and extern declarations of H264
27 *  cavlc tables
28 *
29 * @author
30 *  Ittiam
31 *
32 *  @remarks
33 *   none
34 ******************************************************************************
35 */
36 
37 #ifndef IH264_CAVLC_TABLES_H_
38 #define IH264_CAVLC_TABLES_H_
39 
40 /*****************************************************************************/
41 /* Constant Macros                                                           */
42 /*****************************************************************************/
43 /**
44 ******************************************************************************
45  *  @brief  maximum zeros left
46 ******************************************************************************
47  */
48 #define MAX_ZERO_LEFT 6
49 
50 /*****************************************************************************/
51 /* Extern global declarations                                                */
52 /*****************************************************************************/
53 
54 /**
55  ******************************************************************************
56  * @brief  Assignment of cbp to a codenum for intra and inter prediction modes
57  * chroma format idc != 0
58  * input  : cbp, intra - 0/inter - 1
59  * output : codenum
60  * @remarks Table 9-4 � Assignment of codeNum to values of coded_block_pattern
61  * for macroblock prediction modes in H264 spec
62  ******************************************************************************
63  */
64 extern const UWORD8 gu1_cbp_map_tables[48][2];
65 
66 /**
67  ******************************************************************************
68  * @brief  total non-zero coefficients and numbers of trailing ones of a residual
69  * block are mapped to coefftoken using the tables given below.
70  * input  : VLC-Num  | Trailing ones | Total coeffs
71  * output : coeff_token (code word, size of the code word)
72  * @remarks Table-9-5 coeff_token mapping to TotalCoeff( coeff_token )
73  * and TrailingOnes( coeff_token ) in H264 spec
74  ******************************************************************************
75  */
76 extern const UWORD8 gu1_code_coeff_token_table[3][4][16];
77 extern const UWORD8 gu1_size_coeff_token_table[3][4][16];
78 extern const UWORD8 gu1_code_coeff_token_table_chroma[4][4];
79 extern const UWORD8 gu1_size_coeff_token_table_chroma[4][4];
80 
81 /**
82  ******************************************************************************
83  * @brief  Thresholds for determining whether to increment Level table number.
84  * input  : suffix_length
85  * output : threshold
86  ******************************************************************************
87  */
88 extern const UWORD8 gu1_threshold_vlc_level[6];
89 
90 /**
91  ******************************************************************************
92  * @brief  table for encoding total number of zeros
93  * input  : coeff_token, total zeros
94  * output : code word, size of the code word
95  * @remarks Table-9-7, 9-8  total_zeros tables for 4x4 blocks with
96  * TotalCoeff( coeff_token ) in H264 spec
97  ******************************************************************************
98  */
99 extern const UWORD8 gu1_size_zero_table[135];
100 extern const UWORD8 gu1_code_zero_table[135];
101 extern const UWORD8 gu1_size_zero_table_chroma[9];
102 extern const UWORD8 gu1_code_zero_table_chroma[9];
103 
104 /**
105  ******************************************************************************
106  * @brief  index to access zero table (for speed)
107  * input  : TotalCoeff( coeff_token )
108  * output : index to access zero table
109  ******************************************************************************
110  */
111 extern const UWORD8 gu1_index_zero_table[15];
112 
113 /**
114  ******************************************************************************
115  * @brief  table for encoding runs of zeros before
116  * input  : zeros left, runs of zeros before
117  * output : code word, size of the code word
118  * @remarks Table-9-10  table for run_before in H264 spec
119  ******************************************************************************
120  */
121 extern const UWORD8 gu1_size_run_table[42];
122 extern const UWORD8 gu1_code_run_table[42];
123 
124 /**
125  ******************************************************************************
126  * @brief  index to access run table (look up)
127  * input  : zeros left
128  * output : index to access run table
129  ******************************************************************************
130  */
131 extern const UWORD8 gu1_index_run_table[7];
132 
133 #endif /* IH264_CAVLC_TABLES_H_ */
134