source: 3DVCSoftware/branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.cpp @ 192

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

Reintegrated branch 4.1-dev0 Rev. 188.

  • Property svn:eol-style set to native
File size: 20.5 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2012, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TComPic.cpp
35    \brief    picture class
36*/
37
38#include "TComPic.h"
39#include "SEI.h"
40
41//! \ingroup TLibCommon
42//! \{
43
44// ====================================================================================================================
45// Constructor / destructor / create / destroy
46// ====================================================================================================================
47
48TComPic::TComPic()
49{
50  m_uiTLayer          = 0;
51
52  m_apcPicSym         = NULL;
53  m_apcPicYuv[0]      = NULL;
54  m_apcPicYuv[1]      = NULL;
55#if DEPTH_MAP_GENERATION
56  m_pcPredDepthMap    = NULL;
57#if PDM_REMOVE_DEPENDENCE
58  m_pcPredDepthMap_temp    = NULL;
59#endif
60#endif
61#if HHI_INTER_VIEW_MOTION_PRED
62  m_pcOrgDepthMap     = NULL;
63#endif
64#if HHI_INTER_VIEW_RESIDUAL_PRED
65  m_pcResidual        = NULL;
66#endif
67  m_pcPicYuvPred      = NULL;
68  m_pcPicYuvResi      = NULL;
69  m_bIsLongTerm       = false;
70  m_bReconstructed    = false;
71  m_usedForTMVP       = true;
72  m_bNeededForOutput  = false;
73  m_pSliceSUMap       = NULL;
74  m_uiCurrSliceIdx    = 0; 
75#if HHI_INTERVIEW_SKIP
76  m_pcUsedPelsMap     = NULL;
77#endif
78#if SONY_COLPIC_AVAILABILITY
79  m_iViewOrderIdx     = 0;
80#endif
81  m_aaiCodedScale     = 0;
82  m_aaiCodedOffset    = 0;
83#if OL_QTLIMIT_PREDCODING_B0068
84  m_bReduceBitsQTL    = 0;
85#endif
86#if QC_SIMPLE_NBDV_B0047
87  m_bRapCheck = false;
88  m_eRapRefList = REF_PIC_LIST_0;
89  m_uiRapRefIdx = 0;
90#endif
91
92}
93
94TComPic::~TComPic()
95{
96}
97
98Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Bool bIsVirtual )
99{
100  m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
101  if (!bIsVirtual)
102  {
103    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
104  }
105  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
106 
107  /* there are no SEI messages associated with this picture initially */
108  m_SEIs = NULL;
109  m_bUsedByCurr = false;
110  return;
111}
112
113Void TComPic::destroy()
114{
115  if (m_apcPicSym)
116  {
117    m_apcPicSym->destroy();
118    delete m_apcPicSym;
119    m_apcPicSym = NULL;
120  }
121 
122  if (m_apcPicYuv[0])
123  {
124    m_apcPicYuv[0]->destroy();
125    delete m_apcPicYuv[0];
126    m_apcPicYuv[0]  = NULL;
127  }
128 
129  if (m_apcPicYuv[1])
130  {
131    m_apcPicYuv[1]->destroy();
132    delete m_apcPicYuv[1];
133    m_apcPicYuv[1]  = NULL;
134  }
135#if HHI_INTERVIEW_SKIP
136  if( m_pcUsedPelsMap )
137  {
138    m_pcUsedPelsMap->destroy();
139    delete m_pcUsedPelsMap;
140    m_pcUsedPelsMap = NULL;
141  }
142#endif
143#if DEPTH_MAP_GENERATION
144  if( m_pcPredDepthMap )
145  {
146    m_pcPredDepthMap->destroy();
147    delete m_pcPredDepthMap;
148    m_pcPredDepthMap = NULL;
149  }
150#if PDM_REMOVE_DEPENDENCE
151  if( m_pcPredDepthMap_temp )         //  estimated depth map
152  {
153    m_pcPredDepthMap_temp->destroy();
154    delete m_pcPredDepthMap_temp;
155    m_pcPredDepthMap_temp = NULL;
156  }                     
157#endif
158#endif
159#if HHI_INTER_VIEW_MOTION_PRED
160  if( m_pcOrgDepthMap )
161  {
162    m_pcOrgDepthMap->destroy();
163    delete m_pcOrgDepthMap;
164    m_pcOrgDepthMap = NULL;
165  }
166#endif
167#if HHI_INTER_VIEW_RESIDUAL_PRED
168  if( m_pcResidual )
169  {
170    m_pcResidual->destroy();
171    delete m_pcResidual;
172    m_pcResidual = NULL;
173  }
174#endif
175  delete m_SEIs;
176}
177
178Void TComPic::compressMotion()
179{
180  TComPicSym* pPicSym = getPicSym(); 
181  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ )
182  {
183    TComDataCU* pcCU = pPicSym->getCU(uiCUAddr);
184    pcCU->compressMV(); 
185  } 
186}
187
188#if DEPTH_MAP_GENERATION
189Void
190TComPic::addPrdDepthMapBuffer( UInt uiSubSampExpX, UInt uiSubSampExpY )
191{
192  AOT( m_pcPredDepthMap );
193  AOF( m_apcPicYuv[1]   );
194  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
195  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
196  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
197  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
198  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
199  m_pcPredDepthMap    = new TComPicYuv;
200  m_pcPredDepthMap    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
201#if PDM_REMOVE_DEPENDENCE
202  m_pcPredDepthMap_temp    = new TComPicYuv;
203  m_pcPredDepthMap_temp    ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth );
204#endif
205}
206#endif
207
208#if HHI_INTER_VIEW_MOTION_PRED
209Void
210TComPic::addOrgDepthMapBuffer()
211{
212  AOT( m_pcOrgDepthMap );
213  AOF( m_apcPicYuv[1]  );
214  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
215  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
216  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
217  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
218  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
219  m_pcOrgDepthMap     = new TComPicYuv;
220  m_pcOrgDepthMap     ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
221}
222#endif
223
224#if HHI_INTER_VIEW_RESIDUAL_PRED
225Void
226TComPic::addResidualBuffer()
227{
228  AOT( m_pcResidual   );
229  AOF( m_apcPicYuv[1] );
230  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
231  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
232  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
233  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
234  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
235  m_pcResidual        = new TComPicYuv;
236  m_pcResidual        ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
237}
238#endif
239
240#if DEPTH_MAP_GENERATION
241Void
242TComPic::removePrdDepthMapBuffer()
243{
244  if( m_pcPredDepthMap )
245  {
246    m_pcPredDepthMap->destroy();
247    delete m_pcPredDepthMap;
248    m_pcPredDepthMap = NULL;
249  }
250#if PDM_REMOVE_DEPENDENCE
251  if(m_pcPredDepthMap_temp)
252  {
253    m_pcPredDepthMap_temp->destroy();
254    delete m_pcPredDepthMap_temp;
255    m_pcPredDepthMap_temp = NULL;
256  }
257#endif
258}
259#endif
260
261#if HHI_INTER_VIEW_MOTION_PRED
262Void
263TComPic::removeOrgDepthMapBuffer()
264{
265  if( m_pcOrgDepthMap )
266  {
267    m_pcOrgDepthMap->destroy();
268    delete m_pcOrgDepthMap;
269    m_pcOrgDepthMap = NULL;
270  }
271}
272#endif
273
274#if HHI_INTER_VIEW_RESIDUAL_PRED
275Void
276TComPic::removeResidualBuffer()
277{
278  if( m_pcResidual )
279  {
280    m_pcResidual->destroy();
281    delete m_pcResidual;
282    m_pcResidual = NULL;
283  }
284}
285#endif
286
287/** Create non-deblocked filter information
288 * \param pSliceStartAddress array for storing slice start addresses
289 * \param numSlices number of slices in picture
290 * \param sliceGranularityDepth slice granularity
291 * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross".
292 * \param numTiles number of tiles in picture
293 * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross".
294 */
295Void TComPic::createNonDBFilterInfo(UInt* pSliceStartAddress, Int numSlices, Int sliceGranularityDepth
296                                    ,Bool bNDBFilterCrossSliceBoundary
297                                    ,Int numTiles
298                                    ,Bool bNDBFilterCrossTileBoundary)
299{
300  UInt maxNumSUInLCU = getNumPartInCU();
301  UInt numLCUInPic   = getNumCUsInFrame();
302  UInt picWidth      = getSlice(0)->getSPS()->getPicWidthInLumaSamples();
303  UInt picHeight     = getSlice(0)->getSPS()->getPicHeightInLumaSamples();
304  Int  numLCUsInPicWidth = getFrameWidthInCU();
305  Int  numLCUsInPicHeight= getFrameHeightInCU();
306  UInt maxNumSUInLCUWidth = getNumPartInWidth();
307  UInt maxNumSUInLCUHeight= getNumPartInHeight();
308
309  m_bIndependentSliceBoundaryForNDBFilter = (bNDBFilterCrossSliceBoundary)?(false):((numSlices > 1)?(true):(false)) ;
310  m_sliceGranularityForNDBFilter = sliceGranularityDepth;
311  m_bIndependentTileBoundaryForNDBFilter  = (bNDBFilterCrossTileBoundary)?(false) :((numTiles > 1)?(true):(false));
312
313  m_pbValidSlice = new Bool[numSlices];
314  for(Int s=0; s< numSlices; s++)
315  {
316    m_pbValidSlice[s] = true;
317  }
318#if !LCU_SYNTAX_ALF
319  if( pSliceStartAddress == NULL || (numSlices == 1 && numTiles == 1) )
320  {
321    return;
322  }
323#endif
324  m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic];
325
326  //initialization
327  for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ )
328  {
329    m_pSliceSUMap[i] = -1;
330  }
331  for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ )
332  {
333    TComDataCU* pcCU = getCU( CUAddr );
334    pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU)); 
335    pcCU->getNDBFilterBlocks()->clear();
336  }
337  m_vSliceCUDataLink.clear();
338
339  m_vSliceCUDataLink.resize(numSlices);
340
341  UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr;
342  UInt LPelX, TPelY, LCUX, LCUY;
343  UInt currSU;
344  UInt startSU, endSU;
345
346  for(Int s=0; s< numSlices; s++)
347  {
348    //1st step: decide the real start address
349    startAddr = pSliceStartAddress[s];
350    endAddr   = pSliceStartAddress[s+1] -1;
351
352    startLCU            = startAddr / maxNumSUInLCU;
353    firstCUInStartLCU   = startAddr % maxNumSUInLCU;
354
355    endLCU              = endAddr   / maxNumSUInLCU;
356    lastCUInEndLCU      = endAddr   % maxNumSUInLCU;   
357
358    uiAddr = m_apcPicSym->getCUOrderMap(startLCU);
359
360    LCUX      = getCU(uiAddr)->getCUPelX();
361    LCUY      = getCU(uiAddr)->getCUPelY();
362    LPelX     = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ];
363    TPelY     = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ];
364    currSU    = firstCUInStartLCU;
365
366    Bool bMoveToNextLCU = false;
367    Bool bSliceInOneLCU = (startLCU == endLCU);
368
369    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
370    {
371      currSU ++;
372
373      if(bSliceInOneLCU)
374      {
375        if(currSU > lastCUInEndLCU)
376        {
377          m_pbValidSlice[s] = false;
378          break;
379        }
380      }
381
382      if(currSU >= maxNumSUInLCU )
383      {
384        bMoveToNextLCU = true;
385        break;
386      }
387
388      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
389      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
390
391    }
392
393
394    if(!m_pbValidSlice[s])
395    {
396      continue;
397    }
398
399    if(currSU != firstCUInStartLCU)
400    {
401      if(!bMoveToNextLCU)
402      {
403        firstCUInStartLCU = currSU;
404      }
405      else
406      {
407        startLCU++;
408        firstCUInStartLCU = 0;
409        assert( startLCU < getNumCUsInFrame());
410      }
411      assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr);
412    }
413
414
415    //2nd step: assign NonDBFilterInfo to each processing block
416    for(UInt i= startLCU; i <= endLCU; i++)
417    {
418      startSU = (i == startLCU)?(firstCUInStartLCU):(0);
419      endSU   = (i == endLCU  )?(lastCUInEndLCU   ):(maxNumSUInLCU -1);
420
421      uiAddr = m_apcPicSym->getCUOrderMap(i);
422      Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
423
424      TComDataCU* pcCU = getCU(uiAddr);
425      m_vSliceCUDataLink[s].push_back(pcCU);
426
427      createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight);
428    }
429  }
430
431  //step 3: border availability
432  for(Int s=0; s< numSlices; s++)
433  {
434    if(!m_pbValidSlice[s])
435    {
436      continue;
437    }
438
439    for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++)
440    {
441      TComDataCU* pcCU = m_vSliceCUDataLink[s][i];
442      uiAddr = pcCU->getAddr();
443
444      if(pcCU->getPic()==0)
445      {
446        continue;
447      }
448      Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
449      Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false;
450
451      if(m_bIndependentTileBoundaryForNDBFilter)
452      {
453        //left
454        if( uiAddr % numLCUsInPicWidth != 0)
455        {
456          bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;
457        }
458        //right
459        if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )
460        {
461          bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;
462        }
463        //top
464        if( uiAddr >= numLCUsInPicWidth)
465        {
466          bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) !=  iTileID )?true:false;
467        }
468        //down
469        if( uiAddr + numLCUsInPicWidth < numLCUInPic )
470        {
471          bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false;
472        }
473
474      }
475
476      pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight
477        ,m_bIndependentSliceBoundaryForNDBFilter
478        ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary
479        ,m_bIndependentTileBoundaryForNDBFilter);
480
481    }
482
483  }
484
485  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
486  {
487    m_pNDBFilterYuvTmp = new TComPicYuv();
488    m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
489  }
490}
491#if QC_SIMPLE_NBDV_B0047
492Bool TComPic::getDisCandRefPictures(Int iColPOC)
493{
494  UInt uiTempLayerCurr=7;
495  TComSlice* currSlice = getCurrSlice();
496  UInt iPOCCurr=currSlice->getPOC();
497  UInt iPOCDiff = 255;
498  Bool  bRAP=false;
499  Bool bCheck = false;
500  Int MaxRef = currSlice->getNumRefIdx(RefPicList(0));
501  RefPicList eRefPicList = REF_PIC_LIST_0 ;
502  if(currSlice->isInterB())
503  {
504    if(currSlice->getNumRefIdx(RefPicList(0))< currSlice->getNumRefIdx(RefPicList(1)))
505      MaxRef = currSlice->getNumRefIdx(RefPicList(1));
506  }
507  for(Int lpRef = 0; lpRef < MaxRef; lpRef++)
508  {
509    for(Int lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
510    {
511      eRefPicList = RefPicList(0);
512      if(currSlice->isInterB())
513        eRefPicList = RefPicList(lpNr==0 ? (currSlice->getColDir()): (1-currSlice->getColDir()));
514      if(iColPOC == currSlice->getRefPOC(eRefPicList, lpRef))
515        continue;
516      if(lpRef >= currSlice->getNumRefIdx(eRefPicList)||(currSlice->getViewId() != currSlice->getRefPic( eRefPicList, lpRef)->getViewId()))
517        continue;
518      Int iTempPoc = currSlice->getRefPic(eRefPicList, lpRef)->getPOC();
519      UInt uiTempLayer = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getTLayer(); 
520      Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
521      bRAP = (currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV? 1:0);
522      if( bRAP)
523      {
524         bCheck = true;
525         this->setRapRefIdx(lpRef);
526         this->setRapRefList(eRefPicList);
527         return bCheck;
528      }
529      if(uiTempLayerCurr > uiTempLayer)
530      {
531        bCheck = true;
532        if(uiTempLayerCurr == uiTempLayer)
533        {
534          if(iPOCDiff > iTempDiff)
535          {
536            iPOCDiff=iTempDiff;
537            if(iPOCDiff < 255)
538            {
539              this->setRapRefIdx(lpRef);
540              this->setRapRefList(eRefPicList);
541            }
542          }
543        }
544        else
545        {
546          iPOCDiff=iTempDiff;
547          uiTempLayerCurr = uiTempLayer;
548          this->setRapRefIdx(lpRef);
549          this->setRapRefList(eRefPicList);
550        } 
551      }
552    }
553  }
554  return bCheck;
555}
556#endif
557
558#if HHI_INTERVIEW_SKIP
559Void TComPic::addUsedPelsMapBuffer()
560{
561  AOT( m_pcUsedPelsMap );
562  AOF( m_apcPicYuv[1]  );
563  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
564  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
565  UInt  uiMaxCuWidth  = m_apcPicSym->getMaxCUWidth();
566  UInt  uiMaxCuHeight = m_apcPicSym->getMaxCUHeight();
567  UInt  uiMaxCuDepth  = m_apcPicSym->getMaxCUDepth ();
568  m_pcUsedPelsMap     = new TComPicYuv;
569  m_pcUsedPelsMap     ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
570
571}
572Void
573TComPic::removeUsedPelsMapBuffer()
574{
575  if( m_pcUsedPelsMap )
576  {
577    m_pcUsedPelsMap->destroy();
578    delete m_pcUsedPelsMap;
579    m_pcUsedPelsMap = NULL;
580  }
581}
582#endif
583
584/** Create non-deblocked filter information for LCU
585 * \param tileID tile index
586 * \param sliceID slice index
587 * \param pcCU CU data pointer
588 * \param startSU start SU index in LCU
589 * \param endSU end SU index in LCU
590 * \param sliceGranularyDepth slice granularity
591 * \param picWidth picture width
592 * \param picHeight picture height
593 */
594Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
595{
596  UInt LCUX          = pcCU->getCUPelX();
597  UInt LCUY          = pcCU->getCUPelY();
598  Int* pCUSliceMap    = pcCU->getSliceSUMap();
599  UInt maxNumSUInLCU = getNumPartInCU();
600  UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
601  UInt maxNumSUInLCUWidth = getNumPartInWidth();
602  UInt LPelX, TPelY;
603  UInt currSU;
604
605
606  //get the number of valid NBFilterBLock
607  currSU   = startSU;
608  while(currSU <= endSU)
609  {
610    LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
611    TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
612
613    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
614    {
615      currSU += maxNumSUInSGU;
616      if(currSU >= maxNumSUInLCU || currSU > endSU)
617      {
618        break;
619      }
620      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
621      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
622    }
623
624    if(currSU >= maxNumSUInLCU || currSU > endSU)
625    {
626      break;
627    }
628
629    NDBFBlockInfo NDBFBlock;
630
631    NDBFBlock.tileID  = tileID;
632    NDBFBlock.sliceID = sliceID;
633    NDBFBlock.posY    = TPelY;
634    NDBFBlock.posX    = LPelX;
635    NDBFBlock.startSU = currSU;
636
637    UInt uiLastValidSU  = currSU;
638    UInt uiIdx, uiLPelX_su, uiTPelY_su;
639    for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
640    {
641      if(uiIdx > endSU)
642      {
643        break;       
644      }
645      uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
646      uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
647      if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
648      {
649        continue;
650      }
651      pCUSliceMap[uiIdx] = sliceID;
652      uiLastValidSU = uiIdx;
653    }
654    NDBFBlock.endSU = uiLastValidSU;
655
656    UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
657    UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
658    NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
659    NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
660    NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
661    NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
662
663    pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
664
665    currSU += maxNumSUInSGU;
666  }
667
668}
669
670/** destroy non-deblocked filter information for LCU
671 */
672Void TComPic::destroyNonDBFilterInfo()
673{
674  if(m_pbValidSlice != NULL)
675  {
676    delete[] m_pbValidSlice;
677    m_pbValidSlice = NULL;
678  }
679
680  if(m_pSliceSUMap != NULL)
681  {
682    delete[] m_pSliceSUMap;
683    m_pSliceSUMap = NULL;
684  }
685  for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
686  {
687    TComDataCU* pcCU = getCU( CUAddr );
688    pcCU->getNDBFilterBlocks()->clear();
689  }
690
691  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
692  {
693    m_pNDBFilterYuvTmp->destroy();
694    delete m_pNDBFilterYuvTmp;
695    m_pNDBFilterYuvTmp = NULL;
696  }
697
698}
699
700
701//! \}
Note: See TracBrowser for help on using the repository browser.