Changeset 431 in SHVCSoftware for branches/SHM-3.1-dev/source/App


Ignore:
Timestamp:
11 Oct 2013, 05:54:02 (11 years ago)
Author:
seregin
Message:

initial porting of HM12

Location:
branches/SHM-3.1-dev/source/App
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-3.1-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r389 r431  
    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  }
     
    235233    if( pcListPic )
    236234    {
    237       if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
     235      if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] )
    238236      {
    239237        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }       
     
    242240        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    243241
    244         recon_opened[curLayerId] = true;
     242        openedReconFile[curLayerId] = true;
    245243      }
    246244      if ( bNewPicture && bNewPOC &&
     
    278276  pcBLPic.destroy();
    279277
    280   for(UInt layer = 1; layer <= m_tgtLayerId; layer++)
     278  UInt layerIdmin = m_acTDecTop[0].getBLReconFile() == NULL ? 0 : 1;
     279
     280  for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++)
    281281#else
    282282  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     
    310310
    311311  // main decoder loop
    312   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)
    313313
    314314#if SYNTAX_OUTPUT
     
    341341    streampos location = bitstreamFile.tellg();
    342342    AnnexBStats stats = AnnexBStats();
    343     Bool bPreviousPictureDecoded = false;
    344343
    345344    vector<uint8_t> nalUnit;
     
    363362      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    364363      {
    365         if(bPreviousPictureDecoded)
    366         {
    367           bNewPicture = true;
    368           bPreviousPictureDecoded = false;
    369         }
    370         else
    371         {
    372364          bNewPicture = false;
    373365        }
    374       }
    375366      else
    376367      {
     
    386377          bytestream.reset();
    387378        }
    388         bPreviousPictureDecoded = true;
    389379      }
    390380    }
     
    396386    if( pcListPic )
    397387    {
    398       if ( m_pchReconFile && !recon_opened )
     388      if ( m_pchReconFile && !openedReconFile )
    399389      {
    400390        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
     
    402392
    403393        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    404         recon_opened = true;
     394        openedReconFile = true;
    405395      }
    406396      if ( bNewPicture &&
     
    508498
    509499/** \param pcListPic list of pictures to be written to file
    510     \todo            DYN_REF_FREE should be revised
    511  */
     500\todo            DYN_REF_FREE should be revised
     501*/
    512502#if SVC_EXTENSION
    513503Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId )
     
    517507{
    518508  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    519   Int not_displayed = 0;
     509  Int numPicsNotYetDisplayed = 0;
    520510
    521511  while (iterPic != pcListPic->end())
     
    528518#endif
    529519    {
    530        not_displayed++;
     520      numPicsNotYetDisplayed++;
    531521    }
    532522    iterPic++;
    533523  }
    534524  iterPic   = pcListPic->begin();
    535  
    536   while (iterPic != pcListPic->end())
    537   {
    538     TComPic* pcPic = *(iterPic);
    539    
    540 #if SVC_EXTENSION
    541     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
    542 #else
    543     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
    544 #endif
    545     {
    546       // write to file
    547        not_displayed--;
    548 #if SVC_EXTENSION
    549       if ( m_pchReconFile[layerId] )
    550       {
    551         const Window &conf = pcPic->getConformanceWindow();
    552         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     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();
    553558#if REPN_FORMAT_IN_VPS
    554         UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
    555         Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    556         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    557                                        conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
    558                                        conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
    559                                        conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
    560                                        conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
    561 
    562 #else
    563         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    564                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    565                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    566                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    567                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    568 #endif
    569       }
    570      
    571       // update POC of display order
    572       m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
    573 #else
    574       if ( m_pchReconFile )
    575       {
     559          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     560          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     561          m_acTVideoIOYuvReconFile[layerId].write( pcPic->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() );
     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        {
     598#if !DYN_REF_FREE
     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        {
    576674#if SYNTAX_OUTPUT
    577         const Window &conf = pcPic->getConformanceWindow();
    578         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    579         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    580                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    581                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    582                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    583                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    584 #endif
    585       }
    586      
    587       // update POC of display order
    588       m_iPOCLastDisplay = pcPic->getPOC();
    589 #endif
    590      
    591       // erase non-referenced picture in the reference picture list after display
    592       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    593       {
     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        {
    594692#if !DYN_REF_FREE
    595         pcPic->setReconMark(false);
    596        
    597         // mark it should be extended later
    598         pcPic->getPicYuvRec()->setBorderExtension( false );
    599        
    600 #else
    601         pcPic->destroy();
    602         pcListPic->erase( iterPic );
    603         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    604         continue;
    605 #endif
    606       }
    607       pcPic->setOutputMark(false);
    608     }
    609    
    610     iterPic++;
     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    }
    611710  }
    612711}
     
    628727
    629728  iterPic   = pcListPic->begin();
    630  
    631   while (iterPic != pcListPic->end())
    632   {
    633     TComPic* pcPic = *(iterPic);
    634 
    635     if ( pcPic->getOutputMark() )
    636     {
    637       // write to file
    638 #if SVC_EXTENSION
    639       if ( m_pchReconFile[layerId] )
    640       {
    641         const Window &conf = pcPic->getConformanceWindow();
    642         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     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();
    643751#if REPN_FORMAT_IN_VPS
    644         UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
    645         Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    646         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    647                                        conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
    648                                        conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
    649                                        conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
    650                                        conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
    651 
    652 #else
    653         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    654                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    655                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    656                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    657                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    658 #endif
    659       }
    660      
    661       // update POC of display order
    662       m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
    663 #else
    664       if ( m_pchReconFile )
    665       {
    666         const Window &conf = pcPic->getConformanceWindow();
    667         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    668         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    669                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    670                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    671                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    672                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    673       }
    674      
    675       // update POC of display order
    676       m_iPOCLastDisplay = pcPic->getPOC();
    677 #endif
    678      
    679       // erase non-referenced picture in the reference picture list after display
    680       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    681       {
     752          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     753          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     754          m_acTVideoIOYuvReconFile[layerId].write( pcPic->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() );
     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        {
    682791#if !DYN_REF_FREE
    683         pcPic->setReconMark(false);
    684        
    685         // mark it should be extended later
    686         pcPic->getPicYuvRec()->setBorderExtension( false );
    687        
    688 #else
    689         pcPic->destroy();
    690         pcListPic->erase( iterPic );
    691         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    692         continue;
    693 #endif
    694       }
    695       pcPic->setOutputMark(false);
    696     }
     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      }
    697907#if !SVC_EXTENSION
    698908#if !DYN_REF_FREE
    699     if(pcPic)
    700     {
    701       pcPic->destroy();
    702       delete pcPic;
    703       pcPic = NULL;
    704     }
     909      if(pcPic)
     910      {
     911        pcPic->destroy();
     912        delete pcPic;
     913        pcPic = NULL;
     914      }
    705915#endif   
    706916#endif
    707     iterPic++;
     917      iterPic++;
     918    }
    708919  }
    709920#if SVC_EXTENSION
  • branches/SHM-3.1-dev/source/App/TAppDecoder/TAppDecTop.h

    r313 r431  
    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
  • branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r405 r431  
    348348 
    349349#if SVC_EXTENSION
    350   string  cfg_LayerCfgFile  [MAX_LAYERS];
     350  string  cfg_LayerCfgFile   [MAX_LAYERS];
    351351  string  cfg_BitstreamFile;
    352   string* cfg_InputFile     [MAX_LAYERS];
    353   string* cfg_ReconFile     [MAX_LAYERS];
    354   Double* cfg_fQP           [MAX_LAYERS];
     352  string* cfg_InputFile      [MAX_LAYERS];
     353  string* cfg_ReconFile      [MAX_LAYERS];
     354  Double* cfg_fQP            [MAX_LAYERS];
    355355
    356356#if REPN_FORMAT_IN_VPS
     
    565565  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
    566566#endif
     567
     568  //Field coding parameters
     569  ("FieldCoding", m_isField, false, "Signals if it's a field based coding")
     570  ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not")
    567571  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
    568572  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
     
    862866  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
    863867
     868  if(m_isField)
     869  {
     870#if SVC_EXTENSION
     871    for(Int layer = 0; layer < MAX_LAYERS; layer++)
     872    {
     873      //Frame height
     874      m_acLayerCfg[layer].m_iSourceHeightOrg = m_acLayerCfg[layer].m_iSourceHeight;
     875      //Field height
     876      m_acLayerCfg[layer].m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight >> 1;
     877    }
     878#else
     879    //Frame height
     880    m_iSourceHeightOrg = m_iSourceHeight;
     881    //Field height
     882    m_iSourceHeight = m_iSourceHeight >> 1;
     883#endif
     884    //number of fields to encode
     885    m_framesToBeEncoded *= 2;
     886  }
     887 
    864888  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    865889  {
     
    11931217        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    11941218        m_iSourceHeight += m_confBottom;
     1219        if ( m_isField )
     1220        {
     1221          m_iSourceHeightOrg += m_confBottom << 1;
     1222          m_aiPad[1] = m_confBottom << 1;
     1223        }
    11951224      }
    11961225      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
     
    15151544#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    15161545  Int checkGOP=1;
    1517   Int numRefs = 1;
     1546  Int numRefs = m_isField ? 2 : 1;
    15181547#endif
    15191548  Int refList[MAX_NUM_REF_PICS+1];
    15201549  refList[0]=0;
     1550  if(m_isField)
     1551  {
     1552    refList[1] = 1;
     1553  }
    15211554  Bool isOK[MAX_GOP];
    15221555  for(Int i=0; i<MAX_GOP; i++)
     
    15461579  for(UInt layer=0; layer<m_numLayers; layer++)
    15471580  {
    1548     if(m_acLayerCfg[layer].xCheckParameter())
     1581    if(m_acLayerCfg[layer].xCheckParameter(m_isField))
    15491582    {
    15501583      printf("\nError: invalid configuration parameter found in layer %d \n", layer);
     
    21812214  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    21822215#endif
    2183   printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2216  if (m_isField)
     2217  {
     2218    printf("Frame/Field          : Field based coding\n");
     2219    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2220    if (m_isTopFieldFirst)
     2221    {
     2222      printf("Field Order            : Top field first\n");
     2223    }
     2224    else
     2225    {
     2226      printf("Field Order            : Bottom field first\n");
     2227    }
     2228  }
     2229  else
     2230  {
     2231    printf("Frame/Field                  : Frame based coding\n");
     2232    printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2233  }
    21842234  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
    21852235  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
  • branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.h

    r402 r431  
    8888  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    8989  Int       m_iSourceWidth;                                   ///< source width in pixel
    90   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 
    9195  Int       m_conformanceMode;
    9296  Int       m_confLeft;
     
    97101  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    98102#endif 
     103
     104  Bool      m_isField;                                        ///< enable field coding
     105  Bool      m_isTopFieldFirst;
    99106
    100107  // profile/level
  • branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r389 r431  
    161161Bool confirmPara(Bool bflag, const char* message);
    162162
    163 Bool TAppEncLayerCfg::xCheckParameter()
     163Bool TAppEncLayerCfg::xCheckParameter( Bool isField )
    164164{
    165165  switch (m_conformanceMode)
     
    185185        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    186186        m_iSourceHeight += m_confBottom;
     187        if ( isField )
     188        {
     189          m_iSourceHeightOrg += m_confBottom << 1;
     190          m_aiPad[1] = m_confBottom << 1;
     191        }
    187192      }
    188193      break;
  • branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h

    r403 r431  
    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;
     
    104105  Void  xPrintParameter();
    105106#endif
    106   Bool  xCheckParameter();
     107  Bool  xCheckParameter( Bool isField );
    107108
    108109  Void    setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p;          }
     
    113114  Int     getSourceWidth()            {return m_iSourceWidth;     }
    114115  Int     getSourceHeight()           {return m_iSourceHeight;    }
     116  Int     getSourceHeightOrg()        {return m_iSourceHeightOrg; }
    115117  Int     getConformanceMode()        { return m_conformanceMode; }
    116118  Int*    getPad()                    {return m_aiPad;            }
  • branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r427 r431  
    888888}
    889889
    890 Void TAppEncTop::xInitLib()
     890Void TAppEncTop::xInitLib(Bool isFieldCoding)
    891891{
    892892#if SVC_EXTENSION
    893893  for(UInt layer=0; layer<m_numLayers; layer++)
    894894  {
    895     m_acTEncTop[layer].init();
     895    m_acTEncTop[layer].init(isFieldCoding);
    896896  }
    897897#if VPS_RENAME
     
    10911091  vps->setExtensionOffset( 0xffff );
    10921092#endif
    1093 #else
    1094   m_cTEncTop.init();
    1095 #endif
     1093#else //SVC_EXTENSION
     1094  m_cTEncTop.init(isFieldCoding);
     1095#endif //SVC_EXTENSION
    10961096}
    10971097
     
    11241124  xInitLibCfg();
    11251125  xCreateLib();
    1126   xInitLib();
     1126  xInitLib(m_isField);
    11271127
    11281128  // main encoder loop
     
    11361136    // allocate original YUV buffer
    11371137    pcPicYuvOrg[layer] = new TComPicYuv;
     1138    if( m_isField )
     1139    {
    11381140#if SVC_UPSAMPLING
    1139     pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
    1140 #else
    1141     pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1142 #endif
     1141      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1142#else
     1143      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1144#endif
     1145    }
     1146    else
     1147    {
     1148#if SVC_UPSAMPLING
     1149      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1150#else
     1151      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1152#endif
     1153    }
    11431154  }
    11441155
     
    11821193          m_iFrameRcvd++;
    11831194          // check end of file
    1184           bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     1195          bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    11851196        }
    11861197
    1187         m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     1198        if ( m_isField )
     1199        {
     1200          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst );
     1201        }
     1202        else
     1203        {
     1204          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     1205        }
    11881206      }
    11891207
     
    12321250      {
    12331251        // call encoding function for one frame
    1234         m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1252        if ( m_isField )
     1253        {
     1254          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
     1255        }
     1256        else
     1257        {
     1258          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1259        }
    12351260      }
    12361261    }
     
    12691294    if (bEos)
    12701295    {
    1271       printOutSummary();
     1296      printOutSummary(m_isTopFieldFirst);
    12721297    }
    12731298
     
    13011326}
    13021327
    1303 Void TAppEncTop::printOutSummary()
     1328Void TAppEncTop::printOutSummary(Bool isField)
    13041329{
    13051330  UInt layer;
     
    13081333  for(layer = 0; layer < m_numLayers; layer++)
    13091334  {
    1310     m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
    1311     m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
    1312     m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
    1313     m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1335    if(isField)
     1336    {
     1337      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1338      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1339      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1340      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1341    }
     1342    else
     1343    {
     1344      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2);
     1345      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1346      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1347      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1348    }
    13141349  }
    13151350
     
    13421377    m_gcAnalyzeB[layer].printOut('b', layer);
    13431378  }
     1379
     1380  if(isField)
     1381  {
     1382    for(layer = 0; layer < m_numLayers; layer++)
     1383    {
     1384      //-- interlaced summary
     1385      m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1386      printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
     1387      m_gcAnalyzeAll_in.printOutInterlaced('a',  m_gcAnalyzeAll[layer].getBits());
     1388
     1389#if _SUMMARY_OUT_
     1390      m_gcAnalyzeAll_in.printSummaryOutInterlaced();
     1391#endif
     1392    }
     1393  }
    13441394}
    13451395
     
    13601410  xInitLibCfg();
    13611411  xCreateLib();
    1362   xInitLib();
     1412  xInitLib(m_isField);
    13631413
    13641414  // main encoder loop
     
    13691419
    13701420  // allocate original YUV buffer
    1371   pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1421  if( m_isField )
     1422  {
     1423    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1424  }
     1425  else
     1426  {
     1427    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1428  }
    13721429
    13731430  while ( !bEos )
     
    13821439    m_iFrameRcvd++;
    13831440
    1384     bEos = (m_iFrameRcvd == m_framesToBeEncoded);
    1385 
     1441    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    13861442    Bool flush = 0;
    13871443    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     
    13951451
    13961452    // call encoding function for one frame
     1453    if ( m_isField )
     1454    {
     1455      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
     1456    }
     1457    else
     1458    {
    13971459    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     1460    }
    13981461
    13991462    // write bistream to file if necessary
     
    14051468  }
    14061469
    1407   m_cTEncTop.printSummary();
     1470  m_cTEncTop.printSummary(m_isField);
    14081471
    14091472  // delete original YUV buffer
     
    14791542Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
    14801543{
    1481   Int i;
    1482 
    1483   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
    1484 
    1485   for ( i = 0; i < iNumEncoded; i++ )
    1486   {
    1487     --iterPicYuvRec;
    1488   }
    1489 
    1490   for ( i = 0; i < iNumEncoded; i++ )
    1491   {
    1492     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1544  if (m_isField)
     1545  {
     1546    //Reinterlace fields
     1547    Int i;
     1548    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1549
     1550    for ( i = 0; i < iNumEncoded; i++ )
     1551    {
     1552      --iterPicYuvRec;
     1553    }
     1554
     1555    for ( i = 0; i < iNumEncoded/2; i++ )
     1556    {
     1557      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1558      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1559
    14931560#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    1494     if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
    1495 #else
    1496     if (!m_acLayerCfg[layer].getReconFile().empty())
    1497 #endif
    1498     {
    1499       m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    1500         m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1561      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed())
     1562#else
     1563      if (!m_acLayerCfg[layer].getReconFile().empty())
     1564#endif
     1565      {
     1566        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
     1567      }
     1568    }
     1569  }
     1570  else
     1571  {
     1572    Int i;
     1573
     1574    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1575
     1576    for ( i = 0; i < iNumEncoded; i++ )
     1577    {
     1578      --iterPicYuvRec;
     1579    }
     1580
     1581    for ( i = 0; i < iNumEncoded; i++ )
     1582    {
     1583      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1584#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1585      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
     1586#else
     1587      if (!m_acLayerCfg[layer].getReconFile().empty())
     1588#endif
     1589      {
     1590        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
     1591          m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1592      }
    15011593    }
    15021594  }
     
    15051597Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    15061598{
    1507   Int i;
    1508 
    1509   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1599  if (m_isField)
     1600  {
     1601    //Reinterlace fields
     1602    Int i;
     1603    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    15101604
    15111605#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    1512   for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
    1513 #else
    1514   for ( i = 0; i < iNumEncoded; i++ )
    1515 #endif
    1516   {
    1517     const AccessUnit& au = *(iterBitstream++);
    1518     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1519     rateStatsAccum(au, stats);
     1606    for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ )
     1607#else
     1608    for ( i = 0; i < iNumEncoded/2; i++ )
     1609#endif
     1610    {     
     1611      const AccessUnit& auTop = *(iterBitstream++);
     1612      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1613      rateStatsAccum(auTop, statsTop);
     1614
     1615      const AccessUnit& auBottom = *(iterBitstream++);
     1616      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1617      rateStatsAccum(auBottom, statsBottom);
     1618    }
     1619  }
     1620  else
     1621  {
     1622    Int i;
     1623
     1624    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1625
     1626#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1627    for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
     1628#else
     1629    for ( i = 0; i < iNumEncoded; i++ )
     1630#endif
     1631    {
     1632      const AccessUnit& au = *(iterBitstream++);
     1633      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1634      rateStatsAccum(au, stats);
     1635    }
    15201636  }
    15211637}
     
    15611677Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    15621678{
    1563   Int i;
    1564 
    1565   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    1566   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    1567 
    1568   for ( i = 0; i < iNumEncoded; i++ )
    1569   {
    1570     --iterPicYuvRec;
    1571   }
    1572 
    1573   for ( i = 0; i < iNumEncoded; i++ )
    1574   {
    1575     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1576     if (m_pchReconFile)
    1577     {
     1679  if (m_isField)
     1680  {
     1681    //Reinterlace fields
     1682    Int i;
     1683    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1684    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1685
     1686    for ( i = 0; i < iNumEncoded; i++ )
     1687    {
     1688      --iterPicYuvRec;
     1689    }
     1690
     1691    for ( i = 0; i < iNumEncoded/2; i++ )
     1692    {
     1693      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1694      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1695
     1696      if (m_pchReconFile)
     1697      {
     1698        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1699      }
     1700
     1701      const AccessUnit& auTop = *(iterBitstream++);
     1702      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1703      rateStatsAccum(auTop, statsTop);
     1704
     1705      const AccessUnit& auBottom = *(iterBitstream++);
     1706      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1707      rateStatsAccum(auBottom, statsBottom);
     1708    }
     1709  }
     1710  else
     1711  {
     1712    Int i;
     1713
     1714    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1715    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1716
     1717    for ( i = 0; i < iNumEncoded; i++ )
     1718    {
     1719      --iterPicYuvRec;
     1720    }
     1721
     1722    for ( i = 0; i < iNumEncoded; i++ )
     1723    {
     1724      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1725      if (m_pchReconFile)
     1726      {
    15781727#if SYNTAX_OUTPUT
    1579       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    1580 #endif
    1581     }
    1582 
    1583     const AccessUnit& au = *(iterBitstream++);
    1584     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1585     rateStatsAccum(au, stats);
     1728        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1729#endif
     1730      }
     1731
     1732      const AccessUnit& au = *(iterBitstream++);
     1733      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1734      rateStatsAccum(au, stats);
     1735    }
    15861736  }
    15871737}
     
    16021752    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    16031753    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1604     case NAL_UNIT_CODED_SLICE_TSA_R:
     1754    case NAL_UNIT_CODED_SLICE_TLA_R:
    16051755    case NAL_UNIT_CODED_SLICE_TSA_N:
    16061756    case NAL_UNIT_CODED_SLICE_STSA_R:
  • branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.h

    r313 r431  
    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.