source: 3DVCSoftware/branches/HTM-14.1-update-dev3-NTT/source/Lib/TLibDecoder/TDecCu.cpp @ 1255

Last change on this file since 1255 was 1255, checked in by ntt, 9 years ago

Reactivation of VSP

  • Property svn:eol-style set to native
File size: 52.1 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecCu.cpp
35    \brief    CU decoder class
36*/
37
38#include "TDecCu.h"
39#include "TLibCommon/TComTU.h"
40#include "TLibCommon/TComPrediction.h"
41
42//! \ingroup TLibDecoder
43//! \{
44
45// ====================================================================================================================
46// Constructor / destructor / create / destroy
47// ====================================================================================================================
48
49TDecCu::TDecCu()
50{
51  m_ppcYuvResi = NULL;
52  m_ppcYuvReco = NULL;
53  m_ppcCU      = NULL;
54#if H_3D_DBBP
55  m_ppcYuvRecoDBBP = NULL;
56#endif
57}
58
59TDecCu::~TDecCu()
60{
61}
62
63Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
64{
65  m_pcEntropyDecoder  = pcEntropyDecoder;
66  m_pcTrQuant         = pcTrQuant;
67  m_pcPrediction      = pcPrediction;
68}
69
70/**
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
75 */
76Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC )
77{
78  m_uiMaxDepth = uiMaxDepth+1;
79
80  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
81  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
82  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
83#if H_3D_DBBP
84  m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
85#endif
86
87  UInt uiNumPartitions;
88  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
89  {
90    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
91    UInt uiWidth  = uiMaxWidth  >> ui;
92    UInt uiHeight = uiMaxHeight >> ui;
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) );
97#if H_3D_DBBP
98    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
99#endif
100}
101
102  m_bDecodeDQP = false;
103  m_IsChromaQpAdjCoded = false;
104
105  // initialize partition order.
106  UInt* piTmp = &g_auiZscanToRaster[0];
107  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
108  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
109
110  // initialize conversion matrix from partition index to pel
111  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
112}
113
114Void TDecCu::destroy()
115{
116  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
117  {
118    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
119    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
120    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
121#if H_3D_DBBP
122    m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
123#endif
124  }
125
126  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
127  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
128  delete [] m_ppcCU     ; m_ppcCU      = NULL;
129#if H_3D_DBBP
130  delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
131#endif
132}
133
134// ====================================================================================================================
135// Public member functions
136// ====================================================================================================================
137
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
142 */
143Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment )
144{
145  if ( pCtu->getSlice()->getPPS()->getUseDQP() )
146  {
147    setdQPFlag(true);
148  }
149
150  if ( pCtu->getSlice()->getUseChromaQpAdj() )
151  {
152    setIsChromaQpAdjCoded(true);
153  }
154 
155  // start from the top level CU
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
162 */
163Void TDecCu::decompressCtu( TComDataCU* pCtu )
164{
165#if !H_3D_IV_MERGE
166  xDecompressCU( pCtu, 0,  0 );
167#endif
168}
169
170// ====================================================================================================================
171// Protected member functions
172// ====================================================================================================================
173
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 );
182  }
183  else
184  {
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);
200  UInt uiQNumParts      = uiCurNumParts>>2;
201
202
203  Bool bBoundary = false;
204  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
205  UInt uiRPelX   = uiLPelX + (maxCuWidth>>uiDepth)  - 1;
206  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
207  UInt uiBPelY   = uiTPelY + (maxCuHeight>>uiDepth) - 1;
208#if H_MV_ENC_DEC_TRAC
209  DTRACE_CU_S("=========== coding_quadtree ===========\n")
210  DTRACE_CU("x0", uiLPelX)
211  DTRACE_CU("x1", uiTPelY)
212  DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth)
213  DTRACE_CU("cqtDepth"  , uiDepth)
214#endif
215
216  if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) )
217  {
218    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
219  }
220  else
221  {
222    bBoundary = true;
223  }
224  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
225  {
226    UInt uiIdx = uiAbsPartIdx;
227    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
228    {
229      setdQPFlag(true);
230      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
231    }
232
233    if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
234    {
235      setIsChromaQpAdjCoded(true);
236    }
237
238    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
239    {
240      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
241      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
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
252      uiIdx += uiQNumParts;
253    }
254    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
255    {
256      if ( getdQPFlag() )
257      {
258        UInt uiQPSrcPartIdx = uiAbsPartIdx;
259        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
260      }
261    }
262    return;
263  }
264
265#if H_MV_ENC_DEC_TRAC
266  DTRACE_CU_S("=========== coding_unit ===========\n")
267#if H_MV_ENC_DEC_TRAC
268#if ENC_DEC_TRACE
269    stopAtPos  ( pcCU->getSlice()->getPOC(), 
270    pcCU->getSlice()->getLayerId(), 
271    uiLPelX,
272    uiTPelY,
273    uiRPelX-uiLPelX+1, 
274    uiBPelY-uiTPelY+1);
275#endif
276#endif
277
278#endif
279
280  if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP())
281  {
282    setdQPFlag(true);
283    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
284  }
285#if NH_3D_NBDV
286  DisInfo DvInfo; 
287  DvInfo.m_acNBDV.setZero();
288  DvInfo.m_aVIdxCan = 0;
289#if NH_3D_NBDV_REF 
290  DvInfo.m_acDoNBDV.setZero();
291#endif
292 
293if(!pcCU->getSlice()->isIntra())
294  {
295#if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
296    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
297#else
298#if NH_3D_IV_MERGE && NH_3D_VSP
299    if( pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
300#else
301#if NH_3D_ARP && NH_3D_VSP
302    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
303#else
304#if NH_3D_VSP
305    if( pcCU->getSlice()->getViewSynthesisPredFlag() )
306#else
307#if H_3D_ARP
308    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
309#else
310#if H_3D_IV_MERGE
311    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
312#else
313    if (0)
314#endif
315#endif
316#endif
317#endif
318#endif
319#endif
320    {
321      m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true);
322      m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
323      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
324      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
325      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
326      m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth));
327      m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth));
328      m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);     
329#if H_3D_IV_MERGE
330      if( pcCU->getSlice()->getIsDepth())
331      {
332        m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo);
333      }
334      else
335      {
336#endif
337#if NH_3D_NBDV_REF
338      if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
339      {
340        m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
341      }
342      else
343#endif
344      {
345        m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
346      }
347#if H_3D_IV_MERGE
348      }
349#endif
350#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
351      if ( g_decTraceDispDer )
352      {
353        DTRACE_CU( "RefViewIdx",  DvInfo.m_aVIdxCan );       
354        DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() );
355        DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() );
356        DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() );
357        DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() );
358      }
359#endif
360      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
361      m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth);
362      m_ppcCU[uiDepth]->setWidth(0, cWidTemp);
363      m_ppcCU[uiDepth]->setHeight(0, cHeightTemp);
364     }
365  }
366#endif
367
368  if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
369  {
370    setIsChromaQpAdjCoded(true);
371  }
372
373  if (pps.getTransquantBypassEnableFlag())
374  {
375    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
376  }
377
378  // decode CU mode and the partition size
379  if( !pcCU->getSlice()->isIntra())
380  {
381    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
382  }
383
384
385  if( pcCU->isSkipped(uiAbsPartIdx) )
386  {
387#if H_MV_ENC_DEC_TRAC
388    DTRACE_PU_S("=========== prediction_unit ===========\n")
389    DTRACE_PU("x0", uiLPelX)
390    DTRACE_PU("x1", uiTPelY)
391#endif
392    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
393    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
394#if H_3D_IV_MERGE
395    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
396    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
397    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
398#else
399#if NH_3D_MLC
400    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
401    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
402#else
403    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
404    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
405#endif
406#endif
407    Int numValidMergeCand = 0;
408    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
409    {
410      uhInterDirNeighbours[ui] = 0;
411    }
412    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
413    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
414#if H_3D_ARP
415    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
416#endif
417#if H_3D_IC
418    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
419#endif
420
421
422#if NH_3D_VSP
423    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
424    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
425#endif
426#if H_3D_SPIVMP
427    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
428    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
429    TComMvField*  pcMvFieldSP;
430    UChar* puhInterDirSP;
431    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
432    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
433#endif
434
435#if NH_3D_MLC
436    m_ppcCU[uiDepth]->initAvailableFlags();
437#endif
438    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
439#if NH_3D_MLC
440    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
441#if H_3D_SPIVMP
442      , pcMvFieldSP, puhInterDirSP
443#endif
444      , numValidMergeCand, uiMergeIndex );
445
446    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
447#if NH_3D_VSP
448      , vspFlag
449#endif
450#if H_3D_SPIVMP
451      , bSPIVMPFlag
452#endif
453      , numValidMergeCand );
454#endif
455#if NH_3D_VSP
456    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
457#endif
458
459    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
460
461    TComMv cTmpMv( 0, 0 );
462    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
463    {
464      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
465      {
466        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
467        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
468        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
469        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
470#if NH_3D_VSP
471        if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
472        {
473          if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
474          {
475            UInt dummy;
476            Int vspSize;
477            Int width, height;
478            m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height );
479            m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
480            pcCU->setVSPFlag( uiAbsPartIdx, vspSize );
481          }
482        }
483#endif
484#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
485        if ( g_decTraceMvFromMerge )
486        {       
487          if ( uiRefListIdx == 0 )
488          {
489            DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
490            DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
491            DTRACE_PU( "refIdxL0   ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
492          }
493          else
494          {
495            DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
496            DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
497            DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
498          }
499        }
500#endif
501      }
502    }
503#if H_3D_SPIVMP
504    pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
505    if (bSPIVMPFlag[uiMergeIndex])
506    {
507      UInt uiSPAddr;
508      Int iWidth = pcCU->getWidth(uiAbsPartIdx);
509      Int iHeight = pcCU->getHeight(uiAbsPartIdx);
510
511      Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
512
513      pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
514
515      for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
516      {
517        pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
518        pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
519        pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
520        pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
521      }
522    }
523    delete[] pcMvFieldSP;
524    delete[] puhInterDirSP;
525#endif
526
527    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
528#if H_3D_IV_MERGE
529    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
530#endif
531
532    return;
533  }
534#if H_3D
535  m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth );
536  if(!pcCU->getDISFlag(uiAbsPartIdx))
537  {
538#endif
539
540  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
541  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
542
543  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
544  {
545    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
546
547    if(pcCU->getIPCMFlag(uiAbsPartIdx))
548    {
549#if H_3D_DIM_SDC
550      m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
551#endif
552      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
553#if H_3D_IV_MERGE
554      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
555#endif
556      return;
557    }
558  }
559
560  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
561  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
562
563  // Coefficient decoding
564  Bool bCodeDQP = getdQPFlag();
565  Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded();
566  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded );
567  setIsChromaQpAdjCoded( isChromaQpAdjCoded );
568  setdQPFlag( bCodeDQP );
569#if H_3D
570  }
571#endif
572  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
573#if H_3D_IV_MERGE
574  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
575#endif
576}
577
578Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment)
579{
580  if(  pcCU->getSlice()->getPPS()->getUseDQP())
581  {
582    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
583  }
584
585  if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded())
586  {
587    pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP
588  }
589
590  isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx );
591}
592
593Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx,  UInt uiDepth )
594{
595  TComPic* pcPic = pCtu->getPic();
596#if !H_3D_IV_MERGE
597  TComSlice * pcSlice = pCtu->getSlice();
598  const TComSPS &sps=*(pcSlice->getSPS());
599
600  Bool bBoundary = false;
601  UInt uiLPelX   = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
602  UInt uiRPelX   = uiLPelX + (sps.getMaxCUWidth()>>uiDepth)  - 1;
603  UInt uiTPelY   = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
604  UInt uiBPelY   = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1;
605
606  if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) )
607  {
608    bBoundary = true;
609  }
610
611  if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
612  {
613    UInt uiNextDepth = uiDepth + 1;
614    UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1);
615    UInt uiIdx = uiAbsPartIdx;
616    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
617    {
618      uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
619      uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
620
621      if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
622      {
623        xDecompressCU(pCtu, uiIdx, uiNextDepth );
624      }
625
626      uiIdx += uiQNumParts;
627    }
628    return;
629  }
630#endif
631  // Residual reconstruction
632  m_ppcYuvResi[uiDepth]->clear();
633
634  m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx );
635
636  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
637  {
638    case MODE_INTER:
639#if H_3D_DBBP
640    if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
641    {
642      xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
643    }
644    else
645    {
646#endif
647#if H_3D_INTER_SDC
648      if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
649      {
650        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
651      }
652      else
653      {
654#endif
655      xReconInter( m_ppcCU[uiDepth], uiDepth );
656#if H_3D_INTER_SDC
657      }
658#endif
659#if H_3D_DBBP
660    }
661#endif
662      break;
663    case MODE_INTRA:
664#if H_3D
665    if( m_ppcCU[uiDepth]->getDISFlag(0) )
666    {
667      xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
668    }
669#if H_3D_DIM_SDC
670    else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
671    {
672      xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
673    }
674#endif
675    else
676#endif
677      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
678      break;
679    default:
680      assert(0);
681      break;
682  }
683
684#if DEBUG_STRING
685  const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0);
686  if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode))
687  {
688    PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0);
689    std::ostream &ss(std::cout);
690
691    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;
692  }
693#endif
694
695  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
696  {
697    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
698  }
699
700  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
701}
702
703Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
704{
705
706  // inter prediction
707  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
708
709#if DEBUG_STRING
710  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER);
711  if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask)
712  {
713    printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth]));
714  }
715#endif
716
717  // inter recon
718  xDecodeInterTexture( pcCU, uiDepth );
719
720#if DEBUG_STRING
721  if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask)
722  {
723    printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth]));
724  }
725#endif
726
727  // clip for only non-zero cbp case
728  if  ( pcCU->getQtRootCbf( 0) )
729  {
730    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
731  }
732  else
733  {
734    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
735  }
736#if DEBUG_STRING
737  if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask)
738  {
739    printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth]));
740  }
741#endif
742
743}
744
745#if H_3D
746Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
747{
748  UInt uiWidth        = pcCU->getWidth  ( 0 );
749  UInt uiHeight       = pcCU->getHeight ( 0 );
750
751  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
752
753  UInt    uiStride    = pcRecoYuv->getStride  ();
754  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
755
756
757  AOF( uiWidth == uiHeight );
758  AOF( uiAbsPartIdx == 0 );
759
760  Bool  bAboveAvail = false;
761  Bool  bLeftAvail  = false;
762  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
763  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, 
764    m_pcPrediction->getPredicBuf       (),
765    m_pcPrediction->getPredicBufWidth  (),
766    m_pcPrediction->getPredicBufHeight (),
767    bAboveAvail, bLeftAvail
768    );
769
770  if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
771  {
772    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), VER_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
773  }
774  else if ( pcCU->getDISType(uiAbsPartIdx) == 1 )
775  {
776    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), HOR_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
777  }
778  else if ( pcCU->getDISType(uiAbsPartIdx) == 2 )
779  {
780    Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
781    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
782    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
783    {
784      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
785      {
786        piReco[ uiX ] = pSingleDepth;
787      }
788      piReco+= uiStride;
789    }
790  }
791  else if ( pcCU->getDISType(uiAbsPartIdx) == 3 )
792  {
793    Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
794    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
795    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
796    {
797      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
798      {
799        piReco[ uiX ] = pSingleDepth;
800      }
801      piReco+= uiStride;
802    }
803  }
804
805  // clear UV
806  UInt  uiStrideC     = pcRecoYuv->getCStride();
807  Pel   *pRecCb       = pcRecoYuv->getCbAddr();
808  Pel   *pRecCr       = pcRecoYuv->getCrAddr();
809
810  for (Int y=0; y<uiHeight/2; y++)
811  {
812    for (Int x=0; x<uiWidth/2; x++)
813    {
814      pRecCb[x] = 1<<(g_bitDepthC-1);
815      pRecCr[x] = 1<<(g_bitDepthC-1);
816    }
817
818    pRecCb += uiStrideC;
819    pRecCr += uiStrideC;
820  }
821}
822#endif
823#if H_3D_INTER_SDC
824Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
825{
826  // inter prediction
827  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
828
829  UInt  uiWidth      = pcCU->getWidth ( 0 );
830  UInt  uiHeight     = pcCU->getHeight( 0 );
831
832  Pel  *pResi;
833  UInt uiPelX, uiPelY;
834  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
835
836  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
837  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
838  {
839    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
840    {
841      pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
842    }
843    pResi += uiResiStride;
844  }
845
846  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
847
848  // clear UV
849  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
850  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
851  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
852
853  for (Int y = 0; y < uiHeight/2; y++)
854  {
855    for (Int x = 0; x < uiWidth/2; x++)
856    {
857      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
858      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
859    }
860
861    pRecCb += uiStrideC;
862    pRecCr += uiStrideC;
863  }
864}
865#endif
866
867#if H_3D_DBBP
868Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
869{
870  AOF(!pcCU->getSlice()->getIsDepth());
871  AOF(!pcCU->getSlice()->isIntra());
872  PartSize ePartSize = pcCU->getPartitionSize( 0 );
873 
874  // get collocated depth block
875  UInt uiDepthStride = 0;
876#if H_3D_FCO
877  Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
878#else
879  Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
880#endif
881  AOF( pDepthPels != NULL );
882  AOF( uiDepthStride != 0 );
883 
884  // compute mask by segmenting depth block
885  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
886  Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU);
887  AOF(bValidMask);
888 
889  DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
890  TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
891 
892  // first, extract the two sets of motion parameters
893  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
894  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
895  {
896    UInt uiPartAddr = uiSegment*uiPUOffset;
897   
898    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
899   
900    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
901    {
902      RefPicList eRefList = (RefPicList)uiRefListIdx;
903      pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
904    }
905   
906    AOF( pcCU->getARPW(uiPartAddr) == 0 );
907    AOF( pcCU->getICFlag(uiPartAddr) == false );
908    AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
909    AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
910  }
911 
912  // do motion compensation for each segment as 2Nx2N
913  pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
914  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
915  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
916  {
917    pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
918 
919    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
920    {
921      RefPicList eRefList = (RefPicList)uiRefListIdx;
922
923      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
924    }
925   
926    // inter prediction
927    m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
928  }
929 
930  // restore motion information in both segments again
931  pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
932  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
933  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
934  {
935    UInt uiPartAddr = uiSegment*uiPUOffset;
936   
937    pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
938    pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
939   
940    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
941    {
942      RefPicList eRefList = (RefPicList)uiRefListIdx;
943
944      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
945    }
946  }
947 
948  // reconstruct final prediction signal by combining both segments
949  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize);
950
951  // inter recon
952  xDecodeInterTexture( pcCU, 0, uiDepth );
953 
954  // clip for only non-zero cbp case
955  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
956  {
957    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
958  }
959  else
960  {
961    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
962  }
963}
964#endif
965
966
967Void
968TDecCu::xIntraRecBlk(       TComYuv*    pcRecoYuv,
969                            TComYuv*    pcPredYuv,
970                            TComYuv*    pcResiYuv,
971                      const ComponentID compID,
972                            TComTU     &rTu)
973{
974  if (!rTu.ProcessComponentSection(compID))
975  {
976    return;
977  }
978  const Bool       bIsLuma = isLuma(compID);
979
980
981  TComDataCU *pcCU = rTu.getCU();
982  const TComSPS &sps=*(pcCU->getSlice()->getSPS());
983  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
984
985  const TComRectangle &tuRect  =rTu.getRect(compID);
986  const UInt uiWidth           = tuRect.width;
987  const UInt uiHeight          = tuRect.height;
988  const UInt uiStride          = pcRecoYuv->getStride (compID);
989        Pel* piPred            = pcPredYuv->getAddr( compID, uiAbsPartIdx );
990  const ChromaFormat chFmt     = rTu.GetChromaFormat();
991
992  if (uiWidth != uiHeight)
993  {
994    //------------------------------------------------
995
996    //split at current level if dividing into square sub-TUs
997
998    TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
999
1000    //recurse further
1001    do
1002    {
1003      xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse);
1004    } while (subTURecurse.nextSection(rTu));
1005
1006    //------------------------------------------------
1007
1008    return;
1009  }
1010
1011  const UInt uiChPredMode  = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx );
1012  const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize()));
1013  const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode;
1014  const UInt uiChFinalMode = ((chFmt == CHROMA_422)       && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode;
1015
1016  //===== init availability pattern =====
1017  Bool  bAboveAvail = false;
1018  Bool  bLeftAvail  = false;
1019
1020  const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
1021
1022#if DEBUG_STRING
1023  std::ostream &ss(std::cout);
1024#endif
1025
1026  DEBUG_STRING_NEW(sTemp)
1027  m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
1028
1029
1030  //===== get prediction signal =====
1031#if H_3D_DIM
1032  if( isDimMode( uiLumaPredMode ) )
1033  {
1034    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
1035  }
1036  else
1037  {
1038#endif
1039
1040  m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
1041#if H_3D_DIM
1042  }
1043#endif
1044
1045#if DEBUG_STRING
1046  ss << sTemp;
1047#endif
1048
1049  //===== inverse transform =====
1050  Pel*      piResi            = pcResiYuv->getAddr( compID, uiAbsPartIdx );
1051  TCoeff*   pcCoeff           = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx );
1052
1053  const QpParam cQP(*pcCU, compID);
1054
1055
1056  DEBUG_STRING_NEW(sDebug);
1057#if DEBUG_STRING
1058  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
1059  std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
1060#endif
1061#if H_3D
1062  Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
1063
1064  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
1065#else
1066  if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0)
1067#endif
1068  {
1069    m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
1070  }
1071  else
1072  {
1073    for (UInt y = 0; y < uiHeight; y++)
1074    {
1075      for (UInt x = 0; x < uiWidth; x++)
1076      {
1077        piResi[(y * uiStride) + x] = 0;
1078      }
1079    }
1080  }
1081
1082#if DEBUG_STRING
1083  if (psDebug)
1084  {
1085    ss << (*psDebug);
1086  }
1087#endif
1088
1089  //===== reconstruction =====
1090  const UInt uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride(compID);
1091
1092  const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0);
1093  const Pel* pResiLuma  = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
1094  const Int  strideLuma = pcResiYuv->getStride( COMPONENT_Y );
1095
1096        Pel* pPred      = piPred;
1097        Pel* pResi      = piResi;
1098        Pel* pReco      = pcRecoYuv->getAddr( compID, uiAbsPartIdx );
1099        Pel* pRecIPred  = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
1100
1101
1102#if DEBUG_STRING
1103  const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1104  const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1105  const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1106  if (bDebugPred || bDebugResi || bDebugReco)
1107  {
1108    ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl;
1109  }
1110#endif
1111
1112  const Int clipbd = sps.getBitDepth(toChannelType(compID));
1113#if O0043_BEST_EFFORT_DECODING
1114  const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd;
1115#endif
1116
1117  if( useCrossComponentPrediction )
1118  {
1119    TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true );
1120  }
1121
1122  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1123  {
1124#if DEBUG_STRING
1125    if (bDebugPred || bDebugResi || bDebugReco)
1126    {
1127      ss << "###: ";
1128    }
1129
1130    if (bDebugPred)
1131    {
1132      ss << " - pred: ";
1133      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1134      {
1135        ss << pPred[ uiX ] << ", ";
1136      }
1137    }
1138    if (bDebugResi)
1139    {
1140      ss << " - resi: ";
1141    }
1142#endif
1143
1144    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1145    {
1146#if DEBUG_STRING
1147      if (bDebugResi)
1148      {
1149        ss << pResi[ uiX ] << ", ";
1150      }
1151#endif
1152#if O0043_BEST_EFFORT_DECODING
1153      pReco    [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd );
1154#else
1155      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd );
1156#endif
1157      pRecIPred[ uiX ] = pReco[ uiX ];
1158    }
1159#if DEBUG_STRING
1160    if (bDebugReco)
1161    {
1162      ss << " - reco: ";
1163      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1164      {
1165        ss << pReco[ uiX ] << ", ";
1166      }
1167    }
1168
1169    if (bDebugPred || bDebugResi || bDebugReco)
1170    {
1171      ss << "\n";
1172    }
1173#endif
1174    pPred     += uiStride;
1175    pResi     += uiStride;
1176    pReco     += uiStride;
1177    pRecIPred += uiRecIPredStride;
1178  }
1179}
1180#if H_3D_DIM
1181      mapDepthModeToIntraDir( uiChromaPredMode );
1182#endif
1183
1184
1185Void
1186TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
1187{
1188  if (pcCU->getIPCMFlag(0))
1189  {
1190    xReconPCM( pcCU, uiDepth );
1191    return;
1192  }
1193  const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1;
1194  for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++)
1195  {
1196    const ChannelType chanType=ChannelType(chType);
1197    const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true;
1198    const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 );
1199
1200    TComTURecurse tuRecurseCU(pcCU, 0);
1201    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT);
1202
1203    do
1204    {
1205      xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU );
1206    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
1207  }
1208}
1209
1210#if H_3D_DIM_SDC
1211Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1212{
1213  UInt uiWidth        = pcCU->getWidth  ( 0 );
1214  UInt uiHeight       = pcCU->getHeight ( 0 );
1215  TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
1216  UInt numParts = 1;
1217  UInt sdcDepth    = 0;
1218  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
1219  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
1220  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
1221
1222  UInt    uiStride = 0;
1223  Pel*    piReco;
1224  Pel*    piPred;
1225  Pel*    piResi;
1226
1227  UInt    uiZOrder;       
1228  Pel*    piRecIPred;     
1229  UInt    uiRecIPredStride;
1230
1231  UInt    uiLumaPredMode = 0; 
1232
1233  if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1)
1234  {
1235    numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
1236    sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
1237    uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
1238  }
1239
1240  for ( Int i = 0; i < numParts; i++ )
1241  {
1242    uiStride    = pcRecoYuv->getStride  ();
1243    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
1244    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
1245    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
1246
1247    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1248    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
1249    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
1250
1251    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
1252
1253    AOF( uiWidth == uiHeight );
1254
1255    //===== init availability pattern =====
1256    Bool  bAboveAvail = false;
1257    Bool  bLeftAvail  = false;
1258
1259    pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
1260    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
1261
1262    TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
1263    //===== get prediction signal =====
1264    if( isDimMode( uiLumaPredMode ) )
1265    {
1266      m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation  );
1267      Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
1268      Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
1269      for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 
1270      { 
1271        dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
1272      }
1273    }
1274    else
1275    {
1276      m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
1277    }
1278
1279    if ( numParts > 1 )
1280    {
1281      for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1282      {
1283        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1284        {
1285          piReco        [ uiX ] = ClipY( piPred[ uiX ] );
1286          piRecIPred    [ uiX ] = piReco[ uiX ];
1287        }
1288        piPred     += uiStride;
1289        piReco     += uiStride;
1290        piRecIPred += uiRecIPredStride;
1291      }
1292    }
1293    uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 );
1294    dmm4Segmentation->destroy(); delete dmm4Segmentation;
1295  }
1296  uiAbsPartIdx = 0;
1297 
1298  if ( numParts > 1 )
1299  {
1300    uiWidth = pcCU->getWidth( 0 );
1301    uiHeight = pcCU->getHeight( 0 );
1302  }
1303  piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
1304  piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
1305  piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
1306  uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1307  piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
1308  uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
1309  // number of segments depends on prediction mode
1310  UInt uiNumSegments = 1;
1311  Bool* pbMask = NULL;
1312  UInt uiMaskStride = 0;
1313 
1314  if( getDimType( uiLumaPredMode ) == DMM1_IDX )
1315  {
1316    Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
1317
1318    WedgeList* pacWedgeList  = pcCU->isDMM1UpscaleMode(uiWidth) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] :  &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
1319    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
1320
1321    uiNumSegments = 2;
1322
1323    pbMask       = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern();
1324    uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride();
1325  }
1326  if( getDimType( uiLumaPredMode ) == DMM4_IDX )
1327  {
1328    uiNumSegments = 2;
1329    pbMask  = dmm4SegmentationOrg->getPattern();
1330    uiMaskStride = dmm4SegmentationOrg->getStride();
1331  }
1332  // get DC prediction for each segment
1333  Pel apDCPredValues[2];
1334  if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
1335  {
1336    apDCPredValues[0] = pcCU->getDmmPredictor( 0 );
1337    apDCPredValues[1] = pcCU->getDmmPredictor( 1 );
1338  }
1339  else
1340  {
1341    m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
1342  }
1343 
1344  // reconstruct residual based on mask + DC residuals
1345  Pel apDCResiValues[2];
1346  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
1347  {
1348#if H_3D_DIM_DLT
1349    Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
1350    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1351    Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
1352
1353    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
1354#else
1355    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1356#endif
1357  }
1358 
1359  //===== reconstruction =====
1360  Bool*pMask      = pbMask;
1361  Pel* pPred      = piPred;
1362  Pel* pResi      = piResi;
1363  Pel* pReco      = piReco;
1364  Pel* pRecIPred  = piRecIPred;
1365 
1366  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1367  {
1368    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1369    {
1370      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1371      assert( ucSegment < uiNumSegments );
1372     
1373      Pel pResiDC = apDCResiValues[ucSegment];
1374     
1375      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
1376      pRecIPred[ uiX ] = pReco[ uiX ];
1377    }
1378    pPred     += uiStride;
1379    pResi     += uiStride;
1380    pReco     += uiStride;
1381    pRecIPred += uiRecIPredStride;
1382    pMask     += uiMaskStride;
1383  }
1384 
1385  // clear UV
1386  UInt  uiStrideC     = pcPredYuv->getCStride();
1387  Pel   *pRecCb       = pcPredYuv->getCbAddr();
1388  Pel   *pRecCr       = pcPredYuv->getCrAddr();
1389 
1390  for (Int y=0; y<uiHeight/2; y++)
1391  {
1392    for (Int x=0; x<uiWidth/2; x++)
1393    {
1394      pRecCb[x] = 128;
1395      pRecCr[x] = 128;
1396    }
1397   
1398    pRecCb += uiStrideC;
1399    pRecCr += uiStrideC;
1400  }
1401  dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
1402}
1403#endif
1404
1405
1406/** Function for deriving reconstructed PU/CU chroma samples with QTree structure
1407 * \param pcRecoYuv pointer to reconstructed sample arrays
1408 * \param pcPredYuv pointer to prediction sample arrays
1409 * \param pcResiYuv pointer to residue sample arrays
1410 * \param chType    texture channel type (luma/chroma)
1411 * \param rTu       reference to transform data
1412 *
1413 \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure
1414 */
1415
1416Void
1417TDecCu::xIntraRecQT(TComYuv*    pcRecoYuv,
1418                    TComYuv*    pcPredYuv,
1419                    TComYuv*    pcResiYuv,
1420                    const ChannelType chType,
1421                    TComTU     &rTu)
1422{
1423  UInt uiTrDepth    = rTu.GetTransformDepthRel();
1424  TComDataCU *pcCU  = rTu.getCU();
1425  UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
1426  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1427  if( uiTrMode == uiTrDepth )
1428  {
1429    if (isLuma(chType))
1430    {
1431      xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y,  rTu );
1432    }
1433    else
1434    {
1435      const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat());
1436      for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++)
1437      {
1438        xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu );
1439      }
1440    }
1441  }
1442  else
1443  {
1444    TComTURecurse tuRecurseChild(rTu, false);
1445    do
1446    {
1447      xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild );
1448    } while (tuRecurseChild.nextSection(rTu));
1449  }
1450}
1451
1452Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1453{
1454  UInt uiCtuRsAddr = pcCU->getCtuRsAddr();
1455
1456  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx );
1457
1458  return;
1459}
1460
1461Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth )
1462{
1463
1464  TComTURecurse tuRecur(pcCU, 0, uiDepth);
1465
1466  for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
1467  {
1468    const ComponentID compID=ComponentID(ch);
1469    DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID])
1470
1471    m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur );
1472  }
1473
1474  DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT])
1475}
1476
1477/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1478 * \param pcCU pointer to current CU
1479 * \param uiPartIdx part index
1480 * \param piPCM pointer to PCM code arrays
1481 * \param piReco pointer to reconstructed sample arrays
1482 * \param uiStride stride of reconstructed sample arrays
1483 * \param uiWidth CU width
1484 * \param uiHeight CU height
1485 * \param compID colour component ID
1486 * \returns Void
1487 */
1488Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID)
1489{
1490        Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx);
1491  const UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride(compID);
1492  const TComSPS &sps           = *(pcCU->getSlice()->getSPS());
1493  const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID));
1494
1495  for(UInt uiY = 0; uiY < uiHeight; uiY++ )
1496  {
1497    for(UInt uiX = 0; uiX < uiWidth; uiX++ )
1498    {
1499      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1500      piPicReco[uiX] = piReco[uiX];
1501    }
1502    piPCM += uiWidth;
1503    piReco += uiStride;
1504    piPicReco += uiPicStride;
1505  }
1506}
1507
1508/** Function for reconstructing a PCM mode CU.
1509 * \param pcCU pointer to current CU
1510 * \param uiDepth CU Depth
1511 * \returns Void
1512 */
1513Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
1514{
1515  const UInt maxCuWidth     = pcCU->getSlice()->getSPS()->getMaxCUWidth();
1516  const UInt maxCuHeight    = pcCU->getSlice()->getSPS()->getMaxCUHeight();
1517  for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++)
1518  {
1519    const ComponentID compID = ComponentID(ch);
1520    const UInt width  = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID)));
1521    const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID)));
1522    const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID);
1523    Pel * pPCMChannel = pcCU->getPCMSample(compID);
1524    Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID);
1525    xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID );
1526  }
1527}
1528
1529/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1530 * \param pCU   pointer to current CU
1531 * \param depth CU Depth
1532 */
1533Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
1534{
1535  const ChromaFormat format = pCU->getPic()->getChromaFormat();
1536  const UInt numValidComp   = getNumberValidComponents(format);
1537  const UInt maxCuWidth     = pCU->getSlice()->getSPS()->getMaxCUWidth();
1538  const UInt maxCuHeight    = pCU->getSlice()->getSPS()->getMaxCUHeight();
1539
1540  for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++)
1541  {
1542    const ComponentID component = ComponentID(componentIndex);
1543
1544    const UInt width  = maxCuWidth  >> (depth + getComponentScaleX(component, format));
1545    const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format));
1546
1547    Pel *source      = m_ppcYuvReco[depth]->getAddr(component, 0, width);
1548    Pel *destination = pCU->getPCMSample(component);
1549
1550    const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component);
1551
1552    for (Int line = 0; line < height; line++)
1553    {
1554      for (Int column = 0; column < width; column++)
1555      {
1556        destination[column] = source[column];
1557      }
1558
1559      source      += sourceStride;
1560      destination += width;
1561    }
1562  }
1563}
1564
1565//! \}
Note: See TracBrowser for help on using the repository browser.