source: 3DVCSoftware/branches/HTM-13.0-MV-draft-2/source/Lib/TLibDecoder/TDecCu.cpp

Last change on this file was 1128, checked in by tech, 10 years ago

Removed 3D-HEVC related code.

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