source: 3DVCSoftware/branches/HTM-9.0-Fix/source/Lib/TLibDecoder/TDecCu.cpp @ 728

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

One added macro is “MTK_F0110_FIX”.
The added macro disabled sub-PU IVMP for depth and fixed some delete problems.

  • Property svn:eol-style set to native
File size: 47.5 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecCu.cpp
35    \brief    CU decoder class
36*/
37
38#include "TDecCu.h"
39
40//! \ingroup TLibDecoder
41//! \{
42
43// ====================================================================================================================
44// Constructor / destructor / create / destroy
45// ====================================================================================================================
46
47TDecCu::TDecCu()
48{
49  m_ppcYuvResi = NULL;
50  m_ppcYuvReco = NULL;
51  m_ppcCU      = NULL;
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 
74  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
75  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
76  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
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   
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) );
88  }
89 
90  m_bDecodeDQP = false;
91
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  {
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;
108  }
109 
110  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
111  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
112  delete [] m_ppcCU     ; m_ppcCU      = NULL;
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{
124  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
125  {
126    setdQPFlag(true);
127  }
128
129  // start from the top level CU
130  xDecodeCU( pcCU, 0, 0, ruiIsLast);
131}
132
133/** \param    pcCU        pointer of CU data
134 */
135Void TDecCu::decompressCU( TComDataCU* pcCU )
136{
137#if !QC_DEPTH_IV_MRG_F0125
138  xDecompressCU( pcCU, 0,  0 );
139#endif
140}
141
142// ====================================================================================================================
143// Protected member functions
144// ====================================================================================================================
145
146/**decode end-of-slice flag
147 * \param pcCU
148 * \param uiAbsPartIdx
149 * \param uiDepth
150 * \returns Bool
151 */
152Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)
153{
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();
160  UInt uiGranularityWidth = g_uiMaxCUWidth;
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  {
176    if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) 
177    {
178      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
179    }
180    else 
181    {
182      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
183      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
184    }
185  }
186
187  return uiIsLast>0;
188}
189
190/** decode CU block recursively
191 * \param pcCU
192 * \param uiAbsPartIdx
193 * \param uiDepth
194 * \returns Void
195 */
196
197Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
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;
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
215  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
216  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
217  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
218  {
219    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
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;
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
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     
240      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
241      if ( bSubInSlice )
242      {
243        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
244        {
245          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
246        }
247        else
248        {
249          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
250        }
251      }
252     
253      uiIdx += uiQNumParts;
254    }
255    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
256    {
257      if ( getdQPFlag() )
258      {
259        UInt uiQPSrcPartIdx;
260        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
261        {
262          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
263        }
264        else
265        {
266          uiQPSrcPartIdx = uiAbsPartIdx;
267        }
268        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
269      }
270    }
271    return;
272  }
273 
274#if H_MV_ENC_DEC_TRAC
275  DTRACE_CU_S("=========== coding_unit ===========\n")
276#endif
277
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  }
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()) )
300#else
301#if H_3D_IV_MERGE
302    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
303#else
304    if (0)
305#endif
306#endif
307#endif
308    {
309      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
310      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
311      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
312      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
313      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
314      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
315      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
316      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
317#if 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
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.
327      {
328        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
329      }
330      else
331#endif
332      {
333        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
334      }
335#if QC_DEPTH_IV_MRG_F0125
336      }
337#endif
338#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
339      if ( g_decTraceDispDer )
340      {
341        DTRACE_CU( "RefViewIdx",  DvInfo.m_aVIdxCan );       
342        DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() );
343        DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() );
344        DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() );
345        DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() );
346      }
347#endif
348
349      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
350      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
351      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
352      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
353     }
354  }
355#endif
356  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
357  {
358    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
359  }
360 
361  // decode CU mode and the partition size
362  if( !pcCU->getSlice()->isIntra())
363  {
364    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
365  }
366 
367  if( pcCU->isSkipped(uiAbsPartIdx) )
368  {
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
374    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
375    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
376#if H_3D_IV_MERGE
377    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
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
381    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
382    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
383#endif
384    Int numValidMergeCand = 0;
385    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
386    {
387      uhInterDirNeighbours[ui] = 0;
388    }
389    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
390    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
391
392#if LGE_SHARP_VSP_INHERIT_F0104
393#if H_3D_IC
394    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
395#endif
396#if H_3D_ARP
397    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
398#endif
399#endif
400
401#if H_3D_VSP
402    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
403    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
404    InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
405#if MTK_SPIVMP_F0110
406    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
407    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
408    TComMvField*  pcMvFieldSP;
409    UChar* puhInterDirSP;
410    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
411    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
412#endif
413#if ETRIKHU_MERGE_REUSE_F0093
414    m_ppcCU[uiDepth]->initAvailableFlags();
415    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
416    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
417#if MTK_SPIVMP_F0110
418      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
419#endif
420      , numValidMergeCand, uiMergeIndex );
421#else
422    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand, uiMergeIndex );
423#endif
424    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
425#else
426#if ETRIKHU_MERGE_REUSE_F0093
427    m_ppcCU[uiDepth]->initAvailableFlags();
428    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
429    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
430#else
431    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
432#endif
433#endif
434#if H_3D_VSP
435    if(vspFlag[uiMergeIndex])
436    {
437      pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth);
438    }
439#endif
440    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
441
442    TComMv cTmpMv( 0, 0 );
443    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
444    {       
445      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
446      {
447        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
448        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
449        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
450        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
451#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
452        if ( g_decTraceMvFromMerge )
453        {       
454          if ( uiRefListIdx == 0 )
455          {
456            DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
457            DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
458            DTRACE_PU( "refIdxL0   ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
459          }
460          else
461          {
462            DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
463            DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
464            DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
465          }
466        }
467#endif
468      }
469    }
470#if MTK_SPIVMP_F0110
471    pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
472    if (bSPIVMPFlag[uiMergeIndex])
473    {
474      UInt uiSPAddr;
475      Int iWidth = pcCU->getWidth(uiAbsPartIdx);
476      Int iHeight = pcCU->getHeight(uiAbsPartIdx);
477
478      Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
479
480      pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
481
482      for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
483      {
484        pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
485        pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
486        pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
487        pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
488      }
489    }
490#if MTK_F0110_FIX
491    delete[] pcMvFieldSP;
492    delete[] puhInterDirSP;
493#else
494    delete pcMvFieldSP;
495    delete puhInterDirSP;
496#endif
497#endif
498#if !LGE_SHARP_VSP_INHERIT_F0104
499#if H_3D_IC
500    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
501#endif
502#if H_3D_ARP
503    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
504#endif
505#endif
506
507    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
508#if QC_DEPTH_IV_MRG_F0125
509    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
510#endif
511    return;
512  }
513
514  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
515  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
516
517  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
518  {
519    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
520
521    if(pcCU->getIPCMFlag(uiAbsPartIdx))
522    {
523      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
524#if QC_DEPTH_IV_MRG_F0125
525      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
526#endif
527      return;
528    }
529  }
530
531  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
532  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
533 
534  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
535  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
536#if !LGE_SHARP_VSP_INHERIT_F0104
537#if H_3D_IC
538  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
539#endif
540#if H_3D_ARP
541  m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth ); 
542#endif 
543#endif
544#if H_3D_INTER_SDC
545  m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
546#endif
547  // Coefficient decoding
548  Bool bCodeDQP = getdQPFlag();
549  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
550  setdQPFlag( bCodeDQP );
551  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
552#if QC_DEPTH_IV_MRG_F0125
553  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
554#endif
555}
556
557Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
558{
559  if(  pcCU->getSlice()->getPPS()->getUseDQP())
560  {
561    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
562  }
563
564  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
565}
566
567Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
568{
569  TComPic* pcPic = pcCU->getPic();
570#if !QC_DEPTH_IV_MRG_F0125 
571  Bool bBoundary = false;
572  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
573  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
574  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
575  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
576 
577  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
578  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
579  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
580  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
581  {
582    bBoundary = true;
583  }
584 
585  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
586  {
587    UInt uiNextDepth = uiDepth + 1;
588    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
589    UInt uiIdx = uiAbsPartIdx;
590    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
591    {
592      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
593      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
594     
595      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
596      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
597      {
598        xDecompressCU(pcCU, uiIdx, uiNextDepth );
599      }
600     
601      uiIdx += uiQNumParts;
602    }
603    return;
604  }
605#endif 
606  // Residual reconstruction
607  m_ppcYuvResi[uiDepth]->clear();
608 
609  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
610 
611  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
612  {
613    case MODE_INTER:
614#if H_3D_INTER_SDC
615      if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) )
616      {
617        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
618      }
619      else
620      {
621#endif
622      xReconInter( m_ppcCU[uiDepth], uiDepth );
623#if H_3D_INTER_SDC
624      }
625#endif
626      break;
627    case MODE_INTRA:
628#if H_3D_DIM_SDC
629      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
630        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
631      else
632#endif
633      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
634      break;
635    default:
636      assert(0);
637      break;
638  }
639  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
640  {
641    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
642  }
643 
644  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
645}
646
647Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
648{
649 
650  // inter prediction
651  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
652 
653  // inter recon
654  xDecodeInterTexture( pcCU, 0, uiDepth );
655 
656  // clip for only non-zero cbp case
657  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
658  {
659    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
660  }
661  else
662  {
663    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
664  }
665}
666
667#if H_3D_INTER_SDC
668Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
669{
670  // inter prediction
671  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
672
673  UInt  uiWidth      = pcCU->getWidth ( 0 );
674  UInt  uiHeight     = pcCU->getHeight( 0 );
675  UChar* pMask       = pcCU->getInterSDCMask();
676
677  memset( pMask, 0, uiWidth*uiHeight );
678  pcCU->xSetInterSDCCUMask( pcCU, pMask );
679
680  Pel  *pResi;
681  UInt uiPelX, uiPelY;
682  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
683
684  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
685  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
686  {
687    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
688    {
689      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
690
691      pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );;
692    }
693    pResi += uiResiStride;
694  }
695
696  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
697
698  // clear UV
699  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
700  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
701  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
702
703  for (Int y = 0; y < uiHeight/2; y++)
704  {
705    for (Int x = 0; x < uiWidth/2; x++)
706    {
707      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
708      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
709    }
710
711    pRecCb += uiStrideC;
712    pRecCr += uiStrideC;
713  }
714}
715#endif
716
717Void
718TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
719                         UInt        uiTrDepth,
720                         UInt        uiAbsPartIdx,
721                         TComYuv*    pcRecoYuv,
722                         TComYuv*    pcPredYuv, 
723                         TComYuv*    pcResiYuv )
724{
725  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
726  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
727  UInt    uiStride          = pcRecoYuv->getStride  ();
728  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
729  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
730  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
731 
732  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
733  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
734 
735  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
736 
737  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
738  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
739  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
740  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
741  //===== init availability pattern =====
742  Bool  bAboveAvail = false;
743  Bool  bLeftAvail  = false;
744  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
745  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
746                                     m_pcPrediction->getPredicBuf       (),
747                                     m_pcPrediction->getPredicBufWidth  (),
748                                     m_pcPrediction->getPredicBufHeight (),
749                                     bAboveAvail, bLeftAvail );
750 
751  //===== get prediction signal =====
752#if H_3D_DIM
753  if( isDimMode( uiLumaPredMode ) )
754  {
755    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
756  }
757  else
758  {
759#endif
760  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
761#if H_3D_DIM
762  }
763#endif
764 
765  //===== inverse transform =====
766  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
767
768  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
769  assert(scalingListType < 6);
770  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
771
772 
773  //===== reconstruction =====
774  Pel* pPred      = piPred;
775  Pel* pResi      = piResi;
776  Pel* pReco      = piReco;
777  Pel* pRecIPred  = piRecIPred;
778  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
779  {
780    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
781    {
782#if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159
783        if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
784        {
785            pReco    [ uiX ] = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
786        }
787        else
788        {
789      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
790        }
791#else
792      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
793#endif
794      pRecIPred[ uiX ] = pReco[ uiX ];
795    }
796    pPred     += uiStride;
797    pResi     += uiStride;
798    pReco     += uiStride;
799    pRecIPred += uiRecIPredStride;
800  }
801}
802
803
804Void
805TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
806                           UInt        uiTrDepth,
807                           UInt        uiAbsPartIdx,
808                           TComYuv*    pcRecoYuv,
809                           TComYuv*    pcPredYuv, 
810                           TComYuv*    pcResiYuv,
811                           UInt        uiChromaId )
812{
813  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
814  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
815
816  if( uiLog2TrSize == 2 )
817  {
818    assert( uiTrDepth > 0 );
819    uiTrDepth--;
820    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
821    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
822    if( !bFirstQ )
823    {
824      return;
825    }
826  }
827 
828  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
829  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
830  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
831  UInt      uiStride          = pcRecoYuv->getCStride ();
832  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
833  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
834  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
835 
836  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
837  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
838 
839  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
840 
841  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
842  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
843  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
844  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
845  //===== init availability pattern =====
846  Bool  bAboveAvail = false;
847  Bool  bLeftAvail  = false;
848  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
849
850  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
851                                           m_pcPrediction->getPredicBuf       (),
852                                           m_pcPrediction->getPredicBufWidth  (),
853                                           m_pcPrediction->getPredicBufHeight (),
854                                           bAboveAvail, bLeftAvail );
855  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
856 
857  //===== get prediction signal =====
858  {
859    if( uiChromaPredMode == DM_CHROMA_IDX )
860    {
861      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
862#if H_3D_DIM
863      mapDepthModeToIntraDir( uiChromaPredMode );
864#endif
865    }
866    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
867  }
868
869  //===== inverse transform =====
870  Int curChromaQpOffset;
871  if(eText == TEXT_CHROMA_U)
872  {
873    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
874  }
875  else
876  {
877    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
878  }
879  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
880
881  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
882  assert(scalingListType < 6);
883  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
884
885  //===== reconstruction =====
886  Pel* pPred      = piPred;
887  Pel* pResi      = piResi;
888  Pel* pReco      = piReco;
889  Pel* pRecIPred  = piRecIPred;
890  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
891  {
892    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
893    {
894      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
895      pRecIPred[ uiX ] = pReco[ uiX ];
896    }
897    pPred     += uiStride;
898    pResi     += uiStride;
899    pReco     += uiStride;
900    pRecIPred += uiRecIPredStride;
901  }
902}
903
904
905Void
906TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
907{
908  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
909  UInt  uiNumPart     = pcCU->getNumPartInter();
910  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
911 
912  if (pcCU->getIPCMFlag(0))
913  {
914    xReconPCM( pcCU, uiDepth );
915    return;
916  }
917
918  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
919  {
920    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
921  } 
922
923  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
924  {
925    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
926  }
927
928}
929
930#if H_3D_DIM_SDC
931Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
932{
933  UInt uiWidth        = pcCU->getWidth  ( 0 );
934  UInt uiHeight       = pcCU->getHeight ( 0 );
935 
936  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
937  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
938  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
939 
940  UInt    uiStride    = pcRecoYuv->getStride  ();
941  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
942  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
943  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
944 
945  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
946  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
947  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
948 
949  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
950 
951  AOF( uiWidth == uiHeight );
952  AOF( uiAbsPartIdx == 0 );
953  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
954  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
955 
956  //===== init availability pattern =====
957  Bool  bAboveAvail = false;
958  Bool  bLeftAvail  = false;
959  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
960  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
961 
962  //===== get prediction signal =====
963#if H_3D_DIM
964  if( isDimMode( uiLumaPredMode ) )
965  {
966    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
967  }
968  else
969  {
970#endif
971    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
972#if H_3D_DIM
973  }
974#endif
975 
976  // number of segments depends on prediction mode
977  UInt uiNumSegments = 1;
978  Bool* pbMask = NULL;
979  UInt uiMaskStride = 0;
980 
981  if( getDimType( uiLumaPredMode ) == DMM1_IDX )
982  {
983    Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
984   
985    WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
986    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
987   
988    uiNumSegments = 2;
989    pbMask = pcWedgelet->getPattern();
990    uiMaskStride = pcWedgelet->getStride();
991  }
992 
993  // get DC prediction for each segment
994  Pel apDCPredValues[2];
995  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
996 
997  // reconstruct residual based on mask + DC residuals
998  Pel apDCResiValues[2];
999  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
1000  {
1001#if H_3D_DIM_DLT
1002    Pel   pPredIdx    = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
1003    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1004    Pel   pRecoValue  = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
1005   
1006    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
1007#else
1008    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1009#endif
1010  }
1011 
1012  //===== reconstruction =====
1013  Bool*pMask      = pbMask;
1014  Pel* pPred      = piPred;
1015  Pel* pResi      = piResi;
1016  Pel* pReco      = piReco;
1017  Pel* pRecIPred  = piRecIPred;
1018 
1019  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1020  {
1021    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1022    {
1023      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1024      assert( ucSegment < uiNumSegments );
1025     
1026      Pel pResiDC = apDCResiValues[ucSegment];
1027     
1028      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
1029      pRecIPred[ uiX ] = pReco[ uiX ];
1030    }
1031    pPred     += uiStride;
1032    pResi     += uiStride;
1033    pReco     += uiStride;
1034    pRecIPred += uiRecIPredStride;
1035    pMask     += uiMaskStride;
1036  }
1037 
1038  // clear UV
1039  UInt  uiStrideC     = pcPredYuv->getCStride();
1040  Pel   *pRecCb       = pcPredYuv->getCbAddr();
1041  Pel   *pRecCr       = pcPredYuv->getCrAddr();
1042 
1043  for (Int y=0; y<uiHeight/2; y++)
1044  {
1045    for (Int x=0; x<uiWidth/2; x++)
1046    {
1047      pRecCb[x] = 128;
1048      pRecCr[x] = 128;
1049    }
1050   
1051    pRecCb += uiStrideC;
1052    pRecCr += uiStrideC;
1053  }
1054}
1055#endif
1056
1057/** Function for deriving recontructed PU/CU Luma sample with QTree structure
1058 * \param pcCU pointer of current CU
1059 * \param uiTrDepth current tranform split depth
1060 * \param uiAbsPartIdx  part index
1061 * \param pcRecoYuv pointer to reconstructed sample arrays
1062 * \param pcPredYuv pointer to prediction sample arrays
1063 * \param pcResiYuv pointer to residue sample arrays
1064 *
1065 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
1066 */
1067Void
1068TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
1069                     UInt        uiTrDepth,
1070                     UInt        uiAbsPartIdx,
1071                     TComYuv*    pcRecoYuv,
1072                     TComYuv*    pcPredYuv, 
1073                     TComYuv*    pcResiYuv )
1074{
1075  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1076  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1077  if( uiTrMode == uiTrDepth )
1078  {
1079    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1080  }
1081  else
1082  {
1083    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1084    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1085    {
1086      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1087    }
1088  }
1089}
1090
1091/** Function for deriving recontructed PU/CU chroma samples with QTree structure
1092 * \param pcCU pointer of current CU
1093 * \param uiTrDepth current tranform split depth
1094 * \param uiAbsPartIdx  part index
1095 * \param pcRecoYuv pointer to reconstructed sample arrays
1096 * \param pcPredYuv pointer to prediction sample arrays
1097 * \param pcResiYuv pointer to residue sample arrays
1098 *
1099 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1100 */
1101Void
1102TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1103                     UInt        uiTrDepth,
1104                     UInt        uiAbsPartIdx,
1105                     TComYuv*    pcRecoYuv,
1106                     TComYuv*    pcPredYuv, 
1107                     TComYuv*    pcResiYuv )
1108{
1109  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1110  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1111  if( uiTrMode == uiTrDepth )
1112  {
1113    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1114    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1115  }
1116  else
1117  {
1118    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1119    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1120    {
1121      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1122    }
1123  }
1124}
1125
1126Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1127{
1128  UInt uiCUAddr = pcCU->getAddr();
1129 
1130  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1131 
1132  return;
1133}
1134
1135Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1136{
1137  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1138  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1139  TCoeff* piCoeff;
1140 
1141  Pel*    pResi;
1142  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
1143 
1144  // Y
1145  piCoeff = pcCU->getCoeffY();
1146  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1147
1148  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
1149
1150  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1151 
1152  // Cb and Cr
1153  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
1154  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1155
1156  uiWidth  >>= 1;
1157  uiHeight >>= 1;
1158  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1159  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1160
1161  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
1162  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1163
1164  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1165  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1166}
1167
1168/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1169 * \param pcCU pointer to current CU
1170 * \param uiPartIdx part index
1171 * \param piPCM pointer to PCM code arrays
1172 * \param piReco pointer to reconstructed sample arrays
1173 * \param uiStride stride of reconstructed sample arrays
1174 * \param uiWidth CU width
1175 * \param uiHeight CU height
1176 * \param ttText texture component type
1177 * \returns Void
1178 */
1179Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1180{
1181  UInt uiX, uiY;
1182  Pel* piPicReco;
1183  UInt uiPicStride;
1184  UInt uiPcmLeftShiftBit; 
1185
1186  if( ttText == TEXT_LUMA )
1187  {
1188    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1189    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1190    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
1191  }
1192  else
1193  {
1194    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1195
1196    if( ttText == TEXT_CHROMA_U )
1197    {
1198      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1199    }
1200    else
1201    {
1202      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1203    }
1204    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
1205  }
1206
1207  for( uiY = 0; uiY < uiHeight; uiY++ )
1208  {
1209    for( uiX = 0; uiX < uiWidth; uiX++ )
1210    {
1211      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1212      piPicReco[uiX] = piReco[uiX];
1213    }
1214    piPCM += uiWidth;
1215    piReco += uiStride;
1216    piPicReco += uiPicStride;
1217  }
1218}
1219
1220/** Function for reconstructing a PCM mode CU.
1221 * \param pcCU pointer to current CU
1222 * \param uiDepth CU Depth
1223 * \returns Void
1224 */
1225Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
1226{
1227  // Luma
1228  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1229  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1230
1231  Pel* piPcmY = pcCU->getPCMSampleY();
1232  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1233
1234  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1235
1236  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1237
1238  // Cb and Cr
1239  UInt uiCWidth  = (uiWidth>>1);
1240  UInt uiCHeight = (uiHeight>>1);
1241
1242  Pel* piPcmCb = pcCU->getPCMSampleCb();
1243  Pel* piPcmCr = pcCU->getPCMSampleCr();
1244  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1245  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1246
1247  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1248
1249  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1250  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1251}
1252
1253/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1254 * \param pcCU pointer to current CU
1255 * \param uiDepth CU Depth
1256 * \returns Void
1257 */
1258Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
1259{
1260  // Luma
1261  UInt width  = (g_uiMaxCUWidth >> depth);
1262  UInt height = (g_uiMaxCUHeight >> depth);
1263
1264  Pel* pPcmY = pCU->getPCMSampleY();
1265  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1266
1267  UInt stride = m_ppcYuvReco[depth]->getStride();
1268
1269  for(Int y = 0; y < height; y++ )
1270  {
1271    for(Int x = 0; x < width; x++ )
1272    {
1273      pPcmY[x] = pRecoY[x];
1274    }
1275    pPcmY += width;
1276    pRecoY += stride;
1277  }
1278
1279  // Cb and Cr
1280  UInt widthC  = (width>>1);
1281  UInt heightC = (height>>1);
1282
1283  Pel* pPcmCb = pCU->getPCMSampleCb();
1284  Pel* pPcmCr = pCU->getPCMSampleCr();
1285  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1286  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1287
1288  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1289
1290  for(Int y = 0; y < heightC; y++ )
1291  {
1292    for(Int x = 0; x < widthC; x++ )
1293    {
1294      pPcmCb[x] = pRecoCb[x];
1295      pPcmCr[x] = pRecoCr[x];
1296    }
1297    pPcmCr += widthC;
1298    pPcmCb += widthC;
1299    pRecoCb += strideC;
1300    pRecoCr += strideC;
1301  }
1302
1303}
1304
1305//! \}
Note: See TracBrowser for help on using the repository browser.