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


Ignore:
Timestamp:
11 May 2012, 21:20:17 (13 years ago)
Author:
hschwarz
Message:

updated trunk (move to HM6.1)

File:
1 edited

Legend:

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

    r5 r56  
    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-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TDecEntropy.cpp
    3735    \brief    entropy decoder class
     
    4038#include "TDecEntropy.h"
    4139
     40//! \ingroup TLibDecoder
     41//! \{
     42
    4243Void TDecEntropy::setEntropyDecoder         ( TDecEntropyIf* p )
    4344{
     
    4546}
    4647
    47 #include "../TLibCommon/TComAdaptiveLoopFilter.h"
    48 
    49 Void TDecEntropy::decodeAux(ALFParam* pAlfParam)
    50 {
    51   UInt uiSymbol;
    52   Int sqrFiltLengthTab[3] = {SQR_FILT_LENGTH_9SYM, SQR_FILT_LENGTH_7SYM, SQR_FILT_LENGTH_5SYM};
    53   Int FiltTab[3] = {9, 7, 5};
    54  
    55   pAlfParam->filters_per_group = 0;
    56  
    57   memset (pAlfParam->filterPattern, 0 , sizeof(Int)*NO_VAR_BINS);
    58 #if ENABLE_FORCECOEFF0
    59   m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    60   if (!uiSymbol) pAlfParam->filtNo = -1;
    61   else pAlfParam->filtNo = uiSymbol; //nonZeroCoeffs
    62 #else
    63   pAlfParam->filtNo = 1; //nonZeroCoeffs
    64 #endif
    65 
    66 #if MQT_BA_RA
    67   m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol);
    68   pAlfParam->alf_pcr_region_flag = uiSymbol; 
    69 #endif
    70 
    71   m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol);
    72   Int TabIdx = uiSymbol;
    73   pAlfParam->realfiltNo = 2-TabIdx;
    74   pAlfParam->tap = FiltTab[pAlfParam->realfiltNo];
    75 #if TI_ALF_MAX_VSIZE_7
    76   pAlfParam->tapV = TComAdaptiveLoopFilter::ALFTapHToTapV(pAlfParam->tap);
    77 #endif
    78   pAlfParam->num_coeff = sqrFiltLengthTab[pAlfParam->realfiltNo];
    79  
    80   if (pAlfParam->filtNo>=0)
    81   {
    82     if(pAlfParam->realfiltNo >= 0)
    83     {
    84       // filters_per_fr
    85       m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol);
    86       pAlfParam->noFilters = uiSymbol + 1;
    87       pAlfParam->filters_per_group = pAlfParam->noFilters;
    88 
    89       if(pAlfParam->noFilters == 2)
    90       {
    91         m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol);
    92         pAlfParam->startSecondFilter = uiSymbol;
    93         pAlfParam->filterPattern [uiSymbol] = 1;
    94       }
    95       else if (pAlfParam->noFilters > 2)
    96       {
    97         pAlfParam->filters_per_group = 1;
    98         for (int i=1; i<NO_VAR_BINS; i++)
    99         {
    100           m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol);
    101           pAlfParam->filterPattern[i] = uiSymbol;
    102           pAlfParam->filters_per_group += uiSymbol;
    103         }
    104       }
    105     }
    106   }
    107   else
    108   {
    109     memset (pAlfParam->filterPattern, 0, NO_VAR_BINS*sizeof(Int));
    110   }
    111   // Reconstruct varIndTab[]
    112   memset(pAlfParam->varIndTab, 0, NO_VAR_BINS * sizeof(int));
    113   if(pAlfParam->filtNo>=0)
    114   {
    115     for(Int i = 1; i < NO_VAR_BINS; ++i)
    116     {
    117       if(pAlfParam->filterPattern[i])
    118         pAlfParam->varIndTab[i] = pAlfParam->varIndTab[i-1] + 1;
    119       else
    120         pAlfParam->varIndTab[i] = pAlfParam->varIndTab[i-1];
    121     }
    122   }
    123 }
    124 
    125 Void TDecEntropy::readFilterCodingParams(ALFParam* pAlfParam)
    126 {
    127   UInt uiSymbol;
    128   int ind, scanPos;
    129   int golombIndexBit;
    130   int kMin;
    131   int maxScanVal;
    132   int *pDepthInt;
    133   int fl;
    134  
    135   // Determine fl
    136   if(pAlfParam->num_coeff == SQR_FILT_LENGTH_9SYM)
    137     fl = 4;
    138   else if(pAlfParam->num_coeff == SQR_FILT_LENGTH_7SYM)
    139     fl = 3;
    140   else
    141     fl = 2;
    142  
    143   // Determine maxScanVal
    144   maxScanVal = 0;
    145   pDepthInt = pDepthIntTab[fl - 2];
    146   for(ind = 0; ind < pAlfParam->num_coeff; ind++)
    147     maxScanVal = max(maxScanVal, pDepthInt[ind]);
    148  
    149   // Golomb parameters
    150   m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol);
    151   pAlfParam->minKStart = 1 + uiSymbol;
    152  
    153   kMin = pAlfParam->minKStart;
    154   for(scanPos = 0; scanPos < maxScanVal; scanPos++)
    155   {
    156     m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    157     golombIndexBit = uiSymbol;
    158     if(golombIndexBit)
    159       pAlfParam->kMinTab[scanPos] = kMin + 1;
    160     else
    161       pAlfParam->kMinTab[scanPos] = kMin;
    162     kMin = pAlfParam->kMinTab[scanPos];
    163   }
    164 }
    165 
    166 Int TDecEntropy::golombDecode(Int k)
    167 {
    168   UInt uiSymbol;
    169   Int q = -1;
    170   Int nr = 0;
    171   Int m = (Int)pow(2.0, k);
    172   Int a;
    173  
    174   uiSymbol = 1;
    175   while (uiSymbol)
    176   {
    177     m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    178     q++;
    179   }
    180   for(a = 0; a < k; ++a)          // read out the sequential log2(M) bits
    181   {
    182     m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    183     if(uiSymbol)
    184       nr += 1 << a;
    185   }
    186   nr += q * m;                    // add the bits and the multiple of M
    187   if(nr != 0)
    188   {
    189     m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    190     nr = (uiSymbol)? nr: -nr;
    191   }
    192   return nr;
    193 }
    194 
    195 
    196 
    197 Void TDecEntropy::readFilterCoeffs(ALFParam* pAlfParam)
    198 {
    199   int ind, scanPos, i;
    200   int *pDepthInt;
    201   int fl;
    202  
    203   if(pAlfParam->num_coeff == SQR_FILT_LENGTH_9SYM)
    204     fl = 4;
    205   else if(pAlfParam->num_coeff == SQR_FILT_LENGTH_7SYM)
    206     fl = 3;
    207   else
    208     fl = 2;
    209  
    210   pDepthInt = pDepthIntTab[fl - 2];
    211  
    212   for(ind = 0; ind < pAlfParam->filters_per_group_diff; ++ind)
    213   {
    214     for(i = 0; i < pAlfParam->num_coeff; i++)
    215     {
    216       scanPos = pDepthInt[i] - 1;
    217       pAlfParam->coeffmulti[ind][i] = golombDecode(pAlfParam->kMinTab[scanPos]);
    218     }
    219   }
    220  
    221 }
    222 Void TDecEntropy::decodeFilterCoeff (ALFParam* pAlfParam)
    223 {
    224   readFilterCodingParams (pAlfParam);
    225   readFilterCoeffs (pAlfParam);
    226 }
    227 
    228 
    229 
    230 Void TDecEntropy::decodeFilt(ALFParam* pAlfParam)
    231 {
    232   UInt uiSymbol;
    233  
    234   if (pAlfParam->filtNo >= 0)
    235   {
    236     pAlfParam->filters_per_group_diff = pAlfParam->filters_per_group;
    237     if (pAlfParam->filters_per_group > 1)
    238     {
    239 #if ENABLE_FORCECOEFF0
    240       m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol);
    241       pAlfParam->forceCoeff0 = uiSymbol;
    242 
    243       if (pAlfParam->forceCoeff0)
    244       {
    245         pAlfParam->filters_per_group_diff = 0;
    246         for (int i=0; i<pAlfParam->filters_per_group; i++)
    247         {
    248           m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol);
    249           pAlfParam->codedVarBins[i] = uiSymbol;
    250           pAlfParam->filters_per_group_diff += uiSymbol;
    251         }
    252       }
    253       else
    254 #else
    255       pAlfParam->forceCoeff0 = 0;
    256 #endif
    257       {
    258         for (int i=0; i<NO_VAR_BINS; i++)
    259           pAlfParam->codedVarBins[i] = 1;
    260 
    261       }
    262       m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol);
    263       pAlfParam->predMethod = uiSymbol;
    264     }
    265     else
    266     {
    267       pAlfParam->forceCoeff0 = 0;
    268       pAlfParam->predMethod = 0;
    269     }
    270 
    271     decodeFilterCoeff (pAlfParam);
    272   }
    273 }
    274 
    275 Void TDecEntropy::decodeAlfParam(ALFParam* pAlfParam)
    276 {
    277   UInt uiSymbol;
    278   Int iSymbol;
    279   m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    280   pAlfParam->alf_flag = uiSymbol;
    281  
    282   if (!pAlfParam->alf_flag)
    283   {
    284     m_pcEntropyDecoderIf->setAlfCtrl(false);
    285     m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(0); //unncessary
    286     return;
    287   }
    288  
    289   Int pos;
    290   decodeAux(pAlfParam);
    291   decodeFilt(pAlfParam);
    292   // filter parameters for chroma
    293   m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol);
    294   pAlfParam->chroma_idc = uiSymbol;
    295  
    296   if(pAlfParam->chroma_idc)
    297   {
    298     m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol);
    299     pAlfParam->tap_chroma = (uiSymbol<<1) + 5;
    300     pAlfParam->num_coeff_chroma = ((pAlfParam->tap_chroma*pAlfParam->tap_chroma+1)>>1) + 1;
    301    
    302     // filter coefficients for chroma
    303     for(pos=0; pos<pAlfParam->num_coeff_chroma; pos++)
    304     {
    305       m_pcEntropyDecoderIf->parseAlfSvlc(iSymbol);
    306       pAlfParam->coeff_chroma[pos] = iSymbol;
    307     }
    308   }
    309  
    310   // region control parameters for luma
    311   m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol);
    312   pAlfParam->cu_control_flag = uiSymbol;
    313   if (pAlfParam->cu_control_flag)
    314   {
    315     m_pcEntropyDecoderIf->setAlfCtrl(true);
    316     m_pcEntropyDecoderIf->parseAlfCtrlDepth(uiSymbol);
    317     m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(uiSymbol);
    318 #if TSB_ALF_HEADER
    319     pAlfParam->alf_max_depth = uiSymbol;
    320     decodeAlfCtrlParam(pAlfParam);
    321 #endif
    322   }
    323   else
    324   {
    325     m_pcEntropyDecoderIf->setAlfCtrl(false);
    326     m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(0); //unncessary
    327   }
    328 }
    329 
    330 #if TSB_ALF_HEADER
    331 Void TDecEntropy::decodeAlfCtrlParam( ALFParam* pAlfParam )
    332 {
    333   UInt uiSymbol;
    334   m_pcEntropyDecoderIf->parseAlfFlagNum( uiSymbol, pAlfParam->num_cus_in_frame, pAlfParam->alf_max_depth );
    335   pAlfParam->num_alf_cu_flag = uiSymbol;
    336  
    337   for(UInt i=0; i<pAlfParam->num_alf_cu_flag; i++)
    338   {
    339     m_pcEntropyDecoderIf->parseAlfCtrlFlag( pAlfParam->alf_cu_flag[i] );
    340   }
    341 }
    342 #endif
    343 
    344 Void TDecEntropy::decodeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    345 {
    346   m_pcEntropyDecoderIf->parseAlfCtrlFlag( pcCU, uiAbsPartIdx, uiDepth );
    347 }
     48#include "TLibCommon/TComAdaptiveLoopFilter.h"
     49#include "TLibCommon/TComSampleAdaptiveOffset.h"
    34850
    34951Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     
    36163Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
    36264{
    363 #if !CHANGE_GET_MERGE_CANDIDATE
    364   UInt uiNumCand = 0;
    365   for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
    366   {
    367     if( pcSubCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) )
    368     {
    369       uiNumCand++;
    370       break;
    371     }
    372   }
    373   if( uiNumCand )
    374   {
    375 #endif
    376     // at least one merge candidate exists
    377     m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
    378 #if !CHANGE_GET_MERGE_CANDIDATE
    379   }
    380   else
    381   {
    382     assert( !pcSubCU->getMergeFlag( uiAbsPartIdx ) );
    383   }
    384 #endif
     65  // at least one merge candidate exists
     66  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
    38567}
    38668
     
    39678Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth )
    39779{
    398   UInt uiNumCand = 0;
    399   for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
    400   {
    401     if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) )
    402     {
    403       uiNumCand++;
    404     }
    405   }
    406 #if HHI_MPI
    407   if( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
    408     uiNumCand++;
    409 #endif
    410   // Merge to left or above depending on uiMergeIndex
    41180  UInt uiMergeIndex = 0;
    412   if ( uiNumCand > 1 )
    413   {
    414     // two different motion parameter sets exist
    415     // parse merge index.
    416     m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth );
    417   }
    418   else
    419   {
    420     for( UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
    421     {
    422       if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) )
    423       {
    424         uiMergeIndex = uiIter;
    425         break;
    426       }
    427     }
    428   }
     81  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth );
    42982  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
    430   pcCU->setInterDirSubParts( puhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, uiPartIdx, uiDepth );
    431 
    432   TComMv cTmpMv( 0, 0 );
    433   if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0  ) //if ( ref. frame list0 has at least 1 entry )
    434   {
    435     pcCU->setMVPIdxSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth);
    436     pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth);
    437     pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
    438     pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
    439 
    440   }
    441   if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry )
    442   {
    443     pcCU->setMVPIdxSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth);
    444     pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth);
    445     pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
    446     pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
    447   }
    448 }
    449 
     83}
    45084
    45185#if HHI_INTER_VIEW_RESIDUAL_PRED
     
    478112}
    479113#endif
    480 
    481114
    482115Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     
    519152  else                                                                // if it is Inter mode, encode motion vector and reference index
    520153  {
    521     if ( pcCU->getSlice()->getSPS()->getUseMRG() )
    522     {
    523       decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
    524     }
    525     else
    526     {
    527 #if MS_LCEC_LOOKUP_TABLE_EXCEPTION
    528       if ( pcCU->getSlice()->getSymbolMode() == 0 )
    529       {
    530         if ( pcCU->isSuroundingRefIdxException( uiAbsPartIdx ) )
    531         {
    532           pcCU->getSlice()->setRefIdxCombineCoding( false );
    533         }
    534         else
    535         {
    536           pcCU->getSlice()->setRefIdxCombineCoding( true );
    537         }
    538       }
    539 #endif
    540       decodeInterDir( pcCU, uiAbsPartIdx, uiDepth );
    541 
    542       if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry )
    543       {
    544         decodeRefFrmIdx ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0 );
    545         decodeMvd       ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0 );
    546         decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0, pcSubCU);
    547       }
    548 
    549       if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry )
    550       {
    551         decodeRefFrmIdx ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1 );
    552         decodeMvd       ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1 );
    553         decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1, pcSubCU);
    554       }
    555     }
    556   }
     154    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
     155  }
     156}
     157
     158/** Parse I_PCM information.
     159 * \param pcCU  pointer to CUpointer to CU
     160 * \param uiAbsPartIdx CU index
     161 * \param uiDepth CU depth
     162 * \returns Void
     163 */
     164Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     165{
     166  if(!pcCU->getSlice()->getSPS()->getUsePCM()
     167    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
     168    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
     169  {
     170    return;
     171  }
     172 
     173  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
    557174}
    558175
     
    567184}
    568185
    569 Void TDecEntropy::decodeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    570 {
    571   if ( pcCU->getSlice()->isInterP() )
    572   {
    573     memset( pcCU->getInterDir() + uiAbsPartIdx, 1, sizeof(UChar)*( pcCU->getTotalNumPart() >> (uiDepth << 1) ) );
    574     return;
    575   }
    576  
    577   UInt uiInterDir;
    578  
    579   UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2;
    580  
    581   switch ( pcCU->getPartitionSize( uiAbsPartIdx ) )
    582   {
    583      
    584     case SIZE_2Nx2N:
    585     {
    586       m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
    587       pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    588       break;
    589     }
    590      
    591     case SIZE_2NxN:
    592     {
    593       m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
    594       pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    595      
    596       uiAbsPartIdx += uiPartOffset << 1;
    597       m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
    598       pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    599       break;
    600     }
    601     case SIZE_Nx2N:
    602     {
    603       m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
    604       pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    605      
    606       uiAbsPartIdx += uiPartOffset;
    607       m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
    608       pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    609       break;
    610     }
    611     case SIZE_NxN:
    612     {
    613       for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ )
    614       {
    615         m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
    616         pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    617         uiAbsPartIdx += uiPartOffset;
    618       }
    619       break;
    620     }
    621     default:
    622       break;
    623   }
    624  
    625   return;
    626 }
    627 
    628 /** decode motion information for every PU block
     186/** decode motion information for every PU block.
    629187 * \param pcCU
    630  * \param uiPartIdx
    631188 * \param uiAbsPartIdx
    632189 * \param uiDepth
     
    640197  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
    641198
     199#if CU_BASED_MRG_CAND_LIST
     200#if HHI_INTER_VIEW_MOTION_PRED
     201  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
     202  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     203  for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ui++ )
     204#else
     205  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
     206  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
     207  for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ )
     208#endif
     209  {
     210    uhInterDirNeighbours[ui] = 0;
     211  }
     212  Int numValidMergeCand = 0;
     213  bool isMerged = false;
     214#endif
     215
    642216  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    643217  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    644218  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
    645219  {
     220#if !CU_BASED_MRG_CAND_LIST
     221#if HHI_INTER_VIEW_MOTION_PRED
     222    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
     223    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     224    Int numValidMergeCand = 0;
     225    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui )
     226#else
    646227    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    647228    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    648     UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand
     229    Int numValidMergeCand = 0;
    649230    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
     231#endif
    650232    {
    651233      uhInterDirNeighbours[ui] = 0;
    652       uiNeighbourCandIdx[ui] = 0;
    653     }
    654 #if !CHANGE_GET_MERGE_CANDIDATE
    655     pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx );
    656     for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
    657     {
    658       pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiSubPartIdx, uiPartIdx, uiDepth );
    659     }
    660 #endif
    661 #if PART_MRG
    662     if (pcCU->getWidth( uiAbsPartIdx ) > 8 && uiNumPU == 2 && uiPartIdx == 0)
    663     {
    664       pcCU->setMergeFlagSubParts( true, uiSubPartIdx, uiPartIdx, uiDepth );
    665     }
    666     else
     234    }
    667235#endif
    668236    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    669237    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
    670238    {
    671 #if CHANGE_GET_MERGE_CANDIDATE
    672       pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx );
    673       for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
    674       {
    675         pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiSubPartIdx, uiPartIdx, uiDepth );
    676       }
    677 #endif
    678239      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
     240#if CU_BASED_MRG_CAND_LIST
     241      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     242      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
     243      {
     244        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
     245        if ( !isMerged )
     246        {
     247          pcSubCU->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     248          isMerged = true;
     249        }
     250        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
     251      }
     252      else
     253      {
     254#if SIMP_MRG_PRUN
     255        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     256        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     257#else     
     258        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     259        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     260#endif
     261      }
     262#else
     263#if SIMP_MRG_PRUN       
     264      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     265      pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     266#else     
     267      pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     268      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     269#endif
     270#endif
     271      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
     272
     273      TComMv cTmpMv( 0, 0 );
     274      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     275      {       
     276        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
     277        {
     278          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
     279          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
     280          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
     281          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
     282
     283        }
     284      }
    679285    }
    680286    else
    681287    {
    682 #if MS_LCEC_LOOKUP_TABLE_EXCEPTION
    683       if ( pcCU->getSlice()->getSymbolMode() == 0 )
    684       {
    685         if ( pcCU->isSuroundingRefIdxException( uiAbsPartIdx ) )
    686         {
    687           pcCU->getSlice()->setRefIdxCombineCoding( false );
    688         }
    689         else
    690         {
    691           pcCU->getSlice()->setRefIdxCombineCoding( true );
    692         }
    693       }
    694 #endif
    695288      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
    696289      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     
    733326Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
    734327{
    735 #if DCM_COMB_LIST
    736328  if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getInterDir( uiAbsPartIdx ) != 3)
    737329  {
     
    751343    {
    752344      m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    753     }else{
     345    }
     346    else
     347    {
    754348      iRefFrmIdx=0;
    755349    }
     
    758352    eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    759353
    760     pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiPartIdx, uiDepth );
     354    pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
    761355
    762356    pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
     
    764358  else
    765359  {
    766 #endif
    767 
    768   Int iRefFrmIdx = 0;
    769   Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    770 
    771   if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
    772   {
    773     m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    774   }
    775   else if ( !iParseRefFrmIdx )
    776   {
    777     iRefFrmIdx = NOT_VALID;
    778   }
    779   else
    780   {
    781     iRefFrmIdx = 0;
    782   }
    783 
    784   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    785   pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiPartIdx, uiDepth );
    786 
    787 #if DCM_COMB_LIST
    788   }
    789 #endif 
     360    Int iRefFrmIdx = 0;
     361    Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
     362
     363    if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
     364    {
     365      m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
     366    }
     367    else if ( !iParseRefFrmIdx )
     368    {
     369      iRefFrmIdx = NOT_VALID;
     370    }
     371    else
     372    {
     373      iRefFrmIdx = 0;
     374    }
     375
     376    PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
     377    pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
     378  }
    790379}
    791380
     
    808397Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
    809398{
    810   Int iMVPIdx;
     399  Int iMVPIdx = -1;
    811400
    812401  TComMv cZeroMv( 0, 0 );
     
    818407
    819408  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
    820   iMVPIdx = -1;
    821409  cMv = cZeroMv;
     410
     411  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
     412  {
     413#if HHI_INTER_VIEW_MOTION_PRED
     414    const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcSubCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
     415    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx, iNumAMVPCands );
     416#else
     417    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
     418#endif
     419  }
    822420  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
    823 #if DCM_SIMPLIFIED_MVP==0
    824   pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo);
    825 #endif
    826421  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
    827   if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
    828   {
    829     m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList );
    830   }
    831422  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
    832423  if ( iRefIdx >= 0 )
     
    837428
    838429  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
    839   pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0);
    840 }
    841 
    842 Void TDecEntropy::decodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList, TComDataCU* pcSubCU )
    843 {
    844   Int iMVPIdx;
    845  
    846   TComMv cZeroMv( 0, 0 );
    847   TComMv cMv     = cZeroMv;
    848   Int    iRefIdx = -1;
    849  
    850   UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2;
    851   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
    852  
    853   pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, eRefList );
    854  
    855   TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
    856   AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
    857  
    858   switch ( ePartSize )
    859   {
    860     case SIZE_2Nx2N:
    861     {
    862       iRefIdx = pcSubCUMvField->getRefIdx(0);
    863       iMVPIdx =-1;
    864       cMv = cZeroMv;
    865       pcSubCU->fillMvpCand(0, 0, eRefList, iRefIdx, pAMVPInfo);
    866 #if DCM_SIMPLIFIED_MVP==0
    867       pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(0), pAMVPInfo);
    868 #endif
    869       pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, 0, 0, uiDepth);
    870       if ( (pcSubCU->getInterDir(0) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(0) == AM_EXPL) )
    871       {
    872         m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiAbsPartIdx, uiDepth, eRefList );
    873       }
    874       pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, 0, 0, uiDepth );
    875      
    876       if ( iRefIdx >= 0 )
    877       {
    878         m_pcPrediction->getMvPredAMVP( pcSubCU, 0, 0, eRefList, iRefIdx, cMv);
    879         cMv += pcSubCUMvField->getMvd( 0 );
    880       }
    881      
    882       pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, 0, 0, 0);
    883       break;
    884     }
    885     case SIZE_2NxN:
    886     {
    887       for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 2; uiPartIdx++, uiPartAddr+=(uiPartOffset << 1))
    888       {
    889         iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
    890         iMVPIdx =-1;
    891         cMv = cZeroMv;
    892         pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
    893 #if DCM_SIMPLIFIED_MVP==0
    894         pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo);
    895 #endif
    896         pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
    897         if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
    898         {
    899           m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList );
    900         }
    901         pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
    902         if ( iRefIdx >= 0 )
    903         {
    904           m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv);
    905           cMv += pcSubCUMvField->getMvd( uiPartAddr );
    906         }
    907        
    908         pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0);
    909        
    910       }
    911       break;
    912     }
    913     case SIZE_Nx2N:
    914     {
    915       for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 2; uiPartIdx++, uiPartAddr+=uiPartOffset)
    916       {
    917         iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
    918         iMVPIdx =-1;
    919         cMv = cZeroMv;
    920         pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
    921 #if DCM_SIMPLIFIED_MVP==0
    922         pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo);
    923 #endif
    924         pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
    925         if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
    926         {
    927           m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList );
    928         }
    929         pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
    930        
    931         if ( iRefIdx >= 0 )
    932         {
    933           m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv);
    934           cMv += pcSubCUMvField->getMvd( uiPartAddr );
    935         }
    936        
    937         pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0);
    938        
    939       }
    940       break;
    941     }
    942     case SIZE_NxN:
    943     {
    944       for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 4; uiPartIdx++, uiPartAddr+=uiPartOffset)
    945       {
    946         iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
    947         iMVPIdx =-1;
    948         cMv = cZeroMv;
    949         pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
    950 #if DCM_SIMPLIFIED_MVP==0
    951         pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo);
    952 #endif
    953         pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
    954         if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
    955         {
    956           m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList );
    957         }
    958         pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
    959         if ( iRefIdx >= 0 )
    960         {
    961           m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv);
    962           cMv += pcSubCUMvField->getMvd( uiPartAddr );
    963         }
    964        
    965         pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0);
    966       }
    967       break;
    968     }
    969     default:
    970       break;
    971   }
    972  
    973   return;
    974 }
    975 
    976 /** decode reference frame index
    977  * \param pcCU
    978  * \param uiAbsPartIdx
    979  * \param uiDepth
    980  * \param eRefList
    981  * \returns Void
    982  */
    983 Void TDecEntropy::decodeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList )
    984 {
    985 #if DCM_COMB_LIST
    986   if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0)
    987   {
    988     Int iRefFrmIdx = 0;
    989 
    990     Int iRefFrmIdxTemp;
    991     UInt uiInterDir;
    992     RefPicList eRefListTemp;
    993 
    994     UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2;
    995 
    996     switch ( pcCU->getPartitionSize( uiAbsPartIdx ) )
    997     {
    998       case SIZE_2Nx2N:
    999       {
    1000         if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0)
    1001         {
    1002           if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
    1003           {
    1004             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    1005           }
    1006           else
    1007           {
    1008             iRefFrmIdx=0;
    1009           }
    1010           uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
    1011           iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
    1012           eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    1013 
    1014           pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth );
    1015           pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    1016         }
    1017         else if(pcCU->getInterDir( uiAbsPartIdx ) == 3)
    1018         {
    1019           Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1020 
    1021           if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1022           {
    1023             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1024           }
    1025           else if ( !iParseRefFrmIdx )
    1026           {
    1027             iRefFrmIdx = NOT_VALID;
    1028           }
    1029           else
    1030           {
    1031             iRefFrmIdx = 0;
    1032           }
    1033      
    1034           pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth );
    1035         }
    1036         break;
    1037       }
    1038       case SIZE_2NxN:
    1039       {
    1040         if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0)
    1041         {
    1042           if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
    1043           {
    1044             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    1045           }
    1046           else
    1047           {
    1048             iRefFrmIdx=0;
    1049           }
    1050           uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
    1051           iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
    1052           eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    1053 
    1054           pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth );
    1055           pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    1056         }
    1057         else if(pcCU->getInterDir( uiAbsPartIdx ) == 3)
    1058         {
    1059           Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1060 
    1061           if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1062           {
    1063             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1064           }
    1065           else if ( !iParseRefFrmIdx )
    1066           {
    1067             iRefFrmIdx = NOT_VALID;
    1068           }
    1069           else
    1070           {
    1071             iRefFrmIdx = 0;
    1072           }
    1073      
    1074           pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth );
    1075         }
    1076 
    1077         uiAbsPartIdx += uiPartOffset << 1;
    1078 
    1079         if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0)
    1080         {
    1081           if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
    1082           {
    1083             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    1084           }
    1085           else
    1086           {
    1087             iRefFrmIdx=0;
    1088           }
    1089           uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
    1090           iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
    1091           eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    1092 
    1093           pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth );
    1094           pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    1095         }
    1096         else if(pcCU->getInterDir( uiAbsPartIdx ) == 3)
    1097         {
    1098           Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1099      
    1100           if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1101           {
    1102             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1103           }
    1104           else if ( !iParseRefFrmIdx )
    1105           {
    1106             iRefFrmIdx = NOT_VALID;
    1107           }
    1108           else
    1109           {
    1110             iRefFrmIdx = 0;
    1111           }
    1112           pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth );
    1113         }
    1114         break;
    1115       }
    1116       case SIZE_Nx2N:
    1117       {
    1118         if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0)
    1119         {
    1120           if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
    1121           {
    1122             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    1123           }
    1124           else
    1125           {
    1126             iRefFrmIdx=0;
    1127           }
    1128           uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
    1129           iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
    1130           eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    1131 
    1132           pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth );
    1133           pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    1134         }
    1135         else if(pcCU->getInterDir( uiAbsPartIdx ) == 3)
    1136         {
    1137           Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1138 
    1139           if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1140           {
    1141             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1142           }
    1143           else if ( !iParseRefFrmIdx )
    1144           {
    1145             iRefFrmIdx = NOT_VALID;
    1146           }
    1147           else
    1148           {
    1149             iRefFrmIdx = 0;
    1150           }
    1151           pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth );
    1152         }
    1153 
    1154         uiAbsPartIdx += uiPartOffset;
    1155        
    1156         if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0)
    1157         {
    1158           if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
    1159           {
    1160             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    1161           }
    1162           else
    1163           {
    1164             iRefFrmIdx=0;
    1165           }
    1166           uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
    1167           iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
    1168           eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    1169 
    1170           pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth );
    1171           pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    1172         }
    1173         else if(pcCU->getInterDir( uiAbsPartIdx ) == 3)
    1174         {
    1175           Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1176      
    1177           if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1178           {
    1179             m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1180           }
    1181           else if ( !iParseRefFrmIdx )
    1182           {
    1183             iRefFrmIdx = NOT_VALID;
    1184           }
    1185           else
    1186           {
    1187             iRefFrmIdx = 0;
    1188           }
    1189           pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth );
    1190         }
    1191         break;
    1192       }
    1193       case SIZE_NxN:
    1194       {
    1195         for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ )
    1196         {
    1197           if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0)
    1198           {
    1199             if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
    1200             {
    1201               m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
    1202             }
    1203             else
    1204             {
    1205               iRefFrmIdx=0;
    1206             }
    1207             uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
    1208             iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
    1209             eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
    1210 
    1211             pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth );
    1212             pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth );
    1213           }
    1214           else if(pcCU->getInterDir( uiAbsPartIdx ) == 3)
    1215           {
    1216             Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1217        
    1218             if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1219             {
    1220               m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1221             }
    1222             else if ( !iParseRefFrmIdx )
    1223             {
    1224               iRefFrmIdx = NOT_VALID;
    1225             }
    1226             else
    1227             {
    1228               iRefFrmIdx = 0;
    1229             }
    1230             pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth );
    1231           }
    1232           uiAbsPartIdx += uiPartOffset;
    1233         }
    1234         break;
    1235       }
    1236       default:
    1237         break;
    1238     }
    1239   }
    1240   else
    1241   {
    1242 #endif
    1243 
    1244   Int iRefFrmIdx = 0;
    1245   Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1246   UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2;
    1247  
    1248   switch ( pcCU->getPartitionSize( uiAbsPartIdx ) )
    1249   {
    1250     case SIZE_2Nx2N:
    1251     {
    1252       if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1253       {
    1254         m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1255       }
    1256       else if ( !iParseRefFrmIdx )
    1257       {
    1258         iRefFrmIdx = NOT_VALID;
    1259       }
    1260       else
    1261       {
    1262         iRefFrmIdx = 0;
    1263       }
    1264      
    1265       pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth );
    1266       break;
    1267     }
    1268     case SIZE_2NxN:
    1269     {
    1270       if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1271       {
    1272         m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1273       }
    1274       else if ( !iParseRefFrmIdx )
    1275       {
    1276         iRefFrmIdx = NOT_VALID;
    1277       }
    1278       else
    1279       {
    1280         iRefFrmIdx = 0;
    1281       }
    1282      
    1283       pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth );
    1284       uiAbsPartIdx += (uiPartOffset << 1);
    1285      
    1286       iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1287      
    1288       if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1289       {
    1290         m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1291       }
    1292       else if ( !iParseRefFrmIdx )
    1293       {
    1294         iRefFrmIdx = NOT_VALID;
    1295       }
    1296       else
    1297       {
    1298         iRefFrmIdx = 0;
    1299       }
    1300       pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth );
    1301       break;
    1302     }
    1303     case SIZE_Nx2N:
    1304     {
    1305       if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1306       {
    1307         m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1308       }
    1309       else if ( !iParseRefFrmIdx )
    1310       {
    1311         iRefFrmIdx = NOT_VALID;
    1312       }
    1313       else
    1314       {
    1315         iRefFrmIdx = 0;
    1316       }
    1317       pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth );
    1318       uiAbsPartIdx += uiPartOffset;
    1319      
    1320       iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1321      
    1322       if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1323       {
    1324         m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1325       }
    1326       else if ( !iParseRefFrmIdx )
    1327       {
    1328         iRefFrmIdx = NOT_VALID;
    1329       }
    1330       else
    1331       {
    1332         iRefFrmIdx = 0;
    1333       }
    1334       pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth );
    1335       break;
    1336     }
    1337     case SIZE_NxN:
    1338     {
    1339       for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ )
    1340       {
    1341         iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
    1342        
    1343         if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx)
    1344         {
    1345           m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
    1346         }
    1347         else if ( !iParseRefFrmIdx )
    1348         {
    1349           iRefFrmIdx = NOT_VALID;
    1350         }
    1351         else
    1352         {
    1353           iRefFrmIdx = 0;
    1354         }
    1355         pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth );
    1356         uiAbsPartIdx += uiPartOffset;
    1357       }
    1358       break;
    1359     }
    1360     default:
    1361       break;
    1362   }
    1363 #if DCM_COMB_LIST
    1364   }
    1365 #endif
    1366 
    1367   return;
    1368 }
    1369 
    1370 Void TDecEntropy::decodeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList )
    1371 {
    1372   UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2;
    1373  
    1374   switch ( pcCU->getPartitionSize( uiAbsPartIdx ) )
    1375   {
    1376     case SIZE_2Nx2N:
    1377     {
    1378       if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
    1379       {
    1380         m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList );
    1381       }
    1382       break;
    1383     }
    1384     case SIZE_2NxN:
    1385     {
    1386       if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
    1387       {
    1388         m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList );
    1389       }
    1390      
    1391       uiAbsPartIdx += (uiPartOffset << 1);
    1392       if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
    1393       {
    1394         m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList );
    1395       }
    1396       break;
    1397     }
    1398     case SIZE_Nx2N:
    1399     {
    1400       if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
    1401       {
    1402         m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList );
    1403       }
    1404      
    1405       uiAbsPartIdx += uiPartOffset;
    1406       if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
    1407       {
    1408         m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList );
    1409       }
    1410       break;
    1411     }
    1412     case SIZE_NxN:
    1413     {
    1414       for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ )
    1415       {
    1416         if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
    1417         {
    1418           m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList );
    1419         }
    1420         uiAbsPartIdx += uiPartOffset;
    1421       }
    1422       break;
    1423     }
    1424     default:
    1425       break;
    1426   }
    1427   return;
    1428 }
    1429 
    1430 Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 )
     430  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
     431}
     432
     433#if UNIFIED_TRANSFORM_TREE
     434Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP )
     435#else
     436Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 )
     437#endif
    1431438{
    1432439  UInt uiSubdiv;
    1433440  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
    1434  
    1435 #if CAVLC_RQT_CBP
    1436   if(pcCU->getSlice()->getSymbolMode()==0)
    1437   {
    1438     // code CBP and transform split flag jointly
    1439     UInt uiTrDepth =  uiDepth - pcCU->getDepth( uiAbsPartIdx );
    1440     m_pcEntropyDecoderIf->parseCbfTrdiv( pcCU, uiAbsPartIdx, uiTrDepth, uiDepth, uiSubdiv );
     441
     442#if UNIFIED_TRANSFORM_TREE
     443  if(uiTrIdx==0)
     444  {
     445    m_bakAbsPartIdxCU = uiAbsPartIdx;
     446  }
     447  if( uiLog2TrafoSize == 2 )
     448  {
     449    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
     450    if( ( uiAbsPartIdx % partNum ) == 0 )
     451    {
     452      m_uiBakAbsPartIdx   = uiAbsPartIdx;
     453      m_uiBakChromaOffset = offsetChroma;
     454    }
     455  }
     456#endif // UNIFIED_TRANSFORM_TREE
     457  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
     458  {
     459    uiSubdiv = 1;
     460  }
     461#if G519_TU_AMP_NSQT_HARMONIZATION
     462  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
     463#else
     464  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
     465#endif
     466  {
     467    uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));
     468  }
     469  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     470  {
     471    uiSubdiv = 1;
     472  }
     473  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
     474  {
     475    uiSubdiv = 0;
     476  }
     477  else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
     478  {
     479    uiSubdiv = 0;
    1441480  }
    1442481  else
    1443   {//CABAC
    1444 #endif
    1445   if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
    1446   {
    1447     uiSubdiv = 1;
    1448   }
    1449   else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
    1450   {
    1451     uiSubdiv = 1;
    1452   }
    1453   else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
    1454   {
    1455     uiSubdiv = 0;
    1456   }
    1457   else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
    1458   {
    1459     uiSubdiv = 0;
    1460   }
    1461   else
    1462482  {
    1463483    assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
    1464 #if HHI_RQT_FORCE_SPLIT_ACC2_PU
    1465     const UInt uiTrMode = uiDepth - pcCU->getDepth( uiAbsPartIdx );
    1466     UInt uiCtx = uiDepth;
    1467 #if HHI_RQT_FORCE_SPLIT_NxN
    1468     const Bool bNxNOK = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN && uiTrMode > 0;
    1469 #else
    1470     const Bool bNxNOK = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN;
    1471 #endif
    1472 #if HHI_RQT_FORCE_SPLIT_RECT
    1473     const Bool bSymmetricOK  = pcCU->getPartitionSize( uiAbsPartIdx ) >= SIZE_2NxN  && pcCU->getPartitionSize( uiAbsPartIdx ) < SIZE_NxN   && uiTrMode > 0;
    1474 #else
    1475     const Bool bSymmetricOK  = pcCU->getPartitionSize( uiAbsPartIdx ) >= SIZE_2NxN  && pcCU->getPartitionSize( uiAbsPartIdx ) < SIZE_NxN;
    1476 #endif
    1477     const Bool bNeedSubdivFlag = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTRA ||
    1478     bNxNOK || bSymmetricOK;
    1479    
    1480     if( ! bNeedSubdivFlag )
    1481     {
    1482       uiSubdiv = 1;
    1483     }
    1484     else
    1485       m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiCtx );
    1486 #else
    1487484    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth );
    1488 #endif
    1489   }
    1490 #if CAVLC_RQT_CBP
    1491   }
    1492 #endif
     485  }
    1493486 
    1494487  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
    1495488 
    1496   if(pcCU->getSlice()->getSymbolMode()==0)
    1497   {
    1498     if( uiSubdiv )
    1499     {
    1500       ++uiDepth;
    1501       const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
    1502      
    1503       for( Int i = 0; i < 4; i++ )
    1504       {
    1505         UInt uiDummyCbfY = 0;
    1506         UInt uiDummyCbfU = 0;
    1507         UInt uiDummyCbfV = 0;
    1508         xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, i, uiDummyCbfY, uiDummyCbfU, uiDummyCbfV );
    1509         uiAbsPartIdx += uiQPartNum;
     489  if( uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     490  {
     491    const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0;
     492    if( bFirstCbfOfCU )
     493    {
     494      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
     495      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
     496    }
     497    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
     498    {
     499      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
     500      {
     501        if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     502        {
     503          uiUCbfFront3++;
     504          pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
     505          //printf( " \nsave bits, U Cbf");
     506        }
     507        else
     508        {
     509          m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
     510          uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
     511        }
     512      }
     513      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
     514      {
     515        if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
     516        {
     517          uiVCbfFront3++;
     518          pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
     519          //printf( " \nsave bits, V Cbf");
     520        }
     521        else
     522        {
     523          m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
     524          uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
     525        }
    1510526      }
    1511527    }
    1512528    else
    1513529    {
    1514       assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
    1515       pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
     530      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
     531      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
     532      if ( uiLog2TrafoSize == 2 )
     533      {
     534        uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
     535        uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
     536      }
     537    }
     538  }
     539 
     540  if( uiSubdiv )
     541  {
     542#if UNIFIED_TRANSFORM_TREE
     543    UInt size;
     544    width  >>= 1;
     545    height >>= 1;
     546    size = width*height;
     547    uiTrIdx++;
     548#endif
     549    ++uiDepth;
     550    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
     551    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
     552    UInt uiLumaTrMode, uiChromaTrMode;
     553    pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode );
     554    UInt uiYCbf = 0;
     555    UInt uiUCbf = 0;
     556    UInt uiVCbf = 0;
     557   
     558    UInt uiCurrentCbfY = 0;
     559    UInt uiCurrentCbfU = 0;
     560    UInt uiCurrentCbfV = 0;
     561   
     562    for( Int i = 0; i < 4; i++ )
     563    {
     564#if UNIFIED_TRANSFORM_TREE
     565      UInt nsAddr = 0;
     566      nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 );
     567      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP );
     568#else
     569      UInt nsAddr = 0;
     570      nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 );
     571      xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );
     572#endif
     573      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
     574      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode );
     575      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode );
     576      uiAbsPartIdx += uiQPartNum;
     577#if UNIFIED_TRANSFORM_TREE
     578      offsetLuma += size;  offsetChroma += (size>>2);
     579#endif
     580    }
     581   
     582    uiYCbfFront3 += uiCurrentCbfY;
     583    uiUCbfFront3 += uiCurrentCbfU;
     584    uiVCbfFront3 += uiCurrentCbfV;
     585   
     586    pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
     587    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
     588    {
     589      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode;
     590      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode;
     591      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode;
    1516592    }
    1517593  }
    1518594  else
    1519595  {
    1520     if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
    1521     {
    1522       const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0;
    1523       if( bFirstCbfOfCU )
    1524       {
    1525         pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
    1526         pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
    1527       }
    1528       if( bFirstCbfOfCU || uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
    1529       {
    1530         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
    1531         {
    1532           if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
    1533           {
    1534             uiUCbfFront3++;
    1535             pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
    1536             //printf( " \nsave bits, U Cbf");
    1537           }
    1538           else
    1539           {
    1540             m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
    1541             uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
    1542           }
    1543         }
    1544         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
    1545         {
    1546           if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
    1547           {
    1548             uiVCbfFront3++;
    1549             pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
    1550             //printf( " \nsave bits, V Cbf");
    1551           }
    1552           else
    1553           {
    1554             m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
    1555             uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
    1556           }
    1557         }
     596    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
     597    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
     598   
     599    {
     600      DTRACE_CABAC_VL( g_nSymbolCounter++ );
     601      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
     602      DTRACE_CABAC_V( uiAbsPartIdx );
     603      DTRACE_CABAC_T( "\tdepth=" );
     604      DTRACE_CABAC_V( uiDepth );
     605      DTRACE_CABAC_T( "\ttrdepth=" );
     606      DTRACE_CABAC_V( uiTrDepth );
     607      DTRACE_CABAC_T( "\n" );
     608    }
     609   
     610    UInt uiLumaTrMode, uiChromaTrMode;
     611    pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
     612    if(pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTER && pcCU->useNonSquarePU( uiAbsPartIdx ) )
     613    {
     614      pcCU->setNSQTIdxSubParts( uiLog2TrafoSize, uiAbsPartIdx, absTUPartIdx, uiLumaTrMode );
     615    }
     616    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     617    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     618    {
     619      pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     620    }
     621    else
     622    {
     623      const UInt uiLog2CUSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - pcCU->getDepth( uiAbsPartIdx );
     624      if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0
     625          && ( uiLog2CUSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() + 1 || uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) )
     626      {
     627        pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     628        //printf( " \nsave bits, Y Cbf");
     629        uiYCbfFront3++;   
    1558630      }
    1559631      else
    1560632      {
    1561         pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
    1562         pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
    1563        
    1564         if ( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
    1565         {
    1566           uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
    1567           uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
    1568         }
    1569       }
    1570     }
    1571    
    1572     if( uiSubdiv )
    1573     {
    1574       ++uiDepth;
    1575       const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
    1576       const UInt uiStartAbsPartIdx = uiAbsPartIdx;
    1577       UInt uiLumaTrMode, uiChromaTrMode;
    1578       pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode );
    1579       UInt uiYCbf = 0;
    1580       UInt uiUCbf = 0;
    1581       UInt uiVCbf = 0;
    1582      
    1583       UInt uiCurrentCbfY = 0;
    1584       UInt uiCurrentCbfU = 0;
    1585       UInt uiCurrentCbfV = 0;
    1586      
    1587       for( Int i = 0; i < 4; i++ )
    1588       {
    1589         xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );
    1590         uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
    1591         uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode );
    1592         uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode );
    1593         uiAbsPartIdx += uiQPartNum;
    1594       }
    1595      
    1596       uiYCbfFront3 += uiCurrentCbfY;
    1597       uiUCbfFront3 += uiCurrentCbfU;
    1598       uiVCbfFront3 += uiCurrentCbfV;
    1599      
    1600       pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
    1601       for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
    1602       {
    1603         pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode;
    1604         pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode;
    1605         pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode;
     633        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth );
     634        uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
     635      }
     636    }
     637#if UNIFIED_TRANSFORM_TREE
     638    // transform_unit begin
     639    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
     640    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
     641    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
     642    if( uiLog2TrafoSize == 2 )
     643    {
     644      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
     645      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
     646      {
     647        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
     648        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
     649      }
     650    }
     651    if ( cbfY || cbfU || cbfV )
     652    {
     653      // dQP: only for LCU
     654      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
     655      {
     656        if ( bCodeDQP )
     657        {
     658          decodeQP( pcCU, m_bakAbsPartIdxCU);
     659          bCodeDQP = false;
     660        }
     661      }
     662    }
     663    if( cbfY )
     664    {
     665      Int trWidth = width;
     666      Int trHeight = height;
     667      pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
     668      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
     669    }
     670    if( uiLog2TrafoSize > 2 )
     671    {
     672      Int trWidth = width >> 1;
     673      Int trHeight = height >> 1;
     674      pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
     675      if( cbfU )
     676      {
     677        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
     678      }
     679      if( cbfV )
     680      {
     681        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
    1606682      }
    1607683    }
    1608684    else
    1609685    {
    1610       assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
    1611       pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
    1612      
    1613       {
    1614         DTRACE_CABAC_V( g_nSymbolCounter++ );
    1615         DTRACE_CABAC_T( "\tTrIdx: abspart=" );
    1616         DTRACE_CABAC_V( uiAbsPartIdx );
    1617         DTRACE_CABAC_T( "\tdepth=" );
    1618         DTRACE_CABAC_V( uiDepth );
    1619         DTRACE_CABAC_T( "\ttrdepth=" );
    1620         DTRACE_CABAC_V( uiTrDepth );
    1621         DTRACE_CABAC_T( "\n" );
    1622       }
    1623      
    1624       UInt uiLumaTrMode, uiChromaTrMode;
    1625       pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
    1626       pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
    1627       if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
    1628       {
    1629         pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
    1630       }
    1631       else
    1632       {
    1633         if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
    1634         {
    1635           pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
    1636           //printf( " \nsave bits, Y Cbf");
    1637           uiYCbfFront3++;   
    1638         }
    1639         else
    1640         {
    1641           m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth );
    1642           uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
    1643         }
    1644       }
    1645      
    1646       if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA )
    1647       {
    1648         Bool bCodeChroma   = true;
    1649         UInt uiDepthChroma = uiDepth;
    1650         if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
    1651         {
    1652           UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
    1653           bCodeChroma  = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
    1654           uiDepthChroma--;
    1655         }
    1656         if( bCodeChroma )
    1657         {
    1658           pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepthChroma );
    1659           pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepthChroma );
    1660           m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode, uiDepthChroma );
    1661           m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode, uiDepthChroma );
    1662         }
    1663       }
    1664     }
    1665   }
    1666 }
    1667 
     686      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
     687      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
     688      {
     689        Int trWidth = width;
     690        Int trHeight = height;
     691        pcCU->getNSQTSize( uiTrIdx - 1, uiAbsPartIdx, trWidth, trHeight );
     692        if( cbfU )
     693        {
     694          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
     695        }
     696        if( cbfV )
     697        {
     698          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
     699        }
     700      }
     701    }
     702    // transform_unit end
     703#endif // UNIFIED_TRANSFORM_TREE
     704  }
     705}
     706
     707#if !UNIFIED_TRANSFORM_TREE
    1668708Void TDecEntropy::decodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1669709{
    1670   DTRACE_CABAC_V( g_nSymbolCounter++ )
     710  DTRACE_CABAC_VL( g_nSymbolCounter++ )
    1671711  DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" )
    1672712  DTRACE_CABAC_V( uiDepth )
     
    1675715  UInt temp1 = 0;
    1676716  UInt temp2 = 0;
    1677   xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 );
    1678 }
    1679 
     717  xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 );
     718}
     719#endif // UNIFIED_TRANSFORM_TREE
     720
     721#if UNIFIED_TRANSFORM_TREE
     722Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
     723{
     724  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
     725  {
     726    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
     727  }
     728}
     729#else
    1680730Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1681731{
    1682   if ( pcCU->getSlice()->getSPS()->getUseDQP() )
     732  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
    1683733  {
    1684734    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, uiDepth );
    1685735  }
    1686736}
    1687 
    1688 Void TDecEntropy::decodeViewidx(Int & riViewIdx)
    1689 {
    1690   m_pcEntropyDecoderIf->parseViewIdx( riViewIdx );
    1691 }
    1692 
    1693 Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType )
    1694 {
    1695   if ( pcCU->getCbf( uiAbsPartIdx, eType, uiTrIdx ) )
    1696   {
    1697 #if SNY_DQP   
     737#endif
     738
     739#if !UNIFIED_TRANSFORM_TREE
     740Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP )
     741{
     742  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2;
     743  UInt uiCbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx );
     744  UInt uiCbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
     745  UInt uiCbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
     746  if( uiLog2TrSize == 2 )
     747  {
     748    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
     749    if( ( uiAbsPartIdx % uiQPDiv ) == 0 )
     750    {
     751      m_uiBakAbsPartIdx   = uiAbsPartIdx;
     752      m_uiBakChromaOffset = uiChromaOffset;
     753    }
     754    else if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) )
     755    {
     756      uiCbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
     757      uiCbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
     758    }
     759  }
     760
     761  if ( uiCbfY || uiCbfU || uiCbfV )
     762  {
    1698763    // dQP: only for LCU
    1699     if ( pcCU->getSlice()->getSPS()->getUseDQP() )
    1700     {
    1701       if ( pcCU->getdQPFlag())// non-skip
    1702       {
    1703         decodeQP( pcCU, 0, 0 );
    1704         pcCU->setdQPFlag(false);
     764    if ( pcCU->getSlice()->getPPS()->getUseDQP() )
     765    {
     766      if ( bCodeDQP )
     767      {
     768        decodeQP( pcCU, uiAbsPartIdx, uiDepth);
     769        bCodeDQP = false;
    1705770      }
    1706771    }   
    1707 #endif//SNY_DQP
    1708772    UInt uiLumaTrMode, uiChromaTrMode;
    1709773    pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
    1710     const UInt uiStopTrMode = eType == TEXT_LUMA ? uiLumaTrMode : uiChromaTrMode;
     774    const UInt uiStopTrMode = uiLumaTrMode;
    1711775   
    1712776    if( uiTrIdx == uiStopTrMode )
    1713777    {
    1714       UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2;
    1715       if( eType != TEXT_LUMA && uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
     778      if( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ) )
     779      {
     780        Int trWidth = uiWidth;
     781        Int trHeight = uiHeight;
     782        pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
     783        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+uiLumaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
     784      }
     785     
     786      uiWidth  >>= 1;
     787      uiHeight >>= 1;
     788
     789      if( uiLog2TrSize == 2 )
    1716790      {
    1717791        UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
    1718         if( ( uiAbsPartIdx % uiQPDiv ) != 0 )
    1719         {
    1720           return;
    1721         }
    1722         uiWidth  <<= 1;
    1723         uiHeight <<= 1;
    1724       }
    1725       m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eType );
     792        if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) )
     793        {
     794          uiWidth  <<= 1;
     795          uiHeight <<= 1;
     796          Int trWidth = uiWidth;
     797          Int trHeight = uiHeight;
     798          pcCU->getNSQTSize( uiTrIdx-1, uiAbsPartIdx, trWidth, trHeight );
     799          if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) )
     800          {
     801            m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
     802          }
     803          if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) )
     804          {
     805            m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
     806          }
     807        }
     808      }
     809      else
     810      {
     811        Int trWidth = uiWidth;
     812        Int trHeight = uiHeight;
     813        pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
     814        if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) )
     815        {
     816          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
     817        }
     818        if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) )
     819        {
     820          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
     821        }
     822      }
    1726823    }
    1727824    else
    1728825    {
    1729826      {
    1730         DTRACE_CABAC_V( g_nSymbolCounter++ );
     827        DTRACE_CABAC_VL( g_nSymbolCounter++ );
    1731828        DTRACE_CABAC_T( "\tgoing down\tdepth=" );
    1732829        DTRACE_CABAC_V( uiDepth );
     
    1736833      }
    1737834      if( uiCurrTrIdx <= uiTrIdx )
     835      {
    1738836        assert(1);
     837      }
    1739838      UInt uiSize;
    1740839      uiWidth  >>= 1;
     
    1747846      UInt uiIdx      = uiAbsPartIdx;
    1748847     
    1749 #if !CAVLC_RQT_CBP
    1750       if(pcCU->getSlice()->getSymbolMode() == 0)
    1751       {
    1752         UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2;
    1753         if( eType == TEXT_LUMA || uiLog2TrSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
    1754           m_pcEntropyDecoderIf->parseBlockCbf(pcCU, uiIdx, eType, uiTrIdx, uiDepth, uiQPartNum);
    1755         else
    1756         {
    1757           UInt uiCbf = pcCU->getCbf( uiIdx, eType );
    1758           pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx, uiDepth );
    1759           uiCbf = pcCU->getCbf( uiIdx + uiQPartNum, eType );
    1760           pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + uiQPartNum, uiDepth );
    1761           uiCbf = pcCU->getCbf( uiIdx + 2*uiQPartNum, eType );
    1762           pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + 2*uiQPartNum, uiDepth );
    1763           uiCbf = pcCU->getCbf( uiIdx + 3*uiQPartNum, eType );
    1764           pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + 3*uiQPartNum, uiDepth );
    1765         }
    1766         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum;
    1767         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum;
    1768         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum;
    1769         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType );
    1770       }
    1771       else
    1772       {
    1773 #endif
    1774         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum;
    1775         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum;
    1776         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum;
    1777         xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType );
    1778 #if !CAVLC_RQT_CBP
    1779       }
    1780 #endif
    1781       {
    1782         DTRACE_CABAC_V( g_nSymbolCounter++ );
     848      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
     849      uiLumaOffset += uiSize;  uiChromaOffset += (uiSize>>2);  uiIdx += uiQPartNum;
     850     
     851      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
     852      uiLumaOffset += uiSize;  uiChromaOffset += (uiSize>>2);  uiIdx += uiQPartNum;
     853     
     854      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
     855      uiLumaOffset += uiSize;  uiChromaOffset += (uiSize>>2);  uiIdx += uiQPartNum;
     856     
     857      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
     858      {
     859        DTRACE_CABAC_VL( g_nSymbolCounter++ );
    1783860        DTRACE_CABAC_T( "\tgoing up\n" );
    1784861      }
     
    1786863  }
    1787864}
     865#endif // !UNIFIED_TRANSFORM_TREE
    1788866
    1789867/** decode coefficients
     
    1795873 * \returns Void
    1796874 */
    1797 Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight )
     875Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
    1798876{
    1799877  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
    1800878  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
    1801879  UInt uiChromaOffset = uiLumaOffset>>2;
     880#if UNIFIED_TRANSFORM_TREE
     881  UInt temp  = 0;
     882  UInt temp1 = 0;
     883  UInt temp2 = 0;
     884#else
    1802885  UInt uiLumaTrMode, uiChromaTrMode;
     886#endif
    1803887 
    1804888  if( pcCU->isIntra(uiAbsPartIdx) )
    1805889  {
     890#if !UNIFIED_TRANSFORM_TREE
    1806891    decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) );
    1807892   
    1808893    pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode );
    1809894   
    1810     if (pcCU->getSlice()->getSymbolMode() == 0)
    1811     {
    1812 #if !CAVLC_RQT_CBP
    1813       m_pcEntropyDecoderIf->parseCbf( pcCU, uiAbsPartIdx, TEXT_ALL, 0, uiDepth );
    1814 #endif
    1815       if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0
    1816          && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0)
    1817         return;
    1818     }
     895#endif // !UNIFIED_TRANSFORM_TREE
    1819896  }
    1820897  else
    1821898  {
    1822     if (pcCU->getSlice()->getSymbolMode()==0)
    1823     {
    1824 #if !CAVLC_RQT_CBP
    1825       m_pcEntropyDecoderIf->parseCbf( pcCU, uiAbsPartIdx, TEXT_ALL, 0, uiDepth );
    1826       if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0
    1827          && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0)
    1828         return;
    1829 #endif
    1830     }
    1831     else
    1832     {
    1833 #if HHI_MRG_SKIP
    1834       UInt uiQtRootCbf = 1;
     899    UInt uiQtRootCbf = 1;
    1835900#if HHI_MPI
    1836       if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N &&
    1837             ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) )
     901    if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N &&
     902          ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) )
    1838903#else
    1839       if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
    1840 #endif
    1841       {
    1842         m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf );
    1843       }
    1844 #else
    1845       UInt uiQtRootCbf;
     904    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
     905#endif
     906    {
    1846907      m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf );
    1847 #endif
    1848       if ( !uiQtRootCbf )
    1849       {
    1850         pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
    1851         pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
    1852         return;
    1853       }
    1854     }
    1855    
     908    }
     909    if ( !uiQtRootCbf )
     910    {
     911      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
     912      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
     913      pcCU->setNSQTIdxSubParts( uiAbsPartIdx, uiDepth );
     914      return;
     915    }
     916   
     917#if !UNIFIED_TRANSFORM_TREE
    1856918    decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) );
    1857919   
    1858 #if CAVLC_RQT_CBP
    1859     if (pcCU->getSlice()->getSymbolMode() == 0)
    1860     {
    1861       if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0
    1862          && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0)
    1863          return;
    1864     }
    1865 #endif
    1866920    pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode );
    1867   }
    1868  
    1869   xDecodeCoeff( pcCU, pcCU->getCoeffY()  + uiLumaOffset,   uiAbsPartIdx, uiDepth, uiWidth,    uiHeight,    0, uiLumaTrMode,   TEXT_LUMA     );
    1870   xDecodeCoeff( pcCU, pcCU->getCoeffCb() + uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth>>1, uiHeight>>1, 0, uiChromaTrMode, TEXT_CHROMA_U );
    1871   xDecodeCoeff( pcCU, pcCU->getCoeffCr() + uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth>>1, uiHeight>>1, 0, uiChromaTrMode, TEXT_CHROMA_V );
    1872 }
    1873 
    1874 #if MTK_SAO
    1875 /** decodeQAO One Part
    1876  * \param  pQaoParam, iPartIdx
    1877  */
    1878 Void TDecEntropy::decodeQAOOnePart(SAOParam* pQaoParam, Int iPartIdx)
    1879 {
    1880   UInt uiSymbol;
    1881   Int iSymbol; 
    1882 
    1883   SAOQTPart*  pAlfPart = &(pQaoParam->psSaoPart[iPartIdx]);
    1884   static Int iTypeLength[MAX_NUM_SAO_TYPE] = {
    1885     SAO_EO_LEN,
    1886     SAO_EO_LEN,
    1887     SAO_EO_LEN,
    1888     SAO_EO_LEN,
    1889     SAO_BO_LEN,
    1890     SAO_BO_LEN
    1891   }; 
    1892   if(!pAlfPart->bSplit)
    1893   {
    1894 
    1895     m_pcEntropyDecoderIf->parseAoUvlc(uiSymbol);
    1896 
    1897     if (uiSymbol)
    1898     {
    1899       pAlfPart->iBestType = uiSymbol-1;
    1900       pAlfPart->bEnableFlag = true;
    1901     }
    1902     else
    1903     {
    1904       pAlfPart->iBestType = -1;
    1905       pAlfPart->bEnableFlag = false;
    1906     }
    1907 
    1908     if (pAlfPart->bEnableFlag)
    1909     {
    1910 
    1911       pAlfPart->iLength = iTypeLength[pAlfPart->iBestType];
    1912 
    1913       for(Int i=0; i< pAlfPart->iLength; i++)
    1914       {
    1915         m_pcEntropyDecoderIf->parseAoSvlc(iSymbol);
    1916         pAlfPart->iOffset[i] = iSymbol;
    1917       }
    1918 
    1919     }
    1920     return;
    1921   }
    1922 
    1923   //split
    1924   if (pAlfPart->PartLevel < pQaoParam->iMaxSplitLevel)
    1925   {
    1926     for(Int i=0;i<NUM_DOWN_PART;i++)
    1927     {
    1928       decodeQAOOnePart(pQaoParam, pAlfPart->DownPartsIdx[i]);
    1929     }
    1930   }
    1931 }
    1932 /** decode QuadTree Split Flag
    1933  * \param  pQaoParam, iPartIdx
    1934  */
    1935 Void TDecEntropy::decodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int iPartIdx)
    1936 {
    1937   UInt uiSymbol;
    1938   SAOQTPart*  pAlfPart = &(pQaoParam->psSaoPart[iPartIdx]);
    1939 
    1940   if(pAlfPart->PartLevel < pQaoParam->iMaxSplitLevel)
    1941   {
    1942 
    1943     //send one flag
    1944     m_pcEntropyDecoderIf->parseAoFlag(uiSymbol);
    1945     pAlfPart->bSplit = uiSymbol? true:false;
    1946     if(pAlfPart->bSplit)
    1947     {
    1948       for (Int i=0;i<NUM_DOWN_PART;i++)
    1949       {
    1950         decodeQuadTreeSplitFlag(pQaoParam, pAlfPart->DownPartsIdx[i]);
    1951       }
    1952     }
    1953   }
    1954 
    1955 }
    1956 /** decode Sao Param
    1957  * \param  pQaoParam
    1958  */
    1959 Void TDecEntropy::decodeSaoParam(SAOParam* pQaoParam)
    1960 {
    1961   UInt uiSymbol;
    1962 
    1963   m_pcEntropyDecoderIf->parseAoFlag(uiSymbol);
    1964   if (uiSymbol)
    1965   {
    1966     pQaoParam->bSaoFlag = true;
    1967   }
    1968   else
    1969   {
    1970     pQaoParam->bSaoFlag = false;
    1971   }
    1972   if (pQaoParam->bSaoFlag)
    1973   {
    1974     decodeQuadTreeSplitFlag(pQaoParam, 0);
    1975     decodeQAOOnePart(pQaoParam, 0);
    1976   }
    1977 
    1978 }
    1979 
    1980 #endif
     921#endif // !UNIFIED_TRANSFORM_TREE
     922  }
     923#if UNIFIED_TRANSFORM_TREE
     924  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP );
     925#else // UNIFIED_TRANSFORM_TREE
     926  xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP );
     927#endif // UNIFIED_TRANSFORM_TREE
     928}
     929
     930//! \}
Note: See TracChangeset for help on using the changeset viewer.