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


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

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

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

    r1196 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3737
    3838#include "TDecCu.h"
     39#include "TLibCommon/TComTU.h"
     40#include "TLibCommon/TComPrediction.h"
    3941
    4042//! \ingroup TLibDecoder
     
    5052  m_ppcYuvReco = NULL;
    5153  m_ppcCU      = NULL;
    52 #if H_3D_DBBP
     54#if NH_3D_DBBP
    5355  m_ppcYuvRecoDBBP = NULL;
    5456#endif
     
    6769
    6870/**
    69  \param    uiMaxDepth    total number of allowable depth
    70  \param    uiMaxWidth    largest CU width
    71  \param    uiMaxHeight   largest CU height
     71 \param    uiMaxDepth      total number of allowable depth
     72 \param    uiMaxWidth      largest CU width
     73 \param    uiMaxHeight     largest CU height
     74 \param    chromaFormatIDC chroma format
    7275 */
    73 Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
     76Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC )
    7477{
    7578  m_uiMaxDepth = uiMaxDepth+1;
    76  
     79
    7780  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
    7881  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
    7982  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
    80 #if H_3D_DBBP
     83#if NH_3D_DBBP
    8184  m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
    8285#endif
    83  
    84   UInt uiNumPartitions;
     86
    8587  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
    8688  {
    87     uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
     89    UInt uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
    8890    UInt uiWidth  = uiMaxWidth  >> ui;
    8991    UInt uiHeight = uiMaxHeight >> ui;
    90    
    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     m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
    94 #if H_3D_DBBP
    95     m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
    96 #endif
    97   }
    98  
     92
     93    // The following arrays (m_ppcYuvResi, m_ppcYuvReco and m_ppcCU) are only required for CU depths
     94    // although data is allocated for all possible depths of the CU/TU tree except the last.
     95    // Since the TU tree will always include at least one additional depth greater than the CU tree,
     96    // there will be enough entries for these arrays.
     97    // (Section 7.4.3.2: "The CVS shall not contain data that result in (Log2MinTrafoSize) MinTbLog2SizeY
     98    //                    greater than or equal to MinCbLog2SizeY")
     99    // TODO: tidy the array allocation given the above comment.
     100
     101    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
     102    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
     103    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
     104#if NH_3D_DBBP
     105    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
     106#endif
     107}
     108
    99109  m_bDecodeDQP = false;
     110  m_IsChromaQpAdjCoded = false;
    100111
    101112  // initialize partition order.
     
    103114  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
    104115  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
    105  
     116
    106117  // initialize conversion matrix from partition index to pel
    107118  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
     
    115126    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
    116127    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
    117 #if H_3D_DBBP
     128#if NH_3D_DBBP
    118129    m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
    119130#endif
    120131  }
    121  
     132
    122133  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
    123134  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
    124135  delete [] m_ppcCU     ; m_ppcCU      = NULL;
    125 #if H_3D_DBBP
     136#if NH_3D_DBBP
    126137  delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
    127138#endif
     
    132143// ====================================================================================================================
    133144
    134 /** \param    pcCU        pointer of CU data
    135  \param    ruiIsLast   last data?
     145/**
     146 Parse a CTU.
     147 \param    pCtu                      [in/out] pointer to CTU data structure
     148 \param    isLastCtuOfSliceSegment   [out]    true, if last CTU of the slice segment
    136149 */
    137 Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
    138 {
    139   if ( pcCU->getSlice()->getPPS()->getUseDQP() )
     150Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment )
     151{
     152  if ( pCtu->getSlice()->getPPS()->getUseDQP() )
    140153  {
    141154    setdQPFlag(true);
    142155  }
    143156
     157  if ( pCtu->getSlice()->getUseChromaQpAdj() )
     158  {
     159    setIsChromaQpAdjCoded(true);
     160  }
     161 
    144162  // start from the top level CU
    145   xDecodeCU( pcCU, 0, 0, ruiIsLast);
    146 }
    147 
    148 /** \param    pcCU        pointer of CU data
     163  xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment);
     164}
     165
     166/**
     167 Decoding process for a CTU.
     168 \param    pCtu                      [in/out] pointer to CTU data structure
    149169 */
    150 Void TDecCu::decompressCU( TComDataCU* pcCU )
    151 {
    152 #if !H_3D_IV_MERGE
    153   xDecompressCU( pcCU, 0,  0 );
     170Void TDecCu::decompressCtu( TComDataCU* pCtu )
     171{
     172#if !NH_3D_IV_MERGE
     173  xDecompressCU( pCtu, 0,  0 );
    154174#endif
    155175}
     
    159179// ====================================================================================================================
    160180
    161 /**decode end-of-slice flag
    162  * \param pcCU
    163  * \param uiAbsPartIdx
    164  * \param uiDepth
    165  * \returns Bool
    166  */
    167 Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)
    168 {
    169   UInt uiIsLast;
    170   TComPic* pcPic = pcCU->getPic();
    171   TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
    172   UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
    173   UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
    174   UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
    175   UInt uiGranularityWidth = g_uiMaxCUWidth;
    176   UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    177   UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    178 
    179   if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
    180     &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
    181   {
    182     m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
     181//! decode end-of-slice flag
     182Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx )
     183{
     184  UInt uiIsLastCtuOfSliceSegment;
     185
     186  if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx))
     187  {
     188    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment );
    183189  }
    184190  else
    185191  {
    186     uiIsLast=0;
    187   }
    188  
    189   if(uiIsLast)
    190   {
    191     if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice())
    192     {
    193       pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
    194     }
    195     else
    196     {
    197       pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
    198       pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
    199     }
    200   }
    201 
    202   return uiIsLast>0;
    203 }
    204 
    205 /** decode CU block recursively
    206  * \param pcCU
    207  * \param uiAbsPartIdx
    208  * \param uiDepth
    209  * \returns Void
    210  */
    211 
    212 Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
    213 {
    214   TComPic* pcPic = pcCU->getPic();
    215   UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
     192    uiIsLastCtuOfSliceSegment=0;
     193  }
     194
     195  return uiIsLastCtuOfSliceSegment>0;
     196}
     197
     198//! decode CU block recursively
     199Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment)
     200{
     201  TComPic* pcPic        = pcCU->getPic();
     202  const TComSPS &sps    = pcPic->getPicSym()->getSPS();
     203  const TComPPS &pps    = pcPic->getPicSym()->getPPS();
     204  const UInt maxCuWidth = sps.getMaxCUWidth();
     205  const UInt maxCuHeight= sps.getMaxCUHeight();
     206  UInt uiCurNumParts    = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1);
    216207  UInt uiQNumParts      = uiCurNumParts>>2;
    217  
     208
     209
    218210  Bool bBoundary = false;
    219211  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    220   UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
     212  UInt uiRPelX   = uiLPelX + (maxCuWidth>>uiDepth)  - 1;
    221213  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    222   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
     214  UInt uiBPelY   = uiTPelY + (maxCuHeight>>uiDepth) - 1;
    223215#if H_MV_ENC_DEC_TRAC
    224216  DTRACE_CU_S("=========== coding_quadtree ===========\n")
    225217  DTRACE_CU("x0", uiLPelX)
    226218  DTRACE_CU("x1", uiTPelY)
    227   DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth)
     219  DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth)
    228220  DTRACE_CU("cqtDepth"  , uiDepth)
    229221#endif
    230222
    231   TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
    232   Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
    233   if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     223  if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) )
    234224  {
    235225    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
     
    239229    bBoundary = true;
    240230  }
    241  
    242   if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
     231  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
    243232  {
    244233    UInt uiIdx = uiAbsPartIdx;
    245     if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     234    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
    246235    {
    247236      setdQPFlag(true);
     
    249238    }
    250239
     240    if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
     241    {
     242      setIsChromaQpAdjCoded(true);
     243    }
     244
    251245    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
    252246    {
    253247      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
    254248      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    255      
    256       Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
    257       if ( bSubInSlice )
    258       {
    259         if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
    260         {
    261           xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
    262         }
    263         else
    264         {
    265           pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
    266         }
    267       }
    268      
     249
     250      if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
     251      {
     252        xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment );
     253      }
     254      else
     255      {
     256        pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
     257      }
     258
    269259      uiIdx += uiQNumParts;
    270260    }
    271     if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     261    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
    272262    {
    273263      if ( getdQPFlag() )
    274264      {
    275         UInt uiQPSrcPartIdx;
    276         if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
    277         {
    278           uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
    279         }
    280         else
    281         {
    282           uiQPSrcPartIdx = uiAbsPartIdx;
    283         }
     265        UInt uiQPSrcPartIdx = uiAbsPartIdx;
    284266        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
    285267      }
     
    287269    return;
    288270  }
    289  
     271
    290272#if H_MV_ENC_DEC_TRAC
    291273  DTRACE_CU_S("=========== coding_unit ===========\n")
     
    303285#endif
    304286
    305   if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     287  if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP())
    306288  {
    307289    setdQPFlag(true);
    308290    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
    309291  }
    310 #if H_3D_NBDV
     292#if NH_3D_NBDV
    311293  DisInfo DvInfo;
    312294  DvInfo.m_acNBDV.setZero();
    313295  DvInfo.m_aVIdxCan = 0;
    314 #if H_3D_NBDV_REF 
     296#if NH_3D_NBDV_REF 
    315297  DvInfo.m_acDoNBDV.setZero();
    316298#endif
    317299 
    318  
    319   if(!pcCU->getSlice()->isIntra())
    320   {
    321 #if H_3D_ARP && H_3D_IV_MERGE
    322     if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() )
     300if(!pcCU->getSlice()->isIntra())
     301  {
     302#if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
     303    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
    323304#else
     305#if NH_3D_IV_MERGE && NH_3D_VSP
     306    if( pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
     307#else
     308#if NH_3D_ARP && NH_3D_VSP
     309    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
     310#else
     311#if NH_3D_VSP
     312    if( pcCU->getSlice()->getViewSynthesisPredFlag() )
     313#else
    324314#if H_3D_ARP
    325     if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
     315    if( pcCU->getSlice()->getIvResPredFlag( ) )
    326316#else
    327317#if H_3D_IV_MERGE
    328318    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
    329319#else
     320#if NH_3D_DBBP
     321    if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )
     322#else
    330323    if (0)
    331324#endif
    332325#endif
    333326#endif
    334     {
    335       m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
    336       m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
     327#endif
     328#endif
     329#endif
     330#endif
     331    {
     332      m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true);
     333      m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
    337334      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
    338335      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
    339336      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
    340       m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
    341       m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
    342       m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
    343 #if H_3D_IV_MERGE
     337      m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth));
     338      m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth));
     339      m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);     
     340#if NH_3D_IV_MERGE
    344341      if( pcCU->getSlice()->getIsDepth())
    345342      {
     
    349346      {
    350347#endif
    351 #if H_3D_NBDV_REF
     348#if NH_3D_NBDV_REF
    352349      if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
    353350      {
     
    359356        m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
    360357      }
    361 #if H_3D_IV_MERGE
     358#if NH_3D_IV_MERGE
    362359      }
    363360#endif
     
    372369      }
    373370#endif
    374 
    375371      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
    376       m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
    377       m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
    378       m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
     372      m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth);
     373      m_ppcCU[uiDepth]->setWidth(0, cWidTemp);
     374      m_ppcCU[uiDepth]->setHeight(0, cHeightTemp);
    379375     }
    380376  }
    381377#endif
    382   if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     378
     379  if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
     380  {
     381    setIsChromaQpAdjCoded(true);
     382  }
     383
     384  if (pps.getTransquantBypassEnableFlag())
    383385  {
    384386    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
    385387  }
    386  
     388
    387389  // decode CU mode and the partition size
    388390  if( !pcCU->getSlice()->isIntra())
     
    390392    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
    391393  }
    392  
     394
     395
    393396  if( pcCU->isSkipped(uiAbsPartIdx) )
    394397  {
     
    400403    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
    401404    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
    402 #if H_3D_IV_MERGE
     405#if NH_3D_IV_MERGE
    403406    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
     407    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
     408    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     409#else
     410#if NH_3D_MLC
    404411    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
    405412    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
     
    408415    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
    409416#endif
     417#endif
    410418    Int numValidMergeCand = 0;
    411419    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
     
    415423    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
    416424    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
    417 #if H_3D_ARP
     425#if NH_3D_ARP
    418426    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
    419427#endif
    420 #if H_3D_IC
     428#if NH_3D_IC
    421429    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
    422430#endif
    423431
    424 #if H_3D_VSP
     432
     433#if NH_3D_VSP
    425434    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
    426435    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
    427 #if H_3D_SPIVMP
     436#endif
     437#if NH_3D_SPIVMP
    428438    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
    429439    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
    430440    TComMvField*  pcMvFieldSP;
    431441    UChar* puhInterDirSP;
    432     pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2];
    433     puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()];
    434 #endif
     442    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2];
     443    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()];
     444#endif
     445
     446#if NH_3D_MLC
    435447    m_ppcCU[uiDepth]->initAvailableFlags();
     448#endif
    436449    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     450#if NH_3D_MLC
    437451    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
    438 #if H_3D_SPIVMP
     452#if NH_3D_SPIVMP
    439453      , pcMvFieldSP, puhInterDirSP
    440454#endif
    441455      , numValidMergeCand, uiMergeIndex );
    442456
    443     m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
    444 #if H_3D_SPIVMP
     457    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
     458#if NH_3D_VSP
     459      , vspFlag
     460#endif
     461#if NH_3D_SPIVMP
    445462      , bSPIVMPFlag
    446463#endif
    447464      , numValidMergeCand );
     465#endif
     466#if NH_3D_VSP
    448467    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    449 #else
    450 #if H_3D
    451     m_ppcCU[uiDepth]->initAvailableFlags();
    452     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    453     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    454 #else
    455     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    456 #endif
    457 #endif
     468#endif
     469
    458470    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    459471
    460472    TComMv cTmpMv( 0, 0 );
    461473    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    462     {       
     474    {
    463475      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    464476      {
     
    467479        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    468480        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    469 #if H_3D_VSP
     481#if NH_3D_VSP
    470482        if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
    471483        {
     
    500512      }
    501513    }
    502 #if H_3D_SPIVMP
     514#if NH_3D_SPIVMP
    503515    pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    504516    if (bSPIVMPFlag[uiMergeIndex])
     
    524536#endif
    525537
    526     xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    527 #if H_3D_IV_MERGE
     538    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
     539#if NH_3D_IV_MERGE
    528540    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    529541#endif
     542
    530543    return;
    531544  }
    532 #if H_3D
     545#if NH_3D_DIS
    533546  m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth );
    534547  if(!pcCU->getDISFlag(uiAbsPartIdx))
    535548  {
    536549#endif
     550
    537551  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
    538552  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
     
    544558    if(pcCU->getIPCMFlag(uiAbsPartIdx))
    545559    {
    546 #if H_3D_DIM_SDC
     560#if NH_3D_SDC_INTRA
    547561      m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
    548562#endif
    549       xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    550 #if H_3D_IV_MERGE
     563      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
     564#if NH_3D_IV_MERGE
    551565      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    552566#endif
     
    555569  }
    556570
    557   UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
    558   UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
    559  
    560571  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
    561572  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
     
    563574  // Coefficient decoding
    564575  Bool bCodeDQP = getdQPFlag();
    565   m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
     576  Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded();
     577  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded );
     578  setIsChromaQpAdjCoded( isChromaQpAdjCoded );
    566579  setdQPFlag( bCodeDQP );
    567 #if H_3D
    568   }
    569 #endif
    570   xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
    571 #if H_3D_IV_MERGE
     580#if NH_3D_DIS
     581  }
     582#endif
     583  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
     584#if NH_3D_IV_MERGE
    572585  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    573586#endif
    574587}
    575588
    576 Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
     589Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment)
    577590{
    578591  if(  pcCU->getSlice()->getPPS()->getUseDQP())
     
    581594  }
    582595
    583   ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
    584 }
    585 
    586 Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
    587 {
    588   TComPic* pcPic = pcCU->getPic();
    589 #if !H_3D_IV_MERGE
     596  if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded())
     597  {
     598    pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP
     599  }
     600
     601  isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx );
     602}
     603
     604Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx,  UInt uiDepth )
     605{
     606  TComPic* pcPic = pCtu->getPic();
     607#if !NH_3D_IV_MERGE
     608  TComSlice * pcSlice = pCtu->getSlice();
     609  const TComSPS &sps=*(pcSlice->getSPS());
     610
    590611  Bool bBoundary = false;
    591   UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    592   UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
    593   UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    594   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
    595 
    596   UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
    597   TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
    598   Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
    599   if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
     612  UInt uiLPelX   = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     613  UInt uiRPelX   = uiLPelX + (sps.getMaxCUWidth()>>uiDepth)  - 1;
     614  UInt uiTPelY   = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     615  UInt uiBPelY   = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1;
     616
     617  if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) )
    600618  {
    601619    bBoundary = true;
    602620  }
    603621
    604   if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
     622  if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
    605623  {
    606624    UInt uiNextDepth = uiDepth + 1;
    607     UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
     625    UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1);
    608626    UInt uiIdx = uiAbsPartIdx;
    609627    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
    610628    {
    611       uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
    612       uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    613 
    614       Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
    615       if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    616       {
    617         xDecompressCU(pcCU, uiIdx, uiNextDepth );
     629      uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
     630      uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
     631
     632      if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
     633      {
     634        xDecompressCU(pCtu, uiIdx, uiNextDepth );
    618635      }
    619636
     
    622639    return;
    623640  }
    624 #endif 
     641#endif
    625642  // Residual reconstruction
    626643  m_ppcYuvResi[uiDepth]->clear();
    627644
    628   m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
     645  m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx );
    629646
    630647  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
    631648  {
    632   case MODE_INTER:
    633 #if H_3D_DBBP
     649    case MODE_INTER:
     650#if NH_3D_DBBP
    634651    if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
    635652    {
     
    639656    {
    640657#endif
    641 #if H_3D_INTER_SDC
     658#if NH_3D_SDC_INTER
    642659      if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
    643660      {
     
    647664      {
    648665#endif
    649         xReconInter( m_ppcCU[uiDepth], uiDepth );
    650 #if H_3D_INTER_SDC
    651       }
    652 #endif
    653 #if H_3D_DBBP
    654     }
    655 #endif
    656     break;
    657   case MODE_INTRA:
    658 #if H_3D
     666      xReconInter( m_ppcCU[uiDepth], uiDepth );
     667#if NH_3D_SDC_INTER
     668      }
     669#endif
     670#if NH_3D_DBBP
     671    }
     672#endif
     673      break;
     674    case MODE_INTRA:
     675#if NH_3D
     676#if NH_3D_DIS
    659677    if( m_ppcCU[uiDepth]->getDISFlag(0) )
    660678    {
    661679      xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
    662680    }
    663 #if H_3D_DIM_SDC
     681#else
     682    if(false )
     683    {
     684     // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
     685    }
     686#endif
     687#if NH_3D_SDC_INTRA
    664688    else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
    665689    {
     
    670694#endif
    671695      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
    672     break;
    673   default:
    674     assert(0);
    675     break;
    676   }
     696      break;
     697    default:
     698      assert(0);
     699      break;
     700  }
     701
     702#if DEBUG_STRING
     703  const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0);
     704  if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode))
     705  {
     706    PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0);
     707    std::ostream &ss(std::cout);
     708
     709    ss <<"###: " << (predMode==MODE_INTRA?"Intra   ":"Inter   ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl;
     710  }
     711#endif
     712
    677713  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
    678714  {
     
    685721Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
    686722{
    687  
     723
    688724  // inter prediction
    689725  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
    690  
     726
     727#if DEBUG_STRING
     728  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER);
     729  if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask)
     730  {
     731    printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth]));
     732  }
     733#endif
     734
    691735  // inter recon
    692   xDecodeInterTexture( pcCU, 0, uiDepth );
    693  
     736  xDecodeInterTexture( pcCU, uiDepth );
     737
     738#if DEBUG_STRING
     739  if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask)
     740  {
     741    printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth]));
     742  }
     743#endif
     744
    694745  // clip for only non-zero cbp case
    695   if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
    696   {
    697     m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
     746  if  ( pcCU->getQtRootCbf( 0) )
     747  {
     748    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
    698749  }
    699750  else
     
    701752    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
    702753  }
    703 }
    704 
    705 #if H_3D
     754#if DEBUG_STRING
     755  if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask)
     756  {
     757    printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth]));
     758  }
     759#endif
     760
     761}
     762
     763#if NH_3D_DIS
    706764Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    707765{
     
    711769  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
    712770
    713   UInt    uiStride    = pcRecoYuv->getStride  ();
    714   Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
     771  UInt    uiStride    = pcRecoYuv->getStride  (COMPONENT_Y);
     772  Pel*    piReco      = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
    715773
    716774
    717775  AOF( uiWidth == uiHeight );
    718776  AOF( uiAbsPartIdx == 0 );
    719 
    720   Bool  bAboveAvail = false;
    721   Bool  bLeftAvail  = false;
    722   pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
    723   pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0,
    724     m_pcPrediction->getPredicBuf       (),
    725     m_pcPrediction->getPredicBufWidth  (),
    726     m_pcPrediction->getPredicBufHeight (),
    727     bAboveAvail, bLeftAvail
    728     );
     777 
     778  TComTURecurse rTu(pcCU, 0);
     779  const ChromaFormat chFmt     = rTu.GetChromaFormat();
    729780
    730781  if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
    731782  {
    732     m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), VER_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
     783    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     784    m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
     785    m_pcPrediction->predIntraAng( COMPONENT_Y,   VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions );
    733786  }
    734787  else if ( pcCU->getDISType(uiAbsPartIdx) == 1 )
    735788  {
    736     m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), HOR_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
     789    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     790    m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
     791    m_pcPrediction->predIntraAng( COMPONENT_Y,   HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions );
    737792  }
    738793  else if ( pcCU->getDISType(uiAbsPartIdx) == 2 )
    739794  {
    740     Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
     795    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
    741796    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
    742797    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     
    751806  else if ( pcCU->getDISType(uiAbsPartIdx) == 3 )
    752807  {
    753     Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
     808    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
    754809    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
    755810    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     
    764819
    765820  // clear UV
    766   UInt  uiStrideC     = pcRecoYuv->getCStride();
    767   Pel   *pRecCb       = pcRecoYuv->getCbAddr();
    768   Pel   *pRecCr       = pcRecoYuv->getCrAddr();
     821  UInt  uiStrideC     = pcRecoYuv->getStride(COMPONENT_Cb);
     822  Pel   *pRecCb       = pcRecoYuv->getAddr(COMPONENT_Cb);
     823  Pel   *pRecCr       = pcRecoYuv->getAddr(COMPONENT_Cr);
    769824
    770825  for (Int y=0; y<uiHeight/2; y++)
     
    772827    for (Int x=0; x<uiWidth/2; x++)
    773828    {
    774       pRecCb[x] = 1<<(g_bitDepthC-1);
    775       pRecCr[x] = 1<<(g_bitDepthC-1);
     829      pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
     830      pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
    776831    }
    777832
     
    781836}
    782837#endif
    783 #if H_3D_INTER_SDC
     838#if NH_3D_SDC_INTER
    784839Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    785840{
     
    792847  Pel  *pResi;
    793848  UInt uiPelX, uiPelY;
    794   UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
    795 
    796   pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
     849  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride( COMPONENT_Y );
     850  Int  bitDepthC = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA);
     851
     852  pResi = m_ppcYuvResi[uiDepth]->getAddr( COMPONENT_Y );
    797853  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
    798854  {
     
    804860  }
    805861
    806   m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
     862  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
    807863
    808864  // clear UV
    809   UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
    810   Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
    811   Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
     865  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getStride( COMPONENT_Cb );
     866  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cb );
     867  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cr );
    812868
    813869  for (Int y = 0; y < uiHeight/2; y++)
     
    815871    for (Int x = 0; x < uiWidth/2; x++)
    816872    {
    817       pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
    818       pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
     873      pRecCb[x] = (Pel)( 1 << ( bitDepthC - 1 ) );
     874      pRecCr[x] = (Pel)( 1 << ( bitDepthC - 1 ) );
    819875    }
    820876
     
    825881#endif
    826882
    827 #if H_3D_DBBP
     883#if NH_3D_DBBP
    828884Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    829885{
     
    831887  AOF(!pcCU->getSlice()->isIntra());
    832888  PartSize ePartSize = pcCU->getPartitionSize( 0 );
     889 
     890  Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    833891 
    834892  // get collocated depth block
     
    851909 
    852910  // first, extract the two sets of motion parameters
    853   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
     911  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
    854912  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
    855913  {
     
    857915   
    858916    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
     917    assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2  );  // only uni-prediction allowed
    859918   
    860919    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     
    864923    }
    865924   
     925#if NH_3D
    866926    AOF( pcCU->getARPW(uiPartAddr) == 0 );
    867927    AOF( pcCU->getICFlag(uiPartAddr) == false );
    868928    AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
    869929    AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
     930#endif
    870931  }
    871932 
     
    907968 
    908969  // reconstruct final prediction signal by combining both segments
    909   m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize);
     970  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY);
    910971
    911972  // inter recon
    912   xDecodeInterTexture( pcCU, 0, uiDepth );
     973  xDecodeInterTexture( pcCU, uiDepth );
    913974 
    914975  // clip for only non-zero cbp case
    915   if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
    916   {
    917     m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
     976  if  ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) )
     977  {
     978    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
    918979  }
    919980  else
     
    924985#endif
    925986
     987
    926988Void
    927 TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
    928                          UInt        uiTrDepth,
    929                          UInt        uiAbsPartIdx,
    930                          TComYuv*    pcRecoYuv,
    931                          TComYuv*    pcPredYuv,
    932                          TComYuv*    pcResiYuv )
    933 {
    934   UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
    935   UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
    936   UInt    uiStride          = pcRecoYuv->getStride  ();
    937   Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
    938   Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    939   Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
    940  
    941   UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
    942   TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
    943  
    944   UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
    945  
    946   UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    947   Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    948   UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    949   Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
     989TDecCu::xIntraRecBlk(       TComYuv*    pcRecoYuv,
     990                            TComYuv*    pcPredYuv,
     991                            TComYuv*    pcResiYuv,
     992                      const ComponentID compID,
     993                            TComTU     &rTu)
     994{
     995  if (!rTu.ProcessComponentSection(compID))
     996  {
     997    return;
     998  }
     999  const Bool       bIsLuma = isLuma(compID);
     1000
     1001
     1002  TComDataCU *pcCU = rTu.getCU();
     1003  const TComSPS &sps=*(pcCU->getSlice()->getSPS());
     1004  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
     1005
     1006  const TComRectangle &tuRect  =rTu.getRect(compID);
     1007  const UInt uiWidth           = tuRect.width;
     1008  const UInt uiHeight          = tuRect.height;
     1009  const UInt uiStride          = pcRecoYuv->getStride (compID);
     1010        Pel* piPred            = pcPredYuv->getAddr( compID, uiAbsPartIdx );
     1011  const ChromaFormat chFmt     = rTu.GetChromaFormat();
     1012
     1013  if (uiWidth != uiHeight)
     1014  {
     1015    //------------------------------------------------
     1016
     1017    //split at current level if dividing into square sub-TUs
     1018
     1019    TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
     1020
     1021    //recurse further
     1022    do
     1023    {
     1024      xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse);
     1025    } while (subTURecurse.nextSection(rTu));
     1026
     1027    //------------------------------------------------
     1028
     1029    return;
     1030  }
     1031
     1032  const UInt uiChPredMode  = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx );
     1033  const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize()));
     1034  const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode;
     1035  const UInt uiChFinalMode = ((chFmt == CHROMA_422)       && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode;
     1036
    9501037  //===== init availability pattern =====
    951   Bool  bAboveAvail = false;
    952   Bool  bLeftAvail  = false;
    953   pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
    954   pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth,
    955                                      m_pcPrediction->getPredicBuf       (),
    956                                      m_pcPrediction->getPredicBufWidth  (),
    957                                      m_pcPrediction->getPredicBufHeight (),
    958                                      bAboveAvail, bLeftAvail );
    959  
     1038  const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     1039
     1040#if DEBUG_STRING
     1041  std::ostream &ss(std::cout);
     1042#endif
     1043
     1044  DEBUG_STRING_NEW(sTemp)
     1045  m_pcPrediction->initIntraPatternChType( rTu, compID, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
     1046
     1047
    9601048  //===== get prediction signal =====
    961 #if H_3D_DIM
    962   if( isDimMode( uiLumaPredMode ) )
    963   {
    964     m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
     1049#if NH_3D_DMM
     1050  if( bIsLuma && isDmmMode( uiChFinalMode ) )
     1051  {
     1052    m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight );
    9651053  }
    9661054  else
    9671055  {
    9681056#endif
    969   m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    970 #if H_3D_DIM
    971   }
    972 #endif
    973  
     1057  m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions );
     1058#if NH_3D_DMM
     1059  }
     1060#endif
     1061
     1062#if DEBUG_STRING
     1063  ss << sTemp;
     1064#endif
     1065
     1066  //===== inverse transform =====
     1067  Pel*      piResi            = pcResiYuv->getAddr( compID, uiAbsPartIdx );
     1068  TCoeff*   pcCoeff           = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx );
     1069
     1070  const QpParam cQP(*pcCU, compID);
     1071
     1072
     1073  DEBUG_STRING_NEW(sDebug);
     1074#if DEBUG_STRING
     1075  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
     1076  std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
     1077#endif
    9741078#if H_3D
    975   Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
     1079  Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
    9761080
    9771081  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
    9781082#else
    979   if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) )
    980 #endif
    981   {
    982   //===== inverse transform =====
    983   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    984 
    985   Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
    986     assert(scalingListType < SCALING_LIST_NUM);
    987   m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
    988 
    989  
     1083  if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0)
     1084#endif
     1085  {
     1086    m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
     1087  }
     1088  else
     1089  {
     1090    for (UInt y = 0; y < uiHeight; y++)
     1091    {
     1092      for (UInt x = 0; x < uiWidth; x++)
     1093      {
     1094        piResi[(y * uiStride) + x] = 0;
     1095      }
     1096    }
     1097  }
     1098
     1099#if DEBUG_STRING
     1100  if (psDebug)
     1101  {
     1102    ss << (*psDebug);
     1103  }
     1104#endif
     1105
    9901106  //===== reconstruction =====
    991   Pel* pPred      = piPred;
    992   Pel* pResi      = piResi;
    993   Pel* pReco      = piReco;
    994   Pel* pRecIPred  = piRecIPred;
     1107  const UInt uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride(compID);
     1108
     1109  const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0);
     1110  const Pel* pResiLuma  = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
     1111  const Int  strideLuma = pcResiYuv->getStride( COMPONENT_Y );
     1112
     1113        Pel* pPred      = piPred;
     1114        Pel* pResi      = piResi;
     1115        Pel* pReco      = pcRecoYuv->getAddr( compID, uiAbsPartIdx );
     1116        Pel* pRecIPred  = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
     1117
     1118
     1119#if DEBUG_STRING
     1120  const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
     1121  const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
     1122  const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
     1123  if (bDebugPred || bDebugResi || bDebugReco)
     1124  {
     1125    ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl;
     1126  }
     1127#endif
     1128
     1129  const Int clipbd = sps.getBitDepth(toChannelType(compID));
     1130#if O0043_BEST_EFFORT_DECODING
     1131  const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd;
     1132#endif
     1133
     1134  if( useCrossComponentPrediction )
     1135  {
     1136    TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true );
     1137  }
     1138
    9951139  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    9961140  {
     1141#if DEBUG_STRING
     1142    if (bDebugPred || bDebugResi || bDebugReco)
     1143    {
     1144      ss << "###: ";
     1145    }
     1146
     1147    if (bDebugPred)
     1148    {
     1149      ss << " - pred: ";
     1150      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     1151      {
     1152        ss << pPred[ uiX ] << ", ";
     1153      }
     1154    }
     1155    if (bDebugResi)
     1156    {
     1157      ss << " - resi: ";
     1158    }
     1159#endif
     1160
    9971161    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    9981162    {
    999       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
     1163#if DEBUG_STRING
     1164      if (bDebugResi)
     1165      {
     1166        ss << pResi[ uiX ] << ", ";
     1167      }
     1168#endif
     1169#if O0043_BEST_EFFORT_DECODING
     1170      pReco    [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd );
     1171#else
     1172      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd );
     1173#endif
    10001174      pRecIPred[ uiX ] = pReco[ uiX ];
    10011175    }
     1176#if DEBUG_STRING
     1177    if (bDebugReco)
     1178    {
     1179      ss << " - reco: ";
     1180      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     1181      {
     1182        ss << pReco[ uiX ] << ", ";
     1183      }
     1184    }
     1185
     1186    if (bDebugPred || bDebugResi || bDebugReco)
     1187    {
     1188      ss << "\n";
     1189    }
     1190#endif
    10021191    pPred     += uiStride;
    10031192    pResi     += uiStride;
     
    10061195  }
    10071196}
    1008   else
    1009   {
    1010     //===== reconstruction =====
    1011     Pel* pPred      = piPred;
    1012     Pel* pReco      = piReco;
    1013     Pel* pRecIPred  = piRecIPred;
    1014     for ( Int y = 0; y < uiHeight; y++ )
    1015     {
    1016       for ( Int x = 0; x < uiWidth; x++ )
    1017       {
    1018         pReco    [ x ] = pPred[ x ];
    1019         pRecIPred[ x ] = pReco[ x ];
    1020       }
    1021       pPred     += uiStride;
    1022       pReco     += uiStride;
    1023       pRecIPred += uiRecIPredStride;
    1024     }
    1025   }
    1026 }
    1027 
    1028 
    1029 Void
    1030 TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
    1031                            UInt        uiTrDepth,
    1032                            UInt        uiAbsPartIdx,
    1033                            TComYuv*    pcRecoYuv,
    1034                            TComYuv*    pcPredYuv,
    1035                            TComYuv*    pcResiYuv,
    1036                            UInt        uiChromaId )
    1037 {
    1038   UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
    1039   UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
    1040 
    1041   if( uiLog2TrSize == 2 )
    1042   {
    1043     assert( uiTrDepth > 0 );
    1044     uiTrDepth--;
    1045     UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
    1046     Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
    1047     if( !bFirstQ )
    1048     {
    1049       return;
    1050     }
    1051   }
    1052 
    1053   TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
    1054   UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
    1055   UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
    1056   UInt      uiStride          = pcRecoYuv->getCStride ();
    1057   Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
    1058   Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
    1059   Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
    1060 
    1061   UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
    1062   TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
    1063 
    1064   UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
    1065 
    1066   UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    1067   Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
    1068   UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
    1069   Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
    1070   //===== init availability pattern =====
    1071   Bool  bAboveAvail = false;
    1072   Bool  bLeftAvail  = false;
    1073   pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
    1074 
    1075   pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
    1076     m_pcPrediction->getPredicBuf       (),
    1077     m_pcPrediction->getPredicBufWidth  (),
    1078     m_pcPrediction->getPredicBufHeight (),
    1079     bAboveAvail, bLeftAvail );
    1080   Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
    1081 
    1082   //===== get prediction signal =====
    1083   {
    1084     if( uiChromaPredMode == DM_CHROMA_IDX )
    1085     {
    1086       uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
    1087 #if H_3D_DIM
    1088       mapDepthModeToIntraDir( uiChromaPredMode );
    1089 #endif
    1090     }
    1091     m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
    1092   }
    1093 
    1094   if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) )
    1095   {
    1096     //===== inverse transform =====
    1097     Int curChromaQpOffset;
    1098     if(eText == TEXT_CHROMA_U)
    1099     {
    1100       curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
    1101     }
    1102     else
    1103     {
    1104       curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
    1105     }
    1106     m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
    1107 
    1108     Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
    1109     assert(scalingListType < SCALING_LIST_NUM);
    1110     m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
    1111 
    1112     //===== reconstruction =====
    1113     Pel* pPred      = piPred;
    1114     Pel* pResi      = piResi;
    1115     Pel* pReco      = piReco;
    1116     Pel* pRecIPred  = piRecIPred;
    1117     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1118     {
    1119       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1120       {
    1121         pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
    1122         pRecIPred[ uiX ] = pReco[ uiX ];
    1123       }
    1124       pPred     += uiStride;
    1125       pResi     += uiStride;
    1126       pReco     += uiStride;
    1127       pRecIPred += uiRecIPredStride;
    1128     }
    1129   }
    1130   else
    1131   {
    1132     //===== reconstruction =====
    1133     Pel* pPred      = piPred;
    1134     Pel* pReco      = piReco;
    1135     Pel* pRecIPred  = piRecIPred;
    1136     for ( Int y = 0; y < uiHeight; y++ )
    1137     {
    1138       for ( Int x = 0; x < uiWidth; x++ )
    1139       {
    1140         pReco    [ x ] = pPred[ x ];
    1141         pRecIPred[ x ] = pReco[ x ];
    1142       }
    1143       pPred     += uiStride;
    1144       pReco     += uiStride;
    1145       pRecIPred += uiRecIPredStride;
    1146     }   
    1147   }
    1148 }
    1149 
    11501197
    11511198Void
    11521199TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
    11531200{
    1154   UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
    1155   UInt  uiNumPart     = pcCU->getNumPartitions();
    1156   UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
    1157  
    11581201  if (pcCU->getIPCMFlag(0))
    11591202  {
     
    11611204    return;
    11621205  }
    1163 
    1164   for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
    1165   {
    1166     xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
    1167   } 
    1168 
    1169   for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
    1170   {
    1171     xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
    1172   }
    1173 
    1174 }
    1175 
    1176 #if H_3D_DIM_SDC
     1206  const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1;
     1207  for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++)
     1208  {
     1209    const ChannelType chanType=ChannelType(chType);
     1210    const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true;
     1211    const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 );
     1212
     1213    TComTURecurse tuRecurseCU(pcCU, 0);
     1214    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT);
     1215
     1216    do
     1217    {
     1218      xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU );
     1219    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
     1220  }
     1221}
     1222
     1223#if NH_3D_SDC_INTRA
    11771224Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    11781225{
    1179   UInt uiWidth        = pcCU->getWidth  ( 0 );
    1180   UInt uiHeight       = pcCU->getHeight ( 0 );
    1181   TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
    1182   UInt numParts = 1;
    1183   UInt sdcDepth    = 0;
    11841226  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
    11851227  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
    11861228  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
    11871229
    1188   UInt    uiStride = 0;
    1189   Pel*    piReco;
    1190   Pel*    piPred;
    1191   Pel*    piResi;
    1192 
    1193   UInt    uiZOrder;       
    1194   Pel*    piRecIPred;     
    1195   UInt    uiRecIPredStride;
    1196 
    1197   UInt    uiLumaPredMode = 0; 
    1198 
    1199   if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1)
    1200   {
    1201     numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
    1202     sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
    1203     uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
    1204   }
    1205 
    1206   for ( Int i = 0; i < numParts; i++ )
    1207   {
    1208     uiStride    = pcRecoYuv->getStride  ();
    1209     piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
    1210     piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1211     piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
    1212 
    1213     uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    1214     piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    1215     uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    1216 
    1217     uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
    1218 
    1219     AOF( uiWidth == uiHeight );
    1220 
    1221     //===== init availability pattern =====
    1222     Bool  bAboveAvail = false;
    1223     Bool  bLeftAvail  = false;
    1224 
    1225     pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
    1226     pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
    1227 
    1228     TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
    1229     //===== get prediction signal =====
    1230     if( isDimMode( uiLumaPredMode ) )
    1231     {
    1232       m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation  );
    1233       Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
    1234       Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
    1235       for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
    1236       {
    1237         dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
    1238       }
    1239     }
    1240     else
    1241     {
    1242       m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    1243     }
    1244 
    1245     if ( numParts > 1 )
    1246     {
    1247       for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    1248       {
    1249         for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    1250         {
    1251           piReco        [ uiX ] = ClipY( piPred[ uiX ] );
    1252           piRecIPred    [ uiX ] = piReco[ uiX ];
    1253         }
    1254         piPred     += uiStride;
    1255         piReco     += uiStride;
    1256         piRecIPred += uiRecIPredStride;
    1257       }
    1258     }
    1259     uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 );
    1260     dmm4Segmentation->destroy(); delete dmm4Segmentation;
    1261   }
    1262   uiAbsPartIdx = 0;
    1263  
    1264   if ( numParts > 1 )
    1265   {
    1266     uiWidth = pcCU->getWidth( 0 );
    1267     uiHeight = pcCU->getHeight( 0 );
    1268   }
    1269   piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
    1270   piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
    1271   piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
    1272   uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    1273   piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
    1274   uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
    1275   // number of segments depends on prediction mode
    1276   UInt uiNumSegments = 1;
     1230  UInt uiWidth        = pcCU->getWidth ( 0 );
     1231  UInt uiHeight       = pcCU->getHeight( 0 );
     1232  UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );
     1233  const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
     1234  const TComSPS     &sps    = *(pcCU->getSlice()->getSPS());
     1235  const ChromaFormat chFmt  = pcCU->getPic()->getChromaFormat();
     1236
     1237  UInt sdcDepth = 0;
     1238  UInt uiStride;
     1239  Pel* piReco;
     1240  Pel* piPred;
     1241  Pel* piResi;
     1242
     1243  Pel* piRecIPred;
     1244  UInt uiRecIPredStride;
     1245 
     1246  Pel apDCPredValues[2];
     1247  UInt uiNumSegments;
     1248
    12771249  Bool* pbMask = NULL;
    12781250  UInt uiMaskStride = 0;
    1279  
    1280   if( getDimType( uiLumaPredMode ) == DMM1_IDX )
    1281   {
    1282     Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
    1283 
    1284     WedgeList* pacWedgeList  = pcCU->isDMM1UpscaleMode(uiWidth) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] :  &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
    1285     TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
    1286 
    1287     uiNumSegments = 2;
    1288 
    1289     pbMask       = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern();
    1290     uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride();
    1291   }
    1292   if( getDimType( uiLumaPredMode ) == DMM4_IDX )
    1293   {
    1294     uiNumSegments = 2;
    1295     pbMask  = dmm4SegmentationOrg->getPattern();
    1296     uiMaskStride = dmm4SegmentationOrg->getStride();
    1297   }
    1298   // get DC prediction for each segment
    1299   Pel apDCPredValues[2];
    1300   if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
    1301   {
    1302     apDCPredValues[0] = pcCU->getDmmPredictor( 0 );
    1303     apDCPredValues[1] = pcCU->getDmmPredictor( 1 );
    1304   }
    1305   else
    1306   {
    1307     m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
    1308   }
     1251
     1252#if NH_3D_DMM
     1253  if( isDmmMode( uiLumaPredMode ) )
     1254  {
     1255    assert( uiWidth == uiHeight  );
     1256    assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE );
     1257    assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) );
     1258
     1259    uiNumSegments     = 2;
     1260
     1261    uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
     1262    piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
     1263    piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
     1264    piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
     1265
     1266    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
     1267    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
     1268
     1269    //===== init availability pattern =====
     1270    TComTURecurse tuRecurseCU(pcCU, 0);
     1271    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
     1272
     1273    m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
     1274
     1275    // get partition
     1276    pbMask       = new Bool[ uiWidth*uiHeight ];
     1277    uiMaskStride = uiWidth;
     1278    switch( getDmmType( uiLumaPredMode ) )
     1279    {
     1280    case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break;
     1281    case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask );                                     } break;
     1282    default: assert(0);
     1283    }
     1284
     1285    // get predicted partition values
     1286    Pel predDC1 = 0, predDC2 = 0;
     1287    m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 );
     1288
     1289    // set prediction signal
     1290    Pel* pDst = piPred;
     1291    m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 );
     1292    apDCPredValues[0] = predDC1;
     1293    apDCPredValues[1] = predDC2;
     1294  }
     1295  else // regular HEVC intra modes
     1296  {
     1297#endif
     1298    uiNumSegments = 1;
     1299
     1300    if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
     1301    {
     1302      sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
     1303    }
     1304   
     1305    //===== loop over partitions =====
     1306    TComTURecurse tuRecurseCU(pcCU, 0);
     1307    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT);
     1308
     1309    do
     1310    {
     1311      const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y);
     1312      const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU();
     1313     
     1314      Pel* piPredTU       = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdxTU );
     1315      UInt uiStrideTU     = pcPredYuv->getStride( COMPONENT_Y );
     1316     
     1317      Pel* piRecIPredTU   = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU );
     1318      UInt uiRecIPredStrideTU  = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
     1319     
     1320      const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     1321     
     1322      //===== init pattern for luma prediction =====
     1323     
     1324      m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter  DEBUG_STRING_PASS_INTO(sTemp) );
     1325     
     1326      m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bUseFilter );
     1327     
     1328      // copy for prediction of next part
     1329      for( UInt uiY = 0; uiY < puRect.height; uiY++ )
     1330      {
     1331        for( UInt uiX = 0; uiX < puRect.width; uiX++ )
     1332        {
     1333          piPredTU      [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY );
     1334          piRecIPredTU  [ uiX ] = piPredTU[ uiX ];
     1335        }
     1336        piPredTU     += uiStrideTU;
     1337        piRecIPredTU += uiRecIPredStrideTU;
     1338      }
     1339     
     1340     
     1341    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
     1342
     1343    // reset to full block
     1344    uiWidth  = pcCU->getWidth( 0 );
     1345    uiHeight = pcCU->getHeight( 0 );
     1346
     1347    uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
     1348    piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
     1349    piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
     1350    piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
     1351   
     1352    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
     1353    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
     1354
     1355    m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0;
     1356#if NH_3D_DMM
     1357  }
     1358#endif
    13091359 
    13101360  // reconstruct residual based on mask + DC residuals
     
    13121362  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
    13131363  {
    1314 #if H_3D_DIM_DLT
     1364#if NH_3D_DLT
    13151365    Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
    13161366    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
     
    13391389      Pel pResiDC = apDCResiValues[ucSegment];
    13401390     
    1341       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
     1391      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY );
    13421392      pRecIPred[ uiX ] = pReco[ uiX ];
    13431393    }
     
    13491399  }
    13501400 
    1351   // clear UV
    1352   UInt  uiStrideC     = pcPredYuv->getCStride();
    1353   Pel   *pRecCb       = pcPredYuv->getCbAddr();
    1354   Pel   *pRecCr       = pcPredYuv->getCrAddr();
     1401  // clear chroma
     1402  UInt  uiStrideC     = pcPredYuv->getStride( COMPONENT_Cb );
     1403  Pel   *pRecCb       = pcPredYuv->getAddr  ( COMPONENT_Cb, uiAbsPartIdx );
     1404  Pel   *pRecCr       = pcPredYuv->getAddr  ( COMPONENT_Cr, uiAbsPartIdx );
    13551405 
    13561406  for (Int y=0; y<uiHeight/2; y++)
     
    13651415    pRecCr += uiStrideC;
    13661416  }
    1367   dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
    1368 }
    1369 #endif
    1370 
    1371 /** Function for deriving recontructed PU/CU Luma sample with QTree structure
    1372  * \param pcCU pointer of current CU
    1373  * \param uiTrDepth current tranform split depth
    1374  * \param uiAbsPartIdx  part index
     1417#if NH_3D_DMM
     1418  if( pbMask ) { delete[] pbMask; }
     1419#endif
     1420}
     1421#endif
     1422
     1423
     1424/** Function for deriving reconstructed PU/CU chroma samples with QTree structure
    13751425 * \param pcRecoYuv pointer to reconstructed sample arrays
    13761426 * \param pcPredYuv pointer to prediction sample arrays
    13771427 * \param pcResiYuv pointer to residue sample arrays
    1378  *
    1379  \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
     1428 * \param chType    texture channel type (luma/chroma)
     1429 * \param rTu       reference to transform data
     1430 *
     1431 \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure
    13801432 */
     1433
    13811434Void
    1382 TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
    1383                      UInt        uiTrDepth,
    1384                      UInt        uiAbsPartIdx,
    1385                      TComYuv*    pcRecoYuv,
    1386                      TComYuv*    pcPredYuv,
    1387                      TComYuv*    pcResiYuv )
    1388 {
    1389   UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
     1435TDecCu::xIntraRecQT(TComYuv*    pcRecoYuv,
     1436                    TComYuv*    pcPredYuv,
     1437                    TComYuv*    pcResiYuv,
     1438                    const ChannelType chType,
     1439                    TComTU     &rTu)
     1440{
     1441  UInt uiTrDepth    = rTu.GetTransformDepthRel();
     1442  TComDataCU *pcCU  = rTu.getCU();
     1443  UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
    13901444  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
    13911445  if( uiTrMode == uiTrDepth )
    13921446  {
    1393     xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
     1447    if (isLuma(chType))
     1448    {
     1449      xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y,  rTu );
     1450    }
     1451    else
     1452    {
     1453      const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat());
     1454      for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++)
     1455      {
     1456        xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu );
     1457      }
     1458    }
    13941459  }
    13951460  else
    13961461  {
    1397     UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
    1398     for( UInt uiPart = 0; uiPart < 4; uiPart++ )
    1399     {
    1400       xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
    1401     }
    1402   }
    1403 }
    1404 
    1405 /** Function for deriving recontructed PU/CU chroma samples with QTree structure
    1406  * \param pcCU pointer of current CU
    1407  * \param uiTrDepth current tranform split depth
    1408  * \param uiAbsPartIdx  part index
    1409  * \param pcRecoYuv pointer to reconstructed sample arrays
    1410  * \param pcPredYuv pointer to prediction sample arrays
    1411  * \param pcResiYuv pointer to residue sample arrays
    1412  *
    1413  \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
    1414  */
    1415 Void
    1416 TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
    1417                      UInt        uiTrDepth,
    1418                      UInt        uiAbsPartIdx,
    1419                      TComYuv*    pcRecoYuv,
    1420                      TComYuv*    pcPredYuv,
    1421                      TComYuv*    pcResiYuv )
    1422 {
    1423   UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
    1424   UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
    1425   if( uiTrMode == uiTrDepth )
    1426   {
    1427     xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
    1428     xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
    1429   }
    1430   else
    1431   {
    1432     UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
    1433     for( UInt uiPart = 0; uiPart < 4; uiPart++ )
    1434     {
    1435       xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
    1436     }
     1462    TComTURecurse tuRecurseChild(rTu, false);
     1463    do
     1464    {
     1465      xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild );
     1466    } while (tuRecurseChild.nextSection(rTu));
    14371467  }
    14381468}
     
    14401470Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
    14411471{
    1442   UInt uiCUAddr = pcCU->getAddr();
    1443  
    1444   m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
    1445  
     1472  UInt uiCtuRsAddr = pcCU->getCtuRsAddr();
     1473
     1474  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx );
     1475
    14461476  return;
    14471477}
    14481478
    1449 Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1450 {
    1451   UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
    1452   UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
    1453   TCoeff* piCoeff;
    1454  
    1455   Pel*    pResi;
    1456   UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
    1457  
    1458   // Y
    1459   piCoeff = pcCU->getCoeffY();
    1460   pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
    1461 
    1462   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    1463 
    1464   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
    1465  
    1466   // Cb and Cr
    1467   Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
    1468   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
    1469 
    1470   uiWidth  >>= 1;
    1471   uiHeight >>= 1;
    1472   piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
    1473   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
    1474 
    1475   curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
    1476   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
    1477 
    1478   piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
    1479   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
     1479Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth )
     1480{
     1481
     1482  TComTURecurse tuRecur(pcCU, 0, uiDepth);
     1483
     1484  for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
     1485  {
     1486    const ComponentID compID=ComponentID(ch);
     1487    DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID])
     1488
     1489    m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur );
     1490  }
     1491
     1492  DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT])
    14801493}
    14811494
     
    14881501 * \param uiWidth CU width
    14891502 * \param uiHeight CU height
    1490  * \param ttText texture component type
     1503 * \param compID colour component ID
    14911504 * \returns Void
    14921505 */
    1493 Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
    1494 {
    1495   UInt uiX, uiY;
    1496   Pel* piPicReco;
    1497   UInt uiPicStride;
    1498   UInt uiPcmLeftShiftBit;
    1499 
    1500   if( ttText == TEXT_LUMA )
    1501   {
    1502     uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
    1503     piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
    1504     uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
    1505   }
    1506   else
    1507   {
    1508     uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
    1509 
    1510     if( ttText == TEXT_CHROMA_U )
    1511     {
    1512       piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
    1513     }
    1514     else
    1515     {
    1516       piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
    1517     }
    1518     uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
    1519   }
    1520 
    1521   for( uiY = 0; uiY < uiHeight; uiY++ )
    1522   {
    1523     for( uiX = 0; uiX < uiWidth; uiX++ )
     1506Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID)
     1507{
     1508        Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx);
     1509  const UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride(compID);
     1510  const TComSPS &sps           = *(pcCU->getSlice()->getSPS());
     1511  const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID));
     1512
     1513  for(UInt uiY = 0; uiY < uiHeight; uiY++ )
     1514  {
     1515    for(UInt uiX = 0; uiX < uiWidth; uiX++ )
    15241516    {
    15251517      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
     
    15391531Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
    15401532{
    1541   // Luma
    1542   UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
    1543   UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
    1544 
    1545   Pel* piPcmY = pcCU->getPCMSampleY();
    1546   Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
    1547 
    1548   UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
    1549 
    1550   xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
    1551 
    1552   // Cb and Cr
    1553   UInt uiCWidth  = (uiWidth>>1);
    1554   UInt uiCHeight = (uiHeight>>1);
    1555 
    1556   Pel* piPcmCb = pcCU->getPCMSampleCb();
    1557   Pel* piPcmCr = pcCU->getPCMSampleCr();
    1558   Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
    1559   Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
    1560 
    1561   UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
    1562 
    1563   xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
    1564   xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
    1565 }
    1566 
    1567 /** Function for filling the PCM buffer of a CU using its reconstructed sample array
    1568  * \param pcCU pointer to current CU
    1569  * \param uiDepth CU Depth
    1570  * \returns Void
     1533  const UInt maxCuWidth     = pcCU->getSlice()->getSPS()->getMaxCUWidth();
     1534  const UInt maxCuHeight    = pcCU->getSlice()->getSPS()->getMaxCUHeight();
     1535  for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++)
     1536  {
     1537    const ComponentID compID = ComponentID(ch);
     1538    const UInt width  = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID)));
     1539    const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID)));
     1540    const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID);
     1541    Pel * pPCMChannel = pcCU->getPCMSample(compID);
     1542    Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID);
     1543    xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID );
     1544  }
     1545}
     1546
     1547/** Function for filling the PCM buffer of a CU using its reconstructed sample array
     1548 * \param pCU   pointer to current CU
     1549 * \param depth CU Depth
    15711550 */
    15721551Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
    15731552{
    1574   // Luma
    1575   UInt width  = (g_uiMaxCUWidth >> depth);
    1576   UInt height = (g_uiMaxCUHeight >> depth);
    1577 
    1578   Pel* pPcmY = pCU->getPCMSampleY();
    1579   Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
    1580 
    1581   UInt stride = m_ppcYuvReco[depth]->getStride();
    1582 
    1583   for(Int y = 0; y < height; y++ )
    1584   {
    1585     for(Int x = 0; x < width; x++ )
    1586     {
    1587       pPcmY[x] = pRecoY[x];
    1588     }
    1589     pPcmY += width;
    1590     pRecoY += stride;
    1591   }
    1592 
    1593   // Cb and Cr
    1594   UInt widthC  = (width>>1);
    1595   UInt heightC = (height>>1);
    1596 
    1597   Pel* pPcmCb = pCU->getPCMSampleCb();
    1598   Pel* pPcmCr = pCU->getPCMSampleCr();
    1599   Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
    1600   Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
    1601 
    1602   UInt strideC = m_ppcYuvReco[depth]->getCStride();
    1603 
    1604   for(Int y = 0; y < heightC; y++ )
    1605   {
    1606     for(Int x = 0; x < widthC; x++ )
    1607     {
    1608       pPcmCb[x] = pRecoCb[x];
    1609       pPcmCr[x] = pRecoCr[x];
    1610     }
    1611     pPcmCr += widthC;
    1612     pPcmCb += widthC;
    1613     pRecoCb += strideC;
    1614     pRecoCr += strideC;
    1615   }
    1616 
     1553  const ChromaFormat format = pCU->getPic()->getChromaFormat();
     1554  const UInt numValidComp   = getNumberValidComponents(format);
     1555  const UInt maxCuWidth     = pCU->getSlice()->getSPS()->getMaxCUWidth();
     1556  const UInt maxCuHeight    = pCU->getSlice()->getSPS()->getMaxCUHeight();
     1557
     1558  for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++)
     1559  {
     1560    const ComponentID component = ComponentID(componentIndex);
     1561
     1562    const UInt width  = maxCuWidth  >> (depth + getComponentScaleX(component, format));
     1563    const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format));
     1564
     1565    Pel *source      = m_ppcYuvReco[depth]->getAddr(component, 0, width);
     1566    Pel *destination = pCU->getPCMSample(component);
     1567
     1568    const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component);
     1569
     1570    for (Int line = 0; line < height; line++)
     1571    {
     1572      for (Int column = 0; column < width; column++)
     1573      {
     1574        destination[column] = source[column];
     1575      }
     1576
     1577      source      += sourceStride;
     1578      destination += width;
     1579    }
     1580  }
    16171581}
    16181582
Note: See TracChangeset for help on using the changeset viewer.