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