Ignore:
Timestamp:
4 May 2015, 18:38:08 (10 years ago)
Author:
tech
Message:

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev0/source/Lib/TLibDecoder/TDecCu.cpp

    r1196 r1200  
    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
     
    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];
     
    8184  m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
    8285#endif
    83  
     86
    8487  UInt uiNumPartitions;
    8588  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
     
    8891    UInt uiWidth  = uiMaxWidth  >> ui;
    8992    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) );
     93
     94    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
     95    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
     96    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
    9497#if H_3D_DBBP
    9598    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
    9699#endif
    97   }
    98  
     100}
     101
    99102  m_bDecodeDQP = false;
     103  m_IsChromaQpAdjCoded = false;
    100104
    101105  // initialize partition order.
     
    103107  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
    104108  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
    105  
     109
    106110  // initialize conversion matrix from partition index to pel
    107111  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
     
    119123#endif
    120124  }
    121  
     125
    122126  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
    123127  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
     
    132136// ====================================================================================================================
    133137
    134 /** \param    pcCU        pointer of CU data
    135  \param    ruiIsLast   last data?
     138/**
     139 Parse a CTU.
     140 \param    pCtu                      [in/out] pointer to CTU data structure
     141 \param    isLastCtuOfSliceSegment   [out]    true, if last CTU of the slice segment
    136142 */
    137 Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
    138 {
    139   if ( pcCU->getSlice()->getPPS()->getUseDQP() )
     143Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment )
     144{
     145  if ( pCtu->getSlice()->getPPS()->getUseDQP() )
    140146  {
    141147    setdQPFlag(true);
    142148  }
    143149
     150  if ( pCtu->getSlice()->getUseChromaQpAdj() )
     151  {
     152    setIsChromaQpAdjCoded(true);
     153  }
     154
    144155  // start from the top level CU
    145   xDecodeCU( pcCU, 0, 0, ruiIsLast);
    146 }
    147 
    148 /** \param    pcCU        pointer of CU data
     156  xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment);
     157}
     158
     159/**
     160 Decoding process for a CTU.
     161 \param    pCtu                      [in/out] pointer to CTU data structure
    149162 */
    150 Void TDecCu::decompressCU( TComDataCU* pcCU )
     163Void TDecCu::decompressCtu( TComDataCU* pCtu )
    151164{
    152165#if !H_3D_IV_MERGE
    153   xDecompressCU( pcCU, 0,  0 );
     166  xDecompressCU( pCtu, 0,  0 );
    154167#endif
    155168}
     
    159172// ====================================================================================================================
    160173
    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 );
     174//! decode end-of-slice flag
     175Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx )
     176{
     177  UInt uiIsLastCtuOfSliceSegment;
     178
     179  if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx))
     180  {
     181    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment );
    183182  }
    184183  else
    185184  {
    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);
     185    uiIsLastCtuOfSliceSegment=0;
     186  }
     187
     188  return uiIsLastCtuOfSliceSegment>0;
     189}
     190
     191//! decode CU block recursively
     192Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment)
     193{
     194  TComPic* pcPic        = pcCU->getPic();
     195  const TComSPS &sps    = pcPic->getPicSym()->getSPS();
     196  const TComPPS &pps    = pcPic->getPicSym()->getPPS();
     197  const UInt maxCuWidth = sps.getMaxCUWidth();
     198  const UInt maxCuHeight= sps.getMaxCUHeight();
     199  UInt uiCurNumParts    = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1);
    216200  UInt uiQNumParts      = uiCurNumParts>>2;
    217  
     201
     202
    218203  Bool bBoundary = false;
    219204  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    220   UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
     205  UInt uiRPelX   = uiLPelX + (maxCuWidth>>uiDepth)  - 1;
    221206  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    222   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
     207  UInt uiBPelY   = uiTPelY + (maxCuHeight>>uiDepth) - 1;
    223208#if H_MV_ENC_DEC_TRAC
    224209  DTRACE_CU_S("=========== coding_quadtree ===========\n")
    225210  DTRACE_CU("x0", uiLPelX)
    226211  DTRACE_CU("x1", uiTPelY)
    227   DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth)
     212  DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth)
    228213  DTRACE_CU("cqtDepth"  , uiDepth)
    229214#endif
    230215
    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() ) )
     216  if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) )
    234217  {
    235218    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
     
    239222    bBoundary = true;
    240223  }
    241  
    242   if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
     224  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
    243225  {
    244226    UInt uiIdx = uiAbsPartIdx;
    245     if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     227    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
    246228    {
    247229      setdQPFlag(true);
     
    249231    }
    250232
     233    if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
     234    {
     235      setIsChromaQpAdjCoded(true);
     236    }
     237
    251238    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
    252239    {
    253240      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
    254241      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      
     242
     243      if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
     244      {
     245        xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment );
     246      }
     247      else
     248      {
     249        pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
     250      }
     251
    269252      uiIdx += uiQNumParts;
    270253    }
    271     if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     254    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
    272255    {
    273256      if ( getdQPFlag() )
    274257      {
    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         }
     258        UInt uiQPSrcPartIdx = uiAbsPartIdx;
    284259        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
    285260      }
     
    287262    return;
    288263  }
    289  
     264
    290265#if H_MV_ENC_DEC_TRAC
    291266  DTRACE_CU_S("=========== coding_unit ===========\n")
     
    303278#endif
    304279
    305   if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
     280  if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP())
    306281  {
    307282    setdQPFlag(true);
     
    316291#endif
    317292 
    318  
    319   if(!pcCU->getSlice()->isIntra())
     293if(!pcCU->getSlice()->isIntra())
    320294  {
    321295#if H_3D_ARP && H_3D_IV_MERGE
     
    380354  }
    381355#endif
    382   if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     356
     357  if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
     358  {
     359    setIsChromaQpAdjCoded(true);
     360  }
     361
     362  if (pps.getTransquantBypassEnableFlag())
    383363  {
    384364    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
    385365  }
    386  
     366
    387367  // decode CU mode and the partition size
    388368  if( !pcCU->getSlice()->isIntra())
     
    390370    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
    391371  }
    392  
     372
     373
    393374  if( pcCU->isSkipped(uiAbsPartIdx) )
    394375  {
     
    460441    TComMv cTmpMv( 0, 0 );
    461442    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
    462     {       
     443    {
    463444      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
    464445      {
     
    524505#endif
    525506
    526     xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
     507    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
    527508#if H_3D_IV_MERGE
    528509    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
    529510#endif
     511
    530512    return;
    531513  }
     
    535517  {
    536518#endif
     519
    537520  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
    538521  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
     
    547530      m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
    548531#endif
    549       xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
     532      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
    550533#if H_3D_IV_MERGE
    551534      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
     
    555538  }
    556539
    557   UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
    558   UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
    559  
    560540  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
    561541  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
     
    563543  // Coefficient decoding
    564544  Bool bCodeDQP = getdQPFlag();
    565   m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
     545  Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded();
     546  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded );
     547  setIsChromaQpAdjCoded( isChromaQpAdjCoded );
    566548  setdQPFlag( bCodeDQP );
    567549#if H_3D
    568550  }
    569551#endif
    570   xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
     552  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
    571553#if H_3D_IV_MERGE
    572554  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
     
    574556}
    575557
    576 Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
     558Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment)
    577559{
    578560  if(  pcCU->getSlice()->getPPS()->getUseDQP())
     
    581563  }
    582564
    583   ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
    584 }
    585 
    586 Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
    587 {
    588   TComPic* pcPic = pcCU->getPic();
     565  if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded())
     566  {
     567    pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP
     568  }
     569
     570  isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx );
     571}
     572
     573Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx,  UInt uiDepth )
     574{
     575  TComPic* pcPic = pCtu->getPic();
    589576#if !H_3D_IV_MERGE
     577  TComSlice * pcSlice = pCtu->getSlice();
     578  const TComSPS &sps=*(pcSlice->getSPS());
     579
    590580  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() ) )
     581  UInt uiLPelX   = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     582  UInt uiRPelX   = uiLPelX + (sps.getMaxCUWidth()>>uiDepth)  - 1;
     583  UInt uiTPelY   = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     584  UInt uiBPelY   = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1;
     585
     586  if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) )
    600587  {
    601588    bBoundary = true;
    602589  }
    603590
    604   if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
     591  if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
    605592  {
    606593    UInt uiNextDepth = uiDepth + 1;
    607     UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
     594    UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1);
    608595    UInt uiIdx = uiAbsPartIdx;
    609596    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
    610597    {
    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 );
     598      uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
     599      uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
     600
     601      if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
     602      {
     603        xDecompressCU(pCtu, uiIdx, uiNextDepth );
    618604      }
    619605
     
    622608    return;
    623609  }
    624 #endif 
     610#endif
    625611  // Residual reconstruction
    626612  m_ppcYuvResi[uiDepth]->clear();
    627613
    628   m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
     614  m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx );
    629615
    630616  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
    631617  {
    632   case MODE_INTER:
     618    case MODE_INTER:
    633619#if H_3D_DBBP
    634620    if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
     
    647633      {
    648634#endif
    649         xReconInter( m_ppcCU[uiDepth], uiDepth );
     635      xReconInter( m_ppcCU[uiDepth], uiDepth );
    650636#if H_3D_INTER_SDC
    651637      }
     
    654640    }
    655641#endif
    656     break;
    657   case MODE_INTRA:
     642      break;
     643    case MODE_INTRA:
    658644#if H_3D
    659645    if( m_ppcCU[uiDepth]->getDISFlag(0) )
     
    670656#endif
    671657      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
    672     break;
    673   default:
    674     assert(0);
    675     break;
    676   }
     658      break;
     659    default:
     660      assert(0);
     661      break;
     662  }
     663
     664#if DEBUG_STRING
     665  const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0);
     666  if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode))
     667  {
     668    PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0);
     669    std::ostream &ss(std::cout);
     670
     671    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;
     672  }
     673#endif
     674
    677675  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
    678676  {
     
    685683Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
    686684{
    687  
     685
    688686  // inter prediction
    689687  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
    690  
     688
     689#if DEBUG_STRING
     690  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER);
     691  if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask)
     692  {
     693    printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth]));
     694  }
     695#endif
     696
    691697  // inter recon
    692   xDecodeInterTexture( pcCU, 0, uiDepth );
    693  
     698  xDecodeInterTexture( pcCU, uiDepth );
     699
     700#if DEBUG_STRING
     701  if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask)
     702  {
     703    printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth]));
     704  }
     705#endif
     706
    694707  // 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 ) );
     708  if  ( pcCU->getQtRootCbf( 0) )
     709  {
     710    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
    698711  }
    699712  else
     
    701714    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
    702715  }
     716#if DEBUG_STRING
     717  if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask)
     718  {
     719    printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth]));
     720  }
     721#endif
     722
    703723}
    704724
     
    924944#endif
    925945
     946
    926947Void
    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);
     948TDecCu::xIntraRecBlk(       TComYuv*    pcRecoYuv,
     949                            TComYuv*    pcPredYuv,
     950                            TComYuv*    pcResiYuv,
     951                      const ComponentID compID,
     952                            TComTU     &rTu)
     953{
     954  if (!rTu.ProcessComponentSection(compID))
     955  {
     956    return;
     957  }
     958  const Bool       bIsLuma = isLuma(compID);
     959
     960
     961  TComDataCU *pcCU = rTu.getCU();
     962  const TComSPS &sps=*(pcCU->getSlice()->getSPS());
     963  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
     964
     965  const TComRectangle &tuRect  =rTu.getRect(compID);
     966  const UInt uiWidth           = tuRect.width;
     967  const UInt uiHeight          = tuRect.height;
     968  const UInt uiStride          = pcRecoYuv->getStride (compID);
     969        Pel* piPred            = pcPredYuv->getAddr( compID, uiAbsPartIdx );
     970  const ChromaFormat chFmt     = rTu.GetChromaFormat();
     971
     972  if (uiWidth != uiHeight)
     973  {
     974    //------------------------------------------------
     975
     976    //split at current level if dividing into square sub-TUs
     977
     978    TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
     979
     980    //recurse further
     981    do
     982    {
     983      xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse);
     984    } while (subTURecurse.nextSection(rTu));
     985
     986    //------------------------------------------------
     987
     988    return;
     989  }
     990
     991  const UInt uiChPredMode  = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx );
     992  const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize()));
     993  const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode;
     994  const UInt uiChFinalMode = ((chFmt == CHROMA_422)       && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode;
     995
    950996  //===== init availability pattern =====
    951997  Bool  bAboveAvail = false;
    952998  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  
     999
     1000  const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
     1001
     1002#if DEBUG_STRING
     1003  std::ostream &ss(std::cout);
     1004#endif
     1005
     1006  DEBUG_STRING_NEW(sTemp)
     1007  m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
     1008
     1009
    9601010  //===== get prediction signal =====
    9611011#if H_3D_DIM
     
    9671017  {
    9681018#endif
    969   m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
     1019
     1020  m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
    9701021#if H_3D_DIM
    9711022  }
    9721023#endif
    973  
     1024
     1025#if DEBUG_STRING
     1026  ss << sTemp;
     1027#endif
     1028
     1029  //===== inverse transform =====
     1030  Pel*      piResi            = pcResiYuv->getAddr( compID, uiAbsPartIdx );
     1031  TCoeff*   pcCoeff           = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx );
     1032
     1033  const QpParam cQP(*pcCU, compID);
     1034
     1035
     1036  DEBUG_STRING_NEW(sDebug);
     1037#if DEBUG_STRING
     1038  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
     1039  std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
     1040#endif
    9741041#if H_3D
    9751042  Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
     
    9771044  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
    9781045#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  
     1046  if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0)
     1047#endif
     1048  {
     1049    m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
     1050  }
     1051  else
     1052  {
     1053    for (UInt y = 0; y < uiHeight; y++)
     1054    {
     1055      for (UInt x = 0; x < uiWidth; x++)
     1056      {
     1057        piResi[(y * uiStride) + x] = 0;
     1058      }
     1059    }
     1060  }
     1061
     1062#if DEBUG_STRING
     1063  if (psDebug)
     1064  {
     1065    ss << (*psDebug);
     1066  }
     1067#endif
     1068
    9901069  //===== reconstruction =====
    991   Pel* pPred      = piPred;
    992   Pel* pResi      = piResi;
    993   Pel* pReco      = piReco;
    994   Pel* pRecIPred  = piRecIPred;
     1070  const UInt uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride(compID);
     1071
     1072  const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0);
     1073  const Pel* pResiLuma  = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
     1074  const Int  strideLuma = pcResiYuv->getStride( COMPONENT_Y );
     1075
     1076        Pel* pPred      = piPred;
     1077        Pel* pResi      = piResi;
     1078        Pel* pReco      = pcRecoYuv->getAddr( compID, uiAbsPartIdx );
     1079        Pel* pRecIPred  = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
     1080
     1081
     1082#if DEBUG_STRING
     1083  const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
     1084  const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
     1085  const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
     1086  if (bDebugPred || bDebugResi || bDebugReco)
     1087  {
     1088    ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl;
     1089  }
     1090#endif
     1091
     1092  const Int clipbd = sps.getBitDepth(toChannelType(compID));
     1093#if O0043_BEST_EFFORT_DECODING
     1094  const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd;
     1095#endif
     1096
     1097  if( useCrossComponentPrediction )
     1098  {
     1099    TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true );
     1100  }
     1101
    9951102  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
    9961103  {
     1104#if DEBUG_STRING
     1105    if (bDebugPred || bDebugResi || bDebugReco)
     1106    {
     1107      ss << "###: ";
     1108    }
     1109
     1110    if (bDebugPred)
     1111    {
     1112      ss << " - pred: ";
     1113      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     1114      {
     1115        ss << pPred[ uiX ] << ", ";
     1116      }
     1117    }
     1118    if (bDebugResi)
     1119    {
     1120      ss << " - resi: ";
     1121    }
     1122#endif
     1123
    9971124    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    9981125    {
    999       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
     1126#if DEBUG_STRING
     1127      if (bDebugResi)
     1128      {
     1129        ss << pResi[ uiX ] << ", ";
     1130      }
     1131#endif
     1132#if O0043_BEST_EFFORT_DECODING
     1133      pReco    [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd );
     1134#else
     1135      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd );
     1136#endif
    10001137      pRecIPred[ uiX ] = pReco[ uiX ];
    10011138    }
     1139#if DEBUG_STRING
     1140    if (bDebugReco)
     1141    {
     1142      ss << " - reco: ";
     1143      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     1144      {
     1145        ss << pReco[ uiX ] << ", ";
     1146      }
     1147    }
     1148
     1149    if (bDebugPred || bDebugResi || bDebugReco)
     1150    {
     1151      ss << "\n";
     1152    }
     1153#endif
    10021154    pPred     += uiStride;
    10031155    pResi     += uiStride;
     
    10061158  }
    10071159}
    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 );
    10871160#if H_3D_DIM
    10881161      mapDepthModeToIntraDir( uiChromaPredMode );
    10891162#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 }
    11491163
    11501164
     
    11521166TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
    11531167{
    1154   UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
    1155   UInt  uiNumPart     = pcCU->getNumPartitions();
    1156   UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
    1157  
    11581168  if (pcCU->getIPCMFlag(0))
    11591169  {
     
    11611171    return;
    11621172  }
    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 
     1173  const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1;
     1174  for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++)
     1175  {
     1176    const ChannelType chanType=ChannelType(chType);
     1177    const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true;
     1178    const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 );
     1179
     1180    TComTURecurse tuRecurseCU(pcCU, 0);
     1181    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT);
     1182
     1183    do
     1184    {
     1185      xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU );
     1186    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
     1187  }
    11741188}
    11751189
     
    13691383#endif
    13701384
    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
     1385
     1386/** Function for deriving reconstructed PU/CU chroma samples with QTree structure
    13751387 * \param pcRecoYuv pointer to reconstructed sample arrays
    13761388 * \param pcPredYuv pointer to prediction sample arrays
    13771389 * \param pcResiYuv pointer to residue sample arrays
    1378  *
    1379  \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
     1390 * \param chType    texture channel type (luma/chroma)
     1391 * \param rTu       reference to transform data
     1392 *
     1393 \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure
    13801394 */
     1395
    13811396Void
    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;
     1397TDecCu::xIntraRecQT(TComYuv*    pcRecoYuv,
     1398                    TComYuv*    pcPredYuv,
     1399                    TComYuv*    pcResiYuv,
     1400                    const ChannelType chType,
     1401                    TComTU     &rTu)
     1402{
     1403  UInt uiTrDepth    = rTu.GetTransformDepthRel();
     1404  TComDataCU *pcCU  = rTu.getCU();
     1405  UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
    13901406  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
    13911407  if( uiTrMode == uiTrDepth )
    13921408  {
    1393     xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
     1409    if (isLuma(chType))
     1410    {
     1411      xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y,  rTu );
     1412    }
     1413    else
     1414    {
     1415      const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat());
     1416      for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++)
     1417      {
     1418        xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu );
     1419      }
     1420    }
    13941421  }
    13951422  else
    13961423  {
    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     }
     1424    TComTURecurse tuRecurseChild(rTu, false);
     1425    do
     1426    {
     1427      xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild );
     1428    } while (tuRecurseChild.nextSection(rTu));
    14371429  }
    14381430}
     
    14401432Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
    14411433{
    1442   UInt uiCUAddr = pcCU->getAddr();
    1443  
    1444   m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
    1445  
     1434  UInt uiCtuRsAddr = pcCU->getCtuRsAddr();
     1435
     1436  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx );
     1437
    14461438  return;
    14471439}
    14481440
    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 );
     1441Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth )
     1442{
     1443
     1444  TComTURecurse tuRecur(pcCU, 0, uiDepth);
     1445
     1446  for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
     1447  {
     1448    const ComponentID compID=ComponentID(ch);
     1449    DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID])
     1450
     1451    m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur );
     1452  }
     1453
     1454  DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT])
    14801455}
    14811456
     
    14881463 * \param uiWidth CU width
    14891464 * \param uiHeight CU height
    1490  * \param ttText texture component type
     1465 * \param compID colour component ID
    14911466 * \returns Void
    14921467 */
    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++ )
     1468Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID)
     1469{
     1470        Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx);
     1471  const UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride(compID);
     1472  const TComSPS &sps           = *(pcCU->getSlice()->getSPS());
     1473  const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID));
     1474
     1475  for(UInt uiY = 0; uiY < uiHeight; uiY++ )
     1476  {
     1477    for(UInt uiX = 0; uiX < uiWidth; uiX++ )
    15241478    {
    15251479      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
     
    15391493Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
    15401494{
    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
     1495  const UInt maxCuWidth     = pcCU->getSlice()->getSPS()->getMaxCUWidth();
     1496  const UInt maxCuHeight    = pcCU->getSlice()->getSPS()->getMaxCUHeight();
     1497  for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++)
     1498  {
     1499    const ComponentID compID = ComponentID(ch);
     1500    const UInt width  = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID)));
     1501    const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID)));
     1502    const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID);
     1503    Pel * pPCMChannel = pcCU->getPCMSample(compID);
     1504    Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID);
     1505    xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID );
     1506  }
     1507}
     1508
     1509/** Function for filling the PCM buffer of a CU using its reconstructed sample array
     1510 * \param pCU   pointer to current CU
     1511 * \param depth CU Depth
    15711512 */
    15721513Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
    15731514{
    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 
     1515  const ChromaFormat format = pCU->getPic()->getChromaFormat();
     1516  const UInt numValidComp   = getNumberValidComponents(format);
     1517  const UInt maxCuWidth     = pCU->getSlice()->getSPS()->getMaxCUWidth();
     1518  const UInt maxCuHeight    = pCU->getSlice()->getSPS()->getMaxCUHeight();
     1519
     1520  for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++)
     1521  {
     1522    const ComponentID component = ComponentID(componentIndex);
     1523
     1524    const UInt width  = maxCuWidth  >> (depth + getComponentScaleX(component, format));
     1525    const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format));
     1526
     1527    Pel *source      = m_ppcYuvReco[depth]->getAddr(component, 0, width);
     1528    Pel *destination = pCU->getPCMSample(component);
     1529
     1530    const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component);
     1531
     1532    for (Int line = 0; line < height; line++)
     1533    {
     1534      for (Int column = 0; column < width; column++)
     1535      {
     1536        destination[column] = source[column];
     1537      }
     1538
     1539      source      += sourceStride;
     1540      destination += width;
     1541    }
     1542  }
    16171543}
    16181544
Note: See TracChangeset for help on using the changeset viewer.