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

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