| 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 |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
|---|
| 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. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 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 | */ |
|---|
| 33 | |
|---|
| 34 | /** \file TDecEntropy.cpp |
|---|
| 35 | \brief entropy decoder class |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #include "TDecEntropy.h" |
|---|
| 39 | #include "TLibCommon/TComTU.h" |
|---|
| 40 | #include "TLibCommon/TComPrediction.h" |
|---|
| 41 | |
|---|
| 42 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 43 | #include "../TLibCommon/Debug.h" |
|---|
| 44 | static const Bool bDebugRQT = DebugOptionList::DebugRQT.getInt()!=0; |
|---|
| 45 | static const Bool bDebugPredEnabled = DebugOptionList::DebugPred.getInt()!=0; |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | //! \ingroup TLibDecoder |
|---|
| 49 | //! \{ |
|---|
| 50 | |
|---|
| 51 | Void TDecEntropy::setEntropyDecoder ( TDecEntropyIf* p ) |
|---|
| 52 | { |
|---|
| 53 | m_pcEntropyDecoderIf = p; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
|---|
| 57 | |
|---|
| 58 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 59 | { |
|---|
| 60 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 61 | } |
|---|
| 62 | #if H_3D |
|---|
| 63 | Void TDecEntropy::decodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 64 | { |
|---|
| 65 | if( !pcCU->getSlice()->getDepthIntraSkipFlag() ) |
|---|
| 66 | { |
|---|
| 67 | return; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | m_pcEntropyDecoderIf->parseDIS( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 71 | } |
|---|
| 72 | #endif |
|---|
| 73 | |
|---|
| 74 | Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 75 | { |
|---|
| 76 | m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | /** decode merge flag |
|---|
| 81 | * \param pcSubCU |
|---|
| 82 | * \param uiAbsPartIdx |
|---|
| 83 | * \param uiDepth |
|---|
| 84 | * \param uiPUIdx |
|---|
| 85 | * \returns Void |
|---|
| 86 | */ |
|---|
| 87 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
|---|
| 88 | { |
|---|
| 89 | // at least one merge candidate exists |
|---|
| 90 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | /** decode merge index |
|---|
| 94 | * \param pcCU |
|---|
| 95 | * \param uiPartIdx |
|---|
| 96 | * \param uiAbsPartIdx |
|---|
| 97 | * \param uiDepth |
|---|
| 98 | * \returns Void |
|---|
| 99 | */ |
|---|
| 100 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 101 | { |
|---|
| 102 | UInt uiMergeIndex = 0; |
|---|
| 103 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex ); |
|---|
| 104 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | #if H_3D_ARP |
|---|
| 108 | Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 109 | { |
|---|
| 110 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
|---|
| 111 | { |
|---|
| 112 | return; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
|---|
| 116 | { |
|---|
| 117 | pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth ); |
|---|
| 118 | } |
|---|
| 119 | else |
|---|
| 120 | { |
|---|
| 121 | m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth ); |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | #endif |
|---|
| 125 | |
|---|
| 126 | #if H_3D_IC |
|---|
| 127 | Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 128 | { |
|---|
| 129 | pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); |
|---|
| 130 | |
|---|
| 131 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) |
|---|
| 132 | { |
|---|
| 133 | return; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | if( !pcCU->getSlice()->getApplyIC() ) |
|---|
| 137 | return; |
|---|
| 138 | |
|---|
| 139 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
|---|
| 140 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 141 | } |
|---|
| 142 | #endif |
|---|
| 143 | |
|---|
| 144 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 145 | { |
|---|
| 146 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 150 | { |
|---|
| 151 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 155 | { |
|---|
| 156 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
|---|
| 160 | { |
|---|
| 161 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
|---|
| 162 | { |
|---|
| 163 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 164 | #if H_3D_DIM_SDC |
|---|
| 165 | decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 166 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
|---|
| 167 | #endif |
|---|
| 168 | if (pcCU->getPic()->getChromaFormat()!=CHROMA_400) |
|---|
| 169 | { |
|---|
| 170 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 171 | if (enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) && pcCU->getPartitionSize( uiAbsPartIdx )==SIZE_NxN) |
|---|
| 172 | { |
|---|
| 173 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
|---|
| 174 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset, uiDepth+1 ); |
|---|
| 175 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 ); |
|---|
| 176 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 ); |
|---|
| 177 | } |
|---|
| 178 | } |
|---|
| 179 | } |
|---|
| 180 | else // if it is Inter mode, encode motion vector and reference index |
|---|
| 181 | { |
|---|
| 182 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | /** Parse I_PCM information. |
|---|
| 187 | * \param pcCU pointer to CUpointer to CU |
|---|
| 188 | * \param uiAbsPartIdx CU index |
|---|
| 189 | * \param uiDepth CU depth |
|---|
| 190 | * \returns Void |
|---|
| 191 | */ |
|---|
| 192 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 193 | { |
|---|
| 194 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
|---|
| 195 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
|---|
| 196 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
|---|
| 197 | { |
|---|
| 198 | return; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 205 | { |
|---|
| 206 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 210 | { |
|---|
| 211 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 212 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 213 | if (bDebugPredEnabled) |
|---|
| 214 | { |
|---|
| 215 | UInt cdir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiAbsPartIdx); |
|---|
| 216 | if (cdir==36) |
|---|
| 217 | { |
|---|
| 218 | cdir=pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx); |
|---|
| 219 | } |
|---|
| 220 | printf("coding chroma Intra dir: %d, uiAbsPartIdx: %d, luma dir: %d\n", cdir, uiAbsPartIdx, pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx)); |
|---|
| 221 | } |
|---|
| 222 | #endif |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | /** decode motion information for every PU block. |
|---|
| 227 | * \param pcCU |
|---|
| 228 | * \param uiAbsPartIdx |
|---|
| 229 | * \param uiDepth |
|---|
| 230 | * \param pcSubCU |
|---|
| 231 | * \returns Void |
|---|
| 232 | */ |
|---|
| 233 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
|---|
| 234 | { |
|---|
| 235 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
|---|
| 236 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
|---|
| 237 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; |
|---|
| 238 | //#if H_3D_IV_MERGE |
|---|
| 239 | #if NH_3D_MLC |
|---|
| 240 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
|---|
| 241 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 242 | #else |
|---|
| 243 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
|---|
| 244 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
|---|
| 245 | #endif |
|---|
| 246 | #if H_3D_SPIVMP |
|---|
| 247 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 248 | TComMvField* pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
|---|
| 249 | UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
|---|
| 250 | #endif |
|---|
| 251 | #if H_3D_IV_MERGE |
|---|
| 252 | pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
|---|
| 253 | #endif |
|---|
| 254 | for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ ) |
|---|
| 255 | { |
|---|
| 256 | uhInterDirNeighbours[ui] = 0; |
|---|
| 257 | } |
|---|
| 258 | Int numValidMergeCand = 0; |
|---|
| 259 | Bool hasMergedCandList = false; |
|---|
| 260 | |
|---|
| 261 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
|---|
| 262 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
|---|
| 263 | #if H_3D |
|---|
| 264 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
|---|
| 265 | { |
|---|
| 266 | #if H_MV_ENC_DEC_TRAC |
|---|
| 267 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
|---|
| 268 | // ToDo: |
|---|
| 269 | //DTRACE_PU("x0", uiLPelX) |
|---|
| 270 | //DTRACE_PU("x1", uiTPelY) |
|---|
| 271 | #endif |
|---|
| 272 | |
|---|
| 273 | ////// Parse PUs syntax |
|---|
| 274 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 275 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
|---|
| 276 | { |
|---|
| 277 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); |
|---|
| 278 | } |
|---|
| 279 | else |
|---|
| 280 | { |
|---|
| 281 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 282 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 283 | { |
|---|
| 284 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
|---|
| 285 | { |
|---|
| 286 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 287 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 288 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | } |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | ////// Parse CUs extension syntax |
|---|
| 295 | decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 296 | decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 297 | |
|---|
| 298 | #if H_3D_ARP |
|---|
| 299 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 300 | #endif |
|---|
| 301 | #if H_3D_IC |
|---|
| 302 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 303 | #endif |
|---|
| 304 | |
|---|
| 305 | ////// Decode motion vectors |
|---|
| 306 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
|---|
| 307 | { |
|---|
| 308 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
|---|
| 309 | { |
|---|
| 310 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
|---|
| 311 | #if H_3D_DBBP |
|---|
| 312 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false ) |
|---|
| 313 | #else |
|---|
| 314 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
|---|
| 315 | #endif |
|---|
| 316 | { |
|---|
| 317 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
|---|
| 318 | if ( !isMerged ) |
|---|
| 319 | { |
|---|
| 320 | #if H_3D_VSP |
|---|
| 321 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 322 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 323 | #if H_3D_SPIVMP |
|---|
| 324 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 325 | #endif |
|---|
| 326 | pcSubCU->initAvailableFlags(); |
|---|
| 327 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
|---|
| 328 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 329 | #if H_3D_SPIVMP |
|---|
| 330 | , pcMvFieldSP, puhInterDirSP |
|---|
| 331 | #endif |
|---|
| 332 | , numValidMergeCand ); |
|---|
| 333 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
|---|
| 334 | #if H_3D_SPIVMP |
|---|
| 335 | , bSPIVMPFlag |
|---|
| 336 | #endif |
|---|
| 337 | , numValidMergeCand ); |
|---|
| 338 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 339 | |
|---|
| 340 | #else |
|---|
| 341 | #if H_3D |
|---|
| 342 | pcSubCU->initAvailableFlags(); |
|---|
| 343 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
|---|
| 344 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
|---|
| 345 | |
|---|
| 346 | #else |
|---|
| 347 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
|---|
| 348 | #endif |
|---|
| 349 | #endif |
|---|
| 350 | isMerged = true; |
|---|
| 351 | } |
|---|
| 352 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
|---|
| 353 | } |
|---|
| 354 | else |
|---|
| 355 | { |
|---|
| 356 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
|---|
| 357 | #if H_3D_VSP |
|---|
| 358 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 359 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 360 | #if H_3D_SPIVMP |
|---|
| 361 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 362 | #endif |
|---|
| 363 | pcSubCU->initAvailableFlags(); |
|---|
| 364 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 365 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 366 | #if H_3D_SPIVMP |
|---|
| 367 | , pcMvFieldSP, puhInterDirSP |
|---|
| 368 | #endif |
|---|
| 369 | ,numValidMergeCand, uiMergeIndex ); |
|---|
| 370 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
|---|
| 371 | #if H_3D_SPIVMP |
|---|
| 372 | , bSPIVMPFlag |
|---|
| 373 | #endif |
|---|
| 374 | ,numValidMergeCand ); |
|---|
| 375 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 376 | #else |
|---|
| 377 | #if H_3D |
|---|
| 378 | pcSubCU->initAvailableFlags(); |
|---|
| 379 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 380 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 381 | #else |
|---|
| 382 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 383 | #endif |
|---|
| 384 | #endif |
|---|
| 385 | } |
|---|
| 386 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 387 | |
|---|
| 388 | TComMv cTmpMv( 0, 0 ); |
|---|
| 389 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 390 | { |
|---|
| 391 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
|---|
| 392 | { |
|---|
| 393 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
|---|
| 394 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
|---|
| 395 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 396 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 397 | #if H_3D_VSP |
|---|
| 398 | #if H_3D_DBBP |
|---|
| 399 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) ) |
|---|
| 400 | #else |
|---|
| 401 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 ) |
|---|
| 402 | #endif |
|---|
| 403 | { |
|---|
| 404 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
|---|
| 405 | { |
|---|
| 406 | UInt dummy; |
|---|
| 407 | Int vspSize; |
|---|
| 408 | Int width, height; |
|---|
| 409 | pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 ); |
|---|
| 410 | pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
|---|
| 411 | pcCU->setVSPFlag( uiSubPartIdx, vspSize ); |
|---|
| 412 | } |
|---|
| 413 | } |
|---|
| 414 | #endif |
|---|
| 415 | } |
|---|
| 416 | } |
|---|
| 417 | #if H_3D_SPIVMP |
|---|
| 418 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 419 | if (bSPIVMPFlag[uiMergeIndex] != 0) |
|---|
| 420 | { |
|---|
| 421 | Int iWidth, iHeight; |
|---|
| 422 | UInt uiIdx; |
|---|
| 423 | pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true ); |
|---|
| 424 | |
|---|
| 425 | UInt uiSPAddr; |
|---|
| 426 | |
|---|
| 427 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
|---|
| 428 | |
|---|
| 429 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
|---|
| 430 | |
|---|
| 431 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
|---|
| 432 | { |
|---|
| 433 | pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
|---|
| 434 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
|---|
| 435 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
|---|
| 436 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
|---|
| 437 | } |
|---|
| 438 | } |
|---|
| 439 | #endif |
|---|
| 440 | } |
|---|
| 441 | else |
|---|
| 442 | { |
|---|
| 443 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 444 | { |
|---|
| 445 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
|---|
| 446 | { |
|---|
| 447 | decodeMvsAMVP ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 448 | } |
|---|
| 449 | } |
|---|
| 450 | } |
|---|
| 451 | |
|---|
| 452 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) |
|---|
| 453 | { |
|---|
| 454 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
|---|
| 455 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
|---|
| 456 | pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth); |
|---|
| 457 | } |
|---|
| 458 | } |
|---|
| 459 | #else |
|---|
| 460 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
|---|
| 461 | { |
|---|
| 462 | #if H_MV_ENC_DEC_TRAC |
|---|
| 463 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
|---|
| 464 | // ToDo: |
|---|
| 465 | //DTRACE_PU("x0", uiLPelX) |
|---|
| 466 | //DTRACE_PU("x1", uiTPelY) |
|---|
| 467 | #endif |
|---|
| 468 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 469 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
|---|
| 470 | { |
|---|
| 471 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); |
|---|
| 472 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 473 | if (bDebugPredEnabled) |
|---|
| 474 | { |
|---|
| 475 | std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx; |
|---|
| 476 | std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl; |
|---|
| 477 | } |
|---|
| 478 | #endif |
|---|
| 479 | |
|---|
| 480 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
|---|
| 481 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
|---|
| 482 | { |
|---|
| 483 | if ( !hasMergedCandList ) |
|---|
| 484 | { |
|---|
| 485 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set. |
|---|
| 486 | |
|---|
| 487 | #if NH_3D_MLC |
|---|
| 488 | #if H_3D_VSP |
|---|
| 489 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 490 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 491 | #endif |
|---|
| 492 | #if H_3D_SPIVMP |
|---|
| 493 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 494 | #endif |
|---|
| 495 | pcSubCU->initAvailableFlags(); |
|---|
| 496 | #endif |
|---|
| 497 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
|---|
| 498 | #if NH_3D_MLC |
|---|
| 499 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 500 | #if H_3D_SPIVMP |
|---|
| 501 | , pcMvFieldSP, puhInterDirSP |
|---|
| 502 | #endif |
|---|
| 503 | , numValidMergeCand ); |
|---|
| 504 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 505 | #if H_3D_VSP |
|---|
| 506 | , vspFlag |
|---|
| 507 | #endif |
|---|
| 508 | #if H_3D_SPIVMP |
|---|
| 509 | , bSPIVMPFlag |
|---|
| 510 | #endif |
|---|
| 511 | , numValidMergeCand ); |
|---|
| 512 | #if H_3D_VSP |
|---|
| 513 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 514 | #endif |
|---|
| 515 | #endif |
|---|
| 516 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore. |
|---|
| 517 | hasMergedCandList = true; |
|---|
| 518 | } |
|---|
| 519 | } |
|---|
| 520 | else |
|---|
| 521 | { |
|---|
| 522 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
|---|
| 523 | |
|---|
| 524 | #if NH_3D_MLC |
|---|
| 525 | #if H_3D_VSP |
|---|
| 526 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 527 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 528 | #endif |
|---|
| 529 | #if H_3D_SPIVMP |
|---|
| 530 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 531 | #endif |
|---|
| 532 | pcSubCU->initAvailableFlags(); |
|---|
| 533 | #endif |
|---|
| 534 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 535 | #if NH_3D_MLC |
|---|
| 536 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 537 | #if H_3D_SPIVMP |
|---|
| 538 | , pcMvFieldSP, puhInterDirSP |
|---|
| 539 | #endif |
|---|
| 540 | ,numValidMergeCand, uiMergeIndex ); |
|---|
| 541 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 542 | #if H_3D_VSP |
|---|
| 543 | , vspFlag |
|---|
| 544 | #endif |
|---|
| 545 | #if H_3D_SPIVMP |
|---|
| 546 | , bSPIVMPFlag |
|---|
| 547 | #endif |
|---|
| 548 | ,numValidMergeCand ); |
|---|
| 549 | #if H_3D_VSP |
|---|
| 550 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 551 | #endif |
|---|
| 552 | #endif |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
|---|
| 556 | |
|---|
| 557 | TComMv cTmpMv( 0, 0 ); |
|---|
| 558 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 559 | { |
|---|
| 560 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
|---|
| 561 | { |
|---|
| 562 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
|---|
| 563 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
|---|
| 564 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 565 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 566 | |
|---|
| 567 | } |
|---|
| 568 | } |
|---|
| 569 | } |
|---|
| 570 | else |
|---|
| 571 | { |
|---|
| 572 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
|---|
| 573 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 574 | { |
|---|
| 575 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
|---|
| 576 | { |
|---|
| 577 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 578 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 579 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
|---|
| 580 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 581 | if (bDebugPredEnabled) |
|---|
| 582 | { |
|---|
| 583 | std::cout << "refListIdx: " << uiRefListIdx << std::endl; |
|---|
| 584 | std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl; |
|---|
| 585 | std::cout << "MVD vertical: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl; |
|---|
| 586 | std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl; |
|---|
| 587 | std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl; |
|---|
| 588 | } |
|---|
| 589 | #endif |
|---|
| 590 | } |
|---|
| 591 | } |
|---|
| 592 | } |
|---|
| 593 | |
|---|
| 594 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) |
|---|
| 595 | { |
|---|
| 596 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
|---|
| 597 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
|---|
| 598 | pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth); |
|---|
| 599 | } |
|---|
| 600 | } |
|---|
| 601 | #endif |
|---|
| 602 | #if H_3D_SPIVMP |
|---|
| 603 | delete[] pcMvFieldSP; |
|---|
| 604 | delete[] puhInterDirSP; |
|---|
| 605 | #endif |
|---|
| 606 | return; |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | /** decode inter direction for a PU block |
|---|
| 610 | * \param pcCU |
|---|
| 611 | * \param uiAbsPartIdx |
|---|
| 612 | * \param uiDepth |
|---|
| 613 | * \param uiPartIdx |
|---|
| 614 | * \returns Void |
|---|
| 615 | */ |
|---|
| 616 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
|---|
| 617 | { |
|---|
| 618 | UInt uiInterDir; |
|---|
| 619 | |
|---|
| 620 | if ( pcCU->getSlice()->isInterP() ) |
|---|
| 621 | { |
|---|
| 622 | uiInterDir = 1; |
|---|
| 623 | } |
|---|
| 624 | else |
|---|
| 625 | { |
|---|
| 626 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx ); |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
|---|
| 630 | } |
|---|
| 631 | |
|---|
| 632 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
|---|
| 633 | { |
|---|
| 634 | Int iRefFrmIdx = 0; |
|---|
| 635 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
|---|
| 636 | |
|---|
| 637 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
|---|
| 638 | { |
|---|
| 639 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList ); |
|---|
| 640 | } |
|---|
| 641 | else if ( !iParseRefFrmIdx ) |
|---|
| 642 | { |
|---|
| 643 | iRefFrmIdx = NOT_VALID; |
|---|
| 644 | } |
|---|
| 645 | else |
|---|
| 646 | { |
|---|
| 647 | iRefFrmIdx = 0; |
|---|
| 648 | } |
|---|
| 649 | |
|---|
| 650 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
|---|
| 651 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 652 | } |
|---|
| 653 | |
|---|
| 654 | /** decode motion vector difference for a PU block |
|---|
| 655 | * \param pcCU |
|---|
| 656 | * \param uiAbsPartIdx |
|---|
| 657 | * \param uiDepth |
|---|
| 658 | * \param uiPartIdx |
|---|
| 659 | * \param eRefList |
|---|
| 660 | * \returns Void |
|---|
| 661 | */ |
|---|
| 662 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
|---|
| 663 | { |
|---|
| 664 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
|---|
| 665 | { |
|---|
| 666 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
|---|
| 667 | } |
|---|
| 668 | } |
|---|
| 669 | |
|---|
| 670 | #if H_3D |
|---|
| 671 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
|---|
| 672 | { |
|---|
| 673 | Int iMVPIdx = -1; |
|---|
| 674 | |
|---|
| 675 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) ) |
|---|
| 676 | { |
|---|
| 677 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
|---|
| 678 | #if H_MV_ENC_DEC_TRAC |
|---|
| 679 | #if ENC_DEC_TRACE |
|---|
| 680 | if ( eRefList == REF_PIC_LIST_0 ) |
|---|
| 681 | { |
|---|
| 682 | DTRACE_PU("mvp_l0_flag", iMVPIdx) |
|---|
| 683 | } |
|---|
| 684 | else |
|---|
| 685 | { |
|---|
| 686 | DTRACE_PU("mvp_l1_flag", iMVPIdx) |
|---|
| 687 | } |
|---|
| 688 | #endif |
|---|
| 689 | #endif |
|---|
| 690 | } |
|---|
| 691 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | Void TDecEntropy::decodeMvsAMVP( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
|---|
| 695 | { |
|---|
| 696 | TComMv cZeroMv( 0, 0 ); |
|---|
| 697 | TComMv cMv = cZeroMv; |
|---|
| 698 | Int iRefIdx = -1; |
|---|
| 699 | |
|---|
| 700 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
|---|
| 701 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
|---|
| 702 | |
|---|
| 703 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
|---|
| 704 | cMv = cZeroMv; |
|---|
| 705 | |
|---|
| 706 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
|---|
| 707 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
|---|
| 708 | if ( iRefIdx >= 0 ) |
|---|
| 709 | { |
|---|
| 710 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv); |
|---|
| 711 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
|---|
| 715 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
|---|
| 716 | } |
|---|
| 717 | #else |
|---|
| 718 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
|---|
| 719 | { |
|---|
| 720 | Int iMVPIdx = -1; |
|---|
| 721 | |
|---|
| 722 | TComMv cZeroMv( 0, 0 ); |
|---|
| 723 | TComMv cMv = cZeroMv; |
|---|
| 724 | Int iRefIdx = -1; |
|---|
| 725 | |
|---|
| 726 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
|---|
| 727 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
|---|
| 728 | |
|---|
| 729 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
|---|
| 730 | cMv = cZeroMv; |
|---|
| 731 | |
|---|
| 732 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) ) |
|---|
| 733 | { |
|---|
| 734 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
|---|
| 735 | #if H_MV_ENC_DEC_TRAC |
|---|
| 736 | #if ENC_DEC_TRACE |
|---|
| 737 | if ( eRefList == REF_PIC_LIST_0 ) |
|---|
| 738 | { |
|---|
| 739 | DTRACE_PU("mvp_l0_flag", iMVPIdx) |
|---|
| 740 | } |
|---|
| 741 | else |
|---|
| 742 | { |
|---|
| 743 | DTRACE_PU("mvp_l1_flag", iMVPIdx) |
|---|
| 744 | } |
|---|
| 745 | #endif |
|---|
| 746 | #endif |
|---|
| 747 | } |
|---|
| 748 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
|---|
| 749 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
|---|
| 750 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
|---|
| 751 | if ( iRefIdx >= 0 ) |
|---|
| 752 | { |
|---|
| 753 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv); |
|---|
| 754 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
|---|
| 755 | } |
|---|
| 756 | |
|---|
| 757 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
|---|
| 758 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
|---|
| 759 | } |
|---|
| 760 | #endif |
|---|
| 761 | |
|---|
| 762 | Void TDecEntropy::xDecodeTransform ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU ) |
|---|
| 763 | { |
|---|
| 764 | |
|---|
| 765 | TComDataCU *pcCU=rTu.getCU(); |
|---|
| 766 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
|---|
| 767 | const UInt uiDepth=rTu.GetTransformDepthTotal(); |
|---|
| 768 | const UInt uiTrDepth = rTu.GetTransformDepthRel(); |
|---|
| 769 | |
|---|
| 770 | #if H_MV_ENC_DEC_TRAC |
|---|
| 771 | #if ENC_DEC_TRACE |
|---|
| 772 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 773 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 774 | |
|---|
| 775 | DTRACE_TU_S("=========== transform_tree ===========\n") |
|---|
| 776 | DTRACE_TU("x0", uiLPelX) |
|---|
| 777 | DTRACE_TU("x1", uiTPelY) |
|---|
| 778 | |
|---|
| 779 | DTRACE_TU("log2TrafoSize", pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ) |
|---|
| 780 | DTRACE_TU("trafoDepth" , uiDepth) |
|---|
| 781 | #endif |
|---|
| 782 | #endif |
|---|
| 783 | |
|---|
| 784 | UInt uiSubdiv; |
|---|
| 785 | const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents(); |
|---|
| 786 | const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat()); |
|---|
| 787 | |
|---|
| 788 | const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize(); |
|---|
| 789 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 790 | if (bDebugRQT) |
|---|
| 791 | { |
|---|
| 792 | printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n", |
|---|
| 793 | rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber()); |
|---|
| 794 | fflush(stdout); |
|---|
| 795 | } |
|---|
| 796 | #endif |
|---|
| 797 | |
|---|
| 798 | if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
|---|
| 799 | { |
|---|
| 800 | uiSubdiv = 1; |
|---|
| 801 | } |
|---|
| 802 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->isInter(uiAbsPartIdx)) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
|---|
| 803 | { |
|---|
| 804 | uiSubdiv = (uiLog2TrafoSize >quadtreeTULog2MinSizeInCU); |
|---|
| 805 | } |
|---|
| 806 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
|---|
| 807 | { |
|---|
| 808 | uiSubdiv = 1; |
|---|
| 809 | } |
|---|
| 810 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
|---|
| 811 | { |
|---|
| 812 | uiSubdiv = 0; |
|---|
| 813 | } |
|---|
| 814 | else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU ) |
|---|
| 815 | { |
|---|
| 816 | uiSubdiv = 0; |
|---|
| 817 | } |
|---|
| 818 | else |
|---|
| 819 | { |
|---|
| 820 | assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU ); |
|---|
| 821 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
|---|
| 822 | } |
|---|
| 823 | |
|---|
| 824 | for(Int chan=COMPONENT_Cb; chan<numValidComponent; chan++) |
|---|
| 825 | { |
|---|
| 826 | const ComponentID compID=ComponentID(chan); |
|---|
| 827 | const UInt trDepthTotalAdj=rTu.GetTransformDepthTotalAdj(compID); |
|---|
| 828 | |
|---|
| 829 | const Bool bFirstCbfOfCU = uiTrDepth == 0; |
|---|
| 830 | |
|---|
| 831 | if( bFirstCbfOfCU ) |
|---|
| 832 | { |
|---|
| 833 | pcCU->setCbfSubParts( 0, compID, rTu.GetAbsPartIdxTU(compID), trDepthTotalAdj); |
|---|
| 834 | } |
|---|
| 835 | if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) ) |
|---|
| 836 | { |
|---|
| 837 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth - 1 ) ) |
|---|
| 838 | { |
|---|
| 839 | m_pcEntropyDecoderIf->parseQtCbf( rTu, compID, (uiSubdiv == 0) ); |
|---|
| 840 | } |
|---|
| 841 | } |
|---|
| 842 | } |
|---|
| 843 | |
|---|
| 844 | if( uiSubdiv ) |
|---|
| 845 | { |
|---|
| 846 | const UInt uiQPartNum = pcCU->getPic()->getNumPartitionsInCtu() >> ((uiDepth+1) << 1); |
|---|
| 847 | UInt uiYUVCbf[MAX_NUM_COMPONENT] = {0,0,0}; |
|---|
| 848 | |
|---|
| 849 | TComTURecurse tuRecurseChild(rTu, true); |
|---|
| 850 | |
|---|
| 851 | do |
|---|
| 852 | { |
|---|
| 853 | xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurseChild, quadtreeTULog2MinSizeInCU ); |
|---|
| 854 | UInt childTUAbsPartIdx=tuRecurseChild.GetAbsPartIdxTU(); |
|---|
| 855 | for(UInt ch=0; ch<numValidComponent; ch++) |
|---|
| 856 | { |
|---|
| 857 | uiYUVCbf[ch] |= pcCU->getCbf(childTUAbsPartIdx , ComponentID(ch), uiTrDepth+1 ); |
|---|
| 858 | } |
|---|
| 859 | } while (tuRecurseChild.nextSection(rTu) ); |
|---|
| 860 | |
|---|
| 861 | for(UInt ch=0; ch<numValidComponent; ch++) |
|---|
| 862 | { |
|---|
| 863 | UChar *pBase = pcCU->getCbf( ComponentID(ch) ) + uiAbsPartIdx; |
|---|
| 864 | const UChar flag = uiYUVCbf[ch] << uiTrDepth; |
|---|
| 865 | |
|---|
| 866 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
|---|
| 867 | { |
|---|
| 868 | pBase[ui] |= flag; |
|---|
| 869 | } |
|---|
| 870 | } |
|---|
| 871 | } |
|---|
| 872 | else |
|---|
| 873 | { |
|---|
| 874 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
|---|
| 875 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
|---|
| 876 | |
|---|
| 877 | #if !H_MV_ENC_DEC_TRAC |
|---|
| 878 | { |
|---|
| 879 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
|---|
| 880 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
|---|
| 881 | DTRACE_CABAC_V( uiAbsPartIdx ); |
|---|
| 882 | DTRACE_CABAC_T( "\tdepth=" ); |
|---|
| 883 | DTRACE_CABAC_V( uiDepth ); |
|---|
| 884 | DTRACE_CABAC_T( "\ttrdepth=" ); |
|---|
| 885 | DTRACE_CABAC_V( uiTrDepth ); |
|---|
| 886 | DTRACE_CABAC_T( "\n" ); |
|---|
| 887 | } |
|---|
| 888 | #endif |
|---|
| 889 | |
|---|
| 890 | pcCU->setCbfSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, uiDepth ); |
|---|
| 891 | |
|---|
| 892 | if( (!pcCU->isIntra(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && ((!bChroma) || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 )) )) |
|---|
| 893 | { |
|---|
| 894 | pcCU->setCbfSubParts( 1 << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, uiDepth ); |
|---|
| 895 | } |
|---|
| 896 | else |
|---|
| 897 | { |
|---|
| 898 | m_pcEntropyDecoderIf->parseQtCbf( rTu, COMPONENT_Y, true ); |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | |
|---|
| 902 | // transform_unit begin |
|---|
| 903 | UInt cbf[MAX_NUM_COMPONENT]={0,0,0}; |
|---|
| 904 | Bool validCbf = false; |
|---|
| 905 | Bool validChromaCbf = false; |
|---|
| 906 | const UInt uiTrIdx = rTu.GetTransformDepthRel(); |
|---|
| 907 | |
|---|
| 908 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
|---|
| 909 | { |
|---|
| 910 | const ComponentID compID = ComponentID(ch); |
|---|
| 911 | |
|---|
| 912 | cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrIdx ); |
|---|
| 913 | |
|---|
| 914 | if (cbf[compID] != 0) |
|---|
| 915 | { |
|---|
| 916 | validCbf = true; |
|---|
| 917 | if (isChroma(compID)) |
|---|
| 918 | { |
|---|
| 919 | validChromaCbf = true; |
|---|
| 920 | } |
|---|
| 921 | } |
|---|
| 922 | } |
|---|
| 923 | |
|---|
| 924 | if ( validCbf ) |
|---|
| 925 | { |
|---|
| 926 | |
|---|
| 927 | // dQP: only for CTU |
|---|
| 928 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
|---|
| 929 | { |
|---|
| 930 | if ( bCodeDQP ) |
|---|
| 931 | { |
|---|
| 932 | const UInt uiAbsPartIdxCU=rTu.GetAbsPartIdxCU(); |
|---|
| 933 | decodeQP( pcCU, uiAbsPartIdxCU); |
|---|
| 934 | bCodeDQP = false; |
|---|
| 935 | } |
|---|
| 936 | } |
|---|
| 937 | |
|---|
| 938 | if ( pcCU->getSlice()->getUseChromaQpAdj() ) |
|---|
| 939 | { |
|---|
| 940 | if ( validChromaCbf && isChromaQpAdjCoded && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) ) |
|---|
| 941 | { |
|---|
| 942 | decodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() ); |
|---|
| 943 | isChromaQpAdjCoded = false; |
|---|
| 944 | } |
|---|
| 945 | } |
|---|
| 946 | |
|---|
| 947 | const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); |
|---|
| 948 | |
|---|
| 949 | for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++) |
|---|
| 950 | { |
|---|
| 951 | const ComponentID compID=ComponentID(ch); |
|---|
| 952 | |
|---|
| 953 | if( rTu.ProcessComponentSection(compID) ) |
|---|
| 954 | { |
|---|
| 955 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 956 | if (bDebugRQT) |
|---|
| 957 | { |
|---|
| 958 | printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1); |
|---|
| 959 | } |
|---|
| 960 | #endif |
|---|
| 961 | |
|---|
| 962 | if (rTu.getRect(compID).width != rTu.getRect(compID).height) |
|---|
| 963 | { |
|---|
| 964 | //code two sub-TUs |
|---|
| 965 | TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
|---|
| 966 | |
|---|
| 967 | do |
|---|
| 968 | { |
|---|
| 969 | const UInt subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(), compID, (uiTrIdx + 1)); |
|---|
| 970 | |
|---|
| 971 | if (subTUCBF != 0) |
|---|
| 972 | { |
|---|
| 973 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 974 | if (bDebugRQT) |
|---|
| 975 | { |
|---|
| 976 | printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1); |
|---|
| 977 | } |
|---|
| 978 | #endif |
|---|
| 979 | m_pcEntropyDecoderIf->parseCoeffNxN( subTUIterator, compID ); |
|---|
| 980 | } |
|---|
| 981 | } while (subTUIterator.nextSection(rTu)); |
|---|
| 982 | } |
|---|
| 983 | else |
|---|
| 984 | { |
|---|
| 985 | if(isChroma(compID) && (cbf[COMPONENT_Y] != 0)) |
|---|
| 986 | { |
|---|
| 987 | m_pcEntropyDecoderIf->parseCrossComponentPrediction( rTu, compID ); |
|---|
| 988 | } |
|---|
| 989 | |
|---|
| 990 | if(cbf[compID] != 0) |
|---|
| 991 | { |
|---|
| 992 | m_pcEntropyDecoderIf->parseCoeffNxN( rTu, compID ); |
|---|
| 993 | } |
|---|
| 994 | } |
|---|
| 995 | } |
|---|
| 996 | } |
|---|
| 997 | } |
|---|
| 998 | // transform_unit end |
|---|
| 999 | } |
|---|
| 1000 | } |
|---|
| 1001 | |
|---|
| 1002 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
|---|
| 1003 | { |
|---|
| 1004 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
|---|
| 1005 | { |
|---|
| 1006 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
|---|
| 1007 | } |
|---|
| 1008 | } |
|---|
| 1009 | |
|---|
| 1010 | Void TDecEntropy::decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
|---|
| 1011 | { |
|---|
| 1012 | if ( pcCU->getSlice()->getUseChromaQpAdj() ) |
|---|
| 1013 | { |
|---|
| 1014 | m_pcEntropyDecoderIf->parseChromaQpAdjustment( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
|---|
| 1015 | } |
|---|
| 1016 | } |
|---|
| 1017 | |
|---|
| 1018 | |
|---|
| 1019 | //! decode coefficients |
|---|
| 1020 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded ) |
|---|
| 1021 | { |
|---|
| 1022 | #if H_3D_DIM_SDC |
|---|
| 1023 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) ) |
|---|
| 1024 | { |
|---|
| 1025 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
|---|
| 1026 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
|---|
| 1027 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
|---|
| 1028 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
|---|
| 1029 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
|---|
| 1030 | } |
|---|
| 1031 | #if H_3D_INTER_SDC |
|---|
| 1032 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) ) |
|---|
| 1033 | { |
|---|
| 1034 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
|---|
| 1035 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
|---|
| 1036 | assert( pcCU->getSlice()->getIsDepth() ); |
|---|
| 1037 | } |
|---|
| 1038 | #endif |
|---|
| 1039 | if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) |
|---|
| 1040 | { |
|---|
| 1041 | Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; |
|---|
| 1042 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; |
|---|
| 1043 | |
|---|
| 1044 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
|---|
| 1045 | { |
|---|
| 1046 | for( Int iPart = 0; iPart < iPartNum; iPart++ ) |
|---|
| 1047 | { |
|---|
| 1048 | if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) |
|---|
| 1049 | { |
|---|
| 1050 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ); |
|---|
| 1051 | } |
|---|
| 1052 | } |
|---|
| 1053 | } |
|---|
| 1054 | else |
|---|
| 1055 | { |
|---|
| 1056 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 1057 | return; |
|---|
| 1058 | } |
|---|
| 1059 | } |
|---|
| 1060 | #endif |
|---|
| 1061 | |
|---|
| 1062 | if( pcCU->isIntra(uiAbsPartIdx) ) |
|---|
| 1063 | { |
|---|
| 1064 | } |
|---|
| 1065 | else |
|---|
| 1066 | { |
|---|
| 1067 | UInt uiQtRootCbf = 1; |
|---|
| 1068 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
|---|
| 1069 | { |
|---|
| 1070 | m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf ); |
|---|
| 1071 | } |
|---|
| 1072 | if ( !uiQtRootCbf ) |
|---|
| 1073 | { |
|---|
| 1074 | static const UInt cbfZero[MAX_NUM_COMPONENT]={0,0,0}; |
|---|
| 1075 | pcCU->setCbfSubParts( cbfZero, uiAbsPartIdx, uiDepth ); |
|---|
| 1076 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
|---|
| 1077 | return; |
|---|
| 1078 | } |
|---|
| 1079 | |
|---|
| 1080 | } |
|---|
| 1081 | |
|---|
| 1082 | TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth); |
|---|
| 1083 | |
|---|
| 1084 | #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST |
|---|
| 1085 | if (bDebugRQT) |
|---|
| 1086 | { |
|---|
| 1087 | printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN); |
|---|
| 1088 | } |
|---|
| 1089 | #endif |
|---|
| 1090 | |
|---|
| 1091 | Int quadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx); |
|---|
| 1092 | |
|---|
| 1093 | xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurse, quadtreeTULog2MinSizeInCU ); |
|---|
| 1094 | } |
|---|
| 1095 | |
|---|
| 1096 | #if H_3D_INTER_SDC |
|---|
| 1097 | Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1098 | { |
|---|
| 1099 | pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth ); |
|---|
| 1100 | if ( pcCU->isSkipped( uiAbsPartIdx ) ) |
|---|
| 1101 | { |
|---|
| 1102 | return; |
|---|
| 1103 | } |
|---|
| 1104 | |
|---|
| 1105 | |
|---|
| 1106 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || |
|---|
| 1107 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) ) |
|---|
| 1108 | { |
|---|
| 1109 | return; |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) ) |
|---|
| 1113 | { |
|---|
| 1114 | return; |
|---|
| 1115 | } |
|---|
| 1116 | |
|---|
| 1117 | assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); |
|---|
| 1118 | m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 1119 | } |
|---|
| 1120 | #endif |
|---|
| 1121 | #if H_3D_DBBP |
|---|
| 1122 | Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1123 | { |
|---|
| 1124 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
|---|
| 1125 | { |
|---|
| 1126 | m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 1127 | } |
|---|
| 1128 | } |
|---|
| 1129 | #endif |
|---|
| 1130 | |
|---|
| 1131 | |
|---|
| 1132 | |
|---|
| 1133 | //! \} |
|---|