Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecEntropy.cpp


Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/TDecEntropy.cpp

    r1196 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3737
    3838#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"
     44static const Bool bDebugRQT = DebugOptionList::DebugRQT.getInt()!=0;
     45static const Bool bDebugPredEnabled = DebugOptionList::DebugPred.getInt()!=0;
     46#endif
    3947
    4048//! \ingroup TLibDecoder
     
    5260  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
    5361}
    54 #if H_3D
     62#if NH_3D_DIS
    5563Void TDecEntropy::decodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    5664{
     
    5967    return;
    6068  } 
    61 
    6269  m_pcEntropyDecoderIf->parseDIS( pcCU, uiAbsPartIdx, uiDepth );
    6370}
     
    6875  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
    6976}
     77
    7078
    7179/** decode merge flag
    7280 * \param pcSubCU
    73  * \param uiAbsPartIdx 
     81 * \param uiAbsPartIdx
    7482 * \param uiDepth
    75  * \param uiPUIdx 
     83 * \param uiPUIdx
    7684 * \returns Void
    7785 */
    7886Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
    79 { 
     87{
    8088  // at least one merge candidate exists
    8189  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
     
    8492/** decode merge index
    8593 * \param pcCU
    86  * \param uiPartIdx
    87  * \param uiAbsPartIdx
    88  * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours
    89  * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours
     94 * \param uiPartIdx
     95 * \param uiAbsPartIdx
    9096 * \param uiDepth
    9197 * \returns Void
     
    98104}
    99105
    100 #if H_3D_ARP
     106#if NH_3D_ARP
    101107Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    102108{
     
    117123#endif
    118124
    119 #if H_3D_IC
     125#if NH_3D_IC
    120126Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    121127{
    122128  pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
    123129
     130#if NH_3D_ARP
    124131  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
     132#else
     133  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
     134#endif
    125135  {
    126136    return;
     
    155165  {
    156166    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
    157 #if H_3D_DIM_SDC
    158     decodeSDCFlag   ( pcCU, uiAbsPartIdx, uiDepth );   
    159 #if H_3D_DISABLE_CHROMA
    160     if(!pcCU->getSDCFlag(uiAbsPartIdx) && pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0  )
    161 #else
    162     if(!pcCU->getSDCFlag(uiAbsPartIdx))
    163 #endif
    164 #endif
    165     decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
     167#if NH_3D_SDC_INTRA
     168    decodeSDCFlag   ( pcCU, uiAbsPartIdx, uiDepth );
     169#endif
     170    if (pcCU->getPic()->getChromaFormat()!=CHROMA_400)
     171    {
     172      decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
     173      if (enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) && pcCU->getPartitionSize( uiAbsPartIdx )==SIZE_NxN)
     174      {
     175        UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2;
     176        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset,   uiDepth+1 );
     177        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 );
     178        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 );
     179      }
     180    }
    166181  }
    167182  else                                                                // if it is Inter mode, encode motion vector and reference index
     
    171186}
    172187
    173 /** Parse I_PCM information. 
     188/** Parse I_PCM information.
    174189 * \param pcCU  pointer to CUpointer to CU
    175190 * \param uiAbsPartIdx CU index
     
    185200    return;
    186201  }
    187  
     202
    188203  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
    189204}
     
    197212{
    198213  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
    199 }
     214#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     215  if (bDebugPredEnabled)
     216  {
     217    UInt cdir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiAbsPartIdx);
     218    if (cdir==36)
     219    {
     220      cdir=pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx);
     221    }
     222    printf("coding chroma Intra dir: %d, uiAbsPartIdx: %d, luma dir: %d\n", cdir, uiAbsPartIdx, pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx));
     223  }
     224#endif
     225}
     226
    200227
    201228/** decode motion information for every PU block.
    202229 * \param pcCU
    203  * \param uiAbsPartIdx 
     230 * \param uiAbsPartIdx
    204231 * \param uiDepth
    205232 * \param pcSubCU
     
    210237  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    211238  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
    212   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
    213 
    214 #if H_3D_IV_MERGE
     239  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
     240//#if H_3D_IV_MERGE
     241#if NH_3D_MLC
    215242  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    216243  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    219246  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    220247#endif
    221 #if H_3D_SPIVMP
     248#if NH_3D_SPIVMP
    222249  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];     
    223   TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2];
    224   UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()];
     250  TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2];
     251  UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()];
     252#endif
     253#if NH_3D_IV_MERGE
     254  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
    225255#endif
    226256  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
     
    229259  }
    230260  Int numValidMergeCand = 0;
    231   Bool isMerged = false;
     261  Bool hasMergedCandList = false;
    232262
    233263  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    234264  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    235 #if H_3D_IV_MERGE
    236   pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
    237 #endif
    238 #if H_3D
     265#if NH_3D
    239266  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
    240267  {
     
    268295
    269296  ////// Parse CUs extension syntax
     297#if NH_3D_DBBP
    270298  decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
    271   decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth );
    272 
    273 #if H_3D_ARP
     299#endif
     300#if NH_3D_SDC_INTER
     301  decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth );
     302#endif
     303#if NH_3D_ARP
    274304  decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
    275305#endif
    276 #if H_3D_IC
     306#if NH_3D_IC
    277307  decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    278308#endif
     
    284314    {
    285315      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    286 #if H_3D_DBBP
     316#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     317      if (bDebugPredEnabled)
     318      {
     319        std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx;
     320        std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl;
     321      }
     322#endif
     323
     324#if NH_3D_DBBP
    287325      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
    288326#else
     
    290328#endif
    291329      {
    292         pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    293         if ( !isMerged )
    294         {
    295 #if H_3D_VSP
     330        if ( !hasMergedCandList )
     331        {
     332          pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
     333
     334#if NH_3D_MLC
     335#if NH_3D_VSP
    296336          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    297337          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    298 #if H_3D_SPIVMP
     338#endif
     339#if NH_3D_SPIVMP
    299340          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    300341#endif
    301342          pcSubCU->initAvailableFlags();
    302           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
     343#endif
     344          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     345#if NH_3D_MLC
    303346          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    304 #if H_3D_SPIVMP
     347#if NH_3D_SPIVMP
    305348            , pcMvFieldSP, puhInterDirSP
    306349#endif
    307350            , numValidMergeCand );
    308           pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
    309 #if H_3D_SPIVMP
     351          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
     352#if NH_3D_VSP
     353            , vspFlag
     354#endif
     355#if NH_3D_SPIVMP
    310356            , bSPIVMPFlag
    311357#endif
    312358            , numValidMergeCand );
     359#if NH_3D_VSP
    313360          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    314 
    315 #else
    316 #if H_3D
    317           pcSubCU->initAvailableFlags();
    318           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
    319           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    320 
    321 #else
    322           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    323 #endif
    324 #endif
    325           isMerged = true;
    326         }
    327         pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
     361#endif
     362#endif
     363          pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
     364          hasMergedCandList = true;
     365        }
    328366      }
    329367      else
    330368      {
    331         uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    332 #if H_3D_VSP
     369#if NH_3D_MLC
     370#if NH_3D_VSP
    333371        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    334372        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    335 #if H_3D_SPIVMP
     373#endif
     374#if NH_3D_SPIVMP
    336375        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    337376#endif
    338377        pcSubCU->initAvailableFlags();
     378#endif
    339379        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     380#if NH_3D_MLC
    340381        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
    341 #if H_3D_SPIVMP
     382#if NH_3D_SPIVMP
    342383          , pcMvFieldSP, puhInterDirSP
    343384#endif
    344385          ,numValidMergeCand, uiMergeIndex );
    345         pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
    346 #if H_3D_SPIVMP
     386        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
     387#if NH_3D_VSP
     388          , vspFlag
     389#endif
     390#if NH_3D_SPIVMP
    347391          , bSPIVMPFlag
    348392#endif
    349393          ,numValidMergeCand );
     394#if NH_3D_VSP
    350395        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    351 #else
    352 #if H_3D
    353         pcSubCU->initAvailableFlags();
    354         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    355         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    356 #else
    357         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    358396#endif
    359397#endif
     
    363401      TComMv cTmpMv( 0, 0 );
    364402      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    365       {       
     403      {
    366404        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    367405        {
     
    370408          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    371409          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    372 #if H_3D_VSP
    373 #if H_3D_DBBP
     410#if NH_3D_VSP
     411#if NH_3D_DBBP
    374412          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
    375413#else
     
    390428        }
    391429      }
    392 #if H_3D_SPIVMP
     430#if NH_3D_SPIVMP
    393431      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
    394432      if (bSPIVMPFlag[uiMergeIndex] != 0)
     
    421459        {
    422460          decodeMvsAMVP   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
     461#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     462          if (bDebugPredEnabled)
     463          {
     464            std::cout << "refListIdx: " << uiRefListIdx << std::endl;
     465            std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl;
     466            std::cout << "MVD vertical:   " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl;
     467            std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl;
     468            std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl;
     469          }
     470#endif
    423471        }
    424472      }
     
    445493    {
    446494      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
     495#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     496      if (bDebugPredEnabled)
     497      {
     498        std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx;
     499        std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl;
     500      }
     501#endif
     502#if NH_3D_IC
     503      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
     504#endif
     505
    447506      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    448       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    449       {
    450         pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    451         if ( !isMerged )
    452         {
     507      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
     508      {
     509        if ( !hasMergedCandList )
     510        {
     511          pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
     512
     513#if NH_3D_MLC
     514#if NH_3D_VSP
     515          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     516          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
     517#endif
     518#if NH_3D_SPIVMP
     519          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
     520#endif
     521          pcSubCU->initAvailableFlags();
     522#endif
    453523          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    454           isMerged = true;
    455         }
    456         pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
     524#if NH_3D_MLC
     525          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
     526#if NH_3D_SPIVMP
     527            , pcMvFieldSP, puhInterDirSP
     528#endif
     529            , numValidMergeCand );
     530          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
     531#if NH_3D_VSP
     532            , vspFlag
     533#endif
     534#if NH_3D_SPIVMP
     535            , bSPIVMPFlag
     536#endif
     537            , numValidMergeCand );
     538#if NH_3D_VSP
     539          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
     540#endif
     541#endif
     542          pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
     543          hasMergedCandList = true;
     544        }
    457545      }
    458546      else
    459547      {
    460548        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     549
     550#if NH_3D_MLC
     551#if NH_3D_VSP
     552        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     553        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
     554#endif
     555#if NH_3D_SPIVMP
     556        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
     557#endif
     558        pcSubCU->initAvailableFlags();
     559#endif
    461560        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    462       }
     561#if NH_3D_MLC
     562        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
     563#if NH_3D_SPIVMP
     564          , pcMvFieldSP, puhInterDirSP
     565#endif
     566          ,numValidMergeCand, uiMergeIndex );
     567        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
     568#if NH_3D_VSP
     569          , vspFlag
     570#endif
     571#if NH_3D_SPIVMP
     572          , bSPIVMPFlag
     573#endif
     574          ,numValidMergeCand );
     575#if NH_3D_VSP
     576        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
     577#endif
     578#endif
     579      }
     580
    463581      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    464582
    465583      TComMv cTmpMv( 0, 0 );
    466584      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    467       {       
     585      {
    468586        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    469587        {
     
    472590          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    473591          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
    474         }
    475       }
     592#if NH_3D_VSP
     593          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
     594          {
     595            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
     596            {
     597              UInt dummy;
     598              Int vspSize;
     599              Int width, height;
     600              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
     601              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
     602              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
     603            }
     604          }
     605#endif
     606        }
     607      }
     608#if NH_3D_SPIVMP
     609      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
     610      if (bSPIVMPFlag[uiMergeIndex] != 0)
     611      {
     612        Int iWidth, iHeight;
     613        UInt uiIdx;
     614        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
     615
     616        UInt uiSPAddr;
     617
     618        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
     619
     620        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
     621
     622        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
     623        {
     624          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
     625          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
     626          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
     627          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
     628        }
     629      }
     630#endif
    476631    }
    477632    else
     
    479634      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    480635      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    481       {       
     636      {
    482637        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    483638        {
     
    485640          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    486641          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
    487         }
    488       }
    489     }
     642#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     643          if (bDebugPredEnabled)
     644          {
     645            std::cout << "refListIdx: " << uiRefListIdx << std::endl;
     646            std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl;
     647            std::cout << "MVD vertical:   " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl;
     648            std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl;
     649            std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl;
     650          }
     651#endif
     652        }
     653      }
     654#if NH_3D_IC
     655      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
     656#endif
     657    }
     658
    490659    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
    491660    {
     
    496665  }
    497666#endif
    498 #if H_3D_SPIVMP
     667#if NH_3D_SPIVMP
    499668  delete[] pcMvFieldSP;
    500669  delete[] puhInterDirSP;
     
    505674/** decode inter direction for a PU block
    506675 * \param pcCU
    507  * \param uiAbsPartIdx 
     676 * \param uiAbsPartIdx
    508677 * \param uiDepth
    509  * \param uiPartIdx 
     678 * \param uiPartIdx
    510679 * \returns Void
    511680 */
     
    550719/** decode motion vector difference for a PU block
    551720 * \param pcCU
    552  * \param uiAbsPartIdx 
     721 * \param uiAbsPartIdx
    553722 * \param uiDepth
    554723 * \param uiPartIdx
    555  * \param eRefList 
     724 * \param eRefList
    556725 * \returns Void
    557726 */
     
    564733}
    565734
    566 #if H_3D
     735#if NH_3D
    567736Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
    568737{
     
    656825#endif
    657826
    658 Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU)
    659 {
     827Void TDecEntropy::xDecodeTransform        ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU )
     828{
     829
     830  TComDataCU *pcCU=rTu.getCU();
     831  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
     832  const UInt uiDepth=rTu.GetTransformDepthTotal();
     833  const UInt uiTrDepth = rTu.GetTransformDepthRel();
    660834
    661835#if H_MV_ENC_DEC_TRAC
     
    663837  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    664838  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    665  
     839
    666840  DTRACE_TU_S("=========== transform_tree ===========\n")
    667841  DTRACE_TU("x0", uiLPelX)
    668842  DTRACE_TU("x1", uiTPelY)
    669   DTRACE_TU("log2TrafoSize", g_uiMaxCUWidth>>uiDepth)
     843 
     844  DTRACE_TU("log2TrafoSize", pcCU->getSlice()->getSPS()->getMaxCUWidth()  >> uiDepth )
    670845  DTRACE_TU("trafoDepth"  , uiDepth)
    671846#endif
     
    673848
    674849  UInt uiSubdiv;
    675   const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
    676 
    677   if(uiTrIdx==0)
    678   {
    679     m_bakAbsPartIdxCU = uiAbsPartIdx;
    680   }
    681   if( uiLog2TrafoSize == 2 )
    682   {
    683     UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
    684     if( ( uiAbsPartIdx % partNum ) == 0 )
    685     {
    686       m_uiBakAbsPartIdx   = uiAbsPartIdx;
    687       m_uiBakChromaOffset = offsetChroma;
    688     }
    689   }
    690   if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
     850  const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents();
     851  const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat());
     852
     853  const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize();
     854#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     855  if (bDebugRQT)
     856  {
     857    printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n",
     858        rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber());
     859    fflush(stdout);
     860  }
     861#endif
     862
     863  if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
    691864  {
    692865    uiSubdiv = 1;
    693866  }
    694   else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
    695   {
    696     uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU);
     867  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->isInter(uiAbsPartIdx)) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
     868  {
     869    uiSubdiv = (uiLog2TrafoSize >quadtreeTULog2MinSizeInCU);
    697870  }
    698871  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     
    713886    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
    714887  }
    715  
    716   const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
    717   {
     888
     889  for(Int chan=COMPONENT_Cb; chan<numValidComponent; chan++)
     890  {
     891    const ComponentID compID=ComponentID(chan);
     892    const UInt trDepthTotalAdj=rTu.GetTransformDepthTotalAdj(compID);
     893
    718894    const Bool bFirstCbfOfCU = uiTrDepth == 0;
     895
    719896    if( bFirstCbfOfCU )
    720897    {
    721       pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
    722       pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
    723     }
    724     if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
    725     {
    726 #if H_3D_DISABLE_CHROMA
    727       if (pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 )     
    728       {
    729         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
    730         {
    731           m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
    732         }
    733         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
    734         {
    735           m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
    736         }
    737       }
    738       else
    739       {
    740         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
    741         {
    742           pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiTrDepth - 1 );
    743         }
    744         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
    745         {
    746           pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiTrDepth - 1 );
    747         }
    748       }
    749 #else
    750       if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
    751       {
    752         m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
    753       }
    754       if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
    755       {
    756         m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
    757       }
    758 #endif
    759     }
    760     else
    761     {
    762       pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
    763       pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
    764     }
    765   }
    766  
     898      pcCU->setCbfSubParts( 0, compID, rTu.GetAbsPartIdxTU(compID), trDepthTotalAdj);
     899    }
     900    if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) )
     901    {
     902      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth - 1 ) )
     903      {
     904        m_pcEntropyDecoderIf->parseQtCbf( rTu, compID, (uiSubdiv == 0) );
     905      }
     906    }
     907  }
     908
    767909  if( uiSubdiv )
    768910  {
    769     UInt size;
    770     width  >>= 1;
    771     height >>= 1;
    772     size = width*height;
    773     uiTrIdx++;
    774     ++uiDepth;
    775     const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
    776     const UInt uiStartAbsPartIdx = uiAbsPartIdx;
    777     UInt uiYCbf = 0;
    778     UInt uiUCbf = 0;
    779     UInt uiVCbf = 0;
    780    
    781     for( Int i = 0; i < 4; i++ )
    782     {
    783       xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU );
    784       uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
    785       uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
    786       uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
    787       uiAbsPartIdx += uiQPartNum;
    788       offsetLuma += size;  offsetChroma += (size>>2);
    789     }
    790    
    791     for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
    792     {
    793       pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
    794       pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
    795       pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
     911    const UInt uiQPartNum = pcCU->getPic()->getNumPartitionsInCtu() >> ((uiDepth+1) << 1);
     912    UInt uiYUVCbf[MAX_NUM_COMPONENT] = {0,0,0};
     913
     914    TComTURecurse tuRecurseChild(rTu, true);
     915
     916    do
     917    {
     918      xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurseChild, quadtreeTULog2MinSizeInCU );
     919      UInt childTUAbsPartIdx=tuRecurseChild.GetAbsPartIdxTU();
     920      for(UInt ch=0; ch<numValidComponent; ch++)
     921      {
     922        uiYUVCbf[ch] |= pcCU->getCbf(childTUAbsPartIdx , ComponentID(ch),  uiTrDepth+1 );
     923      }
     924    } while (tuRecurseChild.nextSection(rTu) );
     925
     926    for(UInt ch=0; ch<numValidComponent; ch++)
     927    {
     928      UChar *pBase = pcCU->getCbf( ComponentID(ch) ) + uiAbsPartIdx;
     929      const UChar flag = uiYUVCbf[ch] << uiTrDepth;
     930
     931      for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
     932      {
     933        pBase[ui] |= flag;
     934      }
    796935    }
    797936  }
     
    800939    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
    801940    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
    802    
     941
    803942#if !H_MV_ENC_DEC_TRAC
    804943    {
     
    813952    }
    814953#endif
    815    
    816     pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
    817     if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
    818     {
    819       pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     954
     955    pcCU->setCbfSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, uiDepth );
     956
     957    if( (!pcCU->isIntra(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && ((!bChroma) || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 )) ))
     958    {
     959      pcCU->setCbfSubParts( 1 << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, uiDepth );
    820960    }
    821961    else
    822962    {
    823       m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
     963      m_pcEntropyDecoderIf->parseQtCbf( rTu, COMPONENT_Y, true );
    824964    }
    825965
    826966
    827967    // transform_unit begin
    828     UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
    829     UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
    830     UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
    831     if( uiLog2TrafoSize == 2 )
    832     {
    833       UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
    834       if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
    835       {
    836         cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
    837         cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
    838       }
    839     }
    840     if ( cbfY || cbfU || cbfV )
    841     {
    842       // dQP: only for LCU
     968    UInt cbf[MAX_NUM_COMPONENT]={0,0,0};
     969    Bool validCbf       = false;
     970    Bool validChromaCbf = false;
     971    const UInt uiTrIdx = rTu.GetTransformDepthRel();
     972
     973    for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
     974    {
     975      const ComponentID compID = ComponentID(ch);
     976
     977      cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrIdx );
     978
     979      if (cbf[compID] != 0)
     980      {
     981        validCbf = true;
     982        if (isChroma(compID))
     983        {
     984          validChromaCbf = true;
     985        }
     986      }
     987    }
     988
     989    if ( validCbf )
     990    {
     991
     992      // dQP: only for CTU
    843993      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
    844994      {
    845995        if ( bCodeDQP )
    846996        {
    847           decodeQP( pcCU, m_bakAbsPartIdxCU);
     997          const UInt uiAbsPartIdxCU=rTu.GetAbsPartIdxCU();
     998          decodeQP( pcCU, uiAbsPartIdxCU);
    848999          bCodeDQP = false;
    8491000        }
    8501001      }
    851     }
    852     if( cbfY )
    853     {
    854       Int trWidth = width;
    855       Int trHeight = height;
    856       m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
    857     }
    858     if( uiLog2TrafoSize > 2 )
    859     {
    860       Int trWidth = width >> 1;
    861       Int trHeight = height >> 1;
    862       if( cbfU )
    863       {
    864         m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
    865       }
    866       if( cbfV )
    867       {
    868         m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
    869       }
    870     }
    871     else
    872     {
    873       UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
    874       if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
    875       {
    876         Int trWidth = width;
    877         Int trHeight = height;
    878         if( cbfU )
    879         {
    880           m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
    881         }
    882         if( cbfV )
    883         {
    884           m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
     1002
     1003      if ( pcCU->getSlice()->getUseChromaQpAdj() )
     1004      {
     1005        if ( validChromaCbf && isChromaQpAdjCoded && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) )
     1006        {
     1007          decodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() );
     1008          isChromaQpAdjCoded = false;
     1009        }
     1010      }
     1011
     1012      const UInt numValidComp=pcCU->getPic()->getNumberValidComponents();
     1013
     1014      for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++)
     1015      {
     1016        const ComponentID compID=ComponentID(ch);
     1017
     1018        if( rTu.ProcessComponentSection(compID) )
     1019        {
     1020#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     1021          if (bDebugRQT)
     1022          {
     1023            printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1);
     1024          }
     1025#endif
     1026
     1027          if (rTu.getRect(compID).width != rTu.getRect(compID).height)
     1028          {
     1029            //code two sub-TUs
     1030            TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
     1031
     1032            do
     1033            {
     1034              const UInt subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(), compID, (uiTrIdx + 1));
     1035
     1036              if (subTUCBF != 0)
     1037              {
     1038#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     1039                if (bDebugRQT)
     1040                {
     1041                  printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1);
     1042                }
     1043#endif
     1044                m_pcEntropyDecoderIf->parseCoeffNxN( subTUIterator, compID );
     1045              }
     1046            } while (subTUIterator.nextSection(rTu));
     1047          }
     1048          else
     1049          {
     1050            if(isChroma(compID) && (cbf[COMPONENT_Y] != 0))
     1051            {
     1052              m_pcEntropyDecoderIf->parseCrossComponentPrediction( rTu, compID );
     1053            }
     1054
     1055            if(cbf[compID] != 0)
     1056            {
     1057              m_pcEntropyDecoderIf->parseCoeffNxN( rTu, compID );
     1058            }
     1059          }
    8851060        }
    8861061      }
     
    8981073}
    8991074
    900 
    901 /** decode coefficients
    902  * \param pcCU
    903  * \param uiAbsPartIdx
    904  * \param uiDepth
    905  * \param uiWidth
    906  * \param uiHeight
    907  * \returns Void
    908  */
    909 Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
    910 {
    911   UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
    912   UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
    913   UInt uiChromaOffset = uiLumaOffset>>2;
    914 #if H_3D_DIM_SDC
     1075Void TDecEntropy::decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx )
     1076{
     1077  if ( pcCU->getSlice()->getUseChromaQpAdj() )
     1078  {
     1079    m_pcEntropyDecoderIf->parseChromaQpAdjustment( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
     1080  }
     1081}
     1082
     1083
     1084//! decode coefficients
     1085Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded )
     1086{
     1087#if NH_3D_SDC_INTRA
    9151088  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
    9161089  {
    9171090    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
    9181091    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
    919     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
    920 #if H_3D_DISABLE_CHROMA
    921     if (pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 )
    922     {
    923       assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
    924       assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
    925     }
    926 #else
    927     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
    928     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
    929 #endif
    930   }
    931 
    932 #if H_3D_INTER_SDC
     1092    assert( pcCU->getCbf(uiAbsPartIdx, COMPONENT_Y) == 1 );
     1093}
     1094#endif
     1095#if NH_3D_SDC_INTER
    9331096  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
    9341097  {
     
    9381101  }
    9391102#endif
    940   if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
    941   {
    942     Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
    943     UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
    944  
    945     if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
    946     {
    947       for( Int iPart = 0; iPart < iPartNum; iPart++ )
    948       {
    949         if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE )
    950         {
    951           m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
    952         }
    953       }
    954     }
    955     else
     1103#if NH_3D
     1104  if( pcCU->getSlice()->getIsDepth() )
     1105  {
     1106#if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
     1107    if( pcCU->getSDCFlag( uiAbsPartIdx ) )
    9561108    {
    9571109      m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
    9581110      return;
    9591111    }
     1112#endif
     1113#if NH_3D_DMM
     1114    if( pcCU->isIntra( uiAbsPartIdx ) )
     1115    {
     1116      Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
     1117      UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
     1118      for( Int iPart = 0; iPart < iPartNum; iPart++ )
     1119      {
     1120        if( isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx + uiPartOffset*iPart ) ) )
     1121        {
     1122          m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
     1123        }
     1124      }
     1125    }
     1126#endif
    9601127  }
    9611128#endif
     
    9731140    if ( !uiQtRootCbf )
    9741141    {
    975       pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
     1142      static const UInt cbfZero[MAX_NUM_COMPONENT]={0,0,0};
     1143      pcCU->setCbfSubParts( cbfZero, uiAbsPartIdx, uiDepth );
    9761144      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
    9771145      return;
    9781146    }
    979    
    980   }
    981 
    982   Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
    983 
    984   xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU );
    985 }
    986 
    987 #if H_3D_INTER_SDC
     1147
     1148  }
     1149
     1150  TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth);
     1151
     1152#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     1153  if (bDebugRQT)
     1154  {
     1155    printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN);
     1156  }
     1157#endif
     1158
     1159  Int quadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
     1160 
     1161  xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurse, quadtreeTULog2MinSizeInCU );
     1162}
     1163
     1164#if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    9881165Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    9891166{
     
    10101187}
    10111188#endif
    1012 #if H_3D_DBBP
     1189#if NH_3D_DBBP
    10131190Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    10141191{
     
    10201197#endif
    10211198
     1199
     1200
    10221201//! \}
Note: See TracChangeset for help on using the changeset viewer.