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

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

Merged 14.1-update-dev2@1277.

  • Property svn:eol-style set to native
File size: 54.2 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 NH_3D_DIS
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 NH_3D_SDC_INTRA
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 NH_3D_DIS
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 NH_3D
669#if NH_3D_DIS
670    if( m_ppcCU[uiDepth]->getDISFlag(0) )
671    {
672      xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
673    }
674#else
675    if(false )
676    {
677     // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
678    }
679#endif
680#if NH_3D_SDC_INTRA
681    else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
682    {
683      xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
684    }
685#endif
686    else
687#endif
688      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
689      break;
690    default:
691      assert(0);
692      break;
693  }
694
695#if DEBUG_STRING
696  const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0);
697  if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode))
698  {
699    PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0);
700    std::ostream &ss(std::cout);
701
702    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;
703  }
704#endif
705
706  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
707  {
708    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
709  }
710
711  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
712}
713
714Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
715{
716
717  // inter prediction
718  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
719
720#if DEBUG_STRING
721  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER);
722  if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask)
723  {
724    printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth]));
725  }
726#endif
727
728  // inter recon
729  xDecodeInterTexture( pcCU, uiDepth );
730
731#if DEBUG_STRING
732  if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask)
733  {
734    printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth]));
735  }
736#endif
737
738  // clip for only non-zero cbp case
739  if  ( pcCU->getQtRootCbf( 0) )
740  {
741    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
742  }
743  else
744  {
745    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
746  }
747#if DEBUG_STRING
748  if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask)
749  {
750    printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth]));
751  }
752#endif
753
754}
755
756#if NH_3D_DIS
757Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
758{
759  UInt uiWidth        = pcCU->getWidth  ( 0 );
760  UInt uiHeight       = pcCU->getHeight ( 0 );
761
762  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
763
764  UInt    uiStride    = pcRecoYuv->getStride  (COMPONENT_Y);
765  Pel*    piReco      = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
766
767
768  AOF( uiWidth == uiHeight );
769  AOF( uiAbsPartIdx == 0 );
770
771  Bool  bAboveAvail = false;
772  Bool  bLeftAvail  = false;
773 
774  TComTURecurse rTu(pcCU, 0);
775  const ChromaFormat chFmt     = rTu.GetChromaFormat();
776
777  if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
778  {
779    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
780    m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
781    m_pcPrediction->predIntraAng( COMPONENT_Y,   VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
782  }
783  else if ( pcCU->getDISType(uiAbsPartIdx) == 1 )
784  {
785    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
786    m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
787    m_pcPrediction->predIntraAng( COMPONENT_Y,   HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
788  }
789  else if ( pcCU->getDISType(uiAbsPartIdx) == 2 )
790  {
791    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
792    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
793    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
794    {
795      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
796      {
797        piReco[ uiX ] = pSingleDepth;
798      }
799      piReco+= uiStride;
800    }
801  }
802  else if ( pcCU->getDISType(uiAbsPartIdx) == 3 )
803  {
804    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
805    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
806    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
807    {
808      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
809      {
810        piReco[ uiX ] = pSingleDepth;
811      }
812      piReco+= uiStride;
813    }
814  }
815
816  // clear UV
817  UInt  uiStrideC     = pcRecoYuv->getStride(COMPONENT_Cb);
818  Pel   *pRecCb       = pcRecoYuv->getAddr(COMPONENT_Cb);
819  Pel   *pRecCr       = pcRecoYuv->getAddr(COMPONENT_Cr);
820
821  for (Int y=0; y<uiHeight/2; y++)
822  {
823    for (Int x=0; x<uiWidth/2; x++)
824    {
825      pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
826      pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
827    }
828
829    pRecCb += uiStrideC;
830    pRecCr += uiStrideC;
831  }
832}
833#endif
834#if H_3D_INTER_SDC
835Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
836{
837  // inter prediction
838  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
839
840  UInt  uiWidth      = pcCU->getWidth ( 0 );
841  UInt  uiHeight     = pcCU->getHeight( 0 );
842
843  Pel  *pResi;
844  UInt uiPelX, uiPelY;
845  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
846
847  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
848  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
849  {
850    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
851    {
852      pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
853    }
854    pResi += uiResiStride;
855  }
856
857  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
858
859  // clear UV
860  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
861  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
862  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
863
864  for (Int y = 0; y < uiHeight/2; y++)
865  {
866    for (Int x = 0; x < uiWidth/2; x++)
867    {
868      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
869      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
870    }
871
872    pRecCb += uiStrideC;
873    pRecCr += uiStrideC;
874  }
875}
876#endif
877
878#if NH_3D_DBBP
879Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
880{
881  AOF(!pcCU->getSlice()->getIsDepth());
882  AOF(!pcCU->getSlice()->isIntra());
883  PartSize ePartSize = pcCU->getPartitionSize( 0 );
884 
885  Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
886 
887  // get collocated depth block
888  UInt uiDepthStride = 0;
889#if H_3D_FCO
890  Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
891#else
892  Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
893#endif
894  AOF( pDepthPels != NULL );
895  AOF( uiDepthStride != 0 );
896 
897  // compute mask by segmenting depth block
898  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
899  Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU);
900  AOF(bValidMask);
901 
902  DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
903  TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
904 
905  // first, extract the two sets of motion parameters
906  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
907  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
908  {
909    UInt uiPartAddr = uiSegment*uiPUOffset;
910   
911    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
912    assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2  );  // only uni-prediction allowed
913   
914    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
915    {
916      RefPicList eRefList = (RefPicList)uiRefListIdx;
917      pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
918    }
919   
920#if H_3D
921    AOF( pcCU->getARPW(uiPartAddr) == 0 );
922    AOF( pcCU->getICFlag(uiPartAddr) == false );
923    AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
924    AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
925#endif
926  }
927 
928  // do motion compensation for each segment as 2Nx2N
929  pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
930  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
931  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
932  {
933    pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
934 
935    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
936    {
937      RefPicList eRefList = (RefPicList)uiRefListIdx;
938
939      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
940    }
941   
942    // inter prediction
943    m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
944  }
945 
946  // restore motion information in both segments again
947  pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
948  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
949  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
950  {
951    UInt uiPartAddr = uiSegment*uiPUOffset;
952   
953    pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
954    pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
955   
956    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
957    {
958      RefPicList eRefList = (RefPicList)uiRefListIdx;
959
960      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
961    }
962  }
963 
964  // reconstruct final prediction signal by combining both segments
965  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY);
966
967  // inter recon
968  xDecodeInterTexture( pcCU, uiDepth );
969 
970  // clip for only non-zero cbp case
971  if  ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) )
972  {
973    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
974  }
975  else
976  {
977    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
978  }
979}
980#endif
981
982
983Void
984TDecCu::xIntraRecBlk(       TComYuv*    pcRecoYuv,
985                            TComYuv*    pcPredYuv,
986                            TComYuv*    pcResiYuv,
987                      const ComponentID compID,
988                            TComTU     &rTu)
989{
990  if (!rTu.ProcessComponentSection(compID))
991  {
992    return;
993  }
994  const Bool       bIsLuma = isLuma(compID);
995
996
997  TComDataCU *pcCU = rTu.getCU();
998  const TComSPS &sps=*(pcCU->getSlice()->getSPS());
999  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
1000
1001  const TComRectangle &tuRect  =rTu.getRect(compID);
1002  const UInt uiWidth           = tuRect.width;
1003  const UInt uiHeight          = tuRect.height;
1004  const UInt uiStride          = pcRecoYuv->getStride (compID);
1005        Pel* piPred            = pcPredYuv->getAddr( compID, uiAbsPartIdx );
1006  const ChromaFormat chFmt     = rTu.GetChromaFormat();
1007
1008  if (uiWidth != uiHeight)
1009  {
1010    //------------------------------------------------
1011
1012    //split at current level if dividing into square sub-TUs
1013
1014    TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
1015
1016    //recurse further
1017    do
1018    {
1019      xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse);
1020    } while (subTURecurse.nextSection(rTu));
1021
1022    //------------------------------------------------
1023
1024    return;
1025  }
1026
1027  const UInt uiChPredMode  = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx );
1028  const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize()));
1029  const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode;
1030  const UInt uiChFinalMode = ((chFmt == CHROMA_422)       && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode;
1031
1032  //===== init availability pattern =====
1033  Bool  bAboveAvail = false;
1034  Bool  bLeftAvail  = false;
1035
1036  const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
1037
1038#if DEBUG_STRING
1039  std::ostream &ss(std::cout);
1040#endif
1041
1042  DEBUG_STRING_NEW(sTemp)
1043  m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
1044
1045
1046  //===== get prediction signal =====
1047#if NH_3D_DMM
1048  if( bIsLuma && isDmmMode( uiChFinalMode ) )
1049  {
1050    m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight );
1051  }
1052  else
1053  {
1054#endif
1055  m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
1056#if NH_3D_DMM
1057  }
1058#endif
1059
1060#if DEBUG_STRING
1061  ss << sTemp;
1062#endif
1063
1064  //===== inverse transform =====
1065  Pel*      piResi            = pcResiYuv->getAddr( compID, uiAbsPartIdx );
1066  TCoeff*   pcCoeff           = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx );
1067
1068  const QpParam cQP(*pcCU, compID);
1069
1070
1071  DEBUG_STRING_NEW(sDebug);
1072#if DEBUG_STRING
1073  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
1074  std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
1075#endif
1076#if H_3D
1077  Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
1078
1079  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
1080#else
1081  if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0)
1082#endif
1083  {
1084    m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
1085  }
1086  else
1087  {
1088    for (UInt y = 0; y < uiHeight; y++)
1089    {
1090      for (UInt x = 0; x < uiWidth; x++)
1091      {
1092        piResi[(y * uiStride) + x] = 0;
1093      }
1094    }
1095  }
1096
1097#if DEBUG_STRING
1098  if (psDebug)
1099  {
1100    ss << (*psDebug);
1101  }
1102#endif
1103
1104  //===== reconstruction =====
1105  const UInt uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride(compID);
1106
1107  const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0);
1108  const Pel* pResiLuma  = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
1109  const Int  strideLuma = pcResiYuv->getStride( COMPONENT_Y );
1110
1111        Pel* pPred      = piPred;
1112        Pel* pResi      = piResi;
1113        Pel* pReco      = pcRecoYuv->getAddr( compID, uiAbsPartIdx );
1114        Pel* pRecIPred  = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
1115
1116
1117#if DEBUG_STRING
1118  const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1119  const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1120  const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1121  if (bDebugPred || bDebugResi || bDebugReco)
1122  {
1123    ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl;
1124  }
1125#endif
1126
1127  const Int clipbd = sps.getBitDepth(toChannelType(compID));
1128#if O0043_BEST_EFFORT_DECODING
1129  const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd;
1130#endif
1131
1132  if( useCrossComponentPrediction )
1133  {
1134    TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true );
1135  }
1136
1137  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1138  {
1139#if DEBUG_STRING
1140    if (bDebugPred || bDebugResi || bDebugReco)
1141    {
1142      ss << "###: ";
1143    }
1144
1145    if (bDebugPred)
1146    {
1147      ss << " - pred: ";
1148      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1149      {
1150        ss << pPred[ uiX ] << ", ";
1151      }
1152    }
1153    if (bDebugResi)
1154    {
1155      ss << " - resi: ";
1156    }
1157#endif
1158
1159    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1160    {
1161#if DEBUG_STRING
1162      if (bDebugResi)
1163      {
1164        ss << pResi[ uiX ] << ", ";
1165      }
1166#endif
1167#if O0043_BEST_EFFORT_DECODING
1168      pReco    [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd );
1169#else
1170      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd );
1171#endif
1172      pRecIPred[ uiX ] = pReco[ uiX ];
1173    }
1174#if DEBUG_STRING
1175    if (bDebugReco)
1176    {
1177      ss << " - reco: ";
1178      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1179      {
1180        ss << pReco[ uiX ] << ", ";
1181      }
1182    }
1183
1184    if (bDebugPred || bDebugResi || bDebugReco)
1185    {
1186      ss << "\n";
1187    }
1188#endif
1189    pPred     += uiStride;
1190    pResi     += uiStride;
1191    pReco     += uiStride;
1192    pRecIPred += uiRecIPredStride;
1193  }
1194}
1195
1196Void
1197TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
1198{
1199  if (pcCU->getIPCMFlag(0))
1200  {
1201    xReconPCM( pcCU, uiDepth );
1202    return;
1203  }
1204  const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1;
1205  for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++)
1206  {
1207    const ChannelType chanType=ChannelType(chType);
1208    const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true;
1209    const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 );
1210
1211    TComTURecurse tuRecurseCU(pcCU, 0);
1212    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT);
1213
1214    do
1215    {
1216      xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU );
1217    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
1218  }
1219}
1220
1221#if NH_3D_SDC_INTRA
1222Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1223{
1224  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
1225  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
1226  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
1227
1228  UInt uiWidth        = pcCU->getWidth ( 0 );
1229  UInt uiHeight       = pcCU->getHeight( 0 );
1230  UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );
1231  const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
1232  const TComSPS     &sps    = *(pcCU->getSlice()->getSPS());
1233  const ChromaFormat chFmt  = pcCU->getPic()->getChromaFormat();
1234
1235  UInt sdcDepth = 0;
1236  UInt uiStride;
1237  Pel* piReco;
1238  Pel* piPred;
1239  Pel* piResi;
1240
1241  Pel* piRecIPred;
1242  UInt uiRecIPredStride;
1243 
1244  Pel apDCPredValues[2];
1245  UInt uiNumSegments;
1246
1247  Bool* pbMask = NULL;
1248  UInt uiMaskStride = 0;
1249
1250#if NH_3D_DMM
1251  if( isDmmMode( uiLumaPredMode ) )
1252  {
1253    assert( uiWidth == uiHeight  );
1254    assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE );
1255    assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) );
1256
1257    uiNumSegments     = 2;
1258
1259    uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
1260    piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1261    piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1262    piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1263
1264    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
1265    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
1266
1267    //===== init availability pattern =====
1268    TComTURecurse tuRecurseCU(pcCU, 0);
1269    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
1270
1271    Bool bAboveAvail = false;
1272    Bool bLeftAvail  = false;
1273    m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, bAboveAvail, bLeftAvail, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
1274
1275    // get partition
1276    pbMask       = new Bool[ uiWidth*uiHeight ];
1277    uiMaskStride = uiWidth;
1278    switch( getDmmType( uiLumaPredMode ) )
1279    {
1280    case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break;
1281    case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask );                                     } break;
1282    default: assert(0);
1283    }
1284
1285    // get predicted partition values
1286    Pel predDC1 = 0, predDC2 = 0;
1287    m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 );
1288
1289    // set prediction signal
1290    Pel* pDst = piPred;
1291    m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 );
1292    apDCPredValues[0] = predDC1;
1293    apDCPredValues[1] = predDC2;
1294  }
1295  else // regular HEVC intra modes
1296  {
1297#endif
1298    uiNumSegments = 1;
1299
1300    if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
1301    {
1302      sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
1303    }
1304   
1305    //===== loop over partitions =====
1306    TComTURecurse tuRecurseCU(pcCU, 0);
1307    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT);
1308
1309    do
1310    {
1311      const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y);
1312      const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU();
1313     
1314      Pel* piPredTU       = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdxTU );
1315      UInt uiStrideTU     = pcPredYuv->getStride( COMPONENT_Y );
1316     
1317      Pel* piRecIPredTU   = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU );
1318      UInt uiRecIPredStrideTU  = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
1319     
1320      const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
1321     
1322      //===== init pattern for luma prediction =====
1323      Bool bAboveAvail = false;
1324      Bool bLeftAvail  = false;
1325     
1326      m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilter  DEBUG_STRING_PASS_INTO(sTemp) );
1327     
1328      m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bAboveAvail, bLeftAvail, bUseFilter );
1329     
1330      // copy for prediction of next part
1331      for( UInt uiY = 0; uiY < puRect.height; uiY++ )
1332      {
1333        for( UInt uiX = 0; uiX < puRect.width; uiX++ )
1334        {
1335          piPredTU      [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY );
1336          piRecIPredTU  [ uiX ] = piPredTU[ uiX ];
1337        }
1338        piPredTU     += uiStrideTU;
1339        piRecIPredTU += uiRecIPredStrideTU;
1340      }
1341     
1342     
1343    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
1344
1345    // reset to full block
1346    uiWidth  = pcCU->getWidth( 0 );
1347    uiHeight = pcCU->getHeight( 0 );
1348
1349    uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
1350    piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1351    piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1352    piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1353   
1354    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
1355    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
1356
1357    m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0;
1358#if NH_3D_DMM
1359  }
1360#endif
1361 
1362  // reconstruct residual based on mask + DC residuals
1363  Pel apDCResiValues[2];
1364  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
1365  {
1366#if NH_3D_DLT
1367    Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
1368    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1369    Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
1370
1371    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
1372#else
1373    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1374#endif
1375  }
1376 
1377  //===== reconstruction =====
1378  Bool*pMask      = pbMask;
1379  Pel* pPred      = piPred;
1380  Pel* pResi      = piResi;
1381  Pel* pReco      = piReco;
1382  Pel* pRecIPred  = piRecIPred;
1383 
1384  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1385  {
1386    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1387    {
1388      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1389      assert( ucSegment < uiNumSegments );
1390     
1391      Pel pResiDC = apDCResiValues[ucSegment];
1392     
1393      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY );
1394      pRecIPred[ uiX ] = pReco[ uiX ];
1395    }
1396    pPred     += uiStride;
1397    pResi     += uiStride;
1398    pReco     += uiStride;
1399    pRecIPred += uiRecIPredStride;
1400    pMask     += uiMaskStride;
1401  }
1402 
1403  // clear chroma
1404  UInt  uiStrideC     = pcPredYuv->getStride( COMPONENT_Cb );
1405  Pel   *pRecCb       = pcPredYuv->getAddr  ( COMPONENT_Cb, uiAbsPartIdx );
1406  Pel   *pRecCr       = pcPredYuv->getAddr  ( COMPONENT_Cr, uiAbsPartIdx );
1407 
1408  for (Int y=0; y<uiHeight/2; y++)
1409  {
1410    for (Int x=0; x<uiWidth/2; x++)
1411    {
1412      pRecCb[x] = 128;
1413      pRecCr[x] = 128;
1414    }
1415   
1416    pRecCb += uiStrideC;
1417    pRecCr += uiStrideC;
1418  }
1419#if NH_3D_DMM
1420  if( pbMask ) { delete[] pbMask; }
1421#endif
1422}
1423#endif
1424
1425
1426/** Function for deriving reconstructed PU/CU chroma samples with QTree structure
1427 * \param pcRecoYuv pointer to reconstructed sample arrays
1428 * \param pcPredYuv pointer to prediction sample arrays
1429 * \param pcResiYuv pointer to residue sample arrays
1430 * \param chType    texture channel type (luma/chroma)
1431 * \param rTu       reference to transform data
1432 *
1433 \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure
1434 */
1435
1436Void
1437TDecCu::xIntraRecQT(TComYuv*    pcRecoYuv,
1438                    TComYuv*    pcPredYuv,
1439                    TComYuv*    pcResiYuv,
1440                    const ChannelType chType,
1441                    TComTU     &rTu)
1442{
1443  UInt uiTrDepth    = rTu.GetTransformDepthRel();
1444  TComDataCU *pcCU  = rTu.getCU();
1445  UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
1446  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1447  if( uiTrMode == uiTrDepth )
1448  {
1449    if (isLuma(chType))
1450    {
1451      xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y,  rTu );
1452    }
1453    else
1454    {
1455      const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat());
1456      for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++)
1457      {
1458        xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu );
1459      }
1460    }
1461  }
1462  else
1463  {
1464    TComTURecurse tuRecurseChild(rTu, false);
1465    do
1466    {
1467      xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild );
1468    } while (tuRecurseChild.nextSection(rTu));
1469  }
1470}
1471
1472Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1473{
1474  UInt uiCtuRsAddr = pcCU->getCtuRsAddr();
1475
1476  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx );
1477
1478  return;
1479}
1480
1481Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth )
1482{
1483
1484  TComTURecurse tuRecur(pcCU, 0, uiDepth);
1485
1486  for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
1487  {
1488    const ComponentID compID=ComponentID(ch);
1489    DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID])
1490
1491    m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur );
1492  }
1493
1494  DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT])
1495}
1496
1497/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1498 * \param pcCU pointer to current CU
1499 * \param uiPartIdx part index
1500 * \param piPCM pointer to PCM code arrays
1501 * \param piReco pointer to reconstructed sample arrays
1502 * \param uiStride stride of reconstructed sample arrays
1503 * \param uiWidth CU width
1504 * \param uiHeight CU height
1505 * \param compID colour component ID
1506 * \returns Void
1507 */
1508Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID)
1509{
1510        Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx);
1511  const UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride(compID);
1512  const TComSPS &sps           = *(pcCU->getSlice()->getSPS());
1513  const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID));
1514
1515  for(UInt uiY = 0; uiY < uiHeight; uiY++ )
1516  {
1517    for(UInt uiX = 0; uiX < uiWidth; uiX++ )
1518    {
1519      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1520      piPicReco[uiX] = piReco[uiX];
1521    }
1522    piPCM += uiWidth;
1523    piReco += uiStride;
1524    piPicReco += uiPicStride;
1525  }
1526}
1527
1528/** Function for reconstructing a PCM mode CU.
1529 * \param pcCU pointer to current CU
1530 * \param uiDepth CU Depth
1531 * \returns Void
1532 */
1533Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
1534{
1535  const UInt maxCuWidth     = pcCU->getSlice()->getSPS()->getMaxCUWidth();
1536  const UInt maxCuHeight    = pcCU->getSlice()->getSPS()->getMaxCUHeight();
1537  for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++)
1538  {
1539    const ComponentID compID = ComponentID(ch);
1540    const UInt width  = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID)));
1541    const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID)));
1542    const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID);
1543    Pel * pPCMChannel = pcCU->getPCMSample(compID);
1544    Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID);
1545    xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID );
1546  }
1547}
1548
1549/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1550 * \param pCU   pointer to current CU
1551 * \param depth CU Depth
1552 */
1553Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
1554{
1555  const ChromaFormat format = pCU->getPic()->getChromaFormat();
1556  const UInt numValidComp   = getNumberValidComponents(format);
1557  const UInt maxCuWidth     = pCU->getSlice()->getSPS()->getMaxCUWidth();
1558  const UInt maxCuHeight    = pCU->getSlice()->getSPS()->getMaxCUHeight();
1559
1560  for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++)
1561  {
1562    const ComponentID component = ComponentID(componentIndex);
1563
1564    const UInt width  = maxCuWidth  >> (depth + getComponentScaleX(component, format));
1565    const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format));
1566
1567    Pel *source      = m_ppcYuvReco[depth]->getAddr(component, 0, width);
1568    Pel *destination = pCU->getPCMSample(component);
1569
1570    const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component);
1571
1572    for (Int line = 0; line < height; line++)
1573    {
1574      for (Int column = 0; column < width; column++)
1575      {
1576        destination[column] = source[column];
1577      }
1578
1579      source      += sourceStride;
1580      destination += width;
1581    }
1582  }
1583}
1584
1585//! \}
Note: See TracBrowser for help on using the repository browser.