[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 | |
---|
| 764 | if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) |
---|
| 765 | { |
---|
| 766 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
| 767 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
| 768 | bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | if(bParseSplitFlag) |
---|
| 772 | { |
---|
| 773 | #endif |
---|
| 774 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
| 775 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 776 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
| 777 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 778 | } |
---|
| 779 | else |
---|
| 780 | uiSymbol = 0; |
---|
| 781 | #endif |
---|
| 782 | |
---|
[2] | 783 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
| 784 | |
---|
| 785 | return; |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | /** parse partition size |
---|
| 789 | * \param pcCU |
---|
| 790 | * \param uiAbsPartIdx |
---|
| 791 | * \param uiDepth |
---|
| 792 | * \returns Void |
---|
| 793 | */ |
---|
| 794 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 795 | { |
---|
| 796 | UInt uiSymbol, uiMode = 0; |
---|
| 797 | PartSize eMode; |
---|
[189] | 798 | |
---|
| 799 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 800 | Bool bParsePartSize = true; |
---|
| 801 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
| 802 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
| 803 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
| 804 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
| 805 | |
---|
| 806 | if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) |
---|
| 807 | { |
---|
| 808 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
| 809 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
| 810 | if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN) |
---|
| 811 | { |
---|
| 812 | bParsePartSize = false; |
---|
| 813 | eMode = SIZE_2Nx2N; |
---|
| 814 | } |
---|
| 815 | } |
---|
| 816 | #endif |
---|
[2] | 817 | |
---|
| 818 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 819 | { |
---|
[189] | 820 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 821 | if(bParsePartSize) |
---|
[2] | 822 | { |
---|
[189] | 823 | #endif |
---|
| 824 | uiSymbol = 1; |
---|
| 825 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 826 | { |
---|
| 827 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
| 828 | } |
---|
| 829 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
| 830 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
[2] | 831 | } |
---|
[189] | 832 | #endif |
---|
[56] | 833 | UInt uiTrLevel = 0; |
---|
| 834 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
| 835 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
| 836 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
| 837 | if( eMode == SIZE_NxN ) |
---|
| 838 | { |
---|
| 839 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 840 | } |
---|
| 841 | else |
---|
| 842 | { |
---|
| 843 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 844 | } |
---|
[2] | 845 | } |
---|
| 846 | else |
---|
| 847 | { |
---|
[189] | 848 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 849 | if(bParsePartSize) |
---|
[2] | 850 | { |
---|
[189] | 851 | #endif |
---|
| 852 | UInt uiMaxNumBits = 2; |
---|
| 853 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
[2] | 854 | { |
---|
[189] | 855 | uiMaxNumBits ++; |
---|
[2] | 856 | } |
---|
[189] | 857 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
[56] | 858 | { |
---|
[189] | 859 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
| 860 | if ( uiSymbol ) |
---|
| 861 | { |
---|
| 862 | break; |
---|
| 863 | } |
---|
| 864 | uiMode++; |
---|
| 865 | } |
---|
| 866 | eMode = (PartSize) uiMode; |
---|
| 867 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
| 868 | { |
---|
| 869 | if (eMode == SIZE_2NxN) |
---|
| 870 | { |
---|
[56] | 871 | #if AMP_CTX |
---|
[189] | 872 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
[56] | 873 | #else |
---|
[189] | 874 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUYPosiSCModel.get( 0, 0, 0 )); |
---|
[2] | 875 | #endif |
---|
[189] | 876 | if (uiSymbol == 0) |
---|
| 877 | { |
---|
[56] | 878 | #if AMP_CTX |
---|
[189] | 879 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
[56] | 880 | #else |
---|
[189] | 881 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUYPosiSCModel.get( 0, 0, 1 )); |
---|
[56] | 882 | #endif |
---|
[189] | 883 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
| 884 | } |
---|
[56] | 885 | } |
---|
[189] | 886 | else if (eMode == SIZE_Nx2N) |
---|
| 887 | { |
---|
[56] | 888 | #if AMP_CTX |
---|
[189] | 889 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
[56] | 890 | #else |
---|
[189] | 891 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUXPosiSCModel.get( 0, 0, 0 )); |
---|
[2] | 892 | #endif |
---|
[189] | 893 | if (uiSymbol == 0) |
---|
| 894 | { |
---|
[56] | 895 | #if AMP_CTX |
---|
[189] | 896 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
[56] | 897 | #else |
---|
[189] | 898 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUXPosiSCModel.get( 0, 0, 1 )); |
---|
[56] | 899 | #endif |
---|
[189] | 900 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
| 901 | } |
---|
[2] | 902 | } |
---|
| 903 | } |
---|
[189] | 904 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
[2] | 905 | } |
---|
[189] | 906 | #endif |
---|
[2] | 907 | } |
---|
| 908 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
| 909 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | /** parse prediction mode |
---|
| 913 | * \param pcCU |
---|
| 914 | * \param uiAbsPartIdx |
---|
| 915 | * \param uiDepth |
---|
| 916 | * \returns Void |
---|
| 917 | */ |
---|
| 918 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 919 | { |
---|
| 920 | if( pcCU->getSlice()->isIntra() ) |
---|
| 921 | { |
---|
| 922 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
| 923 | return; |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | UInt uiSymbol; |
---|
| 927 | Int iPredMode = MODE_INTER; |
---|
[56] | 928 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 929 | iPredMode += uiSymbol; |
---|
| 930 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
| 931 | } |
---|
[56] | 932 | |
---|
| 933 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 934 | { |
---|
[56] | 935 | UInt uiSymbol; |
---|
| 936 | Int intraPredMode; |
---|
[2] | 937 | |
---|
[5] | 938 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 939 | UInt uiFlag = 0; |
---|
[56] | 940 | if( pcCU->getSlice()->getSPS()->getUseDMM() && (g_uiMaxCUWidth>>uiDepth) <= DMM_WEDGEMODEL_MAX_SIZE ) |
---|
[2] | 941 | { |
---|
[56] | 942 | m_pcTDecBinIf->decodeBin( uiFlag, m_cDmmFlagSCModel.get(0, 0, 0) ); |
---|
[2] | 943 | } |
---|
[56] | 944 | if( uiFlag ) |
---|
[2] | 945 | { |
---|
| 946 | UInt uiDMMode; |
---|
[100] | 947 | |
---|
[5] | 948 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
[56] | 949 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
| 950 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
[2] | 951 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
| 952 | { |
---|
[56] | 953 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 2; |
---|
[2] | 954 | } |
---|
| 955 | #else |
---|
[56] | 956 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode = uiSymbol; |
---|
| 957 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
| 958 | { |
---|
| 959 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1; |
---|
[2] | 960 | } |
---|
| 961 | #endif |
---|
[56] | 962 | intraPredMode = uiDMMode + NUM_INTRA_MODE; |
---|
[2] | 963 | |
---|
[5] | 964 | #if HHI_DMM_WEDGE_INTRA |
---|
[56] | 965 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 966 | if( intraPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 967 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 968 | if( intraPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
[5] | 969 | #endif |
---|
| 970 | #if HHI_DMM_PRED_TEX |
---|
[56] | 971 | if( intraPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 972 | if( intraPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
[5] | 973 | #endif |
---|
[2] | 974 | } |
---|
| 975 | else |
---|
| 976 | { |
---|
| 977 | #endif |
---|
[56] | 978 | #if !LOGI_INTRA_NAME_3MPM |
---|
[100] | 979 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
[56] | 980 | #endif |
---|
[100] | 981 | |
---|
[189] | 982 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 983 | Bool bCodeEdgeIntra = false; |
---|
| 984 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 985 | { |
---|
| 986 | UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); |
---|
| 987 | if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) |
---|
| 988 | bCodeEdgeIntra = true; |
---|
| 989 | } |
---|
| 990 | #endif |
---|
| 991 | |
---|
[56] | 992 | #if LOGI_INTRA_NAME_3MPM |
---|
[100] | 993 | Int uiPreds[3] = {-1, -1, -1}; |
---|
[2] | 994 | #else |
---|
[100] | 995 | Int uiPreds[2] = {-1, -1}; |
---|
[56] | 996 | #endif |
---|
[100] | 997 | Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); |
---|
[189] | 998 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 999 | UInt uiCheckBit = 0; |
---|
| 1000 | #endif |
---|
| 1001 | |
---|
| 1002 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
| 1003 | |
---|
| 1004 | if ( uiSymbol ) |
---|
[56] | 1005 | { |
---|
| 1006 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
[100] | 1007 | #if LOGI_INTRA_NAME_3MPM |
---|
| 1008 | if (uiSymbol) |
---|
| 1009 | { |
---|
| 1010 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 1011 | uiSymbol++; |
---|
| 1012 | } |
---|
[5] | 1013 | #endif |
---|
[100] | 1014 | intraPredMode = uiPreds[uiSymbol]; |
---|
[56] | 1015 | } |
---|
[100] | 1016 | else |
---|
[2] | 1017 | { |
---|
[100] | 1018 | intraPredMode = 0; |
---|
| 1019 | |
---|
| 1020 | #if LOGI_INTRA_NAME_3MPM |
---|
| 1021 | |
---|
| 1022 | m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 ); |
---|
[189] | 1023 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 1024 | if (bCodeEdgeIntra) |
---|
| 1025 | { |
---|
| 1026 | if (uiSymbol==31) |
---|
| 1027 | { |
---|
| 1028 | m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1); |
---|
| 1029 | if (uiCheckBit) |
---|
| 1030 | uiSymbol = EDGE_INTRA_IDX; |
---|
| 1031 | } |
---|
| 1032 | } |
---|
| 1033 | #endif |
---|
| 1034 | intraPredMode = uiSymbol; |
---|
| 1035 | |
---|
| 1036 | //postponed sorting of MPMs (only in remaining branch) |
---|
| 1037 | if (uiPreds[0] > uiPreds[1]) |
---|
| 1038 | { |
---|
| 1039 | std::swap(uiPreds[0], uiPreds[1]); |
---|
| 1040 | } |
---|
| 1041 | if (uiPreds[0] > uiPreds[2]) |
---|
| 1042 | { |
---|
| 1043 | std::swap(uiPreds[0], uiPreds[2]); |
---|
| 1044 | } |
---|
| 1045 | if (uiPreds[1] > uiPreds[2]) |
---|
| 1046 | { |
---|
| 1047 | std::swap(uiPreds[1], uiPreds[2]); |
---|
| 1048 | } |
---|
| 1049 | #else |
---|
| 1050 | m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 ); |
---|
| 1051 | intraPredMode = uiSymbol; |
---|
| 1052 | |
---|
| 1053 | if ( intraPredMode == 31 ) |
---|
| 1054 | { |
---|
| 1055 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 1056 | intraPredMode += uiSymbol; |
---|
| 1057 | } |
---|
| 1058 | #endif |
---|
[189] | 1059 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 1060 | if ( intraPredMode != EDGE_INTRA_IDX) |
---|
| 1061 | { |
---|
| 1062 | #endif |
---|
| 1063 | for ( Int i = 0; i < uiPredNum; i++ ) |
---|
| 1064 | { |
---|
| 1065 | intraPredMode += ( intraPredMode >= uiPreds[i] ); |
---|
| 1066 | } |
---|
[189] | 1067 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 1068 | } |
---|
| 1069 | #endif |
---|
[2] | 1070 | } |
---|
[100] | 1071 | |
---|
[189] | 1072 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 1073 | if( intraPredMode == EDGE_INTRA_IDX ) |
---|
[2] | 1074 | { |
---|
[100] | 1075 | xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 1076 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 1077 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); |
---|
| 1078 | if( uiSymbol ) |
---|
| 1079 | { |
---|
| 1080 | intraPredMode = EDGE_INTRA_DELTA_IDX; |
---|
| 1081 | Int iDeltaDC0; |
---|
| 1082 | Int iDeltaDC1; |
---|
| 1083 | |
---|
| 1084 | xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
| 1085 | if( iDeltaDC0 != 0 ) |
---|
| 1086 | { |
---|
| 1087 | UInt uiSign; |
---|
| 1088 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 1089 | if ( uiSign ) |
---|
| 1090 | { |
---|
| 1091 | iDeltaDC0 = -iDeltaDC0; |
---|
| 1092 | } |
---|
| 1093 | } |
---|
| 1094 | xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); |
---|
| 1095 | if( iDeltaDC1 != 0 ) |
---|
| 1096 | { |
---|
| 1097 | UInt uiSign; |
---|
| 1098 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 1099 | if ( uiSign ) |
---|
| 1100 | { |
---|
| 1101 | iDeltaDC1 = -iDeltaDC1; |
---|
| 1102 | } |
---|
| 1103 | } |
---|
| 1104 | |
---|
| 1105 | pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); |
---|
| 1106 | pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); |
---|
| 1107 | } |
---|
| 1108 | #endif |
---|
[2] | 1109 | } |
---|
[56] | 1110 | #endif |
---|
[100] | 1111 | |
---|
[56] | 1112 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 1113 | } |
---|
[2] | 1114 | #endif |
---|
[100] | 1115 | |
---|
[56] | 1116 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth ); |
---|
| 1117 | } |
---|
[2] | 1118 | |
---|
| 1119 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1120 | { |
---|
| 1121 | UInt uiSymbol; |
---|
| 1122 | |
---|
[56] | 1123 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
| 1124 | |
---|
| 1125 | if( uiSymbol == 0 ) |
---|
[2] | 1126 | { |
---|
[56] | 1127 | uiSymbol = DM_CHROMA_IDX; |
---|
[2] | 1128 | } |
---|
| 1129 | else |
---|
| 1130 | { |
---|
[56] | 1131 | if( pcCU->getSlice()->getSPS()->getUseLMChroma() ) |
---|
[2] | 1132 | { |
---|
[56] | 1133 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) ); |
---|
[2] | 1134 | } |
---|
[56] | 1135 | else |
---|
| 1136 | { |
---|
| 1137 | uiSymbol = 1; |
---|
| 1138 | } |
---|
[2] | 1139 | |
---|
[56] | 1140 | if( uiSymbol == 0 ) |
---|
[2] | 1141 | { |
---|
[56] | 1142 | uiSymbol = LM_CHROMA_IDX; |
---|
| 1143 | } |
---|
| 1144 | else |
---|
| 1145 | { |
---|
| 1146 | UInt uiIPredMode; |
---|
| 1147 | #if CHROMA_MODE_CODING |
---|
| 1148 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
| 1149 | #else |
---|
| 1150 | xReadUnaryMaxSymbol( uiIPredMode, m_cCUChromaPredSCModel.get( 0, 0 ) + 1, 0, 3 ); |
---|
[2] | 1151 | #endif |
---|
[56] | 1152 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
| 1153 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
| 1154 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
[2] | 1155 | } |
---|
| 1156 | } |
---|
| 1157 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
| 1158 | return; |
---|
| 1159 | } |
---|
| 1160 | |
---|
| 1161 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1162 | { |
---|
| 1163 | UInt uiSymbol; |
---|
[56] | 1164 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
| 1165 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
| 1166 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
| 1167 | |
---|
| 1168 | if( uiSymbol ) |
---|
[2] | 1169 | { |
---|
| 1170 | uiSymbol = 2; |
---|
| 1171 | } |
---|
[56] | 1172 | |
---|
[2] | 1173 | uiSymbol++; |
---|
| 1174 | ruiInterDir = uiSymbol; |
---|
| 1175 | return; |
---|
| 1176 | } |
---|
| 1177 | |
---|
| 1178 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
| 1179 | { |
---|
| 1180 | UInt uiSymbol; |
---|
| 1181 | |
---|
| 1182 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C) |
---|
| 1183 | { |
---|
[56] | 1184 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
| 1185 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
[2] | 1186 | |
---|
[56] | 1187 | if( uiSymbol ) |
---|
[2] | 1188 | { |
---|
[56] | 1189 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); |
---|
[2] | 1190 | uiSymbol++; |
---|
| 1191 | } |
---|
| 1192 | riRefFrmIdx = uiSymbol; |
---|
| 1193 | } |
---|
| 1194 | else |
---|
| 1195 | { |
---|
[56] | 1196 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
| 1197 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
[2] | 1198 | |
---|
[56] | 1199 | if( uiSymbol ) |
---|
| 1200 | { |
---|
| 1201 | xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); |
---|
| 1202 | uiSymbol++; |
---|
| 1203 | } |
---|
| 1204 | riRefFrmIdx = uiSymbol; |
---|
[2] | 1205 | } |
---|
| 1206 | |
---|
| 1207 | return; |
---|
| 1208 | } |
---|
| 1209 | |
---|
[56] | 1210 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
[2] | 1211 | { |
---|
| 1212 | UInt uiSymbol; |
---|
[56] | 1213 | UInt uiHorAbs; |
---|
| 1214 | UInt uiVerAbs; |
---|
| 1215 | UInt uiHorSign = 0; |
---|
| 1216 | UInt uiVerSign = 0; |
---|
| 1217 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
[2] | 1218 | |
---|
[56] | 1219 | #if H0111_MVD_L1_ZERO |
---|
| 1220 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
| 1221 | { |
---|
| 1222 | uiHorAbs=0; |
---|
| 1223 | uiVerAbs=0; |
---|
| 1224 | } |
---|
| 1225 | else |
---|
| 1226 | { |
---|
[2] | 1227 | #endif |
---|
| 1228 | |
---|
[56] | 1229 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
| 1230 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
[2] | 1231 | |
---|
[56] | 1232 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
| 1233 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
| 1234 | pCtx++; |
---|
| 1235 | |
---|
| 1236 | if( bHorAbsGr0 ) |
---|
| 1237 | { |
---|
| 1238 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1239 | uiHorAbs += uiSymbol; |
---|
| 1240 | } |
---|
| 1241 | |
---|
| 1242 | if( bVerAbsGr0 ) |
---|
| 1243 | { |
---|
| 1244 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1245 | uiVerAbs += uiSymbol; |
---|
| 1246 | } |
---|
| 1247 | |
---|
| 1248 | if( bHorAbsGr0 ) |
---|
| 1249 | { |
---|
| 1250 | if( 2 == uiHorAbs ) |
---|
| 1251 | { |
---|
| 1252 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 1253 | uiHorAbs += uiSymbol; |
---|
| 1254 | } |
---|
| 1255 | |
---|
| 1256 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
| 1257 | } |
---|
| 1258 | |
---|
| 1259 | if( bVerAbsGr0 ) |
---|
| 1260 | { |
---|
| 1261 | if( 2 == uiVerAbs ) |
---|
| 1262 | { |
---|
| 1263 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 1264 | uiVerAbs += uiSymbol; |
---|
| 1265 | } |
---|
| 1266 | |
---|
| 1267 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | #if H0111_MVD_L1_ZERO |
---|
| 1271 | } |
---|
[2] | 1272 | #endif |
---|
| 1273 | |
---|
[56] | 1274 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
| 1275 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 1276 | return; |
---|
| 1277 | } |
---|
| 1278 | |
---|
| 1279 | |
---|
| 1280 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
| 1281 | { |
---|
| 1282 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
[56] | 1283 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1284 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
| 1285 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1286 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
| 1287 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1288 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
| 1289 | DTRACE_CABAC_T( "\n" ) |
---|
| 1290 | } |
---|
| 1291 | |
---|
| 1292 | Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
| 1293 | { |
---|
| 1294 | UInt uiSymbol; |
---|
[56] | 1295 | const UInt uiCtx = 0; |
---|
[2] | 1296 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
[56] | 1297 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1298 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
| 1299 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1300 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 1301 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1302 | DTRACE_CABAC_V( uiCtx ) |
---|
| 1303 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1304 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1305 | DTRACE_CABAC_T( "\n" ) |
---|
| 1306 | |
---|
| 1307 | uiQtRootCbf = uiSymbol; |
---|
| 1308 | } |
---|
| 1309 | |
---|
| 1310 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1311 | { |
---|
[56] | 1312 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1313 | Int qp; |
---|
| 1314 | #endif |
---|
[2] | 1315 | UInt uiDQp; |
---|
| 1316 | Int iDQp; |
---|
| 1317 | |
---|
| 1318 | m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) ); |
---|
| 1319 | |
---|
| 1320 | if ( uiDQp == 0 ) |
---|
| 1321 | { |
---|
[56] | 1322 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1323 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
| 1324 | #else |
---|
| 1325 | uiDQp = pcCU->getRefQP(uiAbsPartIdx); |
---|
| 1326 | #endif |
---|
[2] | 1327 | } |
---|
| 1328 | else |
---|
| 1329 | { |
---|
[56] | 1330 | UInt uiSign; |
---|
| 1331 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1332 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1333 | #else |
---|
| 1334 | UInt uiQpBdOffsetY = 6*(g_uiBitIncrement + g_uiBitDepth - 8); |
---|
| 1335 | #endif |
---|
| 1336 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
| 1337 | |
---|
| 1338 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1339 | UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign); |
---|
| 1340 | #else |
---|
| 1341 | UInt uiMaxAbsDQpMinus1 = 24 + (uiQpBdOffsetY/2) + (uiSign); |
---|
| 1342 | #endif |
---|
| 1343 | UInt uiAbsDQpMinus1; |
---|
| 1344 | xReadUnaryMaxSymbol (uiAbsDQpMinus1, &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1); |
---|
| 1345 | |
---|
| 1346 | iDQp = uiAbsDQpMinus1 + 1; |
---|
| 1347 | |
---|
| 1348 | if(uiSign) |
---|
[2] | 1349 | { |
---|
| 1350 | iDQp = -iDQp; |
---|
| 1351 | } |
---|
[56] | 1352 | |
---|
| 1353 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1354 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
| 1355 | #else |
---|
| 1356 | #if LOSSLESS_CODING |
---|
| 1357 | uiDQp = (pcCU->getRefQP(uiAbsPartIdx) + iDQp + 52) % 52; |
---|
| 1358 | #else |
---|
| 1359 | uiDQp = pcCU->getRefQP(uiAbsPartIdx) + iDQp; |
---|
| 1360 | #endif |
---|
| 1361 | #endif |
---|
[2] | 1362 | } |
---|
| 1363 | |
---|
[56] | 1364 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ; |
---|
| 1365 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 1366 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1367 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 1368 | #else |
---|
| 1369 | pcCU->setQPSubParts( uiDQp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 1370 | #endif |
---|
[2] | 1371 | } |
---|
| 1372 | |
---|
| 1373 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
| 1374 | { |
---|
| 1375 | UInt uiSymbol; |
---|
| 1376 | const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth ); |
---|
[56] | 1377 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
[2] | 1378 | |
---|
[56] | 1379 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1380 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
| 1381 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1382 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 1383 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1384 | DTRACE_CABAC_V( uiCtx ) |
---|
| 1385 | DTRACE_CABAC_T( "\tetype=" ) |
---|
| 1386 | DTRACE_CABAC_V( eType ) |
---|
| 1387 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1388 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1389 | DTRACE_CABAC_T( "\n" ) |
---|
| 1390 | |
---|
| 1391 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
| 1392 | } |
---|
| 1393 | |
---|
| 1394 | /** Parse (X,Y) position of the last significant coefficient |
---|
| 1395 | * \param uiPosLastX reference to X component of last coefficient |
---|
| 1396 | * \param uiPosLastY reference to Y component of last coefficient |
---|
[56] | 1397 | * \param width Block width |
---|
| 1398 | * \param height Block height |
---|
[2] | 1399 | * \param eTType plane type / luminance or chrominance |
---|
| 1400 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
[56] | 1401 | * |
---|
[2] | 1402 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
| 1403 | */ |
---|
[56] | 1404 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
[2] | 1405 | { |
---|
| 1406 | UInt uiLast; |
---|
[56] | 1407 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
| 1408 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
[2] | 1409 | |
---|
[56] | 1410 | // posX |
---|
| 1411 | #if LAST_CTX_REDUCTION |
---|
| 1412 | Int widthCtx = eTType ? 4 : width; |
---|
| 1413 | const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) ); |
---|
| 1414 | #else |
---|
| 1415 | const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ width ] * ( g_aucConvertToBit[ width ] + 3 ) ); |
---|
| 1416 | #endif |
---|
| 1417 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
[2] | 1418 | { |
---|
[56] | 1419 | #if LAST_CTX_REDUCTION |
---|
| 1420 | if ( eTType ) |
---|
[2] | 1421 | { |
---|
[56] | 1422 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + (uiPosLastX>>g_aucConvertToBit[ width ]) ) ); |
---|
| 1423 | } |
---|
| 1424 | else |
---|
| 1425 | { |
---|
| 1426 | #endif |
---|
| 1427 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + puiCtxIdxX[ uiPosLastX ] ) ); |
---|
| 1428 | #if LAST_CTX_REDUCTION |
---|
| 1429 | } |
---|
| 1430 | #endif |
---|
| 1431 | if( !uiLast ) |
---|
| 1432 | { |
---|
[2] | 1433 | break; |
---|
| 1434 | } |
---|
| 1435 | } |
---|
| 1436 | |
---|
[56] | 1437 | // posY |
---|
| 1438 | #if LAST_CTX_REDUCTION |
---|
| 1439 | Int heightCtx = eTType? 4 : height; |
---|
| 1440 | const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) ); |
---|
| 1441 | #else |
---|
| 1442 | const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ height ] * ( g_aucConvertToBit[ height ] + 3 ) ); |
---|
| 1443 | #endif |
---|
| 1444 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
[2] | 1445 | { |
---|
[56] | 1446 | #if LAST_CTX_REDUCTION |
---|
| 1447 | if (eTType) |
---|
[2] | 1448 | { |
---|
[56] | 1449 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + (uiPosLastY>>g_aucConvertToBit[ height ]) ) ); |
---|
| 1450 | } |
---|
| 1451 | else |
---|
| 1452 | { |
---|
| 1453 | #endif |
---|
| 1454 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + puiCtxIdxY[ uiPosLastY ] ) ); |
---|
| 1455 | #if LAST_CTX_REDUCTION |
---|
| 1456 | } |
---|
| 1457 | #endif |
---|
| 1458 | if( !uiLast ) |
---|
| 1459 | { |
---|
[2] | 1460 | break; |
---|
| 1461 | } |
---|
| 1462 | } |
---|
[56] | 1463 | if ( uiPosLastX > 3 ) |
---|
| 1464 | { |
---|
| 1465 | UInt uiTemp = 0; |
---|
| 1466 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
| 1467 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1468 | { |
---|
| 1469 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1470 | uiTemp += uiLast << i; |
---|
| 1471 | } |
---|
| 1472 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
| 1473 | } |
---|
| 1474 | if ( uiPosLastY > 3 ) |
---|
| 1475 | { |
---|
| 1476 | UInt uiTemp = 0; |
---|
| 1477 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
| 1478 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1479 | { |
---|
| 1480 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1481 | uiTemp += uiLast << i; |
---|
| 1482 | } |
---|
| 1483 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
| 1484 | } |
---|
| 1485 | |
---|
[2] | 1486 | if( uiScanIdx == SCAN_VER ) |
---|
| 1487 | { |
---|
| 1488 | swap( uiPosLastX, uiPosLastY ); |
---|
| 1489 | } |
---|
| 1490 | } |
---|
| 1491 | |
---|
| 1492 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1493 | { |
---|
[56] | 1494 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1495 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
| 1496 | DTRACE_CABAC_V( eTType ) |
---|
| 1497 | DTRACE_CABAC_T( "\twidth=" ) |
---|
| 1498 | DTRACE_CABAC_V( uiWidth ) |
---|
| 1499 | DTRACE_CABAC_T( "\theight=" ) |
---|
| 1500 | DTRACE_CABAC_V( uiHeight ) |
---|
| 1501 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
| 1502 | DTRACE_CABAC_V( uiDepth ) |
---|
| 1503 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
| 1504 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1505 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
| 1506 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
| 1507 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
| 1508 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
| 1509 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
| 1510 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
| 1511 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
| 1512 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1513 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
| 1514 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1515 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
| 1516 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
| 1517 | DTRACE_CABAC_T( "\n" ) |
---|
| 1518 | |
---|
| 1519 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
| 1520 | { |
---|
| 1521 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1522 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1523 | } |
---|
| 1524 | |
---|
| 1525 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
| 1526 | |
---|
| 1527 | //----- parse significance map ----- |
---|
| 1528 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
[56] | 1529 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
[2] | 1530 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
[56] | 1531 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
| 1532 | int blockType = uiLog2BlockSize; |
---|
| 1533 | if (uiWidth != uiHeight) |
---|
| 1534 | { |
---|
| 1535 | uiScanIdx = SCAN_DIAG; |
---|
| 1536 | blockType = 4; |
---|
| 1537 | } |
---|
[2] | 1538 | |
---|
[56] | 1539 | //===== decode last significant ===== |
---|
| 1540 | UInt uiPosLastX, uiPosLastY; |
---|
| 1541 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
| 1542 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
| 1543 | pcCoef[ uiBlkPosLast ] = 1; |
---|
[2] | 1544 | |
---|
[56] | 1545 | //===== decode significance flags ===== |
---|
| 1546 | UInt uiScanPosLast = uiBlkPosLast; |
---|
| 1547 | if (uiScanIdx == SCAN_ZIGZAG) |
---|
| 1548 | { |
---|
| 1549 | // Map zigzag to diagonal scan |
---|
| 1550 | uiScanIdx = SCAN_DIAG; |
---|
| 1551 | } |
---|
| 1552 | const UInt * scan; |
---|
| 1553 | if (uiWidth == uiHeight) |
---|
| 1554 | { |
---|
| 1555 | scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
| 1556 | } |
---|
| 1557 | else |
---|
| 1558 | { |
---|
| 1559 | scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
| 1560 | } |
---|
| 1561 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
| 1562 | { |
---|
| 1563 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
| 1564 | if( uiBlkPosLast == uiBlkPos ) |
---|
[2] | 1565 | { |
---|
[56] | 1566 | break; |
---|
[2] | 1567 | } |
---|
[56] | 1568 | } |
---|
[2] | 1569 | |
---|
[56] | 1570 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
| 1571 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
| 1572 | |
---|
| 1573 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
| 1574 | UInt uiNumOne = 0; |
---|
| 1575 | UInt uiGoRiceParam = 0; |
---|
| 1576 | |
---|
| 1577 | #if MULTIBITS_DATA_HIDING |
---|
| 1578 | UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG(); |
---|
| 1579 | #if LOSSLESS_CODING |
---|
| 1580 | Bool beValid; |
---|
| 1581 | if (pcCU->isLosslessCoded(uiAbsPartIdx)) |
---|
[2] | 1582 | { |
---|
[56] | 1583 | beValid = false; |
---|
| 1584 | } |
---|
| 1585 | else |
---|
| 1586 | { |
---|
| 1587 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
| 1588 | } |
---|
[2] | 1589 | #else |
---|
[56] | 1590 | Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
[2] | 1591 | #endif |
---|
[56] | 1592 | UInt absSum = 0; |
---|
| 1593 | #endif // MULTIBITS_DATA_HIDING |
---|
| 1594 | |
---|
| 1595 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
| 1596 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
| 1597 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
| 1598 | const UInt * scanCG; |
---|
| 1599 | if (uiWidth == uiHeight) |
---|
| 1600 | { |
---|
| 1601 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
| 1602 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1603 | if( uiLog2BlockSize == 3 ) |
---|
[2] | 1604 | { |
---|
[56] | 1605 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
[2] | 1606 | } |
---|
[56] | 1607 | else if( uiLog2BlockSize == 5 ) |
---|
| 1608 | { |
---|
| 1609 | scanCG = g_sigLastScanCG32x32; |
---|
| 1610 | } |
---|
| 1611 | #endif |
---|
[2] | 1612 | } |
---|
[56] | 1613 | else |
---|
[2] | 1614 | { |
---|
[56] | 1615 | scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ]; |
---|
[2] | 1616 | } |
---|
[56] | 1617 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
| 1618 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
| 1619 | { |
---|
| 1620 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
| 1621 | uiGoRiceParam = 0; |
---|
| 1622 | Int numNonZero = 0; |
---|
| 1623 | |
---|
| 1624 | #if MULTIBITS_DATA_HIDING |
---|
| 1625 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
[2] | 1626 | #endif |
---|
[56] | 1627 | |
---|
| 1628 | Int pos[SCAN_SET_SIZE]; |
---|
| 1629 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
| 1630 | { |
---|
| 1631 | #if MULTIBITS_DATA_HIDING |
---|
| 1632 | lastNZPosInCG = iScanPosSig; |
---|
| 1633 | firstNZPosInCG = iScanPosSig; |
---|
[2] | 1634 | #endif |
---|
[56] | 1635 | iScanPosSig--; |
---|
| 1636 | pos[ numNonZero ] = uiBlkPosLast; |
---|
| 1637 | numNonZero = 1; |
---|
| 1638 | } |
---|
[2] | 1639 | |
---|
[56] | 1640 | #if !MULTILEVEL_SIGMAP_EXT |
---|
| 1641 | if( blockType > 3 ) |
---|
[2] | 1642 | { |
---|
| 1643 | #endif |
---|
[56] | 1644 | // decode significant_coeffgroup_flag |
---|
| 1645 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
| 1646 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
| 1647 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
| 1648 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1649 | if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) ) |
---|
[2] | 1650 | { |
---|
[56] | 1651 | iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0); |
---|
| 1652 | iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0); |
---|
[2] | 1653 | } |
---|
[56] | 1654 | #endif |
---|
| 1655 | #if !REMOVE_INFER_SIGGRP |
---|
| 1656 | Bool bInferredCGFlag = false; |
---|
| 1657 | #endif |
---|
| 1658 | #if REMOVE_INFER_SIGGRP |
---|
| 1659 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
| 1660 | #else |
---|
| 1661 | if( iSubSet == iLastScanSet ) |
---|
| 1662 | #endif |
---|
[2] | 1663 | { |
---|
[56] | 1664 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
| 1665 | } |
---|
| 1666 | else |
---|
| 1667 | { |
---|
| 1668 | #if !REMOVE_INFER_SIGGRP |
---|
| 1669 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1670 | if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight) && ( iSubSet ) ) |
---|
| 1671 | #else |
---|
| 1672 | if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight) && ( iSubSet ) ) |
---|
| 1673 | #endif |
---|
[2] | 1674 | { |
---|
[56] | 1675 | #endif |
---|
| 1676 | UInt uiSigCoeffGroup; |
---|
| 1677 | #if MULTILEVEL_SIGMAP_EXT |
---|
| 1678 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight ); |
---|
| 1679 | #else |
---|
| 1680 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
| 1681 | #endif |
---|
| 1682 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
| 1683 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
| 1684 | #if !REMOVE_INFER_SIGGRP |
---|
[2] | 1685 | } |
---|
| 1686 | else |
---|
| 1687 | { |
---|
[56] | 1688 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
| 1689 | bInferredCGFlag = true; |
---|
[2] | 1690 | } |
---|
[56] | 1691 | #endif |
---|
| 1692 | } |
---|
| 1693 | |
---|
| 1694 | // decode significant_coeff_flag |
---|
| 1695 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
| 1696 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
| 1697 | { |
---|
| 1698 | uiBlkPos = scan[ iScanPosSig ]; |
---|
| 1699 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
| 1700 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
| 1701 | uiSig = 0; |
---|
[2] | 1702 | |
---|
[56] | 1703 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
[2] | 1704 | { |
---|
[56] | 1705 | #if REMOVE_INFER_SIGGRP |
---|
| 1706 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
| 1707 | #else |
---|
| 1708 | if( iScanPosSig > iSubPos || bInferredCGFlag || numNonZero ) |
---|
| 1709 | #endif |
---|
[2] | 1710 | { |
---|
[56] | 1711 | uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); |
---|
| 1712 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
[2] | 1713 | } |
---|
[56] | 1714 | else |
---|
| 1715 | { |
---|
| 1716 | uiSig = 1; |
---|
| 1717 | } |
---|
[2] | 1718 | } |
---|
[56] | 1719 | pcCoef[ uiBlkPos ] = uiSig; |
---|
| 1720 | if( uiSig ) |
---|
[2] | 1721 | { |
---|
[56] | 1722 | pos[ numNonZero ] = uiBlkPos; |
---|
| 1723 | numNonZero ++; |
---|
| 1724 | #if MULTIBITS_DATA_HIDING |
---|
| 1725 | if( lastNZPosInCG == -1 ) |
---|
[2] | 1726 | { |
---|
[56] | 1727 | lastNZPosInCG = iScanPosSig; |
---|
| 1728 | } |
---|
| 1729 | firstNZPosInCG = iScanPosSig; |
---|
[2] | 1730 | #endif |
---|
| 1731 | } |
---|
[56] | 1732 | } |
---|
| 1733 | #if !MULTILEVEL_SIGMAP_EXT |
---|
| 1734 | } |
---|
| 1735 | else |
---|
| 1736 | { |
---|
| 1737 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
| 1738 | { |
---|
| 1739 | UInt uiBlkPos = scan[ iScanPosSig ]; |
---|
| 1740 | UInt uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
| 1741 | UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
| 1742 | UInt uiSig = 0; |
---|
| 1743 | UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType ); |
---|
| 1744 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
| 1745 | pcCoef[ uiBlkPos ] = uiSig; |
---|
| 1746 | if( uiSig ) |
---|
[2] | 1747 | { |
---|
[56] | 1748 | pos[ numNonZero ] = uiBlkPos; |
---|
| 1749 | numNonZero ++; |
---|
| 1750 | #if MULTIBITS_DATA_HIDING |
---|
| 1751 | if( lastNZPosInCG == -1 ) |
---|
[2] | 1752 | { |
---|
[56] | 1753 | lastNZPosInCG = iScanPosSig; |
---|
[2] | 1754 | } |
---|
[56] | 1755 | firstNZPosInCG = iScanPosSig; |
---|
| 1756 | #endif |
---|
[2] | 1757 | } |
---|
| 1758 | } |
---|
| 1759 | } |
---|
[56] | 1760 | #endif |
---|
| 1761 | |
---|
[2] | 1762 | |
---|
[56] | 1763 | if( numNonZero ) |
---|
[2] | 1764 | { |
---|
[56] | 1765 | #if MULTIBITS_DATA_HIDING |
---|
| 1766 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig ); |
---|
| 1767 | absSum = 0; |
---|
| 1768 | #endif // MULTIBITS_DATA_HIDING |
---|
| 1769 | |
---|
| 1770 | UInt c1 = 1; |
---|
| 1771 | #if !RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1772 | UInt c2 = 0; |
---|
| 1773 | #endif |
---|
| 1774 | #if LEVEL_CTX_LUMA_RED |
---|
| 1775 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
| 1776 | #else |
---|
| 1777 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 3 : 0; |
---|
| 1778 | #endif |
---|
| 1779 | UInt uiBin; |
---|
[2] | 1780 | |
---|
[56] | 1781 | if( uiNumOne > 0 ) |
---|
[2] | 1782 | { |
---|
[56] | 1783 | uiCtxSet++; |
---|
| 1784 | #if !LEVEL_CTX_LUMA_RED |
---|
| 1785 | if(eTType==TEXT_LUMA && uiNumOne > 3) |
---|
[2] | 1786 | { |
---|
[56] | 1787 | uiCtxSet++; |
---|
[2] | 1788 | } |
---|
[56] | 1789 | #endif |
---|
| 1790 | } |
---|
| 1791 | |
---|
| 1792 | uiNumOne >>= 1; |
---|
| 1793 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
| 1794 | Int absCoeff[SCAN_SET_SIZE]; |
---|
| 1795 | |
---|
| 1796 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1797 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
| 1798 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
| 1799 | Int firstC2FlagIdx = -1; |
---|
| 1800 | |
---|
| 1801 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
| 1802 | #else |
---|
| 1803 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
| 1804 | #endif |
---|
| 1805 | { |
---|
| 1806 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
| 1807 | if( uiBin == 1 ) |
---|
[2] | 1808 | { |
---|
[56] | 1809 | c1 = 0; |
---|
| 1810 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1811 | if (firstC2FlagIdx == -1) |
---|
| 1812 | { |
---|
| 1813 | firstC2FlagIdx = idx; |
---|
| 1814 | } |
---|
| 1815 | #endif |
---|
| 1816 | } |
---|
| 1817 | else if( (c1 < 3) && (c1 > 0) ) |
---|
| 1818 | { |
---|
[2] | 1819 | c1++; |
---|
| 1820 | } |
---|
[56] | 1821 | absCoeff[ idx ] = uiBin + 1; |
---|
| 1822 | } |
---|
| 1823 | |
---|
| 1824 | if (c1 == 0) |
---|
| 1825 | { |
---|
| 1826 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1827 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
| 1828 | if ( firstC2FlagIdx != -1) |
---|
[2] | 1829 | { |
---|
[56] | 1830 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
| 1831 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
[2] | 1832 | } |
---|
[56] | 1833 | #else |
---|
| 1834 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + 3 * uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + 3 * uiCtxSet; |
---|
| 1835 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
| 1836 | { |
---|
| 1837 | if( absCoeff[ idx ] == 2 ) |
---|
| 1838 | { |
---|
| 1839 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c2] ); |
---|
| 1840 | absCoeff[ idx ] = uiBin + 2; |
---|
| 1841 | c2 += (c2 < 2); |
---|
| 1842 | uiNumOne++; |
---|
| 1843 | } |
---|
| 1844 | } |
---|
| 1845 | #endif |
---|
[2] | 1846 | } |
---|
[56] | 1847 | |
---|
| 1848 | #if MULTIBITS_DATA_HIDING |
---|
| 1849 | UInt coeffSigns; |
---|
| 1850 | if ( signHidden && beValid ) |
---|
| 1851 | { |
---|
| 1852 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
| 1853 | coeffSigns <<= 32 - (numNonZero-1); |
---|
| 1854 | } |
---|
| 1855 | else |
---|
| 1856 | { |
---|
| 1857 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
| 1858 | coeffSigns <<= 32 - numNonZero; |
---|
| 1859 | } |
---|
| 1860 | #else |
---|
| 1861 | UInt coeffSigns; |
---|
| 1862 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
| 1863 | coeffSigns <<= 32 - numNonZero; |
---|
| 1864 | #endif |
---|
[2] | 1865 | |
---|
[56] | 1866 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1867 | Int iFirstCoeff2 = 1; |
---|
| 1868 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
| 1869 | #else |
---|
| 1870 | if (c1 == 0) |
---|
| 1871 | #endif |
---|
[2] | 1872 | { |
---|
[56] | 1873 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
[2] | 1874 | { |
---|
[56] | 1875 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
| 1876 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
[2] | 1877 | |
---|
[56] | 1878 | if( absCoeff[ idx ] == baseLevel) |
---|
[2] | 1879 | { |
---|
[56] | 1880 | UInt uiLevel; |
---|
[2] | 1881 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
[56] | 1882 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
[2] | 1883 | } |
---|
[56] | 1884 | |
---|
| 1885 | if(absCoeff[ idx ] >= 2) |
---|
[2] | 1886 | { |
---|
[56] | 1887 | iFirstCoeff2 = 0; |
---|
| 1888 | uiNumOne++; |
---|
[2] | 1889 | } |
---|
| 1890 | #else |
---|
[56] | 1891 | if( absCoeff[ idx ] == 3 ) |
---|
| 1892 | { |
---|
| 1893 | UInt uiLevel; |
---|
| 1894 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
| 1895 | absCoeff[ idx ] = uiLevel + 3; |
---|
| 1896 | } |
---|
[2] | 1897 | #endif |
---|
| 1898 | } |
---|
| 1899 | } |
---|
[56] | 1900 | |
---|
| 1901 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
[2] | 1902 | { |
---|
[56] | 1903 | Int blkPos = pos[ idx ]; |
---|
| 1904 | #if MULTIBITS_DATA_HIDING |
---|
| 1905 | // Signs applied later. |
---|
| 1906 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
| 1907 | absSum += absCoeff[ idx ]; |
---|
| 1908 | |
---|
| 1909 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
| 1910 | { |
---|
| 1911 | // Infer sign of 1st element. |
---|
| 1912 | if (absSum&0x1) |
---|
| 1913 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
| 1914 | } |
---|
| 1915 | else |
---|
| 1916 | { |
---|
| 1917 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
| 1918 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
| 1919 | coeffSigns <<= 1; |
---|
| 1920 | } |
---|
| 1921 | #else |
---|
| 1922 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
| 1923 | pcCoef[ blkPos ] = ( absCoeff[ idx ] ^ sign ) - sign; |
---|
| 1924 | coeffSigns <<= 1; |
---|
| 1925 | #endif |
---|
[2] | 1926 | } |
---|
| 1927 | } |
---|
[56] | 1928 | else |
---|
| 1929 | { |
---|
| 1930 | uiNumOne >>= 1; |
---|
| 1931 | } |
---|
[2] | 1932 | } |
---|
| 1933 | |
---|
| 1934 | return; |
---|
| 1935 | } |
---|
| 1936 | |
---|
| 1937 | |
---|
[56] | 1938 | #if SAO_UNIT_INTERLEAVING |
---|
| 1939 | Void TDecSbac::parseSaoUvlc (UInt& ruiVal) |
---|
[2] | 1940 | { |
---|
| 1941 | UInt uiCode; |
---|
| 1942 | Int i; |
---|
[56] | 1943 | |
---|
| 1944 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 1945 | if ( uiCode == 0 ) |
---|
| 1946 | { |
---|
| 1947 | ruiVal = 0; |
---|
| 1948 | return; |
---|
| 1949 | } |
---|
[56] | 1950 | |
---|
[2] | 1951 | i=1; |
---|
| 1952 | while (1) |
---|
| 1953 | { |
---|
[56] | 1954 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 1 ) ); |
---|
[2] | 1955 | if ( uiCode == 0 ) break; |
---|
| 1956 | i++; |
---|
| 1957 | } |
---|
[56] | 1958 | |
---|
[2] | 1959 | ruiVal = i; |
---|
| 1960 | } |
---|
| 1961 | |
---|
[56] | 1962 | Void TDecSbac::parseSaoSvlc (Int& riVal) |
---|
[2] | 1963 | { |
---|
| 1964 | UInt uiCode; |
---|
| 1965 | Int iSign; |
---|
| 1966 | Int i; |
---|
[56] | 1967 | |
---|
| 1968 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 0 ) ); |
---|
| 1969 | |
---|
[2] | 1970 | if ( uiCode == 0 ) |
---|
| 1971 | { |
---|
| 1972 | riVal = 0; |
---|
| 1973 | return; |
---|
| 1974 | } |
---|
[56] | 1975 | |
---|
[2] | 1976 | // read sign |
---|
[56] | 1977 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 1 ) ); |
---|
| 1978 | |
---|
| 1979 | if ( uiCode == 0 ) |
---|
| 1980 | { |
---|
| 1981 | iSign = 1; |
---|
| 1982 | } |
---|
| 1983 | else |
---|
| 1984 | { |
---|
| 1985 | iSign = -1; |
---|
| 1986 | } |
---|
| 1987 | |
---|
[2] | 1988 | // read magnitude |
---|
| 1989 | i=1; |
---|
| 1990 | while (1) |
---|
| 1991 | { |
---|
[56] | 1992 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 2 ) ); |
---|
[2] | 1993 | if ( uiCode == 0 ) break; |
---|
| 1994 | i++; |
---|
| 1995 | } |
---|
[56] | 1996 | |
---|
[2] | 1997 | riVal = i*iSign; |
---|
| 1998 | } |
---|
| 1999 | |
---|
[56] | 2000 | Void TDecSbac::parseSaoUflc (UInt& riVal) |
---|
[2] | 2001 | { |
---|
| 2002 | UInt uiSymbol; |
---|
[56] | 2003 | riVal = 0; |
---|
| 2004 | for (Int i=0;i<5;i++) |
---|
| 2005 | { |
---|
| 2006 | m_pcTDecBinIf->decodeBinEP ( uiSymbol ); |
---|
| 2007 | if (uiSymbol) |
---|
| 2008 | { |
---|
| 2009 | riVal |= (1<<i); |
---|
| 2010 | } |
---|
| 2011 | } |
---|
[2] | 2012 | } |
---|
[56] | 2013 | Void TDecSbac::parseSaoMergeLeft (UInt& ruiVal, UInt uiCompIdx) |
---|
| 2014 | { |
---|
| 2015 | UInt uiCode; |
---|
| 2016 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) ); |
---|
| 2017 | ruiVal = (Int)uiCode; |
---|
| 2018 | } |
---|
[2] | 2019 | |
---|
[56] | 2020 | Void TDecSbac::parseSaoMergeUp (UInt& ruiVal) |
---|
[2] | 2021 | { |
---|
| 2022 | UInt uiCode; |
---|
[56] | 2023 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) ); |
---|
| 2024 | ruiVal = (Int)uiCode; |
---|
| 2025 | } |
---|
| 2026 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
| 2027 | { |
---|
| 2028 | UInt uiCode; |
---|
[2] | 2029 | Int i; |
---|
[56] | 2030 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 2031 | if ( uiCode == 0 ) |
---|
| 2032 | { |
---|
| 2033 | ruiVal = 0; |
---|
| 2034 | return; |
---|
| 2035 | } |
---|
| 2036 | i=1; |
---|
| 2037 | while (1) |
---|
| 2038 | { |
---|
[56] | 2039 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) ); |
---|
[2] | 2040 | if ( uiCode == 0 ) break; |
---|
| 2041 | i++; |
---|
| 2042 | } |
---|
| 2043 | ruiVal = i; |
---|
| 2044 | } |
---|
| 2045 | |
---|
[56] | 2046 | inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) |
---|
[2] | 2047 | { |
---|
[56] | 2048 | Int i; |
---|
| 2049 | psDst->partIdx = psSrc->partIdx; |
---|
| 2050 | psDst->typeIdx = psSrc->typeIdx; |
---|
| 2051 | if (psDst->typeIdx != -1) |
---|
| 2052 | { |
---|
| 2053 | if (psDst->typeIdx == SAO_BO) |
---|
| 2054 | { |
---|
| 2055 | psDst->bandPosition = psSrc->bandPosition ; |
---|
| 2056 | } |
---|
| 2057 | else |
---|
| 2058 | { |
---|
| 2059 | psDst->bandPosition = 0; |
---|
| 2060 | } |
---|
| 2061 | psDst->length = psSrc->length; |
---|
| 2062 | for (i=0;i<psDst->length;i++) |
---|
| 2063 | { |
---|
| 2064 | psDst->offset[i] = psSrc->offset[i]; |
---|
| 2065 | } |
---|
| 2066 | } |
---|
| 2067 | else |
---|
| 2068 | { |
---|
| 2069 | psDst->length = 0; |
---|
| 2070 | for (i=0;i<SAO_BO_LEN;i++) |
---|
| 2071 | { |
---|
| 2072 | psDst->offset[i] = 0; |
---|
| 2073 | } |
---|
| 2074 | } |
---|
| 2075 | } |
---|
| 2076 | Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam) |
---|
| 2077 | { |
---|
| 2078 | UInt uiSymbol; |
---|
| 2079 | Int iSymbol; |
---|
| 2080 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = { |
---|
| 2081 | SAO_EO_LEN, |
---|
| 2082 | SAO_EO_LEN, |
---|
| 2083 | SAO_EO_LEN, |
---|
| 2084 | SAO_EO_LEN, |
---|
| 2085 | SAO_BO_LEN |
---|
| 2086 | }; |
---|
[2] | 2087 | |
---|
[56] | 2088 | parseSaoTypeIdx(uiSymbol); |
---|
| 2089 | psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
| 2090 | if (uiSymbol) |
---|
| 2091 | { |
---|
| 2092 | psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; |
---|
| 2093 | if( psSaoLcuParam->typeIdx == SAO_BO ) |
---|
| 2094 | { |
---|
| 2095 | // Parse Left Band Index |
---|
| 2096 | parseSaoUflc( uiSymbol ); |
---|
| 2097 | psSaoLcuParam->bandPosition = uiSymbol; |
---|
| 2098 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
| 2099 | { |
---|
| 2100 | parseSaoSvlc(iSymbol); |
---|
| 2101 | psSaoLcuParam->offset[i] = iSymbol; |
---|
| 2102 | } |
---|
| 2103 | } |
---|
| 2104 | else if( psSaoLcuParam->typeIdx < 4 ) |
---|
| 2105 | { |
---|
| 2106 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[0] = uiSymbol; |
---|
| 2107 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[1] = uiSymbol; |
---|
| 2108 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
| 2109 | parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
| 2110 | } |
---|
| 2111 | } |
---|
| 2112 | else |
---|
| 2113 | { |
---|
| 2114 | psSaoLcuParam->length = 0; |
---|
| 2115 | } |
---|
| 2116 | } |
---|
[2] | 2117 | |
---|
[56] | 2118 | Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag) |
---|
| 2119 | { |
---|
| 2120 | Int iAddr = pcCU->getAddr(); |
---|
| 2121 | UInt uiSymbol; |
---|
| 2122 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
[2] | 2123 | { |
---|
[56] | 2124 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
| 2125 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
| 2126 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
| 2127 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
| 2128 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; |
---|
| 2129 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; |
---|
| 2130 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; |
---|
| 2131 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; |
---|
| 2132 | |
---|
| 2133 | if (pSaoParam->bSaoFlag[iCompIdx]) |
---|
| 2134 | { |
---|
| 2135 | if (rx>0 && iCUAddrInSlice!=0) |
---|
| 2136 | { |
---|
| 2137 | parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol; |
---|
| 2138 | } |
---|
| 2139 | else |
---|
| 2140 | { |
---|
| 2141 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
| 2142 | } |
---|
| 2143 | |
---|
| 2144 | if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) |
---|
| 2145 | { |
---|
| 2146 | if ((ry > 0) && (iCUAddrUpInSlice>0||bLFCrossSliceBoundaryFlag)) |
---|
| 2147 | { |
---|
| 2148 | parseSaoMergeUp(uiSymbol); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol; |
---|
| 2149 | } |
---|
| 2150 | else |
---|
| 2151 | { |
---|
| 2152 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
| 2153 | } |
---|
| 2154 | if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) |
---|
| 2155 | { |
---|
| 2156 | parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr])); |
---|
| 2157 | } |
---|
| 2158 | else |
---|
| 2159 | { |
---|
| 2160 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); |
---|
| 2161 | } |
---|
| 2162 | } |
---|
| 2163 | else |
---|
| 2164 | { |
---|
| 2165 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); |
---|
| 2166 | } |
---|
| 2167 | } |
---|
| 2168 | else |
---|
| 2169 | { |
---|
| 2170 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
| 2171 | pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0; |
---|
| 2172 | } |
---|
[2] | 2173 | } |
---|
[56] | 2174 | } |
---|
| 2175 | #endif |
---|
[2] | 2176 | |
---|
[56] | 2177 | /** |
---|
| 2178 | - Initialize our contexts from the nominated source. |
---|
| 2179 | . |
---|
| 2180 | \param pSrc Contexts to be copied. |
---|
| 2181 | */ |
---|
| 2182 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
| 2183 | { |
---|
| 2184 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
| 2185 | } |
---|
[2] | 2186 | |
---|
[56] | 2187 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
| 2188 | { |
---|
| 2189 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
[2] | 2190 | |
---|
[56] | 2191 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
| 2192 | xCopyContextsFrom( pSrc ); |
---|
| 2193 | |
---|
| 2194 | } |
---|
| 2195 | |
---|
| 2196 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
| 2197 | { |
---|
| 2198 | xCopyFrom(pScr); |
---|
| 2199 | } |
---|
| 2200 | |
---|
| 2201 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
| 2202 | { |
---|
| 2203 | xCopyContextsFrom(pScr); |
---|
| 2204 | } |
---|
| 2205 | |
---|
| 2206 | #if OL_FLUSH |
---|
| 2207 | Void TDecSbac::decodeFlush ( ) |
---|
| 2208 | { |
---|
| 2209 | UInt uiBit; |
---|
| 2210 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
| 2211 | m_pcTDecBinIf->flush(); |
---|
| 2212 | |
---|
| 2213 | } |
---|
| 2214 | #endif |
---|
| 2215 | |
---|
[189] | 2216 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA_A0070 && LGE_EDGE_INTRA_DELTA_DC) |
---|
[56] | 2217 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
| 2218 | { |
---|
| 2219 | UInt uiSymbol; |
---|
| 2220 | UInt uiCount = 0; |
---|
| 2221 | do |
---|
[2] | 2222 | { |
---|
[56] | 2223 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
| 2224 | uiCount++; |
---|
[2] | 2225 | } |
---|
[56] | 2226 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
[2] | 2227 | |
---|
[56] | 2228 | ruiSymbol = uiCount - 1; |
---|
| 2229 | |
---|
| 2230 | if( uiSymbol ) |
---|
| 2231 | { |
---|
| 2232 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
| 2233 | ruiSymbol += uiSymbol + 1; |
---|
| 2234 | } |
---|
| 2235 | |
---|
| 2236 | return; |
---|
[2] | 2237 | } |
---|
| 2238 | #endif |
---|
[56] | 2239 | #if HHI_DMM_WEDGE_INTRA |
---|
| 2240 | Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2241 | { |
---|
| 2242 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
| 2243 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
| 2244 | |
---|
| 2245 | UInt uiSymbol, uiTabIdx = 0; |
---|
| 2246 | for ( Int i = 0; i < iBits; i++ ) |
---|
| 2247 | { |
---|
| 2248 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
| 2249 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
| 2250 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
| 2251 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
| 2252 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
| 2253 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
| 2254 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
| 2255 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
| 2256 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
| 2257 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
| 2258 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
| 2259 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
| 2260 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
| 2261 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
| 2262 | } |
---|
| 2263 | |
---|
| 2264 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2265 | } |
---|
| 2266 | |
---|
| 2267 | Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2268 | { |
---|
| 2269 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
| 2270 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
| 2271 | |
---|
| 2272 | UInt uiSymbol, uiTabIdx = 0; |
---|
| 2273 | for ( Int i = 0; i < iBits; i++ ) |
---|
| 2274 | { |
---|
| 2275 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) ); |
---|
| 2276 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
| 2277 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
| 2278 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
| 2279 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
| 2280 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
| 2281 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
| 2282 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
| 2283 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
| 2284 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
| 2285 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
| 2286 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
| 2287 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
| 2288 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
| 2289 | } |
---|
| 2290 | |
---|
| 2291 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2292 | |
---|
| 2293 | UInt uiDC1, uiDC2; |
---|
| 2294 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2295 | Int iDC1 = uiDC1; |
---|
| 2296 | if ( uiDC1 ) |
---|
| 2297 | { |
---|
| 2298 | UInt uiSign; |
---|
| 2299 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2300 | if ( uiSign ) |
---|
| 2301 | { |
---|
| 2302 | iDC1 = -iDC1; |
---|
| 2303 | } |
---|
| 2304 | } |
---|
| 2305 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2306 | Int iDC2 = uiDC2; |
---|
| 2307 | if ( uiDC2 ) |
---|
| 2308 | { |
---|
| 2309 | UInt uiSign; |
---|
| 2310 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2311 | if ( uiSign ) |
---|
| 2312 | { |
---|
| 2313 | iDC2 = -iDC2; |
---|
| 2314 | } |
---|
| 2315 | } |
---|
| 2316 | |
---|
| 2317 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2318 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2319 | } |
---|
| 2320 | |
---|
| 2321 | Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2322 | { |
---|
| 2323 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
| 2324 | { |
---|
| 2325 | UInt uiDeltaEnd = 0; |
---|
| 2326 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
| 2327 | |
---|
| 2328 | Int iDeltaEnd; |
---|
| 2329 | if( uiDeltaEnd != 0 ) |
---|
| 2330 | { |
---|
| 2331 | UInt uiAbsValMinus1; |
---|
| 2332 | UInt uiSymbol; |
---|
| 2333 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
| 2334 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
| 2335 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
| 2336 | |
---|
| 2337 | iDeltaEnd = uiDeltaEnd; |
---|
| 2338 | UInt uiSign; |
---|
| 2339 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2340 | if( uiSign ) |
---|
| 2341 | { |
---|
| 2342 | iDeltaEnd = -iDeltaEnd; |
---|
| 2343 | } |
---|
| 2344 | } |
---|
| 2345 | else |
---|
| 2346 | { |
---|
| 2347 | iDeltaEnd = 0; |
---|
| 2348 | } |
---|
| 2349 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
| 2350 | } |
---|
| 2351 | } |
---|
| 2352 | |
---|
| 2353 | Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2354 | { |
---|
| 2355 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
| 2356 | { |
---|
| 2357 | UInt uiDeltaEnd = 0; |
---|
| 2358 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) ); |
---|
| 2359 | |
---|
| 2360 | Int iDeltaEnd; |
---|
| 2361 | if( uiDeltaEnd != 0 ) |
---|
| 2362 | { |
---|
| 2363 | UInt uiAbsValMinus1; |
---|
| 2364 | UInt uiSymbol; |
---|
| 2365 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 = uiSymbol; |
---|
| 2366 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
| 2367 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
| 2368 | |
---|
| 2369 | iDeltaEnd = uiDeltaEnd; |
---|
| 2370 | UInt uiSign; |
---|
| 2371 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2372 | if( uiSign ) |
---|
| 2373 | { |
---|
| 2374 | iDeltaEnd = -iDeltaEnd; |
---|
| 2375 | } |
---|
| 2376 | } |
---|
| 2377 | else |
---|
| 2378 | { |
---|
| 2379 | iDeltaEnd = 0; |
---|
| 2380 | } |
---|
| 2381 | |
---|
| 2382 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
| 2383 | } |
---|
| 2384 | |
---|
| 2385 | UInt uiDC1, uiDC2; |
---|
| 2386 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2387 | Int iDC1 = uiDC1; |
---|
| 2388 | if ( uiDC1 ) |
---|
| 2389 | { |
---|
| 2390 | UInt uiSign; |
---|
| 2391 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2392 | if ( uiSign ) |
---|
| 2393 | { |
---|
| 2394 | iDC1 = -iDC1; |
---|
| 2395 | } |
---|
| 2396 | } |
---|
| 2397 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2398 | Int iDC2 = uiDC2; |
---|
| 2399 | if ( uiDC2 ) |
---|
| 2400 | { |
---|
| 2401 | UInt uiSign; |
---|
| 2402 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2403 | if ( uiSign ) |
---|
| 2404 | { |
---|
| 2405 | iDC2 = -iDC2; |
---|
| 2406 | } |
---|
| 2407 | } |
---|
| 2408 | |
---|
| 2409 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2410 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2411 | } |
---|
| 2412 | #endif |
---|
| 2413 | #if HHI_DMM_PRED_TEX |
---|
| 2414 | Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2415 | { |
---|
| 2416 | UInt uiDC1, uiDC2; |
---|
| 2417 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2418 | Int iDC1 = uiDC1; |
---|
| 2419 | if ( uiDC1 ) |
---|
| 2420 | { |
---|
| 2421 | UInt uiSign; |
---|
| 2422 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2423 | if ( uiSign ) |
---|
| 2424 | { |
---|
| 2425 | iDC1 = -iDC1; |
---|
| 2426 | } |
---|
| 2427 | } |
---|
| 2428 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2429 | Int iDC2 = uiDC2; |
---|
| 2430 | if ( uiDC2 ) |
---|
| 2431 | { |
---|
| 2432 | UInt uiSign; |
---|
| 2433 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2434 | if ( uiSign ) |
---|
| 2435 | { |
---|
| 2436 | iDC2 = -iDC2; |
---|
| 2437 | } |
---|
| 2438 | } |
---|
| 2439 | |
---|
| 2440 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2441 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2442 | } |
---|
| 2443 | |
---|
| 2444 | Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2445 | { |
---|
| 2446 | UInt uiDC1, uiDC2; |
---|
| 2447 | xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2448 | Int iDC1 = uiDC1; |
---|
| 2449 | if ( uiDC1 ) |
---|
| 2450 | { |
---|
| 2451 | UInt uiSign; |
---|
| 2452 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2453 | if ( uiSign ) |
---|
| 2454 | { |
---|
| 2455 | iDC1 = -iDC1; |
---|
| 2456 | } |
---|
| 2457 | } |
---|
| 2458 | xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) ); |
---|
| 2459 | Int iDC2 = uiDC2; |
---|
| 2460 | if ( uiDC2 ) |
---|
| 2461 | { |
---|
| 2462 | UInt uiSign; |
---|
| 2463 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 2464 | if ( uiSign ) |
---|
| 2465 | { |
---|
| 2466 | iDC2 = -iDC2; |
---|
| 2467 | } |
---|
| 2468 | } |
---|
| 2469 | |
---|
| 2470 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
| 2471 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
| 2472 | } |
---|
| 2473 | #endif |
---|
[100] | 2474 | |
---|
[189] | 2475 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 2476 | Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2477 | { |
---|
| 2478 | UInt uiSymbol = 0; |
---|
| 2479 | |
---|
| 2480 | // 1. Top(0) or Left(1) |
---|
| 2481 | UChar ucLeft; |
---|
| 2482 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 2483 | ucLeft = uiSymbol; |
---|
| 2484 | |
---|
| 2485 | // 2. Start position (lowest bit first) |
---|
| 2486 | UChar ucStart = 0; |
---|
| 2487 | for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) |
---|
| 2488 | { |
---|
| 2489 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 2490 | ucStart |= (uiSymbol << ui); |
---|
| 2491 | } |
---|
| 2492 | |
---|
| 2493 | // 3. Number of edges |
---|
| 2494 | UChar ucMax = 0; |
---|
| 2495 | for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) |
---|
| 2496 | { |
---|
| 2497 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 2498 | ucMax |= (uiSymbol << ui); |
---|
| 2499 | } |
---|
| 2500 | ucMax++; // +1 |
---|
| 2501 | |
---|
| 2502 | // 4. Edges |
---|
| 2503 | UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); |
---|
| 2504 | UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx ); |
---|
| 2505 | for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) |
---|
| 2506 | { |
---|
| 2507 | UChar ucEdge = 0; |
---|
| 2508 | UInt uiReorderEdge = 0; |
---|
| 2509 | // Left-friendly direction |
---|
| 2510 | // 0 ( 0deg) => 0 |
---|
| 2511 | // 1 ( 45deg) => 10 |
---|
| 2512 | // 2 ( -45deg) => 110 |
---|
| 2513 | // 3 ( 90deg) => 1110 |
---|
| 2514 | // 4 ( -90deg) => 11110 |
---|
| 2515 | // 5 ( 135deg) => 111110 |
---|
| 2516 | // 6 (-135deg) => 111111 |
---|
| 2517 | // Right-friendly direction |
---|
| 2518 | // 0 ( 0deg) => 0 |
---|
| 2519 | // 1 ( -45deg) => 10 |
---|
| 2520 | // 2 ( 45deg) => 110 |
---|
| 2521 | // 3 ( -90deg) => 1110 |
---|
| 2522 | // 4 ( 90deg) => 11110 |
---|
| 2523 | // 5 (-135deg) => 111110 |
---|
| 2524 | // 6 ( 135deg) => 111111 |
---|
| 2525 | // refer to a paper "An efficient chain code with Huffman coding" |
---|
| 2526 | for( UInt ui = 0; ui < 6; ui++ ) |
---|
| 2527 | { |
---|
| 2528 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); |
---|
| 2529 | ucEdge <<= 1; |
---|
| 2530 | ucEdge |= uiSymbol; |
---|
| 2531 | if( uiSymbol == 0 ) |
---|
| 2532 | break; |
---|
| 2533 | } |
---|
| 2534 | |
---|
| 2535 | switch( ucEdge ) |
---|
| 2536 | { |
---|
| 2537 | case 0 : // "0" |
---|
| 2538 | uiReorderEdge = 0; |
---|
| 2539 | break; |
---|
| 2540 | case 2 : // "10" |
---|
| 2541 | uiReorderEdge = 1; |
---|
| 2542 | break; |
---|
| 2543 | case 6 : // "110" |
---|
| 2544 | uiReorderEdge = 2; |
---|
| 2545 | break; |
---|
| 2546 | case 14 : // "1110" |
---|
| 2547 | uiReorderEdge = 3; |
---|
| 2548 | break; |
---|
| 2549 | case 30 : // "11110" |
---|
| 2550 | uiReorderEdge = 4; |
---|
| 2551 | break; |
---|
| 2552 | case 62 : // "111110" |
---|
| 2553 | uiReorderEdge = 5; |
---|
| 2554 | break; |
---|
| 2555 | case 63 : // "111111" |
---|
| 2556 | uiReorderEdge = 6; |
---|
| 2557 | break; |
---|
| 2558 | default : |
---|
| 2559 | printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); |
---|
| 2560 | assert(false); |
---|
| 2561 | break; |
---|
| 2562 | } |
---|
| 2563 | pucSymbolList[iPtr] = uiReorderEdge; |
---|
| 2564 | } |
---|
| 2565 | ///////////////////// |
---|
| 2566 | // Edge Reconstruction |
---|
| 2567 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
| 2568 | pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); |
---|
| 2569 | xFree( pucSymbolList ); |
---|
| 2570 | } |
---|
| 2571 | #endif |
---|
[189] | 2572 | |
---|
| 2573 | #if RWTH_SDC_DLT_B0036 |
---|
| 2574 | Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2575 | { |
---|
| 2576 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
| 2577 | |
---|
| 2578 | UInt uiSymbol = 0; |
---|
| 2579 | UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); |
---|
| 2580 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); |
---|
| 2581 | |
---|
| 2582 | if( uiSymbol == 1 ) |
---|
| 2583 | { |
---|
| 2584 | pcCU->setPartSizeSubParts(SIZE_2Nx2N, uiAbsPartIdx, uiDepth); |
---|
| 2585 | |
---|
| 2586 | pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth); |
---|
| 2587 | pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth); |
---|
| 2588 | pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth); |
---|
| 2589 | } |
---|
| 2590 | } |
---|
[100] | 2591 | |
---|
[189] | 2592 | Void TDecSbac::parseSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2593 | { |
---|
| 2594 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
| 2595 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 2596 | |
---|
| 2597 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
| 2598 | |
---|
| 2599 | UInt uiCtx = 0; |
---|
| 2600 | |
---|
| 2601 | UInt uiMPModeIdx = 0; |
---|
| 2602 | |
---|
| 2603 | for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++) |
---|
| 2604 | { |
---|
| 2605 | UInt uiIsMostProb = 0; |
---|
| 2606 | m_pcTDecBinIf->decodeBin( uiIsMostProb, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) ); |
---|
| 2607 | |
---|
| 2608 | if ( uiIsMostProb == 1 ) |
---|
| 2609 | break; |
---|
| 2610 | |
---|
| 2611 | // else: get next most probable pred mode |
---|
| 2612 | uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES; |
---|
| 2613 | } |
---|
| 2614 | |
---|
| 2615 | Int intraPredMode = g_auiSDCPredModes[uiMPModeIdx]; |
---|
| 2616 | |
---|
| 2617 | #if HHI_DMM_WEDGE_INTRA |
---|
| 2618 | if( intraPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 2619 | if( intraPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
| 2620 | #endif |
---|
| 2621 | |
---|
| 2622 | pcCU->setLumaIntraDirSubParts((UChar)intraPredMode, uiAbsPartIdx, uiDepth); |
---|
| 2623 | } |
---|
| 2624 | |
---|
| 2625 | Void TDecSbac::parseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
| 2626 | { |
---|
| 2627 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
| 2628 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
| 2629 | assert( uiSegment < 2 ); |
---|
| 2630 | |
---|
| 2631 | UInt uiResidual = 0; |
---|
| 2632 | UInt uiBit = 0; |
---|
| 2633 | UInt uiAbsIdx = 0; |
---|
| 2634 | UInt uiSign = 0; |
---|
| 2635 | Int iIdx = 0; |
---|
| 2636 | |
---|
| 2637 | UInt uiMaxResidualBits = GetBitsPerDepthValue(); |
---|
| 2638 | assert( uiMaxResidualBits <= g_uiBitDepth ); |
---|
| 2639 | |
---|
| 2640 | m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) ); |
---|
| 2641 | |
---|
| 2642 | if (uiResidual) |
---|
| 2643 | { |
---|
| 2644 | // decode residual sign bit |
---|
| 2645 | m_pcTDecBinIf->decodeBin(uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) ); |
---|
| 2646 | |
---|
| 2647 | // decode residual magnitude |
---|
| 2648 | for (Int i=0; i<uiMaxResidualBits; i++) |
---|
| 2649 | { |
---|
| 2650 | m_pcTDecBinIf->decodeBin(uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) ); |
---|
| 2651 | uiAbsIdx |= uiBit << i; |
---|
| 2652 | } |
---|
| 2653 | |
---|
| 2654 | uiAbsIdx += 1; |
---|
| 2655 | iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx; |
---|
| 2656 | } |
---|
| 2657 | |
---|
| 2658 | pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx); |
---|
| 2659 | } |
---|
| 2660 | #endif |
---|
| 2661 | |
---|
[56] | 2662 | //! \} |
---|