Changeset 442 in SHVCSoftware for trunk/source/App


Ignore:
Timestamp:
21 Oct 2013, 13:41:29 (11 years ago)
Author:
seregin
Message:

reintegrate SHM-3.1-dev branch

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r313 r442  
    5656TAppDecTop::TAppDecTop()
    5757{
    58   ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    5958  for(UInt layer=0; layer < MAX_LAYERS; layer++)
    6059  {
     
    6766: m_iPOCLastDisplay(-MAX_INT)
    6867{
    69   ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    7068}
    7169#endif
     
    146144
    147145  // main decoder loop
    148   Bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
     146  Bool openedReconFile[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
    149147  for(UInt layer=0; layer<=m_tgtLayerId; layer++)
    150148  {
    151     recon_opened[layer] = false;
     149    openedReconFile[layer] = false;
    152150    m_aiPOCLastDisplay[layer] += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
    153151  }
     
    228226    {
    229227      m_acTDecTop[curLayerId].executeLoopFilters(poc, pcListPic);
     228#if EARLY_REF_PIC_MARKING
     229      m_acTDecTop[curLayerId].earlyPicMarking(m_iMaxTemporalLayer, m_targetDecLayerIdSet);
     230#endif
    230231    }
    231232
    232233    if( pcListPic )
    233234    {
    234       if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
     235      if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] )
    235236      {
    236237        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }       
     
    239240        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    240241
    241         recon_opened[curLayerId] = true;
     242        openedReconFile[curLayerId] = true;
    242243      }
    243244      if ( bNewPicture && bNewPOC &&
     
    263264  // delete buffers
    264265#if AVC_BASE
     266  UInt layerIdmin = m_acTDecTop[0].getBLReconFile()->is_open() ? 1 : 0;
     267
    265268  if( streamYUV.is_open() )
    266269  {
     
    273276  }
    274277#endif
    275   pcBLPic.destroy();
    276 
    277   for(UInt layer = 1; layer <= m_tgtLayerId; layer++)
     278  pcBLPic.destroy(); 
     279
     280  for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++)
    278281#else
    279282  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     
    307310
    308311  // main decoder loop
    309   Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     312  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    310313
    311314#if SYNTAX_OUTPUT
     
    338341    streampos location = bitstreamFile.tellg();
    339342    AnnexBStats stats = AnnexBStats();
    340     Bool bPreviousPictureDecoded = false;
    341343
    342344    vector<uint8_t> nalUnit;
     
    360362      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    361363      {
    362         if(bPreviousPictureDecoded)
    363         {
    364           bNewPicture = true;
    365           bPreviousPictureDecoded = false;
    366         }
    367         else
    368         {
    369364          bNewPicture = false;
    370365        }
    371       }
    372366      else
    373367      {
     
    383377          bytestream.reset();
    384378        }
    385         bPreviousPictureDecoded = true;
    386379      }
    387380    }
     
    393386    if( pcListPic )
    394387    {
    395       if ( m_pchReconFile && !recon_opened )
     388      if ( m_pchReconFile && !openedReconFile )
    396389      {
    397390        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
     
    399392
    400393        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    401         recon_opened = true;
     394        openedReconFile = true;
    402395      }
    403396      if ( bNewPicture &&
     
    470463    if ( m_pchReconFile[layer] )
    471464    {
    472       m_acTVideoIOYuvReconFile[layer]. close();
     465      m_acTVideoIOYuvReconFile[layer].close();
    473466    }
    474467
     
    505498
    506499/** \param pcListPic list of pictures to be written to file
    507     \todo            DYN_REF_FREE should be revised
    508  */
     500\todo            DYN_REF_FREE should be revised
     501*/
    509502#if SVC_EXTENSION
    510503Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId )
     
    514507{
    515508  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    516   Int not_displayed = 0;
     509  Int numPicsNotYetDisplayed = 0;
    517510
    518511  while (iterPic != pcListPic->end())
     
    525518#endif
    526519    {
    527        not_displayed++;
     520      numPicsNotYetDisplayed++;
    528521    }
    529522    iterPic++;
    530523  }
    531524  iterPic   = pcListPic->begin();
    532  
    533   while (iterPic != pcListPic->end())
    534   {
    535     TComPic* pcPic = *(iterPic);
    536    
    537 #if SVC_EXTENSION
    538     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
    539 #else
    540     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
    541 #endif
    542     {
    543       // write to file
    544        not_displayed--;
    545 #if SVC_EXTENSION
    546       if ( m_pchReconFile[layerId] )
    547       {
    548         const Window &conf = pcPic->getConformanceWindow();
    549         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    550         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    551                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    552                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    553                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    554                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    555       }
    556      
    557       // update POC of display order
    558       m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
    559 #else
    560       if ( m_pchReconFile )
    561       {
    562 #if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
    563         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec() );
    564 #else
    565         const Window &conf = pcPic->getConformanceWindow();
    566         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    567         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    568                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    569                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    570                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    571                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    572 #endif
    573       }
    574      
    575       // update POC of display order
    576       m_iPOCLastDisplay = pcPic->getPOC();
    577 #endif
    578      
    579       // erase non-referenced picture in the reference picture list after display
    580       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    581       {
     525  if (numPicsNotYetDisplayed>2)
     526  {
     527    iterPic++;
     528  }
     529
     530  TComPic* pcPic = *(iterPic);
     531  if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding
     532  {
     533    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     534    endPic--;
     535    iterPic   = pcListPic->begin();
     536    while (iterPic != endPic)
     537    {
     538      TComPic* pcPicTop = *(iterPic);
     539      iterPic++;
     540      TComPic* pcPicBottom = *(iterPic);
     541
     542#if SVC_EXTENSION
     543      if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
     544        && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_aiPOCLastDisplay[layerId]+1 || m_aiPOCLastDisplay[layerId]<0)))
     545#else
     546      if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
     547        && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0)))
     548#endif
     549      {
     550        // write to file
     551        numPicsNotYetDisplayed = numPicsNotYetDisplayed-2;
     552#if SVC_EXTENSION
     553        if ( m_pchReconFile[layerId] )
     554        {
     555          const Window &conf = pcPicTop->getConformanceWindow();
     556          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     557          const Bool isTff = pcPicTop->isTopField();
     558#if REPN_FORMAT_IN_VPS
     559          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     560          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     561          m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     562            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     563            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     564            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
     565            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset(), isTff );
     566
     567#else
     568          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     569            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     570            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     571            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     572            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     573#endif
     574        }
     575
     576        // update POC of display order
     577        m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
     578#else
     579        if ( m_pchReconFile )
     580        {
     581          const Window &conf = pcPicTop->getConformanceWindow();
     582          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     583          const Bool isTff = pcPicTop->isTopField();
     584          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     585            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     586            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     587            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     588            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     589        }
     590
     591        // update POC of display order
     592        m_iPOCLastDisplay = pcPicBottom->getPOC();
     593#endif
     594
     595        // erase non-referenced picture in the reference picture list after display
     596        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     597        {
    582598#if !DYN_REF_FREE
    583         pcPic->setReconMark(false);
    584        
    585         // mark it should be extended later
    586         pcPic->getPicYuvRec()->setBorderExtension( false );
    587        
    588 #else
    589         pcPic->destroy();
    590         pcListPic->erase( iterPic );
    591         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    592         continue;
    593 #endif
    594       }
    595       pcPic->setOutputMark(false);
    596     }
    597    
    598     iterPic++;
     599          pcPicTop->setReconMark(false);
     600
     601          // mark it should be extended later
     602          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     603
     604#else
     605          pcPicTop->destroy();
     606          pcListPic->erase( iterPic );
     607          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     608          continue;
     609#endif
     610        }
     611        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     612        {
     613#if !DYN_REF_FREE
     614          pcPicBottom->setReconMark(false);
     615
     616          // mark it should be extended later
     617          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     618
     619#else
     620          pcPicBottom->destroy();
     621          pcListPic->erase( iterPic );
     622          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     623          continue;
     624#endif
     625        }
     626        pcPicTop->setOutputMark(false);
     627        pcPicBottom->setOutputMark(false);
     628      }
     629    }
     630  }
     631  else if (!pcPic->isField()) //Frame Decoding
     632  {
     633    iterPic = pcListPic->begin();
     634    while (iterPic != pcListPic->end())
     635    {
     636      pcPic = *(iterPic);
     637
     638#if SVC_EXTENSION
     639      if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
     640#else
     641      if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     642#endif
     643      {
     644        // write to file
     645        numPicsNotYetDisplayed--;
     646#if SVC_EXTENSION
     647        if ( m_pchReconFile[layerId] )
     648        {
     649          const Window &conf = pcPic->getConformanceWindow();
     650          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     651#if REPN_FORMAT_IN_VPS
     652          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     653          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     654          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     655            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     656            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     657            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
     658            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
     659
     660#else
     661          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     662            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     663            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     664            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     665            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     666#endif
     667        }
     668
     669        // update POC of display order
     670        m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
     671#else
     672        if ( m_pchReconFile )
     673        {
     674#if SYNTAX_OUTPUT
     675          const Window &conf = pcPic->getConformanceWindow();
     676          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     677          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     678            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     679            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     680            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     681            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     682#endif
     683        }
     684
     685        // update POC of display order
     686        m_iPOCLastDisplay = pcPic->getPOC();
     687#endif
     688
     689        // erase non-referenced picture in the reference picture list after display
     690        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     691        {
     692#if !DYN_REF_FREE
     693          pcPic->setReconMark(false);
     694
     695          // mark it should be extended later
     696          pcPic->getPicYuvRec()->setBorderExtension( false );
     697
     698#else
     699          pcPic->destroy();
     700          pcListPic->erase( iterPic );
     701          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     702          continue;
     703#endif
     704        }
     705        pcPic->setOutputMark(false);
     706      }
     707
     708      iterPic++;
     709    }
    599710  }
    600711}
     
    616727
    617728  iterPic   = pcListPic->begin();
    618  
    619   while (iterPic != pcListPic->end())
    620   {
    621     TComPic* pcPic = *(iterPic);
    622 
    623     if ( pcPic->getOutputMark() )
    624     {
    625       // write to file
    626 #if SVC_EXTENSION
    627       if ( m_pchReconFile[layerId] )
    628       {
    629         const Window &conf = pcPic->getConformanceWindow();
    630         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    631         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    632                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    633                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    634                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    635                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    636       }
    637      
    638       // update POC of display order
    639       m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
    640 #else
    641       if ( m_pchReconFile )
    642       {
    643         const Window &conf = pcPic->getConformanceWindow();
    644         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    645         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    646                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    647                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    648                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    649                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    650       }
    651      
    652       // update POC of display order
    653       m_iPOCLastDisplay = pcPic->getPOC();
    654 #endif
    655      
    656       // erase non-referenced picture in the reference picture list after display
    657       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    658       {
     729  TComPic* pcPic = *(iterPic);
     730
     731  if (pcPic->isField()) //Field Decoding
     732  {
     733    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     734    endPic--;
     735    TComPic *pcPicTop, *pcPicBottom = NULL;
     736    while (iterPic != endPic)
     737    {
     738      pcPicTop = *(iterPic);
     739      iterPic++;
     740      pcPicBottom = *(iterPic);
     741
     742      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
     743      {
     744        // write to file
     745#if SVC_EXTENSION
     746        if ( m_pchReconFile[layerId] )
     747        {
     748          const Window &conf = pcPicTop->getConformanceWindow();
     749          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     750          const Bool isTff = pcPicTop->isTopField();
     751#if REPN_FORMAT_IN_VPS
     752          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     753          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     754          m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     755            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
     756            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
     757            conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
     758            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), isTff );
     759
     760#else
     761          m_cTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     762            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     763            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     764            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     765            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     766#endif
     767        }
     768
     769        // update POC of display order
     770        m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
     771#else
     772        if ( m_pchReconFile )
     773        {
     774          const Window &conf = pcPicTop->getConformanceWindow();
     775          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     776          const Bool isTff = pcPicTop->isTopField();
     777          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     778            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     779            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     780            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     781            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     782        }
     783
     784        // update POC of display order
     785        m_iPOCLastDisplay = pcPicBottom->getPOC();
     786#endif
     787
     788        // erase non-referenced picture in the reference picture list after display
     789        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     790        {
    659791#if !DYN_REF_FREE
    660         pcPic->setReconMark(false);
    661        
    662         // mark it should be extended later
    663         pcPic->getPicYuvRec()->setBorderExtension( false );
    664        
    665 #else
    666         pcPic->destroy();
    667         pcListPic->erase( iterPic );
    668         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    669         continue;
    670 #endif
    671       }
    672       pcPic->setOutputMark(false);
    673     }
     792          pcPicTop->setReconMark(false);
     793
     794          // mark it should be extended later
     795          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     796
     797#else
     798          pcPicTop->destroy();
     799          pcListPic->erase( iterPic );
     800          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     801          continue;
     802#endif
     803        }
     804        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     805        {
     806#if !DYN_REF_FREE
     807          pcPicBottom->setReconMark(false);
     808
     809          // mark it should be extended later
     810          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     811
     812#else
     813          pcPicBottom->destroy();
     814          pcListPic->erase( iterPic );
     815          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     816          continue;
     817#endif
     818        }
     819        pcPicTop->setOutputMark(false);
     820        pcPicBottom->setOutputMark(false);
     821
     822#if !DYN_REF_FREE
     823        if(pcPicTop)
     824        {
     825          pcPicTop->destroy();
     826          delete pcPicTop;
     827          pcPicTop = NULL;
     828        }
     829#endif
     830      }
     831    }
     832    if(pcPicBottom)
     833    {
     834      pcPicBottom->destroy();
     835      delete pcPicBottom;
     836      pcPicBottom = NULL;
     837    }
     838  }
     839  else //Frame decoding
     840  {
     841    while (iterPic != pcListPic->end())
     842    {
     843      pcPic = *(iterPic);
     844
     845      if ( pcPic->getOutputMark() )
     846      {
     847        // write to file
     848#if SVC_EXTENSION
     849        if ( m_pchReconFile[layerId] )
     850        {
     851          const Window &conf = pcPic->getConformanceWindow();
     852          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     853#if REPN_FORMAT_IN_VPS
     854          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     855          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     856          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     857            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
     858            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
     859            conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
     860            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
     861
     862#else
     863          m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     864            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     865            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     866            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     867            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     868#endif
     869        }
     870
     871        // update POC of display order
     872        m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
     873#else
     874        if ( m_pchReconFile )
     875        {
     876          const Window &conf = pcPic->getConformanceWindow();
     877          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     878          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     879            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     880            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     881            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     882            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     883        }
     884
     885        // update POC of display order
     886        m_iPOCLastDisplay = pcPic->getPOC();
     887#endif
     888
     889        // erase non-referenced picture in the reference picture list after display
     890        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     891        {
     892#if !DYN_REF_FREE
     893          pcPic->setReconMark(false);
     894
     895          // mark it should be extended later
     896          pcPic->getPicYuvRec()->setBorderExtension( false );
     897
     898#else
     899          pcPic->destroy();
     900          pcListPic->erase( iterPic );
     901          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     902          continue;
     903#endif
     904        }
     905        pcPic->setOutputMark(false);
     906      }
    674907#if !SVC_EXTENSION
    675908#if !DYN_REF_FREE
    676     if(pcPic)
    677     {
    678       pcPic->destroy();
    679       delete pcPic;
    680       pcPic = NULL;
    681     }
     909      if(pcPic)
     910      {
     911        pcPic->destroy();
     912        delete pcPic;
     913        pcPic = NULL;
     914      }
    682915#endif   
    683916#endif
    684     iterPic++;
     917      iterPic++;
     918    }
    685919  }
    686920#if SVC_EXTENSION
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r313 r442  
    7070#endif
    7171 
    72   // for output control
    73   Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
     72  // for output control 
    7473#if SVC_EXTENSION
    7574  Int                             m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order
  • trunk/source/App/TAppDownConvert/TAppDownConvert.cpp

    r340 r442  
    270270  FILE * outfile;
    271271
    272   int M,N;
    273   int ratio;
     272  int M = -1 ,N = -1;
     273  int ratio = -1;
    274274  int Frames=0;
    275275  int totalFrames=0;
     
    326326    return -1;
    327327  }
    328   if ( ratio > 1 || ratio < 0)
    329   {
     328
     329  switch( ratio )
     330  {
     331  default:
    330332    printf("\ndown sampling parameter %d is not supported (0: 2x downsampling, 1: 1.5x downsampling)\n", ratio);
    331333    return -1;
    332   }
    333 
    334   if (ratio==0)
    335   {
     334  case 0:
    336335    M=4;
    337336    N=8;
    338   }
    339   else if (ratio==1)
    340   {
     337    break;
     338  case 1:
    341339    M=8;
    342340    N=12;
     341    break;
    343342  }
    344343
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r345 r442  
    6969, m_avcBaseLayerFlag(0)
    7070#endif
     71#if N0120_MAX_TID_REF_CFG
     72, m_maxTidRefPresentFlag(1)
     73#endif
    7174, m_pColumnWidth()
    7275, m_pRowHeight()
    7376, m_scalingListFile()
    74 #if REF_IDX_FRAMEWORK
    7577, m_elRapSliceBEnabled(0)
    76 #endif
    7778{
    7879  for(UInt layer=0; layer<MAX_LAYERS; layer++)
     
    217218    {
    218219      in>>entry.m_refIdc[i];
     220    }
     221  }
     222#endif
     223#if EXTERNAL_USEDBYCURR_N0082
     224  if(entry.m_numRefPics>0){
     225    in>>entry.m_UseExtusedByCurrPic;
     226    if(entry.m_UseExtusedByCurrPic)
     227    {
     228      for ( Int i = 0; i < entry.m_numRefPics; i++ )
     229      {
     230        in>>entry.m_ExtusedByCurrPic[i];
     231      }
    219232    }
    220233  }
     
    335348 
    336349#if SVC_EXTENSION
    337   string  cfg_LayerCfgFile  [MAX_LAYERS];
     350  string  cfg_LayerCfgFile   [MAX_LAYERS];
    338351  string  cfg_BitstreamFile;
    339   string* cfg_InputFile     [MAX_LAYERS];
    340   string* cfg_ReconFile     [MAX_LAYERS];
    341   Double* cfg_fQP           [MAX_LAYERS];
    342 
     352  string* cfg_InputFile      [MAX_LAYERS];
     353  string* cfg_ReconFile      [MAX_LAYERS];
     354  Double* cfg_fQP            [MAX_LAYERS];
     355
     356#if REPN_FORMAT_IN_VPS
     357  Int*    cfg_repFormatIdx  [MAX_LAYERS];
     358#endif
    343359  Int*    cfg_SourceWidth   [MAX_LAYERS];
    344360  Int*    cfg_SourceHeight  [MAX_LAYERS];
     
    384400  Bool*   cfg_RCForceIntraQP       [MAX_LAYERS];
    385401#endif
     402#if N0120_MAX_TID_REF_CFG
     403  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS];
     404#endif
    386405  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    387406  {
     
    389408    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
    390409    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     410#if REPN_FORMAT_IN_VPS
     411    cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx;
     412#endif
    391413    cfg_SourceWidth[layer]  = &m_acLayerCfg[layer].m_iSourceWidth;
    392414    cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight;
     
    426448    cfg_RCForceIntraQP[layer]        = &m_acLayerCfg[layer].m_RCForceIntraQP;
    427449#endif
     450#if N0120_MAX_TID_REF_CFG
     451    cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1;
     452#endif
    428453  }
    429454#if AVC_BASE
     
    432457#if AVC_SYNTAX
    433458  string  cfg_BLSyntaxFile;
     459#endif
     460#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     461  string  cfg_tileSets;
    434462#endif
    435463#else
     
    459487  ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
    460488  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     489#if REPN_FORMAT_IN_VPS
     490  ("RepFormatIdx%d",          cfg_repFormatIdx, -1, MAX_LAYERS, "Index to the representation format structure used from the VPS")
     491#endif
    461492#if VPS_EXTN_DIRECT_REF_LAYERS
    462493#if M0457_PREDICTION_INDICATIONS
     
    474505  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
    475506  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     507#if SCALABILITY_MASK_E0104
     508  ("ScalabilityMask1",        m_scalabilityMask[1], 0, "scalability_mask[1] (multiview)")
     509  ("ScalabilityMask2",        m_scalabilityMask[2], 1, "scalability_mask[2] (scalable)" )
     510#else
    476511  ("ScalabilityMask0",        m_scalabilityMask[0], 0, "scalability_mask[0] (multiview)")
    477512  ("ScalabilityMask1",        m_scalabilityMask[1], 1, "scalability_mask[1] (scalable)" )
     513#endif
    478514  ("BitstreamFile,b",         cfg_BitstreamFile, string(""), "Bitstream output file name")
    479515  ("InputBitDepth",           m_inputBitDepthY,    8, "Bit-depth of input file")
     
    495531                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
    496532#endif
     533#if N0120_MAX_TID_REF_CFG
     534  ("MaxTidRefPresentFlag", m_maxTidRefPresentFlag, true, "max_tid_ref_present_flag (0: not present, 1: present(default)) " )
     535  ("MaxTidIlRefPicsPlus1%d", cfg_maxTidIlRefPicsPlus1, 1, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction")
     536#endif
    497537#if AVC_BASE
    498538  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
     
    502542#endif
    503543#endif
    504 #if REF_IDX_FRAMEWORK
    505544  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
    506 #endif 
    507545#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
    508546  ("IlSampleOnlyPred%d",       m_ilSampleOnlyPred, 0, MAX_LAYERS, "Set inter_layer_sample_pred_only_flag for all slices")
    509547#endif
    510 #else 
     548#else
    511549  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
    512550  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     
    530568  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
    531569#endif
     570
     571  //Field coding parameters
     572  ("FieldCoding", m_isField, false, "Signals if it's a field based coding")
     573  ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not")
    532574  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
    533575  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
     
    810852  ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
    811853#endif
     854#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     855  ("SEIInterLayerConstrainedTileSets", m_interLayerConstrainedTileSetsSEIEnabled, false, "Control generation of inter layer constrained tile sets SEI message")
     856  ("IlNumSetsInMessage",               m_ilNumSetsInMessage,                         0u, "Number of inter layer constrained tile sets")
     857  ("TileSetsArray",                    cfg_tileSets,                         string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
     858#endif
    812859  ;
    813860 
     
    827874  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
    828875
     876  if(m_isField)
     877  {
     878#if SVC_EXTENSION
     879    for(Int layer = 0; layer < MAX_LAYERS; layer++)
     880    {
     881      //Frame height
     882      m_acLayerCfg[layer].m_iSourceHeightOrg = m_acLayerCfg[layer].m_iSourceHeight;
     883      //Field height
     884      m_acLayerCfg[layer].m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight >> 1;
     885    }
     886#else
     887    //Frame height
     888    m_iSourceHeightOrg = m_iSourceHeight;
     889    //Field height
     890    m_iSourceHeight = m_iSourceHeight >> 1;
     891#endif
     892    //number of fields to encode
     893    m_framesToBeEncoded *= 2;
     894  }
     895 
    829896  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    830897  {
     
    11191186#endif
    11201187  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
    1121  
     1188
     1189#if REPN_FORMAT_IN_VPS_123
     1190  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     1191  {
     1192    m_acLayerCfg[layer].setSourceHeight( m_repFormatCfg[ m_acLayerCfg[layer].getRepFormatIdx() ].m_picHeightInLumaSamples);
     1193    m_acLayerCfg[layer].setSourceWidth ( m_repFormatCfg[ m_acLayerCfg[layer].getRepFormatIdx() ].m_picWidthInLumaSamples );
     1194  }
     1195#endif
    11221196  /* rules for input, output and internal bitdepths as per help text */
    11231197  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
     
    11511225        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    11521226        m_iSourceHeight += m_confBottom;
     1227        if ( m_isField )
     1228        {
     1229          m_iSourceHeightOrg += m_confBottom << 1;
     1230          m_aiPad[1] = m_confBottom << 1;
     1231        }
    11531232      }
    11541233      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
     
    12841363    }
    12851364  }
     1365#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     1366  if (m_interLayerConstrainedTileSetsSEIEnabled)
     1367  {
     1368    if (m_iNumColumnsMinus1 == 0 && m_iNumRowsMinus1 == 0)
     1369    {
     1370      printf( "Tiles are not defined (needed for inter-layer comnstrained tile sets SEI).\n" );
     1371      exit( EXIT_FAILURE );
     1372    }
     1373    Char* pTileSets = cfg_tileSets.empty() ? NULL : strdup(cfg_tileSets.c_str());
     1374    int i = 0;
     1375    char *topLeftTileIndex = strtok(pTileSets, " ,");
     1376    while(topLeftTileIndex != NULL)
     1377    {
     1378      if( i >= m_ilNumSetsInMessage )
     1379      {
     1380        printf( "The number of tile sets is larger than defined by IlNumSetsInMessage.\n" );
     1381        exit( EXIT_FAILURE );
     1382      }
     1383      *( m_topLeftTileIndex + i ) = atoi( topLeftTileIndex );
     1384      char *bottonRightTileIndex = strtok(NULL, " ,");
     1385      if( bottonRightTileIndex == NULL )
     1386      {
     1387        printf( "BottonRightTileIndex is missing in the tile sets.\n" );
     1388        exit( EXIT_FAILURE );
     1389      }
     1390      *( m_bottomRightTileIndex + i ) = atoi( bottonRightTileIndex );
     1391      char *ilcIdc = strtok(NULL, " ,");
     1392      if( ilcIdc == NULL )
     1393      {
     1394        printf( "IlcIdc is missing in the tile sets.\n" );
     1395        exit( EXIT_FAILURE );
     1396      }
     1397      *( m_ilcIdc + i ) = atoi( ilcIdc );
     1398      topLeftTileIndex = strtok(NULL, " ,");
     1399      i++;
     1400    }
     1401    if( i < m_ilNumSetsInMessage )
     1402    {
     1403      printf( "The number of tile sets is smaller than defined by IlNumSetsInMessage.\n" );
     1404      exit( EXIT_FAILURE );
     1405    }
     1406    m_skippedTileSetPresentFlag = false;
     1407  }
     1408#endif
    12861409  // check validity of input parameters
    12871410  xCheckParameter();
     
    14671590#endif
    14681591 
    1469 #if !FINAL_RPL_CHANGE_N0082
     1592#if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    14701593  Bool verifiedGOP=false;
    14711594#endif
    14721595  Bool errorGOP=false;
    1473 #if !FINAL_RPL_CHANGE_N0082
     1596#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    14741597  Int checkGOP=1;
    1475   Int numRefs = 1;
     1598  Int numRefs = m_isField ? 2 : 1;
    14761599#endif
    14771600  Int refList[MAX_NUM_REF_PICS+1];
    14781601  refList[0]=0;
     1602  if(m_isField)
     1603  {
     1604    refList[1] = 1;
     1605  }
    14791606  Bool isOK[MAX_GOP];
    14801607  for(Int i=0; i<MAX_GOP; i++)
     
    14821609    isOK[i]=false;
    14831610  }
    1484 #if !FINAL_RPL_CHANGE_N0082
     1611#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    14851612  Int numOK=0;
    14861613#endif
     
    15041631  for(UInt layer=0; layer<m_numLayers; layer++)
    15051632  {
    1506     if(m_acLayerCfg[layer].xCheckParameter())
     1633    if(m_acLayerCfg[layer].xCheckParameter(m_isField))
    15071634    {
    15081635      printf("\nError: invalid configuration parameter found in layer %d \n", layer);
     
    15301657  for(UInt layer=0; layer<m_numLayers; layer++)
    15311658  {
    1532     if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0){
     1659    if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0)
     1660    {
    15331661      memcpy( m_acLayerCfg[layer].m_GOPListLayer, m_GOPList, sizeof(GOPEntry)*MAX_GOP );
    15341662    }
     
    15361664    xConfirmPara(errorGOP,"Invalid GOP structure given");
    15371665  }
     1666#if TEMP_SCALABILITY_FIX
     1667  if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7  &&
     1668    m_acLayerCfg[1].m_GOPListLayer[5].m_temporalId == 0 && m_acLayerCfg[1].m_GOPListLayer[7].m_temporalId == 0)
     1669#else
    15381670  //tentative for encoder
    1539   if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 ){
     1671  if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 )
     1672#endif
     1673  {
    15401674    //RA, POC5
    15411675    m_acLayerCfg[1].m_GOPListLayer[5].m_usedByCurrPic[2] = 0;
     
    15451679    m_acLayerCfg[1].m_GOPListLayer[7].m_refIdc[2] = 0;
    15461680  }
    1547 #else
     1681#endif
     1682#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    15481683  m_extraRPSs=0;
    15491684  //start looping through frames in coding order until we can verify that the GOP structure is correct.
     
    17421877  xConfirmPara(errorGOP,"Invalid GOP structure given");
    17431878#endif
     1879#if EXTERNAL_USEDBYCURR_N0082
     1880  for(UInt layer=0; layer<m_numLayers; layer++)
     1881  {
     1882    for (Int i=0; i< m_iGOPSize; i++){
     1883      if (m_acLayerCfg[layer].m_GOPListLayer[i].m_UseExtusedByCurrPic == 1 )
     1884      {
     1885        for(Int j=0; j<m_acLayerCfg[layer].m_GOPListLayer[i].m_numRefPics; j++ )
     1886        {
     1887          m_acLayerCfg[layer].m_GOPListLayer[i].m_usedByCurrPic[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j];
     1888          m_acLayerCfg[layer].m_GOPListLayer[i].m_refIdc[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j];
     1889        }
     1890      }
     1891    }
     1892  }
     1893#endif
    17441894  m_maxTempLayer = 1;
    17451895  for(Int i=0; i<m_iGOPSize; i++)
     
    20452195  }
    20462196#endif
     2197#if N0120_MAX_TID_REF_CFG
     2198  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
     2199  {
     2200    xConfirmPara(m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
     2201  }
     2202#endif
    20472203#undef xConfirmPara
    20482204  if (check_failed)
     
    20812237#if SVC_EXTENSION 
    20822238  printf("Total number of layers        : %d\n", m_numLayers       );
     2239#if SCALABILITY_MASK_E0104
     2240  printf("Multiview                     : %d\n", m_scalabilityMask[1] );
     2241  printf("Scalable                      : %d\n", m_scalabilityMask[2] );
     2242#else
    20832243  printf("Multiview                     : %d\n", m_scalabilityMask[0] );
    20842244  printf("Scalable                      : %d\n", m_scalabilityMask[1] );
     2245#endif
    20852246#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    20862247  printf("Adaptive Resolution Change    : %d\n", m_adaptiveResolutionChange );
     
    21052266  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    21062267#endif
    2107   printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2268  if (m_isField)
     2269  {
     2270    printf("Frame/Field          : Field based coding\n");
     2271    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2272    if (m_isTopFieldFirst)
     2273    {
     2274      printf("Field Order            : Top field first\n");
     2275    }
     2276    else
     2277    {
     2278      printf("Field Order            : Bottom field first\n");
     2279    }
     2280  }
     2281  else
     2282  {
     2283    printf("Frame/Field                  : Frame based coding\n");
     2284    printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2285  }
    21082286  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
    21092287  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
     
    22092387  printf("AvcBase:%d ", 0);
    22102388#endif
    2211 #if REF_IDX_FRAMEWORK
    2212   printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
    22132389  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
    22142390  printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV);
    22152391  printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE);
    22162392  printf("REF_IDX_MFM: %d ", REF_IDX_MFM);
    2217 #endif
    22182393#else
    22192394  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r345 r442  
    5959  // file I/O
    6060#if SVC_EXTENSION
    61   TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS]; 
     61  TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS];
    6262  Int       m_numLayers;                                      ///< number of layers
    6363  Int       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES]; ///< scalability_mask
     
    6868  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    6969#if AVC_BASE
    70   Int       m_avcBaseLayerFlag;                               ///< AVC_BASElayer_flag
     70  Int       m_avcBaseLayerFlag;                               ///< avc_baselayer_flag
    7171#endif
    7272#if AVC_SYNTAX
     
    7676  Int       m_ilSampleOnlyPred[ MAX_LAYERS ];
    7777#endif
     78#if N0120_MAX_TID_REF_CFG
     79  Bool      m_maxTidRefPresentFlag;
     80#endif
    7881#else
    7982  Char*     m_pchInputFile;                                   ///< source file name
     
    8588  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    8689  Int       m_iSourceWidth;                                   ///< source width in pixel
    87   Int       m_iSourceHeight;                                  ///< source height in pixel
     90  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     91 
     92  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
     93 
     94 
    8895  Int       m_conformanceMode;
    8996  Int       m_confLeft;
     
    94101  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    95102#endif 
     103
     104  Bool      m_isField;                                        ///< enable field coding
     105  Bool      m_isTopFieldFirst;
    96106
    97107  // profile/level
     
    340350  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
    341351
    342 #if REF_IDX_FRAMEWORK
     352#if SVC_EXTENSION
    343353  Int       m_elRapSliceBEnabled;
    344354#endif
     
    353363#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    354364  Int       m_adaptiveResolutionChange;                       ///< Indicate adaptive resolution change frame
     365#endif
     366#if REPN_FORMAT_IN_VPS
     367  RepFormatCfg m_repFormatCfg[16];                            ///< Rep_format structures
     368#endif
     369#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     370  Bool      m_interLayerConstrainedTileSetsSEIEnabled;
     371  UInt      m_ilNumSetsInMessage;
     372  Bool      m_skippedTileSetPresentFlag;
     373  UInt      m_topLeftTileIndex[1024];
     374  UInt      m_bottomRightTileIndex[1024];
     375  UInt      m_ilcIdc[1024];
    355376#endif
    356377public:
     
    381402  Void cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString);
    382403#endif
     404#if REPN_FORMAT_IN_VPS
     405  RepFormatCfg* getRepFormatCfg(Int i)  { return &m_repFormatCfg[i]; }
     406#endif
    383407#endif
    384408};// END CLASS DEFINITION TAppEncCfg
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r313 r442  
    3232  m_conformanceMode( 0 ),
    3333  m_aidQP(NULL)
     34#if REPN_FORMAT_IN_VPS
     35, m_repFormatIdx (-1)
     36#endif
    3437{
    3538  m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     
    158161Bool confirmPara(Bool bflag, const char* message);
    159162
    160 Bool TAppEncLayerCfg::xCheckParameter()
     163Bool TAppEncLayerCfg::xCheckParameter( Bool isField )
    161164{
    162165  switch (m_conformanceMode)
     
    182185        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    183186        m_iSourceHeight += m_confBottom;
     187        if ( isField )
     188        {
     189          m_iSourceHeightOrg += m_confBottom << 1;
     190          m_aiPad[1] = m_confBottom << 1;
     191        }
    184192      }
    185193      break;
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r345 r442  
    3333  Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
    3434  Int       m_iSourceWidth;                                   ///< source width in pixel
    35   Int       m_iSourceHeight;                                  ///< source height in pixel
     35  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     36  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
    3637  Int       m_conformanceMode;
    3738  Int       m_confLeft;
     
    6667#endif
    6768
     69#if N0120_MAX_TID_REF_CFG
     70  Int       m_maxTidIlRefPicsPlus1;
     71#endif
    6872#if SVC_EXTENSION
    6973  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     
    8488  GOPEntry  m_GOPListLayer[MAX_GOP];                            ///< for layer
    8589#endif
     90#if REPN_FORMAT_IN_VPS
     91  Int       m_repFormatIdx;
     92#endif
    8693public:
    8794  TAppEncLayerCfg();
     
    98105  Void  xPrintParameter();
    99106#endif
    100   Bool  xCheckParameter();
     107  Bool  xCheckParameter( Bool isField );
    101108
    102109  Void    setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p;          }
     
    107114  Int     getSourceWidth()            {return m_iSourceWidth;     }
    108115  Int     getSourceHeight()           {return m_iSourceHeight;    }
     116  Int     getSourceHeightOrg()        {return m_iSourceHeightOrg; }
    109117  Int     getConformanceMode()        { return m_conformanceMode; }
    110118  Int*    getPad()                    {return m_aiPad;            }
     
    147155  GOPEntry getGOPEntry(Int i )        {return m_GOPListLayer[i];  }
    148156#endif
     157#if REPN_FORMAT_IN_VPS
     158  Int     getRepFormatIdx()           { return m_repFormatIdx;  }
     159  Void    setRepFormatIdx(Int x)      { m_repFormatIdx = x;     }
     160  Void    setSourceWidth(Int x)       { m_iSourceWidth = x;     }
     161  Void    setSourceHeight(Int x)      { m_iSourceHeight = x;    }
     162#endif
     163#if N0120_MAX_TID_REF_CFG
     164  Int     getMaxTidIlRefPicsPlus1()   { return m_maxTidIlRefPicsPlus1; }
     165#endif
    149166}; // END CLASS DEFINITION TAppEncLayerCfg
    150167
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r345 r442  
    9090    vps->setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
    9191  }
    92 
     92#if REPN_FORMAT_IN_VPS
     93  vps->setRepFormatIdxPresentFlag( true );   // Could be disabled to optimize in some cases.
     94  Int maxRepFormatIdx = -1;
     95  Int formatIdx = -1;
     96  for(UInt layer=0; layer < m_numLayers; layer++)
     97  {
     98    // Auto generation of the format index
     99    if( m_acLayerCfg[layer].getRepFormatIdx() == -1 )
     100    {
     101      // Currently only picture width and height are considred. It has to be updated if different chroma format and bit-depth will are used.
     102      Bool found = false;
     103      for( UInt idx = 0; idx < layer; idx++ )
     104      {
     105        if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight() )
     106        {
     107          found = true;
     108          break;
     109        }
     110      }
     111      if( !found )
     112      {
     113        formatIdx++;
     114      }
     115
     116      m_acLayerCfg[layer].setRepFormatIdx( formatIdx );
     117    }
     118
     119    assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );   
     120    vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() );
     121    maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx );
     122  }
     123  assert( vps->getVpsRepFormatIdx( 0 ) == 0 );  // Base layer should point to the first one.
     124  Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1];
     125  // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS
     126  for(Int i = 0; i <= maxRepFormatIdx; i++)
     127  {
     128    mapIdxToLayer[i] = -1;
     129    UInt layer;
     130    for(layer=0; layer < m_numLayers; layer++)
     131    {
     132      if( vps->getVpsRepFormatIdx(layer) == i )
     133      {
     134        mapIdxToLayer[i] = layer;
     135        break;
     136      }
     137    }
     138    assert( layer != m_numLayers );   // One of the VPS Rep format indices not set
     139  }
     140  vps->setVpsNumRepFormats( maxRepFormatIdx + 1 );
     141  for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++)
     142  {
     143    RepFormat *repFormat = vps->getVpsRepFormat( idx );   
     144    repFormat->setPicWidthVpsInLumaSamples  ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth()   );
     145    repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight()  );
     146    repFormat->setChromaFormatVpsIdc        ( 1                                             );  // Need modification to change for each layer - corresponds to 420
     147    repFormat->setSeparateColourPlaneVpsFlag( 0                                             );  // Need modification to change for each layer
     148    repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY()                        );  // Need modification to change for each layer
     149    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
     150  }
     151  delete [] mapIdxToLayer;
     152#endif
    93153  for(UInt layer=0; layer<m_numLayers; layer++)
    94154  {
     
    157217    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
    158218    m_acTEncTop[layer].setUseAMP( m_enableAMP );
     219#if N0120_MAX_TID_REF_CFG
     220    if (layer<m_numLayers-1)
     221    {
     222       m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1());
     223    }
     224#endif
    159225#if VPS_EXTN_DIRECT_REF_LAYERS
    160226    if(layer)
     
    195261        {
    196262          m_acTEncTop[layer].setMotionPredRefLayerId   ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i));
    197           m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true);
     263          m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true);
    198264        }       
    199265      }
     
    397463    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    398464    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     465#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     466    m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled );
     467    m_acTEncTop[layer].setIlNumSetsInMessage( m_ilNumSetsInMessage );
     468    m_acTEncTop[layer].setSkippedTileSetPresentFlag( m_skippedTileSetPresentFlag );
     469    m_acTEncTop[layer].setTopLeftTileIndex( m_topLeftTileIndex );
     470    m_acTEncTop[layer].setBottomRightTileIndex( m_bottomRightTileIndex );
     471    m_acTEncTop[layer].setIlcIdc( m_ilcIdc );
     472#endif
    399473    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    400474    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    475549    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    476550    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    477 #if REF_IDX_FRAMEWORK
    478551    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
    479 #endif
    480552#if SCALED_REF_LAYER_OFFSETS
    481553    if( layer > 0 )
     
    824896}
    825897
    826 Void TAppEncTop::xInitLib()
     898Void TAppEncTop::xInitLib(Bool isFieldCoding)
    827899{
    828900#if SVC_EXTENSION
    829901  for(UInt layer=0; layer<m_numLayers; layer++)
    830902  {
    831     m_acTEncTop[layer].init();
     903    m_acTEncTop[layer].init(isFieldCoding);
    832904  }
    833905#if VPS_RENAME
     
    889961#endif
    890962#if N0120_MAX_TID_REF_PRESENT_FLAG
    891   vps->setMaxTidIlRefPicsPlus1PresentFlag(true);
    892   if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
     963#if N0120_MAX_TID_REF_CFG
     964  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
     965#else
     966  vps->setMaxTidRefPresentFlag(true);
     967#endif
     968  if (vps->getMaxTidRefPresentFlag())
    893969  {
    894970    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    895971    {
    896       vps->setMaxSublayerForIlpPlus1(i, vps->getMaxTLayers()+1);
     972#if N0120_MAX_TID_REF_CFG
     973      vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
     974#else
     975      vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
     976#endif
    897977    }
    898978  }
     
    901981    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    902982    {
    903       vps->setMaxSublayerForIlpPlus1(i, 7);
     983      vps->setMaxTidIlRefPicsPlus1(i, 7);
    904984    }
    905985  }
     
    9831063#endif
    9841064  }
     1065#if IL_SL_SIGNALLING_N0371
     1066  for(i = 1; i < vps->getMaxLayers(); i++)
     1067  {
     1068    for(Int j = 0; j < i; j++)
     1069    {
     1070      vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) );
     1071    }
     1072  }
     1073#endif
    9851074#endif
    9861075#if JCTVC_M0458_INTERLAYER_RPS_SIG       
    9871076    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
    9881077#endif
     1078#if N0147_IRAP_ALIGN_FLAG   
     1079    vps->setCrossLayerIrapAlignFlag(true);
     1080    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1081    {
     1082      for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1083      {
     1084        if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
     1085        {         
     1086          if(m_acTEncTop[layerCtr].getIntraPeriod() !=  m_acTEncTop[refLayerCtr].getIntraPeriod())
     1087          {
     1088            vps->setCrossLayerIrapAlignFlag(false);
     1089            break;
     1090          }
     1091        }
     1092      }
     1093    }
     1094
     1095    if( vps->getAvcBaseLayerFlag() )
     1096    {
     1097      vps->setCrossLayerIrapAlignFlag(false);
     1098    }
     1099#endif
    9891100#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    9901101  vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false);
    9911102#endif
    992 #else
    993   m_cTEncTop.init();
    994 #endif
     1103#if VPS_EXTN_OFFSET
     1104  // to be updated according to the current semantics
     1105  vps->setExtensionOffset( 0xffff );
     1106#endif
     1107#else //SVC_EXTENSION
     1108  m_cTEncTop.init(isFieldCoding);
     1109#endif //SVC_EXTENSION
    9951110}
    9961111
     
    10231138  xInitLibCfg();
    10241139  xCreateLib();
    1025   xInitLib();
     1140  xInitLib(m_isField);
    10261141
    10271142  // main encoder loop
     
    10351150    // allocate original YUV buffer
    10361151    pcPicYuvOrg[layer] = new TComPicYuv;
     1152    if( m_isField )
     1153    {
    10371154#if SVC_UPSAMPLING
    1038     pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
    1039 #else
    1040     pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1041 #endif
     1155      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1156#else
     1157      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1158#endif
     1159    }
     1160    else
     1161    {
     1162#if SVC_UPSAMPLING
     1163      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1164#else
     1165      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1166#endif
     1167    }
    10421168  }
    10431169
     
    10811207          m_iFrameRcvd++;
    10821208          // check end of file
    1083           bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     1209          bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    10841210        }
    10851211
    1086         m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     1212        if ( m_isField )
     1213        {
     1214          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst );
     1215        }
     1216        else
     1217        {
     1218          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     1219        }
    10871220      }
    10881221
     
    11311264      {
    11321265        // call encoding function for one frame
    1133         m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1266        if ( m_isField )
     1267        {
     1268          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
     1269        }
     1270        else
     1271        {
     1272          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1273        }
    11341274      }
    11351275    }
     
    11681308    if (bEos)
    11691309    {
    1170       printOutSummary();
     1310      printOutSummary(m_isTopFieldFirst);
    11711311    }
    11721312
     
    12001340}
    12011341
    1202 Void TAppEncTop::printOutSummary()
     1342Void TAppEncTop::printOutSummary(Bool isField)
    12031343{
    12041344  UInt layer;
     
    12071347  for(layer = 0; layer < m_numLayers; layer++)
    12081348  {
    1209     m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
    1210     m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
    1211     m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
    1212     m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1349    if(isField)
     1350    {
     1351      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2);
     1352      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1353      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1354      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1355    }
     1356    else
     1357    {
     1358      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1359      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1360      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1361      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1362    }
    12131363  }
    12141364
     
    12411391    m_gcAnalyzeB[layer].printOut('b', layer);
    12421392  }
     1393
     1394  if(isField)
     1395  {
     1396    for(layer = 0; layer < m_numLayers; layer++)
     1397    {
     1398      //-- interlaced summary
     1399      m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1400      printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
     1401      m_gcAnalyzeAll_in.printOutInterlaced('a',  m_gcAnalyzeAll[layer].getBits());
     1402
     1403#if _SUMMARY_OUT_
     1404      m_gcAnalyzeAll_in.printSummaryOutInterlaced();
     1405#endif
     1406    }
     1407  }
    12431408}
    12441409
     
    12591424  xInitLibCfg();
    12601425  xCreateLib();
    1261   xInitLib();
     1426  xInitLib(m_isField);
    12621427
    12631428  // main encoder loop
     
    12681433
    12691434  // allocate original YUV buffer
    1270   pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1435  if( m_isField )
     1436  {
     1437    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1438  }
     1439  else
     1440  {
     1441    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1442  }
    12711443
    12721444  while ( !bEos )
     
    12811453    m_iFrameRcvd++;
    12821454
    1283     bEos = (m_iFrameRcvd == m_framesToBeEncoded);
    1284 
     1455    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    12851456    Bool flush = 0;
    12861457    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     
    12941465
    12951466    // call encoding function for one frame
     1467    if ( m_isField )
     1468    {
     1469      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
     1470    }
     1471    else
     1472    {
    12961473    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     1474    }
    12971475
    12981476    // write bistream to file if necessary
     
    13041482  }
    13051483
    1306   m_cTEncTop.printSummary();
     1484  m_cTEncTop.printSummary(m_isField);
    13071485
    13081486  // delete original YUV buffer
     
    13781556Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
    13791557{
    1380   Int i;
    1381 
    1382   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
    1383 
    1384   for ( i = 0; i < iNumEncoded; i++ )
    1385   {
    1386     --iterPicYuvRec;
    1387   }
    1388 
    1389   for ( i = 0; i < iNumEncoded; i++ )
    1390   {
    1391     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1558  if (m_isField)
     1559  {
     1560    //Reinterlace fields
     1561    Int i;
     1562    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1563
     1564    for ( i = 0; i < iNumEncoded; i++ )
     1565    {
     1566      --iterPicYuvRec;
     1567    }
     1568
     1569    for ( i = 0; i < iNumEncoded/2; i++ )
     1570    {
     1571      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1572      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1573
    13921574#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    1393     if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
    1394 #else
    1395     if (!m_acLayerCfg[layer].getReconFile().empty())
    1396 #endif
    1397     {
    1398       m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    1399         m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1575      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed())
     1576#else
     1577      if (!m_acLayerCfg[layer].getReconFile().empty())
     1578#endif
     1579      {
     1580        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
     1581      }
     1582    }
     1583  }
     1584  else
     1585  {
     1586    Int i;
     1587
     1588    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1589
     1590    for ( i = 0; i < iNumEncoded; i++ )
     1591    {
     1592      --iterPicYuvRec;
     1593    }
     1594
     1595    for ( i = 0; i < iNumEncoded; i++ )
     1596    {
     1597      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1598#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1599      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
     1600#else
     1601      if (!m_acLayerCfg[layer].getReconFile().empty())
     1602#endif
     1603      {
     1604        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
     1605          m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1606      }
    14001607    }
    14011608  }
     
    14041611Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    14051612{
    1406   Int i;
    1407 
    1408   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1613  if (m_isField)
     1614  {
     1615    //Reinterlace fields
     1616    Int i;
     1617    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    14091618
    14101619#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    1411   for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
    1412 #else
    1413   for ( i = 0; i < iNumEncoded; i++ )
    1414 #endif
    1415   {
    1416     const AccessUnit& au = *(iterBitstream++);
    1417     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1418     rateStatsAccum(au, stats);
     1620    for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ )
     1621#else
     1622    for ( i = 0; i < iNumEncoded/2; i++ )
     1623#endif
     1624    {     
     1625      const AccessUnit& auTop = *(iterBitstream++);
     1626      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1627      rateStatsAccum(auTop, statsTop);
     1628
     1629      const AccessUnit& auBottom = *(iterBitstream++);
     1630      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1631      rateStatsAccum(auBottom, statsBottom);
     1632    }
     1633  }
     1634  else
     1635  {
     1636    Int i;
     1637
     1638    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1639
     1640#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1641    for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
     1642#else
     1643    for ( i = 0; i < iNumEncoded; i++ )
     1644#endif
     1645    {
     1646      const AccessUnit& au = *(iterBitstream++);
     1647      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1648      rateStatsAccum(au, stats);
     1649    }
    14191650  }
    14201651}
     
    14601691Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    14611692{
    1462   Int i;
    1463 
    1464   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    1465   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    1466 
    1467   for ( i = 0; i < iNumEncoded; i++ )
    1468   {
    1469     --iterPicYuvRec;
    1470   }
    1471 
    1472   for ( i = 0; i < iNumEncoded; i++ )
    1473   {
    1474     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1475     if (m_pchReconFile)
    1476     {
    1477 #if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
    1478       m_cTVideoIOYuvReconFile.write( pcPicYuvRec );
    1479 #else
    1480       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    1481 #endif
    1482     }
    1483 
    1484     const AccessUnit& au = *(iterBitstream++);
    1485     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1486     rateStatsAccum(au, stats);
     1693  if (m_isField)
     1694  {
     1695    //Reinterlace fields
     1696    Int i;
     1697    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1698    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1699
     1700    for ( i = 0; i < iNumEncoded; i++ )
     1701    {
     1702      --iterPicYuvRec;
     1703    }
     1704
     1705    for ( i = 0; i < iNumEncoded/2; i++ )
     1706    {
     1707      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1708      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1709
     1710      if (m_pchReconFile)
     1711      {
     1712        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1713      }
     1714
     1715      const AccessUnit& auTop = *(iterBitstream++);
     1716      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1717      rateStatsAccum(auTop, statsTop);
     1718
     1719      const AccessUnit& auBottom = *(iterBitstream++);
     1720      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1721      rateStatsAccum(auBottom, statsBottom);
     1722    }
     1723  }
     1724  else
     1725  {
     1726    Int i;
     1727
     1728    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1729    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1730
     1731    for ( i = 0; i < iNumEncoded; i++ )
     1732    {
     1733      --iterPicYuvRec;
     1734    }
     1735
     1736    for ( i = 0; i < iNumEncoded; i++ )
     1737    {
     1738      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1739      if (m_pchReconFile)
     1740      {
     1741#if SYNTAX_OUTPUT
     1742        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1743#endif
     1744      }
     1745
     1746      const AccessUnit& au = *(iterBitstream++);
     1747      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1748      rateStatsAccum(au, stats);
     1749    }
    14871750  }
    14881751}
  • trunk/source/App/TAppEncoder/TAppEncTop.h

    r313 r442  
    8282  Void  xCreateLib        ();                               ///< create files & encoder class
    8383  Void  xInitLibCfg       ();                               ///< initialize internal variables
    84   Void  xInitLib          ();                               ///< initialize encoder class
     84  Void  xInitLib          (Bool isFieldCoding);             ///< initialize encoder class
    8585  Void  xDestroyLib       ();                               ///< destroy encoder class
    8686 
     
    9999  Void xWriteRecon(UInt layer, Int iNumEncoded);
    100100  Void xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits);
    101   Void printOutSummary();
     101  Void printOutSummary(Bool isField);
    102102#else
    103103  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
Note: See TracChangeset for help on using the changeset viewer.