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