[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TDecSbac.cpp |
---|
| 35 | \brief Context-adaptive entropy decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecSbac.h" |
---|
| 39 | |
---|
| 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
| 43 | ////////////////////////////////////////////////////////////////////// |
---|
| 44 | // Construction/Destruction |
---|
| 45 | ////////////////////////////////////////////////////////////////////// |
---|
| 46 | |
---|
| 47 | TDecSbac::TDecSbac() |
---|
| 48 | // new structure here |
---|
| 49 | : m_pcBitstream ( 0 ) |
---|
| 50 | , m_pcTDecBinIf ( NULL ) |
---|
| 51 | , m_numContextModels ( 0 ) |
---|
| 52 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) |
---|
| 53 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 54 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 55 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 56 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 57 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 58 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 59 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 60 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 61 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 62 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 63 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 64 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 65 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 66 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 67 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 68 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 69 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 70 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 71 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 72 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 73 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 74 | , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 75 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 76 | , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 77 | , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 78 | { |
---|
| 79 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | TDecSbac::~TDecSbac() |
---|
| 83 | { |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | // ==================================================================================================================== |
---|
| 87 | // Public member functions |
---|
| 88 | // ==================================================================================================================== |
---|
| 89 | |
---|
| 90 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
| 91 | { |
---|
| 92 | SliceType sliceType = pSlice->getSliceType(); |
---|
| 93 | Int qp = pSlice->getSliceQp(); |
---|
| 94 | |
---|
| 95 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
| 96 | { |
---|
| 97 | switch (sliceType) |
---|
| 98 | { |
---|
| 99 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
| 100 | sliceType = B_SLICE; |
---|
| 101 | break; |
---|
| 102 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
| 103 | sliceType = P_SLICE; |
---|
| 104 | break; |
---|
| 105 | default : // should not occur |
---|
| 106 | assert(0); |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
| 111 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
| 112 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
| 113 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
| 114 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
| 115 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
| 116 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
| 117 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
| 118 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
| 119 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
| 120 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
| 121 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
| 122 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
| 123 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
| 124 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
| 125 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
| 126 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
| 127 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
| 128 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
| 129 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
| 130 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
| 131 | m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
| 132 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
| 133 | |
---|
| 134 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
| 135 | m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
| 136 | m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
| 137 | m_uiLastDQpNonZero = 0; |
---|
| 138 | |
---|
| 139 | // new structure |
---|
| 140 | m_uiLastQp = qp; |
---|
| 141 | |
---|
| 142 | m_pcTDecBinIf->start(); |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile. |
---|
| 146 | * Intialize CABAC states. Start CABAC. |
---|
| 147 | */ |
---|
| 148 | Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp ) |
---|
| 149 | { |
---|
| 150 | UInt uiBit; |
---|
| 151 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
| 152 | assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1 |
---|
| 153 | m_pcTDecBinIf->finish(); |
---|
| 154 | m_pcBitstream->readOutTrailingBits(); |
---|
| 155 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
| 156 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
| 157 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
| 158 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
| 159 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
| 160 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
| 161 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
| 162 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
| 163 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
| 164 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
| 165 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
| 166 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
| 167 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
| 168 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
| 169 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
| 170 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
| 171 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
| 172 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
| 173 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
| 174 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
| 175 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
| 176 | m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
| 177 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
| 178 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
| 179 | m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
| 180 | m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
| 181 | m_pcTDecBinIf->start(); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
| 185 | { |
---|
| 186 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
| 187 | if ( ruiBit ) |
---|
| 188 | { |
---|
| 189 | m_pcTDecBinIf->finish(); |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
| 195 | { |
---|
| 196 | if (uiMaxSymbol == 0) |
---|
| 197 | { |
---|
| 198 | ruiSymbol = 0; |
---|
| 199 | return; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
| 203 | |
---|
| 204 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
| 205 | { |
---|
| 206 | return; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | UInt uiSymbol = 0; |
---|
| 210 | UInt uiCont; |
---|
| 211 | |
---|
| 212 | do |
---|
| 213 | { |
---|
| 214 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
| 215 | uiSymbol++; |
---|
| 216 | } |
---|
| 217 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
| 218 | |
---|
| 219 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
| 220 | { |
---|
| 221 | uiSymbol++; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | ruiSymbol = uiSymbol; |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
| 228 | { |
---|
| 229 | UInt uiSymbol = 0; |
---|
| 230 | UInt uiBit = 1; |
---|
| 231 | |
---|
| 232 | while( uiBit ) |
---|
| 233 | { |
---|
| 234 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
| 235 | uiSymbol += uiBit << uiCount++; |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | if ( --uiCount ) |
---|
| 239 | { |
---|
| 240 | UInt bins; |
---|
| 241 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount ); |
---|
| 242 | uiSymbol += bins; |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | ruiSymbol = uiSymbol; |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
| 249 | { |
---|
| 250 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
| 251 | |
---|
| 252 | if( !ruiSymbol ) |
---|
| 253 | { |
---|
| 254 | return; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | UInt uiSymbol = 0; |
---|
| 258 | UInt uiCont; |
---|
| 259 | |
---|
| 260 | do |
---|
| 261 | { |
---|
| 262 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
| 263 | uiSymbol++; |
---|
| 264 | } |
---|
| 265 | while( uiCont ); |
---|
| 266 | |
---|
| 267 | ruiSymbol = uiSymbol; |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | /** Parsing of coeff_abs_level_remaing |
---|
| 272 | * \param ruiSymbol reference to coeff_abs_level_remaing |
---|
| 273 | * \param ruiParam reference to parameter |
---|
| 274 | * \returns Void |
---|
| 275 | */ |
---|
| 276 | Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ) |
---|
| 277 | { |
---|
| 278 | |
---|
| 279 | UInt prefix = 0; |
---|
| 280 | UInt codeWord = 0; |
---|
| 281 | do |
---|
| 282 | { |
---|
| 283 | prefix++; |
---|
| 284 | m_pcTDecBinIf->decodeBinEP( codeWord ); |
---|
| 285 | } |
---|
| 286 | while( codeWord); |
---|
| 287 | codeWord = 1 - codeWord; |
---|
| 288 | prefix -= codeWord; |
---|
| 289 | codeWord=0; |
---|
| 290 | if (prefix < COEF_REMAIN_BIN_REDUCTION ) |
---|
| 291 | { |
---|
| 292 | m_pcTDecBinIf->decodeBinsEP(codeWord,rParam); |
---|
| 293 | rSymbol = (prefix<<rParam) + codeWord; |
---|
| 294 | } |
---|
| 295 | else |
---|
| 296 | { |
---|
| 297 | m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam); |
---|
| 298 | rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | /** Parse I_PCM information. |
---|
| 303 | * \param pcCU |
---|
| 304 | * \param uiAbsPartIdx |
---|
| 305 | * \param uiDepth |
---|
| 306 | * \returns Void |
---|
| 307 | * |
---|
| 308 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 309 | */ |
---|
| 310 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 311 | { |
---|
| 312 | UInt uiSymbol; |
---|
| 313 | |
---|
| 314 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
| 315 | |
---|
| 316 | if (uiSymbol) |
---|
| 317 | { |
---|
| 318 | Bool bIpcmFlag = true; |
---|
| 319 | |
---|
| 320 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 321 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 322 | pcCU->setTrIdxSubParts ( 0, uiAbsPartIdx, uiDepth ); |
---|
| 323 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
| 324 | |
---|
| 325 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 326 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 327 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
| 328 | |
---|
| 329 | Pel* piPCMSample; |
---|
| 330 | UInt uiWidth; |
---|
| 331 | UInt uiHeight; |
---|
| 332 | UInt uiSampleBits; |
---|
| 333 | UInt uiX, uiY; |
---|
| 334 | |
---|
| 335 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
| 336 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 337 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 338 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 339 | |
---|
| 340 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 341 | { |
---|
| 342 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 343 | { |
---|
| 344 | UInt uiSample; |
---|
| 345 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 346 | piPCMSample[uiX] = uiSample; |
---|
| 347 | } |
---|
| 348 | piPCMSample += uiWidth; |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
| 352 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 353 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 354 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
[494] | 355 | #if AUXILIARY_PICTURES |
---|
| 356 | ChromaFormat format = pcCU->getSlice()->getChromaFormatIdc(); |
---|
| 357 | UInt uiGrayVal = 1 << (uiSampleBits - 1); |
---|
| 358 | #endif |
---|
[313] | 359 | |
---|
| 360 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 361 | { |
---|
| 362 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 363 | { |
---|
| 364 | UInt uiSample; |
---|
[494] | 365 | #if AUXILIARY_PICTURES |
---|
| 366 | if (format == CHROMA_400) |
---|
[540] | 367 | { |
---|
[494] | 368 | uiSample = uiGrayVal; |
---|
[540] | 369 | } |
---|
[494] | 370 | else |
---|
| 371 | #endif |
---|
[313] | 372 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 373 | piPCMSample[uiX] = uiSample; |
---|
| 374 | } |
---|
| 375 | piPCMSample += uiWidth; |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
| 379 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 380 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 381 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 382 | |
---|
| 383 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 384 | { |
---|
| 385 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 386 | { |
---|
| 387 | UInt uiSample; |
---|
[494] | 388 | #if AUXILIARY_PICTURES |
---|
| 389 | if (format == CHROMA_400) |
---|
[540] | 390 | { |
---|
[494] | 391 | uiSample = uiGrayVal; |
---|
[540] | 392 | } |
---|
[494] | 393 | else |
---|
| 394 | #endif |
---|
[313] | 395 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 396 | piPCMSample[uiX] = uiSample; |
---|
| 397 | } |
---|
| 398 | piPCMSample += uiWidth; |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | m_pcTDecBinIf->start(); |
---|
| 402 | } |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | Void TDecSbac::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 406 | { |
---|
| 407 | UInt uiSymbol; |
---|
| 408 | m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) ); |
---|
| 409 | pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); |
---|
| 410 | } |
---|
| 411 | |
---|
| 412 | /** parse skip flag |
---|
| 413 | * \param pcCU |
---|
| 414 | * \param uiAbsPartIdx |
---|
| 415 | * \param uiDepth |
---|
| 416 | * \returns Void |
---|
| 417 | */ |
---|
| 418 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 419 | { |
---|
| 420 | if( pcCU->getSlice()->isIntra() ) |
---|
| 421 | { |
---|
| 422 | return; |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | UInt uiSymbol = 0; |
---|
| 426 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
| 427 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
| 428 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 429 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
| 430 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
| 431 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
| 432 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
| 433 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 434 | DTRACE_CABAC_T( "\n"); |
---|
| 435 | |
---|
| 436 | if( uiSymbol ) |
---|
| 437 | { |
---|
| 438 | pcCU->setSkipFlagSubParts( true, uiAbsPartIdx, uiDepth ); |
---|
| 439 | pcCU->setPredModeSubParts( MODE_INTER, uiAbsPartIdx, uiDepth ); |
---|
| 440 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 441 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 442 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
| 443 | } |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | /** parse merge flag |
---|
| 447 | * \param pcCU |
---|
| 448 | * \param uiAbsPartIdx |
---|
| 449 | * \param uiDepth |
---|
| 450 | * \param uiPUIdx |
---|
| 451 | * \returns Void |
---|
| 452 | */ |
---|
| 453 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 454 | { |
---|
| 455 | UInt uiSymbol; |
---|
| 456 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
| 457 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 458 | |
---|
| 459 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 460 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
| 461 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 462 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
| 463 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
| 464 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
| 465 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 466 | DTRACE_CABAC_T( "\n" ); |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ) |
---|
| 470 | { |
---|
| 471 | UInt uiUnaryIdx = 0; |
---|
| 472 | UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
| 473 | if ( uiNumCand > 1 ) |
---|
| 474 | { |
---|
| 475 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
| 476 | { |
---|
| 477 | UInt uiSymbol = 0; |
---|
| 478 | if ( uiUnaryIdx==0 ) |
---|
| 479 | { |
---|
| 480 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
| 481 | } |
---|
| 482 | else |
---|
| 483 | { |
---|
| 484 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 485 | } |
---|
| 486 | if( uiSymbol == 0 ) |
---|
| 487 | { |
---|
| 488 | break; |
---|
| 489 | } |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | ruiMergeIndex = uiUnaryIdx; |
---|
| 493 | |
---|
| 494 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 495 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
| 496 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
| 497 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
| 498 | DTRACE_CABAC_T( "\n" ) |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
| 502 | { |
---|
| 503 | UInt uiSymbol; |
---|
| 504 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1); |
---|
| 505 | riMVPIdx = uiSymbol; |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 509 | { |
---|
| 510 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 511 | { |
---|
| 512 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
| 513 | return; |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | UInt uiSymbol; |
---|
| 517 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
| 518 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 519 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
| 520 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
| 521 | |
---|
| 522 | return; |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | /** parse partition size |
---|
| 526 | * \param pcCU |
---|
| 527 | * \param uiAbsPartIdx |
---|
| 528 | * \param uiDepth |
---|
| 529 | * \returns Void |
---|
| 530 | */ |
---|
| 531 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 532 | { |
---|
| 533 | UInt uiSymbol, uiMode = 0; |
---|
| 534 | PartSize eMode; |
---|
[345] | 535 | |
---|
[313] | 536 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 537 | { |
---|
| 538 | uiSymbol = 1; |
---|
| 539 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 540 | { |
---|
| 541 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
| 542 | } |
---|
| 543 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
| 544 | UInt uiTrLevel = 0; |
---|
| 545 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
| 546 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
| 547 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
| 548 | if( eMode == SIZE_NxN ) |
---|
| 549 | { |
---|
| 550 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 551 | } |
---|
| 552 | else |
---|
| 553 | { |
---|
| 554 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 555 | } |
---|
| 556 | } |
---|
| 557 | else |
---|
| 558 | { |
---|
| 559 | UInt uiMaxNumBits = 2; |
---|
| 560 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
| 561 | { |
---|
| 562 | uiMaxNumBits ++; |
---|
| 563 | } |
---|
| 564 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
| 565 | { |
---|
| 566 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
| 567 | if ( uiSymbol ) |
---|
| 568 | { |
---|
| 569 | break; |
---|
| 570 | } |
---|
| 571 | uiMode++; |
---|
| 572 | } |
---|
| 573 | eMode = (PartSize) uiMode; |
---|
| 574 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
| 575 | { |
---|
| 576 | if (eMode == SIZE_2NxN) |
---|
| 577 | { |
---|
[595] | 578 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
[313] | 579 | if (uiSymbol == 0) |
---|
| 580 | { |
---|
| 581 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
| 582 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
| 583 | } |
---|
| 584 | } |
---|
| 585 | else if (eMode == SIZE_Nx2N) |
---|
| 586 | { |
---|
[595] | 587 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); |
---|
[313] | 588 | if (uiSymbol == 0) |
---|
| 589 | { |
---|
| 590 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
| 591 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
| 592 | } |
---|
| 593 | } |
---|
| 594 | } |
---|
| 595 | } |
---|
| 596 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
| 597 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 598 | } |
---|
| 599 | |
---|
| 600 | /** parse prediction mode |
---|
| 601 | * \param pcCU |
---|
| 602 | * \param uiAbsPartIdx |
---|
| 603 | * \param uiDepth |
---|
| 604 | * \returns Void |
---|
| 605 | */ |
---|
| 606 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 607 | { |
---|
| 608 | if( pcCU->getSlice()->isIntra() ) |
---|
| 609 | { |
---|
| 610 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
| 611 | return; |
---|
| 612 | } |
---|
| 613 | |
---|
| 614 | UInt uiSymbol; |
---|
| 615 | Int iPredMode = MODE_INTER; |
---|
| 616 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
| 617 | iPredMode += uiSymbol; |
---|
| 618 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
| 622 | { |
---|
| 623 | PartSize mode = pcCU->getPartitionSize( absPartIdx ); |
---|
| 624 | UInt partNum = mode==SIZE_NxN?4:1; |
---|
| 625 | UInt partOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; |
---|
| 626 | UInt mpmPred[4],symbol; |
---|
| 627 | Int j,intraPredMode; |
---|
| 628 | if (mode==SIZE_NxN) |
---|
| 629 | { |
---|
| 630 | depth++; |
---|
| 631 | } |
---|
| 632 | for (j=0;j<partNum;j++) |
---|
| 633 | { |
---|
| 634 | m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
| 635 | mpmPred[j] = symbol; |
---|
| 636 | } |
---|
| 637 | for (j=0;j<partNum;j++) |
---|
| 638 | { |
---|
| 639 | Int preds[3] = {-1, -1, -1}; |
---|
| 640 | Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds); |
---|
| 641 | if (mpmPred[j]) |
---|
| 642 | { |
---|
| 643 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
| 644 | if (symbol) |
---|
| 645 | { |
---|
| 646 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
| 647 | symbol++; |
---|
| 648 | } |
---|
| 649 | intraPredMode = preds[symbol]; |
---|
| 650 | } |
---|
| 651 | else |
---|
| 652 | { |
---|
| 653 | m_pcTDecBinIf->decodeBinsEP( symbol, 5 ); |
---|
| 654 | intraPredMode = symbol; |
---|
| 655 | |
---|
| 656 | //postponed sorting of MPMs (only in remaining branch) |
---|
| 657 | if (preds[0] > preds[1]) |
---|
| 658 | { |
---|
| 659 | std::swap(preds[0], preds[1]); |
---|
| 660 | } |
---|
| 661 | if (preds[0] > preds[2]) |
---|
| 662 | { |
---|
| 663 | std::swap(preds[0], preds[2]); |
---|
| 664 | } |
---|
| 665 | if (preds[1] > preds[2]) |
---|
| 666 | { |
---|
| 667 | std::swap(preds[1], preds[2]); |
---|
| 668 | } |
---|
| 669 | for ( Int i = 0; i < predNum; i++ ) |
---|
| 670 | { |
---|
| 671 | intraPredMode += ( intraPredMode >= preds[i] ); |
---|
| 672 | } |
---|
| 673 | } |
---|
| 674 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); |
---|
| 675 | } |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 679 | { |
---|
| 680 | UInt uiSymbol; |
---|
| 681 | |
---|
[494] | 682 | #if AUXILIARY_PICTURES |
---|
| 683 | if ( pcCU->getSlice()->getChromaFormatIdc() == CHROMA_400 ) |
---|
| 684 | { |
---|
| 685 | uiSymbol = DC_IDX; |
---|
| 686 | } |
---|
| 687 | else |
---|
| 688 | { |
---|
| 689 | #endif |
---|
[313] | 690 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
| 691 | |
---|
| 692 | if( uiSymbol == 0 ) |
---|
| 693 | { |
---|
| 694 | uiSymbol = DM_CHROMA_IDX; |
---|
| 695 | } |
---|
| 696 | else |
---|
| 697 | { |
---|
| 698 | { |
---|
| 699 | UInt uiIPredMode; |
---|
| 700 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
| 701 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
| 702 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
| 703 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
| 704 | } |
---|
| 705 | } |
---|
[494] | 706 | #if AUXILIARY_PICTURES |
---|
| 707 | } |
---|
| 708 | #endif |
---|
[313] | 709 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
| 710 | return; |
---|
| 711 | } |
---|
| 712 | |
---|
| 713 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) |
---|
| 714 | { |
---|
| 715 | UInt uiSymbol; |
---|
| 716 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
| 717 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
| 718 | uiSymbol = 0; |
---|
| 719 | if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) |
---|
| 720 | { |
---|
| 721 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | if( uiSymbol ) |
---|
| 725 | { |
---|
| 726 | uiSymbol = 2; |
---|
| 727 | } |
---|
| 728 | else |
---|
| 729 | { |
---|
| 730 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) ); |
---|
| 731 | assert(uiSymbol == 0 || uiSymbol == 1); |
---|
| 732 | } |
---|
| 733 | |
---|
| 734 | uiSymbol++; |
---|
| 735 | ruiInterDir = uiSymbol; |
---|
| 736 | return; |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) |
---|
| 740 | { |
---|
| 741 | UInt uiSymbol; |
---|
| 742 | { |
---|
| 743 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
| 744 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 745 | |
---|
| 746 | if( uiSymbol ) |
---|
| 747 | { |
---|
| 748 | UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; |
---|
| 749 | pCtx++; |
---|
| 750 | UInt ui; |
---|
| 751 | for( ui = 0; ui < uiRefNum; ++ui ) |
---|
| 752 | { |
---|
| 753 | if( ui == 0 ) |
---|
| 754 | { |
---|
| 755 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 756 | } |
---|
| 757 | else |
---|
| 758 | { |
---|
| 759 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 760 | } |
---|
| 761 | if( uiSymbol == 0 ) |
---|
| 762 | { |
---|
| 763 | break; |
---|
| 764 | } |
---|
| 765 | } |
---|
| 766 | uiSymbol = ui + 1; |
---|
| 767 | } |
---|
| 768 | riRefFrmIdx = uiSymbol; |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | return; |
---|
| 772 | } |
---|
| 773 | |
---|
| 774 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
| 775 | { |
---|
| 776 | UInt uiSymbol; |
---|
| 777 | UInt uiHorAbs; |
---|
| 778 | UInt uiVerAbs; |
---|
| 779 | UInt uiHorSign = 0; |
---|
| 780 | UInt uiVerSign = 0; |
---|
| 781 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
| 782 | |
---|
| 783 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
| 784 | { |
---|
| 785 | uiHorAbs=0; |
---|
| 786 | uiVerAbs=0; |
---|
| 787 | } |
---|
| 788 | else |
---|
| 789 | { |
---|
| 790 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
| 791 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
| 792 | |
---|
| 793 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
| 794 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
| 795 | pCtx++; |
---|
| 796 | |
---|
| 797 | if( bHorAbsGr0 ) |
---|
| 798 | { |
---|
| 799 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 800 | uiHorAbs += uiSymbol; |
---|
| 801 | } |
---|
| 802 | |
---|
| 803 | if( bVerAbsGr0 ) |
---|
| 804 | { |
---|
| 805 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 806 | uiVerAbs += uiSymbol; |
---|
| 807 | } |
---|
| 808 | |
---|
| 809 | if( bHorAbsGr0 ) |
---|
| 810 | { |
---|
| 811 | if( 2 == uiHorAbs ) |
---|
| 812 | { |
---|
| 813 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 814 | uiHorAbs += uiSymbol; |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | if( bVerAbsGr0 ) |
---|
| 821 | { |
---|
| 822 | if( 2 == uiVerAbs ) |
---|
| 823 | { |
---|
| 824 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 825 | uiVerAbs += uiSymbol; |
---|
| 826 | } |
---|
| 827 | |
---|
| 828 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
| 829 | } |
---|
| 830 | |
---|
| 831 | } |
---|
| 832 | |
---|
| 833 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
| 834 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 835 | return; |
---|
| 836 | } |
---|
| 837 | |
---|
| 838 | |
---|
| 839 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
| 840 | { |
---|
| 841 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
| 842 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 843 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
| 844 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 845 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
| 846 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 847 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
| 848 | DTRACE_CABAC_T( "\n" ) |
---|
| 849 | } |
---|
| 850 | |
---|
| 851 | Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) |
---|
| 852 | { |
---|
| 853 | UInt uiSymbol; |
---|
| 854 | const UInt uiCtx = 0; |
---|
| 855 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
| 856 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 857 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
| 858 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 859 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 860 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 861 | DTRACE_CABAC_V( uiCtx ) |
---|
| 862 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 863 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 864 | DTRACE_CABAC_T( "\n" ) |
---|
| 865 | |
---|
| 866 | uiQtRootCbf = uiSymbol; |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 870 | { |
---|
| 871 | Int qp; |
---|
| 872 | UInt uiDQp; |
---|
| 873 | Int iDQp; |
---|
| 874 | |
---|
| 875 | UInt uiSymbol; |
---|
| 876 | |
---|
| 877 | xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX); |
---|
| 878 | |
---|
| 879 | if( uiDQp >= CU_DQP_TU_CMAX) |
---|
| 880 | { |
---|
| 881 | xReadEpExGolomb( uiSymbol, CU_DQP_EG_k ); |
---|
| 882 | uiDQp+=uiSymbol; |
---|
| 883 | } |
---|
| 884 | |
---|
| 885 | if ( uiDQp > 0 ) |
---|
| 886 | { |
---|
| 887 | UInt uiSign; |
---|
[442] | 888 | #if REPN_FORMAT_IN_VPS |
---|
| 889 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
| 890 | #else |
---|
[313] | 891 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
[442] | 892 | #endif |
---|
[313] | 893 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
| 894 | iDQp = uiDQp; |
---|
| 895 | if(uiSign) |
---|
| 896 | { |
---|
| 897 | iDQp = -iDQp; |
---|
| 898 | } |
---|
| 899 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
| 900 | } |
---|
| 901 | else |
---|
| 902 | { |
---|
| 903 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
| 904 | } |
---|
| 905 | pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); |
---|
| 906 | pcCU->setCodedQP(qp); |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
| 910 | { |
---|
| 911 | UInt uiSymbol; |
---|
| 912 | const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); |
---|
[494] | 913 | #if AUXILIARY_PICTURES |
---|
| 914 | if (pcCU->getSlice()->getChromaFormatIdc() == CHROMA_400 && (eType == TEXT_CHROMA_U || eType == TEXT_CHROMA_V)) |
---|
| 915 | { |
---|
| 916 | uiSymbol = 0; |
---|
| 917 | } |
---|
| 918 | else |
---|
| 919 | { |
---|
| 920 | #endif |
---|
[313] | 921 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
[494] | 922 | #if AUXILIARY_PICTURES |
---|
| 923 | } |
---|
| 924 | #endif |
---|
[313] | 925 | |
---|
| 926 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 927 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
| 928 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 929 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 930 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 931 | DTRACE_CABAC_V( uiCtx ) |
---|
| 932 | DTRACE_CABAC_T( "\tetype=" ) |
---|
| 933 | DTRACE_CABAC_V( eType ) |
---|
| 934 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 935 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 936 | DTRACE_CABAC_T( "\n" ) |
---|
| 937 | |
---|
| 938 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
| 939 | } |
---|
| 940 | |
---|
| 941 | void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) |
---|
| 942 | { |
---|
| 943 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
| 944 | { |
---|
| 945 | return; |
---|
| 946 | } |
---|
| 947 | if(width != 4 || height != 4) |
---|
| 948 | { |
---|
| 949 | return; |
---|
| 950 | } |
---|
| 951 | |
---|
| 952 | UInt useTransformSkip; |
---|
| 953 | m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); |
---|
| 954 | if(eTType!= TEXT_LUMA) |
---|
| 955 | { |
---|
| 956 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; |
---|
| 957 | if(uiLog2TrafoSize == 2) |
---|
| 958 | { |
---|
| 959 | uiDepth --; |
---|
| 960 | } |
---|
| 961 | } |
---|
| 962 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 963 | DTRACE_CABAC_T("\tparseTransformSkip()"); |
---|
| 964 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 965 | DTRACE_CABAC_V( useTransformSkip ) |
---|
| 966 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
| 967 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
| 968 | DTRACE_CABAC_T( "\tetype=" ) |
---|
| 969 | DTRACE_CABAC_V( eTType ) |
---|
| 970 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 971 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 972 | DTRACE_CABAC_T( "\n" ) |
---|
| 973 | |
---|
| 974 | pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); |
---|
| 975 | } |
---|
| 976 | |
---|
| 977 | /** Parse (X,Y) position of the last significant coefficient |
---|
| 978 | * \param uiPosLastX reference to X component of last coefficient |
---|
| 979 | * \param uiPosLastY reference to Y component of last coefficient |
---|
| 980 | * \param width Block width |
---|
| 981 | * \param height Block height |
---|
| 982 | * \param eTType plane type / luminance or chrominance |
---|
| 983 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
| 984 | * |
---|
| 985 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
| 986 | */ |
---|
| 987 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
| 988 | { |
---|
| 989 | UInt uiLast; |
---|
| 990 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
| 991 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
| 992 | |
---|
| 993 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
| 994 | blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2)); |
---|
| 995 | blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); |
---|
| 996 | shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2); |
---|
| 997 | shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); |
---|
| 998 | // posX |
---|
| 999 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
| 1000 | { |
---|
| 1001 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) ); |
---|
| 1002 | if( !uiLast ) |
---|
| 1003 | { |
---|
| 1004 | break; |
---|
| 1005 | } |
---|
| 1006 | } |
---|
| 1007 | |
---|
| 1008 | // posY |
---|
| 1009 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
| 1010 | { |
---|
| 1011 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) ); |
---|
| 1012 | if( !uiLast ) |
---|
| 1013 | { |
---|
| 1014 | break; |
---|
| 1015 | } |
---|
| 1016 | } |
---|
| 1017 | if ( uiPosLastX > 3 ) |
---|
| 1018 | { |
---|
| 1019 | UInt uiTemp = 0; |
---|
| 1020 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
| 1021 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1022 | { |
---|
| 1023 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1024 | uiTemp += uiLast << i; |
---|
| 1025 | } |
---|
| 1026 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
| 1027 | } |
---|
| 1028 | if ( uiPosLastY > 3 ) |
---|
| 1029 | { |
---|
| 1030 | UInt uiTemp = 0; |
---|
| 1031 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
| 1032 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1033 | { |
---|
| 1034 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1035 | uiTemp += uiLast << i; |
---|
| 1036 | } |
---|
| 1037 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
| 1038 | } |
---|
| 1039 | |
---|
| 1040 | if( uiScanIdx == SCAN_VER ) |
---|
| 1041 | { |
---|
| 1042 | swap( uiPosLastX, uiPosLastY ); |
---|
| 1043 | } |
---|
| 1044 | } |
---|
| 1045 | |
---|
| 1046 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1047 | { |
---|
| 1048 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 1049 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
| 1050 | DTRACE_CABAC_V( eTType ) |
---|
| 1051 | DTRACE_CABAC_T( "\twidth=" ) |
---|
| 1052 | DTRACE_CABAC_V( uiWidth ) |
---|
| 1053 | DTRACE_CABAC_T( "\theight=" ) |
---|
| 1054 | DTRACE_CABAC_V( uiHeight ) |
---|
| 1055 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
| 1056 | DTRACE_CABAC_V( uiDepth ) |
---|
| 1057 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
| 1058 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1059 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
| 1060 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
| 1061 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
| 1062 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
| 1063 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
| 1064 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
| 1065 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
| 1066 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1067 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
| 1068 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1069 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
| 1070 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
| 1071 | DTRACE_CABAC_T( "\n" ) |
---|
| 1072 | |
---|
| 1073 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
| 1074 | { |
---|
| 1075 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1076 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1077 | } |
---|
| 1078 | if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) |
---|
| 1079 | { |
---|
| 1080 | parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType); |
---|
| 1081 | } |
---|
| 1082 | |
---|
| 1083 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
| 1084 | |
---|
| 1085 | //----- parse significance map ----- |
---|
| 1086 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1087 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
| 1088 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
| 1089 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
| 1090 | |
---|
| 1091 | //===== decode last significant ===== |
---|
| 1092 | UInt uiPosLastX, uiPosLastY; |
---|
| 1093 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
| 1094 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
| 1095 | pcCoef[ uiBlkPosLast ] = 1; |
---|
| 1096 | |
---|
| 1097 | //===== decode significance flags ===== |
---|
| 1098 | UInt uiScanPosLast; |
---|
| 1099 | const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
| 1100 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
| 1101 | { |
---|
| 1102 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
| 1103 | if( uiBlkPosLast == uiBlkPos ) |
---|
| 1104 | { |
---|
| 1105 | break; |
---|
| 1106 | } |
---|
| 1107 | } |
---|
| 1108 | |
---|
| 1109 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
| 1110 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
| 1111 | |
---|
| 1112 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
| 1113 | UInt c1 = 1; |
---|
| 1114 | UInt uiGoRiceParam = 0; |
---|
| 1115 | |
---|
| 1116 | Bool beValid; |
---|
| 1117 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
| 1118 | { |
---|
| 1119 | beValid = false; |
---|
| 1120 | } |
---|
| 1121 | else |
---|
| 1122 | { |
---|
| 1123 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
| 1124 | } |
---|
| 1125 | UInt absSum = 0; |
---|
| 1126 | |
---|
| 1127 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
| 1128 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
| 1129 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
| 1130 | const UInt * scanCG; |
---|
| 1131 | { |
---|
| 1132 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
| 1133 | if( uiLog2BlockSize == 3 ) |
---|
| 1134 | { |
---|
| 1135 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
| 1136 | } |
---|
| 1137 | else if( uiLog2BlockSize == 5 ) |
---|
| 1138 | { |
---|
| 1139 | scanCG = g_sigLastScanCG32x32; |
---|
| 1140 | } |
---|
| 1141 | } |
---|
| 1142 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
| 1143 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
| 1144 | { |
---|
| 1145 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
| 1146 | uiGoRiceParam = 0; |
---|
| 1147 | Int numNonZero = 0; |
---|
| 1148 | |
---|
| 1149 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
| 1150 | |
---|
| 1151 | Int pos[SCAN_SET_SIZE]; |
---|
| 1152 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
| 1153 | { |
---|
| 1154 | lastNZPosInCG = iScanPosSig; |
---|
| 1155 | firstNZPosInCG = iScanPosSig; |
---|
| 1156 | iScanPosSig--; |
---|
| 1157 | pos[ numNonZero ] = uiBlkPosLast; |
---|
| 1158 | numNonZero = 1; |
---|
| 1159 | } |
---|
| 1160 | |
---|
| 1161 | // decode significant_coeffgroup_flag |
---|
| 1162 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
| 1163 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
| 1164 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
| 1165 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
| 1166 | { |
---|
| 1167 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
| 1168 | } |
---|
| 1169 | else |
---|
| 1170 | { |
---|
| 1171 | UInt uiSigCoeffGroup; |
---|
| 1172 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
| 1173 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
| 1174 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
| 1175 | } |
---|
| 1176 | |
---|
| 1177 | // decode significant_coeff_flag |
---|
| 1178 | Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
| 1179 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
| 1180 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
| 1181 | { |
---|
| 1182 | uiBlkPos = scan[ iScanPosSig ]; |
---|
| 1183 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
| 1184 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
| 1185 | uiSig = 0; |
---|
| 1186 | |
---|
| 1187 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
| 1188 | { |
---|
| 1189 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
| 1190 | { |
---|
| 1191 | uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType ); |
---|
| 1192 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
| 1193 | } |
---|
| 1194 | else |
---|
| 1195 | { |
---|
| 1196 | uiSig = 1; |
---|
| 1197 | } |
---|
| 1198 | } |
---|
| 1199 | pcCoef[ uiBlkPos ] = uiSig; |
---|
| 1200 | if( uiSig ) |
---|
| 1201 | { |
---|
| 1202 | pos[ numNonZero ] = uiBlkPos; |
---|
| 1203 | numNonZero ++; |
---|
| 1204 | if( lastNZPosInCG == -1 ) |
---|
| 1205 | { |
---|
| 1206 | lastNZPosInCG = iScanPosSig; |
---|
| 1207 | } |
---|
| 1208 | firstNZPosInCG = iScanPosSig; |
---|
| 1209 | } |
---|
| 1210 | } |
---|
| 1211 | |
---|
| 1212 | if( numNonZero ) |
---|
| 1213 | { |
---|
| 1214 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); |
---|
| 1215 | absSum = 0; |
---|
| 1216 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
| 1217 | UInt uiBin; |
---|
| 1218 | if( c1 == 0 ) |
---|
| 1219 | { |
---|
| 1220 | uiCtxSet++; |
---|
| 1221 | } |
---|
| 1222 | c1 = 1; |
---|
| 1223 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
| 1224 | Int absCoeff[SCAN_SET_SIZE]; |
---|
| 1225 | |
---|
| 1226 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
| 1227 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
| 1228 | Int firstC2FlagIdx = -1; |
---|
| 1229 | |
---|
| 1230 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
| 1231 | { |
---|
| 1232 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
| 1233 | if( uiBin == 1 ) |
---|
| 1234 | { |
---|
| 1235 | c1 = 0; |
---|
| 1236 | if (firstC2FlagIdx == -1) |
---|
| 1237 | { |
---|
| 1238 | firstC2FlagIdx = idx; |
---|
| 1239 | } |
---|
| 1240 | } |
---|
| 1241 | else if( (c1 < 3) && (c1 > 0) ) |
---|
| 1242 | { |
---|
| 1243 | c1++; |
---|
| 1244 | } |
---|
| 1245 | absCoeff[ idx ] = uiBin + 1; |
---|
| 1246 | } |
---|
| 1247 | |
---|
| 1248 | if (c1 == 0) |
---|
| 1249 | { |
---|
| 1250 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
| 1251 | if ( firstC2FlagIdx != -1) |
---|
| 1252 | { |
---|
| 1253 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
| 1254 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
| 1255 | } |
---|
| 1256 | } |
---|
| 1257 | |
---|
| 1258 | UInt coeffSigns; |
---|
| 1259 | if ( signHidden && beValid ) |
---|
| 1260 | { |
---|
| 1261 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
| 1262 | coeffSigns <<= 32 - (numNonZero-1); |
---|
| 1263 | } |
---|
| 1264 | else |
---|
| 1265 | { |
---|
| 1266 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
| 1267 | coeffSigns <<= 32 - numNonZero; |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | Int iFirstCoeff2 = 1; |
---|
| 1271 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
| 1272 | { |
---|
| 1273 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
| 1274 | { |
---|
| 1275 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
| 1276 | |
---|
| 1277 | if( absCoeff[ idx ] == baseLevel) |
---|
| 1278 | { |
---|
| 1279 | UInt uiLevel; |
---|
| 1280 | xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam ); |
---|
| 1281 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
| 1282 | if(absCoeff[idx]>3*(1<<uiGoRiceParam)) |
---|
| 1283 | { |
---|
| 1284 | uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); |
---|
| 1285 | } |
---|
| 1286 | } |
---|
| 1287 | |
---|
| 1288 | if(absCoeff[ idx ] >= 2) |
---|
| 1289 | { |
---|
| 1290 | iFirstCoeff2 = 0; |
---|
| 1291 | } |
---|
| 1292 | } |
---|
| 1293 | } |
---|
| 1294 | |
---|
| 1295 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
| 1296 | { |
---|
| 1297 | Int blkPos = pos[ idx ]; |
---|
| 1298 | // Signs applied later. |
---|
| 1299 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
| 1300 | absSum += absCoeff[ idx ]; |
---|
| 1301 | |
---|
| 1302 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
| 1303 | { |
---|
| 1304 | // Infer sign of 1st element. |
---|
| 1305 | if (absSum&0x1) |
---|
| 1306 | { |
---|
| 1307 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
| 1308 | } |
---|
| 1309 | } |
---|
| 1310 | else |
---|
| 1311 | { |
---|
| 1312 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
| 1313 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
| 1314 | coeffSigns <<= 1; |
---|
| 1315 | } |
---|
| 1316 | } |
---|
| 1317 | } |
---|
| 1318 | } |
---|
| 1319 | |
---|
| 1320 | return; |
---|
| 1321 | } |
---|
| 1322 | |
---|
| 1323 | |
---|
| 1324 | Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) |
---|
| 1325 | { |
---|
| 1326 | if (maxSymbol == 0) |
---|
| 1327 | { |
---|
| 1328 | val = 0; |
---|
| 1329 | return; |
---|
| 1330 | } |
---|
| 1331 | |
---|
| 1332 | UInt code; |
---|
| 1333 | Int i; |
---|
| 1334 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
| 1335 | if ( code == 0 ) |
---|
| 1336 | { |
---|
| 1337 | val = 0; |
---|
| 1338 | return; |
---|
| 1339 | } |
---|
| 1340 | |
---|
| 1341 | i=1; |
---|
| 1342 | while (1) |
---|
| 1343 | { |
---|
| 1344 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
| 1345 | if ( code == 0 ) |
---|
| 1346 | { |
---|
| 1347 | break; |
---|
| 1348 | } |
---|
| 1349 | i++; |
---|
| 1350 | if (i == maxSymbol) |
---|
| 1351 | { |
---|
| 1352 | break; |
---|
| 1353 | } |
---|
| 1354 | } |
---|
| 1355 | |
---|
| 1356 | val = i; |
---|
| 1357 | } |
---|
| 1358 | Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) |
---|
| 1359 | { |
---|
| 1360 | m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); |
---|
| 1361 | } |
---|
| 1362 | Void TDecSbac::parseSaoMerge (UInt& ruiVal) |
---|
| 1363 | { |
---|
| 1364 | UInt uiCode; |
---|
| 1365 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) ); |
---|
| 1366 | ruiVal = (Int)uiCode; |
---|
| 1367 | } |
---|
| 1368 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
| 1369 | { |
---|
| 1370 | UInt uiCode; |
---|
| 1371 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
| 1372 | if (uiCode == 0) |
---|
| 1373 | { |
---|
| 1374 | ruiVal = 0; |
---|
| 1375 | } |
---|
| 1376 | else |
---|
| 1377 | { |
---|
| 1378 | m_pcTDecBinIf->decodeBinEP( uiCode ); |
---|
| 1379 | if (uiCode == 0) |
---|
| 1380 | { |
---|
[540] | 1381 | ruiVal = 1; |
---|
[313] | 1382 | } |
---|
| 1383 | else |
---|
| 1384 | { |
---|
[540] | 1385 | ruiVal = 2; |
---|
[313] | 1386 | } |
---|
| 1387 | } |
---|
| 1388 | } |
---|
| 1389 | |
---|
[540] | 1390 | Void TDecSbac::parseSaoSign(UInt& val) |
---|
| 1391 | { |
---|
| 1392 | m_pcTDecBinIf->decodeBinEP ( val ); |
---|
| 1393 | } |
---|
| 1394 | |
---|
| 1395 | Void TDecSbac::parseSAOBlkParam (SAOBlkParam& saoBlkParam |
---|
| 1396 | , Bool* sliceEnabled |
---|
| 1397 | , Bool leftMergeAvail |
---|
| 1398 | , Bool aboveMergeAvail |
---|
| 1399 | ) |
---|
| 1400 | { |
---|
| 1401 | UInt uiSymbol; |
---|
| 1402 | |
---|
| 1403 | Bool isLeftMerge = false; |
---|
| 1404 | Bool isAboveMerge= false; |
---|
| 1405 | |
---|
| 1406 | if(leftMergeAvail) |
---|
| 1407 | { |
---|
| 1408 | parseSaoMerge(uiSymbol); //sao_merge_left_flag |
---|
| 1409 | isLeftMerge = (uiSymbol?true:false); |
---|
| 1410 | } |
---|
| 1411 | |
---|
| 1412 | if( aboveMergeAvail && !isLeftMerge) |
---|
| 1413 | { |
---|
| 1414 | parseSaoMerge(uiSymbol); //sao_merge_up_flag |
---|
| 1415 | isAboveMerge = (uiSymbol?true:false); |
---|
| 1416 | } |
---|
| 1417 | |
---|
| 1418 | if(isLeftMerge || isAboveMerge) //merge mode |
---|
| 1419 | { |
---|
| 1420 | saoBlkParam[SAO_Y].modeIdc = saoBlkParam[SAO_Cb].modeIdc = saoBlkParam[SAO_Cr].modeIdc = SAO_MODE_MERGE; |
---|
| 1421 | saoBlkParam[SAO_Y].typeIdc = saoBlkParam[SAO_Cb].typeIdc = saoBlkParam[SAO_Cr].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; |
---|
| 1422 | } |
---|
| 1423 | else //new or off mode |
---|
| 1424 | { |
---|
| 1425 | for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) |
---|
| 1426 | { |
---|
| 1427 | SAOOffset& ctbParam = saoBlkParam[compIdx]; |
---|
| 1428 | |
---|
| 1429 | if(!sliceEnabled[compIdx]) |
---|
| 1430 | { |
---|
| 1431 | //off |
---|
| 1432 | ctbParam.modeIdc = SAO_MODE_OFF; |
---|
| 1433 | continue; |
---|
| 1434 | } |
---|
| 1435 | |
---|
| 1436 | //type |
---|
| 1437 | if(compIdx == SAO_Y || compIdx == SAO_Cb) |
---|
| 1438 | { |
---|
| 1439 | parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma |
---|
| 1440 | |
---|
| 1441 | assert(uiSymbol ==0 || uiSymbol ==1 || uiSymbol ==2); |
---|
| 1442 | |
---|
| 1443 | if(uiSymbol ==0) //OFF |
---|
| 1444 | { |
---|
| 1445 | ctbParam.modeIdc = SAO_MODE_OFF; |
---|
| 1446 | } |
---|
| 1447 | else if(uiSymbol == 1) //BO |
---|
| 1448 | { |
---|
| 1449 | ctbParam.modeIdc = SAO_MODE_NEW; |
---|
| 1450 | ctbParam.typeIdc = SAO_TYPE_START_BO; |
---|
| 1451 | } |
---|
| 1452 | else //2, EO |
---|
| 1453 | { |
---|
| 1454 | ctbParam.modeIdc = SAO_MODE_NEW; |
---|
| 1455 | ctbParam.typeIdc = SAO_TYPE_START_EO; |
---|
| 1456 | } |
---|
| 1457 | |
---|
| 1458 | } |
---|
| 1459 | else //Cr, follow Cb SAO type |
---|
| 1460 | { |
---|
| 1461 | ctbParam.modeIdc = saoBlkParam[SAO_Cb].modeIdc; |
---|
| 1462 | ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; |
---|
| 1463 | } |
---|
| 1464 | |
---|
| 1465 | if(ctbParam.modeIdc == SAO_MODE_NEW) |
---|
| 1466 | { |
---|
| 1467 | Int offset[4]; |
---|
| 1468 | for(Int i=0; i< 4; i++) |
---|
| 1469 | { |
---|
| 1470 | parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs |
---|
| 1471 | offset[i] = (Int)uiSymbol; |
---|
| 1472 | } |
---|
| 1473 | |
---|
| 1474 | if(ctbParam.typeIdc == SAO_TYPE_START_BO) |
---|
| 1475 | { |
---|
| 1476 | for(Int i=0; i< 4; i++) |
---|
| 1477 | { |
---|
| 1478 | if(offset[i] != 0) |
---|
| 1479 | { |
---|
| 1480 | parseSaoSign(uiSymbol); //sao_offset_sign |
---|
| 1481 | if(uiSymbol) |
---|
| 1482 | { |
---|
| 1483 | offset[i] = -offset[i]; |
---|
| 1484 | } |
---|
| 1485 | } |
---|
| 1486 | } |
---|
| 1487 | parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position |
---|
| 1488 | ctbParam.typeAuxInfo = uiSymbol; |
---|
| 1489 | |
---|
| 1490 | for(Int i=0; i<4; i++) |
---|
| 1491 | { |
---|
| 1492 | ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; |
---|
| 1493 | } |
---|
| 1494 | |
---|
| 1495 | } |
---|
| 1496 | else //EO |
---|
| 1497 | { |
---|
| 1498 | ctbParam.typeAuxInfo = 0; |
---|
| 1499 | |
---|
| 1500 | if(compIdx == SAO_Y || compIdx == SAO_Cb) |
---|
| 1501 | { |
---|
| 1502 | parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma |
---|
| 1503 | ctbParam.typeIdc += uiSymbol; |
---|
| 1504 | } |
---|
| 1505 | else |
---|
| 1506 | { |
---|
| 1507 | ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; |
---|
| 1508 | } |
---|
| 1509 | ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; |
---|
| 1510 | ctbParam.offset[SAO_CLASS_EO_HALF_VALLEY] = offset[1]; |
---|
| 1511 | ctbParam.offset[SAO_CLASS_EO_PLAIN ] = 0; |
---|
| 1512 | ctbParam.offset[SAO_CLASS_EO_HALF_PEAK ] = -offset[2]; |
---|
| 1513 | ctbParam.offset[SAO_CLASS_EO_FULL_PEAK ] = -offset[3]; |
---|
| 1514 | } |
---|
| 1515 | } |
---|
| 1516 | } |
---|
| 1517 | } |
---|
| 1518 | } |
---|
| 1519 | |
---|
[313] | 1520 | /** |
---|
| 1521 | - Initialize our contexts from the nominated source. |
---|
| 1522 | . |
---|
| 1523 | \param pSrc Contexts to be copied. |
---|
| 1524 | */ |
---|
| 1525 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
| 1526 | { |
---|
| 1527 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
| 1528 | } |
---|
| 1529 | |
---|
| 1530 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
| 1531 | { |
---|
| 1532 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
| 1533 | |
---|
| 1534 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
| 1535 | xCopyContextsFrom( pSrc ); |
---|
| 1536 | |
---|
| 1537 | } |
---|
| 1538 | |
---|
| 1539 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
| 1540 | { |
---|
| 1541 | xCopyFrom(pScr); |
---|
| 1542 | } |
---|
| 1543 | |
---|
| 1544 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
| 1545 | { |
---|
| 1546 | xCopyContextsFrom(pScr); |
---|
| 1547 | } |
---|
| 1548 | //! \} |
---|