source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp @ 11

Last change on this file since 11 was 11, checked in by poznan-univ, 13 years ago

Poznan disocclusion coding - CU Skip

  • Property svn:eol-style set to native
File size: 40.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-2011, 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 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
35
36/** \file     TDecCu.cpp
37    \brief    CU decoder class
38*/
39
40#include "TDecCu.h"
41
42// ====================================================================================================================
43// Constructor / destructor / create / destroy
44// ====================================================================================================================
45
46TDecCu::TDecCu()
47{
48  m_ppcYuvResi    = NULL;
49  m_ppcYuvReco    = NULL;
50  m_ppcYuvResPred = NULL;
51#if POZNAN_AVAIL_MAP
52  m_ppcYuvAvail   = NULL;
53#endif
54#if POZNAN_SYNTH_VIEW
55  m_ppcYuvSynth   = NULL;
56#endif
57  m_ppcCU         = NULL;
58}
59
60TDecCu::~TDecCu()
61{
62}
63
64Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
65{
66  m_pcEntropyDecoder  = pcEntropyDecoder;
67  m_pcTrQuant         = pcTrQuant;
68  m_pcPrediction      = pcPrediction;
69}
70
71/**
72 \param    uiMaxDepth    total number of allowable depth
73 \param    uiMaxWidth    largest CU width
74 \param    uiMaxHeight   largest CU height
75 */
76Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )
77{
78  m_uiMaxDepth = uiMaxDepth+1;
79 
80  m_ppcYuvResi    = new TComYuv*    [m_uiMaxDepth-1];
81  m_ppcYuvReco    = new TComYuv*    [m_uiMaxDepth-1];
82  m_ppcYuvResPred = new TComYuv*    [m_uiMaxDepth-1];
83#if POZNAN_AVAIL_MAP
84  m_ppcYuvAvail   = new TComYuv*    [m_uiMaxDepth-1];
85#endif
86#if POZNAN_SYNTH_VIEW
87  m_ppcYuvSynth   = new TComYuv*    [m_uiMaxDepth-1];
88#endif
89  m_ppcCU         = new TComDataCU* [m_uiMaxDepth-1];
90 
91  UInt uiNumPartitions;
92  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
93  {
94    uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 );
95    UInt uiWidth  = uiMaxWidth  >> ui;
96    UInt uiHeight = uiMaxHeight >> ui;
97   
98    m_ppcYuvResi   [ui] = new TComYuv;    m_ppcYuvResi   [ui]->create( uiWidth, uiHeight );
99    m_ppcYuvReco   [ui] = new TComYuv;    m_ppcYuvReco   [ui]->create( uiWidth, uiHeight );
100    m_ppcYuvResPred[ui] = new TComYuv;    m_ppcYuvResPred[ui]->create( uiWidth, uiHeight );
101#if POZNAN_AVAIL_MAP
102    m_ppcYuvAvail  [ui] = new TComYuv;    m_ppcYuvAvail  [ui]->create( uiWidth, uiHeight );
103#endif
104#if POZNAN_SYNTH_VIEW
105    m_ppcYuvSynth  [ui] = new TComYuv;    m_ppcYuvSynth  [ui]->create( uiWidth, uiHeight );
106#endif
107
108    m_ppcCU        [ui] = new TComDataCU; m_ppcCU        [ui]->create( uiNumPartitions, uiWidth, uiHeight, true );
109  }
110 
111  // initialize partition order.
112  UInt* piTmp = &g_auiZscanToRaster[0];
113  initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp);
114  initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
115 
116  // initialize conversion matrix from partition index to pel
117  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
118}
119
120Void TDecCu::destroy()
121{
122  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
123  {
124    m_ppcYuvResi   [ui]->destroy(); delete m_ppcYuvResi   [ui]; m_ppcYuvResi   [ui] = NULL;
125    m_ppcYuvReco   [ui]->destroy(); delete m_ppcYuvReco   [ui]; m_ppcYuvReco   [ui] = NULL;
126    m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL;
127#if POZNAN_AVAIL_MAP
128    m_ppcYuvAvail  [ui]->destroy(); delete m_ppcYuvAvail  [ui]; m_ppcYuvAvail  [ui] = NULL;
129#endif
130#if POZNAN_SYNTH_VIEW
131    m_ppcYuvSynth  [ui]->destroy(); delete m_ppcYuvSynth  [ui]; m_ppcYuvSynth  [ui] = NULL;
132#endif
133    m_ppcCU        [ui]->destroy(); delete m_ppcCU        [ui]; m_ppcCU        [ui] = NULL;
134  }
135 
136  delete [] m_ppcYuvResi;    m_ppcYuvResi    = NULL;
137  delete [] m_ppcYuvReco;    m_ppcYuvReco    = NULL;
138  delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL;
139#if POZNAN_AVAIL_MAP
140  delete [] m_ppcYuvAvail;   m_ppcYuvAvail   = NULL;
141#endif
142#if POZNAN_SYNTH_VIEW
143  delete [] m_ppcYuvSynth;   m_ppcYuvSynth   = NULL;
144#endif
145
146  delete [] m_ppcCU;         m_ppcCU         = NULL;
147}
148
149// ====================================================================================================================
150// Public member functions
151// ====================================================================================================================
152
153/** \param    pcCU        pointer of CU data
154 \param    ruiIsLast   last data?
155 */
156Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast )
157{
158#if SNY_DQP   
159  if ( pcCU->getSlice()->getSPS()->getUseDQP() )
160  {
161    pcCU->setdQPFlag(true); 
162  }
163#endif//SNY_DQP
164  // start from the top level CU
165  xDecodeCU( pcCU, 0, 0 );
166 
167#if SNY_DQP
168  // dQP: only for LCU
169  if ( pcCU->getSlice()->getSPS()->getUseDQP() )
170  {
171    if ( pcCU->isSkipped( 0 ) && pcCU->getDepth( 0 ) == 0 )
172    {
173    }
174    else if ( pcCU->getdQPFlag())// non-skip
175    {
176      m_pcEntropyDecoder->decodeQP( pcCU, 0, 0 );
177      pcCU->setdQPFlag(false);
178    }
179  }
180#else
181  // dQP: only for LCU
182  if ( pcCU->getSlice()->getSPS()->getUseDQP() )
183  {
184    if ( pcCU->isSkipped( 0 ) && pcCU->getDepth( 0 ) == 0 )
185    {
186    }
187    else
188    {
189      m_pcEntropyDecoder->decodeQP( pcCU, 0, 0 );
190    }
191  }
192#endif//SNY_DQP
193 
194  //--- Read terminating bit ---
195  m_pcEntropyDecoder->decodeTerminatingBit( ruiIsLast );
196}
197
198/** \param    pcCU        pointer of CU data
199 */
200Void TDecCu::decompressCU( TComDataCU* pcCU )
201{
202  xDecompressCU( pcCU, pcCU, 0,  0 );
203}
204
205// ====================================================================================================================
206// Protected member functions
207// ====================================================================================================================
208
209/** decode CU block recursively
210 * \param pcCU
211 * \param uiAbsPartIdx
212 * \param uiDepth
213 * \returns Void
214 */
215Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
216{
217  TComPic* pcPic = pcCU->getPic();
218
219#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
220  Bool bWholeCUCanBeSynthesized = false;
221  Bool bOneSubCUCanNotBeSynthesied = false;
222  Bool bSubCUCanBeSynthesized[4];
223  Bool * pbSubCUCanBeSynthesized = bSubCUCanBeSynthesized;
224  pcPic->checkSynthesisAvailability(pcCU, pcCU->getAddr(), uiAbsPartIdx, uiDepth, pbSubCUCanBeSynthesized); //KUBA SYNTH
225  Int  iSubCUCanNotBeSynthesized = 0;
226  Int  iSubCUCanBeSynthesizedCnt = 0;
227  for(Int i = 0; i < 4; i++)
228  {
229    if (!bSubCUCanBeSynthesized[i])
230    {
231      iSubCUCanNotBeSynthesized = i;
232    }
233    else
234    {
235      iSubCUCanBeSynthesizedCnt ++;
236    }
237  }
238  if(iSubCUCanBeSynthesizedCnt == 4)
239  {
240    bWholeCUCanBeSynthesized = true;
241  }
242  else if(iSubCUCanBeSynthesizedCnt == 3)
243  {
244    bOneSubCUCanNotBeSynthesied = true;
245  }
246
247  if(bWholeCUCanBeSynthesized)
248  {
249    pcCU->setPredModeSubParts( MODE_SYNTH, uiAbsPartIdx, uiDepth );
250    pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx );
251    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
252    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
253    //pcCU->setSizeSubParts( pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth, pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth );
254    return;   
255  }
256#endif
257
258  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
259  UInt uiQNumParts      = uiCurNumParts>>2;
260 
261  Bool bBoundary = false;
262  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
263  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
264  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
265  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
266 
267  if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
268  {
269#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
270    if(bOneSubCUCanNotBeSynthesied && (uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )) // KUBA SYNTH check if CU has 3 synthesied subCU - no split flag is send in that case and CU split is assumed
271    {
272      pcCU->setDepthSubParts( uiDepth + 1, uiAbsPartIdx );
273    }
274    else 
275#endif
276#if HHI_MPI
277    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
278#endif
279      m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
280  }
281  else
282  {
283    bBoundary = true;
284  }
285 
286  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
287  {
288    UInt uiIdx = uiAbsPartIdx;
289    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
290    {
291      uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
292      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
293     
294      if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
295        xDecodeCU( pcCU, uiIdx, uiDepth+1 );
296     
297      uiIdx += uiQNumParts;
298    }
299   
300    return;
301  }
302 
303#if TSB_ALF_HEADER
304#else
305  m_pcEntropyDecoder->decodeAlfCtrlFlag( pcCU, uiAbsPartIdx, uiDepth );
306#endif
307 
308  // decode CU mode and the partition size
309#if HHI_MPI
310  if( !pcCU->getSlice()->isIntra() && pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
311#else
312  if( !pcCU->getSlice()->isIntra() )
313#endif
314  {
315    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
316  }
317 
318
319  if( pcCU->isSkipped(uiAbsPartIdx) )
320  {
321#if HHI_MRG_SKIP
322    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
323    m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
324    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
325    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
326    UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand
327    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
328    {
329      uhInterDirNeighbours[ui] = 0;
330      uiNeighbourCandIdx[ui] = 0;
331    }
332    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx );
333    for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
334  {
335      pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiAbsPartIdx, 0, uiDepth );
336    }
337    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
338#else
339    pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiAbsPartIdx, 0, uiDepth);
340    pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiAbsPartIdx, 0, uiDepth);
341   
342    pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiAbsPartIdx, 0, uiDepth);
343    pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiAbsPartIdx, 0, uiDepth);
344   
345    if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry )
346    {
347      m_pcEntropyDecoder->decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0, m_ppcCU[uiDepth]);
348    }
349   
350    if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry )
351    {
352      m_pcEntropyDecoder->decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1, m_ppcCU[uiDepth]);
353    }
354#endif
355#if HHI_MPI
356    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
357    {
358      TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
359      pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx );
360
361      UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
362      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
363      {
364        const UChar uhNewDepth = max( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
365        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_SKIP );
366        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
367        pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth );
368        pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth );
369        pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth );
370      }
371    }
372#endif
373 
374#if HHI_INTER_VIEW_RESIDUAL_PRED
375    m_pcEntropyDecoder->decodeResPredFlag( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 );
376#endif
377    return;
378  }
379
380#if HHI_MPI
381  if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 )
382  {
383#endif
384    m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
385
386    m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
387
388    // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
389    m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
390
391#if HHI_MPI
392    if( !pcCU->isIntra( uiAbsPartIdx ) )
393    {
394      m_ppcCU[uiDepth]  ->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
395      m_ppcCU[uiDepth]  ->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
396#if HHI_INTER_VIEW_RESIDUAL_PRED
397      m_pcEntropyDecoder->decodeResPredFlag    ( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 );
398#endif
399    }
400
401    if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth )
402    {
403      assert( pcCU->getZorderIdxInCU() == 0 );
404      TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
405      pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx );
406
407      UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
408      for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
409      {
410        const UChar uhNewDepth = max( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) );
411        pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER );
412        pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N );
413        pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth );
414        pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth );
415        pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth );
416      }
417
418      if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
419      {
420        UInt uiIdx = uiAbsPartIdx;
421        for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
422        {
423          uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
424          uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
425
426          if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
427            xDecodeCU( pcCU, uiIdx, uiDepth+1 );
428
429          uiIdx += uiQNumParts;
430        }
431        return;
432      }
433    }
434  }
435#endif
436
437  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
438  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
439 
440  // Coefficient decoding
441  m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight );
442 
443}
444
445Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx,  UInt uiDepth )
446{
447  TComPic* pcPic = pcCU->getPic();
448#if POZNAN_SYNTH_VIEW
449  if(pcPic->getPicYuvSynth())  m_ppcYuvSynth[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx );
450#endif
451#if POZNAN_AVAIL_MAP
452  if(pcPic->getPicYuvAvail())  m_ppcYuvAvail[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx );
453#endif
454 
455  Bool bBoundary = false;
456  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
457  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
458  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
459  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
460 
461  if( ( uiRPelX >= pcCU->getSlice()->getSPS()->getWidth() ) || ( uiBPelY >= pcCU->getSlice()->getSPS()->getHeight() ) )
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      if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
477        xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth );
478     
479      uiIdx += uiQNumParts;
480    }
481    return;
482  }
483 
484  // Residual reconstruction
485  m_ppcYuvResi[uiDepth]->clear();
486 
487  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
488 
489  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
490  {
491    case MODE_SKIP:
492    case MODE_INTER:
493      xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
494      break;
495    case MODE_INTRA:
496      xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
497      break;
498#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
499    case MODE_SYNTH:
500    //  break;
501#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
502      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx);
503#else
504      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx); //Poprawiæ
505#endif
506      //m_ppcYuvReco[uiDepth]->clear();
507      break;
508#endif
509    default:
510      assert(0);
511      break;
512  }
513 
514  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
515}
516
517Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
518{
519#if HHI_MPI
520  if( pcCU->getTextureModeDepth( 0 ) != -1 )
521    pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
522#endif
523 
524  // inter prediction
525  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
526 
527#if HHI_MPI
528  if( pcCU->getTextureModeDepth( 0 ) != -1 )
529    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
530#endif
531 
532#if HHI_INTER_VIEW_RESIDUAL_PRED
533  if( pcCU->getResPredFlag( 0 ) )
534  {
535    AOF( pcCU->getResPredAvail( 0 ) );
536    Bool bOK = pcCU->getResidualSamples( 0, m_ppcYuvResPred[uiDepth] );
537    AOF( bOK );
538    m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
539  }
540#endif
541
542  // inter recon
543  xDecodeInterTexture( pcCU, 0, uiDepth );
544 
545  // clip for only non-zero cbp case
546  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
547  {
548    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
549  }
550  else
551  {
552#if HHI_INTER_VIEW_RESIDUAL_PRED
553    if( pcCU->getResPredFlag( 0 ) )
554    {
555      m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
556    }
557#endif
558    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
559  }
560}
561
562Void TDecCu::xDecodeIntraTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel* piReco, Pel* piPred, Pel* piResi, UInt uiStride, TCoeff* pCoeff, UInt uiWidth, UInt uiHeight, UInt uiCurrDepth )
563{
564  if( pcCU->getTransformIdx(0) == uiCurrDepth )
565  {
566    UInt uiX, uiY;
567    TComPattern* pcPattern = pcCU->getPattern();
568    UInt uiZorder          = pcCU->getZorderIdxInCU()+uiPartIdx;
569    Pel* pPred             = piPred;
570    Pel* pResi             = piResi;
571    Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), uiZorder);
572    UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride();
573   
574    pcPattern->initPattern( pcCU, uiCurrDepth, uiPartIdx );
575   
576    Bool bAboveAvail = false;
577    Bool bLeftAvail  = false;
578   
579    pcPattern->initAdiPattern(pcCU, uiPartIdx, uiCurrDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail);
580   
581    m_pcPrediction->predIntraLumaAng( pcPattern, pcCU->getLumaIntraDir(uiPartIdx), pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
582   
583    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
584#if INTRA_DST_TYPE_7
585  m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight );
586#else
587  m_pcTrQuant->invtransformNxN( pResi, uiStride, pCoeff, uiWidth, uiHeight );
588#endif
589    // Reconstruction
590    {
591      pResi = piResi;
592      pPred = piPred;
593      for( uiY = 0; uiY < uiHeight; uiY++ )
594      {
595        for( uiX = 0; uiX < uiWidth; uiX++ )
596        {
597          piReco   [uiX] = Clip(pPred[uiX] + pResi[uiX]);
598          piPicReco[uiX] = piReco[uiX];
599        }
600        piReco    += uiStride;
601        pPred     += uiStride;
602        pResi     += uiStride;
603        piPicReco += uiPicStride;
604      }
605    }
606  }
607  else
608  {
609    uiCurrDepth++;
610    uiWidth  >>= 1;
611    uiHeight >>= 1;
612    UInt uiPartOffset  = pcCU->getTotalNumPart()>>(uiCurrDepth<<1);
613    UInt uiCoeffOffset = uiWidth  * uiHeight;
614    UInt uiPelOffset   = uiHeight * uiStride;
615    Pel* pResi = piResi;
616    Pel* pReco = piReco;
617    Pel* pPred = piPred;
618    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
619    uiPartIdx += uiPartOffset;
620    pCoeff    += uiCoeffOffset;
621    pResi      = piResi + uiWidth;
622    pReco      = piReco + uiWidth;
623    pPred      = piPred + uiWidth;
624    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
625    uiPartIdx += uiPartOffset;
626    pCoeff    += uiCoeffOffset;
627    pResi      = piResi + uiPelOffset;
628    pReco      = piReco + uiPelOffset;
629    pPred      = piPred + uiPelOffset;
630    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
631    uiPartIdx += uiPartOffset;
632    pCoeff    += uiCoeffOffset;
633    pResi      = piResi + uiPelOffset + uiWidth;
634    pReco      = piReco + uiPelOffset + uiWidth;
635    pPred      = piPred + uiPelOffset + uiWidth;
636    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
637  }
638}
639
640// ADI chroma
641Void TDecCu::xRecurIntraInvTransChroma(TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piResi, Pel* piPred, Pel* piReco, UInt uiStride, TCoeff* piCoeff, UInt uiWidth, UInt uiHeight, UInt uiTrMode, UInt uiCurrTrMode, TextType eText )
642{
643  if( uiTrMode == uiCurrTrMode )
644  {
645    UInt uiX, uiY;
646    UInt uiZorder    = pcCU->getZorderIdxInCU()+uiAbsPartIdx;
647    Pel* pResi       = piResi;
648    Pel* pPred       = piPred;
649    Pel* piPicReco;
650    if( eText == TEXT_CHROMA_U )
651      piPicReco= pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), uiZorder);
652    else
653      piPicReco= pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), uiZorder);
654   
655    UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
656   
657    pcCU->getPattern()->initPattern( pcCU, uiCurrTrMode, uiAbsPartIdx );
658   
659    Bool bAboveAvail = false;
660    Bool bLeftAvail  = false;
661   
662    pcCU->getPattern()->initAdiPatternChroma(pcCU,uiAbsPartIdx, uiCurrTrMode, m_pcPrediction->getPredicBuf(),m_pcPrediction->getPredicBufWidth(),m_pcPrediction->getPredicBufHeight(),bAboveAvail,bLeftAvail);
663   
664    UInt uiModeL        = pcCU->getLumaIntraDir(0);
665    UInt uiMode         = pcCU->getChromaIntraDir(0);
666   
667    if (uiMode==4) uiMode = uiModeL;
668   
669    Int*   pPatChr;
670   
671    if (eText==TEXT_CHROMA_U)
672    {
673      pPatChr=  pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
674    }
675    else // (eText==TEXT_CHROMA_V)
676    {
677      pPatChr=  pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
678    }
679   
680    m_pcPrediction-> predIntraChromaAng( pcCU->getPattern(), pPatChr, uiMode, pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
681   
682    // Inverse Transform
683    if( pcCU->getCbf(0, eText, uiCurrTrMode) )
684    {
685#if INTRA_DST_TYPE_7
686    m_pcTrQuant->invtransformNxN( eText, REG_DCT, pResi, uiStride, piCoeff, uiWidth, uiHeight);
687#else
688    m_pcTrQuant->invtransformNxN( pResi, uiStride, piCoeff, uiWidth, uiHeight );
689#endif
690    }
691    pResi = piResi;
692   
693    for( uiY = 0; uiY < uiHeight; uiY++ )
694    {
695      for( uiX = 0; uiX < uiWidth; uiX++ )
696      {
697        piReco   [uiX] = Clip( pPred[uiX] + pResi[uiX] );
698        piPicReco[uiX] = piReco[uiX];
699      }
700     
701      pPred     += uiStride;
702      pResi     += uiStride;
703      piReco    += uiStride;
704      piPicReco += uiPicStride;
705    }
706  }
707  else
708  {
709    uiCurrTrMode++;
710    uiWidth  >>= 1;
711    uiHeight >>= 1;
712    UInt uiCoeffOffset = uiWidth*uiHeight;
713    UInt uiPelOffset   = uiHeight*uiStride;
714    UInt uiPartOffst   = pcCU->getTotalNumPart()>>(uiCurrTrMode<<1);
715    Pel* pResi = piResi;
716    Pel* pPred = piPred;
717    Pel* pReco = piReco;
718    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
719    uiAbsPartIdx += uiPartOffst;
720    piCoeff      += uiCoeffOffset;
721    pResi         = piResi + uiWidth; pPred = piPred + uiWidth; pReco = piReco + uiWidth;
722    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
723    uiAbsPartIdx += uiPartOffst;
724    piCoeff      += uiCoeffOffset;
725    pResi         = piResi + uiPelOffset; pPred = piPred + uiPelOffset; pReco = piReco + uiPelOffset;
726    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
727    uiAbsPartIdx += uiPartOffst;
728    piCoeff      += uiCoeffOffset;
729    pResi         = piResi + uiPelOffset + uiWidth; pPred = piPred + uiPelOffset + uiWidth; pReco = piReco + uiPelOffset + uiWidth;
730    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
731  }
732}
733
734Void
735TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
736                         UInt        uiTrDepth,
737                         UInt        uiAbsPartIdx,
738                         TComYuv*    pcRecoYuv,
739                         TComYuv*    pcPredYuv, 
740                         TComYuv*    pcResiYuv )
741{
742  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
743  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
744  UInt    uiStride          = pcRecoYuv->getStride  ();
745  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
746  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
747  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
748 
749  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
750  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
751 
752  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
753 
754  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
755  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
756  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
757 
758  //===== init availability pattern =====
759  Bool  bAboveAvail = false;
760  Bool  bLeftAvail  = false;
761  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
762  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
763                                     m_pcPrediction->getPredicBuf       (),
764                                     m_pcPrediction->getPredicBufWidth  (),
765                                     m_pcPrediction->getPredicBufHeight (),
766                                     bAboveAvail, bLeftAvail );
767 
768#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
769  if( uiLumaPredMode > MAX_MODE_ID_INTRA_DIR )
770  {
771    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
772  } 
773  else
774#endif
775  {   
776  //===== get prediction signal =====
777  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
778  }
779  //===== inverse transform =====
780  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
781#if INTRA_DST_TYPE_7
782  m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight );
783#else
784  m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
785#endif 
786
787 
788  //===== reconstruction =====
789  {
790    Pel* pPred      = piPred;
791    Pel* pResi      = piResi;
792    Pel* pReco      = piReco;
793    Pel* pRecIPred  = piRecIPred;
794    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
795    {
796      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
797      {
798        pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
799        pRecIPred[ uiX ] = pReco[ uiX ];
800      }
801      pPred     += uiStride;
802      pResi     += uiStride;
803      pReco     += uiStride;
804      pRecIPred += uiRecIPredStride;
805    }
806  }
807}
808
809
810Void
811TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
812                           UInt        uiTrDepth,
813                           UInt        uiAbsPartIdx,
814                           TComYuv*    pcRecoYuv,
815                           TComYuv*    pcPredYuv, 
816                           TComYuv*    pcResiYuv,
817                           UInt        uiChromaId )
818{
819  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
820  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
821  if( uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
822  {
823    assert( uiTrDepth > 0 );
824    uiTrDepth--;
825    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
826    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
827    if( !bFirstQ )
828    {
829      return;
830    }
831  }
832 
833  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
834  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
835  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
836  UInt      uiStride          = pcRecoYuv->getCStride ();
837  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
838  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
839  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
840 
841  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
842  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
843 
844  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
845 
846#if !LM_CHROMA
847  if( uiChromaPredMode == 4 )
848  {
849    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
850  }
851#endif
852 
853  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
854  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
855  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
856 
857  //===== init availability pattern =====
858  Bool  bAboveAvail = false;
859  Bool  bLeftAvail  = false;
860  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
861  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, 
862                                           m_pcPrediction->getPredicBuf       (),
863                                           m_pcPrediction->getPredicBufWidth  (),
864                                           m_pcPrediction->getPredicBufHeight (),
865                                           bAboveAvail, bLeftAvail );
866  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
867 
868  //===== get prediction signal =====
869#if LM_CHROMA
870  if(pcCU->getSlice()->getSPS()->getUseLMChroma() && uiChromaPredMode == 3)
871  {
872      m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
873  }
874  else
875  {
876    if( uiChromaPredMode == 4 )
877    {
878    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
879    }
880  m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
881  }
882#else // LM_CHROMA
883  m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
884#endif
885
886  //===== inverse transform =====
887  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
888#if INTRA_DST_TYPE_7
889  m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight );
890#else
891  m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
892#endif
893
894  //===== reconstruction =====
895  {
896    Pel* pPred      = piPred;
897    Pel* pResi      = piResi;
898    Pel* pReco      = piReco;
899    Pel* pRecIPred  = piRecIPred;
900    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
901    {
902      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
903      {
904        pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
905        pRecIPred[ uiX ] = pReco[ uiX ];
906      }
907      pPred     += uiStride;
908      pResi     += uiStride;
909      pReco     += uiStride;
910      pRecIPred += uiRecIPredStride;
911    }
912  }
913}
914
915Void
916TDecCu::xIntraRecQT( TComDataCU* pcCU,
917                    UInt        uiTrDepth,
918                    UInt        uiAbsPartIdx,
919                    TComYuv*    pcRecoYuv,
920                    TComYuv*    pcPredYuv, 
921                    TComYuv*    pcResiYuv )
922{
923  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
924  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
925  if( uiTrMode == uiTrDepth )
926  {
927    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
928    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
929    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
930  }
931  else
932  {
933    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
934    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
935    {
936      xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
937    }
938  }
939}
940
941Void
942TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
943{
944  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
945  UInt  uiNumPart     = pcCU->getNumPartInter();
946  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
947 
948#if LM_CHROMA
949  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
950  {
951    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
952  } 
953
954  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
955  {
956    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
957  }
958#else
959
960  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
961  {
962    xIntraRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
963  }
964#endif
965
966}
967
968#if LM_CHROMA
969
970/** Funtion for deriving recontructed PU/CU Luma sample with QTree structure
971 * \param pcCU pointer of current CU
972 * \param uiTrDepth current tranform split depth
973 * \param uiAbsPartIdx  part index
974 * \param pcRecoYuv pointer to reconstructed sample arrays
975 * \param pcPredYuv pointer to prediction sample arrays
976 * \param pcResiYuv pointer to residue sample arrays
977 *
978 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
979 */
980Void
981TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
982                     UInt        uiTrDepth,
983                     UInt        uiAbsPartIdx,
984                     TComYuv*    pcRecoYuv,
985                     TComYuv*    pcPredYuv, 
986                     TComYuv*    pcResiYuv )
987{
988  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
989  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
990  if( uiTrMode == uiTrDepth )
991  {
992    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
993  }
994  else
995  {
996    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
997    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
998    {
999      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1000    }
1001  }
1002}
1003
1004/** Funtion for deriving recontructed PU/CU chroma samples with QTree structure
1005 * \param pcCU pointer of current CU
1006 * \param uiTrDepth current tranform split depth
1007 * \param uiAbsPartIdx  part index
1008 * \param pcRecoYuv pointer to reconstructed sample arrays
1009 * \param pcPredYuv pointer to prediction sample arrays
1010 * \param pcResiYuv pointer to residue sample arrays
1011 *
1012 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1013 */
1014Void
1015TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1016                     UInt        uiTrDepth,
1017                     UInt        uiAbsPartIdx,
1018                     TComYuv*    pcRecoYuv,
1019                     TComYuv*    pcPredYuv, 
1020                     TComYuv*    pcResiYuv )
1021{
1022  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1023  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1024  if( uiTrMode == uiTrDepth )
1025  {
1026    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1027    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1028  }
1029  else
1030  {
1031    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1032    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1033    {
1034      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1035    }
1036  }
1037}
1038#endif
1039
1040Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1041{
1042  UInt uiCUAddr = pcCU->getAddr();
1043 
1044  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1045 
1046  return;
1047}
1048
1049Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1050{
1051  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1052  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1053  TCoeff* piCoeff;
1054 
1055  Pel*    pResi;
1056  UInt    uiLumaTrMode, uiChromaTrMode;
1057 
1058  pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
1059 
1060  // Y
1061  piCoeff = pcCU->getCoeffY();
1062  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1063  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
1064  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
1065 
1066  // Cb and Cr
1067  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
1068 
1069  uiWidth  >>= 1;
1070  uiHeight >>= 1;
1071  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1072  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1073  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1074  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1075}
1076
Note: See TracBrowser for help on using the repository browser.