Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecCu.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/TDecCu.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     TDecCu.cpp
    3735    \brief    CU decoder class
     
    4038#include "TDecCu.h"
    4139
     40//! \ingroup TLibDecoder
     41//! \{
     42
    4243// ====================================================================================================================
    4344// Constructor / destructor / create / destroy
     
    4647TDecCu::TDecCu()
    4748{
    48   m_ppcYuvResi    = NULL;
    49   m_ppcYuvReco    = NULL;
     49  m_ppcYuvResi = NULL;
     50  m_ppcYuvReco = NULL;
     51#if HHI_INTER_VIEW_RESIDUAL_PRED
    5052  m_ppcYuvResPred = NULL;
    51   m_ppcCU         = NULL;
     53#endif
     54  m_ppcCU      = NULL;
    5255}
    5356
     
    7275  m_uiMaxDepth = uiMaxDepth+1;
    7376 
    74   m_ppcYuvResi    = new TComYuv*    [m_uiMaxDepth-1];
    75   m_ppcYuvReco    = new TComYuv*    [m_uiMaxDepth-1];
    76   m_ppcYuvResPred = new TComYuv*    [m_uiMaxDepth-1];
    77   m_ppcCU         = new TComDataCU* [m_uiMaxDepth-1];
     77  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
     78  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
     79#if HHI_INTER_VIEW_RESIDUAL_PRED
     80  m_ppcYuvResPred = new TComYuv*   [m_uiMaxDepth-1];
     81#endif
     82  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
    7883 
    7984  UInt uiNumPartitions;
     
    8489    UInt uiHeight = uiMaxHeight >> ui;
    8590   
    86     m_ppcYuvResi   [ui] = new TComYuv;    m_ppcYuvResi   [ui]->create( uiWidth, uiHeight );
    87     m_ppcYuvReco   [ui] = new TComYuv;    m_ppcYuvReco   [ui]->create( uiWidth, uiHeight );
     91    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight );
     92    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
     93#if HHI_INTER_VIEW_RESIDUAL_PRED
    8894    m_ppcYuvResPred[ui] = new TComYuv;    m_ppcYuvResPred[ui]->create( uiWidth, uiHeight );
    89     m_ppcCU        [ui] = new TComDataCU; m_ppcCU        [ui]->create( uiNumPartitions, uiWidth, uiHeight, true );
    90   }
    91  
     95#endif
     96    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
     97  }
     98 
     99  m_bDecodeDQP = false;
     100
    92101  // initialize partition order.
    93102  UInt* piTmp = &g_auiZscanToRaster[0];
     
    97106  // initialize conversion matrix from partition index to pel
    98107  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
     108  initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
    99109}
    100110
     
    103113  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
    104114  {
    105     m_ppcYuvResi   [ui]->destroy(); delete m_ppcYuvResi   [ui]; m_ppcYuvResi   [ui] = NULL;
    106     m_ppcYuvReco   [ui]->destroy(); delete m_ppcYuvReco   [ui]; m_ppcYuvReco   [ui] = NULL;
     115    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
     116    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
     117#if HHI_INTER_VIEW_RESIDUAL_PRED
    107118    m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL;
    108     m_ppcCU        [ui]->destroy(); delete m_ppcCU        [ui]; m_ppcCU        [ui] = NULL;
    109   }
    110  
    111   delete [] m_ppcYuvResi;    m_ppcYuvResi    = NULL;
    112   delete [] m_ppcYuvReco;    m_ppcYuvReco    = NULL;
     119#endif
     120    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
     121  }
     122 
     123  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
     124  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
     125#if HHI_INTER_VIEW_RESIDUAL_PRED
    113126  delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL;
    114   delete [] m_ppcCU;         m_ppcCU         = NULL;
     127#endif
     128  delete [] m_ppcCU     ; m_ppcCU      = NULL;
    115129}
    116130
     
    124138Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
    125139{
    126 #if SNY_DQP   
    127   if ( pcCU->getSlice()->getSPS()->getUseDQP() )
    128   {
    129     pcCU->setdQPFlag(true);
    130   }
    131 #endif//SNY_DQP
     140  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
     141  {
     142    setdQPFlag(true);
     143  }
     144
     145#if BURST_IPCM
     146  pcCU->setNumSucIPCM(0);
     147#endif
     148
    132149  // start from the top level CU
    133   xDecodeCU( pcCU, 0, 0 );
    134  
    135 #if SNY_DQP
    136   // dQP: only for LCU
    137   if ( pcCU->getSlice()->getSPS()->getUseDQP() )
    138   {
    139     if ( pcCU->isSkipped( 0 ) && pcCU->getDepth( 0 ) == 0 )
    140     {
    141     }
    142     else if ( pcCU->getdQPFlag())// non-skip
    143     {
    144       m_pcEntropyDecoder->decodeQP( pcCU, 0, 0 );
    145       pcCU->setdQPFlag(false);
    146     }
    147   }
    148 #else
    149   // dQP: only for LCU
    150   if ( pcCU->getSlice()->getSPS()->getUseDQP() )
    151   {
    152     if ( pcCU->isSkipped( 0 ) && pcCU->getDepth( 0 ) == 0 )
    153     {
    154     }
    155     else
    156     {
    157       m_pcEntropyDecoder->decodeQP( pcCU, 0, 0 );
    158     }
    159   }
    160 #endif//SNY_DQP
    161  
    162   //--- Read terminating bit ---
    163   m_pcEntropyDecoder->decodeTerminatingBit( ruiIsLast );
     150  xDecodeCU( pcCU, 0, 0, ruiIsLast);
    164151}
    165152
     
    174161// Protected member functions
    175162// ====================================================================================================================
     163
     164/**decode end-of-slice flag
     165 * \param pcCU
     166 * \param uiAbsPartIdx
     167 * \param uiDepth
     168 * \returns Bool
     169 */
     170Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) {
     171  UInt uiIsLast;
     172  TComPic* pcPic = pcCU->getPic();
     173  TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
     174  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
     175  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
     176  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
     177  UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity());
     178  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     179  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     180
     181#if HHI_MPI
     182  const UInt uiCUWidth  = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUWidth>>uiDepth  : pcCU->getWidth (uiAbsPartIdx);
     183  const UInt uiCUHeight = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUHeight>>uiDepth : pcCU->getHeight(uiAbsPartIdx);
     184  if(((uiPosX+uiCUWidth)%uiGranularityWidth==0||(uiPosX+uiCUWidth==uiWidth))
     185    &&((uiPosY+uiCUHeight)%uiGranularityWidth==0||(uiPosY+uiCUHeight==uiHeight)))
     186#else
     187  if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
     188    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
     189#endif
     190  {
     191    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
     192  }
     193  else
     194  {
     195    uiIsLast=0;
     196  }
     197 
     198  if(uiIsLast)
     199  {
     200    if(pcSlice->isNextEntropySlice()&&!pcSlice->isNextSlice())
     201    {
     202      pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
     203    }
     204    else
     205    {
     206      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
     207      pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
     208    }
     209  }
     210
     211  return uiIsLast>0;
     212}
    176213
    177214/** decode CU block recursively
     
    181218 * \returns Void
    182219 */
    183 Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     220
     221Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
    184222{
    185223  TComPic* pcPic = pcCU->getPic();
     
    192230  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    193231  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
    194  
    195   if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
    196   {
     232
     233  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
     234  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr();
     235  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     236  {
     237#if BURST_IPCM
     238    if(pcCU->getNumSucIPCM() == 0)
     239    {
     240#if HHI_MPI
     241      if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
     242#endif
     243      m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
     244    }
     245    else
     246    {
     247      pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx );
     248    }
     249#else
    197250#if HHI_MPI
    198251    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
    199252#endif
    200       m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
     253    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
     254#endif
    201255  }
    202256  else
     
    208262  {
    209263    UInt uiIdx = uiAbsPartIdx;
     264    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     265    {
     266      setdQPFlag(true);
     267      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
     268    }
     269
    210270    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
    211271    {
     
    213273      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    214274     
    215       if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
    216         xDecodeCU( pcCU, uiIdx, uiDepth+1 );
     275      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr();
     276      if ( bSubInSlice )
     277      {
     278        if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
     279        {
     280          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
     281        }
     282        else
     283        {
     284          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
     285        }
     286      }
     287      if(ruiIsLast)
     288      {
     289        break;
     290      }
    217291     
    218292      uiIdx += uiQNumParts;
    219293    }
    220    
     294    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     295    {
     296      if ( getdQPFlag() )
     297      {
     298        UInt uiQPSrcPartIdx;
     299        if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() )
     300        {
     301          uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU();
     302        }
     303        else
     304        {
     305          uiQPSrcPartIdx = uiAbsPartIdx;
     306        }
     307        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
     308      }
     309    }
    221310    return;
    222311  }
    223312 
    224 #if TSB_ALF_HEADER
    225 #else
    226   m_pcEntropyDecoder->decodeAlfCtrlFlag( pcCU, uiAbsPartIdx, uiDepth );
    227 #endif
    228  
     313  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     314  {
     315    setdQPFlag(true);
     316    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
     317  }
     318
    229319  // decode CU mode and the partition size
    230 #if HHI_MPI
    231   if( !pcCU->getSlice()->isIntra() && pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
     320#if BURST_IPCM
     321  if( !pcCU->getSlice()->isIntra() && pcCU->getNumSucIPCM() == 0 )
    232322#else
    233323  if( !pcCU->getSlice()->isIntra() )
    234324#endif
     325#if HHI_MPI
     326  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
     327#endif
    235328  {
    236329    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
    237330  }
    238  
    239 
     331 
    240332  if( pcCU->isSkipped(uiAbsPartIdx) )
    241333  {
    242 #if HHI_MRG_SKIP
    243334    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    244335    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
     336#if HHI_INTER_VIEW_MOTION_PRED
     337    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
     338    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     339    Int numValidMergeCand = 0;
     340    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui )
     341#else
    245342    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
    246343    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    247     UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand
     344    Int numValidMergeCand = 0;
    248345    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
     346#endif
    249347    {
    250348      uhInterDirNeighbours[ui] = 0;
    251       uiNeighbourCandIdx[ui] = 0;
    252     }
    253     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx );
    254     for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
    255   {
    256       pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiAbsPartIdx, 0, uiDepth );
    257349    }
    258350    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
    259 #else
    260     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiAbsPartIdx, 0, uiDepth);
    261     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiAbsPartIdx, 0, uiDepth);
    262    
    263     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiAbsPartIdx, 0, uiDepth);
    264     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiAbsPartIdx, 0, uiDepth);
    265    
    266     if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry )
    267     {
    268       m_pcEntropyDecoder->decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0, m_ppcCU[uiDepth]);
    269     }
    270    
    271     if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry )
    272     {
    273       m_pcEntropyDecoder->decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1, m_ppcCU[uiDepth]);
    274     }
    275 #endif
    276351#if HHI_MPI
    277352    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
     
    283358      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
    284359      {
    285         const UChar uhNewDepth = max( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
     360        const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
    286361        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_SKIP );
    287362        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
     
    291366      }
    292367    }
    293 #endif
    294  
     368    else
     369    {
     370#endif
     371#if SIMP_MRG_PRUN     
     372    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
     373    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     374#else
     375    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     376    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
     377#endif
     378    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
     379
     380    TComMv cTmpMv( 0, 0 );
     381    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     382    {       
     383      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
     384      {
     385        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
     386        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
     387        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     388        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     389      }
     390    }
     391#if HHI_MPI
     392    }
     393#endif
    295394#if HHI_INTER_VIEW_RESIDUAL_PRED
    296395    m_pcEntropyDecoder->decodeResPredFlag( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 );
    297396#endif
     397    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    298398    return;
    299399  }
     
    303403  {
    304404#endif
     405#if BURST_IPCM
     406  if( pcCU->getNumSucIPCM() == 0 )
     407  {
    305408    m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
    306 
    307409    m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
    308 
    309     // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
    310     m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
     410  }
     411  else
     412  {
     413    pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth );
     414    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     415    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
     416    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
     417  }
     418#else
     419  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
     420  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
     421#endif
     422
     423  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
     424  {
     425    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
     426
     427    if(pcCU->getIPCMFlag(uiAbsPartIdx))
     428    {
     429      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
     430      return;
     431    }
     432  }
     433
     434#if ! HHI_MPI
     435  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
     436  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
     437#endif
     438 
     439  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
     440  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
     441 
     442#if HHI_INTER_VIEW_RESIDUAL_PRED
     443  if( !pcCU->isIntra( uiAbsPartIdx ) )
     444  {
     445    m_pcEntropyDecoder->decodeResPredFlag    ( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 );
     446  }
     447#endif
    311448
    312449#if HHI_MPI
    313     if( !pcCU->isIntra( uiAbsPartIdx ) )
    314     {
    315       m_ppcCU[uiDepth]  ->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    316       m_ppcCU[uiDepth]  ->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    317 #if HHI_INTER_VIEW_RESIDUAL_PRED
    318       m_pcEntropyDecoder->decodeResPredFlag    ( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 );
    319 #endif
    320     }
    321 
    322450    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
    323451    {
     
    329457      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
    330458      {
    331         const UChar uhNewDepth = max( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
     459        const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
    332460        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER );
    333461        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
     
    340468      {
    341469        UInt uiIdx = uiAbsPartIdx;
     470        if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     471        {
     472          setdQPFlag(true);
     473          pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
     474        }
     475
    342476        for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
    343477        {
     
    345479          uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    346480
    347           if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
    348             xDecodeCU( pcCU, uiIdx, uiDepth+1 );
    349 
     481          Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr();
     482          if ( bSubInSlice )
     483          {
     484            if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
     485            {
     486              xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
     487            }
     488            else
     489            {
     490              pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
     491            }
     492          }
     493          if(ruiIsLast)
     494          {
     495            break;
     496          }
    350497          uiIdx += uiQNumParts;
     498        }
     499        if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     500        {
     501          if ( getdQPFlag() )
     502          {
     503            UInt uiQPSrcPartIdx;
     504            if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() )
     505            {
     506              uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU();
     507            }
     508            else
     509            {
     510              uiQPSrcPartIdx = uiAbsPartIdx;
     511            }
     512            pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
     513          }
    351514        }
    352515        return;
     
    354517    }
    355518  }
    356 #endif
    357519
    358520  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
    359521  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
    360  
     522#endif
     523
    361524  // Coefficient decoding
    362   m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight );
    363  
     525  Bool bCodeDQP = getdQPFlag();
     526  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
     527  setdQPFlag( bCodeDQP );
     528  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
     529}
     530
     531Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
     532{
     533  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     534  {
     535    if( getdQPFlag() )
     536    {
     537      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
     538    }
     539  }
     540
     541#if BURST_IPCM
     542  if( pcCU->getNumSucIPCM() > 0 )
     543  {
     544    ruiIsLast = 0;
     545    return;
     546  }
     547#endif
     548
     549  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
    364550}
    365551
     
    374560  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
    375561 
    376   if( ( uiRPelX >= pcCU->getSlice()->getSPS()->getWidth() ) || ( uiBPelY >= pcCU->getSlice()->getSPS()->getHeight() ) )
     562  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
     563  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
     564  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr();
     565  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    377566  {
    378567    bBoundary = true;
     
    389578      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    390579     
    391       if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
     580      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getEntropySliceCurEndCUAddr());
     581      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     582      {
    392583        xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth );
     584      }
    393585     
    394586      uiIdx += uiQNumParts;
     
    415607      break;
    416608  }
     609#if LOSSLESS_CODING
     610  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
     611  {
     612    xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth);   
     613  }
     614#endif
    417615 
    418616  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
     
    433631    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
    434632#endif
    435  
     633
    436634#if HHI_INTER_VIEW_RESIDUAL_PRED
    437635  if( pcCU->getResPredFlag( 0 ) )
     
    461659#endif
    462660    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
    463   }
    464 }
    465 
    466 Void TDecCu::xDecodeIntraTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel* piReco, Pel* piPred, Pel* piResi, UInt uiStride, TCoeff* pCoeff, UInt uiWidth, UInt uiHeight, UInt uiCurrDepth )
    467 {
    468   if( pcCU->getTransformIdx(0) == uiCurrDepth )
    469   {
    470     UInt uiX, uiY;
    471     TComPattern* pcPattern = pcCU->getPattern();
    472     UInt uiZorder          = pcCU->getZorderIdxInCU()+uiPartIdx;
    473     Pel* pPred             = piPred;
    474     Pel* pResi             = piResi;
    475     Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), uiZorder);
    476     UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride();
    477    
    478     pcPattern->initPattern( pcCU, uiCurrDepth, uiPartIdx );
    479    
    480     Bool bAboveAvail = false;
    481     Bool bLeftAvail  = false;
    482    
    483     pcPattern->initAdiPattern(pcCU, uiPartIdx, uiCurrDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail);
    484    
    485     m_pcPrediction->predIntraLumaAng( pcPattern, pcCU->getLumaIntraDir(uiPartIdx), pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
    486    
    487     m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
    488 #if INTRA_DST_TYPE_7
    489   m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight );
    490 #else
    491   m_pcTrQuant->invtransformNxN( pResi, uiStride, pCoeff, uiWidth, uiHeight );
    492 #endif
    493     // Reconstruction
    494     {
    495       pResi = piResi;
    496       pPred = piPred;
    497       for( uiY = 0; uiY < uiHeight; uiY++ )
    498       {
    499         for( uiX = 0; uiX < uiWidth; uiX++ )
    500         {
    501           piReco   [uiX] = Clip(pPred[uiX] + pResi[uiX]);
    502           piPicReco[uiX] = piReco[uiX];
    503         }
    504         piReco    += uiStride;
    505         pPred     += uiStride;
    506         pResi     += uiStride;
    507         piPicReco += uiPicStride;
    508       }
    509     }
    510   }
    511   else
    512   {
    513     uiCurrDepth++;
    514     uiWidth  >>= 1;
    515     uiHeight >>= 1;
    516     UInt uiPartOffset  = pcCU->getTotalNumPart()>>(uiCurrDepth<<1);
    517     UInt uiCoeffOffset = uiWidth  * uiHeight;
    518     UInt uiPelOffset   = uiHeight * uiStride;
    519     Pel* pResi = piResi;
    520     Pel* pReco = piReco;
    521     Pel* pPred = piPred;
    522     xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
    523     uiPartIdx += uiPartOffset;
    524     pCoeff    += uiCoeffOffset;
    525     pResi      = piResi + uiWidth;
    526     pReco      = piReco + uiWidth;
    527     pPred      = piPred + uiWidth;
    528     xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
    529     uiPartIdx += uiPartOffset;
    530     pCoeff    += uiCoeffOffset;
    531     pResi      = piResi + uiPelOffset;
    532     pReco      = piReco + uiPelOffset;
    533     pPred      = piPred + uiPelOffset;
    534     xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
    535     uiPartIdx += uiPartOffset;
    536     pCoeff    += uiCoeffOffset;
    537     pResi      = piResi + uiPelOffset + uiWidth;
    538     pReco      = piReco + uiPelOffset + uiWidth;
    539     pPred      = piPred + uiPelOffset + uiWidth;
    540     xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
    541   }
    542 }
    543 
    544 // ADI chroma
    545 Void TDecCu::xRecurIntraInvTransChroma(TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piResi, Pel* piPred, Pel* piReco, UInt uiStride, TCoeff* piCoeff, UInt uiWidth, UInt uiHeight, UInt uiTrMode, UInt uiCurrTrMode, TextType eText )
    546 {
    547   if( uiTrMode == uiCurrTrMode )
    548   {
    549     UInt uiX, uiY;
    550     UInt uiZorder    = pcCU->getZorderIdxInCU()+uiAbsPartIdx;
    551     Pel* pResi       = piResi;
    552     Pel* pPred       = piPred;
    553     Pel* piPicReco;
    554     if( eText == TEXT_CHROMA_U )
    555       piPicReco= pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), uiZorder);
    556     else
    557       piPicReco= pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), uiZorder);
    558    
    559     UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
    560    
    561     pcCU->getPattern()->initPattern( pcCU, uiCurrTrMode, uiAbsPartIdx );
    562    
    563     Bool bAboveAvail = false;
    564     Bool bLeftAvail  = false;
    565    
    566     pcCU->getPattern()->initAdiPatternChroma(pcCU,uiAbsPartIdx, uiCurrTrMode, m_pcPrediction->getPredicBuf(),m_pcPrediction->getPredicBufWidth(),m_pcPrediction->getPredicBufHeight(),bAboveAvail,bLeftAvail);
    567    
    568     UInt uiModeL        = pcCU->getLumaIntraDir(0);
    569     UInt uiMode         = pcCU->getChromaIntraDir(0);
    570    
    571     if (uiMode==4) uiMode = uiModeL;
    572    
    573     Int*   pPatChr;
    574    
    575     if (eText==TEXT_CHROMA_U)
    576     {
    577       pPatChr=  pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
    578     }
    579     else // (eText==TEXT_CHROMA_V)
    580     {
    581       pPatChr=  pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
    582     }
    583    
    584     m_pcPrediction-> predIntraChromaAng( pcCU->getPattern(), pPatChr, uiMode, pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
    585    
    586     // Inverse Transform
    587     if( pcCU->getCbf(0, eText, uiCurrTrMode) )
    588     {
    589 #if INTRA_DST_TYPE_7
    590     m_pcTrQuant->invtransformNxN( eText, REG_DCT, pResi, uiStride, piCoeff, uiWidth, uiHeight);
    591 #else
    592     m_pcTrQuant->invtransformNxN( pResi, uiStride, piCoeff, uiWidth, uiHeight );
    593 #endif
    594     }
    595     pResi = piResi;
    596    
    597     for( uiY = 0; uiY < uiHeight; uiY++ )
    598     {
    599       for( uiX = 0; uiX < uiWidth; uiX++ )
    600       {
    601         piReco   [uiX] = Clip( pPred[uiX] + pResi[uiX] );
    602         piPicReco[uiX] = piReco[uiX];
    603       }
    604      
    605       pPred     += uiStride;
    606       pResi     += uiStride;
    607       piReco    += uiStride;
    608       piPicReco += uiPicStride;
    609     }
    610   }
    611   else
    612   {
    613     uiCurrTrMode++;
    614     uiWidth  >>= 1;
    615     uiHeight >>= 1;
    616     UInt uiCoeffOffset = uiWidth*uiHeight;
    617     UInt uiPelOffset   = uiHeight*uiStride;
    618     UInt uiPartOffst   = pcCU->getTotalNumPart()>>(uiCurrTrMode<<1);
    619     Pel* pResi = piResi;
    620     Pel* pPred = piPred;
    621     Pel* pReco = piReco;
    622     xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
    623     uiAbsPartIdx += uiPartOffst;
    624     piCoeff      += uiCoeffOffset;
    625     pResi         = piResi + uiWidth; pPred = piPred + uiWidth; pReco = piReco + uiWidth;
    626     xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
    627     uiAbsPartIdx += uiPartOffst;
    628     piCoeff      += uiCoeffOffset;
    629     pResi         = piResi + uiPelOffset; pPred = piPred + uiPelOffset; pReco = piReco + uiPelOffset;
    630     xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
    631     uiAbsPartIdx += uiPartOffst;
    632     piCoeff      += uiCoeffOffset;
    633     pResi         = piResi + uiPelOffset + uiWidth; pPred = piPred + uiPelOffset + uiWidth; pReco = piReco + uiPelOffset + uiWidth;
    634     xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
    635661  }
    636662}
     
    670696                                     bAboveAvail, bLeftAvail );
    671697 
     698  //===== get prediction signal =====
    672699#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    673   if( uiLumaPredMode > MAX_MODE_ID_INTRA_DIR )
     700  if( uiLumaPredMode >= NUM_INTRA_MODE )
    674701  {
    675702    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
    676703  }
    677704  else
    678 #endif
    679   {   
    680   //===== get prediction signal =====
     705  {
     706#endif
    681707  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
    682   }
     708#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     709  }
     710#endif
     711 
    683712  //===== inverse transform =====
    684   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
    685 #if INTRA_DST_TYPE_7
    686   m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight );
     713#if H0736_AVC_STYLE_QP_RANGE
     714  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    687715#else
    688   m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
    689 #endif 
     716  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );
     717#endif
     718
     719  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
     720  assert(scalingListType < 6);
     721#if LOSSLESS_CODING
     722  m_pcTrQuant->invtransformNxN( pcCU, TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
     723#else 
     724  m_pcTrQuant->invtransformNxN(       TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
     725#endif
    690726
    691727 
    692728  //===== reconstruction =====
    693   {
    694     Pel* pPred      = piPred;
    695     Pel* pResi      = piResi;
    696     Pel* pReco      = piReco;
    697     Pel* pRecIPred  = piRecIPred;
    698     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    699     {
    700       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    701       {
    702         pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
    703         pRecIPred[ uiX ] = pReco[ uiX ];
    704       }
    705       pPred     += uiStride;
    706       pResi     += uiStride;
    707       pReco     += uiStride;
    708       pRecIPred += uiRecIPredStride;
    709     }
     729  Pel* pPred      = piPred;
     730  Pel* pResi      = piResi;
     731  Pel* pReco      = piReco;
     732  Pel* pRecIPred  = piRecIPred;
     733  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     734  {
     735    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     736    {
     737      pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
     738      pRecIPred[ uiX ] = pReco[ uiX ];
     739    }
     740    pPred     += uiStride;
     741    pResi     += uiStride;
     742    pReco     += uiStride;
     743    pRecIPred += uiRecIPredStride;
    710744  }
    711745}
     
    723757  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
    724758  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
    725   if( uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
     759
     760  if( uiLog2TrSize == 2 )
    726761  {
    727762    assert( uiTrDepth > 0 );
     
    748783  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
    749784 
    750 #if !LM_CHROMA
    751   if( uiChromaPredMode == 4 )
    752   {
    753     uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
    754   }
    755 #endif
    756  
    757785  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    758786  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
     
    763791  Bool  bLeftAvail  = false;
    764792  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
     793
     794  if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 )
     795  {
     796    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth,
     797                                     m_pcPrediction->getPredicBuf       (),
     798                                     m_pcPrediction->getPredicBufWidth  (),
     799                                     m_pcPrediction->getPredicBufHeight (),
     800                                     bAboveAvail, bLeftAvail,
     801                                     true );
     802
     803    m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight );
     804  }
     805 
    765806  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
    766807                                           m_pcPrediction->getPredicBuf       (),
     
    771812 
    772813  //===== get prediction signal =====
    773 #if LM_CHROMA
    774   if(pcCU->getSlice()->getSPS()->getUseLMChroma() && uiChromaPredMode == 3)
    775   {
    776       m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
     814  if( uiChromaPredMode == LM_CHROMA_IDX )
     815  {
     816    m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
    777817  }
    778818  else
    779819  {
    780     if( uiChromaPredMode == 4 )
    781     {
    782     uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
    783     }
    784   m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
    785   }
    786 #else // LM_CHROMA
    787   m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
    788 #endif
     820    if( uiChromaPredMode == DM_CHROMA_IDX )
     821    {
     822      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
     823#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     824      mapDMMtoIntraMode( uiChromaPredMode );
     825#endif
     826    }
     827    m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
     828  }
    789829
    790830  //===== inverse transform =====
    791   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
    792 #if INTRA_DST_TYPE_7
    793   m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight );
     831  if(eText == TEXT_CHROMA_U)
     832  {
     833#if H0736_AVC_STYLE_QP_RANGE
     834    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
    794835#else
    795   m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
     836    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getPPS()->getChromaQpOffset() );
     837#endif
     838  }
     839  else
     840  {
     841#if H0736_AVC_STYLE_QP_RANGE
     842    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
     843#else
     844    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
     845#endif
     846  }
     847
     848  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
     849  assert(scalingListType < 6);
     850#if LOSSLESS_CODING
     851  m_pcTrQuant->invtransformNxN( pcCU, eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
     852#else 
     853  m_pcTrQuant->invtransformNxN(       eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
    796854#endif
    797855
    798856  //===== reconstruction =====
    799   {
    800     Pel* pPred      = piPred;
    801     Pel* pResi      = piResi;
    802     Pel* pReco      = piReco;
    803     Pel* pRecIPred  = piRecIPred;
    804     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    805     {
    806       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    807       {
    808         pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
    809         pRecIPred[ uiX ] = pReco[ uiX ];
    810       }
    811       pPred     += uiStride;
    812       pResi     += uiStride;
    813       pReco     += uiStride;
    814       pRecIPred += uiRecIPredStride;
    815     }
     857  Pel* pPred      = piPred;
     858  Pel* pResi      = piResi;
     859  Pel* pReco      = piReco;
     860  Pel* pRecIPred  = piRecIPred;
     861  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     862  {
     863    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     864    {
     865      pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
     866      pRecIPred[ uiX ] = pReco[ uiX ];
     867    }
     868    pPred     += uiStride;
     869    pResi     += uiStride;
     870    pReco     += uiStride;
     871    pRecIPred += uiRecIPredStride;
    816872  }
    817873}
     
    850906  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
    851907 
    852 #if LM_CHROMA
     908  if (pcCU->getIPCMFlag(0))
     909  {
     910    xReconPCM( pcCU, uiAbsPartIdx, uiDepth );
     911    return;
     912  }
     913
    853914  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
    854915  {
     
    860921    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
    861922  }
    862 #else
    863 
    864   for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
    865   {
    866     xIntraRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
    867   }
    868 #endif
    869 
    870 }
    871 
    872 #if LM_CHROMA
    873 
    874 /** Funtion for deriving recontructed PU/CU Luma sample with QTree structure
     923
     924}
     925
     926/** Function for deriving recontructed PU/CU Luma sample with QTree structure
    875927 * \param pcCU pointer of current CU
    876928 * \param uiTrDepth current tranform split depth
     
    906958}
    907959
    908 /** Funtion for deriving recontructed PU/CU chroma samples with QTree structure
     960/** Function for deriving recontructed PU/CU chroma samples with QTree structure
    909961 * \param pcCU pointer of current CU
    910962 * \param uiTrDepth current tranform split depth
     
    940992  }
    941993}
    942 #endif
    943994
    944995Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
     
    9651016  piCoeff = pcCU->getCoeffY();
    9661017  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
    967   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
     1018
     1019#if H0736_AVC_STYLE_QP_RANGE
     1020  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
     1021#else
     1022  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 );
     1023#endif
     1024
    9681025  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
    9691026 
    9701027  // Cb and Cr
    971   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
    972  
     1028#if H0736_AVC_STYLE_QP_RANGE
     1029  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
     1030#else
     1031  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() );
     1032#endif
     1033
    9731034  uiWidth  >>= 1;
    9741035  uiHeight >>= 1;
    9751036  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
    9761037  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
     1038
     1039#if H0736_AVC_STYLE_QP_RANGE
     1040  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
     1041#else
     1042  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
     1043#endif
     1044
    9771045  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
    9781046  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
    9791047}
    9801048
     1049/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
     1050 * \param pcCU pointer to current CU
     1051 * \param uiPartIdx part index
     1052 * \param piPCM pointer to PCM code arrays
     1053 * \param piReco pointer to reconstructed sample arrays
     1054 * \param uiStride stride of reconstructed sample arrays
     1055 * \param uiWidth CU width
     1056 * \param uiHeight CU height
     1057 * \param ttText texture component type
     1058 * \returns Void
     1059 */
     1060Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
     1061{
     1062  UInt uiX, uiY;
     1063  Pel* piPicReco;
     1064  UInt uiPicStride;
     1065  UInt uiPcmLeftShiftBit;
     1066
     1067  if( ttText == TEXT_LUMA )
     1068  {
     1069    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
     1070    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
     1071    uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
     1072  }
     1073  else
     1074  {
     1075    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
     1076
     1077    if( ttText == TEXT_CHROMA_U )
     1078    {
     1079      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
     1080    }
     1081    else
     1082    {
     1083      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
     1084    }
     1085    uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
     1086  }
     1087
     1088  for( uiY = 0; uiY < uiHeight; uiY++ )
     1089  {
     1090    for( uiX = 0; uiX < uiWidth; uiX++ )
     1091    {
     1092      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
     1093      piPicReco[uiX] = piReco[uiX];
     1094    }
     1095    piPCM += uiWidth;
     1096    piReco += uiStride;
     1097    piPicReco += uiPicStride;
     1098  }
     1099}
     1100
     1101/** Function for reconstructing a PCM mode CU.
     1102 * \param pcCU pointer to current CU
     1103 * \param uiAbsPartIdx CU index
     1104 * \param uiDepth CU Depth
     1105 * \returns Void
     1106 */
     1107Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1108{
     1109  // Luma
     1110  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
     1111  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
     1112
     1113  Pel* piPcmY = pcCU->getPCMSampleY();
     1114  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
     1115
     1116  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
     1117
     1118  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
     1119
     1120  // Cb and Cr
     1121  UInt uiCWidth  = (uiWidth>>1);
     1122  UInt uiCHeight = (uiHeight>>1);
     1123
     1124  Pel* piPcmCb = pcCU->getPCMSampleCb();
     1125  Pel* piPcmCr = pcCU->getPCMSampleCr();
     1126  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
     1127  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
     1128
     1129  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
     1130
     1131  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
     1132  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
     1133}
     1134
     1135#if LOSSLESS_CODING
     1136/** Function for filling the PCM buffer of a CU using its reconstructed sample array
     1137 * \param pcCU pointer to current CU
     1138 * \param uiAbsPartIdx CU index
     1139 * \param uiDepth CU Depth
     1140 * \returns Void
     1141 */
     1142Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth)
     1143{
     1144  // Luma
     1145  UInt width  = (g_uiMaxCUWidth >> depth);
     1146  UInt height = (g_uiMaxCUHeight >> depth);
     1147
     1148  Pel* pPcmY = pCU->getPCMSampleY();
     1149  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
     1150
     1151  UInt stride = m_ppcYuvReco[depth]->getStride();
     1152
     1153  for(Int y = 0; y < height; y++ )
     1154  {
     1155    for(Int x = 0; x < width; x++ )
     1156    {
     1157      pPcmY[x] = pRecoY[x];
     1158    }
     1159    pPcmY += width;
     1160    pRecoY += stride;
     1161  }
     1162
     1163  // Cb and Cr
     1164  UInt widthC  = (width>>1);
     1165  UInt heightC = (height>>1);
     1166
     1167  Pel* pPcmCb = pCU->getPCMSampleCb();
     1168  Pel* pPcmCr = pCU->getPCMSampleCr();
     1169  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
     1170  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
     1171
     1172  UInt strideC = m_ppcYuvReco[depth]->getCStride();
     1173
     1174  for(Int y = 0; y < heightC; y++ )
     1175  {
     1176    for(Int x = 0; x < widthC; x++ )
     1177    {
     1178      pPcmCb[x] = pRecoCb[x];
     1179      pPcmCr[x] = pRecoCr[x];
     1180    }
     1181    pPcmCr += widthC;
     1182    pPcmCb += widthC;
     1183    pRecoCb += strideC;
     1184    pRecoCr += strideC;
     1185  }
     1186
     1187}
     1188#endif
     1189
     1190//! \}
Note: See TracChangeset for help on using the changeset viewer.