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