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