source: 3DVCSoftware/branches/HTM-5.1-dev0/source/Lib/TLibCommon/TComPic.cpp @ 289

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

Clean up of macros related to NBDV.

  • Property svn:eol-style set to native
File size: 20.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-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 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 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 H3D_NBDV
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#if QC_REM_IDV_B0046
522      TComSlice* refSlice = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice();
523      bRAP = (refSlice->getSPS()->getViewId() && (refSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || refSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))? 1: 0;     
524#else
525      bRAP = (currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV? 1:0);
526#endif
527      if( bRAP)
528      {
529         bCheck = true;
530         this->setRapRefIdx(lpRef);
531         this->setRapRefList(eRefPicList);
532         return bCheck;
533      }
534      if(uiTempLayerCurr > uiTempLayer)
535      {
536        bCheck = true;
537        if(uiTempLayerCurr == uiTempLayer)
538        {
539          if(iPOCDiff > iTempDiff)
540          {
541            iPOCDiff=iTempDiff;
542            if(iPOCDiff < 255)
543            {
544              this->setRapRefIdx(lpRef);
545              this->setRapRefList(eRefPicList);
546            }
547          }
548        }
549        else
550        {
551          iPOCDiff=iTempDiff;
552          uiTempLayerCurr = uiTempLayer;
553          this->setRapRefIdx(lpRef);
554          this->setRapRefList(eRefPicList);
555        } 
556      }
557    }
558  }
559  return bCheck;
560}
561#endif
562
563#if HHI_INTERVIEW_SKIP
564Void TComPic::addUsedPelsMapBuffer()
565{
566  AOT( m_pcUsedPelsMap );
567  AOF( m_apcPicYuv[1]  );
568  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
569  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
570  UInt  uiMaxCuWidth  = m_apcPicSym->getMaxCUWidth();
571  UInt  uiMaxCuHeight = m_apcPicSym->getMaxCUHeight();
572  UInt  uiMaxCuDepth  = m_apcPicSym->getMaxCUDepth ();
573  m_pcUsedPelsMap     = new TComPicYuv;
574  m_pcUsedPelsMap     ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
575
576}
577Void
578TComPic::removeUsedPelsMapBuffer()
579{
580  if( m_pcUsedPelsMap )
581  {
582    m_pcUsedPelsMap->destroy();
583    delete m_pcUsedPelsMap;
584    m_pcUsedPelsMap = NULL;
585  }
586}
587#endif
588
589/** Create non-deblocked filter information for LCU
590 * \param tileID tile index
591 * \param sliceID slice index
592 * \param pcCU CU data pointer
593 * \param startSU start SU index in LCU
594 * \param endSU end SU index in LCU
595 * \param sliceGranularyDepth slice granularity
596 * \param picWidth picture width
597 * \param picHeight picture height
598 */
599Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
600{
601  UInt LCUX          = pcCU->getCUPelX();
602  UInt LCUY          = pcCU->getCUPelY();
603  Int* pCUSliceMap    = pcCU->getSliceSUMap();
604  UInt maxNumSUInLCU = getNumPartInCU();
605  UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
606  UInt maxNumSUInLCUWidth = getNumPartInWidth();
607  UInt LPelX, TPelY;
608  UInt currSU;
609
610
611  //get the number of valid NBFilterBLock
612  currSU   = startSU;
613  while(currSU <= endSU)
614  {
615    LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
616    TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
617
618    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
619    {
620      currSU += maxNumSUInSGU;
621      if(currSU >= maxNumSUInLCU || currSU > endSU)
622      {
623        break;
624      }
625      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
626      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
627    }
628
629    if(currSU >= maxNumSUInLCU || currSU > endSU)
630    {
631      break;
632    }
633
634    NDBFBlockInfo NDBFBlock;
635
636    NDBFBlock.tileID  = tileID;
637    NDBFBlock.sliceID = sliceID;
638    NDBFBlock.posY    = TPelY;
639    NDBFBlock.posX    = LPelX;
640    NDBFBlock.startSU = currSU;
641
642    UInt uiLastValidSU  = currSU;
643    UInt uiIdx, uiLPelX_su, uiTPelY_su;
644    for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
645    {
646      if(uiIdx > endSU)
647      {
648        break;       
649      }
650      uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
651      uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
652      if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
653      {
654        continue;
655      }
656      pCUSliceMap[uiIdx] = sliceID;
657      uiLastValidSU = uiIdx;
658    }
659    NDBFBlock.endSU = uiLastValidSU;
660
661    UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
662    UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
663    NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
664    NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
665    NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
666    NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
667
668    pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
669
670    currSU += maxNumSUInSGU;
671  }
672
673}
674
675/** destroy non-deblocked filter information for LCU
676 */
677Void TComPic::destroyNonDBFilterInfo()
678{
679  if(m_pbValidSlice != NULL)
680  {
681    delete[] m_pbValidSlice;
682    m_pbValidSlice = NULL;
683  }
684
685  if(m_pSliceSUMap != NULL)
686  {
687    delete[] m_pSliceSUMap;
688    m_pSliceSUMap = NULL;
689  }
690  for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
691  {
692    TComDataCU* pcCU = getCU( CUAddr );
693    pcCU->getNDBFilterBlocks()->clear();
694  }
695
696  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
697  {
698    m_pNDBFilterYuvTmp->destroy();
699    delete m_pNDBFilterYuvTmp;
700    m_pNDBFilterYuvTmp = NULL;
701  }
702
703}
704
705
706//! \}
Note: See TracBrowser for help on using the repository browser.