source: 3DVCSoftware/branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.cpp @ 1274

Last change on this file since 1274 was 1274, checked in by tech, 9 years ago

Merged HTM-14.1-update-dev3@1273.

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