Newer
Older

Karsten Suehring
committed
m_paramsetMap[psId].pNaluData=0;
m_paramsetMap[psId].parameterSet = new T;
setID(m_paramsetMap[psId].parameterSet, psId);
}
return m_paramsetMap[psId].parameterSet;
}
void clearMap()
{
m_paramsetMap.clear();
}

Karsten Suehring
committed
void storePS(int psId, T *ps, const std::vector<uint8_t> *pNaluData)
{
CHECK( psId >= m_maxId, "Invalid PS id" );
if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
{
MapData<T> &mapData=m_paramsetMap[psId];
// work out changed flag
calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, pNaluData);
if( ! mapData.bChanged )
{
// just keep the old one
delete ps;
return;
}
if (find(m_activePsId.begin(), m_activePsId.end(), psId) != m_activePsId.end())

Karsten Suehring
committed
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
{
std::swap( m_paramsetMap[psId].parameterSet, m_lastActiveParameterSet );
}
delete m_paramsetMap[psId].pNaluData;
delete m_paramsetMap[psId].parameterSet;
m_paramsetMap[psId].parameterSet = ps;
}
else
{
m_paramsetMap[psId].parameterSet = ps;
m_paramsetMap[psId].bChanged = false;
}
if (pNaluData != 0)
{
m_paramsetMap[psId].pNaluData=new std::vector<uint8_t>;
*(m_paramsetMap[psId].pNaluData) = *pNaluData;
}
else
{
m_paramsetMap[psId].pNaluData=0;
}
}
void setChangedFlag(int psId, bool bChanged=true)
{
if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
{
m_paramsetMap[psId].bChanged=bChanged;
}
}
void clearChangedFlag(int psId)
{
if ( m_paramsetMap.find(psId) != m_paramsetMap.end() )
{
m_paramsetMap[psId].bChanged=false;
}
}
bool getChangedFlag(int psId) const
{
const typename std::map<int,MapData<T> >::const_iterator constit=m_paramsetMap.find(psId);
if ( constit != m_paramsetMap.end() )
{
return constit->second.bChanged;
}
return false;
}
T* getPS(int psId)
{
typename std::map<int,MapData<T> >::iterator it=m_paramsetMap.find(psId);
return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
}
const T* getPS(int psId) const
{
typename std::map<int,MapData<T> >::const_iterator it=m_paramsetMap.find(psId);
return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet;
}
T* getFirstPS()
{
return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second.parameterSet;
}
void setActive(int psId) { m_activePsId.push_back(psId); }
void clear() { m_activePsId.clear(); }

Karsten Suehring
committed
private:
std::map<int,MapData<T> > m_paramsetMap;
int m_maxId;
std::vector<int> m_activePsId;

Karsten Suehring
committed
T* m_lastActiveParameterSet;
static void setID(T* parameterSet, const int psId);
};
class ParameterSetManager
{
public:
ParameterSetManager();
virtual ~ParameterSetManager();
void storeDPS(DPS *dps, const std::vector<uint8_t> &naluData) { m_dpsMap.storePS( dps->getDecodingParameterSetId(), dps, &naluData); };
//! get pointer to existing video parameter set
DPS* getDPS(int dpsId) { return m_dpsMap.getPS(dpsId); };
bool getDPSChangedFlag(int dpsId) const { return m_dpsMap.getChangedFlag(dpsId); }
void clearDPSChangedFlag(int dpsId) { m_dpsMap.clearChangedFlag(dpsId); }
DPS* getFirstDPS() { return m_dpsMap.getFirstPS(); };

Karsten Suehring
committed
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
//! store sequence parameter set and take ownership of it
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); };
bool getSPSChangedFlag(int spsId) const { return m_spsMap.getChangedFlag(spsId); }
void clearSPSChangedFlag(int spsId) { m_spsMap.clearChangedFlag(spsId); }
SPS* getFirstSPS() { return m_spsMap.getFirstPS(); };
//! store picture parameter set and take ownership of it
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); };
bool getPPSChangedFlag(int ppsId) const { return m_ppsMap.getChangedFlag(ppsId); }
void clearPPSChangedFlag(int ppsId) { m_ppsMap.clearChangedFlag(ppsId); }
PPS* getFirstPPS() { return m_ppsMap.getFirstPS(); };
//! activate a SPS from a active parameter sets SEI message
//! \returns true, if activation is successful
// bool activateSPSWithSEI(int SPSId);
//! activate a PPS and depending on isIDR 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; }
void storeAPS(APS *aps, const std::vector<uint8_t> &naluData) { m_apsMap.storePS((aps->getAPSId() << NUM_APS_TYPE_LEN) + aps->getAPSType(), aps, &naluData); };
APS* getAPS(int apsId, int apsType) { return m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType); };
bool getAPSChangedFlag(int apsId, int apsType) const { return m_apsMap.getChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
void clearAPSChangedFlag(int apsId, int apsType) { m_apsMap.clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
APS* getFirstAPS() { return m_apsMap.getFirstPS(); };
bool activateAPS(int apsId, int apsType);

Karsten Suehring
committed
const SPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); };
const DPS* getActiveDPS()const { return m_dpsMap.getPS(m_activeDPSId); };

