source: 3DVCSoftware/branches/HTM-9.2-dev0/source/Lib/TLibCommon/TComPic.cpp

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

Merged HTM-9.0-dev0@731. (MV-HEVC 6 HLS)

  • Property svn:eol-style set to native
File size: 23.7 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  << std::endl << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            <<  "\t" << "OutMark" <<  "\t" << "OutFlag" << std::endl;
506  else
507    std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << "\t" << getOutputMark() << "\t" << getSlice(0)->getPicOutputFlag() <<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#endif
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
573#if H_3D
574TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
575{ 
576  Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag ); 
577  return getPicYuv( layerIdInNuh, poc, recon );
578}
579#if H_3D_ARP
580TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
581{
582  TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin();
583  Int iLayer = 0;
584
585  assert( layerIdInNuh < m_lists.size() );
586
587  while( iLayer != layerIdInNuh )
588  {
589    itL++;
590    iLayer++;
591  }
592
593  return *itL;
594}
595#endif
596#endif
597#endif // H_MV
598
599#if H_3D_NBDV
600Int TComPic::getDisCandRefPictures( Int iColPOC )
601{
602  UInt       uiTempLayerCurr = 7;
603  TComSlice* currSlice       = getSlice(getCurrSliceIdx());
604  UInt       numDdvCandPics  = 0;
605
606  if ( !currSlice->getEnableTMVPFlag() )
607    return numDdvCandPics;
608
609  numDdvCandPics += 1;
610
611  UInt pocCurr = currSlice->getPOC();
612  UInt pocDiff = 255;
613
614  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
615  {
616    UInt x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
617
618    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
619    {
620      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() 
621        && (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) && numDdvCandPics!=2)
622      {
623        TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
624        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0; 
625        UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer(); 
626       
627        if( bRAP )
628        {
629          this->setRapRefIdx(i);
630          this->setRapRefList((RefPicList)x);
631          numDdvCandPics = 2;
632
633          return numDdvCandPics;
634        }
635        else if (uiTempLayerCurr > uiTempLayer) 
636        {
637           uiTempLayerCurr = uiTempLayer; 
638        }
639      }
640    }
641  }
642
643  UInt z   = -1; // GT: Added to make code compile needs to be checked!
644  UInt idx = 0;
645 
646  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
647  {
648    UInt x = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
649   
650    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
651    {
652      Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
653      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr): (pocCurr - iTempPoc);
654     
655      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() &&  (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) 
656        && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
657      {
658        pocDiff = iTempDiff;
659        z       = x;
660        idx     = i;
661      }
662    }
663  }
664
665  if( pocDiff < 255 )
666  {
667    this->setRapRefIdx(idx);
668    this->setRapRefList((RefPicList) z );
669    numDdvCandPics = 2;
670  }
671
672  return numDdvCandPics;
673}
674
675Void TComPic::checkTemporalIVRef()
676{
677  TComSlice* currSlice = getSlice(getCurrSliceIdx());
678  const Int numCandPics = this->getNumDdvCandPics();
679  for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
680  {
681    RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
682    Int        curCandPicRefIdx = 0;
683    if( curCandPic == 0 ) 
684    { 
685      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1-currSlice->getColFromL0Flag() : 0);
686      curCandPicRefIdx = currSlice->getColRefIdx();
687    }
688    else                 
689    {
690      eCurRefPicList   = this->getRapRefList();
691      curCandPicRefIdx = this->getRapRefIdx();
692    }
693    TComPic* pcCandColPic = currSlice->getRefPic( eCurRefPicList, curCandPicRefIdx);
694    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0);// currently only support single slice
695
696    if(!pcCandColSlice->isIntra())
697    {
698      for( Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2: 1); iColRefDir ++ )
699      {
700        for( Int iColRefIdx =0; iColRefIdx < pcCandColSlice->getNumRefIdx(( RefPicList )iColRefDir ); iColRefIdx++)
701        {
702          m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
703          Int iColViewIdx    = pcCandColSlice->getViewIndex();
704          Int iColRefViewIdx = pcCandColSlice->getRefPic( ( RefPicList )iColRefDir, iColRefIdx)->getViewIndex();
705          if(iColViewIdx == iColRefViewIdx)
706            continue;
707
708          for(Int iCurrRefDir = 0;(iCurrRefDir < (currSlice->isInterB() ? 2: 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false ); iCurrRefDir++)
709          {
710            for( Int iCurrRefIdx =0; iCurrRefIdx < currSlice->getNumRefIdx(( RefPicList )iCurrRefDir ); iCurrRefIdx++)
711            {
712              if( currSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx )->getViewIndex() == iColRefViewIdx )
713              { 
714                m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
715                break;
716              }
717            }
718          }
719        }
720      }
721    }
722  }
723}
724Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
725{
726  return m_abTIVRINCurrRL[currCandPic][iColRefDir][iColRefIdx];
727}
728
729Void TComPic::checkTextureRef(  )
730{
731  TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
732  TComPic* pcTextPic = pcCurrSlice->getTexturePic();
733#if H_3D_FCO
734  if ( pcTextPic )
735  {
736#endif
737
738  TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
739
740  for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
741  {
742    for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
743    {
744      Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
745      Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
746      m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
747      Int iCurrRefDir = iTextRefDir;
748      for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
749      {
750        if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
751          pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
752        { 
753          m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
754        }
755      }
756    }
757
758  }
759#if H_3D_FCO
760  }
761#endif
762
763}
764
765Int TComPic::isTextRefValid(Int iTextRefDir, Int iTextRefIdx)
766{
767  return m_aiTexToDepRef[iTextRefDir][iTextRefIdx];
768}
769#endif
770//! \}
Note: See TracBrowser for help on using the repository browser.