[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 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, 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 | } |
---|
[983] | 54 | #if MTK_SINGLE_DEPTH_MODE_I0095 |
---|
| 55 | Void TDecEntropy::decodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 56 | { |
---|
| 57 | if ( !pcCU->getSlice()->getIsDepth() ) |
---|
| 58 | { |
---|
| 59 | return; |
---|
| 60 | } |
---|
| 61 | if(!pcCU->getSlice()->getApplySingleDepthMode()) |
---|
| 62 | { |
---|
| 63 | return; |
---|
| 64 | } |
---|
| 65 | m_pcEntropyDecoderIf->parseSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 66 | } |
---|
| 67 | #endif |
---|
[608] | 68 | Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 69 | { |
---|
| 70 | m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 71 | } |
---|
| 72 | |
---|
[2] | 73 | /** decode merge flag |
---|
| 74 | * \param pcSubCU |
---|
| 75 | * \param uiAbsPartIdx |
---|
| 76 | * \param uiDepth |
---|
| 77 | * \param uiPUIdx |
---|
| 78 | * \returns Void |
---|
| 79 | */ |
---|
| 80 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 81 | { |
---|
[56] | 82 | // at least one merge candidate exists |
---|
| 83 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
[2] | 84 | } |
---|
| 85 | |
---|
| 86 | /** decode merge index |
---|
| 87 | * \param pcCU |
---|
| 88 | * \param uiPartIdx |
---|
| 89 | * \param uiAbsPartIdx |
---|
| 90 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
| 91 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
| 92 | * \param uiDepth |
---|
| 93 | * \returns Void |
---|
| 94 | */ |
---|
[608] | 95 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 96 | { |
---|
| 97 | UInt uiMergeIndex = 0; |
---|
[608] | 98 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex ); |
---|
[2] | 99 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 100 | } |
---|
| 101 | |
---|
[608] | 102 | #if H_3D_ARP |
---|
| 103 | Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[443] | 104 | { |
---|
[608] | 105 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 106 | { |
---|
[443] | 107 | return; |
---|
[608] | 108 | } |
---|
| 109 | |
---|
| 110 | if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
| 111 | { |
---|
| 112 | pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 113 | } |
---|
[443] | 114 | else |
---|
[608] | 115 | { |
---|
[443] | 116 | m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
[608] | 117 | } |
---|
[443] | 118 | } |
---|
| 119 | #endif |
---|
[608] | 120 | |
---|
| 121 | #if H_3D_IC |
---|
| 122 | Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 123 | { |
---|
| 124 | pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); |
---|
| 125 | |
---|
[833] | 126 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) |
---|
[608] | 127 | { |
---|
| 128 | return; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | if( !pcCU->getSlice()->getApplyIC() ) |
---|
| 132 | return; |
---|
| 133 | |
---|
| 134 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
---|
| 135 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 136 | } |
---|
| 137 | #endif |
---|
| 138 | |
---|
[2] | 139 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 140 | { |
---|
| 141 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 145 | { |
---|
| 146 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 150 | { |
---|
| 151 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[833] | 152 | |
---|
| 153 | #if H_3D_DBBP |
---|
[950] | 154 | |
---|
| 155 | if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) ) |
---|
[833] | 156 | { |
---|
| 157 | decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth); |
---|
| 158 | |
---|
| 159 | if( pcCU->getDBBPFlag(uiAbsPartIdx) ) |
---|
| 160 | { |
---|
| 161 | |
---|
| 162 | // get collocated depth block |
---|
| 163 | UInt uiDepthStride = 0; |
---|
| 164 | Pel* pDepthPels = NULL; |
---|
| 165 | pDepthPels = pcCU->getVirtualDepthBlock(uiAbsPartIdx, pcCU->getWidth(uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), uiDepthStride); |
---|
| 166 | |
---|
| 167 | AOF( pDepthPels != NULL ); |
---|
| 168 | AOF( uiDepthStride != 0 ); |
---|
| 169 | |
---|
| 170 | // derive true partitioning for this CU based on depth |
---|
| 171 | // (needs to be done in parsing process as motion vector predictors are also derived during parsing) |
---|
| 172 | PartSize eVirtualPartSize = m_pcPrediction->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(uiAbsPartIdx)); |
---|
| 173 | AOF( eVirtualPartSize != SIZE_NONE ); |
---|
| 174 | |
---|
| 175 | pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth); |
---|
[950] | 176 | |
---|
| 177 | // make sure that DBBP flag is set for both segments |
---|
| 178 | UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 179 | pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth); |
---|
| 180 | pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx+uiPUOffset, 1, uiDepth); |
---|
[833] | 181 | } |
---|
| 182 | } |
---|
| 183 | #endif |
---|
[2] | 184 | } |
---|
| 185 | |
---|
| 186 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 187 | { |
---|
| 188 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
| 189 | { |
---|
[608] | 190 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 191 | #if H_3D_DIM_SDC |
---|
| 192 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
[443] | 193 | #endif |
---|
[608] | 194 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 195 | } |
---|
| 196 | else // if it is Inter mode, encode motion vector and reference index |
---|
| 197 | { |
---|
[56] | 198 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
| 199 | } |
---|
| 200 | } |
---|
[2] | 201 | |
---|
[56] | 202 | /** Parse I_PCM information. |
---|
| 203 | * \param pcCU pointer to CUpointer to CU |
---|
| 204 | * \param uiAbsPartIdx CU index |
---|
| 205 | * \param uiDepth CU depth |
---|
| 206 | * \returns Void |
---|
| 207 | */ |
---|
| 208 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 209 | { |
---|
| 210 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
| 211 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
| 212 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
---|
| 213 | { |
---|
| 214 | return; |
---|
[2] | 215 | } |
---|
[189] | 216 | |
---|
[56] | 217 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 218 | } |
---|
| 219 | |
---|
| 220 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 221 | { |
---|
| 222 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 226 | { |
---|
| 227 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 228 | } |
---|
| 229 | |
---|
[56] | 230 | /** decode motion information for every PU block. |
---|
[2] | 231 | * \param pcCU |
---|
| 232 | * \param uiAbsPartIdx |
---|
| 233 | * \param uiDepth |
---|
| 234 | * \param pcSubCU |
---|
| 235 | * \returns Void |
---|
| 236 | */ |
---|
| 237 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 238 | { |
---|
| 239 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 240 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
| 241 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 242 | |
---|
[608] | 243 | #if H_3D_IV_MERGE |
---|
[56] | 244 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 245 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 246 | #else |
---|
| 247 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 248 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 249 | #endif |
---|
[773] | 250 | #if H_3D_SPIVMP |
---|
[724] | 251 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 252 | TComMvField* pcMvFieldSP; |
---|
| 253 | UChar* puhInterDirSP; |
---|
| 254 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
| 255 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
| 256 | #endif |
---|
[608] | 257 | for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
[56] | 258 | { |
---|
| 259 | uhInterDirNeighbours[ui] = 0; |
---|
| 260 | } |
---|
| 261 | Int numValidMergeCand = 0; |
---|
[608] | 262 | Bool isMerged = false; |
---|
[56] | 263 | |
---|
[2] | 264 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 265 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
[608] | 266 | #if H_3D_IV_MERGE |
---|
| 267 | pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
| 268 | #endif |
---|
[2] | 269 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
| 270 | { |
---|
[608] | 271 | #if H_MV_ENC_DEC_TRAC |
---|
| 272 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
| 273 | // ToDo: |
---|
| 274 | //DTRACE_PU("x0", uiLPelX) |
---|
| 275 | //DTRACE_PU("x1", uiTPelY) |
---|
[56] | 276 | #endif |
---|
[2] | 277 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 278 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
| 279 | { |
---|
[608] | 280 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); |
---|
[56] | 281 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[724] | 282 | #if H_3D_ARP |
---|
| 283 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 284 | #endif |
---|
[833] | 285 | #if H_3D_IC |
---|
| 286 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 287 | #endif |
---|
| 288 | #if H_3D_DBBP |
---|
| 289 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false ) |
---|
| 290 | #else |
---|
[56] | 291 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
---|
[833] | 292 | #endif |
---|
[2] | 293 | { |
---|
[56] | 294 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 295 | if ( !isMerged ) |
---|
[2] | 296 | { |
---|
[608] | 297 | #if H_3D_VSP |
---|
| 298 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 299 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 300 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
[773] | 301 | #if H_3D_SPIVMP |
---|
[724] | 302 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 303 | #endif |
---|
| 304 | pcSubCU->initAvailableFlags(); |
---|
| 305 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
[950] | 306 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
---|
| 307 | , inheritedVSPDisInfo |
---|
[773] | 308 | #if H_3D_SPIVMP |
---|
[950] | 309 | , pcMvFieldSP, puhInterDirSP |
---|
| 310 | #endif |
---|
[724] | 311 | , numValidMergeCand ); |
---|
[950] | 312 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
| 313 | #if H_3D_SPIVMP |
---|
| 314 | , bSPIVMPFlag |
---|
| 315 | #endif |
---|
| 316 | , numValidMergeCand ); |
---|
[608] | 317 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
[622] | 318 | |
---|
[608] | 319 | if(vspFlag[uiMergeIndex]) |
---|
| 320 | { |
---|
| 321 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 322 | } |
---|
| 323 | #else |
---|
[773] | 324 | #if H_3D |
---|
[724] | 325 | pcSubCU->initAvailableFlags(); |
---|
| 326 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
| 327 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 328 | |
---|
| 329 | #else |
---|
[608] | 330 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 331 | #endif |
---|
[724] | 332 | #endif |
---|
[56] | 333 | isMerged = true; |
---|
[2] | 334 | } |
---|
[56] | 335 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
| 336 | } |
---|
| 337 | else |
---|
| 338 | { |
---|
[622] | 339 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[608] | 340 | #if H_3D_VSP |
---|
| 341 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 342 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 343 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
[773] | 344 | #if H_3D_SPIVMP |
---|
[724] | 345 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 346 | #endif |
---|
| 347 | pcSubCU->initAvailableFlags(); |
---|
| 348 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[950] | 349 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours |
---|
| 350 | , inheritedVSPDisInfo |
---|
[773] | 351 | #if H_3D_SPIVMP |
---|
[950] | 352 | , pcMvFieldSP, puhInterDirSP |
---|
| 353 | #endif |
---|
[724] | 354 | ,numValidMergeCand, uiMergeIndex ); |
---|
[950] | 355 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
| 356 | #if H_3D_SPIVMP |
---|
| 357 | , bSPIVMPFlag |
---|
| 358 | #endif |
---|
| 359 | ,numValidMergeCand ); |
---|
[608] | 360 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 361 | if(vspFlag[uiMergeIndex]) |
---|
[296] | 362 | { |
---|
[608] | 363 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
[296] | 364 | } |
---|
[443] | 365 | #else |
---|
[773] | 366 | #if H_3D |
---|
[724] | 367 | pcSubCU->initAvailableFlags(); |
---|
[608] | 368 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[724] | 369 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 370 | #else |
---|
| 371 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[443] | 372 | #endif |
---|
[724] | 373 | #endif |
---|
[56] | 374 | } |
---|
| 375 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 376 | |
---|
[884] | 377 | #if H_3D_DDD |
---|
[833] | 378 | if( uiMergeIndex == pcSubCU->getUseDDDCandIdx() ) |
---|
| 379 | { |
---|
| 380 | assert( pcCU->getSlice()->getViewIndex() != 0 ); |
---|
| 381 | pcCU->setUseDDD( true, uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 382 | pcCU->setDDDepthSubParts( pcSubCU->getDDTmpDepth(),uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 383 | } |
---|
| 384 | else |
---|
| 385 | { |
---|
| 386 | pcCU->setUseDDD( false, uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 387 | } |
---|
| 388 | #endif |
---|
| 389 | |
---|
[56] | 390 | TComMv cTmpMv( 0, 0 ); |
---|
| 391 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 392 | { |
---|
| 393 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
[2] | 394 | { |
---|
[56] | 395 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 396 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 397 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 398 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
[884] | 399 | #if H_3D_VSP |
---|
[833] | 400 | #if H_3D_DBBP |
---|
| 401 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) ) |
---|
| 402 | #else |
---|
| 403 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 ) |
---|
| 404 | #endif |
---|
| 405 | { |
---|
| 406 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
| 407 | { |
---|
| 408 | UInt dummy; |
---|
| 409 | Int vspSize; |
---|
| 410 | Int width, height; |
---|
| 411 | pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 ); |
---|
| 412 | pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
| 413 | pcCU->setVSPFlag( uiSubPartIdx, vspSize ); |
---|
| 414 | } |
---|
| 415 | } |
---|
| 416 | #endif |
---|
[2] | 417 | } |
---|
| 418 | } |
---|
[773] | 419 | #if H_3D_SPIVMP |
---|
[724] | 420 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 421 | if (bSPIVMPFlag[uiMergeIndex] != 0) |
---|
| 422 | { |
---|
| 423 | Int iWidth, iHeight; |
---|
| 424 | UInt uiIdx; |
---|
| 425 | pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true ); |
---|
| 426 | |
---|
| 427 | UInt uiSPAddr; |
---|
| 428 | |
---|
| 429 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 430 | |
---|
| 431 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 432 | |
---|
| 433 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
| 434 | { |
---|
| 435 | pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
| 436 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
| 437 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
| 438 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
| 439 | } |
---|
| 440 | } |
---|
| 441 | #endif |
---|
[56] | 442 | } |
---|
| 443 | else |
---|
| 444 | { |
---|
[2] | 445 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 446 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 447 | { |
---|
| 448 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 449 | { |
---|
| 450 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 451 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 452 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 453 | } |
---|
| 454 | } |
---|
[724] | 455 | #if H_3D_ARP |
---|
| 456 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 457 | #endif |
---|
[833] | 458 | #if H_3D_IC |
---|
| 459 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 460 | #endif |
---|
[2] | 461 | } |
---|
[622] | 462 | #if H_3D_VSP |
---|
[833] | 463 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) && (pcCU->getVSPFlag(uiSubPartIdx) == 0)) |
---|
| 464 | #else |
---|
[608] | 465 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) |
---|
| 466 | #endif |
---|
| 467 | { |
---|
| 468 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
| 469 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
| 470 | pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 471 | } |
---|
[2] | 472 | } |
---|
[773] | 473 | #if H_3D_SPIVMP |
---|
[735] | 474 | delete[] pcMvFieldSP; |
---|
| 475 | delete[] puhInterDirSP; |
---|
[724] | 476 | #endif |
---|
[2] | 477 | return; |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | /** decode inter direction for a PU block |
---|
| 481 | * \param pcCU |
---|
| 482 | * \param uiAbsPartIdx |
---|
| 483 | * \param uiDepth |
---|
| 484 | * \param uiPartIdx |
---|
| 485 | * \returns Void |
---|
| 486 | */ |
---|
| 487 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
| 488 | { |
---|
| 489 | UInt uiInterDir; |
---|
| 490 | |
---|
| 491 | if ( pcCU->getSlice()->isInterP() ) |
---|
| 492 | { |
---|
| 493 | uiInterDir = 1; |
---|
| 494 | } |
---|
| 495 | else |
---|
| 496 | { |
---|
[608] | 497 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx ); |
---|
[2] | 498 | } |
---|
| 499 | |
---|
| 500 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 504 | { |
---|
[608] | 505 | Int iRefFrmIdx = 0; |
---|
| 506 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 507 | |
---|
| 508 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
[2] | 509 | { |
---|
[608] | 510 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList ); |
---|
[2] | 511 | } |
---|
[608] | 512 | else if ( !iParseRefFrmIdx ) |
---|
| 513 | { |
---|
| 514 | iRefFrmIdx = NOT_VALID; |
---|
| 515 | } |
---|
[2] | 516 | else |
---|
| 517 | { |
---|
[608] | 518 | iRefFrmIdx = 0; |
---|
| 519 | } |
---|
[2] | 520 | |
---|
[608] | 521 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 522 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 523 | } |
---|
| 524 | |
---|
| 525 | /** decode motion vector difference for a PU block |
---|
| 526 | * \param pcCU |
---|
| 527 | * \param uiAbsPartIdx |
---|
| 528 | * \param uiDepth |
---|
| 529 | * \param uiPartIdx |
---|
| 530 | * \param eRefList |
---|
| 531 | * \returns Void |
---|
| 532 | */ |
---|
| 533 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 534 | { |
---|
| 535 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 536 | { |
---|
| 537 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 542 | { |
---|
[56] | 543 | Int iMVPIdx = -1; |
---|
[2] | 544 | |
---|
| 545 | TComMv cZeroMv( 0, 0 ); |
---|
| 546 | TComMv cMv = cZeroMv; |
---|
| 547 | Int iRefIdx = -1; |
---|
| 548 | |
---|
| 549 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
| 550 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
| 551 | |
---|
| 552 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 553 | cMv = cZeroMv; |
---|
[56] | 554 | |
---|
[608] | 555 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) ) |
---|
[56] | 556 | { |
---|
| 557 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
---|
[608] | 558 | #if H_MV_ENC_DEC_TRAC |
---|
| 559 | #if ENC_DEC_TRACE |
---|
| 560 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
| 561 | { |
---|
| 562 | DTRACE_PU("mvp_l0_flag", iMVPIdx) |
---|
| 563 | } |
---|
| 564 | else |
---|
| 565 | { |
---|
| 566 | DTRACE_PU("mvp_l1_flag", iMVPIdx) |
---|
| 567 | } |
---|
[56] | 568 | #endif |
---|
[608] | 569 | #endif |
---|
[56] | 570 | } |
---|
[2] | 571 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 572 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 573 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 574 | if ( iRefIdx >= 0 ) |
---|
| 575 | { |
---|
[608] | 576 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv); |
---|
[2] | 577 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
[56] | 581 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
---|
[2] | 582 | } |
---|
| 583 | |
---|
[872] | 584 | Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU) |
---|
[2] | 585 | { |
---|
[56] | 586 | UInt uiSubdiv; |
---|
| 587 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
| 588 | |
---|
| 589 | if(uiTrIdx==0) |
---|
| 590 | { |
---|
| 591 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
| 592 | } |
---|
| 593 | if( uiLog2TrafoSize == 2 ) |
---|
| 594 | { |
---|
| 595 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 596 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
| 597 | { |
---|
| 598 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
| 599 | m_uiBakChromaOffset = offsetChroma; |
---|
| 600 | } |
---|
| 601 | } |
---|
| 602 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
| 603 | { |
---|
| 604 | uiSubdiv = 1; |
---|
| 605 | } |
---|
| 606 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
| 607 | { |
---|
[872] | 608 | uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU); |
---|
[56] | 609 | } |
---|
| 610 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 611 | { |
---|
| 612 | uiSubdiv = 1; |
---|
| 613 | } |
---|
| 614 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 615 | { |
---|
| 616 | uiSubdiv = 0; |
---|
| 617 | } |
---|
[872] | 618 | else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU ) |
---|
[56] | 619 | { |
---|
| 620 | uiSubdiv = 0; |
---|
| 621 | } |
---|
| 622 | else |
---|
| 623 | { |
---|
[872] | 624 | assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU ); |
---|
[608] | 625 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
---|
[56] | 626 | } |
---|
[2] | 627 | |
---|
[56] | 628 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
[2] | 629 | { |
---|
[608] | 630 | const Bool bFirstCbfOfCU = uiTrDepth == 0; |
---|
[56] | 631 | if( bFirstCbfOfCU ) |
---|
[2] | 632 | { |
---|
[56] | 633 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 634 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 635 | } |
---|
[56] | 636 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
[2] | 637 | { |
---|
[56] | 638 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
[2] | 639 | { |
---|
[608] | 640 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
[2] | 641 | } |
---|
[56] | 642 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
[2] | 643 | { |
---|
[608] | 644 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
[2] | 645 | } |
---|
| 646 | } |
---|
[56] | 647 | else |
---|
[2] | 648 | { |
---|
[56] | 649 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 650 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 651 | } |
---|
| 652 | } |
---|
| 653 | |
---|
[56] | 654 | if( uiSubdiv ) |
---|
[2] | 655 | { |
---|
[56] | 656 | UInt size; |
---|
| 657 | width >>= 1; |
---|
| 658 | height >>= 1; |
---|
| 659 | size = width*height; |
---|
| 660 | uiTrIdx++; |
---|
| 661 | ++uiDepth; |
---|
| 662 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 663 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
| 664 | UInt uiYCbf = 0; |
---|
| 665 | UInt uiUCbf = 0; |
---|
| 666 | UInt uiVCbf = 0; |
---|
| 667 | |
---|
| 668 | for( Int i = 0; i < 4; i++ ) |
---|
[2] | 669 | { |
---|
[872] | 670 | xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU ); |
---|
[608] | 671 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 ); |
---|
| 672 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 ); |
---|
| 673 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 ); |
---|
[56] | 674 | uiAbsPartIdx += uiQPartNum; |
---|
| 675 | offsetLuma += size; offsetChroma += (size>>2); |
---|
[2] | 676 | } |
---|
[56] | 677 | |
---|
| 678 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
| 679 | { |
---|
[608] | 680 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth; |
---|
| 681 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth; |
---|
| 682 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth; |
---|
[56] | 683 | } |
---|
[2] | 684 | } |
---|
| 685 | else |
---|
| 686 | { |
---|
[56] | 687 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 688 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
| 689 | |
---|
[608] | 690 | #if !H_MV_ENC_DEC_TRAC |
---|
[2] | 691 | { |
---|
[56] | 692 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 693 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
| 694 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 695 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
| 696 | DTRACE_CABAC_V( uiDepth ); |
---|
| 697 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
| 698 | DTRACE_CABAC_V( uiTrDepth ); |
---|
| 699 | DTRACE_CABAC_T( "\n" ); |
---|
[2] | 700 | } |
---|
[608] | 701 | #endif |
---|
[56] | 702 | |
---|
| 703 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 704 | 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] | 705 | { |
---|
[608] | 706 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
[2] | 707 | } |
---|
[56] | 708 | else |
---|
[2] | 709 | { |
---|
[608] | 710 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth ); |
---|
[2] | 711 | } |
---|
[608] | 712 | |
---|
| 713 | |
---|
[56] | 714 | // transform_unit begin |
---|
| 715 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
| 716 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 717 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 718 | if( uiLog2TrafoSize == 2 ) |
---|
[2] | 719 | { |
---|
[56] | 720 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 721 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 722 | { |
---|
[56] | 723 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 724 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
[2] | 725 | } |
---|
| 726 | } |
---|
[56] | 727 | if ( cbfY || cbfU || cbfV ) |
---|
[2] | 728 | { |
---|
[56] | 729 | // dQP: only for LCU |
---|
| 730 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 731 | { |
---|
[56] | 732 | if ( bCodeDQP ) |
---|
[2] | 733 | { |
---|
[56] | 734 | decodeQP( pcCU, m_bakAbsPartIdxCU); |
---|
| 735 | bCodeDQP = false; |
---|
[2] | 736 | } |
---|
| 737 | } |
---|
| 738 | } |
---|
[56] | 739 | if( cbfY ) |
---|
[2] | 740 | { |
---|
[56] | 741 | Int trWidth = width; |
---|
| 742 | Int trHeight = height; |
---|
| 743 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
[2] | 744 | } |
---|
[56] | 745 | if( uiLog2TrafoSize > 2 ) |
---|
[2] | 746 | { |
---|
[56] | 747 | Int trWidth = width >> 1; |
---|
| 748 | Int trHeight = height >> 1; |
---|
| 749 | if( cbfU ) |
---|
[2] | 750 | { |
---|
[56] | 751 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 752 | } |
---|
[56] | 753 | if( cbfV ) |
---|
[2] | 754 | { |
---|
[56] | 755 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 756 | } |
---|
| 757 | } |
---|
| 758 | else |
---|
| 759 | { |
---|
[56] | 760 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 761 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 762 | { |
---|
[56] | 763 | Int trWidth = width; |
---|
| 764 | Int trHeight = height; |
---|
| 765 | if( cbfU ) |
---|
[2] | 766 | { |
---|
[56] | 767 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 768 | } |
---|
[56] | 769 | if( cbfV ) |
---|
[2] | 770 | { |
---|
[56] | 771 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 772 | } |
---|
| 773 | } |
---|
| 774 | } |
---|
[56] | 775 | // transform_unit end |
---|
[2] | 776 | } |
---|
| 777 | } |
---|
| 778 | |
---|
[56] | 779 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 780 | { |
---|
| 781 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 782 | { |
---|
| 783 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 784 | } |
---|
| 785 | } |
---|
[2] | 786 | |
---|
| 787 | |
---|
| 788 | /** decode coefficients |
---|
| 789 | * \param pcCU |
---|
| 790 | * \param uiAbsPartIdx |
---|
| 791 | * \param uiDepth |
---|
| 792 | * \param uiWidth |
---|
| 793 | * \param uiHeight |
---|
| 794 | * \returns Void |
---|
| 795 | */ |
---|
[56] | 796 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
[2] | 797 | { |
---|
| 798 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 799 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 800 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[833] | 801 | #if H_3D_DIM_SDC |
---|
| 802 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) ) |
---|
| 803 | { |
---|
| 804 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 805 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
| 806 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
| 807 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
| 808 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
| 809 | } |
---|
| 810 | |
---|
| 811 | #if H_3D_INTER_SDC |
---|
| 812 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) ) |
---|
| 813 | { |
---|
| 814 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
---|
| 815 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
---|
| 816 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
| 817 | } |
---|
| 818 | #endif |
---|
| 819 | if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) |
---|
| 820 | { |
---|
| 821 | Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; |
---|
| 822 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; |
---|
[2] | 823 | |
---|
[833] | 824 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
| 825 | { |
---|
| 826 | for( Int iPart = 0; iPart < iPartNum; iPart++ ) |
---|
| 827 | { |
---|
| 828 | if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) |
---|
| 829 | { |
---|
| 830 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ); |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | } |
---|
| 834 | else |
---|
| 835 | { |
---|
| 836 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 837 | return; |
---|
| 838 | } |
---|
| 839 | } |
---|
[443] | 840 | #endif |
---|
[608] | 841 | |
---|
[2] | 842 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 843 | { |
---|
| 844 | } |
---|
| 845 | else |
---|
| 846 | { |
---|
[56] | 847 | UInt uiQtRootCbf = 1; |
---|
| 848 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
| 849 | { |
---|
[608] | 850 | m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf ); |
---|
[2] | 851 | } |
---|
[56] | 852 | if ( !uiQtRootCbf ) |
---|
| 853 | { |
---|
| 854 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
| 855 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 856 | return; |
---|
| 857 | } |
---|
[2] | 858 | |
---|
| 859 | } |
---|
[872] | 860 | |
---|
| 861 | Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx); |
---|
| 862 | |
---|
| 863 | xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU ); |
---|
[608] | 864 | } |
---|
[189] | 865 | |
---|
[655] | 866 | #if H_3D_INTER_SDC |
---|
[833] | 867 | Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 868 | { |
---|
| 869 | pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth ); |
---|
| 870 | |
---|
| 871 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) || |
---|
| 872 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) ) |
---|
| 873 | { |
---|
| 874 | return; |
---|
| 875 | } |
---|
| 876 | |
---|
| 877 | if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
| 878 | { |
---|
| 879 | return; |
---|
| 880 | } |
---|
| 881 | |
---|
| 882 | assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); |
---|
| 883 | m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 884 | } |
---|
[189] | 885 | #endif |
---|
[833] | 886 | #if H_3D_DBBP |
---|
| 887 | Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 888 | { |
---|
| 889 | m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 890 | } |
---|
| 891 | #endif |
---|
[189] | 892 | |
---|
[56] | 893 | //! \} |
---|