[191] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file ContextTables.h |
---|
| 35 | \brief Defines constants and tables for SBAC |
---|
| 36 | \todo number of context models is not matched to actual use, should be fixed |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #ifndef __CONTEXTTABLES__ |
---|
| 40 | #define __CONTEXTTABLES__ |
---|
| 41 | |
---|
| 42 | //! \ingroup TLibCommon |
---|
| 43 | //! \{ |
---|
| 44 | #define FIX827 1 ///< Fix for issue #827: CABAC init tables |
---|
| 45 | #define FIX712 1 ///< Fix for issue #712: CABAC init tables |
---|
| 46 | |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | // Constants |
---|
| 49 | // ==================================================================================================================== |
---|
| 50 | |
---|
| 51 | #define MAX_NUM_CTX_MOD 512 ///< maximum number of supported contexts |
---|
| 52 | |
---|
| 53 | #define NUM_SPLIT_FLAG_CTX 3 ///< number of context models for split flag |
---|
| 54 | #define NUM_SKIP_FLAG_CTX 3 ///< number of context models for skip flag |
---|
| 55 | |
---|
| 56 | #define NUM_MERGE_FLAG_EXT_CTX 1 ///< number of context models for merge flag of merge extended |
---|
| 57 | #define NUM_MERGE_IDX_EXT_CTX 1 ///< number of context models for merge index of merge extended |
---|
| 58 | |
---|
| 59 | #define NUM_PART_SIZE_CTX 4 ///< number of context models for partition size |
---|
| 60 | #define NUM_CU_AMP_CTX 1 ///< number of context models for partition size (AMP) |
---|
| 61 | #define NUM_PRED_MODE_CTX 1 ///< number of context models for prediction mode |
---|
| 62 | |
---|
| 63 | #define NUM_ADI_CTX 1 ///< number of context models for intra prediction |
---|
| 64 | |
---|
| 65 | #define NUM_CHROMA_PRED_CTX 2 ///< number of context models for intra prediction (chroma) |
---|
| 66 | #define NUM_INTER_DIR_CTX 5 ///< number of context models for inter prediction direction |
---|
| 67 | #define NUM_MV_RES_CTX 2 ///< number of context models for motion vector difference |
---|
| 68 | |
---|
| 69 | #define NUM_REF_NO_CTX 2 ///< number of context models for reference index |
---|
| 70 | #define NUM_TRANS_SUBDIV_FLAG_CTX 3 ///< number of context models for transform subdivision flags |
---|
| 71 | #define NUM_QT_CBF_CTX 5 ///< number of context models for QT CBF |
---|
| 72 | #define NUM_QT_ROOT_CBF_CTX 1 ///< number of context models for QT ROOT CBF |
---|
| 73 | #define NUM_DELTA_QP_CTX 3 ///< number of context models for dQP |
---|
| 74 | |
---|
| 75 | #define NUM_SIG_CG_FLAG_CTX 2 ///< number of context models for MULTI_LEVEL_SIGNIFICANCE |
---|
| 76 | |
---|
| 77 | #define NUM_SIG_FLAG_CTX 42 ///< number of context models for sig flag |
---|
| 78 | #define NUM_SIG_FLAG_CTX_LUMA 27 ///< number of context models for luma sig flag |
---|
| 79 | #define NUM_SIG_FLAG_CTX_CHROMA 15 ///< number of context models for chroma sig flag |
---|
| 80 | |
---|
| 81 | #define NUM_CTX_LAST_FLAG_XY 15 ///< number of context models for last coefficient position |
---|
| 82 | |
---|
| 83 | #define NUM_ONE_FLAG_CTX 24 ///< number of context models for greater than 1 flag |
---|
| 84 | #define NUM_ONE_FLAG_CTX_LUMA 16 ///< number of context models for greater than 1 flag of luma |
---|
| 85 | #define NUM_ONE_FLAG_CTX_CHROMA 8 ///< number of context models for greater than 1 flag of chroma |
---|
| 86 | #define NUM_ABS_FLAG_CTX 6 ///< number of context models for greater than 2 flag |
---|
| 87 | #define NUM_ABS_FLAG_CTX_LUMA 4 ///< number of context models for greater than 2 flag of luma |
---|
| 88 | #define NUM_ABS_FLAG_CTX_CHROMA 2 ///< number of context models for greater than 2 flag of chroma |
---|
| 89 | |
---|
| 90 | #define NUM_MVP_IDX_CTX 2 ///< number of context models for MVP index |
---|
| 91 | |
---|
| 92 | #define NUM_SAO_MERGE_FLAG_CTX 1 ///< number of context models for SAO merge flags |
---|
| 93 | #define NUM_SAO_TYPE_IDX_CTX 1 ///< number of context models for SAO type index |
---|
| 94 | #if INTRA_BL |
---|
| 95 | #define NUM_INTRA_BL_PRED_CTX 3 |
---|
| 96 | #endif |
---|
| 97 | |
---|
| 98 | #define NUM_TRANSFORMSKIP_FLAG_CTX 1 ///< number of context models for transform skipping |
---|
| 99 | #define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX 1 |
---|
| 100 | #define CNU 154 ///< dummy initialization value for unused context models 'Context model Not Used' |
---|
| 101 | |
---|
| 102 | // ==================================================================================================================== |
---|
| 103 | // Tables |
---|
| 104 | // ==================================================================================================================== |
---|
| 105 | |
---|
| 106 | // initial probability for cu_transquant_bypass flag |
---|
| 107 | static const UChar |
---|
| 108 | INIT_CU_TRANSQUANT_BYPASS_FLAG[3][NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX] = |
---|
| 109 | { |
---|
| 110 | { 154 }, |
---|
| 111 | { 154 }, |
---|
| 112 | { 154 }, |
---|
| 113 | }; |
---|
| 114 | |
---|
| 115 | // initial probability for split flag |
---|
| 116 | static const UChar |
---|
| 117 | INIT_SPLIT_FLAG[3][NUM_SPLIT_FLAG_CTX] = |
---|
| 118 | { |
---|
| 119 | { 107, 139, 126, }, |
---|
| 120 | { 107, 139, 126, }, |
---|
| 121 | { 139, 141, 157, }, |
---|
| 122 | }; |
---|
| 123 | |
---|
| 124 | static const UChar |
---|
| 125 | INIT_SKIP_FLAG[3][NUM_SKIP_FLAG_CTX] = |
---|
| 126 | { |
---|
| 127 | { 197, 185, 201, }, |
---|
| 128 | { 197, 185, 201, }, |
---|
| 129 | { CNU, CNU, CNU, }, |
---|
| 130 | }; |
---|
| 131 | |
---|
| 132 | static const UChar |
---|
| 133 | INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] = |
---|
| 134 | { |
---|
| 135 | { 154, }, |
---|
| 136 | { 110, }, |
---|
| 137 | { CNU, }, |
---|
| 138 | }; |
---|
| 139 | |
---|
| 140 | static const UChar |
---|
| 141 | INIT_MERGE_IDX_EXT[3][NUM_MERGE_IDX_EXT_CTX] = |
---|
| 142 | { |
---|
| 143 | { 137, }, |
---|
| 144 | { 122, }, |
---|
| 145 | { CNU, }, |
---|
| 146 | }; |
---|
| 147 | |
---|
| 148 | static const UChar |
---|
| 149 | INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = |
---|
| 150 | { |
---|
| 151 | { 154, 139, CNU, CNU, }, |
---|
| 152 | { 154, 139, CNU, CNU, }, |
---|
| 153 | { 184, CNU, CNU, CNU, }, |
---|
| 154 | }; |
---|
| 155 | |
---|
| 156 | static const UChar |
---|
| 157 | INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = |
---|
| 158 | { |
---|
| 159 | { 154, }, |
---|
| 160 | { 154, }, |
---|
| 161 | { CNU, }, |
---|
| 162 | }; |
---|
| 163 | |
---|
| 164 | static const UChar |
---|
| 165 | INIT_PRED_MODE[3][NUM_PRED_MODE_CTX] = |
---|
| 166 | { |
---|
| 167 | { 134, }, |
---|
| 168 | { 149, }, |
---|
| 169 | { CNU, }, |
---|
| 170 | }; |
---|
| 171 | |
---|
| 172 | static const UChar |
---|
| 173 | INIT_INTRA_PRED_MODE[3][NUM_ADI_CTX] = |
---|
| 174 | { |
---|
| 175 | { 183, }, |
---|
| 176 | { 154, }, |
---|
| 177 | { 184, }, |
---|
| 178 | }; |
---|
| 179 | |
---|
| 180 | static const UChar |
---|
| 181 | INIT_CHROMA_PRED_MODE[3][NUM_CHROMA_PRED_CTX] = |
---|
| 182 | { |
---|
| 183 | { 152, 139, }, |
---|
| 184 | { 152, 139, }, |
---|
| 185 | { 63, 139, }, |
---|
| 186 | }; |
---|
| 187 | |
---|
| 188 | static const UChar |
---|
| 189 | INIT_INTER_DIR[3][NUM_INTER_DIR_CTX] = |
---|
| 190 | { |
---|
| 191 | { 95, 79, 63, 31, 31, }, |
---|
| 192 | { 95, 79, 63, 31, 31, }, |
---|
| 193 | { CNU, CNU, CNU, CNU, CNU, }, |
---|
| 194 | }; |
---|
| 195 | |
---|
| 196 | static const UChar |
---|
| 197 | INIT_MVD[3][NUM_MV_RES_CTX] = |
---|
| 198 | { |
---|
| 199 | { 169, 198, }, |
---|
| 200 | { 140, 198, }, |
---|
| 201 | { CNU, CNU, }, |
---|
| 202 | }; |
---|
| 203 | |
---|
| 204 | static const UChar |
---|
| 205 | INIT_REF_PIC[3][NUM_REF_NO_CTX] = |
---|
| 206 | { |
---|
| 207 | { 153, 153 }, |
---|
| 208 | { 153, 153 }, |
---|
| 209 | { CNU, CNU }, |
---|
| 210 | }; |
---|
| 211 | |
---|
| 212 | static const UChar |
---|
| 213 | INIT_DQP[3][NUM_DELTA_QP_CTX] = |
---|
| 214 | { |
---|
| 215 | { 154, 154, 154, }, |
---|
| 216 | { 154, 154, 154, }, |
---|
| 217 | { 154, 154, 154, }, |
---|
| 218 | }; |
---|
| 219 | |
---|
| 220 | static const UChar |
---|
| 221 | INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = |
---|
| 222 | { |
---|
| 223 | { 153, 111, CNU, CNU, CNU, 149, 92, 167, CNU, CNU, }, |
---|
| 224 | { 153, 111, CNU, CNU, CNU, 149, 107, 167, CNU, CNU, }, |
---|
| 225 | { 111, 141, CNU, CNU, CNU, 94, 138, 182, CNU, CNU, }, |
---|
| 226 | }; |
---|
| 227 | |
---|
| 228 | static const UChar |
---|
| 229 | INIT_QT_ROOT_CBF[3][NUM_QT_ROOT_CBF_CTX] = |
---|
| 230 | { |
---|
| 231 | { 79, }, |
---|
| 232 | { 79, }, |
---|
| 233 | { CNU, }, |
---|
| 234 | }; |
---|
| 235 | |
---|
| 236 | static const UChar |
---|
| 237 | INIT_LAST[3][2*NUM_CTX_LAST_FLAG_XY] = |
---|
| 238 | { |
---|
| 239 | { 125, 110, 124, 110, 95, 94, 125, 111, 111, 79, 125, 126, 111, 111, 79, |
---|
| 240 | 108, 123, 93, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
| 241 | }, |
---|
| 242 | { 125, 110, 94, 110, 95, 79, 125, 111, 110, 78, 110, 111, 111, 95, 94, |
---|
| 243 | 108, 123, 108, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
| 244 | }, |
---|
| 245 | { 110, 110, 124, 125, 140, 153, 125, 127, 140, 109, 111, 143, 127, 111, 79, |
---|
| 246 | 108, 123, 63, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
| 247 | }, |
---|
| 248 | }; |
---|
| 249 | |
---|
| 250 | static const UChar |
---|
| 251 | INIT_SIG_CG_FLAG[3][2 * NUM_SIG_CG_FLAG_CTX] = |
---|
| 252 | { |
---|
| 253 | { 121, 140, |
---|
| 254 | 61, 154, |
---|
| 255 | }, |
---|
| 256 | { 121, 140, |
---|
| 257 | 61, 154, |
---|
| 258 | }, |
---|
| 259 | { 91, 171, |
---|
| 260 | 134, 141, |
---|
| 261 | }, |
---|
| 262 | }; |
---|
| 263 | |
---|
| 264 | static const UChar |
---|
| 265 | INIT_SIG_FLAG[3][NUM_SIG_FLAG_CTX] = |
---|
| 266 | { |
---|
| 267 | { 170, 154, 139, 153, 139, 123, 123, 63, 124, 166, 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 170, 153, 138, 138, 122, 121, 122, 121, 167, 151, 183, 140, 151, 183, 140, }, |
---|
| 268 | { 155, 154, 139, 153, 139, 123, 123, 63, 153, 166, 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 166, 183, 140, 136, 153, 154, 170, 153, 123, 123, 107, 121, 107, 121, 167, 151, 183, 140, 151, 183, 140, }, |
---|
| 269 | { 111, 111, 125, 110, 110, 94, 124, 108, 124, 107, 125, 141, 179, 153, 125, 107, 125, 141, 179, 153, 125, 107, 125, 141, 179, 153, 125, 140, 139, 182, 182, 152, 136, 152, 136, 153, 136, 139, 111, 136, 139, 111, }, |
---|
| 270 | }; |
---|
| 271 | |
---|
| 272 | static const UChar |
---|
| 273 | INIT_ONE_FLAG[3][NUM_ONE_FLAG_CTX] = |
---|
| 274 | { |
---|
| 275 | { 154, 196, 167, 167, 154, 152, 167, 182, 182, 134, 149, 136, 153, 121, 136, 122, 169, 208, 166, 167, 154, 152, 167, 182, }, |
---|
| 276 | { 154, 196, 196, 167, 154, 152, 167, 182, 182, 134, 149, 136, 153, 121, 136, 137, 169, 194, 166, 167, 154, 167, 137, 182, }, |
---|
| 277 | { 140, 92, 137, 138, 140, 152, 138, 139, 153, 74, 149, 92, 139, 107, 122, 152, 140, 179, 166, 182, 140, 227, 122, 197, }, |
---|
| 278 | }; |
---|
| 279 | |
---|
| 280 | static const UChar |
---|
| 281 | INIT_ABS_FLAG[3][NUM_ABS_FLAG_CTX] = |
---|
| 282 | { |
---|
| 283 | { 107, 167, 91, 107, 107, 167, }, |
---|
| 284 | { 107, 167, 91, 122, 107, 167, }, |
---|
| 285 | { 138, 153, 136, 167, 152, 152, }, |
---|
| 286 | }; |
---|
| 287 | |
---|
| 288 | static const UChar |
---|
| 289 | INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = |
---|
| 290 | { |
---|
| 291 | { 168, CNU, }, |
---|
| 292 | { 168, CNU, }, |
---|
| 293 | { CNU, CNU, }, |
---|
| 294 | }; |
---|
| 295 | |
---|
| 296 | static const UChar |
---|
| 297 | INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = |
---|
| 298 | { |
---|
| 299 | { 153, }, |
---|
| 300 | { 153, }, |
---|
| 301 | { 153, }, |
---|
| 302 | }; |
---|
| 303 | |
---|
| 304 | static const UChar |
---|
| 305 | INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = |
---|
| 306 | { |
---|
| 307 | #if FIX827 |
---|
| 308 | { 160, }, |
---|
| 309 | { 185, }, |
---|
| 310 | { 200, }, |
---|
| 311 | #else |
---|
| 312 | { 200, }, |
---|
| 313 | { 185, }, |
---|
| 314 | { 160, }, |
---|
| 315 | #endif |
---|
| 316 | }; |
---|
| 317 | |
---|
| 318 | static const UChar |
---|
| 319 | INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] = |
---|
| 320 | { |
---|
| 321 | #if FIX712 |
---|
| 322 | { 224, 167, 122, }, |
---|
| 323 | { 124, 138, 94, }, |
---|
| 324 | { 153, 138, 138, }, |
---|
| 325 | #else |
---|
| 326 | { 153, 138, 138, }, |
---|
| 327 | { 124, 138, 94, }, |
---|
| 328 | { 224, 167, 122, }, |
---|
| 329 | #endif |
---|
| 330 | }; |
---|
| 331 | |
---|
| 332 | #if INTRA_BL |
---|
| 333 | static const UChar |
---|
| 334 | INIT_INTRA_BL_PRED_FLAG[3][NUM_INTRA_BL_PRED_CTX] = |
---|
| 335 | { |
---|
| 336 | { 185, 185, 201, }, |
---|
| 337 | { 197, 197, 185, }, |
---|
| 338 | { 197, 197, 185, }, |
---|
| 339 | }; |
---|
| 340 | #endif |
---|
| 341 | static const UChar |
---|
| 342 | INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = |
---|
| 343 | { |
---|
| 344 | { 139, 139}, |
---|
| 345 | { 139, 139}, |
---|
| 346 | { 139, 139}, |
---|
| 347 | }; |
---|
| 348 | //! \} |
---|
| 349 | |
---|
| 350 | |
---|
| 351 | #endif |
---|