Changeset 1319 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibCommon
- Timestamp:
- 21 Jul 2015, 23:31:40 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibCommon
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibCommon/NAL.h
r1262 r1319 51 51 UInt m_nuhLayerId; ///< nuh_layer_id 52 52 53 NALUnit(const NALUnit &src) 54 :m_nalUnitType (src.m_nalUnitType) 55 ,m_temporalId (src.m_temporalId) 56 ,m_nuhLayerId (src.m_nuhLayerId) 57 { } 53 58 /** construct an NALunit structure with given header values. */ 54 59 NALUnit( … … 61 66 {} 62 67 63 /** default constructor - no initialization; must be perfo med by user */68 /** default constructor - no initialization; must be performed by user */ 64 69 NALUnit() {} 70 71 virtual ~NALUnit() { } 65 72 66 73 /** returns true if the NALunit is a slice NALunit */ -
branches/SHM-dev/source/Lib/TLibCommon/TComBitStream.cpp
r1260 r1319 60 60 } 61 61 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 63 TComInputBitstream::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 72 TComInputBitstream::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 { } 74 80 75 81 // ==================================================================================================================== 76 82 // Public member functions 77 83 // ==================================================================================================================== 84 85 Void TComInputBitstream::resetToStart() 86 { 87 m_fifo_idx=0; 88 m_num_held_bits=0; 89 m_held_bits=0; 90 m_numBitsRead=0; 91 } 78 92 79 93 Char* TComOutputBitstream::getByteStream() const … … 283 297 UInt aligned_word = 0; 284 298 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()); 286 300 287 301 switch (num_bytes_to_load) 288 302 { 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++]; 293 307 } 294 308 … … 351 365 { 352 366 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 } 359 391 } 360 392 if (uiNumBits&0x7) 361 393 { 362 uiByte = 0;394 UInt uiByte = 0; 363 395 read(uiNumBits&0x7, uiByte); 364 396 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; 377 400 } 378 401 -
branches/SHM-dev/source/Lib/TLibCommon/TComBitStream.h
r1262 r1319 163 163 class TComInputBitstream 164 164 { 165 std::vector<uint8_t> *m_fifo; /// FIFO for storage of complete bytes166 std::vector<UInt> m_emulationPreventionByteLocation;167 168 165 protected: 166 std::vector<uint8_t> m_fifo; /// FIFO for storage of complete bytes 167 std::vector<UInt> m_emulationPreventionByteLocation; 168 169 169 UInt m_fifo_idx; /// Read index into m_fifo 170 170 … … 175 175 public: 176 176 /** 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(); 183 184 184 185 // interface for decoding … … 187 188 Void readByte ( UInt &ruiBits ) 188 189 { 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++]; 191 192 } 192 193 … … 194 195 { 195 196 assert(m_fifo_idx > 0); 196 byte = (*m_fifo)[m_fifo_idx - 1];197 byte = m_fifo[m_fifo_idx - 1]; 197 198 } 198 199 … … 209 210 UInt readByte() { UInt tmp; readByte( tmp ); return tmp; } 210 211 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; } 212 213 TComInputBitstream *extractSubstream( UInt uiNumBits ); // Read the nominated number of bits, and return as a bitstream. 213 Void deleteFifo(); // Delete internal fifo of bitstream.214 214 UInt getNumBitsRead() { return m_numBitsRead; } 215 215 UInt readByteAlignment(); 216 216 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; } 225 226 }; 226 227 -
branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
r1316 r1319 51 51 ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS); 52 52 ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS); 53 TComVPS ParameterSetManager::m_activeVPS;53 Int ParameterSetManager::m_activeVPSId = -1; 54 54 #endif 55 55 … … 2790 2790 ParameterSetManager::ParameterSetManager() 2791 2791 #if SVC_EXTENSION 2792 : m_active SPS()2792 : m_activePPSId(-1) 2793 2793 #else 2794 2794 : m_vpsMap(MAX_NUM_VPS) 2795 2795 , m_spsMap(MAX_NUM_SPS) 2796 2796 , 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 { 2805 2801 } 2806 2802 … … 2812 2808 //! activate a SPS from a active parameter sets SEI message 2813 2809 //! \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 else2828 {2829 printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist.");2830 }2831 }2832 else2833 {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 //} 2838 2834 2839 2835 //! activate a PPS and depending on isIDR parameter also SPS and VPS … … 2844 2840 if (pps) 2845 2841 { 2842 #if SVC_EXTENSION 2843 m_activePPSId = ppsId; 2844 #endif 2846 2845 Int spsId = pps->getSPSId(); 2847 if (!isIRAP && (spsId != m_activeSPS .getSPSId()))2846 if (!isIRAP && (spsId != m_activeSPSId )) 2848 2847 { 2849 2848 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 } 2870 2874 } 2871 2875 else 2872 2876 { 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 } 2879 2879 } 2880 2880 } … … 2883 2883 printf("Warning: tried to activate non-existing PPS."); 2884 2884 } 2885 2886 // Failed to activate if reach here. 2887 m_activeSPSId=-1; 2888 m_activeVPSId=-1; 2885 2889 return false; 2886 2890 } … … 2905 2909 } 2906 2910 2907 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData)2911 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData) 2908 2912 { 2909 2913 if (!bChanged) … … 2922 2926 else 2923 2927 { 2924 const UChar *pNewDataArray=&( *pNewData)[0];2928 const UChar *pNewDataArray=&(newData)[0]; 2925 2929 const UChar *pOldDataArray=&(*pOldData)[0]; 2926 2930 if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) -
branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
r1316 r1319 2502 2502 2503 2503 2504 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData);2504 Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData); 2505 2505 2506 2506 template <class T> class ParameterSetMap … … 2528 2528 } 2529 2529 2530 Void storePS(Int psId, T *ps, const std::vector<UChar> *pNaluData)2530 Void storePS(Int psId, T *ps, const std::vector<UChar> &naluData) 2531 2531 { 2532 2532 assert ( psId < m_maxId ); … … 2536 2536 2537 2537 // work out changed flag 2538 calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, pNaluData);2538 calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, naluData); 2539 2539 delete m_paramsetMap[psId].pNaluData; 2540 2540 delete m_paramsetMap[psId].parameterSet; … … 2547 2547 m_paramsetMap[psId].bChanged = false; 2548 2548 } 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; 2558 2551 } 2559 2552 … … 2578 2571 T* getPS(Int psId) 2579 2572 { 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; 2581 2581 } 2582 2582 … … 2598 2598 2599 2599 //! 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); }; 2601 2601 //! get pointer to existing video parameter set 2602 2602 TComVPS* getVPS(Int vpsId) { return m_vpsMap.getPS(vpsId); }; … … 2606 2606 2607 2607 //! 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); }; 2609 2609 //! get pointer to existing sequence parameter set 2610 2610 TComSPS* getSPS(Int spsId) { return m_spsMap.getPS(spsId); }; … … 2614 2614 2615 2615 //! 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); }; 2617 2617 //! get pointer to existing picture parameter set 2618 2618 TComPPS* getPPS(Int ppsId) { return m_ppsMap.getPS(ppsId); }; … … 2623 2623 //! activate a SPS from a active parameter sets SEI message 2624 2624 //! \returns true, if activation is successful 2625 Bool activateSPSWithSEI(Int SPSId);2625 // Bool activateSPSWithSEI(Int SPSId); 2626 2626 2627 2627 //! activate a PPS and depending on isIDR parameter also SPS and VPS … … 2629 2629 Bool activatePPS(Int ppsId, Bool isIRAP); 2630 2630 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); }; 2633 2633 2634 2634 #if SVC_EXTENSION 2635 const TComPPS* getActivePPS()const { return &m_activePPS; };2635 const TComPPS* getActivePPS()const { return m_ppsMap.getPS(m_activePPSId); }; 2636 2636 #endif 2637 2637 … … 2643 2643 static ParameterSetMap<TComPPS> m_ppsMap; 2644 2644 2645 TComPPS m_activePPS;2646 static TComVPS m_activeVPS;2645 Int m_activePPSId; 2646 static Int m_activeVPSId; // -1 for nothing active; 2647 2647 #else 2648 2648 ParameterSetMap<TComVPS> m_vpsMap; … … 2650 2650 ParameterSetMap<TComPPS> m_ppsMap; 2651 2651 2652 TComVPS m_activeVPS; // used for SEI message2653 #endif 2654 2655 TComSPS m_activeSPS; // used for SEI message2652 Int m_activeVPSId; // -1 for nothing active 2653 #endif 2654 2655 Int m_activeSPSId; // -1 for nothing active 2656 2656 }; 2657 2657
Note: See TracChangeset for help on using the changeset viewer.