Changeset 651 in 3DVCSoftware


Ignore:
Timestamp:
21 Oct 2013, 17:52:23 (11 years ago)
Author:
tech
Message:

Update to HM 12.0.

Location:
branches/HTM-8.2-dev0-Cleanup
Files:
72 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_intra_main.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_intra_main10.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main10
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_lowdelay_P_main.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_lowdelay_P_main10.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main10
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_lowdelay_main.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_lowdelay_main10.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main10
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_randomaccess_main.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/encoder_randomaccess_main10.cfg

    r608 r651  
    33ReconFile                     : rec.yuv
    44
    5 #======== Profile/Level ================
     5#======== Profile ================
    66Profile                       : main10
    7 Level                         : 6.2
    87
    98#======== Unit definition ================
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BQMall.cfg

    r608 r651  
    77SourceHeight                  : 480         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BQSquare.cfg

    r608 r651  
    77SourceHeight                  : 240         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 2.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BQTerrace.cfg

    r608 r651  
    77SourceHeight                  : 1080        # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BasketballDrill.cfg

    r608 r651  
    77SourceHeight                  : 480         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BasketballDrillText.cfg

    r608 r651  
    77SourceHeight                  : 480         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BasketballDrive.cfg

    r608 r651  
    77SourceHeight                  : 1080        # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 4.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BasketballPass.cfg

    r608 r651  
    77SourceHeight                  : 240         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 2.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/BlowingBubbles.cfg

    r608 r651  
    77SourceHeight                  : 240         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 2.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Cactus.cfg

    r608 r651  
    77SourceHeight                  : 1080        # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 4.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/ChinaSpeed.cfg

    r608 r651  
    77SourceHeight                  : 768         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/FourPeople.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Johnny.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Kimono.cfg

    r608 r651  
    77SourceHeight                  : 1080        # Input  frame height
    88FramesToBeEncoded              : 240         # Number of frames to be coded
     9
     10Level                         : 4.0
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/KristenAndSara.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/NebutaFestival_10bit.cfg

    r608 r651  
    77SourceHeight                  : 1600        # Input  frame height
    88FramesToBeEncoded              : 300         # Number of frames to be coded
     9
     10Level                         : 5
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/ParkScene.cfg

    r608 r651  
    77SourceHeight                  : 1080        # Input  frame height
    88FramesToBeEncoded              : 240         # Number of frames to be coded
     9
     10Level                         : 4.0
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/PartyScene.cfg

    r608 r651  
    77SourceHeight                  : 480         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/PeopleOnStreet.cfg

    r608 r651  
    77SourceHeight                  : 1600        # Input  frame height
    88FramesToBeEncoded              : 150         # Number of frames to be coded
     9
     10Level                         : 5
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/RaceHorses.cfg

    r608 r651  
    77SourceHeight                  : 240         # Input  frame height
    88FramesToBeEncoded              : 300         # Number of frames to be coded
     9
     10Level                         : 2
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/RaceHorsesC.cfg

    r608 r651  
    77SourceHeight                  : 480         # Input  frame height
    88FramesToBeEncoded              : 300         # Number of frames to be coded
     9
     10Level                         : 3
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/SlideEditing.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 300         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/SlideShow.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 500         # Number of frames to be coded
     9
     10Level                         : 3.1
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/SteamLocomotiveTrain_10bit.cfg

    r608 r651  
    77SourceHeight                  : 1600        # Input  frame height
    88FramesToBeEncoded              : 300         # Number of frames to be coded
     9
     10Level                         : 5
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Traffic.cfg

    r608 r651  
    77SourceHeight                  : 1600        # Input  frame height
    88FramesToBeEncoded              : 150         # Number of frames to be coded
     9
     10Level                         : 5
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Vidyo1.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Vidyo3.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4
  • branches/HTM-8.2-dev0-Cleanup/cfg/HEVC/HM/per-sequence/Vidyo4.cfg

    r608 r651  
    77SourceHeight                  : 720         # Input  frame height
    88FramesToBeEncoded              : 600         # Number of frames to be coded
     9
     10Level                         : 4
  • branches/HTM-8.2-dev0-Cleanup/source/App/TAppDecoder/TAppDecTop.cpp

    r648 r651  
    6060#endif
    6161{
    62   ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    6362#if H_MV
    6463  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1;
     
    148147
    149148  // main decoder loop
    150   Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     149  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    151150#else
    152151#if H_3D
     
    176175#endif
    177176    AnnexBStats stats = AnnexBStats();
    178 #if !H_MV
    179     Bool bPreviousPictureDecoded = false;
    180 #endif
    181 
    182177    vector<uint8_t> nalUnit;
    183178    InputNALUnit nalu;
     
    246241#endif
    247242        }
    248 
    249        
    250243#else
    251244      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    252245      {
    253         if(bPreviousPictureDecoded)
    254         {
    255           bNewPicture = true;
    256           bPreviousPictureDecoded = false;
    257         }
    258         else
    259         {
    260           bNewPicture = false;
    261         }
     246        bNewPicture = false;
    262247      }
    263248      else
     
    290275#endif
    291276        }
    292 #if !H_MV
    293         bPreviousPictureDecoded = true;
    294 #endif
    295277      }
    296278    }
     
    321303      if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )
    322304#else
    323       if ( m_pchReconFile && !recon_opened )
     305      if ( m_pchReconFile && !openedReconFile )
    324306#endif
    325307      {
     
    334316#else
    335317        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    336         recon_opened = true;
     318        openedReconFile = true;
    337319      }
    338320      if ( bNewPicture &&
     
    462444{
    463445  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    464   Int not_displayed = 0;
    465 
    466   while (iterPic != pcListPic->end())
    467   {
    468     TComPic* pcPic = *(iterPic);
    469 #if H_MV
    470     if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
    471 #else
    472     if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
    473 #endif
    474     {
    475        not_displayed++;
    476     }
    477     iterPic++;
    478   }
    479   iterPic   = pcListPic->begin();
     446  Int numPicsNotYetDisplayed = 0;
    480447 
    481448  while (iterPic != pcListPic->end())
    482449  {
    483450    TComPic* pcPic = *(iterPic);
    484    
    485 #if H_MV
    486     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))
    487 #else
    488     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
    489 #endif
    490     {
    491       // write to file
    492        not_displayed--;
     451#if H_MV
     452    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
     453#else
     454    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
     455#endif
     456    {
     457      numPicsNotYetDisplayed++;
     458    }
     459    iterPic++;
     460  }
     461  iterPic   = pcListPic->begin();
     462  if (numPicsNotYetDisplayed>2)
     463  {
     464    iterPic++;
     465  }
     466 
     467  TComPic* pcPic = *(iterPic);
     468  if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding
     469  {
     470    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     471    endPic--;
     472    iterPic   = pcListPic->begin();
     473    while (iterPic != endPic)
     474    {
     475      TComPic* pcPicTop = *(iterPic);
     476      iterPic++;
     477      TComPic* pcPicBottom = *(iterPic);
     478     
     479#if H_MV
     480      if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
     481          && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_pocLastDisplay[decIdx]+1 || m_pocLastDisplay[decIdx]<0)))
     482#else
     483      if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
     484          && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0)))
     485#endif
     486      {
     487        // write to file
     488        numPicsNotYetDisplayed = numPicsNotYetDisplayed-2;
    493489#if H_MV
    494490      if ( m_pchReconFiles[decIdx] )
    495491#else
    496       if ( m_pchReconFile )
    497 #endif
    498       {
    499         const Window &conf = pcPic->getConformanceWindow();
    500         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     492        if ( m_pchReconFile )
     493#endif
     494        {
     495          const Window &conf = pcPicTop->getConformanceWindow();
     496          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     497
     498          const Bool isTff = pcPicTop->isTopField();
     499#if H_MV
     500        assert( conf   .getScaledFlag() );
     501        assert( defDisp.getScaledFlag() );
     502        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     503#else
     504          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     505#endif
     506                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     507                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     508                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     509                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     510        }
     511       
     512        // update POC of display order
     513#if H_MV
     514        m_pocLastDisplay[decIdx] = pcPic->getPOC();
     515#else
     516        m_iPOCLastDisplay = pcPicBottom->getPOC();
     517#endif
     518       
     519        // erase non-referenced picture in the reference picture list after display
     520        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     521        {
     522#if !DYN_REF_FREE
     523          pcPicTop->setReconMark(false);
     524         
     525          // mark it should be extended later
     526          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     527         
     528#else
     529          pcPicTop->destroy();
     530          pcListPic->erase( iterPic );
     531          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     532          continue;
     533#endif
     534        }
     535        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     536        {
     537#if !DYN_REF_FREE
     538          pcPicBottom->setReconMark(false);
     539         
     540          // mark it should be extended later
     541          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     542         
     543#else
     544          pcPicBottom->destroy();
     545          pcListPic->erase( iterPic );
     546          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     547          continue;
     548#endif
     549        }
     550        pcPicTop->setOutputMark(false);
     551        pcPicBottom->setOutputMark(false);
     552      }
     553    }
     554  }
     555  else if (!pcPic->isField()) //Frame Decoding
     556  {
     557    iterPic = pcListPic->begin();
     558    while (iterPic != pcListPic->end())
     559    {
     560      pcPic = *(iterPic);
     561
     562#if H_MV
     563      if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))
     564#else     
     565      if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     566#endif
     567      {
     568        // write to file
     569        numPicsNotYetDisplayed--;
     570#if H_MV
     571      if ( m_pchReconFiles[decIdx] )
     572#else
     573        if ( m_pchReconFile )
     574#endif
     575        {
     576          const Window &conf = pcPic->getConformanceWindow();
     577          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    501578#if H_MV
    502579        assert( conf   .getScaledFlag() );
     
    504581        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
    505582#else
    506         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    507 #endif
    508                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    509                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    510                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    511                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     583          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     584#endif
     585                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     586                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     587                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     588                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     589        }
     590       
     591        // update POC of display order
     592#if H_MV
     593        m_pocLastDisplay[decIdx] = pcPic->getPOC();
     594#else
     595        m_iPOCLastDisplay = pcPic->getPOC();
     596#endif
     597       
     598        // erase non-referenced picture in the reference picture list after display
     599        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     600        {
     601#if !DYN_REF_FREE
     602          pcPic->setReconMark(false);
     603         
     604          // mark it should be extended later
     605          pcPic->getPicYuvRec()->setBorderExtension( false );
     606         
     607#else
     608          pcPic->destroy();
     609          pcListPic->erase( iterPic );
     610          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     611          continue;
     612#endif
     613        }
     614        pcPic->setOutputMark(false);
    512615      }
    513616     
    514       // update POC of display order
    515 #if H_MV
    516       m_pocLastDisplay[decIdx] = pcPic->getPOC();
    517 #else
    518       m_iPOCLastDisplay = pcPic->getPOC();
    519 #endif
    520      
    521       // erase non-referenced picture in the reference picture list after display
    522       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    523       {
    524 #if !DYN_REF_FREE
    525         pcPic->setReconMark(false);
    526        
    527         // mark it should be extended later
    528         pcPic->getPicYuvRec()->setBorderExtension( false );
    529        
    530 #else
    531         pcPic->destroy();
    532         pcListPic->erase( iterPic );
    533         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    534         continue;
    535 #endif
    536       }
    537       pcPic->setOutputMark(false);
    538     }
    539    
    540     iterPic++;
    541   }
    542 }
    543 
     617      iterPic++;
     618    }
     619  }
     620}
    544621/** \param pcListPic list of pictures to be written to file
    545622    \todo            DYN_REF_FREE should be revised
     
    554631  {
    555632    return;
    556   } 
     633  }
    557634  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    558 
     635 
    559636  iterPic   = pcListPic->begin();
     637  TComPic* pcPic = *(iterPic);
    560638 
    561   while (iterPic != pcListPic->end())
    562   {
    563     TComPic* pcPic = *(iterPic);
    564 
    565     if ( pcPic->getOutputMark() )
    566     {
    567       // write to file
     639  if (pcPic->isField()) //Field Decoding
     640  {
     641    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     642    endPic--;
     643    TComPic *pcPicTop, *pcPicBottom = NULL;
     644    while (iterPic != endPic)
     645    {
     646      pcPicTop = *(iterPic);
     647      iterPic++;
     648      pcPicBottom = *(iterPic);
     649     
     650      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
     651      {
     652        // write to file
    568653#if H_MV
    569654      if ( m_pchReconFiles[decIdx] )
    570655#else
    571       if ( m_pchReconFile )
    572 #endif
    573       {
    574         const Window &conf = pcPic->getConformanceWindow();
    575         const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     656        if ( m_pchReconFile )
     657#endif
     658        {
     659          const Window &conf = pcPicTop->getConformanceWindow();
     660          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     661          const Bool isTff = pcPicTop->isTopField();
     662#if H_MV
     663        assert( conf   .getScaledFlag() );
     664        assert( defDisp.getScaledFlag() );
     665        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     666#else
     667          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     668#endif
     669                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     670                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     671                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     672                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     673        }
     674       
     675        // update POC of display order
     676#if H_MV
     677      m_pocLastDisplay[decIdx] = pcPic->getPOC();
     678#else
     679      m_iPOCLastDisplay = pcPicBottom->getPOC();
     680#endif       
     681        // erase non-referenced picture in the reference picture list after display
     682        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     683        {
     684#if !DYN_REF_FREE
     685          pcPicTop->setReconMark(false);
     686         
     687          // mark it should be extended later
     688          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     689         
     690#else
     691          pcPicTop->destroy();
     692          pcListPic->erase( iterPic );
     693          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     694          continue;
     695#endif
     696        }
     697        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     698        {
     699#if !DYN_REF_FREE
     700          pcPicBottom->setReconMark(false);
     701         
     702          // mark it should be extended later
     703          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     704         
     705#else
     706          pcPicBottom->destroy();
     707          pcListPic->erase( iterPic );
     708          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     709          continue;
     710#endif
     711        }
     712        pcPicTop->setOutputMark(false);
     713        pcPicBottom->setOutputMark(false);
     714       
     715#if !DYN_REF_FREE
     716        if(pcPicTop)
     717        {
     718          pcPicTop->destroy();
     719          delete pcPicTop;
     720          pcPicTop = NULL;
     721        }
     722#endif
     723      }
     724    }
     725    if(pcPicBottom)
     726    {
     727      pcPicBottom->destroy();
     728      delete pcPicBottom;
     729      pcPicBottom = NULL;
     730    }
     731  }
     732  else //Frame decoding
     733  {
     734    while (iterPic != pcListPic->end())
     735    {
     736      pcPic = *(iterPic);
     737     
     738      if ( pcPic->getOutputMark() )
     739      {
     740        // write to file
     741        if ( m_pchReconFile )
     742        {
     743          const Window &conf = pcPic->getConformanceWindow();
     744          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    576745#if H_MV
    577746        assert( conf   .getScaledFlag() );
     
    579748        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
    580749#else
    581         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    582 #endif
    583                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    584                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    585                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    586                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    587       }
    588      
    589       // update POC of display order
     750          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     751#endif
     752                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     753                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     754                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     755                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     756        }
     757       
     758        // update POC of display order
    590759#if H_MV
    591760      m_pocLastDisplay[decIdx] = pcPic->getPOC();
    592761#else
    593       m_iPOCLastDisplay = pcPic->getPOC();
    594 #endif
    595      
    596       // erase non-referenced picture in the reference picture list after display
    597       if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    598       {
     762        m_iPOCLastDisplay = pcPic->getPOC();
     763#endif
     764       
     765        // erase non-referenced picture in the reference picture list after display
     766        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     767        {
    599768#if !DYN_REF_FREE
    600         pcPic->setReconMark(false);
    601        
    602         // mark it should be extended later
    603         pcPic->getPicYuvRec()->setBorderExtension( false );
    604        
    605 #else
    606         pcPic->destroy();
    607         pcListPic->erase( iterPic );
    608         iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    609         continue;
    610 #endif
    611       }
    612       pcPic->setOutputMark(false);
    613     }
     769          pcPic->setReconMark(false);
     770         
     771          // mark it should be extended later
     772          pcPic->getPicYuvRec()->setBorderExtension( false );
     773         
     774#else
     775          pcPic->destroy();
     776          pcListPic->erase( iterPic );
     777          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     778          continue;
     779#endif
     780        }
     781        pcPic->setOutputMark(false);
     782      }
    614783#if !H_MV
    615784#if !DYN_REF_FREE
    616     if(pcPic)
    617     {
    618       pcPic->destroy();
    619       delete pcPic;
    620       pcPic = NULL;
    621     }
    622 #endif
    623 #endif
    624     iterPic++;
     785      if(pcPic)
     786      {
     787        pcPic->destroy();
     788        delete pcPic;
     789        pcPic = NULL;
     790      }
     791#endif   
     792#endif
     793      iterPic++;
     794    }
    625795  }
    626796#if H_MV
  • branches/HTM-8.2-dev0-Cleanup/source/App/TAppDecoder/TAppDecTop.h

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

    r648 r651  
    418418  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
    419419
     420  //Field coding parameters
     421  ("FieldCoding", m_isField, false, "Signals if it's a field based coding")
     422  ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not")
     423 
    420424  // Profile and level
    421425  ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
     
    812816  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
    813817
     818  if(m_isField)
     819  {
     820    //Frame height
     821    m_iSourceHeightOrg = m_iSourceHeight;
     822    //Field height
     823    m_iSourceHeight = m_iSourceHeight >> 1;
     824    //number of fields to encode
     825    m_framesToBeEncoded *= 2;
     826  }
     827 
    814828  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    815829  {
     
    930944        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    931945        m_iSourceHeight += m_confBottom;
     946        if ( m_isField )
     947        {
     948          m_iSourceHeightOrg += m_confBottom << 1;
     949          m_aiPad[1] = m_confBottom << 1;
     950        }
    932951      }
    933952      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
     
    16921711  Bool errorGOP=false;
    16931712  Int checkGOP=1;
    1694   Int numRefs = 1;
     1713  Int numRefs = m_isField ? 2 : 1;
    16951714  Int refList[MAX_NUM_REF_PICS+1];
    16961715  refList[0]=0;
     1716  if(m_isField)
     1717  {
     1718    refList[1] = 1;
     1719  }
    16971720  Bool isOK[MAX_GOP];
    16981721  for(Int i=0; i<MAX_GOP; i++)
     
    22132236  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    22142237  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     2238  if (m_isField)
     2239  {
     2240    printf("Frame/Field          : Field based coding\n");
     2241    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2242    if (m_isTopFieldFirst)
     2243    {
     2244      printf("Field Order            : Top field first\n");
     2245    }
     2246    else
     2247    {
     2248      printf("Field Order            : Bottom field first\n");
     2249    }
     2250  }
     2251  else
     2252  {
     2253    printf("Frame/Field                  : Frame based coding\n");
    22152254  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2255  }
    22162256  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
    22172257  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
  • branches/HTM-8.2-dev0-Cleanup/source/App/TAppEncoder/TAppEncCfg.h

    r648 r651  
    139139  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    140140  Int       m_iSourceWidth;                                   ///< source width in pixel
    141   Int       m_iSourceHeight;                                  ///< source height in pixel
     141  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     142 
     143  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
     144 
     145  bool      m_isField;                                        ///< enable field coding
     146  bool      m_isTopFieldFirst;
     147 
    142148  Int       m_conformanceMode;
    143149  Int       m_confLeft;
  • branches/HTM-8.2-dev0-Cleanup/source/App/TAppEncoder/TAppEncTop.cpp

    r648 r651  
    756756}
    757757
    758 Void TAppEncTop::xInitLib()
     758Void TAppEncTop::xInitLib(Bool isFieldCoding)
    759759{
    760760#if H_MV
     
    762762  {
    763763#if KWU_RC_MADPRED_E0227
    764     m_acTEncTopList[layer]->init( this );
    765 #else
    766     m_acTEncTopList[layer]->init( );
    767 #endif
    768   }
    769 #else
    770   m_cTEncTop.init();
     764    m_acTEncTopList[layer]->init( isFieldCoding, this );
     765#else
     766    m_acTEncTopList[layer]->init( isFieldCoding );
     767#endif
     768  }
     769#else
     770  m_cTEncTop.init( isFieldCoding );
    771771#endif
    772772}
     
    799799  xInitLibCfg();
    800800  xCreateLib();
    801   xInitLib();
     801  xInitLib(m_isField);
    802802 
    803803  // main encoder loop
     
    824824
    825825  // allocate original YUV buffer
     826  if( m_isField )
     827  {
     828    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     829  }
     830  else
     831  {
    826832  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     833  }
    827834 
    828835#if H_MV
     
    900907  for(Int layer=0; layer < m_numberOfLayers; layer++ )
    901908  {
    902     m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() );
     909    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField );
    903910  }
    904911#else
     
    914921    m_iFrameRcvd++;
    915922
    916     bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     923    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    917924
    918925    Bool flush = 0;
     
    927934
    928935    // call encoding function for one frame
     936    if ( m_isField )
     937    {
     938      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
     939    }
     940    else
     941    {
    929942    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     943    }
    930944   
    931945    // write bistream to file if necessary
     
    937951  }
    938952
    939   m_cTEncTop.printSummary();
     953  m_cTEncTop.printSummary(m_isField);
    940954#endif
    941955
     
    10481062#endif
    10491063{
    1050   Int i;
    1051  
     1064  if (m_isField)
     1065  {
     1066    //Reinterlace fields
     1067    Int i;
    10521068#if H_MV
    10531069  if( iNumEncoded > 0 )
     
    10551071    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
    10561072#else
    1057   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    1058   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    1059 #endif
    1060 
    1061   for ( i = 0; i < iNumEncoded; i++ )
    1062   {
    1063     --iterPicYuvRec;
    1064   }
    1065  
    1066   for ( i = 0; i < iNumEncoded; i++ )
    1067   {
    1068     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1073    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1074    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1075#endif
     1076   
     1077    for ( i = 0; i < iNumEncoded; i++ )
     1078    {
     1079      --iterPicYuvRec;
     1080    }
     1081   
     1082    for ( i = 0; i < iNumEncoded/2; i++ )
     1083    {
     1084      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1085      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1086     
    10691087#if H_MV
    10701088      if (m_pchReconFileList[layerId])
    10711089      {
    1072         m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    1073       }
    1074     }
    1075   }
     1090        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1091      }
     1092    }
    10761093  if( ! accessUnits.empty() )
    10771094  {
     
    10791096    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
    10801097    {
     1098      const vector<UInt>& stats = writeAnnexB(bitstreamFile, *aUIter);
     1099      rateStatsAccum(*aUIter, stats);
     1100    }
     1101  }
     1102#else
     1103      if (m_pchReconFile)
     1104      {
     1105        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1106      }
     1107
     1108      const AccessUnit& auTop = *(iterBitstream++);
     1109      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1110      rateStatsAccum(auTop, statsTop);
     1111     
     1112      const AccessUnit& auBottom = *(iterBitstream++);
     1113      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1114      rateStatsAccum(auBottom, statsBottom);
     1115    }
     1116#endif
     1117  }
     1118  else
     1119  {
     1120    Int i;
     1121#if H_MV
     1122  if( iNumEncoded > 0 )
     1123  {
     1124    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     1125#else
     1126    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1127    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1128#endif
     1129   
     1130    for ( i = 0; i < iNumEncoded; i++ )
     1131    {
     1132      --iterPicYuvRec;
     1133    }
     1134   
     1135    for ( i = 0; i < iNumEncoded; i++ )
     1136    {
     1137      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1138#if H_MV
     1139      if (m_pchReconFileList[layerId])
     1140      {
     1141        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1142      }
     1143    }
     1144  }
     1145  if( ! accessUnits.empty() )
     1146  {
     1147    list<AccessUnit>::iterator aUIter;
     1148    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
     1149    {
    10811150      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
    10821151      rateStatsAccum(*aUIter, stats);
     
    10841153  }
    10851154#else
    1086     if (m_pchReconFile)
    1087     {
    1088       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    1089     }
    1090 
    1091     const AccessUnit& au = *(iterBitstream++);
    1092     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1093     rateStatsAccum(au, stats);
    1094   }
    1095 #endif
    1096 }
    1097 
     1155      if (m_pchReconFile)
     1156      {
     1157        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1158      }
     1159     
     1160      const AccessUnit& au = *(iterBitstream++);
     1161      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1162      rateStatsAccum(au, stats);
     1163#endif
     1164    }
     1165  }
     1166}
    10981167/**
    10991168 *
  • branches/HTM-8.2-dev0-Cleanup/source/App/TAppEncoder/TAppEncTop.h

    r648 r651  
    9696  Void  xCreateLib        ();                               ///< create files & encoder class
    9797  Void  xInitLibCfg       ();                               ///< initialize internal variables
    98   Void  xInitLib          ();                               ///< initialize encoder class
     98  Void  xInitLib          (Bool isFieldCoding);             ///< initialize encoder class
    9999  Void  xDestroyLib       ();                               ///< destroy encoder class
    100100 
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/CommonDef.h

    r648 r651  
    6161#if H_MV
    6262#define NV_VERSION        "8.1"                 ///< Current software version
    63 #define HM_VERSION        "11.0"                ///<
     63#define HM_VERSION        "12.0"                ///<
    6464#else
    65 #define NV_VERSION        "11.0"                 ///< Current software version
     65#define NV_VERSION        "12.0"                 ///< Current software version
    6666#endif
    6767
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComMv.h

    r622 r651  
    4040
    4141#include "CommonDef.h"
     42#include <cstdlib>
    4243
    4344//! \ingroup TLibCommon
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComPic.cpp

    r647 r651  
    5050, m_bUsedByCurr                           (false)
    5151, m_bIsLongTerm                           (false)
    52 , m_bIsUsedAsLongTerm                     (false)
    5352, m_apcPicSym                             (NULL)
    5453, m_pcPicYuvPred                          (NULL)
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComPic.h

    r647 r651  
    6161  Bool                  m_bUsedByCurr;            //  Used by current picture
    6262  Bool                  m_bIsLongTerm;            //  IS long term picture
    63   Bool                  m_bIsUsedAsLongTerm;      //  long term picture is used as reference before
    6463  TComPicSym*           m_apcPicSym;              //  Symbol
    6564 
     
    8382  Window                m_defaultDisplayWindow;
    8483
     84  bool                  m_isTop;
     85  bool                  m_isField;
     86 
    8587  std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink;
    8688
     
    208210  TComPicYuv*   getYuvPicBufferForIndependentBoundaryProcessing()             {return m_pNDBFilterYuvTmp;}
    209211  std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter      (Int sliceID) { return m_vSliceCUDataLink[sliceID];}
     212
     213
     214  /* field coding parameters*/
     215
     216   Void              setTopField(bool b)                  {m_isTop = b;}
     217   bool              isTopField()                         {return m_isTop;}
     218   Void              setField(bool b)                     {m_isField = b;}
     219   bool              isField()                            {return m_isField;}
    210220
    211221#if H_MV
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComPicSym.cpp

    r608 r651  
    6161,m_uiNumAllocatedSlice (0)
    6262,m_apcTComDataCU (NULL)
    63 ,m_iTileBoundaryIndependenceIdr (0)
    6463,m_iNumColumnsMinus1 (0)
    6564,m_iNumRowsMinus1(0)
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComPicSym.h

    r608 r651  
    9999  UInt          m_uiNumAllocatedSlice;
    100100  TComDataCU**  m_apcTComDataCU;        ///< array of CU data
    101  
    102   Int           m_iTileBoundaryIndependenceIdr;
     101   
    103102  Int           m_iNumColumnsMinus1;
    104103  Int           m_iNumRowsMinus1;
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComPrediction.cpp

    r647 r651  
    12611261  Int k, l, bottomLeft, topRight;
    12621262  Int horPred;
    1263   Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
     1263  Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
    12641264  UInt blkSize = width;
    12651265  UInt offset2D = width;
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComRdCost.h

    r647 r651  
    148148private:
    149149  // for distortion
    150   Int                     m_iBlkWidth;
    151   Int                     m_iBlkHeight;
    152150 
    153151#if AMP_SAD
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComRom.cpp

    r647 r651  
    5555  ::memset( g_aucConvertToBit,   -1, sizeof( g_aucConvertToBit ) );
    5656  c=0;
    57   for ( i=4; i<MAX_CU_SIZE; i*=2 )
     57  for ( i=4; i<=MAX_CU_SIZE; i*=2 )
    5858  {
    5959    g_aucConvertToBit[ i ] = c;
    6060    c++;
    6161  }
    62   g_aucConvertToBit[ i ] = c;
    6362 
    6463  c=2;
     
    292291
    293292#if FAST_UDI_USE_MPM
    294 const UChar g_aucIntraModeNumFast[7] =
     293const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] =
    295294{
    296295  3,  //   2x2
     
    299298  3,  //  16x16   
    300299  3,  //  32x32   
    301   3,  //  64x64   
    302   3   // 128x128 
     300  3   //  64x64   
    303301};
    304302#else // FAST_UDI_USE_MPM
    305 const UChar g_aucIntraModeNumFast[7] =
     303const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] =
    306304{
    307305  3,  //   2x2
     
    310308  4,  //  16x16   33
    311309  4,  //  32x32   33
    312   5,  //  64x64   33
    313   4   // 128x128  33
     310  5   //  64x64   33
    314311};
    315312#endif // FAST_UDI_USE_MPM
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComRom.h

    r647 r651  
    5656// ====================================================================================================================
    5757
    58 #define     MAX_CU_DEPTH            7                           // log2(LCUSize)
     58#define     MAX_CU_DEPTH            6                           // log2(LCUSize)
    5959#define     MAX_CU_SIZE             (1<<(MAX_CU_DEPTH))         // maximum allowable size of CU
    6060#define     MIN_PU_SIZE             4
     
    136136// ====================================================================================================================
    137137
    138 extern const UChar  g_aucIntraModeNumFast[7];
     138extern const UChar  g_aucIntraModeNumFast[ MAX_CU_DEPTH ];
    139139
    140140// ====================================================================================================================
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComSlice.cpp

    r648 r651  
    302302  if (!pocHasMsb)
    303303  {
    304     poc = poc % pocCycle;
     304    poc = poc & (pocCycle - 1);
    305305  }
    306306 
     
    313313      if (!pocHasMsb)
    314314      {
    315         picPoc = picPoc % pocCycle;
     315        picPoc = picPoc & (pocCycle - 1);
    316316      }
    317317     
     
    806806}
    807807
    808 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)
     808Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic)
    809809{
    810810  for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++)
     
    832832  {
    833833    pocCRA = getPOC();
    834     prevRAPisBLA = false;
    835834  }
    836835  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
    837836  {
    838837    pocCRA = getPOC();
    839     prevRAPisBLA = false;
     838    associatedIRAPType = getNalUnitType();
    840839  }
    841840  else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     
    844843  {
    845844    pocCRA = getPOC();
    846     prevRAPisBLA = true;
     845    associatedIRAPType = getNalUnitType();
    847846  }
    848847}
     
    869868{
    870869  TComPic*                 rpcPic;
     870  setAssociatedIRAPPOC(pocCRA);
    871871  Int pocCurr = getPOC();
    872872
     
    10541054}
    10551055
    1056 Int TComSlice::m_prevPOC = 0;
     1056Int TComSlice::m_prevTid0POC = 0;
    10571057
    10581058/** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag.
     
    11091109}
    11101110
     1111
     1112Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic)
     1113{
     1114  TComPic* rpcPic;
     1115
     1116  Int nalUnitType = this->getNalUnitType();
     1117
     1118  // When a picture is a leading picture, it shall be a RADL or RASL picture.
     1119  if(this->getAssociatedIRAPPOC() > this->getPOC())
     1120  {
     1121    // Do not check IRAP pictures since they may get a POC lower than their associated IRAP
     1122    if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP ||
     1123       nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23)
     1124    {
     1125      assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1126             nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R ||
     1127             nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1128             nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R);
     1129    }
     1130  }
     1131
     1132  // When a picture is a trailing picture, it shall not be a RADL or RASL picture.
     1133  if(this->getAssociatedIRAPPOC() < this->getPOC())
     1134  {
     1135    assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N &&
     1136           nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R &&
     1137           nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N &&
     1138           nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R);
     1139  }
     1140
     1141  // No RASL pictures shall be present in the bitstream that are associated
     1142  // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP.
     1143  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1144     nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1145  {
     1146    assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL &&
     1147           this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP);
     1148  }
     1149
     1150  // No RASL pictures shall be present in the bitstream that are associated with
     1151  // an IDR picture.
     1152  if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1153     nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1154  {
     1155    assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP   &&
     1156           this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL);
     1157  }
     1158
     1159  // No RADL pictures shall be present in the bitstream that are associated with
     1160  // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated
     1161  // with an IDR picture having nal_unit_type equal to IDR_N_LP.
     1162  if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1163     nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)
     1164  {
     1165    assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP   &&
     1166           this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP);
     1167  }
     1168
     1169  // loop through all pictures in the reference picture buffer
     1170  TComList<TComPic*>::iterator iterPic = rcListPic.begin();
     1171  while ( iterPic != rcListPic.end())
     1172  {
     1173    rpcPic = *(iterPic++);
     1174    if (rpcPic->getPOC() == this->getPOC())
     1175    {
     1176      continue;
     1177    }
     1178
     1179    // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture
     1180    // in decoding order shall precede the IRAP picture in output order.
     1181    // (Note that any picture following in output order would be present in the DPB)
     1182    if(rpcPic->getSlice(0)->getPicOutputFlag() == 1)
     1183    {
     1184      if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP    ||
     1185         nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP    ||
     1186         nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL  ||
     1187         nalUnitType == NAL_UNIT_CODED_SLICE_CRA         ||
     1188         nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP    ||
     1189         nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL)
     1190      {
     1191        assert(rpcPic->getPOC() < this->getPOC());
     1192      }
     1193    }
     1194
     1195    // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture
     1196    // in decoding order shall precede any RADL picture associated with the IRAP
     1197    // picture in output order.
     1198    if(rpcPic->getSlice(0)->getPicOutputFlag() == 1)
     1199    {
     1200      if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1201          nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R))
     1202      {
     1203        // rpcPic precedes the IRAP in decoding order
     1204        if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC())
     1205        {
     1206          // rpcPic must not be the IRAP picture
     1207          if(this->getAssociatedIRAPPOC() != rpcPic->getPOC())
     1208          {
     1209            assert(rpcPic->getPOC() < this->getPOC());
     1210          }
     1211        }
     1212      }
     1213    }
     1214
     1215    // When a picture is a leading picture, it shall precede, in decoding order,
     1216    // all trailing pictures that are associated with the same IRAP picture.
     1217    if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1218       nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R ||
     1219       nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
     1220       nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)
     1221    {
     1222      if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC())
     1223      {
     1224        // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB
     1225        // rpcPic would violate the constraint if it was a trailing picture
     1226        assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
     1227      }
     1228    }
     1229
     1230    // Any RASL picture associated with a CRA or BLA picture shall precede any
     1231    // RADL picture associated with the CRA or BLA picture in output order
     1232    if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1233       nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1234    {
     1235      if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP   ||
     1236          this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   ||
     1237          this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ||
     1238          this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA)       &&
     1239          this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC())
     1240      {
     1241        if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N ||
     1242           rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R)
     1243        {
     1244          assert(rpcPic->getPOC() > this->getPOC());
     1245        }
     1246      }
     1247    }
     1248
     1249    // Any RASL picture associated with a CRA picture shall follow, in output
     1250    // order, any IRAP picture that precedes the CRA picture in decoding order.
     1251    if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ||
     1252       nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R)
     1253    {
     1254      if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA)
     1255      {
     1256        if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() &&
     1257           (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP   ||
     1258            rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   ||
     1259            rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ||
     1260            rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP   ||
     1261            rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
     1262            rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))
     1263        {
     1264          assert(this->getPOC() > rpcPic->getSlice(0)->getPOC());
     1265        }
     1266      }
     1267    }
     1268  }
     1269}
     1270
     1271
     1272
    11111273/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet.
    11121274*/
     
    11151277  TComPic* rpcPic;
    11161278  Int i, isReference;
     1279
     1280  checkLeadingPictureRestrictions(rcListPic);
    11171281
    11181282  // loop through all pictures in the reference picture buffer
     
    11511315      else
    11521316      {
    1153         if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()))
    11541317        {
    11551318          isReference = 1;
     
    12111374      else
    12121375      {
    1213         if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced())
    12141376        {
    12151377          isAvailable = 1;
     
    12301392        if (!pReferencePictureSet->getCheckLTMSBPresent(i))
    12311393        {
    1232           curPoc = curPoc % pocCycle;
    1233           refPoc = refPoc % pocCycle;
     1394          curPoc = curPoc & (pocCycle - 1);
     1395          refPoc = refPoc & (pocCycle - 1);
    12341396        }
    12351397       
     
    24372599TComScalingList::TComScalingList()
    24382600{
    2439   m_useTransformSkip = false;
    24402601  init();
    24412602}
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComSlice.h

    r648 r651  
    155155  Void     setScalingListPresentFlag    (Bool b)                               { m_scalingListPresentFlag = b;    }
    156156  Bool     getScalingListPresentFlag    ()                                     { return m_scalingListPresentFlag; }
    157   Bool     getUseTransformSkip    ()                                     { return m_useTransformSkip; }     
    158   Void     setUseTransformSkip    (Bool b)                               { m_useTransformSkip = b;    }
    159157  Int*     getScalingListAddress          (UInt sizeId, UInt listId)           { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient
    160158  Bool     checkPredMode                  (UInt sizeId, UInt listId);
     
    182180  UInt     m_predMatrixId                [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index
    183181  Int      *m_scalingListCoef            [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix
    184   Bool     m_useTransformSkip;                                                      //!< transform skipping flag for setting default scaling matrix for 4x4
    185182};
    186183
     
    16171614#endif
    16181615  Int         m_iLastIDR;
    1619   static Int  m_prevPOC;
     1616  Int         m_iAssociatedIRAP;
     1617  NalUnitType m_iAssociatedIRAPType;
     1618  static Int  m_prevTid0POC;
    16201619  TComReferencePictureSet *m_pcRPS;
    16211620  TComReferencePictureSet m_LocalRPS;
     
    17761775  Void      setRPSidx          ( Int iBDidx ) { m_iBDidx = iBDidx; }
    17771776  Int       getRPSidx          () { return m_iBDidx; }
    1778   Int       getPrevPOC      ()                          { return  m_prevPOC;       }
     1777  Int       getPrevTid0POC      ()                        { return  m_prevTid0POC;       }
    17791778  TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; }
    17801779  Void      setLastIDR(Int iIDRPOC)                       { m_iLastIDR = iIDRPOC; }
    17811780  Int       getLastIDR()                                  { return m_iLastIDR; }
     1781  Void      setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)             { m_iAssociatedIRAP = iAssociatedIRAPPOC; }
     1782  Int       getAssociatedIRAPPOC()                        { return m_iAssociatedIRAP; }
     1783  Void      setAssociatedIRAPType(NalUnitType associatedIRAPType)    { m_iAssociatedIRAPType = associatedIRAPType; }
     1784  NalUnitType getAssociatedIRAPType()                        { return m_iAssociatedIRAPType; }
    17821785  SliceType getSliceType    ()                          { return  m_eSliceType;         }
    17831786  Int       getPOC          ()                          { return  m_iPOC;           }
     
    18241827  Void      checkColRefIdx      (UInt curSliceIdx, TComPic* pic);
    18251828  Bool      getIsUsedAsLongTerm (Int i, Int j)                  { return m_bIsUsedAsLongTerm[i][j]; }
     1829  Void      setIsUsedAsLongTerm (Int i, Int j, Bool value)      { m_bIsUsedAsLongTerm[i][j] = value; }
    18261830  Bool      getCheckLDC     ()                                  { return m_bCheckLDC; }
    18271831  Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
     
    18301834  Void      setReferenced(Bool b)                               { m_bRefenced = b; }
    18311835  Bool      isReferenced()                                      { return m_bRefenced; }
    1832   Void      setPOC              ( Int i )                       { m_iPOC              = i; if(getTLayer()==0) m_prevPOC=i; }
     1836  Bool      isReferenceNalu()                                   { return ((getNalUnitType() <= NAL_UNIT_RESERVED_VCL_R15) && (getNalUnitType()%2 != 0)) || ((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_RESERVED_IRAP_VCL23) ); }
     1837  Void      setPOC              ( Int i )                       { m_iPOC              = i; if ((getTLayer()==0) && (isReferenceNalu() && (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) {m_prevTid0POC=i;} }
    18331838  Void      setNalUnitType      ( NalUnitType e )               { m_eNalUnitType      = e;      }
    18341839  NalUnitType getNalUnitType    () const                        { return m_eNalUnitType;        }
     
    18361841  Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
    18371842  Bool      isIRAP              () const                        { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); } 
    1838   Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic);
     1843  Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
    18391844  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic);
    18401845  Void      setSliceType        ( SliceType e )                 { m_eSliceType        = e;      }
     
    19121917  Void setTLayerInfo( UInt uiTLayer );
    19131918  Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum );
     1919  Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic );
    19141920  Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList);
    19151921#if H_MV
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibCommon/TComWeightPrediction.h

    r608 r651  
    5353class TComWeightPrediction
    5454{
    55   wpScalingParam  m_wp0[3], m_wp1[3];
    56 
    5755public:
    5856  TComWeightPrediction();
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibDecoder/SEIread.cpp

    r608 r651  
    315315
    316316  /* restore primary bitstream for sei_message */
     317  getBitstream()->deleteFifo();
    317318  delete getBitstream();
    318319  setBitstream(bs);
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibDecoder/SyntaxElementParser.cpp

    r622 r651  
    5858  if (length < 10)
    5959  {
    60     fprintf( g_hTrace, "%-50s u(%d)  : %d\n", pSymbolName, length, rValue );
     60    fprintf( g_hTrace, "%-50s u(%d)  : %u\n", pSymbolName, length, rValue );
    6161  }
    6262  else
    6363  {
    64     fprintf( g_hTrace, "%-50s u(%d) : %d\n", pSymbolName, length, rValue );
     64    fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
    6565  }
    6666  fflush ( g_hTrace );
     
    7777#endif
    7878  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
    79   fprintf( g_hTrace, "%-50s ue(v) : %d\n", pSymbolName, rValue );
     79  fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue );
    8080  fflush ( g_hTrace );
    8181}
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r649 r651  
    14411441      READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 
    14421442      Int iPOClsb = uiCode;
    1443       Int iPrevPOC = rpcSlice->getPrevPOC();
     1443      Int iPrevPOC = rpcSlice->getPrevTid0POC();
    14441444      Int iMaxPOClsb = 1<< sps->getBitsForPOC();
    1445       Int iPrevPOClsb = iPrevPOC%iMaxPOClsb;
     1445      Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
    14461446      Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb;
    14471447      Int iPOCmsb;
     
    15721572            rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
    15731573            rps->setCheckLTMSBPresent(j,false); 
     1574           
     1575            // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
     1576            if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
     1577            {
     1578              deltaPocMSBCycleLT = 0;
     1579            }
    15741580          }
    15751581          prevDeltaMSB = deltaPocMSBCycleLT;
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibDecoder/TDecSlice.h

    r608 r651  
    6565  TDecEntropy*    m_pcEntropyDecoder;
    6666  TDecCu*         m_pcCuDecoder;
    67   UInt            m_uiCurrSliceIdx;
    6867
    6968  TDecSbac*       m_pcBufferSbacDecoders;   ///< line to store temporary contexts, one per column of tiles.
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibDecoder/TDecTop.cpp

    r648 r651  
    347347#endif
    348348#endif
     349  m_associatedIRAPType = NAL_UNIT_INVALID;
    349350  m_pocCRA = 0;
    350   m_prevRAPisBLA = false;
    351351  m_pocRandomAccess = MAX_INT; 
    352352  m_prevPOC                = MAX_INT;
    353353  m_bFirstSliceInPicture    = true;
    354354  m_bFirstSliceInSequence   = true;
     355  m_prevSliceSkipped = false;
     356  m_skippedPOC = 0;
    355357#if H_MV
    356358  m_layerId = 0;
     
    686688  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    687689
     690  // set POC for dependent slices in skipped pictures
     691  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped)
     692  {
     693    m_apcSlicePilot->setPOC(m_skippedPOC);
     694  }
     695
     696  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
     697  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
     698
    688699#if H_MV 
    689700  TComVPS* vps     = m_apcSlicePilot->getVPS();
     
    699710    if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    700711    {
     712    m_prevSliceSkipped = true;
     713    m_skippedPOC = m_apcSlicePilot->getPOC();
    701714      return false;
    702715    }
     
    704717    if (isSkipPictureForBLA(iPOCLastDisplay))
    705718    {
     719    m_prevSliceSkipped = true;
     720    m_skippedPOC = m_apcSlicePilot->getPOC();
    706721      return false;
    707722    }
     723
     724  // clear previous slice skipped flag
     725  m_prevSliceSkipped = false;
    708726
    709727  //we should only get a different poc for a new picture (with CTU address==0)
     
    766784    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
    767785
     786    Bool isField = false;
     787    Bool isTff = false;
     788   
     789    if(!m_SEIs.empty())
     790    {
     791      // Check if any new Picture Timing SEI has arrived
     792      SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
     793      if (pictureTimingSEIs.size()>0)
     794      {
     795        SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
     796        isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2);
     797        isTff =  (pictureTiming->m_picStruct == 1);
     798      }
     799    }
     800   
     801    //Set Field/Frame coding mode
     802    m_pcPic->setField(isField);
     803    m_pcPic->setTopField(isTff);
     804   
    768805    // transfer any SEI messages that have been received to the picture
    769806    pcPic->setSEIs(m_SEIs);
     
    904941  if (bNextSlice)
    905942  {
    906     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic );
     943    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
    907944    // Set reference list
    908945#if H_MV   
     
    10031040      pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
    10041041    }
    1005     pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip());
    10061042    if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
    10071043    {
     
    11681204Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    11691205{
    1170   if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
     1206  if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) &&
     1207       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    11711208  {
    11721209    iPOCLastDisplay++;
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibDecoder/TDecTop.h

    r648 r651  
    176176  Int                     m_iMaxRefPicNum;
    177177 
     178  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
    178179  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
    179   Bool                    m_prevRAPisBLA;      ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture
    180180  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
    181181
     
    211211  Bool                    m_bFirstSliceInPicture;
    212212  Bool                    m_bFirstSliceInSequence;
     213  Bool                    m_prevSliceSkipped;
     214  Int                     m_skippedPOC;
     215
    213216#if H_MV
    214217  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncAnalyze.cpp

    r608 r651  
    5252TEncAnalyze             m_gcAnalyzeP;
    5353TEncAnalyze             m_gcAnalyzeB;
     54
     55TEncAnalyze             m_gcAnalyzeAll_in;
    5456#endif
    5557
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncAnalyze.h

    r608 r651  
    116116  }
    117117 
     118  Void    printOutInterlaced ( Char cDelim, Double bits )
     119  {
     120    Double dFps     =   m_dFrmRate; //--CFG_KDY
     121    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
     122   
     123    printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     124    //printf( "\t------------ "  " ----------"   " -------- "  " -------- "  " --------\n" );
     125    printf( "\t %8d    %c"          "%12.4lf  "    "%8.4lf  "   "%8.4lf  "    "%8.4lf\n",
     126           getNumPic(), cDelim,
     127           bits * dScale,
     128           getPsnrY() / (Double)getNumPic(),
     129           getPsnrU() / (Double)getNumPic(),
     130           getPsnrV() / (Double)getNumPic() );
     131  }
     132 
     133  Void    printSummaryOutInterlaced (Int bits)
     134  {
     135    FILE* pFile = fopen ("summaryTotal.txt", "at");
     136    Double dFps     =   m_dFrmRate; //--CFG_KDY
     137    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
     138   
     139    fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale,
     140            getPsnrY() / (Double)getNumPic(),
     141            getPsnrU() / (Double)getNumPic(),
     142            getPsnrV() / (Double)getNumPic() );
     143    fclose(pFile);
     144  }
     145 
     146 
    118147  Void    printSummary(Char ch)
    119148  {
     
    155184extern TEncAnalyze             m_gcAnalyzeP;
    156185extern TEncAnalyze             m_gcAnalyzeB;
     186
     187extern TEncAnalyze             m_gcAnalyzeAll_in;
    157188#endif
    158189
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncCavlc.cpp

    r648 r651  
    11301130    if( !pcSlice->getIdrPicFlag() )
    11311131    {
    1132       Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC());
     1132      Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
    11331133      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
    11341134      TComReferencePictureSet* rps = pcSlice->getRPS();
     
    19271927{
    19281928  // Bool state = true, state2 = false;
    1929   Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC());
     1929  Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
    19301930  for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++)
    19311931  {
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncCu.cpp

    r650 r651  
    432432
    433433  // variables for fast encoder decision
    434   Bool    bEarlySkip  = false;
    435   Bool    bTrySplit    = true;
    436   Double  fRD_Skip    = MAX_DOUBLE;
     434#if H_3D_QTLPC 
     435  Bool    bTrySplit     = true;
     436  Bool    bTrySplitDQP  = true;
     437#endif
    437438
    438439  // variable for Early CU determination
     
    443444  Bool earlyDetectionSkipMode = false;
    444445
    445   Bool    bTrySplitDQP  = true;
    446446#if H_3D_VSP
    447447  DisInfo DvInfo;
     
    453453#endif
    454454#endif
    455   static  Double  afCost[ MAX_CU_DEPTH ];
    456   static  Int      aiNum [ MAX_CU_DEPTH ];
    457 
    458   if ( rpcBestCU->getAddr() == 0 )
    459   {
    460     ::memset( afCost, 0, sizeof( afCost ) );
    461     ::memset( aiNum,  0, sizeof( aiNum  ) );
    462   }
    463 
    464455  Bool bBoundary = false;
    465456  UInt uiLPelX   = rpcBestCU->getCUPelX();
     
    529520      }
    530521      // variables for fast encoder decision
    531       bEarlySkip  = false;
     522#if H_3D_QTLPC
    532523      bTrySplit    = true;
    533       fRD_Skip    = MAX_DOUBLE;
     524#endif
    534525
    535526      rpcTempCU->initEstData( uiDepth, iQP );
     
    633624        rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
    634625#endif
    635         // fast encoder decision for early skip
    636         if ( m_pcEncCfg->getUseFastEnc() )
    637         {
    638           Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];
    639           if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] )
    640           {
    641             bEarlySkip = true;
    642             bTrySplit  = false;
    643           }
    644         }
    645626
    646627        if(!m_pcEncCfg->getUseEarlySkipDetection())
    647628        {
    648629          // 2Nx2N, NxN
    649           if ( !bEarlySkip )
    650           {
    651630#if H_3D_IC
    652631            rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
     
    664643              doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
    665644            }
    666           }
    667645        }
    668646#if H_3D_IC
     
    671649      }
    672650
    673 #if H_3D_QTLPC
     651#if H_3D_QTLPC     
    674652      if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL())
    675653      {
    676654        bTrySplitDQP = bTrySplit;
    677       }
    678       else
    679       {
    680 #endif
    681         if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )
    682         {
    683           if(iQP == iBaseQP)
    684           {
    685             bTrySplitDQP = bTrySplit;
    686           }
    687         }
    688         else
    689         {
    690           bTrySplitDQP = bTrySplit;
    691         }
    692 #if H_3D_QTLPC
    693655      }
    694656#endif
     
    750712        {
    751713          // 2Nx2N, NxN
    752           if ( !bEarlySkip )
    753           {
    754714            if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))
    755715            {
     
    771731              }
    772732            }
    773           }
    774733
    775734          // 2NxN, Nx2N
     
    10461005        // do normal intra modes
    10471006#if H_3D_DIM_ENC
    1048         if ( !bEarlySkip || ( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() ) )
    1049 #else
    1050         if ( !bEarlySkip )
     1007        if (( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() ) )
    10511008#endif
    10521009        {
     
    11461103#endif
    11471104    rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
    1148 
    1149     // accumulate statistics for early skip
    1150     if ( m_pcEncCfg->getUseFastEnc() )
    1151     {
    1152       if ( rpcBestCU->isSkipped(0) )
    1153       {
    1154         Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];
    1155         afCost[ iIdx ] += rpcBestCU->getTotalCost();
    1156         aiNum [ iIdx ] ++;
    1157       }
    1158     }
    11591105
    11601106    // Early CU determination
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncGOP.cpp

    r648 r651  
    355355#endif
    356356#if H_MV
    357 Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid)
    358 #else
    359 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
     357Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid, bool isField, bool isTff)
     358#else
     359Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, bool isField, bool isTff)
    360360#endif
    361361{
     
    371371
    372372#if !H_MV
    373   xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );
     373  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField );
     374
    374375 
    375376  m_iNumPicCoded = 0;
     
    443444
    444445    /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding
    445     Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC;
    446     Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC;
    447     if(iPOCLast == 0)
     446    Int iTimeOffset;
     447    Int pocCurr;
     448   
     449    if(iPOCLast == 0) //case first frame or first top field
    448450    {
    449451      pocCurr=0;
    450452      iTimeOffset = 1;
     453    }
     454    else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value
     455    {
     456      pocCurr = 1;
     457      iTimeOffset = 1;
     458    }
     459    else
     460    {
     461      pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField;
     462      iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC;
    451463    }
    452464    if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
     
    467479    accessUnitsInGOP.push_back(AccessUnit());
    468480    AccessUnit& accessUnit = accessUnitsInGOP.back();
    469     xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr );
     481    xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField);
    470482
    471483    //  Slice data initialization
     
    477489
    478490#if H_MV
    479     m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId() );     
    480 #else
    481     m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
    482 #endif
     491    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId(), isField  );     
     492#else
     493    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField  );
     494#endif
     495   
     496    //Set Frame/Field coding
     497    pcSlice->getPic()->setField(isField);
     498
    483499    pcSlice->setLastIDR(m_iLastIDR);
    484500    pcSlice->setSliceIdx(0);
     
    500516    pcSlice->setLFCrossSliceBoundaryFlag(  pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()  );
    501517    pcSlice->setScalingList ( m_pcEncTop->getScalingList()  );
    502     pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());
    503518    if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF)
    504519    {
     
    554569    if(pcSlice->getTemporalLayerNonReferenceFlag())
    555570    {
    556       if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
     571      if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R &&
     572          !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE))
     573        // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker)
    557574      {
    558575        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N);
     
    13561373        }
    13571374      }
    1358       pictureTimingSEI.m_auCpbRemovalDelay = std::max<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .
     1375      pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
    13591376      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded;
    13601377      Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2;
     
    18841901      xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime );
    18851902
     1903    //In case of field coding, compute the interlaced PSNR for both fields
     1904    if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff)))
     1905    {
     1906      //get complementary top field
     1907      TComPic* pcPicTop;
     1908      TComList<TComPic*>::iterator   iterPic = rcListPic.begin();
     1909      while ((*iterPic)->getPOC() != pcPic->getPOC()-1)
     1910      {
     1911        iterPic ++;
     1912      }
     1913      pcPicTop = *(iterPic);
     1914      xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime );
     1915    }
     1916   
    18861917      if (digestStr)
    18871918      {
     
    20162047            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    20172048          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2049          pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0;
    20182050          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
    20192051          writeRBSPTrailingBits(nalu.m_Bitstream);
     
    21362168
    21372169#if !H_MV
    2138   assert ( m_iNumPicCoded == iNumPicRcvd );
     2170  assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) );
    21392171#endif
    21402172}
    21412173
    21422174#if !H_MV
    2143 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded)
     2175Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, bool isField)
    21442176{
    21452177  assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic());
     
    21472179   
    21482180  //--CFG_KDY
     2181  if(isField)
     2182  {
     2183    m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2);
     2184    m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2);
     2185    m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2);
     2186    m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2);
     2187  }
     2188  else
     2189  {
    21492190  m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() );
    21502191  m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() );
    21512192  m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() );
    21522193  m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() );
     2194  }
    21532195 
    21542196  //-- all
     
    21732215  m_gcAnalyzeB.printSummary('B');
    21742216#endif
     2217
     2218  if(isField)
     2219  {
     2220    //-- interlaced summary
     2221    m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate());
     2222    printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
     2223    m_gcAnalyzeAll_in.printOutInterlaced('a',  m_gcAnalyzeAll.getBits());
     2224   
     2225#if _SUMMARY_OUT_
     2226    m_gcAnalyzeAll_in.printSummaryOutInterlaced();
     2227#endif
     2228  }
    21752229
    21762230  printf("\nRVM: %.3lf\n" , xCalculateRVM());
     
    22162270// Protected member functions
    22172271// ====================================================================================================================
     2272
     2273
     2274Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField )
     2275{
     2276  assert( iNumPicRcvd > 0 );
     2277  //  Exception for the first frames
     2278  if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField  && (iPOCLast == 0))  )
     2279  {
     2280    m_iGopSize    = 1;
     2281  }
     2282  else
     2283  {
     2284    m_iGopSize    = m_pcCfg->getGOPSize();
     2285  }
     2286  assert (m_iGopSize > 0);
     2287 
     2288  return;
     2289}
    22182290
    22192291Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut )
     
    22392311                         TComPic*&                 rpcPic,
    22402312                         TComPicYuv*&              rpcPicYuvRecOut,
    2241                          Int                       pocCurr )
     2313                         Int                       pocCurr,
     2314                         bool                      isField)
    22422315{
    22432316  Int i;
    22442317  //  Rec. output
    22452318  TComList<TComPicYuv*>::iterator     iterPicYuvRec = rcListPicYuvRecOut.end();
    2246   for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ )
     2319 
     2320  if (isField)
     2321  {
     2322    for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ )
     2323    {
     2324      iterPicYuvRec--;
     2325    }
     2326  }
     2327  else
     2328  {
     2329    for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ )
    22472330  {
    22482331    iterPicYuvRec--;
    22492332  }
    22502333 
     2334  }
     2335 
     2336  if (isField)
     2337  {
     2338    if(pocCurr == 1)
     2339    {
     2340      iterPicYuvRec++;
     2341    }
     2342  }
    22512343  rpcPicYuvRecOut = *(iterPicYuvRec);
    22522344 
     
    25822674}
    25832675
     2676
     2677Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, bool isTff)
     2678{
     2679 
     2680  for (Int y = 0; y < height; y++)
     2681  {
     2682    for (Int x = 0; x < width; x++)
     2683    {
     2684      dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x];
     2685      dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x];
     2686    }
     2687    top += stride;
     2688    bottom += stride;
     2689    dst += stride*2;
     2690  }
     2691}
     2692
     2693
     2694Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime )
     2695{
     2696#if  H_MV
     2697  assert( 0 ); // Field coding and MV need to be aligned.
     2698#else
     2699  Int     x, y;
     2700 
     2701  UInt64 uiSSDY_in  = 0;
     2702  UInt64 uiSSDU_in  = 0;
     2703  UInt64 uiSSDV_in  = 0;
     2704 
     2705  Double  dYPSNR_in  = 0.0;
     2706  Double  dUPSNR_in  = 0.0;
     2707  Double  dVPSNR_in  = 0.0;
     2708 
     2709  /*------ INTERLACED PSNR -----------*/
     2710 
     2711  /* Luma */
     2712 
     2713  Pel*  pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr();
     2714  Pel*  pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr();
     2715  Pel*  pRecTop = pcPicRecTop->getLumaAddr();
     2716  Pel*  pRecBottom = pcPicRecBottom->getLumaAddr();
     2717 
     2718  Int   iWidth;
     2719  Int   iHeight;
     2720  Int iStride;
     2721 
     2722  iWidth  = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0);
     2723  iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1);
     2724  iStride = pcPicOrgTop->getPicYuvOrg()->getStride();
     2725  Int   iSize   = iWidth*iHeight;
     2726  bool isTff = pcPicOrgTop->isTopField();
     2727 
     2728  TComPicYuv* pcOrgInterlaced = new TComPicYuv;
     2729  pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     2730 
     2731  TComPicYuv* pcRecInterlaced = new TComPicYuv;
     2732  pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     2733 
     2734  Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr();
     2735  Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr();
     2736 
     2737  //=== Interlace fields ====
     2738  reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff);
     2739  reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff);
     2740 
     2741  //===== calculate PSNR =====
     2742  for( y = 0; y < iHeight << 1; y++ )
     2743  {
     2744    for( x = 0; x < iWidth; x++ )
     2745    {
     2746      Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] );
     2747      uiSSDY_in   += iDiff * iDiff;
     2748    }
     2749    pOrgInterlaced += iStride;
     2750    pRecInterlaced += iStride;
     2751  }
     2752 
     2753  /*Chroma*/
     2754 
     2755  iHeight >>= 1;
     2756  iWidth  >>= 1;
     2757  iStride >>= 1;
     2758 
     2759  pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr();
     2760  pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr();
     2761  pRecTop = pcPicRecTop->getCbAddr();
     2762  pRecBottom = pcPicRecBottom->getCbAddr();
     2763  pOrgInterlaced = pcOrgInterlaced->getCbAddr();
     2764  pRecInterlaced = pcRecInterlaced->getCbAddr();
     2765 
     2766  //=== Interlace fields ====
     2767  reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff);
     2768  reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff);
     2769 
     2770  //===== calculate PSNR =====
     2771  for( y = 0; y < iHeight << 1; y++ )
     2772  {
     2773    for( x = 0; x < iWidth; x++ )
     2774    {
     2775      Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] );
     2776      uiSSDU_in   += iDiff * iDiff;
     2777    }
     2778    pOrgInterlaced += iStride;
     2779    pRecInterlaced += iStride;
     2780  }
     2781 
     2782  pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr();
     2783  pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr();
     2784  pRecTop = pcPicRecTop->getCrAddr();
     2785  pRecBottom = pcPicRecBottom->getCrAddr();
     2786  pOrgInterlaced = pcOrgInterlaced->getCrAddr();
     2787  pRecInterlaced = pcRecInterlaced->getCrAddr();
     2788 
     2789  //=== Interlace fields ====
     2790  reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff);
     2791  reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff);
     2792 
     2793  //===== calculate PSNR =====
     2794  for( y = 0; y < iHeight << 1; y++ )
     2795  {
     2796    for( x = 0; x < iWidth; x++ )
     2797    {
     2798      Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] );
     2799      uiSSDV_in   += iDiff * iDiff;
     2800    }
     2801    pOrgInterlaced += iStride;
     2802    pRecInterlaced += iStride;
     2803  }
     2804 
     2805  Int maxvalY = 255 << (g_bitDepthY-8);
     2806  Int maxvalC = 255 << (g_bitDepthC-8);
     2807  Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2;
     2808  Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0;
     2809  dYPSNR_in            = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 );
     2810  dUPSNR_in            = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 );
     2811  dVPSNR_in            = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 );
     2812 
     2813  /* calculate the size of the access unit, excluding:
     2814   *  - any AnnexB contributions (start_code_prefix, zero_byte, etc.,)
     2815   *  - SEI NAL units
     2816   */
     2817  UInt numRBSPBytes = 0;
     2818  for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++)
     2819  {
     2820    UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
     2821   
     2822    if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
     2823      numRBSPBytes += numRBSPBytes_nal;
     2824  }
     2825 
     2826  UInt uibits = numRBSPBytes * 8 ;
     2827 
     2828  //===== add PSNR =====
     2829  m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits);
     2830 
     2831  printf("\n                                      Interlaced frame %d: [Y %6.4lf dB    U %6.4lf dB    V %6.4lf dB]", pcPicOrgBottom->getPOC()/2 , dYPSNR_in, dUPSNR_in, dVPSNR_in );
     2832 
     2833  pcOrgInterlaced->destroy();
     2834  delete pcOrgInterlaced;
     2835  pcRecInterlaced->destroy();
     2836  delete pcRecInterlaced;
     2837#endif
     2838}
    25842839/** Function for deciding the nal_unit_type.
    25852840 * \param pocCurr POC of the current picture
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncGOP.h

    r648 r651  
    147147#if H_MV
    148148  Void  initGOP     ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP);
    149   Void  compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid );
     149  Void  compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid, Bool isField, Bool isTff );
    150150#else
    151   Void  compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
     151  Void  compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff );
    152152#endif
    153153  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
     
    168168
    169169#if !H_MV
    170   Void  printOutSummary      ( UInt uiNumAllPicCoded );
     170  Void  printOutSummary      ( UInt uiNumAllPicCoded , bool isField);
    171171#endif
    172172#if H_3D_VSO
     
    187187
    188188protected:
     189  Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField );
     190
    189191  Void  xInitGOP          ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut );
    190   Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr );
     192  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, bool isField );
    191193 
    192194  Void  xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime );
     195  Void  xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime );
     196
    193197#if H_3D_VSO
    194198  Dist64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncSlice.cpp

    r649 r651  
    188188 */
    189189#if H_MV
    190 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId )
    191 #else
    192 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )
     190Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId, bool isField )
     191#else
     192Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, bool isField )
    193193#endif
    194194{
     
    334334    Int    NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
    335335    Int    SHIFT_QP = 12;
    336     Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames );
     336    Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) );
    337337#if FULL_NBIT
    338338    Int    bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8);
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncSlice.h

    r648 r651  
    118118#if H_MV
    119119  Void    initEncSlice        ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
    120                                 Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId );
     120                                Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId, bool isField );
    121121#else
    122122  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
    123                                 Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );
     123                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, bool isField );
    124124#endif
    125125#if RATE_CONTROL_LAMBDA_DOMAIN
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncTop.cpp

    r648 r651  
    293293
    294294#if KWU_RC_MADPRED_E0227
    295 Void TEncTop::init(TAppEncTop* pcTAppEncTop)
     295Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding)
    296296#else
    297 Void TEncTop::init()
     297Void TEncTop::init(Bool isFieldCoding)
    298298#endif
    299299{
     
    313313  m_cPPS.setSPS(&m_cSPS);
    314314  xInitPPS();
    315   xInitRPS();
     315  xInitRPS(isFieldCoding);
    316316
    317317  xInitPPSforTiles();
     
    444444#if H_MV
    445445  }
    446   m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId );
     446  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId, false, false );
    447447
    448448  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
     
    450450#else
    451451  // compress GOP
    452   m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut);
     452  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false);
    453453#endif
    454454
     
    467467#endif
    468468}
     469/**------------------------------------------------
     470 Separate interlaced frame into two fields
     471 -------------------------------------------------**/
     472void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, bool isTop)
     473{
     474  if (!isTop)
     475  {
     476    org += stride;
     477  }
     478  for (Int y = 0; y < height>>1; y++)
     479  {
     480    for (Int x = 0; x < width; x++)
     481    {
     482      dstField[x] = org[x];
     483    }
     484   
     485    dstField += stride;
     486    org += stride*2;
     487  }
     488 
     489}
     490
     491#if H_MV
     492Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff, Int gopId )
     493{
     494  assert( 0 ); // Field coding and multiview need to be furhter harmonized.
     495}
     496#else
     497Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff)
     498{
     499  /* -- TOP FIELD -- */
     500 
     501  if (pcPicYuvOrg)
     502  {
     503   
     504    /* -- Top field initialization -- */
     505   
     506    TComPic *pcTopField;
     507    xGetNewPicBuffer( pcTopField );
     508    pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO);
     509    pcTopField->setReconMark (false);
     510   
     511    pcTopField->getSlice(0)->setPOC( m_iPOCLast );
     512    pcTopField->getPicYuvRec()->setBorderExtension(false);
     513    pcTopField->setTopField(isTff);
     514   
     515    int nHeight = pcPicYuvOrg->getHeight();
     516    int nWidth = pcPicYuvOrg->getWidth();
     517    int nStride = pcPicYuvOrg->getStride();
     518    int nPadLuma = pcPicYuvOrg->getLumaMargin();
     519    int nPadChroma = pcPicYuvOrg->getChromaMargin();
     520   
     521    // Get pointers
     522    Pel * PicBufY = pcPicYuvOrg->getBufY();
     523    Pel * PicBufU = pcPicYuvOrg->getBufU();
     524    Pel * PicBufV = pcPicYuvOrg->getBufV();
     525   
     526    Pel * pcTopFieldY =  pcTopField->getPicYuvOrg()->getLumaAddr();
     527    Pel * pcTopFieldU =  pcTopField->getPicYuvOrg()->getCbAddr();
     528    Pel * pcTopFieldV =  pcTopField->getPicYuvOrg()->getCrAddr();
     529   
     530    // compute image characteristics
     531    if ( getUseAdaptiveQP() )
     532    {
     533      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) );
     534    }
     535   
     536    /* -- Defield -- */
     537   
     538    bool isTop = isTff;
     539   
     540    separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop);
     541    separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
     542    separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
     543   
     544  }
     545 
     546  if (m_iPOCLast == 0) // compress field 0
     547  {
     548    m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
     549  }
     550 
     551  /* -- BOTTOM FIELD -- */
     552 
     553  if (pcPicYuvOrg)
     554  {
     555   
     556    /* -- Bottom field initialization -- */
     557   
     558    TComPic* pcBottomField;
     559    xGetNewPicBuffer( pcBottomField );
     560    pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO);
     561    pcBottomField->setReconMark (false);
     562   
     563    TComPicYuv* rpcPicYuvRec = new TComPicYuv;
     564    if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize )
     565    {
     566      rpcPicYuvRec = rcListPicYuvRecOut.popFront();
     567    }
     568    else
     569    {
     570      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     571    }
     572    rcListPicYuvRecOut.pushBack( rpcPicYuvRec );
     573   
     574    pcBottomField->getSlice(0)->setPOC( m_iPOCLast);
     575    pcBottomField->getPicYuvRec()->setBorderExtension(false);
     576    pcBottomField->setTopField(!isTff);
     577   
     578    int nHeight = pcPicYuvOrg->getHeight();
     579    int nWidth = pcPicYuvOrg->getWidth();
     580    int nStride = pcPicYuvOrg->getStride();
     581    int nPadLuma = pcPicYuvOrg->getLumaMargin();
     582    int nPadChroma = pcPicYuvOrg->getChromaMargin();
     583   
     584    // Get pointers
     585    Pel * PicBufY = pcPicYuvOrg->getBufY();
     586    Pel * PicBufU = pcPicYuvOrg->getBufU();
     587    Pel * PicBufV = pcPicYuvOrg->getBufV();
     588   
     589    Pel * pcBottomFieldY =  pcBottomField->getPicYuvOrg()->getLumaAddr();
     590    Pel * pcBottomFieldU =  pcBottomField->getPicYuvOrg()->getCbAddr();
     591    Pel * pcBottomFieldV =  pcBottomField->getPicYuvOrg()->getCrAddr();
     592   
     593    // Compute image characteristics
     594    if ( getUseAdaptiveQP() )
     595    {
     596      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) );
     597    }
     598   
     599    /* -- Defield -- */
     600   
     601    bool isTop = !isTff;
     602   
     603    separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop);
     604    separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
     605    separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop);
     606   
     607  }
     608 
     609  if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) )
     610  {
     611    iNumEncoded = 0;
     612    return;
     613  }
     614 
     615  // compress GOP
     616  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff);
     617 
     618  iNumEncoded = m_iNumPicRcvd;
     619  m_iNumPicRcvd = 0;
     620  m_uiNumAllPicCoded += iNumEncoded;
     621}
     622#endif
     623
     624
    469625
    470626// ====================================================================================================================
     
    821977
    822978//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
    823 Void TEncTop::xInitRPS()
     979Void TEncTop::xInitRPS(Bool isFieldCoding)
    824980{
    825981  TComReferencePictureSet*      rps;
    826982 
    827   m_cSPS.createRPSList(getGOPSize()+m_extraRPSs);
     983  m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1);
    828984  TComRPSList* rpsList = m_cSPS.getRPSList();
    829985
     
    9221078        printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n");
    9231079        rps->setNumberOfNegativePictures(numNeg);
    924         rps->setNumberOfPositivePictures(numNeg+numPos);
     1080        rps->setNumberOfPictures(numNeg+numPos);
    9251081      }
    9261082      if (numPos != rps->getNumberOfPositivePictures())
     
    9281084        printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n");
    9291085        rps->setNumberOfPositivePictures(numPos);
    930         rps->setNumberOfPositivePictures(numNeg+numPos);
     1086        rps->setNumberOfPictures(numNeg+numPos);
    9311087      }
    9321088      RPSTemp.setNumberOfPictures(numNeg+numPos);
     
    9921148#endif //INTER_RPS_AUTO
    9931149  }
    994  
     1150  //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file.
     1151  //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS.
     1152  if (isFieldCoding)
     1153  {
     1154    rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs);
     1155    rps->setNumberOfPictures(1);
     1156    rps->setNumberOfNegativePictures(1);
     1157    rps->setNumberOfPositivePictures(0);
     1158    rps->setNumberOfLongtermPictures(0);
     1159    rps->setDeltaPOC(0,-1);
     1160    rps->setPOC(0,0);
     1161    rps->setUsed(0,true);
     1162    rps->setInterRPSPrediction(false);
     1163    rps->setDeltaRIdxMinus1(0);
     1164    rps->setDeltaRPS(0);
     1165    rps->setNumRefIdc(0);
     1166}
    9951167}
    9961168
     
    10371209    }
    10381210  }
     1211#if H_MV
     1212  }
     1213#endif
     1214  if(POCCurr == 1 && slice->getPic()->isField())
     1215  {
     1216    slice->setRPSidx(m_iGOPSize+m_extraRPSs);
     1217  }
    10391218
    10401219  slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
    10411220  slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
    1042 #if H_MV
    1043   }
    1044 #endif
    1045 
    10461221}
    10471222
     
    11561331}
    11571332#if H_MV
    1158 Void TEncTop::printSummary( Int numAllPicCoded )
    1159 {
     1333Void TEncTop::printSummary( Int numAllPicCoded, Bool isField )
     1334{
     1335  assert ( !isField ); // Multiview and field coding need to be further unified
    11601336  assert (numAllPicCoded == m_cAnalyzeAll.getNumPic());
    11611337
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibEncoder/TEncTop.h

    r635 r651  
    145145 
    146146  Void  xInitPPSforTiles  ();
    147   Void  xInitRPS          ();                             ///< initialize PPS from encoder options
     147  Void  xInitRPS          (Bool isFieldCoding);           ///< initialize PPS from encoder options
    148148
    149149public:
     
    154154  Void      destroy         ();
    155155#if KWU_RC_MADPRED_E0227
    156   Void      init            ( TAppEncTop* pcTAppEncTop );
    157 #else
    158   Void      init            ();
     156  Void      init            ( TAppEncTop* pcTAppEncTop, Bool isFieldCoding );
     157#else
     158  Void      init            (Bool isFieldCoding);
    159159#endif
    160160
     
    228228#if H_MV
    229229  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded  , Int gopId  ); 
     230
     231   /// encode several number of pictures until end-of-sequence
     232  Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
     233              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff  , Int gopId );
     234
    230235#else
    231236  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    232               std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 
    233 #endif
    234 
    235 #if H_MV
    236   Void printSummary      ( Int numAllPicCoded );
    237 #else
    238   void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }
     237              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded );
     238   /// encode several number of pictures until end-of-sequence
     239  Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
     240              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff);
     241
     242#endif
     243
     244#if H_MV
     245  Void printSummary      ( Int numAllPicCoded, bool isField );
     246#else
     247  Void printSummary(bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); }
    239248#endif
    240249
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibVideoIO/TVideoIOYuv.cpp

    r608 r651  
    339339}
    340340
     341static Bool writeField(ostream& fd, Pel* top, Pel* bottom, Bool is16bit,
     342                       UInt stride,
     343                       UInt width, UInt height, bool isTff)
     344{
     345  Int write_len = width * (is16bit ? 2 : 1)*2;
     346  UChar *buf = new UChar[write_len];
     347  for (Int y = 0; y < height; y++)
     348  {
     349    if (!is16bit)
     350    {
     351      for (Int x = 0; x < width; x++)
     352      {
     353        buf[x] = isTff ? (UChar) top[x] : (UChar) bottom[x];
     354        buf[width+x] = isTff ? (UChar) bottom[x] : (UChar) top[x];
     355      }
     356    }
     357    else
     358    {
     359      for (Int x = 0; x < width; x++)
     360      {
     361        buf[2*x] = isTff ? top[x] & 0xff : bottom[x] & 0xff;
     362        buf[2*x+1] = isTff ? (top[x] >> 8) & 0xff : (bottom[x] >> 8) & 0xff;
     363       
     364        buf[width+2*x] = isTff ? bottom[x] & 0xff : top[x] & 0xff;
     365        buf[width+2*x+1] = isTff ? (bottom[x] >> 8) & 0xff : (top[x] >> 8) & 0xff;
     366      }
     367    }
     368   
     369    fd.write(reinterpret_cast<Char*>(buf), write_len);
     370    if (fd.eof() || fd.fail() )
     371    {
     372      delete[] buf;
     373      return false;
     374    }
     375    top += stride;
     376    bottom += stride;
     377  }
     378  delete[] buf;
     379  return true;
     380}
    341381/**
    342382 * Read one Y'CbCr frame, performing any required input scaling to change
     
    501541}
    502542
     543
     544/**
     545 * Write one Y'CbCr frame. No bit-depth conversion is performed, pcPicYuv is
     546 * assumed to be at TVideoIO::m_fileBitdepth depth.
     547 *
     548 * @param pPicTop     input top field YUV buffer class pointer
     549 * @param pPicBottom  input bottom field YUV buffer class pointer
     550 * @param aiPad       source padding size, aiPad[0] = horizontal, aiPad[1] = vertical
     551 * @return true for success, false in case of error
     552 */
     553Bool TVideoIOYuv::write( TComPicYuv* pPicTop, TComPicYuv* pPicBottom, Int cropLeft, Int cropRight, Int cropTop, Int cropBottom , bool isTff)
     554{
     555  // compute actual YUV frame size excluding padding size
     556  Int   iStride = pPicTop->getStride();
     557  UInt  width  = pPicTop->getWidth()  - cropLeft - cropRight;
     558  UInt  height = pPicTop->getHeight() - cropTop  - cropBottom;
     559  Bool is16bit = m_fileBitDepthY > 8 || m_fileBitDepthC > 8;
     560 
     561  TComPicYuv *dstPicTop = NULL;
     562  TComPicYuv *dstPicBottom = NULL;
     563 
     564  Bool retval = true;
     565 
     566  if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0)
     567  {
     568    dstPicTop = new TComPicYuv;
     569    dstPicTop->create( pPicTop->getWidth(), pPicTop->getHeight(), 1, 1, 0 );
     570    pPicTop->copyToPic(dstPicTop);
     571   
     572    dstPicBottom = new TComPicYuv;
     573    dstPicBottom->create( pPicBottom->getWidth(), pPicBottom->getHeight(), 1, 1, 0 );
     574    pPicBottom->copyToPic(dstPicBottom);
     575   
     576    Pel minvalY = 0;
     577    Pel minvalC = 0;
     578    Pel maxvalY = (1 << m_fileBitDepthY) - 1;
     579    Pel maxvalC = (1 << m_fileBitDepthC) - 1;
     580#if CLIP_TO_709_RANGE
     581    if (-m_bitDepthShiftY < 0 && m_fileBitDepthY >= 8)
     582    {
     583      /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */
     584      minvalY = 1 << (m_fileBitDepthY - 8);
     585      maxvalY = (0xff << (m_fileBitDepthY - 8)) -1;
     586    }
     587    if (-m_bitDepthShiftC < 0 && m_fileBitDepthC >= 8)
     588    {
     589      /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */
     590      minvalC = 1 << (m_fileBitDepthC - 8);
     591      maxvalC = (0xff << (m_fileBitDepthC - 8)) -1;
     592    }
     593#endif
     594    scalePlane(dstPicTop->getLumaAddr(), dstPicTop->getStride(), dstPicTop->getWidth(), dstPicTop->getHeight(), -m_bitDepthShiftY, minvalY, maxvalY);
     595    scalePlane(dstPicTop->getCbAddr(), dstPicTop->getCStride(), dstPicTop->getWidth()>>1, dstPicTop->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC);
     596    scalePlane(dstPicTop->getCrAddr(), dstPicTop->getCStride(), dstPicTop->getWidth()>>1, dstPicTop->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC);
     597   
     598    scalePlane(dstPicBottom->getLumaAddr(), dstPicBottom->getStride(), dstPicBottom->getWidth(), dstPicBottom->getHeight(), -m_bitDepthShiftY, minvalY, maxvalY);
     599    scalePlane(dstPicBottom->getCbAddr(), dstPicBottom->getCStride(), dstPicBottom->getWidth()>>1, dstPicBottom->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC);
     600    scalePlane(dstPicBottom->getCrAddr(), dstPicBottom->getCStride(), dstPicBottom->getWidth()>>1, dstPicBottom->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC);
     601  }
     602  else
     603  {
     604    dstPicTop = pPicTop;
     605    dstPicBottom = pPicBottom;
     606  }
     607  // location of upper left pel in a plane
     608  Int planeOffset = 0; //cropLeft + cropTop * iStride;
     609  //Write luma
     610  if (! writeField(m_cHandle, dstPicTop->getLumaAddr() + planeOffset,  dstPicBottom->getLumaAddr() + planeOffset, is16bit, iStride, width, height, isTff))
     611  {
     612    retval=false;
     613    goto exit;
     614  }
     615 
     616  width >>= 1;
     617  height >>= 1;
     618  iStride >>= 1;
     619  cropLeft >>= 1;
     620  cropRight >>= 1;
     621 
     622  planeOffset = 0; // cropLeft + cropTop * iStride;
     623 
     624  //Write chroma U
     625  if (! writeField(m_cHandle, dstPicTop->getCbAddr() + planeOffset, dstPicBottom->getCbAddr() + planeOffset, is16bit, iStride, width, height, isTff))
     626  {
     627    retval=false;
     628    goto exit;
     629  }
     630 
     631  //Write chroma V
     632  if (! writeField(m_cHandle, dstPicTop->getCrAddr() + planeOffset, dstPicBottom->getCrAddr() + planeOffset, is16bit, iStride, width, height, isTff))
     633   
     634  {
     635    retval=false;
     636    goto exit;
     637  }
     638 
     639exit:
     640  if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0)
     641  {
     642    dstPicTop->destroy();
     643    delete dstPicTop;
     644    dstPicBottom->destroy();
     645    delete dstPicBottom;
     646  } 
     647  return retval;
     648}
  • branches/HTM-8.2-dev0-Cleanup/source/Lib/TLibVideoIO/TVideoIOYuv.h

    r608 r651  
    7272  Bool  read  ( TComPicYuv*   pPicYuv, Int aiPad[2] );     ///< read  one YUV frame with padding parameter
    7373  Bool  write( TComPicYuv*    pPicYuv, Int confLeft=0, Int confRight=0, Int confTop=0, Int confBottom=0 );
     74  Bool  write( TComPicYuv*    pPicYuv, TComPicYuv*    pPicYuv2, Int confLeft=0, Int confRight=0, Int confTop=0, Int confBottom=0  , bool isTff=false);
    7475 
    7576  Bool  isEof ();                                           ///< check for end-of-file
Note: See TracChangeset for help on using the changeset viewer.