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

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

Reactive DoNBDV ( the MACRO is "NH_3D_NBDV_REF")

By Yi-Wen Chen (yiwen.chen@…)

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