Changeset 1319 in SHVCSoftware


Ignore:
Timestamp:
21 Jul 2015, 23:31:40 (9 years ago)
Author:
seregin
Message:

port rev 4394

Location:
branches/SHM-dev/source
Files:
14 edited

Legend:

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

    r1292 r1319  
    215215    AnnexBStats stats = AnnexBStats();
    216216
    217     vector<uint8_t> nalUnit;
    218217    InputNALUnit nalu;
    219     byteStreamNALUnit(bytestream, nalUnit, stats);
     218    byteStreamNALUnit(bytestream, nalu.getBitstream().getFifo(), stats);
    220219
    221220    // call actual decoding function
     
    223222    Bool bNewPOC = false;
    224223
    225     if (nalUnit.empty())
     224    if (nalu.getBitstream().getFifo().empty())
    226225    {
    227226      /* this can happen if the following occur:
     
    234233    else
    235234    {
    236       read(nalu, nalUnit);
     235      read(nalu);
    237236      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
    238237#if CONFORMANCE_BITSTREAM_MODE
     
    473472    AnnexBStats stats = AnnexBStats();
    474473
    475     vector<uint8_t> nalUnit;
    476474    InputNALUnit nalu;
    477     byteStreamNALUnit(bytestream, nalUnit, stats);
     475    byteStreamNALUnit(bytestream, nalu.getBitstream().getFifo(), stats);
    478476
    479477    // call actual decoding function
    480478    Bool bNewPicture = false;
    481     if (nalUnit.empty())
     479    if (nalu.getBitstream().getFifo().empty())
    482480    {
    483481      /* this can happen if the following occur:
     
    490488    else
    491489    {
    492       read(nalu, nalUnit);
     490      read(nalu);
    493491      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    494492      {
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1316 r1319  
    31143114      fprintf(stderr, "****************************************************************************\n");
    31153115    }
    3116   }
    3117   if ( m_bufferingPeriodSEIEnabled && !m_activeParameterSetsSEIEnabled)
    3118   {
    3119     fprintf(stderr, "****************************************************************************\n");
    3120     fprintf(stderr, "** WARNING: using buffering period SEI requires SPS activation with       **\n");
    3121     fprintf(stderr, "**          active parameter sets SEI. Enabling active parameter sets SEI **\n");
    3122     fprintf(stderr, "****************************************************************************\n");
    3123     m_activeParameterSetsSEIEnabled = 1;
    3124   }
    3125   if ( m_pictureTimingSEIEnabled && !m_activeParameterSetsSEIEnabled)
    3126   {
    3127     fprintf(stderr, "****************************************************************************\n");
    3128     fprintf(stderr, "** WARNING: using picture timing SEI requires SPS activation with active  **\n");
    3129     fprintf(stderr, "**          parameter sets SEI. Enabling active parameter sets SEI.       **\n");
    3130     fprintf(stderr, "****************************************************************************\n");
    3131     m_activeParameterSetsSEIEnabled = 1;
    31323116  }
    31333117
  • branches/SHM-dev/source/Lib/TLibCommon/NAL.h

    r1262 r1319  
    5151  UInt        m_nuhLayerId;  ///< nuh_layer_id
    5252
     53  NALUnit(const NALUnit &src)
     54  :m_nalUnitType (src.m_nalUnitType)
     55  ,m_temporalId  (src.m_temporalId)
     56  ,m_nuhLayerId  (src.m_nuhLayerId)
     57  { }
    5358  /** construct an NALunit structure with given header values. */
    5459  NALUnit(
     
    6166  {}
    6267
    63   /** default constructor - no initialization; must be perfomed by user */
     68  /** default constructor - no initialization; must be performed by user */
    6469  NALUnit() {}
     70
     71  virtual ~NALUnit() { }
    6572
    6673  /** returns true if the NALunit is a slice NALunit */
  • branches/SHM-dev/source/Lib/TLibCommon/TComBitStream.cpp

    r1260 r1319  
    6060}
    6161
    62 TComInputBitstream::TComInputBitstream(std::vector<uint8_t>* buf)
    63 {
    64   m_fifo = buf;
    65   m_fifo_idx = 0;
    66   m_held_bits = 0;
    67   m_num_held_bits = 0;
    68   m_numBitsRead = 0;
    69 }
    70 
    71 TComInputBitstream::~TComInputBitstream()
    72 {
    73 }
     62
     63TComInputBitstream::TComInputBitstream()
     64: m_fifo()
     65, m_emulationPreventionByteLocation()
     66, m_fifo_idx(0)
     67, m_num_held_bits(0)
     68, m_held_bits(0)
     69, m_numBitsRead(0)
     70{ }
     71
     72TComInputBitstream::TComInputBitstream(const TComInputBitstream &src)
     73: m_fifo(src.m_fifo)
     74, m_emulationPreventionByteLocation(src.m_emulationPreventionByteLocation)
     75, m_fifo_idx(src.m_fifo_idx)
     76, m_num_held_bits(src.m_num_held_bits)
     77, m_held_bits(src.m_held_bits)
     78, m_numBitsRead(src.m_numBitsRead)
     79{ }
    7480
    7581// ====================================================================================================================
    7682// Public member functions
    7783// ====================================================================================================================
     84
     85Void TComInputBitstream::resetToStart()
     86{
     87  m_fifo_idx=0;
     88  m_num_held_bits=0;
     89  m_held_bits=0;
     90  m_numBitsRead=0;
     91}
    7892
    7993Char* TComOutputBitstream::getByteStream() const
     
    283297  UInt aligned_word = 0;
    284298  UInt num_bytes_to_load = (uiNumberOfBits - 1) >> 3;
    285   assert(m_fifo_idx + num_bytes_to_load < m_fifo->size());
     299  assert(m_fifo_idx + num_bytes_to_load < m_fifo.size());
    286300
    287301  switch (num_bytes_to_load)
    288302  {
    289   case 3: aligned_word  = (*m_fifo)[m_fifo_idx++] << 24;
    290   case 2: aligned_word |= (*m_fifo)[m_fifo_idx++] << 16;
    291   case 1: aligned_word |= (*m_fifo)[m_fifo_idx++] <<  8;
    292   case 0: aligned_word |= (*m_fifo)[m_fifo_idx++];
     303  case 3: aligned_word  = m_fifo[m_fifo_idx++] << 24;
     304  case 2: aligned_word |= m_fifo[m_fifo_idx++] << 16;
     305  case 1: aligned_word |= m_fifo[m_fifo_idx++] <<  8;
     306  case 0: aligned_word |= m_fifo[m_fifo_idx++];
    293307  }
    294308
     
    351365{
    352366  UInt uiNumBytes = uiNumBits/8;
    353   std::vector<uint8_t>* buf = new std::vector<uint8_t>;
    354   UInt uiByte;
    355   for (UInt ui = 0; ui < uiNumBytes; ui++)
    356   {
    357     read(8, uiByte);
    358     buf->push_back(uiByte);
     367  TComInputBitstream *pResult = new TComInputBitstream;
     368
     369  std::vector<uint8_t> &buf = pResult->getFifo();
     370  buf.reserve((uiNumBits+7)>>3);
     371
     372  if (m_num_held_bits == 0)
     373  {
     374    std::size_t currentOutputBufferSize=buf.size();
     375    const UInt uiNumBytesToReadFromFifo = std::min<UInt>(uiNumBytes, m_fifo.size() - m_fifo_idx);
     376    buf.resize(currentOutputBufferSize+uiNumBytes);
     377    memcpy(&(buf[currentOutputBufferSize]), &(m_fifo[m_fifo_idx]), uiNumBytesToReadFromFifo); m_fifo_idx+=uiNumBytesToReadFromFifo;
     378    if (uiNumBytesToReadFromFifo != uiNumBytes)
     379    {
     380      memset(&(buf[currentOutputBufferSize+uiNumBytesToReadFromFifo]), 0, uiNumBytes - uiNumBytesToReadFromFifo);
     381    }
     382  }
     383  else
     384  {
     385    for (UInt ui = 0; ui < uiNumBytes; ui++)
     386    {
     387      UInt uiByte;
     388      read(8, uiByte);
     389      buf.push_back(uiByte);
     390    }
    359391  }
    360392  if (uiNumBits&0x7)
    361393  {
    362     uiByte = 0;
     394    UInt uiByte = 0;
    363395    read(uiNumBits&0x7, uiByte);
    364396    uiByte <<= 8-(uiNumBits&0x7);
    365     buf->push_back(uiByte);
    366   }
    367   return new TComInputBitstream(buf);
    368 }
    369 
    370 /**
    371  - delete internal fifo
    372  */
    373 Void TComInputBitstream::deleteFifo()
    374 {
    375   delete m_fifo;
    376   m_fifo = NULL;
     397    buf.push_back(uiByte);
     398  }
     399  return pResult;
    377400}
    378401
  • branches/SHM-dev/source/Lib/TLibCommon/TComBitStream.h

    r1262 r1319  
    163163class TComInputBitstream
    164164{
    165   std::vector<uint8_t> *m_fifo; /// FIFO for storage of complete bytes
    166   std::vector<UInt> m_emulationPreventionByteLocation;
    167 
    168165protected:
     166  std::vector<uint8_t> m_fifo; /// FIFO for storage of complete bytes
     167  std::vector<UInt>    m_emulationPreventionByteLocation;
     168
    169169  UInt m_fifo_idx; /// Read index into m_fifo
    170170
     
    175175public:
    176176  /**
    177    * Create a new bitstream reader object that reads from buf.  Ownership
    178    * of buf remains with the callee, although the constructed object
    179    * will hold a reference to buf
    180    */
    181   TComInputBitstream(std::vector<uint8_t>* buf);
    182   ~TComInputBitstream();
     177   * Create a new bitstream reader object that reads from buf.
     178   */
     179  TComInputBitstream();
     180  virtual ~TComInputBitstream() { }
     181  TComInputBitstream(const TComInputBitstream &src);
     182
     183  Void resetToStart();
    183184
    184185  // interface for decoding
     
    187188  Void        readByte        ( UInt &ruiBits )
    188189  {
    189     assert(m_fifo_idx < m_fifo->size());
    190     ruiBits = (*m_fifo)[m_fifo_idx++];
     190    assert(m_fifo_idx < m_fifo.size());
     191    ruiBits = m_fifo[m_fifo_idx++];
    191192  }
    192193
     
    194195  {
    195196    assert(m_fifo_idx > 0);
    196     byte = (*m_fifo)[m_fifo_idx - 1];
     197    byte = m_fifo[m_fifo_idx - 1];
    197198  }
    198199
     
    209210  UInt     readByte() { UInt tmp; readByte( tmp ); return tmp; }
    210211  UInt getNumBitsUntilByteAligned() { return m_num_held_bits & (0x7); }
    211   UInt getNumBitsLeft() { return 8*((UInt)m_fifo->size() - m_fifo_idx) + m_num_held_bits; }
     212  UInt getNumBitsLeft() { return 8*((UInt)m_fifo.size() - m_fifo_idx) + m_num_held_bits; }
    212213  TComInputBitstream *extractSubstream( UInt uiNumBits ); // Read the nominated number of bits, and return as a bitstream.
    213   Void                deleteFifo(); // Delete internal fifo of bitstream.
    214214  UInt  getNumBitsRead() { return m_numBitsRead; }
    215215  UInt readByteAlignment();
    216216
    217   Void      pushEmulationPreventionByteLocation ( UInt pos )                  { m_emulationPreventionByteLocation.push_back( pos ); }
    218   UInt      numEmulationPreventionBytesRead     ()                            { return (UInt) m_emulationPreventionByteLocation.size();    }
    219   std::vector<UInt>  getEmulationPreventionByteLocation  ()                   { return m_emulationPreventionByteLocation;           }
    220   UInt      getEmulationPreventionByteLocation  ( UInt idx )                  { return m_emulationPreventionByteLocation[ idx ];    }
    221   Void      clearEmulationPreventionByteLocation()                            { m_emulationPreventionByteLocation.clear();          }
    222   Void      setEmulationPreventionByteLocation  ( std::vector<UInt> vec )     { m_emulationPreventionByteLocation = vec;            }
    223 
    224   const std::vector<uint8_t> *getFifo() const { return m_fifo; }
     217  Void      pushEmulationPreventionByteLocation ( UInt pos )                         { m_emulationPreventionByteLocation.push_back( pos ); }
     218  UInt      numEmulationPreventionBytesRead     ()                                   { return (UInt) m_emulationPreventionByteLocation.size();    }
     219  const std::vector<UInt> &getEmulationPreventionByteLocation  () const              { return m_emulationPreventionByteLocation;           }
     220  UInt      getEmulationPreventionByteLocation  ( UInt idx )                         { return m_emulationPreventionByteLocation[ idx ];    }
     221  Void      clearEmulationPreventionByteLocation()                                   { m_emulationPreventionByteLocation.clear();          }
     222  Void      setEmulationPreventionByteLocation  ( const std::vector<UInt> &vec )     { m_emulationPreventionByteLocation = vec;            }
     223
     224  const std::vector<uint8_t> &getFifo() const { return m_fifo; }
     225        std::vector<uint8_t> &getFifo()       { return m_fifo; }
    225226};
    226227
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp

    r1316 r1319  
    5151ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS);
    5252ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS);
    53 TComVPS ParameterSetManager::m_activeVPS;
     53Int ParameterSetManager::m_activeVPSId = -1;
    5454#endif
    5555
     
    27902790ParameterSetManager::ParameterSetManager()
    27912791#if SVC_EXTENSION
    2792 : m_activeSPS()
     2792: m_activePPSId(-1)
    27932793#else
    27942794: m_vpsMap(MAX_NUM_VPS)
    27952795, m_spsMap(MAX_NUM_SPS)
    27962796, m_ppsMap(MAX_NUM_PPS)
    2797 , m_activeVPS()
    2798 , m_activeSPS()
    2799 #endif
    2800 {
    2801 #if !SVC_EXTENSION
    2802   m_activeVPS.setVPSId(-1);
    2803 #endif
    2804   m_activeSPS.setSPSId(-1);
     2797, m_activeVPSId(-1)
     2798#endif
     2799, m_activeSPSId(-1)
     2800{
    28052801}
    28062802
     
    28122808//! activate a SPS from a active parameter sets SEI message
    28132809//! \returns true, if activation is successful
    2814 Bool ParameterSetManager::activateSPSWithSEI(Int spsId)
    2815 {
    2816   TComSPS *sps = m_spsMap.getPS(spsId);
    2817   if (sps)
    2818   {
    2819     Int vpsId = sps->getVPSId();
    2820     TComVPS *vps = m_vpsMap.getPS(vpsId);
    2821     if (vps)
    2822     {
    2823       m_activeVPS = *(vps);
    2824       m_activeSPS = *(sps);
    2825       return true;
    2826     }
    2827     else
    2828     {
    2829       printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist.");
    2830     }
    2831   }
    2832   else
    2833   {
    2834     printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message.");
    2835   }
    2836   return false;
    2837 }
     2810//Bool ParameterSetManager::activateSPSWithSEI(Int spsId)
     2811//{
     2812//  TComSPS *sps = m_spsMap.getPS(spsId);
     2813//  if (sps)
     2814//  {
     2815//    Int vpsId = sps->getVPSId();
     2816//    TComVPS *vps = m_vpsMap.getPS(vpsId);
     2817//    if (vps)
     2818//    {
     2819//      m_activeVPS = *(vps);
     2820//      m_activeSPS = *(sps);
     2821//      return true;
     2822//    }
     2823//    else
     2824//    {
     2825//      printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist.");
     2826//    }
     2827//  }
     2828//  else
     2829//  {
     2830//    printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message.");
     2831//  }
     2832//  return false;
     2833//}
    28382834
    28392835//! activate a PPS and depending on isIDR parameter also SPS and VPS
     
    28442840  if (pps)
    28452841  {
     2842#if SVC_EXTENSION
     2843    m_activePPSId = ppsId;
     2844#endif
    28462845    Int spsId = pps->getSPSId();
    2847     if (!isIRAP && (spsId != m_activeSPS.getSPSId() ))
     2846    if (!isIRAP && (spsId != m_activeSPSId ))
    28482847    {
    28492848      printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR.");
    2850       return false;
    2851     }
    2852     TComSPS *sps = m_spsMap.getPS(spsId);
    2853     if (sps)
    2854     {
    2855       Int vpsId = sps->getVPSId();
    2856       if (!isIRAP && (vpsId != m_activeVPS.getVPSId() ))
    2857       {
    2858         printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR.");
    2859         return false;
    2860       }
    2861       TComVPS *vps =m_vpsMap.getPS(vpsId);
    2862       if (vps)
    2863       {
    2864         m_activeVPS = *(vps);
    2865         m_activeSPS = *(sps);
    2866 #if SVC_EXTENSION
    2867         m_activePPS = *(pps);
    2868 #endif
    2869         return true;
     2849    }
     2850    else
     2851    {
     2852      TComSPS *sps = m_spsMap.getPS(spsId);
     2853      if (sps)
     2854      {
     2855        Int vpsId = sps->getVPSId();
     2856        if (!isIRAP && (vpsId != m_activeVPSId ))
     2857        {
     2858          printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR.");
     2859        }
     2860        else
     2861        {
     2862          TComVPS *vps =m_vpsMap.getPS(vpsId);
     2863          if (vps)
     2864          {
     2865            m_activeVPSId = vpsId;
     2866            m_activeSPSId = spsId;
     2867            return true;
     2868          }
     2869          else
     2870          {
     2871            printf("Warning: tried to activate PPS that refers to a non-existing VPS.");
     2872          }
     2873        }
    28702874      }
    28712875      else
    28722876      {
    2873         printf("Warning: tried to activate PPS that refers to a non-existing VPS.");
    2874       }
    2875     }
    2876     else
    2877     {
    2878       printf("Warning: tried to activate a PPS that refers to a non-existing SPS.");
     2877        printf("Warning: tried to activate a PPS that refers to a non-existing SPS.");
     2878      }
    28792879    }
    28802880  }
     
    28832883    printf("Warning: tried to activate non-existing PPS.");
    28842884  }
     2885
     2886  // Failed to activate if reach here.
     2887  m_activeSPSId=-1;
     2888  m_activeVPSId=-1;
    28852889  return false;
    28862890}
     
    29052909}
    29062910
    2907 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData)
     2911Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData)
    29082912{
    29092913  if (!bChanged)
     
    29222926      else
    29232927      {
    2924         const UChar *pNewDataArray=&(*pNewData)[0];
     2928        const UChar *pNewDataArray=&(newData)[0];
    29252929        const UChar *pOldDataArray=&(*pOldData)[0];
    29262930        if (memcmp(pOldDataArray, pNewDataArray, pOldData->size()))
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h

    r1316 r1319  
    25022502
    25032503
    2504 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData);
     2504Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData);
    25052505
    25062506template <class T> class ParameterSetMap
     
    25282528  }
    25292529
    2530   Void storePS(Int psId, T *ps, const std::vector<UChar> *pNaluData)
     2530  Void storePS(Int psId, T *ps, const std::vector<UChar> &naluData)
    25312531  {
    25322532    assert ( psId < m_maxId );
     
    25362536
    25372537      // work out changed flag
    2538       calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, pNaluData);
     2538      calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, naluData);
    25392539      delete m_paramsetMap[psId].pNaluData;
    25402540      delete m_paramsetMap[psId].parameterSet;
     
    25472547      m_paramsetMap[psId].bChanged = false;
    25482548    }
    2549     if (pNaluData)
    2550     {
    2551       m_paramsetMap[psId].pNaluData=new std::vector<UChar>;
    2552       *(m_paramsetMap[psId].pNaluData) = *pNaluData;
    2553     }
    2554     else
    2555     {
    2556       m_paramsetMap[psId].pNaluData=0;
    2557     }
     2549    m_paramsetMap[psId].pNaluData=new std::vector<UChar>;
     2550    *(m_paramsetMap[psId].pNaluData) = naluData;
    25582551  }
    25592552
     
    25782571  T* getPS(Int psId)
    25792572  {
    2580     return ( m_paramsetMap.find(psId) == m_paramsetMap.end() ) ? NULL : m_paramsetMap[psId].parameterSet;
     2573    typename std::map<Int,MapData<T> >::iterator it=m_paramsetMap.find(psId);
     2574    return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
     2575  }
     2576
     2577  const T* getPS(Int psId) const
     2578  {
     2579    typename std::map<Int,MapData<T> >::const_iterator it=m_paramsetMap.find(psId);
     2580    return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
    25812581  }
    25822582
     
    25982598
    25992599  //! store sequence parameter set and take ownership of it
    2600   Void           storeVPS(TComVPS *vps, const std::vector<UChar> *pNaluData) { m_vpsMap.storePS( vps->getVPSId(), vps, pNaluData); };
     2600  Void           storeVPS(TComVPS *vps, const std::vector<UChar> &naluData) { m_vpsMap.storePS( vps->getVPSId(), vps, naluData); };
    26012601  //! get pointer to existing video parameter set
    26022602  TComVPS*       getVPS(Int vpsId)                                           { return m_vpsMap.getPS(vpsId); };
     
    26062606
    26072607  //! store sequence parameter set and take ownership of it
    2608   Void           storeSPS(TComSPS *sps, const std::vector<UChar> *pNaluData) { m_spsMap.storePS( sps->getSPSId(), sps, pNaluData); };
     2608  Void           storeSPS(TComSPS *sps, const std::vector<UChar> &naluData) { m_spsMap.storePS( sps->getSPSId(), sps, naluData); };
    26092609  //! get pointer to existing sequence parameter set
    26102610  TComSPS*       getSPS(Int spsId)                                           { return m_spsMap.getPS(spsId); };
     
    26142614
    26152615  //! store picture parameter set and take ownership of it
    2616   Void           storePPS(TComPPS *pps, const std::vector<UChar> *pNaluData) { m_ppsMap.storePS( pps->getPPSId(), pps, pNaluData); };
     2616  Void           storePPS(TComPPS *pps, const std::vector<UChar> &naluData) { m_ppsMap.storePS( pps->getPPSId(), pps, naluData); };
    26172617  //! get pointer to existing picture parameter set
    26182618  TComPPS*       getPPS(Int ppsId)                                           { return m_ppsMap.getPS(ppsId); };
     
    26232623  //! activate a SPS from a active parameter sets SEI message
    26242624  //! \returns true, if activation is successful
    2625   Bool           activateSPSWithSEI(Int SPSId);
     2625  // Bool           activateSPSWithSEI(Int SPSId);
    26262626
    26272627  //! activate a PPS and depending on isIDR parameter also SPS and VPS
     
    26292629  Bool           activatePPS(Int ppsId, Bool isIRAP);
    26302630
    2631   const TComVPS* getActiveVPS()const { return &m_activeVPS; };
    2632   const TComSPS* getActiveSPS()const { return &m_activeSPS; };
     2631  const TComVPS* getActiveVPS()const { return m_vpsMap.getPS(m_activeVPSId); };
     2632  const TComSPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); };
    26332633
    26342634#if SVC_EXTENSION
    2635   const TComPPS* getActivePPS()const { return &m_activePPS; };
     2635  const TComPPS* getActivePPS()const { return m_ppsMap.getPS(m_activePPSId); };
    26362636#endif
    26372637
     
    26432643  static ParameterSetMap<TComPPS> m_ppsMap;
    26442644
    2645   TComPPS                  m_activePPS;
    2646   static TComVPS           m_activeVPS;
     2645  Int    m_activePPSId;
     2646  static Int m_activeVPSId; // -1 for nothing active;
    26472647#else
    26482648  ParameterSetMap<TComVPS> m_vpsMap;
     
    26502650  ParameterSetMap<TComPPS> m_ppsMap;
    26512651
    2652   TComVPS                  m_activeVPS; // used for SEI message
    2653 #endif
    2654 
    2655   TComSPS                  m_activeSPS; // used for SEI message
     2652  Int m_activeVPSId; // -1 for nothing active
     2653#endif
     2654
     2655  Int m_activeSPSId; // -1 for nothing active
    26562656};
    26572657
  • branches/SHM-dev/source/Lib/TLibDecoder/NALread.cpp

    r1259 r1319  
    3434/**
    3535 \file     NALread.cpp
    36  \brief    reading funtionality for NAL units
     36 \brief    reading functionality for NAL units
    3737 */
    3838
     
    105105Void readNalUnitHeader(InputNALUnit& nalu)
    106106{
    107   TComInputBitstream& bs = *nalu.m_Bitstream;
     107  TComInputBitstream& bs = nalu.getBitstream();
    108108
    109109  Bool forbidden_zero_bit = bs.read(1);           // forbidden_zero_bit
     
    165165 * a bitstream
    166166 */
    167 Void read(InputNALUnit& nalu, vector<uint8_t>& nalUnitBuf)
     167Void read(InputNALUnit& nalu)
    168168{
    169   /* perform anti-emulation prevention */
    170   TComInputBitstream *pcBitstream = new TComInputBitstream(NULL);
    171   convertPayloadToRBSP(nalUnitBuf, pcBitstream, (nalUnitBuf[0] & 64) == 0);
    172 
    173   nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf);
    174   nalu.m_Bitstream->setEmulationPreventionByteLocation(pcBitstream->getEmulationPreventionByteLocation());
    175   delete pcBitstream;
     169  TComInputBitstream &bitstream = nalu.getBitstream();
     170  vector<uint8_t>& nalUnitBuf=bitstream.getFifo();
     171  // perform anti-emulation prevention
     172  convertPayloadToRBSP(nalUnitBuf, &bitstream, (nalUnitBuf[0] & 64) == 0);
     173  bitstream.resetToStart();
    176174  readNalUnitHeader(nalu);
    177175}
  • branches/SHM-dev/source/Lib/TLibDecoder/NALread.h

    r1259 r1319  
    3434/**
    3535 \file     NALread.h
    36  \brief    reading funtionality for NAL units
     36 \brief    reading functionality for NAL units
    3737 */
    3838
     
    5353 * bitstream object.
    5454 */
    55 struct InputNALUnit : public NALUnit
     55class InputNALUnit : public NALUnit
    5656{
    57   InputNALUnit() : m_Bitstream(0) {};
    58   ~InputNALUnit() { delete m_Bitstream; }
     57  private:
     58    TComInputBitstream m_Bitstream;
    5959
    60   TComInputBitstream* m_Bitstream;
     60  public:
     61    InputNALUnit(const InputNALUnit &src) : NALUnit(src), m_Bitstream(src.m_Bitstream) {};
     62    InputNALUnit() : m_Bitstream() {};
     63    virtual ~InputNALUnit() { }
     64    const TComInputBitstream &getBitstream() const { return m_Bitstream; }
     65          TComInputBitstream &getBitstream()       { return m_Bitstream; }
    6166};
    6267
    63 Void read(InputNALUnit& nalu, std::vector<uint8_t>& nalUnitBuf);
     68Void read(InputNALUnit& nalu);
     69Void readNalUnitHeader(InputNALUnit& nalu);
    6470
    6571//! \}
  • branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp

    r1307 r1319  
    471471
    472472  /* restore primary bitstream for sei_message */
    473   getBitstream()->deleteFifo();
    474473  delete getBitstream();
    475474  setBitstream(bs);
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp

    r1292 r1319  
    154154  for (UInt ui = 0; ui < uiNumSubstreams; ui++)
    155155  {
    156     ppcSubstreams[ui]->deleteFifo();
    157156    delete ppcSubstreams[ui];
    158157  }
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r1316 r1319  
    6363
    6464TDecTop::TDecTop()
    65   : m_pDecodedSEIOutputStream(NULL),
    66     m_warningMessageSkipPicture(false)
    67 {
    68   m_pcPic = 0;
    69   m_iMaxRefPicNum = 0;
     65  : m_iMaxRefPicNum(0)
     66  , m_associatedIRAPType(NAL_UNIT_INVALID)
     67  , m_pocCRA(0)
     68  , m_pocRandomAccess(MAX_INT)
     69  , m_cListPic()
     70  , m_parameterSetManager()
     71  , m_apcSlicePilot(NULL)
     72  , m_SEIs()
     73  , m_cPrediction()
     74  , m_cTrQuant()
     75  , m_cGopDecoder()
     76  , m_cSliceDecoder()
     77  , m_cCuDecoder()
     78  , m_cEntropyDecoder()
     79  , m_cCavlcDecoder()
     80  , m_cSbacDecoder()
     81  , m_cBinCABAC()
     82  , m_seiReader()
     83  , m_cLoopFilter()
     84  , m_cSAO()
     85  , m_pcPic(NULL)
     86#if !SVC_EXTENSION
     87  , m_prevPOC(MAX_INT)
     88#endif
     89  , m_prevTid0POC(0)
     90  , m_bFirstSliceInPicture(true)
     91#if !SVC_EXTENSION
     92  , m_bFirstSliceInSequence(true)
     93#endif
     94  , m_prevSliceSkipped(false)
     95  , m_skippedPOC(0)
     96  , m_bFirstSliceInBitstream(true)
     97  , m_lastPOCNoOutputPriorPics(-1)
     98  , m_isNoOutputPriorPics(false)
     99  , m_craNoRaslOutputFlag(false)
     100#if O0043_BEST_EFFORT_DECODING
     101  , m_forceDecodeBitDepth(8)
     102#endif
     103  , m_pDecodedSEIOutputStream(NULL)
     104  , m_warningMessageSkipPicture(false)
     105  , m_prefixSEINALUs()
     106{
    70107#if ENC_DEC_TRACE
    71108  if (g_hTrace == NULL)
     
    76113  g_nSymbolCounter = 0;
    77114#endif
    78   m_associatedIRAPType = NAL_UNIT_INVALID;
    79   m_pocCRA = 0;
    80   m_pocRandomAccess = MAX_INT;
    81 #if !SVC_EXTENSION
    82   m_prevPOC                = MAX_INT;
    83 #endif
    84   m_prevTid0POC            = 0;
    85   m_bFirstSliceInPicture    = true;
    86 #if !SVC_EXTENSION
    87   m_bFirstSliceInSequence   = true;
    88 #endif
    89   m_prevSliceSkipped = false;
    90   m_skippedPOC = 0;
    91   m_bFirstSliceInBitstream  = true;
    92   m_lastPOCNoOutputPriorPics = -1;
    93   m_craNoRaslOutputFlag = false;
    94   m_isNoOutputPriorPics = false;
    95115
    96116#if SVC_EXTENSION
     
    133153  }
    134154#endif
     155  while (!m_prefixSEINALUs.empty())
     156  {
     157    delete m_prefixSEINALUs.front();
     158    m_prefixSEINALUs.pop_front();
     159  }
    135160#if CGS_3D_ASYMLUT
    136161  if(m_pColorMappedPic)
     
    431456      assert (0);
    432457    }
     458
     459    xParsePrefixSEImessages();
    433460
    434461#if RExt__HIGH_BIT_DEPTH_SUPPORT==0
     
    699726    }
    700727
     728    xParsePrefixSEImessages();
     729
    701730    // Check if any new SEI has arrived
    702731     if(!m_SEIs.empty())
     
    709738     }
    710739  }
    711 
     740}
     741
     742
     743Void TDecTop::xParsePrefixSEIsForUnknownVCLNal()
     744{
     745  while (!m_prefixSEINALUs.empty())
     746  {
     747    // do nothing?
     748    printf("Discarding Prefix SEI associated with unknown VCL NAL unit.\n");
     749    delete m_prefixSEINALUs.front();
     750  }
     751  // TODO: discard following suffix SEIs as well?
     752}
     753
     754
     755Void TDecTop::xParsePrefixSEImessages()
     756{
     757#if SVC_EXTENSION
     758    if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit
     759    {
     760      return;
     761    }
     762#endif
     763
     764  while (!m_prefixSEINALUs.empty())
     765  {
     766    InputNALUnit &nalu=*m_prefixSEINALUs.front();
     767#if LAYERS_NOT_PRESENT_SEI
     768    m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
     769#else
     770    m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
     771#endif
     772    delete m_prefixSEINALUs.front();
     773    m_prefixSEINALUs.pop_front();
     774  }
    712775}
    713776
     
    783846    m_apcSlicePilot->setPOC(m_skippedPOC);
    784847  }
     848
     849  xUpdatePreviousTid0POC(m_apcSlicePilot);
    785850
    786851  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
     
    17951860
    17961861  //  Decode a picture
    1797   m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic);
     1862  m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
    17981863
    17991864#if SVC_EXTENSION
     
    18081873}
    18091874
    1810 Void TDecTop::xDecodeVPS(const std::vector<UChar> *pNaluData)
     1875Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData)
    18111876{
    18121877  TComVPS* vps = new TComVPS();
    18131878
    18141879  m_cEntropyDecoder.decodeVPS( vps );
    1815   m_parameterSetManager.storeVPS(vps, pNaluData);
     1880  m_parameterSetManager.storeVPS(vps, naluData);
    18161881#if SVC_EXTENSION
    18171882  checkValueOfTargetOutputLayerSetIdx(vps);
     
    18371902}
    18381903
    1839 Void TDecTop::xDecodeSPS(const std::vector<UChar> *pNaluData)
     1904Void TDecTop::xDecodeSPS(const std::vector<UChar> &naluData)
    18401905{
    18411906  TComSPS* sps = new TComSPS();
     
    18471912#endif
    18481913  m_cEntropyDecoder.decodeSPS( sps );
    1849   m_parameterSetManager.storeSPS(sps, pNaluData);
     1914  m_parameterSetManager.storeSPS(sps, naluData);
    18501915}
    18511916
    18521917#if CGS_3D_ASYMLUT
    1853 Void TDecTop::xDecodePPS( const std::vector<UChar> *pNaluData, TCom3DAsymLUT * pc3DAsymLUT )
     1918Void TDecTop::xDecodePPS( const std::vector<UChar> &naluData, TCom3DAsymLUT * pc3DAsymLUT )
    18541919#else
    1855 Void TDecTop::xDecodePPS(const std::vector<UChar> *pNaluData)
     1920Void TDecTop::xDecodePPS(const std::vector<UChar> &naluData)
    18561921#endif
    18571922{
     
    18661931  m_cEntropyDecoder.decodePPS( pps );
    18671932#endif
    1868   m_parameterSetManager.storePPS( pps, pNaluData);
    1869 }
    1870 
    1871 Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
    1872 {
    1873   if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    1874   {
    1875 #if SVC_EXTENSION
    1876     if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit
    1877     {
    1878       return;
    1879     }
    1880 #endif
    1881 #if LAYERS_NOT_PRESENT_SEI
    1882     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream  );
    1883 #else
    1884     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
    1885 #endif
    1886   }
    1887   else
    1888   {
    1889 #if LAYERS_NOT_PRESENT_SEI
    1890     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream  );
    1891 #else
    1892     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
    1893 #endif
    1894     SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
    1895     if (activeParamSets.size()>0)
    1896     {
    1897       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
    1898 #if R0247_SEI_ACTIVE
    1899       assert(seiAps->activeSeqParameterSetId.size()>0);
    1900       if( !getLayerDec(0)->m_parameterSetManager.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
    1901       {
    1902         printf ("Warning SPS activation with Active parameter set SEI failed");
    1903       }
    1904       for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++)
    1905       {
    1906         Int layerIdx = seiAps->layerSpsIdx[c];
    1907         if( !getLayerDec(layerIdx)->m_parameterSetManager.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) )
    1908         {
    1909           printf ("Warning SPS activation with Active parameter set SEI failed");
    1910         }
    1911       }
    1912 #else
    1913       assert(seiAps->activeSeqParameterSetId.size()>0);
    1914       if (! m_parameterSetManager.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
    1915       {
    1916         printf ("Warning SPS activation with Active parameter set SEI failed");
    1917       }
    1918 #endif
    1919     }
    1920   }
     1933  m_parameterSetManager.storePPS( pps, naluData);
    19211934}
    19221935
     
    19371950  // Initialize entropy decoder
    19381951  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
    1939   m_cEntropyDecoder.setBitstream      (nalu.m_Bitstream);
     1952  m_cEntropyDecoder.setBitstream      (&(nalu.getBitstream()));
    19401953
    19411954#if SVC_EXTENSION
     
    19521965      assert( nalu.m_nuhLayerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    19531966#endif
    1954       xDecodeVPS(nalu.m_Bitstream->getFifo());
     1967      xDecodeVPS(nalu.getBitstream().getFifo());
    19551968#if RExt__DECODER_DEBUG_BIT_STATISTICS
    1956       TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     1969      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS, nalu.getBitstream().readByteAlignment(), 0);
    19571970#endif
    19581971#if SVC_EXTENSION
     
    19621975
    19631976    case NAL_UNIT_SPS:
    1964       xDecodeSPS(nalu.m_Bitstream->getFifo());
     1977      xDecodeSPS(nalu.getBitstream().getFifo());
    19651978#if RExt__DECODER_DEBUG_BIT_STATISTICS
    1966       TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     1979      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS, nalu.getBitstream().readByteAlignment(), 0);
    19671980#endif
    19681981      return false;
     
    19701983    case NAL_UNIT_PPS:
    19711984#if CGS_3D_ASYMLUT
    1972       xDecodePPS( nalu.m_Bitstream->getFifo(), &m_c3DAsymLUTPPS );
     1985      xDecodePPS( nalu.getBitstream().getFifo(), &m_c3DAsymLUTPPS );
    19731986#else
    1974       xDecodePPS(nalu.m_Bitstream->getFifo());
     1987      xDecodePPS(nalu.getBitstream().getFifo());
    19751988#endif
    19761989#if RExt__DECODER_DEBUG_BIT_STATISTICS
    1977       TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     1990      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS, nalu.getBitstream().readByteAlignment(),0);
    19781991#endif
    19791992      return false;
    19801993
    19811994    case NAL_UNIT_PREFIX_SEI:
     1995      // Buffer up prefix SEI messages until SPS of associated VCL is known.
     1996      m_prefixSEINALUs.push_back(new InputNALUnit(nalu));
     1997      return false;
     1998
    19821999    case NAL_UNIT_SUFFIX_SEI:
    19832000#if SVC_EXTENSION
     
    19872004      }
    19882005#endif
    1989       xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
     2006      if (m_pcPic)
     2007      {
     2008#if SVC_EXTENSION
     2009        m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
     2010#else
     2011        m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
     2012#endif
     2013      }
     2014      else
     2015      {
     2016        printf ("Note: received suffix SEI but no picture currently active.\n");
     2017      }
    19902018      return false;
    19912019
     
    20792107    case NAL_UNIT_RESERVED_VCL30:
    20802108    case NAL_UNIT_RESERVED_VCL31:
     2109      printf ("Note: found reserved VCL NAL unit.\n");
     2110      xParsePrefixSEIsForUnknownVCLNal();
     2111      return false;
    20812112
    20822113    case NAL_UNIT_RESERVED_NVCL41:
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h

    r1295 r1319  
    5656#include "SEIread.h"
    5757
    58 struct InputNALUnit;
     58class InputNALUnit;
    5959
    6060//! \ingroup TLibDecoder
     
    7979  TComSlice*              m_apcSlicePilot;
    8080
    81   SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
     81  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices, excluding prefix SEIs...
    8282
    8383  // functional classes
     
    123123
    124124  Bool                    m_warningMessageSkipPicture;
     125
     126  std::list<InputNALUnit*> m_prefixSEINALUs; /// Buffered up prefix SEI NAL Units.
    125127
    126128#if SVC_EXTENSION
     
    277279  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
    278280#endif
    279   Void      xDecodeVPS(const std::vector<UChar> *pNaluData);
    280   Void      xDecodeSPS(const std::vector<UChar> *pNaluData);
     281  Void      xDecodeVPS(const std::vector<UChar> &naluData);
     282  Void      xDecodeSPS(const std::vector<UChar> &naluData); 
    281283#if CGS_3D_ASYMLUT
    282   Void      xDecodePPS(const std::vector<UChar> *pNaluData, TCom3DAsymLUT *pc3DAsymLUT);
     284  Void      xDecodePPS(const std::vector<UChar> &naluData, TCom3DAsymLUT *pc3DAsymLUT);
    283285#else
    284   Void      xDecodePPS(const std::vector<UChar> *pNaluData);
     286  Void      xDecodePPS(const std::vector<UChar> &naluData);
    285287#endif
    286288  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
    287289  Void      xUpdatePreviousTid0POC( TComSlice *pSlice ) { if ((pSlice->getTLayer()==0) && (pSlice->isReferenceNalu() && (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) { m_prevTid0POC=pSlice->getPOC(); } }
     290  Void      xParsePrefixSEImessages();
     291  Void      xParsePrefixSEIsForUnknownVCLNal();
    288292
    289293
  • branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r1307 r1319  
    7979  case SEI::ACTIVE_PARAMETER_SETS:
    8080    xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei));
    81     break;
    82   case SEI::DECODED_PICTURE_HASH:
    83     xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
    8481    break;
    8582#if SVC_EXTENSION
     
    9794    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps);
    9895    break;
     96#endif
     97  case SEI::DECODED_PICTURE_HASH:
     98    xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
     99    break;
     100#if !SVC_EXTENSION
    99101  case SEI::BUFFERING_PERIOD:
    100102    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps);
     
    398400  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
    399401  {
    400     WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay");
     402    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay_increment");
    401403  }
    402404  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
Note: See TracChangeset for help on using the changeset viewer.