📄 extractor.cpp
字号:
/* JVT-S080 LMI {
else
{
ROT ( pcScalableSei );
}
JVT-S080 LMI } */
//===== set packet length =====
while( pcBinData->data()[ pcBinData->size() - 1 ] == 0x00 )
{
RNOK( pcBinData->decreaseEndPos( 1 ) ); // remove zero at end
}
//==== get parameters =====
if( ! bApplyToNext )
{
uiLayer = cPacketDescription.Layer;
uiLevel = cPacketDescription.Level;
uiFGSLayer = cPacketDescription.FGSLayer;
}
bApplyToNext = cPacketDescription.ApplyToNext;
bNewPicture = ( ! cPacketDescription.ParameterSet && ! cPacketDescription.ApplyToNext );
//==== 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] ++;
// BUG_FIX liuhui{
if( uiFirstTempLevel &&
( cPacketDescription.NalUnitType == NAL_UNIT_CODED_SLICE ||
cPacketDescription.NalUnitType == NAL_UNIT_CODED_SLICE_IDR ) )
setBaseLayerAVCCompatible(true);
// BUG_FIX liuhui}
}
if(cPacketDescription.uiNumLevelsQL != 0)
{
//QL SEI packet
bApplyToNext = false;
}
RNOK( m_pcReadBitstream->releasePacket( pcBinData ) );
pcBinData = NULL;
}
//----- reset input file -----
RNOKS( static_cast<ReadBitstreamFile*>(m_pcReadBitstream)->uninit() );
RNOKS( static_cast<ReadBitstreamFile*>(m_pcReadBitstream)->init ( m_pcExtractorParameter->getInFile() ) );
//{{Quality level estimation and modified truncation- JVTO044 and m12007
//France Telecom R&D-(nathalie.cammas@francetelecom.com)
//save number of frames per layer
for(uiLayer = 0; uiLayer < MAX_LAYERS; uiLayer++)
{
m_auiNbImages[uiLayer] = auiNumImage[uiLayer];
}
return Err::m_nOK;
}
Void Extractor::AllocateAndInitializeDatas()
{
UInt uiLayer, uiFGSLayer, uiPoint, uiFrame;
for(uiLayer=0; uiLayer<MAX_LAYERS; uiLayer++)
{
m_aaadMaxRate[uiLayer] = new Double[m_auiNbImages[uiLayer]];
m_aaiLevelForFrame[uiLayer] = new Int[m_auiNbImages[uiLayer]];
m_aadTargetByteForFrame[uiLayer] = new Double[m_auiNbImages[uiLayer]];
m_aaiNumLevels[uiLayer] = new Int[m_auiNbImages[uiLayer]];
for(uiFGSLayer = 0; uiFGSLayer <= MAX_FGS_LAYERS; uiFGSLayer++)
{
m_aaadTargetBytesFGS[uiLayer][uiFGSLayer] = new Double[m_auiNbImages[uiLayer]];
m_aaadBytesForFrameFGS[uiLayer][uiFGSLayer] = new Double[m_auiNbImages[uiLayer]];
}
for(uiPoint = 0; uiPoint < MAX_NUM_RD_LEVELS; uiPoint++)
{
m_aaauiBytesForQualityLevel[uiLayer][uiPoint] = new UInt[m_auiNbImages[uiLayer]];
m_aaadQualityLevel[uiLayer][uiPoint] = new Double[m_auiNbImages[uiLayer]];
}
}
for(uiLayer=0; uiLayer<MAX_LAYERS; uiLayer++)
{
for(uiFrame=0; uiFrame<m_auiNbImages[uiLayer]; uiFrame++)
{
m_aaadMaxRate[uiLayer][uiFrame] = 0;
m_aaiLevelForFrame[uiLayer][uiFrame] = -1;
m_aadTargetByteForFrame[uiLayer][uiFrame] = 0;
m_aaiNumLevels[uiLayer][uiFrame] = 0;
for(uiFGSLayer = 0; uiFGSLayer <= MAX_FGS_LAYERS; uiFGSLayer++)
{
m_aaadTargetBytesFGS[uiLayer][uiFGSLayer][uiFrame] = 0;
m_aaadBytesForFrameFGS[uiLayer][uiFGSLayer][uiFrame] = 0;
}
for(uiPoint = 0; uiPoint < MAX_NUM_RD_LEVELS; uiPoint++)
{
m_aaauiBytesForQualityLevel[uiLayer][uiPoint][uiFrame] = 0;
m_aaadQualityLevel[uiLayer][uiPoint][uiFrame] = 0;
}
}
}
}
ErrVal
Extractor::xAnalyse()
{
UInt uiLayer = 0;
UInt uiLevel = 0;
UInt uiFGSLayer = 0;
Bool bNewPicture = false;
Bool bApplyToNext = false;
Bool bEOS = false;
BinData* pcBinData = 0;
h264::SEI::SEIMessage* pcScalableSei = 0;
h264::PacketDescription cPacketDescription;
//{{Quality level estimation and modified truncation- JVTO044 and m12007
//France Telecom R&D-(nathalie.cammas@francetelecom.com)
//Quality levels information
UInt uiNumFrame;
// BUG_FIX liuhui{
UInt uiMaxLayer = 0;
UInt uiMaxTempLevel = 0;
h264::SEI::ScalableSei* pcTmpScalableSei = 0;
// BUG_FIX liuhui}
//Common information to dead substreams and quality levels
//arrays initialization
static UInt auiNumImage[MAX_LAYERS] =
{
0,0,0,0,0,0,0,0
};
//}}Quality level estimation and modified truncation- JVTO044 and m12007
UInt uiPId = 0;
// HS: packet trace
Int64 i64StartPos = 0;
Int64 i64EndPos = 0;
Int iLastTempLevel= 0;
m_uiMaxSize = 0;
//========== initialize (scalable SEI message shall be the first packet of the stream) ===========
{
RNOK( m_pcH264AVCPacketAnalyzer->init() );
//--- get first packet ---
RNOK( m_pcReadBitstream->extractPacket( pcBinData, bEOS ) );
if( bEOS )
{
RNOK( m_pcReadBitstream->releasePacket( pcBinData ) );
return Err::m_nERR;
}
//--- analyse packet ---
RNOK( m_pcH264AVCPacketAnalyzer ->process( pcBinData, cPacketDescription, pcScalableSei ) );
if( !pcScalableSei )
{
printf("No scalability SEI messages found!\nExtractor exit.\n\n ");
exit( 0 );
}
// HS: packet trace
if( ! cPacketDescription.ApplyToNext )
{
i64EndPos = static_cast<ReadBitstreamFile*>(m_pcReadBitstream)->getFilePos();
UInt uiStart = (UInt)( i64StartPos & 0xFFFFFFFF );
UInt uiSize = (UInt)( i64EndPos - i64StartPos );
i64StartPos = i64EndPos;
if( m_pcTraceFile )
{
::fprintf( m_pcTraceFile, "Start-Pos. Length LId TId QId Packet-Type Discardable Truncatable""\n" );
::fprintf( m_pcTraceFile, "========== ====== === === === ============ =========== ===========""\n" );
::fprintf( m_pcTraceFile, "0x%08x" "%8d" "%5d""%5d""%5d"" %s" " %s"" %s" "\n",
uiStart,
uiSize,
cPacketDescription.Layer,
cPacketDescription.Level,
cPacketDescription.FGSLayer,
"StreamHeader",
" No", " No" );
}
m_uiMaxSize = max( m_uiMaxSize, uiSize );
}
//--- initialize stream description ----
RNOK( m_cScalableStreamDescription.init( (h264::SEI::ScalableSei*)pcScalableSei ) );
// BUG_FIX liuhui{
m_cScalableStreamDescription.setBaseLayerMode( getBaseLayerAVCCompatible() );
pcTmpScalableSei = (h264::SEI::ScalableSei* ) pcScalableSei;
m_uiScalableNumLayersMinus1 = pcTmpScalableSei->getNumLayersMinus1();
uiMaxLayer = pcTmpScalableSei->getDependencyId( m_uiScalableNumLayersMinus1);
uiMaxTempLevel = pcTmpScalableSei->getTemporalLevel(m_uiScalableNumLayersMinus1);
// BUG_FIX liuhui}
if(pcBinData)
{
RNOK( m_pcReadBitstream->releasePacket( pcBinData ) );
pcBinData = NULL;
}
}
while( ! bEOS )
{
//===== get packet =====
RNOK( m_pcReadBitstream->extractPacket( pcBinData, bEOS ) );
if( bEOS )
{
RNOK( m_pcReadBitstream->releasePacket( pcBinData ) );
pcBinData = NULL;
continue;
}
//===== get packet description =====
RNOK( m_pcH264AVCPacketAnalyzer->process( pcBinData, cPacketDescription, pcScalableSei ) );
//S051{
if(m_uiSuffixUnitEnable&&(cPacketDescription.NalUnitType== NAL_UNIT_CODED_SLICE ||
cPacketDescription.NalUnitType== NAL_UNIT_CODED_SLICE_IDR )&&m_bUseSIP)//for the AVC suffix
{
int iPos=0;
h264::PacketDescription cPacketDescriptionTemp;
h264::SEI::SEIMessage* pcScalableSeiTemp = 0;
BinData* pcBinDataTemp = 0;
RNOK(m_pcReadBitstream->getPosition(iPos));
RNOK( m_pcReadBitstream->extractPacket( pcBinDataTemp, bEOS ) );
ROT(bEOS);
RNOK( m_pcH264AVCPacketAnalyzer->process( pcBinDataTemp, cPacketDescriptionTemp, pcScalableSeiTemp ) );
cPacketDescription.bDiscardable=cPacketDescriptionTemp.bDiscardable;
if(pcScalableSeiTemp)
{
delete pcScalableSeiTemp;
pcScalableSeiTemp=0;
}
if(pcBinDataTemp)
{
m_pcReadBitstream->releasePacket(pcBinDataTemp);
pcBinDataTemp=0;
}
RNOK(m_pcReadBitstream->setPosition(iPos));
}
//S051}
// *LMH (ADD) ->
if ( m_pcExtractorParameter->getROIFlag() )
{
//-- ROI Extraction ICU/ETRI
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;
if (false == CurNalKeepingNeed(cPacketDescription, rcExtPoint))
{
if(pcBinData)
{
RNOK( m_pcReadBitstream->releasePacket( pcBinData ) );
pcBinData = NULL;
}
continue;
}
}
// *LMH (ADD) <-
// JVT-S080 LMI {
//ROT ( pcScalableSei );
delete pcScalableSei;
pcScalableSei = NULL;
// JVT-S080 LMI }
// HS: packet trace
if( ! cPacketDescription.ApplyToNext )
{
if( iLastTempLevel )
{
cPacketDescription.Level = iLastTempLevel;
iLastTempLevel = 0;
}
i64EndPos = static_cast<ReadBitstreamFile*>(m_pcReadBitstream)->getFilePos();
UInt uiStart = (UInt)( i64StartPos & 0xFFFFFFFF );
UInt uiSize = (UInt)( i64EndPos - i64StartPos );
i64StartPos = i64EndPos;
if( m_pcTraceFile )
{
::fprintf( m_pcTraceFile, "0x%08x" "%8d" "%5d""%5d""%5d"" %s" " %s"" %s" "\n",
uiStart,
uiSize,
cPacketDescription.Layer,
cPacketDescription.Level,
cPacketDescription.FGSLayer,
cPacketDescription.ParameterSet ? "ParameterSet" : " SliceData",
cPacketDescription.ParameterSet || ( cPacketDescription.Level == 0 && cPacketDescription.FGSLayer == 0 ) ? " No" : "Yes",
cPacketDescription.FGSLayer ? "Yes" : " No" );
}
m_uiMaxSize = max( m_uiMaxSize, uiSize );
}
else
{
iLastTempLevel = cPacketDescription.Level;
}
//===== set packet length =====
while( pcBinData->data()[ pcBinData->size() - 1 ] == 0x00 )
{
RNOK( pcBinData->decreaseEndPos( 1 ) ); // remove zero at end
}
//==== get parameters =====
UInt uiPacketSize = 4 + pcBinData->size();
if( ! bApplyToNext )
{
uiLayer = cPacketDescription.Layer;
uiLevel = cPacketDescription.Level;
uiFGSLayer = cPacketDescription.FGSLayer;
}
//JVT-T054{
if(uiFGSLayer > 0)
m_bEnableQLTruncation[uiLayer][uiFGSLayer-1] = cPacketDescription.bEnableQLTruncation;
//JVT-T054}
bApplyToNext = cPacketDescription.ApplyToNext;
bNewPicture = ( ! cPacketDescription.ParameterSet && ! cPacketDescription.ApplyToNext );
uiPId = cPacketDescription.uiPId;
//S051{
if(!m_bUseSIP)
//S051}
//JVT-P031
if(cPacketDescription.bDiscardable)
{
m_bInInputStreamDS = true;
}
//~JVT-P031
//==== 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 )
{
//NonRequired JVT-Q066 (06-04-08){{
if(m_pcH264AVCPacketAnalyzer->getNonRequiredSeiFlag() == 1 )
{
uiLayer = uiMaxLayer;
}
//NonRequired JVT-Q066 (06-04-08)}}
uiNumFrame = auiNumImage[uiLayer];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -