source: 3DVCSoftware/trunk/source/Lib/TLibCommon/TComPic.cpp @ 296

Last change on this file since 296 was 296, checked in by tech, 11 years ago

Reintegrated branch 5.1-dev0 rev. 295.

  • 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 H3D_IVMP
62  m_pcOrgDepthMap     = NULL;
63#endif
64#if H3D_IVRP
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 INTER_VIEW_VECTOR_SCALING_C0115
79  m_iViewOrderIdx     = 0;    // will be changed to view_id
80#endif
81  m_aaiCodedScale     = 0;
82  m_aaiCodedOffset    = 0;
83#if OL_QTLIMIT_PREDCODING_B0068
84  m_bReduceBitsQTL    = 0;
85#endif
86#if H3D_NBDV
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 H3D_IVMP
160  if( m_pcOrgDepthMap )
161  {
162    m_pcOrgDepthMap->destroy();
163    delete m_pcOrgDepthMap;
164    m_pcOrgDepthMap = NULL;
165  }
166#endif
167#if H3D_IVRP
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 H3D_IVMP
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 H3D_IVRP
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 H3D_IVMP
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 H3D_IVRP
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  m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic];
319
320  //initialization
321  for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ )
322  {
323    m_pSliceSUMap[i] = -1;
324  }
325  for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ )
326  {
327    TComDataCU* pcCU = getCU( CUAddr );
328    pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU)); 
329    pcCU->getNDBFilterBlocks()->clear();
330  }
331  m_vSliceCUDataLink.clear();
332
333  m_vSliceCUDataLink.resize(numSlices);
334
335  UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr;
336  UInt LPelX, TPelY, LCUX, LCUY;
337  UInt currSU;
338  UInt startSU, endSU;
339
340  for(Int s=0; s< numSlices; s++)
341  {
342    //1st step: decide the real start address
343    startAddr = pSliceStartAddress[s];
344    endAddr   = pSliceStartAddress[s+1] -1;
345
346    startLCU            = startAddr / maxNumSUInLCU;
347    firstCUInStartLCU   = startAddr % maxNumSUInLCU;
348
349    endLCU              = endAddr   / maxNumSUInLCU;
350    lastCUInEndLCU      = endAddr   % maxNumSUInLCU;   
351
352    uiAddr = m_apcPicSym->getCUOrderMap(startLCU);
353
354    LCUX      = getCU(uiAddr)->getCUPelX();
355    LCUY      = getCU(uiAddr)->getCUPelY();
356    LPelX     = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ];
357    TPelY     = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ];
358    currSU    = firstCUInStartLCU;
359
360    Bool bMoveToNextLCU = false;
361    Bool bSliceInOneLCU = (startLCU == endLCU);
362
363    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
364    {
365      currSU ++;
366
367      if(bSliceInOneLCU)
368      {
369        if(currSU > lastCUInEndLCU)
370        {
371          m_pbValidSlice[s] = false;
372          break;
373        }
374      }
375
376      if(currSU >= maxNumSUInLCU )
377      {
378        bMoveToNextLCU = true;
379        break;
380      }
381
382      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
383      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
384
385    }
386
387
388    if(!m_pbValidSlice[s])
389    {
390      continue;
391    }
392
393    if(currSU != firstCUInStartLCU)
394    {
395      if(!bMoveToNextLCU)
396      {
397        firstCUInStartLCU = currSU;
398      }
399      else
400      {
401        startLCU++;
402        firstCUInStartLCU = 0;
403        assert( startLCU < getNumCUsInFrame());
404      }
405      assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr);
406    }
407
408
409    //2nd step: assign NonDBFilterInfo to each processing block
410    for(UInt i= startLCU; i <= endLCU; i++)
411    {
412      startSU = (i == startLCU)?(firstCUInStartLCU):(0);
413      endSU   = (i == endLCU  )?(lastCUInEndLCU   ):(maxNumSUInLCU -1);
414
415      uiAddr = m_apcPicSym->getCUOrderMap(i);
416      Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
417
418      TComDataCU* pcCU = getCU(uiAddr);
419      m_vSliceCUDataLink[s].push_back(pcCU);
420
421      createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight);
422    }
423  }
424
425  //step 3: border availability
426  for(Int s=0; s< numSlices; s++)
427  {
428    if(!m_pbValidSlice[s])
429    {
430      continue;
431    }
432
433    for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++)
434    {
435      TComDataCU* pcCU = m_vSliceCUDataLink[s][i];
436      uiAddr = pcCU->getAddr();
437
438      if(pcCU->getPic()==0)
439      {
440        continue;
441      }
442      Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
443      Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false;
444
445      if(m_bIndependentTileBoundaryForNDBFilter)
446      {
447        //left
448        if( uiAddr % numLCUsInPicWidth != 0)
449        {
450          bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;
451        }
452        //right
453        if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )
454        {
455          bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;
456        }
457        //top
458        if( uiAddr >= numLCUsInPicWidth)
459        {
460          bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) !=  iTileID )?true:false;
461        }
462        //down
463        if( uiAddr + numLCUsInPicWidth < numLCUInPic )
464        {
465          bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false;
466        }
467
468      }
469
470      pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight
471        ,m_bIndependentSliceBoundaryForNDBFilter
472        ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary
473        ,m_bIndependentTileBoundaryForNDBFilter);
474
475    }
476
477  }
478
479  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
480  {
481    m_pNDBFilterYuvTmp = new TComPicYuv();
482    m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
483  }
484}
485#if H3D_NBDV
486Bool TComPic::getDisCandRefPictures(Int iColPOC)
487{
488  UInt uiTempLayerCurr=7;
489  TComSlice* currSlice = getCurrSlice();
490  UInt iPOCCurr=currSlice->getPOC();
491  UInt iPOCDiff = 255;
492  Bool  bRAP=false;
493  Bool bCheck = false;
494  Int MaxRef = currSlice->getNumRefIdx(RefPicList(0));
495  RefPicList eRefPicList = REF_PIC_LIST_0 ;
496  if(currSlice->isInterB())
497  {
498    if(currSlice->getNumRefIdx(RefPicList(0))< currSlice->getNumRefIdx(RefPicList(1)))
499      MaxRef = currSlice->getNumRefIdx(RefPicList(1));
500  }
501  for(Int lpRef = 0; lpRef < MaxRef; lpRef++)
502  {
503    for(Int lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
504    {
505      eRefPicList = RefPicList(0);
506      if(currSlice->isInterB())
507        eRefPicList = RefPicList(lpNr==0 ? (currSlice->getColDir()): (1-currSlice->getColDir()));
508      if(iColPOC == currSlice->getRefPOC(eRefPicList, lpRef))
509        continue;
510      if(lpRef >= currSlice->getNumRefIdx(eRefPicList)||(currSlice->getViewId() != currSlice->getRefPic( eRefPicList, lpRef)->getViewId()))
511        continue;
512      Int iTempPoc = currSlice->getRefPic(eRefPicList, lpRef)->getPOC();
513      UInt uiTempLayer = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getTLayer(); 
514      Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
515#if QC_REM_IDV_B0046
516      TComSlice* refSlice = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice();
517      bRAP = (refSlice->getSPS()->getViewId() && (refSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || refSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))? 1: 0;     
518#else
519      bRAP = (currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV? 1:0);
520#endif
521      if( bRAP)
522      {
523         bCheck = true;
524         this->setRapRefIdx(lpRef);
525         this->setRapRefList(eRefPicList);
526         return bCheck;
527      }
528      if(uiTempLayerCurr > uiTempLayer)
529      {
530        bCheck = true;
531        if(uiTempLayerCurr == uiTempLayer)
532        {
533          if(iPOCDiff > iTempDiff)
534          {
535            iPOCDiff=iTempDiff;
536            if(iPOCDiff < 255)
537            {
538              this->setRapRefIdx(lpRef);
539              this->setRapRefList(eRefPicList);
540            }
541          }
542        }
543        else
544        {
545          iPOCDiff=iTempDiff;
546          uiTempLayerCurr = uiTempLayer;
547          this->setRapRefIdx(lpRef);
548          this->setRapRefList(eRefPicList);
549        } 
550      }
551    }
552  }
553  return bCheck;
554}
555#endif
556
557#if HHI_INTERVIEW_SKIP
558Void TComPic::addUsedPelsMapBuffer()
559{
560  AOT( m_pcUsedPelsMap );
561  AOF( m_apcPicYuv[1]  );
562  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
563  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
564  UInt  uiMaxCuWidth  = m_apcPicSym->getMaxCUWidth();
565  UInt  uiMaxCuHeight = m_apcPicSym->getMaxCUHeight();
566  UInt  uiMaxCuDepth  = m_apcPicSym->getMaxCUDepth ();
567  m_pcUsedPelsMap     = new TComPicYuv;
568  m_pcUsedPelsMap     ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
569
570}
571Void
572TComPic::removeUsedPelsMapBuffer()
573{
574  if( m_pcUsedPelsMap )
575  {
576    m_pcUsedPelsMap->destroy();
577    delete m_pcUsedPelsMap;
578    m_pcUsedPelsMap = NULL;
579  }
580}
581#endif
582
583/** Create non-deblocked filter information for LCU
584 * \param tileID tile index
585 * \param sliceID slice index
586 * \param pcCU CU data pointer
587 * \param startSU start SU index in LCU
588 * \param endSU end SU index in LCU
589 * \param sliceGranularyDepth slice granularity
590 * \param picWidth picture width
591 * \param picHeight picture height
592 */
593Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
594{
595  UInt LCUX          = pcCU->getCUPelX();
596  UInt LCUY          = pcCU->getCUPelY();
597  Int* pCUSliceMap    = pcCU->getSliceSUMap();
598  UInt maxNumSUInLCU = getNumPartInCU();
599  UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
600  UInt maxNumSUInLCUWidth = getNumPartInWidth();
601  UInt LPelX, TPelY;
602  UInt currSU;
603
604
605  //get the number of valid NBFilterBLock
606  currSU   = startSU;
607  while(currSU <= endSU)
608  {
609    LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
610    TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
611
612    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
613    {
614      currSU += maxNumSUInSGU;
615      if(currSU >= maxNumSUInLCU || currSU > endSU)
616      {
617        break;
618      }
619      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
620      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
621    }
622
623    if(currSU >= maxNumSUInLCU || currSU > endSU)
624    {
625      break;
626    }
627
628    NDBFBlockInfo NDBFBlock;
629
630    NDBFBlock.tileID  = tileID;
631    NDBFBlock.sliceID = sliceID;
632    NDBFBlock.posY    = TPelY;
633    NDBFBlock.posX    = LPelX;
634    NDBFBlock.startSU = currSU;
635
636    UInt uiLastValidSU  = currSU;
637    UInt uiIdx, uiLPelX_su, uiTPelY_su;
638    for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
639    {
640      if(uiIdx > endSU)
641      {
642        break;       
643      }
644      uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
645      uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
646      if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
647      {
648        continue;
649      }
650      pCUSliceMap[uiIdx] = sliceID;
651      uiLastValidSU = uiIdx;
652    }
653    NDBFBlock.endSU = uiLastValidSU;
654
655    UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
656    UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
657    NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
658    NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
659    NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
660    NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
661
662    pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
663
664    currSU += maxNumSUInSGU;
665  }
666
667}
668
669/** destroy non-deblocked filter information for LCU
670 */
671Void TComPic::destroyNonDBFilterInfo()
672{
673  if(m_pbValidSlice != NULL)
674  {
675    delete[] m_pbValidSlice;
676    m_pbValidSlice = NULL;
677  }
678
679  if(m_pSliceSUMap != NULL)
680  {
681    delete[] m_pSliceSUMap;
682    m_pSliceSUMap = NULL;
683  }
684  for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
685  {
686    TComDataCU* pcCU = getCU( CUAddr );
687    pcCU->getNDBFilterBlocks()->clear();
688  }
689
690  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
691  {
692    m_pNDBFilterYuvTmp->destroy();
693    delete m_pNDBFilterYuvTmp;
694    m_pNDBFilterYuvTmp = NULL;
695  }
696
697}
698
699
700//! \}
Note: See TracBrowser for help on using the repository browser.