📄 slicereader.cpp
字号:
rpcSH = new SliceHeader ( *pcSPS, *pcPPS );
ROF( rpcSH );
rpcSH->setNalUnitType ( eNalUnitType );
UInt m_uiNextLayerId = 0;
m_uiNextLayerId = uiLayerID;
// if(eNalUnitType==NAL_UNIT_CODED_SLICE_SCALABLE )
if(eNalUnitType==NAL_UNIT_CODED_SLICE_SCALABLE && m_uiNextLayerId != 0)
{
rpcSH->setLayerId ( 1 );
rpcSH->setBaseLayerId(MSYS_UINT_MAX); // will be modified later
}
else
{
rpcSH->setLayerId(0);
rpcSH->setBaseLayerId ( MSYS_UINT_MAX );
}
rpcSH->setTemporalLevel ( uiTemporalLevel );
rpcSH->setQualityLevel ( 0 );
rpcSH->setFirstMbInSlice( 0 );
rpcSH->setFragmentedFlag( false);
UInt uiMaxPocLsb = 1 << rpcSH->getSPS().getLog2MaxPicOrderCntLsb();
rpcSH->setFrameNum( uiFrameNum);
rpcSH->setPicOrderCntLsb( uiPoc % uiMaxPocLsb);
// TMM_INTERLACE{
// rpcSH->setPoc( uiPoc);
if( rpcSH->getPicType() == FRAME )
{
rpcSH->setTopFieldPoc( uiPoc );
rpcSH->setBotFieldPoc( uiPoc );
}
else if ( rpcSH->getPicType() == TOP_FIELD )
{
rpcSH->setTopFieldPoc( uiPoc );
}
else
{
rpcSH->setBotFieldPoc( uiPoc );
}
// TMM_INTERLACE}
rpcSH->setAdaptivePredictionFlag(1);
rpcSH->setDirectSpatialMvPredFlag(false);
rpcSH->setNumRefIdxActiveOverrideFlag( true);
rpcSH->setNumRefIdxActive( LIST_0, 1);
if ( rpcSH->getPicOrderCntLsb() % uiMaxGopSize == 0 || (uiGopSize - ((rpcSH->getPicOrderCntLsb() % uiMaxGopSize) >> (uiMaxDecompositionStages-uiDecompositionStages)) < (unsigned)( 1<<(uiDecompositionStages-uiTemporalLevel) ) ) )
{
rpcSH->setSliceType ( P_SLICE );
if( rpcSH->getPicOrderCntLsb() % (1<<(uiMaxDecompositionStages-uiDecompositionStages+1)) == 0)
rpcSH->setNalRefIdc ( NAL_REF_IDC_PRIORITY_HIGHEST);
else
rpcSH->setNalRefIdc ( NAL_REF_IDC_PRIORITY_HIGH);
}
else
{
rpcSH->setSliceType ( B_SLICE );
if( rpcSH->getPicOrderCntLsb() % (1<<(uiMaxDecompositionStages-uiDecompositionStages+1)) == 0)
rpcSH->setNalRefIdc ( NAL_REF_IDC_PRIORITY_LOW);
else
rpcSH->setNalRefIdc ( NAL_REF_IDC_PRIORITY_LOWEST);
rpcSH->setNumRefIdxActive( LIST_1, 1);
}
//if(eNalUnitType==NAL_UNIT_CODED_SLICE||)
//key picture MMCO for base and enhancement layer
{
if(rpcSH->getPoc() % uiMaxGopSize == 0 || (uiGopSize - ((rpcSH->getPicOrderCntLsb() % uiMaxGopSize) >> (uiMaxDecompositionStages-uiDecompositionStages)) < (unsigned)( 1<<(uiDecompositionStages-uiTemporalLevel) ) ) )
{
UInt index=rpcSH->getPoc() / uiMaxGopSize;
if( index>0 )rpcSH->setAdaptiveRefPicBufferingFlag(true);
else rpcSH->setAdaptiveRefPicBufferingFlag(false);
if(index>1)
{
Bool bNumber2Gop= index >2 ? true : false;
rpcSH->setDefualtMmcoBuffer(uiDecompositionStages,bNumber2Gop);
}
rpcSH->setSliceType(P_SLICE);
rpcSH->setNalRefIdc(NAL_REF_IDC_PRIORITY_HIGHEST);
}
if(rpcSH->getPoc() % uiMaxGopSize == 0 || (uiGopSize - ((rpcSH->getPicOrderCntLsb() % uiMaxGopSize) >> (uiMaxDecompositionStages-uiDecompositionStages)) < (unsigned)( 1<<(uiDecompositionStages-uiTemporalLevel) ) ) )
{
UInt index=rpcSH->getPoc() / uiMaxGopSize;
if( index>1 )
{
rpcSH->getRplrBuffer(LIST_0).setRefPicListReorderingFlag(true);
rpcSH->getRplrBuffer(LIST_0).clear();
//TMM_EC
if ( uiGopSize == 1)
rpcSH->getRplrBuffer(LIST_0).set(0,Rplr(RPLR_NEG,0));
else
rpcSH->getRplrBuffer(LIST_0).set(0,Rplr(RPLR_NEG,uiGopSize/2-1));
}
else
{
rpcSH->getRplrBuffer(LIST_0).setRefPicListReorderingFlag(false);
}
}
}
//weighted prediction
RNOK( rpcSH->getPredWeightTable(LIST_0).init( 64 ) );
RNOK( rpcSH->getPredWeightTable(LIST_1).init( 64 ) );
return Err::m_nOK;
}
//TMM_EC }}
ErrVal
SliceReader::readSliceHeader( NalUnitParser* pcNalUnitParser,
SliceHeader*& rpcSH,
//JVT-P031
UInt uiFirstFragNumMbsInSlice,
Bool bFirstFragFGSCompSep
//~JVT-P031
)
{
NalUnitType eNalUnitType=pcNalUnitParser->getNalUnitType();
NalRefIdc eNalRefIdc=pcNalUnitParser->getNalRefIdc();
UInt uiLayerId=pcNalUnitParser->getLayerId();
UInt uiTemporalLevel=pcNalUnitParser->getTemporalLevel();
UInt uiQualityLevel=pcNalUnitParser->getQualityLevel();
Bool bUseBasePredFlag=pcNalUnitParser->getUseBasePredFlag();
UInt uiFragmentOrder=pcNalUnitParser->getFragmentOrder();
Bool bScalable = ( eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_SCALABLE );
UInt uiFirstMbInSlice;
UInt uiSliceType;
UInt uiPPSId;
SequenceParameterSet* pcSPS;
PictureParameterSet* pcPPS;
//===== read first parameters =====
//JVT-P031
Bool bFGSCycleAlignedFragment = true;
//JVT-V088 LMI {
UInt uiTl0PicIdx;
if( bScalable && pcNalUnitParser->getTl0PicIdxPresentFlag() )
{
RNOK(m_pcHeaderReadIf->getCode(uiTl0PicIdx, 8, "SH: tl0_pic_idx"));
}
//JVT-V088 LMI }
if( uiLayerId == 0 && uiQualityLevel == 0 &&
(eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_SCALABLE || eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE ) )
{
Bool eAdaptiveRefPicMarkingModeFlag = false;
MmcoBuffer eMmcoBaseBuffer;
RNOK( m_pcParameterSetMng ->get ( pcPPS, m_uiPPSId_AVC ) );
RNOK( m_pcParameterSetMng ->get ( pcSPS, m_uiSPSId_AVC ) );
rpcSH = new SliceHeader ( *pcSPS, *pcPPS );
ROF( rpcSH );
//JVT-V088 LMI
if( pcNalUnitParser->getTl0PicIdxPresentFlag() )
rpcSH->setTl0PicIdx ( uiTl0PicIdx );
if( eNalRefIdc != 0)
{
if( bUseBasePredFlag && eNalUnitType != NAL_UNIT_CODED_SLICE_IDR_SCALABLE)
{
RNOK(m_pcHeaderReadIf->getFlag( eAdaptiveRefPicMarkingModeFlag, "DRPM: adaptive_ref_pic_marking_mode_flag"));
if( eAdaptiveRefPicMarkingModeFlag )
{
RNOK( rpcSH->getMmcoBaseBuffer().read( m_pcHeaderReadIf ) );
}
}
}
rpcSH->setNalUnitType ( eNalUnitType );
rpcSH->setNalRefIdc ( eNalRefIdc );
rpcSH->setLayerId ( uiLayerId );
rpcSH->setTemporalLevel ( uiTemporalLevel );
rpcSH->setQualityLevel ( uiQualityLevel );
rpcSH->setLayerBaseFlag ( pcNalUnitParser->getLayerBaseFlag() );
rpcSH->setDiscardableFlag ( pcNalUnitParser->getDiscardableFlag() );
rpcSH->setFragmentedFlag ( pcNalUnitParser->getFragmentedFlag() );
rpcSH->setLastFragmentFlag ( pcNalUnitParser->getLastFragmentFlag() );
rpcSH->setFragmentOrder ( pcNalUnitParser->getFragmentOrder() );
rpcSH->setUseBaseRepresentationFlag( bUseBasePredFlag );
rpcSH->setAdaptiveRefPicMarkingFlag( eAdaptiveRefPicMarkingModeFlag );
rpcSH->setPicOrderCntLsb( m_uiPOC_AVC );
return Err::m_nOK;
}
else
{
RNOK( m_pcHeaderReadIf ->getUvlc( uiFirstMbInSlice, "SH: first_mb_in_slice" ) );
RNOK( m_pcHeaderReadIf ->getUvlc( uiSliceType, "SH: slice_type" ) );
if( uiSliceType > 4 && ! bScalable )
{
uiSliceType -= 5;
}
RNOK( m_pcHeaderReadIf ->getUvlc( uiPPSId, "SH: pic_parameter_set_id" ) );
RNOK( m_pcParameterSetMng ->get ( pcPPS, uiPPSId) );
RNOK( m_pcParameterSetMng ->get ( pcSPS, pcPPS->getSeqParameterSetId() ) );
}
//===== create and initialize slice header =====
rpcSH = new SliceHeader ( *pcSPS, *pcPPS );
ROF( rpcSH );
rpcSH->setNalUnitType ( eNalUnitType );
rpcSH->setNalRefIdc ( eNalRefIdc );
rpcSH->setLayerId ( uiLayerId );
rpcSH->setTemporalLevel ( uiTemporalLevel );
rpcSH->setQualityLevel ( uiQualityLevel );
rpcSH->setLayerBaseFlag ( pcNalUnitParser->getLayerBaseFlag() );
rpcSH->setUseBaseRepresentationFlag ( bUseBasePredFlag );
rpcSH->setDiscardableFlag ( pcNalUnitParser->getDiscardableFlag() );
rpcSH->setFragmentedFlag ( pcNalUnitParser->getFragmentedFlag() );
rpcSH->setLastFragmentFlag( pcNalUnitParser->getLastFragmentFlag() );
rpcSH->setFragmentOrder ( pcNalUnitParser->getFragmentOrder() );
//JVT-V088 LMI
if( bScalable && pcNalUnitParser->getTl0PicIdxPresentFlag() )
rpcSH->setTl0PicIdx ( uiTl0PicIdx );
rpcSH->setFirstMbInSlice( uiFirstMbInSlice);
rpcSH->setSliceType ( SliceType( uiSliceType ) );
rpcSH->setFGSCycleAlignedFragment( bFGSCycleAlignedFragment );
//JVT-P031
if ( uiFragmentOrder > 0 )
{
rpcSH->setFgsComponentSep(bFirstFragFGSCompSep);
rpcSH->setNumMbsInSlice(uiFirstFragNumMbsInSlice);
}
//~JVT-P031
//===== read remaining parameters =====
RNOK( rpcSH->read( m_pcHeaderReadIf ) );
if ( eNalUnitType == NAL_UNIT_CODED_SLICE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_IDR )
{
m_uiPPSId_AVC = uiPPSId;
m_uiSPSId_AVC = pcPPS->getSeqParameterSetId();
m_uiPOC_AVC = rpcSH->getPicOrderCntLsb();
}
//JVT-S036 lsj end
//--ICU/ETRI FMO Implementation
rpcSH->FMOInit();
// JVT-S054 (2) (ADD) ->
if (rpcSH->getNumMbsInSlice() != 0)
rpcSH->setLastMbInSlice(rpcSH->getFMO()->getLastMbInSlice(uiFirstMbInSlice, rpcSH->getNumMbsInSlice()));
else
// JVT-S054 (2) (ADD) <-
rpcSH->setLastMbInSlice(rpcSH->getFMO()->getLastMBInSliceGroup(rpcSH->getFMO()->getSliceGroupId(uiFirstMbInSlice)));
if ( !rpcSH->getSPS().getFrameMbsOnlyFlag() )
{
if ( (!rpcSH->getFieldPicFlag()) && (rpcSH->getSPS().getMbAdaptiveFrameFieldFlag()) )
{
rpcSH->setFirstMbInSlice ( uiFirstMbInSlice << 1 );
}
}
return Err::m_nOK;
}
//JVT-S036 lsj start
ErrVal
SliceReader::readSliceHeaderSuffix( NalUnitType eNalUnitType,
NalRefIdc eNalRefIdc,
UInt uiLayerId,
UInt uiQualityLevel,
Bool bUseBasePredFlag,
SliceHeader* pcSliceHeader
)
{
//===== read first parameters =====
Bool eAdaptiveRefPicMarkingModeFlag = false;
if( eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_SCALABLE ||
eNalUnitType == NAL_UNIT_CODED_SLICE_SCALABLE )
{
if( uiLayerId == 0 && uiQualityLevel == 0 )
{
if( eNalRefIdc != 0)
{
if( bUseBasePredFlag && eNalUnitType != NAL_UNIT_CODED_SLICE_IDR_SCALABLE )
{
RNOK(m_pcHeaderReadIf->getFlag( eAdaptiveRefPicMarkingModeFlag, "DRPM: adaptive_ref_pic_marking_mode_flag"));
if( eAdaptiveRefPicMarkingModeFlag )
{
RNOK( pcSliceHeader->getMmcoBaseBuffer().read( m_pcHeaderReadIf ) );
}
}
}
pcSliceHeader->setUseBaseRepresentationFlag( bUseBasePredFlag ); //bug-fix suffix shenqiu
pcSliceHeader->setAdaptiveRefPicMarkingFlag( eAdaptiveRefPicMarkingModeFlag );
return Err::m_nOK;
}
else
return Err::m_nERR;
}
else
return Err::m_nERR;
}
//prefix unit{{
ErrVal
SliceReader::readSliceHeaderPrefix( NalUnitType eNalUnitType,
NalRefIdc eNalRefIdc,
UInt uiLayerId,
UInt uiQualityLevel,
Bool bUseBasePredFlag,
SliceHeader* pcSliceHeader
)
{
//===== read first parameters =====
Bool eAdaptiveRefPicMarkingModeFlag = false;
if( uiLayerId == 0 && uiQualityLevel == 0 )
{
if( eNalRefIdc != 0)
{
if( bUseBasePredFlag && eNalUnitType != NAL_UNIT_CODED_SLICE_IDR_SCALABLE )
{
RNOK(m_pcHeaderReadIf->getFlag( eAdaptiveRefPicMarkingModeFlag, "DRPM: adaptive_ref_pic_marking_mode_flag"));
if( eAdaptiveRefPicMarkingModeFlag )
{
RNOK( pcSliceHeader->getMmcoBaseBuffer().read( m_pcHeaderReadIf ) );
}
}
}
pcSliceHeader->setUseBaseRepresentationFlag( bUseBasePredFlag );
pcSliceHeader->setAdaptiveRefPicMarkingFlag( eAdaptiveRefPicMarkingModeFlag );
return Err::m_nOK;
}
else
return Err::m_nERR;
}
//prefix unit}}
//JVT-S036 lsj end
H264AVC_NAMESPACE_END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -