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

Last change on this file since 1010 was 820, checked in by rwth, 11 years ago
  • cleanup: removed some assertions and added some comments
  • Property svn:eol-style set to native
File size: 52.4 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 
756  // get collocated depth block
757  UInt uiDepthStride = 0;
758  Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
759  AOF( pDepthPels != NULL );
760  AOF( uiDepthStride != 0 );
761 
762  // compute mask by segmenting depth block
763  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
764  Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask);
765  AOF(bValidMask);
766 
767  DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
768  TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
769 
770  // first, extract the two sets of motion parameters
771  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
772  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
773  {
774    UInt uiPartAddr = uiSegment*uiPUOffset;
775   
776    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
777   
778    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
779    {
780      RefPicList eRefList = (RefPicList)uiRefListIdx;
781      pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
782    }
783   
784    pDBBPTmpData->ahVSPFlag[uiSegment] = pcCU->getVSPFlag( uiPartAddr );
785    pDBBPTmpData->acDvInfo[uiSegment] = pcCU->getDvInfo( uiPartAddr );
786  }
787 
788  // do motion compensation for each segment as 2Nx2N
789  pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
790  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
791  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
792  {
793    pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
794   
795    pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], 0, 0, uiDepth );
796    pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], 0, 0, uiDepth );
797   
798    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
799    {
800      RefPicList eRefList = (RefPicList)uiRefListIdx;
801
802      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
803    }
804   
805    // inter prediction
806    m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
807  }
808 
809  // restore motion information in both segments again
810  pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
811  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
812  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
813  {
814    UInt uiPartAddr = uiSegment*uiPUOffset;
815   
816    pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
817   
818    pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], uiPartAddr, uiSegment, uiDepth );
819    pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], uiPartAddr, uiSegment, uiDepth );
820   
821    pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
822   
823    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
824    {
825      RefPicList eRefList = (RefPicList)uiRefListIdx;
826
827      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
828    }
829  }
830 
831  // reconstruct final prediction signal by combining both segments
832  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0));
833 
834  // inter recon
835  xDecodeInterTexture( pcCU, 0, uiDepth );
836 
837  // clip for only non-zero cbp case
838  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
839  {
840    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
841  }
842  else
843  {
844    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
845  }
846}
847#endif
848
849Void
850TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
851                         UInt        uiTrDepth,
852                         UInt        uiAbsPartIdx,
853                         TComYuv*    pcRecoYuv,
854                         TComYuv*    pcPredYuv, 
855                         TComYuv*    pcResiYuv )
856{
857  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
858  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
859  UInt    uiStride          = pcRecoYuv->getStride  ();
860  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
861  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
862  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
863 
864  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
865  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
866 
867  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
868 
869  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
870  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
871  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
872  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
873  //===== init availability pattern =====
874  Bool  bAboveAvail = false;
875  Bool  bLeftAvail  = false;
876  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
877  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
878                                     m_pcPrediction->getPredicBuf       (),
879                                     m_pcPrediction->getPredicBufWidth  (),
880                                     m_pcPrediction->getPredicBufHeight (),
881                                     bAboveAvail, bLeftAvail );
882 
883  //===== get prediction signal =====
884#if H_3D_DIM
885  if( isDimMode( uiLumaPredMode ) )
886  {
887    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
888  }
889  else
890  {
891#endif
892  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
893#if H_3D_DIM
894  }
895#endif
896 
897  //===== inverse transform =====
898  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
899
900  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
901  assert(scalingListType < 6);
902  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
903
904 
905  //===== reconstruction =====
906  Pel* pPred      = piPred;
907  Pel* pResi      = piResi;
908  Pel* pReco      = piReco;
909  Pel* pRecIPred  = piRecIPred;
910  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
911  {
912    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
913    {
914#if H_3D
915      if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
916      {
917        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 ] ) );
918      }
919      else
920      {
921        pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
922      }
923#else
924      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
925#endif
926      pRecIPred[ uiX ] = pReco[ uiX ];
927    }
928    pPred     += uiStride;
929    pResi     += uiStride;
930    pReco     += uiStride;
931    pRecIPred += uiRecIPredStride;
932  }
933}
934
935
936Void
937TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
938                           UInt        uiTrDepth,
939                           UInt        uiAbsPartIdx,
940                           TComYuv*    pcRecoYuv,
941                           TComYuv*    pcPredYuv, 
942                           TComYuv*    pcResiYuv,
943                           UInt        uiChromaId )
944{
945  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
946  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
947
948  if( uiLog2TrSize == 2 )
949  {
950    assert( uiTrDepth > 0 );
951    uiTrDepth--;
952    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
953    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
954    if( !bFirstQ )
955    {
956      return;
957    }
958  }
959 
960  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
961  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
962  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
963  UInt      uiStride          = pcRecoYuv->getCStride ();
964  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
965  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
966  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
967 
968  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
969  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
970 
971  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
972 
973  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
974  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
975  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
976  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
977  //===== init availability pattern =====
978  Bool  bAboveAvail = false;
979  Bool  bLeftAvail  = false;
980  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
981
982  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
983                                           m_pcPrediction->getPredicBuf       (),
984                                           m_pcPrediction->getPredicBufWidth  (),
985                                           m_pcPrediction->getPredicBufHeight (),
986                                           bAboveAvail, bLeftAvail );
987  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
988 
989  //===== get prediction signal =====
990  {
991    if( uiChromaPredMode == DM_CHROMA_IDX )
992    {
993      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
994#if H_3D_DIM
995      mapDepthModeToIntraDir( uiChromaPredMode );
996#endif
997    }
998    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
999  }
1000
1001  //===== inverse transform =====
1002  Int curChromaQpOffset;
1003  if(eText == TEXT_CHROMA_U)
1004  {
1005    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
1006  }
1007  else
1008  {
1009    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
1010  }
1011  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1012
1013  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
1014  assert(scalingListType < 6);
1015  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
1016
1017  //===== reconstruction =====
1018  Pel* pPred      = piPred;
1019  Pel* pResi      = piResi;
1020  Pel* pReco      = piReco;
1021  Pel* pRecIPred  = piRecIPred;
1022  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1023  {
1024    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1025    {
1026      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
1027      pRecIPred[ uiX ] = pReco[ uiX ];
1028    }
1029    pPred     += uiStride;
1030    pResi     += uiStride;
1031    pReco     += uiStride;
1032    pRecIPred += uiRecIPredStride;
1033  }
1034}
1035
1036
1037Void
1038TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
1039{
1040  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
1041  UInt  uiNumPart     = pcCU->getNumPartInter();
1042  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
1043 
1044  if (pcCU->getIPCMFlag(0))
1045  {
1046    xReconPCM( pcCU, uiDepth );
1047    return;
1048  }
1049
1050  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
1051  {
1052    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
1053  } 
1054
1055  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
1056  {
1057    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
1058  }
1059
1060}
1061
1062#if H_3D_DIM_SDC
1063Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1064{
1065  UInt uiWidth        = pcCU->getWidth  ( 0 );
1066  UInt uiHeight       = pcCU->getHeight ( 0 );
1067 
1068  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
1069  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
1070  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
1071 
1072  UInt    uiStride    = pcRecoYuv->getStride  ();
1073  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
1074  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
1075  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
1076 
1077  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1078  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
1079  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
1080 
1081  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
1082 
1083  AOF( uiWidth == uiHeight );
1084  AOF( uiAbsPartIdx == 0 );
1085  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
1086  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
1087 
1088  //===== init availability pattern =====
1089  Bool  bAboveAvail = false;
1090  Bool  bLeftAvail  = false;
1091  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
1092  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
1093 
1094  //===== get prediction signal =====
1095#if H_3D_DIM
1096  if( isDimMode( uiLumaPredMode ) )
1097  {
1098    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
1099  }
1100  else
1101  {
1102#endif
1103    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
1104#if H_3D_DIM
1105  }
1106#endif
1107 
1108  // number of segments depends on prediction mode
1109  UInt uiNumSegments = 1;
1110  Bool* pbMask = NULL;
1111  UInt uiMaskStride = 0;
1112 
1113  if( getDimType( uiLumaPredMode ) == DMM1_IDX )
1114  {
1115    Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
1116   
1117    WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
1118    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
1119   
1120    uiNumSegments = 2;
1121    pbMask = pcWedgelet->getPattern();
1122    uiMaskStride = pcWedgelet->getStride();
1123  }
1124 
1125  // get DC prediction for each segment
1126  Pel apDCPredValues[2];
1127  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
1128 
1129  // reconstruct residual based on mask + DC residuals
1130  Pel apDCResiValues[2];
1131  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
1132  {
1133#if H_3D_DIM_DLT
1134    Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
1135    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1136    Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
1137
1138    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
1139#else
1140    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
1141#endif
1142  }
1143 
1144  //===== reconstruction =====
1145  Bool*pMask      = pbMask;
1146  Pel* pPred      = piPred;
1147  Pel* pResi      = piResi;
1148  Pel* pReco      = piReco;
1149  Pel* pRecIPred  = piRecIPred;
1150 
1151  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1152  {
1153    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1154    {
1155      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1156      assert( ucSegment < uiNumSegments );
1157     
1158      Pel pResiDC = apDCResiValues[ucSegment];
1159     
1160      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
1161      pRecIPred[ uiX ] = pReco[ uiX ];
1162    }
1163    pPred     += uiStride;
1164    pResi     += uiStride;
1165    pReco     += uiStride;
1166    pRecIPred += uiRecIPredStride;
1167    pMask     += uiMaskStride;
1168  }
1169 
1170  // clear UV
1171  UInt  uiStrideC     = pcPredYuv->getCStride();
1172  Pel   *pRecCb       = pcPredYuv->getCbAddr();
1173  Pel   *pRecCr       = pcPredYuv->getCrAddr();
1174 
1175  for (Int y=0; y<uiHeight/2; y++)
1176  {
1177    for (Int x=0; x<uiWidth/2; x++)
1178    {
1179      pRecCb[x] = 128;
1180      pRecCr[x] = 128;
1181    }
1182   
1183    pRecCb += uiStrideC;
1184    pRecCr += uiStrideC;
1185  }
1186}
1187#endif
1188
1189/** Function for deriving recontructed PU/CU Luma sample with QTree structure
1190 * \param pcCU pointer of current CU
1191 * \param uiTrDepth current tranform split depth
1192 * \param uiAbsPartIdx  part index
1193 * \param pcRecoYuv pointer to reconstructed sample arrays
1194 * \param pcPredYuv pointer to prediction sample arrays
1195 * \param pcResiYuv pointer to residue sample arrays
1196 *
1197 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
1198 */
1199Void
1200TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
1201                     UInt        uiTrDepth,
1202                     UInt        uiAbsPartIdx,
1203                     TComYuv*    pcRecoYuv,
1204                     TComYuv*    pcPredYuv, 
1205                     TComYuv*    pcResiYuv )
1206{
1207  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1208  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1209  if( uiTrMode == uiTrDepth )
1210  {
1211    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1212  }
1213  else
1214  {
1215    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1216    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1217    {
1218      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1219    }
1220  }
1221}
1222
1223/** Function for deriving recontructed PU/CU chroma samples with QTree structure
1224 * \param pcCU pointer of current CU
1225 * \param uiTrDepth current tranform split depth
1226 * \param uiAbsPartIdx  part index
1227 * \param pcRecoYuv pointer to reconstructed sample arrays
1228 * \param pcPredYuv pointer to prediction sample arrays
1229 * \param pcResiYuv pointer to residue sample arrays
1230 *
1231 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1232 */
1233Void
1234TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1235                     UInt        uiTrDepth,
1236                     UInt        uiAbsPartIdx,
1237                     TComYuv*    pcRecoYuv,
1238                     TComYuv*    pcPredYuv, 
1239                     TComYuv*    pcResiYuv )
1240{
1241  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1242  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1243  if( uiTrMode == uiTrDepth )
1244  {
1245    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1246    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1247  }
1248  else
1249  {
1250    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1251    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1252    {
1253      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1254    }
1255  }
1256}
1257
1258Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1259{
1260  UInt uiCUAddr = pcCU->getAddr();
1261 
1262  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1263 
1264  return;
1265}
1266
1267Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1268{
1269  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1270  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1271  TCoeff* piCoeff;
1272 
1273  Pel*    pResi;
1274  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
1275 
1276  // Y
1277  piCoeff = pcCU->getCoeffY();
1278  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1279
1280  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
1281
1282  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1283 
1284  // Cb and Cr
1285  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
1286  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1287
1288  uiWidth  >>= 1;
1289  uiHeight >>= 1;
1290  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1291  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1292
1293  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
1294  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1295
1296  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1297  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1298}
1299
1300/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1301 * \param pcCU pointer to current CU
1302 * \param uiPartIdx part index
1303 * \param piPCM pointer to PCM code arrays
1304 * \param piReco pointer to reconstructed sample arrays
1305 * \param uiStride stride of reconstructed sample arrays
1306 * \param uiWidth CU width
1307 * \param uiHeight CU height
1308 * \param ttText texture component type
1309 * \returns Void
1310 */
1311Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1312{
1313  UInt uiX, uiY;
1314  Pel* piPicReco;
1315  UInt uiPicStride;
1316  UInt uiPcmLeftShiftBit; 
1317
1318  if( ttText == TEXT_LUMA )
1319  {
1320    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1321    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1322    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
1323  }
1324  else
1325  {
1326    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1327
1328    if( ttText == TEXT_CHROMA_U )
1329    {
1330      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1331    }
1332    else
1333    {
1334      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1335    }
1336    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
1337  }
1338
1339  for( uiY = 0; uiY < uiHeight; uiY++ )
1340  {
1341    for( uiX = 0; uiX < uiWidth; uiX++ )
1342    {
1343      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1344      piPicReco[uiX] = piReco[uiX];
1345    }
1346    piPCM += uiWidth;
1347    piReco += uiStride;
1348    piPicReco += uiPicStride;
1349  }
1350}
1351
1352/** Function for reconstructing a PCM mode CU.
1353 * \param pcCU pointer to current CU
1354 * \param uiDepth CU Depth
1355 * \returns Void
1356 */
1357Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
1358{
1359  // Luma
1360  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1361  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1362
1363  Pel* piPcmY = pcCU->getPCMSampleY();
1364  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1365
1366  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1367
1368  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1369
1370  // Cb and Cr
1371  UInt uiCWidth  = (uiWidth>>1);
1372  UInt uiCHeight = (uiHeight>>1);
1373
1374  Pel* piPcmCb = pcCU->getPCMSampleCb();
1375  Pel* piPcmCr = pcCU->getPCMSampleCr();
1376  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1377  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1378
1379  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1380
1381  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1382  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1383}
1384
1385/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1386 * \param pcCU pointer to current CU
1387 * \param uiDepth CU Depth
1388 * \returns Void
1389 */
1390Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
1391{
1392  // Luma
1393  UInt width  = (g_uiMaxCUWidth >> depth);
1394  UInt height = (g_uiMaxCUHeight >> depth);
1395
1396  Pel* pPcmY = pCU->getPCMSampleY();
1397  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1398
1399  UInt stride = m_ppcYuvReco[depth]->getStride();
1400
1401  for(Int y = 0; y < height; y++ )
1402  {
1403    for(Int x = 0; x < width; x++ )
1404    {
1405      pPcmY[x] = pRecoY[x];
1406    }
1407    pPcmY += width;
1408    pRecoY += stride;
1409  }
1410
1411  // Cb and Cr
1412  UInt widthC  = (width>>1);
1413  UInt heightC = (height>>1);
1414
1415  Pel* pPcmCb = pCU->getPCMSampleCb();
1416  Pel* pPcmCr = pCU->getPCMSampleCr();
1417  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1418  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1419
1420  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1421
1422  for(Int y = 0; y < heightC; y++ )
1423  {
1424    for(Int x = 0; x < widthC; x++ )
1425    {
1426      pPcmCb[x] = pRecoCb[x];
1427      pPcmCr[x] = pRecoCr[x];
1428    }
1429    pPcmCr += widthC;
1430    pPcmCb += widthC;
1431    pRecoCb += strideC;
1432    pRecoCr += strideC;
1433  }
1434
1435}
1436
1437//! \}
Note: See TracBrowser for help on using the repository browser.