📄 extractor.cpp
字号:
}
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];
m_aaadQualityLevel[uiLayer][ui][uiNumFrame] = cPacketDescription.auiQualityLevelQL[ui];
}
bApplyToNext = false;
}
else
{
if(m_bQualityLevelInSEI == false)
{
if(uiFGSLayer != 0)
m_aaadQualityLevel[uiLayer][uiFGSLayer][uiNumFrame] = uiPId;
else
m_aaadQualityLevel[uiLayer][uiFGSLayer][uiNumFrame] = 63;
}
}
}
//}}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 ) );
}
else
{
RNOK( m_cScalableStreamDescription.addPacketNoUse( uiPacketSize, uiLayer, uiLevel, uiFGSLayer, bNewPicture ) );
}
}
else
//S051}
//JVT-P031
if(!m_bExtractDeadSubstream[uiLayer]|| !cPacketDescription.bDiscardable)
RNOK( m_cScalableStreamDescription.addPacket( uiPacketSize, uiLayer, uiLevel, uiFGSLayer, bNewPicture ) );
//~JVT-P031
UInt eNalUnitType = cPacketDescription.NalUnitType;
if( !cPacketDescription.bDiscardable && (eNalUnitType == NAL_UNIT_CODED_SLICE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_IDR ||
eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_SCALABLE) )
{
m_cScalableStreamDescription.m_bSPSRequired[uiLayer][cPacketDescription.SPSid] = true;
m_cScalableStreamDescription.m_bPPSRequired[uiLayer][cPacketDescription.PPSid] = true;
}
// BUG_FIX liuhui{ //delete
// BUG_FIX liuhui}
//JVT-P031
//add packet to calculate maxrate (rate before discardable stream
if(!m_bExtractDeadSubstream[uiLayer] || !cPacketDescription.bDiscardable)
m_aaadMaxRate[uiLayer][uiNumFrame] += uiPacketSize;
//~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() );
// BUG_FIX liuhui{
m_uiScalableNumLayersMinus1 = pcTmpScalableSei->getNumLayersMinus1();
for( UInt uiScalableLayerId = 0; uiScalableLayerId <= m_uiScalableNumLayersMinus1; uiScalableLayerId++ )
{
UInt uiDependencyId = pcTmpScalableSei->getDependencyId( uiScalableLayerId );
UInt uiQualityLevel = pcTmpScalableSei->getQualityLevel(uiScalableLayerId);
UInt uiTempLevel = pcTmpScalableSei->getTemporalLevel(uiScalableLayerId);
//if( getBaseLayerAVCCompatible() &&
// ( uiDependencyId == 0 && uiTempLevel == pcTmpScalableSei->getStdAVCOffset() ) )
// uiTempLevel = 0;
m_auiDependencyId[uiScalableLayerId] = uiDependencyId;
m_auiTempLevel [uiScalableLayerId] = uiTempLevel;
m_auiQualityLevel[uiScalableLayerId] = uiQualityLevel;
UInt uiBitrate = pcTmpScalableSei->getAvgBitrate(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_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiQualityLevel] = (Double) uiBitrate;
m_adTotalBitrate[uiScalableLayerId] = 0; //initial value
if(pcTmpScalableSei->getNumDirectlyDependentLayers(uiScalableLayerId))
m_auiDirDepLayer[uiScalableLayerId] = pcTmpScalableSei->getNumDirectlyDependentLayerIdDeltaMinus1(uiScalableLayerId, 0); //JVT-S036 lsj
else
m_auiDirDepLayer[uiScalableLayerId] = MSYS_UINT_MAX;
if(!m_adFrameRate[uiTempLevel])
m_adFrameRate[uiTempLevel] = pcTmpScalableSei->getAvgFrmRate(uiScalableLayerId)/256.0;
}
uiMaxLayer = pcTmpScalableSei->getDependencyId( m_uiScalableNumLayersMinus1);
uiMaxTempLevel = pcTmpScalableSei->getTemporalLevel(m_uiScalableNumLayersMinus1);
//calculate detail bitrate info, according to variables
//m_adFrameRate[TL],m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel )
//m_aaadSingleBitrate[][][],
//to get :m_aaauiSingleBits[][][] & m_adTotalBitrate[SL]
for( UInt uiDependencyId = 0; uiDependencyId <= uiMaxLayer; uiDependencyId++)
{
UInt uiMinTL = 0;
if( uiDependencyId == 0 && getBaseLayerAVCCompatible() )
uiMinTL = pcTmpScalableSei->getStdAVCOffset();
if( uiMinTL > uiMaxTempLevel )// only when base layer mode AVC: uiMinTL>0
{
m_aadMinBitrate[uiDependencyId][uiMinTL] = m_aaadSingleBitrate[uiDependencyId][uiMinTL][0];
UInt uiScalableLayerIdDes = getScalableLayer( uiDependencyId, uiMinTL, 0 );
m_adTotalBitrate[uiScalableLayerIdDes] = m_aaadSingleBitrate[uiDependencyId][uiMinTL][0];
//do when only uiMinTL exists
for( UInt uiFGS = 1; uiFGS < MAX_QUALITY_LEVELS; uiFGS++ ) // <0TQ>
{
uiScalableLayerIdDes = getScalableLayer( uiDependencyId, uiMinTL, uiFGS );
UInt uiDependentLayer = getScalableLayer( uiDependencyId, uiMinTL, uiFGS-1 );
if(uiScalableLayerIdDes == MSYS_UINT_MAX )
continue;
m_adTotalBitrate[uiScalableLayerIdDes] = m_adTotalBitrate[uiDependentLayer]
+m_aaadSingleBitrate[uiDependencyId][uiMinTL][uiFGS];
}
}
for( UInt uiTempLevel = uiMinTL; uiTempLevel <= uiMaxTempLevel; uiTempLevel++)
{
for( UInt uiFGS = 0; uiFGS < MAX_QUALITY_LEVELS; uiFGS++)
{
UInt uiScalableLayerIdDes = getScalableLayer( uiDependencyId, uiTempLevel, uiFGS );
if(uiScalableLayerIdDes == MSYS_UINT_MAX) // No such scalable layers
continue;
if(m_auiDirDepLayer[uiScalableLayerIdDes] == MSYS_UINT_MAX) // no direct dependent layer
{ //usually base layer: D=0,T=0,Q=0
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
m_adTotalBitrate[uiScalableLayerIdDes] = m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
}
else//with direct dependent layer
{
UInt uiScalableLayerIdBas = uiScalableLayerIdDes - m_auiDirDepLayer[uiScalableLayerIdDes];
UInt uiDepLayer = m_auiDependencyId[uiScalableLayerIdBas];
UInt uiDepTL = m_auiTempLevel[uiScalableLayerIdBas];
UInt uiDepQuality = m_auiQualityLevel[uiScalableLayerIdBas];
if( uiFGS ) //Q!=0
{
assert(uiScalableLayerIdBas == getScalableLayer( uiDependencyId, uiTempLevel, uiFGS-1 ));
m_adTotalBitrate[uiScalableLayerIdDes] = m_adTotalBitrate[uiScalableLayerIdBas];
for( UInt uiTIndex = 0; uiTIndex <= uiTempLevel; uiTIndex++)
m_adTotalBitrate[uiScalableLayerIdDes] += m_aaadSingleBitrate[uiDependencyId][uiTIndex][uiFGS]
*m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTIndex )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel )
*(1 << (uiTempLevel-uiTIndex));
}
else if( uiTempLevel ) // T != 0, Q = 0
{
//assert(uiScalableLayerIdBas == getScalableLayer( uiLayer, uiTempLevel-1, uiFGS));
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aadMinBitrate[uiDependencyId][uiTempLevel-1]
*m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel-1 )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel )*2 ;
m_aadMinBitrate[uiDependencyId][uiTempLevel] += m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
m_adTotalBitrate[uiScalableLayerIdDes] = m_adTotalBitrate[uiScalableLayerIdBas]
*m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiDepTL )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel )
*(1 << (uiTempLevel-uiDepTL));
m_adTotalBitrate[uiScalableLayerIdDes] += m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
if( uiDependencyId ) //D>0, T>0, Q=0
{
UInt uiTmpScalableLayer = getScalableLayer(uiDependencyId, 0, 0);
UInt uiTmpScalableLayerIdBas = uiTmpScalableLayer - m_auiDirDepLayer[uiTmpScalableLayer];
UInt uiTmpDepLayer = m_auiDependencyId[uiTmpScalableLayerIdBas];
UInt uiTmpDepQuality = m_auiQualityLevel[uiTmpScalableLayerIdBas];
//bitrate calculation
if( uiTmpDepLayer==0 && getBaseLayerAVCCompatible() )
{
UInt uiBaseTL = pcTmpScalableSei->getStdAVCOffset();
if( uiTempLevel <= uiBaseTL )
{
for( UInt uiQIndex = 0; uiQIndex <= uiTmpDepQuality; uiQIndex++ )
m_adTotalBitrate[uiScalableLayerIdDes] += (signed)m_cScalableStreamDescription.getNALUBytes( uiTmpDepLayer, uiTempLevel, uiQIndex )
*8.0/1000*m_cScalableStreamDescription.getFrameRate( uiDependencyId, uiTempLevel )
/m_cScalableStreamDescription.getNumPictures( uiMaxLayer, uiTempLevel );
}
if( uiTempLevel > uiBaseTL )
{
m_aadMinBitrate[uiDependencyId][uiTempLevel] += m_aaadSingleBitrate[uiTmpDepLayer][uiTempLevel][uiFGS];
for( UInt uiQualityLevel = 0; uiQualityLevel <= uiTmpDepQuality; uiQualityLevel++ )
m_adTotalBitrate[uiScalableLayerIdDes] += m_aaadSingleBitrate[uiTmpDepLayer][uiTempLevel][uiQualityLevel];
}
}
else if ( !getBaseLayerAVCCompatible() ) //SCALABLE mode
{
m_aadMinBitrate[uiDependencyId][uiTempLevel] += m_aaadSingleBitrate[uiTmpDepLayer][uiTempLevel][uiFGS];
for( UInt uiQualityLevel = 0; uiQualityLevel <= uiTmpDepQuality; uiQualityLevel++ )
m_adTotalBitrate[uiScalableLayerIdDes] += m_aaadSingleBitrate[uiTmpDepLayer][uiTempLevel][uiQualityLevel];
}
}
}
else //D!=0, T=0, Q=0
{
if( uiDepLayer==0 && getBaseLayerAVCCompatible() )
{
UInt uiBaseTL = pcTmpScalableSei->getStdAVCOffset();
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aadMinBitrate[uiDepLayer][uiBaseTL]*m_cScalableStreamDescription.getNumPictures( uiDepLayer, uiBaseTL )
/m_cScalableStreamDescription.getNumPictures( uiDependencyId, uiTempLevel )/(1 << (uiBaseTL-uiTempLevel) )
+ m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
m_adTotalBitrate[uiScalableLayerIdDes] = m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
for( UInt uiTmpQL = 0; uiTmpQL <= uiDepQuality; uiTmpQL++ )
m_adTotalBitrate[uiScalableLayerIdDes] += (signed)m_cScalableStreamDescription.getNALUBytes(uiDepLayer, uiTempLevel, uiTmpQL )
*8.0/1000*m_cScalableStreamDescription.getFrameRate( uiDependencyId, uiTempLevel )
/m_cScalableStreamDescription.getNumPictures( uiDependencyId, uiTempLevel );
}
else
{
//assert(uiScalableLayerIdBas == getScalableLayer( uiDepLayer, uiTempLevel, uiDepQuality ));
m_aadMinBitrate[uiDependencyId][uiTempLevel] = m_aadMinBitrate[uiDepLayer][uiTempLevel]
+ m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
m_adTotalBitrate[uiScalableLayerIdDes] = m_aaadSingleBitrate[uiDependencyId][uiTempLevel][uiFGS];
for(UInt uiQualityLevel = 0; uiQualityLevel <= uiDepQuality; uiQualityLevel++)
m_adTotalBitrate[uiScalableLayerIdDes] += m_aaadSingleBitrate[uiDepLayer][uiTempLevel][uiQualityLevel];
}
}
}
}
}
}
xOutput( );
// BUG_FIX liuhui}
//----- 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;
if(m_bInInputStreamDS == false)
{
uiLayerDeb = 0;
}
else
{
uiLayerDeb = m_cScalableStreamDescription.getNumberOfLayers()-1;
}
for(uiLayer = uiLayerDeb; uiLayer < m_cScalableStreamDescription.getNumberOfLayers();uiLayer++)
{
CalculateMaxRate(uiLayer);
}
}
//}}Quality level estimation and modified truncation- JVTO044 and m12007
if( m_cScalableStreamDescription.getBaseLayerModeAVC() )
{
printf("Base-layer mode: AVC-Compatible.\n"
"The T in <DTQ> for base layer is just for identification. \n");
}
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
Extractor::xSetParameters()
{
UInt uiLayer, uiLevel, uiFGSLayer;
//JVT-T054{
Bool bQuit = false;
//JVT-T054}
//=========== clear all ===========
for( uiLayer = 0; uiLayer < MAX_LAYERS; uiLayer++ )
for( uiLevel = 0; uiLevel <= MAX_DSTAGES; uiLevel++ )
{
m_aadTargetSNRLayer[uiLayer][uiLevel] = -1;
}
#define ERROR(x,t) {if(x) {::printf("\nERROR: %s\n",t); assert(0); return Err::m_nERR;} }
#define WARNING(x,t) {if(x) {::printf("\nWARNING: %s\n",t); } }
const MyList<ExtractorParameter::Point>& rcExtList = m_pcExtractorParameter->getExtractionList();
ROT( rcExtList.size() != 1 );
MyList<ExtractorParameter::Point>::const_iterator cIter = rcExtList.begin ();
MyList<ExtractorParameter::Point>::const_iterator cEnd = rcExtList.end ();
const ExtractorParameter::Point& rcExtPoint = *cIter;
UInt uiExtLayer = MSYS_UINT_MAX;
UInt uiExtLevel = MSYS_UINT_MAX;
//----- layer -----
for( uiLayer = 0; uiLayer < m_cScalableStreamDescription.getNumberOfLayers(); uiLayer++ )
{
if( rcExtPoint.uiWidth < m_cScalableStreamDescription.getFrameWidth (uiLayer) ||
rcExtPoint.uiHeight < m_cScalableStreamDescription.getFrameHeight(uiLayer) )
{
break;
}
uiExtLayer = uiLayer;
}
ERROR( uiExtLayer==MSYS_UINT_MAX, "Spatial resolution of extraction/inclusion point not supported" );
m_pcExtractorParameter->setLayer(uiExtLayer);
//--- level ---
for( uiLevel = 0; uiLevel <= MAX_DSTAGES; uiLevel++ )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -