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 24 * ih264_cabac_tables.h 25 * 26 * @brief 27 * This file contains enumerations, macros and extern declarations of H264 28 * cabac tables 29 * 30 * @author 31 * ittiam 32 * 33 * @remarks 34 * none 35 ****************************************************************************** 36 */ 37 38 #ifndef _IH264_CABAC_TABLES_H_ 39 #define _IH264_CABAC_TABLES_H_ 40 41 /*****************************************************************************/ 42 /* Constant Macros */ 43 /*****************************************************************************/ 44 45 /** 46 ****************************************************************************** 47 * @brief maximum range of cabac_init_idc (0-2) + 1 for ISLICE 48 ****************************************************************************** 49 */ 50 #define NUM_CAB_INIT_IDC_PLUS_ONE 4 51 52 /** 53 ****************************************************************************** 54 * @brief max range of qps in H264 (0-51) 55 ****************************************************************************** 56 */ 57 #define QP_RANGE 52 58 59 /** 60 ****************************************************************************** 61 * @brief max range of cabac contexts in H264 (0-459) 62 ****************************************************************************** 63 */ 64 #define NUM_CABAC_CTXTS 460 65 66 67 /** Macros for Cabac checks */ 68 /** MbType */ 69 /** |x|x|I_PCM|SKIP| 70 |S|Inter/Intra|P/B|NON-BD16x16/BD16x16,I16x16/I4x4| */ 71 #define CAB_INTRA 0x00 /* 0000 00xx */ 72 #define CAB_INTER 0x04 /* 0000 01xx */ 73 #define CAB_I4x4 0x00 /* 0000 00x0 */ 74 #define CAB_I16x16 0x01 /* 0000 00x1 */ 75 #define CAB_BD16x16 0x04 /* 0000 0100 */ 76 #define CAB_NON_BD16x16 0x05 /* 0000 0101 */ 77 #define CAB_P 0x07 /* 0000 0111 */ 78 #define CAB_SI4x4 0x08 /* 0000 10x0 */ 79 #define CAB_SI16x16 0x09 /* 0000 10x1 */ 80 #define CAB_SKIP_MASK 0x10 /* 0001 0000 */ 81 #define CAB_SKIP 0x10 /* 0001 0000 */ 82 #define CAB_P_SKIP 0x16 /* 0001 x11x */ 83 #define CAB_B_SKIP 0x14 /* 0001 x100 */ 84 #define CAB_BD16x16_MASK 0x07 /* 0000 0111 */ 85 #define CAB_INTRA_MASK 0x04 /* 0000 0100 */ 86 #define CAB_I_PCM 0x20 /* 001x xxxx */ 87 88 /** 89 ****************************************************************************** 90 * @enum ctxBlockCat 91 ****************************************************************************** 92 */ 93 typedef enum 94 { 95 LUMA_DC_CTXCAT = 0, 96 LUMA_AC_CTXCAT = 1, 97 LUMA_4X4_CTXCAT = 2, 98 CHROMA_DC_CTXCAT = 3, 99 CHROMA_AC_CTXCAT = 4, 100 LUMA_8X8_CTXCAT = 5, 101 NUM_CTX_CAT = 6 102 } CTX_BLOCK_CAT; 103 104 105 /** 106 ****************************************************************************** 107 * @enum ctxIdxOffset 108 ****************************************************************************** 109 */ 110 typedef enum 111 { 112 MB_TYPE_SI_SLICE = 0, 113 MB_TYPE_I_SLICE = 3, 114 MB_SKIP_FLAG_P_SLICE = 11, 115 MB_TYPE_P_SLICE = 14, 116 SUB_MB_TYPE_P_SLICE = 21, 117 MB_SKIP_FLAG_B_SLICE = 24, 118 MB_TYPE_B_SLICE = 27, 119 SUB_MB_TYPE_B_SLICE = 36, 120 MVD_X = 40, 121 MVD_Y = 47, 122 REF_IDX = 54, 123 MB_QP_DELTA = 60, 124 INTRA_CHROMA_PRED_MODE = 64, 125 PREV_INTRA4X4_PRED_MODE_FLAG = 68, 126 REM_INTRA4X4_PRED_MODE = 69, 127 MB_FIELD_DECODING_FLAG = 70, 128 CBP_LUMA = 73, 129 CBP_CHROMA = 77, 130 CBF = 85, 131 SIGNIFICANT_COEFF_FLAG_FRAME = 105, 132 SIGNIFICANT_COEFF_FLAG_FLD = 277, 133 LAST_SIGNIFICANT_COEFF_FLAG_FRAME = 166, 134 LAST_SIGNIFICANT_COEFF_FLAG_FLD = 338, 135 COEFF_ABS_LEVEL_MINUS1 = 227, 136 137 /* High profile related Syntax element CABAC offsets */ 138 TRANSFORM_SIZE_8X8_FLAG = 399, 139 SIGNIFICANT_COEFF_FLAG_8X8_FRAME = 402, 140 LAST_SIGNIFICANT_COEFF_FLAG_8X8_FRAME = 417, 141 COEFF_ABS_LEVEL_MINUS1_8X8 = 426, 142 SIGNIFICANT_COEFF_FLAG_8X8_FIELD = 436, 143 LAST_SIGNIFICANT_COEFF_FLAG_8X8_FIELD = 451, 144 145 /* SVC related CABAC offsets */ 146 BASE_MODE_FLAG = 460, 147 MOTION_PREDICTION_FLAG_L0 = 463, 148 MOTION_PREDICTION_FLAG_L1 = 464, 149 RESIDUAL_PREDICTION_FLAG = 465, 150 151 } cabac_table_num_t; 152 153 154 /** 155 ****************************************************************************** 156 * @enum ctxIdxOffset 157 ****************************************************************************** 158 */ 159 typedef enum 160 { 161 SIG_COEFF_CTXT_CAT_0_OFFSET = 0, 162 SIG_COEFF_CTXT_CAT_1_OFFSET = 15, 163 SIG_COEFF_CTXT_CAT_2_OFFSET = 29, 164 SIG_COEFF_CTXT_CAT_3_OFFSET = 44, 165 SIG_COEFF_CTXT_CAT_4_OFFSET = 47, 166 SIG_COEFF_CTXT_CAT_5_OFFSET = 0, 167 COEFF_ABS_LEVEL_CAT_0_OFFSET = 0, 168 COEFF_ABS_LEVEL_CAT_1_OFFSET = 10, 169 COEFF_ABS_LEVEL_CAT_2_OFFSET = 20, 170 COEFF_ABS_LEVEL_CAT_3_OFFSET = 30, 171 COEFF_ABS_LEVEL_CAT_4_OFFSET = 39, 172 COEFF_ABS_LEVEL_CAT_5_OFFSET = 0 173 } cabac_blk_cat_offset_t; 174 175 176 /*****************************************************************************/ 177 /* Global declarations */ 178 /*****************************************************************************/ 179 extern const UWORD32 gau4_ih264_cabac_table[128][4]; 180 extern const UWORD8 gau1_ih264_cabac_ctxt_init_table[NUM_CAB_INIT_IDC_PLUS_ONE][QP_RANGE][NUM_CABAC_CTXTS]; 181 182 #endif /* _IH264_CABAC_TABLES_H_ */ 183