source: 3DVCSoftware/branches/HTM-8.2-dev2-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp @ 1417

Last change on this file since 1417 was 669, checked in by zhang, 11 years ago

JCT3V-F0125

  • Property svn:eol-style set to native
File size: 44.2 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 *
[608]6 * Copyright (c) 2010-2013, 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;
[2]52}
53
54TDecCu::~TDecCu()
55{
56}
57
58Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
59{
60  m_pcEntropyDecoder  = pcEntropyDecoder;
61  m_pcTrQuant         = pcTrQuant;
62  m_pcPrediction      = pcPrediction;
63}
64
65/**
66 \param    uiMaxDepth    total number of allowable depth
67 \param    uiMaxWidth    largest CU width
68 \param    uiMaxHeight   largest CU height
69 */
70Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
71{
72  m_uiMaxDepth = uiMaxDepth+1;
73 
[56]74  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
75  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
76  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
[2]77 
78  UInt uiNumPartitions;
79  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
80  {
81    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
82    UInt uiWidth  = uiMaxWidth  >> ui;
83    UInt uiHeight = uiMaxHeight >> ui;
84   
[56]85    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight );
86    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
87    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
[2]88  }
89 
[56]90  m_bDecodeDQP = false;
91
[2]92  // initialize partition order.
93  UInt* piTmp = &g_auiZscanToRaster[0];
94  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
95  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
96 
97  // initialize conversion matrix from partition index to pel
98  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
99}
100
101Void TDecCu::destroy()
102{
103  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
104  {
[56]105    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
106    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
107    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
[2]108  }
109 
[56]110  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
111  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
112  delete [] m_ppcCU     ; m_ppcCU      = NULL;
[2]113}
114
115// ====================================================================================================================
116// Public member functions
117// ====================================================================================================================
118
119/** \param    pcCU        pointer of CU data
120 \param    ruiIsLast   last data?
121 */
122Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
123{
[56]124  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
[2]125  {
[56]126    setdQPFlag(true);
[2]127  }
[56]128
[2]129  // start from the top level CU
[56]130  xDecodeCU( pcCU, 0, 0, ruiIsLast);
[2]131}
132
133/** \param    pcCU        pointer of CU data
134 */
135Void TDecCu::decompressCU( TComDataCU* pcCU )
136{
[669]137#if !QC_DEPTH_IV_MRG_F0125
[608]138  xDecompressCU( pcCU, 0,  0 );
[669]139#endif
[2]140}
141
142// ====================================================================================================================
143// Protected member functions
144// ====================================================================================================================
145
[56]146/**decode end-of-slice flag
147 * \param pcCU
148 * \param uiAbsPartIdx
149 * \param uiDepth
150 * \returns Bool
151 */
[608]152Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)
153{
[56]154  UInt uiIsLast;
155  TComPic* pcPic = pcCU->getPic();
156  TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
157  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
158  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
159  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
[608]160  UInt uiGranularityWidth = g_uiMaxCUWidth;
[56]161  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
162  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
163
164  if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
165    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
166  {
167    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
168  }
169  else
170  {
171    uiIsLast=0;
172  }
173 
174  if(uiIsLast) 
175  {
[608]176    if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) 
[56]177    {
[608]178      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
[56]179    }
180    else 
181    {
182      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
[608]183      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
[56]184    }
185  }
186
187  return uiIsLast>0;
188}
189
[2]190/** decode CU block recursively
191 * \param pcCU
192 * \param uiAbsPartIdx
193 * \param uiDepth
194 * \returns Void
195 */
[56]196
197Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
[2]198{
199  TComPic* pcPic = pcCU->getPic();
200  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
201  UInt uiQNumParts      = uiCurNumParts>>2;
202 
203  Bool bBoundary = false;
204  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
205  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
206  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
207  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
[608]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", g_uiMaxCUWidth>>uiDepth)
213  DTRACE_CU("cqtDepth"  , uiDepth)
214#endif
[56]215  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
[608]216  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
[56]217  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
[2]218  {
[608]219    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
[2]220  }
221  else
222  {
223    bBoundary = true;
224  }
225 
226  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
227  {
228    UInt uiIdx = uiAbsPartIdx;
[56]229    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
230    {
231      setdQPFlag(true);
232      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
233    }
234
[2]235    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
236    {
237      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
238      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
239     
[608]240      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
[56]241      if ( bSubInSlice )
242      {
[608]243        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
[56]244        {
245          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
246        }
247        else
248        {
249          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
250        }
251      }
[2]252     
253      uiIdx += uiQNumParts;
254    }
[56]255    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
256    {
257      if ( getdQPFlag() )
258      {
259        UInt uiQPSrcPartIdx;
[608]260        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
[56]261        {
[608]262          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
[56]263        }
264        else
265        {
266          uiQPSrcPartIdx = uiAbsPartIdx;
267        }
268        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
269      }
270    }
[2]271    return;
272  }
273 
[608]274#if H_MV_ENC_DEC_TRAC
275  DTRACE_CU_S("=========== coding_unit ===========\n")
276#endif
277
[56]278  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
279  {
280    setdQPFlag(true);
281    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
282  }
[608]283#if H_3D_NBDV
284  DisInfo DvInfo; 
285  DvInfo.bDV = false;
286  DvInfo.m_acNBDV.setZero();
287  DvInfo.m_aVIdxCan = 0;
288#if H_3D_NBDV_REF 
289  DvInfo.m_acDoNBDV.setZero();
290#endif
291 
292 
293  if(!pcCU->getSlice()->isIntra())
294  {
295#if H_3D_ARP && H_3D_IV_MERGE
296    if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() ))
297#else
298#if H_3D_ARP
299    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
[443]300#else
[608]301#if H_3D_IV_MERGE
302    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
303#else
304    if (0)
[443]305#endif
306#endif
307#endif
[608]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 );     
[669]317#if QC_DEPTH_IV_MRG_F0125
318      if( pcCU->getSlice()->getIsDepth())
319      {
320        DvInfo.bDV = m_ppcCU[uiDepth]->getDispNeighBlocks(0, 0, &DvInfo);
321      }
322      else
323      {
324#endif
[608]325#if H_3D_NBDV_REF
326      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]327      {
[608]328        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
[622]329      }
[608]330      else
[56]331#endif
[622]332      {
[608]333        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
[622]334      }
[669]335#if QC_DEPTH_IV_MRG_F0125
336      }
337#endif
[622]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
[608]349      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
350      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
351      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
352      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
353     }
354  }
355#endif
356  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
[2]357  {
[608]358    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
359  }
360 
361  // decode CU mode and the partition size
362  if( !pcCU->getSlice()->isIntra())
363  {
[2]364    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
365  }
[56]366 
[2]367  if( pcCU->isSkipped(uiAbsPartIdx) )
368  {
[608]369#if H_MV_ENC_DEC_TRAC
370    DTRACE_PU_S("=========== prediction_unit ===========\n")
371    DTRACE_PU("x0", uiLPelX)
372    DTRACE_PU("x1", uiTPelY)
373#endif
[2]374    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
375    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
[608]376#if H_3D_IV_MERGE
377    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
[56]378    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
379    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
380#else
[2]381    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
382    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
[608]383#endif
[56]384    Int numValidMergeCand = 0;
[608]385    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
[2]386    {
387      uhInterDirNeighbours[ui] = 0;
388    }
[608]389    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
390    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
[2]391
[608]392#if H_3D_VSP
393    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
394    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
395    InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
396    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand, uiMergeIndex );
397    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
[443]398#else
[608]399    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
[443]400#endif
[622]401#if H_3D_VSP
[608]402    if(vspFlag[uiMergeIndex])
[296]403    {
[608]404      pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth);
[443]405    }
406#endif
[56]407    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
408
409    TComMv cTmpMv( 0, 0 );
410    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
411    {       
412      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
413      {
414        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
415        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
416        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
417        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
[622]418#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
419        if ( g_decTraceMvFromMerge )
420        {       
421          if ( uiRefListIdx == 0 )
422          {
423            DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
424            DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
425            DTRACE_PU( "refIdxL0   ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
426          }
427          else
428          {
429            DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
430            DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
431            DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
432          }
433        }
434#endif
[56]435      }
436    }
[608]437#if H_3D_IC
[189]438    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
439#endif
[608]440#if H_3D_ARP
441    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
[56]442#endif
443    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
[669]444#if QC_DEPTH_IV_MRG_F0125
445    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
446#endif
[2]447    return;
448  }
449
[608]450  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
451  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
[2]452
[56]453  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
454  {
455    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
[2]456
[56]457    if(pcCU->getIPCMFlag(uiAbsPartIdx))
[2]458    {
[56]459      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
[669]460#if QC_DEPTH_IV_MRG_F0125
461      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
462#endif
[56]463      return;
464    }
465  }
466
467  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
468  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
469 
470  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
471  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
[608]472#if H_3D_IC
[189]473  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
474#endif
[608]475#if H_3D_ARP
476  m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth ); 
477#endif 
[655]478#if H_3D_INTER_SDC
[608]479  m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
[296]480#endif
[2]481  // Coefficient decoding
[56]482  Bool bCodeDQP = getdQPFlag();
483  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
484  setdQPFlag( bCodeDQP );
485  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
[669]486#if QC_DEPTH_IV_MRG_F0125
487  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
488#endif
[2]489}
490
[56]491Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
492{
[608]493  if(  pcCU->getSlice()->getPPS()->getUseDQP())
[56]494  {
[608]495    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
[56]496  }
497
498  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
499}
500
[608]501Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
[2]502{
503  TComPic* pcPic = pcCU->getPic();
[669]504#if !QC_DEPTH_IV_MRG_F0125 
[2]505  Bool bBoundary = false;
506  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
507  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
508  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
509  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
510 
[56]511  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
512  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
[608]513  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
[56]514  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
[2]515  {
516    bBoundary = true;
517  }
518 
519  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
520  {
521    UInt uiNextDepth = uiDepth + 1;
522    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
523    UInt uiIdx = uiAbsPartIdx;
524    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
525    {
526      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
527      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
528     
[608]529      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
[56]530      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
531      {
[608]532        xDecompressCU(pcCU, uiIdx, uiNextDepth );
[56]533      }
[2]534     
535      uiIdx += uiQNumParts;
536    }
537    return;
538  }
[669]539#endif 
[2]540  // Residual reconstruction
541  m_ppcYuvResi[uiDepth]->clear();
542 
543  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
544 
545  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
546  {
547    case MODE_INTER:
[655]548#if H_3D_INTER_SDC
[608]549      if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) )
550      {
551        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
552      }
553      else
554      {
555#endif
556      xReconInter( m_ppcCU[uiDepth], uiDepth );
[655]557#if H_3D_INTER_SDC
[608]558      }
559#endif
[2]560      break;
561    case MODE_INTRA:
[608]562#if H_3D_DIM_SDC
[189]563      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
564        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
565      else
566#endif
[608]567      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
[2]568      break;
569    default:
570      assert(0);
571      break;
572  }
[56]573  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
574  {
[608]575    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
[56]576  }
[2]577 
578  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
579}
580
[608]581Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
[2]582{
583 
584  // inter prediction
585  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
[608]586 
[2]587  // inter recon
588  xDecodeInterTexture( pcCU, 0, uiDepth );
589 
590  // clip for only non-zero cbp case
591  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
592  {
593    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
594  }
595  else
596  {
[608]597    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
598  }
599}
600
[655]601#if H_3D_INTER_SDC
[608]602Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
603{
604  // inter prediction
605  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
606
607  UInt  uiWidth      = pcCU->getWidth ( 0 );
608  UInt  uiHeight     = pcCU->getHeight( 0 );
609  UChar* pMask       = pcCU->getInterSDCMask();
610
611  memset( pMask, 0, uiWidth*uiHeight );
612  pcCU->xSetInterSDCCUMask( pcCU, pMask );
613
614  Pel  *pResi;
615  UInt uiPelX, uiPelY;
616  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
617
618  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
619  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
620  {
621    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
[2]622    {
[608]623      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
624
625      pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );;
[2]626    }
[608]627    pResi += uiResiStride;
[2]628  }
[608]629
630  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
631
632  // clear UV
633  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
634  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
635  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
636
637  for (Int y = 0; y < uiHeight/2; y++)
638  {
639    for (Int x = 0; x < uiWidth/2; x++)
640    {
641      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
642      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
643    }
644
645    pRecCb += uiStrideC;
646    pRecCr += uiStrideC;
647  }
[2]648}
[608]649#endif
[2]650
651Void
652TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
653                         UInt        uiTrDepth,
654                         UInt        uiAbsPartIdx,
655                         TComYuv*    pcRecoYuv,
656                         TComYuv*    pcPredYuv, 
657                         TComYuv*    pcResiYuv )
658{
659  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
660  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
661  UInt    uiStride          = pcRecoYuv->getStride  ();
662  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
663  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
664  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
665 
666  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
667  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
668 
669  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
670 
671  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
672  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
673  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
[608]674  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
[2]675  //===== init availability pattern =====
676  Bool  bAboveAvail = false;
677  Bool  bLeftAvail  = false;
678  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
679  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
680                                     m_pcPrediction->getPredicBuf       (),
681                                     m_pcPrediction->getPredicBufWidth  (),
682                                     m_pcPrediction->getPredicBufHeight (),
683                                     bAboveAvail, bLeftAvail );
684 
[56]685  //===== get prediction signal =====
[608]686#if H_3D_DIM
687  if( isDimMode( uiLumaPredMode ) )
[2]688  {
[608]689    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
690  }
[2]691  else
[56]692  {
[2]693#endif
[608]694  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
695#if H_3D_DIM
[2]696  }
[56]697#endif
698 
[2]699  //===== inverse transform =====
[608]700  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
[2]701
[56]702  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
703  assert(scalingListType < 6);
[608]704  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
[56]705
[2]706 
707  //===== reconstruction =====
[56]708  Pel* pPred      = piPred;
709  Pel* pResi      = piResi;
710  Pel* pReco      = piReco;
711  Pel* pRecIPred  = piRecIPred;
712  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
[2]713  {
[56]714    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
[2]715    {
[608]716      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
[56]717      pRecIPred[ uiX ] = pReco[ uiX ];
[2]718    }
[56]719    pPred     += uiStride;
720    pResi     += uiStride;
721    pReco     += uiStride;
722    pRecIPred += uiRecIPredStride;
[2]723  }
724}
725
726
727Void
728TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
729                           UInt        uiTrDepth,
730                           UInt        uiAbsPartIdx,
731                           TComYuv*    pcRecoYuv,
732                           TComYuv*    pcPredYuv, 
733                           TComYuv*    pcResiYuv,
734                           UInt        uiChromaId )
735{
736  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
737  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
[56]738
739  if( uiLog2TrSize == 2 )
[2]740  {
741    assert( uiTrDepth > 0 );
742    uiTrDepth--;
743    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
744    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
745    if( !bFirstQ )
746    {
747      return;
748    }
749  }
750 
751  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
752  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
753  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
754  UInt      uiStride          = pcRecoYuv->getCStride ();
755  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
756  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
757  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
758 
759  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
760  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
761 
762  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
763 
764  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
765  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
766  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
[608]767  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
[2]768  //===== init availability pattern =====
769  Bool  bAboveAvail = false;
770  Bool  bLeftAvail  = false;
771  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
[56]772
[608]773  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
[2]774                                           m_pcPrediction->getPredicBuf       (),
775                                           m_pcPrediction->getPredicBufWidth  (),
776                                           m_pcPrediction->getPredicBufHeight (),
777                                           bAboveAvail, bLeftAvail );
778  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
779 
780  //===== get prediction signal =====
781  {
[56]782    if( uiChromaPredMode == DM_CHROMA_IDX )
[2]783    {
[56]784      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
[608]785#if H_3D_DIM
786      mapDepthModeToIntraDir( uiChromaPredMode );
[56]787#endif
[2]788    }
[608]789    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
[2]790  }
791
792  //===== inverse transform =====
[608]793  Int curChromaQpOffset;
[56]794  if(eText == TEXT_CHROMA_U)
795  {
[608]796    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
[56]797  }
798  else
799  {
[608]800    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
[56]801  }
[608]802  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
[2]803
[56]804  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
805  assert(scalingListType < 6);
[608]806  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
[56]807
[2]808  //===== reconstruction =====
[56]809  Pel* pPred      = piPred;
810  Pel* pResi      = piResi;
811  Pel* pReco      = piReco;
812  Pel* pRecIPred  = piRecIPred;
813  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
[2]814  {
[56]815    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
[2]816    {
[608]817      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
[56]818      pRecIPred[ uiX ] = pReco[ uiX ];
[2]819    }
[56]820    pPred     += uiStride;
821    pResi     += uiStride;
822    pReco     += uiStride;
823    pRecIPred += uiRecIPredStride;
[2]824  }
825}
826
827
828Void
[608]829TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
[2]830{
831  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
832  UInt  uiNumPart     = pcCU->getNumPartInter();
833  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
834 
[56]835  if (pcCU->getIPCMFlag(0))
836  {
[608]837    xReconPCM( pcCU, uiDepth );
[56]838    return;
839  }
840
[2]841  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
842  {
843    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
844  } 
845
846  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
847  {
848    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
849  }
850
851}
852
[608]853#if H_3D_DIM_SDC
[189]854Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
855{
856  UInt uiWidth        = pcCU->getWidth  ( 0 );
857  UInt uiHeight       = pcCU->getHeight ( 0 );
858 
859  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
860  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
861  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
862 
863  UInt    uiStride    = pcRecoYuv->getStride  ();
864  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
865  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
866  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
867 
868  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
869  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
870  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
871 
872  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
873 
874  AOF( uiWidth == uiHeight );
875  AOF( uiAbsPartIdx == 0 );
876  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
877  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
878 
879  //===== init availability pattern =====
880  Bool  bAboveAvail = false;
881  Bool  bLeftAvail  = false;
882  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
883  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
884 
885  //===== get prediction signal =====
[608]886#if H_3D_DIM
887  if( isDimMode( uiLumaPredMode ) )
[189]888  {
[608]889    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
[189]890  }
891  else
892  {
893#endif
[608]894    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
895#if H_3D_DIM
[189]896  }
897#endif
898 
899  // number of segments depends on prediction mode
[608]900  UInt uiNumSegments = 1;
[189]901  Bool* pbMask = NULL;
902  UInt uiMaskStride = 0;
903 
[608]904  if( getDimType( uiLumaPredMode ) == DMM1_IDX )
[189]905  {
[608]906    Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
[189]907   
[608]908    WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
[189]909    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
910   
911    uiNumSegments = 2;
912    pbMask = pcWedgelet->getPattern();
913    uiMaskStride = pcWedgelet->getStride();
914  }
915 
916  // get DC prediction for each segment
917  Pel apDCPredValues[2];
[608]918  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
[189]919 
920  // reconstruct residual based on mask + DC residuals
921  Pel apDCResiValues[2];
[608]922  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
[189]923  {
[608]924#if H_3D_DIM_DLT
925    Pel   pPredIdx    = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
926    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
927    Pel   pRecoValue  = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
[189]928   
[608]929    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
930#else
931    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
[443]932#endif
[189]933  }
934 
935  //===== reconstruction =====
936  Bool*pMask      = pbMask;
937  Pel* pPred      = piPred;
938  Pel* pResi      = piResi;
939  Pel* pReco      = piReco;
940  Pel* pRecIPred  = piRecIPred;
941 
942  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
943  {
944    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
945    {
946      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
947      assert( ucSegment < uiNumSegments );
948     
949      Pel pResiDC = apDCResiValues[ucSegment];
950     
[608]951      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
[189]952      pRecIPred[ uiX ] = pReco[ uiX ];
953    }
954    pPred     += uiStride;
955    pResi     += uiStride;
956    pReco     += uiStride;
957    pRecIPred += uiRecIPredStride;
958    pMask     += uiMaskStride;
959  }
960 
961  // clear UV
962  UInt  uiStrideC     = pcPredYuv->getCStride();
963  Pel   *pRecCb       = pcPredYuv->getCbAddr();
964  Pel   *pRecCr       = pcPredYuv->getCrAddr();
965 
966  for (Int y=0; y<uiHeight/2; y++)
967  {
968    for (Int x=0; x<uiWidth/2; x++)
969    {
[608]970      pRecCb[x] = 128;
971      pRecCr[x] = 128;
[189]972    }
973   
974    pRecCb += uiStrideC;
975    pRecCr += uiStrideC;
976  }
977}
978#endif
979
[56]980/** Function for deriving recontructed PU/CU Luma sample with QTree structure
[2]981 * \param pcCU pointer of current CU
982 * \param uiTrDepth current tranform split depth
983 * \param uiAbsPartIdx  part index
984 * \param pcRecoYuv pointer to reconstructed sample arrays
985 * \param pcPredYuv pointer to prediction sample arrays
986 * \param pcResiYuv pointer to residue sample arrays
987 *
988 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
989 */
990Void
991TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
992                     UInt        uiTrDepth,
993                     UInt        uiAbsPartIdx,
994                     TComYuv*    pcRecoYuv,
995                     TComYuv*    pcPredYuv, 
996                     TComYuv*    pcResiYuv )
997{
998  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
999  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1000  if( uiTrMode == uiTrDepth )
1001  {
1002    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1003  }
1004  else
1005  {
1006    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1007    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1008    {
1009      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1010    }
1011  }
1012}
1013
[56]1014/** Function for deriving recontructed PU/CU chroma samples with QTree structure
[2]1015 * \param pcCU pointer of current CU
1016 * \param uiTrDepth current tranform split depth
1017 * \param uiAbsPartIdx  part index
1018 * \param pcRecoYuv pointer to reconstructed sample arrays
1019 * \param pcPredYuv pointer to prediction sample arrays
1020 * \param pcResiYuv pointer to residue sample arrays
1021 *
1022 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1023 */
1024Void
1025TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1026                     UInt        uiTrDepth,
1027                     UInt        uiAbsPartIdx,
1028                     TComYuv*    pcRecoYuv,
1029                     TComYuv*    pcPredYuv, 
1030                     TComYuv*    pcResiYuv )
1031{
1032  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1033  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1034  if( uiTrMode == uiTrDepth )
1035  {
1036    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1037    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1038  }
1039  else
1040  {
1041    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1042    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1043    {
1044      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1045    }
1046  }
1047}
1048
1049Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1050{
1051  UInt uiCUAddr = pcCU->getAddr();
1052 
1053  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1054 
1055  return;
1056}
1057
1058Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1059{
1060  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1061  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1062  TCoeff* piCoeff;
1063 
1064  Pel*    pResi;
[608]1065  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
[2]1066 
1067  // Y
1068  piCoeff = pcCU->getCoeffY();
1069  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
[56]1070
[608]1071  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
[56]1072
[608]1073  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
[2]1074 
1075  // Cb and Cr
[608]1076  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
1077  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
[56]1078
[2]1079  uiWidth  >>= 1;
1080  uiHeight >>= 1;
1081  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
[608]1082  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
[56]1083
[608]1084  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
1085  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
[56]1086
[2]1087  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
[608]1088  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
[2]1089}
1090
[56]1091/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1092 * \param pcCU pointer to current CU
1093 * \param uiPartIdx part index
1094 * \param piPCM pointer to PCM code arrays
1095 * \param piReco pointer to reconstructed sample arrays
1096 * \param uiStride stride of reconstructed sample arrays
1097 * \param uiWidth CU width
1098 * \param uiHeight CU height
1099 * \param ttText texture component type
1100 * \returns Void
1101 */
1102Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1103{
1104  UInt uiX, uiY;
1105  Pel* piPicReco;
1106  UInt uiPicStride;
1107  UInt uiPcmLeftShiftBit; 
1108
1109  if( ttText == TEXT_LUMA )
1110  {
1111    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1112    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
[608]1113    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
[56]1114  }
1115  else
1116  {
1117    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1118
1119    if( ttText == TEXT_CHROMA_U )
1120    {
1121      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1122    }
1123    else
1124    {
1125      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1126    }
[608]1127    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
[56]1128  }
1129
1130  for( uiY = 0; uiY < uiHeight; uiY++ )
1131  {
1132    for( uiX = 0; uiX < uiWidth; uiX++ )
1133    {
1134      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1135      piPicReco[uiX] = piReco[uiX];
1136    }
1137    piPCM += uiWidth;
1138    piReco += uiStride;
1139    piPicReco += uiPicStride;
1140  }
1141}
1142
1143/** Function for reconstructing a PCM mode CU.
1144 * \param pcCU pointer to current CU
1145 * \param uiDepth CU Depth
1146 * \returns Void
1147 */
[608]1148Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
[56]1149{
1150  // Luma
1151  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1152  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1153
1154  Pel* piPcmY = pcCU->getPCMSampleY();
1155  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1156
1157  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1158
1159  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1160
1161  // Cb and Cr
1162  UInt uiCWidth  = (uiWidth>>1);
1163  UInt uiCHeight = (uiHeight>>1);
1164
1165  Pel* piPcmCb = pcCU->getPCMSampleCb();
1166  Pel* piPcmCr = pcCU->getPCMSampleCr();
1167  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1168  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1169
1170  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1171
1172  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1173  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1174}
1175
1176/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1177 * \param pcCU pointer to current CU
1178 * \param uiDepth CU Depth
1179 * \returns Void
1180 */
[608]1181Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
[56]1182{
1183  // Luma
1184  UInt width  = (g_uiMaxCUWidth >> depth);
1185  UInt height = (g_uiMaxCUHeight >> depth);
1186
1187  Pel* pPcmY = pCU->getPCMSampleY();
1188  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1189
1190  UInt stride = m_ppcYuvReco[depth]->getStride();
1191
1192  for(Int y = 0; y < height; y++ )
1193  {
1194    for(Int x = 0; x < width; x++ )
1195    {
1196      pPcmY[x] = pRecoY[x];
1197    }
1198    pPcmY += width;
1199    pRecoY += stride;
1200  }
1201
1202  // Cb and Cr
1203  UInt widthC  = (width>>1);
1204  UInt heightC = (height>>1);
1205
1206  Pel* pPcmCb = pCU->getPCMSampleCb();
1207  Pel* pPcmCr = pCU->getPCMSampleCr();
1208  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1209  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1210
1211  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1212
1213  for(Int y = 0; y < heightC; y++ )
1214  {
1215    for(Int x = 0; x < widthC; x++ )
1216    {
1217      pPcmCb[x] = pRecoCb[x];
1218      pPcmCr[x] = pRecoCr[x];
1219    }
1220    pPcmCr += widthC;
1221    pPcmCb += widthC;
1222    pRecoCb += strideC;
1223    pRecoCr += strideC;
1224  }
1225
1226}
1227
1228//! \}
Note: See TracBrowser for help on using the repository browser.