📄 extractor.cpp
字号:
if(cPacketDescription.NalUnitType == 1 || cPacketDescription.NalUnitType == 5)
{
cPacketDescription.Level = uiLevel;
cPacketDescription.bDiscardable = bDiscardable_prefix;
}
bDiscardable_prefix = cPacketDescription.bDiscardable;
//prefix unit}}
uiLayer = cPacketDescription.Layer;
uiLevel = cPacketDescription.Level;
uiFGSLayer = cPacketDescription.FGSLayer;
}
bApplyToNext = cPacketDescription.ApplyToNext;
bNewPicture = ( ! cPacketDescription.ParameterSet && ! cPacketDescription.ApplyToNext && !bFirstPacket );
if((cPacketDescription.NalUnitType == 20 || cPacketDescription.NalUnitType == 21 ) && cPacketDescription.Layer == 0 && cPacketDescription.FGSLayer == 0 && getBaseLayerAVCCompatible())
{
bNewPicture = false;
}
//prefix unit{{
if( cPacketDescription.NalUnitType == 14 )
bNewPicture = false;
//prefix unit}}
uiPId = cPacketDescription.uiPId;
//==== update stream description =====
//{{Quality level estimation and modified truncation- JVTO044 and m12007
//France Telecom R&D-(nathalie.cammas@francetelecom.com)
//count number of picture per layer in input stream
if (bNewPicture && uiFGSLayer == 0 && cPacketDescription.NalUnitType != NAL_UNIT_SEI)
{
auiNumImage[uiLayer] ++;
}
if(cPacketDescription.ParameterSet || cPacketDescription.NalUnitType == NAL_UNIT_SEI
|| cPacketDescription.NalUnitType == NAL_UNIT_PREFIX ) //prefix unit
{
//NonRequired JVT-Q066 (06-04-08){{
if(m_pcH264AVCPacketAnalyzer->getNonRequiredSeiFlag() == 1 )
{
uiLayer = uiMaxLayer;
}
//NonRequired JVT-Q066 (06-04-08)}}
uiNumFrame = auiNumImage[uiLayer];
}
else
uiNumFrame = auiNumImage[uiLayer]-1;
if(cPacketDescription.uiNumLevelsQL != 0)
{
//QL SEI packet
bApplyToNext = false;
}
if(m_pcExtractorParameter->getExtractUsingQL() == true)
{
m_bInInputStreamQL = true;
//Saving of Quality Level SEI information
if(cPacketDescription.uiNumLevelsQL != 0)
{
m_bQualityLevelInSEI = true;
m_aaiNumLevels[uiLayer][uiNumFrame] = cPacketDescription.uiNumLevelsQL;
for(UInt ui = 0; ui < (UInt)m_aaiNumLevels[uiLayer][uiNumFrame]; ui++)
{
//m_aaauiBytesForQualityLevel[uiLayer][ui][uiNumFrame] = cPacketDescription.auiDeltaBytesRateOfLevelQL[ui]; //JVT-W137
//m_aaadQualityLevel[uiLayer][ui][uiNumFrame] = cPacketDescription.auiQualityLevelQL[ui];//SEI changes update
m_aaadPriorityLevel[uiLayer][ui][uiNumFrame] = cPacketDescription.auiPriorityLevelPR[ui];//SEI changes update
}
bApplyToNext = false;
}
else
{
if(m_bQualityLevelInSEI == false)
{
//SEI changes update {
if(uiFGSLayer != 0)
//m_aaadQualityLevel[uiLayer][uiFGSLayer][uiNumFrame] = uiPId;
m_aaadPriorityLevel[uiLayer][uiFGSLayer][uiNumFrame] = uiPId;
else
//m_aaadQualityLevel[uiLayer][uiFGSLayer][uiNumFrame] = 63;
m_aaadPriorityLevel[uiLayer][uiFGSLayer][uiNumFrame] = 63;
//SEI changes update }
}
}
}
//}}Quality level estimation and modified truncation- JVTO044 and m12007
//S051{
if(m_bUseSIP)
{
const MyList<ExtractorParameter::Point>& rcExtList = m_pcExtractorParameter->getExtractionList();
ROT( rcExtList.size() != 1 );
MyList<ExtractorParameter::Point>::const_iterator cIter = rcExtList.begin ();
const ExtractorParameter::Point& rcExtPoint = *cIter;
UInt uiExtLayer = MSYS_UINT_MAX;
//----- layer -----
for( UInt i = 0; i < m_cScalableStreamDescription.getNumberOfLayers(); i++ )
{
if( rcExtPoint.uiWidth < m_cScalableStreamDescription.getFrameWidth (i) ||
rcExtPoint.uiHeight < m_cScalableStreamDescription.getFrameHeight(i) )
{
break;
}
uiExtLayer = i;
}
if(!cPacketDescription.bDiscardable||cPacketDescription.Layer>=uiExtLayer)
{
RNOK( m_cScalableStreamDescription.addPacket( uiPacketSize, uiLayer, uiLevel, uiFGSLayer, bNewPicture ) );
RNOK( m_cScalableStreamDescription.addPic( cPacketDescription ) );
}
else
{
RNOK( m_cScalableStreamDescription.addPacketNoUse( uiPacketSize, uiLayer, uiLevel, uiFGSLayer, bNewPicture ) );
RNOK( m_cScalableStreamDescription.addPic( cPacketDescription ) );
}
//DS_FIX_FT_09_2007
UInt eNalUnitType = cPacketDescription.NalUnitType;
if( (!cPacketDescription.bDiscardable || cPacketDescription.Layer == uiExtLayer )&& (eNalUnitType == NAL_UNIT_CODED_SLICE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_IDR ||
eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE ) )
{
if( eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE )
m_cScalableStreamDescription.m_bSubsetSPSRequired[uiLayer][cPacketDescription.SPSid] = true;
else
m_cScalableStreamDescription.m_bSPSRequired[uiLayer][cPacketDescription.SPSid] = true;
m_cScalableStreamDescription.m_bPPSRequired[uiLayer][cPacketDescription.PPSid] = true;
}
//~DS_FIX_FT_09_2007
}
else
{ //DS_FIX_FT_09_2007
//S051}
//JVT-P031
if(!m_bUseSIP || !cPacketDescription.bDiscardable)
{
RNOK( m_cScalableStreamDescription.addPacket( uiPacketSize, uiLayer, uiLevel, uiFGSLayer, bNewPicture ) );
RNOK( m_cScalableStreamDescription.addPic( cPacketDescription ) );
}
//~JVT-P031
//DS_FIX_FT_09_2007
UInt eNalUnitType = cPacketDescription.NalUnitType;
if( eNalUnitType == NAL_UNIT_CODED_SLICE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_IDR ||
eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE )
{
if( eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE )
m_cScalableStreamDescription.m_bSubsetSPSRequired[uiLayer][cPacketDescription.SPSid] = true;
else
m_cScalableStreamDescription.m_bSPSRequired[uiLayer][cPacketDescription.SPSid] = true;
m_cScalableStreamDescription.m_bPPSRequired[uiLayer][cPacketDescription.PPSid] = true;
}
} //~DS_FIX_FT_09_2007
//JVT-P031
//add packet to calculate maxrate (rate before discardable stream
if( !cPacketDescription.bDiscardable)
m_aaadMaxRate[uiLayer][uiNumFrame] += uiPacketSize;
m_aaauiBytesForQualityLevel[uiLayer][uiFGSLayer][uiNumFrame] += uiPacketSize; //JVT-W137
//~JVT-P031
//{{Quality level estimation and modified truncation- JVTO044 and m12007
//France Telecom R&D-(nathalie.cammas@francetelecom.com)
addPacket(uiLayer, uiNumFrame,uiFGSLayer,uiPacketSize);
if(bNewPicture)
setLevel(uiLayer, uiLevel,uiNumFrame);
//}}Quality level estimation and modified truncation- JVTO044 and m12007
if(pcBinData)
{
RNOK( m_pcReadBitstream->releasePacket( pcBinData ) );
pcBinData = NULL;
}
}
RNOK( m_cScalableStreamDescription.analyse() );
m_uiScalableNumLayersMinus1 = pcTmpScalableSei->getNumLayersMinus1();
for( UInt uiScalableLayerId = 0; uiScalableLayerId <= m_uiScalableNumLayersMinus1; uiScalableLayerId++ )
{
UInt uiDependencyId = pcTmpScalableSei->getDependencyId( uiScalableLayerId );
UInt uiQualityLevel = pcTmpScalableSei->getQualityId(uiScalableLayerId);
UInt uiTempLevel = pcTmpScalableSei->getTemporalId(uiScalableLayerId);
m_auiDependencyId[uiScalableLayerId] = uiDependencyId;
m_auiTempLevel [uiScalableLayerId] = uiTempLevel;
m_auiQualityLevel[uiScalableLayerId] = uiQualityLevel;
UInt uiBitrate = pcTmpScalableSei->getAvgBitrateBPS(uiScalableLayerId);
m_auiFrmWidth[uiScalableLayerId] = (pcTmpScalableSei->getFrmWidthInMbsMinus1(uiScalableLayerId)+1) << 4;
m_auiFrmHeight[uiScalableLayerId] = (pcTmpScalableSei->getFrmHeightInMbsMinus1(uiScalableLayerId)+1) << 4;
m_adFramerate[uiScalableLayerId] = (pcTmpScalableSei->getAvgFrmRate(uiScalableLayerId))/256.0;
m_aaauiScalableLayerId[uiDependencyId][uiTempLevel][uiQualityLevel] = uiScalableLayerId;
m_adTotalBitrate[uiScalableLayerId] = (Double) uiBitrate;
if(pcTmpScalableSei->getNumDirectlyDependentLayers(uiScalableLayerId) >= 1)
{
m_auiDirDepLayerDelta[uiScalableLayerId][0] = pcTmpScalableSei->getNumDirectlyDependentLayerIdDeltaMinus1(uiScalableLayerId, 0) + 1; //JVT-S036 lsj
if(pcTmpScalableSei->getNumDirectlyDependentLayers(uiScalableLayerId) == 2)
m_auiDirDepLayerDelta[uiScalableLayerId][1] = pcTmpScalableSei->getNumDirectlyDependentLayerIdDeltaMinus1(uiScalableLayerId, 1) + 1; //JVT-S036 lsj
}
if(!m_adFrameRate[uiTempLevel])
m_adFrameRate[uiTempLevel] = pcTmpScalableSei->getAvgFrmRate(uiScalableLayerId)/256.0;
}
uiMaxLayer = pcTmpScalableSei->getDependencyId( m_uiScalableNumLayersMinus1);
uiMaxTempLevel = pcTmpScalableSei->getTemporalId(m_uiScalableNumLayersMinus1);
//NS leak fix extractor begin
if (pcTmpScalableSei)
{
pcScalableSei = (h264::SEI::ScalableSei*) pcTmpScalableSei;
delete pcScalableSei;
pcTmpScalableSei = NULL;
pcScalableSei = NULL;
}
//NS leak fix extractor end
//calculate dependent relationship among scalable layers with list
for( UInt uiSId = 0; uiSId <= m_uiScalableNumLayersMinus1; uiSId++ )
{
if( m_auiDirDepLayerDelta[uiSId][0] != MSYS_UINT_MAX ) // with dependent layers
{
xMakeDepLayerList( uiSId-m_auiDirDepLayerDelta[uiSId][0], m_acDepLayerList[uiSId] );
}
if( m_auiDirDepLayerDelta[uiSId][1] != MSYS_UINT_MAX )
{
xMakeDepLayerList( uiSId-m_auiDirDepLayerDelta[uiSId][1], m_acDepLayerList[uiSId] );
}
}
//calculate min_bitrate and single_bitrate for each scalable layer (representation)
for( UInt uiDependencyId = 0; uiDependencyId <= uiMaxLayer; uiDependencyId++)
{
for( UInt uiTempLevel = 0; uiTempLevel <= uiMaxTempLevel; uiTempLevel++)
{
for( UInt uiQualityLevel = 0; uiQualityLevel < MAX_QUALITY_LEVELS; uiQualityLevel++)
{
UInt uiScalableLayerIdDes = getScalableLayer( uiDependencyId, uiTempLevel, uiQualityLevel );
if(uiScalableLayerIdDes == MSYS_UINT_MAX) // No such scalable layers
continue;
if(m_auiDirDepLayerDelta[uiScalableLayerIdDes][0] == MSYS_UINT_MAX) // no direct dependent layer
{ //usually base layer: D=0,T=0,Q=0
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] = m_adTotalBitrate[uiScalableLayerIdDes];
}
else//with direct dependent layer
{
UInt uiScalableLayerIdBas = uiScalableLayerIdDes - m_auiDirDepLayerDelta[uiScalableLayerIdDes][0];
UInt uiDepLayer = m_auiDependencyId[uiScalableLayerIdBas];
UInt uiDepTL = m_auiTempLevel[uiScalableLayerIdBas];
if( uiQualityLevel ) //Q!=0
{
ROF(uiScalableLayerIdBas == getScalableLayer( uiDependencyId, uiTempLevel, uiQualityLevel-1 ));
m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] =
m_adTotalBitrate[uiScalableLayerIdDes] - m_adTotalBitrate[uiScalableLayerIdBas];
if( uiTempLevel && m_auiDirDepLayerDelta[uiScalableLayerIdDes][1] != MSYS_UINT_MAX ) // T>0, Q>0
{
//In this case, uiQualityLevel within all TL shall be considered
for( UInt uiTL = 0; uiTL < uiTempLevel; uiTL++ )
{
Double dFactor = m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTL )
/m_cScalableStreamDescription.getFrameRate(uiMaxLayer, uiTL )
*m_cScalableStreamDescription.getFrameRate(uiMaxLayer, uiTempLevel )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel ); //this factor represents the factor of different TL to current TL
m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] -= m_aaadSingleBitrate[uiDependencyId][uiTL][uiQualityLevel] * dFactor;
}
}
}
else if( uiTempLevel ) // T != 0, Q = 0
{
Double dFactor = m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiDepTL )
/m_cScalableStreamDescription.getFrameRate(uiMaxLayer, uiDepTL )
*m_cScalableStreamDescription.getFrameRate(uiMaxLayer, uiTempLevel )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel ); //this factor represents the factor of different TL to current TL
// default value: for D=0, or base layer without current TL exist
m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] = m_adTotalBitrate[uiScalableLayerIdDes]
- m_adTotalBitrate[m_aaauiScalableLayerId[uiDepLayer][uiDepTL][uiQualityLevel]] * dFactor;
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] +
m_aadMinBitrate[uiDepLayer][uiDepTL] * dFactor;
if( uiDependencyId && m_auiDirDepLayerDelta[uiScalableLayerIdDes][1] != MSYS_UINT_MAX ) //D>0, T>0, Q=0
{
//In this case, pictures with TL=uiTempLevel in base layer exists
UInt uiTmpScalableLayerIdBas = uiScalableLayerIdDes - m_auiDirDepLayerDelta[uiScalableLayerIdDes][1];
UInt uiTmpDepLayer = m_auiDependencyId[uiTmpScalableLayerIdBas];
//bitrate calculation
//store tmp value for base layer
m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] =
m_adTotalBitrate[uiScalableLayerIdDes] - m_adTotalBitrate[uiTmpScalableLayerIdBas];
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aadMinBitrate[uiTmpDepLayer][uiTempLevel];
//consider the same layer
for( UInt uiTL = 0; uiTL < uiTempLevel; uiTL++ )
{
dFactor = m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTL )
/m_cScalableStreamDescription.getFrameRate(uiMaxLayer, uiTL )
*m_cScalableStreamDescription.getFrameRate(uiMaxLayer, uiTempLevel )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel );
m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] -= m_aaadSingleBitrate[uiDependencyId][uiTL][uiQualityLevel] * dFactor;
m_aadMinBitrate[uiDependencyId][uiTempLevel] += m_aaadSingleBitrate[uiDependencyId][uiTL][uiQualityLevel] * dFactor;
}
m_aadMinBitrate[uiDependencyId][uiTempLevel] += m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel];
}
}
else //D!=0, T=0, Q=0
{
m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] =
m_adTotalBitrate[uiScalableLayerIdDes] - m_adTotalBitrate[uiScalableLayerIdBas];
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aadMinBitrate[uiDepLayer][uiTempLevel]
+ m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel];
}
}
}
}
}
xOutput( );
//----- reset input file -----
RNOKS( static_cast<ReadBitstreamFile*>(m_pcReadBitstream)->uninit() );
RNOKS( static_cast<ReadBitstreamFile*>(m_pcReadBitstream)->init ( m_pcExtractorParameter->getInFile() ) );
//initialize max rate for each frame
//if dead substream is present for the layer: max rate is equal to max rate before dead substream
//else max rate is equal to the rate of the frame
if(m_bInInputStreamQL)
{
setQualityLevel();
UInt uiLayerDeb = 0;
uiLayerDeb = m_cScalableStreamDescription.getNumberOfLayers()-1;
for(uiLayer = uiLayerDeb; uiLayer < m_cScalableStreamDescription.getNumberOfLayers();uiLayer++)
{
CalculateMaxRate(uiLayer);
}
}
//}}Quality level estimation and modified truncation- JVTO044 and m12007
RNOK( m_pcH264AVCPacketAnalyzer->uninit() );
return Err::m_nOK;
}
UInt Extractor::addPIDToTable(UInt uiPID)
{
//look if uiPID already in table
UInt ui;
for(ui=0;ui<m_uiNbPID;ui++)
{
if(m_auiPID[ui] == uiPID)
return 0;
}
m_auiPID[m_uiNbPID] = uiPID;
m_uiNbPID++;
return 1;
}
ErrVal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -