[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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" |
---|
| 39 | |
---|
[56] | 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
[2] | 43 | ////////////////////////////////////////////////////////////////////// |
---|
| 44 | // Construction/Destruction |
---|
| 45 | ////////////////////////////////////////////////////////////////////// |
---|
| 46 | |
---|
| 47 | TDecSbac::TDecSbac() |
---|
| 48 | // new structure here |
---|
| 49 | : m_pcBitstream ( 0 ) |
---|
| 50 | , m_pcTDecBinIf ( NULL ) |
---|
[56] | 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) |
---|
[152] | 54 | #if LGE_ILLUCOMP_B0045 |
---|
| 55 | , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 56 | #endif |
---|
[56] | 57 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 58 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 59 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 60 | , m_cResPredFlagSCModel ( 1, 1, NUM_RES_PRED_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 61 | #endif |
---|
[56] | 62 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 63 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 64 | , m_cCUAlfCtrlFlagSCModel ( 1, 1, NUM_ALF_CTRL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 65 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 66 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 67 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 68 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 69 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 70 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 71 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 72 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 73 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 74 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 75 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 76 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 77 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 78 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 79 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 80 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 81 | , m_cALFFlagSCModel ( 1, 1, NUM_ALF_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 82 | , m_cALFUvlcSCModel ( 1, 1, NUM_ALF_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 83 | , m_cALFSvlcSCModel ( 1, 1, NUM_ALF_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 84 | #if AMP_CTX |
---|
| 85 | , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 86 | #else |
---|
[56] | 87 | , m_cCUXPosiSCModel ( 1, 1, NUM_CU_X_POS_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 88 | , m_cCUYPosiSCModel ( 1, 1, NUM_CU_Y_POS_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 89 | #endif |
---|
[56] | 90 | , m_cSaoFlagSCModel ( 1, 1, NUM_SAO_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 91 | , m_cSaoUvlcSCModel ( 1, 1, NUM_SAO_UVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 92 | , m_cSaoSvlcSCModel ( 1, 1, NUM_SAO_SVLC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 93 | #if SAO_UNIT_INTERLEAVING |
---|
| 94 | , m_cSaoMergeLeftSCModel ( 1, 1, NUM_SAO_MERGE_LEFT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 95 | , m_cSaoMergeUpSCModel ( 1, 1, NUM_SAO_MERGE_UP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 96 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 97 | #endif |
---|
[5] | 98 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 99 | , m_cDmmFlagSCModel ( 1, 1, NUM_DMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 100 | , m_cDmmModeSCModel ( 1, 1, NUM_DMM_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 101 | , m_cDmmDataSCModel ( 1, 1, NUM_DMM_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 102 | #endif |
---|
[100] | 103 | #if LGE_EDGE_INTRA |
---|
| 104 | , m_cEdgeIntraSCModel ( 1, 1, NUM_EDGE_INTRA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 105 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 106 | , m_cEdgeIntraDeltaDCSCModel ( 1, 1, NUM_EDGE_INTRA_DELTA_DC_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 107 | #endif |
---|
| 108 | #endif |
---|
[2] | 109 | { |
---|
[56] | 110 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
| 111 | m_iSliceGranularity = 0; |
---|
[2] | 112 | } |
---|
| 113 | |
---|
| 114 | TDecSbac::~TDecSbac() |
---|
| 115 | { |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | // ==================================================================================================================== |
---|
| 119 | // Public member functions |
---|
| 120 | // ==================================================================================================================== |
---|
| 121 | |
---|
[56] | 122 | #if CABAC_INIT_FLAG |
---|
| 123 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
[2] | 124 | { |
---|
[56] | 125 | SliceType sliceType = pSlice->getSliceType(); |
---|
| 126 | Int qp = pSlice->getSliceQp(); |
---|
| 127 | |
---|
| 128 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
| 129 | { |
---|
| 130 | switch (sliceType) |
---|
| 131 | { |
---|
| 132 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
| 133 | sliceType = B_SLICE; |
---|
| 134 | break; |
---|
| 135 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
| 136 | sliceType = P_SLICE; |
---|
| 137 | break; |
---|
| 138 | default : // should not occur |
---|
| 139 | assert(0); |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | #else |
---|
| 144 | Void TDecSbac::resetEntropywithQPandInitIDC (Int qp, Int iID) |
---|
| 145 | { |
---|
| 146 | SliceType sliceType = (SliceType)iID; |
---|
| 147 | #endif |
---|
| 148 | |
---|
| 149 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
| 150 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
[152] | 151 | #if LGE_ILLUCOMP_B0045 |
---|
| 152 | m_cCUICFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_IC_FLAG ); |
---|
| 153 | #endif |
---|
[56] | 154 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
| 155 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
| 156 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 157 | m_cResPredFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_RES_PRED_FLAG ); |
---|
[2] | 158 | #endif |
---|
[56] | 159 | m_cCUAlfCtrlFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_CTRL_FLAG ); |
---|
| 160 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
| 161 | #if AMP_CTX |
---|
| 162 | m_cCUAMPSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_AMP_POS ); |
---|
[2] | 163 | #else |
---|
[56] | 164 | m_cCUXPosiSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_X_POS ); |
---|
| 165 | m_cCUYPosiSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_Y_POS ); |
---|
[2] | 166 | #endif |
---|
[56] | 167 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
| 168 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
| 169 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
| 170 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
| 171 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
| 172 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
| 173 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
| 174 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
| 175 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
| 176 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
| 177 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
| 178 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
| 179 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
| 180 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
| 181 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
| 182 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
| 183 | m_cALFFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_FLAG ); |
---|
| 184 | m_cALFUvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_UVLC ); |
---|
| 185 | m_cALFSvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ALF_SVLC ); |
---|
| 186 | m_cSaoFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_FLAG ); |
---|
| 187 | m_cSaoUvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_UVLC ); |
---|
| 188 | m_cSaoSvlcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_SVLC ); |
---|
| 189 | #if SAO_UNIT_INTERLEAVING |
---|
| 190 | m_cSaoMergeLeftSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); |
---|
| 191 | m_cSaoMergeUpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); |
---|
| 192 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
[2] | 193 | #endif |
---|
[56] | 194 | |
---|
| 195 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
[100] | 196 | #if LGE_EDGE_INTRA |
---|
| 197 | m_cEdgeIntraSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EDGE_INTRA ); |
---|
| 198 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 199 | m_cEdgeIntraDeltaDCSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC ); |
---|
| 200 | #endif |
---|
| 201 | #endif |
---|
[56] | 202 | m_uiLastDQpNonZero = 0; |
---|
[5] | 203 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 204 | m_cDmmFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_FLAG ); |
---|
| 205 | m_cDmmModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_MODE ); |
---|
| 206 | m_cDmmDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM_DATA ); |
---|
[2] | 207 | #endif |
---|
| 208 | |
---|
| 209 | // new structure |
---|
[56] | 210 | m_uiLastQp = qp; |
---|
[2] | 211 | |
---|
| 212 | m_pcTDecBinIf->start(); |
---|
| 213 | } |
---|
| 214 | |
---|
[56] | 215 | /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile. |
---|
| 216 | * Intialize CABAC states. Start CABAC. |
---|
| 217 | */ |
---|
| 218 | Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp ) |
---|
| 219 | { |
---|
| 220 | UInt uiBit; |
---|
| 221 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
| 222 | m_pcTDecBinIf->finish(); |
---|
| 223 | #if !OL_FLUSH_ALIGN |
---|
| 224 | // Account for misaligned CABAC. |
---|
| 225 | Int iCABACReadAhead = m_pcTDecBinIf->getBitsReadAhead(); |
---|
| 226 | iCABACReadAhead--; |
---|
| 227 | Int iStreamBits = 8-m_pcBitstream->getNumBitsUntilByteAligned(); |
---|
| 228 | if (iCABACReadAhead >= iStreamBits) |
---|
| 229 | { |
---|
| 230 | // Misaligned CABAC has read into the 1st byte of the next tile. |
---|
| 231 | // Back up a byte prior to alignment. |
---|
| 232 | m_pcBitstream->backupByte(); |
---|
| 233 | } |
---|
| 234 | #endif |
---|
| 235 | m_pcBitstream->readOutTrailingBits(); |
---|
| 236 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
| 237 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
[152] | 238 | #if LGE_ILLUCOMP_B0045 |
---|
| 239 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
| 240 | #endif |
---|
[56] | 241 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
| 242 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
| 243 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 244 | m_cResPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG ); |
---|
| 245 | #endif |
---|
| 246 | m_cCUAlfCtrlFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG ); |
---|
| 247 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
| 248 | #if AMP_CTX |
---|
| 249 | m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS ); |
---|
| 250 | #else |
---|
| 251 | m_cCUXPosiSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_X_POS ); |
---|
| 252 | m_cCUYPosiSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_Y_POS ); |
---|
| 253 | #endif |
---|
| 254 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
| 255 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
| 256 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
| 257 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
| 258 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
| 259 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
| 260 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
| 261 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
| 262 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
| 263 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
| 264 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
| 265 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
| 266 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
| 267 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
| 268 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
| 269 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
| 270 | m_cALFFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_FLAG ); |
---|
| 271 | m_cALFUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_UVLC ); |
---|
| 272 | m_cALFSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC ); |
---|
| 273 | m_cSaoFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG ); |
---|
| 274 | m_cSaoUvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC ); |
---|
| 275 | m_cSaoSvlcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC ); |
---|
| 276 | #if SAO_UNIT_INTERLEAVING |
---|
| 277 | m_cSaoMergeLeftSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG ); |
---|
| 278 | m_cSaoMergeUpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG ); |
---|
| 279 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
| 280 | #endif |
---|
| 281 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
| 282 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 283 | m_cDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG ); |
---|
| 284 | m_cDmmModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_MODE ); |
---|
| 285 | m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); |
---|
| 286 | #endif |
---|
| 287 | |
---|
| 288 | m_pcTDecBinIf->start(); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | Void TDecSbac::readTileMarker( UInt& uiTileIdx, UInt uiBitsUsed ) |
---|
| 292 | { |
---|
| 293 | UInt uiSymbol; |
---|
| 294 | uiTileIdx = 0; |
---|
| 295 | for (Int iShift=uiBitsUsed-1; iShift>=0; iShift--) |
---|
| 296 | { |
---|
| 297 | m_pcTDecBinIf->decodeBinEP ( uiSymbol ); |
---|
| 298 | if (uiSymbol) |
---|
| 299 | { |
---|
| 300 | uiTileIdx |= (1<<iShift); |
---|
| 301 | } |
---|
| 302 | } |
---|
| 303 | } |
---|
| 304 | |
---|
[2] | 305 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
| 306 | { |
---|
| 307 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | |
---|
| 311 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
| 312 | { |
---|
| 313 | if (uiMaxSymbol == 0) |
---|
| 314 | { |
---|
| 315 | ruiSymbol = 0; |
---|
| 316 | return; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
| 320 | |
---|
| 321 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
| 322 | { |
---|
| 323 | return; |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | UInt uiSymbol = 0; |
---|
| 327 | UInt uiCont; |
---|
| 328 | |
---|
| 329 | do |
---|
| 330 | { |
---|
| 331 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
| 332 | uiSymbol++; |
---|
| 333 | } |
---|
| 334 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
| 335 | |
---|
| 336 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
| 337 | { |
---|
| 338 | uiSymbol++; |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | ruiSymbol = uiSymbol; |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
| 345 | { |
---|
| 346 | UInt uiSymbol = 0; |
---|
| 347 | UInt uiBit = 1; |
---|
| 348 | |
---|
| 349 | while( uiBit ) |
---|
| 350 | { |
---|
| 351 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
| 352 | uiSymbol += uiBit << uiCount++; |
---|
| 353 | } |
---|
| 354 | |
---|
[56] | 355 | if ( --uiCount ) |
---|
[2] | 356 | { |
---|
[56] | 357 | UInt bins; |
---|
| 358 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount ); |
---|
| 359 | uiSymbol += bins; |
---|
[2] | 360 | } |
---|
| 361 | |
---|
| 362 | ruiSymbol = uiSymbol; |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
| 366 | { |
---|
| 367 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
| 368 | |
---|
| 369 | if( !ruiSymbol ) |
---|
| 370 | { |
---|
| 371 | return; |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | UInt uiSymbol = 0; |
---|
| 375 | UInt uiCont; |
---|
| 376 | |
---|
| 377 | do |
---|
| 378 | { |
---|
| 379 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
| 380 | uiSymbol++; |
---|
| 381 | } |
---|
| 382 | while( uiCont ); |
---|
| 383 | |
---|
| 384 | ruiSymbol = uiSymbol; |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | /** Parsing of coeff_abs_level_minus3 |
---|
| 388 | * \param ruiSymbol reference to coeff_abs_level_minus3 |
---|
| 389 | * \param ruiGoRiceParam reference to Rice parameter |
---|
| 390 | * \returns Void |
---|
| 391 | */ |
---|
| 392 | Void TDecSbac::xReadGoRiceExGolomb( UInt &ruiSymbol, UInt &ruiGoRiceParam ) |
---|
| 393 | { |
---|
| 394 | Bool bExGolomb = false; |
---|
| 395 | UInt uiCodeWord = 0; |
---|
| 396 | UInt uiQuotient = 0; |
---|
| 397 | UInt uiRemainder = 0; |
---|
| 398 | UInt uiMaxVlc = g_auiGoRiceRange[ ruiGoRiceParam ]; |
---|
| 399 | UInt uiMaxPreLen = g_auiGoRicePrefixLen[ ruiGoRiceParam ]; |
---|
| 400 | |
---|
| 401 | do |
---|
| 402 | { |
---|
| 403 | uiQuotient++; |
---|
| 404 | m_pcTDecBinIf->decodeBinEP( uiCodeWord ); |
---|
| 405 | } |
---|
| 406 | while( uiCodeWord && uiQuotient < uiMaxPreLen ); |
---|
| 407 | |
---|
| 408 | uiCodeWord = 1 - uiCodeWord; |
---|
| 409 | uiQuotient -= uiCodeWord; |
---|
| 410 | |
---|
[56] | 411 | if ( ruiGoRiceParam > 0 ) |
---|
[2] | 412 | { |
---|
[56] | 413 | m_pcTDecBinIf->decodeBinsEP( uiRemainder, ruiGoRiceParam ); |
---|
[2] | 414 | } |
---|
| 415 | |
---|
| 416 | ruiSymbol = uiRemainder + ( uiQuotient << ruiGoRiceParam ); |
---|
| 417 | bExGolomb = ruiSymbol == ( uiMaxVlc + 1 ); |
---|
| 418 | |
---|
| 419 | if( bExGolomb ) |
---|
| 420 | { |
---|
| 421 | xReadEpExGolomb( uiCodeWord, 0 ); |
---|
| 422 | ruiSymbol += uiCodeWord; |
---|
| 423 | } |
---|
| 424 | |
---|
[56] | 425 | #if EIGHT_BITS_RICE_CODE |
---|
| 426 | ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 23 ) ]; |
---|
| 427 | #else |
---|
[2] | 428 | ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 15 ) ]; |
---|
[56] | 429 | #endif |
---|
[2] | 430 | |
---|
| 431 | return; |
---|
| 432 | } |
---|
[56] | 433 | |
---|
| 434 | |
---|
| 435 | /** Parse I_PCM information. |
---|
| 436 | * \param pcCU |
---|
| 437 | * \param uiAbsPartIdx |
---|
| 438 | * \param uiDepth |
---|
| 439 | * \returns Void |
---|
| 440 | * |
---|
| 441 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 442 | */ |
---|
| 443 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 444 | { |
---|
| 445 | UInt uiSymbol; |
---|
[56] | 446 | #if BURST_IPCM |
---|
| 447 | Int numSubseqIPCM = 0; |
---|
| 448 | Bool readPCMSampleFlag = false; |
---|
| 449 | |
---|
| 450 | if(pcCU->getNumSucIPCM() > 0) |
---|
[2] | 451 | { |
---|
[56] | 452 | readPCMSampleFlag = true; |
---|
[2] | 453 | } |
---|
[56] | 454 | else |
---|
| 455 | { |
---|
| 456 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
[2] | 457 | |
---|
[56] | 458 | if (uiSymbol) |
---|
| 459 | { |
---|
| 460 | readPCMSampleFlag = true; |
---|
| 461 | m_pcTDecBinIf->decodeNumSubseqIPCM(numSubseqIPCM); |
---|
| 462 | pcCU->setNumSucIPCM(numSubseqIPCM + 1); |
---|
| 463 | m_pcTDecBinIf->decodePCMAlignBits(); |
---|
| 464 | } |
---|
[2] | 465 | } |
---|
[56] | 466 | #else |
---|
| 467 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
| 468 | #endif |
---|
[2] | 469 | |
---|
[56] | 470 | #if BURST_IPCM |
---|
| 471 | if (readPCMSampleFlag == true) |
---|
| 472 | #else |
---|
| 473 | if (uiSymbol) |
---|
[2] | 474 | #endif |
---|
| 475 | { |
---|
[56] | 476 | Bool bIpcmFlag = true; |
---|
| 477 | |
---|
| 478 | #if !BURST_IPCM |
---|
| 479 | m_pcTDecBinIf->decodePCMAlignBits(); |
---|
[2] | 480 | #endif |
---|
| 481 | |
---|
[56] | 482 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 483 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 484 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
[2] | 485 | |
---|
[56] | 486 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 487 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 488 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
| 489 | |
---|
| 490 | Pel* piPCMSample; |
---|
| 491 | UInt uiWidth; |
---|
| 492 | UInt uiHeight; |
---|
| 493 | UInt uiSampleBits; |
---|
| 494 | UInt uiX, uiY; |
---|
| 495 | |
---|
| 496 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
| 497 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 498 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 499 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 500 | |
---|
| 501 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 502 | { |
---|
| 503 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 504 | { |
---|
| 505 | UInt uiSample; |
---|
| 506 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 507 | piPCMSample[uiX] = uiSample; |
---|
| 508 | } |
---|
| 509 | piPCMSample += uiWidth; |
---|
| 510 | } |
---|
| 511 | |
---|
| 512 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
| 513 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 514 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 515 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 516 | |
---|
| 517 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 518 | { |
---|
| 519 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 520 | { |
---|
| 521 | UInt uiSample; |
---|
| 522 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 523 | piPCMSample[uiX] = uiSample; |
---|
| 524 | } |
---|
| 525 | piPCMSample += uiWidth; |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
| 529 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 530 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 531 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 532 | |
---|
| 533 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 534 | { |
---|
| 535 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 536 | { |
---|
| 537 | UInt uiSample; |
---|
| 538 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 539 | piPCMSample[uiX] = uiSample; |
---|
| 540 | } |
---|
| 541 | piPCMSample += uiWidth; |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | #if BURST_IPCM |
---|
| 545 | pcCU->setNumSucIPCM( pcCU->getNumSucIPCM() - 1); |
---|
| 546 | if(pcCU->getNumSucIPCM() == 0) |
---|
| 547 | { |
---|
| 548 | m_pcTDecBinIf->resetBac(); |
---|
| 549 | } |
---|
| 550 | #else |
---|
| 551 | m_pcTDecBinIf->resetBac(); |
---|
| 552 | #endif |
---|
[2] | 553 | } |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | /** parse skip flag |
---|
| 557 | * \param pcCU |
---|
| 558 | * \param uiAbsPartIdx |
---|
| 559 | * \param uiDepth |
---|
| 560 | * \returns Void |
---|
| 561 | */ |
---|
| 562 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 563 | { |
---|
| 564 | if( pcCU->getSlice()->isIntra() ) |
---|
| 565 | { |
---|
| 566 | return; |
---|
| 567 | } |
---|
| 568 | |
---|
| 569 | UInt uiSymbol = 0; |
---|
| 570 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
| 571 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
[56] | 572 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
[2] | 573 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
| 574 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
| 575 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
| 576 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
| 577 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 578 | DTRACE_CABAC_T( "\n"); |
---|
| 579 | |
---|
| 580 | if( uiSymbol ) |
---|
| 581 | { |
---|
| 582 | pcCU->setPredModeSubParts( MODE_SKIP, uiAbsPartIdx, uiDepth ); |
---|
| 583 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 584 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 585 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
| 586 | } |
---|
| 587 | } |
---|
| 588 | |
---|
[152] | 589 | #if LGE_ILLUCOMP_B0045 |
---|
| 590 | /** parse illumination compensation flag |
---|
| 591 | * \param pcCU |
---|
| 592 | * \param uiAbsPartIdx |
---|
| 593 | * \param uiDepth |
---|
| 594 | * \returns Void |
---|
| 595 | */ |
---|
| 596 | Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 597 | { |
---|
| 598 | UInt uiSymbol = 0; |
---|
| 599 | UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx ); |
---|
| 600 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) ); |
---|
| 601 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 602 | DTRACE_CABAC_T( "\tICFlag" ); |
---|
| 603 | DTRACE_CABAC_T( "\tuiCtxIC: "); |
---|
| 604 | DTRACE_CABAC_V( uiCtxIC ); |
---|
| 605 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
| 606 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 607 | DTRACE_CABAC_T( "\n"); |
---|
| 608 | |
---|
| 609 | pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth ); |
---|
| 610 | } |
---|
| 611 | #endif |
---|
| 612 | |
---|
| 613 | |
---|
[2] | 614 | /** parse merge flag |
---|
| 615 | * \param pcCU |
---|
| 616 | * \param uiAbsPartIdx |
---|
| 617 | * \param uiDepth |
---|
| 618 | * \param uiPUIdx |
---|
| 619 | * \returns Void |
---|
| 620 | */ |
---|
| 621 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 622 | { |
---|
| 623 | UInt uiSymbol; |
---|
[56] | 624 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
[2] | 625 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 626 | |
---|
[56] | 627 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
[2] | 628 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
| 629 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 630 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
| 631 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
| 632 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
| 633 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 634 | DTRACE_CABAC_T( "\n" ); |
---|
| 635 | } |
---|
| 636 | |
---|
[56] | 637 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 638 | { |
---|
[56] | 639 | UInt uiNumCand = MRG_MAX_NUM_CANDS; |
---|
| 640 | #if !MRG_IDX_CTX_RED |
---|
| 641 | UInt auiCtx[4] = { 0, 1, 2, 3 }; |
---|
| 642 | #endif |
---|
| 643 | UInt uiUnaryIdx = 0; |
---|
| 644 | uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
[5] | 645 | #if HHI_MPI |
---|
[2] | 646 | const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE; |
---|
[56] | 647 | const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : uiNumCand; |
---|
[2] | 648 | #endif |
---|
[56] | 649 | if ( uiNumCand > 1 ) |
---|
[2] | 650 | { |
---|
[56] | 651 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
[2] | 652 | { |
---|
[56] | 653 | UInt uiSymbol = 0; |
---|
| 654 | #if MRG_IDX_CTX_RED |
---|
| 655 | if ( uiUnaryIdx==0 ) |
---|
[2] | 656 | { |
---|
[56] | 657 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 658 | } |
---|
[56] | 659 | else |
---|
| 660 | { |
---|
| 661 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 662 | } |
---|
| 663 | #else |
---|
| 664 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, auiCtx[uiUnaryIdx] ) ); |
---|
[2] | 665 | #endif |
---|
[56] | 666 | if( uiSymbol == 0 ) |
---|
[2] | 667 | { |
---|
[56] | 668 | break; |
---|
[2] | 669 | } |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | ruiMergeIndex = uiUnaryIdx; |
---|
| 673 | |
---|
[56] | 674 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 675 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
| 676 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
| 677 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
| 678 | DTRACE_CABAC_T( "\n" ) |
---|
[5] | 679 | #if HHI_MPI |
---|
[2] | 680 | if( ruiMergeIndex > uiMviMergePos ) |
---|
| 681 | { |
---|
[56] | 682 | assert( bMVIAvailable ); |
---|
[2] | 683 | ruiMergeIndex--; |
---|
| 684 | } |
---|
| 685 | else if( ruiMergeIndex == uiMviMergePos ) |
---|
| 686 | { |
---|
[56] | 687 | assert( bMVIAvailable ); |
---|
[2] | 688 | pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 689 | } |
---|
| 690 | #endif |
---|
| 691 | } |
---|
| 692 | |
---|
[56] | 693 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 694 | Void |
---|
[2] | 695 | TDecSbac::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 696 | { |
---|
[56] | 697 | UInt uiCtx = pcCU->getCtxResPredFlag( uiAbsPartIdx ); |
---|
[2] | 698 | UInt uiSymbol = 0; |
---|
| 699 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) ); |
---|
| 700 | rbResPredFlag = ( uiSymbol != 0 ); |
---|
| 701 | } |
---|
[56] | 702 | #endif |
---|
[2] | 703 | |
---|
[56] | 704 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 705 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx, Int iNumAMVPCands ) |
---|
[2] | 706 | { |
---|
| 707 | UInt uiSymbol; |
---|
[56] | 708 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, iNumAMVPCands-1); |
---|
[2] | 709 | riMVPIdx = uiSymbol; |
---|
| 710 | } |
---|
[56] | 711 | #else |
---|
| 712 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
| 713 | { |
---|
| 714 | UInt uiSymbol; |
---|
| 715 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1); |
---|
| 716 | riMVPIdx = uiSymbol; |
---|
| 717 | } |
---|
| 718 | #endif |
---|
[2] | 719 | |
---|
| 720 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 721 | { |
---|
| 722 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 723 | { |
---|
| 724 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
| 725 | return; |
---|
| 726 | } |
---|
| 727 | |
---|
| 728 | UInt uiSymbol; |
---|
| 729 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
[56] | 730 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 731 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
| 732 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
| 733 | |
---|
| 734 | return; |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | /** parse partition size |
---|
| 738 | * \param pcCU |
---|
| 739 | * \param uiAbsPartIdx |
---|
| 740 | * \param uiDepth |
---|
| 741 | * \returns Void |
---|
| 742 | */ |
---|
| 743 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 744 | { |
---|
| 745 | UInt uiSymbol, uiMode = 0; |
---|
| 746 | PartSize eMode; |
---|
| 747 | |
---|
| 748 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 749 | { |
---|
| 750 | uiSymbol = 1; |
---|
| 751 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 752 | { |
---|
| 753 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
| 754 | } |
---|
| 755 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
[56] | 756 | UInt uiTrLevel = 0; |
---|
| 757 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
| 758 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
| 759 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
| 760 | if( eMode == SIZE_NxN ) |
---|
| 761 | { |
---|
| 762 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 763 | } |
---|
| 764 | else |
---|
| 765 | { |
---|
| 766 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 767 | } |
---|
[2] | 768 | } |
---|
| 769 | else |
---|
| 770 | { |
---|
[56] | 771 | UInt uiMaxNumBits = 2; |
---|
| 772 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
[2] | 773 | { |
---|
[56] | 774 | uiMaxNumBits ++; |
---|
[2] | 775 | } |
---|
[56] | 776 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
[2] | 777 | { |
---|
[56] | 778 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
| 779 | if ( uiSymbol ) |
---|
[2] | 780 | { |
---|
[56] | 781 | break; |
---|
[2] | 782 | } |
---|
[56] | 783 | uiMode++; |
---|
[2] | 784 | } |
---|
| 785 | eMode = (PartSize) uiMode; |
---|
[56] | 786 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
[2] | 787 | { |
---|
[56] | 788 | if (eMode == SIZE_2NxN) |
---|
| 789 | { |
---|
| 790 | #if AMP_CTX |
---|
| 791 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
| 792 | #else |
---|
| 793 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUYPosiSCModel.get( 0, 0, 0 )); |
---|
[2] | 794 | #endif |
---|
[56] | 795 | if (uiSymbol == 0) |
---|
| 796 | { |
---|
| 797 | #if AMP_CTX |
---|
| 798 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
| 799 | #else |
---|
| 800 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUYPosiSCModel.get( 0, 0, 1 )); |
---|
| 801 | #endif |
---|
| 802 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
| 803 | } |
---|
[2] | 804 | } |
---|
[56] | 805 | else if (eMode == SIZE_Nx2N) |
---|
[2] | 806 | { |
---|
[56] | 807 | #if AMP_CTX |
---|
| 808 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
| 809 | #else |
---|
| 810 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUXPosiSCModel.get( 0, 0, 0 )); |
---|
[2] | 811 | #endif |
---|
[56] | 812 | if (uiSymbol == 0) |
---|
[2] | 813 | { |
---|
[56] | 814 | #if AMP_CTX |
---|
| 815 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
| 816 | #else |
---|
| 817 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUXPosiSCModel.get( 0, 0, 1 )); |
---|
| 818 | #endif |
---|
| 819 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
[2] | 820 | } |
---|
| 821 | } |
---|
| 822 | } |
---|
| 823 | } |
---|
| 824 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
| 825 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 826 | } |
---|
| 827 | |
---|
| 828 | /** parse prediction mode |
---|
| 829 | * \param pcCU |
---|
| 830 | * \param uiAbsPartIdx |
---|
| 831 | * \param uiDepth |
---|
| 832 | * \returns Void |
---|
| 833 | */ |
---|
| 834 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 835 | { |
---|
| 836 | if( pcCU->getSlice()->isIntra() ) |
---|
| 837 | { |
---|
| 838 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
| 839 | return; |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | UInt uiSymbol; |
---|
| 843 | Int iPredMode = MODE_INTER; |
---|
[56] | 844 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 845 | iPredMode += uiSymbol; |
---|
| 846 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
| 847 | } |
---|
[56] | 848 | |
---|
| 849 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 850 | { |
---|
[56] | 851 | UInt uiSymbol; |
---|
| 852 | Int intraPredMode; |
---|
[2] | 853 | |
---|
[5] | 854 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 855 | UInt uiFlag = 0; |
---|
[56] | 856 | if( pcCU->getSlice()->getSPS()->getUseDMM() && (g_uiMaxCUWidth>>uiDepth) <= DMM_WEDGEMODEL_MAX_SIZE ) |
---|
[2] | 857 | { |
---|
[56] | 858 | m_pcTDecBinIf->decodeBin( uiFlag, m_cDmmFlagSCModel.get(0, 0, 0) ); |
---|
[2] | 859 | } |
---|
[56] | 860 | if( uiFlag ) |
---|
[2] | 861 | { |
---|
| 862 | UInt uiDMMode; |
---|
[100] | 863 | |
---|
[5] | 864 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
[56] | 865 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
| 866 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
[2] | 867 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
| 868 | { |
---|
[56] | 869 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 2; |
---|
[2] | 870 | } |
---|
| 871 | #else |
---|
[56] | 872 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
| 873 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
| 874 | { |
---|
| 875 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
[2] | 876 | } |
---|
| 877 | #endif |
---|
[56] | 878 | intraPredMode = uiDMMode + NUM_INTRA_MODE; |
---|
[2] | 879 | |
---|
[5] | 880 | #if HHI_DMM_WEDGE_INTRA |
---|
[56] | 881 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 882 | if( intraPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 883 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 884 | if( intraPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
[5] | 885 | #endif |
---|
| 886 | #if HHI_DMM_PRED_TEX |
---|
[56] | 887 | if( intraPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 888 | if( intraPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
[5] | 889 | #endif |
---|
[2] | 890 | } |
---|
| 891 | else |
---|
| 892 | { |
---|
| 893 | #endif |
---|
[56] | 894 | #if !LOGI_INTRA_NAME_3MPM |
---|
[100] | 895 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
[56] | 896 | #endif |
---|
[100] | 897 | |
---|
| 898 | #if LGE_EDGE_INTRA |
---|
| 899 | Bool bCodeEdgeIntra = false; |
---|
| 900 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 901 | { |
---|
| 902 | UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); |
---|
| 903 | if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) |
---|
| 904 | bCodeEdgeIntra = true; |
---|
| 905 | } |
---|
| 906 | #endif |
---|
| 907 | |
---|
[56] | 908 | #if LOGI_INTRA_NAME_3MPM |
---|
[100] | 909 | Int uiPreds[3] = {-1, -1, -1}; |
---|
[2] | 910 | #else |
---|
[100] | 911 | Int uiPreds[2] = {-1, -1}; |
---|
[56] | 912 | #endif |
---|
[100] | 913 | Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); |
---|
| 914 | #if LGE_EDGE_INTRA |
---|
| 915 | UInt uiCheckBit = 0; |
---|
| 916 | #endif |
---|
| 917 | |
---|
| 918 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
| 919 | |
---|
| 920 | if ( uiSymbol ) |
---|
[56] | 921 | { |
---|
| 922 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
[100] | 923 | #if LOGI_INTRA_NAME_3MPM |
---|
| 924 | if (uiSymbol) |
---|
| 925 | { |
---|
| 926 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 927 | uiSymbol++; |
---|
| 928 | } |
---|
[5] | 929 | #endif |
---|
[100] | 930 | intraPredMode = uiPreds[uiSymbol]; |
---|
[56] | 931 | } |
---|
[100] | 932 | else |
---|
[2] | 933 | { |
---|
[100] | 934 | intraPredMode = 0; |
---|
| 935 | |
---|
| 936 | #if LOGI_INTRA_NAME_3MPM |
---|
| 937 | |
---|
| 938 | m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 ); |
---|
| 939 | #if LGE_EDGE_INTRA |
---|
| 940 | if (bCodeEdgeIntra) |
---|
| 941 | { |
---|
| 942 | if (uiSymbol==31) |
---|
| 943 | { |
---|
| 944 | m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1); |
---|
| 945 | if (uiCheckBit) |
---|
| 946 | uiSymbol = EDGE_INTRA_IDX; |
---|
| 947 | } |
---|
| 948 | } |
---|
| 949 | #endif |
---|
| 950 | intraPredMode = uiSymbol; |
---|
| 951 | |
---|
| 952 | //postponed sorting of MPMs (only in remaining branch) |
---|
| 953 | if (uiPreds[0] > uiPreds[1]) |
---|
| 954 | { |
---|
| 955 | std::swap(uiPreds[0], uiPreds[1]); |
---|
| 956 | } |
---|
| 957 | if (uiPreds[0] > uiPreds[2]) |
---|
| 958 | { |
---|
| 959 | std::swap(uiPreds[0], uiPreds[2]); |
---|
| 960 | } |
---|
| 961 | if (uiPreds[1] > uiPreds[2]) |
---|
| 962 | { |
---|
| 963 | std::swap(uiPreds[1], uiPreds[2]); |
---|
| 964 | } |
---|
| 965 | #else |
---|
| 966 | m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 ); |
---|
| 967 | intraPredMode = uiSymbol; |
---|
| 968 | |
---|
| 969 | if ( intraPredMode == 31 ) |
---|
| 970 | { |
---|
| 971 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 972 | intraPredMode += uiSymbol; |
---|
| 973 | } |
---|
| 974 | #endif |
---|
| 975 | #if LGE_EDGE_INTRA |
---|
| 976 | if ( intraPredMode != EDGE_INTRA_IDX) |
---|
| 977 | { |
---|
| 978 | #endif |
---|
| 979 | for ( Int i = 0; i < uiPredNum; i++ ) |
---|
| 980 | { |
---|
| 981 | intraPredMode += ( intraPredMode >= uiPreds[i] ); |
---|
| 982 | } |
---|
| 983 | #if LGE_EDGE_INTRA |
---|
| 984 | } |
---|
| 985 | #endif |
---|
[2] | 986 | } |
---|
[100] | 987 | |
---|
| 988 | #if LGE_EDGE_INTRA |
---|
| 989 | if( intraPredMode == EDGE_INTRA_IDX ) |
---|
[2] | 990 | { |
---|
[100] | 991 | xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 992 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 993 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); |
---|
| 994 | if( uiSymbol ) |
---|
| 995 | { |
---|
| 996 | intraPredMode = EDGE_INTRA_DELTA_IDX; |
---|
| 997 | Int iDeltaDC0; |
---|
| 998 | Int iDeltaDC1; |
---|
| 999 | |
---|
| 1000 | xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
| 1001 | if( iDeltaDC0 != 0 ) |
---|
| 1002 | { |
---|
| 1003 | UInt uiSign; |
---|
| 1004 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 1005 | if ( uiSign ) |
---|
| 1006 | { |
---|
| 1007 | iDeltaDC0 = -iDeltaDC0; |
---|
| 1008 | } |
---|
| 1009 | } |
---|
| 1010 | xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
| 1011 | if( iDeltaDC1 != 0 ) |
---|
| 1012 | { |
---|
| 1013 | UInt uiSign; |
---|
| 1014 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 1015 | if ( uiSign ) |
---|
| 1016 | { |
---|
| 1017 | iDeltaDC1 = -iDeltaDC1; |
---|
| 1018 | } |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); |
---|
| 1022 | pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); |
---|
| 1023 | } |
---|
| 1024 | #endif |
---|
[2] | 1025 | } |
---|
[56] | 1026 | #endif |
---|
[100] | 1027 | |
---|
[56] | 1028 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 1029 | } |
---|
[2] | 1030 | #endif |
---|
[100] | 1031 | |
---|
[56] | 1032 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth ); |
---|
| 1033 | } |
---|
[2] | 1034 | |
---|
| 1035 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1036 | { |
---|
| 1037 | UInt uiSymbol; |
---|
| 1038 | |
---|
[56] | 1039 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
| 1040 | |
---|
| 1041 | if( uiSymbol == 0 ) |
---|
[2] | 1042 | { |
---|
[56] | 1043 | uiSymbol = DM_CHROMA_IDX; |
---|
[2] | 1044 | } |
---|
| 1045 | else |
---|
| 1046 | { |
---|
[56] | 1047 | if( pcCU->getSlice()->getSPS()->getUseLMChroma() ) |
---|
[2] | 1048 | { |
---|
[56] | 1049 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) ); |
---|
[2] | 1050 | } |
---|
[56] | 1051 | else |
---|
| 1052 | { |
---|
| 1053 | uiSymbol = 1; |
---|
| 1054 | } |
---|
[2] | 1055 | |
---|
[56] | 1056 | if( uiSymbol == 0 ) |
---|
[2] | 1057 | { |
---|
[56] | 1058 | uiSymbol = LM_CHROMA_IDX; |
---|
| 1059 | } |
---|
| 1060 | else |
---|
| 1061 | { |
---|
| 1062 | UInt uiIPredMode; |
---|
| 1063 | #if CHROMA_MODE_CODING |
---|
| 1064 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
| 1065 | #else |
---|
| 1066 | xReadUnaryMaxSymbol( uiIPredMode, m_cCUChromaPredSCModel.get( 0, 0 ) + 1, 0, 3 ); |
---|
[2] | 1067 | #endif |
---|
[56] | 1068 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
| 1069 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
| 1070 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
[2] | 1071 | } |
---|
| 1072 | } |
---|
| 1073 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
| 1074 | return; |
---|
| 1075 | } |
---|
| 1076 | |
---|
| 1077 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1078 | { |
---|
| 1079 | UInt uiSymbol; |
---|
[56] | 1080 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
| 1081 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
| 1082 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
| 1083 | |
---|
| 1084 | if( uiSymbol ) |
---|
[2] | 1085 | { |
---|
| 1086 | uiSymbol = 2; |
---|
| 1087 | } |
---|
[56] | 1088 | |
---|
[2] | 1089 | uiSymbol++; |
---|
| 1090 | ruiInterDir = uiSymbol; |
---|
| 1091 | return; |
---|
| 1092 | } |
---|
| 1093 | |
---|
| 1094 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
| 1095 | { |
---|
| 1096 | UInt uiSymbol; |
---|
| 1097 | |
---|
| 1098 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C) |
---|
| 1099 | { |
---|
[56] | 1100 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
| 1101 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
[2] | 1102 | |
---|
[56] | 1103 | if( uiSymbol ) |
---|
[2] | 1104 | { |
---|
[56] | 1105 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); |
---|
[2] | 1106 | uiSymbol++; |
---|
| 1107 | } |
---|
| 1108 | riRefFrmIdx = uiSymbol; |
---|
| 1109 | } |
---|
| 1110 | else |
---|
| 1111 | { |
---|
[56] | 1112 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
| 1113 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
[2] | 1114 | |
---|
[56] | 1115 | if( uiSymbol ) |
---|
| 1116 | { |
---|
| 1117 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); |
---|
| 1118 | uiSymbol++; |
---|
| 1119 | } |
---|
| 1120 | riRefFrmIdx = uiSymbol; |
---|
[2] | 1121 | } |
---|
| 1122 | |
---|
| 1123 | return; |
---|
| 1124 | } |
---|
| 1125 | |
---|
[56] | 1126 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
[2] | 1127 | { |
---|
| 1128 | UInt uiSymbol; |
---|
[56] | 1129 | UInt uiHorAbs; |
---|
| 1130 | UInt uiVerAbs; |
---|
| 1131 | UInt uiHorSign = 0; |
---|
| 1132 | UInt uiVerSign = 0; |
---|
| 1133 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
[2] | 1134 | |
---|
[56] | 1135 | #if H0111_MVD_L1_ZERO |
---|
| 1136 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
| 1137 | { |
---|
| 1138 | uiHorAbs=0; |
---|
| 1139 | uiVerAbs=0; |
---|
| 1140 | } |
---|
| 1141 | else |
---|
| 1142 | { |
---|
[2] | 1143 | #endif |
---|
| 1144 | |
---|
[56] | 1145 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
| 1146 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
[2] | 1147 | |
---|
[56] | 1148 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
| 1149 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
| 1150 | pCtx++; |
---|
| 1151 | |
---|
| 1152 | if( bHorAbsGr0 ) |
---|
| 1153 | { |
---|
| 1154 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1155 | uiHorAbs += uiSymbol; |
---|
| 1156 | } |
---|
| 1157 | |
---|
| 1158 | if( bVerAbsGr0 ) |
---|
| 1159 | { |
---|
| 1160 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1161 | uiVerAbs += uiSymbol; |
---|
| 1162 | } |
---|
| 1163 | |
---|
| 1164 | if( bHorAbsGr0 ) |
---|
| 1165 | { |
---|
| 1166 | if( 2 == uiHorAbs ) |
---|
| 1167 | { |
---|
| 1168 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 1169 | uiHorAbs += uiSymbol; |
---|
| 1170 | } |
---|
| 1171 | |
---|
| 1172 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
| 1173 | } |
---|
| 1174 | |
---|
| 1175 | if( bVerAbsGr0 ) |
---|
| 1176 | { |
---|
| 1177 | if( 2 == uiVerAbs ) |
---|
| 1178 | { |
---|
| 1179 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 1180 | uiVerAbs += uiSymbol; |
---|
| 1181 | } |
---|
| 1182 | |
---|
| 1183 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
| 1184 | } |
---|
| 1185 | |
---|
| 1186 | #if H0111_MVD_L1_ZERO |
---|
| 1187 | } |
---|
[2] | 1188 | #endif |
---|
| 1189 | |
---|
[56] | 1190 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
| 1191 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 1192 | return; |
---|
| 1193 | } |
---|
| 1194 | |
---|
| 1195 | |
---|
| 1196 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
| 1197 | { |
---|
| 1198 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
[56] | 1199 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1200 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
| 1201 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1202 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
| 1203 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1204 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
| 1205 | DTRACE_CABAC_T( "\n" ) |
---|
| 1206 | } |
---|
| 1207 | |
---|
| 1208 | Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
| 1209 | { |
---|
| 1210 | UInt uiSymbol; |
---|
[56] | 1211 | const UInt uiCtx = 0; |
---|
[2] | 1212 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
[56] | 1213 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1214 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
| 1215 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1216 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 1217 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1218 | DTRACE_CABAC_V( uiCtx ) |
---|
| 1219 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1220 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1221 | DTRACE_CABAC_T( "\n" ) |
---|
| 1222 | |
---|
| 1223 | uiQtRootCbf = uiSymbol; |
---|
| 1224 | } |
---|
| 1225 | |
---|
| 1226 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1227 | { |
---|
[56] | 1228 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1229 | Int qp; |
---|
| 1230 | #endif |
---|
[2] | 1231 | UInt uiDQp; |
---|
| 1232 | Int iDQp; |
---|
| 1233 | |
---|
| 1234 | m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) ); |
---|
| 1235 | |
---|
| 1236 | if ( uiDQp == 0 ) |
---|
| 1237 | { |
---|
[56] | 1238 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1239 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
| 1240 | #else |
---|
| 1241 | uiDQp = pcCU->getRefQP(uiAbsPartIdx); |
---|
| 1242 | #endif |
---|
[2] | 1243 | } |
---|
| 1244 | else |
---|
| 1245 | { |
---|
[56] | 1246 | UInt uiSign; |
---|
| 1247 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1248 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1249 | #else |
---|
| 1250 | UInt uiQpBdOffsetY = 6*(g_uiBitIncrement + g_uiBitDepth - 8); |
---|
| 1251 | #endif |
---|
| 1252 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
| 1253 | |
---|
| 1254 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1255 | UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign); |
---|
| 1256 | #else |
---|
| 1257 | UInt uiMaxAbsDQpMinus1 = 24 + (uiQpBdOffsetY/2) + (uiSign); |
---|
| 1258 | #endif |
---|
| 1259 | UInt uiAbsDQpMinus1; |
---|
| 1260 | xReadUnaryMaxSymbol (uiAbsDQpMinus1, &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1); |
---|
| 1261 | |
---|
| 1262 | iDQp = uiAbsDQpMinus1 + 1; |
---|
| 1263 | |
---|
| 1264 | if(uiSign) |
---|
[2] | 1265 | { |
---|
| 1266 | iDQp = -iDQp; |
---|
| 1267 | } |
---|
[56] | 1268 | |
---|
| 1269 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1270 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
| 1271 | #else |
---|
| 1272 | #if LOSSLESS_CODING |
---|
| 1273 | uiDQp = (pcCU->getRefQP(uiAbsPartIdx) + iDQp + 52) % 52; |
---|
| 1274 | #else |
---|
| 1275 | uiDQp = pcCU->getRefQP(uiAbsPartIdx) + iDQp; |
---|
| 1276 | #endif |
---|
| 1277 | #endif |
---|
[2] | 1278 | } |
---|
| 1279 | |
---|
[56] | 1280 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ; |
---|
| 1281 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 1282 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1283 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 1284 | #else |
---|
| 1285 | pcCU->setQPSubParts( uiDQp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 1286 | #endif |
---|
[2] | 1287 | } |
---|
| 1288 | |
---|
| 1289 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
| 1290 | { |
---|
| 1291 | UInt uiSymbol; |
---|
| 1292 | const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth ); |
---|
[56] | 1293 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
[2] | 1294 | |
---|
[56] | 1295 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1296 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
| 1297 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1298 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 1299 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1300 | DTRACE_CABAC_V( uiCtx ) |
---|
| 1301 | DTRACE_CABAC_T( "\tetype=" ) |
---|
| 1302 | DTRACE_CABAC_V( eType ) |
---|
| 1303 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1304 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1305 | DTRACE_CABAC_T( "\n" ) |
---|
| 1306 | |
---|
| 1307 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
| 1308 | } |
---|
| 1309 | |
---|
| 1310 | /** Parse (X,Y) position of the last significant coefficient |
---|
| 1311 | * \param uiPosLastX reference to X component of last coefficient |
---|
| 1312 | * \param uiPosLastY reference to Y component of last coefficient |
---|
[56] | 1313 | * \param width Block width |
---|
| 1314 | * \param height Block height |
---|
[2] | 1315 | * \param eTType plane type / luminance or chrominance |
---|
| 1316 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
[56] | 1317 | * |
---|
[2] | 1318 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
| 1319 | */ |
---|
[56] | 1320 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
[2] | 1321 | { |
---|
| 1322 | UInt uiLast; |
---|
[56] | 1323 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
| 1324 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
[2] | 1325 | |
---|
[56] | 1326 | // posX |
---|
| 1327 | #if LAST_CTX_REDUCTION |
---|
| 1328 | Int widthCtx = eTType ? 4 : width; |
---|
| 1329 | const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) ); |
---|
| 1330 | #else |
---|
| 1331 | const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ width ] * ( g_aucConvertToBit[ width ] + 3 ) ); |
---|
| 1332 | #endif |
---|
| 1333 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
[2] | 1334 | { |
---|
[56] | 1335 | #if LAST_CTX_REDUCTION |
---|
| 1336 | if ( eTType ) |
---|
[2] | 1337 | { |
---|
[56] | 1338 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + (uiPosLastX>>g_aucConvertToBit[ width ]) ) ); |
---|
| 1339 | } |
---|
| 1340 | else |
---|
| 1341 | { |
---|
| 1342 | #endif |
---|
| 1343 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + puiCtxIdxX[ uiPosLastX ] ) ); |
---|
| 1344 | #if LAST_CTX_REDUCTION |
---|
| 1345 | } |
---|
| 1346 | #endif |
---|
| 1347 | if( !uiLast ) |
---|
| 1348 | { |
---|
[2] | 1349 | break; |
---|
| 1350 | } |
---|
| 1351 | } |
---|
| 1352 | |
---|
[56] | 1353 | // posY |
---|
| 1354 | #if LAST_CTX_REDUCTION |
---|
| 1355 | Int heightCtx = eTType? 4 : height; |
---|
| 1356 | const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) ); |
---|
| 1357 | #else |
---|
| 1358 | const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ height ] * ( g_aucConvertToBit[ height ] + 3 ) ); |
---|
| 1359 | #endif |
---|
| 1360 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
[2] | 1361 | { |
---|
[56] | 1362 | #if LAST_CTX_REDUCTION |
---|
| 1363 | if (eTType) |
---|
[2] | 1364 | { |
---|
[56] | 1365 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + (uiPosLastY>>g_aucConvertToBit[ height ]) ) ); |
---|
| 1366 | } |
---|
| 1367 | else |
---|
| 1368 | { |
---|
| 1369 | #endif |
---|
| 1370 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + puiCtxIdxY[ uiPosLastY ] ) ); |
---|
| 1371 | #if LAST_CTX_REDUCTION |
---|
| 1372 | } |
---|
| 1373 | #endif |
---|
| 1374 | if( !uiLast ) |
---|
| 1375 | { |
---|
[2] | 1376 | break; |
---|
| 1377 | } |
---|
| 1378 | } |
---|
[56] | 1379 | if ( uiPosLastX > 3 ) |
---|
| 1380 | { |
---|
| 1381 | UInt uiTemp = 0; |
---|
| 1382 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
| 1383 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1384 | { |
---|
| 1385 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1386 | uiTemp += uiLast << i; |
---|
| 1387 | } |
---|
| 1388 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
| 1389 | } |
---|
| 1390 | if ( uiPosLastY > 3 ) |
---|
| 1391 | { |
---|
| 1392 | UInt uiTemp = 0; |
---|
| 1393 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
| 1394 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1395 | { |
---|
| 1396 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1397 | uiTemp += uiLast << i; |
---|
| 1398 | } |
---|
| 1399 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
| 1400 | } |
---|
| 1401 | |
---|
[2] | 1402 | if( uiScanIdx == SCAN_VER ) |
---|
| 1403 | { |
---|
| 1404 | swap( uiPosLastX, uiPosLastY ); |
---|
| 1405 | } |
---|
| 1406 | } |
---|
| 1407 | |
---|
| 1408 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1409 | { |
---|
[56] | 1410 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1411 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
| 1412 | DTRACE_CABAC_V( eTType ) |
---|
| 1413 | DTRACE_CABAC_T( "\twidth=" ) |
---|
| 1414 | DTRACE_CABAC_V( uiWidth ) |
---|
| 1415 | DTRACE_CABAC_T( "\theight=" ) |
---|
| 1416 | DTRACE_CABAC_V( uiHeight ) |
---|
| 1417 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
| 1418 | DTRACE_CABAC_V( uiDepth ) |
---|
| 1419 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
| 1420 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1421 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
| 1422 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
| 1423 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
| 1424 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
| 1425 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
| 1426 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
| 1427 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
| 1428 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1429 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
| 1430 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1431 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
| 1432 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
| 1433 | DTRACE_CABAC_T( "\n" ) |
---|
| 1434 | |
---|
| 1435 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
| 1436 | { |
---|
| 1437 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1438 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1439 | } |
---|
| 1440 | |
---|
| 1441 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
| 1442 | |
---|
| 1443 | //----- parse significance map ----- |
---|
| 1444 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
[56] | 1445 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
[2] | 1446 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
[56] | 1447 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
| 1448 | int blockType = uiLog2BlockSize; |
---|
| 1449 | if (uiWidth != uiHeight) |
---|
| 1450 | { |
---|
| 1451 | uiScanIdx = SCAN_DIAG; |
---|
| 1452 | blockType = 4; |
---|
| 1453 | } |
---|
[2] | 1454 | |
---|
[56] | 1455 | //===== decode last significant ===== |
---|
| 1456 | UInt uiPosLastX, uiPosLastY; |
---|
| 1457 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
| 1458 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
| 1459 | pcCoef[ uiBlkPosLast ] = 1; |
---|
[2] | 1460 | |
---|
[56] | 1461 | //===== decode significance flags ===== |
---|
| 1462 | UInt uiScanPosLast = uiBlkPosLast; |
---|
| 1463 | if (uiScanIdx == SCAN_ZIGZAG) |
---|
| 1464 | { |
---|
| 1465 | // Map zigzag to diagonal scan |
---|
| 1466 | uiScanIdx = SCAN_DIAG; |
---|
| 1467 | } |
---|
| 1468 | const UInt * scan; |
---|
| 1469 | if (uiWidth == uiHeight) |
---|
| 1470 | { |
---|
| 1471 | scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
| 1472 | } |
---|
| 1473 | else |
---|
| 1474 | { |
---|
| 1475 | scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
| 1476 | } |
---|
| 1477 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
| 1478 | { |
---|
| 1479 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
| 1480 | if( uiBlkPosLast == uiBlkPos ) |
---|
[2] | 1481 | { |
---|
[56] | 1482 | break; |
---|
[2] | 1483 | } |
---|
[56] | 1484 | } |
---|
[2] | 1485 | |
---|
[56] | 1486 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
| 1487 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
| 1488 | |
---|
| 1489 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
| 1490 | UInt uiNumOne = 0; |
---|
| 1491 | UInt uiGoRiceParam = 0; |
---|
| 1492 | |
---|
| 1493 | #if MULTIBITS_DATA_HIDING |
---|
| 1494 | UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG(); |
---|
| 1495 | #if LOSSLESS_CODING |
---|
| 1496 | Bool beValid; |
---|
| 1497 | if (pcCU->isLosslessCoded(uiAbsPartIdx)) |
---|
[2] | 1498 | { |
---|
[56] | 1499 | beValid = false; |
---|
| 1500 | } |
---|
| 1501 | else |
---|
| 1502 | { |
---|
| 1503 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
| 1504 | } |
---|
[2] | 1505 | #else |
---|
[56] | 1506 | Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
[2] | 1507 | #endif |
---|
[56] | 1508 | UInt absSum = 0; |
---|
| 1509 | #endif // MULTIBITS_DATA_HIDING |
---|
| 1510 | |
---|
| 1511 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
| 1512 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
| 1513 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
| 1514 | const UInt * scanCG; |
---|
| 1515 | if (uiWidth == uiHeight) |
---|
| 1516 | { |
---|
| 1517 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
| 1518 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1519 | if( uiLog2BlockSize == 3 ) |
---|
[2] | 1520 | { |
---|
[56] | 1521 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
[2] | 1522 | } |
---|
[56] | 1523 | else if( uiLog2BlockSize == 5 ) |
---|
| 1524 | { |
---|
| 1525 | scanCG = g_sigLastScanCG32x32; |
---|
| 1526 | } |
---|
| 1527 | #endif |
---|
[2] | 1528 | } |
---|
[56] | 1529 | else |
---|
[2] | 1530 | { |
---|
[56] | 1531 | scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
[2] | 1532 | } |
---|
[56] | 1533 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
| 1534 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
| 1535 | { |
---|
| 1536 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
| 1537 | uiGoRiceParam = 0; |
---|
| 1538 | Int numNonZero = 0; |
---|
| 1539 | |
---|
| 1540 | #if MULTIBITS_DATA_HIDING |
---|
| 1541 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
[2] | 1542 | #endif |
---|
[56] | 1543 | |
---|
| 1544 | Int pos[SCAN_SET_SIZE]; |
---|
| 1545 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
| 1546 | { |
---|
| 1547 | #if MULTIBITS_DATA_HIDING |
---|
| 1548 | lastNZPosInCG = iScanPosSig; |
---|
| 1549 | firstNZPosInCG = iScanPosSig; |
---|
[2] | 1550 | #endif |
---|
[56] | 1551 | iScanPosSig--; |
---|
| 1552 | pos[ numNonZero ] = uiBlkPosLast; |
---|
| 1553 | numNonZero = 1; |
---|
| 1554 | } |
---|
[2] | 1555 | |
---|
[56] | 1556 | #if !MULTILEVEL_SIGMAP_EXT |
---|
| 1557 | if( blockType > 3 ) |
---|
[2] | 1558 | { |
---|
| 1559 | #endif |
---|
[56] | 1560 | // decode significant_coeffgroup_flag |
---|
| 1561 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
| 1562 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
| 1563 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
| 1564 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1565 | if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) ) |
---|
[2] | 1566 | { |
---|
[56] | 1567 | iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0); |
---|
| 1568 | iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0); |
---|
[2] | 1569 | } |
---|
[56] | 1570 | #endif |
---|
| 1571 | #if !REMOVE_INFER_SIGGRP |
---|
| 1572 | Bool bInferredCGFlag = false; |
---|
| 1573 | #endif |
---|
| 1574 | #if REMOVE_INFER_SIGGRP |
---|
| 1575 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
| 1576 | #else |
---|
| 1577 | if( iSubSet == iLastScanSet ) |
---|
| 1578 | #endif |
---|
[2] | 1579 | { |
---|
[56] | 1580 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
| 1581 | } |
---|
| 1582 | else |
---|
| 1583 | { |
---|
| 1584 | #if !REMOVE_INFER_SIGGRP |
---|
| 1585 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1586 | if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight) && ( iSubSet ) ) |
---|
| 1587 | #else |
---|
| 1588 | if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight) && ( iSubSet ) ) |
---|
| 1589 | #endif |
---|
[2] | 1590 | { |
---|
[56] | 1591 | #endif |
---|
| 1592 | UInt uiSigCoeffGroup; |
---|
| 1593 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1594 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ); |
---|
| 1595 | #else |
---|
| 1596 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
| 1597 | #endif |
---|
| 1598 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
| 1599 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
| 1600 | #if !REMOVE_INFER_SIGGRP |
---|
[2] | 1601 | } |
---|
| 1602 | else |
---|
| 1603 | { |
---|
[56] | 1604 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
| 1605 | bInferredCGFlag = true; |
---|
[2] | 1606 | } |
---|
[56] | 1607 | #endif |
---|
| 1608 | } |
---|
| 1609 | |
---|
| 1610 | // decode significant_coeff_flag |
---|
| 1611 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
| 1612 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
| 1613 | { |
---|
| 1614 | uiBlkPos = scan[ iScanPosSig ]; |
---|
| 1615 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
| 1616 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
| 1617 | uiSig = 0; |
---|
[2] | 1618 | |
---|
[56] | 1619 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
[2] | 1620 | { |
---|
[56] | 1621 | #if REMOVE_INFER_SIGGRP |
---|
| 1622 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
| 1623 | #else |
---|
| 1624 | if( iScanPosSig > iSubPos || bInferredCGFlag || numNonZero ) |
---|
| 1625 | #endif |
---|
[2] | 1626 | { |
---|
[56] | 1627 | uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); |
---|
| 1628 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
[2] | 1629 | } |
---|
[56] | 1630 | else |
---|
| 1631 | { |
---|
| 1632 | uiSig = 1; |
---|
| 1633 | } |
---|
[2] | 1634 | } |
---|
[56] | 1635 | pcCoef[ uiBlkPos ] = uiSig; |
---|
| 1636 | if( uiSig ) |
---|
[2] | 1637 | { |
---|
[56] | 1638 | pos[ numNonZero ] = uiBlkPos; |
---|
| 1639 | numNonZero ++; |
---|
| 1640 | #if MULTIBITS_DATA_HIDING |
---|
| 1641 | if( lastNZPosInCG == -1 ) |
---|
[2] | 1642 | { |
---|
[56] | 1643 | lastNZPosInCG = iScanPosSig; |
---|
| 1644 | } |
---|
| 1645 | firstNZPosInCG = iScanPosSig; |
---|
[2] | 1646 | #endif |
---|
| 1647 | } |
---|
[56] | 1648 | } |
---|
| 1649 | #if !MULTILEVEL_SIGMAP_EXT |
---|
| 1650 | } |
---|
| 1651 | else |
---|
| 1652 | { |
---|
| 1653 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
| 1654 | { |
---|
| 1655 | UInt uiBlkPos = scan[ iScanPosSig ]; |
---|
| 1656 | UInt uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
| 1657 | UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
| 1658 | UInt uiSig = 0; |
---|
| 1659 | UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); |
---|
| 1660 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
| 1661 | pcCoef[ uiBlkPos ] = uiSig; |
---|
| 1662 | if( uiSig ) |
---|
[2] | 1663 | { |
---|
[56] | 1664 | pos[ numNonZero ] = uiBlkPos; |
---|
| 1665 | numNonZero ++; |
---|
| 1666 | #if MULTIBITS_DATA_HIDING |
---|
| 1667 | if( lastNZPosInCG == -1 ) |
---|
[2] | 1668 | { |
---|
[56] | 1669 | lastNZPosInCG = iScanPosSig; |
---|
[2] | 1670 | } |
---|
[56] | 1671 | firstNZPosInCG = iScanPosSig; |
---|
| 1672 | #endif |
---|
[2] | 1673 | } |
---|
| 1674 | } |
---|
| 1675 | } |
---|
[56] | 1676 | #endif |
---|
| 1677 | |
---|
[2] | 1678 | |
---|
[56] | 1679 | if( numNonZero ) |
---|
[2] | 1680 | { |
---|
[56] | 1681 | #if MULTIBITS_DATA_HIDING |
---|
| 1682 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig ); |
---|
| 1683 | absSum = 0; |
---|
| 1684 | #endif // MULTIBITS_DATA_HIDING |
---|
| 1685 | |
---|
| 1686 | UInt c1 = 1; |
---|
| 1687 | #if !RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1688 | UInt c2 = 0; |
---|
| 1689 | #endif |
---|
| 1690 | #if LEVEL_CTX_LUMA_RED |
---|
| 1691 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
| 1692 | #else |
---|
| 1693 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 3 : 0; |
---|
| 1694 | #endif |
---|
| 1695 | UInt uiBin; |
---|
[2] | 1696 | |
---|
[56] | 1697 | if( uiNumOne > 0 ) |
---|
[2] | 1698 | { |
---|
[56] | 1699 | uiCtxSet++; |
---|
| 1700 | #if !LEVEL_CTX_LUMA_RED |
---|
| 1701 | if(eTType==TEXT_LUMA && uiNumOne > 3) |
---|
[2] | 1702 | { |
---|
[56] | 1703 | uiCtxSet++; |
---|
[2] | 1704 | } |
---|
[56] | 1705 | #endif |
---|
| 1706 | } |
---|
| 1707 | |
---|
| 1708 | uiNumOne >>= 1; |
---|
| 1709 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
| 1710 | Int absCoeff[SCAN_SET_SIZE]; |
---|
| 1711 | |
---|
| 1712 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1713 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
| 1714 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
| 1715 | Int firstC2FlagIdx = -1; |
---|
| 1716 | |
---|
| 1717 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
| 1718 | #else |
---|
| 1719 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
| 1720 | #endif |
---|
| 1721 | { |
---|
| 1722 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
| 1723 | if( uiBin == 1 ) |
---|
[2] | 1724 | { |
---|
[56] | 1725 | c1 = 0; |
---|
| 1726 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1727 | if (firstC2FlagIdx == -1) |
---|
| 1728 | { |
---|
| 1729 | firstC2FlagIdx = idx; |
---|
| 1730 | } |
---|
| 1731 | #endif |
---|
| 1732 | } |
---|
| 1733 | else if( (c1 < 3) && (c1 > 0) ) |
---|
| 1734 | { |
---|
[2] | 1735 | c1++; |
---|
| 1736 | } |
---|
[56] | 1737 | absCoeff[ idx ] = uiBin + 1; |
---|
| 1738 | } |
---|
| 1739 | |
---|
| 1740 | if (c1 == 0) |
---|
| 1741 | { |
---|
| 1742 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1743 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
| 1744 | if ( firstC2FlagIdx != -1) |
---|
[2] | 1745 | { |
---|
[56] | 1746 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
| 1747 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
[2] | 1748 | } |
---|
[56] | 1749 | #else |
---|
| 1750 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + 3 * uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + 3 * uiCtxSet; |
---|
| 1751 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
| 1752 | { |
---|
| 1753 | if( absCoeff[ idx ] == 2 ) |
---|
| 1754 | { |
---|
| 1755 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c2] ); |
---|
| 1756 | absCoeff[ idx ] = uiBin + 2; |
---|
| 1757 | c2 += (c2 < 2); |
---|
| 1758 | uiNumOne++; |
---|
| 1759 | } |
---|
| 1760 | } |
---|
| 1761 | #endif |
---|
[2] | 1762 | } |
---|
[56] | 1763 | |
---|
| 1764 | #if MULTIBITS_DATA_HIDING |
---|
| 1765 | UInt coeffSigns; |
---|
| 1766 | if ( signHidden && beValid ) |
---|
| 1767 | { |
---|
| 1768 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
| 1769 | coeffSigns <<= 32 - (numNonZero-1); |
---|
| 1770 | } |
---|
| 1771 | else |
---|
| 1772 | { |
---|
| 1773 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
| 1774 | coeffSigns <<= 32 - numNonZero; |
---|
| 1775 | } |
---|
| 1776 | #else |
---|
| 1777 | UInt coeffSigns; |
---|
| 1778 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
| 1779 | coeffSigns <<= 32 - numNonZero; |
---|
| 1780 | #endif |
---|
[2] | 1781 | |
---|
[56] | 1782 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1783 | Int iFirstCoeff2 = 1; |
---|
| 1784 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
| 1785 | #else |
---|
| 1786 | if (c1 == 0) |
---|
| 1787 | #endif |
---|
[2] | 1788 | { |
---|
[56] | 1789 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
[2] | 1790 | { |
---|
[56] | 1791 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1792 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
[2] | 1793 | |
---|
[56] | 1794 | if( absCoeff[ idx ] == baseLevel) |
---|
[2] | 1795 | { |
---|
[56] | 1796 | UInt uiLevel; |
---|
[2] | 1797 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
[56] | 1798 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
[2] | 1799 | } |
---|
[56] | 1800 | |
---|
| 1801 | if(absCoeff[ idx ] >= 2) |
---|
[2] | 1802 | { |
---|
[56] | 1803 | iFirstCoeff2 = 0; |
---|
| 1804 | uiNumOne++; |
---|
[2] | 1805 | } |
---|
| 1806 | #else |
---|
[56] | 1807 | if( absCoeff[ idx ] == 3 ) |
---|
| 1808 | { |
---|
| 1809 | UInt uiLevel; |
---|
| 1810 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
| 1811 | absCoeff[ idx ] = uiLevel + 3; |
---|
| 1812 | } |
---|
[2] | 1813 | #endif |
---|
| 1814 | } |
---|
| 1815 | } |
---|
[56] | 1816 | |
---|
| 1817 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
[2] | 1818 | { |
---|
[56] | 1819 | Int blkPos = pos[ idx ]; |
---|
| 1820 | #if MULTIBITS_DATA_HIDING |
---|
| 1821 | // Signs applied later. |
---|
| 1822 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
| 1823 | absSum += absCoeff[ idx ]; |
---|
| 1824 | |
---|
| 1825 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
| 1826 | { |
---|
| 1827 | // Infer sign of 1st element. |
---|
| 1828 | if (absSum&0x1) |
---|
| 1829 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
| 1830 | } |
---|
| 1831 | else |
---|
| 1832 | { |
---|
| 1833 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
| 1834 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
| 1835 | coeffSigns <<= 1; |
---|
| 1836 | } |
---|
| 1837 | #else |
---|
| 1838 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
| 1839 | pcCoef[ blkPos ] = ( absCoeff[ idx ] ^ sign ) - sign; |
---|
| 1840 | coeffSigns <<= 1; |
---|
| 1841 | #endif |
---|
[2] | 1842 | } |
---|
| 1843 | } |
---|
[56] | 1844 | else |
---|
| 1845 | { |
---|
| 1846 | uiNumOne >>= 1; |
---|
| 1847 | } |
---|
[2] | 1848 | } |
---|
| 1849 | |
---|
| 1850 | return; |
---|
| 1851 | } |
---|
| 1852 | |
---|
| 1853 | |
---|
[56] | 1854 | #if SAO_UNIT_INTERLEAVING |
---|
| 1855 | Void TDecSbac::parseSaoUvlc (UInt& ruiVal) |
---|
[2] | 1856 | { |
---|
| 1857 | UInt uiCode; |
---|
| 1858 | Int i; |
---|
[56] | 1859 | |
---|
| 1860 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 1861 | if ( uiCode == 0 ) |
---|
| 1862 | { |
---|
| 1863 | ruiVal = 0; |
---|
| 1864 | return; |
---|
| 1865 | } |
---|
[56] | 1866 | |
---|
[2] | 1867 | i=1; |
---|
| 1868 | while (1) |
---|
| 1869 | { |
---|
[56] | 1870 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 1 ) ); |
---|
[2] | 1871 | if ( uiCode == 0 ) break; |
---|
| 1872 | i++; |
---|
| 1873 | } |
---|
[56] | 1874 | |
---|
[2] | 1875 | ruiVal = i; |
---|
| 1876 | } |
---|
| 1877 | |
---|
[56] | 1878 | Void TDecSbac::parseSaoSvlc (Int& riVal) |
---|
[2] | 1879 | { |
---|
| 1880 | UInt uiCode; |
---|
| 1881 | Int iSign; |
---|
| 1882 | Int i; |
---|
[56] | 1883 | |
---|
| 1884 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 0 ) ); |
---|
| 1885 | |
---|
[2] | 1886 | if ( uiCode == 0 ) |
---|
| 1887 | { |
---|
| 1888 | riVal = 0; |
---|
| 1889 | return; |
---|
| 1890 | } |
---|
[56] | 1891 | |
---|
[2] | 1892 | // read sign |
---|
[56] | 1893 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 1 ) ); |
---|
| 1894 | |
---|
| 1895 | if ( uiCode == 0 ) |
---|
| 1896 | { |
---|
| 1897 | iSign = 1; |
---|
| 1898 | } |
---|
| 1899 | else |
---|
| 1900 | { |
---|
| 1901 | iSign = -1; |
---|
| 1902 | } |
---|
| 1903 | |
---|
[2] | 1904 | // read magnitude |
---|
| 1905 | i=1; |
---|
| 1906 | while (1) |
---|
| 1907 | { |
---|
[56] | 1908 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 2 ) ); |
---|
[2] | 1909 | if ( uiCode == 0 ) break; |
---|
| 1910 | i++; |
---|
| 1911 | } |
---|
[56] | 1912 | |
---|
[2] | 1913 | riVal = i*iSign; |
---|
| 1914 | } |
---|
| 1915 | |
---|
[56] | 1916 | Void TDecSbac::parseSaoUflc (UInt& riVal) |
---|
[2] | 1917 | { |
---|
| 1918 | UInt uiSymbol; |
---|
[56] | 1919 | riVal = 0; |
---|
| 1920 | for (Int i=0;i<5;i++) |
---|
| 1921 | { |
---|
| 1922 | m_pcTDecBinIf->decodeBinEP ( uiSymbol ); |
---|
| 1923 | if (uiSymbol) |
---|
| 1924 | { |
---|
| 1925 | riVal |= (1<<i); |
---|
| 1926 | } |
---|
| 1927 | } |
---|
[2] | 1928 | } |
---|
[56] | 1929 | Void TDecSbac::parseSaoMergeLeft (UInt& ruiVal, UInt uiCompIdx) |
---|
| 1930 | { |
---|
| 1931 | UInt uiCode; |
---|
| 1932 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) ); |
---|
| 1933 | ruiVal = (Int)uiCode; |
---|
| 1934 | } |
---|
[2] | 1935 | |
---|
[56] | 1936 | Void TDecSbac::parseSaoMergeUp (UInt& ruiVal) |
---|
[2] | 1937 | { |
---|
| 1938 | UInt uiCode; |
---|
[56] | 1939 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) ); |
---|
| 1940 | ruiVal = (Int)uiCode; |
---|
| 1941 | } |
---|
| 1942 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
| 1943 | { |
---|
| 1944 | UInt uiCode; |
---|
[2] | 1945 | Int i; |
---|
[56] | 1946 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 1947 | if ( uiCode == 0 ) |
---|
| 1948 | { |
---|
| 1949 | ruiVal = 0; |
---|
| 1950 | return; |
---|
| 1951 | } |
---|
| 1952 | i=1; |
---|
| 1953 | while (1) |
---|
| 1954 | { |
---|
[56] | 1955 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) ); |
---|
[2] | 1956 | if ( uiCode == 0 ) break; |
---|
| 1957 | i++; |
---|
| 1958 | } |
---|
| 1959 | ruiVal = i; |
---|
| 1960 | } |
---|
| 1961 | |
---|
[56] | 1962 | inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) |
---|
[2] | 1963 | { |
---|
[56] | 1964 | Int i; |
---|
| 1965 | psDst->partIdx = psSrc->partIdx; |
---|
| 1966 | psDst->typeIdx = psSrc->typeIdx; |
---|
| 1967 | if (psDst->typeIdx != -1) |
---|
| 1968 | { |
---|
| 1969 | if (psDst->typeIdx == SAO_BO) |
---|
| 1970 | { |
---|
| 1971 | psDst->bandPosition = psSrc->bandPosition ; |
---|
| 1972 | } |
---|
| 1973 | else |
---|
| 1974 | { |
---|
| 1975 | psDst->bandPosition = 0; |
---|
| 1976 | } |
---|
| 1977 | psDst->length = psSrc->length; |
---|
| 1978 | for (i=0;i<psDst->length;i++) |
---|
| 1979 | { |
---|
| 1980 | psDst->offset[i] = psSrc->offset[i]; |
---|
| 1981 | } |
---|
| 1982 | } |
---|
| 1983 | else |
---|
| 1984 | { |
---|
| 1985 | psDst->length = 0; |
---|
| 1986 | for (i=0;i<SAO_BO_LEN;i++) |
---|
| 1987 | { |
---|
| 1988 | psDst->offset[i] = 0; |
---|
| 1989 | } |
---|
| 1990 | } |
---|
| 1991 | } |
---|
| 1992 | Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam) |
---|
| 1993 | { |
---|
| 1994 | UInt uiSymbol; |
---|
| 1995 | Int iSymbol; |
---|
| 1996 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = { |
---|
| 1997 | SAO_EO_LEN, |
---|
| 1998 | SAO_EO_LEN, |
---|
| 1999 | SAO_EO_LEN, |
---|
| 2000 | SAO_EO_LEN, |
---|
| 2001 | SAO_BO_LEN |
---|
| 2002 | }; |
---|
[2] | 2003 | |
---|
[56] | 2004 | parseSaoTypeIdx(uiSymbol); |
---|
| 2005 | psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
| 2006 | if (uiSymbol) |
---|
| 2007 | { |
---|
| 2008 | psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; |
---|
| 2009 | if( psSaoLcuParam->typeIdx == SAO_BO ) |
---|
| 2010 | { |
---|
| 2011 | // Parse Left Band Index |
---|
| 2012 | parseSaoUflc( uiSymbol ); |
---|
| 2013 | psSaoLcuParam->bandPosition = uiSymbol; |
---|
| 2014 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
| 2015 | { |
---|
| 2016 | parseSaoSvlc(iSymbol); |
---|
| 2017 | psSaoLcuParam->offset[i] = iSymbol; |
---|
| 2018 | } |
---|
| 2019 | } |
---|
| 2020 | else if( psSaoLcuParam->typeIdx < 4 ) |
---|
| 2021 | { |
---|
| 2022 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[0] = uiSymbol; |
---|
| 2023 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[1] = uiSymbol; |
---|
| 2024 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
| 2025 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
| 2026 | } |
---|
| 2027 | } |
---|
| 2028 | else |
---|
| 2029 | { |
---|
| 2030 | psSaoLcuParam->length = 0; |
---|
| 2031 | } |
---|
| 2032 | } |
---|
[2] | 2033 | |
---|
[56] | 2034 | Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag) |
---|
| 2035 | { |
---|
| 2036 | Int iAddr = pcCU->getAddr(); |
---|
| 2037 | UInt uiSymbol; |
---|
| 2038 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
[2] | 2039 | { |
---|
[56] | 2040 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
| 2041 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
| 2042 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
| 2043 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
| 2044 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; |
---|
| 2045 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; |
---|
| 2046 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; |
---|
| 2047 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; |
---|
| 2048 | |
---|
| 2049 | if (pSaoParam->bSaoFlag[iCompIdx]) |
---|
| 2050 | { |
---|
| 2051 | if (rx>0 && iCUAddrInSlice!=0) |
---|
| 2052 | { |
---|
| 2053 | parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol; |
---|
| 2054 | } |
---|
| 2055 | else |
---|
| 2056 | { |
---|
| 2057 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
| 2058 | } |
---|
| 2059 | |
---|
| 2060 | if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) |
---|
| 2061 | { |
---|
| 2062 | if ((ry > 0) && (iCUAddrUpInSlice>0||bLFCrossSliceBoundaryFlag)) |
---|
| 2063 | { |
---|
| 2064 | parseSaoMergeUp(uiSymbol); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol; |
---|
| 2065 | } |
---|
| 2066 | else |
---|
| 2067 | { |
---|
| 2068 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
| 2069 | } |
---|
| 2070 | if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) |
---|
| 2071 | { |
---|
| 2072 | parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr])); |
---|
| 2073 | } |
---|
| 2074 | else |
---|
| 2075 | { |
---|
| 2076 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); |
---|
| 2077 | } |
---|
| 2078 | } |
---|
| 2079 | else |
---|
| 2080 | { |
---|
| 2081 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); |
---|
| 2082 | } |
---|
| 2083 | } |
---|
| 2084 | else |
---|
| 2085 | { |
---|
| 2086 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
| 2087 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
| 2088 | } |
---|
[2] | 2089 | } |
---|
[56] | 2090 | } |
---|
| 2091 | #endif |
---|
[2] | 2092 | |
---|
[56] | 2093 | /** |
---|
| 2094 | - Initialize our contexts from the nominated source. |
---|
| 2095 | . |
---|
| 2096 | \param pSrc Contexts to be copied. |
---|
| 2097 | */ |
---|
| 2098 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
| 2099 | { |
---|
| 2100 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
| 2101 | } |
---|
[2] | 2102 | |
---|
[56] | 2103 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
| 2104 | { |
---|
| 2105 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
[2] | 2106 | |
---|
[56] | 2107 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
| 2108 | xCopyContextsFrom( pSrc ); |
---|
| 2109 | |
---|
| 2110 | } |
---|
| 2111 | |
---|
| 2112 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
| 2113 | { |
---|
| 2114 | xCopyFrom(pScr); |
---|
| 2115 | } |
---|
| 2116 | |
---|
| 2117 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
| 2118 | { |
---|
| 2119 | xCopyContextsFrom(pScr); |
---|
| 2120 | } |
---|
| 2121 | |
---|
| 2122 | #if OL_FLUSH |
---|
| 2123 | Void TDecSbac::decodeFlush ( ) |
---|
| 2124 | { |
---|
| 2125 | UInt uiBit; |
---|
| 2126 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
| 2127 | m_pcTDecBinIf->flush(); |
---|
| 2128 | |
---|
| 2129 | } |
---|
| 2130 | #endif |
---|
| 2131 | |
---|
[100] | 2132 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC) |
---|
[56] | 2133 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
| 2134 | { |
---|
| 2135 | UInt uiSymbol; |
---|
| 2136 | UInt uiCount = 0; |
---|
| 2137 | do |
---|
[2] | 2138 | { |
---|
[56] | 2139 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
| 2140 | uiCount++; |
---|
[2] | 2141 | } |
---|
[56] | 2142 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
[2] | 2143 | |
---|
[56] | 2144 | ruiSymbol = uiCount - 1; |
---|
| 2145 | |
---|
| 2146 | if( uiSymbol ) |
---|
| 2147 | { |
---|
| 2148 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
| 2149 | ruiSymbol += uiSymbol + 1; |
---|
| 2150 | } |
---|
| 2151 | |
---|
| 2152 | return; |
---|
[2] | 2153 | } |
---|
| 2154 | #endif |
---|
[56] | 2155 | #if HHI_DMM_WEDGE_INTRA |
---|
| 2156 | Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2157 | { |
---|
| 2158 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
| 2159 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
| 2160 | |
---|
| 2161 | UInt uiSymbol, uiTabIdx = 0; |
---|
| 2162 | for ( Int i = 0; i < iBits; i++ ) |
---|
| 2163 | { |
---|
| 2164 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
| 2165 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
| 2166 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
| 2167 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
| 2168 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
| 2169 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
| 2170 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
| 2171 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
| 2172 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
| 2173 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
| 2174 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
| 2175 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
| 2176 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
| 2177 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
| 2178 | } |
---|
| 2179 | |
---|
| 2180 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2181 | } |
---|
| 2182 | |
---|
| 2183 | Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2184 | { |
---|
| 2185 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
| 2186 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
| 2187 | |
---|
| 2188 | UInt uiSymbol, uiTabIdx = 0; |
---|
| 2189 | for ( Int i = 0; i < iBits; i++ ) |
---|
| 2190 | { |
---|
| 2191 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
| 2192 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
| 2193 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
| 2194 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
| 2195 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
| 2196 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
| 2197 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
| 2198 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
| 2199 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
| 2200 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
| 2201 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
| 2202 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
| 2203 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
| 2204 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
| 2205 | } |
---|
| 2206 | |
---|
| 2207 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2208 | |
---|
| 2209 | UInt uiDC1, uiDC2; |
---|
| 2210 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2211 | Int iDC1 = uiDC1; |
---|
| 2212 | if ( uiDC1 ) |
---|
| 2213 | { |
---|
| 2214 | UInt uiSign; |
---|
| 2215 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2216 | if ( uiSign ) |
---|
| 2217 | { |
---|
| 2218 | iDC1 = -iDC1; |
---|
| 2219 | } |
---|
| 2220 | } |
---|
| 2221 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2222 | Int iDC2 = uiDC2; |
---|
| 2223 | if ( uiDC2 ) |
---|
| 2224 | { |
---|
| 2225 | UInt uiSign; |
---|
| 2226 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2227 | if ( uiSign ) |
---|
| 2228 | { |
---|
| 2229 | iDC2 = -iDC2; |
---|
| 2230 | } |
---|
| 2231 | } |
---|
| 2232 | |
---|
| 2233 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2234 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2235 | } |
---|
| 2236 | |
---|
| 2237 | Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2238 | { |
---|
| 2239 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
| 2240 | { |
---|
| 2241 | UInt uiDeltaEnd = 0; |
---|
| 2242 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
| 2243 | |
---|
| 2244 | Int iDeltaEnd; |
---|
| 2245 | if( uiDeltaEnd != 0 ) |
---|
| 2246 | { |
---|
| 2247 | UInt uiAbsValMinus1; |
---|
| 2248 | UInt uiSymbol; |
---|
| 2249 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
| 2250 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
| 2251 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
| 2252 | |
---|
| 2253 | iDeltaEnd = uiDeltaEnd; |
---|
| 2254 | UInt uiSign; |
---|
| 2255 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2256 | if( uiSign ) |
---|
| 2257 | { |
---|
| 2258 | iDeltaEnd = -iDeltaEnd; |
---|
| 2259 | } |
---|
| 2260 | } |
---|
| 2261 | else |
---|
| 2262 | { |
---|
| 2263 | iDeltaEnd = 0; |
---|
| 2264 | } |
---|
| 2265 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
| 2266 | } |
---|
| 2267 | } |
---|
| 2268 | |
---|
| 2269 | Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2270 | { |
---|
| 2271 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
| 2272 | { |
---|
| 2273 | UInt uiDeltaEnd = 0; |
---|
| 2274 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
| 2275 | |
---|
| 2276 | Int iDeltaEnd; |
---|
| 2277 | if( uiDeltaEnd != 0 ) |
---|
| 2278 | { |
---|
| 2279 | UInt uiAbsValMinus1; |
---|
| 2280 | UInt uiSymbol; |
---|
| 2281 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
| 2282 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
| 2283 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
| 2284 | |
---|
| 2285 | iDeltaEnd = uiDeltaEnd; |
---|
| 2286 | UInt uiSign; |
---|
| 2287 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2288 | if( uiSign ) |
---|
| 2289 | { |
---|
| 2290 | iDeltaEnd = -iDeltaEnd; |
---|
| 2291 | } |
---|
| 2292 | } |
---|
| 2293 | else |
---|
| 2294 | { |
---|
| 2295 | iDeltaEnd = 0; |
---|
| 2296 | } |
---|
| 2297 | |
---|
| 2298 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
| 2299 | } |
---|
| 2300 | |
---|
| 2301 | UInt uiDC1, uiDC2; |
---|
| 2302 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2303 | Int iDC1 = uiDC1; |
---|
| 2304 | if ( uiDC1 ) |
---|
| 2305 | { |
---|
| 2306 | UInt uiSign; |
---|
| 2307 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2308 | if ( uiSign ) |
---|
| 2309 | { |
---|
| 2310 | iDC1 = -iDC1; |
---|
| 2311 | } |
---|
| 2312 | } |
---|
| 2313 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2314 | Int iDC2 = uiDC2; |
---|
| 2315 | if ( uiDC2 ) |
---|
| 2316 | { |
---|
| 2317 | UInt uiSign; |
---|
| 2318 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2319 | if ( uiSign ) |
---|
| 2320 | { |
---|
| 2321 | iDC2 = -iDC2; |
---|
| 2322 | } |
---|
| 2323 | } |
---|
| 2324 | |
---|
| 2325 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2326 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2327 | } |
---|
| 2328 | #endif |
---|
| 2329 | #if HHI_DMM_PRED_TEX |
---|
| 2330 | Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2331 | { |
---|
| 2332 | UInt uiDC1, uiDC2; |
---|
| 2333 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2334 | Int iDC1 = uiDC1; |
---|
| 2335 | if ( uiDC1 ) |
---|
| 2336 | { |
---|
| 2337 | UInt uiSign; |
---|
| 2338 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2339 | if ( uiSign ) |
---|
| 2340 | { |
---|
| 2341 | iDC1 = -iDC1; |
---|
| 2342 | } |
---|
| 2343 | } |
---|
| 2344 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2345 | Int iDC2 = uiDC2; |
---|
| 2346 | if ( uiDC2 ) |
---|
| 2347 | { |
---|
| 2348 | UInt uiSign; |
---|
| 2349 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2350 | if ( uiSign ) |
---|
| 2351 | { |
---|
| 2352 | iDC2 = -iDC2; |
---|
| 2353 | } |
---|
| 2354 | } |
---|
| 2355 | |
---|
| 2356 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2357 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2358 | } |
---|
| 2359 | |
---|
| 2360 | Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2361 | { |
---|
| 2362 | UInt uiDC1, uiDC2; |
---|
| 2363 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2364 | Int iDC1 = uiDC1; |
---|
| 2365 | if ( uiDC1 ) |
---|
| 2366 | { |
---|
| 2367 | UInt uiSign; |
---|
| 2368 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2369 | if ( uiSign ) |
---|
| 2370 | { |
---|
| 2371 | iDC1 = -iDC1; |
---|
| 2372 | } |
---|
| 2373 | } |
---|
| 2374 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2375 | Int iDC2 = uiDC2; |
---|
| 2376 | if ( uiDC2 ) |
---|
| 2377 | { |
---|
| 2378 | UInt uiSign; |
---|
| 2379 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2380 | if ( uiSign ) |
---|
| 2381 | { |
---|
| 2382 | iDC2 = -iDC2; |
---|
| 2383 | } |
---|
| 2384 | } |
---|
| 2385 | |
---|
| 2386 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2387 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2388 | } |
---|
| 2389 | #endif |
---|
[100] | 2390 | |
---|
| 2391 | #if LGE_EDGE_INTRA |
---|
| 2392 | Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2393 | { |
---|
| 2394 | UInt uiSymbol = 0; |
---|
| 2395 | |
---|
| 2396 | // 1. Top(0) or Left(1) |
---|
| 2397 | UChar ucLeft; |
---|
| 2398 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 2399 | ucLeft = uiSymbol; |
---|
| 2400 | |
---|
| 2401 | // 2. Start position (lowest bit first) |
---|
| 2402 | UChar ucStart = 0; |
---|
| 2403 | for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) |
---|
| 2404 | { |
---|
| 2405 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 2406 | ucStart |= (uiSymbol << ui); |
---|
| 2407 | } |
---|
| 2408 | |
---|
| 2409 | // 3. Number of edges |
---|
| 2410 | UChar ucMax = 0; |
---|
| 2411 | for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) |
---|
| 2412 | { |
---|
| 2413 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 2414 | ucMax |= (uiSymbol << ui); |
---|
| 2415 | } |
---|
| 2416 | ucMax++; // +1 |
---|
| 2417 | |
---|
| 2418 | // 4. Edges |
---|
| 2419 | UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); |
---|
| 2420 | UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx ); |
---|
| 2421 | for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) |
---|
| 2422 | { |
---|
| 2423 | UChar ucEdge = 0; |
---|
| 2424 | UInt uiReorderEdge = 0; |
---|
| 2425 | // Left-friendly direction |
---|
| 2426 | // 0 ( 0deg) => 0 |
---|
| 2427 | // 1 ( 45deg) => 10 |
---|
| 2428 | // 2 ( -45deg) => 110 |
---|
| 2429 | // 3 ( 90deg) => 1110 |
---|
| 2430 | // 4 ( -90deg) => 11110 |
---|
| 2431 | // 5 ( 135deg) => 111110 |
---|
| 2432 | // 6 (-135deg) => 111111 |
---|
| 2433 | // Right-friendly direction |
---|
| 2434 | // 0 ( 0deg) => 0 |
---|
| 2435 | // 1 ( -45deg) => 10 |
---|
| 2436 | // 2 ( 45deg) => 110 |
---|
| 2437 | // 3 ( -90deg) => 1110 |
---|
| 2438 | // 4 ( 90deg) => 11110 |
---|
| 2439 | // 5 (-135deg) => 111110 |
---|
| 2440 | // 6 ( 135deg) => 111111 |
---|
| 2441 | // refer to a paper "An efficient chain code with Huffman coding" |
---|
| 2442 | for( UInt ui = 0; ui < 6; ui++ ) |
---|
| 2443 | { |
---|
| 2444 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); |
---|
| 2445 | ucEdge <<= 1; |
---|
| 2446 | ucEdge |= uiSymbol; |
---|
| 2447 | if( uiSymbol == 0 ) |
---|
| 2448 | break; |
---|
| 2449 | } |
---|
| 2450 | |
---|
| 2451 | switch( ucEdge ) |
---|
| 2452 | { |
---|
| 2453 | case 0 : // "0" |
---|
| 2454 | uiReorderEdge = 0; |
---|
| 2455 | break; |
---|
| 2456 | case 2 : // "10" |
---|
| 2457 | uiReorderEdge = 1; |
---|
| 2458 | break; |
---|
| 2459 | case 6 : // "110" |
---|
| 2460 | uiReorderEdge = 2; |
---|
| 2461 | break; |
---|
| 2462 | case 14 : // "1110" |
---|
| 2463 | uiReorderEdge = 3; |
---|
| 2464 | break; |
---|
| 2465 | case 30 : // "11110" |
---|
| 2466 | uiReorderEdge = 4; |
---|
| 2467 | break; |
---|
| 2468 | case 62 : // "111110" |
---|
| 2469 | uiReorderEdge = 5; |
---|
| 2470 | break; |
---|
| 2471 | case 63 : // "111111" |
---|
| 2472 | uiReorderEdge = 6; |
---|
| 2473 | break; |
---|
| 2474 | default : |
---|
| 2475 | printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); |
---|
| 2476 | assert(false); |
---|
| 2477 | break; |
---|
| 2478 | } |
---|
| 2479 | pucSymbolList[iPtr] = uiReorderEdge; |
---|
| 2480 | } |
---|
| 2481 | ///////////////////// |
---|
| 2482 | // Edge Reconstruction |
---|
| 2483 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
| 2484 | pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); |
---|
| 2485 | xFree( pucSymbolList ); |
---|
| 2486 | } |
---|
| 2487 | #endif |
---|
| 2488 | |
---|
[56] | 2489 | //! \} |
---|