source: 3DVCSoftware/branches/HTM-11.2-dev3-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp

Last change on this file was 983, checked in by mediatek-htm, 11 years ago

Integration of Single Depth Mode proposed in JCT3V-I0095.
The MACRO is "MTK_SINGLE_DEPTH_MODE_I0095".

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

  • Property svn:eol-style set to native
File size: 57.3 KB
RevLine 
[5]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
[56]4 * granted under this license. 
[5]5 *
[872]6* Copyright (c) 2010-2014, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
34/** \file     TDecCu.cpp
35    \brief    CU decoder class
36*/
37
38#include "TDecCu.h"
39
[56]40//! \ingroup TLibDecoder
41//! \{
42
[2]43// ====================================================================================================================
44// Constructor / destructor / create / destroy
45// ====================================================================================================================
46
47TDecCu::TDecCu()
48{
[56]49  m_ppcYuvResi = NULL;
50  m_ppcYuvReco = NULL;
51  m_ppcCU      = NULL;
[833]52#if H_3D_DBBP
53  m_ppcYuvRecoDBBP = NULL;
54#endif
[2]55}
56
57TDecCu::~TDecCu()
58{
59}
60
61Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
62{
63  m_pcEntropyDecoder  = pcEntropyDecoder;
64  m_pcTrQuant         = pcTrQuant;
65  m_pcPrediction      = pcPrediction;
66}
67
68/**
69 \param    uiMaxDepth    total number of allowable depth
70 \param    uiMaxWidth    largest CU width
71 \param    uiMaxHeight   largest CU height
72 */
73Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
74{
75  m_uiMaxDepth = uiMaxDepth+1;
76 
[56]77  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
78  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
79  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
[833]80#if H_3D_DBBP
81  m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
82#endif
[2]83 
84  UInt uiNumPartitions;
85  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
86  {
87    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
88    UInt uiWidth  = uiMaxWidth  >> ui;
89    UInt uiHeight = uiMaxHeight >> ui;
90   
[56]91    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight );
92    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
93    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
[833]94#if H_3D_DBBP
95    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
96#endif
[2]97  }
98 
[56]99  m_bDecodeDQP = false;
100
[2]101  // initialize partition order.
102  UInt* piTmp = &g_auiZscanToRaster[0];
103  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
104  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
105 
106  // initialize conversion matrix from partition index to pel
107  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
108}
109
110Void TDecCu::destroy()
111{
112  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
113  {
[56]114    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
115    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
116    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
[833]117#if H_3D_DBBP
118    m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
119#endif
[2]120  }
121 
[56]122  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
123  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
124  delete [] m_ppcCU     ; m_ppcCU      = NULL;
[833]125#if H_3D_DBBP
126  delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
127#endif
[2]128}
129
130// ====================================================================================================================
131// Public member functions
132// ====================================================================================================================
133
134/** \param    pcCU        pointer of CU data
135 \param    ruiIsLast   last data?
136 */
137Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
138{
[56]139  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
[2]140  {
[56]141    setdQPFlag(true);
[2]142  }
[56]143
[2]144  // start from the top level CU
[56]145  xDecodeCU( pcCU, 0, 0, ruiIsLast);
[2]146}
147
148/** \param    pcCU        pointer of CU data
149 */
150Void TDecCu::decompressCU( TComDataCU* pcCU )
151{
[773]152#if !H_3D_IV_MERGE
[608]153  xDecompressCU( pcCU, 0,  0 );
[724]154#endif
[2]155}
156
157// ====================================================================================================================
158// Protected member functions
159// ====================================================================================================================
160
[56]161/**decode end-of-slice flag
162 * \param pcCU
163 * \param uiAbsPartIdx
164 * \param uiDepth
165 * \returns Bool
166 */
[608]167Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)
168{
[56]169  UInt uiIsLast;
170  TComPic* pcPic = pcCU->getPic();
171  TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
172  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
173  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
174  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
[608]175  UInt uiGranularityWidth = g_uiMaxCUWidth;
[56]176  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
177  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
178
179  if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
180    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
181  {
182    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
183  }
184  else
185  {
186    uiIsLast=0;
187  }
188 
189  if(uiIsLast) 
190  {
[608]191    if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) 
[56]192    {
[608]193      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
[56]194    }
195    else 
196    {
197      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
[608]198      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
[56]199    }
200  }
201
202  return uiIsLast>0;
203}
204
[2]205/** decode CU block recursively
206 * \param pcCU
207 * \param uiAbsPartIdx
208 * \param uiDepth
209 * \returns Void
210 */
[56]211
212Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
[2]213{
214  TComPic* pcPic = pcCU->getPic();
215  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
216  UInt uiQNumParts      = uiCurNumParts>>2;
217 
218  Bool bBoundary = false;
219  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
220  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
221  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
222  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
[608]223#if H_MV_ENC_DEC_TRAC
224  DTRACE_CU_S("=========== coding_quadtree ===========\n")
225  DTRACE_CU("x0", uiLPelX)
226  DTRACE_CU("x1", uiTPelY)
227  DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth)
228  DTRACE_CU("cqtDepth"  , uiDepth)
229#endif
[833]230
[56]231  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
[608]232  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
[56]233  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
[2]234  {
[608]235    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
[2]236  }
237  else
238  {
239    bBoundary = true;
240  }
241 
242  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
243  {
244    UInt uiIdx = uiAbsPartIdx;
[56]245    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
246    {
247      setdQPFlag(true);
248      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
249    }
250
[2]251    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
252    {
253      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
254      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
255     
[608]256      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
[56]257      if ( bSubInSlice )
258      {
[608]259        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
[56]260        {
261          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
262        }
263        else
264        {
265          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
266        }
267      }
[2]268     
269      uiIdx += uiQNumParts;
270    }
[56]271    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
272    {
273      if ( getdQPFlag() )
274      {
275        UInt uiQPSrcPartIdx;
[608]276        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
[56]277        {
[608]278          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
[56]279        }
280        else
281        {
282          uiQPSrcPartIdx = uiAbsPartIdx;
283        }
284        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
285      }
286    }
[2]287    return;
288  }
289 
[608]290#if H_MV_ENC_DEC_TRAC
291  DTRACE_CU_S("=========== coding_unit ===========\n")
292#endif
293
[833]294
[884]295#if H_3D_DDD
[833]296      pcCU->setUseDDD( false, uiAbsPartIdx, uiDepth );
297#endif
298
[56]299  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
300  {
301    setdQPFlag(true);
302    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
303  }
[608]304#if H_3D_NBDV
305  DisInfo DvInfo; 
306  DvInfo.bDV = false;
307  DvInfo.m_acNBDV.setZero();
308  DvInfo.m_aVIdxCan = 0;
309#if H_3D_NBDV_REF 
310  DvInfo.m_acDoNBDV.setZero();
311#endif
312 
313 
314  if(!pcCU->getSlice()->isIntra())
315  {
316#if H_3D_ARP && H_3D_IV_MERGE
317    if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() ))
318#else
319#if H_3D_ARP
320    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
[443]321#else
[608]322#if H_3D_IV_MERGE
323    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
324#else
325    if (0)
[443]326#endif
327#endif
328#endif
[608]329    {
330      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
331      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
332      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
333      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
334      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
335      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
336      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
337      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
[773]338#if H_3D_IV_MERGE
[724]339      if( pcCU->getSlice()->getIsDepth())
340      {
[833]341        DvInfo.bDV = m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo);
[724]342      }
343      else
344      {
345#endif
[608]346#if H_3D_NBDV_REF
347      if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() ))  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
[622]348      {
[608]349        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
[622]350      }
[608]351      else
[56]352#endif
[622]353      {
[608]354        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
[622]355      }
[773]356#if H_3D_IV_MERGE
[724]357      }
358#endif
[622]359#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
360      if ( g_decTraceDispDer )
361      {
362        DTRACE_CU( "RefViewIdx",  DvInfo.m_aVIdxCan );       
363        DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() );
364        DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() );
365        DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() );
366        DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() );
367      }
368#endif
369
[608]370      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
371      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
372      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
373      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
374     }
375  }
376#endif
377  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
[2]378  {
[608]379    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
380  }
381 
382  // decode CU mode and the partition size
383  if( !pcCU->getSlice()->isIntra())
384  {
[2]385    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
386  }
[56]387 
[2]388  if( pcCU->isSkipped(uiAbsPartIdx) )
389  {
[608]390#if H_MV_ENC_DEC_TRAC
391    DTRACE_PU_S("=========== prediction_unit ===========\n")
392    DTRACE_PU("x0", uiLPelX)
393    DTRACE_PU("x1", uiTPelY)
394#endif
[2]395    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
396    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
[608]397#if H_3D_IV_MERGE
398    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
[56]399    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
400    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
401#else
[2]402    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
403    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
[608]404#endif
[56]405    Int numValidMergeCand = 0;
[608]406    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
[2]407    {
408      uhInterDirNeighbours[ui] = 0;
409    }
[608]410    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
411    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
[724]412#if H_3D_ARP
413    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
414#endif
[833]415#if H_3D_IC
416    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
417#endif
[724]418
[608]419#if H_3D_VSP
420    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
421    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
422    InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
[773]423#if H_3D_SPIVMP
[724]424    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
425    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
426    TComMvField*  pcMvFieldSP;
427    UChar* puhInterDirSP;
428    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
429    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
430#endif
431    m_ppcCU[uiDepth]->initAvailableFlags();
432    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
[950]433    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
434      , inheritedVSPDisInfo
[773]435#if H_3D_SPIVMP
[950]436      , pcMvFieldSP, puhInterDirSP
437#endif
[724]438      , numValidMergeCand, uiMergeIndex );
[950]439
440    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
441#if H_3D_SPIVMP
442      , bSPIVMPFlag
443#endif
444      , numValidMergeCand );
[608]445    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
[443]446#else
[773]447#if H_3D
[724]448    m_ppcCU[uiDepth]->initAvailableFlags();
[608]449    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
[724]450    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
451#else
452    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
[443]453#endif
[724]454#endif
[622]455#if H_3D_VSP
[608]456    if(vspFlag[uiMergeIndex])
[296]457    {
[608]458      pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth);
[443]459    }
460#endif
[56]461    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
462
[884]463#if H_3D_DDD
[833]464    if( uiMergeIndex == m_ppcCU[uiDepth]->getUseDDDCandIdx() )
465    {
466        assert( pcCU->getSlice()->getViewIndex() != 0 );
467        pcCU->setUseDDD( true, uiAbsPartIdx, 0, uiDepth );
468        pcCU->setDDDepthSubParts( m_ppcCU[uiDepth]->getDDTmpDepth(),uiAbsPartIdx, 0, uiDepth );
469    }
470#endif
471
[56]472    TComMv cTmpMv( 0, 0 );
473    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
474    {       
475      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
476      {
477        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
478        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
479        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
480        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
[884]481#if H_3D_VSP
[833]482        if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
483        {
484          if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
485          {
486            UInt dummy;
487            Int vspSize;
488            Int width, height;
489            m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height );
490            m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
491            pcCU->setVSPFlag( uiAbsPartIdx, vspSize );
492          }
493        }
494#endif
[622]495#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
496        if ( g_decTraceMvFromMerge )
497        {       
498          if ( uiRefListIdx == 0 )
499          {
500            DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
501            DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
502            DTRACE_PU( "refIdxL0   ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
503          }
504          else
505          {
506            DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
507            DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
508            DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
509          }
510        }
511#endif
[56]512      }
513    }
[773]514#if H_3D_SPIVMP
[724]515    pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
516    if (bSPIVMPFlag[uiMergeIndex])
517    {
518      UInt uiSPAddr;
519      Int iWidth = pcCU->getWidth(uiAbsPartIdx);
520      Int iHeight = pcCU->getHeight(uiAbsPartIdx);
521
522      Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
523
524      pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
525
526      for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
527      {
528        pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
529        pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
530        pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
531        pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
532      }
533    }
[735]534    delete[] pcMvFieldSP;
535    delete[] puhInterDirSP;
[724]536#endif
537
[56]538    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
[773]539#if H_3D_IV_MERGE
[724]540    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
541#endif
[2]542    return;
543  }
[983]544#if MTK_SINGLE_DEPTH_MODE_I0095
545  m_pcEntropyDecoder->decodeSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth );
546  if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
547  {
548#endif
[608]549  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
550  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
[2]551
[884]552#if H_3D_DIM_SDC
[833]553  m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
554#endif
[56]555  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
556  {
557    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
[2]558
[56]559    if(pcCU->getIPCMFlag(uiAbsPartIdx))
[2]560    {
[56]561      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
[773]562#if H_3D_IV_MERGE
[724]563      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
564#endif
[56]565      return;
566    }
567  }
568
569  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
570  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
571 
572  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
573  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
[2]574  // Coefficient decoding
[56]575  Bool bCodeDQP = getdQPFlag();
576  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
577  setdQPFlag( bCodeDQP );
[983]578#if MTK_SINGLE_DEPTH_MODE_I0095
579  }
580#endif
[56]581  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
[773]582#if H_3D_IV_MERGE
[724]583  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
584#endif
[2]585}
586
[56]587Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
588{
[608]589  if(  pcCU->getSlice()->getPPS()->getUseDQP())
[56]590  {
[608]591    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
[56]592  }
593
594  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
595}
596
[608]597Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
[2]598{
599  TComPic* pcPic = pcCU->getPic();
[773]600#if !H_3D_IV_MERGE
[2]601  Bool bBoundary = false;
602  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
603  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
604  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
605  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
606 
[56]607  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
608  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
[608]609  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
[56]610  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
[2]611  {
612    bBoundary = true;
613  }
614 
615  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
616  {
617    UInt uiNextDepth = uiDepth + 1;
618    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
619    UInt uiIdx = uiAbsPartIdx;
620    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
621    {
622      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
623      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
624     
[608]625      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
[56]626      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
627      {
[608]628        xDecompressCU(pcCU, uiIdx, uiNextDepth );
[56]629      }
[2]630     
631      uiIdx += uiQNumParts;
632    }
633    return;
634  }
[724]635#endif 
[2]636  // Residual reconstruction
637  m_ppcYuvResi[uiDepth]->clear();
638 
639  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
640 
[872]641#if H_MV_ENC_DEC_TRAC
642#if ENC_DEC_TRACE
643  stopAtPos  ( m_ppcCU[uiDepth]->getSlice()->getPOC(), 
644    m_ppcCU[uiDepth]->getSlice()->getLayerId(), 
645    m_ppcCU[uiDepth]->getCUPelX(),
646    m_ppcCU[uiDepth]->getCUPelY(),
647    m_ppcCU[uiDepth]->getWidth(0), 
648    m_ppcCU[uiDepth]->getHeight(0) );
649#endif
650#endif
651
[2]652  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
653  {
654    case MODE_INTER:
[833]655#if H_3D_DBBP
656      if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
657      {
658        xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
659      }
660      else
661      {
662#endif
[655]663#if H_3D_INTER_SDC
[833]664      if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
[608]665      {
666        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
667      }
668      else
669      {
670#endif
671      xReconInter( m_ppcCU[uiDepth], uiDepth );
[655]672#if H_3D_INTER_SDC
[608]673      }
674#endif
[833]675#if H_3D_DBBP
676      }
677#endif
[2]678      break;
679    case MODE_INTRA:
[983]680#if MTK_SINGLE_DEPTH_MODE_I0095
681      if( m_ppcCU[uiDepth]->getSingleDepthFlag(0) )
682        xReconIntraSingleDepth( m_ppcCU[uiDepth], 0, uiDepth );
[608]683#if H_3D_DIM_SDC
[983]684      else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
685        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
686#endif
687      else
688#else
689#if H_3D_DIM_SDC
[189]690      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
691        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
692      else
693#endif
[983]694#endif
[608]695      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
[2]696      break;
697    default:
698      assert(0);
699      break;
700  }
[56]701  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
702  {
[608]703    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
[56]704  }
[2]705 
706  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
707}
708
[608]709Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
[2]710{
711 
712  // inter prediction
713  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
[608]714 
[2]715  // inter recon
716  xDecodeInterTexture( pcCU, 0, uiDepth );
717 
718  // clip for only non-zero cbp case
719  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
720  {
721    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
722  }
723  else
724  {
[608]725    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
726  }
727}
[983]728#if MTK_SINGLE_DEPTH_MODE_I0095
729Void TDecCu::xReconIntraSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
730{
731  UInt uiWidth        = pcCU->getWidth  ( 0 );
732  UInt uiHeight       = pcCU->getHeight ( 0 );
[608]733
[983]734  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
735
736  UInt    uiStride    = pcRecoYuv->getStride  ();
737  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
738
739
740  AOF( uiWidth == uiHeight );
741  AOF( uiAbsPartIdx == 0 );
742
743  //construction of depth candidates
744  Pel testDepth;
745  Pel DepthNeighbours[5];
746  Int index =0;
747  for( Int i = 0; (i < 5) && (index<MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE) ; i++ )
748  {
749    if(!pcCU->getNeighDepth (0, uiAbsPartIdx, &testDepth, i))
750    {
751      continue;
752    }
753    DepthNeighbours[index]=testDepth;
754    index++;
755    for(Int j=0;j<index-1;j++)
756    {
757     if( (DepthNeighbours[index-1]==DepthNeighbours[j]) )
758     {
759       index--;
760       break;
761     }
762    }
763  }
764
765  if(index==0)
766  {
767    DepthNeighbours[index]=1<<(g_bitDepthY-1);
768    index++;
769  }
770
771  if(index==1)
772  {
773    DepthNeighbours[index]=ClipY(DepthNeighbours[0] + 1 );
774    index++;
775  }
776
777  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
778  {
779    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
780    {
781      piReco[ uiX ] =DepthNeighbours[(Int)pcCU->getSingleDepthValue(uiAbsPartIdx)];
782    }
783    piReco     += uiStride;
784  }
785
786  // clear UV
787  UInt  uiStrideC     = pcRecoYuv->getCStride();
788  Pel   *pRecCb       = pcRecoYuv->getCbAddr();
789  Pel   *pRecCr       = pcRecoYuv->getCrAddr();
790
791  for (Int y=0; y<uiHeight/2; y++)
792  {
793    for (Int x=0; x<uiWidth/2; x++)
794    {
795      pRecCb[x] = 1<<(g_bitDepthC-1);
796      pRecCr[x] = 1<<(g_bitDepthC-1);
797    }
798
799    pRecCb += uiStrideC;
800    pRecCr += uiStrideC;
801  }
802}
803#endif
[655]804#if H_3D_INTER_SDC
[608]805Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
806{
807  // inter prediction
808  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
809
810  UInt  uiWidth      = pcCU->getWidth ( 0 );
811  UInt  uiHeight     = pcCU->getHeight( 0 );
812
813  Pel  *pResi;
814  UInt uiPelX, uiPelY;
815  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
816
817  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
818  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
819  {
820    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
[2]821    {
[833]822      pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
[2]823    }
[608]824    pResi += uiResiStride;
[2]825  }
[608]826
827  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
828
829  // clear UV
830  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
831  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
832  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
833
834  for (Int y = 0; y < uiHeight/2; y++)
835  {
836    for (Int x = 0; x < uiWidth/2; x++)
837    {
838      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
839      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
840    }
841
842    pRecCb += uiStrideC;
843    pRecCr += uiStrideC;
844  }
[2]845}
[608]846#endif
[2]847
[833]848#if H_3D_DBBP
849Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
850{
851  AOF(!pcCU->getSlice()->getIsDepth());
852  AOF(!pcCU->getSlice()->isIntra());
853  PartSize ePartSize = pcCU->getPartitionSize( 0 );
854 
855  // get collocated depth block
856  UInt uiDepthStride = 0;
857  Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
858  AOF( pDepthPels != NULL );
859  AOF( uiDepthStride != 0 );
860 
861  // compute mask by segmenting depth block
862  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
863  Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask);
864  AOF(bValidMask);
865 
866  DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
867  TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
868 
869  // first, extract the two sets of motion parameters
870  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
871  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
872  {
873    UInt uiPartAddr = uiSegment*uiPUOffset;
874   
875    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
876   
877    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
878    {
879      RefPicList eRefList = (RefPicList)uiRefListIdx;
880      pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
881    }
882   
[950]883    AOF( pcCU->getARPW(uiPartAddr) == 0 );
884    AOF( pcCU->getICFlag(uiPartAddr) == false );
885    AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
886    AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
[833]887  }
888 
889  // do motion compensation for each segment as 2Nx2N
890  pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
891  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
892  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
893  {
894    pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
[976]895 
[833]896    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
897    {
898      RefPicList eRefList = (RefPicList)uiRefListIdx;
899
900      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
901    }
902   
903    // inter prediction
904    m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
905  }
906 
907  // restore motion information in both segments again
908  pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
909  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
910  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
911  {
912    UInt uiPartAddr = uiSegment*uiPUOffset;
913   
914    pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
915    pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
916   
917    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
918    {
919      RefPicList eRefList = (RefPicList)uiRefListIdx;
920
921      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
922    }
923  }
924 
925  // reconstruct final prediction signal by combining both segments
926  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0));
927 
928  // inter recon
929  xDecodeInterTexture( pcCU, 0, uiDepth );
930 
931  // clip for only non-zero cbp case
932  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
933  {
934    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
935  }
936  else
937  {
938    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
939  }
940}
941#endif
942
[2]943Void
944TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
945                         UInt        uiTrDepth,
946                         UInt        uiAbsPartIdx,
947                         TComYuv*    pcRecoYuv,
948                         TComYuv*    pcPredYuv, 
949                         TComYuv*    pcResiYuv )
950{
951  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
952  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
953  UInt    uiStride          = pcRecoYuv->getStride  ();
954  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
955  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
956  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
957 
958  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
959  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
960 
961  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
962 
963  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
964  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
965  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
[608]966  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
[2]967  //===== init availability pattern =====
968  Bool  bAboveAvail = false;
969  Bool  bLeftAvail  = false;
970  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
971  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
972                                     m_pcPrediction->getPredicBuf       (),
973                                     m_pcPrediction->getPredicBufWidth  (),
974                                     m_pcPrediction->getPredicBufHeight (),
975                                     bAboveAvail, bLeftAvail );
976 
[56]977  //===== get prediction signal =====
[608]978#if H_3D_DIM
979  if( isDimMode( uiLumaPredMode ) )
[2]980  {
[608]981    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
982  }
[2]983  else
[56]984  {
[2]985#endif
[608]986  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
987#if H_3D_DIM
[2]988  }
[56]989#endif
990 
[884]991#if H_3D
[872]992  Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
993
994  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag )
995#else
996  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) )
997#endif
998  {
[2]999  //===== inverse transform =====
[608]1000  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
[2]1001
[56]1002  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
[872]1003    assert(scalingListType < SCALING_LIST_NUM);
[608]1004  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
[56]1005
[2]1006 
1007  //===== reconstruction =====
[56]1008  Pel* pPred      = piPred;
1009  Pel* pResi      = piResi;
1010  Pel* pReco      = piReco;
1011  Pel* pRecIPred  = piRecIPred;
1012  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
[2]1013  {
[56]1014    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
[2]1015    {
[608]1016      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
[56]1017      pRecIPred[ uiX ] = pReco[ uiX ];
[2]1018    }
[56]1019    pPred     += uiStride;
1020    pResi     += uiStride;
1021    pReco     += uiStride;
1022    pRecIPred += uiRecIPredStride;
[2]1023  }
1024}
[872]1025  else
1026  {
1027    //===== reconstruction =====
1028    Pel* pPred      = piPred;
1029    Pel* pReco      = piReco;
1030    Pel* pRecIPred  = piRecIPred;
1031    for ( Int y = 0; y < uiHeight; y++ )
1032    {
1033      for ( Int x = 0; x < uiWidth; x++ )
1034      {
1035        pReco    [ x ] = pPred[ x ];
1036        pRecIPred[ x ] = pReco[ x ];
1037      }
1038      pPred     += uiStride;
1039      pReco     += uiStride;
1040      pRecIPred += uiRecIPredStride;
1041    }
1042  }
1043}
[2]1044
1045
1046Void
1047TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
1048                           UInt        uiTrDepth,
1049                           UInt        uiAbsPartIdx,
1050                           TComYuv*    pcRecoYuv,
1051                           TComYuv*    pcPredYuv, 
1052                           TComYuv*    pcResiYuv,
1053                           UInt        uiChromaId )
1054{
1055  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
1056  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
[56]1057
1058  if( uiLog2TrSize == 2 )
[2]1059  {
1060    assert( uiTrDepth > 0 );
1061    uiTrDepth--;
1062    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
1063    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
1064    if( !bFirstQ )
1065    {
1066      return;
1067    }
1068  }
1069 
1070  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
1071  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
1072  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
1073  UInt      uiStride          = pcRecoYuv->getCStride ();
1074  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
1075  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
1076  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
1077 
1078  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
1079  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
1080 
1081  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
1082 
1083  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1084  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
1085  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
[608]1086  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
[2]1087  //===== init availability pattern =====
1088  Bool  bAboveAvail = false;
1089  Bool  bLeftAvail  = false;
1090  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
[56]1091
[608]1092  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
[2]1093                                           m_pcPrediction->getPredicBuf       (),
1094                                           m_pcPrediction->getPredicBufWidth  (),
1095                                           m_pcPrediction->getPredicBufHeight (),
1096                                           bAboveAvail, bLeftAvail );
1097  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
1098 
1099  //===== get prediction signal =====
1100  {
[56]1101    if( uiChromaPredMode == DM_CHROMA_IDX )
[2]1102    {
[56]1103      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
[608]1104#if H_3D_DIM
1105      mapDepthModeToIntraDir( uiChromaPredMode );
[56]1106#endif
[2]1107    }
[608]1108    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
[2]1109  }
1110
[872]1111  if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) )
1112  {
[2]1113  //===== inverse transform =====
[608]1114  Int curChromaQpOffset;
[56]1115  if(eText == TEXT_CHROMA_U)
1116  {
[608]1117    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
[56]1118  }
1119  else
1120  {
[608]1121    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
[56]1122  }
[608]1123  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
[2]1124
[56]1125  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
[872]1126    assert(scalingListType < SCALING_LIST_NUM);
[608]1127  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
[56]1128
[2]1129  //===== reconstruction =====
[56]1130  Pel* pPred      = piPred;
1131  Pel* pResi      = piResi;
1132  Pel* pReco      = piReco;
1133  Pel* pRecIPred  = piRecIPred;
1134  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
[2]1135  {
[56]1136    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
[2]1137    {
[608]1138      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
[56]1139      pRecIPred[ uiX ] = pReco[ uiX ];
[2]1140    }
[56]1141    pPred     += uiStride;
1142    pResi     += uiStride;
1143    pReco     += uiStride;
1144    pRecIPred += uiRecIPredStride;
[2]1145  }
1146}
[872]1147  else
1148  {
1149    //===== reconstruction =====
1150    Pel* pPred      = piPred;
1151    Pel* pReco      = piReco;
1152    Pel* pRecIPred  = piRecIPred;
1153    for ( Int y = 0; y < uiHeight; y++ )
1154    {
1155      for ( Int x = 0; x < uiWidth; x++ )
1156      {
1157        pReco    [ x ] = pPred[ x ];
1158        pRecIPred[ x ] = pReco[ x ];
1159      }
1160      pPred     += uiStride;
1161      pReco     += uiStride;
1162      pRecIPred += uiRecIPredStride;
1163    }   
1164  }
1165}
[2]1166
1167
1168Void
[608]1169TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
[2]1170{
1171  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
[964]1172  UInt  uiNumPart     = pcCU->getNumPartitions();
[2]1173  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
1174 
[56]1175  if (pcCU->getIPCMFlag(0))
1176  {
[608]1177    xReconPCM( pcCU, uiDepth );
[56]1178    return;
1179  }
1180
[2]1181  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
1182  {
1183    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
1184  } 
1185
1186  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
1187  {
1188    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
1189  }
1190
1191}
1192
[608]1193#if H_3D_DIM_SDC
[189]1194Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1195{
1196  UInt uiWidth        = pcCU->getWidth  ( 0 );
1197  UInt uiHeight       = pcCU->getHeight ( 0 );
[833]1198  TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
1199  UInt numParts = 1;
1200  UInt sdcDepth    = 0;
1201  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
1202  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
1203  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
1204
1205  UInt    uiStride = 0;
1206  Pel*    piReco;
1207  Pel*    piPred;
1208  Pel*    piResi;
1209
1210  UInt    uiZOrder;       
1211  Pel*    piRecIPred;     
1212  UInt    uiRecIPredStride;
1213
1214  UInt    uiLumaPredMode = 0; 
1215
1216  if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1)
1217  {
1218    numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
1219    sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
1220    uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
1221  }
1222
[884]1223  for ( Int i = 0; i < numParts; i++ )
[833]1224  {
1225    uiStride    = pcRecoYuv->getStride  ();
1226    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
1227    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
1228    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
[884]1229
[833]1230    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1231    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
1232    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
1233
1234    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
1235
1236    AOF( uiWidth == uiHeight );
[884]1237
1238    //===== init availability pattern =====
1239    Bool  bAboveAvail = false;
1240    Bool  bLeftAvail  = false;
1241
1242    pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
1243    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
1244
1245    TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
1246    //===== get prediction signal =====
1247    if( isDimMode( uiLumaPredMode ) )
1248    {
1249      m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation  );
1250      Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
1251      Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
1252      for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 
1253      { 
1254        dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
1255      }
[833]1256    }
[884]1257    else
1258    {
1259      m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
1260    }
1261
[833]1262    if ( numParts > 1 )
1263    {
1264      for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1265      {
1266        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1267        {
1268          piReco        [ uiX ] = ClipY( piPred[ uiX ] );
1269          piRecIPred    [ uiX ] = piReco[ uiX ];
1270        }
1271        piPred     += uiStride;
1272        piReco     += uiStride;
1273        piRecIPred += uiRecIPredStride;
1274      }
1275    }
1276    uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 );
1277    dmm4Segmentation->destroy(); delete dmm4Segmentation;
1278  }
1279  uiAbsPartIdx = 0;
[189]1280 
[833]1281  if ( numParts > 1 )
1282  {
1283    uiWidth = pcCU->getWidth( 0 );
1284    uiHeight = pcCU->getHeight( 0 );
1285  }
1286  piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
1287  piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
1288  piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
1289  uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1290  piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
1291  uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
[189]1292  // number of segments depends on prediction mode
[608]1293  UInt uiNumSegments = 1;
[189]1294  Bool* pbMask = NULL;
1295  UInt uiMaskStride = 0;
1296 
[608]1297  if( getDimType( uiLumaPredMode ) == DMM1_IDX )
[189]1298  {
[608]1299    Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
[189]1300   
[608]1301    WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
[189]1302    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
1303   
1304    uiNumSegments = 2;
1305    pbMask = pcWedgelet->getPattern();
1306    uiMaskStride = pcWedgelet->getStride();
1307  }
[833]1308  if( getDimType( uiLumaPredMode ) == DMM4_IDX )
1309  {
1310    uiNumSegments = 2;
1311    pbMask  = dmm4SegmentationOrg->getPattern();
1312    uiMaskStride = dmm4SegmentationOrg->getStride();
1313  }
[189]1314  // get DC prediction for each segment
1315  Pel apDCPredValues[2];
[950]1316  if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
1317  {
1318    apDCPredValues[0] = pcCU->getDmmPredictor( 0 );
1319    apDCPredValues[1] = pcCU->getDmmPredictor( 1 );
1320  }
1321  else
[976]1322  {
1323    m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
1324  }
[189]1325 
1326  // reconstruct residual based on mask + DC residuals
1327  Pel apDCResiValues[2];
[608]1328  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
[189]1329  {
[608]1330#if H_3D_DIM_DLT
[758]1331    Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
1332    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1333    Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
1334
[608]1335    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
1336#else
1337    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
[443]1338#endif
[189]1339  }
1340 
1341  //===== reconstruction =====
1342  Bool*pMask      = pbMask;
1343  Pel* pPred      = piPred;
1344  Pel* pResi      = piResi;
1345  Pel* pReco      = piReco;
1346  Pel* pRecIPred  = piRecIPred;
1347 
1348  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1349  {
1350    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1351    {
1352      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1353      assert( ucSegment < uiNumSegments );
1354     
1355      Pel pResiDC = apDCResiValues[ucSegment];
1356     
[608]1357      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
[189]1358      pRecIPred[ uiX ] = pReco[ uiX ];
1359    }
1360    pPred     += uiStride;
1361    pResi     += uiStride;
1362    pReco     += uiStride;
1363    pRecIPred += uiRecIPredStride;
1364    pMask     += uiMaskStride;
1365  }
1366 
1367  // clear UV
1368  UInt  uiStrideC     = pcPredYuv->getCStride();
1369  Pel   *pRecCb       = pcPredYuv->getCbAddr();
1370  Pel   *pRecCr       = pcPredYuv->getCrAddr();
1371 
1372  for (Int y=0; y<uiHeight/2; y++)
1373  {
1374    for (Int x=0; x<uiWidth/2; x++)
1375    {
[608]1376      pRecCb[x] = 128;
1377      pRecCr[x] = 128;
[189]1378    }
1379   
1380    pRecCb += uiStrideC;
1381    pRecCr += uiStrideC;
1382  }
[833]1383  dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
[189]1384}
1385#endif
1386
[56]1387/** Function for deriving recontructed PU/CU Luma sample with QTree structure
[2]1388 * \param pcCU pointer of current CU
1389 * \param uiTrDepth current tranform split depth
1390 * \param uiAbsPartIdx  part index
1391 * \param pcRecoYuv pointer to reconstructed sample arrays
1392 * \param pcPredYuv pointer to prediction sample arrays
1393 * \param pcResiYuv pointer to residue sample arrays
1394 *
1395 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
1396 */
1397Void
1398TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
1399                     UInt        uiTrDepth,
1400                     UInt        uiAbsPartIdx,
1401                     TComYuv*    pcRecoYuv,
1402                     TComYuv*    pcPredYuv, 
1403                     TComYuv*    pcResiYuv )
1404{
1405  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1406  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1407  if( uiTrMode == uiTrDepth )
1408  {
1409    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1410  }
1411  else
1412  {
1413    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1414    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1415    {
1416      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1417    }
1418  }
1419}
1420
[56]1421/** Function for deriving recontructed PU/CU chroma samples with QTree structure
[2]1422 * \param pcCU pointer of current CU
1423 * \param uiTrDepth current tranform split depth
1424 * \param uiAbsPartIdx  part index
1425 * \param pcRecoYuv pointer to reconstructed sample arrays
1426 * \param pcPredYuv pointer to prediction sample arrays
1427 * \param pcResiYuv pointer to residue sample arrays
1428 *
1429 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1430 */
1431Void
1432TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1433                     UInt        uiTrDepth,
1434                     UInt        uiAbsPartIdx,
1435                     TComYuv*    pcRecoYuv,
1436                     TComYuv*    pcPredYuv, 
1437                     TComYuv*    pcResiYuv )
1438{
1439  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1440  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1441  if( uiTrMode == uiTrDepth )
1442  {
1443    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1444    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1445  }
1446  else
1447  {
1448    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1449    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1450    {
1451      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1452    }
1453  }
1454}
1455
1456Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1457{
1458  UInt uiCUAddr = pcCU->getAddr();
1459 
1460  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1461 
1462  return;
1463}
1464
1465Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1466{
1467  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1468  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1469  TCoeff* piCoeff;
1470 
1471  Pel*    pResi;
[608]1472  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
[2]1473 
1474  // Y
1475  piCoeff = pcCU->getCoeffY();
1476  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
[56]1477
[608]1478  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
[56]1479
[608]1480  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
[2]1481 
1482  // Cb and Cr
[608]1483  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
1484  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
[56]1485
[2]1486  uiWidth  >>= 1;
1487  uiHeight >>= 1;
1488  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
[608]1489  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
[56]1490
[608]1491  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
1492  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
[56]1493
[2]1494  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
[608]1495  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
[2]1496}
1497
[56]1498/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1499 * \param pcCU pointer to current CU
1500 * \param uiPartIdx part index
1501 * \param piPCM pointer to PCM code arrays
1502 * \param piReco pointer to reconstructed sample arrays
1503 * \param uiStride stride of reconstructed sample arrays
1504 * \param uiWidth CU width
1505 * \param uiHeight CU height
1506 * \param ttText texture component type
1507 * \returns Void
1508 */
1509Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1510{
1511  UInt uiX, uiY;
1512  Pel* piPicReco;
1513  UInt uiPicStride;
1514  UInt uiPcmLeftShiftBit; 
1515
1516  if( ttText == TEXT_LUMA )
1517  {
1518    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1519    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
[608]1520    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
[56]1521  }
1522  else
1523  {
1524    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1525
1526    if( ttText == TEXT_CHROMA_U )
1527    {
1528      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1529    }
1530    else
1531    {
1532      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1533    }
[608]1534    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
[56]1535  }
1536
1537  for( uiY = 0; uiY < uiHeight; uiY++ )
1538  {
1539    for( uiX = 0; uiX < uiWidth; uiX++ )
1540    {
1541      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1542      piPicReco[uiX] = piReco[uiX];
1543    }
1544    piPCM += uiWidth;
1545    piReco += uiStride;
1546    piPicReco += uiPicStride;
1547  }
1548}
1549
1550/** Function for reconstructing a PCM mode CU.
1551 * \param pcCU pointer to current CU
1552 * \param uiDepth CU Depth
1553 * \returns Void
1554 */
[608]1555Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
[56]1556{
1557  // Luma
1558  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1559  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1560
1561  Pel* piPcmY = pcCU->getPCMSampleY();
1562  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1563
1564  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1565
1566  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1567
1568  // Cb and Cr
1569  UInt uiCWidth  = (uiWidth>>1);
1570  UInt uiCHeight = (uiHeight>>1);
1571
1572  Pel* piPcmCb = pcCU->getPCMSampleCb();
1573  Pel* piPcmCr = pcCU->getPCMSampleCr();
1574  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1575  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1576
1577  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1578
1579  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1580  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1581}
1582
1583/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1584 * \param pcCU pointer to current CU
1585 * \param uiDepth CU Depth
1586 * \returns Void
1587 */
[608]1588Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
[56]1589{
1590  // Luma
1591  UInt width  = (g_uiMaxCUWidth >> depth);
1592  UInt height = (g_uiMaxCUHeight >> depth);
1593
1594  Pel* pPcmY = pCU->getPCMSampleY();
1595  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1596
1597  UInt stride = m_ppcYuvReco[depth]->getStride();
1598
1599  for(Int y = 0; y < height; y++ )
1600  {
1601    for(Int x = 0; x < width; x++ )
1602    {
1603      pPcmY[x] = pRecoY[x];
1604    }
1605    pPcmY += width;
1606    pRecoY += stride;
1607  }
1608
1609  // Cb and Cr
1610  UInt widthC  = (width>>1);
1611  UInt heightC = (height>>1);
1612
1613  Pel* pPcmCb = pCU->getPCMSampleCb();
1614  Pel* pPcmCr = pCU->getPCMSampleCr();
1615  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1616  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1617
1618  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1619
1620  for(Int y = 0; y < heightC; y++ )
1621  {
1622    for(Int x = 0; x < widthC; x++ )
1623    {
1624      pPcmCb[x] = pRecoCb[x];
1625      pPcmCr[x] = pRecoCr[x];
1626    }
1627    pPcmCr += widthC;
1628    pPcmCb += widthC;
1629    pRecoCb += strideC;
1630    pRecoCr += strideC;
1631  }
1632
1633}
1634
1635//! \}
Note: See TracBrowser for help on using the repository browser.