source: 3DVCSoftware/branches/HTM-8.2-dev0-MediaTek/source/Lib/TLibCommon/TComPic.cpp @ 630

Last change on this file since 630 was 630, checked in by chang, 11 years ago

Fixed macro news to H_3D_FCO_E0163 with document number.

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