source: 3DVCSoftware/branches/HTM-6.2-dev1-Sharp/source/Lib/TLibDecoder/TDecCu.cpp @ 374

Last change on this file since 374 was 355, checked in by zhang, 12 years ago

JCT3V-D0191 (BVSP clean-ups)

  • Property svn:eol-style set to native
File size: 50.8 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2012, 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#if RWTH_SDC_DLT_B0036
41#define GetDepthValue2Idx(val)     (pcCU->getSlice()->getSPS()->depthValue2idx(val))
42#define GetIdx2DepthValue(val)     (pcCU->getSlice()->getSPS()->idx2DepthValue(val))
43#endif
44
45//! \ingroup TLibDecoder
46//! \{
47
48// ====================================================================================================================
49// Constructor / destructor / create / destroy
50// ====================================================================================================================
51
52TDecCu::TDecCu()
53{
54  m_ppcYuvResi = NULL;
55  m_ppcYuvReco = NULL;
56#if H3D_IVRP
57  m_ppcYuvResPred = NULL;
58#endif
59  m_ppcCU      = NULL;
60}
61
62TDecCu::~TDecCu()
63{
64}
65
66Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
67{
68  m_pcEntropyDecoder  = pcEntropyDecoder;
69  m_pcTrQuant         = pcTrQuant;
70  m_pcPrediction      = pcPrediction;
71}
72
73/**
74 \param    uiMaxDepth    total number of allowable depth
75 \param    uiMaxWidth    largest CU width
76 \param    uiMaxHeight   largest CU height
77 */
78Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
79{
80  m_uiMaxDepth = uiMaxDepth+1;
81 
82  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
83  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
84#if H3D_IVRP
85  m_ppcYuvResPred = new TComYuv*   [m_uiMaxDepth-1];
86#endif
87  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
88 
89  UInt uiNumPartitions;
90  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
91  {
92    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
93    UInt uiWidth  = uiMaxWidth  >> ui;
94    UInt uiHeight = uiMaxHeight >> ui;
95   
96    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight );
97    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
98#if H3D_IVRP
99    m_ppcYuvResPred[ui] = new TComYuv;    m_ppcYuvResPred[ui]->create( uiWidth, uiHeight );
100#endif
101    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
102  }
103 
104  m_bDecodeDQP = false;
105
106  // initialize partition order.
107  UInt* piTmp = &g_auiZscanToRaster[0];
108  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
109  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
110 
111  // initialize conversion matrix from partition index to pel
112  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
113  initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
114}
115
116Void TDecCu::destroy()
117{
118  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
119  {
120    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
121    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
122#if H3D_IVRP
123    m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL;
124#endif
125    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
126  }
127 
128  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
129  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
130#if H3D_IVRP
131  delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL;
132#endif
133  delete [] m_ppcCU     ; m_ppcCU      = NULL;
134}
135
136// ====================================================================================================================
137// Public member functions
138// ====================================================================================================================
139
140/** \param    pcCU        pointer of CU data
141 \param    ruiIsLast   last data?
142 */
143Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
144{
145  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
146  {
147    setdQPFlag(true);
148  }
149
150  pcCU->setNumSucIPCM(0);
151
152  // start from the top level CU
153  xDecodeCU( pcCU, 0, 0, ruiIsLast);
154}
155
156/** \param    pcCU        pointer of CU data
157 */
158Void TDecCu::decompressCU( TComDataCU* pcCU )
159{
160  xDecompressCU( pcCU, pcCU, 0,  0 );
161}
162
163// ====================================================================================================================
164// Protected member functions
165// ====================================================================================================================
166
167/**decode end-of-slice flag
168 * \param pcCU
169 * \param uiAbsPartIdx
170 * \param uiDepth
171 * \returns Bool
172 */
173Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) {
174  UInt uiIsLast;
175  TComPic* pcPic = pcCU->getPic();
176  TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
177  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
178  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
179  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
180  UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity());
181  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
182  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
183
184#if HHI_MPI
185  const UInt uiCUWidth  = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUWidth>>uiDepth  : pcCU->getWidth (uiAbsPartIdx);
186  const UInt uiCUHeight = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUHeight>>uiDepth : pcCU->getHeight(uiAbsPartIdx);
187  if(((uiPosX+uiCUWidth)%uiGranularityWidth==0||(uiPosX+uiCUWidth==uiWidth))
188    &&((uiPosY+uiCUHeight)%uiGranularityWidth==0||(uiPosY+uiCUHeight==uiHeight)))
189#else
190  if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
191    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
192#endif
193  {
194    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
195  }
196  else
197  {
198    uiIsLast=0;
199  }
200 
201  if(uiIsLast) 
202  {
203    if(pcSlice->isNextEntropySlice()&&!pcSlice->isNextSlice()) 
204    {
205      pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
206    }
207    else 
208    {
209      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
210      pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
211    }
212  }
213
214  return uiIsLast>0;
215}
216
217/** decode CU block recursively
218 * \param pcCU
219 * \param uiAbsPartIdx
220 * \param uiDepth
221 * \returns Void
222 */
223
224Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
225{
226  TComPic* pcPic = pcCU->getPic();
227  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
228  UInt uiQNumParts      = uiCurNumParts>>2;
229 
230  Bool bBoundary = false;
231  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
232  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
233  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
234  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
235
236  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
237  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr();
238  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
239  {
240    if(pcCU->getNumSucIPCM() == 0)
241    {
242#if HHI_MPI
243      if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
244#endif
245      m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
246    }
247    else
248    {
249      pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx );
250    }
251  }
252  else
253  {
254    bBoundary = true;
255  }
256 
257  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
258  {
259    UInt uiIdx = uiAbsPartIdx;
260    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
261    {
262      setdQPFlag(true);
263      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
264    }
265
266    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
267    {
268      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
269      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
270     
271      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr();
272      if ( bSubInSlice )
273      {
274        if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
275        {
276          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
277        }
278        else
279        {
280          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
281        }
282      }
283      if(ruiIsLast)
284      {
285        break;
286      }
287     
288      uiIdx += uiQNumParts;
289    }
290    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
291    {
292      if ( getdQPFlag() )
293      {
294        UInt uiQPSrcPartIdx;
295        if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() )
296        {
297          uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU();
298        }
299        else
300        {
301          uiQPSrcPartIdx = uiAbsPartIdx;
302        }
303        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
304      }
305    }
306    return;
307  }
308 
309  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
310  {
311    setdQPFlag(true);
312    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
313  }
314
315  // decode CU mode and the partition size
316  if( !pcCU->getSlice()->isIntra() && pcCU->getNumSucIPCM() == 0 )
317#if HHI_MPI
318  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
319#endif
320  {
321    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
322  }
323 
324  if( pcCU->isSkipped(uiAbsPartIdx) )
325  {
326    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
327    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
328#if H3D_IVMP
329    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
330    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
331    Int numValidMergeCand = 0;
332    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui )
333#else
334    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
335    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
336    Int numValidMergeCand = 0;
337    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
338#endif
339    {
340      uhInterDirNeighbours[ui] = 0;
341    }
342    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
343#if HHI_MPI
344    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
345    {
346      TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
347      pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx );
348
349      UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
350
351      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
352      {
353        const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
354#if MERL_VSP_C0152
355        Int vspIdx = pcTextureCU->getVSPIndex( uiAbsPartIdx + ui);
356        pcCU->setVSPIndex( uiAbsPartIdx + ui, vspIdx);
357#endif
358        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_SKIP );
359        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
360        pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth );
361        pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth );
362        pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth );
363      }
364#if LGE_ILLUCOMP_DEPTH_C0046
365      m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
366#endif
367    }
368    else
369    {
370#endif
371    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
372#if MERL_VSP_C0152
373    Int iVSPIndexTrue[3] = {-1, -1, -1};
374    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue, uiMergeIndex );
375    {
376      Int iVSPIdx = 0;
377      Int numVspIdx;
378      numVspIdx = 3;
379      for (Int i = 0; i < numVspIdx; i++)
380      {
381        if (iVSPIndexTrue[i] == uiMergeIndex)
382          {
383            iVSPIdx = i+1;
384            break;
385          }
386      }
387      pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, 0, uiDepth );  //Initialize the VSP, may change later in get InterMergeCandidates()
388#if QC_BVSP_CleanUP_D0191
389      if(iVSPIdx != 0)
390      {
391        Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
392       cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx);
393      }
394#endif
395    }
396#else
397    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
398#endif
399    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
400
401    TComMv cTmpMv( 0, 0 );
402    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
403    {       
404      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
405      {
406        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
407        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
408        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
409        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
410      }
411    }
412#if LGE_ILLUCOMP_B0045
413    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
414#endif
415#if HHI_MPI
416    }
417#endif
418    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
419    return;
420  }
421
422#if HHI_MPI
423  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
424  {
425#endif
426  if( pcCU->getNumSucIPCM() == 0 ) 
427  {
428    m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
429    m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
430  }
431  else
432  {
433    pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth );
434    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
435    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); 
436    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
437  }
438
439  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
440  {
441    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
442
443    if(pcCU->getIPCMFlag(uiAbsPartIdx))
444    {
445      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
446      return;
447    }
448  }
449
450#if ! HHI_MPI
451  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
452  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
453#endif
454 
455  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
456  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
457 
458#if LGE_ILLUCOMP_B0045
459#if LGE_ILLUCOMP_DEPTH_C0046 && HHI_MPI
460  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) != uiDepth )
461  {
462#endif
463  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
464#endif
465
466#if LGE_ILLUCOMP_DEPTH_C0046 && HHI_MPI
467  }
468#endif
469
470#if HHI_MPI
471    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
472    {
473      assert( pcCU->getZorderIdxInCU() == 0 );
474      TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
475      pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx );
476
477      UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
478
479      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
480      {
481        const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
482#if MERL_VSP_C0152
483        Int vspIdx = pcTextureCU->getVSPIndex( uiAbsPartIdx + ui);
484        pcCU->setVSPIndex( uiAbsPartIdx + ui, vspIdx);
485#endif
486        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER );
487        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
488        pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth );
489        pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth );
490        pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth );
491      }
492#if LGE_ILLUCOMP_DEPTH_C0046
493      m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
494#endif
495      if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
496      {
497        UInt uiIdx = uiAbsPartIdx;
498        if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
499        {
500          setdQPFlag(true);
501          pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
502        }
503
504        for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
505        {
506          uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
507          uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
508
509          Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr();
510          if ( bSubInSlice )
511          {
512            if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
513            {
514              xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
515            }
516            else
517            {
518              pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
519            }
520          }
521          if(ruiIsLast)
522          {
523            break;
524          }
525          uiIdx += uiQNumParts;
526        }
527        if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
528        {
529          if ( getdQPFlag() )
530          {
531            UInt uiQPSrcPartIdx;
532            if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() )
533            {
534              uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU();
535            }
536            else
537            {
538              uiQPSrcPartIdx = uiAbsPartIdx;
539            }
540            pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
541          }
542        }
543        return;
544      }
545    }
546  }
547
548  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
549  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
550#endif
551
552  // Coefficient decoding
553  Bool bCodeDQP = getdQPFlag();
554  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
555  setdQPFlag( bCodeDQP );
556  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
557}
558
559Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
560{
561  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
562  {
563    if( getdQPFlag() )
564    {
565      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
566    }
567  }
568
569  if( pcCU->getNumSucIPCM() > 0 )
570  {
571    ruiIsLast = 0;
572    return;
573  }
574
575  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
576}
577
578Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx,  UInt uiDepth )
579{
580  TComPic* pcPic = pcCU->getPic();
581 
582  Bool bBoundary = false;
583  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
584  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
585  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
586  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
587 
588  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
589  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
590  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr();
591  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
592  {
593    bBoundary = true;
594  }
595 
596  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
597  {
598    UInt uiNextDepth = uiDepth + 1;
599    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
600    UInt uiIdx = uiAbsPartIdx;
601    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
602    {
603      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
604      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
605     
606      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getEntropySliceCurEndCUAddr());
607      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
608      {
609        xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth );
610      }
611     
612      uiIdx += uiQNumParts;
613    }
614    return;
615  }
616 
617  // Residual reconstruction
618  m_ppcYuvResi[uiDepth]->clear();
619 
620  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
621 
622  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
623  {
624    case MODE_SKIP:
625    case MODE_INTER:
626      xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
627      break;
628    case MODE_INTRA:
629#if RWTH_SDC_DLT_B0036
630      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
631        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
632      else
633#endif
634      xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
635      break;
636    default:
637      assert(0);
638      break;
639  }
640#if LOSSLESS_CODING
641  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
642  {
643    xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth);   
644  }
645#endif
646 
647  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
648}
649
650Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
651{
652#if HHI_MPI
653#if FIX_MPI_B0065
654  if( pcCU->getTextureModeDepth( 0 ) != -1 )
655  {
656    TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
657    if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx))
658    {
659      PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx);
660      pcCU->setPartSizeSubParts( partSize, 0, uiDepth );
661    }
662    else
663    {
664      pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
665    }
666  }
667#else
668  if( pcCU->getTextureModeDepth( 0 ) != -1 )
669    pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
670#endif
671#endif
672 
673  // inter prediction
674#if MERL_VSP_C0152
675  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth], uiAbsPartIdx );
676#else
677  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
678#endif
679#if H3D_IVRP
680  if (pcCU->getMergeFlag(0) && pcCU->getMergeIndex(0)==0 && pcCU->getResPredAvail(0))
681  {
682    m_pcPrediction->residualPrediction(pcCU, m_ppcYuvReco[uiDepth], m_ppcYuvResPred[uiDepth]);
683  }
684#endif
685
686#if HHI_MPI
687  if( pcCU->getTextureModeDepth( 0 ) != -1 )
688    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
689#endif
690
691  // inter recon
692  xDecodeInterTexture( pcCU, 0, uiDepth );
693 
694  // clip for only non-zero cbp case
695  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
696  {
697    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
698  }
699  else
700  {
701#if H3D_IVRP
702    if (pcCU->getMergeFlag(0) && pcCU->getMergeIndex(0)==0 && pcCU->getResPredAvail(0))
703    {
704      m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
705    }
706#endif
707    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
708  }
709}
710
711Void
712TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
713                         UInt        uiTrDepth,
714                         UInt        uiAbsPartIdx,
715                         TComYuv*    pcRecoYuv,
716                         TComYuv*    pcPredYuv, 
717                         TComYuv*    pcResiYuv )
718{
719  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
720  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
721  UInt    uiStride          = pcRecoYuv->getStride  ();
722  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
723  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
724  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
725 
726  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
727  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
728 
729  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
730 
731  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
732  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
733  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
734 
735  //===== init availability pattern =====
736  Bool  bAboveAvail = false;
737  Bool  bLeftAvail  = false;
738  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
739  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
740                                     m_pcPrediction->getPredicBuf       (),
741                                     m_pcPrediction->getPredicBufWidth  (),
742                                     m_pcPrediction->getPredicBufHeight (),
743                                     bAboveAvail, bLeftAvail );
744#if LGE_EDGE_INTRA_A0070
745  if( uiLumaPredMode >= EDGE_INTRA_IDX )
746  {
747    m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride
748#if LGE_EDGE_INTRA_DELTA_DC
749      , uiLumaPredMode == EDGE_INTRA_DELTA_IDX
750#endif
751      );
752  } 
753  else
754#endif
755 
756  //===== get prediction signal =====
757#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
758  if( uiLumaPredMode >= NUM_INTRA_MODE )
759  {
760    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
761  } 
762  else
763  {
764#endif
765  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
766#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
767  }
768#endif
769 
770  //===== inverse transform =====
771  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
772
773  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
774  assert(scalingListType < 6);
775#if LOSSLESS_CODING
776  m_pcTrQuant->invtransformNxN( pcCU, TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
777#else 
778  m_pcTrQuant->invtransformNxN(       TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
779#endif
780
781 
782  //===== reconstruction =====
783  Pel* pPred      = piPred;
784  Pel* pResi      = piResi;
785  Pel* pReco      = piReco;
786  Pel* pRecIPred  = piRecIPred;
787  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
788  {
789    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
790    {
791      pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
792      pRecIPred[ uiX ] = pReco[ uiX ];
793    }
794    pPred     += uiStride;
795    pResi     += uiStride;
796    pReco     += uiStride;
797    pRecIPred += uiRecIPredStride;
798  }
799}
800
801
802Void
803TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
804                           UInt        uiTrDepth,
805                           UInt        uiAbsPartIdx,
806                           TComYuv*    pcRecoYuv,
807                           TComYuv*    pcPredYuv, 
808                           TComYuv*    pcResiYuv,
809                           UInt        uiChromaId )
810{
811  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
812  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
813
814  if( uiLog2TrSize == 2 )
815  {
816    assert( uiTrDepth > 0 );
817    uiTrDepth--;
818    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
819    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
820    if( !bFirstQ )
821    {
822      return;
823    }
824  }
825 
826  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
827  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
828  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
829  UInt      uiStride          = pcRecoYuv->getCStride ();
830  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
831  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
832  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
833 
834  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
835  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
836 
837  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
838 
839  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
840  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
841  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
842 
843  //===== init availability pattern =====
844  Bool  bAboveAvail = false;
845  Bool  bLeftAvail  = false;
846  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
847
848  if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 )
849  {
850    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
851                                     m_pcPrediction->getPredicBuf       (),
852                                     m_pcPrediction->getPredicBufWidth  (),
853                                     m_pcPrediction->getPredicBufHeight (),
854                                     bAboveAvail, bLeftAvail, 
855                                     true );
856
857    m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight );
858  }
859 
860  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, 
861                                           m_pcPrediction->getPredicBuf       (),
862                                           m_pcPrediction->getPredicBufWidth  (),
863                                           m_pcPrediction->getPredicBufHeight (),
864                                           bAboveAvail, bLeftAvail );
865  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
866 
867  //===== get prediction signal =====
868  if( uiChromaPredMode == LM_CHROMA_IDX )
869  {
870    m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
871  }
872  else
873  {
874    if( uiChromaPredMode == DM_CHROMA_IDX )
875    {
876      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
877#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
878      mapDMMtoIntraMode( uiChromaPredMode );
879#endif
880    }
881    m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
882  }
883
884  //===== inverse transform =====
885  if(eText == TEXT_CHROMA_U)
886  {
887    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
888  }
889  else
890  {
891    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
892  }
893
894  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
895  assert(scalingListType < 6);
896#if LOSSLESS_CODING
897  m_pcTrQuant->invtransformNxN( pcCU, eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
898#else 
899  m_pcTrQuant->invtransformNxN(       eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
900#endif
901
902  //===== reconstruction =====
903  Pel* pPred      = piPred;
904  Pel* pResi      = piResi;
905  Pel* pReco      = piReco;
906  Pel* pRecIPred  = piRecIPred;
907  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
908  {
909    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
910    {
911      pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
912      pRecIPred[ uiX ] = pReco[ uiX ];
913    }
914    pPred     += uiStride;
915    pResi     += uiStride;
916    pReco     += uiStride;
917    pRecIPred += uiRecIPredStride;
918  }
919}
920
921Void
922TDecCu::xIntraRecQT( TComDataCU* pcCU,
923                    UInt        uiTrDepth,
924                    UInt        uiAbsPartIdx,
925                    TComYuv*    pcRecoYuv,
926                    TComYuv*    pcPredYuv, 
927                    TComYuv*    pcResiYuv )
928{
929  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
930  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
931  if( uiTrMode == uiTrDepth )
932  {
933    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
934    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
935    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
936  }
937  else
938  {
939    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
940    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
941    {
942      xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
943    }
944  }
945}
946
947Void
948TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
949{
950  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
951  UInt  uiNumPart     = pcCU->getNumPartInter();
952  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
953 
954  if (pcCU->getIPCMFlag(0))
955  {
956    xReconPCM( pcCU, uiAbsPartIdx, uiDepth );
957    return;
958  }
959
960  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
961  {
962    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
963  } 
964
965  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
966  {
967    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
968  }
969
970}
971
972#if RWTH_SDC_DLT_B0036
973Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
974{
975  UInt uiWidth        = pcCU->getWidth  ( 0 );
976  UInt uiHeight       = pcCU->getHeight ( 0 );
977 
978  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
979  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
980  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
981 
982  UInt    uiStride    = pcRecoYuv->getStride  ();
983  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
984  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
985  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
986 
987  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
988  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
989  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
990 
991  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
992 
993  AOF( uiWidth == uiHeight );
994  AOF( uiAbsPartIdx == 0 );
995  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
996  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
997 
998  //===== init availability pattern =====
999  Bool  bAboveAvail = false;
1000  Bool  bLeftAvail  = false;
1001  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
1002  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
1003 
1004  //===== get prediction signal =====
1005#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1006  if( uiLumaPredMode >= NUM_INTRA_MODE )
1007  {
1008    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
1009  }
1010  else
1011  {
1012#endif
1013    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
1014#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1015  }
1016#endif
1017 
1018  // number of segments depends on prediction mode
1019  UInt uiNumSegments = 1; 
1020  Bool* pbMask = NULL;
1021  UInt uiMaskStride = 0;
1022 
1023  if( uiLumaPredMode == DMM_WEDGE_FULL_IDX || uiLumaPredMode == DMM_WEDGE_PREDDIR_IDX )
1024  {
1025    Int uiTabIdx = (uiLumaPredMode == DMM_WEDGE_FULL_IDX)?pcCU->getWedgeFullTabIdx(uiAbsPartIdx):pcCU->getWedgePredDirTabIdx(uiAbsPartIdx);
1026   
1027    WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
1028    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
1029   
1030    uiNumSegments = 2;
1031    pbMask = pcWedgelet->getPattern();
1032    uiMaskStride = pcWedgelet->getStride();
1033  }
1034 
1035  // get DC prediction for each segment
1036  Pel apDCPredValues[2];
1037  xAnalyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride);
1038 
1039  // reconstruct residual based on mask + DC residuals
1040  Pel apDCResiValues[2];
1041  Pel apDCRecoValues[2];
1042  for( UInt ui = 0; ui < uiNumSegments; ui++ )
1043  {
1044    Pel   pPredIdx    = GetDepthValue2Idx( apDCPredValues[ui] );
1045    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(ui, uiAbsPartIdx);
1046    Pel   pRecoValue  = GetIdx2DepthValue( pPredIdx + pResiIdx );
1047   
1048    apDCRecoValues[ui]  = pRecoValue;
1049    apDCResiValues[ui]  = pRecoValue - apDCPredValues[ui];
1050  }
1051 
1052  //===== reconstruction =====
1053  Bool*pMask      = pbMask;
1054  Pel* pPred      = piPred;
1055  Pel* pResi      = piResi;
1056  Pel* pReco      = piReco;
1057  Pel* pRecIPred  = piRecIPred;
1058 
1059  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1060  {
1061    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1062    {
1063      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1064      assert( ucSegment < uiNumSegments );
1065     
1066      Pel pPredVal= apDCPredValues[ucSegment];
1067      Pel pResiDC = apDCResiValues[ucSegment];
1068     
1069      pReco    [ uiX ] = Clip( pPredVal + pResiDC );
1070      pRecIPred[ uiX ] = pReco[ uiX ];
1071    }
1072    pPred     += uiStride;
1073    pResi     += uiStride;
1074    pReco     += uiStride;
1075    pRecIPred += uiRecIPredStride;
1076    pMask     += uiMaskStride;
1077  }
1078 
1079  // clear UV
1080  UInt  uiStrideC     = pcPredYuv->getCStride();
1081  Pel   *pRecCb       = pcPredYuv->getCbAddr();
1082  Pel   *pRecCr       = pcPredYuv->getCrAddr();
1083 
1084  for (Int y=0; y<uiHeight/2; y++)
1085  {
1086    for (Int x=0; x<uiWidth/2; x++)
1087    {
1088      pRecCb[x] = (Pel)(128<<g_uiBitIncrement);
1089      pRecCr[x] = (Pel)(128<<g_uiBitIncrement);
1090    }
1091   
1092    pRecCb += uiStrideC;
1093    pRecCr += uiStrideC;
1094  }
1095}
1096#endif
1097
1098/** Function for deriving recontructed PU/CU Luma sample with QTree structure
1099 * \param pcCU pointer of current CU
1100 * \param uiTrDepth current tranform split depth
1101 * \param uiAbsPartIdx  part index
1102 * \param pcRecoYuv pointer to reconstructed sample arrays
1103 * \param pcPredYuv pointer to prediction sample arrays
1104 * \param pcResiYuv pointer to residue sample arrays
1105 *
1106 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
1107 */
1108Void
1109TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
1110                     UInt        uiTrDepth,
1111                     UInt        uiAbsPartIdx,
1112                     TComYuv*    pcRecoYuv,
1113                     TComYuv*    pcPredYuv, 
1114                     TComYuv*    pcResiYuv )
1115{
1116  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1117  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1118  if( uiTrMode == uiTrDepth )
1119  {
1120    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1121  }
1122  else
1123  {
1124    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1125    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1126    {
1127      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1128    }
1129  }
1130}
1131
1132/** Function for deriving recontructed PU/CU chroma samples with QTree structure
1133 * \param pcCU pointer of current CU
1134 * \param uiTrDepth current tranform split depth
1135 * \param uiAbsPartIdx  part index
1136 * \param pcRecoYuv pointer to reconstructed sample arrays
1137 * \param pcPredYuv pointer to prediction sample arrays
1138 * \param pcResiYuv pointer to residue sample arrays
1139 *
1140 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1141 */
1142Void
1143TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1144                     UInt        uiTrDepth,
1145                     UInt        uiAbsPartIdx,
1146                     TComYuv*    pcRecoYuv,
1147                     TComYuv*    pcPredYuv, 
1148                     TComYuv*    pcResiYuv )
1149{
1150  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1151  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1152  if( uiTrMode == uiTrDepth )
1153  {
1154    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1155    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1156  }
1157  else
1158  {
1159    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1160    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1161    {
1162      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1163    }
1164  }
1165}
1166
1167Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1168{
1169  UInt uiCUAddr = pcCU->getAddr();
1170 
1171  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1172 
1173  return;
1174}
1175
1176Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1177{
1178  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1179  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1180  TCoeff* piCoeff;
1181 
1182  Pel*    pResi;
1183  UInt    uiLumaTrMode, uiChromaTrMode;
1184 
1185  pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
1186 
1187  // Y
1188  piCoeff = pcCU->getCoeffY();
1189  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1190
1191  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
1192
1193  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
1194 
1195  // Cb and Cr
1196  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
1197
1198  uiWidth  >>= 1;
1199  uiHeight >>= 1;
1200  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1201  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1202
1203  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
1204
1205  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1206  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1207}
1208
1209/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1210 * \param pcCU pointer to current CU
1211 * \param uiPartIdx part index
1212 * \param piPCM pointer to PCM code arrays
1213 * \param piReco pointer to reconstructed sample arrays
1214 * \param uiStride stride of reconstructed sample arrays
1215 * \param uiWidth CU width
1216 * \param uiHeight CU height
1217 * \param ttText texture component type
1218 * \returns Void
1219 */
1220Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1221{
1222  UInt uiX, uiY;
1223  Pel* piPicReco;
1224  UInt uiPicStride;
1225  UInt uiPcmLeftShiftBit; 
1226
1227  if( ttText == TEXT_LUMA )
1228  {
1229    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1230    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1231    uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
1232  }
1233  else
1234  {
1235    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1236
1237    if( ttText == TEXT_CHROMA_U )
1238    {
1239      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1240    }
1241    else
1242    {
1243      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1244    }
1245    uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
1246  }
1247
1248  for( uiY = 0; uiY < uiHeight; uiY++ )
1249  {
1250    for( uiX = 0; uiX < uiWidth; uiX++ )
1251    {
1252      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1253      piPicReco[uiX] = piReco[uiX];
1254    }
1255    piPCM += uiWidth;
1256    piReco += uiStride;
1257    piPicReco += uiPicStride;
1258  }
1259}
1260
1261/** Function for reconstructing a PCM mode CU.
1262 * \param pcCU pointer to current CU
1263 * \param uiAbsPartIdx CU index
1264 * \param uiDepth CU Depth
1265 * \returns Void
1266 */
1267Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1268{
1269  // Luma
1270  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1271  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1272
1273  Pel* piPcmY = pcCU->getPCMSampleY();
1274  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1275
1276  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1277
1278  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1279
1280  // Cb and Cr
1281  UInt uiCWidth  = (uiWidth>>1);
1282  UInt uiCHeight = (uiHeight>>1);
1283
1284  Pel* piPcmCb = pcCU->getPCMSampleCb();
1285  Pel* piPcmCr = pcCU->getPCMSampleCr();
1286  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1287  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1288
1289  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1290
1291  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1292  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1293}
1294
1295#if LOSSLESS_CODING
1296/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1297 * \param pcCU pointer to current CU
1298 * \param uiAbsPartIdx CU index
1299 * \param uiDepth CU Depth
1300 * \returns Void
1301 */
1302Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth)
1303{
1304  // Luma
1305  UInt width  = (g_uiMaxCUWidth >> depth);
1306  UInt height = (g_uiMaxCUHeight >> depth);
1307
1308  Pel* pPcmY = pCU->getPCMSampleY();
1309  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1310
1311  UInt stride = m_ppcYuvReco[depth]->getStride();
1312
1313  for(Int y = 0; y < height; y++ )
1314  {
1315    for(Int x = 0; x < width; x++ )
1316    {
1317      pPcmY[x] = pRecoY[x];
1318    }
1319    pPcmY += width;
1320    pRecoY += stride;
1321  }
1322
1323  // Cb and Cr
1324  UInt widthC  = (width>>1);
1325  UInt heightC = (height>>1);
1326
1327  Pel* pPcmCb = pCU->getPCMSampleCb();
1328  Pel* pPcmCr = pCU->getPCMSampleCr();
1329  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1330  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1331
1332  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1333
1334  for(Int y = 0; y < heightC; y++ )
1335  {
1336    for(Int x = 0; x < widthC; x++ )
1337    {
1338      pPcmCb[x] = pRecoCb[x];
1339      pPcmCr[x] = pRecoCr[x];
1340    }
1341    pPcmCr += widthC;
1342    pPcmCb += widthC;
1343    pRecoCb += strideC;
1344    pRecoCr += strideC;
1345  }
1346
1347}
1348#endif
1349
1350#if RWTH_SDC_DLT_B0036
1351Void TDecCu::xAnalyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride )
1352{
1353  Int iSumDepth[2];
1354  memset(iSumDepth, 0, sizeof(Int)*2);
1355  Int iSumPix[2];
1356  memset(iSumPix, 0, sizeof(Int)*2);
1357#if HS_REFERENCE_SUBSAMPLE_C0154
1358  Int subSamplePix;
1359  if ( uiSize == 64 || uiSize == 32 )
1360  {
1361    subSamplePix = 2;
1362  }
1363  else
1364  {
1365    subSamplePix = 1;
1366  }
1367  for (Int y=0; y<uiSize; y+=subSamplePix)
1368  {
1369    for (Int x=0; x<uiSize; x+=subSamplePix)
1370    {
1371      UChar ucSegment = pMask?(UChar)pMask[x]:0;
1372      assert( ucSegment < uiNumSegments );
1373 
1374      iSumDepth[ucSegment] += pOrig[x];
1375      iSumPix[ucSegment]   += 1;
1376    }
1377    pOrig  += uiStride*subSamplePix;
1378    pMask  += uiMaskStride*subSamplePix;
1379  }
1380#else
1381  for (Int y=0; y<uiSize; y++)
1382  {
1383    for (Int x=0; x<uiSize; x++)
1384    {
1385      UChar ucSegment = pMask?(UChar)pMask[x]:0;
1386      assert( ucSegment < uiNumSegments );
1387     
1388      iSumDepth[ucSegment] += pOrig[x];
1389      iSumPix[ucSegment]   += 1;
1390    }
1391   
1392    pOrig  += uiStride;
1393    pMask  += uiMaskStride;
1394  }
1395#endif
1396  // compute mean for each segment
1397  for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )
1398  {
1399    if( iSumPix[ucSeg] > 0 )
1400      rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
1401    else
1402      rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
1403  }
1404}
1405#endif
1406
1407//! \}
Note: See TracBrowser for help on using the repository browser.