source: 3DVCSoftware/branches/HTM-DEV-2.0-dev1-Mediatek/source/Lib/TLibCommon/TComPic.cpp @ 566

Last change on this file since 566 was 566, checked in by mediatek-htm, 11 years ago

Integration of JCT3V-E0172. The MACRO is "MTK_RVS_BUGFIX_E0172".

By Na Zhang (na.zhang@…)

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