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

Last change on this file since 510 was 510, checked in by mitsubishi-htm, 11 years ago

-VSP compensation part migration, not fully tested, intermediate version

  • Property svn:eol-style set to native
File size: 35.5 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecCu.cpp
35    \brief    CU decoder class
36*/
37
38#include "TDecCu.h"
39
40//! \ingroup TLibDecoder
41//! \{
42
43// ====================================================================================================================
44// Constructor / destructor / create / destroy
45// ====================================================================================================================
46
47TDecCu::TDecCu()
48{
49  m_ppcYuvResi = NULL;
50  m_ppcYuvReco = NULL;
51  m_ppcCU      = NULL;
52}
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 && H_3D_IV_MERGE
284    if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() ))
285#else
286#if H_3D_ARP
287    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
288#else
289#if H_3D_IV_MERGE
290    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
291#else
292    if (0)
293#endif
294#endif
295#endif
296    {
297      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
298      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
299      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
300      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
301      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
302      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
303      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
304      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
305#if H_3D_NBDV_REF
306      if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() ))  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
307        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
308      else
309#endif
310        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
311
312      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
313      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
314      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
315      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
316     }
317  }
318#endif
319  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
320  {
321    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
322  }
323 
324  // decode CU mode and the partition size
325  if( !pcCU->getSlice()->isIntra())
326  {
327    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
328  }
329 
330  if( pcCU->isSkipped(uiAbsPartIdx) )
331  {
332    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
333    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
334#if H_3D_IV_MERGE
335    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
336    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
337    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
338#else
339    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
340    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
341#endif
342    Int numValidMergeCand = 0;
343    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
344    {
345      uhInterDirNeighbours[ui] = 0;
346    }
347    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
348    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
349
350#if H_3D_VSP
351    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
352    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
353
354    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, numValidMergeCand, uiMergeIndex );
355    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
356#else
357    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
358#endif
359
360    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
361
362    TComMv cTmpMv( 0, 0 );
363    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
364    {       
365      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
366      {
367        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
368        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
369        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
370        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
371      }
372    }
373#if H_3D_IC
374    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
375#endif
376#if H_3D_ARP
377    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
378#endif
379    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
380    return;
381  }
382
383  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
384  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
385
386  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
387  {
388    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
389
390    if(pcCU->getIPCMFlag(uiAbsPartIdx))
391    {
392      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
393      return;
394    }
395  }
396
397  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
398  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
399 
400  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
401  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
402#if H_3D_IC
403  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
404#endif
405#if H_3D_ARP
406  m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth ); 
407#endif 
408  // Coefficient decoding
409  Bool bCodeDQP = getdQPFlag();
410  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
411  setdQPFlag( bCodeDQP );
412  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
413}
414
415Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
416{
417  if(  pcCU->getSlice()->getPPS()->getUseDQP())
418  {
419    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
420  }
421
422  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
423}
424
425Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
426{
427  TComPic* pcPic = pcCU->getPic();
428 
429  Bool bBoundary = false;
430  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
431  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
432  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
433  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
434 
435  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
436  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
437  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
438  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
439  {
440    bBoundary = true;
441  }
442 
443  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
444  {
445    UInt uiNextDepth = uiDepth + 1;
446    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
447    UInt uiIdx = uiAbsPartIdx;
448    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
449    {
450      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
451      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
452     
453      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
454      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
455      {
456        xDecompressCU(pcCU, uiIdx, uiNextDepth );
457      }
458     
459      uiIdx += uiQNumParts;
460    }
461    return;
462  }
463 
464  // Residual reconstruction
465  m_ppcYuvResi[uiDepth]->clear();
466 
467  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
468 
469  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
470  {
471    case MODE_INTER:
472      xReconInter( m_ppcCU[uiDepth], uiDepth );
473      break;
474    case MODE_INTRA:
475      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
476      break;
477    default:
478      assert(0);
479      break;
480  }
481  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
482  {
483    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
484  }
485 
486  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
487}
488
489Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
490{
491 
492  // inter prediction
493  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
494 
495  // inter recon
496  xDecodeInterTexture( pcCU, 0, uiDepth );
497 
498  // clip for only non-zero cbp case
499  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
500  {
501    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
502  }
503  else
504  {
505    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
506  }
507}
508
509Void
510TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
511                         UInt        uiTrDepth,
512                         UInt        uiAbsPartIdx,
513                         TComYuv*    pcRecoYuv,
514                         TComYuv*    pcPredYuv, 
515                         TComYuv*    pcResiYuv )
516{
517  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
518  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
519  UInt    uiStride          = pcRecoYuv->getStride  ();
520  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
521  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
522  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
523 
524  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
525  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
526 
527  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
528 
529  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
530  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
531  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
532  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
533  //===== init availability pattern =====
534  Bool  bAboveAvail = false;
535  Bool  bLeftAvail  = false;
536  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
537  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
538                                     m_pcPrediction->getPredicBuf       (),
539                                     m_pcPrediction->getPredicBufWidth  (),
540                                     m_pcPrediction->getPredicBufHeight (),
541                                     bAboveAvail, bLeftAvail );
542 
543  //===== get prediction signal =====
544  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
545 
546  //===== inverse transform =====
547  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
548
549  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
550  assert(scalingListType < 6);
551  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
552
553 
554  //===== reconstruction =====
555  Pel* pPred      = piPred;
556  Pel* pResi      = piResi;
557  Pel* pReco      = piReco;
558  Pel* pRecIPred  = piRecIPred;
559  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
560  {
561    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
562    {
563      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
564      pRecIPred[ uiX ] = pReco[ uiX ];
565    }
566    pPred     += uiStride;
567    pResi     += uiStride;
568    pReco     += uiStride;
569    pRecIPred += uiRecIPredStride;
570  }
571}
572
573
574Void
575TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
576                           UInt        uiTrDepth,
577                           UInt        uiAbsPartIdx,
578                           TComYuv*    pcRecoYuv,
579                           TComYuv*    pcPredYuv, 
580                           TComYuv*    pcResiYuv,
581                           UInt        uiChromaId )
582{
583  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
584  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
585
586  if( uiLog2TrSize == 2 )
587  {
588    assert( uiTrDepth > 0 );
589    uiTrDepth--;
590    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
591    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
592    if( !bFirstQ )
593    {
594      return;
595    }
596  }
597 
598  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
599  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
600  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
601  UInt      uiStride          = pcRecoYuv->getCStride ();
602  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
603  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
604  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
605 
606  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
607  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
608 
609  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
610 
611  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
612  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
613  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
614  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
615  //===== init availability pattern =====
616  Bool  bAboveAvail = false;
617  Bool  bLeftAvail  = false;
618  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
619
620  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
621                                           m_pcPrediction->getPredicBuf       (),
622                                           m_pcPrediction->getPredicBufWidth  (),
623                                           m_pcPrediction->getPredicBufHeight (),
624                                           bAboveAvail, bLeftAvail );
625  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
626 
627  //===== get prediction signal =====
628  {
629    if( uiChromaPredMode == DM_CHROMA_IDX )
630    {
631      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
632    }
633    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
634  }
635
636  //===== inverse transform =====
637  Int curChromaQpOffset;
638  if(eText == TEXT_CHROMA_U)
639  {
640    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
641  }
642  else
643  {
644    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
645  }
646  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
647
648  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
649  assert(scalingListType < 6);
650  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
651
652  //===== reconstruction =====
653  Pel* pPred      = piPred;
654  Pel* pResi      = piResi;
655  Pel* pReco      = piReco;
656  Pel* pRecIPred  = piRecIPred;
657  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
658  {
659    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
660    {
661      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
662      pRecIPred[ uiX ] = pReco[ uiX ];
663    }
664    pPred     += uiStride;
665    pResi     += uiStride;
666    pReco     += uiStride;
667    pRecIPred += uiRecIPredStride;
668  }
669}
670
671
672Void
673TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
674{
675  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
676  UInt  uiNumPart     = pcCU->getNumPartInter();
677  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
678 
679  if (pcCU->getIPCMFlag(0))
680  {
681    xReconPCM( pcCU, uiDepth );
682    return;
683  }
684
685  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
686  {
687    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
688  } 
689
690  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
691  {
692    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
693  }
694
695}
696
697/** Function for deriving recontructed PU/CU Luma sample with QTree structure
698 * \param pcCU pointer of current CU
699 * \param uiTrDepth current tranform split depth
700 * \param uiAbsPartIdx  part index
701 * \param pcRecoYuv pointer to reconstructed sample arrays
702 * \param pcPredYuv pointer to prediction sample arrays
703 * \param pcResiYuv pointer to residue sample arrays
704 *
705 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
706 */
707Void
708TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
709                     UInt        uiTrDepth,
710                     UInt        uiAbsPartIdx,
711                     TComYuv*    pcRecoYuv,
712                     TComYuv*    pcPredYuv, 
713                     TComYuv*    pcResiYuv )
714{
715  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
716  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
717  if( uiTrMode == uiTrDepth )
718  {
719    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
720  }
721  else
722  {
723    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
724    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
725    {
726      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
727    }
728  }
729}
730
731/** Function for deriving recontructed PU/CU chroma samples with QTree structure
732 * \param pcCU pointer of current CU
733 * \param uiTrDepth current tranform split depth
734 * \param uiAbsPartIdx  part index
735 * \param pcRecoYuv pointer to reconstructed sample arrays
736 * \param pcPredYuv pointer to prediction sample arrays
737 * \param pcResiYuv pointer to residue sample arrays
738 *
739 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
740 */
741Void
742TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
743                     UInt        uiTrDepth,
744                     UInt        uiAbsPartIdx,
745                     TComYuv*    pcRecoYuv,
746                     TComYuv*    pcPredYuv, 
747                     TComYuv*    pcResiYuv )
748{
749  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
750  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
751  if( uiTrMode == uiTrDepth )
752  {
753    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
754    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
755  }
756  else
757  {
758    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
759    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
760    {
761      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
762    }
763  }
764}
765
766Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
767{
768  UInt uiCUAddr = pcCU->getAddr();
769 
770  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
771 
772  return;
773}
774
775Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
776{
777  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
778  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
779  TCoeff* piCoeff;
780 
781  Pel*    pResi;
782  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
783 
784  // Y
785  piCoeff = pcCU->getCoeffY();
786  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
787
788  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
789
790  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
791 
792  // Cb and Cr
793  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
794  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
795
796  uiWidth  >>= 1;
797  uiHeight >>= 1;
798  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
799  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
800
801  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
802  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
803
804  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
805  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
806}
807
808/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
809 * \param pcCU pointer to current CU
810 * \param uiPartIdx part index
811 * \param piPCM pointer to PCM code arrays
812 * \param piReco pointer to reconstructed sample arrays
813 * \param uiStride stride of reconstructed sample arrays
814 * \param uiWidth CU width
815 * \param uiHeight CU height
816 * \param ttText texture component type
817 * \returns Void
818 */
819Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
820{
821  UInt uiX, uiY;
822  Pel* piPicReco;
823  UInt uiPicStride;
824  UInt uiPcmLeftShiftBit; 
825
826  if( ttText == TEXT_LUMA )
827  {
828    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
829    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
830    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
831  }
832  else
833  {
834    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
835
836    if( ttText == TEXT_CHROMA_U )
837    {
838      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
839    }
840    else
841    {
842      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
843    }
844    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
845  }
846
847  for( uiY = 0; uiY < uiHeight; uiY++ )
848  {
849    for( uiX = 0; uiX < uiWidth; uiX++ )
850    {
851      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
852      piPicReco[uiX] = piReco[uiX];
853    }
854    piPCM += uiWidth;
855    piReco += uiStride;
856    piPicReco += uiPicStride;
857  }
858}
859
860/** Function for reconstructing a PCM mode CU.
861 * \param pcCU pointer to current CU
862 * \param uiDepth CU Depth
863 * \returns Void
864 */
865Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
866{
867  // Luma
868  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
869  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
870
871  Pel* piPcmY = pcCU->getPCMSampleY();
872  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
873
874  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
875
876  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
877
878  // Cb and Cr
879  UInt uiCWidth  = (uiWidth>>1);
880  UInt uiCHeight = (uiHeight>>1);
881
882  Pel* piPcmCb = pcCU->getPCMSampleCb();
883  Pel* piPcmCr = pcCU->getPCMSampleCr();
884  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
885  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
886
887  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
888
889  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
890  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
891}
892
893/** Function for filling the PCM buffer of a CU using its reconstructed sample array
894 * \param pcCU pointer to current CU
895 * \param uiDepth CU Depth
896 * \returns Void
897 */
898Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
899{
900  // Luma
901  UInt width  = (g_uiMaxCUWidth >> depth);
902  UInt height = (g_uiMaxCUHeight >> depth);
903
904  Pel* pPcmY = pCU->getPCMSampleY();
905  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
906
907  UInt stride = m_ppcYuvReco[depth]->getStride();
908
909  for(Int y = 0; y < height; y++ )
910  {
911    for(Int x = 0; x < width; x++ )
912    {
913      pPcmY[x] = pRecoY[x];
914    }
915    pPcmY += width;
916    pRecoY += stride;
917  }
918
919  // Cb and Cr
920  UInt widthC  = (width>>1);
921  UInt heightC = (height>>1);
922
923  Pel* pPcmCb = pCU->getPCMSampleCb();
924  Pel* pPcmCr = pCU->getPCMSampleCr();
925  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
926  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
927
928  UInt strideC = m_ppcYuvReco[depth]->getCStride();
929
930  for(Int y = 0; y < heightC; y++ )
931  {
932    for(Int x = 0; x < widthC; x++ )
933    {
934      pPcmCb[x] = pRecoCb[x];
935      pPcmCr[x] = pRecoCr[x];
936    }
937    pPcmCr += widthC;
938    pPcmCb += widthC;
939    pRecoCb += strideC;
940    pRecoCr += strideC;
941  }
942
943}
944
945//! \}
Note: See TracBrowser for help on using the repository browser.