source: 3DVCSoftware/branches/HTM-8.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp @ 615

Last change on this file since 615 was 615, checked in by tech, 12 years ago

Cleanups and macro removals related to merge and vsp

  • MTK_VSP_FIX_ALIGN_WD_E0172
  • H_3D_FIX_BVSP
  • QC_INRIA_MTK_MRG_E0126
  • MTK_DVMCP_FIX_E0172
  • TComDataCU::xAddVspCand
  • TComDataCU::xAddIvMRGCand
  • TComDataCU::getInterMergeCandidates
  • Property svn:eol-style set to native
File size: 42.6 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecCu.cpp
35    \brief    CU decoder class
36*/
37
38#include "TDecCu.h"
39
40//! \ingroup TLibDecoder
41//! \{
42
43// ====================================================================================================================
44// Constructor / destructor / create / destroy
45// ====================================================================================================================
46
47TDecCu::TDecCu()
48{
49  m_ppcYuvResi = NULL;
50  m_ppcYuvReco = NULL;
51  m_ppcCU      = NULL;
52}
53
54TDecCu::~TDecCu()
55{
56}
57
58Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
59{
60  m_pcEntropyDecoder  = pcEntropyDecoder;
61  m_pcTrQuant         = pcTrQuant;
62  m_pcPrediction      = pcPrediction;
63}
64
65/**
66 \param    uiMaxDepth    total number of allowable depth
67 \param    uiMaxWidth    largest CU width
68 \param    uiMaxHeight   largest CU height
69 */
70Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
71{
72  m_uiMaxDepth = uiMaxDepth+1;
73 
74  m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1];
75  m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
76  m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
77 
78  UInt uiNumPartitions;
79  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
80  {
81    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
82    UInt uiWidth  = uiMaxWidth  >> ui;
83    UInt uiHeight = uiMaxHeight >> ui;
84   
85    m_ppcYuvResi[ui] = new TComYuv;    m_ppcYuvResi[ui]->create( uiWidth, uiHeight );
86    m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
87    m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
88  }
89 
90  m_bDecodeDQP = false;
91
92  // initialize partition order.
93  UInt* piTmp = &g_auiZscanToRaster[0];
94  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
95  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
96 
97  // initialize conversion matrix from partition index to pel
98  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
99}
100
101Void TDecCu::destroy()
102{
103  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
104  {
105    m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;
106    m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
107    m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
108  }
109 
110  delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;
111  delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
112  delete [] m_ppcCU     ; m_ppcCU      = NULL;
113}
114
115// ====================================================================================================================
116// Public member functions
117// ====================================================================================================================
118
119/** \param    pcCU        pointer of CU data
120 \param    ruiIsLast   last data?
121 */
122Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
123{
124  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
125  {
126    setdQPFlag(true);
127  }
128
129  // start from the top level CU
130  xDecodeCU( pcCU, 0, 0, ruiIsLast);
131}
132
133/** \param    pcCU        pointer of CU data
134 */
135Void TDecCu::decompressCU( TComDataCU* pcCU )
136{
137  xDecompressCU( pcCU, 0,  0 );
138}
139
140// ====================================================================================================================
141// Protected member functions
142// ====================================================================================================================
143
144/**decode end-of-slice flag
145 * \param pcCU
146 * \param uiAbsPartIdx
147 * \param uiDepth
148 * \returns Bool
149 */
150Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)
151{
152  UInt uiIsLast;
153  TComPic* pcPic = pcCU->getPic();
154  TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
155  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
156  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
157  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
158  UInt uiGranularityWidth = g_uiMaxCUWidth;
159  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
160  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
161
162  if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth))
163    &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)))
164  {
165    m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast );
166  }
167  else
168  {
169    uiIsLast=0;
170  }
171 
172  if(uiIsLast) 
173  {
174    if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) 
175    {
176      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
177    }
178    else 
179    {
180      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
181      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
182    }
183  }
184
185  return uiIsLast>0;
186}
187
188/** decode CU block recursively
189 * \param pcCU
190 * \param uiAbsPartIdx
191 * \param uiDepth
192 * \returns Void
193 */
194
195Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
196{
197  TComPic* pcPic = pcCU->getPic();
198  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
199  UInt uiQNumParts      = uiCurNumParts>>2;
200 
201  Bool bBoundary = false;
202  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
203  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
204  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
205  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
206#if H_MV_ENC_DEC_TRAC
207  DTRACE_CU_S("=========== coding_quadtree ===========\n")
208  DTRACE_CU("x0", uiLPelX)
209  DTRACE_CU("x1", uiTPelY)
210  DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth)
211  DTRACE_CU("cqtDepth"  , uiDepth)
212#endif
213  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
214  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
215  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
216  {
217    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
218  }
219  else
220  {
221    bBoundary = true;
222  }
223 
224  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
225  {
226    UInt uiIdx = uiAbsPartIdx;
227    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
228    {
229      setdQPFlag(true);
230      pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
231    }
232
233    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
234    {
235      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
236      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
237     
238      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
239      if ( bSubInSlice )
240      {
241        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
242        {
243          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
244        }
245        else
246        {
247          pcCU->setOutsideCUPart( uiIdx, uiDepth+1 );
248        }
249      }
250     
251      uiIdx += uiQNumParts;
252    }
253    if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
254    {
255      if ( getdQPFlag() )
256      {
257        UInt uiQPSrcPartIdx;
258        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
259        {
260          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
261        }
262        else
263        {
264          uiQPSrcPartIdx = uiAbsPartIdx;
265        }
266        pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP
267      }
268    }
269    return;
270  }
271 
272#if H_MV_ENC_DEC_TRAC
273  DTRACE_CU_S("=========== coding_unit ===========\n")
274#endif
275
276  if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
277  {
278    setdQPFlag(true);
279    pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
280  }
281#if H_3D_NBDV
282  DisInfo DvInfo; 
283  DvInfo.bDV = false;
284  DvInfo.m_acNBDV.setZero();
285  DvInfo.m_aVIdxCan = 0;
286#if H_3D_NBDV_REF 
287  DvInfo.m_acDoNBDV.setZero();
288#endif
289 
290 
291  if(!pcCU->getSlice()->isIntra())
292  {
293#if H_3D_ARP && H_3D_IV_MERGE
294    if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() ))
295#else
296#if H_3D_ARP
297    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
298#else
299#if H_3D_IV_MERGE
300    if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
301#else
302    if (0)
303#endif
304#endif
305#endif
306    {
307      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
308      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
309      PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
310      UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
311      UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
312      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
313      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
314      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
315#if H_3D_NBDV_REF
316      if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() ))  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
317        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true);
318      else
319#endif
320        DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
321
322      pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
323      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
324      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
325      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
326     }
327  }
328#endif
329  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
330  {
331    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
332  }
333 
334  // decode CU mode and the partition size
335  if( !pcCU->getSlice()->isIntra())
336  {
337    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
338  }
339 
340  if( pcCU->isSkipped(uiAbsPartIdx) )
341  {
342#if H_MV_ENC_DEC_TRAC
343    DTRACE_PU_S("=========== prediction_unit ===========\n")
344    DTRACE_PU("x0", uiLPelX)
345    DTRACE_PU("x1", uiTPelY)
346#endif
347    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
348    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
349#if H_3D_IV_MERGE
350    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
351    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
352    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
353#else
354    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
355    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
356#endif
357    Int numValidMergeCand = 0;
358    for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
359    {
360      uhInterDirNeighbours[ui] = 0;
361    }
362    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
363    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
364
365#if H_3D_VSP
366    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
367    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
368    InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
369    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand, uiMergeIndex );
370    pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
371#else
372    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
373#endif
374#if H_3D_VSP
375    if(vspFlag[uiMergeIndex])
376    {
377      pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth);
378    }
379#endif
380    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
381
382    TComMv cTmpMv( 0, 0 );
383    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
384    {       
385      if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
386      {
387        pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
388        pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth);
389        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
390        pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
391      }
392    }
393#if H_3D_IC
394    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
395#endif
396#if H_3D_ARP
397    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
398#endif
399    xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
400    return;
401  }
402
403  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
404  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
405
406  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
407  {
408    m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
409
410    if(pcCU->getIPCMFlag(uiAbsPartIdx))
411    {
412      xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
413      return;
414    }
415  }
416
417  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
418  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
419 
420  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
421  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
422#if H_3D_IC
423  m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
424#endif
425#if H_3D_ARP
426  m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth ); 
427#endif 
428#if LGE_INTER_SDC_E0156
429  m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
430#endif
431  // Coefficient decoding
432  Bool bCodeDQP = getdQPFlag();
433  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP );
434  setdQPFlag( bCodeDQP );
435  xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
436}
437
438Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)
439{
440  if(  pcCU->getSlice()->getPPS()->getUseDQP())
441  {
442    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
443  }
444
445  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
446}
447
448Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
449{
450  TComPic* pcPic = pcCU->getPic();
451 
452  Bool bBoundary = false;
453  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
454  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
455  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
456  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
457 
458  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
459  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
460  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
461  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
462  {
463    bBoundary = true;
464  }
465 
466  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
467  {
468    UInt uiNextDepth = uiDepth + 1;
469    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
470    UInt uiIdx = uiAbsPartIdx;
471    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
472    {
473      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
474      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
475     
476      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
477      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
478      {
479        xDecompressCU(pcCU, uiIdx, uiNextDepth );
480      }
481     
482      uiIdx += uiQNumParts;
483    }
484    return;
485  }
486 
487  // Residual reconstruction
488  m_ppcYuvResi[uiDepth]->clear();
489 
490  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
491 
492  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
493  {
494    case MODE_INTER:
495#if LGE_INTER_SDC_E0156
496      if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) )
497      {
498        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
499      }
500      else
501      {
502#endif
503      xReconInter( m_ppcCU[uiDepth], uiDepth );
504#if LGE_INTER_SDC_E0156
505      }
506#endif
507      break;
508    case MODE_INTRA:
509#if H_3D_DIM_SDC
510      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
511        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
512      else
513#endif
514      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
515      break;
516    default:
517      assert(0);
518      break;
519  }
520  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
521  {
522    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
523  }
524 
525  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
526}
527
528Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
529{
530 
531  // inter prediction
532  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
533 
534  // inter recon
535  xDecodeInterTexture( pcCU, 0, uiDepth );
536 
537  // clip for only non-zero cbp case
538  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
539  {
540    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
541  }
542  else
543  {
544    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
545  }
546}
547
548#if LGE_INTER_SDC_E0156
549Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
550{
551  // inter prediction
552  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
553
554  UInt  uiWidth      = pcCU->getWidth ( 0 );
555  UInt  uiHeight     = pcCU->getHeight( 0 );
556  UChar* pMask       = pcCU->getInterSDCMask();
557
558  memset( pMask, 0, uiWidth*uiHeight );
559  pcCU->xSetInterSDCCUMask( pcCU, pMask );
560
561  Pel  *pResi;
562  UInt uiPelX, uiPelY;
563  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
564
565  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
566  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
567  {
568    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
569    {
570      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
571
572      pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );;
573    }
574    pResi += uiResiStride;
575  }
576
577  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
578
579  // clear UV
580  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
581  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
582  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
583
584  for (Int y = 0; y < uiHeight/2; y++)
585  {
586    for (Int x = 0; x < uiWidth/2; x++)
587    {
588      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
589      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
590    }
591
592    pRecCb += uiStrideC;
593    pRecCr += uiStrideC;
594  }
595}
596#endif
597
598Void
599TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
600                         UInt        uiTrDepth,
601                         UInt        uiAbsPartIdx,
602                         TComYuv*    pcRecoYuv,
603                         TComYuv*    pcPredYuv, 
604                         TComYuv*    pcResiYuv )
605{
606  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
607  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
608  UInt    uiStride          = pcRecoYuv->getStride  ();
609  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
610  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
611  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
612 
613  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
614  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
615 
616  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
617 
618  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
619  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
620  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
621  Bool    useTransformSkip  = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA);
622  //===== init availability pattern =====
623  Bool  bAboveAvail = false;
624  Bool  bLeftAvail  = false;
625  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
626  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
627                                     m_pcPrediction->getPredicBuf       (),
628                                     m_pcPrediction->getPredicBufWidth  (),
629                                     m_pcPrediction->getPredicBufHeight (),
630                                     bAboveAvail, bLeftAvail );
631 
632  //===== get prediction signal =====
633#if H_3D_DIM
634  if( isDimMode( uiLumaPredMode ) )
635  {
636    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
637  }
638  else
639  {
640#endif
641  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
642#if H_3D_DIM
643  }
644#endif
645 
646  //===== inverse transform =====
647  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
648
649  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA];
650  assert(scalingListType < 6);
651  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip );
652
653 
654  //===== reconstruction =====
655  Pel* pPred      = piPred;
656  Pel* pResi      = piResi;
657  Pel* pReco      = piReco;
658  Pel* pRecIPred  = piRecIPred;
659  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
660  {
661    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
662    {
663      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
664      pRecIPred[ uiX ] = pReco[ uiX ];
665    }
666    pPred     += uiStride;
667    pResi     += uiStride;
668    pReco     += uiStride;
669    pRecIPred += uiRecIPredStride;
670  }
671}
672
673
674Void
675TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
676                           UInt        uiTrDepth,
677                           UInt        uiAbsPartIdx,
678                           TComYuv*    pcRecoYuv,
679                           TComYuv*    pcPredYuv, 
680                           TComYuv*    pcResiYuv,
681                           UInt        uiChromaId )
682{
683  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
684  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
685
686  if( uiLog2TrSize == 2 )
687  {
688    assert( uiTrDepth > 0 );
689    uiTrDepth--;
690    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
691    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
692    if( !bFirstQ )
693    {
694      return;
695    }
696  }
697 
698  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
699  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
700  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
701  UInt      uiStride          = pcRecoYuv->getCStride ();
702  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
703  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
704  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
705 
706  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
707  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
708 
709  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
710 
711  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
712  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
713  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
714  Bool      useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);
715  //===== init availability pattern =====
716  Bool  bAboveAvail = false;
717  Bool  bLeftAvail  = false;
718  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
719
720  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
721                                           m_pcPrediction->getPredicBuf       (),
722                                           m_pcPrediction->getPredicBufWidth  (),
723                                           m_pcPrediction->getPredicBufHeight (),
724                                           bAboveAvail, bLeftAvail );
725  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
726 
727  //===== get prediction signal =====
728  {
729    if( uiChromaPredMode == DM_CHROMA_IDX )
730    {
731      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
732#if H_3D_DIM
733      mapDepthModeToIntraDir( uiChromaPredMode );
734#endif
735    }
736    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
737  }
738
739  //===== inverse transform =====
740  Int curChromaQpOffset;
741  if(eText == TEXT_CHROMA_U)
742  {
743    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
744  }
745  else
746  {
747    curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
748  }
749  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
750
751  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
752  assert(scalingListType < 6);
753  m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );
754
755  //===== reconstruction =====
756  Pel* pPred      = piPred;
757  Pel* pResi      = piResi;
758  Pel* pReco      = piReco;
759  Pel* pRecIPred  = piRecIPred;
760  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
761  {
762    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
763    {
764      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
765      pRecIPred[ uiX ] = pReco[ uiX ];
766    }
767    pPred     += uiStride;
768    pResi     += uiStride;
769    pReco     += uiStride;
770    pRecIPred += uiRecIPredStride;
771  }
772}
773
774
775Void
776TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
777{
778  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
779  UInt  uiNumPart     = pcCU->getNumPartInter();
780  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
781 
782  if (pcCU->getIPCMFlag(0))
783  {
784    xReconPCM( pcCU, uiDepth );
785    return;
786  }
787
788  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
789  {
790    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
791  } 
792
793  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
794  {
795    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
796  }
797
798}
799
800#if H_3D_DIM_SDC
801Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
802{
803  UInt uiWidth        = pcCU->getWidth  ( 0 );
804  UInt uiHeight       = pcCU->getHeight ( 0 );
805 
806  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
807  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
808  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
809 
810  UInt    uiStride    = pcRecoYuv->getStride  ();
811  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
812  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
813  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
814 
815  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
816  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
817  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
818 
819  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
820 
821  AOF( uiWidth == uiHeight );
822  AOF( uiAbsPartIdx == 0 );
823  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
824  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
825 
826  //===== init availability pattern =====
827  Bool  bAboveAvail = false;
828  Bool  bLeftAvail  = false;
829  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
830  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
831 
832  //===== get prediction signal =====
833#if H_3D_DIM
834  if( isDimMode( uiLumaPredMode ) )
835  {
836    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
837  }
838  else
839  {
840#endif
841    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
842#if H_3D_DIM
843  }
844#endif
845 
846  // number of segments depends on prediction mode
847  UInt uiNumSegments = 1;
848  Bool* pbMask = NULL;
849  UInt uiMaskStride = 0;
850 
851  if( getDimType( uiLumaPredMode ) == DMM1_IDX )
852  {
853    Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx);
854   
855    WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
856    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
857   
858    uiNumSegments = 2;
859    pbMask = pcWedgelet->getPattern();
860    uiMaskStride = pcWedgelet->getStride();
861  }
862 
863  // get DC prediction for each segment
864  Pel apDCPredValues[2];
865#if KWU_SDC_SIMPLE_DC_E0117
866  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
867#else
868  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride);
869#endif
870 
871  // reconstruct residual based on mask + DC residuals
872  Pel apDCResiValues[2];
873  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
874  {
875#if H_3D_DIM_DLT
876    Pel   pPredIdx    = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
877    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
878    Pel   pRecoValue  = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
879   
880    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
881#else
882    apDCResiValues[uiSegment]  = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
883#endif
884  }
885 
886  //===== reconstruction =====
887  Bool*pMask      = pbMask;
888  Pel* pPred      = piPred;
889  Pel* pResi      = piResi;
890  Pel* pReco      = piReco;
891  Pel* pRecIPred  = piRecIPred;
892 
893  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
894  {
895    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
896    {
897      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
898      assert( ucSegment < uiNumSegments );
899     
900      Pel pResiDC = apDCResiValues[ucSegment];
901     
902      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResiDC );
903      pRecIPred[ uiX ] = pReco[ uiX ];
904    }
905    pPred     += uiStride;
906    pResi     += uiStride;
907    pReco     += uiStride;
908    pRecIPred += uiRecIPredStride;
909    pMask     += uiMaskStride;
910  }
911 
912  // clear UV
913  UInt  uiStrideC     = pcPredYuv->getCStride();
914  Pel   *pRecCb       = pcPredYuv->getCbAddr();
915  Pel   *pRecCr       = pcPredYuv->getCrAddr();
916 
917  for (Int y=0; y<uiHeight/2; y++)
918  {
919    for (Int x=0; x<uiWidth/2; x++)
920    {
921      pRecCb[x] = 128;
922      pRecCr[x] = 128;
923    }
924   
925    pRecCb += uiStrideC;
926    pRecCr += uiStrideC;
927  }
928}
929#endif
930
931/** Function for deriving recontructed PU/CU Luma sample with QTree structure
932 * \param pcCU pointer of current CU
933 * \param uiTrDepth current tranform split depth
934 * \param uiAbsPartIdx  part index
935 * \param pcRecoYuv pointer to reconstructed sample arrays
936 * \param pcPredYuv pointer to prediction sample arrays
937 * \param pcResiYuv pointer to residue sample arrays
938 *
939 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
940 */
941Void
942TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
943                     UInt        uiTrDepth,
944                     UInt        uiAbsPartIdx,
945                     TComYuv*    pcRecoYuv,
946                     TComYuv*    pcPredYuv, 
947                     TComYuv*    pcResiYuv )
948{
949  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
950  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
951  if( uiTrMode == uiTrDepth )
952  {
953    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
954  }
955  else
956  {
957    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
958    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
959    {
960      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
961    }
962  }
963}
964
965/** Function for deriving recontructed PU/CU chroma samples with QTree structure
966 * \param pcCU pointer of current CU
967 * \param uiTrDepth current tranform split depth
968 * \param uiAbsPartIdx  part index
969 * \param pcRecoYuv pointer to reconstructed sample arrays
970 * \param pcPredYuv pointer to prediction sample arrays
971 * \param pcResiYuv pointer to residue sample arrays
972 *
973 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
974 */
975Void
976TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
977                     UInt        uiTrDepth,
978                     UInt        uiAbsPartIdx,
979                     TComYuv*    pcRecoYuv,
980                     TComYuv*    pcPredYuv, 
981                     TComYuv*    pcResiYuv )
982{
983  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
984  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
985  if( uiTrMode == uiTrDepth )
986  {
987    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
988    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
989  }
990  else
991  {
992    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
993    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
994    {
995      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
996    }
997  }
998}
999
1000Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1001{
1002  UInt uiCUAddr = pcCU->getAddr();
1003 
1004  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1005 
1006  return;
1007}
1008
1009Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1010{
1011  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1012  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1013  TCoeff* piCoeff;
1014 
1015  Pel*    pResi;
1016  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
1017 
1018  // Y
1019  piCoeff = pcCU->getCoeffY();
1020  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1021
1022  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
1023
1024  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1025 
1026  // Cb and Cr
1027  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
1028  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1029
1030  uiWidth  >>= 1;
1031  uiHeight >>= 1;
1032  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1033  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1034
1035  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
1036  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
1037
1038  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1039  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
1040}
1041
1042/** Function for deriving reconstructed luma/chroma samples of a PCM mode CU.
1043 * \param pcCU pointer to current CU
1044 * \param uiPartIdx part index
1045 * \param piPCM pointer to PCM code arrays
1046 * \param piReco pointer to reconstructed sample arrays
1047 * \param uiStride stride of reconstructed sample arrays
1048 * \param uiWidth CU width
1049 * \param uiHeight CU height
1050 * \param ttText texture component type
1051 * \returns Void
1052 */
1053Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText)
1054{
1055  UInt uiX, uiY;
1056  Pel* piPicReco;
1057  UInt uiPicStride;
1058  UInt uiPcmLeftShiftBit; 
1059
1060  if( ttText == TEXT_LUMA )
1061  {
1062    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
1063    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1064    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
1065  }
1066  else
1067  {
1068    uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
1069
1070    if( ttText == TEXT_CHROMA_U )
1071    {
1072      piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1073    }
1074    else
1075    {
1076      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
1077    }
1078    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
1079  }
1080
1081  for( uiY = 0; uiY < uiHeight; uiY++ )
1082  {
1083    for( uiX = 0; uiX < uiWidth; uiX++ )
1084    {
1085      piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit);
1086      piPicReco[uiX] = piReco[uiX];
1087    }
1088    piPCM += uiWidth;
1089    piReco += uiStride;
1090    piPicReco += uiPicStride;
1091  }
1092}
1093
1094/** Function for reconstructing a PCM mode CU.
1095 * \param pcCU pointer to current CU
1096 * \param uiDepth CU Depth
1097 * \returns Void
1098 */
1099Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
1100{
1101  // Luma
1102  UInt uiWidth  = (g_uiMaxCUWidth >> uiDepth);
1103  UInt uiHeight = (g_uiMaxCUHeight >> uiDepth);
1104
1105  Pel* piPcmY = pcCU->getPCMSampleY();
1106  Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth);
1107
1108  UInt uiStride = m_ppcYuvResi[uiDepth]->getStride();
1109
1110  xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA);
1111
1112  // Cb and Cr
1113  UInt uiCWidth  = (uiWidth>>1);
1114  UInt uiCHeight = (uiHeight>>1);
1115
1116  Pel* piPcmCb = pcCU->getPCMSampleCb();
1117  Pel* piPcmCr = pcCU->getPCMSampleCr();
1118  Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr();
1119  Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr();
1120
1121  UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride();
1122
1123  xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U);
1124  xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V);
1125}
1126
1127/** Function for filling the PCM buffer of a CU using its reconstructed sample array
1128 * \param pcCU pointer to current CU
1129 * \param uiDepth CU Depth
1130 * \returns Void
1131 */
1132Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
1133{
1134  // Luma
1135  UInt width  = (g_uiMaxCUWidth >> depth);
1136  UInt height = (g_uiMaxCUHeight >> depth);
1137
1138  Pel* pPcmY = pCU->getPCMSampleY();
1139  Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width);
1140
1141  UInt stride = m_ppcYuvReco[depth]->getStride();
1142
1143  for(Int y = 0; y < height; y++ )
1144  {
1145    for(Int x = 0; x < width; x++ )
1146    {
1147      pPcmY[x] = pRecoY[x];
1148    }
1149    pPcmY += width;
1150    pRecoY += stride;
1151  }
1152
1153  // Cb and Cr
1154  UInt widthC  = (width>>1);
1155  UInt heightC = (height>>1);
1156
1157  Pel* pPcmCb = pCU->getPCMSampleCb();
1158  Pel* pPcmCr = pCU->getPCMSampleCr();
1159  Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr();
1160  Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr();
1161
1162  UInt strideC = m_ppcYuvReco[depth]->getCStride();
1163
1164  for(Int y = 0; y < heightC; y++ )
1165  {
1166    for(Int x = 0; x < widthC; x++ )
1167    {
1168      pPcmCb[x] = pRecoCb[x];
1169      pPcmCr[x] = pRecoCr[x];
1170    }
1171    pPcmCr += widthC;
1172    pPcmCb += widthC;
1173    pRecoCb += strideC;
1174    pRecoCr += strideC;
1175  }
1176
1177}
1178
1179//! \}
Note: See TracBrowser for help on using the repository browser.