?? h264avcencoder.cpp
字號:
if( bProfileLevelInfoPresentFlag )
{
UInt uiOpProfileIdc, uiOpLevelIdc;
Bool uiOpConstraintSet0Flag, uiOpConstraintSet1Flag,
uiOpConstraintSet2Flag, uiOpConstraintSet3Flag;
uiOpProfileIdc = 0; // may be changed
uiOpLevelIdc = 0; // may be changed
uiOpConstraintSet0Flag = false; // may be changed
uiOpConstraintSet1Flag = false; // may be changed
uiOpConstraintSet2Flag = false; // may be changed
uiOpConstraintSet3Flag = false; // may be changed
pcViewScalInfoSei->setOpProfileIdc( i, uiOpProfileIdc );
pcViewScalInfoSei->setOpConstraintSet0Flag( i, uiOpConstraintSet0Flag );
pcViewScalInfoSei->setOpConstraintSet1Flag( i, uiOpConstraintSet1Flag );
pcViewScalInfoSei->setOpConstraintSet2Flag( i, uiOpConstraintSet2Flag );
pcViewScalInfoSei->setOpConstraintSet3Flag( i, uiOpConstraintSet3Flag );
pcViewScalInfoSei->setOpLevelIdc( i, uiOpLevelIdc );
}
else
{
UInt uiProfileLevelInfoSrcOpIdDelta = 0; //may be changed
pcViewScalInfoSei->setProfileLevelInfoSrcOpIdDelta( i, uiProfileLevelInfoSrcOpIdDelta );
}
if( bBitRateInfoPresentFlag )
{
UInt uiAvgBitrate, uiMaxBitrate, uiMaxBitrateCalcWindow;
uiAvgBitrate = (UInt)dBitRate[uiTemporalId];
uiMaxBitrate = (UInt)dMaxRate; //may be changed
uiMaxBitrateCalcWindow = 100; //should be changed
pcViewScalInfoSei->setAvgBitrate( i, uiAvgBitrate );
pcViewScalInfoSei->setMaxBitrate( i, uiMaxBitrate );
pcViewScalInfoSei->setMaxBitrateCalcWindow( i, uiMaxBitrateCalcWindow );
}
if( bFrmRateInfoPresentFlag )
{
UInt uiConstantFrmRateIdc, uiAvgFrmRate;
uiConstantFrmRateIdc = 0;
uiAvgFrmRate =(UInt) dFrameRate[uiTemporalId];
pcViewScalInfoSei->setConstantFrmRateIdc( i, uiConstantFrmRateIdc );
pcViewScalInfoSei->setAvgFrmRate( i, uiAvgFrmRate );
}
else
{
UInt uiFrmRateInfoSrcOpIdDelta = 0; //may be changed
pcViewScalInfoSei->setFrmRateInfoSrcOpIdDela( i, uiFrmRateInfoSrcOpIdDelta );
}
if( bOpDependencyInfoPresentFlag )
{
UInt uiNumDirectlyDependentOps =0 ;
pcViewScalInfoSei->setNumDirectlyDependentOps( i, uiNumDirectlyDependentOps );
for( j = 0; j <= uiNumDirectlyDependentOps; j++ )
{
UInt uiDirectlyDependentOpIdDeltaMinus1 = 0;
pcViewScalInfoSei->setDirectlyDependentOpIdDeltaMinus1( i, j, uiDirectlyDependentOpIdDeltaMinus1 );
}
}
else
{
UInt uiOpDependencyInfoSrcOpIdDelta = 0; //should be changed
pcViewScalInfoSei->setOpDependencyInfoSrcOpIdDelta( i, uiOpDependencyInfoSrcOpIdDelta );
}
if( bInitParameterSetsInfoPresentFlag )
{
//the parameters may should be changed
UInt uiNumInitSeqParameterSetMinus1, uiNumInitPicParameterSetMinus1;
uiNumInitSeqParameterSetMinus1 = 0;
uiNumInitPicParameterSetMinus1 = 0;
pcViewScalInfoSei->setNumInitSeqParameterSetMinus1( i, uiNumInitSeqParameterSetMinus1 );
for( j = 0; j <= uiNumInitSeqParameterSetMinus1; j++ )
{
UInt uiInitSeqParameterSetIdDelta = 0;
pcViewScalInfoSei->setInitSeqParameterSetIdDelta( i, j, uiInitSeqParameterSetIdDelta );
}
pcViewScalInfoSei->setNumInitPicParameterSetMinus1( i, uiNumInitPicParameterSetMinus1 );
for( j = 0; j <= uiNumInitPicParameterSetMinus1; j++ )
{
UInt uiInitPicParameterSetIdDelta = 0;
pcViewScalInfoSei->setInitPicParameterSetIdDelta( i, j, uiInitPicParameterSetIdDelta );
}
}
else
{
UInt uiInitParameterSetsInfoSrcOpIdDelta = 0; //may should be changed
pcViewScalInfoSei->setInitParameterSetsInfoSrcOpIdDelta( i, uiInitParameterSetsInfoSrcOpIdDelta );
}
}
UInt uiBits = 0;
SEI::MessageList cSEIMessageList;
cSEIMessageList.push_back ( pcViewScalInfoSei );
RNOK( m_pcNalUnitEncoder ->initNalUnit ( pcExtBinDataAccessor ) );
RNOK( m_pcNalUnitEncoder ->write ( cSEIMessageList ) );
RNOK( m_pcNalUnitEncoder ->closeNalUnit ( uiBits ) );
return Err::m_nOK;
}
//SEI }
ErrVal
H264AVCEncoder::xWriteScalableSEI( ExtBinDataAccessor* pcExtBinDataAccessor )
{
//===== create message =====
SEI::ScalableSei* pcScalableSEI;
RNOK(SEI::ScalableSei::create(pcScalableSEI) );
//===== set message =====
UInt j; //JVT-S036 lsj
UInt uiInputLayers = m_pcCodingParameter->getNumberOfLayers ();
UInt uiLayerNum = 0; //total scalable layer numbers
for ( UInt i = 0; i < uiInputLayers; i++ ) //calculate total scalable layer numbers
{
Bool bH264AVCCompatible = ( i == 0 && m_pcCodingParameter->getBaseLayerMode() > 0 );
Bool bSubSeq = ( i == 0 && m_pcCodingParameter->getBaseLayerMode() > 1 );
LayerParameters& rcLayer = m_pcCodingParameter->getLayerParameters ( i );
UInt uiTotalTempLevel = rcLayer.getDecompositionStages () - rcLayer.getNotCodedMCTFStages();
// *LMH(20060203): Fix Bug due to underflow (Replace)
//UInt uiMinTempLevel = ( !bH264AVCCompatible ||bSubSeq ) ? 0: max( 0, uiTotalTempLevel - 1 );
UInt uiMinTempLevel = ( !bH264AVCCompatible ||bSubSeq ) ? 0: max( 0, (Int)uiTotalTempLevel - 1 );
UInt uiActTempLevel = uiTotalTempLevel - uiMinTempLevel + 1;
UInt uiTotalFGSLevel = (UInt)rcLayer.getNumFGSLayers () + 1;
uiLayerNum += uiActTempLevel * uiTotalFGSLevel;
pcScalableSEI->setROINum ( i, rcLayer.getNumROI() );
pcScalableSEI->setROIID ( i, rcLayer.getROIID() );
pcScalableSEI->setSGID ( i, rcLayer.getSGID() );
pcScalableSEI->setSLID ( i, rcLayer.getSLID() );
}
UInt uiTotalScalableLayer = 0;
//===== get framerate information ===
Double *dFramerate = dGetFramerate();
UInt uiNumLayersMinus1 = uiLayerNum - 1;
pcScalableSEI->setNumLayersMinus1 ( uiNumLayersMinus1 );
UInt uiNumScalableLayer = 0;
for ( UInt uiCurrLayer = 0; uiCurrLayer < uiInputLayers; uiCurrLayer++)
{
LayerParameters& rcLayer = m_pcCodingParameter->getLayerParameters ( uiCurrLayer );
UInt uiTotalTempLevel = rcLayer.getDecompositionStages () - rcLayer.getNotCodedMCTFStages() + 1;
UInt uiTotalFGSLevel = (UInt)rcLayer.getNumFGSLayers () + 1;
//Bool bFGSLayerFlag = uiTotalFGSLevel > 1; //JVT-S036
Bool bH264AVCCompatible = ( uiCurrLayer == 0 && m_pcCodingParameter->getBaseLayerMode() > 0 );
Bool bSubSeq = ( uiCurrLayer == 0 && m_pcCodingParameter->getBaseLayerMode() > 1 );
// *LMH(20060203): Fix Bug due to underflow (Replace)
//UInt uiMinTempLevel = ( !bH264AVCCompatible ||bSubSeq ) ? 0: max(0,uiTotalTempLevel - 2);
UInt uiMinTempLevel = ( !bH264AVCCompatible ||bSubSeq ) ? 0: max(0, (Int)uiTotalTempLevel - 2);
for ( UInt uiCurrTempLevel = 0; uiCurrTempLevel < uiTotalTempLevel; uiCurrTempLevel++ )
{
for ( UInt uiCurrFGSLevel = 0; uiCurrFGSLevel < uiTotalFGSLevel; uiCurrFGSLevel++ )
{
if( uiCurrTempLevel >= uiMinTempLevel )
{
//Bool bSubPicLayerFlag = false;
Bool bSubRegionLayerFlag = false;
Bool bProfileLevelInfoPresentFlag = false;
Bool bInitParameterSetsInfoPresentFlag = false; //may be changed //JVT-S036
if( uiNumScalableLayer == 0 )
{//JVT-S036
bSubRegionLayerFlag = true;
bProfileLevelInfoPresentFlag = true;
bInitParameterSetsInfoPresentFlag = true;
}
Bool bBitrateInfoPresentFlag = true;
Bool bFrmRateInfoPresentFlag = true;//rcLayer.getInputFrameRate () > 0;
Bool bFrmSizeInfoPresentFlag = true;
// BUG_FIX liuhui{
Bool bLayerDependencyInfoPresentFlag = true; //may be changed
// BUG_FIX liuhui}
//Bool bInitParameterSetsInfoPresentFlag = false; //may be changed //JVT-S036
Bool bExactInterayerPredFlag = true; //JVT-S036 may be changed
// JVT-S054 (REMOVE)
//Bool bIroiSliceDivisionFlag = false; //JVT-S036
pcScalableSEI->setLayerId(uiNumScalableLayer, uiNumScalableLayer);
//JVT-S036 start
//pcScalableSEI->setFGSlayerFlag(uiNumScalableLayer, bFGSLayerFlag);
//pcScalableSEI->setSubPicLayerFlag(uiNumScalableLayer,0);
UInt uiTempLevel = uiCurrTempLevel; //BUG_FIX_FT_01_2006
UInt uiDependencyID = uiCurrLayer;
UInt uiQualityLevel = uiCurrFGSLevel;
// BUG_FIX liuhui{
m_aaauiScalableLayerId[uiCurrLayer][uiCurrTempLevel][uiCurrFGSLevel] = uiNumScalableLayer;
// BUG_FIX liuhui}
UInt uiSimplePriorityId = 0;
Bool bDiscardableFlag = false;
if( uiCurrFGSLevel > rcLayer.getNumFGSLayers() )
bDiscardableFlag = true;
pcScalableSEI->setSimplePriorityId(uiNumScalableLayer, uiSimplePriorityId);
pcScalableSEI->setDiscardableFlag(uiNumScalableLayer, bDiscardableFlag);
pcScalableSEI->setTemporalLevel(uiNumScalableLayer, uiTempLevel);
pcScalableSEI->setDependencyId(uiNumScalableLayer, uiDependencyID);
pcScalableSEI->setQualityLevel(uiNumScalableLayer, uiQualityLevel);
//JVT-S036 end
pcScalableSEI->setSubRegionLayerFlag(uiNumScalableLayer, bSubRegionLayerFlag);
// JVT-S054 (REPLACE)
//pcScalableSEI->setIroiSliceDivisionInfoPresentFlag(uiNumScalableLayer, bIroiSliceDivisionFlag); //JVT-S036
pcScalableSEI->setIroiSliceDivisionInfoPresentFlag(uiNumScalableLayer, rcLayer.m_bSliceDivisionFlag);
pcScalableSEI->setProfileLevelInfoPresentFlag(uiNumScalableLayer, bProfileLevelInfoPresentFlag);
pcScalableSEI->setBitrateInfoPresentFlag(uiNumScalableLayer, bBitrateInfoPresentFlag);
pcScalableSEI->setFrmRateInfoPresentFlag(uiNumScalableLayer, bFrmRateInfoPresentFlag);
pcScalableSEI->setFrmSizeInfoPresentFlag(uiNumScalableLayer, bFrmSizeInfoPresentFlag);
pcScalableSEI->setLayerDependencyInfoPresentFlag(uiNumScalableLayer, bLayerDependencyInfoPresentFlag);
pcScalableSEI->setInitParameterSetsInfoPresentFlag(uiNumScalableLayer, bInitParameterSetsInfoPresentFlag);
pcScalableSEI->setExactInterlayerPredFlag(uiNumScalableLayer, bExactInterayerPredFlag);//JVT-S036
if(pcScalableSEI->getProfileLevelInfoPresentFlag(uiNumScalableLayer))
{
UInt uilayerProfileIdc = 0; //may be changed
Bool bLayerConstraintSet0Flag = false; //may be changed
Bool bH264AVCCompatibleTmp = m_pcCodingParameter->getBaseLayerMode() > 0 && uiCurrLayer == 0;
Bool bLayerConstraintSet1Flag = ( bH264AVCCompatibleTmp ? 1 : 0 ); //may be changed
Bool bLayerConstraintSet2Flag = false; //may be changed
Bool bLayerConstraintSet3Flag = false; //may be changed
UInt uiLayerLevelIdc = 0; //may be changed
pcScalableSEI->setLayerProfileIdc(uiNumScalableLayer, uilayerProfileIdc);
pcScalableSEI->setLayerConstraintSet0Flag(uiNumScalableLayer, bLayerConstraintSet0Flag);
pcScalableSEI->setLayerConstraintSet1Flag(uiNumScalableLayer, bLayerConstraintSet1Flag);
pcScalableSEI->setLayerConstraintSet2Flag(uiNumScalableLayer, bLayerConstraintSet2Flag);
pcScalableSEI->setLayerConstraintSet3Flag(uiNumScalableLayer, bLayerConstraintSet3Flag);
pcScalableSEI->setLayerLevelIdc(uiNumScalableLayer, uiLayerLevelIdc);
}
else
{//JVT-S036
UInt bProfileLevelInfoSrcLayerIdDelta = 0; //may be changed
pcScalableSEI->setProfileLevelInfoSrcLayerIdDelta(uiNumScalableLayer, bProfileLevelInfoSrcLayerIdDelta);
}
/* if(pcScalableSEI->getDecodingDependencyInfoPresentFlag(uiNumScalableLayer))
{
//UInt uiTempLevel = uiCurrTempLevel - uiMinTempLevel;
UInt uiTempLevel = uiCurrTempLevel; //BUG_FIX_FT_01_2006
UInt uiDependencyID = uiCurrLayer;
UInt uiQualityLevel = uiCurrFGSLevel;
// BUG_FIX liuhui{
m_aaauiScalableLayerId[uiCurrLayer][uiCurrTempLevel][uiCurrFGSLevel] = uiNumScalableLayer;
// BUG_FIX liuhui}
UInt uiSimplePriorityId = 0;
Bool uiDiscardableFlag = false;
pcScalableSEI->setSimplePriorityId(uiNumScalableLayer, uiSimplePriorityId);
pcScalableSEI->setDiscardableFlag(uiNumScalableLayer, uiDiscardableFlag);
pcScalableSEI->setTemporalLevel(uiNumScalableLayer, uiTempLevel);
pcScalableSEI->setDependencyId(uiNumScalableLayer, uiDependencyID);
pcScalableSEI->setQualityLevel(uiNumScalableLayer, uiQualityLevel);
}
JVT-S036 */
if(pcScalableSEI->getBitrateInfoPresentFlag(uiNumScalableLayer))
{
// BUG_FIX liuhui{
UInt uiAvgBitrate = (UInt)( m_aaadSingleLayerBitrate[uiCurrLayer][uiCurrTempLevel][uiCurrFGSLevel]+0.5 );
// BUG_FIX liuhui}
//JVT-S036 start
UInt uiMaxBitrateLayer = 0; //should be changed
UInt uiMaxBitrateDecodedPicture = 0; //should be changed
UInt uiMaxBitrateCalcWindow = 0; //should be changed
pcScalableSEI->setAvgBitrate(uiNumScalableLayer, uiAvgBitrate);
pcScalableSEI->setMaxBitrateLayer(uiNumScalableLayer, uiMaxBitrateLayer);
pcScalableSEI->setMaxBitrateDecodedPicture(uiNumScalableLayer, uiMaxBitrateDecodedPicture);
pcScalableSEI->setMaxBitrateCalcWindow(uiNumScalableLayer, uiMaxBitrateCalcWindow);
//JVT-S036 end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -