source: 3DVCSoftware/branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp @ 34

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

Updated configuration files and minor decoder bug fix

  • Property svn:eol-style set to native
File size: 41.8 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 )) // 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
444Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx,  UInt uiDepth )
445{
446  TComPic* pcPic = pcCU->getPic();
447#if POZNAN_SYNTH_VIEW
448  if(pcPic->getPicYuvSynth())  m_ppcYuvSynth[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx );
449#endif
450#if POZNAN_AVAIL_MAP
451  if(pcPic->getPicYuvAvail())  m_ppcYuvAvail[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx );
452#endif
453 
454  Bool bBoundary = false;
455  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
456  UInt uiRPelX   = uiLPelX + (g_uiMaxCUWidth>>uiDepth)  - 1;
457  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
458  UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
459 
460  if( ( uiRPelX >= pcCU->getSlice()->getSPS()->getWidth() ) || ( uiBPelY >= pcCU->getSlice()->getSPS()->getHeight() ) )
461  {
462    bBoundary = true;
463  }
464 
465  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
466  {
467    UInt uiNextDepth = uiDepth + 1;
468    UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1);
469    UInt uiIdx = uiAbsPartIdx;
470    for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ )
471    {
472      uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
473      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
474     
475      if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
476        xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth );
477     
478      uiIdx += uiQNumParts;
479    }
480    return;
481  }
482 
483  // Residual reconstruction
484  m_ppcYuvResi[uiDepth]->clear();
485 
486  m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
487 
488  switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
489  {
490    case MODE_SKIP:
491    case MODE_INTER:
492      xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
493      break;
494    case MODE_INTRA:
495      xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
496      break;
497#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
498    case MODE_SYNTH:
499    //  break;
500#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
501      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx);
502#else
503      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx); //Poprawiæ
504#endif
505      //m_ppcYuvReco[uiDepth]->clear();
506      break;
507#endif
508    default:
509      assert(0);
510      break;
511  }
512 
513  xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
514}
515
516Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
517{
518#if HHI_MPI
519  if( pcCU->getTextureModeDepth( 0 ) != -1 )
520    pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
521#endif
522 
523  // inter prediction
524  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
525 
526#if HHI_MPI
527  if( pcCU->getTextureModeDepth( 0 ) != -1 )
528    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
529#endif
530 
531#if HHI_INTER_VIEW_RESIDUAL_PRED
532  if( pcCU->getResPredFlag( 0 ) )
533  {
534    AOF( pcCU->getResPredAvail( 0 ) );
535    Bool bOK = pcCU->getResidualSamples( 0, m_ppcYuvResPred[uiDepth] );
536    AOF( bOK );
537    m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
538  }
539#endif
540
541  // inter recon
542  xDecodeInterTexture( pcCU, 0, uiDepth );
543 
544  // clip for only non-zero cbp case
545  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
546  {
547    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
548  }
549  else
550  {
551#if HHI_INTER_VIEW_RESIDUAL_PRED
552    if( pcCU->getResPredFlag( 0 ) )
553    {
554      m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) );
555    }
556#endif
557    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
558  }
559}
560
561Void TDecCu::xDecodeIntraTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel* piReco, Pel* piPred, Pel* piResi, UInt uiStride, TCoeff* pCoeff, UInt uiWidth, UInt uiHeight, UInt uiCurrDepth )
562{
563  if( pcCU->getTransformIdx(0) == uiCurrDepth )
564  {
565    UInt uiX, uiY;
566    TComPattern* pcPattern = pcCU->getPattern();
567    UInt uiZorder          = pcCU->getZorderIdxInCU()+uiPartIdx;
568    Pel* pPred             = piPred;
569    Pel* pResi             = piResi;
570    Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), uiZorder);
571    UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride();
572   
573    pcPattern->initPattern( pcCU, uiCurrDepth, uiPartIdx );
574   
575    Bool bAboveAvail = false;
576    Bool bLeftAvail  = false;
577   
578    pcPattern->initAdiPattern(pcCU, uiPartIdx, uiCurrDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail);
579   
580    m_pcPrediction->predIntraLumaAng( pcPattern, pcCU->getLumaIntraDir(uiPartIdx), pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
581   
582#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
583    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx) + pcCU->getQpOffsetForTextCU(uiPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
584#else
585    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
586#endif
587#if INTRA_DST_TYPE_7
588  m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight );
589#else
590  m_pcTrQuant->invtransformNxN( pResi, uiStride, pCoeff, uiWidth, uiHeight );
591#endif
592    // Reconstruction
593    {
594      pResi = piResi;
595      pPred = piPred;
596      for( uiY = 0; uiY < uiHeight; uiY++ )
597      {
598        for( uiX = 0; uiX < uiWidth; uiX++ )
599        {
600          piReco   [uiX] = Clip(pPred[uiX] + pResi[uiX]);
601          piPicReco[uiX] = piReco[uiX];
602        }
603        piReco    += uiStride;
604        pPred     += uiStride;
605        pResi     += uiStride;
606        piPicReco += uiPicStride;
607      }
608    }
609  }
610  else
611  {
612    uiCurrDepth++;
613    uiWidth  >>= 1;
614    uiHeight >>= 1;
615    UInt uiPartOffset  = pcCU->getTotalNumPart()>>(uiCurrDepth<<1);
616    UInt uiCoeffOffset = uiWidth  * uiHeight;
617    UInt uiPelOffset   = uiHeight * uiStride;
618    Pel* pResi = piResi;
619    Pel* pReco = piReco;
620    Pel* pPred = piPred;
621    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
622    uiPartIdx += uiPartOffset;
623    pCoeff    += uiCoeffOffset;
624    pResi      = piResi + uiWidth;
625    pReco      = piReco + uiWidth;
626    pPred      = piPred + uiWidth;
627    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
628    uiPartIdx += uiPartOffset;
629    pCoeff    += uiCoeffOffset;
630    pResi      = piResi + uiPelOffset;
631    pReco      = piReco + uiPelOffset;
632    pPred      = piPred + uiPelOffset;
633    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
634    uiPartIdx += uiPartOffset;
635    pCoeff    += uiCoeffOffset;
636    pResi      = piResi + uiPelOffset + uiWidth;
637    pReco      = piReco + uiPelOffset + uiWidth;
638    pPred      = piPred + uiPelOffset + uiWidth;
639    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
640  }
641}
642
643// ADI chroma
644Void 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 )
645{
646  if( uiTrMode == uiCurrTrMode )
647  {
648    UInt uiX, uiY;
649    UInt uiZorder    = pcCU->getZorderIdxInCU()+uiAbsPartIdx;
650    Pel* pResi       = piResi;
651    Pel* pPred       = piPred;
652    Pel* piPicReco;
653    if( eText == TEXT_CHROMA_U )
654      piPicReco= pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), uiZorder);
655    else
656      piPicReco= pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), uiZorder);
657   
658    UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
659   
660    pcCU->getPattern()->initPattern( pcCU, uiCurrTrMode, uiAbsPartIdx );
661   
662    Bool bAboveAvail = false;
663    Bool bLeftAvail  = false;
664   
665    pcCU->getPattern()->initAdiPatternChroma(pcCU,uiAbsPartIdx, uiCurrTrMode, m_pcPrediction->getPredicBuf(),m_pcPrediction->getPredicBufWidth(),m_pcPrediction->getPredicBufHeight(),bAboveAvail,bLeftAvail);
666   
667    UInt uiModeL        = pcCU->getLumaIntraDir(0);
668    UInt uiMode         = pcCU->getChromaIntraDir(0);
669   
670    if (uiMode==4) uiMode = uiModeL;
671   
672    Int*   pPatChr;
673   
674    if (eText==TEXT_CHROMA_U)
675    {
676      pPatChr=  pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
677    }
678    else // (eText==TEXT_CHROMA_V)
679    {
680      pPatChr=  pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
681    }
682   
683    m_pcPrediction-> predIntraChromaAng( pcCU->getPattern(), pPatChr, uiMode, pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
684   
685    // Inverse Transform
686    if( pcCU->getCbf(0, eText, uiCurrTrMode) )
687    {
688#if INTRA_DST_TYPE_7
689    m_pcTrQuant->invtransformNxN( eText, REG_DCT, pResi, uiStride, piCoeff, uiWidth, uiHeight);
690#else
691    m_pcTrQuant->invtransformNxN( pResi, uiStride, piCoeff, uiWidth, uiHeight );
692#endif
693    }
694    pResi = piResi;
695   
696    for( uiY = 0; uiY < uiHeight; uiY++ )
697    {
698      for( uiX = 0; uiX < uiWidth; uiX++ )
699      {
700        piReco   [uiX] = Clip( pPred[uiX] + pResi[uiX] );
701        piPicReco[uiX] = piReco[uiX];
702      }
703     
704      pPred     += uiStride;
705      pResi     += uiStride;
706      piReco    += uiStride;
707      piPicReco += uiPicStride;
708    }
709  }
710  else
711  {
712    uiCurrTrMode++;
713    uiWidth  >>= 1;
714    uiHeight >>= 1;
715    UInt uiCoeffOffset = uiWidth*uiHeight;
716    UInt uiPelOffset   = uiHeight*uiStride;
717    UInt uiPartOffst   = pcCU->getTotalNumPart()>>(uiCurrTrMode<<1);
718    Pel* pResi = piResi;
719    Pel* pPred = piPred;
720    Pel* pReco = piReco;
721    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
722    uiAbsPartIdx += uiPartOffst;
723    piCoeff      += uiCoeffOffset;
724    pResi         = piResi + uiWidth; pPred = piPred + uiWidth; pReco = piReco + uiWidth;
725    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
726    uiAbsPartIdx += uiPartOffst;
727    piCoeff      += uiCoeffOffset;
728    pResi         = piResi + uiPelOffset; pPred = piPred + uiPelOffset; pReco = piReco + uiPelOffset;
729    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
730    uiAbsPartIdx += uiPartOffst;
731    piCoeff      += uiCoeffOffset;
732    pResi         = piResi + uiPelOffset + uiWidth; pPred = piPred + uiPelOffset + uiWidth; pReco = piReco + uiPelOffset + uiWidth;
733    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
734  }
735}
736
737Void
738TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
739                         UInt        uiTrDepth,
740                         UInt        uiAbsPartIdx,
741                         TComYuv*    pcRecoYuv,
742                         TComYuv*    pcPredYuv, 
743                         TComYuv*    pcResiYuv )
744{
745  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
746  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
747  UInt    uiStride          = pcRecoYuv->getStride  ();
748  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
749  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
750  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
751 
752  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
753  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
754 
755  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
756 
757  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
758  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
759  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
760 
761  //===== init availability pattern =====
762  Bool  bAboveAvail = false;
763  Bool  bLeftAvail  = false;
764  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
765  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
766                                     m_pcPrediction->getPredicBuf       (),
767                                     m_pcPrediction->getPredicBufWidth  (),
768                                     m_pcPrediction->getPredicBufHeight (),
769                                     bAboveAvail, bLeftAvail );
770 
771#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
772  if( uiLumaPredMode > MAX_MODE_ID_INTRA_DIR )
773  {
774    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
775  } 
776  else
777#endif
778  {   
779  //===== get prediction signal =====
780  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
781  }
782  //===== inverse transform =====
783#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
784    m_pcTrQuant->setQPforQuant( pcCU->getQP(0) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
785#else
786  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
787#endif
788#if INTRA_DST_TYPE_7
789  m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight );
790#else
791  m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
792#endif 
793
794 
795  //===== reconstruction =====
796  {
797    Pel* pPred      = piPred;
798    Pel* pResi      = piResi;
799    Pel* pReco      = piReco;
800    Pel* pRecIPred  = piRecIPred;
801    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
802    {
803      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
804      {
805        pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
806        pRecIPred[ uiX ] = pReco[ uiX ];
807      }
808      pPred     += uiStride;
809      pResi     += uiStride;
810      pReco     += uiStride;
811      pRecIPred += uiRecIPredStride;
812    }
813  }
814}
815
816
817Void
818TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
819                           UInt        uiTrDepth,
820                           UInt        uiAbsPartIdx,
821                           TComYuv*    pcRecoYuv,
822                           TComYuv*    pcPredYuv, 
823                           TComYuv*    pcResiYuv,
824                           UInt        uiChromaId )
825{
826  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
827  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
828  if( uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
829  {
830    assert( uiTrDepth > 0 );
831    uiTrDepth--;
832    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
833    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
834    if( !bFirstQ )
835    {
836      return;
837    }
838  }
839 
840  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
841  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
842  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
843  UInt      uiStride          = pcRecoYuv->getCStride ();
844  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
845  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
846  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
847 
848  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
849  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
850 
851  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
852 
853#if !LM_CHROMA
854  if( uiChromaPredMode == 4 )
855  {
856    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
857  }
858#endif
859 
860  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
861  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
862  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
863 
864  //===== init availability pattern =====
865  Bool  bAboveAvail = false;
866  Bool  bLeftAvail  = false;
867  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
868  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, 
869                                           m_pcPrediction->getPredicBuf       (),
870                                           m_pcPrediction->getPredicBufWidth  (),
871                                           m_pcPrediction->getPredicBufHeight (),
872                                           bAboveAvail, bLeftAvail );
873  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
874 
875  //===== get prediction signal =====
876#if LM_CHROMA
877  if(pcCU->getSlice()->getSPS()->getUseLMChroma() && uiChromaPredMode == 3)
878  {
879      m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
880  }
881  else
882  {
883    if( uiChromaPredMode == 4 )
884    {
885    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
886    }
887  m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
888  }
889#else // LM_CHROMA
890  m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
891#endif
892
893  //===== inverse transform =====
894#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
895  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
896#else
897  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
898#endif
899#if INTRA_DST_TYPE_7
900  m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight );
901#else
902  m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
903#endif
904
905  //===== reconstruction =====
906  {
907    Pel* pPred      = piPred;
908    Pel* pResi      = piResi;
909    Pel* pReco      = piReco;
910    Pel* pRecIPred  = piRecIPred;
911    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
912    {
913      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
914      {
915        pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
916        pRecIPred[ uiX ] = pReco[ uiX ];
917      }
918      pPred     += uiStride;
919      pResi     += uiStride;
920      pReco     += uiStride;
921      pRecIPred += uiRecIPredStride;
922    }
923  }
924}
925
926Void
927TDecCu::xIntraRecQT( TComDataCU* pcCU,
928                    UInt        uiTrDepth,
929                    UInt        uiAbsPartIdx,
930                    TComYuv*    pcRecoYuv,
931                    TComYuv*    pcPredYuv, 
932                    TComYuv*    pcResiYuv )
933{
934  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
935  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
936  if( uiTrMode == uiTrDepth )
937  {
938    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
939    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
940    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
941  }
942  else
943  {
944    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
945    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
946    {
947      xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
948    }
949  }
950}
951
952Void
953TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
954{
955  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
956  UInt  uiNumPart     = pcCU->getNumPartInter();
957  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
958 
959#if LM_CHROMA
960  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
961  {
962    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
963  } 
964
965  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
966  {
967    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
968  }
969#else
970
971  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
972  {
973    xIntraRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
974  }
975#endif
976
977}
978
979#if LM_CHROMA
980
981/** Funtion for deriving recontructed PU/CU Luma sample with QTree structure
982 * \param pcCU pointer of current CU
983 * \param uiTrDepth current tranform split depth
984 * \param uiAbsPartIdx  part index
985 * \param pcRecoYuv pointer to reconstructed sample arrays
986 * \param pcPredYuv pointer to prediction sample arrays
987 * \param pcResiYuv pointer to residue sample arrays
988 *
989 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
990 */
991Void
992TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
993                     UInt        uiTrDepth,
994                     UInt        uiAbsPartIdx,
995                     TComYuv*    pcRecoYuv,
996                     TComYuv*    pcPredYuv, 
997                     TComYuv*    pcResiYuv )
998{
999  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1000  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1001  if( uiTrMode == uiTrDepth )
1002  {
1003    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1004  }
1005  else
1006  {
1007    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1008    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1009    {
1010      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1011    }
1012  }
1013}
1014
1015/** Funtion for deriving recontructed PU/CU chroma samples with QTree structure
1016 * \param pcCU pointer of current CU
1017 * \param uiTrDepth current tranform split depth
1018 * \param uiAbsPartIdx  part index
1019 * \param pcRecoYuv pointer to reconstructed sample arrays
1020 * \param pcPredYuv pointer to prediction sample arrays
1021 * \param pcResiYuv pointer to residue sample arrays
1022 *
1023 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1024 */
1025Void
1026TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1027                     UInt        uiTrDepth,
1028                     UInt        uiAbsPartIdx,
1029                     TComYuv*    pcRecoYuv,
1030                     TComYuv*    pcPredYuv, 
1031                     TComYuv*    pcResiYuv )
1032{
1033  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1034  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1035  if( uiTrMode == uiTrDepth )
1036  {
1037    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1038    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1039  }
1040  else
1041  {
1042    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1043    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1044    {
1045      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1046    }
1047  }
1048}
1049#endif
1050
1051Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1052{
1053  UInt uiCUAddr = pcCU->getAddr();
1054 
1055  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1056 
1057  return;
1058}
1059
1060Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1061{
1062  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1063  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1064  TCoeff* piCoeff;
1065 
1066  Pel*    pResi;
1067  UInt    uiLumaTrMode, uiChromaTrMode;
1068 
1069  pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
1070 
1071  // Y
1072  piCoeff = pcCU->getCoeffY();
1073  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1074#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
1075  Int QPoffset = pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false);
1076  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(uiAbsPartIdx) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
1077#else
1078  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
1079#endif
1080  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
1081 
1082  // Cb and Cr
1083#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
1084    m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
1085#else
1086  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
1087#endif
1088 
1089  uiWidth  >>= 1;
1090  uiHeight >>= 1;
1091  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1092  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1093  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1094  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1095}
1096
Note: See TracBrowser for help on using the repository browser.