source: 3DVCSoftware/branches/HTM-6.2-dev0/source/Lib/TLibDecoder/TDecCu.cpp @ 433

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

Merged HTM-6.2-dev3-RWTH-Fix Rev. 415

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