[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 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TDecSbac.cpp |
---|
| 35 | \brief Context-adaptive entropy decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecSbac.h" |
---|
| 39 | |
---|
[56] | 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
[2] | 43 | ////////////////////////////////////////////////////////////////////// |
---|
| 44 | // Construction/Destruction |
---|
| 45 | ////////////////////////////////////////////////////////////////////// |
---|
| 46 | |
---|
| 47 | TDecSbac::TDecSbac() |
---|
| 48 | // new structure here |
---|
| 49 | : m_pcBitstream ( 0 ) |
---|
| 50 | , m_pcTDecBinIf ( NULL ) |
---|
[56] | 51 | , m_numContextModels ( 0 ) |
---|
| 52 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) |
---|
| 53 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 54 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 55 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[608] | 56 | #if H_3D_ARP |
---|
| 57 | , m_cCUPUARPWSCModel ( 1, 1, NUM_ARPW_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 58 | #endif |
---|
[608] | 59 | #if H_3D_IC |
---|
| 60 | , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[443] | 61 | #endif |
---|
[56] | 62 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 63 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 64 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 65 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 66 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 67 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 68 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 69 | , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 70 | , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 71 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 72 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 73 | , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 74 | , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 75 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 76 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 77 | , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 78 | , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 79 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 80 | , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[608] | 81 | , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[443] | 82 | , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[608] | 83 | , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 84 | , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 85 | #if H_3D_DIM |
---|
| 86 | , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 87 | , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 88 | , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 89 | #if H_3D_DIM_DMM |
---|
| 90 | , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 91 | , m_cDmm3DataSCModel ( 1, 1, NUM_DMM3_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[443] | 92 | #endif |
---|
[608] | 93 | #if H_3D_DIM_RBC |
---|
| 94 | , m_cRbcDataSCModel ( 1, 1, NUM_RBC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[2] | 95 | #endif |
---|
[608] | 96 | #if H_3D_DIM_SDC |
---|
| 97 | , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 98 | , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[100] | 99 | #endif |
---|
| 100 | #endif |
---|
[655] | 101 | #if H_3D_INTER_SDC |
---|
[608] | 102 | , m_cInterSDCFlagSCModel ( 1, 1, NUM_INTER_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 103 | , m_cInterSDCResidualSCModel ( 1, 1, NUM_INTER_SDC_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
| 104 | , m_cInterSDCResidualSignFlagSCModel ( 1, 1, NUM_INTER_SDC_SIGN_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) |
---|
[443] | 105 | #endif |
---|
[2] | 106 | { |
---|
[56] | 107 | assert( m_numContextModels <= MAX_NUM_CTX_MOD ); |
---|
[2] | 108 | } |
---|
| 109 | |
---|
| 110 | TDecSbac::~TDecSbac() |
---|
| 111 | { |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | // ==================================================================================================================== |
---|
| 115 | // Public member functions |
---|
| 116 | // ==================================================================================================================== |
---|
| 117 | |
---|
[56] | 118 | Void TDecSbac::resetEntropy(TComSlice* pSlice) |
---|
[2] | 119 | { |
---|
[56] | 120 | SliceType sliceType = pSlice->getSliceType(); |
---|
| 121 | Int qp = pSlice->getSliceQp(); |
---|
| 122 | |
---|
| 123 | if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag()) |
---|
| 124 | { |
---|
| 125 | switch (sliceType) |
---|
| 126 | { |
---|
| 127 | case P_SLICE: // change initialization table to B_SLICE initialization |
---|
| 128 | sliceType = B_SLICE; |
---|
| 129 | break; |
---|
| 130 | case B_SLICE: // change initialization table to P_SLICE initialization |
---|
| 131 | sliceType = P_SLICE; |
---|
| 132 | break; |
---|
| 133 | default : // should not occur |
---|
| 134 | assert(0); |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); |
---|
| 139 | m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); |
---|
| 140 | m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
| 141 | m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
[608] | 142 | #if H_3D_ARP |
---|
| 143 | m_cCUPUARPWSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ARPW ); |
---|
[2] | 144 | #endif |
---|
[608] | 145 | #if H_3D_IC |
---|
| 146 | m_cCUICFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_IC_FLAG ); |
---|
[443] | 147 | #endif |
---|
[56] | 148 | m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); |
---|
| 149 | m_cCUAMPSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_AMP_POS ); |
---|
| 150 | m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); |
---|
| 151 | m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
| 152 | m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
| 153 | m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); |
---|
| 154 | m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); |
---|
| 155 | m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); |
---|
| 156 | m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); |
---|
| 157 | m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); |
---|
| 158 | m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
| 159 | m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
| 160 | m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); |
---|
| 161 | m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
| 162 | m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); |
---|
| 163 | m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); |
---|
| 164 | m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); |
---|
| 165 | m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); |
---|
[608] | 166 | m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
[443] | 167 | m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
[56] | 168 | |
---|
| 169 | m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
[608] | 170 | m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
| 171 | m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
| 172 | #if H_3D_DIM |
---|
| 173 | m_cDepthIntraModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
| 174 | m_cDdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_FLAG ); |
---|
| 175 | m_cDdcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_DATA ); |
---|
| 176 | #if H_3D_DIM_DMM |
---|
| 177 | m_cDmm1DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM1_DATA ); |
---|
| 178 | m_cDmm3DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM3_DATA ); |
---|
[100] | 179 | #endif |
---|
[608] | 180 | #if H_3D_DIM_RBC |
---|
| 181 | m_cRbcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_RBC_DATA ); |
---|
[443] | 182 | #endif |
---|
[608] | 183 | #if H_3D_DIM_SDC |
---|
| 184 | m_cSDCResidualFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
| 185 | m_cSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
[2] | 186 | #endif |
---|
[443] | 187 | #endif |
---|
[655] | 188 | #if H_3D_INTER_SDC |
---|
[608] | 189 | m_cInterSDCFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_FLAG ); |
---|
| 190 | m_cInterSDCResidualSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_RESIDUAL ); |
---|
| 191 | m_cInterSDCResidualSignFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_SIGN_FLAG ); |
---|
[443] | 192 | #endif |
---|
[608] | 193 | m_uiLastDQpNonZero = 0; |
---|
[2] | 194 | |
---|
| 195 | // new structure |
---|
[56] | 196 | m_uiLastQp = qp; |
---|
[2] | 197 | |
---|
| 198 | m_pcTDecBinIf->start(); |
---|
| 199 | } |
---|
| 200 | |
---|
[56] | 201 | /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile. |
---|
| 202 | * Intialize CABAC states. Start CABAC. |
---|
| 203 | */ |
---|
| 204 | Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp ) |
---|
| 205 | { |
---|
| 206 | UInt uiBit; |
---|
| 207 | m_pcTDecBinIf->decodeBinTrm(uiBit); |
---|
[608] | 208 | assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1 |
---|
[56] | 209 | m_pcTDecBinIf->finish(); |
---|
| 210 | m_pcBitstream->readOutTrailingBits(); |
---|
| 211 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG ); |
---|
| 212 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); |
---|
| 213 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT ); |
---|
| 214 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT ); |
---|
[608] | 215 | #if H_3D_ARP |
---|
| 216 | m_cCUPUARPWSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ARPW ); |
---|
[56] | 217 | #endif |
---|
[608] | 218 | #if H_3D_IC |
---|
| 219 | m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); |
---|
[443] | 220 | #endif |
---|
[56] | 221 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); |
---|
| 222 | m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS ); |
---|
| 223 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); |
---|
| 224 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); |
---|
| 225 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE ); |
---|
| 226 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR ); |
---|
| 227 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD ); |
---|
| 228 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC ); |
---|
| 229 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP ); |
---|
| 230 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF ); |
---|
| 231 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF ); |
---|
| 232 | m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG ); |
---|
| 233 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG ); |
---|
| 234 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
| 235 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST ); |
---|
| 236 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG ); |
---|
| 237 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG ); |
---|
| 238 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX ); |
---|
[608] | 239 | m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG ); |
---|
[443] | 240 | m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX ); |
---|
[56] | 241 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); |
---|
[608] | 242 | m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); |
---|
| 243 | m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); |
---|
| 244 | |
---|
| 245 | #if H_3D_DIM |
---|
| 246 | m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); |
---|
| 247 | m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); |
---|
| 248 | m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); |
---|
| 249 | #if H_3D_DIM_DMM |
---|
| 250 | m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); |
---|
| 251 | m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA ); |
---|
[56] | 252 | #endif |
---|
[608] | 253 | #if H_3D_DIM_RBC |
---|
| 254 | m_cRbcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RBC_DATA ); |
---|
[443] | 255 | #endif |
---|
[608] | 256 | #if H_3D_DIM_SDC |
---|
| 257 | m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); |
---|
| 258 | m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); |
---|
[443] | 259 | #endif |
---|
[189] | 260 | #endif |
---|
[655] | 261 | #if H_3D_INTER_SDC |
---|
[608] | 262 | m_cInterSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG ); |
---|
| 263 | m_cInterSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL ); |
---|
| 264 | m_cInterSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_SIGN_FLAG ); |
---|
| 265 | #endif |
---|
[56] | 266 | m_pcTDecBinIf->start(); |
---|
| 267 | } |
---|
| 268 | |
---|
[608] | 269 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
[56] | 270 | { |
---|
[608] | 271 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
| 272 | if ( ruiBit ) |
---|
[56] | 273 | { |
---|
[608] | 274 | m_pcTDecBinIf->finish(); |
---|
[56] | 275 | } |
---|
| 276 | } |
---|
| 277 | |
---|
[2] | 278 | |
---|
| 279 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
| 280 | { |
---|
| 281 | if (uiMaxSymbol == 0) |
---|
| 282 | { |
---|
| 283 | ruiSymbol = 0; |
---|
| 284 | return; |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
| 288 | |
---|
| 289 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
| 290 | { |
---|
| 291 | return; |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | UInt uiSymbol = 0; |
---|
| 295 | UInt uiCont; |
---|
| 296 | |
---|
| 297 | do |
---|
| 298 | { |
---|
| 299 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
| 300 | uiSymbol++; |
---|
| 301 | } |
---|
| 302 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
| 303 | |
---|
| 304 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
| 305 | { |
---|
| 306 | uiSymbol++; |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | ruiSymbol = uiSymbol; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
| 313 | { |
---|
| 314 | UInt uiSymbol = 0; |
---|
| 315 | UInt uiBit = 1; |
---|
| 316 | |
---|
| 317 | while( uiBit ) |
---|
| 318 | { |
---|
| 319 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
| 320 | uiSymbol += uiBit << uiCount++; |
---|
| 321 | } |
---|
| 322 | |
---|
[56] | 323 | if ( --uiCount ) |
---|
[2] | 324 | { |
---|
[56] | 325 | UInt bins; |
---|
| 326 | m_pcTDecBinIf->decodeBinsEP( bins, uiCount ); |
---|
| 327 | uiSymbol += bins; |
---|
[2] | 328 | } |
---|
| 329 | |
---|
| 330 | ruiSymbol = uiSymbol; |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
| 334 | { |
---|
| 335 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
| 336 | |
---|
| 337 | if( !ruiSymbol ) |
---|
| 338 | { |
---|
| 339 | return; |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | UInt uiSymbol = 0; |
---|
| 343 | UInt uiCont; |
---|
| 344 | |
---|
| 345 | do |
---|
| 346 | { |
---|
| 347 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
| 348 | uiSymbol++; |
---|
| 349 | } |
---|
| 350 | while( uiCont ); |
---|
| 351 | |
---|
| 352 | ruiSymbol = uiSymbol; |
---|
| 353 | } |
---|
| 354 | |
---|
[608] | 355 | |
---|
| 356 | /** Parsing of coeff_abs_level_remaing |
---|
| 357 | * \param ruiSymbol reference to coeff_abs_level_remaing |
---|
| 358 | * \param ruiParam reference to parameter |
---|
[2] | 359 | * \returns Void |
---|
| 360 | */ |
---|
[608] | 361 | Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ) |
---|
[2] | 362 | { |
---|
| 363 | |
---|
[608] | 364 | UInt prefix = 0; |
---|
| 365 | UInt codeWord = 0; |
---|
[2] | 366 | do |
---|
| 367 | { |
---|
[608] | 368 | prefix++; |
---|
| 369 | m_pcTDecBinIf->decodeBinEP( codeWord ); |
---|
[2] | 370 | } |
---|
[608] | 371 | while( codeWord); |
---|
| 372 | codeWord = 1 - codeWord; |
---|
| 373 | prefix -= codeWord; |
---|
| 374 | codeWord=0; |
---|
| 375 | if (prefix < COEF_REMAIN_BIN_REDUCTION ) |
---|
| 376 | { |
---|
| 377 | m_pcTDecBinIf->decodeBinsEP(codeWord,rParam); |
---|
| 378 | rSymbol = (prefix<<rParam) + codeWord; |
---|
| 379 | } |
---|
| 380 | else |
---|
| 381 | { |
---|
| 382 | m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam); |
---|
| 383 | rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; |
---|
| 384 | } |
---|
| 385 | } |
---|
[2] | 386 | |
---|
[608] | 387 | #if H_3D_DIM |
---|
| 388 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
| 389 | { |
---|
| 390 | UInt uiSymbol; |
---|
| 391 | UInt uiCount = 0; |
---|
| 392 | do |
---|
| 393 | { |
---|
| 394 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
| 395 | uiCount++; |
---|
| 396 | } |
---|
| 397 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
[2] | 398 | |
---|
[608] | 399 | ruiSymbol = uiCount - 1; |
---|
| 400 | |
---|
| 401 | if( uiSymbol ) |
---|
[2] | 402 | { |
---|
[608] | 403 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
| 404 | ruiSymbol += uiSymbol + 1; |
---|
[2] | 405 | } |
---|
| 406 | |
---|
[608] | 407 | return; |
---|
| 408 | } |
---|
[2] | 409 | |
---|
[608] | 410 | Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt dimType ) |
---|
| 411 | { |
---|
| 412 | UInt absValDeltaDC = 0; |
---|
| 413 | xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); |
---|
| 414 | rValDeltaDC = (Pel)absValDeltaDC; |
---|
| 415 | |
---|
| 416 | if( rValDeltaDC != 0 ) |
---|
[2] | 417 | { |
---|
[608] | 418 | UInt uiSign; |
---|
| 419 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
| 420 | if ( uiSign ) |
---|
| 421 | { |
---|
| 422 | rValDeltaDC = -rValDeltaDC; |
---|
| 423 | } |
---|
[2] | 424 | } |
---|
[608] | 425 | } |
---|
| 426 | #if H_3D_DIM_DMM |
---|
| 427 | Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit ) |
---|
| 428 | { |
---|
| 429 | UInt uiSymbol, uiIdx = 0; |
---|
| 430 | for( Int i = 0; i < iNumBit; i++ ) |
---|
| 431 | { |
---|
| 432 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm1DataSCModel.get(0, 0, 0) ); |
---|
| 433 | uiIdx += uiSymbol << i; |
---|
| 434 | } |
---|
| 435 | ruiTabIdx = uiIdx; |
---|
| 436 | } |
---|
[2] | 437 | |
---|
[608] | 438 | Void TDecSbac::xParseDmm3WedgeIdx( UInt& ruiIntraIdx, Int iNumBit ) |
---|
| 439 | { |
---|
| 440 | UInt uiSymbol, uiIdx = 0; |
---|
| 441 | for( Int i = 0; i < iNumBit; i++ ) |
---|
| 442 | { |
---|
| 443 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm3DataSCModel.get(0, 0, 0) ); |
---|
| 444 | uiIdx += uiSymbol << i; |
---|
| 445 | } |
---|
| 446 | ruiIntraIdx = uiIdx; |
---|
| 447 | } |
---|
| 448 | #endif |
---|
| 449 | #if H_3D_DIM_RBC |
---|
| 450 | Void TDecSbac::xParseRbcEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 451 | { |
---|
| 452 | UInt uiSymbol = 0; |
---|
[2] | 453 | |
---|
[608] | 454 | // 1. Top(0) or Left(1) |
---|
| 455 | UChar ucLeft; |
---|
| 456 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 457 | ucLeft = uiSymbol; |
---|
| 458 | |
---|
| 459 | // 2. Start position (lowest bit first) |
---|
| 460 | UChar ucStart = 0; |
---|
| 461 | for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) |
---|
| 462 | { |
---|
| 463 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 464 | ucStart |= (uiSymbol << ui); |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | // 3. Number of edges |
---|
| 468 | UChar ucMax = 0; |
---|
| 469 | for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) |
---|
| 470 | { |
---|
| 471 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 472 | ucMax |= (uiSymbol << ui); |
---|
| 473 | } |
---|
| 474 | ucMax++; // +1 |
---|
| 475 | |
---|
| 476 | // 4. Edges |
---|
| 477 | UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * RBC_MAX_EDGE_NUM_PER_4x4 ); |
---|
| 478 | for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) |
---|
| 479 | { |
---|
| 480 | UChar ucEdge = 0; |
---|
| 481 | UInt uiReorderEdge = 0; |
---|
| 482 | for( UInt ui = 0; ui < 6; ui++ ) |
---|
| 483 | { |
---|
| 484 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cRbcDataSCModel.get( 0, 0, 0 ) ); |
---|
| 485 | ucEdge <<= 1; |
---|
| 486 | ucEdge |= uiSymbol; |
---|
| 487 | if( uiSymbol == 0 ) |
---|
| 488 | break; |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | switch( ucEdge ) |
---|
| 492 | { |
---|
| 493 | case 0 : // "0" |
---|
| 494 | uiReorderEdge = 0; |
---|
| 495 | break; |
---|
| 496 | case 2 : // "10" |
---|
| 497 | uiReorderEdge = 1; |
---|
| 498 | break; |
---|
| 499 | case 6 : // "110" |
---|
| 500 | uiReorderEdge = 2; |
---|
| 501 | break; |
---|
| 502 | case 14 : // "1110" |
---|
| 503 | uiReorderEdge = 3; |
---|
| 504 | break; |
---|
| 505 | case 30 : // "11110" |
---|
| 506 | uiReorderEdge = 4; |
---|
| 507 | break; |
---|
| 508 | case 62 : // "111110" |
---|
| 509 | uiReorderEdge = 5; |
---|
| 510 | break; |
---|
| 511 | case 63 : // "111111" |
---|
| 512 | uiReorderEdge = 6; |
---|
| 513 | break; |
---|
| 514 | default : |
---|
| 515 | printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); |
---|
| 516 | assert(false); |
---|
| 517 | break; |
---|
| 518 | } |
---|
| 519 | pucSymbolList[iPtr] = uiReorderEdge; |
---|
| 520 | } |
---|
| 521 | ///////////////////// |
---|
| 522 | // Edge Reconstruction |
---|
| 523 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
| 524 | pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); |
---|
| 525 | xFree( pucSymbolList ); |
---|
[2] | 526 | } |
---|
[608] | 527 | #endif |
---|
| 528 | #if H_3D_DIM_SDC |
---|
| 529 | Void TDecSbac::xParseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
| 530 | { |
---|
| 531 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
| 532 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 533 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
| 534 | assert( uiSegment < 2 ); |
---|
| 535 | |
---|
| 536 | UInt uiResidual = 0; |
---|
| 537 | UInt uiBit = 0; |
---|
| 538 | UInt uiAbsIdx = 0; |
---|
| 539 | UInt uiSign = 0; |
---|
| 540 | Int iIdx = 0; |
---|
| 541 | |
---|
| 542 | #if H_3D_DIM_DLT |
---|
| 543 | UInt uiMaxResidualBits = pcCU->getSlice()->getVPS()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() ); |
---|
| 544 | #else |
---|
| 545 | UInt uiMaxResidualBits = g_bitDepthY; |
---|
| 546 | #endif |
---|
| 547 | assert( uiMaxResidualBits <= g_bitDepthY ); |
---|
| 548 | |
---|
| 549 | m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) ); |
---|
| 550 | |
---|
[622] | 551 | #if H_MV_ENC_DEC_TRAC |
---|
| 552 | DTRACE_CU("sdc_residual_flag[i]", uiResidual) |
---|
| 553 | #endif |
---|
| 554 | |
---|
[608] | 555 | if (uiResidual) |
---|
| 556 | { |
---|
| 557 | // decode residual sign bit |
---|
| 558 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
[622] | 559 | #if H_MV_ENC_DEC_TRAC |
---|
| 560 | DTRACE_CU("sdc_residual_sign_flag[i]", uiSign) |
---|
| 561 | #endif |
---|
[608] | 562 | |
---|
| 563 | // decode residual magnitude |
---|
| 564 | // prefix part |
---|
| 565 | UInt uiCount = 0; |
---|
| 566 | #if H_3D_DIM_DLT |
---|
| 567 | UInt uiNumDepthValues = pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ); |
---|
| 568 | #else |
---|
| 569 | UInt uiNumDepthValues = ((1 << g_bitDepthY)-1); |
---|
| 570 | #endif |
---|
| 571 | UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2); |
---|
| 572 | for ( UInt ui = 0; ui < uiPrefixThreshold; ui++) |
---|
| 573 | { |
---|
| 574 | m_pcTDecBinIf->decodeBin( uiBit, m_cSDCResidualSCModel.get(0, 0, 0) ); |
---|
| 575 | if ( uiBit == 0 ) |
---|
| 576 | break; |
---|
| 577 | else |
---|
| 578 | uiCount++; |
---|
| 579 | } |
---|
| 580 | // suffix part |
---|
| 581 | if ( uiCount == uiPrefixThreshold ) |
---|
| 582 | { |
---|
| 583 | for ( UInt ui = 0; ui < numBitsForValue(uiNumDepthValues - uiPrefixThreshold); ui++ ) |
---|
| 584 | { |
---|
| 585 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
| 586 | uiAbsIdx |= uiBit << ui; |
---|
| 587 | } |
---|
| 588 | uiAbsIdx += uiCount; |
---|
| 589 | } |
---|
| 590 | else |
---|
[622] | 591 | { |
---|
[608] | 592 | uiAbsIdx = uiCount; |
---|
[622] | 593 | } |
---|
| 594 | |
---|
| 595 | #if H_MV_ENC_DEC_TRAC |
---|
| 596 | DTRACE_CU("sdc_residual_abs_minus1[i]", uiAbsIdx) |
---|
| 597 | #endif |
---|
[608] | 598 | |
---|
| 599 | uiAbsIdx += 1; |
---|
| 600 | iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx; |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx); |
---|
| 604 | } |
---|
| 605 | #endif |
---|
| 606 | #endif |
---|
[56] | 607 | |
---|
| 608 | /** Parse I_PCM information. |
---|
| 609 | * \param pcCU |
---|
| 610 | * \param uiAbsPartIdx |
---|
| 611 | * \param uiDepth |
---|
| 612 | * \returns Void |
---|
| 613 | * |
---|
| 614 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 615 | */ |
---|
| 616 | Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 617 | { |
---|
| 618 | UInt uiSymbol; |
---|
[56] | 619 | |
---|
| 620 | m_pcTDecBinIf->decodeBinTrm(uiSymbol); |
---|
[2] | 621 | |
---|
[608] | 622 | #if H_MV_ENC_DEC_TRAC |
---|
| 623 | DTRACE_CU("pcm_flag", uiSymbol) |
---|
| 624 | #endif |
---|
[56] | 625 | if (uiSymbol) |
---|
| 626 | { |
---|
| 627 | Bool bIpcmFlag = true; |
---|
| 628 | |
---|
| 629 | pcCU->setPartSizeSubParts ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 630 | pcCU->setSizeSubParts ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
[608] | 631 | pcCU->setTrIdxSubParts ( 0, uiAbsPartIdx, uiDepth ); |
---|
[56] | 632 | pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); |
---|
[2] | 633 | |
---|
[56] | 634 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 635 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 636 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
| 637 | |
---|
| 638 | Pel* piPCMSample; |
---|
| 639 | UInt uiWidth; |
---|
| 640 | UInt uiHeight; |
---|
| 641 | UInt uiSampleBits; |
---|
| 642 | UInt uiX, uiY; |
---|
| 643 | |
---|
| 644 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
| 645 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 646 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 647 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 648 | |
---|
| 649 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 650 | { |
---|
| 651 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 652 | { |
---|
| 653 | UInt uiSample; |
---|
| 654 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 655 | piPCMSample[uiX] = uiSample; |
---|
| 656 | } |
---|
| 657 | piPCMSample += uiWidth; |
---|
| 658 | } |
---|
| 659 | |
---|
| 660 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
| 661 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 662 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 663 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 664 | |
---|
| 665 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 666 | { |
---|
| 667 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 668 | { |
---|
| 669 | UInt uiSample; |
---|
| 670 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 671 | piPCMSample[uiX] = uiSample; |
---|
| 672 | } |
---|
| 673 | piPCMSample += uiWidth; |
---|
| 674 | } |
---|
| 675 | |
---|
| 676 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
| 677 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 678 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 679 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 680 | |
---|
| 681 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
| 682 | { |
---|
| 683 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 684 | { |
---|
| 685 | UInt uiSample; |
---|
| 686 | m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); |
---|
| 687 | piPCMSample[uiX] = uiSample; |
---|
| 688 | } |
---|
| 689 | piPCMSample += uiWidth; |
---|
| 690 | } |
---|
| 691 | |
---|
[608] | 692 | m_pcTDecBinIf->start(); |
---|
[2] | 693 | } |
---|
| 694 | } |
---|
| 695 | |
---|
[608] | 696 | Void TDecSbac::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 697 | { |
---|
| 698 | UInt uiSymbol; |
---|
| 699 | m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) ); |
---|
| 700 | #if H_MV_ENC_DEC_TRAC |
---|
| 701 | DTRACE_CU("cu_transquant_bypass_flag", uiSymbol); |
---|
| 702 | #endif |
---|
| 703 | pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); |
---|
| 704 | } |
---|
| 705 | |
---|
[2] | 706 | /** parse skip flag |
---|
| 707 | * \param pcCU |
---|
| 708 | * \param uiAbsPartIdx |
---|
| 709 | * \param uiDepth |
---|
| 710 | * \returns Void |
---|
| 711 | */ |
---|
| 712 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 713 | { |
---|
| 714 | if( pcCU->getSlice()->isIntra() ) |
---|
| 715 | { |
---|
| 716 | return; |
---|
| 717 | } |
---|
| 718 | |
---|
| 719 | UInt uiSymbol = 0; |
---|
| 720 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
| 721 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
[608] | 722 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 723 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
[2] | 724 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
| 725 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
| 726 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
| 727 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
| 728 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 729 | DTRACE_CABAC_T( "\n"); |
---|
[608] | 730 | #endif |
---|
[2] | 731 | |
---|
| 732 | if( uiSymbol ) |
---|
| 733 | { |
---|
[608] | 734 | pcCU->setSkipFlagSubParts( true, uiAbsPartIdx, uiDepth ); |
---|
| 735 | pcCU->setPredModeSubParts( MODE_INTER, uiAbsPartIdx, uiDepth ); |
---|
[2] | 736 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 737 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 738 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
| 739 | } |
---|
[608] | 740 | #if H_MV_ENC_DEC_TRAC |
---|
| 741 | DTRACE_CU("cu_skip_flag", uiSymbol); |
---|
| 742 | #endif |
---|
[2] | 743 | } |
---|
| 744 | |
---|
| 745 | /** parse merge flag |
---|
| 746 | * \param pcCU |
---|
| 747 | * \param uiAbsPartIdx |
---|
| 748 | * \param uiDepth |
---|
| 749 | * \param uiPUIdx |
---|
| 750 | * \returns Void |
---|
| 751 | */ |
---|
| 752 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 753 | { |
---|
| 754 | UInt uiSymbol; |
---|
[56] | 755 | m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) ); |
---|
[608] | 756 | #if H_MV_ENC_DEC_TRAC |
---|
| 757 | DTRACE_PU("merge_flag", uiSymbol) |
---|
| 758 | #endif |
---|
[2] | 759 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 760 | |
---|
[608] | 761 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 762 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
[2] | 763 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
| 764 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 765 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
| 766 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
| 767 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
| 768 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 769 | DTRACE_CABAC_T( "\n" ); |
---|
[608] | 770 | #endif |
---|
[2] | 771 | } |
---|
| 772 | |
---|
[608] | 773 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ) |
---|
[2] | 774 | { |
---|
[56] | 775 | UInt uiUnaryIdx = 0; |
---|
[608] | 776 | UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand(); |
---|
[56] | 777 | if ( uiNumCand > 1 ) |
---|
[2] | 778 | { |
---|
[56] | 779 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
[2] | 780 | { |
---|
[56] | 781 | UInt uiSymbol = 0; |
---|
| 782 | if ( uiUnaryIdx==0 ) |
---|
[2] | 783 | { |
---|
[56] | 784 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 785 | } |
---|
[56] | 786 | else |
---|
| 787 | { |
---|
| 788 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 789 | } |
---|
| 790 | if( uiSymbol == 0 ) |
---|
[2] | 791 | { |
---|
[56] | 792 | break; |
---|
[2] | 793 | } |
---|
| 794 | } |
---|
[608] | 795 | #if H_MV_ENC_DEC_TRAC |
---|
| 796 | DTRACE_PU("merge_idx", uiUnaryIdx) |
---|
| 797 | #endif |
---|
[2] | 798 | } |
---|
| 799 | ruiMergeIndex = uiUnaryIdx; |
---|
| 800 | |
---|
[608] | 801 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 802 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 803 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
| 804 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
| 805 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
| 806 | DTRACE_CABAC_T( "\n" ) |
---|
[2] | 807 | #endif |
---|
| 808 | } |
---|
| 809 | |
---|
[56] | 810 | Void TDecSbac::parseMVPIdx ( Int& riMVPIdx ) |
---|
| 811 | { |
---|
| 812 | UInt uiSymbol; |
---|
| 813 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1); |
---|
| 814 | riMVPIdx = uiSymbol; |
---|
| 815 | } |
---|
[2] | 816 | |
---|
| 817 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 818 | { |
---|
| 819 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 820 | { |
---|
| 821 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
| 822 | return; |
---|
| 823 | } |
---|
[608] | 824 | |
---|
[2] | 825 | UInt uiSymbol; |
---|
[608] | 826 | #if H_3D_QTLPC |
---|
[189] | 827 | Bool bParseSplitFlag = true; |
---|
| 828 | |
---|
| 829 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
| 830 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
| 831 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
| 832 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
| 833 | |
---|
[608] | 834 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
| 835 | |
---|
| 836 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC()) |
---|
[189] | 837 | { |
---|
| 838 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
| 839 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
| 840 | bParseSplitFlag = (pcTextureCU->getDepth(uiAbsPartIdx) > uiDepth); |
---|
| 841 | } |
---|
| 842 | |
---|
| 843 | if(bParseSplitFlag) |
---|
| 844 | { |
---|
| 845 | #endif |
---|
| 846 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
[608] | 847 | #if H_MV_ENC_DEC_TRAC |
---|
| 848 | DTRACE_CU("split_cu_flag", uiSymbol); |
---|
| 849 | #else |
---|
[189] | 850 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 851 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
[608] | 852 | #endif |
---|
| 853 | #if H_3D_QTLPC |
---|
[189] | 854 | } |
---|
| 855 | else |
---|
[608] | 856 | { |
---|
[189] | 857 | uiSymbol = 0; |
---|
[608] | 858 | } |
---|
[189] | 859 | #endif |
---|
[2] | 860 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
| 861 | |
---|
| 862 | return; |
---|
| 863 | } |
---|
| 864 | |
---|
| 865 | /** parse partition size |
---|
| 866 | * \param pcCU |
---|
| 867 | * \param uiAbsPartIdx |
---|
| 868 | * \param uiDepth |
---|
| 869 | * \returns Void |
---|
| 870 | */ |
---|
| 871 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 872 | { |
---|
| 873 | UInt uiSymbol, uiMode = 0; |
---|
| 874 | PartSize eMode; |
---|
[189] | 875 | |
---|
[608] | 876 | #if H_3D_QTLPC |
---|
[189] | 877 | Bool bParsePartSize = true; |
---|
| 878 | TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); |
---|
| 879 | TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); |
---|
| 880 | Bool bDepthMapDetect = (pcTexture != NULL); |
---|
| 881 | Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); |
---|
| 882 | |
---|
[608] | 883 | Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
| 884 | |
---|
| 885 | if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC()) |
---|
[189] | 886 | { |
---|
| 887 | TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); |
---|
| 888 | assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth); |
---|
| 889 | if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN) |
---|
| 890 | { |
---|
| 891 | bParsePartSize = false; |
---|
| 892 | eMode = SIZE_2Nx2N; |
---|
| 893 | } |
---|
| 894 | } |
---|
| 895 | #endif |
---|
[608] | 896 | |
---|
[2] | 897 | |
---|
| 898 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 899 | { |
---|
[608] | 900 | #if H_3D_QTLPC |
---|
[189] | 901 | if(bParsePartSize) |
---|
[2] | 902 | { |
---|
[189] | 903 | #endif |
---|
[608] | 904 | uiSymbol = 1; |
---|
[189] | 905 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 906 | { |
---|
| 907 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
[608] | 908 | #if H_MV_ENC_DEC_TRAC |
---|
| 909 | DTRACE_CU("part_mode", uiSymbol) |
---|
| 910 | #endif |
---|
[189] | 911 | } |
---|
| 912 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
[608] | 913 | #if H_3D_QTLPC |
---|
[2] | 914 | } |
---|
[189] | 915 | #endif |
---|
[56] | 916 | UInt uiTrLevel = 0; |
---|
| 917 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
| 918 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
| 919 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
| 920 | if( eMode == SIZE_NxN ) |
---|
| 921 | { |
---|
| 922 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 923 | } |
---|
| 924 | else |
---|
| 925 | { |
---|
| 926 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
| 927 | } |
---|
[2] | 928 | } |
---|
| 929 | else |
---|
| 930 | { |
---|
[608] | 931 | #if H_3D_QTLPC |
---|
[189] | 932 | if(bParsePartSize) |
---|
[2] | 933 | { |
---|
[189] | 934 | #endif |
---|
| 935 | UInt uiMaxNumBits = 2; |
---|
[608] | 936 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) |
---|
[2] | 937 | { |
---|
[189] | 938 | uiMaxNumBits ++; |
---|
[2] | 939 | } |
---|
[189] | 940 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
[56] | 941 | { |
---|
[189] | 942 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
| 943 | if ( uiSymbol ) |
---|
| 944 | { |
---|
| 945 | break; |
---|
| 946 | } |
---|
| 947 | uiMode++; |
---|
| 948 | } |
---|
| 949 | eMode = (PartSize) uiMode; |
---|
| 950 | if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) ) |
---|
| 951 | { |
---|
| 952 | if (eMode == SIZE_2NxN) |
---|
| 953 | { |
---|
[608] | 954 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
[189] | 955 | if (uiSymbol == 0) |
---|
| 956 | { |
---|
| 957 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
| 958 | eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); |
---|
| 959 | } |
---|
[56] | 960 | } |
---|
[189] | 961 | else if (eMode == SIZE_Nx2N) |
---|
| 962 | { |
---|
| 963 | m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 )); |
---|
| 964 | if (uiSymbol == 0) |
---|
| 965 | { |
---|
| 966 | m_pcTDecBinIf->decodeBinEP(uiSymbol); |
---|
| 967 | eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); |
---|
| 968 | } |
---|
[2] | 969 | } |
---|
| 970 | } |
---|
[608] | 971 | #if H_MV_ENC_DEC_TRAC |
---|
| 972 | DTRACE_CU("part_mode", eMode ) |
---|
| 973 | #endif |
---|
| 974 | #if H_3D_QTLPC |
---|
[2] | 975 | } |
---|
[189] | 976 | #endif |
---|
[2] | 977 | } |
---|
| 978 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
| 979 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 980 | } |
---|
| 981 | |
---|
| 982 | /** parse prediction mode |
---|
| 983 | * \param pcCU |
---|
| 984 | * \param uiAbsPartIdx |
---|
| 985 | * \param uiDepth |
---|
| 986 | * \returns Void |
---|
| 987 | */ |
---|
| 988 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 989 | { |
---|
| 990 | if( pcCU->getSlice()->isIntra() ) |
---|
| 991 | { |
---|
| 992 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
| 993 | return; |
---|
| 994 | } |
---|
| 995 | |
---|
| 996 | UInt uiSymbol; |
---|
| 997 | Int iPredMode = MODE_INTER; |
---|
[56] | 998 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) ); |
---|
[2] | 999 | iPredMode += uiSymbol; |
---|
[608] | 1000 | #if H_MV_ENC_DEC_TRAC |
---|
| 1001 | DTRACE_CU("pred_mode_flag", uiSymbol) |
---|
| 1002 | #endif |
---|
[2] | 1003 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
| 1004 | } |
---|
[608] | 1005 | |
---|
| 1006 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
[443] | 1007 | { |
---|
[608] | 1008 | PartSize mode = pcCU->getPartitionSize( absPartIdx ); |
---|
| 1009 | UInt partNum = mode==SIZE_NxN?4:1; |
---|
| 1010 | UInt partOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; |
---|
| 1011 | UInt mpmPred[4],symbol; |
---|
| 1012 | Int j,intraPredMode; |
---|
| 1013 | if (mode==SIZE_NxN) |
---|
[443] | 1014 | { |
---|
[608] | 1015 | depth++; |
---|
[443] | 1016 | } |
---|
[608] | 1017 | for (j=0;j<partNum;j++) |
---|
[443] | 1018 | { |
---|
[608] | 1019 | #if H_3D_DIM |
---|
| 1020 | if( pcCU->getSlice()->getVpsDepthModesFlag() ) |
---|
[443] | 1021 | { |
---|
[608] | 1022 | parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth ); |
---|
[443] | 1023 | } |
---|
[608] | 1024 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
| 1025 | #if H_3D_DIM_SDC |
---|
| 1026 | if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) |
---|
| 1027 | #endif |
---|
| 1028 | { |
---|
| 1029 | #endif |
---|
| 1030 | m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
| 1031 | mpmPred[j] = symbol; |
---|
| 1032 | #if H_MV_ENC_DEC_TRAC |
---|
| 1033 | DTRACE_CU("prev_intra_luma_pred_flag", symbol) |
---|
| 1034 | #endif |
---|
| 1035 | #if H_3D_DIM |
---|
| 1036 | } |
---|
| 1037 | #endif |
---|
[443] | 1038 | } |
---|
[608] | 1039 | for (j=0;j<partNum;j++) |
---|
[443] | 1040 | { |
---|
[608] | 1041 | #if H_3D_DIM |
---|
| 1042 | if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) |
---|
| 1043 | #if H_3D_DIM_SDC |
---|
| 1044 | if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) |
---|
| 1045 | #endif |
---|
[443] | 1046 | { |
---|
[608] | 1047 | #endif |
---|
| 1048 | Int preds[3] = {-1, -1, -1}; |
---|
| 1049 | Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds); |
---|
| 1050 | if (mpmPred[j]) |
---|
| 1051 | { |
---|
| 1052 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
| 1053 | if (symbol) |
---|
| 1054 | { |
---|
| 1055 | m_pcTDecBinIf->decodeBinEP( symbol ); |
---|
| 1056 | symbol++; |
---|
[443] | 1057 | } |
---|
[608] | 1058 | #if H_MV_ENC_DEC_TRAC |
---|
| 1059 | DTRACE_CU("mpm_idx", symbol) |
---|
| 1060 | #endif |
---|
| 1061 | intraPredMode = preds[symbol]; |
---|
[443] | 1062 | } |
---|
| 1063 | else |
---|
| 1064 | { |
---|
[608] | 1065 | m_pcTDecBinIf->decodeBinsEP( symbol, 5 ); |
---|
| 1066 | intraPredMode = symbol; |
---|
| 1067 | #if H_MV_ENC_DEC_TRAC |
---|
| 1068 | DTRACE_CU("rem_intra_luma_pred_mode", symbol) |
---|
| 1069 | #endif |
---|
| 1070 | //postponed sorting of MPMs (only in remaining branch) |
---|
| 1071 | if (preds[0] > preds[1]) |
---|
[443] | 1072 | { |
---|
[608] | 1073 | std::swap(preds[0], preds[1]); |
---|
[443] | 1074 | } |
---|
[608] | 1075 | if (preds[0] > preds[2]) |
---|
[443] | 1076 | { |
---|
[608] | 1077 | std::swap(preds[0], preds[2]); |
---|
[443] | 1078 | } |
---|
[608] | 1079 | if (preds[1] > preds[2]) |
---|
| 1080 | { |
---|
| 1081 | std::swap(preds[1], preds[2]); |
---|
| 1082 | } |
---|
| 1083 | for ( Int i = 0; i < predNum; i++ ) |
---|
| 1084 | { |
---|
| 1085 | intraPredMode += ( intraPredMode >= preds[i] ); |
---|
| 1086 | } |
---|
[443] | 1087 | } |
---|
[608] | 1088 | pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); |
---|
| 1089 | #if H_3D_DIM |
---|
| 1090 | } |
---|
| 1091 | #endif |
---|
[443] | 1092 | } |
---|
| 1093 | } |
---|
[608] | 1094 | |
---|
| 1095 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[443] | 1096 | { |
---|
[608] | 1097 | UInt uiSymbol; |
---|
| 1098 | |
---|
| 1099 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); |
---|
| 1100 | |
---|
| 1101 | if( uiSymbol == 0 ) |
---|
[443] | 1102 | { |
---|
[608] | 1103 | #if H_MV_ENC_DEC_TRAC |
---|
| 1104 | DTRACE_CU("intra_chroma_pred_mode", uiSymbol ) |
---|
| 1105 | #endif |
---|
| 1106 | uiSymbol = DM_CHROMA_IDX; |
---|
[443] | 1107 | } |
---|
[608] | 1108 | else |
---|
[443] | 1109 | { |
---|
[608] | 1110 | { |
---|
| 1111 | UInt uiIPredMode; |
---|
| 1112 | m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); |
---|
| 1113 | #if H_MV_ENC_DEC_TRAC |
---|
| 1114 | DTRACE_CU("intra_chroma_pred_mode", uiIPredMode ) |
---|
| 1115 | #endif |
---|
| 1116 | UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; |
---|
| 1117 | pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); |
---|
| 1118 | uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; |
---|
| 1119 | } |
---|
[443] | 1120 | } |
---|
[608] | 1121 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
| 1122 | return; |
---|
| 1123 | } |
---|
| 1124 | |
---|
| 1125 | #if H_3D_DIM |
---|
| 1126 | Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
| 1127 | { |
---|
| 1128 | parseIntraDepthMode( pcCU, absPartIdx, depth ); |
---|
| 1129 | |
---|
| 1130 | UInt dir = pcCU->getLumaIntraDir( absPartIdx ); |
---|
| 1131 | UInt dimType = getDimType( dir ); |
---|
| 1132 | |
---|
| 1133 | switch( dimType ) |
---|
[443] | 1134 | { |
---|
[608] | 1135 | #if H_3D_DIM_DMM |
---|
| 1136 | case( DMM1_IDX ): |
---|
[443] | 1137 | { |
---|
[608] | 1138 | UInt uiTabIdx = 0; |
---|
| 1139 | xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); |
---|
| 1140 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth ); |
---|
| 1141 | } break; |
---|
| 1142 | case( DMM3_IDX ): |
---|
| 1143 | { |
---|
| 1144 | UInt uiIntraIdx = 0; |
---|
| 1145 | xParseDmm3WedgeIdx( uiIntraIdx, g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); |
---|
| 1146 | pcCU->setDmm3IntraTabIdxSubParts( uiIntraIdx, absPartIdx, depth ); |
---|
| 1147 | } break; |
---|
| 1148 | case( DMM4_IDX ): break; |
---|
| 1149 | #endif |
---|
| 1150 | #if H_3D_DIM_RBC |
---|
| 1151 | case( RBC_IDX ): |
---|
| 1152 | { |
---|
| 1153 | xParseRbcEdge( pcCU, absPartIdx, depth ); |
---|
| 1154 | } break; |
---|
| 1155 | #endif |
---|
| 1156 | default: break; |
---|
| 1157 | } |
---|
[443] | 1158 | |
---|
[608] | 1159 | #if H_3D_DIM_SDC |
---|
| 1160 | if( pcCU->getSDCFlag(absPartIdx) ) |
---|
| 1161 | { |
---|
| 1162 | assert(pcCU->getPartitionSize(absPartIdx)==SIZE_2Nx2N); |
---|
| 1163 | pcCU->setTrIdxSubParts(0, absPartIdx, depth); |
---|
| 1164 | pcCU->setCbfSubParts(1, 1, 1, absPartIdx, depth); |
---|
| 1165 | |
---|
| 1166 | UInt uiNumSegments = ( dir == DC_IDX || dir == PLANAR_IDX )? 1 : 2; |
---|
| 1167 | for (UInt uiSeg=0; uiSeg<uiNumSegments; uiSeg++) |
---|
| 1168 | { |
---|
| 1169 | xParseSDCResidualData(pcCU, absPartIdx, depth, uiSeg); |
---|
[443] | 1170 | } |
---|
| 1171 | } |
---|
[608] | 1172 | else |
---|
[443] | 1173 | { |
---|
[608] | 1174 | #endif |
---|
| 1175 | if( dimType < DIM_NUM_TYPE ) |
---|
[443] | 1176 | { |
---|
[608] | 1177 | UInt symbol; |
---|
| 1178 | m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); |
---|
| 1179 | if( symbol ) |
---|
[443] | 1180 | { |
---|
[608] | 1181 | dir += symbol; |
---|
| 1182 | for( UInt segment = 0; segment < 2; segment++ ) |
---|
[443] | 1183 | { |
---|
[608] | 1184 | Pel valDeltaDC = 0; |
---|
| 1185 | xParseDimDeltaDC( valDeltaDC, dimType ); |
---|
| 1186 | pcCU->setDimDeltaDC( dimType, segment, absPartIdx, valDeltaDC ); |
---|
[443] | 1187 | } |
---|
| 1188 | } |
---|
| 1189 | } |
---|
[608] | 1190 | #if H_3D_DIM_SDC |
---|
[443] | 1191 | } |
---|
[608] | 1192 | #endif |
---|
[443] | 1193 | |
---|
[608] | 1194 | pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); |
---|
| 1195 | } |
---|
[443] | 1196 | |
---|
[608] | 1197 | Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) |
---|
[2] | 1198 | { |
---|
[608] | 1199 | UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 ); |
---|
| 1200 | UInt dir = 0; |
---|
| 1201 | Bool sdcFlag = 0; |
---|
| 1202 | UInt symbol = 1; |
---|
| 1203 | UInt modeCode = 0 ; |
---|
| 1204 | UInt binNum = 0; |
---|
| 1205 | UInt ctxDepthMode = 0; |
---|
| 1206 | |
---|
| 1207 | if( puIdx == 2 ) |
---|
[443] | 1208 | { |
---|
[608] | 1209 | { |
---|
| 1210 | ctxDepthMode = puIdx*3 + binNum; |
---|
| 1211 | m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); |
---|
| 1212 | modeCode = (modeCode<<1) + symbol; |
---|
| 1213 | binNum++; |
---|
| 1214 | } |
---|
| 1215 | if( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;} |
---|
| 1216 | else if( modeCode == 1 ) { dir = 0; sdcFlag = 0;} |
---|
[2] | 1217 | } |
---|
[608] | 1218 | else if( puIdx == 0 ) |
---|
[2] | 1219 | { |
---|
[608] | 1220 | while( binNum < 3 && symbol ) |
---|
[2] | 1221 | { |
---|
[608] | 1222 | ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum); |
---|
| 1223 | m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); |
---|
| 1224 | modeCode = (modeCode<<1) + symbol; |
---|
| 1225 | binNum++; |
---|
[2] | 1226 | } |
---|
[608] | 1227 | if( modeCode == 0 ) { dir = 0; sdcFlag = 0;} |
---|
| 1228 | else if( modeCode == 2 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
| 1229 | else if( modeCode == 6 ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
| 1230 | else if( modeCode == 7 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
[2] | 1231 | } |
---|
| 1232 | else |
---|
| 1233 | { |
---|
[655] | 1234 | UInt maxBinNum = 0; |
---|
| 1235 | m_pcTDecBinIf->decodeBinEP(symbol); |
---|
| 1236 | if( symbol == 1 ) |
---|
[608] | 1237 | { |
---|
[655] | 1238 | maxBinNum = 3; |
---|
[608] | 1239 | } |
---|
| 1240 | else |
---|
| 1241 | { |
---|
[655] | 1242 | maxBinNum = 2; |
---|
| 1243 | symbol = 1; |
---|
[608] | 1244 | } |
---|
[655] | 1245 | while( binNum<maxBinNum && symbol ) |
---|
| 1246 | { |
---|
| 1247 | ctxDepthMode = puIdx*3 + ( binNum >= 2 ? 2 : binNum ); |
---|
| 1248 | m_pcTDecBinIf->decodeBin(symbol,m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode)); |
---|
| 1249 | modeCode = (modeCode<<1)+symbol; |
---|
| 1250 | binNum++; |
---|
| 1251 | } |
---|
| 1252 | if( maxBinNum == 3 ) |
---|
| 1253 | { |
---|
| 1254 | if ( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;} |
---|
| 1255 | else if ( modeCode == 2 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
| 1256 | else if ( modeCode == 6 ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
| 1257 | else if ( modeCode == 7 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
| 1258 | } |
---|
| 1259 | else |
---|
| 1260 | { |
---|
| 1261 | if ( modeCode == 0 ) { dir = 5; sdcFlag = 0;} |
---|
| 1262 | else if ( modeCode == 2 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;} |
---|
| 1263 | else if ( modeCode == 3 ) { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;} |
---|
| 1264 | } |
---|
[56] | 1265 | } |
---|
[608] | 1266 | pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); |
---|
| 1267 | #if H_3D_DIM_SDC |
---|
| 1268 | pcCU->setSDCFlagSubParts( sdcFlag, absPartIdx, depth ); |
---|
[2] | 1269 | #endif |
---|
[56] | 1270 | } |
---|
[443] | 1271 | #endif |
---|
[2] | 1272 | |
---|
[608] | 1273 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) |
---|
[2] | 1274 | { |
---|
| 1275 | UInt uiSymbol; |
---|
[608] | 1276 | const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
| 1277 | ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); |
---|
| 1278 | uiSymbol = 0; |
---|
| 1279 | if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) |
---|
[2] | 1280 | { |
---|
[608] | 1281 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) ); |
---|
[2] | 1282 | } |
---|
| 1283 | |
---|
[56] | 1284 | if( uiSymbol ) |
---|
[2] | 1285 | { |
---|
| 1286 | uiSymbol = 2; |
---|
| 1287 | } |
---|
[608] | 1288 | else |
---|
| 1289 | { |
---|
| 1290 | m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) ); |
---|
| 1291 | assert(uiSymbol == 0 || uiSymbol == 1); |
---|
| 1292 | } |
---|
[56] | 1293 | |
---|
[2] | 1294 | uiSymbol++; |
---|
| 1295 | ruiInterDir = uiSymbol; |
---|
[608] | 1296 | #if H_MV_ENC_DEC_TRAC |
---|
| 1297 | DTRACE_PU("inter_pred_idc", ruiInterDir - 1 ) |
---|
| 1298 | #endif |
---|
| 1299 | |
---|
[2] | 1300 | return; |
---|
| 1301 | } |
---|
| 1302 | |
---|
[608] | 1303 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) |
---|
[2] | 1304 | { |
---|
| 1305 | UInt uiSymbol; |
---|
| 1306 | { |
---|
[56] | 1307 | ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); |
---|
| 1308 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
[2] | 1309 | |
---|
[56] | 1310 | if( uiSymbol ) |
---|
[2] | 1311 | { |
---|
[608] | 1312 | UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; |
---|
| 1313 | pCtx++; |
---|
| 1314 | UInt ui; |
---|
| 1315 | for( ui = 0; ui < uiRefNum; ++ui ) |
---|
| 1316 | { |
---|
| 1317 | if( ui == 0 ) |
---|
| 1318 | { |
---|
| 1319 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1320 | } |
---|
| 1321 | else |
---|
| 1322 | { |
---|
| 1323 | m_pcTDecBinIf->decodeBinEP( uiSymbol ); |
---|
| 1324 | } |
---|
| 1325 | if( uiSymbol == 0 ) |
---|
| 1326 | { |
---|
| 1327 | break; |
---|
| 1328 | } |
---|
| 1329 | } |
---|
| 1330 | uiSymbol = ui + 1; |
---|
[2] | 1331 | } |
---|
| 1332 | riRefFrmIdx = uiSymbol; |
---|
| 1333 | } |
---|
[608] | 1334 | |
---|
| 1335 | #if H_MV_ENC_DEC_TRAC |
---|
| 1336 | #if ENC_DEC_TRACE |
---|
| 1337 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
| 1338 | { |
---|
| 1339 | DTRACE_PU("ref_idx_l0", uiSymbol) |
---|
| 1340 | } |
---|
[2] | 1341 | else |
---|
| 1342 | { |
---|
[608] | 1343 | DTRACE_PU("ref_idx_l1", uiSymbol) |
---|
[2] | 1344 | } |
---|
[608] | 1345 | #endif |
---|
| 1346 | #endif |
---|
[2] | 1347 | return; |
---|
| 1348 | } |
---|
| 1349 | |
---|
[56] | 1350 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
[2] | 1351 | { |
---|
| 1352 | UInt uiSymbol; |
---|
[56] | 1353 | UInt uiHorAbs; |
---|
| 1354 | UInt uiVerAbs; |
---|
| 1355 | UInt uiHorSign = 0; |
---|
| 1356 | UInt uiVerSign = 0; |
---|
| 1357 | ContextModel *pCtx = m_cCUMvdSCModel.get( 0 ); |
---|
[2] | 1358 | |
---|
[56] | 1359 | if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3) |
---|
| 1360 | { |
---|
| 1361 | uiHorAbs=0; |
---|
| 1362 | uiVerAbs=0; |
---|
| 1363 | } |
---|
| 1364 | else |
---|
| 1365 | { |
---|
| 1366 | m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx ); |
---|
| 1367 | m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx ); |
---|
[2] | 1368 | |
---|
[56] | 1369 | const Bool bHorAbsGr0 = uiHorAbs != 0; |
---|
| 1370 | const Bool bVerAbsGr0 = uiVerAbs != 0; |
---|
| 1371 | pCtx++; |
---|
| 1372 | |
---|
| 1373 | if( bHorAbsGr0 ) |
---|
| 1374 | { |
---|
| 1375 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1376 | uiHorAbs += uiSymbol; |
---|
| 1377 | } |
---|
| 1378 | |
---|
| 1379 | if( bVerAbsGr0 ) |
---|
| 1380 | { |
---|
| 1381 | m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); |
---|
| 1382 | uiVerAbs += uiSymbol; |
---|
| 1383 | } |
---|
| 1384 | |
---|
| 1385 | if( bHorAbsGr0 ) |
---|
| 1386 | { |
---|
| 1387 | if( 2 == uiHorAbs ) |
---|
| 1388 | { |
---|
| 1389 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 1390 | uiHorAbs += uiSymbol; |
---|
| 1391 | } |
---|
| 1392 | |
---|
| 1393 | m_pcTDecBinIf->decodeBinEP( uiHorSign ); |
---|
| 1394 | } |
---|
| 1395 | |
---|
| 1396 | if( bVerAbsGr0 ) |
---|
| 1397 | { |
---|
| 1398 | if( 2 == uiVerAbs ) |
---|
| 1399 | { |
---|
| 1400 | xReadEpExGolomb( uiSymbol, 1 ); |
---|
| 1401 | uiVerAbs += uiSymbol; |
---|
| 1402 | } |
---|
| 1403 | |
---|
| 1404 | m_pcTDecBinIf->decodeBinEP( uiVerSign ); |
---|
| 1405 | } |
---|
| 1406 | |
---|
| 1407 | } |
---|
[2] | 1408 | |
---|
[56] | 1409 | const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs ); |
---|
| 1410 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 1411 | return; |
---|
| 1412 | } |
---|
| 1413 | |
---|
| 1414 | |
---|
| 1415 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
| 1416 | { |
---|
| 1417 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
[608] | 1418 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 1419 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1420 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
| 1421 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1422 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
| 1423 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1424 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
| 1425 | DTRACE_CABAC_T( "\n" ) |
---|
[608] | 1426 | #endif |
---|
[2] | 1427 | } |
---|
| 1428 | |
---|
[608] | 1429 | Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) |
---|
[2] | 1430 | { |
---|
| 1431 | UInt uiSymbol; |
---|
[56] | 1432 | const UInt uiCtx = 0; |
---|
[2] | 1433 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
[608] | 1434 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 1435 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1436 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
| 1437 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1438 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 1439 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1440 | DTRACE_CABAC_V( uiCtx ) |
---|
| 1441 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1442 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1443 | DTRACE_CABAC_T( "\n" ) |
---|
[608] | 1444 | #else |
---|
| 1445 | DTRACE_CU( "rqt_root_cbf", uiSymbol ) |
---|
| 1446 | #endif |
---|
[2] | 1447 | |
---|
| 1448 | uiQtRootCbf = uiSymbol; |
---|
| 1449 | } |
---|
| 1450 | |
---|
| 1451 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1452 | { |
---|
[56] | 1453 | Int qp; |
---|
[2] | 1454 | UInt uiDQp; |
---|
| 1455 | Int iDQp; |
---|
| 1456 | |
---|
[608] | 1457 | UInt uiSymbol; |
---|
| 1458 | |
---|
| 1459 | xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX); |
---|
| 1460 | |
---|
| 1461 | if( uiDQp >= CU_DQP_TU_CMAX) |
---|
[2] | 1462 | { |
---|
[608] | 1463 | xReadEpExGolomb( uiSymbol, CU_DQP_EG_k ); |
---|
| 1464 | uiDQp+=uiSymbol; |
---|
[2] | 1465 | } |
---|
[608] | 1466 | |
---|
| 1467 | if ( uiDQp > 0 ) |
---|
[2] | 1468 | { |
---|
[56] | 1469 | UInt uiSign; |
---|
| 1470 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1471 | m_pcTDecBinIf->decodeBinEP(uiSign); |
---|
[608] | 1472 | iDQp = uiDQp; |
---|
[56] | 1473 | if(uiSign) |
---|
[2] | 1474 | { |
---|
| 1475 | iDQp = -iDQp; |
---|
| 1476 | } |
---|
[56] | 1477 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; |
---|
[2] | 1478 | } |
---|
[608] | 1479 | else |
---|
| 1480 | { |
---|
| 1481 | qp = pcCU->getRefQP(uiAbsPartIdx); |
---|
| 1482 | } |
---|
| 1483 | pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); |
---|
| 1484 | pcCU->setCodedQP(qp); |
---|
[2] | 1485 | } |
---|
| 1486 | |
---|
| 1487 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
| 1488 | { |
---|
| 1489 | UInt uiSymbol; |
---|
[608] | 1490 | const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); |
---|
[56] | 1491 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); |
---|
[608] | 1492 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 1493 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1494 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
| 1495 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1496 | DTRACE_CABAC_V( uiSymbol ) |
---|
| 1497 | DTRACE_CABAC_T( "\tctx=" ) |
---|
| 1498 | DTRACE_CABAC_V( uiCtx ) |
---|
| 1499 | DTRACE_CABAC_T( "\tetype=" ) |
---|
| 1500 | DTRACE_CABAC_V( eType ) |
---|
| 1501 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1502 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1503 | DTRACE_CABAC_T( "\n" ) |
---|
[608] | 1504 | #endif |
---|
[2] | 1505 | |
---|
| 1506 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
| 1507 | } |
---|
| 1508 | |
---|
[608] | 1509 | void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) |
---|
| 1510 | { |
---|
| 1511 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
| 1512 | { |
---|
| 1513 | return; |
---|
| 1514 | } |
---|
| 1515 | if(width != 4 || height != 4) |
---|
| 1516 | { |
---|
| 1517 | return; |
---|
| 1518 | } |
---|
| 1519 | |
---|
| 1520 | UInt useTransformSkip; |
---|
| 1521 | m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); |
---|
| 1522 | if(eTType!= TEXT_LUMA) |
---|
| 1523 | { |
---|
| 1524 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; |
---|
| 1525 | if(uiLog2TrafoSize == 2) |
---|
| 1526 | { |
---|
| 1527 | uiDepth --; |
---|
| 1528 | } |
---|
| 1529 | } |
---|
| 1530 | #if !H_MV_ENC_DEC_TRAC |
---|
| 1531 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
| 1532 | DTRACE_CABAC_T("\tparseTransformSkip()"); |
---|
| 1533 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
| 1534 | DTRACE_CABAC_V( useTransformSkip ) |
---|
| 1535 | DTRACE_CABAC_T( "\tAddr=" ) |
---|
| 1536 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
| 1537 | DTRACE_CABAC_T( "\tetype=" ) |
---|
| 1538 | DTRACE_CABAC_V( eTType ) |
---|
| 1539 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
| 1540 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1541 | DTRACE_CABAC_T( "\n" ) |
---|
| 1542 | #endif |
---|
| 1543 | |
---|
| 1544 | pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); |
---|
| 1545 | } |
---|
| 1546 | |
---|
[2] | 1547 | /** Parse (X,Y) position of the last significant coefficient |
---|
| 1548 | * \param uiPosLastX reference to X component of last coefficient |
---|
| 1549 | * \param uiPosLastY reference to Y component of last coefficient |
---|
[56] | 1550 | * \param width Block width |
---|
| 1551 | * \param height Block height |
---|
[2] | 1552 | * \param eTType plane type / luminance or chrominance |
---|
| 1553 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
[56] | 1554 | * |
---|
[2] | 1555 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
| 1556 | */ |
---|
[56] | 1557 | Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ) |
---|
[2] | 1558 | { |
---|
| 1559 | UInt uiLast; |
---|
[56] | 1560 | ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); |
---|
| 1561 | ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); |
---|
[2] | 1562 | |
---|
[608] | 1563 | Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; |
---|
| 1564 | blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2)); |
---|
| 1565 | blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); |
---|
| 1566 | shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2); |
---|
| 1567 | shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); |
---|
[56] | 1568 | // posX |
---|
| 1569 | for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) |
---|
[2] | 1570 | { |
---|
[608] | 1571 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) ); |
---|
[56] | 1572 | if( !uiLast ) |
---|
| 1573 | { |
---|
[2] | 1574 | break; |
---|
| 1575 | } |
---|
| 1576 | } |
---|
| 1577 | |
---|
[56] | 1578 | // posY |
---|
| 1579 | for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) |
---|
[2] | 1580 | { |
---|
[608] | 1581 | m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) ); |
---|
[56] | 1582 | if( !uiLast ) |
---|
| 1583 | { |
---|
[2] | 1584 | break; |
---|
| 1585 | } |
---|
| 1586 | } |
---|
[56] | 1587 | if ( uiPosLastX > 3 ) |
---|
| 1588 | { |
---|
| 1589 | UInt uiTemp = 0; |
---|
| 1590 | UInt uiCount = ( uiPosLastX - 2 ) >> 1; |
---|
| 1591 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1592 | { |
---|
| 1593 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1594 | uiTemp += uiLast << i; |
---|
| 1595 | } |
---|
| 1596 | uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp; |
---|
| 1597 | } |
---|
| 1598 | if ( uiPosLastY > 3 ) |
---|
| 1599 | { |
---|
| 1600 | UInt uiTemp = 0; |
---|
| 1601 | UInt uiCount = ( uiPosLastY - 2 ) >> 1; |
---|
| 1602 | for ( Int i = uiCount - 1; i >= 0; i-- ) |
---|
| 1603 | { |
---|
| 1604 | m_pcTDecBinIf->decodeBinEP( uiLast ); |
---|
| 1605 | uiTemp += uiLast << i; |
---|
| 1606 | } |
---|
| 1607 | uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; |
---|
| 1608 | } |
---|
| 1609 | |
---|
[2] | 1610 | if( uiScanIdx == SCAN_VER ) |
---|
| 1611 | { |
---|
| 1612 | swap( uiPosLastX, uiPosLastY ); |
---|
| 1613 | } |
---|
| 1614 | } |
---|
| 1615 | |
---|
| 1616 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1617 | { |
---|
[608] | 1618 | #if !H_MV_ENC_DEC_TRAC |
---|
[56] | 1619 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 1620 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
| 1621 | DTRACE_CABAC_V( eTType ) |
---|
| 1622 | DTRACE_CABAC_T( "\twidth=" ) |
---|
| 1623 | DTRACE_CABAC_V( uiWidth ) |
---|
| 1624 | DTRACE_CABAC_T( "\theight=" ) |
---|
| 1625 | DTRACE_CABAC_V( uiHeight ) |
---|
| 1626 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
| 1627 | DTRACE_CABAC_V( uiDepth ) |
---|
| 1628 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
| 1629 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
| 1630 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
| 1631 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
| 1632 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
| 1633 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
| 1634 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
| 1635 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
| 1636 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
| 1637 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1638 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
| 1639 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
| 1640 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
| 1641 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
| 1642 | DTRACE_CABAC_T( "\n" ) |
---|
[608] | 1643 | #endif |
---|
[2] | 1644 | |
---|
| 1645 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
| 1646 | { |
---|
| 1647 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1648 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
| 1649 | } |
---|
[608] | 1650 | if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) |
---|
| 1651 | { |
---|
| 1652 | parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType); |
---|
| 1653 | } |
---|
| 1654 | |
---|
[2] | 1655 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
| 1656 | |
---|
| 1657 | //----- parse significance map ----- |
---|
| 1658 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
[56] | 1659 | const UInt uiMaxNumCoeff = uiWidth * uiHeight; |
---|
[2] | 1660 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
[56] | 1661 | UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
[2] | 1662 | |
---|
[56] | 1663 | //===== decode last significant ===== |
---|
| 1664 | UInt uiPosLastX, uiPosLastY; |
---|
| 1665 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx ); |
---|
| 1666 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
| 1667 | pcCoef[ uiBlkPosLast ] = 1; |
---|
[2] | 1668 | |
---|
[56] | 1669 | //===== decode significance flags ===== |
---|
[608] | 1670 | UInt uiScanPosLast; |
---|
| 1671 | const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ]; |
---|
[56] | 1672 | for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) |
---|
| 1673 | { |
---|
| 1674 | UInt uiBlkPos = scan[ uiScanPosLast ]; |
---|
| 1675 | if( uiBlkPosLast == uiBlkPos ) |
---|
[2] | 1676 | { |
---|
[56] | 1677 | break; |
---|
[2] | 1678 | } |
---|
[56] | 1679 | } |
---|
[2] | 1680 | |
---|
[56] | 1681 | ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); |
---|
| 1682 | ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; |
---|
| 1683 | |
---|
| 1684 | const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; |
---|
[608] | 1685 | UInt c1 = 1; |
---|
[56] | 1686 | UInt uiGoRiceParam = 0; |
---|
| 1687 | |
---|
| 1688 | Bool beValid; |
---|
[608] | 1689 | if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) |
---|
[2] | 1690 | { |
---|
[56] | 1691 | beValid = false; |
---|
| 1692 | } |
---|
| 1693 | else |
---|
| 1694 | { |
---|
| 1695 | beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; |
---|
| 1696 | } |
---|
| 1697 | UInt absSum = 0; |
---|
| 1698 | |
---|
| 1699 | UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; |
---|
| 1700 | ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); |
---|
| 1701 | const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); |
---|
| 1702 | const UInt * scanCG; |
---|
| 1703 | { |
---|
| 1704 | scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; |
---|
| 1705 | if( uiLog2BlockSize == 3 ) |
---|
[2] | 1706 | { |
---|
[56] | 1707 | scanCG = g_sigLastScan8x8[ uiScanIdx ]; |
---|
[2] | 1708 | } |
---|
[56] | 1709 | else if( uiLog2BlockSize == 5 ) |
---|
| 1710 | { |
---|
| 1711 | scanCG = g_sigLastScanCG32x32; |
---|
| 1712 | } |
---|
[2] | 1713 | } |
---|
[56] | 1714 | Int iScanPosSig = (Int) uiScanPosLast; |
---|
| 1715 | for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) |
---|
| 1716 | { |
---|
| 1717 | Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; |
---|
| 1718 | uiGoRiceParam = 0; |
---|
| 1719 | Int numNonZero = 0; |
---|
| 1720 | |
---|
| 1721 | Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; |
---|
| 1722 | |
---|
| 1723 | Int pos[SCAN_SET_SIZE]; |
---|
| 1724 | if( iScanPosSig == (Int) uiScanPosLast ) |
---|
| 1725 | { |
---|
| 1726 | lastNZPosInCG = iScanPosSig; |
---|
| 1727 | firstNZPosInCG = iScanPosSig; |
---|
| 1728 | iScanPosSig--; |
---|
| 1729 | pos[ numNonZero ] = uiBlkPosLast; |
---|
| 1730 | numNonZero = 1; |
---|
| 1731 | } |
---|
[2] | 1732 | |
---|
[608] | 1733 | // decode significant_coeffgroup_flag |
---|
| 1734 | Int iCGBlkPos = scanCG[ iSubSet ]; |
---|
| 1735 | Int iCGPosY = iCGBlkPos / uiNumBlkSide; |
---|
| 1736 | Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); |
---|
| 1737 | if( iSubSet == iLastScanSet || iSubSet == 0) |
---|
| 1738 | { |
---|
| 1739 | uiSigCoeffGroupFlag[ iCGBlkPos ] = 1; |
---|
| 1740 | } |
---|
| 1741 | else |
---|
| 1742 | { |
---|
| 1743 | UInt uiSigCoeffGroup; |
---|
| 1744 | UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
| 1745 | m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] ); |
---|
| 1746 | uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; |
---|
| 1747 | } |
---|
[56] | 1748 | |
---|
[608] | 1749 | // decode significant_coeff_flag |
---|
| 1750 | Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); |
---|
| 1751 | UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; |
---|
| 1752 | for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) |
---|
| 1753 | { |
---|
| 1754 | uiBlkPos = scan[ iScanPosSig ]; |
---|
| 1755 | uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
| 1756 | uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
| 1757 | uiSig = 0; |
---|
| 1758 | |
---|
| 1759 | if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) |
---|
[56] | 1760 | { |
---|
[608] | 1761 | if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) |
---|
[2] | 1762 | { |
---|
[608] | 1763 | uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType ); |
---|
| 1764 | m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] ); |
---|
[2] | 1765 | } |
---|
[608] | 1766 | else |
---|
[2] | 1767 | { |
---|
[608] | 1768 | uiSig = 1; |
---|
[2] | 1769 | } |
---|
[56] | 1770 | } |
---|
[608] | 1771 | pcCoef[ uiBlkPos ] = uiSig; |
---|
| 1772 | if( uiSig ) |
---|
| 1773 | { |
---|
| 1774 | pos[ numNonZero ] = uiBlkPos; |
---|
| 1775 | numNonZero ++; |
---|
| 1776 | if( lastNZPosInCG == -1 ) |
---|
| 1777 | { |
---|
| 1778 | lastNZPosInCG = iScanPosSig; |
---|
| 1779 | } |
---|
| 1780 | firstNZPosInCG = iScanPosSig; |
---|
| 1781 | } |
---|
| 1782 | } |
---|
[2] | 1783 | |
---|
[56] | 1784 | if( numNonZero ) |
---|
[2] | 1785 | { |
---|
[608] | 1786 | Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); |
---|
[56] | 1787 | absSum = 0; |
---|
| 1788 | UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; |
---|
| 1789 | UInt uiBin; |
---|
[608] | 1790 | if( c1 == 0 ) |
---|
[2] | 1791 | { |
---|
[56] | 1792 | uiCtxSet++; |
---|
| 1793 | } |
---|
[608] | 1794 | c1 = 1; |
---|
[56] | 1795 | ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; |
---|
| 1796 | Int absCoeff[SCAN_SET_SIZE]; |
---|
| 1797 | |
---|
| 1798 | for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; |
---|
| 1799 | Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); |
---|
| 1800 | Int firstC2FlagIdx = -1; |
---|
| 1801 | |
---|
| 1802 | for( Int idx = 0; idx < numC1Flag; idx++ ) |
---|
| 1803 | { |
---|
| 1804 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] ); |
---|
| 1805 | if( uiBin == 1 ) |
---|
[2] | 1806 | { |
---|
[56] | 1807 | c1 = 0; |
---|
| 1808 | if (firstC2FlagIdx == -1) |
---|
| 1809 | { |
---|
| 1810 | firstC2FlagIdx = idx; |
---|
| 1811 | } |
---|
| 1812 | } |
---|
| 1813 | else if( (c1 < 3) && (c1 > 0) ) |
---|
| 1814 | { |
---|
[2] | 1815 | c1++; |
---|
| 1816 | } |
---|
[56] | 1817 | absCoeff[ idx ] = uiBin + 1; |
---|
| 1818 | } |
---|
| 1819 | |
---|
| 1820 | if (c1 == 0) |
---|
| 1821 | { |
---|
| 1822 | baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet; |
---|
| 1823 | if ( firstC2FlagIdx != -1) |
---|
[2] | 1824 | { |
---|
[56] | 1825 | m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); |
---|
| 1826 | absCoeff[ firstC2FlagIdx ] = uiBin + 2; |
---|
[2] | 1827 | } |
---|
| 1828 | } |
---|
[56] | 1829 | |
---|
| 1830 | UInt coeffSigns; |
---|
| 1831 | if ( signHidden && beValid ) |
---|
| 1832 | { |
---|
| 1833 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 ); |
---|
| 1834 | coeffSigns <<= 32 - (numNonZero-1); |
---|
| 1835 | } |
---|
| 1836 | else |
---|
| 1837 | { |
---|
| 1838 | m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero ); |
---|
| 1839 | coeffSigns <<= 32 - numNonZero; |
---|
| 1840 | } |
---|
[2] | 1841 | |
---|
[56] | 1842 | Int iFirstCoeff2 = 1; |
---|
| 1843 | if (c1 == 0 || numNonZero > C1FLAG_NUMBER) |
---|
[2] | 1844 | { |
---|
[56] | 1845 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
[2] | 1846 | { |
---|
[56] | 1847 | UInt baseLevel = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1; |
---|
[2] | 1848 | |
---|
[56] | 1849 | if( absCoeff[ idx ] == baseLevel) |
---|
[2] | 1850 | { |
---|
[56] | 1851 | UInt uiLevel; |
---|
[608] | 1852 | xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam ); |
---|
[56] | 1853 | absCoeff[ idx ] = uiLevel + baseLevel; |
---|
[608] | 1854 | if(absCoeff[idx]>3*(1<<uiGoRiceParam)) |
---|
| 1855 | { |
---|
| 1856 | uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); |
---|
| 1857 | } |
---|
[2] | 1858 | } |
---|
[56] | 1859 | |
---|
| 1860 | if(absCoeff[ idx ] >= 2) |
---|
[2] | 1861 | { |
---|
[56] | 1862 | iFirstCoeff2 = 0; |
---|
[2] | 1863 | } |
---|
| 1864 | } |
---|
| 1865 | } |
---|
[56] | 1866 | |
---|
| 1867 | for( Int idx = 0; idx < numNonZero; idx++ ) |
---|
[2] | 1868 | { |
---|
[56] | 1869 | Int blkPos = pos[ idx ]; |
---|
| 1870 | // Signs applied later. |
---|
| 1871 | pcCoef[ blkPos ] = absCoeff[ idx ]; |
---|
| 1872 | absSum += absCoeff[ idx ]; |
---|
| 1873 | |
---|
| 1874 | if ( idx == numNonZero-1 && signHidden && beValid ) |
---|
| 1875 | { |
---|
| 1876 | // Infer sign of 1st element. |
---|
| 1877 | if (absSum&0x1) |
---|
[608] | 1878 | { |
---|
[56] | 1879 | pcCoef[ blkPos ] = -pcCoef[ blkPos ]; |
---|
[608] | 1880 | } |
---|
[56] | 1881 | } |
---|
| 1882 | else |
---|
| 1883 | { |
---|
| 1884 | Int sign = static_cast<Int>( coeffSigns ) >> 31; |
---|
| 1885 | pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign; |
---|
| 1886 | coeffSigns <<= 1; |
---|
| 1887 | } |
---|
[2] | 1888 | } |
---|
| 1889 | } |
---|
| 1890 | } |
---|
| 1891 | |
---|
| 1892 | return; |
---|
| 1893 | } |
---|
| 1894 | |
---|
[608] | 1895 | |
---|
[443] | 1896 | Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) |
---|
| 1897 | { |
---|
[608] | 1898 | if (maxSymbol == 0) |
---|
[2] | 1899 | { |
---|
[608] | 1900 | val = 0; |
---|
[2] | 1901 | return; |
---|
| 1902 | } |
---|
[56] | 1903 | |
---|
[608] | 1904 | UInt code; |
---|
[2] | 1905 | Int i; |
---|
[608] | 1906 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
| 1907 | if ( code == 0 ) |
---|
[2] | 1908 | { |
---|
[608] | 1909 | val = 0; |
---|
[2] | 1910 | return; |
---|
| 1911 | } |
---|
[56] | 1912 | |
---|
[2] | 1913 | i=1; |
---|
| 1914 | while (1) |
---|
| 1915 | { |
---|
[608] | 1916 | m_pcTDecBinIf->decodeBinEP( code ); |
---|
| 1917 | if ( code == 0 ) |
---|
| 1918 | { |
---|
| 1919 | break; |
---|
| 1920 | } |
---|
[2] | 1921 | i++; |
---|
[608] | 1922 | if (i == maxSymbol) |
---|
[56] | 1923 | { |
---|
[608] | 1924 | break; |
---|
[56] | 1925 | } |
---|
| 1926 | } |
---|
[608] | 1927 | |
---|
| 1928 | val = i; |
---|
[2] | 1929 | } |
---|
[608] | 1930 | Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) |
---|
[56] | 1931 | { |
---|
[608] | 1932 | m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); |
---|
[56] | 1933 | } |
---|
[608] | 1934 | Void TDecSbac::parseSaoMerge (UInt& ruiVal) |
---|
[2] | 1935 | { |
---|
| 1936 | UInt uiCode; |
---|
[608] | 1937 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) ); |
---|
[56] | 1938 | ruiVal = (Int)uiCode; |
---|
| 1939 | } |
---|
| 1940 | Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) |
---|
| 1941 | { |
---|
| 1942 | UInt uiCode; |
---|
| 1943 | m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); |
---|
[608] | 1944 | if (uiCode == 0) |
---|
[2] | 1945 | { |
---|
| 1946 | ruiVal = 0; |
---|
| 1947 | } |
---|
[608] | 1948 | else |
---|
[2] | 1949 | { |
---|
[608] | 1950 | m_pcTDecBinIf->decodeBinEP( uiCode ); |
---|
| 1951 | if (uiCode == 0) |
---|
| 1952 | { |
---|
| 1953 | ruiVal = 5; |
---|
| 1954 | } |
---|
| 1955 | else |
---|
| 1956 | { |
---|
| 1957 | ruiVal = 1; |
---|
| 1958 | } |
---|
[2] | 1959 | } |
---|
| 1960 | } |
---|
| 1961 | |
---|
[56] | 1962 | inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) |
---|
[2] | 1963 | { |
---|
[56] | 1964 | Int i; |
---|
| 1965 | psDst->partIdx = psSrc->partIdx; |
---|
| 1966 | psDst->typeIdx = psSrc->typeIdx; |
---|
| 1967 | if (psDst->typeIdx != -1) |
---|
| 1968 | { |
---|
[608] | 1969 | psDst->subTypeIdx = psSrc->subTypeIdx ; |
---|
[56] | 1970 | psDst->length = psSrc->length; |
---|
| 1971 | for (i=0;i<psDst->length;i++) |
---|
| 1972 | { |
---|
| 1973 | psDst->offset[i] = psSrc->offset[i]; |
---|
| 1974 | } |
---|
| 1975 | } |
---|
| 1976 | else |
---|
| 1977 | { |
---|
| 1978 | psDst->length = 0; |
---|
| 1979 | for (i=0;i<SAO_BO_LEN;i++) |
---|
| 1980 | { |
---|
| 1981 | psDst->offset[i] = 0; |
---|
| 1982 | } |
---|
| 1983 | } |
---|
| 1984 | } |
---|
[608] | 1985 | |
---|
| 1986 | Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx) |
---|
[56] | 1987 | { |
---|
| 1988 | UInt uiSymbol; |
---|
[608] | 1989 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = |
---|
| 1990 | { |
---|
[56] | 1991 | SAO_EO_LEN, |
---|
| 1992 | SAO_EO_LEN, |
---|
| 1993 | SAO_EO_LEN, |
---|
| 1994 | SAO_EO_LEN, |
---|
| 1995 | SAO_BO_LEN |
---|
| 1996 | }; |
---|
[2] | 1997 | |
---|
[608] | 1998 | if (compIdx==2) |
---|
| 1999 | { |
---|
| 2000 | uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1); |
---|
| 2001 | } |
---|
| 2002 | else |
---|
| 2003 | { |
---|
| 2004 | parseSaoTypeIdx(uiSymbol); |
---|
| 2005 | } |
---|
[56] | 2006 | psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
| 2007 | if (uiSymbol) |
---|
| 2008 | { |
---|
| 2009 | psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; |
---|
[608] | 2010 | |
---|
| 2011 | Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY; |
---|
| 2012 | Int offsetTh = 1 << min(bitDepth - 5,5); |
---|
| 2013 | |
---|
[56] | 2014 | if( psSaoLcuParam->typeIdx == SAO_BO ) |
---|
| 2015 | { |
---|
| 2016 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
| 2017 | { |
---|
[608] | 2018 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); |
---|
| 2019 | psSaoLcuParam->offset[i] = uiSymbol; |
---|
[56] | 2020 | } |
---|
[608] | 2021 | for(Int i=0; i< psSaoLcuParam->length; i++) |
---|
| 2022 | { |
---|
| 2023 | if (psSaoLcuParam->offset[i] != 0) |
---|
| 2024 | { |
---|
| 2025 | m_pcTDecBinIf->decodeBinEP ( uiSymbol); |
---|
| 2026 | if (uiSymbol) |
---|
| 2027 | { |
---|
| 2028 | psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ; |
---|
| 2029 | } |
---|
| 2030 | } |
---|
| 2031 | } |
---|
| 2032 | parseSaoUflc(5, uiSymbol ); |
---|
| 2033 | psSaoLcuParam->subTypeIdx = uiSymbol; |
---|
[56] | 2034 | } |
---|
| 2035 | else if( psSaoLcuParam->typeIdx < 4 ) |
---|
| 2036 | { |
---|
[608] | 2037 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol; |
---|
| 2038 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol; |
---|
| 2039 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
| 2040 | parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
| 2041 | if (compIdx != 2) |
---|
| 2042 | { |
---|
| 2043 | parseSaoUflc(2, uiSymbol ); |
---|
| 2044 | psSaoLcuParam->subTypeIdx = uiSymbol; |
---|
| 2045 | psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx; |
---|
| 2046 | } |
---|
| 2047 | } |
---|
[56] | 2048 | } |
---|
| 2049 | else |
---|
| 2050 | { |
---|
| 2051 | psSaoLcuParam->length = 0; |
---|
| 2052 | } |
---|
| 2053 | } |
---|
[2] | 2054 | |
---|
[608] | 2055 | Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp) |
---|
[56] | 2056 | { |
---|
| 2057 | Int iAddr = pcCU->getAddr(); |
---|
| 2058 | UInt uiSymbol; |
---|
| 2059 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
[2] | 2060 | { |
---|
[56] | 2061 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
| 2062 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
[608] | 2063 | pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; |
---|
[56] | 2064 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
| 2065 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; |
---|
| 2066 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; |
---|
| 2067 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; |
---|
| 2068 | pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; |
---|
| 2069 | |
---|
[608] | 2070 | } |
---|
| 2071 | if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] ) |
---|
| 2072 | { |
---|
| 2073 | if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) |
---|
[56] | 2074 | { |
---|
[608] | 2075 | parseSaoMerge(uiSymbol); |
---|
| 2076 | pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol; |
---|
| 2077 | } |
---|
| 2078 | if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0) |
---|
| 2079 | { |
---|
| 2080 | if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) |
---|
[56] | 2081 | { |
---|
[608] | 2082 | parseSaoMerge(uiSymbol); |
---|
| 2083 | pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol; |
---|
[56] | 2084 | } |
---|
[608] | 2085 | } |
---|
| 2086 | } |
---|
| 2087 | |
---|
| 2088 | for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) |
---|
| 2089 | { |
---|
| 2090 | if ((iCompIdx == 0 && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0 && pSaoParam->bSaoFlag[1]) ) |
---|
| 2091 | { |
---|
| 2092 | if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) |
---|
| 2093 | { |
---|
| 2094 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag; |
---|
| 2095 | } |
---|
[56] | 2096 | else |
---|
| 2097 | { |
---|
| 2098 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; |
---|
| 2099 | } |
---|
| 2100 | |
---|
| 2101 | if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) |
---|
| 2102 | { |
---|
[608] | 2103 | if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) |
---|
[56] | 2104 | { |
---|
[608] | 2105 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag; |
---|
[56] | 2106 | } |
---|
| 2107 | else |
---|
| 2108 | { |
---|
| 2109 | pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; |
---|
| 2110 | } |
---|
| 2111 | if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) |
---|
| 2112 | { |
---|
[608] | 2113 | pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx; |
---|
| 2114 | parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx); |
---|
[56] | 2115 | } |
---|
| 2116 | else |
---|
| 2117 | { |
---|
| 2118 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); |
---|
| 2119 | } |
---|
| 2120 | } |
---|
| 2121 | else |
---|
| 2122 | { |
---|
| 2123 | copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); |
---|
| 2124 | } |
---|
| 2125 | } |
---|
| 2126 | else |
---|
| 2127 | { |
---|
| 2128 | pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; |
---|
[608] | 2129 | pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; |
---|
[56] | 2130 | } |
---|
[2] | 2131 | } |
---|
[56] | 2132 | } |
---|
[608] | 2133 | |
---|
[56] | 2134 | /** |
---|
| 2135 | - Initialize our contexts from the nominated source. |
---|
| 2136 | . |
---|
| 2137 | \param pSrc Contexts to be copied. |
---|
| 2138 | */ |
---|
| 2139 | Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc ) |
---|
| 2140 | { |
---|
| 2141 | memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); |
---|
| 2142 | } |
---|
[2] | 2143 | |
---|
[56] | 2144 | Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) |
---|
| 2145 | { |
---|
| 2146 | m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); |
---|
[2] | 2147 | |
---|
[56] | 2148 | m_uiLastQp = pSrc->m_uiLastQp; |
---|
| 2149 | xCopyContextsFrom( pSrc ); |
---|
| 2150 | |
---|
| 2151 | } |
---|
| 2152 | |
---|
| 2153 | Void TDecSbac::load ( TDecSbac* pScr ) |
---|
| 2154 | { |
---|
| 2155 | xCopyFrom(pScr); |
---|
| 2156 | } |
---|
| 2157 | |
---|
| 2158 | Void TDecSbac::loadContexts ( TDecSbac* pScr ) |
---|
| 2159 | { |
---|
| 2160 | xCopyContextsFrom(pScr); |
---|
| 2161 | } |
---|
| 2162 | |
---|
[608] | 2163 | #if H_3D_ARP |
---|
| 2164 | Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[56] | 2165 | { |
---|
[608] | 2166 | UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1; |
---|
| 2167 | UInt uiW = 0; |
---|
| 2168 | UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx); |
---|
| 2169 | UInt uiCode = 0; |
---|
[56] | 2170 | |
---|
[608] | 2171 | assert ( uiMaxW > 0 ); |
---|
[56] | 2172 | |
---|
[608] | 2173 | m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) ); |
---|
[2] | 2174 | |
---|
[608] | 2175 | uiW = uiCode; |
---|
| 2176 | if( 1 == uiW ) |
---|
[56] | 2177 | { |
---|
[608] | 2178 | m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 3 ) ); |
---|
| 2179 | uiW += ( 1 == uiCode ? 1 : 0 ); |
---|
[56] | 2180 | } |
---|
[608] | 2181 | #if H_MV_ENC_DEC_TRAC |
---|
| 2182 | DTRACE_CU("iv_res_pred_weight_idx", uiW ) |
---|
| 2183 | #endif |
---|
| 2184 | pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth ); |
---|
[2] | 2185 | } |
---|
| 2186 | #endif |
---|
[56] | 2187 | |
---|
[608] | 2188 | #if H_3D_IC |
---|
| 2189 | /** parse illumination compensation flag |
---|
| 2190 | * \param pcCU |
---|
| 2191 | * \param uiAbsPartIdx |
---|
| 2192 | * \param uiDepth |
---|
| 2193 | * \returns Void |
---|
| 2194 | */ |
---|
| 2195 | Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2196 | { |
---|
| 2197 | UInt uiSymbol = 0; |
---|
| 2198 | UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx ); |
---|
| 2199 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) ); |
---|
| 2200 | #if !H_MV_ENC_DEC_TRAC |
---|
| 2201 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 2202 | DTRACE_CABAC_T( "\tICFlag" ); |
---|
| 2203 | DTRACE_CABAC_T( "\tuiCtxIC: "); |
---|
| 2204 | DTRACE_CABAC_V( uiCtxIC ); |
---|
| 2205 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
| 2206 | DTRACE_CABAC_V( uiSymbol ); |
---|
| 2207 | DTRACE_CABAC_T( "\n"); |
---|
| 2208 | #else |
---|
| 2209 | DTRACE_CU("ic_flag", uiSymbol) |
---|
[56] | 2210 | #endif |
---|
[608] | 2211 | |
---|
| 2212 | pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth ); |
---|
[296] | 2213 | } |
---|
| 2214 | #endif |
---|
| 2215 | |
---|
[655] | 2216 | #if H_3D_INTER_SDC |
---|
[608] | 2217 | Void TDecSbac::parseInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[56] | 2218 | { |
---|
[100] | 2219 | UInt uiSymbol = 0; |
---|
[608] | 2220 | UInt uiCtxInterSDCFlag = pcCU->getCtxInterSDCFlag( uiAbsPartIdx ); |
---|
[100] | 2221 | |
---|
[608] | 2222 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cInterSDCFlagSCModel.get( 0, 0, uiCtxInterSDCFlag ) ); |
---|
[100] | 2223 | |
---|
[608] | 2224 | if( uiSymbol ) |
---|
[100] | 2225 | { |
---|
[608] | 2226 | pcCU->setInterSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth ); |
---|
| 2227 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
| 2228 | pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth ); |
---|
[100] | 2229 | } |
---|
[608] | 2230 | else |
---|
[100] | 2231 | { |
---|
[608] | 2232 | pcCU->setInterSDCFlagSubParts( false, uiAbsPartIdx, 0, uiDepth); |
---|
[100] | 2233 | } |
---|
| 2234 | } |
---|
| 2235 | |
---|
[608] | 2236 | Void TDecSbac::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment ) |
---|
[189] | 2237 | { |
---|
| 2238 | UInt uiAbsIdx = 0; |
---|
| 2239 | UInt uiSign = 0; |
---|
| 2240 | Int iIdx = 0; |
---|
[608] | 2241 | |
---|
| 2242 | xReadExGolombLevel( uiAbsIdx, m_cInterSDCResidualSCModel.get( 0, 0, 0 ) ); |
---|
| 2243 | |
---|
| 2244 | uiAbsIdx++; |
---|
| 2245 | m_pcTDecBinIf->decodeBin( uiSign, m_cInterSDCResidualSignFlagSCModel.get( 0, 0, 0 ) ); |
---|
| 2246 | iIdx = (Int)( uiSign ? -1 : 1 ) * uiAbsIdx; |
---|
| 2247 | |
---|
| 2248 | pcCU->setInterSDCSegmentDCOffset( iIdx, uiSegment, uiAbsPartIdx ); |
---|
[189] | 2249 | } |
---|
| 2250 | #endif |
---|
| 2251 | |
---|
[56] | 2252 | //! \} |
---|