Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecSbac.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibDecoder/TDecSbac.cpp
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 37 37 38 38 #include "TDecSbac.h" 39 #include "TLibCommon/TComTU.h" 40 #include "TLibCommon/TComTrQuant.h" 41 42 #if RExt__DECODER_DEBUG_BIT_STATISTICS 43 #include "TLibCommon/TComCodingStatistics.h" 44 // 45 #define RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(a) , a 46 #else 47 #define RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(a) 48 #endif 39 49 40 50 //! \ingroup TLibDecoder 41 51 //! \{ 52 53 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 54 #include "../TLibCommon/Debug.h" 55 #endif 56 42 57 43 58 ////////////////////////////////////////////////////////////////////// … … 45 60 ////////////////////////////////////////////////////////////////////// 46 61 47 TDecSbac::TDecSbac() 62 TDecSbac::TDecSbac() 48 63 // new structure here 49 : m_pcBitstream ( 0 )50 , m_pcTDecBinIf ( NULL )51 , m_numContextModels ( 0 )52 , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels)53 , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)54 #if H_3D55 , m_cCUDISFlagSCModel ( 1, 1, NUM_DIS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)56 , m_cCUDISTypeSCModel ( 1, 1, NUM_DIS_TYPE_CTX, m_contextModels + m_numContextModels, m_numContextModels)57 #endif 58 , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX, m_contextModels + m_numContextModels, m_numContextModels)59 , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX, m_contextModels + m_numContextModels, m_numContextModels)60 #if H_3D_ARP64 : m_pcBitstream ( 0 ) 65 , m_pcTDecBinIf ( NULL ) 66 , m_numContextModels ( 0 ) 67 , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 68 , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 69 #if NH_3D_DIS 70 , m_cCUDISFlagSCModel ( 1, 1, NUM_DIS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 71 , m_cCUDISTypeSCModel ( 1, 1, NUM_DIS_TYPE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 72 #endif 73 , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 74 , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 75 #if NH_3D_ARP 61 76 , m_cCUPUARPWSCModel ( 1, 1, NUM_ARPW_CTX , m_contextModels + m_numContextModels, m_numContextModels) 62 77 #endif 63 #if H_3D_IC78 #if NH_3D_IC 64 79 , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 65 80 #endif 66 , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 67 , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 68 , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) 69 , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) 70 , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 71 , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) 72 , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) 73 , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) 74 , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) 75 , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 76 , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) 77 , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 78 , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 79 , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 80 , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 81 , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 83 , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 84 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 85 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 86 , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 87 , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) 88 #if H_3D_DIM 89 , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 90 , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 91 , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 92 , m_cAngleFlagSCModel ( 1, 1, NUM_ANGLE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 93 #if H_3D_DIM_SDC 94 , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 95 , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) 96 #endif 97 #endif 98 #if H_3D_DIM_SDC 99 , m_cSDCFlagSCModel ( 1, 1, NUM_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 100 #endif 101 #if H_3D_DBBP 102 , m_cDBBPFlagSCModel ( 1, 1, DBBP_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 103 #endif 81 , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 83 , m_cCUIntraPredSCModel ( 1, 1, NUM_INTRA_PREDICT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 84 , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) 85 , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 86 , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) 87 , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) 88 , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) 89 , m_cCUQtCbfSCModel ( 1, NUM_QT_CBF_CTX_SETS, NUM_QT_CBF_CTX_PER_SET , m_contextModels + m_numContextModels, m_numContextModels) 90 , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 91 , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) 92 , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 93 , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 94 , m_cCuCtxLastX ( 1, NUM_CTX_LAST_FLAG_SETS, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 95 , m_cCuCtxLastY ( 1, NUM_CTX_LAST_FLAG_SETS, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 96 , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 97 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 98 , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 99 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 100 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 101 , m_cTransformSkipSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 102 , m_CUTransquantBypassFlagSCModel ( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 103 , m_explicitRdpcmFlagSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_EXPLICIT_RDPCM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 104 , m_explicitRdpcmDirSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_EXPLICIT_RDPCM_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) 105 , m_cCrossComponentPredictionSCModel ( 1, 1, NUM_CROSS_COMPONENT_PREDICTION_CTX , m_contextModels + m_numContextModels, m_numContextModels) 106 , m_ChromaQpAdjFlagSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 107 , m_ChromaQpAdjIdcSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_IDC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 108 109 #if NH_3D_DMM 110 , m_cNotDmmFlagSCModel ( 1, 1, NUM_NOTDMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 111 , m_cDmmModeSCModel ( 1, 1, NUM_DMM_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 112 #endif 113 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER 114 , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 115 , m_cSDCFlagSCModel ( 1, 1, NUM_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 116 #endif 117 #if NH_3D_SDC_INTRA 118 , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 119 , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) 120 , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 121 #endif 122 #if NH_3D_DBBP 123 , m_cDBBPFlagSCModel ( 1, 1, DBBP_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 124 #endif 125 104 126 { 105 127 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 124 146 { 125 147 case P_SLICE: // change initialization table to B_SLICE initialization 126 sliceType = B_SLICE; 148 sliceType = B_SLICE; 127 149 break; 128 150 case B_SLICE: // change initialization table to P_SLICE initialization 129 sliceType = P_SLICE; 151 sliceType = P_SLICE; 130 152 break; 131 153 default : // should not occur 132 154 assert(0); 133 } 134 } 135 136 m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); 137 m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); 138 #if H_3D 139 m_cCUDISFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DIS_FLAG ); 140 m_cCUDISTypeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DIS_TYPE ); 141 #endif 142 m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); 143 m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); 144 #if H_3D_ARP 155 break; 156 } 157 } 158 159 m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); 160 m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); 161 #if NH_3D_DIS 162 m_cCUDISFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DIS_FLAG ); 163 m_cCUDISTypeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DIS_TYPE ); 164 #endif 165 m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); 166 m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); 167 #if NH_3D_ARP 145 168 m_cCUPUARPWSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ARPW ); 146 169 #endif 147 #if H_3D_IC170 #if NH_3D_IC 148 171 m_cCUICFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_IC_FLAG ); 149 172 #endif 150 m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); 151 m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); 152 m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); 153 m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); 154 m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); 155 m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); 156 m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); 157 m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); 158 m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); 159 m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); 160 m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); 161 m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); 162 m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 163 m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 164 m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); 165 m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); 166 m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); 167 m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); 168 m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 169 170 m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 171 m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 172 m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 173 #if H_3D_DIM 174 m_cDepthIntraModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); 175 m_cDdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_FLAG ); 176 m_cDdcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_DATA ); 177 m_cAngleFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ANGLE_FLAG ); 178 #if H_3D_DIM_SDC 179 m_cSDCResidualFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); 180 m_cSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL ); 181 #endif 182 #endif 183 #if H_3D_DIM_SDC 184 m_cSDCFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_FLAG ); 185 #endif 186 #if H_3D_DBBP 187 m_cDBBPFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DBBP_FLAG ); 188 #endif 189 m_uiLastDQpNonZero = 0; 190 191 // new structure 192 m_uiLastQp = qp; 193 173 m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); 174 m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); 175 m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); 176 m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); 177 m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); 178 m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); 179 m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); 180 m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); 181 m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); 182 m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); 183 m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); 184 m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); 185 m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 186 m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 187 m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); 188 m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); 189 m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); 190 m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); 191 m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 192 m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 193 m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 194 m_CUTransquantBypassFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 195 m_explicitRdpcmFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EXPLICIT_RDPCM_FLAG); 196 m_explicitRdpcmDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EXPLICIT_RDPCM_DIR); 197 m_cCrossComponentPredictionSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CROSS_COMPONENT_PREDICTION ); 198 m_ChromaQpAdjFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG ); 199 m_ChromaQpAdjIdcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_IDC ); 200 #if NH_3D_DMM 201 m_cNotDmmFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_NOTDMM_FLAG ); 202 m_cDmmModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_MODE ); 203 #endif 204 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER 205 m_cDdcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_DATA ); 206 m_cSDCFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_FLAG ); 207 #endif 208 #if NH_3D_SDC_INTRA 209 m_cSDCResidualFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); 210 m_cSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL ); 211 m_cDdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_FLAG ); 212 #endif 213 #if NH_3D_DBBP 214 m_cDBBPFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DBBP_FLAG ); 215 #endif 216 217 for (UInt statisticIndex = 0; statisticIndex < RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS ; statisticIndex++) 218 { 219 m_golombRiceAdaptationStatistics[statisticIndex] = 0; 220 } 221 194 222 m_pcTDecBinIf->start(); 195 223 } 196 224 197 /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile.198 * Intialize CABAC states. Start CABAC.199 */200 Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp )201 {202 UInt uiBit;203 m_pcTDecBinIf->decodeBinTrm(uiBit);204 assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1205 m_pcTDecBinIf->finish();206 m_pcBitstream->readOutTrailingBits();207 m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );208 m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );209 #if H_3D210 m_cCUDISFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DIS_FLAG );211 m_cCUDISTypeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );212 #endif213 m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT );214 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );215 #if H_3D_ARP216 m_cCUPUARPWSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ARPW );217 #endif218 #if H_3D_IC219 m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );220 #endif221 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );222 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );223 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );224 m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE );225 m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR );226 m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD );227 m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC );228 m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP );229 m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF );230 m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF );231 m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG );232 m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG );233 m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST );234 m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST );235 m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG );236 m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG );237 m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX );238 m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );239 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );240 m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );241 m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );242 m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );243 244 #if H_3D_DIM245 m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );246 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );247 m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );248 m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );249 #if H_3D_DIM_SDC250 m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );251 m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );252 #endif253 #endif254 #if H_3D_DIM_SDC255 m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );256 #endif257 #if H_3D_DBBP258 m_cDBBPFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );259 #endif260 m_pcTDecBinIf->start();261 }262 263 225 Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) 264 226 { 265 227 m_pcTDecBinIf->decodeBinTrm( ruiBit ); 266 if ( ruiBit )228 if ( ruiBit == 1 ) 267 229 { 268 230 m_pcTDecBinIf->finish(); 269 } 270 } 271 272 231 232 #if RExt__DECODER_DEBUG_BIT_STATISTICS 233 TComCodingStatistics::IncrementStatisticEP(STATS__TRAILING_BITS, m_pcBitstream->readOutTrailingBits(),0); 234 #else 235 m_pcBitstream->readOutTrailingBits(); 236 #endif 237 } 238 } 239 240 241 242 Void TDecSbac::parseRemainingBytes( Bool noTrailingBytesExpected ) 243 { 244 if (noTrailingBytesExpected) 245 { 246 const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); 247 assert (numberOfRemainingSubstreamBytes == 0); 248 } 249 else 250 { 251 while (m_pcBitstream->getNumBitsLeft()) 252 { 253 UInt trailingNullByte=m_pcBitstream->readByte(); 254 if (trailingNullByte!=0) 255 { 256 printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); 257 assert(trailingNullByte==0); 258 } 259 } 260 } 261 } 262 263 #if RExt__DECODER_DEBUG_BIT_STATISTICS 264 Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol, const class TComCodingStatisticsClassType &whichStat ) 265 #else 273 266 Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) 267 #endif 274 268 { 275 269 if (uiMaxSymbol == 0) … … 278 272 return; 279 273 } 280 281 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] );282 274 275 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 276 283 277 if( ruiSymbol == 0 || uiMaxSymbol == 1 ) 284 278 { 285 279 return; 286 280 } 287 281 288 282 UInt uiSymbol = 0; 289 283 UInt uiCont; 290 284 291 285 do 292 286 { 293 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] );287 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 294 288 uiSymbol++; 295 } 296 while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); 297 289 } while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); 290 298 291 if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) 299 292 { 300 293 uiSymbol++; 301 294 } 302 295 303 296 ruiSymbol = uiSymbol; 304 297 } 305 298 299 #if RExt__DECODER_DEBUG_BIT_STATISTICS 300 Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount, const class TComCodingStatisticsClassType &whichStat ) 301 #else 306 302 Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) 303 #endif 307 304 { 308 305 UInt uiSymbol = 0; 309 306 UInt uiBit = 1; 310 307 311 308 while( uiBit ) 312 309 { 313 m_pcTDecBinIf->decodeBinEP( uiBit );310 m_pcTDecBinIf->decodeBinEP( uiBit RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 314 311 uiSymbol += uiBit << uiCount++; 315 312 } 316 313 317 314 if ( --uiCount ) 318 315 { 319 316 UInt bins; 320 m_pcTDecBinIf->decodeBinsEP( bins, uiCount );317 m_pcTDecBinIf->decodeBinsEP( bins, uiCount RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 321 318 uiSymbol += bins; 322 319 } 323 320 324 321 ruiSymbol = uiSymbol; 325 322 } 326 323 324 #if RExt__DECODER_DEBUG_BIT_STATISTICS 325 Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, const class TComCodingStatisticsClassType &whichStat ) 326 #else 327 327 Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) 328 { 329 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); 330 328 #endif 329 { 330 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 331 331 332 if( !ruiSymbol ) 332 333 { 333 334 return; 334 335 } 335 336 336 337 UInt uiSymbol = 0; 337 338 UInt uiCont; 338 339 339 340 do 340 341 { 341 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] );342 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 342 343 uiSymbol++; 343 } 344 while( uiCont ); 345 344 } while( uiCont ); 345 346 346 ruiSymbol = uiSymbol; 347 347 } … … 349 349 350 350 /** Parsing of coeff_abs_level_remaing 351 * \param ruiSymbol reference to coeff_abs_level_remaing 352 * \param ruiParam reference to parameter 353 * \returns Void 351 * \param rSymbol reference to coeff_abs_level_remaing 352 * \param rParam reference to parameter 353 * \param useLimitedPrefixLength 354 * \param maxLog2TrDynamicRange 354 355 */ 355 Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ) 356 { 357 356 #if RExt__DECODER_DEBUG_BIT_STATISTICS 357 Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const Int maxLog2TrDynamicRange, const class TComCodingStatisticsClassType &whichStat ) 358 #else 359 Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const Int maxLog2TrDynamicRange ) 360 #endif 361 { 358 362 UInt prefix = 0; 359 363 UInt codeWord = 0; 360 do 361 { 362 prefix++; 363 m_pcTDecBinIf->decodeBinEP( codeWord ); 364 } 365 while( codeWord); 364 365 if (useLimitedPrefixLength) 366 { 367 const UInt longestPossiblePrefix = (32 - (COEF_REMAIN_BIN_REDUCTION + maxLog2TrDynamicRange)) + COEF_REMAIN_BIN_REDUCTION; 368 369 do 370 { 371 prefix++; 372 m_pcTDecBinIf->decodeBinEP( codeWord RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 373 } while((codeWord != 0) && (prefix < longestPossiblePrefix)); 374 } 375 else 376 { 377 do 378 { 379 prefix++; 380 m_pcTDecBinIf->decodeBinEP( codeWord RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 381 } while( codeWord); 382 } 383 366 384 codeWord = 1 - codeWord; 367 385 prefix -= codeWord; 368 386 codeWord=0; 387 369 388 if (prefix < COEF_REMAIN_BIN_REDUCTION ) 370 389 { 371 m_pcTDecBinIf->decodeBinsEP(codeWord,rParam );390 m_pcTDecBinIf->decodeBinsEP(codeWord,rParam RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 372 391 rSymbol = (prefix<<rParam) + codeWord; 373 392 } 393 else if (useLimitedPrefixLength) 394 { 395 const UInt maximumPrefixLength = (32 - (COEF_REMAIN_BIN_REDUCTION + maxLog2TrDynamicRange)); 396 397 const UInt prefixLength = prefix - COEF_REMAIN_BIN_REDUCTION; 398 const UInt suffixLength = (prefixLength == maximumPrefixLength) ? (maxLog2TrDynamicRange - rParam) : prefixLength; 399 400 m_pcTDecBinIf->decodeBinsEP(codeWord, (suffixLength + rParam) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 401 402 rSymbol = codeWord + ((((1 << prefixLength) - 1) + COEF_REMAIN_BIN_REDUCTION) << rParam); 403 } 374 404 else 375 405 { 376 m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam );406 m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 377 407 rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; 378 408 } 379 409 } 380 410 381 #if H_3D_DIM 382 Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) 383 { 384 UInt uiSymbol; 385 UInt uiCount = 0; 386 do 387 { 388 m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); 389 uiCount++; 390 } 391 while( uiSymbol && ( uiCount != 3 ) ); 392 ruiSymbol = uiCount - 1; 393 394 if( uiSymbol ) 395 { 396 xReadEpExGolomb( uiSymbol, 0 ); 397 ruiSymbol += uiSymbol + 1; 398 } 399 400 return; 401 } 402 403 Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg ) 404 { 405 UInt absValDeltaDC = 0; 406 xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, 0) ); 407 rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 ); 408 409 if( rValDeltaDC != 0 ) 410 { 411 UInt uiSign; 412 m_pcTDecBinIf->decodeBinEP( uiSign ); 413 if ( uiSign ) 414 { 415 rValDeltaDC = -rValDeltaDC; 416 } 417 } 418 } 419 420 421 #if H_3D_DIM_DMM 422 Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit ) 423 { 424 UInt uiSymbol, uiIdx = 0; 425 for( Int i = 0; i < iNumBit; i++ ) 426 { 427 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 428 uiIdx += uiSymbol << i; 429 } 430 ruiTabIdx = uiIdx; 431 } 432 #endif 433 434 435 #endif 436 /** Parse I_PCM information. 411 /** Parse I_PCM information. 437 412 * \param pcCU 438 * \param uiAbsPartIdx 413 * \param uiAbsPartIdx 439 414 * \param uiDepth 440 415 * \returns Void 441 416 * 442 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 417 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 443 418 */ 444 419 Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) … … 451 426 DTRACE_CU("pcm_flag", uiSymbol) 452 427 #endif 453 if (uiSymbol) 428 429 430 if (uiSymbol == 1) 454 431 { 455 432 Bool bIpcmFlag = true; 433 const TComSPS &sps=*(pcCU->getSlice()->getSPS()); 456 434 457 435 pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); 458 pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );436 pcCU->setSizeSubParts ( sps.getMaxCUWidth()>>uiDepth, sps.getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth ); 459 437 pcCU->setTrIdxSubParts ( 0, uiAbsPartIdx, uiDepth ); 460 438 pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); 461 439 462 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 463 UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; 464 UInt uiChromaOffset = uiLumaOffset>>2; 465 466 Pel* piPCMSample; 467 UInt uiWidth; 468 UInt uiHeight; 469 UInt uiSampleBits; 470 UInt uiX, uiY; 471 472 piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; 473 uiWidth = pcCU->getWidth(uiAbsPartIdx); 474 uiHeight = pcCU->getHeight(uiAbsPartIdx); 475 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); 476 477 for(uiY = 0; uiY < uiHeight; uiY++) 478 { 479 for(uiX = 0; uiX < uiWidth; uiX++) 480 { 481 UInt uiSample; 482 m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); 483 piPCMSample[uiX] = uiSample; 484 } 485 piPCMSample += uiWidth; 486 } 487 #if H_3D_DISABLE_CHROMA 488 if( pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 ) 489 { 490 #endif 491 piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; 492 uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; 493 uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; 494 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 495 496 for(uiY = 0; uiY < uiHeight; uiY++) 497 { 498 for(uiX = 0; uiX < uiWidth; uiX++) 499 { 500 UInt uiSample; 501 m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); 502 piPCMSample[uiX] = uiSample; 503 } 504 piPCMSample += uiWidth; 505 } 506 507 piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; 508 uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; 509 uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; 510 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 511 512 for(uiY = 0; uiY < uiHeight; uiY++) 513 { 514 for(uiX = 0; uiX < uiWidth; uiX++) 515 { 516 UInt uiSample; 517 m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); 518 piPCMSample[uiX] = uiSample; 519 } 520 piPCMSample += uiWidth; 521 } 522 #if H_3D_DISABLE_CHROMA 523 } 524 #endif 440 const UInt minCoeffSizeY = pcCU->getPic()->getMinCUWidth() * pcCU->getPic()->getMinCUHeight(); 441 const UInt offsetY = minCoeffSizeY * uiAbsPartIdx; 442 for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) 443 { 444 const ComponentID compID = ComponentID(ch); 445 const UInt offset = offsetY >> (pcCU->getPic()->getComponentScaleX(compID) + pcCU->getPic()->getComponentScaleY(compID)); 446 Pel * pPCMSample = pcCU->getPCMSample(compID) + offset; 447 const UInt width = pcCU->getWidth (uiAbsPartIdx) >> pcCU->getPic()->getComponentScaleX(compID); 448 const UInt height = pcCU->getHeight(uiAbsPartIdx) >> pcCU->getPic()->getComponentScaleY(compID); 449 const UInt sampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); 450 for (UInt y=0; y<height; y++) 451 { 452 for (UInt x=0; x<width; x++) 453 { 454 UInt sample; 455 m_pcTDecBinIf->xReadPCMCode(sampleBits, sample); 456 pPCMSample[x] = sample; 457 } 458 pPCMSample += width; 459 } 460 } 525 461 m_pcTDecBinIf->start(); 526 462 } … … 530 466 { 531 467 UInt uiSymbol; 532 m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) );468 m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__TQ_BYPASS_FLAG) ); 533 469 #if H_MV_ENC_DEC_TRAC 534 470 DTRACE_CU("cu_transquant_bypass_flag", uiSymbol); 535 471 #endif 472 536 473 pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); 537 474 } … … 539 476 /** parse skip flag 540 477 * \param pcCU 541 * \param uiAbsPartIdx 478 * \param uiAbsPartIdx 542 479 * \param uiDepth 543 480 * \returns Void … … 549 486 return; 550 487 } 551 488 552 489 UInt uiSymbol = 0; 553 490 UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); 554 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) );491 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) ); 555 492 #if !H_MV_ENC_DEC_TRAC 556 493 DTRACE_CABAC_VL( g_nSymbolCounter++ ); … … 562 499 DTRACE_CABAC_T( "\n"); 563 500 #endif 564 565 501 if( uiSymbol ) 566 502 { … … 568 504 pcCU->setPredModeSubParts( MODE_INTER, uiAbsPartIdx, uiDepth ); 569 505 pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); 570 pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );506 pcCU->setSizeSubParts( pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth, pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth ); 571 507 pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); 572 508 } … … 574 510 DTRACE_CU("cu_skip_flag", uiSymbol); 575 511 #endif 576 } 577 #if H_3D 512 513 } 514 #if NH_3D_DIS 578 515 Void TDecSbac::parseDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 579 516 { 580 517 pcCU->setDISFlagSubParts( false, uiAbsPartIdx, uiDepth ); 581 518 UInt uiSymbol = 0; 582 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUDISFlagSCModel.get( 0, 0, 0 ) );519 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUDISFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) ); 583 520 if( uiSymbol ) 584 521 { … … 588 525 pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); 589 526 pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); 590 pcCU->set LumaIntraDirSubParts (DC_IDX, uiAbsPartIdx, uiDepth );591 pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );527 pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, DC_IDX, uiAbsPartIdx, uiDepth ); 528 pcCU->setSizeSubParts( pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth, pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth ); 592 529 pcCU->setMergeFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); 593 530 pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth); 594 pcCU->setCbfSubParts(0, 1, 1, uiAbsPartIdx, uiDepth);531 pcCU->setCbfSubParts(0, COMPONENT_Y, uiAbsPartIdx, uiDepth); 595 532 596 533 UInt uiUnaryIdx = 0; … … 604 541 if ( uiUnaryIdx==0 ) 605 542 { 606 m_pcTDecBinIf->decodeBin( uiSymbol2, m_cCUDISTypeSCModel.get( 0, 0, 0 ) );543 m_pcTDecBinIf->decodeBin( uiSymbol2, m_cCUDISTypeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) ); 607 544 } 608 545 else 609 546 { 610 m_pcTDecBinIf->decodeBinEP( uiSymbol2 );547 m_pcTDecBinIf->decodeBinEP( uiSymbol2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG)); 611 548 } 612 549 if( uiSymbol2 == 0 ) … … 616 553 } 617 554 } 618 pcCU->setDISTypeSubParts(uiUnaryIdx, uiAbsPartIdx, 0, uiDepth); 619 } 620 } 621 #endif 555 pcCU->setDISTypeSubParts((UChar)uiUnaryIdx, uiAbsPartIdx, uiDepth); 556 } 557 } 558 #endif 559 560 622 561 /** parse merge flag 623 562 * \param pcCU 624 * \param uiAbsPartIdx 563 * \param uiAbsPartIdx 625 564 * \param uiDepth 626 565 * \param uiPUIdx … … 630 569 { 631 570 UInt uiSymbol; 632 m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) );571 m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_FLAG) ); 633 572 #if H_MV_ENC_DEC_TRAC 634 573 DTRACE_PU("merge_flag", uiSymbol) 635 574 #endif 636 575 pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); 637 638 576 #if !H_MV_ENC_DEC_TRAC 639 577 DTRACE_CABAC_VL( g_nSymbolCounter++ ); … … 641 579 DTRACE_CABAC_V( uiSymbol ); 642 580 DTRACE_CABAC_T( "\tAddress: " ); 643 DTRACE_CABAC_V( pcCU->get Addr() );581 DTRACE_CABAC_V( pcCU->getCtuRsAddr() ); 644 582 DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); 645 583 DTRACE_CABAC_V( uiAbsPartIdx ); … … 659 597 if ( uiUnaryIdx==0 ) 660 598 { 661 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) );599 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_INDEX) ); 662 600 } 663 601 else 664 602 { 665 m_pcTDecBinIf->decodeBinEP( uiSymbol );603 m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_INDEX) ); 666 604 } 667 605 if( uiSymbol == 0 ) … … 688 626 { 689 627 UInt uiSymbol; 690 xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1 );628 xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVP_IDX) ); 691 629 riMVPIdx = uiSymbol; 692 630 } … … 694 632 Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 695 633 { 696 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth)634 if( uiDepth == pcCU->getSlice()->getSPS()->getLog2DiffMaxMinCodingBlockSize() ) 697 635 { 698 636 pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); 699 637 return; 700 638 } 639 #if RExt__DECODER_DEBUG_BIT_STATISTICS 640 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__SPLIT_FLAG, g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth]+2); 641 #endif 701 642 702 643 UInt uiSymbol; 703 #if H_3D_QTLPC644 #if NH_3D_QTLPC 704 645 Bool bParseSplitFlag = true; 705 646 Bool bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag(); … … 716 657 #endif 717 658 { 718 TComDataCU *pcTextureCU = pcTexture->getC U(pcCU->getAddr());659 TComDataCU *pcTextureCU = pcTexture->getCtu(pcCU->getCtuRsAddr()); 719 660 assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); 720 661 bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); … … 724 665 { 725 666 #endif 726 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth )) );667 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 727 668 #if H_MV_ENC_DEC_TRAC 728 669 DTRACE_CU("split_cu_flag", uiSymbol); 729 670 #else 730 731 732 #endif 733 #if H_3D_QTLPC671 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 672 DTRACE_CABAC_T( "\tSplitFlag\n" ) 673 #endif 674 #if NH_3D_QTLPC 734 675 } 735 676 else … … 745 686 /** parse partition size 746 687 * \param pcCU 747 * \param uiAbsPartIdx 688 * \param uiAbsPartIdx 748 689 * \param uiDepth 749 690 * \returns Void … … 753 694 UInt uiSymbol, uiMode = 0; 754 695 PartSize eMode; 755 756 #if H_3D_QTLPC 696 const UChar cuWidth =UChar(pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth); 697 const UChar cuHeight=UChar(pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth); 698 const Int log2DiffMaxMinCodingBlockSize = pcCU->getSlice()->getSPS()->getLog2DiffMaxMinCodingBlockSize(); 699 700 #if RExt__DECODER_DEBUG_BIT_STATISTICS 701 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__PART_SIZE, g_aucConvertToBit[cuWidth]+2); 702 #endif 703 704 assert ( pcCU->getSlice()->getSPS()->getLog2DiffMaxMinCodingBlockSize() == log2DiffMaxMinCodingBlockSize); 705 706 #if NH_3D_QTLPC 757 707 Bool bParsePartSize = true; 758 708 … … 773 723 #endif 774 724 { 775 TComDataCU *pcTextureCU = pcTexture->getC U(pcCU->getAddr());725 TComDataCU *pcTextureCU = pcTexture->getCtu(pcCU->getCtuRsAddr()); 776 726 assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); 777 727 if(pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth ) … … 788 738 #endif 789 739 790 791 740 if ( pcCU->isIntra( uiAbsPartIdx ) ) 792 741 { 793 #if H_3D_QTLPC742 #if NH_3D_QTLPC 794 743 if(bParsePartSize) 795 744 { 796 745 #endif 797 798 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth)799 800 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) );746 uiSymbol = 1; 747 if( uiDepth == log2DiffMaxMinCodingBlockSize ) 748 { 749 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 801 750 #if H_MV_ENC_DEC_TRAC 802 751 DTRACE_CU("part_mode", uiSymbol) 803 752 #endif 804 805 806 #if H_3D_QTLPC807 } 808 #endif 809 UInt uiTrLevel = 0; 753 } 754 eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; 755 #if NH_3D_QTLPC 756 } 757 #endif 758 UInt uiTrLevel = 0; 810 759 UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; 811 760 UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; … … 822 771 else 823 772 { 824 #if H_3D_QTLPC773 #if NH_3D_QTLPC 825 774 if(bParsePartSize) 826 775 { … … 828 777 { 829 778 #endif 830 UInt uiMaxNumBits = 2; 831 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) 779 UInt uiMaxNumBits = 2; 780 781 if( uiDepth == log2DiffMaxMinCodingBlockSize && !( cuWidth == 8 && cuHeight == 8 ) ) 782 { 783 uiMaxNumBits ++; 784 } 785 786 for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) 787 { 788 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 789 if ( uiSymbol ) 790 { 791 break; 792 } 793 uiMode++; 794 } 795 eMode = (PartSize) uiMode; 796 if ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) 797 { 798 if (eMode == SIZE_2NxN) 799 { 800 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 801 if (uiSymbol == 0) 802 { 803 m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 804 eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); 805 } 806 } 807 else if (eMode == SIZE_Nx2N) 808 { 809 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 810 if (uiSymbol == 0) 811 { 812 m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 813 eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); 814 } 815 } 816 } 817 #if NH_3D_QTLPC 818 } 819 else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD) 820 { 821 UInt uiMaxNumBits = 1; 822 if ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) 832 823 { 833 824 uiMaxNumBits ++; … … 835 826 for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) 836 827 { 837 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );828 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 838 829 if ( uiSymbol ) 839 830 { … … 843 834 } 844 835 eMode = (PartSize) uiMode; 845 if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) 846 { 847 if (eMode == SIZE_2NxN) 848 { 849 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 850 if (uiSymbol == 0) 851 { 852 m_pcTDecBinIf->decodeBinEP(uiSymbol); 853 eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); 854 } 855 } 856 else if (eMode == SIZE_Nx2N) 857 { 858 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 859 if (uiSymbol == 0) 860 { 861 m_pcTDecBinIf->decodeBinEP(uiSymbol); 862 eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); 863 } 864 } 865 } 866 #if H_3D_QTLPC 867 } 868 else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD) 836 if(uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==1 ) 837 { 838 eMode = SIZE_2NxN; 839 } 840 else if (uiMode && (( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize )==0) && uiSymbol==0) 841 { 842 eMode = SIZE_2NxN; 843 } 844 else if (uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==0) 845 { 846 m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 847 eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); 848 } 849 } 850 else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N) 869 851 { 870 852 UInt uiMaxNumBits = 1; 871 if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )853 if ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) 872 854 { 873 855 uiMaxNumBits ++; … … 875 857 for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) 876 858 { 877 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );859 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 878 860 if ( uiSymbol ) 879 861 { … … 883 865 } 884 866 eMode = (PartSize) uiMode; 885 if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 ) 886 { 887 eMode = SIZE_2NxN; 888 } 889 else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0 && uiSymbol==0) 890 { 891 eMode = SIZE_2NxN; 892 } 893 else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0) 894 { 895 m_pcTDecBinIf->decodeBinEP(uiSymbol); 896 eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); 897 } 898 } 899 else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N) 900 { 901 UInt uiMaxNumBits = 1; 902 if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) 903 { 904 uiMaxNumBits ++; 905 } 906 for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) 907 { 908 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); 909 if ( uiSymbol ) 910 { 911 break; 912 } 913 uiMode++; 914 } 915 eMode = (PartSize) uiMode; 916 if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 ) 867 if(uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==1 ) 917 868 { 918 869 eMode = SIZE_Nx2N; 919 870 } 920 else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0&& uiSymbol==0)871 else if (uiMode && (( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize )==0) && uiSymbol==0) 921 872 { 922 873 eMode = SIZE_Nx2N; 923 874 } 924 else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth) && uiSymbol==0)925 { 926 m_pcTDecBinIf->decodeBinEP(uiSymbol );875 else if (uiMode && ( ( pcCU->getSlice()->getSPS()->getUseAMP() && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiDepth < log2DiffMaxMinCodingBlockSize ) && uiSymbol==0) 876 { 877 m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 927 878 eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); 928 879 } … … 936 887 DTRACE_CU("part_mode", eMode ) 937 888 #endif 938 #if H_3D_QTLPC889 #if NH_3D_QTLPC 939 890 } 940 891 #endif 941 892 } 942 893 pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); 943 pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); 944 } 894 pcCU->setSizeSubParts( cuWidth, cuHeight, uiAbsPartIdx, uiDepth ); 895 } 896 945 897 946 898 /** parse prediction mode 947 899 * \param pcCU 948 * \param uiAbsPartIdx 900 * \param uiAbsPartIdx 949 901 * \param uiDepth 950 902 * \returns Void … … 957 909 return; 958 910 } 959 911 960 912 UInt uiSymbol; 961 913 Int iPredMode = MODE_INTER; 962 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) );914 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__PRED_MODE) ); 963 915 iPredMode += uiSymbol; 964 916 #if H_MV_ENC_DEC_TRAC … … 968 920 } 969 921 922 970 923 Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 971 924 { 972 925 PartSize mode = pcCU->getPartitionSize( absPartIdx ); 973 926 UInt partNum = mode==SIZE_NxN?4:1; 974 UInt partOffset = ( pcCU->getPic()->getNumPart InCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2;927 UInt partOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; 975 928 UInt mpmPred[4],symbol; 976 Int j,intraPredMode; 929 Int j,intraPredMode; 977 930 if (mode==SIZE_NxN) 978 931 { 979 932 depth++; 980 933 } 934 #if RExt__DECODER_DEBUG_BIT_STATISTICS 935 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__INTRA_DIR_ANG, g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()>>depth]+2, CHANNEL_TYPE_LUMA); 936 #endif 981 937 for (j=0;j<partNum;j++) 982 938 { 983 #if H_3D_DIM939 #if NH_3D_DMM 984 940 if( pcCU->getSlice()->getIntraSdcWedgeFlag() || pcCU->getSlice()->getIntraContourFlag() ) 985 941 { 986 parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth ); 987 } 988 if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 989 { 990 #endif 991 m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); 992 mpmPred[j] = symbol; 942 xParseIntraDepthMode( pcCU, absPartIdx+partOffset*j, depth ); 943 xParseDmmData ( pcCU, absPartIdx+partOffset*j, depth ); 944 } 945 if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 946 { 947 #endif 948 m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 949 mpmPred[j] = symbol; 993 950 #if H_MV_ENC_DEC_TRAC 994 951 DTRACE_CU("prev_intra_luma_pred_flag", symbol) 995 952 #endif 996 #if H_3D_DIM953 #if NH_3D_DMM 997 954 } 998 955 #endif … … 1000 957 for (j=0;j<partNum;j++) 1001 958 { 1002 #if H_3D_DIM1003 if( pcCU->get LumaIntraDir(absPartIdx+partOffset*j ) < NUM_INTRA_MODE )1004 { 1005 #endif 1006 Int preds[3] = {-1, -1, -1};1007 Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds);1008 1009 1010 m_pcTDecBinIf->decodeBinEP( symbol);1011 1012 1013 m_pcTDecBinIf->decodeBinEP( symbol);1014 1015 959 #if NH_3D_DMM 960 if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 961 { 962 #endif 963 Int preds[NUM_MOST_PROBABLE_MODES] = {-1, -1, -1}; 964 pcCU->getIntraDirPredictor(absPartIdx+partOffset*j, preds, COMPONENT_Y); 965 if (mpmPred[j]) 966 { 967 m_pcTDecBinIf->decodeBinEP( symbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 968 if (symbol) 969 { 970 m_pcTDecBinIf->decodeBinEP( symbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 971 symbol++; 972 } 1016 973 #if H_MV_ENC_DEC_TRAC 1017 974 DTRACE_CU("mpm_idx", symbol) 1018 975 #endif 1019 1020 1021 1022 1023 m_pcTDecBinIf->decodeBinsEP( symbol, 5);1024 976 intraPredMode = preds[symbol]; 977 } 978 else 979 { 980 m_pcTDecBinIf->decodeBinsEP( symbol, 5 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 981 intraPredMode = symbol; 1025 982 #if H_MV_ENC_DEC_TRAC 1026 983 DTRACE_CU("rem_intra_luma_pred_mode", symbol) 1027 984 #endif 1028 //postponed sorting of MPMs (only in remaining branch) 1029 if (preds[0] > preds[1]) 1030 { 1031 std::swap(preds[0], preds[1]); 1032 } 1033 if (preds[0] > preds[2]) 1034 { 1035 std::swap(preds[0], preds[2]); 1036 } 1037 if (preds[1] > preds[2]) 1038 { 1039 std::swap(preds[1], preds[2]); 1040 } 1041 for ( Int i = 0; i < predNum; i++ ) 1042 { 1043 intraPredMode += ( intraPredMode >= preds[i] ); 1044 } 1045 } 1046 pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); 1047 #if H_3D_DIM 1048 } 1049 #endif 1050 } 1051 } 985 986 //postponed sorting of MPMs (only in remaining branch) 987 if (preds[0] > preds[1]) 988 { 989 std::swap(preds[0], preds[1]); 990 } 991 if (preds[0] > preds[2]) 992 { 993 std::swap(preds[0], preds[2]); 994 } 995 if (preds[1] > preds[2]) 996 { 997 std::swap(preds[1], preds[2]); 998 } 999 for ( UInt i = 0; i < NUM_MOST_PROBABLE_MODES; i++ ) 1000 { 1001 intraPredMode += ( intraPredMode >= preds[i] ); 1002 } 1003 } 1004 pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); 1005 #if NH_3D_DMM 1006 } 1007 #endif 1008 } 1009 } 1010 1052 1011 1053 1012 Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 1054 1013 { 1055 1014 UInt uiSymbol; 1056 1057 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); 1058 1015 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1016 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__INTRA_DIR_ANG, g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth]+2, CHANNEL_TYPE_CHROMA); 1017 #endif 1018 1019 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1059 1020 if( uiSymbol == 0 ) 1060 1021 { … … 1062 1023 DTRACE_CU("intra_chroma_pred_mode", uiSymbol ) 1063 1024 #endif 1064 uiSymbol = DM_CHROMA_IDX; 1065 } 1066 else 1067 { 1068 { 1069 UInt uiIPredMode; 1070 m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); 1025 uiSymbol = DM_CHROMA_IDX; 1026 } 1027 else 1028 { 1029 UInt uiIPredMode; 1030 m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1071 1031 #if H_MV_ENC_DEC_TRAC 1072 1032 DTRACE_CU("intra_chroma_pred_mode", uiIPredMode ) 1073 1033 #endif 1074 UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; 1075 pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); 1076 uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; 1077 } 1078 } 1079 pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); 1080 return; 1081 } 1082 1083 #if H_3D_DIM 1084 Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 1085 { 1086 parseIntraDepthMode( pcCU, absPartIdx, depth ); 1087 1088 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 1089 UInt dimType = getDimType( dir ); 1090 1091 switch( dimType ) 1092 { 1093 #if H_3D_DIM_DMM 1094 case( DMM1_IDX ): 1095 { 1096 UInt uiTabIdx = 0; 1097 xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 1098 1099 assert( uiTabIdx < g_dmmWedgeLists[ g_aucConvertToBit[ pcCU->getDMM1BasePatternWidth( pcCU->getWidth( absPartIdx ) )]].size()); 1100 1101 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth ); 1102 } break; 1103 case( DMM4_IDX ): break; 1104 #endif 1105 default: break; 1106 } 1107 1108 pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); 1109 } 1110 1111 Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 1112 { 1113 UInt uiSymbol, uiIsDimMode; 1114 1115 if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed 1116 { 1117 m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, 0 ) ); 1118 } 1119 else 1120 { 1121 uiSymbol = 1; 1122 } 1123 uiIsDimMode = uiSymbol ? 0 : 1; 1124 pcCU->setLumaIntraDirSubParts( 0, absPartIdx, depth ); 1125 1126 //decode DMM index 1127 if( uiIsDimMode ) 1128 { 1129 if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag() ) 1130 { 1131 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) ); 1132 if( !uiSymbol ) 1133 { 1134 pcCU->setLumaIntraDirSubParts( DIM_OFFSET, absPartIdx, depth ); 1135 } 1136 else 1137 { 1138 pcCU->setLumaIntraDirSubParts( ( 1+ DIM_OFFSET ), absPartIdx, depth ); 1139 } 1140 } 1141 else if ( pcCU->getSlice()->getIntraSdcWedgeFlag() ) 1142 { 1143 pcCU->setLumaIntraDirSubParts( DIM_OFFSET, absPartIdx, depth ); 1144 } 1145 else if( pcCU->getSlice()->getIntraContourFlag() ) 1146 { 1147 pcCU->setLumaIntraDirSubParts( ( 1+ DIM_OFFSET ), absPartIdx, depth ); 1148 } 1149 } 1150 } 1151 #endif 1034 UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; 1035 pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); 1036 uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; 1037 } 1038 1039 pcCU->setIntraDirSubParts( CHANNEL_TYPE_CHROMA, uiSymbol, uiAbsPartIdx, uiDepth ); 1040 } 1152 1041 1153 1042 Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) … … 1156 1045 const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); 1157 1046 ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); 1047 1158 1048 uiSymbol = 0; 1159 1049 if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) 1160 1050 { 1161 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) );1051 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__INTER_DIR) ); 1162 1052 } 1163 1053 … … 1168 1058 else 1169 1059 { 1170 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) );1060 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__INTER_DIR) ); 1171 1061 assert(uiSymbol == 0 || uiSymbol == 1); 1172 1062 } … … 1184 1074 { 1185 1075 UInt uiSymbol; 1186 { 1187 ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); 1188 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); 1189 1190 if( uiSymbol ) 1191 { 1192 UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; 1193 pCtx++; 1194 UInt ui; 1195 for( ui = 0; ui < uiRefNum; ++ui ) 1196 { 1197 if( ui == 0 ) 1198 { 1199 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); 1200 } 1201 else 1202 { 1203 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 1204 } 1205 if( uiSymbol == 0 ) 1206 { 1207 break; 1208 } 1209 } 1210 uiSymbol = ui + 1; 1211 } 1212 riRefFrmIdx = uiSymbol; 1213 } 1214 1076 1077 ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); 1078 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); 1079 1080 if( uiSymbol ) 1081 { 1082 UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; 1083 pCtx++; 1084 UInt ui; 1085 for( ui = 0; ui < uiRefNum; ++ui ) 1086 { 1087 if( ui == 0 ) 1088 { 1089 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); 1090 } 1091 else 1092 { 1093 m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); 1094 } 1095 if( uiSymbol == 0 ) 1096 { 1097 break; 1098 } 1099 } 1100 uiSymbol = ui + 1; 1101 } 1102 riRefFrmIdx = uiSymbol; 1215 1103 #if H_MV_ENC_DEC_TRAC 1216 1104 #if ENC_DEC_TRACE … … 1225 1113 #endif 1226 1114 #endif 1115 1227 1116 return; 1228 1117 } … … 1244 1133 else 1245 1134 { 1246 m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx );1247 m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx );1135 m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 1136 m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 1248 1137 1249 1138 const Bool bHorAbsGr0 = uiHorAbs != 0; … … 1253 1142 if( bHorAbsGr0 ) 1254 1143 { 1255 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );1144 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 1256 1145 uiHorAbs += uiSymbol; 1257 1146 } … … 1259 1148 if( bVerAbsGr0 ) 1260 1149 { 1261 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );1150 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 1262 1151 uiVerAbs += uiSymbol; 1263 1152 } … … 1267 1156 if( 2 == uiHorAbs ) 1268 1157 { 1269 xReadEpExGolomb( uiSymbol, 1 );1158 xReadEpExGolomb( uiSymbol, 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 1270 1159 uiHorAbs += uiSymbol; 1271 1160 } 1272 1161 1273 m_pcTDecBinIf->decodeBinEP( uiHorSign );1162 m_pcTDecBinIf->decodeBinEP( uiHorSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 1274 1163 } 1275 1164 … … 1278 1167 if( 2 == uiVerAbs ) 1279 1168 { 1280 xReadEpExGolomb( uiSymbol, 1 );1169 xReadEpExGolomb( uiSymbol, 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 1281 1170 uiVerAbs += uiSymbol; 1282 1171 } 1283 1172 1284 m_pcTDecBinIf->decodeBinEP( uiVerSign );1173 m_pcTDecBinIf->decodeBinEP( uiVerSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 1285 1174 } 1286 1175 … … 1292 1181 } 1293 1182 1183 Void TDecSbac::parseCrossComponentPrediction( TComTU &rTu, ComponentID compID ) 1184 { 1185 TComDataCU *pcCU = rTu.getCU(); 1186 1187 if( isLuma(compID) || !pcCU->getSlice()->getPPS()->getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() ) 1188 { 1189 return; 1190 } 1191 1192 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 1193 1194 if (!pcCU->isIntra(uiAbsPartIdx) || (pcCU->getIntraDir( CHANNEL_TYPE_CHROMA, uiAbsPartIdx ) == DM_CHROMA_IDX)) 1195 { 1196 Char alpha = 0; 1197 UInt symbol = 0; 1198 1199 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1200 DTRACE_CABAC_T("\tparseCrossComponentPrediction()") 1201 DTRACE_CABAC_T( "\tAddr=" ) 1202 DTRACE_CABAC_V( compID ) 1203 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1204 DTRACE_CABAC_V( uiAbsPartIdx ) 1205 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1206 TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__CROSS_COMPONENT_PREDICTION, (g_aucConvertToBit[rTu.getRect(compID).width] + 2), compID); 1207 #endif 1208 ContextModel *pCtx = m_cCrossComponentPredictionSCModel.get(0, 0) + ((compID == COMPONENT_Cr) ? (NUM_CROSS_COMPONENT_PREDICTION_CTX >> 1) : 0); 1209 m_pcTDecBinIf->decodeBin( symbol, pCtx[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1210 1211 if(symbol != 0) 1212 { 1213 // Cross-component prediction alpha is non-zero. 1214 UInt sign = 0; 1215 m_pcTDecBinIf->decodeBin( symbol, pCtx[1] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1216 1217 if (symbol != 0) 1218 { 1219 // alpha is 2 (symbol=1), 4(symbol=2) or 8(symbol=3). 1220 // Read up to two more bits 1221 xReadUnaryMaxSymbol( symbol, (pCtx + 2), 1, 2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1222 symbol += 1; 1223 } 1224 m_pcTDecBinIf->decodeBin( sign, pCtx[4] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1225 1226 alpha = (sign != 0) ? -(1 << symbol) : (1 << symbol); 1227 } 1228 DTRACE_CABAC_T( "\tAlpha=" ) 1229 DTRACE_CABAC_V( alpha ) 1230 DTRACE_CABAC_T( "\n" ) 1231 1232 pcCU->setCrossComponentPredictionAlphaPartRange( alpha, compID, uiAbsPartIdx, rTu.GetAbsPartIdxNumParts( compID ) ); 1233 } 1234 } 1294 1235 1295 1236 Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) 1296 1237 { 1297 m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); 1238 m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) 1239 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__TRANSFORM_SUBDIV_FLAG, 5-uiLog2TransformBlockSize)) 1240 ); 1298 1241 #if !H_MV_ENC_DEC_TRAC 1299 1242 DTRACE_CABAC_VL( g_nSymbolCounter++ ) … … 1307 1250 DTRACE_TU("split_transform_flag", ruiSubdivFlag ) 1308 1251 #endif 1252 1309 1253 } 1310 1254 … … 1313 1257 UInt uiSymbol; 1314 1258 const UInt uiCtx = 0; 1315 m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) );1259 m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__QT_ROOT_CBF) ); 1316 1260 #if !H_MV_ENC_DEC_TRAC 1317 1261 DTRACE_CABAC_VL( g_nSymbolCounter++ ) … … 1327 1271 DTRACE_CU( "rqt_root_cbf", uiSymbol ) 1328 1272 #endif 1329 1273 1330 1274 uiQtRootCbf = uiSymbol; 1331 1275 } … … 1336 1280 UInt uiDQp; 1337 1281 Int iDQp; 1338 1282 1339 1283 UInt uiSymbol; 1340 1284 1341 xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX );1285 xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP) ); 1342 1286 1343 1287 if( uiDQp >= CU_DQP_TU_CMAX) 1344 1288 { 1345 xReadEpExGolomb( uiSymbol, CU_DQP_EG_k );1289 xReadEpExGolomb( uiSymbol, CU_DQP_EG_k RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP)); 1346 1290 uiDQp+=uiSymbol; 1347 1291 } … … 1350 1294 { 1351 1295 UInt uiSign; 1352 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset Y();1353 m_pcTDecBinIf->decodeBinEP(uiSign );1296 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 1297 m_pcTDecBinIf->decodeBinEP(uiSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP)); 1354 1298 iDQp = uiDQp; 1355 1299 if(uiSign) … … 1359 1303 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; 1360 1304 } 1361 else 1305 else 1362 1306 { 1363 1307 qp = pcCU->getRefQP(uiAbsPartIdx); 1364 1308 } 1365 pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); 1309 1310 pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); 1366 1311 pcCU->setCodedQP(qp); 1367 1312 } 1368 1313 1369 Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) 1370 { 1371 UInt uiSymbol; 1372 const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); 1373 m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); 1314 /** parse chroma qp adjustment, converting to the internal table representation. 1315 * \returns Void 1316 */ 1317 Void TDecSbac::parseChromaQpAdjustment( TComDataCU* cu, UInt absPartIdx, UInt depth ) 1318 { 1319 UInt symbol; 1320 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1321 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__CHROMA_QP_ADJUSTMENT, g_aucConvertToBit[cu->getSlice()->getSPS()->getMaxCUWidth()>>depth]+2, CHANNEL_TYPE_CHROMA); 1322 #endif 1323 1324 Int chromaQpOffsetListLen = cu->getSlice()->getPPS()->getPpsRangeExtension().getChromaQpOffsetListLen(); 1325 1326 // cu_chroma_qp_offset_flag 1327 m_pcTDecBinIf->decodeBin( symbol, m_ChromaQpAdjFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1328 1329 if (symbol && chromaQpOffsetListLen > 1) 1330 { 1331 // cu_chroma_qp_offset_idx 1332 xReadUnaryMaxSymbol( symbol, &m_ChromaQpAdjIdcSCModel.get( 0, 0, 0 ), 0, chromaQpOffsetListLen - 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1333 symbol++; 1334 } 1335 /* NB, symbol = 0 if outer flag is not set, 1336 * 1 if outer flag is set and there is no inner flag 1337 * 1+ otherwise */ 1338 cu->setChromaQpAdjSubParts( symbol, absPartIdx, depth ); 1339 cu->setCodedChromaQpAdj(symbol); 1340 } 1341 1342 Void TDecSbac::parseQtCbf( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) 1343 { 1344 TComDataCU* pcCU = rTu.getCU(); 1345 1346 const UInt absPartIdx = rTu.GetAbsPartIdxTU(compID); 1347 const UInt TUDepth = rTu.GetTransformDepthRel(); 1348 const UInt uiCtx = pcCU->getCtxQtCbf( rTu, toChannelType(compID) ); 1349 const UInt contextSet = toChannelType(compID); 1350 1351 const UInt width = rTu.getRect(compID).width; 1352 const UInt height = rTu.getRect(compID).height; 1353 const Bool canQuadSplit = (width >= (MIN_TU_SIZE * 2)) && (height >= (MIN_TU_SIZE * 2)); 1354 const UInt coveredPartIdxes = rTu.GetAbsPartIdxNumParts(compID); 1355 1356 // Since the CBF for chroma is coded at the highest level possible, if sub-TUs are 1357 // to be coded for a 4x8 chroma TU, their CBFs must be coded at the highest 4x8 level 1358 // (i.e. where luma TUs are 8x8 rather than 4x4) 1359 // ___ ___ 1360 // | | | <- 4 x (8x8 luma + 4x8 4:2:2 chroma) 1361 // |___|___| each quadrant has its own chroma CBF 1362 // | | | _ _ _ _ 1363 // |___|___| | 1364 // <--16---> V 1365 // _ _ 1366 // |_|_| <- 4 x 4x4 luma + 1 x 4x8 4:2:2 chroma 1367 // |_|_| no chroma CBF is coded - instead the parent CBF is inherited 1368 // <-8-> if sub-TUs are present, their CBFs had to be coded at the parent level 1369 1370 const UInt lowestTUDepth = TUDepth + ((!lowestLevel && !canQuadSplit) ? 1 : 0); //unsplittable TUs inherit their parent's CBF 1371 UInt lowestTUCBF = 0; 1372 1373 if ((width != height) && (lowestLevel || !canQuadSplit)) //if sub-TUs are present 1374 { 1375 const UInt subTUDepth = lowestTUDepth + 1; 1376 const UInt partIdxesPerSubTU = rTu.GetAbsPartIdxNumParts(compID) >> 1; 1377 1378 UInt combinedSubTUCBF = 0; 1379 1380 for (UInt subTU = 0; subTU < 2; subTU++) 1381 { 1382 UInt uiCbf = MAX_UINT; 1383 m_pcTDecBinIf->decodeBin(uiCbf, m_cCUQtCbfSCModel.get(0, contextSet, uiCtx) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__QT_CBF, g_aucConvertToBit[rTu.getRect(compID).width]+2, compID))); 1384 1385 const UInt subTUAbsPartIdx = absPartIdx + (subTU * partIdxesPerSubTU); 1386 pcCU->setCbfPartRange((uiCbf << subTUDepth), compID, subTUAbsPartIdx, partIdxesPerSubTU); 1387 combinedSubTUCBF |= uiCbf; 1374 1388 #if !H_MV_ENC_DEC_TRAC 1375 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1376 DTRACE_CABAC_T( "\tparseQtCbf()" ) 1377 DTRACE_CABAC_T( "\tsymbol=" ) 1378 DTRACE_CABAC_V( uiSymbol ) 1379 DTRACE_CABAC_T( "\tctx=" ) 1380 DTRACE_CABAC_V( uiCtx ) 1381 DTRACE_CABAC_T( "\tetype=" ) 1382 DTRACE_CABAC_V( eType ) 1383 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1384 DTRACE_CABAC_V( uiAbsPartIdx ) 1385 DTRACE_CABAC_T( "\n" ) 1389 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1390 DTRACE_CABAC_T( "\tparseQtCbf()" ) 1391 DTRACE_CABAC_T( "\tsub-TU=" ) 1392 DTRACE_CABAC_V( subTU ) 1393 DTRACE_CABAC_T( "\tsymbol=" ) 1394 DTRACE_CABAC_V( uiCbf ) 1395 DTRACE_CABAC_T( "\tctx=" ) 1396 DTRACE_CABAC_V( uiCtx ) 1397 DTRACE_CABAC_T( "\tetype=" ) 1398 DTRACE_CABAC_V( compID ) 1399 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1400 DTRACE_CABAC_V( subTUAbsPartIdx ) 1401 DTRACE_CABAC_T( "\n" ) 1386 1402 #else 1387 if ( eType == TEXT_CHROMA_U)1388 { 1389 DTRACE_TU("cbf_cb", ui Symbol)1390 } 1391 else if ( eType == TEXT_CHROMA_V)1392 { 1393 DTRACE_TU("cbf_cr", ui Symbol)1403 if ( compID == COMPONENT_Cb ) 1404 { 1405 DTRACE_TU("cbf_cb", uiCbf ) 1406 } 1407 else if ( compID == COMPONENT_Cr ) 1408 { 1409 DTRACE_TU("cbf_cr", uiCbf ) 1394 1410 } 1395 1411 else 1396 1412 { 1397 DTRACE_TU("cbf_luma", uiSymbol ) 1398 } 1399 #endif 1400 1401 pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); 1402 } 1403 1404 void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) 1405 { 1413 DTRACE_TU("cbf_luma", uiCbf ) 1414 } 1415 #endif 1416 1417 } 1418 1419 //propagate the sub-TU CBF up to the lowest TU level 1420 if (combinedSubTUCBF != 0) 1421 { 1422 pcCU->bitwiseOrCbfPartRange((combinedSubTUCBF << lowestTUDepth), compID, absPartIdx, coveredPartIdxes); 1423 lowestTUCBF = combinedSubTUCBF; 1424 } 1425 } 1426 else 1427 { 1428 UInt uiCbf = MAX_UINT; 1429 m_pcTDecBinIf->decodeBin(uiCbf, m_cCUQtCbfSCModel.get(0, contextSet, uiCtx) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__QT_CBF, g_aucConvertToBit[rTu.getRect(compID).width]+2, compID))); 1430 1431 pcCU->setCbfSubParts((uiCbf << lowestTUDepth), compID, absPartIdx, rTu.GetTransformDepthTotalAdj(compID)); 1432 #if !H_MV_ENC_DEC_TRAC 1433 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1434 DTRACE_CABAC_T( "\tparseQtCbf()" ) 1435 DTRACE_CABAC_T( "\tsymbol=" ) 1436 DTRACE_CABAC_V( uiCbf ) 1437 DTRACE_CABAC_T( "\tctx=" ) 1438 DTRACE_CABAC_V( uiCtx ) 1439 DTRACE_CABAC_T( "\tetype=" ) 1440 DTRACE_CABAC_V( compID ) 1441 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1442 DTRACE_CABAC_V( rTu.GetAbsPartIdxTU(compID) ) 1443 DTRACE_CABAC_T( "\n" ) 1444 #else 1445 if ( compID == COMPONENT_Cb ) 1446 { 1447 DTRACE_TU("cbf_cb", uiCbf ) 1448 } 1449 else if ( compID == COMPONENT_Cr ) 1450 { 1451 DTRACE_TU("cbf_cr", uiCbf ) 1452 } 1453 else 1454 { 1455 DTRACE_TU("cbf_luma", uiCbf ) 1456 } 1457 #endif 1458 lowestTUCBF = uiCbf; 1459 } 1460 1461 //propagate the lowest level CBF up to the current level 1462 if (lowestTUCBF != 0) 1463 { 1464 for (UInt depth = TUDepth; depth < lowestTUDepth; depth++) 1465 { 1466 pcCU->bitwiseOrCbfPartRange((lowestTUCBF << depth), compID, absPartIdx, coveredPartIdxes); 1467 } 1468 } 1469 } 1470 1471 1472 Void TDecSbac::parseTransformSkipFlags (TComTU &rTu, ComponentID component) 1473 { 1474 TComDataCU* pcCU=rTu.getCU(); 1475 UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(component); 1476 1406 1477 if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) 1407 1478 { 1408 1479 return; 1409 1480 } 1410 if(width != 4 || height != 4) 1481 1482 if (!TUCompRectHasAssociatedTransformSkipFlag(rTu.getRect(component), pcCU->getSlice()->getPPS()->getPpsRangeExtension().getLog2MaxTransformSkipBlockSize())) 1411 1483 { 1412 1484 return; 1413 1485 } 1414 1486 1415 1487 UInt useTransformSkip; 1416 m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); 1417 if(eTType!= TEXT_LUMA) 1418 { 1419 const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; 1420 if(uiLog2TrafoSize == 2) 1421 { 1422 uiDepth --; 1423 } 1424 } 1488 1489 m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, toChannelType(component), 0 ) 1490 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__TRANSFORM_SKIP_FLAGS, component)) 1491 ); 1492 1425 1493 #if !H_MV_ENC_DEC_TRAC 1426 1494 DTRACE_CABAC_VL( g_nSymbolCounter++ ) … … 1429 1497 DTRACE_CABAC_V( useTransformSkip ) 1430 1498 DTRACE_CABAC_T( "\tAddr=" ) 1431 DTRACE_CABAC_V( pcCU->get Addr() )1499 DTRACE_CABAC_V( pcCU->getCtuRsAddr() ) 1432 1500 DTRACE_CABAC_T( "\tetype=" ) 1433 DTRACE_CABAC_V( eTType)1501 DTRACE_CABAC_V( component ) 1434 1502 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1435 DTRACE_CABAC_V( uiAbsPartIdx)1503 DTRACE_CABAC_V( rTu.GetAbsPartIdxTU() ) 1436 1504 DTRACE_CABAC_T( "\n" ) 1437 1505 #endif 1438 1506 1439 pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); 1440 } 1507 pcCU->setTransformSkipPartRange( useTransformSkip, component, uiAbsPartIdx, rTu.GetAbsPartIdxNumParts(component)); 1508 } 1509 1441 1510 1442 1511 /** Parse (X,Y) position of the last significant coefficient … … 1445 1514 * \param width Block width 1446 1515 * \param height Block height 1447 * \param eTType plane type / luminance or chrominance1516 * \param component chroma compinent ID 1448 1517 * \param uiScanIdx scan type (zig-zag, hor, ver) 1449 1518 * 1450 1519 * This method decodes the X and Y component within a block of the last significant coefficient. 1451 1520 */ 1452 Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx )1521 Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, ComponentID component, UInt uiScanIdx ) 1453 1522 { 1454 1523 UInt uiLast; 1455 ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); 1456 ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); 1524 1525 ContextModel *pCtxX = m_cCuCtxLastX.get( 0, toChannelType(component) ); 1526 ContextModel *pCtxY = m_cCuCtxLastY.get( 0, toChannelType(component) ); 1527 1528 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1529 TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__LAST_SIG_X_Y, g_aucConvertToBit[width]+2, component); 1530 #endif 1531 1532 1533 if ( uiScanIdx == SCAN_VER ) 1534 { 1535 swap( width, height ); 1536 } 1457 1537 1458 1538 Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; 1459 blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2));1460 blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); 1461 shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2);1462 shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); 1539 getLastSignificantContextParameters(component, width, height, blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY); 1540 1541 //------------------ 1542 1463 1543 // posX 1544 1464 1545 for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) 1465 1546 { 1466 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) ); 1547 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1548 1467 1549 if( !uiLast ) 1468 1550 { … … 1472 1554 1473 1555 // posY 1556 1474 1557 for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) 1475 1558 { 1476 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) ); 1559 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1560 1477 1561 if( !uiLast ) 1478 1562 { … … 1480 1564 } 1481 1565 } 1566 1567 // EP-coded part 1568 1482 1569 if ( uiPosLastX > 3 ) 1483 1570 { … … 1486 1573 for ( Int i = uiCount - 1; i >= 0; i-- ) 1487 1574 { 1488 m_pcTDecBinIf->decodeBinEP( uiLast );1575 m_pcTDecBinIf->decodeBinEP( uiLast RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1489 1576 uiTemp += uiLast << i; 1490 1577 } … … 1497 1584 for ( Int i = uiCount - 1; i >= 0; i-- ) 1498 1585 { 1499 m_pcTDecBinIf->decodeBinEP( uiLast );1586 m_pcTDecBinIf->decodeBinEP( uiLast RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1500 1587 uiTemp += uiLast << i; 1501 1588 } 1502 1589 uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; 1503 1590 } 1504 1591 1505 1592 if( uiScanIdx == SCAN_VER ) 1506 1593 { … … 1509 1596 } 1510 1597 1511 Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) 1512 { 1598 Void TDecSbac::parseCoeffNxN( TComTU &rTu, ComponentID compID ) 1599 { 1600 TComDataCU* pcCU=rTu.getCU(); 1601 const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(compID); 1602 const TComRectangle &rRect=rTu.getRect(compID); 1603 const UInt uiWidth=rRect.width; 1604 const UInt uiHeight=rRect.height; 1605 TCoeff* pcCoef=(pcCU->getCoeff(compID)+rTu.getCoefficientOffset(compID)); 1606 const TComSPS &sps=*(pcCU->getSlice()->getSPS()); 1513 1607 #if !H_MV_ENC_DEC_TRAC 1514 1608 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1515 1609 DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) 1516 DTRACE_CABAC_V( eTType)1610 DTRACE_CABAC_V( compID ) 1517 1611 DTRACE_CABAC_T( "\twidth=" ) 1518 1612 DTRACE_CABAC_V( uiWidth ) … … 1520 1614 DTRACE_CABAC_V( uiHeight ) 1521 1615 DTRACE_CABAC_T( "\tdepth=" ) 1522 DTRACE_CABAC_V( uiDepth ) 1616 // DTRACE_CABAC_V( rTu.GetTransformDepthTotalAdj(compID) ) 1617 DTRACE_CABAC_V( rTu.GetTransformDepthTotal() ) 1523 1618 DTRACE_CABAC_T( "\tabspartidx=" ) 1524 DTRACE_CABAC_V( uiAbsPartIdx ) 1619 // DTRACE_CABAC_V( uiAbsPartIdx ) 1620 DTRACE_CABAC_V( rTu.GetAbsPartIdxTU(compID) ) 1525 1621 DTRACE_CABAC_T( "\ttoCU-X=" ) 1526 1622 DTRACE_CABAC_V( pcCU->getCUPelX() ) … … 1528 1624 DTRACE_CABAC_V( pcCU->getCUPelY() ) 1529 1625 DTRACE_CABAC_T( "\tCU-addr=" ) 1530 DTRACE_CABAC_V( pcCU->get Addr() )1626 DTRACE_CABAC_V( pcCU->getCtuRsAddr() ) 1531 1627 DTRACE_CABAC_T( "\tinCU-X=" ) 1532 DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1628 // DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1629 DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[rTu.GetAbsPartIdxTU(compID)] ] ) 1533 1630 DTRACE_CABAC_T( "\tinCU-Y=" ) 1534 DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1631 // DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1632 DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[rTu.GetAbsPartIdxTU(compID)] ] ) 1535 1633 DTRACE_CABAC_T( "\tpredmode=" ) 1536 1634 DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) 1537 1635 DTRACE_CABAC_T( "\n" ) 1538 1636 #endif 1539 1540 if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) 1541 { 1542 uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); 1543 uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); 1544 } 1637 1638 //-------------------------------------------------------------------------------------------------- 1639 1640 if( uiWidth > sps.getMaxTrSize() ) 1641 { 1642 std::cerr << "ERROR: parseCoeffNxN was passed a TU with dimensions larger than the maximum allowed size" << std::endl; 1643 assert(false); 1644 exit(1); 1645 } 1646 1647 //-------------------------------------------------------------------------------------------------- 1648 1649 //set parameters 1650 1651 const ChannelType chType = toChannelType(compID); 1652 const UInt uiLog2BlockWidth = g_aucConvertToBit[ uiWidth ] + 2; 1653 const UInt uiLog2BlockHeight = g_aucConvertToBit[ uiHeight ] + 2; 1654 const UInt uiMaxNumCoeff = uiWidth * uiHeight; 1655 const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; 1656 1657 const ChannelType channelType = toChannelType(compID); 1658 const Bool extendedPrecision = sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag(); 1659 1660 const Bool alignCABACBeforeBypass = sps.getSpsRangeExtension().getCabacBypassAlignmentEnabledFlag(); 1661 const Int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(channelType); 1662 1663 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1664 TComCodingStatisticsClassType ctype_group(STATS__CABAC_BITS__SIG_COEFF_GROUP_FLAG, uiLog2BlockWidth, compID); 1665 TComCodingStatisticsClassType ctype_map(STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG, uiLog2BlockWidth, compID); 1666 TComCodingStatisticsClassType ctype_gt1(STATS__CABAC_BITS__GT1_FLAG, uiLog2BlockWidth, compID); 1667 TComCodingStatisticsClassType ctype_gt2(STATS__CABAC_BITS__GT2_FLAG, uiLog2BlockWidth, compID); 1668 #endif 1669 1670 Bool beValid; 1671 if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) 1672 { 1673 beValid = false; 1674 if((!pcCU->isIntra(uiAbsPartIdx)) && pcCU->isRDPCMEnabled(uiAbsPartIdx)) 1675 { 1676 parseExplicitRdpcmMode(rTu, compID); 1677 } 1678 } 1679 else 1680 { 1681 beValid = pcCU->getSlice()->getPPS()->getSignHideFlag(); 1682 } 1683 1684 UInt absSum = 0; 1685 1686 //-------------------------------------------------------------------------------------------------- 1687 1545 1688 if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) 1546 1689 { 1547 parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType); 1548 } 1549 1550 eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); 1551 1552 //----- parse significance map ----- 1553 const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; 1554 const UInt uiMaxNumCoeff = uiWidth * uiHeight; 1555 const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; 1556 UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); 1557 1690 parseTransformSkipFlags(rTu, compID); 1691 // This TU has coefficients and is transform skipped. Check whether is inter coded and if yes decode the explicit RDPCM mode 1692 if(pcCU->getTransformSkip(uiAbsPartIdx, compID) && (!pcCU->isIntra(uiAbsPartIdx)) && pcCU->isRDPCMEnabled(uiAbsPartIdx) ) 1693 { 1694 parseExplicitRdpcmMode(rTu, compID); 1695 if(pcCU->getExplicitRdpcmMode(compID, uiAbsPartIdx) != RDPCM_OFF) 1696 { 1697 // Sign data hiding is avoided for horizontal and vertical RDPCM modes 1698 beValid = false; 1699 } 1700 } 1701 } 1702 1703 Int uiIntraMode = -1; 1704 const Bool bIsLuma = isLuma(compID); 1705 Int isIntra = pcCU->isIntra(uiAbsPartIdx) ? 1 : 0; 1706 if ( isIntra && pcCU->isRDPCMEnabled(uiAbsPartIdx) ) 1707 { 1708 const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize())); 1709 uiIntraMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); 1710 uiIntraMode = (uiIntraMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, rTu.GetChromaFormat(), partsPerMinCU)) : uiIntraMode; 1711 uiIntraMode = ((rTu.GetChromaFormat() == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiIntraMode] : uiIntraMode; 1712 1713 Bool transformSkip = pcCU->getTransformSkip( uiAbsPartIdx,compID); 1714 Bool rdpcm_lossy = ( transformSkip /*&& isIntra*/ && ( (uiIntraMode == HOR_IDX) || (uiIntraMode == VER_IDX) ) ); 1715 if ( rdpcm_lossy ) 1716 { 1717 beValid = false; 1718 } 1719 } 1720 1721 //-------------------------------------------------------------------------------------------------- 1722 1723 const Bool bUseGolombRiceParameterAdaptation = sps.getSpsRangeExtension().getPersistentRiceAdaptationEnabledFlag(); 1724 UInt ¤tGolombRiceStatistic = m_golombRiceAdaptationStatistics[rTu.getGolombRiceStatisticsIndex(compID)]; 1725 1726 //select scans 1727 TUEntropyCodingParameters codingParameters; 1728 getTUEntropyCodingParameters(codingParameters, rTu, compID); 1729 1558 1730 //===== decode last significant ===== 1559 1731 UInt uiPosLastX, uiPosLastY; 1560 parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx);1561 UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2Block Size);1732 parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, compID, codingParameters.scanType ); 1733 UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockWidth); 1562 1734 pcCoef[ uiBlkPosLast ] = 1; 1563 1735 1564 1736 //===== decode significance flags ===== 1565 1737 UInt uiScanPosLast; 1566 const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];1567 1738 for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) 1568 1739 { 1569 UInt uiBlkPos = scan[ uiScanPosLast ];1740 UInt uiBlkPos = codingParameters.scan[ uiScanPosLast ]; 1570 1741 if( uiBlkPosLast == uiBlkPos ) 1571 1742 { … … 1574 1745 } 1575 1746 1576 ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); 1577 ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; 1578 1579 const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; 1580 UInt c1 = 1; 1581 UInt uiGoRiceParam = 0; 1582 1583 Bool beValid; 1584 if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) 1585 { 1586 beValid = false; 1587 } 1588 else 1589 { 1590 beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; 1591 } 1592 UInt absSum = 0; 1747 ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, isChroma(chType) ); 1748 ContextModel * const baseCtx = m_cCUSigSCModel.get( 0, 0 ) + getSignificanceMapContextOffset(compID); 1749 1750 const Int iLastScanSet = uiScanPosLast >> MLS_CG_SIZE; 1751 UInt c1 = 1; 1752 UInt uiGoRiceParam = 0; 1753 1593 1754 1594 1755 UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; 1595 ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); 1596 const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); 1597 const UInt * scanCG; 1598 { 1599 scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; 1600 if( uiLog2BlockSize == 3 ) 1601 { 1602 scanCG = g_sigLastScan8x8[ uiScanIdx ]; 1603 } 1604 else if( uiLog2BlockSize == 5 ) 1605 { 1606 scanCG = g_sigLastScanCG32x32; 1607 } 1608 } 1756 memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); 1757 1609 1758 Int iScanPosSig = (Int) uiScanPosLast; 1610 1759 for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) 1611 1760 { 1612 Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; 1613 uiGoRiceParam = 0; 1761 Int iSubPos = iSubSet << MLS_CG_SIZE; 1762 uiGoRiceParam = currentGolombRiceStatistic / RExt__GOLOMB_RICE_INCREMENT_DIVISOR; 1763 Bool updateGolombRiceStatistics = bUseGolombRiceParameterAdaptation; //leave the statistics at 0 when not using the adaptation system 1614 1764 Int numNonZero = 0; 1615 1616 Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; 1617 1618 Int pos[SCAN_SET_SIZE]; 1765 1766 Int lastNZPosInCG = -1; 1767 Int firstNZPosInCG = 1 << MLS_CG_SIZE; 1768 1769 Bool escapeDataPresentInGroup = false; 1770 1771 Int pos[1 << MLS_CG_SIZE]; 1772 1619 1773 if( iScanPosSig == (Int) uiScanPosLast ) 1620 1774 { … … 1627 1781 1628 1782 // decode significant_coeffgroup_flag 1629 Int iCGBlkPos = scanCG[ iSubSet ]; 1630 Int iCGPosY = iCGBlkPos / uiNumBlkSide; 1631 Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); 1783 Int iCGBlkPos = codingParameters.scanCG[ iSubSet ]; 1784 Int iCGPosY = iCGBlkPos / codingParameters.widthInGroups; 1785 Int iCGPosX = iCGBlkPos - (iCGPosY * codingParameters.widthInGroups); 1786 1632 1787 if( iSubSet == iLastScanSet || iSubSet == 0) 1633 1788 { … … 1637 1792 { 1638 1793 UInt uiSigCoeffGroup; 1639 UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight);1640 m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );1794 UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, codingParameters.widthInGroups, codingParameters.heightInGroups ); 1795 m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_group) ); 1641 1796 uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; 1642 1797 } 1643 1798 1644 1799 // decode significant_coeff_flag 1645 Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); 1646 UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; 1800 const Int patternSigCtx = TComTrQuant::calcPatternSigCtx(uiSigCoeffGroupFlag, iCGPosX, iCGPosY, codingParameters.widthInGroups, codingParameters.heightInGroups); 1801 1802 UInt uiBlkPos, uiSig, uiCtxSig; 1647 1803 for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) 1648 1804 { 1649 uiBlkPos = scan[ iScanPosSig ]; 1650 uiPosY = uiBlkPos >> uiLog2BlockSize; 1651 uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); 1805 uiBlkPos = codingParameters.scan[ iScanPosSig ]; 1652 1806 uiSig = 0; 1653 1807 1654 1808 if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) 1655 1809 { 1656 1810 if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) 1657 1811 { 1658 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType );1659 m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );1812 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, codingParameters, iScanPosSig, uiLog2BlockWidth, uiLog2BlockHeight, chType ); 1813 m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_map) ); 1660 1814 } 1661 1815 else … … 1676 1830 } 1677 1831 } 1678 1679 if( numNonZero )1832 1833 if( numNonZero > 0 ) 1680 1834 { 1681 1835 Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); 1836 1682 1837 absSum = 0; 1683 UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; 1838 1839 const UInt uiCtxSet = getContextSetIndex(compID, iSubSet, (c1 == 0)); 1840 c1 = 1; 1684 1841 UInt uiBin; 1685 if( c1 == 0 ) 1686 {1687 uiCtxSet++; 1688 }1689 c1 = 1; 1690 ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet;1691 Int absCoeff[SCAN_SET_SIZE];1692 1693 for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1;1842 1843 ContextModel *baseCtxMod = m_cCUOneSCModel.get( 0, 0 ) + (NUM_ONE_FLAG_CTX_PER_SET * uiCtxSet); 1844 1845 Int absCoeff[1 << MLS_CG_SIZE]; 1846 1847 for ( Int i = 0; i < numNonZero; i++) 1848 { 1849 absCoeff[i] = 1; 1850 } 1694 1851 Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); 1695 1852 Int firstC2FlagIdx = -1; … … 1697 1854 for( Int idx = 0; idx < numC1Flag; idx++ ) 1698 1855 { 1699 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] );1856 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_gt1) ); 1700 1857 if( uiBin == 1 ) 1701 1858 { … … 1705 1862 firstC2FlagIdx = idx; 1706 1863 } 1864 else //if a greater-than-one has been encountered already this group 1865 { 1866 escapeDataPresentInGroup = true; 1867 } 1707 1868 } 1708 1869 else if( (c1 < 3) && (c1 > 0) ) … … 1712 1873 absCoeff[ idx ] = uiBin + 1; 1713 1874 } 1714 1875 1715 1876 if (c1 == 0) 1716 1877 { 1717 baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet;1878 baseCtxMod = m_cCUAbsSCModel.get( 0, 0 ) + (NUM_ABS_FLAG_CTX_PER_SET * uiCtxSet); 1718 1879 if ( firstC2FlagIdx != -1) 1719 1880 { 1720 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] );1881 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_gt2) ); 1721 1882 absCoeff[ firstC2FlagIdx ] = uiBin + 2; 1722 } 1883 if (uiBin != 0) 1884 { 1885 escapeDataPresentInGroup = true; 1886 } 1887 } 1888 } 1889 1890 escapeDataPresentInGroup = escapeDataPresentInGroup || (numNonZero > C1FLAG_NUMBER); 1891 1892 const Bool alignGroup = escapeDataPresentInGroup && alignCABACBeforeBypass; 1893 1894 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1895 TComCodingStatisticsClassType ctype_signs((alignGroup ? STATS__CABAC_BITS__ALIGNED_SIGN_BIT : STATS__CABAC_BITS__SIGN_BIT ), uiLog2BlockWidth, compID); 1896 TComCodingStatisticsClassType ctype_escs ((alignGroup ? STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS : STATS__CABAC_BITS__ESCAPE_BITS), uiLog2BlockWidth, compID); 1897 #endif 1898 1899 if (alignGroup) 1900 { 1901 m_pcTDecBinIf->align(); 1723 1902 } 1724 1903 … … 1726 1905 if ( signHidden && beValid ) 1727 1906 { 1728 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 );1907 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_signs) ); 1729 1908 coeffSigns <<= 32 - (numNonZero-1); 1730 1909 } 1731 1910 else 1732 1911 { 1733 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero );1912 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_signs) ); 1734 1913 coeffSigns <<= 32 - numNonZero; 1735 1914 } 1736 1737 Int iFirstCoeff2 = 1; 1738 if ( c1 == 0 || numNonZero > C1FLAG_NUMBER)1915 1916 Int iFirstCoeff2 = 1; 1917 if (escapeDataPresentInGroup) 1739 1918 { 1740 1919 for( Int idx = 0; idx < numNonZero; idx++ ) … … 1745 1924 { 1746 1925 UInt uiLevel; 1747 xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam ); 1926 xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam, extendedPrecision, maxLog2TrDynamicRange RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_escs) ); 1927 1748 1928 absCoeff[ idx ] = uiLevel + baseLevel; 1749 if(absCoeff[idx]>3*(1<<uiGoRiceParam)) 1929 1930 if (absCoeff[idx] > (3 << uiGoRiceParam)) 1750 1931 { 1751 uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); 1932 uiGoRiceParam = bUseGolombRiceParameterAdaptation ? (uiGoRiceParam + 1) : (std::min<UInt>((uiGoRiceParam + 1), 4)); 1933 } 1934 1935 if (updateGolombRiceStatistics) 1936 { 1937 const UInt initialGolombRiceParameter = currentGolombRiceStatistic / RExt__GOLOMB_RICE_INCREMENT_DIVISOR; 1938 1939 if (uiLevel >= (3 << initialGolombRiceParameter)) 1940 { 1941 currentGolombRiceStatistic++; 1942 } 1943 else if (((uiLevel * 2) < (1 << initialGolombRiceParameter)) && (currentGolombRiceStatistic > 0)) 1944 { 1945 currentGolombRiceStatistic--; 1946 } 1947 1948 updateGolombRiceStatistics = false; 1752 1949 } 1753 1950 } 1754 1951 1755 if(absCoeff[ idx ] >= 2) 1952 if(absCoeff[ idx ] >= 2) 1756 1953 { 1757 1954 iFirstCoeff2 = 0; … … 1784 1981 } 1785 1982 } 1786 1983 1984 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 1985 printSBACCoeffData(uiPosLastX, uiPosLastY, uiWidth, uiHeight, compID, uiAbsPartIdx, codingParameters.scanType, pcCoef); 1986 #endif 1987 1787 1988 return; 1788 1989 } 1789 1790 1990 1791 1991 Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) … … 1799 1999 UInt code; 1800 2000 Int i; 1801 m_pcTDecBinIf->decodeBinEP( code );2001 m_pcTDecBinIf->decodeBinEP( code RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1802 2002 if ( code == 0 ) 1803 2003 { … … 1809 2009 while (1) 1810 2010 { 1811 m_pcTDecBinIf->decodeBinEP( code );2011 m_pcTDecBinIf->decodeBinEP( code RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1812 2012 if ( code == 0 ) 1813 2013 { … … 1815 2015 } 1816 2016 i++; 1817 if (i == maxSymbol) 2017 if (i == maxSymbol) 1818 2018 { 1819 2019 break; … … 1823 2023 val = i; 1824 2024 } 2025 1825 2026 Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) 1826 2027 { 1827 m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); 1828 } 2028 m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 2029 } 2030 1829 2031 Void TDecSbac::parseSaoMerge (UInt& ruiVal) 1830 2032 { 1831 2033 UInt uiCode; 1832 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) );2034 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1833 2035 ruiVal = (Int)uiCode; 1834 2036 } 2037 1835 2038 Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) 1836 2039 { 1837 2040 UInt uiCode; 1838 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );1839 if (uiCode == 0) 2041 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 2042 if (uiCode == 0) 1840 2043 { 1841 2044 ruiVal = 0; … … 1843 2046 else 1844 2047 { 1845 m_pcTDecBinIf->decodeBinEP( uiCode );2048 m_pcTDecBinIf->decodeBinEP( uiCode RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1846 2049 if (uiCode == 0) 1847 2050 { … … 1857 2060 Void TDecSbac::parseSaoSign(UInt& val) 1858 2061 { 1859 m_pcTDecBinIf->decodeBinEP ( val );2062 m_pcTDecBinIf->decodeBinEP ( val RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1860 2063 } 1861 2064 … … 1864 2067 , Bool leftMergeAvail 1865 2068 , Bool aboveMergeAvail 2069 , const BitDepths &bitDepths 1866 2070 ) 1867 2071 { … … 1884 2088 1885 2089 if(isLeftMerge || isAboveMerge) //merge mode 1886 { 1887 saoBlkParam[SAO_Y].modeIdc = saoBlkParam[SAO_Cb].modeIdc = saoBlkParam[SAO_Cr].modeIdc = SAO_MODE_MERGE; 1888 saoBlkParam[SAO_Y].typeIdc = saoBlkParam[SAO_Cb].typeIdc = saoBlkParam[SAO_Cr].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; 1889 } 2090 { 2091 for (UInt componentIndex = 0; componentIndex < MAX_NUM_COMPONENT; componentIndex++) 2092 { 2093 saoBlkParam[componentIndex].modeIdc = (sliceEnabled[componentIndex]) ? SAO_MODE_MERGE : SAO_MODE_OFF; 2094 saoBlkParam[componentIndex].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; 2095 } 2096 } 1890 2097 else //new or off mode 1891 { 1892 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 1893 { 2098 { 2099 for(Int compId=COMPONENT_Y; compId < MAX_NUM_COMPONENT; compId++) 2100 { 2101 const ComponentID compIdx=ComponentID(compId); 2102 const ComponentID firstCompOfChType = getFirstComponentOfChannel(toChannelType(compIdx)); 1894 2103 SAOOffset& ctbParam = saoBlkParam[compIdx]; 1895 2104 #if O0043_BEST_EFFORT_DECODING 2105 const Int bitDepthOrig = bitDepths.stream[toChannelType(compIdx)]; 2106 const Int forceBitDepthAdjust = bitDepthOrig - bitDepths.recon[toChannelType(compIdx)]; 2107 #else 2108 const Int bitDepthOrig = bitDepths.recon[toChannelType(compIdx)]; 2109 #endif 2110 const Int maxOffsetQVal=TComSampleAdaptiveOffset::getMaxOffsetQVal(bitDepthOrig); 1896 2111 if(!sliceEnabled[compIdx]) 1897 2112 { 1898 2113 //off 1899 2114 ctbParam.modeIdc = SAO_MODE_OFF; 1900 2115 continue; 1901 2116 } 1902 2117 1903 2118 //type 1904 if(compIdx == SAO_Y || compIdx == SAO_Cb)1905 {2119 if(compIdx == firstCompOfChType) 2120 { 1906 2121 parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma 1907 2122 … … 1909 2124 1910 2125 if(uiSymbol ==0) //OFF 1911 {2126 { 1912 2127 ctbParam.modeIdc = SAO_MODE_OFF; 1913 }2128 } 1914 2129 else if(uiSymbol == 1) //BO 1915 2130 { 1916 2131 ctbParam.modeIdc = SAO_MODE_NEW; 1917 2132 ctbParam.typeIdc = SAO_TYPE_START_BO; 1918 }2133 } 1919 2134 else //2, EO 1920 {2135 { 1921 2136 ctbParam.modeIdc = SAO_MODE_NEW; 1922 2137 ctbParam.typeIdc = SAO_TYPE_START_EO; 1923 2138 } 1924 2139 1925 }2140 } 1926 2141 else //Cr, follow Cb SAO type 1927 2142 { 1928 ctbParam.modeIdc = saoBlkParam[ SAO_Cb].modeIdc;1929 ctbParam.typeIdc = saoBlkParam[ SAO_Cb].typeIdc;1930 }2143 ctbParam.modeIdc = saoBlkParam[COMPONENT_Cb].modeIdc; 2144 ctbParam.typeIdc = saoBlkParam[COMPONENT_Cb].typeIdc; 2145 } 1931 2146 1932 2147 if(ctbParam.modeIdc == SAO_MODE_NEW) 1933 {2148 { 1934 2149 Int offset[4]; 1935 2150 for(Int i=0; i< 4; i++) 1936 {1937 parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx]); //sao_offset_abs2151 { 2152 parseSaoMaxUvlc(uiSymbol, maxOffsetQVal ); //sao_offset_abs 1938 2153 offset[i] = (Int)uiSymbol; 1939 }2154 } 1940 2155 1941 2156 if(ctbParam.typeIdc == SAO_TYPE_START_BO) 1942 {2157 { 1943 2158 for(Int i=0; i< 4; i++) 1944 {2159 { 1945 2160 if(offset[i] != 0) 1946 {2161 { 1947 2162 parseSaoSign(uiSymbol); //sao_offset_sign 1948 2163 if(uiSymbol) 1949 { 2164 { 2165 #if O0043_BEST_EFFORT_DECODING 2166 offset[i] >>= forceBitDepthAdjust; 2167 #endif 1950 2168 offset[i] = -offset[i]; 1951 }1952 }1953 }2169 } 2170 } 2171 } 1954 2172 parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position 1955 2173 ctbParam.typeAuxInfo = uiSymbol; 1956 2174 1957 2175 for(Int i=0; i<4; i++) 1958 {2176 { 1959 2177 ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; 1960 }2178 } 1961 2179 1962 2180 } … … 1965 2183 ctbParam.typeAuxInfo = 0; 1966 2184 1967 if( compIdx == SAO_Y || compIdx == SAO_Cb)1968 {2185 if(firstCompOfChType == compIdx) 2186 { 1969 2187 parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma 1970 2188 ctbParam.typeIdc += uiSymbol; 1971 }1972 else1973 {1974 ctbParam.typeIdc = saoBlkParam[ SAO_Cb].typeIdc;1975 }2189 } 2190 else 2191 { 2192 ctbParam.typeIdc = saoBlkParam[firstCompOfChType].typeIdc; 2193 } 1976 2194 ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; 1977 2195 ctbParam.offset[SAO_CLASS_EO_HALF_VALLEY] = offset[1]; … … 1979 2197 ctbParam.offset[SAO_CLASS_EO_HALF_PEAK ] = -offset[2]; 1980 2198 ctbParam.offset[SAO_CLASS_EO_FULL_PEAK ] = -offset[3]; 1981 }2199 } 1982 2200 } 1983 2201 } … … 1990 2208 \param pSrc Contexts to be copied. 1991 2209 */ 1992 Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc )2210 Void TDecSbac::xCopyContextsFrom( const TDecSbac* pSrc ) 1993 2211 { 1994 2212 memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); 1995 } 1996 1997 Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) 2213 memcpy(m_golombRiceAdaptationStatistics, pSrc->m_golombRiceAdaptationStatistics, (sizeof(UInt) * RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS)); 2214 } 2215 2216 Void TDecSbac::xCopyFrom( const TDecSbac* pSrc ) 1998 2217 { 1999 2218 m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); 2000 2001 m_uiLastQp = pSrc->m_uiLastQp;2002 2219 xCopyContextsFrom( pSrc ); 2003 2004 } 2005 2006 Void TDecSbac::load ( TDecSbac* pScr ) 2007 { 2008 xCopyFrom(pScr); 2009 } 2010 2011 Void TDecSbac::loadContexts ( TDecSbac* pScr ) 2012 { 2013 xCopyContextsFrom(pScr); 2014 } 2015 2016 #if H_3D_ARP 2220 } 2221 2222 Void TDecSbac::load ( const TDecSbac* pSrc ) 2223 { 2224 xCopyFrom(pSrc); 2225 } 2226 2227 Void TDecSbac::loadContexts ( const TDecSbac* pSrc ) 2228 { 2229 xCopyContextsFrom(pSrc); 2230 } 2231 2232 /** Performs CABAC decoding of the explicit RDPCM mode 2233 * \param rTu current TU data structure 2234 * \param compID component identifier 2235 */ 2236 Void TDecSbac::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) 2237 { 2238 TComDataCU* cu = rTu.getCU(); 2239 const UInt absPartIdx=rTu.GetAbsPartIdxTU(compID); 2240 const TComRectangle &rect = rTu.getRect(compID); 2241 const UInt tuHeight = g_aucConvertToBit[rect.height]; 2242 const UInt tuWidth = g_aucConvertToBit[rect.width]; 2243 UInt code = 0; 2244 2245 assert(tuHeight == tuWidth); 2246 2247 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2248 const TComCodingStatisticsClassType ctype(STATS__EXPLICIT_RDPCM_BITS, g_aucConvertToBit[cu->getSlice()->getSPS()->getMaxCUWidth()>>rTu.GetTransformDepthTotal()]+2); 2249 #endif 2250 2251 m_pcTDecBinIf->decodeBin(code, m_explicitRdpcmFlagSCModel.get (0, toChannelType(compID), 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 2252 2253 if(code == 0) 2254 { 2255 cu->setExplicitRdpcmModePartRange( RDPCM_OFF, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); 2256 } 2257 else 2258 { 2259 m_pcTDecBinIf->decodeBin(code, m_explicitRdpcmDirSCModel.get (0, toChannelType(compID), 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 2260 if(code == 0) 2261 { 2262 cu->setExplicitRdpcmModePartRange( RDPCM_HOR, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); 2263 } 2264 else 2265 { 2266 cu->setExplicitRdpcmModePartRange( RDPCM_VER, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); 2267 } 2268 } 2269 } 2270 2271 #if NH_3D_ARP 2017 2272 Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2018 2273 { 2019 UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1;2020 2274 UInt uiW = 0; 2021 2275 UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx); 2022 2276 UInt uiCode = 0; 2023 2277 2024 assert ( uiMaxW > 0 ); 2025 2026 m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) ); 2278 m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG)); 2027 2279 2028 2280 uiW = uiCode; 2029 2281 if( 1 == uiW ) 2030 2282 { 2031 m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) );2283 m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG)); 2032 2284 uiW += ( 1 == uiCode ? 1 : 0 ); 2033 2285 } … … 2039 2291 #endif 2040 2292 2041 #if H_3D_IC2293 #if NH_3D_IC 2042 2294 /** parse illumination compensation flag 2043 2295 * \param pcCU … … 2049 2301 { 2050 2302 UInt uiSymbol = 0; 2051 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) ); 2303 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__3D_IC) ); 2304 2052 2305 #if !H_MV_ENC_DEC_TRAC 2053 2306 DTRACE_CABAC_VL( g_nSymbolCounter++ ); … … 2066 2319 #endif 2067 2320 2068 #if H_3D_INTER_SDC2321 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER 2069 2322 Void TDecSbac::parseDeltaDC( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 2070 2323 { 2071 if( ! ( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) ) 2072 { 2324 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER 2325 if( !(pcCU->getSDCFlag( absPartIdx )) ) 2326 #endif 2327 #if NH_3D_DMM 2328 if( !(pcCU->isIntra( absPartIdx ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) )) ) 2329 #endif 2073 2330 assert( 0 ); 2074 }2075 2331 2076 2332 UInt symbol = 1; 2077 UInt uiNumSegments = isDimMode( pcCU->getLumaIntraDir( absPartIdx ) ) ? 2 : 1; 2078 2333 #if NH_3D_SDC_INTRA 2079 2334 if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx )) 2080 2335 { 2081 2082 m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, 0 ) ); 2083 assert( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N ); 2084 pcCU->setTrIdxSubParts( 0, absPartIdx, depth ); 2085 pcCU->setCbfSubParts( 1, 1, 1, absPartIdx, depth ); 2086 } 2336 m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SDC_DELTADC_FLAG) ); 2337 assert( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N ); 2338 assert( pcCU->getTransformIdx(absPartIdx) == 0 ); 2339 assert( pcCU->getCbf(absPartIdx, COMPONENT_Y) == 1 ); 2340 } 2341 #endif 2342 UInt uiNumSegments = 1; 2343 #if NH_3D_DMM 2344 uiNumSegments = isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ) ? 2 : 1; 2345 #endif 2087 2346 2088 2347 for( UInt segment = 0; segment < uiNumSegments; segment++ ) … … 2091 2350 if( symbol ) 2092 2351 { 2093 xParseD imDeltaDC( valDeltaDC, uiNumSegments );2352 xParseDeltaDC( valDeltaDC, uiNumSegments ); 2094 2353 } 2095 2354 2096 2355 if( pcCU->isIntra( absPartIdx ) ) 2097 2356 { 2098 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 2099 2357 #if NH_3D_SDC_INTRA 2100 2358 if( pcCU->getSDCFlag( absPartIdx ) ) 2101 2359 { … … 2104 2362 else 2105 2363 { 2106 pcCU->setDimDeltaDC( getDimType( dir ), segment, absPartIdx, valDeltaDC ); 2107 } 2108 } 2364 #endif 2365 #if NH_3D_DMM 2366 pcCU->setDmmDeltaDC( getDmmType( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ), segment, absPartIdx, valDeltaDC ); 2367 #endif 2368 #if NH_3D_SDC_INTRA 2369 } 2370 #endif 2371 } 2372 #if NH_3D_SDC_INTER 2109 2373 else 2110 2374 { 2111 2375 pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx ); 2112 2376 } 2113 } 2114 } 2115 2377 #endif 2378 } 2379 } 2380 2381 Void TDecSbac::xParseDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg ) 2382 { 2383 UInt absValDeltaDC = 0; 2384 xReadExGolombLevelDdc( absValDeltaDC ); 2385 rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 ); 2386 2387 if( rValDeltaDC != 0 ) 2388 { 2389 UInt uiSign; 2390 m_pcTDecBinIf->decodeBinEP( uiSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTADC_SIGN_EP) ); 2391 if ( uiSign ) 2392 { 2393 rValDeltaDC = -rValDeltaDC; 2394 } 2395 } 2396 #if H_MV_ENC_DEC_TRAC 2397 DTRACE_CU("delta_dc", rValDeltaDC); 2398 #endif 2399 } 2400 2401 Void TDecSbac::xReadExGolombLevelDdc( UInt& ruiSymbol ) 2402 { 2403 UInt uiSymbol; 2404 UInt uiCount = 0; 2405 do 2406 { 2407 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDdcDataSCModel.get(0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTADC_PREFIX) ); 2408 uiCount++; 2409 } 2410 while( uiSymbol && ( uiCount != 3 ) ); 2411 ruiSymbol = uiCount - 1; 2412 2413 if( uiSymbol ) 2414 { 2415 xReadEpExGolomb( uiSymbol, 0 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTADC_SUFFIX_EP) ); 2416 ruiSymbol += uiSymbol + 1; 2417 } 2418 2419 return; 2420 } 2421 #endif 2422 #if NH_3D_DMM 2423 Void TDecSbac::xParseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 2424 { 2425 pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, 0, absPartIdx, depth ); 2426 2427 UInt uiSymbol; 2428 if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed 2429 { 2430 m_pcTDecBinIf->decodeBin( uiSymbol, m_cNotDmmFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__NOTDMM_FLAG) ); 2431 } 2432 else 2433 { 2434 uiSymbol = 1; 2435 } 2436 2437 //decode DMM mode index 2438 if( !uiSymbol ) 2439 { 2440 if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag() ) 2441 { 2442 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DMMMODE) ); 2443 if( !uiSymbol ) 2444 { 2445 pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, DMM_OFFSET, absPartIdx, depth ); 2446 } 2447 else 2448 { 2449 pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, ( 1+ DMM_OFFSET ), absPartIdx, depth ); 2450 } 2451 } 2452 else if( pcCU->getSlice()->getIntraSdcWedgeFlag() ) 2453 { 2454 pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, DMM_OFFSET, absPartIdx, depth ); 2455 } 2456 else if( pcCU->getSlice()->getIntraContourFlag() ) 2457 { 2458 pcCU->setIntraDirSubParts( CHANNEL_TYPE_LUMA, ( 1+ DMM_OFFSET ), absPartIdx, depth ); 2459 } 2460 } 2461 } 2462 2463 Void TDecSbac::xParseDmmData( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 2464 { 2465 UInt dir = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ); 2466 switch( getDmmType( dir ) ) 2467 { 2468 case( DMM1_IDX ): 2469 { 2470 UInt uiTabIdx = 0; 2471 xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 2472 assert( uiTabIdx < getWedgeListScaled( pcCU->getWidth( absPartIdx ) )->size() ); 2473 pcCU->setDmm1WedgeTabIdxSubParts( uiTabIdx, absPartIdx, depth ); 2474 } break; 2475 case( DMM4_IDX ): break; 2476 default: break; 2477 } 2478 } 2479 2480 Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit ) 2481 { 2482 UInt uiSymbol, uiIdx = 0; 2483 for( Int i = 0; i < iNumBit; i++ ) 2484 { 2485 m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DMM1_BITS_EP) ); 2486 uiIdx += uiSymbol << i; 2487 } 2488 ruiTabIdx = uiIdx; 2489 } 2490 #endif 2491 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER 2116 2492 Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2117 2493 { 2118 2494 UInt uiSymbol = 0; 2119 UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); 2120 2121 m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); 2495 2496 m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SDC_INTRA_FLAG) ); 2497 #if H_MV_ENC_DEC_TRAC 2122 2498 DTRACE_CU("dc_only_flag", uiSymbol) 2499 #endif 2123 2500 if( uiSymbol ) 2124 2501 { 2125 2502 pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, uiDepth ); 2126 2503 pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); 2127 pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth);2504 pcCU->setCbfSubParts(1, COMPONENT_Y, uiAbsPartIdx, uiDepth); 2128 2505 } 2129 2506 else … … 2135 2512 #endif 2136 2513 2137 #if H_3D_DBBP2514 #if NH_3D_DBBP 2138 2515 Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2139 2516 { … … 2143 2520 UInt uiSymbol = 0; 2144 2521 2145 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );2522 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DBBP_FLAG) ); 2146 2523 DTRACE_CU("dbbp_flag", uiSymbol) 2147 2524 PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); 2148 2525 AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N ); 2149 UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMax CUDepth() - uiDepth ) << 1 ) ) >> 4;2526 UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; 2150 2527 pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx, 0, uiDepth); 2151 2528 pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx+uiPUOffset, 1, uiDepth); … … 2154 2531 2155 2532 2156 2157 2533 //! \}
Note: See TracChangeset for help on using the changeset viewer.