Commit 1b415e40 authored by Karsten Suehring's avatar Karsten Suehring
Browse files

BitstreamExtractor: fix parameter set access after duplicates

- after storing a *PS in the parameter set manager, the object may be deleted
- retrieve a PS back after storing
- add more explicit warnings in comments
parent c0ff13e9
Pipeline #4434 passed with stage
in 13 minutes and 21 seconds
......@@ -195,7 +195,11 @@ uint32_t BitstreamExtractorApp::decode()
VPS* vps = new VPS();
m_hlSynaxReader.setBitstream( &nalu.getBitstream() );
m_hlSynaxReader.parseVPS( vps );
int vpsId = vps->getVPSId();
// note: storeVPS may invalidate the vps pointer!
m_parameterSetManager.storeVPS( vps, nalu.getBitstream().getFifo() );
// get VPS back
vps = m_parameterSetManager.getVPS(vpsId);
xPrintVPSInfo(vps);
#if JVET_P0118_OLS_EXTRACTION
m_vpsId = vps->getVPSId();
......@@ -241,9 +245,13 @@ uint32_t BitstreamExtractorApp::decode()
SPS* sps = new SPS();
m_hlSynaxReader.setBitstream( &nalu.getBitstream() );
m_hlSynaxReader.parseSPS( sps );
int spsId = sps->getSPSId();
// note: storeSPS may invalidate the sps pointer!
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
// *** add modifications here ***
// only write, if not dropped earlier
......@@ -259,7 +267,11 @@ uint32_t BitstreamExtractorApp::decode()
PPS* pps = new PPS();
m_hlSynaxReader.setBitstream( &nalu.getBitstream() );
m_hlSynaxReader.parsePPS( pps );
int ppsId = pps->getPPSId();
// note: storePPS may invalidate the pps pointer!
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());
// example: just write the parsed PPS back to the stream
......
......@@ -222,6 +222,8 @@ public:
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); }
VPS* getVPS( int vpsId ) { return m_vpsMap.getPS( vpsId ); };
......@@ -234,6 +236,7 @@ public:
DPS* getFirstDPS() { return m_dpsMap.getFirstPS(); };
#endif
// 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); };
// get pointer to existing sequence parameter set
SPS* getSPS(int spsId) { return m_spsMap.getPS(spsId); };
......@@ -242,6 +245,7 @@ public:
SPS* getFirstSPS() { return m_spsMap.getFirstPS(); };
// 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); };
// get pointer to existing picture parameter set
PPS* getPPS(int ppsId) { return m_ppsMap.getPS(ppsId); };
......@@ -252,8 +256,11 @@ public:
// activate a PPS and depending on isIRAP parameter also SPS
// returns true, if activation is successful
bool activatePPS(int ppsId, bool isIRAP);
APS** getAPSs() { return &m_apss[0]; }
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); };
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)); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment