[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TDecEntropy.cpp |
---|
| 35 | \brief entropy decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecEntropy.h" |
---|
| 39 | |
---|
[56] | 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
[2] | 43 | Void TDecEntropy::setEntropyDecoder ( TDecEntropyIf* p ) |
---|
| 44 | { |
---|
| 45 | m_pcEntropyDecoderIf = p; |
---|
| 46 | } |
---|
| 47 | |
---|
[56] | 48 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
[2] | 49 | |
---|
| 50 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 51 | { |
---|
| 52 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 53 | } |
---|
| 54 | |
---|
[608] | 55 | Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 56 | { |
---|
| 57 | m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 58 | } |
---|
| 59 | |
---|
[2] | 60 | /** decode merge flag |
---|
| 61 | * \param pcSubCU |
---|
| 62 | * \param uiAbsPartIdx |
---|
| 63 | * \param uiDepth |
---|
| 64 | * \param uiPUIdx |
---|
| 65 | * \returns Void |
---|
| 66 | */ |
---|
| 67 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 68 | { |
---|
[56] | 69 | // at least one merge candidate exists |
---|
| 70 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
[2] | 71 | } |
---|
| 72 | |
---|
| 73 | /** decode merge index |
---|
| 74 | * \param pcCU |
---|
| 75 | * \param uiPartIdx |
---|
| 76 | * \param uiAbsPartIdx |
---|
| 77 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
| 78 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
| 79 | * \param uiDepth |
---|
| 80 | * \returns Void |
---|
| 81 | */ |
---|
[608] | 82 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 83 | { |
---|
| 84 | UInt uiMergeIndex = 0; |
---|
[608] | 85 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex ); |
---|
[2] | 86 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 87 | } |
---|
| 88 | |
---|
[608] | 89 | #if H_3D_ARP |
---|
| 90 | Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[443] | 91 | { |
---|
[608] | 92 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 93 | { |
---|
[443] | 94 | return; |
---|
[608] | 95 | } |
---|
| 96 | |
---|
| 97 | if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
| 98 | { |
---|
| 99 | pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 100 | } |
---|
[443] | 101 | else |
---|
[608] | 102 | { |
---|
[443] | 103 | m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
[608] | 104 | } |
---|
[443] | 105 | } |
---|
| 106 | #endif |
---|
[608] | 107 | |
---|
| 108 | #if H_3D_IC |
---|
| 109 | Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 110 | { |
---|
| 111 | pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); |
---|
| 112 | |
---|
[724] | 113 | #if SEC_ONLY_TEXTURE_IC_F0151 |
---|
| 114 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() ) |
---|
| 115 | #else |
---|
[608] | 116 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) ) |
---|
[724] | 117 | #endif |
---|
[608] | 118 | { |
---|
| 119 | return; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | if( !pcCU->getSlice()->getApplyIC() ) |
---|
| 123 | return; |
---|
| 124 | |
---|
| 125 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
---|
| 126 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 127 | } |
---|
| 128 | #endif |
---|
| 129 | |
---|
[2] | 130 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 131 | { |
---|
| 132 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 136 | { |
---|
| 137 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 141 | { |
---|
| 142 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 146 | { |
---|
| 147 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
| 148 | { |
---|
[608] | 149 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 150 | #if H_3D_DIM_SDC |
---|
| 151 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
[443] | 152 | #endif |
---|
[608] | 153 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 154 | } |
---|
| 155 | else // if it is Inter mode, encode motion vector and reference index |
---|
| 156 | { |
---|
[56] | 157 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
| 158 | } |
---|
| 159 | } |
---|
[2] | 160 | |
---|
[56] | 161 | /** Parse I_PCM information. |
---|
| 162 | * \param pcCU pointer to CUpointer to CU |
---|
| 163 | * \param uiAbsPartIdx CU index |
---|
| 164 | * \param uiDepth CU depth |
---|
| 165 | * \returns Void |
---|
| 166 | */ |
---|
| 167 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 168 | { |
---|
| 169 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
| 170 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
| 171 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
---|
| 172 | { |
---|
| 173 | return; |
---|
[2] | 174 | } |
---|
[608] | 175 | #if H_3D_DIM_SDC |
---|
[189] | 176 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
| 177 | { |
---|
| 178 | return; |
---|
| 179 | } |
---|
| 180 | #endif |
---|
| 181 | |
---|
[56] | 182 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 183 | } |
---|
| 184 | |
---|
| 185 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 186 | { |
---|
| 187 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 191 | { |
---|
| 192 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 193 | } |
---|
| 194 | |
---|
[56] | 195 | /** decode motion information for every PU block. |
---|
[2] | 196 | * \param pcCU |
---|
| 197 | * \param uiAbsPartIdx |
---|
| 198 | * \param uiDepth |
---|
| 199 | * \param pcSubCU |
---|
| 200 | * \returns Void |
---|
| 201 | */ |
---|
| 202 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 203 | { |
---|
| 204 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 205 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
| 206 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 207 | |
---|
[608] | 208 | #if H_3D_IV_MERGE |
---|
[56] | 209 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 210 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 211 | #else |
---|
| 212 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 213 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 214 | #endif |
---|
[724] | 215 | #if MTK_SPIVMP_F0110 |
---|
| 216 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 217 | TComMvField* pcMvFieldSP; |
---|
| 218 | UChar* puhInterDirSP; |
---|
| 219 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
| 220 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
| 221 | #endif |
---|
[608] | 222 | for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
[56] | 223 | { |
---|
| 224 | uhInterDirNeighbours[ui] = 0; |
---|
| 225 | } |
---|
| 226 | Int numValidMergeCand = 0; |
---|
[608] | 227 | Bool isMerged = false; |
---|
[56] | 228 | |
---|
[2] | 229 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 230 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
[608] | 231 | #if H_3D_IV_MERGE |
---|
| 232 | pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
| 233 | #endif |
---|
[2] | 234 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
| 235 | { |
---|
[608] | 236 | #if H_MV_ENC_DEC_TRAC |
---|
| 237 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
| 238 | // ToDo: |
---|
| 239 | //DTRACE_PU("x0", uiLPelX) |
---|
| 240 | //DTRACE_PU("x1", uiTPelY) |
---|
[56] | 241 | #endif |
---|
[2] | 242 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 243 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
| 244 | { |
---|
[608] | 245 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); |
---|
[56] | 246 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[724] | 247 | #if LGE_SHARP_VSP_INHERIT_F0104 |
---|
| 248 | #if H_3D_IC |
---|
| 249 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 250 | #endif |
---|
| 251 | #if H_3D_ARP |
---|
| 252 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 253 | #endif |
---|
| 254 | #endif |
---|
[56] | 255 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
---|
[2] | 256 | { |
---|
[56] | 257 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 258 | if ( !isMerged ) |
---|
[2] | 259 | { |
---|
[608] | 260 | #if H_3D_VSP |
---|
| 261 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 262 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 263 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
[724] | 264 | #if MTK_SPIVMP_F0110 |
---|
| 265 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 266 | #endif |
---|
| 267 | #if ETRIKHU_MERGE_REUSE_F0093 |
---|
| 268 | pcSubCU->initAvailableFlags(); |
---|
| 269 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
| 270 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo |
---|
| 271 | #if MTK_SPIVMP_F0110 |
---|
| 272 | , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP |
---|
| 273 | #endif |
---|
| 274 | , numValidMergeCand ); |
---|
| 275 | #else |
---|
[608] | 276 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand ); |
---|
[724] | 277 | #endif |
---|
[608] | 278 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
[622] | 279 | |
---|
[608] | 280 | if(vspFlag[uiMergeIndex]) |
---|
| 281 | { |
---|
| 282 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 283 | } |
---|
| 284 | #else |
---|
[724] | 285 | #if ETRIKHU_MERGE_REUSE_F0093 |
---|
| 286 | pcSubCU->initAvailableFlags(); |
---|
| 287 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
| 288 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 289 | |
---|
| 290 | #else |
---|
[608] | 291 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 292 | #endif |
---|
[724] | 293 | #endif |
---|
[56] | 294 | isMerged = true; |
---|
[2] | 295 | } |
---|
[56] | 296 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
| 297 | } |
---|
| 298 | else |
---|
| 299 | { |
---|
[622] | 300 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[608] | 301 | #if H_3D_VSP |
---|
| 302 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 303 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 304 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
[724] | 305 | #if MTK_SPIVMP_F0110 |
---|
| 306 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 307 | #endif |
---|
| 308 | #if ETRIKHU_MERGE_REUSE_F0093 |
---|
| 309 | pcSubCU->initAvailableFlags(); |
---|
| 310 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 311 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo |
---|
| 312 | #if MTK_SPIVMP_F0110 |
---|
| 313 | , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP |
---|
| 314 | #endif |
---|
| 315 | ,numValidMergeCand, uiMergeIndex ); |
---|
| 316 | #else |
---|
[608] | 317 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo,numValidMergeCand, uiMergeIndex ); |
---|
[724] | 318 | #endif |
---|
[608] | 319 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 320 | if(vspFlag[uiMergeIndex]) |
---|
[296] | 321 | { |
---|
[608] | 322 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
[296] | 323 | } |
---|
[443] | 324 | #else |
---|
[724] | 325 | #if ETRIKHU_MERGE_REUSE_F0093 |
---|
| 326 | pcSubCU->initAvailableFlags(); |
---|
[608] | 327 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[724] | 328 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 329 | #else |
---|
| 330 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[443] | 331 | #endif |
---|
[724] | 332 | #endif |
---|
[56] | 333 | } |
---|
| 334 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 335 | |
---|
| 336 | TComMv cTmpMv( 0, 0 ); |
---|
| 337 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 338 | { |
---|
| 339 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
[2] | 340 | { |
---|
[56] | 341 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 342 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 343 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 344 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 345 | } |
---|
| 346 | } |
---|
[724] | 347 | #if MTK_SPIVMP_F0110 |
---|
| 348 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 349 | if (bSPIVMPFlag[uiMergeIndex] != 0) |
---|
| 350 | { |
---|
| 351 | Int iWidth, iHeight; |
---|
| 352 | UInt uiIdx; |
---|
| 353 | pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true ); |
---|
| 354 | |
---|
| 355 | UInt uiSPAddr; |
---|
| 356 | |
---|
| 357 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 358 | |
---|
| 359 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 360 | |
---|
| 361 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
| 362 | { |
---|
| 363 | pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
| 364 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
| 365 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
| 366 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
| 367 | } |
---|
| 368 | } |
---|
| 369 | #endif |
---|
[56] | 370 | } |
---|
| 371 | else |
---|
| 372 | { |
---|
[2] | 373 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 374 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 375 | { |
---|
| 376 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 377 | { |
---|
| 378 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 379 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 380 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 381 | } |
---|
| 382 | } |
---|
[724] | 383 | #if LGE_SHARP_VSP_INHERIT_F0104 |
---|
| 384 | #if H_3D_IC |
---|
| 385 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 386 | #endif |
---|
| 387 | #if H_3D_ARP |
---|
| 388 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 389 | #endif |
---|
| 390 | #endif |
---|
[2] | 391 | } |
---|
[622] | 392 | #if H_3D_VSP |
---|
[608] | 393 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) && (pcCU->getVSPFlag(uiSubPartIdx) == false)) |
---|
| 394 | #else |
---|
| 395 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) |
---|
| 396 | #endif |
---|
| 397 | { |
---|
| 398 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
| 399 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
| 400 | pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 401 | } |
---|
[2] | 402 | } |
---|
[724] | 403 | #if MTK_SPIVMP_F0110 |
---|
[735] | 404 | #if MTK_F0110_FIX |
---|
| 405 | delete[] pcMvFieldSP; |
---|
| 406 | delete[] puhInterDirSP; |
---|
| 407 | #else |
---|
[724] | 408 | delete pcMvFieldSP; |
---|
| 409 | delete puhInterDirSP; |
---|
| 410 | #endif |
---|
[735] | 411 | #endif |
---|
[2] | 412 | return; |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | /** decode inter direction for a PU block |
---|
| 416 | * \param pcCU |
---|
| 417 | * \param uiAbsPartIdx |
---|
| 418 | * \param uiDepth |
---|
| 419 | * \param uiPartIdx |
---|
| 420 | * \returns Void |
---|
| 421 | */ |
---|
| 422 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
| 423 | { |
---|
| 424 | UInt uiInterDir; |
---|
| 425 | |
---|
| 426 | if ( pcCU->getSlice()->isInterP() ) |
---|
| 427 | { |
---|
| 428 | uiInterDir = 1; |
---|
| 429 | } |
---|
| 430 | else |
---|
| 431 | { |
---|
[608] | 432 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx ); |
---|
[2] | 433 | } |
---|
| 434 | |
---|
| 435 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 439 | { |
---|
[608] | 440 | Int iRefFrmIdx = 0; |
---|
| 441 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 442 | |
---|
| 443 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
[2] | 444 | { |
---|
[608] | 445 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList ); |
---|
[2] | 446 | } |
---|
[608] | 447 | else if ( !iParseRefFrmIdx ) |
---|
| 448 | { |
---|
| 449 | iRefFrmIdx = NOT_VALID; |
---|
| 450 | } |
---|
[2] | 451 | else |
---|
| 452 | { |
---|
[608] | 453 | iRefFrmIdx = 0; |
---|
| 454 | } |
---|
[2] | 455 | |
---|
[608] | 456 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 457 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 458 | } |
---|
| 459 | |
---|
| 460 | /** decode motion vector difference for a PU block |
---|
| 461 | * \param pcCU |
---|
| 462 | * \param uiAbsPartIdx |
---|
| 463 | * \param uiDepth |
---|
| 464 | * \param uiPartIdx |
---|
| 465 | * \param eRefList |
---|
| 466 | * \returns Void |
---|
| 467 | */ |
---|
| 468 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 469 | { |
---|
| 470 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 471 | { |
---|
| 472 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 477 | { |
---|
[56] | 478 | Int iMVPIdx = -1; |
---|
[2] | 479 | |
---|
| 480 | TComMv cZeroMv( 0, 0 ); |
---|
| 481 | TComMv cMv = cZeroMv; |
---|
| 482 | Int iRefIdx = -1; |
---|
| 483 | |
---|
| 484 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
| 485 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
| 486 | |
---|
| 487 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 488 | cMv = cZeroMv; |
---|
[56] | 489 | |
---|
[608] | 490 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) ) |
---|
[56] | 491 | { |
---|
| 492 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
---|
[608] | 493 | #if H_MV_ENC_DEC_TRAC |
---|
| 494 | #if ENC_DEC_TRACE |
---|
| 495 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
| 496 | { |
---|
| 497 | DTRACE_PU("mvp_l0_flag", iMVPIdx) |
---|
| 498 | } |
---|
| 499 | else |
---|
| 500 | { |
---|
| 501 | DTRACE_PU("mvp_l1_flag", iMVPIdx) |
---|
| 502 | } |
---|
[56] | 503 | #endif |
---|
[608] | 504 | #endif |
---|
[56] | 505 | } |
---|
[2] | 506 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 507 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 508 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 509 | if ( iRefIdx >= 0 ) |
---|
| 510 | { |
---|
[608] | 511 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv); |
---|
[2] | 512 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
[56] | 516 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
---|
[2] | 517 | } |
---|
| 518 | |
---|
[608] | 519 | Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP) |
---|
[2] | 520 | { |
---|
[56] | 521 | UInt uiSubdiv; |
---|
| 522 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
| 523 | |
---|
| 524 | if(uiTrIdx==0) |
---|
| 525 | { |
---|
| 526 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
| 527 | } |
---|
| 528 | if( uiLog2TrafoSize == 2 ) |
---|
| 529 | { |
---|
| 530 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 531 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
| 532 | { |
---|
| 533 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
| 534 | m_uiBakChromaOffset = offsetChroma; |
---|
| 535 | } |
---|
| 536 | } |
---|
| 537 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
| 538 | { |
---|
| 539 | uiSubdiv = 1; |
---|
| 540 | } |
---|
| 541 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
| 542 | { |
---|
| 543 | uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx)); |
---|
| 544 | } |
---|
| 545 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 546 | { |
---|
| 547 | uiSubdiv = 1; |
---|
| 548 | } |
---|
| 549 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 550 | { |
---|
| 551 | uiSubdiv = 0; |
---|
| 552 | } |
---|
| 553 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
| 554 | { |
---|
| 555 | uiSubdiv = 0; |
---|
| 556 | } |
---|
| 557 | else |
---|
| 558 | { |
---|
| 559 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
[608] | 560 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
---|
[56] | 561 | } |
---|
[2] | 562 | |
---|
[56] | 563 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
[2] | 564 | { |
---|
[608] | 565 | const Bool bFirstCbfOfCU = uiTrDepth == 0; |
---|
[56] | 566 | if( bFirstCbfOfCU ) |
---|
[2] | 567 | { |
---|
[56] | 568 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 569 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 570 | } |
---|
[56] | 571 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
[2] | 572 | { |
---|
[56] | 573 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
[2] | 574 | { |
---|
[608] | 575 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
[2] | 576 | } |
---|
[56] | 577 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
[2] | 578 | { |
---|
[608] | 579 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
[2] | 580 | } |
---|
| 581 | } |
---|
[56] | 582 | else |
---|
[2] | 583 | { |
---|
[56] | 584 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 585 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 586 | } |
---|
| 587 | } |
---|
| 588 | |
---|
[56] | 589 | if( uiSubdiv ) |
---|
[2] | 590 | { |
---|
[56] | 591 | UInt size; |
---|
| 592 | width >>= 1; |
---|
| 593 | height >>= 1; |
---|
| 594 | size = width*height; |
---|
| 595 | uiTrIdx++; |
---|
| 596 | ++uiDepth; |
---|
| 597 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 598 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
| 599 | UInt uiYCbf = 0; |
---|
| 600 | UInt uiUCbf = 0; |
---|
| 601 | UInt uiVCbf = 0; |
---|
| 602 | |
---|
| 603 | for( Int i = 0; i < 4; i++ ) |
---|
[2] | 604 | { |
---|
[608] | 605 | xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
| 606 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 ); |
---|
| 607 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 ); |
---|
| 608 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 ); |
---|
[56] | 609 | uiAbsPartIdx += uiQPartNum; |
---|
| 610 | offsetLuma += size; offsetChroma += (size>>2); |
---|
[2] | 611 | } |
---|
[56] | 612 | |
---|
| 613 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
| 614 | { |
---|
[608] | 615 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth; |
---|
| 616 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth; |
---|
| 617 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth; |
---|
[56] | 618 | } |
---|
[2] | 619 | } |
---|
| 620 | else |
---|
| 621 | { |
---|
[56] | 622 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 623 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
| 624 | |
---|
[608] | 625 | #if !H_MV_ENC_DEC_TRAC |
---|
[2] | 626 | { |
---|
[56] | 627 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 628 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
| 629 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 630 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
| 631 | DTRACE_CABAC_V( uiDepth ); |
---|
| 632 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
| 633 | DTRACE_CABAC_V( uiTrDepth ); |
---|
| 634 | DTRACE_CABAC_T( "\n" ); |
---|
[2] | 635 | } |
---|
[608] | 636 | #endif |
---|
[56] | 637 | |
---|
| 638 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 639 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
[2] | 640 | { |
---|
[608] | 641 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
[2] | 642 | } |
---|
[56] | 643 | else |
---|
[2] | 644 | { |
---|
[608] | 645 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth ); |
---|
[2] | 646 | } |
---|
[608] | 647 | |
---|
| 648 | |
---|
[56] | 649 | // transform_unit begin |
---|
| 650 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
| 651 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 652 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 653 | if( uiLog2TrafoSize == 2 ) |
---|
[2] | 654 | { |
---|
[56] | 655 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 656 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 657 | { |
---|
[56] | 658 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 659 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
[2] | 660 | } |
---|
| 661 | } |
---|
[56] | 662 | if ( cbfY || cbfU || cbfV ) |
---|
[2] | 663 | { |
---|
[56] | 664 | // dQP: only for LCU |
---|
| 665 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 666 | { |
---|
[56] | 667 | if ( bCodeDQP ) |
---|
[2] | 668 | { |
---|
[56] | 669 | decodeQP( pcCU, m_bakAbsPartIdxCU); |
---|
| 670 | bCodeDQP = false; |
---|
[2] | 671 | } |
---|
| 672 | } |
---|
| 673 | } |
---|
[56] | 674 | if( cbfY ) |
---|
[2] | 675 | { |
---|
[56] | 676 | Int trWidth = width; |
---|
| 677 | Int trHeight = height; |
---|
| 678 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
[2] | 679 | } |
---|
[56] | 680 | if( uiLog2TrafoSize > 2 ) |
---|
[2] | 681 | { |
---|
[56] | 682 | Int trWidth = width >> 1; |
---|
| 683 | Int trHeight = height >> 1; |
---|
| 684 | if( cbfU ) |
---|
[2] | 685 | { |
---|
[56] | 686 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 687 | } |
---|
[56] | 688 | if( cbfV ) |
---|
[2] | 689 | { |
---|
[56] | 690 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 691 | } |
---|
| 692 | } |
---|
| 693 | else |
---|
| 694 | { |
---|
[56] | 695 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 696 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 697 | { |
---|
[56] | 698 | Int trWidth = width; |
---|
| 699 | Int trHeight = height; |
---|
| 700 | if( cbfU ) |
---|
[2] | 701 | { |
---|
[56] | 702 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 703 | } |
---|
[56] | 704 | if( cbfV ) |
---|
[2] | 705 | { |
---|
[56] | 706 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 707 | } |
---|
| 708 | } |
---|
| 709 | } |
---|
[56] | 710 | // transform_unit end |
---|
[2] | 711 | } |
---|
| 712 | } |
---|
| 713 | |
---|
[56] | 714 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 715 | { |
---|
| 716 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 717 | { |
---|
| 718 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 719 | } |
---|
| 720 | } |
---|
[2] | 721 | |
---|
| 722 | |
---|
| 723 | /** decode coefficients |
---|
| 724 | * \param pcCU |
---|
| 725 | * \param uiAbsPartIdx |
---|
| 726 | * \param uiDepth |
---|
| 727 | * \param uiWidth |
---|
| 728 | * \param uiHeight |
---|
| 729 | * \returns Void |
---|
| 730 | */ |
---|
[56] | 731 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
[2] | 732 | { |
---|
| 733 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 734 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 735 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
| 736 | |
---|
[608] | 737 | #if H_3D_DIM_SDC |
---|
| 738 | if( pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
[189] | 739 | { |
---|
| 740 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 741 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
| 742 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
| 743 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
| 744 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
[608] | 745 | return; |
---|
| 746 | } |
---|
[443] | 747 | #endif |
---|
[608] | 748 | |
---|
[655] | 749 | #if H_3D_INTER_SDC |
---|
[608] | 750 | if( pcCU->getInterSDCFlag( uiAbsPartIdx ) ) |
---|
| 751 | { |
---|
| 752 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
---|
| 753 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
---|
| 754 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
| 755 | |
---|
| 756 | decodeInterSDCResidualData( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[189] | 757 | return; |
---|
| 758 | } |
---|
| 759 | #endif |
---|
[608] | 760 | |
---|
[2] | 761 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 762 | { |
---|
| 763 | } |
---|
| 764 | else |
---|
| 765 | { |
---|
[56] | 766 | UInt uiQtRootCbf = 1; |
---|
| 767 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
| 768 | { |
---|
[608] | 769 | m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf ); |
---|
[2] | 770 | } |
---|
[56] | 771 | if ( !uiQtRootCbf ) |
---|
| 772 | { |
---|
| 773 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
| 774 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 775 | return; |
---|
| 776 | } |
---|
[2] | 777 | |
---|
| 778 | } |
---|
[608] | 779 | xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP ); |
---|
| 780 | } |
---|
[189] | 781 | |
---|
[655] | 782 | #if H_3D_INTER_SDC |
---|
[608] | 783 | Void TDecEntropy::decodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 784 | { |
---|
| 785 | pcCU->setInterSDCFlagSubParts( false, uiAbsPartIdx, 0, uiDepth); |
---|
| 786 | |
---|
| 787 | if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) |
---|
[189] | 788 | { |
---|
[608] | 789 | return; |
---|
[189] | 790 | } |
---|
| 791 | |
---|
[608] | 792 | if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
[189] | 793 | { |
---|
[608] | 794 | return; |
---|
[189] | 795 | } |
---|
[608] | 796 | |
---|
| 797 | m_pcEntropyDecoderIf->parseInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 798 | } |
---|
| 799 | |
---|
[608] | 800 | Void TDecEntropy::decodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[189] | 801 | { |
---|
[608] | 802 | if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) |
---|
| 803 | { |
---|
| 804 | return; |
---|
| 805 | } |
---|
[189] | 806 | |
---|
[608] | 807 | if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || !pcCU->getInterSDCFlag( uiAbsPartIdx ) ) |
---|
| 808 | { |
---|
| 809 | return; |
---|
| 810 | } |
---|
| 811 | |
---|
| 812 | UInt uiNumSegments = ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ? 1 : ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ); |
---|
| 813 | |
---|
[189] | 814 | // decode residual data for each segment |
---|
| 815 | for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ ) |
---|
[608] | 816 | { |
---|
| 817 | m_pcEntropyDecoderIf->parseInterSDCResidualData( pcCU, uiAbsPartIdx, uiDepth, uiSeg ); |
---|
| 818 | } |
---|
[189] | 819 | } |
---|
| 820 | #endif |
---|
| 821 | |
---|
[56] | 822 | //! \} |
---|