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