source: 3DVCSoftware/branches/HTM-8.2-dev2-LG/source/Lib/TLibDecoder/TDecCu.cpp @ 1417

Last change on this file since 1417 was 690, checked in by lg, 11 years ago

Integration of "Removal of redundancy on VSP, ARP and IC"
FJCT3V-F0104
MACRO "LGE_SHARP_VSP_INHERIT_F0104"

By Taesup Kim (taesup.kim@…)

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