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

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

Upgrade to HM-16.6.

  • Property svn:eol-style set to native
File size: 54.3 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  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
88  {
89    UInt uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
90    UInt uiWidth  = uiMaxWidth  >> ui;
91    UInt uiHeight = uiMaxHeight >> ui;
92
93    // The following arrays (m_ppcYuvResi, m_ppcYuvReco and m_ppcCU) are only required for CU depths
94    // although data is allocated for all possible depths of the CU/TU tree except the last.
95    // Since the TU tree will always include at least one additional depth greater than the CU tree,
96    // there will be enough entries for these arrays.
97    // (Section 7.4.3.2: "The CVS shall not contain data that result in (Log2MinTrafoSize) MinTbLog2SizeY
98    //                    greater than or equal to MinCbLog2SizeY")
99    // TODO: tidy the array allocation given the above comment.
100
101    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
102    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
103    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
104#if NH_3D_DBBP
105    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
106#endif
107}
108
109  m_bDecodeDQP = false;
110  m_IsChromaQpAdjCoded = false;
111
112  // initialize partition order.
113  UInt* piTmp = &g_auiZscanToRaster[0];
114  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
115  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
116
117  // initialize conversion matrix from partition index to pel
118  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
119}
120
121Void TDecCu::destroy()
122{
123  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
124  {
125    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
126    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
127    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
128#if NH_3D_DBBP
129    m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
130#endif
131  }
132
133  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
134  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
135  delete [] m_ppcCU     ; m_ppcCU      = NULL;
136#if NH_3D_DBBP
137  delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
138#endif
139}
140
141// ====================================================================================================================
142// Public member functions
143// ====================================================================================================================
144
145/**
146 Parse a CTU.
147 \param    pCtu                      [in/out] pointer to CTU data structure
148 \param    isLastCtuOfSliceSegment   [out]    true, if last CTU of the slice segment
149 */
150Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment )
151{
152  if ( pCtu->getSlice()->getPPS()->getUseDQP() )
153  {
154    setdQPFlag(true);
155  }
156
157  if ( pCtu->getSlice()->getUseChromaQpAdj() )
158  {
159    setIsChromaQpAdjCoded(true);
160  }
161 
162  // start from the top level CU
163  xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment);
164}
165
166/**
167 Decoding process for a CTU.
168 \param    pCtu                      [in/out] pointer to CTU data structure
169 */
170Void TDecCu::decompressCtu( TComDataCU* pCtu )
171{
172#if !NH_3D_IV_MERGE
173  xDecompressCU( pCtu, 0,  0 );
174#endif
175}
176
177// ====================================================================================================================
178// Protected member functions
179// ====================================================================================================================
180
181//! decode end-of-slice flag
182Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx )
183{
184  UInt uiIsLastCtuOfSliceSegment;
185
186  if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx))
187  {
188    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment );
189  }
190  else
191  {
192    uiIsLastCtuOfSliceSegment=0;
193  }
194
195  return uiIsLastCtuOfSliceSegment>0;
196}
197
198//! decode CU block recursively
199Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment)
200{
201  TComPic* pcPic        = pcCU->getPic();
202  const TComSPS &sps    = pcPic->getPicSym()->getSPS();
203  const TComPPS &pps    = pcPic->getPicSym()->getPPS();
204  const UInt maxCuWidth = sps.getMaxCUWidth();
205  const UInt maxCuHeight= sps.getMaxCUHeight();
206  UInt uiCurNumParts    = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1);
207  UInt uiQNumParts      = uiCurNumParts>>2;
208
209
210  Bool bBoundary = false;
211  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
212  UInt uiRPelX   = uiLPelX + (maxCuWidth>>uiDepth)  - 1;
213  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
214  UInt uiBPelY   = uiTPelY + (maxCuHeight>>uiDepth) - 1;
215#if H_MV_ENC_DEC_TRAC
216  DTRACE_CU_S("=========== coding_quadtree ===========\n")
217  DTRACE_CU("x0", uiLPelX)
218  DTRACE_CU("x1", uiTPelY)
219  DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth)
220  DTRACE_CU("cqtDepth"  , uiDepth)
221#endif
222
223  if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) )
224  {
225    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
226  }
227  else
228  {
229    bBoundary = true;
230  }
231  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
232  {
233    UInt uiIdx = uiAbsPartIdx;
234    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
235    {
236      setdQPFlag(true);
237      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
238    }
239
240    if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
241    {
242      setIsChromaQpAdjCoded(true);
243    }
244
245    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
246    {
247      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
248      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
249
250      if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
251      {
252        xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment );
253      }
254      else
255      {
256        pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
257      }
258
259      uiIdx += uiQNumParts;
260    }
261    if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP())
262    {
263      if ( getdQPFlag() )
264      {
265        UInt uiQPSrcPartIdx = uiAbsPartIdx;
266        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
267      }
268    }
269    return;
270  }
271
272#if H_MV_ENC_DEC_TRAC
273  DTRACE_CU_S("=========== coding_unit ===========\n")
274#if H_MV_ENC_DEC_TRAC
275#if ENC_DEC_TRACE
276    stopAtPos  ( pcCU->getSlice()->getPOC(), 
277    pcCU->getSlice()->getLayerId(), 
278    uiLPelX,
279    uiTPelY,
280    uiRPelX-uiLPelX+1, 
281    uiBPelY-uiTPelY+1);
282#endif
283#endif
284
285#endif
286
287  if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP())
288  {
289    setdQPFlag(true);
290    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
291  }
292#if NH_3D_NBDV
293  DisInfo DvInfo; 
294  DvInfo.m_acNBDV.setZero();
295  DvInfo.m_aVIdxCan = 0;
296#if NH_3D_NBDV_REF 
297  DvInfo.m_acDoNBDV.setZero();
298#endif
299 
300if(!pcCU->getSlice()->isIntra())
301  {
302#if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
303    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
304#else
305#if NH_3D_IV_MERGE && NH_3D_VSP
306    if( pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
307#else
308#if NH_3D_ARP && NH_3D_VSP
309    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
310#else
311#if NH_3D_VSP
312    if( pcCU->getSlice()->getViewSynthesisPredFlag() )
313#else
314#if H_3D_ARP
315    if( pcCU->getSlice()->getIvResPredFlag( ) )
316#else
317#if H_3D_IV_MERGE
318    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
319#else
320#if NH_3D_DBBP
321    if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )
322#else
323    if (0)
324#endif
325#endif
326#endif
327#endif
328#endif
329#endif
330#endif
331    {
332      m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true);
333      m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
334      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
335      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
336      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
337      m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth));
338      m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth));
339      m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);     
340#if NH_3D_IV_MERGE
341      if( pcCU->getSlice()->getIsDepth())
342      {
343        m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo);
344      }
345      else
346      {
347#endif
348#if NH_3D_NBDV_REF
349      if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
350      {
351        m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
352      }
353      else
354#endif
355      {
356        m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
357      }
358#if NH_3D_IV_MERGE
359      }
360#endif
361#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
362      if ( g_decTraceDispDer )
363      {
364        DTRACE_CU( "RefViewIdx",  DvInfo.m_aVIdxCan );       
365        DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() );
366        DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() );
367        DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() );
368        DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() );
369      }
370#endif
371      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
372      m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth);
373      m_ppcCU[uiDepth]->setWidth(0, cWidTemp);
374      m_ppcCU[uiDepth]->setHeight(0, cHeightTemp);
375     }
376  }
377#endif
378
379  if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() )
380  {
381    setIsChromaQpAdjCoded(true);
382  }
383
384  if (pps.getTransquantBypassEnableFlag())
385  {
386    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
387  }
388
389  // decode CU mode and the partition size
390  if( !pcCU->getSlice()->isIntra())
391  {
392    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
393  }
394
395
396  if( pcCU->isSkipped(uiAbsPartIdx) )
397  {
398#if H_MV_ENC_DEC_TRAC
399    DTRACE_PU_S("=========== prediction_unit ===========\n")
400    DTRACE_PU("x0", uiLPelX)
401    DTRACE_PU("x1", uiTPelY)
402#endif
403    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
404    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
405#if NH_3D_IV_MERGE
406    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
407    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
408    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
409#else
410#if NH_3D_MLC
411    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
412    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
413#else
414    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
415    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
416#endif
417#endif
418    Int numValidMergeCand = 0;
419    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
420    {
421      uhInterDirNeighbours[ui] = 0;
422    }
423    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
424    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
425#if NH_3D_ARP
426    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
427#endif
428#if NH_3D_IC
429    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
430#endif
431
432
433#if NH_3D_VSP
434    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
435    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
436#endif
437#if NH_3D_SPIVMP
438    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
439    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
440    TComMvField*  pcMvFieldSP;
441    UChar* puhInterDirSP;
442    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 
443    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 
444#endif
445
446#if NH_3D_MLC
447    m_ppcCU[uiDepth]->initAvailableFlags();
448#endif
449    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
450#if NH_3D_MLC
451    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
452#if NH_3D_SPIVMP
453      , pcMvFieldSP, puhInterDirSP
454#endif
455      , numValidMergeCand, uiMergeIndex );
456
457    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
458#if NH_3D_VSP
459      , vspFlag
460#endif
461#if NH_3D_SPIVMP
462      , bSPIVMPFlag
463#endif
464      , numValidMergeCand );
465#endif
466#if NH_3D_VSP
467    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
468#endif
469
470    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
471
472    TComMv cTmpMv( 0, 0 );
473    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
474    {
475      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
476      {
477        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
478        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
479        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
480        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
481#if NH_3D_VSP
482        if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
483        {
484          if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
485          {
486            UInt dummy;
487            Int vspSize;
488            Int width, height;
489            m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height );
490            m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
491            pcCU->setVSPFlag( uiAbsPartIdx, vspSize );
492          }
493        }
494#endif
495#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
496        if ( g_decTraceMvFromMerge )
497        {       
498          if ( uiRefListIdx == 0 )
499          {
500            DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
501            DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
502            DTRACE_PU( "refIdxL0   ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
503          }
504          else
505          {
506            DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
507            DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
508            DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
509          }
510        }
511#endif
512      }
513    }
514#if NH_3D_SPIVMP
515    pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
516    if (bSPIVMPFlag[uiMergeIndex])
517    {
518      UInt uiSPAddr;
519      Int iWidth = pcCU->getWidth(uiAbsPartIdx);
520      Int iHeight = pcCU->getHeight(uiAbsPartIdx);
521
522      Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
523
524      pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
525
526      for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
527      {
528        pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
529        pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
530        pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
531        pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
532      }
533    }
534    delete[] pcMvFieldSP;
535    delete[] puhInterDirSP;
536#endif
537
538    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
539#if NH_3D_IV_MERGE
540    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
541#endif
542
543    return;
544  }
545#if NH_3D_DIS
546  m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth );
547  if(!pcCU->getDISFlag(uiAbsPartIdx))
548  {
549#endif
550
551  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
552  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
553
554  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
555  {
556    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
557
558    if(pcCU->getIPCMFlag(uiAbsPartIdx))
559    {
560#if NH_3D_SDC_INTRA
561      m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
562#endif
563      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
564#if NH_3D_IV_MERGE
565      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
566#endif
567      return;
568    }
569  }
570
571  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
572  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
573
574  // Coefficient decoding
575  Bool bCodeDQP = getdQPFlag();
576  Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded();
577  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded );
578  setIsChromaQpAdjCoded( isChromaQpAdjCoded );
579  setdQPFlag( bCodeDQP );
580#if NH_3D_DIS
581  }
582#endif
583  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
584#if NH_3D_IV_MERGE
585  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
586#endif
587}
588
589Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment)
590{
591  if(  pcCU->getSlice()->getPPS()->getUseDQP())
592  {
593    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
594  }
595
596  if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded())
597  {
598    pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP
599  }
600
601  isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx );
602}
603
604Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx,  UInt uiDepth )
605{
606  TComPic* pcPic = pCtu->getPic();
607#if !NH_3D_IV_MERGE
608  TComSlice * pcSlice = pCtu->getSlice();
609  const TComSPS &sps=*(pcSlice->getSPS());
610
611  Bool bBoundary = false;
612  UInt uiLPelX   = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
613  UInt uiRPelX   = uiLPelX + (sps.getMaxCUWidth()>>uiDepth)  - 1;
614  UInt uiTPelY   = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
615  UInt uiBPelY   = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1;
616
617  if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) )
618  {
619    bBoundary = true;
620  }
621
622  if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary )
623  {
624    UInt uiNextDepth = uiDepth + 1;
625    UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1);
626    UInt uiIdx = uiAbsPartIdx;
627    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
628    {
629      uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
630      uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
631
632      if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) )
633      {
634        xDecompressCU(pCtu, uiIdx, uiNextDepth );
635      }
636
637      uiIdx += uiQNumParts;
638    }
639    return;
640  }
641#endif
642  // Residual reconstruction
643  m_ppcYuvResi[uiDepth]->clear();
644
645  m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx );
646
647  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
648  {
649    case MODE_INTER:
650#if NH_3D_DBBP
651    if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
652    {
653      xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
654    }
655    else
656    {
657#endif
658#if H_3D_INTER_SDC
659      if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
660      {
661        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
662      }
663      else
664      {
665#endif
666      xReconInter( m_ppcCU[uiDepth], uiDepth );
667#if H_3D_INTER_SDC
668      }
669#endif
670#if NH_3D_DBBP
671    }
672#endif
673      break;
674    case MODE_INTRA:
675#if NH_3D
676#if NH_3D_DIS
677    if( m_ppcCU[uiDepth]->getDISFlag(0) )
678    {
679      xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
680    }
681#else
682    if(false )
683    {
684     // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
685    }
686#endif
687#if NH_3D_SDC_INTRA
688    else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
689    {
690      xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
691    }
692#endif
693    else
694#endif
695      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
696      break;
697    default:
698      assert(0);
699      break;
700  }
701
702#if DEBUG_STRING
703  const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0);
704  if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode))
705  {
706    PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0);
707    std::ostream &ss(std::cout);
708
709    ss <<"###: " << (predMode==MODE_INTRA?"Intra   ":"Inter   ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl;
710  }
711#endif
712
713  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
714  {
715    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
716  }
717
718  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
719}
720
721Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
722{
723
724  // inter prediction
725  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
726
727#if DEBUG_STRING
728  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER);
729  if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask)
730  {
731    printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth]));
732  }
733#endif
734
735  // inter recon
736  xDecodeInterTexture( pcCU, uiDepth );
737
738#if DEBUG_STRING
739  if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask)
740  {
741    printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth]));
742  }
743#endif
744
745  // clip for only non-zero cbp case
746  if  ( pcCU->getQtRootCbf( 0) )
747  {
748    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
749  }
750  else
751  {
752    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
753  }
754#if DEBUG_STRING
755  if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask)
756  {
757    printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth]));
758  }
759#endif
760
761}
762
763#if NH_3D_DIS
764Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
765{
766  UInt uiWidth        = pcCU->getWidth  ( 0 );
767  UInt uiHeight       = pcCU->getHeight ( 0 );
768
769  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
770
771  UInt    uiStride    = pcRecoYuv->getStride  (COMPONENT_Y);
772  Pel*    piReco      = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
773
774
775  AOF( uiWidth == uiHeight );
776  AOF( uiAbsPartIdx == 0 );
777
778  Bool  bAboveAvail = false;
779  Bool  bLeftAvail  = false;
780 
781  TComTURecurse rTu(pcCU, 0);
782  const ChromaFormat chFmt     = rTu.GetChromaFormat();
783
784  if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
785  {
786    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
787    m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
788    m_pcPrediction->predIntraAng( COMPONENT_Y,   VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions );
789  }
790  else if ( pcCU->getDISType(uiAbsPartIdx) == 1 )
791  {
792    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
793    m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
794    m_pcPrediction->predIntraAng( COMPONENT_Y,   HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions );
795  }
796  else if ( pcCU->getDISType(uiAbsPartIdx) == 2 )
797  {
798    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
799    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
800    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
801    {
802      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
803      {
804        piReco[ uiX ] = pSingleDepth;
805      }
806      piReco+= uiStride;
807    }
808  }
809  else if ( pcCU->getDISType(uiAbsPartIdx) == 3 )
810  {
811    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
812    pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
813    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
814    {
815      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
816      {
817        piReco[ uiX ] = pSingleDepth;
818      }
819      piReco+= uiStride;
820    }
821  }
822
823  // clear UV
824  UInt  uiStrideC     = pcRecoYuv->getStride(COMPONENT_Cb);
825  Pel   *pRecCb       = pcRecoYuv->getAddr(COMPONENT_Cb);
826  Pel   *pRecCr       = pcRecoYuv->getAddr(COMPONENT_Cr);
827
828  for (Int y=0; y<uiHeight/2; y++)
829  {
830    for (Int x=0; x<uiWidth/2; x++)
831    {
832      pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
833      pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
834    }
835
836    pRecCb += uiStrideC;
837    pRecCr += uiStrideC;
838  }
839}
840#endif
841#if H_3D_INTER_SDC
842Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
843{
844  // inter prediction
845  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
846
847  UInt  uiWidth      = pcCU->getWidth ( 0 );
848  UInt  uiHeight     = pcCU->getHeight( 0 );
849
850  Pel  *pResi;
851  UInt uiPelX, uiPelY;
852  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
853
854  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
855  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
856  {
857    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
858    {
859      pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
860    }
861    pResi += uiResiStride;
862  }
863
864  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
865
866  // clear UV
867  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
868  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
869  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
870
871  for (Int y = 0; y < uiHeight/2; y++)
872  {
873    for (Int x = 0; x < uiWidth/2; x++)
874    {
875      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
876      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
877    }
878
879    pRecCb += uiStrideC;
880    pRecCr += uiStrideC;
881  }
882}
883#endif
884
885#if NH_3D_DBBP
886Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
887{
888  AOF(!pcCU->getSlice()->getIsDepth());
889  AOF(!pcCU->getSlice()->isIntra());
890  PartSize ePartSize = pcCU->getPartitionSize( 0 );
891 
892  Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
893 
894  // get collocated depth block
895  UInt uiDepthStride = 0;
896#if H_3D_FCO
897  Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
898#else
899  Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
900#endif
901  AOF( pDepthPels != NULL );
902  AOF( uiDepthStride != 0 );
903 
904  // compute mask by segmenting depth block
905  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
906  Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU);
907  AOF(bValidMask);
908 
909  DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
910  TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
911 
912  // first, extract the two sets of motion parameters
913  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
914  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
915  {
916    UInt uiPartAddr = uiSegment*uiPUOffset;
917   
918    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
919    assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2  );  // only uni-prediction allowed
920   
921    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
922    {
923      RefPicList eRefList = (RefPicList)uiRefListIdx;
924      pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
925    }
926   
927#if H_3D
928    AOF( pcCU->getARPW(uiPartAddr) == 0 );
929    AOF( pcCU->getICFlag(uiPartAddr) == false );
930    AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
931    AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
932#endif
933  }
934 
935  // do motion compensation for each segment as 2Nx2N
936  pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
937  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
938  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
939  {
940    pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
941 
942    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
943    {
944      RefPicList eRefList = (RefPicList)uiRefListIdx;
945
946      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
947    }
948   
949    // inter prediction
950    m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
951  }
952 
953  // restore motion information in both segments again
954  pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
955  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
956  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
957  {
958    UInt uiPartAddr = uiSegment*uiPUOffset;
959   
960    pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
961    pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
962   
963    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
964    {
965      RefPicList eRefList = (RefPicList)uiRefListIdx;
966
967      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
968    }
969  }
970 
971  // reconstruct final prediction signal by combining both segments
972  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY);
973
974  // inter recon
975  xDecodeInterTexture( pcCU, uiDepth );
976 
977  // clip for only non-zero cbp case
978  if  ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) )
979  {
980    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
981  }
982  else
983  {
984    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
985  }
986}
987#endif
988
989
990Void
991TDecCu::xIntraRecBlk(       TComYuv*    pcRecoYuv,
992                            TComYuv*    pcPredYuv,
993                            TComYuv*    pcResiYuv,
994                      const ComponentID compID,
995                            TComTU     &rTu)
996{
997  if (!rTu.ProcessComponentSection(compID))
998  {
999    return;
1000  }
1001  const Bool       bIsLuma = isLuma(compID);
1002
1003
1004  TComDataCU *pcCU = rTu.getCU();
1005  const TComSPS &sps=*(pcCU->getSlice()->getSPS());
1006  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
1007
1008  const TComRectangle &tuRect  =rTu.getRect(compID);
1009  const UInt uiWidth           = tuRect.width;
1010  const UInt uiHeight          = tuRect.height;
1011  const UInt uiStride          = pcRecoYuv->getStride (compID);
1012        Pel* piPred            = pcPredYuv->getAddr( compID, uiAbsPartIdx );
1013  const ChromaFormat chFmt     = rTu.GetChromaFormat();
1014
1015  if (uiWidth != uiHeight)
1016  {
1017    //------------------------------------------------
1018
1019    //split at current level if dividing into square sub-TUs
1020
1021    TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
1022
1023    //recurse further
1024    do
1025    {
1026      xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse);
1027    } while (subTURecurse.nextSection(rTu));
1028
1029    //------------------------------------------------
1030
1031    return;
1032  }
1033
1034  const UInt uiChPredMode  = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx );
1035  const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize()));
1036  const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode;
1037  const UInt uiChFinalMode = ((chFmt == CHROMA_422)       && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode;
1038
1039  //===== init availability pattern =====
1040  const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
1041
1042#if DEBUG_STRING
1043  std::ostream &ss(std::cout);
1044#endif
1045
1046  DEBUG_STRING_NEW(sTemp)
1047  m_pcPrediction->initIntraPatternChType( rTu, compID, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
1048
1049
1050  //===== get prediction signal =====
1051#if NH_3D_DMM
1052  if( bIsLuma && isDmmMode( uiChFinalMode ) )
1053  {
1054    m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight );
1055  }
1056  else
1057  {
1058#endif
1059  m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions );
1060#if NH_3D_DMM
1061  }
1062#endif
1063
1064#if DEBUG_STRING
1065  ss << sTemp;
1066#endif
1067
1068  //===== inverse transform =====
1069  Pel*      piResi            = pcResiYuv->getAddr( compID, uiAbsPartIdx );
1070  TCoeff*   pcCoeff           = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx );
1071
1072  const QpParam cQP(*pcCU, compID);
1073
1074
1075  DEBUG_STRING_NEW(sDebug);
1076#if DEBUG_STRING
1077  const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
1078  std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
1079#endif
1080#if H_3D
1081  Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
1082
1083  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
1084#else
1085  if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0)
1086#endif
1087  {
1088    m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
1089  }
1090  else
1091  {
1092    for (UInt y = 0; y < uiHeight; y++)
1093    {
1094      for (UInt x = 0; x < uiWidth; x++)
1095      {
1096        piResi[(y * uiStride) + x] = 0;
1097      }
1098    }
1099  }
1100
1101#if DEBUG_STRING
1102  if (psDebug)
1103  {
1104    ss << (*psDebug);
1105  }
1106#endif
1107
1108  //===== reconstruction =====
1109  const UInt uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride(compID);
1110
1111  const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0);
1112  const Pel* pResiLuma  = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
1113  const Int  strideLuma = pcResiYuv->getStride( COMPONENT_Y );
1114
1115        Pel* pPred      = piPred;
1116        Pel* pResi      = piResi;
1117        Pel* pReco      = pcRecoYuv->getAddr( compID, uiAbsPartIdx );
1118        Pel* pRecIPred  = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
1119
1120
1121#if DEBUG_STRING
1122  const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1123  const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1124  const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
1125  if (bDebugPred || bDebugResi || bDebugReco)
1126  {
1127    ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl;
1128  }
1129#endif
1130
1131  const Int clipbd = sps.getBitDepth(toChannelType(compID));
1132#if O0043_BEST_EFFORT_DECODING
1133  const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd;
1134#endif
1135
1136  if( useCrossComponentPrediction )
1137  {
1138    TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true );
1139  }
1140
1141  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1142  {
1143#if DEBUG_STRING
1144    if (bDebugPred || bDebugResi || bDebugReco)
1145    {
1146      ss << "###: ";
1147    }
1148
1149    if (bDebugPred)
1150    {
1151      ss << " - pred: ";
1152      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1153      {
1154        ss << pPred[ uiX ] << ", ";
1155      }
1156    }
1157    if (bDebugResi)
1158    {
1159      ss << " - resi: ";
1160    }
1161#endif
1162
1163    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1164    {
1165#if DEBUG_STRING
1166      if (bDebugResi)
1167      {
1168        ss << pResi[ uiX ] << ", ";
1169      }
1170#endif
1171#if O0043_BEST_EFFORT_DECODING
1172      pReco    [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd );
1173#else
1174      pReco    [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd );
1175#endif
1176      pRecIPred[ uiX ] = pReco[ uiX ];
1177    }
1178#if DEBUG_STRING
1179    if (bDebugReco)
1180    {
1181      ss << " - reco: ";
1182      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1183      {
1184        ss << pReco[ uiX ] << ", ";
1185      }
1186    }
1187
1188    if (bDebugPred || bDebugResi || bDebugReco)
1189    {
1190      ss << "\n";
1191    }
1192#endif
1193    pPred     += uiStride;
1194    pResi     += uiStride;
1195    pReco     += uiStride;
1196    pRecIPred += uiRecIPredStride;
1197  }
1198}
1199
1200Void
1201TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
1202{
1203  if (pcCU->getIPCMFlag(0))
1204  {
1205    xReconPCM( pcCU, uiDepth );
1206    return;
1207  }
1208  const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1;
1209  for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++)
1210  {
1211    const ChannelType chanType=ChannelType(chType);
1212    const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true;
1213    const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 );
1214
1215    TComTURecurse tuRecurseCU(pcCU, 0);
1216    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT);
1217
1218    do
1219    {
1220      xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU );
1221    } while (tuRecurseWithPU.nextSection(tuRecurseCU));
1222  }
1223}
1224
1225#if NH_3D_SDC_INTRA
1226Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1227{
1228  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
1229  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
1230  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
1231
1232  UInt uiWidth        = pcCU->getWidth ( 0 );
1233  UInt uiHeight       = pcCU->getHeight( 0 );
1234  UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );
1235  const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
1236  const TComSPS     &sps    = *(pcCU->getSlice()->getSPS());
1237  const ChromaFormat chFmt  = pcCU->getPic()->getChromaFormat();
1238
1239  UInt sdcDepth = 0;
1240  UInt uiStride;
1241  Pel* piReco;
1242  Pel* piPred;
1243  Pel* piResi;
1244
1245  Pel* piRecIPred;
1246  UInt uiRecIPredStride;
1247 
1248  Pel apDCPredValues[2];
1249  UInt uiNumSegments;
1250
1251  Bool* pbMask = NULL;
1252  UInt uiMaskStride = 0;
1253
1254#if NH_3D_DMM
1255  if( isDmmMode( uiLumaPredMode ) )
1256  {
1257    assert( uiWidth == uiHeight  );
1258    assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE );
1259    assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) );
1260
1261    uiNumSegments     = 2;
1262
1263    uiStride          = pcRecoYuv->getStride( COMPONENT_Y );
1264    piReco            = pcRecoYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1265    piPred            = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1266    piResi            = pcResiYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdx );
1267
1268    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getAddr  ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx );
1269    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y );
1270
1271    //===== init availability pattern =====
1272    TComTURecurse tuRecurseCU(pcCU, 0);
1273    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT);
1274
1275    m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) );
1276
1277    // get partition
1278    pbMask       = new Bool[ uiWidth*uiHeight ];
1279    uiMaskStride = uiWidth;
1280    switch( getDmmType( uiLumaPredMode ) )
1281    {
1282    case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break;
1283    case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask );                                     } break;
1284    default: assert(0);
1285    }
1286
1287    // get predicted partition values
1288    Pel predDC1 = 0, predDC2 = 0;
1289    m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 );
1290
1291    // set prediction signal
1292    Pel* pDst = piPred;
1293    m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 );
1294    apDCPredValues[0] = predDC1;
1295    apDCPredValues[1] = predDC2;
1296  }
1297  else // regular HEVC intra modes
1298  {
1299#endif
1300    uiNumSegments = 1;
1301
1302    if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
1303    {
1304      sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
1305    }
1306   
1307    //===== loop over partitions =====
1308    TComTURecurse tuRecurseCU(pcCU, 0);
1309    TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT);
1310
1311    do
1312    {
1313      const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y);
1314      const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU();
1315     
1316      Pel* piPredTU       = pcPredYuv->getAddr  ( COMPONENT_Y, uiAbsPartIdxTU );
1317      UInt uiStrideTU     = pcPredYuv->getStride( COMPONENT_Y );
1318     
1319      Pel* piRecIPredTU   = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU );
1320      UInt uiRecIPredStrideTU  = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
1321     
1322      const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
1323     
1324      //===== init pattern for luma prediction =====
1325     
1326      m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter  DEBUG_STRING_PASS_INTO(sTemp) );
1327     
1328      m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, 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.