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