Changeset 38 in SHVCSoftware for branches/SHM-1.1-dev/source/Lib


Ignore:
Timestamp:
20 Feb 2013, 21:24:20 (12 years ago)
Author:
seregin
Message:

AVC_SYNTAX: initial porting of the AVC metadata file reading

Location:
branches/SHM-1.1-dev/source/Lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/CommonDef.h

    r14 r38  
    5656// ====================================================================================================================
    5757
    58 #define NV_VERSION        "1.0"                 ///< Current software version
     58#define NV_VERSION        "1.1"                 ///< Current software version
    5959
    6060// ====================================================================================================================
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r33 r38  
    383383  m_layerId          = pcPic->getLayerId();
    384384#endif
    385 
    386385  for(int i=0; i<pcPic->getNumPartInCU(); i++)
    387386  {
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/TComMotionInfo.h

    r28 r38  
    141141  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    142142
     143#if AVC_SYNTAX
     144  Void           setMv    (TComMv cMv,  Int iIdx )         { m_pcMv    [iIdx] = cMv; }
     145  Void           setRefIdx(Int iRefIdx, Int iIdx   )       { m_piRefIdx[iIdx] =  iRefIdx; }
     146#endif
     147
    143148  Void setNumPartition( Int iNumPart )
    144149  {
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.cpp

    r33 r38  
    669669#endif
    670670
     671#if AVC_SYNTAX
     672Void TComPic::readBLSyntax( fstream* filestream, UInt numBytes )
     673{
     674  if( !filestream->good() )
     675  {
     676    return;
     677  }
     678
     679  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - this->getPicYuvRec()->getPicCropLeftOffset() - this->getPicYuvRec()->getPicCropRightOffset();
     680  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - this->getPicYuvRec()->getPicCropTopOffset() - this->getPicYuvRec()->getPicCropBottomOffset();
     681  UInt64 uiPOC        = (UInt64)this->getPOC();
     682  UInt   uiPartWidth  = uiWidth / 4;
     683  UInt   uiPartHeight = uiHeight / 4;
     684
     685  UInt uiNumPartInWidth    = this->getNumPartInWidth();
     686  UInt uiNumPartInHeight   = this->getNumPartInHeight();
     687  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
     688
     689  UInt64 uiPos = (UInt64)uiPOC * uiWidth * uiHeight * numBytes / 16;
     690   
     691  filestream->seekg( uiPos, ios_base::beg );
     692
     693  for( Int i = 0; i < this->getNumCUsInFrame(); i++ )
     694  {
     695    TComDataCU* pcCU = this->getCU( i );
     696    pcCU->initCU( this, i );
     697  }
     698
     699  for( Int i = 0; i < uiPartHeight; i++ )
     700  {
     701    for( Int j = 0; j < uiPartWidth; j++ )
     702    {
     703      UInt uiX = ( j / uiNumPartInWidth );
     704      UInt uiY = ( i / uiNumPartInHeight );
     705
     706      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
     707      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
     708      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
     709     
     710      TComDataCU* pcCU = this->getCU( uiLCUAddr );
     711     
     712      TComMv mv;
     713      Short temp;
     714
     715      // RefIdxL0
     716      Char refIdxL0 = -1;
     717      filestream->read( &refIdxL0, 1 );
     718      assert( refIdxL0 >= -1 );
     719      pcCU->getCUMvField( REF_PIC_LIST_0 )->setRefIdx( (Int)refIdxL0, uiPartAddr );
     720
     721      // RefIdxL1
     722      Char refIdxL1 = -1;
     723      filestream->read( &refIdxL1, 1 );
     724      assert( refIdxL1 >= -1 );
     725      pcCU->getCUMvField( REF_PIC_LIST_1 )->setRefIdx( (Int)refIdxL1, uiPartAddr );
     726
     727      // MV L0
     728      temp = 0;
     729      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     730      mv.setHor( (Short)temp );
     731      temp = 0;
     732      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     733      mv.setVer( (Short)temp );
     734      pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv, uiPartAddr );
     735
     736      // MV L1
     737      temp = 0;
     738      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     739      mv.setHor( (Short)temp );
     740      temp = 0;
     741      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     742      mv.setVer( (Short)temp );
     743      pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv, uiPartAddr );
     744
     745      // set dependent information
     746      pcCU->setPredictionMode( uiPartAddr, ( refIdxL0 == NOT_VALID && refIdxL1 == NOT_VALID ) ? MODE_INTRA : MODE_INTER );
     747      UInt uiInterDir = ( refIdxL0 != NOT_VALID ) + ( refIdxL1 != NOT_VALID && pcCU->getSlice()->isInterB() ) * 2;
     748      assert( uiInterDir >= 0 && uiInterDir <= 3 );
     749      pcCU->setInterDir( uiPartAddr, uiInterDir );
     750    }
     751  }
     752}
     753#endif
     754
     755#if SYNTAX_OUTPUT
     756Void TComPic::wrireBLSyntax( fstream* filestream, UInt numBytes )
     757{
     758  if( !filestream->good() )
     759  {
     760    return;
     761  }
     762
     763  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - getSlice(0)->getSPS()->getPicCropLeftOffset() - getSlice(0)->getSPS()->getPicCropRightOffset();
     764  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - getSlice(0)->getSPS()->getPicCropTopOffset() - getSlice(0)->getSPS()->getPicCropBottomOffset();
     765  UInt64 uiPOC        = (UInt64)this->getPOC();
     766  UInt   uiPartWidth  = uiWidth / 4;
     767  UInt   uiPartHeight = uiHeight / 4;
     768
     769  UInt uiNumPartInWidth    = this->getNumPartInWidth();
     770  UInt uiNumPartInHeight   = this->getNumPartInHeight();
     771  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
     772
     773  filestream->seekg( uiPOC * uiWidth * uiHeight * numBytes / 16 );
     774   
     775  for( Int i = 0; i < uiPartHeight; i++ )
     776  {
     777    for( Int j = 0; j < uiPartWidth; j++ )
     778    {
     779      UInt uiX = ( j / uiNumPartInWidth );
     780      UInt uiY = ( i / uiNumPartInHeight );
     781
     782      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
     783      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
     784      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
     785     
     786      TComDataCU* pcCU = this->getCU( uiLCUAddr );
     787     
     788      TComMv mv;
     789      Short temp;
     790      Char refIdxL0 = NOT_VALID, refIdxL1 = NOT_VALID;
     791
     792      // RefIdx
     793      if( !pcCU->isIntra( uiPartAddr ) )
     794      {
     795        refIdxL0 = (Char)pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
     796        refIdxL1 = (Char)pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
     797      }
     798      assert( refIdxL0 >= - 1 && refIdxL1 >= - 1 );
     799      filestream->put( refIdxL0 );
     800      filestream->put( refIdxL1 );
     801
     802      // MV L0
     803      mv.setZero();
     804      if( refIdxL0 >= 0 )
     805      {
     806        mv = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
     807      }
     808      temp = (Short)mv.getHor();
     809      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     810      temp = (Short)mv.getVer();
     811      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     812
     813      // MV L1
     814      mv.setZero();
     815      if( refIdxL1 >= 0 )
     816      {
     817        mv = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
     818      }
     819      temp = (Short)mv.getHor();
     820      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     821      temp = (Short)mv.getVer();
     822      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     823    }
     824  }
     825}
     826#endif
     827
     828
    671829//! \}
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPic.h

    r28 r38  
    4444#include "TComPicYuv.h"
    4545#include "TComBitStream.h"
     46#if AVC_BASE || SYNTAX_OUTPUT
     47#include <fstream>
     48#endif
     49
    4650
    4751//! \ingroup TLibCommon
     
    209213  Void  copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut);
    210214#endif
     215#if AVC_SYNTAX
     216  Void readBLSyntax( fstream* filestream, UInt numBytes );
     217#endif
     218#if SYNTAX_OUTPUT
     219  Void wrireBLSyntax( fstream* filestream, UInt numBytes );
     220#endif
     221
    211222};// END CLASS DEFINITION TComPic
    212223
     
    214225
    215226#endif // __TCOMPIC__
     227
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/TComPicSym.h

    r2 r38  
    125125  UInt        getNumberOfCUsInFrame()   { return m_uiNumCUsInFrame;  }
    126126  TComDataCU*&  getCU( UInt uiCUAddr )  { return m_apcTComDataCU[uiCUAddr];     }
     127
     128#if AVC_SYNTAX
     129  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
     130  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
     131  UInt        getMaxDepth()             { return m_uhTotalDepth;               }
     132#endif
    127133 
    128134  Void        setSlice(TComSlice* p, UInt i) { m_apcTComSlice[i] = p;           }
  • branches/SHM-1.1-dev/source/Lib/TLibCommon/TypeDef.h

    r28 r38  
    4040
    4141#define SVC_EXTENSION                    1
     42
     43#define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
     44
    4245#if SVC_EXTENSION
    4346#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     
    4952#define BUGFIX_925                       1      ///< bug fix ticket #925
    5053#define ENCODER_BUGFIX                   1      ///< L0167: encoder bug fix for inter mode
    51 
    5254#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
    5355
    54 #define AVC_BASE                         0      ///< YUV BL reading for AVC base SVC
    55 
     56#define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
    5657#define REF_IDX_FRAMEWORK                0      ///< inter-layer reference framework
     58
     59#if AVC_BASE
     60#define AVC_SYNTAX                       1      ///< Syntax reading for AVC base
     61#endif
    5762
    5863#if REF_IDX_FRAMEWORK
     
    6065#define REF_IDX_ME_ZEROMV                1      ///< L0051: use zero motion for inter-layer reference picture (without fractional ME)
    6166#define ENCODER_FAST_MODE                1      ///< L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
     67#if !AVC_BASE || AVC_SYNTAX
    6268#define REF_IDX_MFM                      1      ///< L0336: motion vector mapping of inter-layer reference picture
     69#endif
    6370#else
    6471#define INTRA_BL                         1      ///< inter-layer texture prediction
     
    6976
    7077// Hooks
    71 #if !AVC_BASE
     78#if !AVC_BASE || AVC_SYNTAX
    7279#define SVC_MVP                          1      ///< motion hook for merge mode as an example
     80#if !AVC_SYNTAX
    7381#define SVC_BL_CAND_INTRA                0      ///< Intra Base Mode Prediction hook as an example
    7482#endif
     
    8088
    8189#endif
     90#endif
     91#else
     92#define SYNTAX_OUTPUT                    1
    8293#endif
    8394
  • branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r30 r38  
    8181  memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
    8282#endif
     83#if AVC_SYNTAX || SYNTAX_OUTPUT
     84  m_pBLSyntaxFile = NULL;
     85#endif
    8386
    8487}
     
    335338
    336339  m_cGopDecoder.filterPicture(pcPic);
     340
     341#if SYNTAX_OUTPUT
     342  pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES );
     343#endif
    337344
    338345  TComSlice::sortPicList( m_cListPic ); // sorting for application output
     
    559566  {
    560567    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
    561     FILE* pFile = m_ppcTDecTop[0]->getBLReconFile();
    562     UInt uiWidth = pBLPic->getPicYuvRec()->getWidth();
    563     UInt uiHeight = pBLPic->getPicYuvRec()->getHeight();
     568    fstream* pFile = m_ppcTDecTop[0]->getBLReconFile();
     569    UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - pBLPic->getPicYuvRec()->getPicCropLeftOffset() - pBLPic->getPicYuvRec()->getPicCropRightOffset();;
     570    UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - pBLPic->getPicYuvRec()->getPicCropTopOffset() - pBLPic->getPicYuvRec()->getPicCropBottomOffset();
    564571       
    565     if( pFile )
    566     {
    567       fseek( pFile, m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2, SEEK_SET );
     572    if( pFile->good() )
     573    {
     574      UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
     575
     576      pFile->seekg((UInt)uiPos, ios::beg );
    568577
    569578      Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
     
    573582        for( Int j = 0; j < uiWidth; j++ )
    574583        {
    575           pPel[j] = fgetc( pFile );
     584          pPel[j] = pFile->get();
    576585        }
    577586        pPel += uiStride;
     
    584593        for( Int j = 0; j < uiWidth/2; j++ )
    585594        {
    586           pPel[j] = fgetc( pFile );
     595          pPel[j] = pFile->get();
    587596        }
    588597        pPel += uiStride;
     
    595604        for( Int j = 0; j < uiWidth/2; j++ )
    596605        {
    597           pPel[j] = fgetc( pFile );
     606          pPel[j] = pFile->get();
    598607        }
    599608        pPel += uiStride;
    600609      }
    601610    }
     611#if AVC_SYNTAX
     612    if( m_apcSlicePilot->getPOC() == 0 )
     613    {
     614      // initialize partition order.
     615      UInt* piTmp = &g_auiZscanToRaster[0];
     616      initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
     617      initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
     618    }
     619    pBLPic->getSlice( 0 )->setPOC( m_apcSlicePilot->getPOC() );
     620    pBLPic->getSlice( 0 )->setSliceType( m_apcSlicePilot->getSliceType() );
     621    pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     622#endif
    602623  }
    603624#endif
     
    9791000        {
    9801001#if SVC_UPSAMPLING
     1002#if AVC_SYNTAX
     1003          TComSPS* sps = new TComSPS();
     1004          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, sps, true);
     1005#else
    9811006          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL, true);
     1007#endif
    9821008#else
    9831009          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
  • branches/SHM-1.1-dev/source/Lib/TLibDecoder/TDecTop.h

    r28 r38  
    127127  TDecTop**               m_ppcTDecTop;
    128128#if AVC_BASE
    129   FILE*                   m_pBLReconFile;
     129  fstream*                m_pBLReconFile;
    130130  Int                     m_iBLSourceWidth;
    131131  Int                     m_iBLSourceHeight;
    132132#endif
    133133#endif
     134#if AVC_SYNTAX || SYNTAX_OUTPUT
     135  fstream*               m_pBLSyntaxFile;
     136#endif
    134137#if REF_IDX_FRAMEWORK
    135138  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
     
    165168  TDecTop*            getLayerDec(UInt layer)   { return m_ppcTDecTop[layer]; }
    166169#if AVC_BASE
    167   Void      setBLReconFile( FILE* pFile ) { m_pBLReconFile = pFile; }
    168   FILE*     getBLReconFile() { return m_pBLReconFile; }
     170  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
     171  fstream*  getBLReconFile() { return m_pBLReconFile; }
    169172  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
    170173  Int       getBLWidth() { return  m_iBLSourceWidth; }
    171174  Int       getBLHeight() { return  m_iBLSourceHeight; }
    172175#endif
     176#endif
     177#if AVC_SYNTAX || SYNTAX_OUTPUT
     178  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
     179  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
    173180#endif
    174181#if REF_IDX_FRAMEWORK
  • branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r28 r38  
    774774    {
    775775      pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
     776#if AVC_SYNTAX
     777      pcPic->readBLSyntax( m_ppcTEncTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     778#endif
    776779      return;
    777780    }
  • branches/SHM-1.1-dev/source/Lib/TLibEncoder/TEncTop.h

    r28 r38  
    7777  static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
    7878  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
     79#if AVC_SYNTAX
     80  fstream*                m_pBLSyntaxFile;
     81#endif
    7982#endif
    8083 
     
    223226
    224227  Void encodePrep( bool bEos, TComPicYuv* pcPicYuvOrg );
     228#if AVC_SYNTAX
     229  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
     230  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
     231#endif
    225232#else
    226233  Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
Note: See TracChangeset for help on using the changeset viewer.