source: 3DVCSoftware/branches/HTM-14.0-MV-draft-3/source/Lib/TLibDecoder/TDecCu.cpp @ 1213

Last change on this file since 1213 was 1191, checked in by tech, 10 years ago

Removed 3D-HEVC.

  • Property svn:eol-style set to native
File size: 35.0 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-2015, 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#if H_MV_ENC_DEC_TRAC
207  DTRACE_CU_S("=========== coding_quadtree ===========\n")
208  DTRACE_CU("x0", uiLPelX)
209  DTRACE_CU("x1", uiTPelY)
210  DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth)
211  DTRACE_CU("cqtDepth"  , uiDepth)
212#endif
213
214  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
215  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
216  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
217  {
218    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
219  }
220  else
221  {
222    bBoundary = true;
223  }
224 
225  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
226  {
227    UInt uiIdx = uiAbsPartIdx;
228    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
229    {
230      setdQPFlag(true);
231      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
232    }
233
234    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
235    {
236      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
237      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
238     
239      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
240      if ( bSubInSlice )
241      {
242        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
243        {
244          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
245        }
246        else
247        {
248          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
249        }
250      }
251     
252      uiIdx += uiQNumParts;
253    }
254    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
255    {
256      if ( getdQPFlag() )
257      {
258        UInt uiQPSrcPartIdx;
259        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
260        {
261          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
262        }
263        else
264        {
265          uiQPSrcPartIdx = uiAbsPartIdx;
266        }
267        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
268      }
269    }
270    return;
271  }
272 
273#if H_MV_ENC_DEC_TRAC
274  DTRACE_CU_S("=========== coding_unit ===========\n")
275#if H_MV_ENC_DEC_TRAC
276#if ENC_DEC_TRACE
277    stopAtPos  ( pcCU->getSlice()->getPOC(), 
278    pcCU->getSlice()->getLayerId(), 
279    uiLPelX,
280    uiTPelY,
281    uiRPelX-uiLPelX+1, 
282    uiBPelY-uiTPelY+1);
283#endif
284#endif
285
286#endif
287
288  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
289  {
290    setdQPFlag(true);
291    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
292  }
293  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
294  {
295    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
296  }
297 
298  // decode CU mode and the partition size
299  if( !pcCU->getSlice()->isIntra())
300  {
301    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
302  }
303 
304  if( pcCU->isSkipped(uiAbsPartIdx) )
305  {
306#if H_MV_ENC_DEC_TRAC
307    DTRACE_PU_S("=========== prediction_unit ===========\n")
308    DTRACE_PU("x0", uiLPelX)
309    DTRACE_PU("x1", uiTPelY)
310#endif
311    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
312    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
313    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
314    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
315    Int numValidMergeCand = 0;
316    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
317    {
318      uhInterDirNeighbours[ui] = 0;
319    }
320    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
321    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
322
323    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
324    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
325
326    TComMv cTmpMv( 0, 0 );
327    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
328    {       
329      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
330      {
331        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
332        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
333        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
334        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
335#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
336        if ( g_decTraceMvFromMerge )
337        {       
338          if ( uiRefListIdx == 0 )
339          {
340            DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
341            DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
342            DTRACE_PU( "refIdxL0   ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
343          }
344          else
345          {
346            DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor());
347            DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer());
348            DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx());
349          }
350        }
351#endif
352      }
353    }
354
355    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
356    return;
357  }
358  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
359  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
360
361  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
362  {
363    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
364
365    if(pcCU->getIPCMFlag(uiAbsPartIdx))
366    {
367      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
368      return;
369    }
370  }
371
372  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
373  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
374 
375  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
376  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
377
378  // Coefficient decoding
379  Bool bCodeDQP = getdQPFlag();
380  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
381  setdQPFlag( bCodeDQP );
382  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
383}
384
385Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
386{
387  if(  pcCU->getSlice()->getPPS()->getUseDQP())
388  {
389    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
390  }
391
392  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
393}
394
395Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
396{
397  TComPic* pcPic = pcCU->getPic();
398  Bool bBoundary = false;
399  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
400  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
401  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
402  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
403 
404  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
405  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
406  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
407  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
408  {
409    bBoundary = true;
410  }
411 
412  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
413  {
414    UInt uiNextDepth = uiDepth + 1;
415    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
416    UInt uiIdx = uiAbsPartIdx;
417    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
418    {
419      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
420      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
421     
422      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
423      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
424      {
425        xDecompressCU(pcCU, uiIdx, uiNextDepth );
426      }
427     
428      uiIdx += uiQNumParts;
429    }
430    return;
431  }
432  // Residual reconstruction
433  m_ppcYuvResi[uiDepth]->clear();
434 
435  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
436
437  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
438  {
439    case MODE_INTER:
440      xReconInter( m_ppcCU[uiDepth], uiDepth );
441      break;
442    case MODE_INTRA:
443      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
444      break;
445    default:
446      assert(0);
447      break;
448  }
449  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
450  {
451    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
452  }
453 
454  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
455}
456
457Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
458{
459 
460  // inter prediction
461  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
462 
463  // inter recon
464  xDecodeInterTexture( pcCU, 0, uiDepth );
465 
466  // clip for only non-zero cbp case
467  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
468  {
469    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
470  }
471  else
472  {
473    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
474  }
475}
476
477
478
479
480Void
481TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
482                         UInt        uiTrDepth,
483                         UInt        uiAbsPartIdx,
484                         TComYuv*    pcRecoYuv,
485                         TComYuv*    pcPredYuv, 
486                         TComYuv*    pcResiYuv )
487{
488  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
489  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
490  UInt    uiStride          = pcRecoYuv->getStride  ();
491  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
492  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
493  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
494 
495  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
496  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
497 
498  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
499 
500  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
501  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
502  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
503  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
504  //===== init availability pattern =====
505  Bool  bAboveAvail = false;
506  Bool  bLeftAvail  = false;
507  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
508  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
509                                     m_pcPrediction->getPredicBuf       (),
510                                     m_pcPrediction->getPredicBufWidth  (),
511                                     m_pcPrediction->getPredicBufHeight (),
512                                     bAboveAvail, bLeftAvail );
513 
514  //===== get prediction signal =====
515  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
516 
517  if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) )
518  {
519  //===== inverse transform =====
520  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
521
522  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
523    assert(scalingListType < SCALING_LIST_NUM);
524  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
525
526 
527  //===== reconstruction =====
528  Pel* pPred      = piPred;
529  Pel* pResi      = piResi;
530  Pel* pReco      = piReco;
531  Pel* pRecIPred  = piRecIPred;
532  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
533  {
534    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
535    {
536      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
537      pRecIPred[ uiX ] = pReco[ uiX ];
538    }
539    pPred     += uiStride;
540    pResi     += uiStride;
541    pReco     += uiStride;
542    pRecIPred += uiRecIPredStride;
543  }
544}
545  else
546  {
547    //===== reconstruction =====
548    Pel* pPred      = piPred;
549    Pel* pReco      = piReco;
550    Pel* pRecIPred  = piRecIPred;
551    for ( Int y = 0; y < uiHeight; y++ )
552    {
553      for ( Int x = 0; x < uiWidth; x++ )
554      {
555        pReco    [ x ] = pPred[ x ];
556        pRecIPred[ x ] = pReco[ x ];
557      }
558      pPred     += uiStride;
559      pReco     += uiStride;
560      pRecIPred += uiRecIPredStride;
561    }
562  }
563}
564
565
566Void
567TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
568                           UInt        uiTrDepth,
569                           UInt        uiAbsPartIdx,
570                           TComYuv*    pcRecoYuv,
571                           TComYuv*    pcPredYuv, 
572                           TComYuv*    pcResiYuv,
573                           UInt        uiChromaId )
574{
575  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
576  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
577
578  if( uiLog2TrSize == 2 )
579  {
580    assert( uiTrDepth > 0 );
581    uiTrDepth--;
582    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
583    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
584    if( !bFirstQ )
585    {
586      return;
587    }
588  }
589
590  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
591  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
592  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
593  UInt      uiStride          = pcRecoYuv->getCStride ();
594  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
595  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
596  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
597
598  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
599  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
600
601  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
602
603  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
604  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
605  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
606  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
607  //===== init availability pattern =====
608  Bool  bAboveAvail = false;
609  Bool  bLeftAvail  = false;
610  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
611
612  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
613    m_pcPrediction->getPredicBuf       (),
614    m_pcPrediction->getPredicBufWidth  (),
615    m_pcPrediction->getPredicBufHeight (),
616    bAboveAvail, bLeftAvail );
617  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
618
619  //===== get prediction signal =====
620  {
621    if( uiChromaPredMode == DM_CHROMA_IDX )
622    {
623      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
624    }
625    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
626  }
627
628  if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) )
629  {
630    //===== inverse transform =====
631    Int curChromaQpOffset;
632    if(eText == TEXT_CHROMA_U)
633    {
634      curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
635    }
636    else
637    {
638      curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
639    }
640    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
641
642    Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
643    assert(scalingListType < SCALING_LIST_NUM);
644    m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
645
646    //===== reconstruction =====
647    Pel* pPred      = piPred;
648    Pel* pResi      = piResi;
649    Pel* pReco      = piReco;
650    Pel* pRecIPred  = piRecIPred;
651    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
652    {
653      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
654      {
655        pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
656        pRecIPred[ uiX ] = pReco[ uiX ];
657      }
658      pPred     += uiStride;
659      pResi     += uiStride;
660      pReco     += uiStride;
661      pRecIPred += uiRecIPredStride;
662    }
663  }
664  else
665  {
666    //===== reconstruction =====
667    Pel* pPred      = piPred;
668    Pel* pReco      = piReco;
669    Pel* pRecIPred  = piRecIPred;
670    for ( Int y = 0; y < uiHeight; y++ )
671    {
672      for ( Int x = 0; x < uiWidth; x++ )
673      {
674        pReco    [ x ] = pPred[ x ];
675        pRecIPred[ x ] = pReco[ x ];
676      }
677      pPred     += uiStride;
678      pReco     += uiStride;
679      pRecIPred += uiRecIPredStride;
680    }   
681  }
682}
683
684
685Void
686TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
687{
688  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
689  UInt  uiNumPart     = pcCU->getNumPartitions();
690  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
691 
692  if (pcCU->getIPCMFlag(0))
693  {
694    xReconPCM( pcCU, uiDepth );
695    return;
696  }
697
698  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
699  {
700    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
701  } 
702
703  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
704  {
705    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
706  }
707
708}
709
710
711/** Function for deriving recontructed PU/CU Luma sample with QTree structure
712 * \param pcCU pointer of current CU
713 * \param uiTrDepth current tranform split depth
714 * \param uiAbsPartIdx  part index
715 * \param pcRecoYuv pointer to reconstructed sample arrays
716 * \param pcPredYuv pointer to prediction sample arrays
717 * \param pcResiYuv pointer to residue sample arrays
718 *
719 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
720 */
721Void
722TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
723                     UInt        uiTrDepth,
724                     UInt        uiAbsPartIdx,
725                     TComYuv*    pcRecoYuv,
726                     TComYuv*    pcPredYuv, 
727                     TComYuv*    pcResiYuv )
728{
729  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
730  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
731  if( uiTrMode == uiTrDepth )
732  {
733    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
734  }
735  else
736  {
737    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
738    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
739    {
740      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
741    }
742  }
743}
744
745/** Function for deriving recontructed PU/CU chroma samples with QTree structure
746 * \param pcCU pointer of current CU
747 * \param uiTrDepth current tranform split depth
748 * \param uiAbsPartIdx  part index
749 * \param pcRecoYuv pointer to reconstructed sample arrays
750 * \param pcPredYuv pointer to prediction sample arrays
751 * \param pcResiYuv pointer to residue sample arrays
752 *
753 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
754 */
755Void
756TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
757                     UInt        uiTrDepth,
758                     UInt        uiAbsPartIdx,
759                     TComYuv*    pcRecoYuv,
760                     TComYuv*    pcPredYuv, 
761                     TComYuv*    pcResiYuv )
762{
763  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
764  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
765  if( uiTrMode == uiTrDepth )
766  {
767    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
768    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
769  }
770  else
771  {
772    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
773    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
774    {
775      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
776    }
777  }
778}
779
780Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
781{
782  UInt uiCUAddr = pcCU->getAddr();
783 
784  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
785 
786  return;
787}
788
789Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
790{
791  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
792  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
793  TCoeff* piCoeff;
794 
795  Pel*    pResi;
796  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
797 
798  // Y
799  piCoeff = pcCU->getCoeffY();
800  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
801
802  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
803
804  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
805 
806  // Cb and Cr
807  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
808  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
809
810  uiWidth  >>= 1;
811  uiHeight >>= 1;
812  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
813  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
814
815  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
816  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
817
818  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
819  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
820}
821
822/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
823 * \param pcCU pointer to current CU
824 * \param uiPartIdx part index
825 * \param piPCM pointer to PCM code arrays
826 * \param piReco pointer to reconstructed sample arrays
827 * \param uiStride stride of reconstructed sample arrays
828 * \param uiWidth CU width
829 * \param uiHeight CU height
830 * \param ttText texture component type
831 * \returns Void
832 */
833Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
834{
835  UInt uiX, uiY;
836  Pel* piPicReco;
837  UInt uiPicStride;
838  UInt uiPcmLeftShiftBit; 
839
840  if( ttText == TEXT_LUMA )
841  {
842    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
843    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
844    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
845  }
846  else
847  {
848    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
849
850    if( ttText == TEXT_CHROMA_U )
851    {
852      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
853    }
854    else
855    {
856      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
857    }
858    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
859  }
860
861  for( uiY = 0; uiY < uiHeight; uiY++ )
862  {
863    for( uiX = 0; uiX < uiWidth; uiX++ )
864    {
865      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
866      piPicReco[uiX] = piReco[uiX];
867    }
868    piPCM += uiWidth;
869    piReco += uiStride;
870    piPicReco += uiPicStride;
871  }
872}
873
874/** Function for reconstructing a PCM mode CU.
875 * \param pcCU pointer to current CU
876 * \param uiDepth CU Depth
877 * \returns Void
878 */
879Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
880{
881  // Luma
882  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
883  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
884
885  Pel* piPcmY = pcCU->getPCMSampleY();
886  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
887
888  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
889
890  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
891
892  // Cb and Cr
893  UInt uiCWidth  = (uiWidth>>1);
894  UInt uiCHeight = (uiHeight>>1);
895
896  Pel* piPcmCb = pcCU->getPCMSampleCb();
897  Pel* piPcmCr = pcCU->getPCMSampleCr();
898  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
899  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
900
901  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
902
903  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
904  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
905}
906
907/** Function for filling the PCM buffer of a CU using its reconstructed sample array
908 * \param pcCU pointer to current CU
909 * \param uiDepth CU Depth
910 * \returns Void
911 */
912Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
913{
914  // Luma
915  UInt width  = (g_uiMaxCUWidth >> depth);
916  UInt height = (g_uiMaxCUHeight >> depth);
917
918  Pel* pPcmY = pCU->getPCMSampleY();
919  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
920
921  UInt stride = m_ppcYuvReco[depth]->getStride();
922
923  for(Int y = 0; y < height; y++ )
924  {
925    for(Int x = 0; x < width; x++ )
926    {
927      pPcmY[x] = pRecoY[x];
928    }
929    pPcmY += width;
930    pRecoY += stride;
931  }
932
933  // Cb and Cr
934  UInt widthC  = (width>>1);
935  UInt heightC = (height>>1);
936
937  Pel* pPcmCb = pCU->getPCMSampleCb();
938  Pel* pPcmCr = pCU->getPCMSampleCr();
939  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
940  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
941
942  UInt strideC = m_ppcYuvReco[depth]->getCStride();
943
944  for(Int y = 0; y < heightC; y++ )
945  {
946    for(Int x = 0; x < widthC; x++ )
947    {
948      pPcmCb[x] = pRecoCb[x];
949      pPcmCr[x] = pRecoCr[x];
950    }
951    pPcmCr += widthC;
952    pPcmCb += widthC;
953    pRecoCb += strideC;
954    pRecoCr += strideC;
955  }
956
957}
958
959//! \}
Note: See TracBrowser for help on using the repository browser.