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