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