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