Karsten Suehring
committed
protected:
ParameterSetMap<SPS> m_spsMap;
ParameterSetMap<PPS> m_ppsMap;
ParameterSetMap<DPS> m_dpsMap;

Karsten Suehring
committed
#if JVET_O_MAX_NUM_ALF_APS_8
APS* m_apss[ALF_CTB_MAX_NUM_APS];
#else
APS* m_apss[MAX_NUM_APS];
int m_activeDPSId; // -1 for nothing active

Karsten Suehring
committed
int m_activeSPSId; // -1 for nothing active
};
class PreCalcValues
{
public:
PreCalcValues( const SPS& sps, const PPS& pps, bool _isEncoder )
: chrFormat ( sps.getChromaFormatIdc() )

Karsten Suehring
committed
, maxCUWidth ( sps.getMaxCUWidth() )
, maxCUHeight ( sps.getMaxCUHeight() )
, maxCUWidthMask ( maxCUWidth - 1 )
, maxCUHeightMask ( maxCUHeight - 1 )
, maxCUWidthLog2 ( g_aucLog2[ maxCUWidth ] )
, maxCUHeightLog2 ( g_aucLog2[ maxCUHeight ] )
, minCUWidth ( sps.getMaxCUWidth() >> sps.getMaxCodingDepth() )
, minCUHeight ( sps.getMaxCUHeight() >> sps.getMaxCodingDepth() )
, minCUWidthLog2 ( g_aucLog2[ minCUWidth ] )
, minCUHeightLog2 ( g_aucLog2[ minCUHeight ] )
, partsInCtuWidth ( 1 << sps.getMaxCodingDepth() )
, partsInCtuHeight ( 1 << sps.getMaxCodingDepth() )
, partsInCtu ( 1 << (sps.getMaxCodingDepth() << 1) )
, widthInCtus ( (sps.getPicWidthInLumaSamples () + sps.getMaxCUWidth () - 1) / sps.getMaxCUWidth () )
, heightInCtus ( (sps.getPicHeightInLumaSamples() + sps.getMaxCUHeight() - 1) / sps.getMaxCUHeight() )
, sizeInCtus ( widthInCtus * heightInCtus )
, lumaWidth ( sps.getPicWidthInLumaSamples() )
, lumaHeight ( sps.getPicHeightInLumaSamples() )
, fastDeltaQPCuMaxSize( Clip3(sps.getMaxCUHeight() >> (sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u) )

Karsten Suehring
committed
, isEncoder ( _isEncoder )
, ISingleTree ( !sps.getUseDualITree() )
, maxBtDepth { sps.getMaxBTDepthI(), sps.getMaxBTDepth(), sps.getMaxBTDepthIChroma() }
, minBtSize { 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize() }
, maxBtSize { sps.getMaxBTSizeI(), sps.getMaxBTSize(), sps.getMaxBTSizeIChroma() }
, minTtSize { 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize() }
, maxTtSize { sps.getMaxTTSizeI(), sps.getMaxTTSize(), sps.getMaxTTSizeIChroma() }
, minQtSize { sps.getMinQTSize(I_SLICE, CHANNEL_TYPE_LUMA), sps.getMinQTSize(B_SLICE, CHANNEL_TYPE_LUMA), sps.getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA) }

Karsten Suehring
committed
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
{}
const ChromaFormat chrFormat;
const bool multiBlock422;
const unsigned maxCUWidth;
const unsigned maxCUHeight;
// to get CTU position, use (x & maxCUWidthMask) rather than (x % maxCUWidth)
const unsigned maxCUWidthMask;
const unsigned maxCUHeightMask;
const unsigned maxCUWidthLog2;
const unsigned maxCUHeightLog2;
const unsigned minCUWidth;
const unsigned minCUHeight;
const unsigned minCUWidthLog2;
const unsigned minCUHeightLog2;
const unsigned partsInCtuWidth;
const unsigned partsInCtuHeight;
const unsigned partsInCtu;
const unsigned widthInCtus;
const unsigned heightInCtus;
const unsigned sizeInCtus;
const unsigned lumaWidth;
const unsigned lumaHeight;
const unsigned fastDeltaQPCuMaxSize;
const bool noChroma2x2;
const bool isEncoder;
const bool ISingleTree;
private:
const unsigned maxBtDepth[3];
const unsigned minBtSize [3];
const unsigned maxBtSize [3];
const unsigned minTtSize [3];
const unsigned maxTtSize [3];
const unsigned minQtSize [3];
unsigned getValIdx ( const Slice &slice, const ChannelType chType ) const;
public:
unsigned getMaxBtDepth( const Slice &slice, const ChannelType chType ) const;
unsigned getMinBtSize ( const Slice &slice, const ChannelType chType ) const;
unsigned getMaxBtSize ( const Slice &slice, const ChannelType chType ) const;
unsigned getMinTtSize ( const Slice &slice, const ChannelType chType ) const;
unsigned getMaxTtSize ( const Slice &slice, const ChannelType chType ) const;
unsigned getMinQtSize ( const Slice &slice, const ChannelType chType ) const;
};
#if ENABLE_TRACING
void xTraceVPSHeader();

Karsten Suehring
committed
void xTraceSPSHeader();
void xTracePPSHeader();

Karsten Suehring
committed
void xTraceSliceHeader();
void xTraceAccessUnitDelimiter();
#endif
#endif // __SLICE__