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

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

Merged DEV-2.0-dev0@604.

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