Changeset 655 in 3DVCSoftware for trunk/source


Ignore:
Timestamp:
23 Oct 2013, 23:01:30 (11 years ago)
Author:
tech
Message:

Merged 8.1-Cleanup@654

Location:
trunk/source
Files:
69 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r622 r655  
    6060#endif
    6161{
    62   ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    6362#if H_MV
    6463  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1;
     
    148147
    149148  // main decoder loop
    150   Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     149  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    151150#else
    152151#if H_3D
     
    176175#endif
    177176    AnnexBStats stats = AnnexBStats();
    178 #if !H_MV
    179     Bool bPreviousPictureDecoded = false;
    180 #endif
    181 
    182177    vector<uint8_t> nalUnit;
    183178    InputNALUnit nalu;
     
    246241#endif
    247242        }
    248 
    249        
    250243#else
    251244      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    252245      {
    253         if(bPreviousPictureDecoded)
    254         {
    255           bNewPicture = true;
    256           bPreviousPictureDecoded = false;
    257         }
    258         else
    259         {
    260           bNewPicture = false;
    261         }
     246        bNewPicture = false;
    262247      }
    263248      else
     
    290275#endif
    291276        }
    292 #if !H_MV
    293         bPreviousPictureDecoded = true;
    294 #endif
    295277      }
    296278    }
     
    311293        TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic );
    312294        assert( picLastCoded != NULL );       
    313 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    314295        picLastCoded->compressMotion(1);
    315 #else
    316         picLastCoded->compressMotion();         
    317 #endif
    318296      }
    319297    }
     
    325303      if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )
    326304#else
    327       if ( m_pchReconFile && !recon_opened )
     305      if ( m_pchReconFile && !openedReconFile )
    328306#endif
    329307      {
     
    338316#else
    339317        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    340         recon_opened = true;
     318        openedReconFile = true;
    341319      }
    342320      if ( bNewPicture &&
     
    466444{
    467445  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    468   Int not_displayed = 0;
    469 
    470   while (iterPic != pcListPic->end())
    471   {
    472     TComPic* pcPic = *(iterPic);
    473 #if H_MV
    474     if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
    475 #else
    476     if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
    477 #endif
    478     {
    479        not_displayed++;
    480     }
    481     iterPic++;
    482   }
    483   iterPic   = pcListPic->begin();
     446  Int numPicsNotYetDisplayed = 0;
    484447 
    485448  while (iterPic != pcListPic->end())
    486449  {
    487450    TComPic* pcPic = *(iterPic);
    488    
    489 #if H_MV
    490     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))
    491 #else
    492     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
    493 #endif
    494     {
    495       // write to file
    496        not_displayed--;
     451#if H_MV
     452    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
     453#else
     454    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
     455#endif
     456    {
     457      numPicsNotYetDisplayed++;
     458    }
     459    iterPic++;
     460  }
     461  iterPic   = pcListPic->begin();
     462  if (numPicsNotYetDisplayed>2)
     463  {
     464    iterPic++;
     465  }
     466 
     467  TComPic* pcPic = *(iterPic);
     468  if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding
     469  {
     470    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     471    endPic--;
     472    iterPic   = pcListPic->begin();
     473    while (iterPic != endPic)
     474    {
     475      TComPic* pcPicTop = *(iterPic);
     476      iterPic++;
     477      TComPic* pcPicBottom = *(iterPic);
     478     
     479#if H_MV
     480      if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
     481          && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_pocLastDisplay[decIdx]+1 || m_pocLastDisplay[decIdx]<0)))
     482#else
     483      if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
     484          && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0)))
     485#endif
     486      {
     487        // write to file
     488        numPicsNotYetDisplayed = numPicsNotYetDisplayed-2;
    497489#if H_MV
    498490      if ( m_pchReconFiles[decIdx] )
    499491#else
    500       if ( m_pchReconFile )
    501 #endif
    502       {
    503         const Window &conf = pcPic->getConformanceWindow();
    504         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    505 #if H_MV
    506 #if H_MV5
     492        if ( m_pchReconFile )
     493#endif
     494        {
     495          const Window &conf = pcPicTop->getConformanceWindow();
     496          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     497
     498          const Bool isTff = pcPicTop->isTopField();
     499#if H_MV
    507500        assert( conf   .getScaledFlag() );
    508501        assert( defDisp.getScaledFlag() );
    509 #endif
     502        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     503#else
     504          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     505#endif
     506                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     507                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     508                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     509                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     510        }
     511       
     512        // update POC of display order
     513#if H_MV
     514        m_pocLastDisplay[decIdx] = pcPic->getPOC();
     515#else
     516        m_iPOCLastDisplay = pcPicBottom->getPOC();
     517#endif
     518       
     519        // erase non-referenced picture in the reference picture list after display
     520        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     521        {
     522#if !DYN_REF_FREE
     523          pcPicTop->setReconMark(false);
     524         
     525          // mark it should be extended later
     526          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     527         
     528#else
     529          pcPicTop->destroy();
     530          pcListPic->erase( iterPic );
     531          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     532          continue;
     533#endif
     534        }
     535        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     536        {
     537#if !DYN_REF_FREE
     538          pcPicBottom->setReconMark(false);
     539         
     540          // mark it should be extended later
     541          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     542         
     543#else
     544          pcPicBottom->destroy();
     545          pcListPic->erase( iterPic );
     546          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     547          continue;
     548#endif
     549        }
     550        pcPicTop->setOutputMark(false);
     551        pcPicBottom->setOutputMark(false);
     552      }
     553    }
     554  }
     555  else if (!pcPic->isField()) //Frame Decoding
     556  {
     557    iterPic = pcListPic->begin();
     558    while (iterPic != pcListPic->end())
     559    {
     560      pcPic = *(iterPic);
     561
     562#if H_MV
     563      if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))
     564#else     
     565      if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     566#endif
     567      {
     568        // write to file
     569        numPicsNotYetDisplayed--;
     570#if H_MV
     571      if ( m_pchReconFiles[decIdx] )
     572#else
     573        if ( m_pchReconFile )
     574#endif
     575        {
     576          const Window &conf = pcPic->getConformanceWindow();
     577          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     578#if H_MV
     579        assert( conf   .getScaledFlag() );
     580        assert( defDisp.getScaledFlag() );
    510581        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
    511582#else
    512         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    513 #endif
    514                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    515                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    516                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    517                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     583          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     584#endif
     585                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     586                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     587                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     588                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     589        }
     590       
     591        // update POC of display order
     592#if H_MV
     593        m_pocLastDisplay[decIdx] = pcPic->getPOC();
     594#else
     595        m_iPOCLastDisplay = pcPic->getPOC();
     596#endif
     597       
     598        // erase non-referenced picture in the reference picture list after display
     599        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     600        {
     601#if !DYN_REF_FREE
     602          pcPic->setReconMark(false);
     603         
     604          // mark it should be extended later
     605          pcPic->getPicYuvRec()->setBorderExtension( false );
     606         
     607#else
     608          pcPic->destroy();
     609          pcListPic->erase( iterPic );
     610          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     611          continue;
     612#endif
     613        }
     614        pcPic->setOutputMark(false);
    518615      }
    519616     
    520       // update POC of display order
    521 #if H_MV
    522       m_pocLastDisplay[decIdx] = pcPic->getPOC();
    523 #else
    524       m_iPOCLastDisplay = pcPic->getPOC();
    525 #endif
    526      
    527       // erase non-referenced picture in the reference picture list after display
    528       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    529       {
    530 #if !DYN_REF_FREE
    531         pcPic->setReconMark(false);
    532        
    533         // mark it should be extended later
    534         pcPic->getPicYuvRec()->setBorderExtension( false );
    535        
    536 #else
    537         pcPic->destroy();
    538         pcListPic->erase( iterPic );
    539         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    540         continue;
    541 #endif
    542       }
    543       pcPic->setOutputMark(false);
    544     }
    545    
    546     iterPic++;
    547   }
    548 }
    549 
     617      iterPic++;
     618    }
     619  }
     620}
    550621/** \param pcListPic list of pictures to be written to file
    551622    \todo            DYN_REF_FREE should be revised
     
    560631  {
    561632    return;
    562   } 
     633  }
    563634  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    564 
     635 
    565636  iterPic   = pcListPic->begin();
     637  TComPic* pcPic = *(iterPic);
    566638 
    567   while (iterPic != pcListPic->end())
    568   {
    569     TComPic* pcPic = *(iterPic);
    570 
    571     if ( pcPic->getOutputMark() )
    572     {
    573       // write to file
     639  if (pcPic->isField()) //Field Decoding
     640  {
     641    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     642    endPic--;
     643    TComPic *pcPicTop, *pcPicBottom = NULL;
     644    while (iterPic != endPic)
     645    {
     646      pcPicTop = *(iterPic);
     647      iterPic++;
     648      pcPicBottom = *(iterPic);
     649     
     650      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
     651      {
     652        // write to file
    574653#if H_MV
    575654      if ( m_pchReconFiles[decIdx] )
    576655#else
    577       if ( m_pchReconFile )
    578 #endif
    579       {
    580         const Window &conf = pcPic->getConformanceWindow();
    581         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    582 #if H_MV
    583 #if H_MV5
     656        if ( m_pchReconFile )
     657#endif
     658        {
     659          const Window &conf = pcPicTop->getConformanceWindow();
     660          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     661          const Bool isTff = pcPicTop->isTopField();
     662#if H_MV
    584663        assert( conf   .getScaledFlag() );
    585664        assert( defDisp.getScaledFlag() );
    586 #endif
     665        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     666#else
     667          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     668#endif
     669                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     670                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     671                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     672                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     673        }
     674       
     675        // update POC of display order
     676#if H_MV
     677      m_pocLastDisplay[decIdx] = pcPic->getPOC();
     678#else
     679      m_iPOCLastDisplay = pcPicBottom->getPOC();
     680#endif       
     681        // erase non-referenced picture in the reference picture list after display
     682        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     683        {
     684#if !DYN_REF_FREE
     685          pcPicTop->setReconMark(false);
     686         
     687          // mark it should be extended later
     688          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     689         
     690#else
     691          pcPicTop->destroy();
     692          pcListPic->erase( iterPic );
     693          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     694          continue;
     695#endif
     696        }
     697        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     698        {
     699#if !DYN_REF_FREE
     700          pcPicBottom->setReconMark(false);
     701         
     702          // mark it should be extended later
     703          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     704         
     705#else
     706          pcPicBottom->destroy();
     707          pcListPic->erase( iterPic );
     708          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     709          continue;
     710#endif
     711        }
     712        pcPicTop->setOutputMark(false);
     713        pcPicBottom->setOutputMark(false);
     714       
     715#if !DYN_REF_FREE
     716        if(pcPicTop)
     717        {
     718          pcPicTop->destroy();
     719          delete pcPicTop;
     720          pcPicTop = NULL;
     721        }
     722#endif
     723      }
     724    }
     725    if(pcPicBottom)
     726    {
     727      pcPicBottom->destroy();
     728      delete pcPicBottom;
     729      pcPicBottom = NULL;
     730    }
     731  }
     732  else //Frame decoding
     733  {
     734    while (iterPic != pcListPic->end())
     735    {
     736      pcPic = *(iterPic);
     737     
     738      if ( pcPic->getOutputMark() )
     739      {
     740        // write to file
     741#if H_MV
     742      if ( m_pchReconFiles[decIdx] )
     743#else
     744        if ( m_pchReconFile )
     745#endif
     746        {
     747          const Window &conf = pcPic->getConformanceWindow();
     748          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     749#if H_MV
     750        assert( conf   .getScaledFlag() );
     751        assert( defDisp.getScaledFlag() );
    587752        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
    588753#else
    589         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    590 #endif
    591                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    592                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    593                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    594                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    595       }
    596      
    597       // update POC of display order
     754          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     755#endif
     756                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     757                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     758                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     759                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     760        }
     761       
     762        // update POC of display order
    598763#if H_MV
    599764      m_pocLastDisplay[decIdx] = pcPic->getPOC();
    600765#else
    601       m_iPOCLastDisplay = pcPic->getPOC();
    602 #endif
    603      
    604       // erase non-referenced picture in the reference picture list after display
    605       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    606       {
     766        m_iPOCLastDisplay = pcPic->getPOC();
     767#endif
     768       
     769        // erase non-referenced picture in the reference picture list after display
     770        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     771        {
    607772#if !DYN_REF_FREE
    608         pcPic->setReconMark(false);
    609        
    610         // mark it should be extended later
    611         pcPic->getPicYuvRec()->setBorderExtension( false );
    612        
    613 #else
    614         pcPic->destroy();
    615         pcListPic->erase( iterPic );
    616         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    617         continue;
    618 #endif
    619       }
    620       pcPic->setOutputMark(false);
    621     }
     773          pcPic->setReconMark(false);
     774         
     775          // mark it should be extended later
     776          pcPic->getPicYuvRec()->setBorderExtension( false );
     777         
     778#else
     779          pcPic->destroy();
     780          pcListPic->erase( iterPic );
     781          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     782          continue;
     783#endif
     784        }
     785        pcPic->setOutputMark(false);
     786      }
    622787#if !H_MV
    623788#if !DYN_REF_FREE
    624     if(pcPic)
    625     {
    626       pcPic->destroy();
    627       delete pcPic;
    628       pcPic = NULL;
    629     }
    630 #endif
    631 #endif
    632     iterPic++;
     789      if(pcPic)
     790      {
     791        pcPic->destroy();
     792        delete pcPic;
     793        pcPic = NULL;
     794      }
     795#endif   
     796#endif
     797      iterPic++;
     798    }
    633799  }
    634800#if H_MV
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r608 r655  
    7272#endif
    7373    // for output control
    74   Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
    7574#if H_MV
    7675  Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r622 r655  
    8282  m_codedPivotValue = NULL;
    8383  m_targetPivotValue = NULL;
     84
     85#if KWU_RC_MADPRED_E0227
     86  m_depthMADPred = 0;
     87#endif
    8488}
    8589
     
    224228    in>>entry.m_interViewRefPosL[1][i];
    225229  }
    226 #if !H_MV5
    227   if (entry.m_numActiveRefLayerPics > 0 )
    228   {
    229     in>>entry.m_collocatedRefLayerIdx;
    230   }
    231 #endif
    232230#endif
    233231  return in;
     
    369367  ("NumberOfLayers",        m_numberOfLayers     , 1,                     "Number of layers")
    370368#if !H_3D
    371 #if H_MV5
    372369  ("ScalabilityMask",       m_scalabilityMask    , 2                    , "Scalability Mask")   
    373 #else
    374   ("ScalabilityMask",       m_scalabilityMask    , 1                    , "Scalability Mask")   
    375 #endif
    376370#else
    377371  ("ScalabilityMask",       m_scalabilityMask    , 3                    , "Scalability Mask, 1: Texture 3: Texture + Depth ")   
    378372#endif 
    379373  ("DimensionIdLen",        m_dimensionIdLen     , cfg_dimensionLength  , "Number of bits used to store dimensions Id")
    380 #if H_MV5
    381374  ("ViewOrderIndex",        m_viewOrderIndex     , std::vector<Int>(1,0), "View Order Index per layer")
    382375  ("ViewId",                m_viewId             , std::vector<Int>(1,0), "View Id per View Order Index")
    383 #else
    384   ("ViewId",                m_viewId             , std::vector<Int>(1,0), "View Id")
    385 #endif
    386376#if H_3D
    387377  ("DepthFlag",             m_depthFlag          , std::vector<Int>(1,0), "Depth Flag")
     
    428418  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
    429419
     420  //Field coding parameters
     421  ("FieldCoding", m_isField, false, "Signals if it's a field based coding")
     422  ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not")
     423 
    430424  // Profile and level
    431425  ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
     
    517511  ("IlluCompEnable",           m_abUseIC, std::vector<Bool>(2, true), "Enable illumination compensation")
    518512#endif
    519 #if LGE_INTER_SDC_E0156
     513#if H_3D_INTER_SDC
    520514  ("InterSDC",                 m_bDepthInterSDCFlag,        true, "Enable depth inter SDC")
    521515#endif
     
    594588  ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
    595589  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
     590
     591#if KWU_RC_VIEWRC_E0227
     592  ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
     593  ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
     594#endif
     595#if KWU_RC_MADPRED_E0227
     596  ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
     597#endif
    596598#else
    597599  ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
    598600  ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
    599601  ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
    600 #endif
    601 
    602 #if H_MV5
     602
     603#if KWU_RC_VIEWRC_E0227
     604  ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
     605  ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
     606#endif
     607#if KWU_RC_MADPRED_E0227
     608  ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
     609#endif
     610#endif
     611
    603612#if H_MV
    604613  // VPS VUI
     
    617626  ("CtuBasedOffsetEnabledFlag"   , m_ctuBasedOffsetEnabledFlag   , std::vector< Bool >(1,0)  ,MAX_NUM_LAYERS       , "CtuBasedOffsetEnabledFlag    per direct reference for the N-th layer")
    618627  ("MinHorizontalCtuOffsetPlus1" , m_minHorizontalCtuOffsetPlus1 , std::vector< Int  >(1,0)  ,MAX_NUM_LAYERS       , "MinHorizontalCtuOffsetPlus1  per direct reference for the N-th layer")
    619 #endif
    620628#endif
    621629
     
    762770    if( k == 0 )
    763771    {
    764 #if H_MV5
    765772      m_GOPListMvc[0][0].m_sliceType = 'I';
    766 #endif
    767773      for( Int i = 1; i < MAX_GOP + 1; i++ )
    768774      {
     
    810816  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
    811817
     818  if(m_isField)
     819  {
     820    //Frame height
     821    m_iSourceHeightOrg = m_iSourceHeight;
     822    //Field height
     823    m_iSourceHeight = m_iSourceHeight >> 1;
     824    //number of fields to encode
     825    m_framesToBeEncoded *= 2;
     826  }
     827 
    812828  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    813829  {
     
    928944        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    929945        m_iSourceHeight += m_confBottom;
     946        if ( m_isField )
     947        {
     948          m_iSourceHeightOrg += m_confBottom << 1;
     949          m_aiPad[1] = m_confBottom << 1;
     950        }
    930951      }
    931952      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
     
    968989  // allocate slice-based dQP values
    969990#if H_MV
    970 #if H_MV5
    971991  xResizeVector( m_viewOrderIndex    );
    972992
     
    9881008#if H_3D
    9891009  xResizeVector( m_depthFlag );
    990 #endif
    991 #else
    992   xResizeVector( m_viewId    );
    993 #if H_3D
    994   xResizeVector( m_depthFlag );
    995 
    996   std::vector<Int> uniqueViewIds;
    997   for( Int layer = 0; layer < m_numberOfLayers; layer++ )
    998   {   
    999     Bool isIn = false;
    1000     for ( Int i = 0 ; i < uniqueViewIds.size(); i++ )
    1001     {
    1002       isIn = isIn || ( m_viewId[ layer ] == uniqueViewIds[ i ] );
    1003     }
    1004     if ( !isIn )
    1005     {
    1006       uniqueViewIds.push_back( m_viewId[ layer ] );
    1007     }
    1008   }
    1009   m_iNumberOfViews = (Int) uniqueViewIds.size();
    1010 #endif
    1011 
    10121010#endif
    10131011  xResizeVector( m_fQP );
     
    12831281  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
    12841282 
    1285 #if H_MV5
    12861283#if H_3D
    12871284  xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 3, "Scalability Mask must be equal to 2 or 3. ");
     
    12981295
    12991296  m_dimIds.push_back( m_viewOrderIndex );   
    1300 #else
    1301 #if H_3D
    1302   xConfirmPara( m_scalabilityMask != 1 && m_scalabilityMask != 3, "Scalability Mask must be equal to 1 or 3. ");
    1303 #else
    1304   xConfirmPara( m_scalabilityMask != 1 , "Scalability Mask must be equal to 1. ");
    1305 #endif
    1306  
    1307   m_dimIds.push_back( m_viewId );
    1308   const Int viewDimPosition = 0;
    1309 #if H_3D
    1310   if ( m_scalabilityMask & ( 1 << DEPTH_ID ) )
    1311     m_dimIds.push_back( m_depthFlag );
    1312 #endif
    1313 
    1314 #endif
    13151297  xConfirmPara(  m_dimensionIdLen.size() < m_dimIds.size(), "DimensionIdLen must be given for all dimensions. "   );   Int dimBitOffset[MAX_NUM_SCALABILITY_TYPES+1];
    13161298
     
    13291311  {   
    13301312    xConfirmPara( m_dimIds[j].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");   
    1331 #if H_MV5   
    13321313    xConfirmPara( (m_dimIds[j][0] != 0)                 , "DimensionId of layer 0 must be 0. " );
    1333 #else
    1334     xConfirmPara( ( j != viewDimPosition ) &&  (m_dimIds[j][0] != 0), "DimensionId of layer 0 must be 0. " );
    1335 #endif
    13361314    xConfirmPara( m_dimensionIdLen[j] < 1 || m_dimensionIdLen[j] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " );
    13371315     
     
    13721350     xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
    13731351
     1352#if !H_3D_FCO
    13741353     if ( numDiff  == 1 )
    13751354     {
    13761355       Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ];
    1377 #if H_MV5
    13781356       Bool shallBeButIsNotIncreasing = ( !inc  ) ;
    1379 #else
    1380        Bool shallBeButIsNotIncreasing = ( !inc && ( lastDiff != viewDimPosition ) ) ;
    1381 #endif
    13821357       if ( shallBeButIsNotIncreasing )
    13831358       {       
    13841359         printf( "\nError: Positions of Layers %d and %d is not increasing in dimension %d \n", i, j, lastDiff);       
    13851360       }
    1386 #if H_MV5
    13871361       xConfirmPara( shallBeButIsNotIncreasing,  "DimensionIds shall be increasing within one dimension. " );
    1388 #else
    1389        xConfirmPara( shallBeButIsNotIncreasing && ( lastDiff != viewDimPosition ),  "DimensionIds shall be increasing within one dimension. " );
    1390 #endif
    13911362     }
     1363#endif
    13921364   }
    13931365 }
    13941366
    1395 #if H_MV5
    13961367 /// ViewId
    13971368 xConfirmPara( m_viewId.size() != m_iNumberOfViews, "The number of ViewIds must be equal to the number of views." );
     
    13991370  /// Layer sets
    14001371  xConfirmPara( m_vpsNumLayerSets < 0 || m_vpsNumLayerSets > 1024, "VpsNumLayerSets must be greater than 0 and less than 1025. ") ;
    1401 #else
    1402   xConfirmPara( m_vpsNumLayerSets < 0 || m_vpsNumLayerSets > 1024, "VpsNumLayerSets must be greater than 0 and less than 1025") ;
    1403 #endif
    14041372  for( Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
    14051373  {
     
    17431711  Bool errorGOP=false;
    17441712  Int checkGOP=1;
    1745   Int numRefs = 1;
     1713  Int numRefs = m_isField ? 2 : 1;
    17461714  Int refList[MAX_NUM_REF_PICS+1];
    17471715  refList[0]=0;
     1716  if(m_isField)
     1717  {
     1718    refList[1] = 1;
     1719  }
    17481720  Bool isOK[MAX_GOP];
    17491721  for(Int i=0; i<MAX_GOP; i++)
     
    21572129    xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" );
    21582130
     2131#if !KWU_FIX_URQ
    21592132    m_iMaxDeltaQP       = MAX_DELTA_QP;
     2133#endif
    21602134    m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
    21612135  }
    21622136#endif
    2163 #if H_MV5
    21642137#if H_MV
    21652138  // VPS VUI
     
    21842157  }
    21852158#endif
    2186 #endif
    21872159
    21882160  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
     
    22502222#endif
    22512223#if H_MV
    2252 #if H_MV5
    22532224  xPrintParaVector( "ViewIdVal"     , m_viewId );
    22542225  xPrintParaVector( "ViewOrderIndex", m_viewOrderIndex );
    2255 #else
    2256   xPrintParaVector( "ViewId", m_viewId );
    2257 #endif
    22582226#endif
    22592227#if H_3D
     
    22682236  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    22692237  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     2238  if (m_isField)
     2239  {
     2240    printf("Frame/Field          : Field based coding\n");
     2241    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2242    if (m_isTopFieldFirst)
     2243    {
     2244      printf("Field Order            : Top field first\n");
     2245    }
     2246    else
     2247    {
     2248      printf("Field Order            : Bottom field first\n");
     2249    }
     2250  }
     2251  else
     2252  {
     2253    printf("Frame/Field                  : Frame based coding\n");
    22702254  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2255  }
    22712256  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
    22722257  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
     
    22992284    printf("InitialQP                    : %d\n", m_RCInitialQP );
    23002285    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
     2286
     2287#if KWU_RC_MADPRED_E0227
     2288    printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
     2289#endif
     2290#if KWU_RC_VIEWRC_E0227
     2291    printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
     2292    if(m_viewWiseRateCtrl)
     2293    {
     2294
     2295      printf("ViewWiseTargetBits           : ");
     2296      for (Int i = 0 ; i < m_iNumberOfViews ; i++)
     2297        printf("%d ", m_viewTargetBits[i]);
     2298      printf("\n");
     2299    }
     2300    else
     2301    {
     2302      printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
     2303    }
     2304#endif
    23012305  }
    23022306#else
     
    23062310    printf("TargetBitrate                : %d\n", m_targetBitrate);
    23072311    printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
     2312
     2313#if KWU_RC_MADPRED_E0227
     2314    printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
     2315#endif
     2316#if KWU_RC_VIEWRC_E0227
     2317    printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
     2318    if(m_viewWiseRateCtrl)
     2319    {
     2320
     2321      printf("ViewWiseTargetBits           : ");
     2322      for (Int i = 0 ; i < m_iNumberOfViews ; i++)
     2323        printf("%d ", m_viewTargetBits[i]);
     2324      printf("\n");
     2325    }
     2326    else
     2327    {
     2328      printf("TargetBitrate                : %d\n", m_targetBitrate );
     2329    }
     2330#endif
    23082331  }
    23092332#endif
     
    24142437  printf("DLT:%d ", m_useDLT );
    24152438#endif
    2416 #if LGE_INTER_SDC_E0156
     2439#if H_3D_INTER_SDC
    24172440  printf( "interSDC: %d ", m_bDepthInterSDCFlag ? 1 : 0 );
    24182441#endif
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r622 r655  
    6969  std::vector<char*>     m_pchReconFileList;                  ///< output reconstruction file names
    7070  Int                    m_numberOfLayers;                    ///< number of Layers to Encode
    71 #if H_MV5
    7271  Int                    m_iNumberOfViews;                    ///< number of Layers that are views
    73 #else
    74 #if H_3D
    75   Int                    m_iNumberOfViews;                    ///< number of Layers that are views
    76 #endif
    77 #endif
    7872#else
    7973  Char*     m_pchReconFile;                                   ///< output reconstruction file
     
    8377  std::vector< std::vector<Int> > m_dimIds;                   ///< dimension ids ( pointers to m_viewId and m_depthFlag
    8478  std::vector<Int>       m_viewId;                            ///< view id
    85 #if H_MV5
    8679  std::vector<Int>       m_viewOrderIndex;                    ///< view order index 
    87 #endif
    8880#if H_3D
    8981  std::vector<Int>       m_depthFlag;                         ///< depth flag
     
    10698  std::vector< std::vector<Int> > m_dependencyTypes;          ///< Dependency types of direct reference layers
    10799
    108 #if H_MV5
    109100  // VPS VUI
    110101  Bool m_vpsVuiPresentFlag;
     
    122113  std::vector< std::vector<Bool > > m_ctuBasedOffsetEnabledFlag;
    123114  std::vector< std::vector<Int  > > m_minHorizontalCtuOffsetPlus1;
    124 #endif
    125115
    126116#if H_3D_IV_MERGE
     
    149139  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    150140  Int       m_iSourceWidth;                                   ///< source width in pixel
    151   Int       m_iSourceHeight;                                  ///< source height in pixel
     141  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     142 
     143  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
     144 
     145  bool      m_isField;                                        ///< enable field coding
     146  bool      m_isTopFieldFirst;
     147 
    152148  Int       m_conformanceMode;
    153149  Int       m_confLeft;
     
    367363  Int       m_RCInitialQP;                        ///< inital QP for rate control
    368364  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
     365
     366#if KWU_RC_VIEWRC_E0227
     367  vector<Int>     m_viewTargetBits;
     368  Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
     369#endif
     370#if KWU_RC_MADPRED_E0227
     371  UInt       m_depthMADPred;
     372#endif
    369373#else
    370374  Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
    371375  Int       m_targetBitrate;                                 ///< target bitrate
    372376  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
     377
     378#if KWU_RC_VIEWRC_E0227
     379  vector<Int>     m_viewTargetBits;
     380  Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
     381#endif
     382#if KWU_RC_MADPRED_E0227
     383  UInt       m_depthMADPred;
     384#endif
    373385#endif
    374386  Int       m_useScalingListId;                               ///< using quantization matrix
     
    457469  Bool      m_bUsePC;                                         ///< flag for using Predictive Coding with QTL
    458470#endif
    459 #if LGE_INTER_SDC_E0156
     471#if H_3D_INTER_SDC
    460472  Bool m_bDepthInterSDCFlag;                                ///< flag for inter SDC of depth map coding
    461473#endif
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r622 r655  
    8888    vps.setTemporalNestingFlag(true);
    8989  }
    90 #if H_MV5
    9190  vps.setMaxLayersMinus1( m_numberOfLayers - 1);
    92 #else
    93   vps.setMaxLayers( m_numberOfLayers );
    94 #endif
    9591  for(Int i = 0; i < MAX_TLAYER; i++)
    9692  {
     
    124120  xSetDependencies( vps );
    125121  xSetProfileTierLevel     ( vps );
    126 #if H_MV5
    127122  xSetRepFormat            ( vps );
    128 #endif
    129123  xSetLayerSets            ( vps );
    130 #if H_MV5
    131124  xSetVPSVUI               ( vps );
    132 #endif
    133125#if H_3D
    134 #if !H_MV5
    135   vps.initViewIndex();
    136 #endif
    137126  xSetVPSExtension2        ( vps );
    138127  m_ivPicLists.setVPS      ( &vps );
     
    140129
    141130
    142 #if H_MV5
    143131  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
    144 #else
    145   for(Int layer = 0; layer < m_numberOfLayers; layer++)
    146 #endif
    147132  {
    148133    m_frameRcvd                 .push_back(0);
     
    151136    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
    152137    m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
    153 #if H_MV5   
    154138    m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic()  );
    155139    TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ];  // It is not a member, but this name helps avoiding code duplication !!!
     
    160144    m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
    161145    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
    162 #else
    163     m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic()  );
    164     TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
    165    
    166     m_cTEncTop.setLayerIdInVps                 ( layer );
    167     m_cTEncTop.setLayerId                      ( vps.getLayerIdInNuh( layer ) );   
    168     m_cTEncTop.setViewId                       ( vps.getViewId      ( layer ) );
    169 
    170 #endif
    171146#if H_3D
    172 #if H_MV5
    173147    Bool isDepth = ( vps.getDepthId     ( layerId ) != 0 ) ;
    174 #else
    175     Bool isDepth = ( vps.getDepthId     ( layer ) != 0 ) ;
    176     m_cTEncTop.setViewIndex                    ( vps.getViewIndex   ( layer ) );
    177 #endif
    178148    m_cTEncTop.setIsDepth                      ( isDepth );
    179149    //====== Camera Parameters =========
     
    201171    m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
    202172#endif // H_3D_VSO
    203 #if H_MV5
    204173#if H_3D_ARP
    205174    //====== Advanced Inter-view Residual Prediction =========
     
    209178#if H_3D_IC
    210179    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 ? false : m_abUseIC[isDepth ? 1 : 0] );
    211 #endif
    212 #else
    213 #if H_3D_ARP
    214     //====== Advanced Inter-view Residual Prediction =========
    215     m_cTEncTop.setUseAdvRP                     ( ( isDepth || 0==layer ) ? 0 : m_uiUseAdvResPred );
    216     m_cTEncTop.setARPStepNum                   ( ( isDepth || 0==layer ) ? 1 : H_3D_ARP_WFNR     );
    217 #endif
    218 #if H_3D_IC
    219     m_cTEncTop.setUseIC                        ( vps.getViewIndex( layer ) == 0 ? false : m_abUseIC[isDepth ? 1 : 0] );
    220 #endif
    221180#endif
    222181  //========== Depth intra modes ==========
     
    232191#endif
    233192    //====== Depth Inter SDC =========
    234 #if LGE_INTER_SDC_E0156
     193#if H_3D_INTER_SDC
    235194    m_cTEncTop.setInterSDCEnable               ( isDepth ? m_bDepthInterSDCFlag    : false );
    236195#endif
     
    260219  m_cTEncTop.setGOPSize                      ( m_iGOPSize );
    261220#if H_MV
    262 #if H_MV5
    263221m_cTEncTop.setGopList                      ( m_GOPListMvc[layerIdInVps] );
    264222  m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layerIdInVps] );
     
    269227  }
    270228#else
    271   m_cTEncTop.setGopList                      ( m_GOPListMvc[layer] );
    272   m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layer] );
    273   for(Int i = 0; i < MAX_TLAYER; i++)
    274   {
    275     m_cTEncTop.setNumReorderPics             ( m_numReorderPicsMvc[layer][i], i );
    276     m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBufferingMvc[layer][i], i );
    277   }
    278 #endif
    279 #else
    280229  m_cTEncTop.setGopList                      ( m_GOPList );
    281230  m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
     
    291240  }
    292241#if H_MV
    293 #if H_MV5
    294242  m_cTEncTop.setQP                           ( m_iQP[layerIdInVps] );
    295243#else
    296   m_cTEncTop.setQP                           ( m_iQP[layer] );
    297 #endif
    298 #else
    299244  m_cTEncTop.setQP                           ( m_iQP );
    300245#endif
     
    303248
    304249#if H_MV
    305 #if H_MV5
    306250  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layerIdInVps] );
    307251#else
    308   m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layer] );
    309 #endif
    310 #else
    311252  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
    312253#endif
     
    317258  //====== Loop/Deblock Filter ========
    318259#if H_MV
    319 #if H_MV5
    320260  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layerIdInVps]);
    321 #else
    322   m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layer]);
    323 #endif
    324261#else
    325262  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
     
    351288
    352289#if H_MV
    353 #if H_MV5
    354290  if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layerIdInVps] == lowestQP) && (m_useLossless == true))
    355 #else
    356   if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true))
    357 #endif
    358291#else
    359292  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
     
    372305  m_cTEncTop.setUseLossless                  ( m_useLossless );
    373306#if H_MV
    374 #if H_MV5
    375307  m_cTEncTop.setdQPs                         ( m_aidQP[layerIdInVps]   );
    376 #else
    377   m_cTEncTop.setdQPs                         ( m_aidQP[layer]   );
    378 #endif
    379308#else
    380309  m_cTEncTop.setdQPs                         ( m_aidQP        );
     
    435364  m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    436365#if H_MV
    437 #if H_MV5
    438366  m_cTEncTop.setUseSAO ( m_bUseSAO[layerIdInVps] );
    439 #else
    440   m_cTEncTop.setUseSAO ( m_bUseSAO[layer] );
    441 #endif
    442367#else
    443368  m_cTEncTop.setUseSAO ( m_bUseSAO );
     
    512437  m_cTEncTop.setSignHideFlag(m_signHideFlag);
    513438#if RATE_CONTROL_LAMBDA_DOMAIN
    514   m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     439#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
     440  if(!m_cTEncTop.getIsDepth())    //only for texture
     441  {
     442    m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     443  }
     444  else
     445  {
     446    m_cTEncTop.setUseRateCtrl         ( 0 );
     447  }
     448#else
     449    m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     450#endif
     451#if !KWU_RC_VIEWRC_E0227
    515452  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
     453#endif
    516454  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
    517455  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
     
    519457  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
    520458  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
    521 #else
    522   m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
    523   m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
    524   m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
     459
     460#if KWU_RC_MADPRED_E0227
     461  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     462  {
     463    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
     464
     465    if(m_cTEncTop.getUseDepthMADPred())
     466    {
     467      m_cTEncTop.setCamParam(&m_cCameraData);
     468    }
     469  }
     470#endif
     471#if KWU_RC_VIEWRC_E0227
     472  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     473  {
     474    m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
     475
     476    if(m_iNumberOfViews == 1)
     477    {
     478      if(m_viewWiseRateCtrl)
     479      {
     480        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
     481      }
     482      else
     483      {
     484        m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
     485      }
     486    }
     487    else
     488    {
     489      if(m_viewWiseRateCtrl)
     490      {
     491        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
     492      }
     493      else
     494      {
     495        if(m_iNumberOfViews == 2)
     496        {
     497          if(m_cTEncTop.getViewId() == 0)
     498          {
     499            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*80)/100 );
     500          }
     501          else if(m_cTEncTop.getViewId() == 1)
     502          {
     503            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*20)/100 );
     504          }
     505        }
     506        else if(m_iNumberOfViews == 3)
     507        {
     508          if(m_cTEncTop.getViewId() == 0)
     509          {
     510            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*66)/100 );
     511          }
     512          else if(m_cTEncTop.getViewId() == 1)
     513          {
     514            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
     515          }
     516          else if(m_cTEncTop.getViewId() == 2)
     517          {
     518            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
     519          }
     520        }
     521        else
     522        {
     523          m_cTEncTop.setTargetBitrate              ( m_RCTargetBitrate );
     524        }
     525      }
     526    }
     527  }
     528#endif
     529#else
     530#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
     531  if(!m_cTEncTop.getIsDepth())    //only for texture
     532  {
     533    m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
     534    m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
     535    m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
     536  }
     537  else
     538  {
     539    m_cTEncTop.setUseRateCtrl         ( 0 );
     540  }
     541#else
     542  m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
     543  m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
     544  m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
     545#endif
     546
     547 
     548#if KWU_RC_MADPRED_E0227
     549  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     550  {
     551    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
     552
     553    if(m_cTEncTop.getUseDepthMADPred())
     554    {
     555      m_cTEncTop.setCamParam(&m_cCameraData);
     556    }
     557  }
     558#endif
     559
     560#if KWU_RC_VIEWRC_E0227
     561  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     562  {
     563    m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
     564    if(m_iNumberOfViews == 1)
     565    {
     566      if(m_viewWiseRateCtrl)
     567      {
     568        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
     569      }
     570      else
     571      {
     572        m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
     573      }
     574    }
     575    else
     576    {
     577      if(m_viewWiseRateCtrl)
     578      {
     579        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
     580      }
     581      else
     582      {
     583        if(m_iNumberOfViews == 2)
     584        {
     585          if(m_cTEncTop.getViewId() == 0)
     586          {
     587            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*80)/100 );
     588          }
     589          else if(m_cTEncTop.getViewId() == 1)
     590          {
     591            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*20)/100 );
     592          }
     593        }
     594        else if(m_iNumberOfViews == 3)
     595        {
     596          if(m_cTEncTop.getViewId() == 0)
     597          {
     598            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*66)/100 );
     599          }
     600          else if(m_cTEncTop.getViewId() == 1)
     601          {
     602            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
     603          }
     604          else if(m_cTEncTop.getViewId() == 2)
     605          {
     606            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
     607          }
     608        }
     609        else
     610        {
     611          m_cTEncTop.setTargetBitrate              ( m_targetBitrate );
     612        }
     613      }
     614    }
     615  }
     616#endif
    525617#endif
    526618  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
     
    664756}
    665757
    666 Void TAppEncTop::xInitLib()
     758Void TAppEncTop::xInitLib(Bool isFieldCoding)
    667759{
    668760#if H_MV
    669761  for(Int layer=0; layer<m_numberOfLayers; layer++)
    670762  {
    671     m_acTEncTopList[layer]->init( );
    672   }
    673 #else
    674   m_cTEncTop.init();
     763#if KWU_RC_MADPRED_E0227
     764    m_acTEncTopList[layer]->init( isFieldCoding, this );
     765#else
     766    m_acTEncTopList[layer]->init( isFieldCoding );
     767#endif
     768  }
     769#else
     770  m_cTEncTop.init( isFieldCoding );
    675771#endif
    676772}
     
    703799  xInitLibCfg();
    704800  xCreateLib();
    705   xInitLib();
     801  xInitLib(m_isField);
    706802 
    707803  // main encoder loop
     
    728824
    729825  // allocate original YUV buffer
     826  if( m_isField )
     827  {
     828    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     829  }
     830  else
     831  {
    730832  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     833  }
    731834 
    732835#if H_MV
     
    789892      }
    790893    }
     894
     895#if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ
     896    for(Int layer=0; layer < m_numberOfLayers; layer++ )
     897    {
     898      if(m_acTEncTopList[layer]->getUseRateCtrl()  && !m_acTEncTopList[layer]->getIsDepth())
     899      {
     900        m_acTEncTopList[layer]->getRateCtrl()->updateRCGOPStatus();
     901      }
     902    }
     903#endif
     904
    791905    gopSize = maxGopSize;
    792906  }
    793907  for(Int layer=0; layer < m_numberOfLayers; layer++ )
    794908  {
    795     m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() );
     909    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField );
    796910  }
    797911#else
     
    807921    m_iFrameRcvd++;
    808922
    809     bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     923    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    810924
    811925    Bool flush = 0;
     
    820934
    821935    // call encoding function for one frame
     936    if ( m_isField )
     937    {
     938      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
     939    }
     940    else
     941    {
    822942    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     943    }
    823944   
    824945    // write bistream to file if necessary
     
    830951  }
    831952
    832   m_cTEncTop.printSummary();
     953  m_cTEncTop.printSummary(m_isField);
    833954#endif
    834955
     
    9411062#endif
    9421063{
    943   Int i;
    944  
    945 #if H_MV
    946   if( iNumEncoded > 0 )
    947   {
    948     TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
    949 #else
    950   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    951   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    952 #endif
    953 
    954   for ( i = 0; i < iNumEncoded; i++ )
    955   {
    956     --iterPicYuvRec;
    957   }
    958  
    959   for ( i = 0; i < iNumEncoded; i++ )
    960   {
    961     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1064  if (m_isField)
     1065  {
     1066    //Reinterlace fields
     1067    Int i;
     1068#if H_MV
     1069    if( iNumEncoded > 0 )
     1070    {
     1071      TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     1072#else
     1073    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1074    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1075#endif
     1076
     1077    for ( i = 0; i < iNumEncoded; i++ )
     1078    {
     1079      --iterPicYuvRec;
     1080    }
     1081
     1082    for ( i = 0; i < iNumEncoded/2; i++ )
     1083    {
     1084      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1085      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1086
    9621087#if H_MV
    9631088      if (m_pchReconFileList[layerId])
    9641089      {
    965         m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    966       }
    967     }
    968   }
     1090        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1091      }
     1092    }
     1093  }
     1094
    9691095  if( ! accessUnits.empty() )
    9701096  {
     
    9721098    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
    9731099    {
     1100      const vector<UInt>& stats = writeAnnexB(bitstreamFile, *aUIter);
     1101      rateStatsAccum(*aUIter, stats);
     1102    }
     1103  }
     1104#else
     1105      if (m_pchReconFile)
     1106      {
     1107        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1108      }
     1109
     1110      const AccessUnit& auTop = *(iterBitstream++);
     1111      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1112      rateStatsAccum(auTop, statsTop);
     1113
     1114      const AccessUnit& auBottom = *(iterBitstream++);
     1115      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1116      rateStatsAccum(auBottom, statsBottom);
     1117    }
     1118#endif
     1119  }
     1120  else
     1121  {
     1122    Int i;
     1123#if H_MV
     1124    if( iNumEncoded > 0 )
     1125    {
     1126      TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     1127#else
     1128    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1129    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1130#endif
     1131
     1132    for ( i = 0; i < iNumEncoded; i++ )
     1133    {
     1134      --iterPicYuvRec;
     1135    }
     1136
     1137    for ( i = 0; i < iNumEncoded; i++ )
     1138    {
     1139      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1140#if H_MV
     1141      if (m_pchReconFileList[layerId])
     1142      {
     1143        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1144      }   
     1145    }
     1146  }
     1147  if( ! accessUnits.empty() )
     1148  {
     1149    list<AccessUnit>::iterator aUIter;
     1150    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
     1151    {
    9741152      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
    9751153      rateStatsAccum(*aUIter, stats);
     
    9771155  }
    9781156#else
    979     if (m_pchReconFile)
    980     {
    981       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    982     }
    983 
    984     const AccessUnit& au = *(iterBitstream++);
    985     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    986     rateStatsAccum(au, stats);
    987   }
    988 #endif
    989 }
    990 
     1157      if (m_pchReconFile)
     1158      {
     1159        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1160      }
     1161
     1162      const AccessUnit& au = *(iterBitstream++);
     1163      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1164      rateStatsAccum(au, stats);   
     1165    }
     1166#endif   
     1167  }
     1168}
     1169 
    9911170/**
    9921171 *
     
    11211300Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
    11221301{   
    1123 #if H_MV5
    11241302  vps.setScalabilityMaskFlag( m_scalabilityMask );
    1125 #else
    1126   vps.setScalabilityMask( m_scalabilityMask );
    1127 #endif
    11281303  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
    11291304  {
    11301305    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
    1131 #if H_MV5
    11321306    for( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
    1133 #else
    1134     for( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
    1135 #endif
    11361307
    11371308    {       
     
    11401311  }
    11411312
    1142 #if H_MV5
    11431313  Int maxViewId = xGetMax( m_viewId );
    11441314
     
    11531323
    11541324  assert( m_iNumberOfViews == vps.getNumViews() );
    1155 #endif
    11561325}
    11571326
     
    11801349
    11811350  // Max temporal id for inter layer reference pictures + presence flag
    1182 #if H_MV5
    11831351  Bool maxTidRefPresentFlag = false;
    1184 #endif
    11851352  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
    11861353    {
     
    12031370    }
    12041371    vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 );
    1205 #if H_MV5
    12061372    maxTidRefPresentFlag = maxTidRefPresentFlag || ( maxTid != 6 );   
    1207 #endif
    1208   }
    1209 
    1210 #if H_MV5
     1373  }
     1374
    12111375  vps.setMaxTidRefPresentFlag( maxTidRefPresentFlag );
    1212 #endif
    12131376  // Max one active ref layer flag
    12141377  Bool maxOneActiveRefLayerFlag = true; 
    1215 #if H_MV5
    12161378  for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; layerIdInVps++)
    1217 #else
    1218   for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++)
    1219 #endif
    12201379  {
    12211380    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ )
    12221381    {       
    1223 #if H_MV5
    12241382      GOPEntry ge =  m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ];
    1225 #else
    1226       GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ];
    1227 #endif
    12281383      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1);
    12291384    }           
     
    12331388 
    12341389 
    1235 #if H_MV5
    12361390  // All Ref layers active flag
    12371391  Bool allRefLayersActiveFlag = true;
     
    12491403  // Currently cross layer irap aligned is always true.   
    12501404  vps.setCrossLayerIrapAlignedFlag( true );
    1251 #endif
    12521405  vps.setRefLayers();
    12531406};
    12541407
    1255 #if H_MV5
    12561408GOPEntry* TAppEncTop::xGetGopEntry( Int layerIdInVps, Int poc )
    12571409{
     
    12681420  return geFound;
    12691421}
    1270 #endif
    12711422
    12721423Void TAppEncTop::xSetLayerIds( TComVPS& vps )
     
    13081459}
    13091460
    1310 #if H_MV5
    13111461
    13121462Void TAppEncTop::xSetRepFormat( TComVPS& vps )
     
    13331483  }
    13341484}
    1335 #endif
    13361485
    13371486Void TAppEncTop::xSetLayerSets( TComVPS& vps )
     
    13861535  }
    13871536}
    1388 #if H_MV5
    13891537
    13901538Void TAppEncTop::xSetVPSVUI( TComVPS& vps )
     
    14781626}
    14791627#endif
    1480 #endif
    14811628#if H_3D
    14821629Void TAppEncTop::xSetVPSExtension2( TComVPS& vps )
    14831630{
    1484 #if H_MV5
    14851631
    14861632  for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
    1487 #else
    1488   for ( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
    1489 #endif
    14901633  {
    14911634    Bool isDepth      = ( vps.getDepthId( layer ) == 1 ) ;
     
    15171660    vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag );         
    15181661#endif     
    1519 #if LGE_INTER_SDC_E0156
     1662#if H_3D_INTER_SDC
    15201663    vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag );
    15211664#endif
  • trunk/source/App/TAppEncoder/TAppEncTop.h

    r622 r655  
    5050#endif
    5151
     52#if KWU_RC_MADPRED_E0227
     53class TEncTop;
     54#endif
    5255//! \ingroup TAppEncoder
    5356//! \{
     
    9396  Void  xCreateLib        ();                               ///< create files & encoder class
    9497  Void  xInitLibCfg       ();                               ///< initialize internal variables
    95   Void  xInitLib          ();                               ///< initialize encoder class
     98  Void  xInitLib          (Bool isFieldCoding);             ///< initialize encoder class
    9699  Void  xDestroyLib       ();                               ///< destroy encoder class
    97100 
     
    121124  Void xSetLayerSets              ( TComVPS& vps );
    122125  Void xSetProfileTierLevel       ( TComVPS& vps );
    123 #if H_MV5
    124126  Void xSetRepFormat              ( TComVPS& vps );
    125127  Void xSetVPSVUI                 ( TComVPS& vps );
    126128  GOPEntry* xGetGopEntry( Int layerIdInVps, Int poc );
    127 #endif
    128129  Int  xGetMax( std::vector<Int>& vec);
    129130#endif
  • trunk/source/Lib/TAppCommon/TAppComCamPara.cpp

    r608 r655  
    615615{
    616616  UInt uiFoundLine = -1;
    617 #if H_3D_FIX_REN_WARNING
    618617  if ( !xGetCameraDataRow( iView, uiFrame, uiFoundLine ) && xIsIn( m_aiSortedBaseViews, iView ))
    619 #else 
    620   if ( !xGetCameraDataRow( iView, uiFrame, uiFoundLine ) )
    621 #endif
    622618  {
    623619    AOT( m_aadCameraParameters[ uiFoundLine ].size() < 6 );
     
    635631    Int  iDummy;
    636632
    637 #if H_3D_FIX_REN_WARNING
    638633    if( !xGetLeftRightView( iView, m_aiSortedBaseViews, iLeftView, iRightView, iDummy, iDummy ) ||
    639 #else
    640     if( !xGetLeftRightView( iView, m_aiViewsInCfgFile, iLeftView, iRightView, iDummy, iDummy ) ||
    641 #endif
    642634         xGetCameraDataRow( iLeftView,  uiFrame, uiLeftViewLine  )                             ||
    643635         xGetCameraDataRow( iRightView, uiFrame, uiRightViewLine )
    644636      )
    645637    {
    646 #if H_3D_FIX_REN_WARNING
    647638      std::cerr << "No left or no right base view next to view " << (Double)iView / m_dViewNumPrec << " for Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
    648 #else
    649       std::cerr << "No Left or no Right View next to View " << (Double)iView / m_dViewNumPrec << " for Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
    650 #endif
    651639      AOT(true);
    652640      exit( EXIT_FAILURE );
     
    13521340      }
    13531341    }
    1354 #if H_3D_FIX_REN_WARNING
     1342
    13551343    Bool bIgnoreFirst = true;     
    13561344    for( UInt uiERView = 0; uiERView < m_aiSynthViews.size() && !m_bSetupFromCoded; uiERView++ )
     
    13711359      std::cout << std::endl;
    13721360    }
    1373 #endif
    13741361
    13751362    Bool bInterpolateFirst = true;
     
    13901377        if ( bInterpolateFirst )
    13911378        {
    1392 #if H_3D_FIX_REN_WARNING                       
    13931379          std::cout << "Interpolating camera parameters      for virtual view(s): " ;
    1394 #else
    1395           std::cout << "Interpolating Camera Parameters for View(s) " ;
    1396 #endif
    13971380            bInterpolateFirst = false;
    13981381        }         
     
    14981481}
    14991482
    1500 #if H_3D_FIX_REN_WARNING
    15011483Bool
    15021484  TAppComCamPara::xIsIn( std::vector<Int>& rVec, Int iElem)
     
    15091491  return bFound;
    15101492}
    1511 #endif
    15121493
    15131494Int TAppComCamPara::getRelDistLeft( Int iSynthViewIdx, Int iLeftViewIdx, Int iRightViewIdx )
  • trunk/source/Lib/TAppCommon/TAppComCamPara.h

    r608 r655  
    125125  Bool  xGetLeftRightView         ( Int iView, std::vector<Int> aiSortedViews, Int& riLeftView, Int& riRightView, Int& riLeftSortedViewIdx, Int& riRightSortedViewIdx );
    126126  Void  xGetPrevAndNextBaseView   ( Int iSourceViewNum, Int iTargetViewNum, Int& riPrevBaseViewNum, Int& riNextBaseViewNum );
     127#if !KWU_RC_MADPRED_E0227
    127128  Void  xGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
    128129  Void  xGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
     130#endif
    129131  Void  xSetupBaseViewsFromCoded  ();
    130132  Void  xSetupBaseViews           ( Char* pchBaseViewNumbers, UInt uiNumBaseViews );
    131 #if H_3D_FIX_REN_WARNING
    132133  Bool  xIsIn                     ( std::vector<Int>& rVec, Int iNumber);
    133 #endif
    134 
    135134
    136135  // functions for getting and setting scales and offsets
     
    220219  Int**               getCodedScale             ()  { return m_aaiCodedScale;           }
    221220  Int**               getCodedOffset            ()  { return m_aaiCodedOffset;          }
     221
     222#if KWU_RC_MADPRED_E0227
     223  Void  xGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
     224  Void  xGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
     225#endif
    222226};
    223227
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r625 r655  
    6161#if H_MV
    6262#define NV_VERSION        "8.1"                 ///< Current software version
    63 #define HM_VERSION        "11.0"                ///<
     63#define HM_VERSION        "12.0"                ///<
    6464#else
    65 #define NV_VERSION        "11.0"                 ///< Current software version
     65#define NV_VERSION        "12.0"                 ///< Current software version
    6666#endif
    6767
     
    187187}
    188188
    189 #if H_MV5
    190189template <typename T>
    191190__inline T gCeilLog2( T val )
     
    196195  return ceilLog2;
    197196}
    198 #endif
    199197
    200198#define RemoveBitIncrement( exp ) ( exp >> ( g_bitDepthY - 8 ) )
  • trunk/source/Lib/TLibCommon/ContextTables.h

    r622 r655  
    112112#if H_3D_DIM_DMM
    113113#define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
    114 #if !SEC_DMM2_E0146_HHIFIX
    115 #define NUM_DMM2_DATA_CTX             1       ///< number of context models for DMM2 data
    116 #endif
    117114#define NUM_DMM3_DATA_CTX             1       ///< number of context models for DMM3 data
    118115#endif
     
    127124#endif
    128125
    129 #if LGE_INTER_SDC_E0156
     126#if H_3D_INTER_SDC
    130127#define NUM_INTER_SDC_FLAG_CTX        1      ///< number of context models for inter SDC flag
    131128#define NUM_INTER_SDC_SIGN_FLAG_CTX   1      ///< number of context models for sign of inter SDC residual
     
    390387#endif
    391388#if H_3D_DIM
    392 #if ZJU_DEPTH_INTRA_MODE_E0204
    393389static const UChar
    394390INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
     
    398394    {64, 0, CNU, CNU, 168, 109,   0, 0}
    399395};
    400 #else
    401 static const UChar
    402 INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
    403 {
    404   {0,  0,  64,   0, CNU,   0, CNU, 0},
    405   {0, 64,   0, CNU,   0, CNU,   0, 0},
    406   {64, 0, CNU,   0, CNU,   0,   0, 0}
    407 };
    408 #endif
     396
    409397static const UChar
    410398INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] =
     
    429417  { CNU },
    430418};
    431 #if !SEC_DMM2_E0146_HHIFIX
    432 static const UChar
    433 INIT_DMM2_DATA[3][NUM_DMM2_DATA_CTX] =
    434 {
    435   { CNU },
    436   { CNU },
    437   { CNU },
    438 };
    439 #endif
    440419static const UChar
    441420INIT_DMM3_DATA[3][NUM_DMM3_DATA_CTX] =
     
    473452#endif
    474453
    475 #if LGE_INTER_SDC_E0156
     454#if H_3D_INTER_SDC
    476455static const UChar
    477456INIT_INTER_SDC_FLAG[3][NUM_INTER_SDC_FLAG_CTX] =
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r622 r655  
    120120    m_dmmWedgeTabIdx[i] = NULL;
    121121  }
    122 #if !SEC_DMM2_E0146_HHIFIX
    123   m_dmm2DeltaEnd    = NULL;
    124 #endif
    125122  m_dmm3IntraTabIdx = NULL;
    126123#endif
     
    153150  m_pbICFlag             = NULL;
    154151#endif
    155 #if LGE_INTER_SDC_E0156
     152#if H_3D_INTER_SDC
    156153  m_pbInterSDCFlag       = NULL;
    157154  for( Int i = 0; i < 4; i++ )
     
    274271      m_dmmWedgeTabIdx[i]    = (UInt*)xMalloc(UInt, uiNumPartition);
    275272    }
    276 #if !SEC_DMM2_E0146_HHIFIX
    277     m_dmm2DeltaEnd    = (Int* )xMalloc(Int,  uiNumPartition);
    278 #endif
    279273    m_dmm3IntraTabIdx = (UInt*)xMalloc(UInt, uiNumPartition);
    280274#endif
     
    292286#endif
    293287#endif
    294 #if LGE_INTER_SDC_E0156
     288#if H_3D_INTER_SDC
    295289    m_pbInterSDCFlag     = (Bool*  )xMalloc(Bool,   uiNumPartition);
    296290    for( Int i = 0; i < 4; i++ )
     
    305299    m_acCUMvField[1].setNumPartition(uiNumPartition );
    306300  }
    307 #if LGE_INTER_SDC_E0156
     301#if H_3D_INTER_SDC
    308302  m_pucInterSDCMask     = (UChar*  )xMalloc(UChar,    g_uiMaxCUHeight*g_uiMaxCUWidth);
    309303#endif
     
    410404      if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; }
    411405    }
    412 #if !SEC_DMM2_E0146_HHIFIX
    413     if ( m_dmm2DeltaEnd    ) { xFree( m_dmm2DeltaEnd    ); m_dmm2DeltaEnd    = NULL; }
    414 #endif
    415406    if ( m_dmm3IntraTabIdx ) { xFree( m_dmm3IntraTabIdx ); m_dmm3IntraTabIdx = NULL; }
    416407#endif
     
    428419#endif
    429420#endif   
    430 #if LGE_INTER_SDC_E0156
     421#if H_3D_INTER_SDC
    431422    if ( m_pbInterSDCFlag     ) { xFree(m_pbInterSDCFlag);      m_pbInterSDCFlag    = NULL; }
    432423    for(Int i = 0; i < 4; i++ )
     
    436427#endif
    437428  }
    438 #if LGE_INTER_SDC_E0156
     429#if H_3D_INTER_SDC
    439430  if ( m_pucInterSDCMask     ) { xFree(m_pucInterSDCMask);      m_pucInterSDCMask    = NULL; }
    440431#endif
     
    575566    m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui];
    576567#endif
    577 #if LGE_INTER_SDC_E0156
     568#if H_3D_INTER_SDC
    578569    m_pbInterSDCFlag[ui] = pcFrom->m_pbInterSDCFlag[ui];
    579570#endif
     
    631622      memset( m_dmmWedgeTabIdx[i] + firstElement, 0,                      numElements * sizeof( *m_dmmWedgeTabIdx[i] ) );
    632623    }
    633 #if !SEC_DMM2_E0146_HHIFIX
    634     memset( m_dmm2DeltaEnd      + firstElement, 0,                        numElements * sizeof( *m_dmm2DeltaEnd    ) );
    635 #endif
    636624    memset( m_dmm3IntraTabIdx   + firstElement, 0,                        numElements * sizeof( *m_dmm3IntraTabIdx ) );
    637625#endif
     
    649637#endif
    650638#endif
    651 #if LGE_INTER_SDC_E0156
     639#if H_3D_INTER_SDC
    652640    memset( m_pbInterSDCFlag   + firstElement,     0,                    numElements * sizeof( *m_pbInterSDCFlag ) );
    653641    for( Int i = 0; i < 4; i++ )
     
    811799        m_dmmWedgeTabIdx[i] [ui] = 0;
    812800      }
    813 #if !SEC_DMM2_E0146_HHIFIX
    814       m_dmm2DeltaEnd    [ui] = 0;
    815 #endif
    816801      m_dmm3IntraTabIdx [ui] = 0;
    817802#endif
     
    822807#endif
    823808#endif
    824 #if LGE_INTER_SDC_E0156
     809#if H_3D_INTER_SDC
    825810      m_pbInterSDCFlag[ui] = false;
    826811      for( Int i = 0; i < 4; i++ )
     
    925910    memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition );
    926911  }
    927 #if !SEC_DMM2_E0146_HHIFIX
    928   memset( m_dmm2DeltaEnd   , 0, sizeof(Int ) * m_uiNumPartition );
    929 #endif
    930912  memset( m_dmm3IntraTabIdx, 0, sizeof(UInt) * m_uiNumPartition );
    931913#endif
     
    943925#endif
    944926#endif
    945 #if LGE_INTER_SDC_E0156
     927#if H_3D_INTER_SDC
    946928  memset( m_pbInterSDCFlag,           0, sizeof( Bool ) * m_uiNumPartition );
    947929  for( Int i = 0; i < 4; i++ )
     
    1010992        m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui];
    1011993      }
    1012 #if !SEC_DMM2_E0146_HHIFIX
    1013       m_dmm2DeltaEnd    [ui] = pcCU->m_dmm2DeltaEnd   [uiPartOffset+ui];
    1014 #endif
    1015994      m_dmm3IntraTabIdx [ui] = pcCU->m_dmm3IntraTabIdx[uiPartOffset+ui];
    1016995#endif
     
    10211000#endif
    10221001#endif
    1023 #if LGE_INTER_SDC_E0156
     1002#if H_3D_INTER_SDC
    10241003      m_pbInterSDCFlag      [ui] = pcCU->m_pbInterSDCFlag    [ uiPartOffset + ui ];
    10251004      for( Int i = 0; i < 4; i++ )
     
    11671146    m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart;
    11681147  }
    1169 #if !SEC_DMM2_E0146_HHIFIX
    1170   m_dmm2DeltaEnd    = pcCU->getDmm2DeltaEnd()    + uiPart;
    1171 #endif
    11721148  m_dmm3IntraTabIdx = pcCU->getDmm3IntraTabIdx() + uiPart;
    11731149#endif
     
    11851161#endif
    11861162#endif 
    1187 #if LGE_INTER_SDC_E0156
     1163#if H_3D_INTER_SDC
    11881164  m_pbInterSDCFlag          = pcCU->getInterSDCFlag()       + uiPart;
    11891165  for( Int i = 0; i < 4; i++ )
     
    13661342    memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition );
    13671343  }
    1368 #if !SEC_DMM2_E0146_HHIFIX
    1369   memcpy( m_dmm2DeltaEnd    + uiOffset, pcCU->getDmm2DeltaEnd()   , sizeof(Int ) * uiNumPartition );
    1370 #endif
    13711344  memcpy( m_dmm3IntraTabIdx + uiOffset, pcCU->getDmm3IntraTabIdx(), sizeof(UInt) * uiNumPartition );
    13721345#endif
     
    13841357#endif
    13851358#endif
    1386 #if LGE_INTER_SDC_E0156
     1359#if H_3D_INTER_SDC
    13871360  memcpy( m_pbInterSDCFlag  + uiOffset, pcCU->getInterSDCFlag(),      iSizeInBool  );
    13881361  for( Int i = 0; i < 4; i++ )
     
    14961469    memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition );
    14971470  }
    1498 #if !SEC_DMM2_E0146_HHIFIX
    1499   memcpy( rpcCU->getDmm2DeltaEnd()    + m_uiAbsIdxInLCU, m_dmm2DeltaEnd   , sizeof(Int ) * m_uiNumPartition );
    1500 #endif
    15011471  memcpy( rpcCU->getDmm3IntraTabIdx() + m_uiAbsIdxInLCU, m_dmm3IntraTabIdx, sizeof(UInt) * m_uiNumPartition );
    15021472#endif
     
    15141484#endif
    15151485#endif
    1516 #if LGE_INTER_SDC_E0156
     1486#if H_3D_INTER_SDC
    15171487  memcpy( rpcCU->getInterSDCFlag() + m_uiAbsIdxInLCU, m_pbInterSDCFlag,      iSizeInBool  );
    15181488  for( Int i = 0;i < 4; i++ )
     
    16121582    memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart );
    16131583  }
    1614 #if !SEC_DMM2_E0146_HHIFIX
    1615   memcpy( rpcCU->getDmm2DeltaEnd()    + uiPartOffset, m_dmm2DeltaEnd   , sizeof(Int ) * uiQNumPart );
    1616 #endif
    16171584  memcpy( rpcCU->getDmm3IntraTabIdx() + uiPartOffset, m_dmm3IntraTabIdx, sizeof(UInt) * uiQNumPart );
    16181585#endif
     
    16301597#endif
    16311598#endif
    1632 #if LGE_INTER_SDC_E0156
     1599#if H_3D_INTER_SDC
    16331600  memcpy( rpcCU->getInterSDCFlag() + uiPartOffset, m_pbInterSDCFlag,      iSizeInBool  );
    16341601  for( Int i = 0; i < 4; i++ )
     
    23512318#endif
    23522319
    2353 #if LGE_INTER_SDC_E0156
     2320#if H_3D_INTER_SDC
    23542321Void TComDataCU::setInterSDCFlagSubParts ( Bool bInterSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    23552322{
     
    26892656  // check prediction mode
    26902657  UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); 
    2691 #if LGE_SDC_REMOVE_DC_E0158
    26922658  if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) )
    2693 #else
    2694   if( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) )
    2695 #endif
    26962659    return true;
    26972660 
     
    35693532    UInt uiPartIdxCenter;
    35703533    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );   
     3534#if H_3D_FCO
     3535    TComPic * pcTexturePic = m_pcSlice->getTexturePic();
     3536    TComDataCU *pcTextureCU = 0;
     3537    if ( pcTexturePic )
     3538        pcTextureCU = pcTexturePic->getCU( getAddr() );
     3539#else
    35713540    TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() );
     3541#endif
    35723542 
     3543#if H_3D_FCO
     3544    if ( pcTextureCU && pcTexturePic->getReconMark() && !pcTextureCU->isIntra( uiPartIdxCenter ) )
     3545#else
    35733546    if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdxCenter ) )
     3547#endif
    35743548    {
    35753549      pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     
    48304804
    48314805  // use coldir.
    4832 #if H_MV5
    48334806  TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
    4834 #else
    4835 #if H_MV
    4836   TComPic *pColPic; 
    4837   if (getSlice()->getAltCollocatedIndicationFlag() )
    4838   {
    4839     pColPic = getSlice()->getPicFromRefPicSetInterLayer( getSlice()->getActiveMotionPredRefLayerId( getSlice()->getCollocatedRefLayerIdx() ));
    4840   }
    4841   else
    4842   {
    4843     pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); 
    4844   } 
    4845 #else
    4846   TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
    4847 #endif
    4848 #endif
    48494807  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
    48504808  if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE)
     
    49964954                                        + ( iPartWidth/m_pcPic->getMinCUWidth()  )/2];
    49974955}
    4998 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    4999 Void TComDataCU::compressMV(int scale)
     4956#if H_3D
     4957Void TComDataCU::compressMV(Int scale)
    50004958#else
    50014959Void TComDataCU::compressMV()
    50024960#endif
    50034961{
    5004 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
     4962#if H_3D
    50054963  Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize;
    50064964#else
     
    55095467    xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
    55105468
    5511     ///*** Derive bottom right neighbour position ***
    5512 #if !SEC_SIMPLIFIED_NBDV_E0142
    5513     Int iLCUIdxRBNb  = -1;   
    5514     Int iPartIdxRBNb = -1;
    5515     xDeriveRightBottomNbIdx(iLCUIdxRBNb, iPartIdxRBNb );
    5516 #endif
    5517 
    55185469    ///*** Search temporal candidate pictures for disparity vector ***
    55195470    const Int iNumCandPics = getPic()->getNumDdvCandPics();
     
    55335484      }
    55345485
    5535 #if !SEC_SIMPLIFIED_NBDV_E0142
    5536       // Check BR and Center       
    5537       for(Int curPosition = 0; curPosition < 2; curPosition++)
    5538       {
    5539 #endif
    5540         Bool bCheck = false;
    5541 #if !SEC_SIMPLIFIED_NBDV_E0142
    5542         if ( curPosition == 0 && iLCUIdxRBNb >= 0 )
    5543 #if MTK_NBDV_TN_FIX_E0172
    5544           bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb,  cColMv, iTargetViewIdx, iTStartViewIdx);
     5486      Bool bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
     5487
     5488      if( bCheck )
     5489      {
     5490        clipMv(cColMv);
     5491        pDInfo->m_acNBDV = cColMv;
     5492        pDInfo->m_aVIdxCan  = iTargetViewIdx;
     5493
     5494#if H_3D_NBDV_REF
     5495        TComPic* picDepth = NULL;   
     5496#if H_3D_FCO_VSP_DONBDV_E0163
     5497        picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     5498        if ( picDepth->getPicYuvRec() != NULL  ) 
     5499        {
     5500          cColMv.setZero();
     5501        }
     5502        else // Go back with virtual depth
     5503        {
     5504          picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
     5505        }
     5506
     5507        assert(picDepth != NULL);
    55455508#else
    5546           bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb,  cColMv, iTargetViewIdx, iTStartViewIdx);
    5547 #endif
    5548 
    5549         if (curPosition == 1 )
    5550 #endif
    5551 #if MTK_NBDV_TN_FIX_E0172
    5552           bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
    5553 #else
    5554           bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
    5555 #endif
    5556 
    5557         if( bCheck )
    5558         {
    5559           clipMv(cColMv);
    5560           pDInfo->m_acNBDV = cColMv;
    5561           pDInfo->m_aVIdxCan  = iTargetViewIdx;
    5562 
    5563 #if H_3D_NBDV_REF
    5564           TComPic* picDepth = NULL;         
    5565           picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
    5566           assert(picDepth != NULL);
    5567           if (picDepth && bDepthRefine)
    5568             estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv );
    5569 
    5570           pDInfo->m_acDoNBDV  = cColMv;
     5509        picDepth = getSlice()->getIvPic( true, iTargetViewIdx );
     5510        assert(picDepth != NULL);
     5511#endif
     5512        if (picDepth && bDepthRefine)
     5513          estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv );
     5514
     5515        pDInfo->m_acDoNBDV  = cColMv;
    55715516#endif //H_3D_NBDV_REF
    5572           return true;
    5573         }
    5574 #if !SEC_SIMPLIFIED_NBDV_E0142
    5575       }
    5576 #endif
     5517        return true;
     5518      }
    55775519    }
    55785520  }
     
    55875529  if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
    55885530#if H_3D_NBDV_REF
    5589   , bDepthRefine
     5531    , bDepthRefine
    55905532#endif
    55915533    ) )
     
    55995541    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
    56005542#if H_3D_NBDV_REF
    5601   , bDepthRefine
    5602 #endif
    5603     ) )
     5543      , bDepthRefine
     5544#endif
     5545      ) )
    56045546      return true;
    56055547  }
    5606 
    5607 #if !SEC_SIMPLIFIED_NBDV_E0142
    5608   //// ******* Get disparity from above right block ******* /////
    5609   pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true);
    5610   if(pcTmpCU != NULL )
    5611   {
    5612     bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
    5613     if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVERIGHT
    5614 #if H_3D_NBDV_REF
    5615   , bDepthRefine
    5616 #endif
    5617     ) )
    5618       return true;
    5619   }
    5620 
    5621   //// ******* Get disparity from below left block ******* /////
    5622   pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true);
    5623   if( pcTmpCU != NULL )
    5624   {
    5625     bCheckMcpDv = true;
    5626     if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFTBELOW
    5627 #if H_3D_NBDV_REF
    5628   , bDepthRefine
    5629 #endif
    5630     ) )
    5631       return true;
    5632   }
    5633 
    5634   //// ******* Get disparity from above left block ******* /////
    5635   pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true);
    5636   assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
    5637 
    5638   if( pcTmpCU != NULL )
    5639   {
    5640     bCheckMcpDv = (( getAddr() - pcTmpCU->getAddr() ) <= 1);
    5641     if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVELEFT
    5642 #if H_3D_NBDV_REF
    5643   , bDepthRefine
    5644 #endif
    5645     ) )
    5646       return true;
    5647   }
    5648 #endif
    56495548
    56505549  //// ******* Search MCP blocks ******* /////
     
    56625561          pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
    56635562#if H_3D_NBDV_REF
     5563#if H_3D_FCO_VSP_DONBDV_E0163
     5564          TComPic* picDepth  = NULL;
     5565
     5566          picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     5567          if ( picDepth->getPicYuvRec() != NULL ) 
     5568          {
     5569            cDispVec.setZero();
     5570          }
     5571          else // Go back with virtual depth
     5572          {
     5573            picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
     5574          }
     5575
     5576          assert(picDepth != NULL);
     5577#else
    56645578          TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
    56655579          assert(picDepth!=NULL);
     5580#endif
    56665581
    56675582          if (picDepth && bDepthRefine)
     
    56795594  TComMv defaultDV(0, 0);
    56805595  pDInfo->m_acNBDV = defaultDV;
    5681 #if NBDV_DEFAULT_VIEWIDX_BUGFIX
     5596
    56825597  Int valid = 0;
    56835598  Int viewIndex = 0;
     
    57075622#if H_3D_NBDV_REF
    57085623    TComPic* picDepth = NULL;
     5624#if H_3D_FCO_VSP_DONBDV_E0163
     5625    picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     5626    if ( picDepth->getPicYuvRec() != NULL ) 
     5627    {
     5628      defaultDV.setZero();
     5629    }
     5630    else // Go back with virtual depth
     5631    {
     5632      picDepth = getSlice()->getIvPic( true, viewIndex );
     5633    }
     5634
     5635    assert(picDepth != NULL);
     5636#else
    57095637    picDepth = getSlice()->getIvPic( true, viewIndex );
    57105638    assert(picDepth!=NULL);
    5711 
     5639#endif
    57125640    if (picDepth && bDepthRefine)
    57135641    {
     
    57175645#endif
    57185646  }
    5719 #else
    5720   pDInfo->m_aVIdxCan = 0;
    5721 #if H_3D_NBDV_REF
    5722   TComPic* picDepth = NULL;
    5723   picDepth = getSlice()->getIvPic( true, 0 );
    5724   assert(picDepth!=NULL);
    5725 
    5726   if (picDepth && bDepthRefine)
    5727   {
    5728     estimateDVFromDM(0, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view
    5729   }
    5730   pDInfo->m_acDoNBDV = defaultDV;
    5731 #endif
    5732 #endif
    57335647  return false;
    57345648}
     
    57405654  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
    57415655 
    5742 #if NTT_DoNBDV_VECTOR_CLIP_E0141
    57435656  Int depthStartPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((mv->getHor()+2)>>2));
    57445657  Int depthStartPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2));
    57455658  Int depthEndPosX   = Clip3(0,   iPictureWidth - 1,  iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2));
    57465659  Int depthEndPosY   = Clip3(0,   iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
    5747 #else
    5748   Int depthStartPosX = Clip3(0,   iPictureWidth - iBlkWidth,  iBlkX + ((mv->getHor()+2)>>2));
    5749   Int depthStartPosY = Clip3(0,   iPictureHeight- iBlkHeight,  iBlkY + ((mv->getVer()+2)>>2));
    5750   Int depthEndPosX   = Clip3(0,   iPictureWidth - 1,  iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2));
    5751   Int depthEndPosY   = Clip3(0,   iPictureHeight - 1,  iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
    5752 #endif
    57535660
    57545661  Pel* depthTL  = pcBaseViewDepthPicYuv->getLumaAddr();
     
    58125719          TComPic* picDepth = NULL;
    58135720          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());         
     5721#if H_3D_FCO_VSP_DONBDV_E0163
     5722          picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
     5723          if ( picDepth->getPicYuvRec() != NULL ) 
     5724          {
     5725            cMvPred.setZero();
     5726          }
     5727          else// Go back with virtual depth
     5728          {
     5729            picDepth = getSlice()->getIvPic (true, refViewIdx );
     5730          }
     5731          assert(picDepth != NULL);
     5732#else
    58145733          picDepth   = getSlice()->getIvPic (true, refViewIdx );
    58155734          assert(picDepth != NULL);
    5816 
     5735#endif
    58175736          UInt uiPartIdx = 0;   //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV
    58185737          UInt uiPartAddr = 0;  //QC: confirmed
     
    58295748          assert( uiMvpDvPos < IDV_CANDS );
    58305749          paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() );
    5831           //Notes from QC: DvMCP is implemented in a way that doesnE½t carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design.
     5750          //Notes from QC: DvMCP is implemented in a way that doesnot carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design.
    58325751          paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId();
    58335752          paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true;
     
    59015820}
    59025821#endif
    5903 #if MTK_NBDV_TN_FIX_E0172
     5822
    59045823Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
    5905 #else
    5906 Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
    5907 #endif
    59085824{
    59095825
     
    59215837    if(pColCU->getSlice()->isInterB())
    59225838    {
    5923         eColRefPicList = RefPicList(ilist);
     5839      eColRefPicList = RefPicList(ilist);
    59245840    }
    59255841
     
    59395855    else
    59405856    {
    5941 #if MTK_NBDV_TN_FIX_E0172
    59425857      if(getPic()->isTempIVRefValid(currCandPic, ilist,  iColRefIdx))
    59435858      {
    5944 #endif
    5945       rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx);
    5946       rcMv.setIDVFlag(0);
    5947       iTargetViewIdx  = iColRefViewIdx ;
    5948       iStartViewIdx   = iColViewIdx   ;
    5949       return true;   
    5950 #if MTK_NBDV_TN_FIX_E0172
    5951       }
    5952 #endif
     5859        rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx);
     5860        rcMv.setIDVFlag(0);
     5861        iTargetViewIdx  = iColRefViewIdx ;
     5862        iStartViewIdx   = iColViewIdx   ;
     5863        return true;   
     5864      }
    59535865    }
    59545866  }
     
    59575869}
    59585870#endif
    5959 #if  MTK_FAST_TEXTURE_ENCODING_E0173
     5871#if  H_3D_FAST_TEXTURE_ENCODING
    59605872Void
    59615873TComDataCU::getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD)
     
    62426154  for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; }
    62436155}
    6244 #if !SEC_DMM2_E0146_HHIFIX
    6245 Void  TComDataCU::setDmm2DeltaEndSubParts( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth )
    6246 {
    6247   UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
    6248   for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm2DeltaEnd[uiAbsPartIdx+ui] = iDelta; }
    6249 }
    6250 #endif
    62516156Void  TComDataCU::setDmm3IntraTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth )
    62526157{
  • trunk/source/Lib/TLibCommon/TComDataCU.h

    r622 r655  
    208208#if H_3D_DIM_DMM
    209209  UInt*         m_dmmWedgeTabIdx[DMM_NUM_TYPE];
    210 #if !SEC_DMM2_E0146_HHIFIX
    211   Int*          m_dmm2DeltaEnd;
    212 #endif
    213210  UInt*         m_dmm3IntraTabIdx;
    214211#endif
     
    225222#endif
    226223#endif
    227 #if LGE_INTER_SDC_E0156
     224#if H_3D_INTER_SDC
    228225  Bool*         m_pbInterSDCFlag;
    229226  Int*          m_apSegmentInterDCOffset[4];
     
    489486#endif
    490487  );
    491 #if MTK_NBDV_TN_FIX_E0172
    492488  Bool          xGetColDisMV      ( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
    493 #else
    494   Bool          xGetColDisMV      ( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
    495 #endif
    496489  Bool          getDisMvpCandNBDV ( DisInfo* pDInfo
    497490#if H_3D_NBDV_REF
     
    505498#endif //H_3D_NBDV_REF
    506499#endif
    507 #if  MTK_FAST_TEXTURE_ENCODING_E0173
     500#if  H_3D_FAST_TEXTURE_ENCODING
    508501  Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
    509502#endif
     
    545538  Void  setDmmWedgeTabIdxSubParts     ( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth );
    546539
    547 #if !SEC_DMM2_E0146_HHIFIX
    548   Int*  getDmm2DeltaEnd               ()                      { return m_dmm2DeltaEnd;        }
    549   Int   getDmm2DeltaEnd               ( UInt uiIdx )          { return m_dmm2DeltaEnd[uiIdx]; }
    550   Void  setDmm2DeltaEnd               ( UInt uiIdx, Int iD )  { m_dmm2DeltaEnd[uiIdx] = iD;   }
    551   Void  setDmm2DeltaEndSubParts       ( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth );
    552 #endif
    553 
    554540  UInt* getDmm3IntraTabIdx            ()                      { return m_dmm3IntraTabIdx;        }
    555541  UInt  getDmm3IntraTabIdx            ( UInt uiIdx )          { return m_dmm3IntraTabIdx[uiIdx]; }
     
    588574#endif
    589575#endif
    590 #if LGE_INTER_SDC_E0156
     576#if H_3D_INTER_SDC
    591577  Bool*         getInterSDCFlag     ()                        { return m_pbInterSDCFlag;               }
    592578  Bool          getInterSDCFlag     ( UInt uiIdx )            { return m_pbInterSDCFlag[uiIdx];        }
     
    626612  Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }
    627613  Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }
    628 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    629   Void          compressMV            (int scale);
     614#if H_3D
     615  Void          compressMV            ( Int scale );
    630616#else           
    631617  Void          compressMV            ();
  • trunk/source/Lib/TLibCommon/TComMv.h

    r622 r655  
    4040
    4141#include "CommonDef.h"
     42#include <cstdlib>
    4243
    4344//! \ingroup TLibCommon
  • trunk/source/Lib/TLibCommon/TComPattern.h

    r608 r655  
    102102  Bool              m_bICFlag;
    103103#endif
    104 #if LGE_INTER_SDC_E0156
     104#if H_3D_INTER_SDC
    105105  Bool              m_bSDCMRSADFlag;
    106106#endif
     
    119119  Void  setICFlag( Bool bICFlag ) { m_bICFlag = bICFlag; }
    120120#endif
    121 #if LGE_INTER_SDC_E0156
     121#if H_3D_INTER_SDC
    122122  Bool  getSDCMRSADFlag()         { return m_bSDCMRSADFlag; }
    123123  Void  setSDCMRSADFlag( Bool bSDCMRSADFlag )    { m_bSDCMRSADFlag = bSDCMRSADFlag; }
  • trunk/source/Lib/TLibCommon/TComPic.cpp

    r608 r655  
    5050, m_bUsedByCurr                           (false)
    5151, m_bIsLongTerm                           (false)
    52 , m_bIsUsedAsLongTerm                     (false)
    5352, m_apcPicSym                             (NULL)
    5453, m_pcPicYuvPred                          (NULL)
     
    118117  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
    119118
     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
    120130  return;
    121131}
     
    146156  deleteSEIs(m_SEIs);
    147157}
    148 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    149 Void TComPic::compressMotion(int scale)
     158#if H_3D
     159Void TComPic::compressMotion(Int scale)
    150160#else
    151161Void TComPic::compressMotion()
     
    156166  {
    157167    TComDataCU* pcCU = pPicSym->getCU(uiCUAddr);
    158 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
     168#if H_3D
    159169    pcCU->compressMV(scale);
    160170#else
     
    661671  return numDdvCandPics;
    662672}
    663 #endif
    664 #if MTK_NBDV_TN_FIX_E0172
     673
    665674Void TComPic::checkTemporalIVRef()
    666675{
     
    716725  return m_abTIVRINCurrRL[currCandPic][iColRefDir][iColRefIdx];
    717726}
    718 #endif
    719 #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182
     727
    720728Void TComPic::checkTextureRef(  )
    721729{
    722730  TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
    723731  TComPic* pcTextPic = pcCurrSlice->getTexturePic();
     732#if H_3D_FCO
     733  if ( pcTextPic )
     734  {
     735#endif
     736
    724737  TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
    725738
     
    743756
    744757  }
     758#if H_3D_FCO
     759  }
     760#endif
     761
    745762}
    746763
  • trunk/source/Lib/TLibCommon/TComPic.h

    r608 r655  
    6161  Bool                  m_bUsedByCurr;            //  Used by current picture
    6262  Bool                  m_bIsLongTerm;            //  IS long term picture
    63   Bool                  m_bIsUsedAsLongTerm;      //  long term picture is used as reference before
    6463  TComPicSym*           m_apcPicSym;              //  Symbol
    6564 
     
    8382  Window                m_defaultDisplayWindow;
    8483
     84  bool                  m_isTop;
     85  bool                  m_isField;
     86 
    8587  std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink;
    8688
     
    104106  RefPicList  m_eRapRefList;
    105107  Int         m_iNumDdvCandPics;
    106 #endif
    107 #if MTK_NBDV_TN_FIX_E0172
    108108  Bool        m_abTIVRINCurrRL  [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
    109 #endif
    110 #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182 
    111109  Int         m_aiTexToDepRef  [2][MAX_NUM_REF];
    112110#endif
     
    186184  Void          setNumReorderPics(Int i, UInt tlayer) { m_numReorderPics[tlayer] = i;    }
    187185  Int           getNumReorderPics(UInt tlayer)        { return m_numReorderPics[tlayer]; }
    188 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    189   Void          compressMotion(int scale);
     186#if H_3D
     187  Void          compressMotion(Int scale);
    190188#else   
    191189  Void          compressMotion();
     
    212210  TComPicYuv*   getYuvPicBufferForIndependentBoundaryProcessing()             {return m_pNDBFilterYuvTmp;}
    213211  std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter      (Int sliceID) { return m_vSliceCUDataLink[sliceID];}
     212
     213
     214  /* field coding parameters*/
     215
     216   Void              setTopField(bool b)                  {m_isTop = b;}
     217   bool              isTopField()                         {return m_isTop;}
     218   Void              setField(bool b)                     {m_isField = b;}
     219   bool              isField()                            {return m_isField;}
    214220
    215221#if H_MV
     
    224230  UInt          getRapRefIdx()                         {return m_uiRapRefIdx;       }
    225231  RefPicList    getRapRefList()                        {return m_eRapRefList;       }
    226 #endif
    227 #if MTK_NBDV_TN_FIX_E0172
    228   Void      checkTemporalIVRef();
    229   Bool      isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
    230 #endif
    231 #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182
    232   Void      checkTextureRef(  );
    233   Int       isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
     232  Void          checkTemporalIVRef();
     233  Bool          isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
     234  Void          checkTextureRef(  );
     235  Int           isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
    234236#endif
    235237  /** transfer ownership of seis to this picture */
  • trunk/source/Lib/TLibCommon/TComPicSym.cpp

    r608 r655  
    6161,m_uiNumAllocatedSlice (0)
    6262,m_apcTComDataCU (NULL)
    63 ,m_iTileBoundaryIndependenceIdr (0)
    6463,m_iNumColumnsMinus1 (0)
    6564,m_iNumRowsMinus1(0)
  • trunk/source/Lib/TLibCommon/TComPicSym.h

    r608 r655  
    9999  UInt          m_uiNumAllocatedSlice;
    100100  TComDataCU**  m_apcTComDataCU;        ///< array of CU data
    101  
    102   Int           m_iTileBoundaryIndependenceIdr;
     101   
    103102  Int           m_iNumColumnsMinus1;
    104103  Int           m_iNumRowsMinus1;
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r622 r655  
    3939#include "TComPrediction.h"
    4040
    41 #if SHARP_ILLUCOMP_REFINE_E0046
    42 #define IC_REG_COST_SHIFT 7
    43 #define IC_CONST_SHIFT 5
    44 #define IC_SHIFT_DIFF 12
    45 #endif
    46 
    4741//! \ingroup TLibCommon
    4842//! \{
     
    6963  if (m_pDepthBlock != NULL)
    7064      free(m_pDepthBlock);
    71 #if NTT_VSP_COMMON_E0207_E0208
    7265  m_cYuvDepthOnVsp.destroy();
    73 #endif
    7466#endif
    7567
     
    129121    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    130122#endif
    131 #if NTT_VSP_COMMON_E0207_E0208
     123#if H_3D_VSP
    132124    m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    133125#endif
     
    143135  }
    144136#if H_3D_IC
    145 #if SHARP_ILLUCOMP_REFINE_E0046
    146137  m_uiaShift[0] = 0;
    147138  for( Int i = 1; i < 64; i++ )
     
    149140    m_uiaShift[i] = ( (1 << 15) + i/2 ) / i;
    150141  }
    151 #else
    152   for( Int i = 1; i < 64; i++ )
    153   {
    154     m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i;
    155   }
    156 #endif
    157142#endif
    158143}
     
    456441        dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]);
    457442      } break;
    458 #if !SEC_DMM2_E0146_HHIFIX
    459     case( DMM2_IDX ):
    460       {
    461         UInt uiTabIdx = 0;
    462         if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); }
    463         else
    464         {
    465           uiTabIdx = xPredWedgeFromIntra( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm2DeltaEnd( uiAbsPartIdx ) );
    466           pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) );
    467         }
    468         dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]);
    469       } break;
    470 #endif
    471443    case( DMM3_IDX ):
    472444      {
     
    709681#endif
    710682      , bICFlag );
    711 #if SHARP_ILLUCOMP_REFINE_E0046
    712683    bICFlag = bICFlag && (iWidth > 8);
    713 #endif
    714684    xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    715685#if H_3D_ARP
     
    731701  // Get depth reference
    732702  Int       depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
     703#if H_3D_FCO_VSP_DONBDV_E0163
     704  TComPic* pRefPicBaseDepth = 0;
     705  Bool     bIsCurrDepthCoded = false;
     706  pRefPicBaseDepth  = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() );
     707  if ( pRefPicBaseDepth->getPicYuvRec() != NULL  )
     708  {
     709    bIsCurrDepthCoded = true;
     710  }
     711  else
     712  {
     713    pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
     714  }
     715#else
    733716  TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
     717#endif
    734718  assert(pRefPicBaseDepth != NULL);
    735719  TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
     
    752736  pcCU->clipMv(cDv);
    753737
    754 #if NTT_VSP_COMMON_E0207_E0208
     738#if H_3D_FCO_VSP_DONBDV_E0163
     739  if ( bIsCurrDepthCoded )
     740  {
     741      cDv.setZero();
     742  }
     743#endif
    755744  // fetch virtual depth map
    756 #if NTT_VSP_VECTOR_CLIP_E0208
    757745  pcBaseViewDepthPicYuv->extendPicBorder();
    758 #endif
    759746  xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp );
    760747  // sub-PU based compensation
    761748  xPredInterLumaBlkFromDM   ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    762749  xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    763 #else
    764   UInt uiAbsPartIdx = pcCU->getZorderIdxInCU();
    765   Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
    766   Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
    767   xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    768   xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    769 #endif
    770 
    771750}
    772751#endif
     
    984963  if ( yFrac == 0 )
    985964  {
    986 #if MTK_CLIPPING_ALIGN_IC_E0168
     965#if H_3D_IC
    987966    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi || bICFlag
    988967#else
     
    996975  else if ( xFrac == 0 )
    997976  {
    998 #if MTK_CLIPPING_ALIGN_IC_E0168
     977#if H_3D_IC
    999978    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag
    1000979#else
     
    1019998#endif
    1020999      );
    1021 #if MTK_CLIPPING_ALIGN_IC_E0168
     1000#if H_3D_IC
    10221001    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi || bICFlag
    10231002#else
     
    10331012  if( bICFlag )
    10341013  {
    1035 #if SHARP_ILLUCOMP_REFINE_E0046
    10361014    Int a, b, i, j;
    10371015    const Int iShift = IC_CONST_SHIFT;
    10381016
    10391017    xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA );
    1040 #else
    1041     Int a, b, iShift, i, j;
    1042 
    1043     xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_LUMA );
    1044 #endif
    10451018
    10461019
     
    10491022      for ( j = 0; j < width; j++ )
    10501023      {
    1051 #if !MTK_CLIPPING_ALIGN_IC_E0168
    1052         if( bi )
    1053         {
    1054           Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
    1055           dst[j] = ( ( a*dst[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1 << iIFshift ) - IF_INTERNAL_OFFS;
    1056         }
    1057         else
    1058 #endif
    10591024          dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
    10601025      }
    10611026      dst += dstStride;
    10621027    }
    1063 #if MTK_CLIPPING_ALIGN_IC_E0168
     1028
    10641029    if(bi)
    10651030    {
     
    10761041      }
    10771042    }
    1078 #endif
    10791043  }
    10801044#endif
     
    11271091  if ( yFrac == 0 )
    11281092  {
    1129 #if MTK_CLIPPING_ALIGN_IC_E0168
     1093#if H_3D_IC
    11301094    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    11311095#else
     
    11361100#endif
    11371101    );   
    1138 #if MTK_CLIPPING_ALIGN_IC_E0168
     1102#if H_3D_IC
    11391103    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    11401104#else
     
    11481112  else if ( xFrac == 0 )
    11491113  {
    1150 #if MTK_CLIPPING_ALIGN_IC_E0168
     1114#if H_3D_IC
    11511115    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    11521116#else
     
    11571121#endif
    11581122    );
    1159 #if MTK_CLIPPING_ALIGN_IC_E0168
     1123#if H_3D_IC
    11601124    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    11611125#else
     
    11741138#endif 
    11751139      );
    1176 #if MTK_CLIPPING_ALIGN_IC_E0168
     1140#if H_3D_IC
    11771141    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    11781142#else
     
    11891153#endif
    11901154      );
    1191 #if MTK_CLIPPING_ALIGN_IC_E0168
     1155#if H_3D_IC
    11921156    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    11931157#else
     
    12031167  if( bICFlag )
    12041168  {
    1205 #if SHARP_ILLUCOMP_REFINE_E0046
    12061169    Int a, b, i, j;
    12071170    const Int iShift = IC_CONST_SHIFT;
    12081171    xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb
    1209 #else
    1210     Int a, b, iShift, i, j;
    1211     xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_U ); // Cb
    1212 #endif
    12131172    for ( i = 0; i < cxHeight; i++ )
    12141173    {
    12151174      for ( j = 0; j < cxWidth; j++ )
    12161175      {
    1217 #if !MTK_CLIPPING_ALIGN_IC_E0168
    1218         if( bi )
    1219         {
    1220           Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
    1221           dstCb[j] = ( ( a*dstCb[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS;
    1222         }
    1223         else
    1224 #endif
    12251176          dstCb[j] = Clip3(  0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b );
    12261177      }
    12271178      dstCb += dstStride;
    12281179    }
    1229 #if SHARP_ILLUCOMP_REFINE_E0046
    12301180    xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr
    1231 #else
    1232     xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_V ); // Cr
    1233 #endif
    12341181    for ( i = 0; i < cxHeight; i++ )
    12351182    {
    12361183      for ( j = 0; j < cxWidth; j++ )
    12371184      {
    1238 #if !MTK_CLIPPING_ALIGN_IC_E0168
    1239         if( bi )
    1240         {
    1241           Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
    1242           dstCr[j] = ( ( a*dstCr[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS;
    1243         }
    1244         else
    1245 #endif
    12461185          dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b );
    12471186      }
    12481187      dstCr += dstStride;
    12491188    }
    1250 #if MTK_CLIPPING_ALIGN_IC_E0168
     1189
    12511190    if(bi)
    12521191    {
     
    12681207      }
    12691208    }
    1270 #endif
    12711209  }
    12721210#endif
     
    13231261  Int k, l, bottomLeft, topRight;
    13241262  Int horPred;
    1325   Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
     1263  Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
    13261264  UInt blkSize = width;
    13271265  UInt offset2D = width;
     
    14171355}
    14181356
    1419 #if !SHARP_ILLUCOMP_REFINE_E0046
    1420 /** Function for counting leading number of zeros/ones
    1421  * \param x input value
    1422  \ This function counts leading number of zeros for positive numbers and
    1423  \ leading number of ones for negative numbers. This can be implemented in
    1424  \ single instructure cycle on many processors.
    1425  */
    1426 
    1427 Short CountLeadingZerosOnes (Short x)
    1428 {
    1429   Short clz;
    1430   Short i;
    1431 
    1432   if(x == 0)
    1433   {
    1434     clz = 0;
    1435   }
    1436   else
    1437   {
    1438     if (x == -1)
    1439     {
    1440       clz = 15;
    1441     }
    1442     else
    1443     {
    1444       if(x < 0)
    1445       {
    1446         x = ~x;
    1447       }
    1448       clz = 15;
    1449       for(i = 0;i < 15;++i)
    1450       {
    1451         if(x)
    1452         {
    1453           clz --;
    1454         }
    1455         x = x >> 1;
    1456       }
    1457     }
    1458   }
    1459   return clz;
    1460 }
    1461 #endif
    14621357
    14631358/** Function for deriving LM illumination compensation.
    14641359 */
    1465 #if SHARP_ILLUCOMP_REFINE_E0046
    14661360Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType )
    1467 #else
    1468 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, TextType eType )
    1469 #endif
    14701361{
    14711362  TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec();
     
    14951386
    14961387  Int x = 0, y = 0, xx = 0, xy = 0;
    1497 #if SHARP_ILLUCOMP_REFINE_E0046
    14981388  Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12);
    1499 #endif
    15001389
    15011390  if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 )
     
    15191408    }
    15201409
    1521 #if SHARP_ILLUCOMP_REFINE_E0046
    15221410    for( j = 0; j < uiWidth; j+=2 )
    1523 #else
    1524     for( j = 0; j < uiWidth; j++ )
    1525 #endif
    15261411    {
    15271412      x += pRef[j];
    15281413      y += pRec[j];
    1529 #if SHARP_ILLUCOMP_REFINE_E0046
    15301414      xx += (pRef[j] * pRef[j])>>precShift;
    15311415      xy += (pRef[j] * pRec[j])>>precShift;
    1532 #else
    1533       xx += pRef[j] * pRef[j];
    1534       xy += pRef[j] * pRec[j];
    1535 #endif
    1536     }
    1537 #if SHARP_ILLUCOMP_REFINE_E0046
     1416    }
    15381417    iCountShift += g_aucConvertToBit[ uiWidth ] + 1;
    1539 #else
    1540     iCountShift += g_aucConvertToBit[ uiWidth ] + 2;
    1541 #endif
    15421418  }
    15431419
     
    15631439    }
    15641440
    1565 #if SHARP_ILLUCOMP_REFINE_E0046
    15661441    for( i = 0; i < uiHeight; i+=2 )
    1567 #else
    1568     for( i = 0; i < uiHeight; i++ )
    1569 #endif
    15701442    {
    15711443      x += pRef[0];
    15721444      y += pRec[0];
    1573 #if SHARP_ILLUCOMP_REFINE_E0046
     1445
    15741446      xx += (pRef[0] * pRef[0])>>precShift;
    15751447      xy += (pRef[0] * pRec[0])>>precShift;
     
    15771449      pRef += iRefStride*2;
    15781450      pRec += iRecStride*2;
    1579 #else
    1580       xx += pRef[0] * pRef[0];
    1581       xy += pRef[0] * pRec[0];
    1582 
    1583       pRef += iRefStride;
    1584       pRec += iRecStride;
    1585 #endif
    1586     }
    1587 #if SHARP_ILLUCOMP_REFINE_E0046
     1451    }
    15881452    iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 );
    1589 #else
    1590     iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 );
    1591 #endif
    1592   }
    1593 
    1594 #if SHARP_ILLUCOMP_REFINE_E0046
     1453  }
     1454
    15951455  xy += xx >> IC_REG_COST_SHIFT;
    15961456  xx += xx >> IC_REG_COST_SHIFT;
     
    15991459  const Int iShift = IC_CONST_SHIFT;
    16001460  {
    1601 #else
    1602   Int iTempShift = ( ( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC ) + g_aucConvertToBit[ uiWidth ] + 3 - 15;
    1603 
    1604   if( iTempShift > 0 )
    1605   {
    1606     x  = ( x +  ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1607     y  = ( y +  ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1608     xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1609     xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1610     iCountShift -= iTempShift;
    1611   }
    1612 
    1613   iShift = 13;
    1614 
    1615   if( iCountShift == 0 )
    1616   {
    1617     a = 1;
    1618     b = 0;
    1619     iShift = 0;
    1620   }
    1621   else
    1622   {
    1623     Int a1 = ( xy << iCountShift ) - y * x;
    1624     Int a2 = ( xx << iCountShift ) - x * x;             
    1625 #endif
    16261461    {
    16271462      const Int iShiftA2 = 6;
    1628 #if !SHARP_ILLUCOMP_REFINE_E0046
    1629       const Int iShiftA1 = 15;
    1630 #endif
    16311463      const Int iAccuracyShift = 15;
    16321464
     
    16361468      Int a2s = a2;
    16371469
    1638 #if SHARP_ILLUCOMP_REFINE_E0046
    16391470      a1 = Clip3(0, 2*a2, a1);
    16401471      iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2;
    16411472      iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF;
    1642 #else
    1643       iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1;
    1644       iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; 
    1645 #endif
    16461473
    16471474      if( iScaleShiftA1 < 0 )
     
    16621489      a1s = a1 >> iScaleShiftA1;
    16631490
    1664 #if SHARP_ILLUCOMP_REFINE_E0046
    16651491      a = a1s * m_uiaShift[ a2s ];
    16661492      a = a >> iScaleShiftA;
    1667 #else
    1668       if (a2s >= 1)
    1669       {
    1670         a = a1s * m_uiaShift[ a2s - 1];
    1671       }
    1672       else
    1673       {
    1674         a = 0;
    1675       }
    1676 
    1677       if( iScaleShiftA < 0 )
    1678       {
    1679         a = a << -iScaleShiftA;
    1680       }
    1681       else
    1682       {
    1683         a = a >> iScaleShiftA;
    1684       }
    1685 
    1686       a = Clip3( -( 1 << 15 ), ( 1 << 15 ) - 1, a );
    1687 
    1688       Int minA = -(1 << (6));
    1689       Int maxA = (1 << 6) - 1;
    1690       if( a <= maxA && a >= minA )
    1691       {
    1692         // do nothing
    1693       }
    1694       else
    1695       {
    1696         Short n = CountLeadingZerosOnes( a );
    1697         a = a >> (9-n);
    1698         iShift -= (9-n);
    1699       }
    1700 #endif
    17011493      b = (  y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
    17021494    }
     
    17061498
    17071499#if H_3D_VSP
    1708 
    1709 #if NTT_VSP_COMMON_E0207_E0208
    17101500// not fully support iRatioTxtPerDepth* != 1
    17111501Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
     
    17151505
    17161506  Int refDepStride = picRefDepth->getStride();
    1717 
    1718 #if NTT_VSP_VECTOR_CLIP_E0208
    17191507
    17201508  Int refDepOffset  = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride;
     
    17361524  refDepth += refDepOffset;
    17371525
    1738 #else // NTT_VSP_VECTOR_CLIP_E0208
    1739 
    1740   Int widthDepth = picRefDepth->getWidth();
    1741   Int heightDepth = picRefDepth->getHeight();
    1742   Int posX, posY;
    1743   cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture
    1744   posX /= ratioTxtPerDepthX; // texture position -> depth postion
    1745   posY /= ratioTxtPerDepthY;
    1746  
    1747   posX = Clip3(0, widthDepth-width,   posX + ((mv->getHor()+2)>>2));
    1748   posY = Clip3(0, heightDepth-height, posY + ((mv->getVer()+2)>>2));
    1749  
    1750   Pel *refDepth  = picRefDepth->getLumaAddr() + posX + posY * refDepStride;
    1751 
    1752 #endif // NTT_VSP_VECTOR_CLIP_E0208
    1753 
    17541526  Int depStride = yuvDepth->getStride();
    17551527  Pel *depth = yuvDepth->getLumaAddr();
    1756 
    1757 #if NTT_VSP_ADAPTIVE_SPLIT_E0207
    17581528
    17591529  if( width<8 || height<8 )
     
    18941664  }
    18951665
    1896 #else // NTT_VSP_ADAPTIVE_SPLIT_E0207
    1897 
    1898   Int rightOffset = nTxtPerDepthX - 1;
    1899   Int depStrideBlock = depStride * nTxtPerDepthY;
    1900   Int refDepStrideBlock = refDepStride * nTxtPerDepthY;
    1901   Pel *refDepthTop = refDepth;
    1902   Pel *refDepthBot = refDepthTop + (nTxtPerDepthY-1)*refDepStride;
    1903 
    1904   for( Int y=0; y<height; y+= nTxtPerDepthY )
    1905   {
    1906     for( Int x=0; x<width; x+=nTxtPerDepthX )
    1907     {
    1908       Pel maxDepth = refDepthTop[x] > refDepthBot[x] ? refDepthTop[x] : refDepthBot[x];
    1909 
    1910       if( maxDepth < refDepthTop[x+rightOffset] )
    1911       {
    1912         maxDepth = refDepthTop[x+rightOffset];
    1913       }
    1914       if( maxDepth < refDepthBot[x+rightOffset] )
    1915       {
    1916         maxDepth = refDepthBot[x+rightOffset];
    1917       }
    1918 
    1919       depth[x] = maxDepth;
    1920 
    1921     }
    1922     refDepthTop += refDepStrideBlock;
    1923     refDepthBot += refDepStrideBlock;
    1924     depth       += depStrideBlock;
    1925   }
    1926 
    1927 #endif // NTT_VSP_ADAPTIVE_SPLIT_E0207
     1666
    19281667}
    19291668
     
    19431682  Pel *dst    = yuvDst->getLumaAddr(partAddr);
    19441683  Pel *depth  = yuvDepth->getLumaAddr();
    1945  
    1946 #if !(NTT_VSP_DC_BUGFIX_E0208)
    1947   Int widthLuma = picRef->getWidth();
    1948   Int posX, posY;
    1949   cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture
    1950 #endif
    19511684
    19521685#if H_3D_VSP_BLOCKSIZE == 1
     
    20211754      Int xFrac = disparity & 0x3;
    20221755
    2023 #if NTT_VSP_DC_BUGFIX_E0208
    2024 
    20251756      dv.setHor( disparity );
    20261757      cu->clipMv( dv );
     
    20381769      assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
    20391770      m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );
    2040 
    2041 #else // NTT_VSP_DC_BUGFIX_E0208
    2042 
    2043       for( Int j=0; j < nTxtPerDepthX; j++ )
    2044       {
    2045         Int refOffset = xTxt+j + (disparity >> 2);
    2046 #if H_3D_VSP_CONSTRAINED
    2047         if(refOffset<minRelativePos || refOffset>maxRelativePos)
    2048         {
    2049           xFrac = 0;
    2050         }
    2051         refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2052 #endif
    2053         Int absX  = posX + refOffset;
    2054 
    2055         if (xFrac == 0)
    2056         {
    2057           absX = Clip3(0, widthLuma-1, absX);
    2058         }
    2059         else
    2060         {
    2061           absX = Clip3(4, widthLuma-5, absX);
    2062         }
    2063 
    2064         refOffset = absX - posX;
    2065         assert( ref[refOffset] >= 0 && ref[refOffset] <= 255 );
    2066        
    2067         m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi );
    2068       }
    2069 
    2070 #endif // NTT_VSP_DC_BUGFIX_E0208
    2071 
    20721771    }
    20731772    ref   += refStrideBlock;
     
    21011800  Pel *depth  = yuvDepth->getLumaAddr();
    21021801
    2103 #if !(NTT_VSP_DC_BUGFIX_E0208)
    2104   Int widthChroma = picRef->getWidth() >> 1;
    2105   Int posX, posY;
    2106   cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture
    2107   posX >>= 1;
    2108   posY >>= 1;
    2109 #endif
    2110  
    21111802#if H_3D_VSP_BLOCKSIZE == 1
    21121803#if H_3D_VSP_CONSTRAINED
     
    21731864      Int xFrac = disparity & 0x7;
    21741865     
    2175 #if NTT_VSP_DC_BUGFIX_E0208
    2176 
    21771866      dv.setHor( disparity );
    21781867      cu->clipMv( dv );
     
    21931882      m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );
    21941883      m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );
    2195 
    2196 #else // NTT_VSP_DC_BUGFIX_E0208
    2197      
    2198       for( Int j=0; j < nTxtPerDepthX; j++ )
    2199       {
    2200         Int refOffset = xTxt+j + (disparity >> 3);
    2201 #if H_3D_VSP_CONSTRAINED
    2202         if(refOffset<minRelativePos || refOffset>maxRelativePos)
    2203         {
    2204           xFrac = 0;
    2205         }
    2206         refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2207 #endif
    2208         Int absX  = posX + refOffset;
    2209 
    2210         if (xFrac == 0)
    2211         {
    2212           absX = Clip3(0, widthChroma-1, absX);
    2213         }
    2214         else
    2215         {
    2216           absX = Clip3(4, widthChroma-5, absX);
    2217         }
    2218 
    2219         refOffset = absX - posX;
    2220         assert( refCb[refOffset] >= 0 && refCb[refOffset] <= 255 );
    2221         assert( refCr[refOffset] >= 0 && refCr[refOffset] <= 255 );
    2222 
    2223         m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi );
    2224         m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi );
    2225       }
    2226 
    2227 #endif // NTT_VSP_DC_BUGFIX_E0208
    22281884    }
    22291885    refCb += refStrideBlock;
     
    22331889    depth += depStrideBlock;
    22341890  }
    2235 
    2236 }
    2237 #else // NTT_VSP_COMMON_E0207_E0208
    2238 
    2239 // Input:
    2240 // refPic: Ref picture. Full picture, with padding
    2241 // posX, posY:     PU position, texture
    2242 // sizeX, sizeY: PU size
    2243 // partAddr: z-order index
    2244 // dv: disparity vector. derived from neighboring blocks
    2245 //
    2246 // Output: dstPic, PU predictor 64x64
    2247 Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv* dv, UInt partAddr,Int posX, Int posY
    2248                                             , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi )
    2249 {
    2250   Int widthLuma;
    2251   Int heightLuma;
    2252 
    2253   if (isDepth)
    2254   {
    2255     widthLuma   =  pPicBaseDepth->getWidth();
    2256     heightLuma  =  pPicBaseDepth->getHeight();
    2257   }
    2258   else
    2259   {
    2260     widthLuma   =  refPic->getWidth();
    2261     heightLuma  =  refPic->getHeight();
    2262   }
    2263 
    2264 #if H_3D_VSP_BLOCKSIZE != 1
    2265   Int widthDepth  = pPicBaseDepth->getWidth();
    2266   Int heightDepth = pPicBaseDepth->getHeight();
    2267 #endif
    2268 
    2269 #if H_3D_VSP_CONSTRAINED
    2270   Int widthDepth  = pPicBaseDepth->getWidth();
    2271   Int heightDepth = pPicBaseDepth->getHeight();
    2272 #endif
    2273 
    2274   Int nTxtPerDepthX = widthLuma  / ( pPicBaseDepth->getWidth() );  // texture pixel # per depth pixel
    2275   Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() );
    2276 
    2277   Int refStride = refPic->getStride();
    2278   Int dstStride = dstPic->getStride();
    2279   Int depStride =  pPicBaseDepth->getStride();
    2280   Int depthPosX = Clip3(0,   widthLuma - sizeX,  (posX/nTxtPerDepthX) + ((dv->getHor()+2)>>2));
    2281   Int depthPosY = Clip3(0,   heightLuma- sizeY,  (posY/nTxtPerDepthY) + ((dv->getVer()+2)>>2));
    2282   Pel *ref    = refPic->getLumaAddr() + posX + posY * refStride;
    2283   Pel *dst    = dstPic->getLumaAddr(partAddr);
    2284   Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;
    2285 
    2286 #if H_3D_VSP_BLOCKSIZE != 1
    2287 #if H_3D_VSP_BLOCKSIZE == 2
    2288   Int  dW = sizeX>>1;
    2289   Int  dH = sizeY>>1;
    2290 #endif
    2291 #if H_3D_VSP_BLOCKSIZE == 4
    2292   Int  dW = sizeX>>2;
    2293   Int  dH = sizeY>>2;
    2294 #endif
    2295   {
    2296     Pel* depthi = depth;
    2297     for (Int j = 0; j < dH; j++)
    2298     {
    2299       for (Int i = 0; i < dW; i++)
    2300       {
    2301         Pel* depthTmp;
    2302 #if H_3D_VSP_BLOCKSIZE == 2
    2303         if (depthPosX + (i<<1) < widthDepth)
    2304           depthTmp = depthi + (i << 1);
    2305         else
    2306           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2307 #endif
    2308 #if H_3D_VSP_BLOCKSIZE == 4
    2309         if (depthPosX + (i<<2) < widthDepth)
    2310           depthTmp = depthi + (i << 2);
    2311         else
    2312           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2313 #endif
    2314         Int maxV = 0;
    2315         for (Int blockj = 0; blockj < H_3D_VSP_BLOCKSIZE; blockj+=(H_3D_VSP_BLOCKSIZE-1))
    2316         {
    2317           Int iX = 0;
    2318           for (Int blocki = 0; blocki < H_3D_VSP_BLOCKSIZE; blocki+=(H_3D_VSP_BLOCKSIZE-1))
    2319           {
    2320             if (maxV < depthTmp[iX])
    2321               maxV = depthTmp[iX];
    2322 #if H_3D_VSP_BLOCKSIZE == 2
    2323             if (depthPosX + (i<<1) + blocki < widthDepth - 1)
    2324 #else // H_3D_VSP_BLOCKSIZE == 4
    2325             if (depthPosX + (i<<2) + blocki < widthDepth - 1)
    2326 #endif
    2327               iX = (H_3D_VSP_BLOCKSIZE-1);
    2328           }
    2329 #if H_3D_VSP_BLOCKSIZE == 2
    2330           if (depthPosY + (j<<1) + blockj < heightDepth - 1)
    2331 #else // H_3D_VSP_BLOCKSIZE == 4
    2332           if (depthPosY + (j<<2) + blockj < heightDepth - 1)
    2333 #endif
    2334             depthTmp += depStride * (H_3D_VSP_BLOCKSIZE-1);
    2335         }
    2336         m_pDepthBlock[i+j*dW] = maxV;
    2337       } // end of i < dW
    2338 #if H_3D_VSP_BLOCKSIZE == 2
    2339       if (depthPosY + ((j+1)<<1) < heightDepth)
    2340         depthi += (depStride << 1);
    2341       else
    2342         depthi  = depth + (heightDepth-depthPosY-1)*depStride;
    2343 #endif
    2344 #if H_3D_VSP_BLOCKSIZE == 4
    2345       if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
    2346         depthi += (depStride << 2);
    2347       else
    2348         depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
    2349 #endif
    2350     }
    2351   }
    2352 #endif // H_3D_VSP_BLOCKSIZE != 1
    2353 
    2354 #if H_3D_VSP_BLOCKSIZE == 1
    2355 #if H_3D_VSP_CONSTRAINED
    2356   //get LUT based horizontal reference range
    2357   Int range = xGetConstrainedSize(sizeX, sizeY);
    2358 
    2359   // The minimum depth value
    2360   Int minRelativePos = MAX_INT;
    2361   Int maxRelativePos = MIN_INT;
    2362 
    2363   Pel* depthTemp, *depthInitial=depth;
    2364   for (Int yTxt = 0; yTxt < sizeY; yTxt++)
    2365   {
    2366     for (Int xTxt = 0; xTxt < sizeX; xTxt++)
    2367     {
    2368       if (depthPosX+xTxt < widthDepth)
    2369         depthTemp = depthInitial + xTxt;
    2370       else
    2371         depthTemp = depthInitial + (widthDepth - depthPosX - 1);
    2372 
    2373       Int disparity = pShiftLUT[ *depthTemp ]; // << iShiftPrec;
    2374       Int disparityInt = disparity >> 2;
    2375 
    2376       if( disparity <= 0)
    2377       {
    2378         if (minRelativePos > disparityInt+xTxt)
    2379             minRelativePos = disparityInt+xTxt;
    2380       }
    2381       else
    2382       {
    2383         if (maxRelativePos < disparityInt+xTxt)
    2384             maxRelativePos = disparityInt+xTxt;
    2385       }
    2386     }
    2387     if (depthPosY+yTxt < heightDepth)
    2388       depthInitial = depthInitial + depStride;
    2389   }
    2390 
    2391   Int disparity_tmp = pShiftLUT[ *depth ]; // << iShiftPrec;
    2392   if (disparity_tmp <= 0)
    2393     maxRelativePos = minRelativePos + range -1 ;
    2394   else
    2395     minRelativePos = maxRelativePos - range +1 ;
    2396 #endif
    2397 #endif // H_3D_VSP_BLOCKSIZE == 1
    2398 
    2399 #if H_3D_VSP_BLOCKSIZE != 1
    2400   Int yDepth = 0;
    2401 #endif
    2402   for ( Int yTxt = 0; yTxt < sizeY; yTxt += nTxtPerDepthY )
    2403   {
    2404     for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth++ )
    2405     {
    2406       Pel repDepth = 0; // to store the depth value used for warping
    2407 #if H_3D_VSP_BLOCKSIZE == 1
    2408       repDepth = depth[xDepth];
    2409 #endif
    2410 #if H_3D_VSP_BLOCKSIZE == 2
    2411       repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW];
    2412 #endif
    2413 #if H_3D_VSP_BLOCKSIZE == 4
    2414       repDepth = m_pDepthBlock[(xTxt>>2) + (yTxt>>2)*dW];
    2415 #endif
    2416 
    2417       assert( repDepth >= 0 && repDepth <= 255 );
    2418       Int disparity = pShiftLUT[ repDepth ]; // remove << iShiftPrec ??
    2419       Int refOffset = xTxt + (disparity >> 2);
    2420       Int xFrac = disparity & 0x3;
    2421 #if H_3D_VSP_CONSTRAINED
    2422       if(refOffset<minRelativePos || refOffset>maxRelativePos)
    2423         xFrac = 0;
    2424       refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2425 #endif
    2426       Int absX  = posX + refOffset;
    2427 
    2428       if (xFrac == 0)
    2429         absX = Clip3(0, widthLuma-1, absX);
    2430       else
    2431         absX = Clip3(4, widthLuma-5, absX);
    2432 
    2433       refOffset = absX - posX;
    2434 
    2435       assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
    2436       m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi );
    2437     }
    2438     ref   += refStride*nTxtPerDepthY;
    2439     dst   += dstStride*nTxtPerDepthY;
    2440     depth += depStride;
    2441 #if H_3D_VSP_BLOCKSIZE != 1
    2442     yDepth++;
    2443 #endif
    2444 
    2445   }
    2446 }
    2447 
    2448 Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv*dv, UInt partAddr, Int posX, Int posY
    2449                                                , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi)
    2450 {
    2451   Int refStride = refPic->getCStride();
    2452   Int dstStride = dstPic->getCStride();
    2453   Int depStride = pPicBaseDepth->getStride();
    2454 
    2455   Int widthChroma, heightChroma;
    2456   if( isDepth)
    2457   {
    2458      widthChroma   = pPicBaseDepth->getWidth()>>1;
    2459      heightChroma  = pPicBaseDepth->getHeight()>>1;
    2460   }
    2461   else
    2462   {
    2463      widthChroma   = refPic->getWidth()>>1;
    2464      heightChroma  = refPic->getHeight()>>1;
    2465   }
    2466 
    2467   // Below is only for Texture chroma component
    2468 
    2469   Int widthDepth  = pPicBaseDepth->getWidth();
    2470   Int heightDepth = pPicBaseDepth->getHeight();
    2471 
    2472   Int nTxtPerDepthX, nTxtPerDepthY;  // Number of texture samples per one depth sample
    2473   Int nDepthPerTxtX, nDepthPerTxtY;  // Number of depth samples per one texture sample
    2474 
    2475   Int depthPosX;  // Starting position in depth image
    2476   Int depthPosY;
    2477 
    2478   if ( widthChroma > widthDepth )
    2479   {
    2480     nTxtPerDepthX = widthChroma / widthDepth;
    2481     nDepthPerTxtX = 1;
    2482     depthPosX = posX / nTxtPerDepthX + ((dv->getHor()+2)>>2);
    2483   }
    2484   else
    2485   {
    2486     nTxtPerDepthX = 1;
    2487     nDepthPerTxtX = widthDepth / widthChroma;
    2488     depthPosX = posX * nDepthPerTxtX + ((dv->getHor()+2)>>2);
    2489   }
    2490   depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX);
    2491   if ( heightChroma > heightDepth )
    2492   {
    2493     nTxtPerDepthY = heightChroma / heightDepth;
    2494     nDepthPerTxtY = 1;
    2495     depthPosY = posY / nTxtPerDepthY + ((dv->getVer()+2)>>2);
    2496   }
    2497   else
    2498   {
    2499     nTxtPerDepthY = 1;
    2500     nDepthPerTxtY = heightDepth / heightChroma;
    2501     depthPosY = posY * nDepthPerTxtY + ((dv->getVer()+2)>>2);
    2502   }
    2503   depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY);
    2504 
    2505   Pel *refCb  = refPic->getCbAddr() + posX + posY * refStride;
    2506   Pel *refCr  = refPic->getCrAddr() + posX + posY * refStride;
    2507   Pel *dstCb  = dstPic->getCbAddr(partAddr);
    2508   Pel *dstCr  = dstPic->getCrAddr(partAddr);
    2509   Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;  // move the pointer to the current depth pixel position
    2510 
    2511   Int refStrideBlock = refStride * nTxtPerDepthY;
    2512   Int dstStrideBlock = dstStride * nTxtPerDepthY;
    2513   Int depStrideBlock = depStride * nDepthPerTxtY;
    2514 
    2515   if ( widthChroma > widthDepth ) // We assume
    2516   {
    2517     assert( heightChroma > heightDepth );
    2518     printf("This branch should never been reached.\n");
    2519     exit(0);
    2520   }
    2521   else
    2522   {
    2523 #if H_3D_VSP_BLOCKSIZE == 1
    2524   Int  dW = sizeX;
    2525   Int  dH = sizeY;
    2526   Int  sW = 2; // search window size
    2527   Int  sH = 2;
    2528 #endif
    2529 #if H_3D_VSP_BLOCKSIZE == 2
    2530   Int  dW = sizeX;
    2531   Int  dH = sizeY;
    2532   Int  sW = 2; // search window size
    2533   Int  sH = 2;
    2534 #endif
    2535 #if H_3D_VSP_BLOCKSIZE == 4
    2536   Int  dW = sizeX>>1;
    2537   Int  dH = sizeY>>1;
    2538   Int  sW = 4; // search window size
    2539   Int  sH = 4;
    2540 #endif
    2541 
    2542   {
    2543     Pel* depthi = depth;
    2544     for (Int j = 0; j < dH; j++)
    2545     {
    2546       for (Int i = 0; i < dW; i++)
    2547       {
    2548         Pel* depthTmp;
    2549 #if H_3D_VSP_BLOCKSIZE == 1
    2550         depthTmp = depthi + (i << 1);
    2551 #endif
    2552 #if H_3D_VSP_BLOCKSIZE == 2
    2553         if (depthPosX + (i<<1) < widthDepth)
    2554           depthTmp = depthi + (i << 1);
    2555         else
    2556           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2557 #endif
    2558 #if H_3D_VSP_BLOCKSIZE == 4
    2559         if (depthPosX + (i<<2) < widthDepth)
    2560           depthTmp = depthi + (i << 2);
    2561         else
    2562           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2563 #endif
    2564         Int maxV = 0;
    2565         for (Int blockj = 0; blockj < sH; blockj+=(sH-1))
    2566         {
    2567           Int iX = 0;
    2568           for (Int blocki = 0; blocki < sW; blocki+=(sW-1))
    2569           {
    2570             if (maxV < depthTmp[iX])
    2571               maxV = depthTmp[iX];
    2572             if (depthPosX + i*sW + blocki < widthDepth - 1)
    2573                 iX = (sW-1);
    2574           }
    2575           if (depthPosY + j*sH + blockj < heightDepth - 1)
    2576                 depthTmp += depStride * (sH-1);
    2577         }
    2578         m_pDepthBlock[i+j*dW] = maxV;
    2579       } // end of i < dW
    2580 #if H_3D_VSP_BLOCKSIZE == 1
    2581       if (depthPosY + ((j+1)<<1) < heightDepth)
    2582         depthi += (depStride << 1);
    2583       else
    2584         depthi  = depth + (heightDepth-1)*depStride;
    2585 #endif
    2586 #if H_3D_VSP_BLOCKSIZE == 2
    2587       if (depthPosY + ((j+1)<<1) < heightDepth)
    2588         depthi += (depStride << 1);
    2589       else
    2590         depthi  = depth + (heightDepth-depthPosY-1)*depStride;
    2591 #endif
    2592 #if H_3D_VSP_BLOCKSIZE == 4
    2593       if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
    2594         depthi += (depStride << 2);
    2595       else
    2596         depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
    2597 #endif
    2598     }
    2599   }
    2600 
    2601 
    2602 #if H_3D_VSP_BLOCKSIZE == 1
    2603 #if H_3D_VSP_CONSTRAINED
    2604   //get LUT based horizontal reference range
    2605   Int range = xGetConstrainedSize(sizeX, sizeY, false);
    2606 
    2607   // The minimum depth value
    2608   Int minRelativePos = MAX_INT;
    2609   Int maxRelativePos = MIN_INT;
    2610 
    2611   Int depthTmp;
    2612   for (Int yTxt=0; yTxt<sizeY; yTxt++)
    2613   {
    2614     for (Int xTxt=0; xTxt<sizeX; xTxt++)
    2615     {
    2616       depthTmp = m_pDepthBlock[xTxt+yTxt*dW];
    2617       Int disparity = pShiftLUT[ depthTmp ]; // << iShiftPrec;
    2618       Int disparityInt = disparity >> 3;//in chroma resolution
    2619 
    2620       if (disparityInt < 0)
    2621       {
    2622         if (minRelativePos > disparityInt+xTxt)
    2623             minRelativePos = disparityInt+xTxt;
    2624       }
    2625       else
    2626       {
    2627         if (maxRelativePos < disparityInt+xTxt)
    2628             maxRelativePos = disparityInt+xTxt;
    2629       }
    2630     }
    2631   }
    2632 
    2633   depthTmp = m_pDepthBlock[0];
    2634   Int disparity_tmp = pShiftLUT[ depthTmp ]; // << iShiftPrec;
    2635   if ( disparity_tmp < 0 )
    2636     maxRelativePos = minRelativePos + range - 1;
    2637   else
    2638     minRelativePos = maxRelativePos - range + 1;
    2639 
    2640 #endif // H_3D_VSP_CONSTRAINED
    2641 #endif // H_3D_VSP_BLOCKSIZE == 1
    2642 
    2643     // (sizeX, sizeY) is Chroma block size
    2644     for ( Int yTxt = 0, yDepth = 0; yTxt < sizeY; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY )
    2645     {
    2646       for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX )
    2647       {
    2648         Pel repDepth = 0; // to store the depth value used for warping
    2649 #if H_3D_VSP_BLOCKSIZE == 1
    2650         repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW];
    2651 #endif
    2652 #if H_3D_VSP_BLOCKSIZE == 2
    2653         repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW];
    2654 #endif
    2655 #if H_3D_VSP_BLOCKSIZE == 4
    2656         repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW];
    2657 #endif
    2658 
    2659       // calculate the offset in the reference picture
    2660         Int disparity = pShiftLUT[ repDepth ]; // Remove << iShiftPrec;
    2661         Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image
    2662         Int xFrac = disparity & 0x7;
    2663 #if H_3D_VSP_CONSTRAINED
    2664         if(refOffset < minRelativePos || refOffset > maxRelativePos)
    2665           xFrac = 0;
    2666         refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2667 #endif
    2668         Int absX  = posX + refOffset;
    2669 
    2670         if (xFrac == 0)
    2671           absX = Clip3(0, widthChroma-1, absX);
    2672         else
    2673           absX = Clip3(4, widthChroma-5, absX);
    2674 
    2675         refOffset = absX - posX;
    2676 
    2677         assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 );
    2678         assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 );
    2679         m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi);
    2680         m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi);
    2681       }
    2682       refCb += refStrideBlock;
    2683       refCr += refStrideBlock;
    2684       dstCb += dstStrideBlock;
    2685       dstCr += dstStrideBlock;
    2686       depth += depStrideBlock;
    2687     }
    2688   }
    2689 
    2690 }
    2691 
    2692 #endif // NTT_VSP_COMMON_E0207_E0208
     1891}
     1892
    26931893
    26941894#if H_3D_VSP_CONSTRAINED
     
    27681968
    27691969#if H_3D_DIM_DMM
    2770 #if !SEC_DMM2_E0146_HHIFIX
    2771 UInt TComPrediction::xPredWedgeFromIntra( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd )
    2772 {
    2773   UInt uiThisBlockSize = uiWidth;
    2774 
    2775   TComDataCU* pcTempCU;
    2776   UInt        uiTempPartIdx;
    2777   // 1st: try continue above wedgelet
    2778   pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    2779   if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) )
    2780   {
    2781     UInt dimType =  getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) );
    2782     if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType )
    2783     {
    2784       // get offset between current and reference block
    2785       UInt uiOffsetX = 0, uiOffsetY = 0;
    2786       xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
    2787 
    2788       // get reference wedgelet
    2789       WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])];
    2790       TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) );
    2791 
    2792       // find wedgelet, if direction is suitable for continue wedge
    2793       if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) )
    2794       {
    2795         UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    2796         pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd );
    2797         return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    2798       }
    2799     }
    2800   }
    2801 
    2802   // 2nd: try continue left wedglelet
    2803   pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    2804   if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) )
    2805   {
    2806     UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) );
    2807     if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType )
    2808     {
    2809       // get offset between current and reference block
    2810       UInt uiOffsetX = 0, uiOffsetY = 0;
    2811       xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
    2812 
    2813       // get reference wedgelet
    2814       WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])];
    2815       TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) );
    2816 
    2817       // find wedgelet, if direction is suitable for continue wedge
    2818       if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) )
    2819       {
    2820         UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    2821         pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd );
    2822         return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    2823       }
    2824     }
    2825   }
    2826 
    2827   // 3rd: (default) make wedglet from intra dir and max slope point
    2828   Int iSlopeX = 0, iSlopeY = 0;
    2829   UInt uiStartPosX = 0, uiStartPosY = 0;
    2830   if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) )
    2831   {
    2832     UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    2833     xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd );
    2834     return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    2835   }
    2836 
    2837   return 0;
    2838 }
    2839 #endif
    2840 
    28411970UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx )
    28421971{
     
    28471976  Int           uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255;
    28481977
    2849 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    28501978  assert( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 );
    28511979  return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx);
    2852 #else
    2853   if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) { return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); }
    2854   else                                                     { return g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])].at(intraTabIdx).getPatternIdx(); }
    2855 #endif
    28561980}
    28571981
     
    28751999  }
    28762000
    2877 #if SCU_HS_DMM4_REMOVE_DIV_E0242
    2878   Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
    2879   iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;
    2880 #else
    2881   iDC /= (uiWidth*uiHeight);
    2882 #endif
     2001  Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;   //
     2002  iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;        //  iDC /= (uiWidth*uiHeight);
     2003
    28832004  piRefBlkY = cTempYuv.getLumaAddr();
    28842005
     
    29072028  }
    29082029}
    2909 
    2910 #if !SEC_DMM2_E0146_HHIFIX
    2911 Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY )
    2912 {
    2913   ruiOffsetX = 0;
    2914   ruiOffsetY = 0;
    2915 
    2916   // get offset between current and above/left block
    2917   UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    2918   UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    2919 
    2920   UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart();
    2921   UInt uiMaxDepthRefCU = 0;
    2922   while( uiNumPartInRefCU > 1 )
    2923   {
    2924     uiNumPartInRefCU >>= 2;
    2925     uiMaxDepthRefCU++;
    2926   }
    2927 
    2928   UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1);
    2929   UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2;
    2930   UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts;
    2931 
    2932   UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
    2933   UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
    2934 
    2935   if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); }
    2936   if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); }
    2937 }
    2938 
    2939 Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY )
    2940 {
    2941   riSlopeX = 0, riSlopeY = 0, ruiStartPosX = 0, ruiStartPosY = 0;
    2942 
    2943   // 1st step: get wedge start point (max. slope)
    2944   Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt );
    2945   Int iSourceStride = ( uiBlockSize<<1 ) + 1;
    2946 
    2947   UInt uiSlopeMaxAbove = 0, uiPosSlopeMaxAbove = 0;
    2948   for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ )
    2949   {
    2950     if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove )
    2951     {
    2952       uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] );
    2953       uiPosSlopeMaxAbove = uiPosHor;
    2954     }
    2955   }
    2956 
    2957   UInt uiSlopeMaxLeft = 0, uiPosSlopeMaxLeft = 0;
    2958   for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ )
    2959   {
    2960     if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft )
    2961     {
    2962       uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] );
    2963       uiPosSlopeMaxLeft = uiPosVer;
    2964     }
    2965   }
    2966 
    2967   if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 )
    2968   {
    2969     return false;
    2970   }
    2971 
    2972   ruiStartPosX = ( uiSlopeMaxAbove >  uiSlopeMaxLeft  ) ? uiPosSlopeMaxAbove : 0;
    2973   ruiStartPosY = ( uiSlopeMaxLeft  >= uiSlopeMaxAbove ) ? uiPosSlopeMaxLeft  : 0;
    2974 
    2975   // 2nd step: derive wedge direction
    2976   Int uiPreds[3] = {-1, -1, -1};
    2977   Int iMode = -1;
    2978   Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); 
    2979 
    2980   UInt uiDirMode = 0;
    2981   if( iMode >= 0 ) { iPredNum = iMode; }
    2982   if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; }
    2983   if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; }
    2984 
    2985   if( uiDirMode < 2 ) { return false; } // no planar & DC
    2986 
    2987   Bool modeHor       = (uiDirMode < 18);
    2988   Bool modeVer       = !modeHor;
    2989   Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0;
    2990   Int absAng         = abs(intraPredAngle);
    2991   Int signAng        = intraPredAngle < 0 ? -1 : 1;
    2992   Int angTable[9]    = {0,2,5,9,13,17,21,26,32};
    2993   absAng             = angTable[absAng];
    2994   intraPredAngle     = signAng * absAng;
    2995 
    2996   // 3rd step: set slope for direction
    2997   if( modeHor )
    2998   {
    2999     riSlopeX = ( intraPredAngle > 0 ) ?            -32 :              32;
    3000     riSlopeY = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle;
    3001   }
    3002   else if( modeVer )
    3003   {
    3004     riSlopeX = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle;
    3005     riSlopeY = ( intraPredAngle > 0 ) ?            -32 :              32;
    3006   }
    3007 
    3008   return true;
    3009 }
    3010 
    3011 Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd )
    3012 {
    3013   ruhXs = 0;
    3014   ruhYs = 0;
    3015   ruhXe = 0;
    3016   ruhYe = 0;
    3017 
    3018   // scaling of start pos and block size to wedge resolution
    3019   UInt uiScaledStartPosX = 0;
    3020   UInt uiScaledStartPosY = 0;
    3021   UInt uiScaledBlockSize = 0;
    3022   WedgeResolution eWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiBlockSize]];
    3023   switch( eWedgeRes )
    3024   {
    3025   case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; }
    3026   case(   FULL_PEL ): { uiScaledStartPosX =  uiPMSPosX;     uiScaledStartPosY =  uiPMSPosY;     uiScaledBlockSize =  uiBlockSize;     break; }
    3027   case(   HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; }
    3028   }
    3029   Int iMaxPos = (Int)uiScaledBlockSize - 1;
    3030 
    3031   // case above
    3032   if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 )
    3033   {
    3034     ruhXs = (UChar)uiScaledStartPosX;
    3035     ruhYs = 0;
    3036 
    3037     if( iDeltaY == 0 )
    3038     {
    3039       if( iDeltaX < 0 )
    3040       {
    3041         ruhXe = 0;
    3042         ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos );
    3043         return;
    3044       }
    3045       else
    3046       {
    3047         ruhXe = (UChar)iMaxPos;
    3048         ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos );
    3049         std::swap( ruhXs, ruhXe );
    3050         std::swap( ruhYs, ruhYe );
    3051         return;
    3052       }
    3053     }
    3054 
    3055     // regular case
    3056     Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) );
    3057 
    3058     if( iVirtualEndX < 0 )
    3059     {
    3060       Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd;
    3061       if( iYe < (Int)uiScaledBlockSize )
    3062       {
    3063         ruhXe = 0;
    3064         ruhYe = (UChar)std::max( iYe, 0 );
    3065         return;
    3066       }
    3067       else
    3068       {
    3069         ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos );
    3070         ruhYe = (UChar)iMaxPos;
    3071         return;
    3072       }
    3073     }
    3074     else if( iVirtualEndX > iMaxPos )
    3075     {
    3076       Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
    3077       if( iYe < (Int)uiScaledBlockSize )
    3078       {
    3079         ruhXe = (UChar)iMaxPos;
    3080         ruhYe = (UChar)std::max( iYe, 0 );
    3081         std::swap( ruhXs, ruhXe );
    3082         std::swap( ruhYs, ruhYe );
    3083         return;
    3084       }
    3085       else
    3086       {
    3087         ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 );
    3088         ruhYe = (UChar)iMaxPos;
    3089         return;
    3090       }
    3091     }
    3092     else
    3093     {
    3094       Int iXe = iVirtualEndX + iDeltaEnd;
    3095       if( iXe < 0 )
    3096       {
    3097         ruhXe = 0;
    3098         ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 );
    3099         return;
    3100       }
    3101       else if( iXe > iMaxPos )
    3102       {
    3103         ruhXe = (UChar)iMaxPos;
    3104         ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 );
    3105         std::swap( ruhXs, ruhXe );
    3106         std::swap( ruhYs, ruhYe );
    3107         return;
    3108       }
    3109       else
    3110       {
    3111         ruhXe = (UChar)iXe;
    3112         ruhYe = (UChar)iMaxPos;
    3113         return;
    3114       }
    3115     }
    3116   }
    3117 
    3118   // case left
    3119   if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 )
    3120   {
    3121     ruhXs = 0;
    3122     ruhYs = (UChar)uiScaledStartPosY;
    3123 
    3124     if( iDeltaX == 0 )
    3125     {
    3126       if( iDeltaY < 0 )
    3127       {
    3128         ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos );
    3129         ruhYe = 0;
    3130         std::swap( ruhXs, ruhXe );
    3131         std::swap( ruhYs, ruhYe );
    3132         return;
    3133       }
    3134       else
    3135       {
    3136         ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos );
    3137         ruhYe = (UChar)iMaxPos;
    3138         return;
    3139       }
    3140     }
    3141 
    3142     // regular case
    3143     Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) );
    3144 
    3145     if( iVirtualEndY < 0 )
    3146     {
    3147       Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd;
    3148       if( iXe < (Int)uiScaledBlockSize )
    3149       {
    3150         ruhXe = (UChar)std::max( iXe, 0 );
    3151         ruhYe = 0;
    3152         std::swap( ruhXs, ruhXe );
    3153         std::swap( ruhYs, ruhYe );
    3154         return;
    3155       }
    3156       else
    3157       {
    3158         ruhXe = (UChar)iMaxPos;
    3159         ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos );
    3160         std::swap( ruhXs, ruhXe );
    3161         std::swap( ruhYs, ruhYe );
    3162         return;
    3163       }
    3164     }
    3165     else if( iVirtualEndY > (uiScaledBlockSize-1) )
    3166     {
    3167       Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd;
    3168       if( iXe < (Int)uiScaledBlockSize )
    3169       {
    3170         ruhXe = (UChar)std::max( iXe, 0 );
    3171         ruhYe = (UChar)(uiScaledBlockSize-1);
    3172         return;
    3173       }
    3174       else
    3175       {
    3176         ruhXe = (UChar)iMaxPos;
    3177         ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 );
    3178         std::swap( ruhXs, ruhXe );
    3179         std::swap( ruhYs, ruhYe );
    3180         return;
    3181       }
    3182     }
    3183     else
    3184     {
    3185       Int iYe = iVirtualEndY - iDeltaEnd;
    3186       if( iYe < 0 )
    3187       {
    3188         ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 );
    3189         ruhYe = 0;
    3190         std::swap( ruhXs, ruhXe );
    3191         std::swap( ruhYs, ruhYe );
    3192         return;
    3193       }
    3194       else if( iYe > iMaxPos )
    3195       {
    3196         ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 );
    3197         ruhYe = (UChar)iMaxPos;
    3198         return;
    3199       }
    3200       else
    3201       {
    3202         ruhXe = (UChar)iMaxPos;
    3203         ruhYe = (UChar)iYe;
    3204         std::swap( ruhXs, ruhXe );
    3205         std::swap( ruhYs, ruhYe );
    3206         return;
    3207       }
    3208     }
    3209   }
    3210 
    3211   // case origin
    3212   if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 )
    3213   {
    3214     if( iDeltaX*iDeltaY < 0 )
    3215     {
    3216       return;
    3217     }
    3218 
    3219     ruhXs = 0;
    3220     ruhYs = 0;
    3221 
    3222     if( iDeltaY == 0 )
    3223     {
    3224       ruhXe = (UChar)iMaxPos;
    3225       ruhYe = 0;
    3226       std::swap( ruhXs, ruhXe );
    3227       std::swap( ruhYs, ruhYe );
    3228       return;
    3229     }
    3230 
    3231     if( iDeltaX == 0 )
    3232     {
    3233       ruhXe = 0;
    3234       ruhYe = (UChar)iMaxPos;
    3235       return;
    3236     }
    3237 
    3238     Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) );
    3239 
    3240     if( iVirtualEndX > iMaxPos )
    3241     {
    3242       Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
    3243       if( iYe < (Int)uiScaledBlockSize )
    3244       {
    3245         ruhXe = (UChar)(uiScaledBlockSize-1);
    3246         ruhYe = (UChar)std::max( iYe, 0 );
    3247         std::swap( ruhXs, ruhXe );
    3248         std::swap( ruhYs, ruhYe );
    3249         return;
    3250       }
    3251       else
    3252       {
    3253         ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 );
    3254         ruhYe = (UChar)(uiScaledBlockSize-1);
    3255         return;
    3256       }
    3257     }
    3258     else
    3259     {
    3260       Int iXe = iVirtualEndX + iDeltaEnd;
    3261       if( iXe < 0 )
    3262       {
    3263         ruhXe = 0;
    3264         ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 );
    3265         return;
    3266       }
    3267       else if( iXe > iMaxPos )
    3268       {
    3269         ruhXe = (UChar)(uiScaledBlockSize-1);
    3270         ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 );
    3271         std::swap( ruhXs, ruhXe );
    3272         std::swap( ruhYs, ruhYe );
    3273         return;
    3274       }
    3275       else
    3276       {
    3277         ruhXe = (UChar)iXe;
    3278         ruhYe = (UChar)(uiScaledBlockSize-1);
    3279         return;
    3280       }
    3281     }
    3282   }
    3283 }
    3284 
    3285 UInt TComPrediction::xGetWedgePatternIdx( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe )
    3286 {
    3287   WedgeRefList* pcWedgeRefList = &g_dmmWedgeRefLists[(g_aucConvertToBit[uiBlockSize])];
    3288   for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ )
    3289   {
    3290     TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx));
    3291     if( pcTestWedgeRef->getStartX() == uhXs && pcTestWedgeRef->getStartY() == uhYs && pcTestWedgeRef->getEndX() == uhXe && pcTestWedgeRef->getEndY() == uhYe )
    3292     {
    3293       return pcTestWedgeRef->getRefIdx();
    3294     }
    3295   }
    3296   return 0;
    3297 }
    3298 #endif
    3299 #endif
     2030#endif
     2031
    33002032#if H_3D_DIM_RBC
    33012033Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC )
     
    33272059#if H_3D_DIM_SDC
    33282060Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
    3329 #if KWU_SDC_SIMPLE_DC_E0117
    33302061                                         ,UInt uiIntraMode
    33312062                                         ,Bool orgDC
    3332 #endif
    33332063                                        )
    33342064{
     
    33382068  memset(iSumPix, 0, sizeof(Int)*2);
    33392069 
    3340 #if KWU_SDC_SIMPLE_DC_E0117
    33412070  if (orgDC == false)
    33422071  {
     
    33642093    return;
    33652094  }
    3366 #endif
    33672095
    33682096  Int subSamplePix;
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r622 r655  
    7676  Int    m_iLumaRecStride;       ///< stride of #m_pLumaRecBuffer array
    7777#if H_3D_IC
    78 #if SHARP_ILLUCOMP_REFINE_E0046
    7978  UInt   m_uiaShift[ 64 ];       // Table for multiplication to substitue of division operation
    80 #else
    81   UInt   m_uiaShift[ 63 ];       // Table for multiplication to substitue of division operation
    82 #endif
    8379#endif
    8480
     
    8884  Int  xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma = true);
    8985#endif
    90 #if NTT_VSP_COMMON_E0207_E0208
    9186  TComYuv   m_cYuvDepthOnVsp;
    92 #endif
    9387#endif
    9488
     
    126120
    127121#if H_3D_VSP
    128 #if NTT_VSP_COMMON_E0207_E0208
    129122  Void xGetVirtualDepth           ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int txtPerDepthX=1, Int txtPerDepthY=1 );
    130123  Void xPredInterLumaBlkFromDM    ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&pcYuvDst, Bool isBi );
    131124  Void xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&pcYuvDst, Bool isBi );
    132 #else
    133   Void xPredInterLumaBlkFromDM  ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv* dv, UInt partAddr, Int posX, Int posY, Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi );
    134   Void xPredInterChromaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv* dv, UInt partAddr, Int posX, Int posY, Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi );
    135 #endif
    136125#endif
    137126
     
    140129  Void xGetLLSPrediction ( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 );
    141130#if H_3D_IC
    142 #if SHARP_ILLUCOMP_REFINE_E0046
    143131  Void xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType );
    144 #else
    145   Void xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, TextType eType );
    146 #endif
    147132#endif
    148133  Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight );
     
    154139  Void xAssignBiSegDCs          ( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel   valDC1, Pel   valDC2 );
    155140#if H_3D_DIM_DMM
    156 #if !SEC_DMM2_E0146_HHIFIX
    157   UInt xPredWedgeFromIntra      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd = 0 );
    158 #endif
    159141  UInt xPredWedgeFromTex        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx );
    160142  Void xPredContourFromTex      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge );
    161 
    162143  Void xCopyTextureLumaBlock    ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight );
    163 
    164 #if !SEC_DMM2_E0146_HHIFIX
    165   Void xGetBlockOffset          ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY );
    166   Bool xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY );
    167   Void xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd = 0 );
    168   UInt xGetWedgePatternIdx      ( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe );
    169 #endif
    170144#endif
    171145#if H_3D_DIM_RBC
     
    196170#if H_3D_DIM_SDC
    197171  Void analyzeSegmentsSDC         ( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
    198 #if KWU_SDC_SIMPLE_DC_E0117
    199172                                    ,UInt uiIntraMode
    200173                                    ,Bool orgDC=false
    201 #endif
    202174    );
    203175#endif
  • trunk/source/Lib/TLibCommon/TComRdCost.cpp

    r622 r655  
    484484}
    485485
    486 #if SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX
     486#if H_3D_FAST_DEPTH_INTRA
    487487
    488488UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth)
     
    542542  cDtParam.bUseIC       = false;
    543543#endif
    544 #if LGE_INTER_SDC_E0156
     544#if H_3D_INTER_SDC
    545545  cDtParam.bUseSDCMRSAD = false;
    546546#endif
     
    605605    dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
    606606  }
    607 #if H_3D_FIX_UINT_WARNING
     607
    608608  return (UInt) dist;
    609 #else
    610   return dist;
    611 #endif
    612 
    613 }
    614 #endif
    615 
    616 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     609}
     610#endif
     611
     612#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    617613UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    618614{
     
    652648  }
    653649#endif
    654 #if LGE_INTER_SDC_E0156
     650#if H_3D_INTER_SDC
    655651  if( pcDtParam->bUseSDCMRSAD )
    656652  {
     
    692688  }
    693689#endif
    694 #if LGE_INTER_SDC_E0156
     690#if H_3D_INTER_SDC
    695691  if( pcDtParam->bUseSDCMRSAD )
    696692  {
     
    735731  }
    736732#endif
    737 #if LGE_INTER_SDC_E0156
     733#if H_3D_INTER_SDC
    738734  if( pcDtParam->bUseSDCMRSAD )
    739735  {
     
    782778  }
    783779#endif
    784 #if LGE_INTER_SDC_E0156
     780#if H_3D_INTER_SDC
    785781  if( pcDtParam->bUseSDCMRSAD )
    786782  {
     
    838834  }
    839835#endif
    840 #if LGE_INTER_SDC_E0156
     836#if H_3D_INTER_SDC
    841837  if( pcDtParam->bUseSDCMRSAD )
    842838  {
     
    886882  }
    887883#endif
    888 #if LGE_INTER_SDC_E0156
     884#if H_3D_INTER_SDC
    889885  if( pcDtParam->bUseSDCMRSAD )
    890886  {
     
    944940  }
    945941#endif
    946 #if LGE_INTER_SDC_E0156
     942#if H_3D_INTER_SDC
    947943  if( pcDtParam->bUseSDCMRSAD )
    948944  {
     
    10161012  }
    10171013#endif
    1018 #if LGE_INTER_SDC_E0156
     1014#if H_3D_INTER_SDC
    10191015  if( pcDtParam->bUseSDCMRSAD )
    10201016  {
     
    10811077  }
    10821078#endif
    1083 #if LGE_INTER_SDC_E0156
     1079#if H_3D_INTER_SDC
    10841080  if( pcDtParam->bUseSDCMRSAD )
    10851081  {
     
    11851181  }
    11861182#endif
    1187 #if LGE_INTER_SDC_E0156
     1183#if H_3D_INTER_SDC
    11881184  if( pcDtParam->bUseSDCMRSAD )
    11891185  {
     
    12611257#endif
    12621258
    1263 #if H_3D_IC || LGE_INTER_SDC_E0156
     1259#if H_3D_IC || H_3D_INTER_SDC
    12641260UInt TComRdCost::xGetSADic( DistParam* pcDtParam )
    12651261{
     
    35133509  }
    35143510#endif
    3515 #if LGE_INTER_SDC_E0156
     3511#if H_3D_INTER_SDC
    35163512  if( pcDtParam->bUseSDCMRSAD )
    35173513  {
     
    36163612}
    36173613
    3618 #if H_3D_IC || LGE_INTER_SDC_E0156
     3614#if H_3D_IC || H_3D_INTER_SDC
    36193615UInt TComRdCost::xGetHADsic( DistParam* pcDtParam )
    36203616{
  • trunk/source/Lib/TLibCommon/TComRdCost.h

    r622 r655  
    9494  Bool  bUseIC;
    9595#endif
    96 #if LGE_INTER_SDC_E0156
     96#if H_3D_INTER_SDC
    9797  Bool  bUseSDCMRSAD;
    9898#endif
     
    136136    iStrideVir = 0;
    137137#endif
    138 #if LGE_INTER_SDC_E0156
     138#if H_3D_INTER_SDC
    139139    bUseSDCMRSAD = false;
    140140#endif
     
    148148private:
    149149  // for distortion
    150   Int                     m_iBlkWidth;
    151   Int                     m_iBlkHeight;
    152150 
    153151#if AMP_SAD
     
    235233  UInt    calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
    236234 
    237 #if SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX
     235#if H_3D_FAST_DEPTH_INTRA
    238236  UInt    calcVAR(Pel* pi0, Int stride, Int width, Int height, Int cuDepth);
    239237#endif 
     
    283281  static UInt xGetSSE64         ( DistParam* pcDtParam );
    284282  static UInt xGetSSE16N        ( DistParam* pcDtParam );
    285 #if H_3D_IC || LGE_INTER_SDC_E0156
     283#if H_3D_IC || H_3D_INTER_SDC
    286284  static UInt xGetSADic         ( DistParam* pcDtParam );
    287285  static UInt xGetSAD4ic        ( DistParam* pcDtParam );
     
    311309
    312310#if AMP_SAD
    313 #if H_3D_IC || LGE_INTER_SDC_E0156
     311#if H_3D_IC || H_3D_INTER_SDC
    314312  static UInt xGetSAD12ic       ( DistParam* pcDtParam );
    315313  static UInt xGetSAD24ic       ( DistParam* pcDtParam );
     
    322320#endif
    323321
    324 #if H_3D_IC || LGE_INTER_SDC_E0156
     322#if H_3D_IC || H_3D_INTER_SDC
    325323  static UInt xGetHADsic          ( DistParam* pcDtParam );
    326324#endif
     
    343341#endif
    344342
    345 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     343#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    346344  UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    347345#endif
  • trunk/source/Lib/TLibCommon/TComRom.cpp

    r622 r655  
    5555  ::memset( g_aucConvertToBit,   -1, sizeof( g_aucConvertToBit ) );
    5656  c=0;
    57   for ( i=4; i<MAX_CU_SIZE; i*=2 )
     57  for ( i=4; i<=MAX_CU_SIZE; i*=2 )
    5858  {
    5959    g_aucConvertToBit[ i ] = c;
    6060    c++;
    6161  }
    62   g_aucConvertToBit[ i ] = c;
    6362 
    6463  c=2;
     
    292291
    293292#if FAST_UDI_USE_MPM
    294 const UChar g_aucIntraModeNumFast[7] =
     293const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] =
    295294{
    296295  3,  //   2x2
     
    299298  3,  //  16x16   
    300299  3,  //  32x32   
    301   3,  //  64x64   
    302   3   // 128x128 
     300  3   //  64x64   
    303301};
    304302#else // FAST_UDI_USE_MPM
    305 const UChar g_aucIntraModeNumFast[7] =
     303const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] =
    306304{
    307305  3,  //   2x2
     
    310308  4,  //  16x16   33
    311309  4,  //  32x32   33
    312   5,  //  64x64   33
    313   4   // 128x128  33
     310  5   //  64x64   33
    314311};
    315312#endif // FAST_UDI_USE_MPM
     
    347344{ //2x2   4x4   8x8 16x16 32x32 64x64
    348345     0,    7,   10,   11,   11,   13 };
    349 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
     346
    350347const UChar g_dmm3IntraTabIdxBits[6] =
    351348{ //2x2   4x4   8x8 16x16 32x32 64x64
    352349     0,    4,    7,    8,    8,    0 };
    353 #else
    354 const UChar g_dmm3IntraTabIdxBits[6] =
    355 { //2x2   4x4   8x8 16x16 32x32 64x64
    356      0,    6,    9,    9,    9,    0 };
    357 #endif
    358350
    359351extern std::vector< std::vector<TComWedgelet> >   g_dmmWedgeLists;
     
    614606std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
    615607
    616 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    617608Void initWedgeLists( Bool initNodeList )
    618 #else
    619 Void initWedgeLists( Bool initRefinements )
    620 #endif
    621609{
    622610  if( !g_dmmWedgeLists.empty() ) return;
     
    631619    g_dmmWedgeRefLists.push_back( acWedgeRefList );
    632620
    633 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    634621    if( initNodeList )
    635622    {
    636 #endif
    637     // create WedgeNodeList
    638     std::vector<TComWedgeNode> acWedgeNodeList;
    639     for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ )
    640     {
    641       if( acWedgeList[uiPos].getIsCoarse() )
    642       {
    643         TComWedgeNode cWedgeNode;
    644         cWedgeNode.setPatternIdx( uiPos );
    645 
    646 #if !LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    647         if( initRefinements )
     623      // create WedgeNodeList
     624      std::vector<TComWedgeNode> acWedgeNodeList;
     625      for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ )
     626      {
     627        if( acWedgeList[uiPos].getIsCoarse() )
    648628        {
    649 #endif
     629          TComWedgeNode cWedgeNode;
     630          cWedgeNode.setPatternIdx( uiPos );
     631
    650632          UInt uiRefPos = 0;
    651633          for( Int iOffS = -1; iOffS <= 1; iOffS++ )
     
    674656              {
    675657                if( iSx == (Int)acWedgeRefList[k].getStartX() &&
    676                     iSy == (Int)acWedgeRefList[k].getStartY() &&
    677                     iEx == (Int)acWedgeRefList[k].getEndX()   &&
    678                     iEy == (Int)acWedgeRefList[k].getEndY()      )
     658                  iSy == (Int)acWedgeRefList[k].getStartY() &&
     659                  iEx == (Int)acWedgeRefList[k].getEndX()   &&
     660                  iEy == (Int)acWedgeRefList[k].getEndY()      )
    679661                {
    680662                  if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() )
     
    694676            }
    695677          }
    696 #if !LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
     678          acWedgeNodeList.push_back( cWedgeNode );
    697679        }
    698 #endif
    699         acWedgeNodeList.push_back( cWedgeNode );
    700       }
    701     }
    702     g_dmmWedgeNodeLists.push_back( acWedgeNodeList );
    703 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    704   }
    705 #endif
    706   }
    707   return;
     680      }
     681      g_dmmWedgeNodeLists.push_back( acWedgeNodeList );
     682    }
     683  }
    708684}
    709685
  • trunk/source/Lib/TLibCommon/TComRom.h

    r622 r655  
    5656// ====================================================================================================================
    5757
    58 #define     MAX_CU_DEPTH            7                           // log2(LCUSize)
     58#define     MAX_CU_DEPTH            6                           // log2(LCUSize)
    5959#define     MAX_CU_SIZE             (1<<(MAX_CU_DEPTH))         // maximum allowable size of CU
    6060#define     MIN_PU_SIZE             4
     
    136136// ====================================================================================================================
    137137
    138 extern const UChar  g_aucIntraModeNumFast[7];
     138extern const UChar  g_aucIntraModeNumFast[ MAX_CU_DEPTH ];
    139139
    140140// ====================================================================================================================
     
    174174extern       std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
    175175
    176 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    177176Void initWedgeLists( Bool initNodeList = false );
    178 #else
    179 Void initWedgeLists( Bool initRefinements = false );
    180 #endif
    181177Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes );
    182178Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList );
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r622 r655  
    101101, m_enableTMVPFlag                ( true )
    102102#if H_MV
    103 #if H_MV5
    104103, m_refPicSetInterLayer0           ( NULL )
    105104, m_refPicSetInterLayer1           ( NULL )
    106 #else
    107 , m_refPicSetInterLayer           ( NULL )
    108 #endif
    109105, m_layerId                       (0)
    110106, m_viewId                        (0)
    111 #if H_MV5
    112107, m_viewIndex                     (0)
    113 #endif
    114108#if H_3D
    115 #if !H_MV5
    116 , m_viewIndex                     (0)
    117 #endif
    118109, m_isDepth                       (false)
    119110#endif
    120 #if H_MV5
    121111, m_pocResetFlag                  (false)
    122 #endif
    123112, m_discardableFlag               (false)
    124113, m_interLayerPredEnabledFlag     (false)
    125114, m_numInterLayerRefPicsMinus1    (0)
    126 #if !H_MV5
    127 , m_interLayerSamplePredOnlyFlag  (false)
    128 , m_altCollocatedIndicationFlag   (0)
    129 , m_collocatedRefLayerIdx         (0)
    130 #endif
    131115#if H_3D_IC
    132116, m_bApplyIC                      ( false )
     
    164148  for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
    165149  {
    166 #if H_MV5
    167150   m_interLayerPredLayerIdc[ i ] = i;
    168 #else
    169    m_interLayerPredLayerIdc[ i ] = 0;
    170 #endif
    171151  }
    172152#endif
     
    322302  if (!pocHasMsb)
    323303  {
    324     poc = poc % pocCycle;
     304    poc = poc & (pocCycle - 1);
    325305  }
    326306 
     
    333313      if (!pocHasMsb)
    334314      {
    335         picPoc = picPoc % pocCycle;
     315        picPoc = picPoc & (pocCycle - 1);
    336316      }
    337317     
     
    387367  }
    388368}
    389 #if H_MV5
    390369#if !H_MV
    391370#if FIX1071
     
    472451  {
    473452    // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
    474     // “ If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    475     // “ Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     453    // ?If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     454    // ?Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    476455    if (getRapPicFlag())
    477456    {
     
    730709}
    731710#endif
    732 #else
     711Int TComSlice::getNumRpsCurrTempList()
     712{
     713  Int numRpsCurrTempList = 0;
     714
     715  if (m_eSliceType == I_SLICE)
     716  {
     717    return 0;
     718  }
     719  for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++)
     720  {
     721    if(m_pcRPS->getUsed(i))
     722    {
     723      numRpsCurrTempList++;
     724    }
     725  }
    733726#if H_MV
    734 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer , Bool checkNumPocTotalCurr)
    735 #else
    736 #if FIX1071
    737 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
    738 #else
    739 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
    740 #endif
    741 #endif
    742 {
    743 #if FIX1071
    744   if (!checkNumPocTotalCurr)
    745 #endif
    746   {
    747     if (m_eSliceType == I_SLICE)
    748     {
    749       ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
    750       ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
    751      
    752       return;
    753     }
    754    
    755 #if !H_MV
    756     m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    757     m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
    758 #endif
    759   }
    760 
    761   TComPic*  pcRefPic= NULL;
    762   TComPic*  RefPicSetStCurr0[16];
    763   TComPic*  RefPicSetStCurr1[16];
    764   TComPic*  RefPicSetLtCurr[16];
    765   UInt NumPocStCurr0 = 0;
    766   UInt NumPocStCurr1 = 0;
    767   UInt NumPocLtCurr = 0;
    768   Int i;
    769 
    770   for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++)
    771   {
    772     if(m_pcRPS->getUsed(i))
    773     {
    774       pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
    775       pcRefPic->setIsLongTerm(0);
    776       pcRefPic->getPicYuvRec()->extendPicBorder();
    777       RefPicSetStCurr0[NumPocStCurr0] = pcRefPic;
    778       NumPocStCurr0++;
    779       pcRefPic->setCheckLTMSBPresent(false); 
    780     }
    781   }
    782  
    783   for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++)
    784   {
    785     if(m_pcRPS->getUsed(i))
    786     {
    787       pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i));
    788       pcRefPic->setIsLongTerm(0);
    789       pcRefPic->getPicYuvRec()->extendPicBorder();
    790       RefPicSetStCurr1[NumPocStCurr1] = pcRefPic;
    791       NumPocStCurr1++;
    792       pcRefPic->setCheckLTMSBPresent(false); 
    793     }
    794   }
    795  
    796   for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--)
    797   {
    798     if(m_pcRPS->getUsed(i))
    799     {
    800       pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    801       pcRefPic->setIsLongTerm(1);
    802       pcRefPic->getPicYuvRec()->extendPicBorder();
    803       RefPicSetLtCurr[NumPocLtCurr] = pcRefPic;
    804       NumPocLtCurr++;
    805     }
    806     if(pcRefPic==NULL)
    807     {
    808       pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i));
    809     }
    810     pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); 
    811   }
    812 
    813   // ref_pic_list_init
    814   TComPic*  rpsCurrList0[MAX_NUM_REF+1];
    815   TComPic*  rpsCurrList1[MAX_NUM_REF+1];
    816 #if H_MV
    817   Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
    818   assert( numPocInterCurr == 0 || getInterRefEnabledInRPLFlag() );
    819   Int numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( );
    820   assert( numPocTotalCurr == getNumRpsCurrTempList() );
    821 #else
    822   Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
    823 #endif
    824 #if FIX1071
    825   if (checkNumPocTotalCurr)
    826   {
    827     // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
    828 #if H_MV
    829     // – If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    830     // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    831     if ( getRapPicFlag() && m_layerId == 0 )
    832 #else
    833     // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    834     // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    835     if (getRapPicFlag())
    836 #endif
    837     {
    838       assert(numPocTotalCurr == 0);
    839     }
    840 
    841     if (m_eSliceType == I_SLICE)
    842     {
    843       ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
    844       ::memset( m_aiNumRefIdx,   0, sizeof ( m_aiNumRefIdx ));
    845      
    846       return;
    847     }
    848    
    849     assert(numPocTotalCurr > 0);
    850    
    851     m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    852     m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
    853   }
    854 #endif
    855 
    856   Int cIdx = 0;
    857 #if H_MV
    858   if ( getInterRefEnabledInRPLFlag() )
    859   { 
    860 #endif
    861   for ( i=0; i<NumPocStCurr0; i++, cIdx++)
    862   {
    863     rpsCurrList0[cIdx] = RefPicSetStCurr0[i];
    864   }
    865   for ( i=0; i<NumPocStCurr1; i++, cIdx++)
    866   {
    867     rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
    868   }
    869   for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
    870   {
    871     rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
    872   }
    873 #if H_MV
    874   }
    875   for ( i=0; i < getNumActiveRefLayerPics( );  i++, cIdx++)
    876     {
    877     assert( cIdx < MAX_NUM_REF );   
    878       rpsCurrList0[cIdx] = refPicSetInterLayer[i];
    879     }
    880 #endif
    881   assert(cIdx == numPocTotalCurr);
    882 
    883   if (m_eSliceType==B_SLICE)
    884   {
    885     cIdx = 0;
    886 #if H_MV
    887     if ( getInterRefEnabledInRPLFlag() )
    888     { 
    889 #endif
    890     for ( i=0; i<NumPocStCurr1; i++, cIdx++)
    891     {
    892       rpsCurrList1[cIdx] = RefPicSetStCurr1[i];
    893     }
    894     for ( i=0; i<NumPocStCurr0; i++, cIdx++)
    895     {
    896       rpsCurrList1[cIdx] = RefPicSetStCurr0[i];
    897     }
    898     for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
    899     {
    900       rpsCurrList1[cIdx] = RefPicSetLtCurr[i];
    901     }
    902 #if H_MV
    903     }
    904     for ( i=0; i < getNumActiveRefLayerPics( );  i++, cIdx++)
    905       {
    906       assert( cIdx < MAX_NUM_REF );   
    907         rpsCurrList1[cIdx] = refPicSetInterLayer[i];
    908       }
    909 #endif
    910     assert(cIdx == numPocTotalCurr);
    911   }
    912 
    913   ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm));
    914 
    915 #if H_MV
    916   Int numPocSt = NumPocStCurr0 + NumPocStCurr1;
    917   assert(  getInterRefEnabledInRPLFlag( ) || numPocSt == 0 );
    918 
    919   for (Int li = 0; li < 2; li++)
    920   {
    921     if ( m_eSliceType == P_SLICE && li == 1 )
    922     {
    923       m_aiNumRefIdx[1] = 0;
    924       ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1]));
    925     }
    926     else
    927     {
    928       for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++)
    929       {
    930         Bool listModified             =                m_RefPicListModification.getRefPicListModificationFlagL( li );
    931         Int orgIdx                    = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr);
    932 
    933         m_apcRefPicList    [li][rIdx] = ( li == 0 )  ? rpsCurrList0[ orgIdx  ] : rpsCurrList1[ orgIdx  ];
    934         m_bIsUsedAsLongTerm[li][rIdx] = ( orgIdx >= numPocSt ) ;
    935       }
    936     }
    937   }
    938 #else
    939   for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++)
    940   {
    941     cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr;
    942     assert(cIdx >= 0 && cIdx < numPocTotalCurr);
    943     m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ];
    944     m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 );
    945   }
    946   if ( m_eSliceType != B_SLICE )
    947   {
    948     m_aiNumRefIdx[1] = 0;
    949     ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1]));
    950   }
    951   else
    952   {
    953     for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++)
    954     {
    955       cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr;
    956       assert(cIdx >= 0 && cIdx < numPocTotalCurr);
    957       m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ];
    958       m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 );
    959     }
    960   }
    961 #endif
    962 }
    963 
    964 #endif
    965 Int TComSlice::getNumRpsCurrTempList()
    966 {
    967   Int numRpsCurrTempList = 0;
    968 
    969   if (m_eSliceType == I_SLICE)
    970   {
    971     return 0;
    972   }
    973   for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++)
    974   {
    975     if(m_pcRPS->getUsed(i))
    976     {
    977       numRpsCurrTempList++;
    978     }
    979   }
    980 #if H_MV
    981 #if !H_MV5
    982   assert( ( numRpsCurrTempList == 0 ) || getInterRefEnabledInRPLFlag() );
    983 #endif
    984727  numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics();
    985728#endif
     
    1063806}
    1064807
    1065 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)
     808Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic)
    1066809{
    1067810  for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++)
     
    1089832  {
    1090833    pocCRA = getPOC();
    1091     prevRAPisBLA = false;
     834    associatedIRAPType = getNalUnitType();
    1092835  }
    1093836  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
    1094837  {
    1095838    pocCRA = getPOC();
    1096     prevRAPisBLA = false;
     839    associatedIRAPType = getNalUnitType();
    1097840  }
    1098841  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     
    1101844  {
    1102845    pocCRA = getPOC();
    1103     prevRAPisBLA = true;
     846    associatedIRAPType = getNalUnitType();
    1104847  }
    1105848}
     
    1126869{
    1127870  TComPic*                 rpcPic;
     871  setAssociatedIRAPPOC(pocCRA);
    1128872  Int pocCurr = getPOC();
    1129873
     
    12951039#if H_MV
    12961040  // Additional slice header syntax elements
    1297 #if H_MV5
    12981041  m_pocResetFlag               = pSrc->m_pocResetFlag;
    1299 #endif
    13001042  m_discardableFlag            = pSrc->m_discardableFlag;
    13011043  m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag;
     
    13061048    m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ];
    13071049  }
    1308 #if !H_MV5
    1309   m_interLayerSamplePredOnlyFlag = pSrc->m_interLayerSamplePredOnlyFlag;
    1310   m_altCollocatedIndicationFlag  = pSrc->m_altCollocatedIndicationFlag ;   
    1311   m_collocatedRefLayerIdx        = pSrc->m_collocatedRefLayerIdx       ;
    1312   m_numActiveMotionPredRefLayers = pSrc->m_numActiveMotionPredRefLayers;
    1313 
    1314   for (Int layer = 0; layer < MAX_NUM_LAYER_IDS; layer++)
    1315   {   
    1316     m_interLayerPredLayerIdc[layer] = pSrc->m_interLayerPredLayerIdc[layer];
    1317   }
    1318 #endif
    13191050#endif
    13201051#if H_3D_IC
     
    13241055}
    13251056
    1326 Int TComSlice::m_prevPOC = 0;
     1057Int TComSlice::m_prevTid0POC = 0;
    13271058
    13281059/** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag.
     
    13791110}
    13801111
     1112
     1113Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic)
     1114{
     1115  TComPic* rpcPic;
     1116
     1117  Int nalUnitType = this->getNalUnitType();
     1118
     1119  // When a picture is a leading picture, it shall be a RADL or RASL picture.
     1120  if(this->getAssociatedIRAPPOC() > this->getPOC())
     1121  {
     1122    // Do not check IRAP pictures since they may get a POC lower than their associated IRAP
     1123    if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP ||
     1124       nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23)
     1125    {
     1126      assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1127             nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R ||
     1128             nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1129             nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R);
     1130    }
     1131  }
     1132
     1133  // When a picture is a trailing picture, it shall not be a RADL or RASL picture.
     1134  if(this->getAssociatedIRAPPOC() < this->getPOC())
     1135  {
     1136    assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N &&
     1137           nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R &&
     1138           nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N &&
     1139           nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R);
     1140  }
     1141
     1142  // No RASL pictures shall be present in the bitstream that are associated
     1143  // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP.
     1144  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1145     nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1146  {
     1147    assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL &&
     1148           this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP);
     1149  }
     1150
     1151  // No RASL pictures shall be present in the bitstream that are associated with
     1152  // an IDR picture.
     1153  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1154     nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1155  {
     1156    assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP   &&
     1157           this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL);
     1158  }
     1159
     1160  // No RADL pictures shall be present in the bitstream that are associated with
     1161  // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated
     1162  // with an IDR picture having nal_unit_type equal to IDR_N_LP.
     1163  if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1164     nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)
     1165  {
     1166    assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP   &&
     1167           this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP);
     1168  }
     1169
     1170  // loop through all pictures in the reference picture buffer
     1171  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
     1172  while ( iterPic != rcListPic.end())
     1173  {
     1174    rpcPic = *(iterPic++);
     1175    if (rpcPic->getPOC() == this->getPOC())
     1176    {
     1177      continue;
     1178    }
     1179
     1180    // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture
     1181    // in decoding order shall precede the IRAP picture in output order.
     1182    // (Note that any picture following in output order would be present in the DPB)
     1183    if(rpcPic->getSlice(0)->getPicOutputFlag() == 1)
     1184    {
     1185      if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP    ||
     1186         nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP    ||
     1187         nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL  ||
     1188         nalUnitType == NAL_UNIT_CODED_SLICE_CRA         ||
     1189         nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP    ||
     1190         nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL)
     1191      {
     1192        assert(rpcPic->getPOC() < this->getPOC());
     1193      }
     1194    }
     1195
     1196    // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture
     1197    // in decoding order shall precede any RADL picture associated with the IRAP
     1198    // picture in output order.
     1199    if(rpcPic->getSlice(0)->getPicOutputFlag() == 1)
     1200    {
     1201      if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1202          nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R))
     1203      {
     1204        // rpcPic precedes the IRAP in decoding order
     1205        if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC())
     1206        {
     1207          // rpcPic must not be the IRAP picture
     1208          if(this->getAssociatedIRAPPOC() != rpcPic->getPOC())
     1209          {
     1210            assert(rpcPic->getPOC() < this->getPOC());
     1211          }
     1212        }
     1213      }
     1214    }
     1215
     1216    // When a picture is a leading picture, it shall precede, in decoding order,
     1217    // all trailing pictures that are associated with the same IRAP picture.
     1218    if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1219       nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R ||
     1220       nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1221       nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)
     1222    {
     1223      if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC())
     1224      {
     1225        // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB
     1226        // rpcPic would violate the constraint if it was a trailing picture
     1227        assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
     1228      }
     1229    }
     1230
     1231    // Any RASL picture associated with a CRA or BLA picture shall precede any
     1232    // RADL picture associated with the CRA or BLA picture in output order
     1233    if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1234       nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1235    {
     1236      if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP   ||
     1237          this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   ||
     1238          this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ||
     1239          this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA)       &&
     1240          this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC())
     1241      {
     1242        if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N ||
     1243           rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R)
     1244        {
     1245          assert(rpcPic->getPOC() > this->getPOC());
     1246        }
     1247      }
     1248    }
     1249
     1250