source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2a/source/Lib/TLibDecoder/TDecCu.cpp @ 468

Last change on this file since 468 was 468, checked in by lg, 11 years ago

1.IC and full pel depth coding are integrated and is guarded by Macro H_3D_IC.

  • Property svn:eol-style set to native
File size: 34.8 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecCu.cpp
35    \brief    CU decoder class
36*/
37
38#include "TDecCu.h"
39
40//! \ingroup TLibDecoder
41//! \{
42
43// ====================================================================================================================
44// Constructor / destructor / create / destroy
45// ====================================================================================================================
46
47TDecCu::TDecCu()
48{
49  m_ppcYuvResi = NULL;
50  m_ppcYuvReco = NULL;
51  m_ppcCU      = NULL;
52}
53
54TDecCu::~TDecCu()
55{
56}
57
58Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
59{
60  m_pcEntropyDecoder  = pcEntropyDecoder;
61  m_pcTrQuant         = pcTrQuant;
62  m_pcPrediction      = pcPrediction;
63}
64
65/**
66 \param    uiMaxDepth    total number of allowable depth
67 \param    uiMaxWidth    largest CU width
68 \param    uiMaxHeight   largest CU height
69 */
70Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
71{
72  m_uiMaxDepth = uiMaxDepth+1;
73 
74  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
75  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
76  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
77 
78  UInt uiNumPartitions;
79  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
80  {
81    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
82    UInt uiWidth  = uiMaxWidth  >> ui;
83    UInt uiHeight = uiMaxHeight >> ui;
84   
85    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight );
86    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
87    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
88  }
89 
90  m_bDecodeDQP = false;
91
92  // initialize partition order.
93  UInt* piTmp = &g_auiZscanToRaster[0];
94  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
95  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
96 
97  // initialize conversion matrix from partition index to pel
98  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
99}
100
101Void TDecCu::destroy()
102{
103  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
104  {
105    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
106    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
107    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
108  }
109 
110  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
111  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
112  delete [] m_ppcCU     ; m_ppcCU      = NULL;
113}
114
115// ====================================================================================================================
116// Public member functions
117// ====================================================================================================================
118
119/** \param    pcCU        pointer of CU data
120 \param    ruiIsLast   last data?
121 */
122Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
123{
124  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
125  {
126    setdQPFlag(true);
127  }
128
129  // start from the top level CU
130  xDecodeCU( pcCU, 0, 0, ruiIsLast);
131}
132
133/** \param    pcCU        pointer of CU data
134 */
135Void TDecCu::decompressCU( TComDataCU* pcCU )
136{
137  xDecompressCU( pcCU, 0,  0 );
138}
139
140// ====================================================================================================================
141// Protected member functions
142// ====================================================================================================================
143
144/**decode end-of-slice flag
145 * \param pcCU
146 * \param uiAbsPartIdx
147 * \param uiDepth
148 * \returns Bool
149 */
150Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)
151{
152  UInt uiIsLast;
153  TComPic* pcPic = pcCU->getPic();
154  TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
155  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
156  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
157  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
158  UInt uiGranularityWidth = g_uiMaxCUWidth;
159  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
160  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
161
162  if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
163    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
164  {
165    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
166  }
167  else
168  {
169    uiIsLast=0;
170  }
171 
172  if(uiIsLast) 
173  {
174    if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) 
175    {
176      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
177    }
178    else 
179    {
180      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
181      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
182    }
183  }
184
185  return uiIsLast>0;
186}
187
188/** decode CU block recursively
189 * \param pcCU
190 * \param uiAbsPartIdx
191 * \param uiDepth
192 * \returns Void
193 */
194
195Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
196{
197  TComPic* pcPic = pcCU->getPic();
198  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
199  UInt uiQNumParts      = uiCurNumParts>>2;
200 
201  Bool bBoundary = false;
202  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
203  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
204  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
205  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
206 
207  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
208  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
209  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
210  {
211    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
212  }
213  else
214  {
215    bBoundary = true;
216  }
217 
218  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
219  {
220    UInt uiIdx = uiAbsPartIdx;
221    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
222    {
223      setdQPFlag(true);
224      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
225    }
226
227    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
228    {
229      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
230      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
231     
232      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
233      if ( bSubInSlice )
234      {
235        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
236        {
237          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
238        }
239        else
240        {
241          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
242        }
243      }
244     
245      uiIdx += uiQNumParts;
246    }
247    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
248    {
249      if ( getdQPFlag() )
250      {
251        UInt uiQPSrcPartIdx;
252        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
253        {
254          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
255        }
256        else
257        {
258          uiQPSrcPartIdx = uiAbsPartIdx;
259        }
260        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
261      }
262    }
263    return;
264  }
265 
266  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
267  {
268    setdQPFlag(true);
269    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
270  }
271#if H_3D_NBDV
272  DisInfo DvInfo; 
273  DvInfo.bDV = false;
274  DvInfo.m_acNBDV.setZero();
275  DvInfo.m_aVIdxCan = 0;
276#if H_3D_NBDV_REF 
277  DvInfo.m_acDoNBDV.setZero();
278#endif
279 
280 
281  if(!pcCU->getSlice()->isIntra())
282  {
283#if H_3D_ARP
284    if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) )
285#else
286    if(pcCU->getSlice()->getViewIndex() && !pcCU->getSlice()->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
287#endif
288    {
289      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
290      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
291      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
292      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
293      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
294      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
295      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
296      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
297#if H_3D_NBDV_REF
298      if(pcCU->getSlice()->getSPS()->getUseDVPRefine())  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
299        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
300      else
301#endif
302        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
303
304      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
305      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
306      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
307      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
308     }
309  }
310#endif
311  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
312  {
313    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
314  }
315 
316  // decode CU mode and the partition size
317  if( !pcCU->getSlice()->isIntra())
318  {
319    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
320  }
321 
322  if( pcCU->isSkipped(uiAbsPartIdx) )
323  {
324    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
325    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
326    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
327    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
328    Int numValidMergeCand = 0;
329    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
330    {
331      uhInterDirNeighbours[ui] = 0;
332    }
333    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
334    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
335    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
336    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
337
338    TComMv cTmpMv( 0, 0 );
339    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
340    {       
341      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
342      {
343        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
344        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
345        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
346        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
347      }
348    }
349#if H_3D_IC
350    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
351#endif
352#if H_3D_ARP
353    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
354#endif
355    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
356    return;
357  }
358
359  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
360  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
361
362  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
363  {
364    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
365
366    if(pcCU->getIPCMFlag(uiAbsPartIdx))
367    {
368      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
369      return;
370    }
371  }
372
373  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
374  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
375 
376  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
377  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
378#if H_3D_IC
379  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
380#endif
381#if H_3D_ARP
382  m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth ); 
383#endif 
384  // Coefficient decoding
385  Bool bCodeDQP = getdQPFlag();
386  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
387  setdQPFlag( bCodeDQP );
388  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
389}
390
391Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
392{
393  if(  pcCU->getSlice()->getPPS()->getUseDQP())
394  {
395    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
396  }
397
398  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
399}
400
401Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
402{
403  TComPic* pcPic = pcCU->getPic();
404 
405  Bool bBoundary = false;
406  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
407  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
408  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
409  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
410 
411  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
412  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
413  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
414  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
415  {
416    bBoundary = true;
417  }
418 
419  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
420  {
421    UInt uiNextDepth = uiDepth + 1;
422    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
423    UInt uiIdx = uiAbsPartIdx;
424    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
425    {
426      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
427      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
428     
429      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
430      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
431      {
432        xDecompressCU(pcCU, uiIdx, uiNextDepth );
433      }
434     
435      uiIdx += uiQNumParts;
436    }
437    return;
438  }
439 
440  // Residual reconstruction
441  m_ppcYuvResi[uiDepth]->clear();
442 
443  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
444 
445  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
446  {
447    case MODE_INTER:
448      xReconInter( m_ppcCU[uiDepth], uiDepth );
449      break;
450    case MODE_INTRA:
451      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
452      break;
453    default:
454      assert(0);
455      break;
456  }
457  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
458  {
459    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
460  }
461 
462  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
463}
464
465Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
466{
467 
468  // inter prediction
469  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
470 
471  // inter recon
472  xDecodeInterTexture( pcCU, 0, uiDepth );
473 
474  // clip for only non-zero cbp case
475  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
476  {
477    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
478  }
479  else
480  {
481    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
482  }
483}
484
485Void
486TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
487                         UInt        uiTrDepth,
488                         UInt        uiAbsPartIdx,
489                         TComYuv*    pcRecoYuv,
490                         TComYuv*    pcPredYuv, 
491                         TComYuv*    pcResiYuv )
492{
493  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
494  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
495  UInt    uiStride          = pcRecoYuv->getStride  ();
496  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
497  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
498  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
499 
500  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
501  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
502 
503  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
504 
505  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
506  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
507  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
508  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
509  //===== init availability pattern =====
510  Bool  bAboveAvail = false;
511  Bool  bLeftAvail  = false;
512  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
513  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
514                                     m_pcPrediction->getPredicBuf       (),
515                                     m_pcPrediction->getPredicBufWidth  (),
516                                     m_pcPrediction->getPredicBufHeight (),
517                                     bAboveAvail, bLeftAvail );
518 
519  //===== get prediction signal =====
520  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
521 
522  //===== inverse transform =====
523  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
524
525  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
526  assert(scalingListType < 6);
527  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
528
529 
530  //===== reconstruction =====
531  Pel* pPred      = piPred;
532  Pel* pResi      = piResi;
533  Pel* pReco      = piReco;
534  Pel* pRecIPred  = piRecIPred;
535  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
536  {
537    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
538    {
539      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
540      pRecIPred[ uiX ] = pReco[ uiX ];
541    }
542    pPred     += uiStride;
543    pResi     += uiStride;
544    pReco     += uiStride;
545    pRecIPred += uiRecIPredStride;
546  }
547}
548
549
550Void
551TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
552                           UInt        uiTrDepth,
553                           UInt        uiAbsPartIdx,
554                           TComYuv*    pcRecoYuv,
555                           TComYuv*    pcPredYuv, 
556                           TComYuv*    pcResiYuv,
557                           UInt        uiChromaId )
558{
559  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
560  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
561
562  if( uiLog2TrSize == 2 )
563  {
564    assert( uiTrDepth > 0 );
565    uiTrDepth--;
566    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
567    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
568    if( !bFirstQ )
569    {
570      return;
571    }
572  }
573 
574  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
575  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
576  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
577  UInt      uiStride          = pcRecoYuv->getCStride ();
578  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
579  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
580  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
581 
582  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
583  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
584 
585  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
586 
587  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
588  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
589  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
590  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
591  //===== init availability pattern =====
592  Bool  bAboveAvail = false;
593  Bool  bLeftAvail  = false;
594  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
595
596  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
597                                           m_pcPrediction->getPredicBuf       (),
598                                           m_pcPrediction->getPredicBufWidth  (),
599                                           m_pcPrediction->getPredicBufHeight (),
600                                           bAboveAvail, bLeftAvail );
601  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
602 
603  //===== get prediction signal =====
604  {
605    if( uiChromaPredMode == DM_CHROMA_IDX )
606    {
607      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
608    }
609    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
610  }
611
612  //===== inverse transform =====
613  Int curChromaQpOffset;
614  if(eText == TEXT_CHROMA_U)
615  {
616    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
617  }
618  else
619  {
620    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
621  }
622  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
623
624  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
625  assert(scalingListType < 6);
626  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
627
628  //===== reconstruction =====
629  Pel* pPred      = piPred;
630  Pel* pResi      = piResi;
631  Pel* pReco      = piReco;
632  Pel* pRecIPred  = piRecIPred;
633  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
634  {
635    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
636    {
637      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
638      pRecIPred[ uiX ] = pReco[ uiX ];
639    }
640    pPred     += uiStride;
641    pResi     += uiStride;
642    pReco     += uiStride;
643    pRecIPred += uiRecIPredStride;
644  }
645}
646
647
648Void
649TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
650{
651  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
652  UInt  uiNumPart     = pcCU->getNumPartInter();
653  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
654 
655  if (pcCU->getIPCMFlag(0))
656  {
657    xReconPCM( pcCU, uiDepth );
658    return;
659  }
660
661  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
662  {
663    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
664  } 
665
666  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
667  {
668    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
669  }
670
671}
672
673/** Function for deriving recontructed PU/CU Luma sample with QTree structure
674 * \param pcCU pointer of current CU
675 * \param uiTrDepth current tranform split depth
676 * \param uiAbsPartIdx  part index
677 * \param pcRecoYuv pointer to reconstructed sample arrays
678 * \param pcPredYuv pointer to prediction sample arrays
679 * \param pcResiYuv pointer to residue sample arrays
680 *
681 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
682 */
683Void
684TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
685                     UInt        uiTrDepth,
686                     UInt        uiAbsPartIdx,
687                     TComYuv*    pcRecoYuv,
688                     TComYuv*    pcPredYuv, 
689                     TComYuv*    pcResiYuv )
690{
691  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
692  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
693  if( uiTrMode == uiTrDepth )
694  {
695    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
696  }
697  else
698  {
699    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
700    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
701    {
702      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
703    }
704  }
705}
706
707/** Function for deriving recontructed PU/CU chroma samples with QTree structure
708 * \param pcCU pointer of current CU
709 * \param uiTrDepth current tranform split depth
710 * \param uiAbsPartIdx  part index
711 * \param pcRecoYuv pointer to reconstructed sample arrays
712 * \param pcPredYuv pointer to prediction sample arrays
713 * \param pcResiYuv pointer to residue sample arrays
714 *
715 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
716 */
717Void
718TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
719                     UInt        uiTrDepth,
720                     UInt        uiAbsPartIdx,
721                     TComYuv*    pcRecoYuv,
722                     TComYuv*    pcPredYuv, 
723                     TComYuv*    pcResiYuv )
724{
725  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
726  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
727  if( uiTrMode == uiTrDepth )
728  {
729    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
730    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
731  }
732  else
733  {
734    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
735    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
736    {
737      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
738    }
739  }
740}
741
742Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
743{
744  UInt uiCUAddr = pcCU->getAddr();
745 
746  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
747 
748  return;
749}
750
751Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
752{
753  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
754  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
755  TCoeff* piCoeff;
756 
757  Pel*    pResi;
758  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
759 
760  // Y
761  piCoeff = pcCU->getCoeffY();
762  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
763
764  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
765
766  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
767 
768  // Cb and Cr
769  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
770  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
771
772  uiWidth  >>= 1;
773  uiHeight >>= 1;
774  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
775  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
776
777  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
778  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
779
780  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
781  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
782}
783
784/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
785 * \param pcCU pointer to current CU
786 * \param uiPartIdx part index
787 * \param piPCM pointer to PCM code arrays
788 * \param piReco pointer to reconstructed sample arrays
789 * \param uiStride stride of reconstructed sample arrays
790 * \param uiWidth CU width
791 * \param uiHeight CU height
792 * \param ttText texture component type
793 * \returns Void
794 */
795Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
796{
797  UInt uiX, uiY;
798  Pel* piPicReco;
799  UInt uiPicStride;
800  UInt uiPcmLeftShiftBit; 
801
802  if( ttText == TEXT_LUMA )
803  {
804    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
805    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
806    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
807  }
808  else
809  {
810    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
811
812    if( ttText == TEXT_CHROMA_U )
813    {
814      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
815    }
816    else
817    {
818      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
819    }
820    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
821  }
822
823  for( uiY = 0; uiY < uiHeight; uiY++ )
824  {
825    for( uiX = 0; uiX < uiWidth; uiX++ )
826    {
827      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
828      piPicReco[uiX] = piReco[uiX];
829    }
830    piPCM += uiWidth;
831    piReco += uiStride;
832    piPicReco += uiPicStride;
833  }
834}
835
836/** Function for reconstructing a PCM mode CU.
837 * \param pcCU pointer to current CU
838 * \param uiDepth CU Depth
839 * \returns Void
840 */
841Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
842{
843  // Luma
844  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
845  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
846
847  Pel* piPcmY = pcCU->getPCMSampleY();
848  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
849
850  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
851
852  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
853
854  // Cb and Cr
855  UInt uiCWidth  = (uiWidth>>1);
856  UInt uiCHeight = (uiHeight>>1);
857
858  Pel* piPcmCb = pcCU->getPCMSampleCb();
859  Pel* piPcmCr = pcCU->getPCMSampleCr();
860  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
861  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
862
863  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
864
865  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
866  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
867}
868
869/** Function for filling the PCM buffer of a CU using its reconstructed sample array
870 * \param pcCU pointer to current CU
871 * \param uiDepth CU Depth
872 * \returns Void
873 */
874Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
875{
876  // Luma
877  UInt width  = (g_uiMaxCUWidth >> depth);
878  UInt height = (g_uiMaxCUHeight >> depth);
879
880  Pel* pPcmY = pCU->getPCMSampleY();
881  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
882
883  UInt stride = m_ppcYuvReco[depth]->getStride();
884
885  for(Int y = 0; y < height; y++ )
886  {
887    for(Int x = 0; x < width; x++ )
888    {
889      pPcmY[x] = pRecoY[x];
890    }
891    pPcmY += width;
892    pRecoY += stride;
893  }
894
895  // Cb and Cr
896  UInt widthC  = (width>>1);
897  UInt heightC = (height>>1);
898
899  Pel* pPcmCb = pCU->getPCMSampleCb();
900  Pel* pPcmCr = pCU->getPCMSampleCr();
901  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
902  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
903
904  UInt strideC = m_ppcYuvReco[depth]->getCStride();
905
906  for(Int y = 0; y < heightC; y++ )
907  {
908    for(Int x = 0; x < widthC; x++ )
909    {
910      pPcmCb[x] = pRecoCb[x];
911      pPcmCr[x] = pRecoCr[x];
912    }
913    pPcmCr += widthC;
914    pPcmCb += widthC;
915    pRecoCb += strideC;
916    pRecoCr += strideC;
917  }
918
919}
920
921//! \}
Note: See TracBrowser for help on using the repository browser.