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