source: 3DVCSoftware/trunk/source/Lib/TLibDecoder/TDecCu.cpp @ 332

Last change on this file since 332 was 332, checked in by tech, 11 years ago

Merged branch 6.1-Cleanup@329.

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