Skip to content
Snippets Groups Projects
Commit 06a0b41a authored by Frank Bossen's avatar Frank Bossen
Browse files

Merge branch 'paramset_access_fix' into 'master'

BitstreamExtractor: fix parameter set access after duplicates

See merge request !1460
parents 0e895487 1b415e40
No related branches found
No related tags found
1 merge request!1460BitstreamExtractor: fix parameter set access after duplicates
Pipeline #4440 passed
...@@ -195,7 +195,11 @@ uint32_t BitstreamExtractorApp::decode() ...@@ -195,7 +195,11 @@ uint32_t BitstreamExtractorApp::decode()
VPS* vps = new VPS(); VPS* vps = new VPS();
m_hlSynaxReader.setBitstream( &nalu.getBitstream() ); m_hlSynaxReader.setBitstream( &nalu.getBitstream() );
m_hlSynaxReader.parseVPS( vps ); m_hlSynaxReader.parseVPS( vps );
int vpsId = vps->getVPSId();
// note: storeVPS may invalidate the vps pointer!
m_parameterSetManager.storeVPS( vps, nalu.getBitstream().getFifo() ); m_parameterSetManager.storeVPS( vps, nalu.getBitstream().getFifo() );
// get VPS back
vps = m_parameterSetManager.getVPS(vpsId);
xPrintVPSInfo(vps); xPrintVPSInfo(vps);
#if JVET_P0118_OLS_EXTRACTION #if JVET_P0118_OLS_EXTRACTION
m_vpsId = vps->getVPSId(); m_vpsId = vps->getVPSId();
...@@ -241,9 +245,13 @@ uint32_t BitstreamExtractorApp::decode() ...@@ -241,9 +245,13 @@ uint32_t BitstreamExtractorApp::decode()
SPS* sps = new SPS(); SPS* sps = new SPS();
m_hlSynaxReader.setBitstream( &nalu.getBitstream() ); m_hlSynaxReader.setBitstream( &nalu.getBitstream() );
m_hlSynaxReader.parseSPS( sps ); m_hlSynaxReader.parseSPS( sps );
int spsId = sps->getSPSId();
// note: storeSPS may invalidate the sps pointer!
m_parameterSetManager.storeSPS( sps, nalu.getBitstream().getFifo() ); m_parameterSetManager.storeSPS( sps, nalu.getBitstream().getFifo() );
// get SPS back
sps = m_parameterSetManager.getSPS(spsId);
msg (VERBOSE, "SPS Info: SPS ID = %d\n", spsId);
msg (VERBOSE, "SPS Info: SPS ID = %d\n", sps->getSPSId());
// example: just write the parsed SPS back to the stream // example: just write the parsed SPS back to the stream
// *** add modifications here *** // *** add modifications here ***
// only write, if not dropped earlier // only write, if not dropped earlier
...@@ -259,7 +267,11 @@ uint32_t BitstreamExtractorApp::decode() ...@@ -259,7 +267,11 @@ uint32_t BitstreamExtractorApp::decode()
PPS* pps = new PPS(); PPS* pps = new PPS();
m_hlSynaxReader.setBitstream( &nalu.getBitstream() ); m_hlSynaxReader.setBitstream( &nalu.getBitstream() );
m_hlSynaxReader.parsePPS( pps ); m_hlSynaxReader.parsePPS( pps );
int ppsId = pps->getPPSId();
// note: storePPS may invalidate the pps pointer!
m_parameterSetManager.storePPS( pps, nalu.getBitstream().getFifo() ); m_parameterSetManager.storePPS( pps, nalu.getBitstream().getFifo() );
// get PPS back
pps = m_parameterSetManager.getPPS(ppsId);
msg (VERBOSE, "PPS Info: PPS ID = %d\n", pps->getPPSId()); msg (VERBOSE, "PPS Info: PPS ID = %d\n", pps->getPPSId());
// example: just write the parsed PPS back to the stream // example: just write the parsed PPS back to the stream
......
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
protected: protected:
void xPrintVPSInfo (VPS *vps); void xPrintVPSInfo (VPS *vps);
void xWriteVPS(VPS *vps, std::ostream& out, int layerId, int temporalId); void xWriteVPS(VPS *vps, std::ostream& out, int layerId, int temporalId);
void xWriteSPS(SPS *sps, std::ostream& out, int layerId, int temporalId); void xWriteSPS(SPS *sps, std::ostream& out, int layerId, int temporalId);
void xWritePPS(PPS *pps, std::ostream& out, int layerId, int temporalId); void xWritePPS(PPS *pps, std::ostream& out, int layerId, int temporalId);
......
...@@ -222,6 +222,8 @@ public: ...@@ -222,6 +222,8 @@ public:
ParameterSetManager(); ParameterSetManager();
virtual ~ParameterSetManager(); virtual ~ParameterSetManager();
// store video parameter set and take ownership of it
// warning: vps object cannot be used after storing (repeated parameter sets are directly deleted)
void storeVPS(VPS *vps, const std::vector<uint8_t> &naluData) { m_vpsMap.storePS(vps->getVPSId(), vps, &naluData); } void storeVPS(VPS *vps, const std::vector<uint8_t> &naluData) { m_vpsMap.storePS(vps->getVPSId(), vps, &naluData); }
VPS* getVPS( int vpsId ) { return m_vpsMap.getPS( vpsId ); }; VPS* getVPS( int vpsId ) { return m_vpsMap.getPS( vpsId ); };
...@@ -234,6 +236,7 @@ public: ...@@ -234,6 +236,7 @@ public:
DPS* getFirstDPS() { return m_dpsMap.getFirstPS(); }; DPS* getFirstDPS() { return m_dpsMap.getFirstPS(); };
#endif #endif
// store sequence parameter set and take ownership of it // store sequence parameter set and take ownership of it
// warning: sps object cannot be used after storing (repeated parameter sets are directly deleted)
void storeSPS(SPS *sps, const std::vector<uint8_t> &naluData) { m_spsMap.storePS( sps->getSPSId(), sps, &naluData); }; void storeSPS(SPS *sps, const std::vector<uint8_t> &naluData) { m_spsMap.storePS( sps->getSPSId(), sps, &naluData); };
// get pointer to existing sequence parameter set // get pointer to existing sequence parameter set
SPS* getSPS(int spsId) { return m_spsMap.getPS(spsId); }; SPS* getSPS(int spsId) { return m_spsMap.getPS(spsId); };
...@@ -242,6 +245,7 @@ public: ...@@ -242,6 +245,7 @@ public:
SPS* getFirstSPS() { return m_spsMap.getFirstPS(); }; SPS* getFirstSPS() { return m_spsMap.getFirstPS(); };
// store picture parameter set and take ownership of it // store picture parameter set and take ownership of it
// warning: pps object cannot be used after storing (repeated parameter sets are directly deleted)
void storePPS(PPS *pps, const std::vector<uint8_t> &naluData) { m_ppsMap.storePS( pps->getPPSId(), pps, &naluData); }; void storePPS(PPS *pps, const std::vector<uint8_t> &naluData) { m_ppsMap.storePS( pps->getPPSId(), pps, &naluData); };
// get pointer to existing picture parameter set // get pointer to existing picture parameter set
PPS* getPPS(int ppsId) { return m_ppsMap.getPS(ppsId); }; PPS* getPPS(int ppsId) { return m_ppsMap.getPS(ppsId); };
...@@ -252,8 +256,11 @@ public: ...@@ -252,8 +256,11 @@ public:
// activate a PPS and depending on isIRAP parameter also SPS // activate a PPS and depending on isIRAP parameter also SPS
// returns true, if activation is successful // returns true, if activation is successful
bool activatePPS(int ppsId, bool isIRAP); bool activatePPS(int ppsId, bool isIRAP);
APS** getAPSs() { return &m_apss[0]; } APS** getAPSs() { return &m_apss[0]; }
ParameterSetMap<APS>* getApsMap() { return &m_apsMap; } ParameterSetMap<APS>* getApsMap() { return &m_apsMap; }
// store adaptation parameter set and take ownership of it
// warning: aps object cannot be used after storing (repeated parameter sets are directly deleted)
void storeAPS(APS *aps, const std::vector<uint8_t> &naluData) { m_apsMap.storePS(aps->getAPSId() + (MAX_NUM_APS * aps->getAPSType()), aps, &naluData); }; void storeAPS(APS *aps, const std::vector<uint8_t> &naluData) { m_apsMap.storePS(aps->getAPSId() + (MAX_NUM_APS * aps->getAPSType()), aps, &naluData); };
APS* getAPS(int apsId, int apsType) { return m_apsMap.getPS(apsId + (MAX_NUM_APS * apsType)); }; APS* getAPS(int apsId, int apsType) { return m_apsMap.getPS(apsId + (MAX_NUM_APS * apsType)); };
bool getAPSChangedFlag(int apsId, int apsType) const { return m_apsMap.getChangedFlag(apsId + (MAX_NUM_APS * apsType)); } bool getAPSChangedFlag(int apsId, int apsType) const { return m_apsMap.getChangedFlag(apsId + (MAX_NUM_APS * apsType)); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment