source: 3DVCSoftware/branches/HTM-9.3-dev1-RWTH/source/Lib/TLibDecoder/TDecCu.cpp @ 819

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