📄 codingparameter.cpp
字号:
if (uiMBCount != uiFrameSizeInMbs)
{
printf("IROI error\n");
m_bSliceDivisionFlag = false;
return Err::m_nOK;
}
// Display slice division info.
printf("IROI: Slice Division Type %d, Num Slice %d\n", m_uiSliceDivisionType, m_uiNumSliceMinus1+1);
//for (i=0; i<=m_uiNumSliceMinus1; i++)
//{
// printf("(%d, %d, %d, %d, %d)\n", i, m_puiGridSliceWidthInMbsMinus1[i], m_puiGridSliceHeightInMbsMinus1[i], m_puiFirstMbInSlice[i], m_puiLastMbInSlice[i]);
//}
}
// JVT-S054 (ADD) <-
//S051{
ROTREPORT( getAnaSIP ()>0 && getEncSIP(), "Unsupported SIP mode\n");
//S051}
return Err::m_nOK;
}
UInt CodingParameter::getLogFactor( Double r0, Double r1 )
{
Double dLog2Factor = log10( r1 / r0 ) / log10( 2.0 );
Double dRound = floor( dLog2Factor + 0.5 );
Double dEpsilon = 0.0001;
if( dLog2Factor-dEpsilon < dRound && dRound < dLog2Factor+dEpsilon )
{
return (UInt)(dRound);
}
return MSYS_UINT_MAX;
}
//JVT-W080
ErrVal CodingParameter::savePDSParameters( UInt uiNumView
, UInt* num_refs_list0_anc
, UInt* num_refs_list1_anc
, UInt* num_refs_list0_nonanc
, UInt* num_refs_list1_nonanc
, UInt** PDIInitialDelayMinus2L0Anc
, UInt** PDIInitialDelayMinus2L1Anc
, UInt** PDIInitialDelayMinus2L0NonAnc
, UInt** PDIInitialDelayMinus2L1NonAnc
)
{
for( UInt i = 0; i < uiNumView; i++ )
{
UInt j;
for( j = 0; j < num_refs_list0_anc[i]; j++ )
{
m_ppuiPdsInitialDelayMinus2L0Anc[i][j] = PDIInitialDelayMinus2L0Anc[i][j];
}
for( j = 0; j < num_refs_list1_anc[i]; j++ )
{
m_ppuiPdsInitialDelayMinus2L1Anc[i][j] = PDIInitialDelayMinus2L0Anc[i][j];
}
for( j = 0; j < num_refs_list0_nonanc[i]; j++ )
{
m_ppuiPdsInitialDelayMinus2L0NonAnc[i][j] = PDIInitialDelayMinus2L0NonAnc[i][j];
}
for( j = 0; j < num_refs_list1_nonanc[i]; j++ )
{
m_ppuiPdsInitialDelayMinus2L1NonAnc[i][j] = PDIInitialDelayMinus2L0NonAnc[i][j];
}
}
return Err::m_nOK;
}
//~JVT-W080
ErrVal CodingParameter::check()
{
ROTS( m_cLoopFilterParams .check() );
ROTS( m_cMotionVectorSearchParams .check() );
if( getMVCmode() )
{
//===== coder is operated in MVC mode =====
ROTREPORT( getFrameWidth () <= 0 ||
getFrameWidth () % 16, "Frame Width must be greater than 0 and a multiple of 16" );
ROTREPORT( getFrameHeight () <= 0 ||
getFrameHeight () % 16, "Frame Height must be greater than 0 and a multiple of 16" );
ROTREPORT( getMaximumFrameRate () <= 0.0, "Frame rate not supported" );
ROTREPORT( getTotalFrames () == 0, "Total Number Of Frames must be greater than 0" );
ROTREPORT( getSymbolMode () > 1, "Symbol mode not supported" );
ROTREPORT( get8x8Mode () > 2, "FRExt mode not supported" );
ROTREPORT( getMaximumFrameRate() <= 0.0, "Maximum frame rate not supported" );
ROTREPORT( getMaximumDelay () < 0.0, "Maximum delay must be greater than or equal to 0" );
ROTREPORT( getTotalFrames () == 0, "Total Number Of Frames must be greater than 0" );
ROTREPORT( getGOPSize () < 1 ||
getGOPSize () > 64, "GOP Size not supported" );
UInt uiDecStages = getLogFactor( 1.0, getGOPSize() );
ROTREPORT( uiDecStages == MSYS_UINT_MAX && getGOPSize()!= 12 && getGOPSize()!= 15, "GOP Size must be a multiple of 2 or 12 or 15" );
// temporal scalability
if(uiDecStages==MSYS_UINT_MAX)
uiDecStages= (UInt)( log10( m_uiGOPSize+.0) / log10( 2.0 ) +1 );
setDecompositionStages( uiDecStages );
ROTREPORT( getIntraPeriod () <
getGOPSize (), "Intra period must be greater or equal to GOP size" );
if( getIntraPeriod() == MSYS_UINT_MAX )
{
setIntraPeriodLowPass( MSYS_UINT_MAX );
}
else
{
UInt uiIntraPeriod = getIntraPeriod() / getGOPSize() - 1;
ROTREPORT( getIntraPeriod() % getGOPSize(), "Intra period must be a power of 2 of GOP size (or -1)" );
setIntraPeriodLowPass( uiIntraPeriod );
}
ROTREPORT( getNumRefFrames () < 1 ||
getNumRefFrames () > 15, "Number of reference frames not supported" );
return Err::m_nOK;
}
ROTREPORT( getMaximumFrameRate() <= 0.0, "Maximum frame rate not supported" );
ROTREPORT( getMaximumDelay () < 0.0, "Maximum delay must be greater than or equal to 0" );
ROTREPORT( getTotalFrames () == 0, "Total Number Of Frames must be greater than 0" );
ROTREPORT( getGOPSize () < 1 ||
getGOPSize () > 64, "GOP Size not supported" );
UInt uiDecStages = getLogFactor( 1.0, getGOPSize() );
ROTREPORT( uiDecStages == MSYS_UINT_MAX, "GOP Size must be a multiple of 2" );
setDecompositionStages( uiDecStages );
ROTREPORT( getIntraPeriod () <
getGOPSize (), "Intra period must be greater or equal to GOP size" );
if( getIntraPeriod() == MSYS_UINT_MAX )
{
setIntraPeriodLowPass( MSYS_UINT_MAX );
}
else
{
UInt uiIntraPeriod = getIntraPeriod() / getGOPSize() - 1;
ROTREPORT( getIntraPeriod() % getGOPSize(), "Intra period must be a power of 2 of GOP size (or -1)" );
setIntraPeriodLowPass( uiIntraPeriod );
}
ROTREPORT( getNumRefFrames () < 1 ||
getNumRefFrames () > 15, "Number of reference frames not supported" );
ROTREPORT( getBaseLayerMode () > 2, "Base layer mode not supported" );
ROTREPORT( getNumberOfLayers () > MAX_LAYERS, "Number of layers not supported" );
Double dMaxFrameDelay = max( 0, m_dMaximumFrameRate * m_dMaximumDelay / 1000.0 );
UInt uiMaxFrameDelay = (UInt)floor( dMaxFrameDelay );
for( UInt uiLayer = 0; uiLayer < getNumberOfLayers(); uiLayer++ )
{
LayerParameters* pcLayer = &m_acLayerParameters[uiLayer];
RNOK( pcLayer->check() );
UInt uiBaseLayerId = uiLayer && pcLayer->getBaseLayerId() != MSYS_UINT_MAX ? pcLayer->getBaseLayerId() : MSYS_UINT_MAX;
LayerParameters* pcBaseLayer = uiBaseLayerId != MSYS_UINT_MAX ? &m_acLayerParameters[uiBaseLayerId] : 0;
UInt uiLogFactorInOutRate = getLogFactor( pcLayer->getOutputFrameRate (), pcLayer->getInputFrameRate() );
UInt uiLogFactorMaxInRate = getLogFactor( pcLayer->getInputFrameRate (), getMaximumFrameRate () );
// heiko.schwarz@hhi.fhg.de: add some additional check for input/output frame rates
ROTREPORT( pcLayer->getInputFrameRate() < pcLayer->getOutputFrameRate(), "Input frame rate must not be less than output frame rate" );
ROTREPORT( pcLayer->getInputFrameRate() > getMaximumFrameRate(), "Input frame rate must not be greater than maximum frame rate" );
ROTREPORT( getDecompositionStages() < uiLogFactorMaxInRate + uiLogFactorInOutRate, "Number of decomposition stages is too small for the specified output rate" );
ROTREPORT( uiLogFactorInOutRate == MSYS_UINT_MAX, "Input frame rate must be a power of 2 of output frame rate" );
ROTREPORT( uiLogFactorMaxInRate == MSYS_UINT_MAX, "Maximum frame rate must be a power of 2 of input frame rate" );
pcLayer->setNotCodedMCTFStages ( uiLogFactorInOutRate );
pcLayer->setTemporalResolution ( uiLogFactorMaxInRate );
pcLayer->setDecompositionStages ( getDecompositionStages() - uiLogFactorMaxInRate );
pcLayer->setFrameDelay ( uiMaxFrameDelay / ( 1 << uiLogFactorMaxInRate ) );
if( pcBaseLayer ) // for sub-sequence SEI
{
ROTREPORT( pcLayer->getInputFrameRate() < pcBaseLayer->getInputFrameRate(), "Input frame rate less than base layer output frame rate" );
UInt uiLogFactorRate = getLogFactor( pcBaseLayer->getInputFrameRate(), pcLayer->getInputFrameRate() );
ROTREPORT( uiLogFactorRate == MSYS_UINT_MAX, "Input Frame rate must be a power of 2 from layer to layer" );
pcLayer->setBaseLayerTempRes( uiLogFactorRate );
ROTREPORT( pcLayer->getFrameWidth () < pcBaseLayer->getFrameWidth (), "Frame width less than base layer frame width" );
ROTREPORT( pcLayer->getFrameHeight() < pcBaseLayer->getFrameHeight(), "Frame height less than base layer frame height" );
UInt uiLogFactorWidth = getLogFactor( pcBaseLayer->getFrameWidth (), pcLayer->getFrameWidth () );
pcLayer->setBaseLayerSpatRes( uiLogFactorWidth );
// TMM_ESS {
ResizeParameters * resize = pcLayer->getResizeParameters();
if (resize->m_iExtendedSpatialScalability != ESS_NONE)
{
ROTREPORT(resize->m_iInWidth % 16, "Base layer width must be a multiple of 16" );
ROTREPORT(resize->m_iInHeight % 16, "Base layer height must be a multiple of 16" );
if (resize->m_bCrop)
{
ROTREPORT( resize->m_iPosX % 2 , "Cropping Window must be even aligned" );
ROTREPORT( resize->m_iPosY % 2 , "Cropping Window must be even aligned" );
ROTREPORT(resize->m_iGlobWidth % 16, "Enhancement layer width must be a multiple of 16" );
ROTREPORT(resize->m_iGlobHeight % 16, "Enhancement layer height must be a multiple of 16" );
}
else
{
resize->m_iGlobWidth = resize->m_iOutWidth;
resize->m_iGlobHeight = resize->m_iOutHeight;
}
printf("\n\n*************************\n%dx%d -> %dx%d %s -> %dx%d\n",
resize->m_iInWidth, resize->m_iInHeight,
resize->m_iOutWidth, resize->m_iOutHeight,
(resize->m_bCrop ? "Crop" : "No_Crop"),
resize->m_iGlobWidth, resize->m_iGlobHeight);
printf("ExtendedSpatialScalability: %d SpatialScalabilityType: %d\n",
resize->m_iExtendedSpatialScalability,
resize->m_iSpatialScalabilityType);
}
else
{
printf("\n\n*************************\n No_Crop\n");
}
// TMM_ESS }
pcBaseLayer->setContrainedIntraForLP();
}
if( pcLayer->getBaseQualityLevel() > 3 )
pcLayer->setBaseQualityLevel(3);
if( uiLayer == 0 && pcLayer->getBaseQualityLevel() != 0 )
pcLayer->setBaseQualityLevel(0);
// pass parameters from command line to layer configurations
if( m_dLowPassEnhRef >= 0 )
{
pcLayer->setLowPassEnhRef( m_dLowPassEnhRef );
}
if( m_uiBaseWeightZeroBaseBlock <= AR_FGS_MAX_BASE_WEIGHT || m_uiBaseWeightZeroBaseCoeff <= AR_FGS_MAX_BASE_WEIGHT )
{
pcLayer->setAdaptiveRefFGSWeights( m_uiBaseWeightZeroBaseBlock, m_uiBaseWeightZeroBaseCoeff );
}
if( m_uiFgsEncStructureFlag < MSYS_UINT_MAX )
{
pcLayer->setFgsEncStructureFlag( m_uiFgsEncStructureFlag );
}
}
return Err::m_nOK;
}
H264AVC_NAMESPACE_END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -