Home | History | Annotate | Download | only in common
      1 /******************************************************************************
      2 *
      3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
      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 
     19 /**
     20 ******************************************************************************
     21 * @file ihevc_cabac_tables.h
     22 *
     23 * @brief
     24 *  This file contains enumerations, macros and extern declarations of HEVC
     25 *  cabac tables
     26 *
     27 * @author
     28 *  Ittiam
     29 ******************************************************************************
     30 */
     31 
     32 #ifndef _IHEVC_CABAC_TABLES_H_
     33 #define _IHEVC_CABAC_TABLES_H_
     34 
     35 /*****************************************************************************/
     36 /* Constant Macros                                                           */
     37 /*****************************************************************************/
     38 
     39 /**
     40 ******************************************************************************
     41  *  @brief  maximum range of cabac_init_idc (0-2)
     42 ******************************************************************************
     43  */
     44 #define IHEVC_NUM_CAB_IDC   3
     45 
     46 /**
     47 ******************************************************************************
     48  *  @brief  max range of qps in HEVC (0-51)
     49 ******************************************************************************
     50  */
     51 #define IHEVC_MAX_QP      52
     52 
     53 
     54 /*****************************************************************************/
     55 /* Enums                                                                     */
     56 /*****************************************************************************/
     57 
     58 /**
     59  *****************************************************************************
     60  *  @brief   start offsets of cabac contexts for various syntax elements
     61  *
     62  *  @remarks Init ContextModel generation and these offsets are tightly coupled
     63              See the cabac table generation utility for these offsets
     64  *****************************************************************************
     65  */
     66 typedef enum
     67 {
     68     IHEVC_CAB_SAO_MERGE             = 0,
     69     IHEVC_CAB_SAO_TYPE              = IHEVC_CAB_SAO_MERGE               + 1,
     70     IHEVC_CAB_SPLIT_CU_FLAG         = IHEVC_CAB_SAO_TYPE                + 1,
     71     IHEVC_CAB_CU_TQ_BYPASS_FLAG     = IHEVC_CAB_SPLIT_CU_FLAG           + 3,
     72     IHEVC_CAB_SKIP_FLAG             = IHEVC_CAB_CU_TQ_BYPASS_FLAG       + 1,
     73     IHEVC_CAB_QP_DELTA_ABS          = IHEVC_CAB_SKIP_FLAG               + 3,
     74     IHEVC_CAB_PRED_MODE             = IHEVC_CAB_QP_DELTA_ABS            + 2,
     75     IHEVC_CAB_PART_MODE             = IHEVC_CAB_PRED_MODE               + 1,
     76     IHEVC_CAB_INTRA_LUMA_PRED_FLAG  = IHEVC_CAB_PART_MODE               + 4,
     77     IHEVC_CAB_CHROMA_PRED_MODE      = IHEVC_CAB_INTRA_LUMA_PRED_FLAG    + 1,
     78     IHEVC_CAB_MERGE_FLAG_EXT        = IHEVC_CAB_CHROMA_PRED_MODE        + 1,
     79     IHEVC_CAB_MERGE_IDX_EXT         = IHEVC_CAB_MERGE_FLAG_EXT          + 1,
     80     IHEVC_CAB_INTER_PRED_IDC        = IHEVC_CAB_MERGE_IDX_EXT           + 1,
     81     IHEVC_CAB_INTER_REF_IDX         = IHEVC_CAB_INTER_PRED_IDC          + 5,
     82     IHEVC_CAB_MVD_GRT0              = IHEVC_CAB_INTER_REF_IDX           + 2,
     83     IHEVC_CAB_MVD_GRT1              = IHEVC_CAB_MVD_GRT0                + 1,
     84     IHEVC_CAB_MVP_L0L1              = IHEVC_CAB_MVD_GRT1                + 1,
     85     IHEVC_CAB_NORES_IDX             = IHEVC_CAB_MVP_L0L1                + 1,
     86     IHEVC_CAB_SPLIT_TFM             = IHEVC_CAB_NORES_IDX               + 1,
     87     IHEVC_CAB_CBF_LUMA_IDX          = IHEVC_CAB_SPLIT_TFM               + 3,
     88     IHEVC_CAB_CBCR_IDX              = IHEVC_CAB_CBF_LUMA_IDX            + 2,
     89     IHEVC_CAB_TFM_SKIP0             = IHEVC_CAB_CBCR_IDX                + 4,
     90     IHEVC_CAB_TFM_SKIP12            = IHEVC_CAB_TFM_SKIP0               + 1,
     91     IHEVC_CAB_COEFFX_PREFIX         = IHEVC_CAB_TFM_SKIP12              + 1,
     92     IHEVC_CAB_COEFFY_PREFIX         = IHEVC_CAB_COEFFX_PREFIX           + 18,
     93     IHEVC_CAB_CODED_SUBLK_IDX       = IHEVC_CAB_COEFFY_PREFIX           + 18,
     94     IHEVC_CAB_COEFF_FLAG            = IHEVC_CAB_CODED_SUBLK_IDX         + 4,
     95     IHEVC_CAB_COEFABS_GRTR1_FLAG    = IHEVC_CAB_COEFF_FLAG              + 42,
     96     IHEVC_CAB_COEFABS_GRTR2_FLAG    = IHEVC_CAB_COEFABS_GRTR1_FLAG      + 24,
     97     IHEVC_CAB_CTXT_END              = IHEVC_CAB_COEFABS_GRTR2_FLAG      + 6
     98 }IHEVC_CABAC_CTXT_OFFSETS;
     99 
    100 
    101 /*****************************************************************************/
    102 /* Extern global declarations                                                */
    103 /*****************************************************************************/
    104 
    105 /**
    106  ******************************************************************************
    107  * @brief  Table for rangeTabLPS depending on pStateIdx and qCodIRangeIdx
    108  * input   : pStateIdx(0-63) and qCodIRangeIdx(0-3) [(Range >> 6) & 0x3]
    109  * output  : RLps
    110  *
    111  * @remarks See Table 9-40 of HEVC spec for rangeTabLPS
    112  *******************************************************************************
    113  */
    114 extern const UWORD8 gau1_ihevc_cabac_rlps[64][4];
    115 
    116 
    117 /**
    118  ******************************************************************************
    119  * @brief  probaility+MPS state transition tables based on cur State and bin
    120  * input  : curpState[bits7-2]  | curMPS[bit1] | decodedBin[bit0]
    121  * output : nextpState[bits6-1] | nextMPS[bit0]
    122  * @remarks Modified form of Table-9-41 State Transition table in HEVC spec
    123  ******************************************************************************
    124  */
    125 extern const UWORD8 gau1_ihevc_next_state[128*2];
    126 
    127 /**
    128  ******************************************************************************
    129  * @brief  Init context tables for all combinations of qp and cabac_init_idc
    130  * @remarks Packing format MPS in lsb and pState in bits[1-6]
    131  ******************************************************************************
    132  */
    133 extern const UWORD8 gau1_ihevc_cab_ctxts[IHEVC_NUM_CAB_IDC][IHEVC_MAX_QP][IHEVC_CAB_CTXT_END];
    134 
    135 
    136 
    137 #endif /* _IHEVC_CABAC_TABLES_H_ */
    138