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

Last change on this file since 425 was 408, checked in by lg, 12 years ago

D0135->D0092->D0091

  • Property svn:eol-style set to native
File size: 51.2 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#if LGE_VSP_INHERIT_D0092
374    Int iVSPIndexTrue[MRG_MAX_NUM_CANDS_MEM];
375    for (Int i=0; i<MRG_MAX_NUM_CANDS_MEM; i++)
376    {
377        iVSPIndexTrue[i] = 0;
378    }
379#else
380    Int iVSPIndexTrue[3] = {-1, -1, -1};
381#endif
382    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue, uiMergeIndex );
383   
384#if MTK_D0156
385    if( !pcCU->getSlice()->getSPS()->getUseVSPCompensation() )
386    {
387        pcCU->setVSPIndexSubParts( 0, uiAbsPartIdx, 0, uiDepth ); 
388    }
389    else
390#endif
391    {
392      Int iVSPIdx = 0;
393#if LGE_VSP_INHERIT_D0092
394      if (iVSPIndexTrue[uiMergeIndex] == 1)
395      {
396          iVSPIdx = 1;
397      }
398#else
399      Int numVspIdx;
400      numVspIdx = 3;
401      for (Int i = 0; i < numVspIdx; i++)
402      {
403        if (iVSPIndexTrue[i] == uiMergeIndex)
404          {
405            iVSPIdx = i+1;
406            break;
407          }
408      }
409#endif
410      pcCU->setVSPIndexSubParts( iVSPIdx, uiAbsPartIdx, 0, uiDepth );  //Initialize the VSP, may change later in get InterMergeCandidates()
411#if QC_BVSP_CleanUP_D0191 && !LGE_VSP_INHERIT_D0092
412      if(iVSPIdx != 0)
413      {
414        Int iIVCIdx = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC()==pcCU->getSlice()->getPOC() ? 0: pcCU->getSlice()->getNewRefIdx(REF_PIC_LIST_0);
415       cMvFieldNeighbours[ 2*uiMergeIndex].setRefIdx(iIVCIdx);
416      }
417#endif
418    }
419#else
420    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
421#endif
422    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
423
424    TComMv cTmpMv( 0, 0 );
425    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
426    {       
427      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
428      {
429        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
430        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
431        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
432        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
433      }
434    }
435#if LGE_ILLUCOMP_B0045
436    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
437#endif
438#if HHI_MPI
439    }
440#endif
441    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
442    return;
443  }
444
445#if HHI_MPI
446  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
447  {
448#endif
449  if( pcCU->getNumSucIPCM() == 0 ) 
450  {
451    m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
452    m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
453  }
454  else
455  {
456    pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth );
457    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
458    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); 
459    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
460  }
461
462  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
463  {
464    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
465
466    if(pcCU->getIPCMFlag(uiAbsPartIdx))
467    {
468      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
469      return;
470    }
471  }
472
473#if ! HHI_MPI
474  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
475  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
476#endif
477 
478  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
479  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
480 
481#if LGE_ILLUCOMP_B0045
482#if LGE_ILLUCOMP_DEPTH_C0046 && HHI_MPI
483  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) != uiDepth )
484  {
485#endif
486  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
487#endif
488
489#if LGE_ILLUCOMP_DEPTH_C0046 && HHI_MPI
490  }
491#endif
492
493#if HHI_MPI
494    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
495    {
496      assert( pcCU->getZorderIdxInCU() == 0 );
497      TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
498      pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx );
499
500      UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
501
502      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
503      {
504        const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
505#if MERL_VSP_C0152
506        Int vspIdx = pcTextureCU->getVSPIndex( uiAbsPartIdx + ui);
507        pcCU->setVSPIndex( uiAbsPartIdx + ui, vspIdx);
508#endif
509        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER );
510        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
511        pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth );
512        pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth );
513        pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth );
514      }
515#if LGE_ILLUCOMP_DEPTH_C0046
516      m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
517#endif
518      if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
519      {
520        UInt uiIdx = uiAbsPartIdx;
521        if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
522        {
523          setdQPFlag(true);
524          pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
525        }
526
527        for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
528        {
529          uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
530          uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
531
532          Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr();
533          if ( bSubInSlice )
534          {
535            if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
536            {
537              xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
538            }
539            else
540            {
541              pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
542            }
543          }
544          if(ruiIsLast)
545          {
546            break;
547          }
548          uiIdx += uiQNumParts;
549        }
550        if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
551        {
552          if ( getdQPFlag() )
553          {
554            UInt uiQPSrcPartIdx;
555            if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() )
556            {
557              uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU();
558            }
559            else
560            {
561              uiQPSrcPartIdx = uiAbsPartIdx;
562            }
563            pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
564          }
565        }
566        return;
567      }
568    }
569  }
570
571  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
572  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
573#endif
574
575  // Coefficient decoding
576  Bool bCodeDQP = getdQPFlag();
577  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
578  setdQPFlag( bCodeDQP );
579  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
580}
581
582Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
583{
584  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
585  {
586    if( getdQPFlag() )
587    {
588      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
589    }
590  }
591
592  if( pcCU->getNumSucIPCM() > 0 )
593  {
594    ruiIsLast = 0;
595    return;
596  }
597
598  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
599}
600
601Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx,  UInt uiDepth )
602{
603  TComPic* pcPic = pcCU->getPic();
604 
605  Bool bBoundary = false;
606  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
607  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
608  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
609  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
610 
611  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
612  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
613  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr();
614  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
615  {
616    bBoundary = true;
617  }
618 
619  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
620  {
621    UInt uiNextDepth = uiDepth + 1;
622    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
623    UInt uiIdx = uiAbsPartIdx;
624    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
625    {
626      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
627      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
628     
629      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getEntropySliceCurEndCUAddr());
630      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
631      {
632        xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth );
633      }
634     
635      uiIdx += uiQNumParts;
636    }
637    return;
638  }
639 
640  // Residual reconstruction
641  m_ppcYuvResi[uiDepth]->clear();
642 
643  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
644 
645  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
646  {
647    case MODE_SKIP:
648    case MODE_INTER:
649      xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
650      break;
651    case MODE_INTRA:
652#if RWTH_SDC_DLT_B0036
653      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
654        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
655      else
656#endif
657      xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
658      break;
659    default:
660      assert(0);
661      break;
662  }
663#if LOSSLESS_CODING
664  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
665  {
666    xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth);   
667  }
668#endif
669 
670  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
671}
672
673Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
674{
675#if HHI_MPI
676#if FIX_MPI_B0065
677  if( pcCU->getTextureModeDepth( 0 ) != -1 )
678  {
679    TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
680    if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx))
681    {
682      PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx);
683      pcCU->setPartSizeSubParts( partSize, 0, uiDepth );
684    }
685    else
686    {
687      pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
688    }
689  }
690#else
691  if( pcCU->getTextureModeDepth( 0 ) != -1 )
692    pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
693#endif
694#endif
695 
696  // inter prediction
697#if MERL_VSP_C0152
698  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth], uiAbsPartIdx );
699#else
700  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
701#endif
702#if H3D_IVRP
703  if (pcCU->getMergeFlag(0) && pcCU->getMergeIndex(0)==0 && pcCU->getResPredAvail(0))
704  {
705    m_pcPrediction->residualPrediction(pcCU, m_ppcYuvReco[uiDepth], m_ppcYuvResPred[uiDepth]);
706  }
707#endif
708
709#if HHI_MPI
710  if( pcCU->getTextureModeDepth( 0 ) != -1 )
711    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
712#endif
713
714  // inter recon
715  xDecodeInterTexture( pcCU, 0, uiDepth );
716 
717  // clip for only non-zero cbp case
718  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
719  {
720    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
721  }
722  else
723  {
724#if H3D_IVRP
725    if (pcCU->getMergeFlag(0) && pcCU->getMergeIndex(0)==0 && pcCU->getResPredAvail(0))
726    {
727      m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
728    }
729#endif
730    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
731  }
732}
733
734Void
735TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
736                         UInt        uiTrDepth,
737                         UInt        uiAbsPartIdx,
738                         TComYuv*    pcRecoYuv,
739                         TComYuv*    pcPredYuv, 
740                         TComYuv*    pcResiYuv )
741{
742  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
743  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
744  UInt    uiStride          = pcRecoYuv->getStride  ();
745  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
746  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
747  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
748 
749  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
750  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
751 
752  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
753 
754  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
755  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
756  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
757 
758  //===== init availability pattern =====
759  Bool  bAboveAvail = false;
760  Bool  bLeftAvail  = false;
761  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
762  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
763                                     m_pcPrediction->getPredicBuf       (),
764                                     m_pcPrediction->getPredicBufWidth  (),
765                                     m_pcPrediction->getPredicBufHeight (),
766                                     bAboveAvail, bLeftAvail );
767#if LGE_EDGE_INTRA_A0070
768  if( uiLumaPredMode >= EDGE_INTRA_IDX )
769  {
770    m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride
771#if LGE_EDGE_INTRA_DELTA_DC
772      , uiLumaPredMode == EDGE_INTRA_DELTA_IDX
773#endif
774      );
775  } 
776  else
777#endif
778 
779  //===== get prediction signal =====
780#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
781  if( uiLumaPredMode >= NUM_INTRA_MODE )
782  {
783    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
784  } 
785  else
786  {
787#endif
788  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
789#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
790  }
791#endif
792 
793  //===== inverse transform =====
794  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
795
796  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
797  assert(scalingListType < 6);
798#if LOSSLESS_CODING
799  m_pcTrQuant->invtransformNxN( pcCU, TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
800#else 
801  m_pcTrQuant->invtransformNxN(       TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
802#endif
803
804 
805  //===== reconstruction =====
806  Pel* pPred      = piPred;
807  Pel* pResi      = piResi;
808  Pel* pReco      = piReco;
809  Pel* pRecIPred  = piRecIPred;
810  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
811  {
812    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
813    {
814      pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
815      pRecIPred[ uiX ] = pReco[ uiX ];
816    }
817    pPred     += uiStride;
818    pResi     += uiStride;
819    pReco     += uiStride;
820    pRecIPred += uiRecIPredStride;
821  }
822}
823
824
825Void
826TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
827                           UInt        uiTrDepth,
828                           UInt        uiAbsPartIdx,
829                           TComYuv*    pcRecoYuv,
830                           TComYuv*    pcPredYuv, 
831                           TComYuv*    pcResiYuv,
832                           UInt        uiChromaId )
833{
834  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
835  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
836
837  if( uiLog2TrSize == 2 )
838  {
839    assert( uiTrDepth > 0 );
840    uiTrDepth--;
841    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
842    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
843    if( !bFirstQ )
844    {
845      return;
846    }
847  }
848 
849  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
850  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
851  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
852  UInt      uiStride          = pcRecoYuv->getCStride ();
853  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
854  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
855  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
856 
857  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
858  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
859 
860  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
861 
862  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
863  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
864  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
865 
866  //===== init availability pattern =====
867  Bool  bAboveAvail = false;
868  Bool  bLeftAvail  = false;
869  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
870
871  if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 )
872  {
873    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
874                                     m_pcPrediction->getPredicBuf       (),
875                                     m_pcPrediction->getPredicBufWidth  (),
876                                     m_pcPrediction->getPredicBufHeight (),
877                                     bAboveAvail, bLeftAvail, 
878                                     true );
879
880    m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight );
881  }
882 
883  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, 
884                                           m_pcPrediction->getPredicBuf       (),
885                                           m_pcPrediction->getPredicBufWidth  (),
886                                           m_pcPrediction->getPredicBufHeight (),
887                                           bAboveAvail, bLeftAvail );
888  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
889 
890  //===== get prediction signal =====
891  if( uiChromaPredMode == LM_CHROMA_IDX )
892  {
893    m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
894  }
895  else
896  {
897    if( uiChromaPredMode == DM_CHROMA_IDX )
898    {
899      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
900#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
901      mapDMMtoIntraMode( uiChromaPredMode );
902#endif
903    }
904    m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
905  }
906
907  //===== inverse transform =====
908  if(eText == TEXT_CHROMA_U)
909  {
910    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
911  }
912  else
913  {
914    m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
915  }
916
917  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
918  assert(scalingListType < 6);
919#if LOSSLESS_CODING
920  m_pcTrQuant->invtransformNxN( pcCU, eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
921#else 
922  m_pcTrQuant->invtransformNxN(       eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType );
923#endif
924
925  //===== reconstruction =====
926  Pel* pPred      = piPred;
927  Pel* pResi      = piResi;
928  Pel* pReco      = piReco;
929  Pel* pRecIPred  = piRecIPred;
930  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
931  {
932    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
933    {
934      pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
935      pRecIPred[ uiX ] = pReco[ uiX ];
936    }
937    pPred     += uiStride;
938    pResi     += uiStride;
939    pReco     += uiStride;
940    pRecIPred += uiRecIPredStride;
941  }
942}
943
944Void
945TDecCu::xIntraRecQT( TComDataCU* pcCU,
946                    UInt        uiTrDepth,
947                    UInt        uiAbsPartIdx,
948                    TComYuv*    pcRecoYuv,
949                    TComYuv*    pcPredYuv, 
950                    TComYuv*    pcResiYuv )
951{
952  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
953  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
954  if( uiTrMode == uiTrDepth )
955  {
956    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
957    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
958    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
959  }
960  else
961  {
962    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
963    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
964    {
965      xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
966    }
967  }
968}
969
970Void
971TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
972{
973  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
974  UInt  uiNumPart     = pcCU->getNumPartInter();
975  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
976 
977  if (pcCU->getIPCMFlag(0))
978  {
979    xReconPCM( pcCU, uiAbsPartIdx, uiDepth );
980    return;
981  }
982
983  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
984  {
985    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
986  } 
987
988  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
989  {
990    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
991  }
992
993}
994
995#if RWTH_SDC_DLT_B0036
996Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
997{
998  UInt uiWidth        = pcCU->getWidth  ( 0 );
999  UInt uiHeight       = pcCU->getHeight ( 0 );
1000 
1001  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
1002  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
1003  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
1004 
1005  UInt    uiStride    = pcRecoYuv->getStride  ();
1006  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
1007  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
1008  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
1009 
1010  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
1011  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
1012  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
1013 
1014  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
1015 
1016  AOF( uiWidth == uiHeight );
1017  AOF( uiAbsPartIdx == 0 );
1018  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
1019  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
1020 
1021  //===== init availability pattern =====
1022  Bool  bAboveAvail = false;
1023  Bool  bLeftAvail  = false;
1024  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
1025  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
1026 
1027  //===== get prediction signal =====
1028#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1029  if( uiLumaPredMode >= NUM_INTRA_MODE )
1030  {
1031    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
1032  }
1033  else
1034  {
1035#endif
1036    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
1037#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1038  }
1039#endif
1040 
1041  // number of segments depends on prediction mode
1042  UInt uiNumSegments = 1; 
1043  Bool* pbMask = NULL;
1044  UInt uiMaskStride = 0;
1045 
1046  if( uiLumaPredMode == DMM_WEDGE_FULL_IDX || uiLumaPredMode == DMM_WEDGE_PREDDIR_IDX )
1047  {
1048    Int uiTabIdx = (uiLumaPredMode == DMM_WEDGE_FULL_IDX)?pcCU->getWedgeFullTabIdx(uiAbsPartIdx):pcCU->getWedgePredDirTabIdx(uiAbsPartIdx);
1049   
1050    WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
1051    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
1052   
1053    uiNumSegments = 2;
1054    pbMask = pcWedgelet->getPattern();
1055    uiMaskStride = pcWedgelet->getStride();
1056  }
1057 
1058  // get DC prediction for each segment
1059  Pel apDCPredValues[2];
1060  xAnalyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride);
1061 
1062  // reconstruct residual based on mask + DC residuals
1063  Pel apDCResiValues[2];
1064  Pel apDCRecoValues[2];
1065  for( UInt ui = 0; ui < uiNumSegments; ui++ )
1066  {
1067    Pel   pPredIdx    = GetDepthValue2Idx( apDCPredValues[ui] );
1068    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(ui, uiAbsPartIdx);
1069    Pel   pRecoValue  = GetIdx2DepthValue( pPredIdx + pResiIdx );
1070   
1071    apDCRecoValues[ui]  = pRecoValue;
1072    apDCResiValues[ui]  = pRecoValue - apDCPredValues[ui];
1073  }
1074 
1075  //===== reconstruction =====
1076  Bool*pMask      = pbMask;
1077  Pel* pPred      = piPred;
1078  Pel* pResi      = piResi;
1079  Pel* pReco      = piReco;
1080  Pel* pRecIPred  = piRecIPred;
1081 
1082  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
1083  {
1084    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
1085    {
1086      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
1087      assert( ucSegment < uiNumSegments );
1088     
1089      Pel pPredVal= apDCPredValues[ucSegment];
1090      Pel pResiDC = apDCResiValues[ucSegment];
1091     
1092      pReco    [ uiX ] = Clip( pPredVal + pResiDC );
1093      pRecIPred[ uiX ] = pReco[ uiX ];
1094    }
1095    pPred     += uiStride;
1096    pResi     += uiStride;
1097    pReco     += uiStride;
1098    pRecIPred += uiRecIPredStride;
1099    pMask     += uiMaskStride;
1100  }
1101 
1102  // clear UV
1103  UInt  uiStrideC     = pcPredYuv->getCStride();
1104  Pel   *pRecCb       = pcPredYuv->getCbAddr();
1105  Pel   *pRecCr       = pcPredYuv->getCrAddr();
1106 
1107  for (Int y=0; y<uiHeight/2; y++)
1108  {
1109    for (Int x=0; x<uiWidth/2; x++)
1110    {
1111      pRecCb[x] = (Pel)(128<<g_uiBitIncrement);
1112      pRecCr[x] = (Pel)(128<<g_uiBitIncrement);
1113    }
1114   
1115    pRecCb += uiStrideC;
1116    pRecCr += uiStrideC;
1117  }
1118}
1119#endif
1120
1121/** Function for deriving recontructed PU/CU Luma sample with QTree structure
1122 * \param pcCU pointer of current CU
1123 * \param uiTrDepth current tranform split depth
1124 * \param uiAbsPartIdx  part index
1125 * \param pcRecoYuv pointer to reconstructed sample arrays
1126 * \param pcPredYuv pointer to prediction sample arrays
1127 * \param pcResiYuv pointer to residue sample arrays
1128 *
1129 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
1130 */
1131Void
1132TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
1133                     UInt        uiTrDepth,
1134                     UInt        uiAbsPartIdx,
1135                     TComYuv*    pcRecoYuv,
1136                     TComYuv*    pcPredYuv, 
1137                     TComYuv*    pcResiYuv )
1138{
1139  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1140  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1141  if( uiTrMode == uiTrDepth )
1142  {
1143    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1144  }
1145  else
1146  {
1147    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1148    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1149    {
1150      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1151    }
1152  }
1153}
1154
1155/** Function for deriving recontructed PU/CU chroma samples with QTree structure
1156 * \param pcCU pointer of current CU
1157 * \param uiTrDepth current tranform split depth
1158 * \param uiAbsPartIdx  part index
1159 * \param pcRecoYuv pointer to reconstructed sample arrays
1160 * \param pcPredYuv pointer to prediction sample arrays
1161 * \param pcResiYuv pointer to residue sample arrays
1162 *
1163 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1164 */
1165Void
1166TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1167                     UInt        uiTrDepth,
1168                     UInt        uiAbsPartIdx,
1169                     TComYuv*    pcRecoYuv,
1170                     TComYuv*    pcPredYuv, 
1171                     TComYuv*    pcResiYuv )
1172{
1173  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1174  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1175  if( uiTrMode == uiTrDepth )
1176  {
1177    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1178    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1179  }
1180  else
1181  {
1182    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1183    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1184    {
1185      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1186    }
1187  }
1188}
1189
1190Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1191{
1192  UInt uiCUAddr = pcCU->getAddr();
1193 
1194  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1195 
1196  return;
1197}
1198
1199Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1200{
1201  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1202  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1203  TCoeff* piCoeff;
1204 
1205  Pel*    pResi;
1206  UInt    uiLumaTrMode, uiChromaTrMode;
1207 
1208  pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
1209 
1210  // Y
1211  piCoeff = pcCU->getCoeffY();
1212  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1213
1214  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
1215
1216  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
1217 
1218  // Cb and Cr
1219  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() );
1220
1221  uiWidth  >>= 1;
1222  uiHeight >>= 1;
1223  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1224  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1225
1226  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() );
1227
1228  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1229  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1230}
1231
1232/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1233 * \param pcCU pointer to current CU
1234 * \param uiPartIdx part index
1235 * \param piPCM pointer to PCM code arrays
1236 * \param piReco pointer to reconstructed sample arrays
1237 * \param uiStride stride of reconstructed sample arrays
1238 * \param uiWidth CU width
1239 * \param uiHeight CU height
1240 * \param ttText texture component type
1241 * \returns Void
1242 */
1243Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1244{
1245  UInt uiX, uiY;
1246  Pel* piPicReco;
1247  UInt uiPicStride;
1248  UInt uiPcmLeftShiftBit; 
1249
1250  if( ttText == TEXT_LUMA )
1251  {
1252    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1253    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1254    uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
1255  }
1256  else
1257  {
1258    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1259
1260    if( ttText == TEXT_CHROMA_U )
1261    {
1262      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1263    }
1264    else
1265    {
1266      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1267    }
1268    uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
1269  }
1270
1271  for( uiY = 0; uiY < uiHeight; uiY++ )
1272  {
1273    for( uiX = 0; uiX < uiWidth; uiX++ )
1274    {
1275      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1276      piPicReco[uiX] = piReco[uiX];
1277    }
1278    piPCM += uiWidth;
1279    piReco += uiStride;
1280    piPicReco += uiPicStride;
1281  }
1282}
1283
1284/** Function for reconstructing a PCM mode CU.
1285 * \param pcCU pointer to current CU
1286 * \param uiAbsPartIdx CU index
1287 * \param uiDepth CU Depth
1288 * \returns Void
1289 */
1290Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1291{
1292  // Luma
1293  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1294  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1295
1296  Pel* piPcmY = pcCU->getPCMSampleY();
1297  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1298
1299  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1300
1301  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1302
1303  // Cb and Cr
1304  UInt uiCWidth  = (uiWidth>>1);
1305  UInt uiCHeight = (uiHeight>>1);
1306
1307  Pel* piPcmCb = pcCU->getPCMSampleCb();
1308  Pel* piPcmCr = pcCU->getPCMSampleCr();
1309  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1310  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1311
1312  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1313
1314  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1315  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1316}
1317
1318#if LOSSLESS_CODING
1319/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1320 * \param pcCU pointer to current CU
1321 * \param uiAbsPartIdx CU index
1322 * \param uiDepth CU Depth
1323 * \returns Void
1324 */
1325Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth)
1326{
1327  // Luma
1328  UInt width  = (g_uiMaxCUWidth >> depth);
1329  UInt height = (g_uiMaxCUHeight >> depth);
1330
1331  Pel* pPcmY = pCU->getPCMSampleY();
1332  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1333
1334  UInt stride = m_ppcYuvReco[depth]->getStride();
1335
1336  for(Int y = 0; y < height; y++ )
1337  {
1338    for(Int x = 0; x < width; x++ )
1339    {
1340      pPcmY[x] = pRecoY[x];
1341    }
1342    pPcmY += width;
1343    pRecoY += stride;
1344  }
1345
1346  // Cb and Cr
1347  UInt widthC  = (width>>1);
1348  UInt heightC = (height>>1);
1349
1350  Pel* pPcmCb = pCU->getPCMSampleCb();
1351  Pel* pPcmCr = pCU->getPCMSampleCr();
1352  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1353  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1354
1355  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1356
1357  for(Int y = 0; y < heightC; y++ )
1358  {
1359    for(Int x = 0; x < widthC; x++ )
1360    {
1361      pPcmCb[x] = pRecoCb[x];
1362      pPcmCr[x] = pRecoCr[x];
1363    }
1364    pPcmCr += widthC;
1365    pPcmCb += widthC;
1366    pRecoCb += strideC;
1367    pRecoCr += strideC;
1368  }
1369
1370}
1371#endif
1372
1373#if RWTH_SDC_DLT_B0036
1374Void TDecCu::xAnalyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride )
1375{
1376  Int iSumDepth[2];
1377  memset(iSumDepth, 0, sizeof(Int)*2);
1378  Int iSumPix[2];
1379  memset(iSumPix, 0, sizeof(Int)*2);
1380#if HS_REFERENCE_SUBSAMPLE_C0154
1381  Int subSamplePix;
1382  if ( uiSize == 64 || uiSize == 32 )
1383  {
1384    subSamplePix = 2;
1385  }
1386  else
1387  {
1388    subSamplePix = 1;
1389  }
1390  for (Int y=0; y<uiSize; y+=subSamplePix)
1391  {
1392    for (Int x=0; x<uiSize; x+=subSamplePix)
1393    {
1394      UChar ucSegment = pMask?(UChar)pMask[x]:0;
1395      assert( ucSegment < uiNumSegments );
1396 
1397      iSumDepth[ucSegment] += pOrig[x];
1398      iSumPix[ucSegment]   += 1;
1399    }
1400    pOrig  += uiStride*subSamplePix;
1401    pMask  += uiMaskStride*subSamplePix;
1402  }
1403#else
1404  for (Int y=0; y<uiSize; y++)
1405  {
1406    for (Int x=0; x<uiSize; x++)
1407    {
1408      UChar ucSegment = pMask?(UChar)pMask[x]:0;
1409      assert( ucSegment < uiNumSegments );
1410     
1411      iSumDepth[ucSegment] += pOrig[x];
1412      iSumPix[ucSegment]   += 1;
1413    }
1414   
1415    pOrig  += uiStride;
1416    pMask  += uiMaskStride;
1417  }
1418#endif
1419  // compute mean for each segment
1420  for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )
1421  {
1422    if( iSumPix[ucSeg] > 0 )
1423      rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
1424    else
1425      rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
1426  }
1427}
1428#endif
1429
1430//! \}
Note: See TracBrowser for help on using the repository browser.