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

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

Merged 8.1-Cleanup@654

  • Property svn:eol-style set to native
File size: 23.6 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-2013, 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: m_uiTLayer                              (0)
50, m_bUsedByCurr                           (false)
51, m_bIsLongTerm                           (false)
52, m_apcPicSym                             (NULL)
53, m_pcPicYuvPred                          (NULL)
54, m_pcPicYuvResi                          (NULL)
55, m_bReconstructed                        (false)
56, m_bNeededForOutput                      (false)
57, m_uiCurrSliceIdx                        (0)
58, m_pSliceSUMap                           (NULL)
59, m_pbValidSlice                          (NULL)
60, m_sliceGranularityForNDBFilter          (0)
61, m_bIndependentSliceBoundaryForNDBFilter (false)
62, m_bIndependentTileBoundaryForNDBFilter  (false)
63, m_pNDBFilterYuvTmp                      (NULL)
64, m_bCheckLTMSB                           (false)
65#if H_MV
66, m_layerId                               (0)
67, m_viewId                                (0)
68#if H_3D
69, m_viewIndex                             (0)
70, m_isDepth                               (false)
71, m_aaiCodedScale                         (0)
72, m_aaiCodedOffset                        (0)
73#endif
74#endif
75{
76  m_apcPicYuv[0]      = NULL;
77  m_apcPicYuv[1]      = NULL;
78#if H_3D_QTLPC
79  m_bReduceBitsQTL    = 0;
80#endif
81#if H_3D_NBDV
82  m_iNumDdvCandPics   = 0;
83  m_eRapRefList       = REF_PIC_LIST_0;
84  m_uiRapRefIdx       = 0;
85#endif
86}
87
88TComPic::~TComPic()
89{
90}
91
92Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
93                      Int *numReorderPics, Bool bIsVirtual)
94
95{
96  m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
97  if (!bIsVirtual)
98  {
99    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
100  }
101  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
102 
103  // there are no SEI messages associated with this picture initially
104  if (m_SEIs.size() > 0)
105  {
106    deleteSEIs (m_SEIs);
107  }
108  m_bUsedByCurr = false;
109
110  /* store conformance window parameters with picture */
111  m_conformanceWindow = conformanceWindow;
112 
113  /* store display window parameters with picture */
114  m_defaultDisplayWindow = defaultDisplayWindow;
115
116  /* store number of reorder pics with picture */
117  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
118
119  /* initialize the texture to depth reference status */
120#if H_3D_FCO
121  for (int j=0; j<2; j++)
122  {
123      for (int i=0; i<MAX_NUM_REF; i++)
124      {
125          m_aiTexToDepRef[j][i] = -1;
126      }
127  }
128#endif
129
130  return;
131}
132
133Void TComPic::destroy()
134{
135  if (m_apcPicSym)
136  {
137    m_apcPicSym->destroy();
138    delete m_apcPicSym;
139    m_apcPicSym = NULL;
140  }
141 
142  if (m_apcPicYuv[0])
143  {
144    m_apcPicYuv[0]->destroy();
145    delete m_apcPicYuv[0];
146    m_apcPicYuv[0]  = NULL;
147  }
148 
149  if (m_apcPicYuv[1])
150  {
151    m_apcPicYuv[1]->destroy();
152    delete m_apcPicYuv[1];
153    m_apcPicYuv[1]  = NULL;
154  }
155 
156  deleteSEIs(m_SEIs);
157}
158#if H_3D
159Void TComPic::compressMotion(Int scale)
160#else
161Void TComPic::compressMotion()
162#endif
163{
164  TComPicSym* pPicSym = getPicSym(); 
165  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ )
166  {
167    TComDataCU* pcCU = pPicSym->getCU(uiCUAddr);
168#if H_3D
169    pcCU->compressMV(scale); 
170#else
171    pcCU->compressMV(); 
172#endif
173  } 
174}
175
176/** Create non-deblocked filter information
177 * \param pSliceStartAddress array for storing slice start addresses
178 * \param numSlices number of slices in picture
179 * \param sliceGranularityDepth slice granularity
180 * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross".
181 * \param numTiles number of tiles in picture
182 * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross".
183 */
184Void TComPic::createNonDBFilterInfo(std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
185                                    ,std::vector<Bool>* LFCrossSliceBoundary
186                                    ,Int numTiles
187                                    ,Bool bNDBFilterCrossTileBoundary)
188{
189  UInt maxNumSUInLCU = getNumPartInCU();
190  UInt numLCUInPic   = getNumCUsInFrame();
191  UInt picWidth      = getSlice(0)->getSPS()->getPicWidthInLumaSamples();
192  UInt picHeight     = getSlice(0)->getSPS()->getPicHeightInLumaSamples();
193  Int  numLCUsInPicWidth = getFrameWidthInCU();
194  Int  numLCUsInPicHeight= getFrameHeightInCU();
195  UInt maxNumSUInLCUWidth = getNumPartInWidth();
196  UInt maxNumSUInLCUHeight= getNumPartInHeight();
197  Int  numSlices = (Int) sliceStartAddress.size() - 1;
198  m_bIndependentSliceBoundaryForNDBFilter = false;
199  if(numSlices > 1)
200  {
201    for(Int s=0; s< numSlices; s++)
202    {
203      if((*LFCrossSliceBoundary)[s] == false)
204      {
205        m_bIndependentSliceBoundaryForNDBFilter = true;
206      }
207    }
208  }
209  m_sliceGranularityForNDBFilter = sliceGranularityDepth;
210  m_bIndependentTileBoundaryForNDBFilter  = (bNDBFilterCrossTileBoundary)?(false) :((numTiles > 1)?(true):(false));
211
212  m_pbValidSlice = new Bool[numSlices];
213  for(Int s=0; s< numSlices; s++)
214  {
215    m_pbValidSlice[s] = true;
216  }
217  m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic];
218
219  //initialization
220  for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ )
221  {
222    m_pSliceSUMap[i] = -1;
223  }
224  for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ )
225  {
226    TComDataCU* pcCU = getCU( CUAddr );
227    pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU)); 
228    pcCU->getNDBFilterBlocks()->clear();
229  }
230  m_vSliceCUDataLink.clear();
231
232  m_vSliceCUDataLink.resize(numSlices);
233
234  UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr;
235  UInt LPelX, TPelY, LCUX, LCUY;
236  UInt currSU;
237  UInt startSU, endSU;
238
239  for(Int s=0; s< numSlices; s++)
240  {
241    //1st step: decide the real start address
242    startAddr = sliceStartAddress[s];
243    endAddr   = sliceStartAddress[s+1] -1;
244
245    startLCU            = startAddr / maxNumSUInLCU;
246    firstCUInStartLCU   = startAddr % maxNumSUInLCU;
247
248    endLCU              = endAddr   / maxNumSUInLCU;
249    lastCUInEndLCU      = endAddr   % maxNumSUInLCU;   
250
251    uiAddr = m_apcPicSym->getCUOrderMap(startLCU);
252
253    LCUX      = getCU(uiAddr)->getCUPelX();
254    LCUY      = getCU(uiAddr)->getCUPelY();
255    LPelX     = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ];
256    TPelY     = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ];
257    currSU    = firstCUInStartLCU;
258
259    Bool bMoveToNextLCU = false;
260    Bool bSliceInOneLCU = (startLCU == endLCU);
261
262    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
263    {
264      currSU ++;
265
266      if(bSliceInOneLCU)
267      {
268        if(currSU > lastCUInEndLCU)
269        {
270          m_pbValidSlice[s] = false;
271          break;
272        }
273      }
274
275      if(currSU >= maxNumSUInLCU )
276      {
277        bMoveToNextLCU = true;
278        break;
279      }
280
281      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
282      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
283
284    }
285
286
287    if(!m_pbValidSlice[s])
288    {
289      continue;
290    }
291
292    if(currSU != firstCUInStartLCU)
293    {
294      if(!bMoveToNextLCU)
295      {
296        firstCUInStartLCU = currSU;
297      }
298      else
299      {
300        startLCU++;
301        firstCUInStartLCU = 0;
302        assert( startLCU < getNumCUsInFrame());
303      }
304      assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr);
305    }
306
307
308    //2nd step: assign NonDBFilterInfo to each processing block
309    for(UInt i= startLCU; i <= endLCU; i++)
310    {
311      startSU = (i == startLCU)?(firstCUInStartLCU):(0);
312      endSU   = (i == endLCU  )?(lastCUInEndLCU   ):(maxNumSUInLCU -1);
313
314      uiAddr = m_apcPicSym->getCUOrderMap(i);
315      Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
316
317      TComDataCU* pcCU = getCU(uiAddr);
318      m_vSliceCUDataLink[s].push_back(pcCU);
319
320      createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight);
321    }
322  }
323
324  //step 3: border availability
325  for(Int s=0; s< numSlices; s++)
326  {
327    if(!m_pbValidSlice[s])
328    {
329      continue;
330    }
331
332    for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++)
333    {
334      TComDataCU* pcCU = m_vSliceCUDataLink[s][i];
335      uiAddr = pcCU->getAddr();
336
337      if(pcCU->getPic()==0)
338      {
339        continue;
340      }
341      Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
342      Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false;
343
344      if(m_bIndependentTileBoundaryForNDBFilter)
345      {
346        //left
347        if( uiAddr % numLCUsInPicWidth != 0)
348        {
349          bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;
350        }
351        //right
352        if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )
353        {
354          bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;
355        }
356        //top
357        if( uiAddr >= numLCUsInPicWidth)
358        {
359          bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) !=  iTileID )?true:false;
360        }
361        //down
362        if( uiAddr + numLCUsInPicWidth < numLCUInPic )
363        {
364          bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false;
365        }
366
367      }
368
369      pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight
370        , *LFCrossSliceBoundary
371        ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary
372        ,m_bIndependentTileBoundaryForNDBFilter);
373
374    }
375
376  }
377
378  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
379  {
380    m_pNDBFilterYuvTmp = new TComPicYuv();
381    m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
382  }
383
384}
385
386/** Create non-deblocked filter information for LCU
387 * \param tileID tile index
388 * \param sliceID slice index
389 * \param pcCU CU data pointer
390 * \param startSU start SU index in LCU
391 * \param endSU end SU index in LCU
392 * \param sliceGranularyDepth slice granularity
393 * \param picWidth picture width
394 * \param picHeight picture height
395 */
396Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
397{
398  UInt LCUX          = pcCU->getCUPelX();
399  UInt LCUY          = pcCU->getCUPelY();
400  Int* pCUSliceMap    = pcCU->getSliceSUMap();
401  UInt maxNumSUInLCU = getNumPartInCU();
402  UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
403  UInt maxNumSUInLCUWidth = getNumPartInWidth();
404  UInt LPelX, TPelY;
405  UInt currSU;
406
407
408  //get the number of valid NBFilterBLock
409  currSU   = startSU;
410  while(currSU <= endSU)
411  {
412    LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
413    TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
414
415    while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
416    {
417      currSU += maxNumSUInSGU;
418      if(currSU >= maxNumSUInLCU || currSU > endSU)
419      {
420        break;
421      }
422      LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
423      TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
424    }
425
426    if(currSU >= maxNumSUInLCU || currSU > endSU)
427    {
428      break;
429    }
430
431    NDBFBlockInfo NDBFBlock;
432
433    NDBFBlock.tileID  = tileID;
434    NDBFBlock.sliceID = sliceID;
435    NDBFBlock.posY    = TPelY;
436    NDBFBlock.posX    = LPelX;
437    NDBFBlock.startSU = currSU;
438
439    UInt uiLastValidSU  = currSU;
440    UInt uiIdx, uiLPelX_su, uiTPelY_su;
441    for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
442    {
443      if(uiIdx > endSU)
444      {
445        break;       
446      }
447      uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
448      uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
449      if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
450      {
451        continue;
452      }
453      pCUSliceMap[uiIdx] = sliceID;
454      uiLastValidSU = uiIdx;
455    }
456    NDBFBlock.endSU = uiLastValidSU;
457
458    UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
459    UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
460    NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
461    NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
462    NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
463    NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
464
465    pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
466
467    currSU += maxNumSUInSGU;
468  }
469
470}
471
472/** destroy non-deblocked filter information for LCU
473 */
474Void TComPic::destroyNonDBFilterInfo()
475{
476  if(m_pbValidSlice != NULL)
477  {
478    delete[] m_pbValidSlice;
479    m_pbValidSlice = NULL;
480  }
481
482  if(m_pSliceSUMap != NULL)
483  {
484    delete[] m_pSliceSUMap;
485    m_pSliceSUMap = NULL;
486  }
487  for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
488  {
489    TComDataCU* pcCU = getCU( CUAddr );
490    pcCU->getNDBFilterBlocks()->clear();
491  }
492
493  if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
494  {
495    m_pNDBFilterYuvTmp->destroy();
496    delete m_pNDBFilterYuvTmp;
497    m_pNDBFilterYuvTmp = NULL;
498  }
499
500}
501#if H_MV
502Void TComPic::print( Bool legend )
503{
504  if ( legend )
505    std::cout  << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            << std::endl;
506  else
507    std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << std::endl;
508}
509
510TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc )
511{
512  TComPic* pcPic = NULL;
513  for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() && pcPic == NULL ); itL++)
514  {   
515    for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() && pcPic == NULL ); itP++)
516    {
517      TComPic* currPic = (*itP); 
518      if ( ( currPic->getPOC() == poc ) && ( currPic->getLayerId() == layerIdInNuh ) )
519      {
520        pcPic = currPic ;     
521      }
522    }
523  }
524  return pcPic;
525}
526
527#if H_3D
528TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
529{
530  return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
531}
532
533Void TComPicLists::print()
534{
535  Bool first = true;     
536  for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() ); itL++)
537  {   
538    for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++)
539    {
540      if ( first )
541      {
542        (*itP)->print( true );       
543        first = false; 
544      }
545      (*itP)->print( false );       
546    }
547  }
548}
549
550TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag )
551{
552  TComPic*    pcPic = getPic( layerIdInNuh, poc );
553  TComPicYuv* pcPicYuv = NULL;
554
555  if (pcPic != NULL)
556  {
557    if( reconFlag )
558    {
559      if ( pcPic->getReconMark() )
560      {
561        pcPicYuv = pcPic->getPicYuvRec();
562      }
563    }
564    else
565    {
566      pcPicYuv = pcPic->getPicYuvOrg();
567    }
568  };
569
570  return pcPicYuv;
571}
572
573TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
574{ 
575  Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag ); 
576  return getPicYuv( layerIdInNuh, poc, recon );
577}
578#if H_3D_ARP
579TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
580{
581  TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin();
582  Int iLayer = 0;
583
584  assert( layerIdInNuh < m_lists.size() );
585
586  while( iLayer != layerIdInNuh )
587  {
588    itL++;
589    iLayer++;
590  }
591
592  return *itL;
593}
594#endif
595#endif // H_3D
596#endif // H_MV
597
598#if H_3D_NBDV
599Int TComPic::getDisCandRefPictures( Int iColPOC )
600{
601  UInt       uiTempLayerCurr = 7;
602  TComSlice* currSlice       = getSlice(getCurrSliceIdx());
603  UInt       numDdvCandPics  = 0;
604
605  if ( !currSlice->getEnableTMVPFlag() )
606    return numDdvCandPics;
607
608  numDdvCandPics += 1;
609
610  UInt pocCurr = currSlice->getPOC();
611  UInt pocDiff = 255;
612
613  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
614  {
615    UInt x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
616
617    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
618    {
619      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() 
620        && (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) && numDdvCandPics!=2)
621      {
622        TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
623        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0; 
624        UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer(); 
625       
626        if( bRAP )
627        {
628          this->setRapRefIdx(i);
629          this->setRapRefList((RefPicList)x);
630          numDdvCandPics = 2;
631
632          return numDdvCandPics;
633        }
634        else if (uiTempLayerCurr > uiTempLayer) 
635        {
636           uiTempLayerCurr = uiTempLayer; 
637        }
638      }
639    }
640  }
641
642  UInt z   = -1; // GT: Added to make code compile needs to be checked!
643  UInt idx = 0;
644 
645  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
646  {
647    UInt x = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
648   
649    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
650    {
651      Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
652      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr): (pocCurr - iTempPoc);
653     
654      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() &&  (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) 
655        && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
656      {
657        pocDiff = iTempDiff;
658        z       = x;
659        idx     = i;
660      }
661    }
662  }
663
664  if( pocDiff < 255 )
665  {
666    this->setRapRefIdx(idx);
667    this->setRapRefList((RefPicList) z );
668    numDdvCandPics = 2;
669  }
670
671  return numDdvCandPics;
672}
673
674Void TComPic::checkTemporalIVRef()
675{
676  TComSlice* currSlice = getSlice(getCurrSliceIdx());
677  const Int numCandPics = this->getNumDdvCandPics();
678  for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
679  {
680    RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
681    Int        curCandPicRefIdx = 0;
682    if( curCandPic == 0 ) 
683    { 
684      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1-currSlice->getColFromL0Flag() : 0);
685      curCandPicRefIdx = currSlice->getColRefIdx();
686    }
687    else                 
688    {
689      eCurRefPicList   = this->getRapRefList();
690      curCandPicRefIdx = this->getRapRefIdx();
691    }
692    TComPic* pcCandColPic = currSlice->getRefPic( eCurRefPicList, curCandPicRefIdx);
693    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0);// currently only support single slice
694
695    if(!pcCandColSlice->isIntra())
696    {
697      for( Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2: 1); iColRefDir ++ )
698      {
699        for( Int iColRefIdx =0; iColRefIdx < pcCandColSlice->getNumRefIdx(( RefPicList )iColRefDir ); iColRefIdx++)
700        {
701          m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
702          Int iColViewIdx    = pcCandColSlice->getViewIndex();
703          Int iColRefViewIdx = pcCandColSlice->getRefPic( ( RefPicList )iColRefDir, iColRefIdx)->getViewIndex();
704          if(iColViewIdx == iColRefViewIdx)
705            continue;
706
707          for(Int iCurrRefDir = 0;(iCurrRefDir < (currSlice->isInterB() ? 2: 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false ); iCurrRefDir++)
708          {
709            for( Int iCurrRefIdx =0; iCurrRefIdx < currSlice->getNumRefIdx(( RefPicList )iCurrRefDir ); iCurrRefIdx++)
710            {
711              if( currSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx )->getViewIndex() == iColRefViewIdx )
712              { 
713                m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
714                break;
715              }
716            }
717          }
718        }
719      }
720    }
721  }
722}
723Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
724{
725  return m_abTIVRINCurrRL[currCandPic][iColRefDir][iColRefIdx];
726}
727
728Void TComPic::checkTextureRef(  )
729{
730  TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
731  TComPic* pcTextPic = pcCurrSlice->getTexturePic();
732#if H_3D_FCO
733  if ( pcTextPic )
734  {
735#endif
736
737  TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
738
739  for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
740  {
741    for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
742    {
743      Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
744      Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
745      m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
746      Int iCurrRefDir = iTextRefDir;
747      for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
748      {
749        if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
750          pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
751        { 
752          m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
753        }
754      }
755    }
756
757  }
758#if H_3D_FCO
759  }
760#endif
761
762}
763
764Int TComPic::isTextRefValid(Int iTextRefDir, Int iTextRefIdx)
765{
766  return m_aiTexToDepRef[iTextRefDir][iTextRefIdx];
767}
768#endif
769//! \}
Note: See TracBrowser for help on using the repository browser.