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

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

Poznan Tools

  • Encoding only disoccluded CUs in depended views
  • Depth based motion prediction
  • Texture QP adjustment based on depth data
  • Nonlinear depth representation
  • 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}
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#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
584    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx) + pcCU->getQpOffsetForTextCU(uiPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
585#else
586    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
587#endif
588#if INTRA_DST_TYPE_7
589  m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight );
590#else
591  m_pcTrQuant->invtransformNxN( pResi, uiStride, pCoeff, uiWidth, uiHeight );
592#endif
593    // Reconstruction
594    {
595      pResi = piResi;
596      pPred = piPred;
597      for( uiY = 0; uiY < uiHeight; uiY++ )
598      {
599        for( uiX = 0; uiX < uiWidth; uiX++ )
600        {
601          piReco   [uiX] = Clip(pPred[uiX] + pResi[uiX]);
602          piPicReco[uiX] = piReco[uiX];
603        }
604        piReco    += uiStride;
605        pPred     += uiStride;
606        pResi     += uiStride;
607        piPicReco += uiPicStride;
608      }
609    }
610  }
611  else
612  {
613    uiCurrDepth++;
614    uiWidth  >>= 1;
615    uiHeight >>= 1;
616    UInt uiPartOffset  = pcCU->getTotalNumPart()>>(uiCurrDepth<<1);
617    UInt uiCoeffOffset = uiWidth  * uiHeight;
618    UInt uiPelOffset   = uiHeight * uiStride;
619    Pel* pResi = piResi;
620    Pel* pReco = piReco;
621    Pel* pPred = piPred;
622    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
623    uiPartIdx += uiPartOffset;
624    pCoeff    += uiCoeffOffset;
625    pResi      = piResi + uiWidth;
626    pReco      = piReco + uiWidth;
627    pPred      = piPred + uiWidth;
628    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
629    uiPartIdx += uiPartOffset;
630    pCoeff    += uiCoeffOffset;
631    pResi      = piResi + uiPelOffset;
632    pReco      = piReco + uiPelOffset;
633    pPred      = piPred + uiPelOffset;
634    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
635    uiPartIdx += uiPartOffset;
636    pCoeff    += uiCoeffOffset;
637    pResi      = piResi + uiPelOffset + uiWidth;
638    pReco      = piReco + uiPelOffset + uiWidth;
639    pPred      = piPred + uiPelOffset + uiWidth;
640    xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth );
641  }
642}
643
644// ADI chroma
645Void 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 )
646{
647  if( uiTrMode == uiCurrTrMode )
648  {
649    UInt uiX, uiY;
650    UInt uiZorder    = pcCU->getZorderIdxInCU()+uiAbsPartIdx;
651    Pel* pResi       = piResi;
652    Pel* pPred       = piPred;
653    Pel* piPicReco;
654    if( eText == TEXT_CHROMA_U )
655      piPicReco= pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), uiZorder);
656    else
657      piPicReco= pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), uiZorder);
658   
659    UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride();
660   
661    pcCU->getPattern()->initPattern( pcCU, uiCurrTrMode, uiAbsPartIdx );
662   
663    Bool bAboveAvail = false;
664    Bool bLeftAvail  = false;
665   
666    pcCU->getPattern()->initAdiPatternChroma(pcCU,uiAbsPartIdx, uiCurrTrMode, m_pcPrediction->getPredicBuf(),m_pcPrediction->getPredicBufWidth(),m_pcPrediction->getPredicBufHeight(),bAboveAvail,bLeftAvail);
667   
668    UInt uiModeL        = pcCU->getLumaIntraDir(0);
669    UInt uiMode         = pcCU->getChromaIntraDir(0);
670   
671    if (uiMode==4) uiMode = uiModeL;
672   
673    Int*   pPatChr;
674   
675    if (eText==TEXT_CHROMA_U)
676    {
677      pPatChr=  pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
678    }
679    else // (eText==TEXT_CHROMA_V)
680    {
681      pPatChr=  pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() );
682    }
683   
684    m_pcPrediction-> predIntraChromaAng( pcCU->getPattern(), pPatChr, uiMode, pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
685   
686    // Inverse Transform
687    if( pcCU->getCbf(0, eText, uiCurrTrMode) )
688    {
689#if INTRA_DST_TYPE_7
690    m_pcTrQuant->invtransformNxN( eText, REG_DCT, pResi, uiStride, piCoeff, uiWidth, uiHeight);
691#else
692    m_pcTrQuant->invtransformNxN( pResi, uiStride, piCoeff, uiWidth, uiHeight );
693#endif
694    }
695    pResi = piResi;
696   
697    for( uiY = 0; uiY < uiHeight; uiY++ )
698    {
699      for( uiX = 0; uiX < uiWidth; uiX++ )
700      {
701        piReco   [uiX] = Clip( pPred[uiX] + pResi[uiX] );
702        piPicReco[uiX] = piReco[uiX];
703      }
704     
705      pPred     += uiStride;
706      pResi     += uiStride;
707      piReco    += uiStride;
708      piPicReco += uiPicStride;
709    }
710  }
711  else
712  {
713    uiCurrTrMode++;
714    uiWidth  >>= 1;
715    uiHeight >>= 1;
716    UInt uiCoeffOffset = uiWidth*uiHeight;
717    UInt uiPelOffset   = uiHeight*uiStride;
718    UInt uiPartOffst   = pcCU->getTotalNumPart()>>(uiCurrTrMode<<1);
719    Pel* pResi = piResi;
720    Pel* pPred = piPred;
721    Pel* pReco = piReco;
722    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
723    uiAbsPartIdx += uiPartOffst;
724    piCoeff      += uiCoeffOffset;
725    pResi         = piResi + uiWidth; pPred = piPred + uiWidth; pReco = piReco + uiWidth;
726    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
727    uiAbsPartIdx += uiPartOffst;
728    piCoeff      += uiCoeffOffset;
729    pResi         = piResi + uiPelOffset; pPred = piPred + uiPelOffset; pReco = piReco + uiPelOffset;
730    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
731    uiAbsPartIdx += uiPartOffst;
732    piCoeff      += uiCoeffOffset;
733    pResi         = piResi + uiPelOffset + uiWidth; pPred = piPred + uiPelOffset + uiWidth; pReco = piReco + uiPelOffset + uiWidth;
734    xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText );
735  }
736}
737
738Void
739TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU,
740                         UInt        uiTrDepth,
741                         UInt        uiAbsPartIdx,
742                         TComYuv*    pcRecoYuv,
743                         TComYuv*    pcPredYuv, 
744                         TComYuv*    pcResiYuv )
745{
746  UInt    uiWidth           = pcCU     ->getWidth   ( 0 ) >> uiTrDepth;
747  UInt    uiHeight          = pcCU     ->getHeight  ( 0 ) >> uiTrDepth;
748  UInt    uiStride          = pcRecoYuv->getStride  ();
749  Pel*    piReco            = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
750  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
751  Pel*    piResi            = pcResiYuv->getLumaAddr( uiAbsPartIdx );
752 
753  UInt    uiNumCoeffInc     = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 );
754  TCoeff* pcCoeff           = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx );
755 
756  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
757 
758  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
759  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
760  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
761 
762  //===== init availability pattern =====
763  Bool  bAboveAvail = false;
764  Bool  bLeftAvail  = false;
765  pcCU->getPattern()->initPattern   ( pcCU, uiTrDepth, uiAbsPartIdx );
766  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 
767                                     m_pcPrediction->getPredicBuf       (),
768                                     m_pcPrediction->getPredicBufWidth  (),
769                                     m_pcPrediction->getPredicBufHeight (),
770                                     bAboveAvail, bLeftAvail );
771 
772#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
773  if( uiLumaPredMode > MAX_MODE_ID_INTRA_DIR )
774  {
775    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
776  } 
777  else
778#endif
779  {   
780  //===== get prediction signal =====
781  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
782  }
783  //===== inverse transform =====
784#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
785    m_pcTrQuant->setQPforQuant( pcCU->getQP(0) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
786#else
787  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
788#endif
789#if INTRA_DST_TYPE_7
790  m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight );
791#else
792  m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
793#endif 
794
795 
796  //===== reconstruction =====
797  {
798    Pel* pPred      = piPred;
799    Pel* pResi      = piResi;
800    Pel* pReco      = piReco;
801    Pel* pRecIPred  = piRecIPred;
802    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
803    {
804      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
805      {
806        pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
807        pRecIPred[ uiX ] = pReco[ uiX ];
808      }
809      pPred     += uiStride;
810      pResi     += uiStride;
811      pReco     += uiStride;
812      pRecIPred += uiRecIPredStride;
813    }
814  }
815}
816
817
818Void
819TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,
820                           UInt        uiTrDepth,
821                           UInt        uiAbsPartIdx,
822                           TComYuv*    pcRecoYuv,
823                           TComYuv*    pcPredYuv, 
824                           TComYuv*    pcResiYuv,
825                           UInt        uiChromaId )
826{
827  UInt uiFullDepth  = pcCU->getDepth( 0 ) + uiTrDepth;
828  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;
829  if( uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
830  {
831    assert( uiTrDepth > 0 );
832    uiTrDepth--;
833    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );
834    Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );
835    if( !bFirstQ )
836    {
837      return;
838    }
839  }
840 
841  TextType  eText             = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );
842  UInt      uiWidth           = pcCU     ->getWidth   ( 0 ) >> ( uiTrDepth + 1 );
843  UInt      uiHeight          = pcCU     ->getHeight  ( 0 ) >> ( uiTrDepth + 1 );
844  UInt      uiStride          = pcRecoYuv->getCStride ();
845  Pel*      piReco            = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );
846  Pel*      piPred            = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );
847  Pel*      piResi            = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );
848 
849  UInt      uiNumCoeffInc     = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;
850  TCoeff*   pcCoeff           = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );
851 
852  UInt      uiChromaPredMode  = pcCU->getChromaIntraDir( 0 );
853 
854#if !LM_CHROMA
855  if( uiChromaPredMode == 4 )
856  {
857    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
858  }
859#endif
860 
861  UInt      uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
862  Pel*      piRecIPred        = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );
863  UInt      uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getCStride();
864 
865  //===== init availability pattern =====
866  Bool  bAboveAvail = false;
867  Bool  bLeftAvail  = false;
868  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
869  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, 
870                                           m_pcPrediction->getPredicBuf       (),
871                                           m_pcPrediction->getPredicBufWidth  (),
872                                           m_pcPrediction->getPredicBufHeight (),
873                                           bAboveAvail, bLeftAvail );
874  Int* pPatChroma   = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );
875 
876  //===== get prediction signal =====
877#if LM_CHROMA
878  if(pcCU->getSlice()->getSPS()->getUseLMChroma() && uiChromaPredMode == 3)
879  {
880      m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
881  }
882  else
883  {
884    if( uiChromaPredMode == 4 )
885    {
886    uiChromaPredMode          = pcCU->getLumaIntraDir( 0 );
887    }
888  m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
889  }
890#else // LM_CHROMA
891  m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
892#endif
893
894  //===== inverse transform =====
895#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
896  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
897#else
898  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
899#endif
900#if INTRA_DST_TYPE_7
901  m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight );
902#else
903  m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight );
904#endif
905
906  //===== reconstruction =====
907  {
908    Pel* pPred      = piPred;
909    Pel* pResi      = piResi;
910    Pel* pReco      = piReco;
911    Pel* pRecIPred  = piRecIPred;
912    for( UInt uiY = 0; uiY < uiHeight; uiY++ )
913    {
914      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
915      {
916        pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
917        pRecIPred[ uiX ] = pReco[ uiX ];
918      }
919      pPred     += uiStride;
920      pResi     += uiStride;
921      pReco     += uiStride;
922      pRecIPred += uiRecIPredStride;
923    }
924  }
925}
926
927Void
928TDecCu::xIntraRecQT( TComDataCU* pcCU,
929                    UInt        uiTrDepth,
930                    UInt        uiAbsPartIdx,
931                    TComYuv*    pcRecoYuv,
932                    TComYuv*    pcPredYuv, 
933                    TComYuv*    pcResiYuv )
934{
935  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
936  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
937  if( uiTrMode == uiTrDepth )
938  {
939    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
940    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
941    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
942  }
943  else
944  {
945    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
946    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
947    {
948      xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
949    }
950  }
951}
952
953Void
954TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
955{
956  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
957  UInt  uiNumPart     = pcCU->getNumPartInter();
958  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
959 
960#if LM_CHROMA
961  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
962  {
963    xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
964  } 
965
966  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
967  {
968    xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
969  }
970#else
971
972  for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ )
973  {
974    xIntraRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] );
975  }
976#endif
977
978}
979
980#if LM_CHROMA
981
982/** Funtion for deriving recontructed PU/CU Luma sample with QTree structure
983 * \param pcCU pointer of current CU
984 * \param uiTrDepth current tranform split depth
985 * \param uiAbsPartIdx  part index
986 * \param pcRecoYuv pointer to reconstructed sample arrays
987 * \param pcPredYuv pointer to prediction sample arrays
988 * \param pcResiYuv pointer to residue sample arrays
989 *
990 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure
991 */
992Void
993TDecCu::xIntraLumaRecQT( TComDataCU* pcCU,
994                     UInt        uiTrDepth,
995                     UInt        uiAbsPartIdx,
996                     TComYuv*    pcRecoYuv,
997                     TComYuv*    pcPredYuv, 
998                     TComYuv*    pcResiYuv )
999{
1000  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1001  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1002  if( uiTrMode == uiTrDepth )
1003  {
1004    xIntraRecLumaBlk  ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv );
1005  }
1006  else
1007  {
1008    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1009    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1010    {
1011      xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1012    }
1013  }
1014}
1015
1016/** Funtion for deriving recontructed PU/CU chroma samples with QTree structure
1017 * \param pcCU pointer of current CU
1018 * \param uiTrDepth current tranform split depth
1019 * \param uiAbsPartIdx  part index
1020 * \param pcRecoYuv pointer to reconstructed sample arrays
1021 * \param pcPredYuv pointer to prediction sample arrays
1022 * \param pcResiYuv pointer to residue sample arrays
1023 *
1024 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure
1025 */
1026Void
1027TDecCu::xIntraChromaRecQT( TComDataCU* pcCU,
1028                     UInt        uiTrDepth,
1029                     UInt        uiAbsPartIdx,
1030                     TComYuv*    pcRecoYuv,
1031                     TComYuv*    pcPredYuv, 
1032                     TComYuv*    pcResiYuv )
1033{
1034  UInt uiFullDepth  = pcCU->getDepth(0) + uiTrDepth;
1035  UInt uiTrMode     = pcCU->getTransformIdx( uiAbsPartIdx );
1036  if( uiTrMode == uiTrDepth )
1037  {
1038    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 );
1039    xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 );
1040  }
1041  else
1042  {
1043    UInt uiNumQPart  = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 );
1044    for( UInt uiPart = 0; uiPart < 4; uiPart++ )
1045    {
1046      xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv );
1047    }
1048  }
1049}
1050#endif
1051
1052Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth )
1053{
1054  UInt uiCUAddr = pcCU->getAddr();
1055 
1056  m_ppcYuvReco[uiDepth]->copyToPicYuv  ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx );
1057 
1058  return;
1059}
1060
1061Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1062{
1063  UInt    uiWidth    = pcCU->getWidth ( uiAbsPartIdx );
1064  UInt    uiHeight   = pcCU->getHeight( uiAbsPartIdx );
1065  TCoeff* piCoeff;
1066 
1067  Pel*    pResi;
1068  UInt    uiLumaTrMode, uiChromaTrMode;
1069 
1070  pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
1071 
1072  // Y
1073  piCoeff = pcCU->getCoeffY();
1074  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
1075#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
1076  Int QPoffset = pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false);
1077  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(uiAbsPartIdx) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
1078#else
1079  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
1080#endif
1081  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
1082 
1083  // Cb and Cr
1084#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
1085    m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
1086#else
1087  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
1088#endif
1089 
1090  uiWidth  >>= 1;
1091  uiHeight >>= 1;
1092  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
1093  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1094  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
1095  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
1096}
1097
Note: See TracBrowser for help on using the repository browser.