📄 codingparameter.cpp
字号:
}
}
// Debug
if (uiSliceId != (m_uiNumSliceMinus1+1))
{
printf("IROI error\n");
m_bSliceDivisionFlag = false;
return Err::m_nOK;
}
uiMBCount = 0;
for (uiSliceId = 0; uiSliceId <= m_uiNumSliceMinus1; uiSliceId++)
{
uiMBAddr = m_puiFirstMbInSlice[uiSliceId];
for (i = 0; i <= m_puiGridSliceHeightInMbsMinus1[uiSliceId]; i++, uiMBAddr+=uiFrameWidthInMbs)
{
for (j = 0; j <= m_puiGridSliceWidthInMbsMinus1[uiSliceId]; j++, uiMBCount++)
{
m_puiSliceId[uiMBAddr+j] = uiSliceId;
}
}
}
// Debug
if (uiMBCount != uiFrameSizeInMbs)
{
printf("IROI error\n");
m_bSliceDivisionFlag = false;
return Err::m_nOK;
}
if( m_dNumFGSLayers == 0 )
{
m_uiFGSMotionMode = 0;
}
// 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;
}
ErrVal CodingParameter::check()
{
ROTS( m_cLoopFilterParams .check() );
ROTS( m_cMotionVectorSearchParams .check() );
if( getAVCmode() )
{
Bool bStringNotOk = SequenceStructure::checkString( getSequenceFormatString() );
//===== 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( getDPBSize () == 0, "DPBSize must be greater than 0" );
ROTREPORT( getNumDPBRefFrames () == 0 ||
getNumDPBRefFrames () > getDPBSize(), "NumRefFrames must be greater than 0 and must not be greater than DPB size" );
ROTREPORT( getLog2MaxFrameNum () < 4 ||
getLog2MaxFrameNum () > 16, "Log2MaxFrameNum must be in the range of [4..16]" );
ROTREPORT( getLog2MaxPocLsb () < 4 ||
getLog2MaxPocLsb () > 15, "Log2MaxFrameNum must be in the range of [4..15]" );
ROTREPORT( bStringNotOk, "Unvalid SequenceFormatString" );
ROTREPORT( getMaxRefIdxActiveBL0() <= 0 ||
getMaxRefIdxActiveBL0() > 15, "Unvalid value for MaxRefIdxActiveBL0" );
ROTREPORT( getMaxRefIdxActiveBL1() <= 0 ||
getMaxRefIdxActiveBL1() > 15, "Unvalid value for MaxRefIdxActiveBL1" );
ROTREPORT( getMaxRefIdxActiveP () <= 0 ||
getMaxRefIdxActiveP () > 15, "Unvalid value for MaxRefIdxActiveP" );
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 power 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" );
ROTREPORT( m_uiEncodeKeyPictures > 2, "Key picture mode not supported" );
ROTREPORT( m_uiMGSKeyPictureControl > 2, "Unsupported value for MGSControl" );
ROTREPORT( m_uiMGSKeyPictureControl &&
!m_uiCGSSNRRefinementFlag, "MGSControl can only be specified in connection with CGSSNRRefinementFlag=1" );
ROTREPORT( m_uiMGSKeyPictureMotionRefinement > 1, "Unsupported value for MGSKeyPicMotRef" );
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 ) );
ROTREPORT( pcLayer->getNumFGSLayers() != 0.0 && getCGSSNRRefinement(), "MGS and FGS together are not supported" );
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 + -