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

Last change on this file since 1233 was 1233, checked in by etri-htm, 9 years ago

Reactive_MLC (the MACRO is "NH_3D_MLC")

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