📄 sliceheaderbase.cpp
字号:
Void
DecRefPicMarking::copy( const DecRefPicMarking& rcDecRefPicMarking )
{
StatBuf<MmcoCommand,33>::copy( rcDecRefPicMarking );
m_bDecRefBasePicMarking = rcDecRefPicMarking.m_bDecRefBasePicMarking;
m_bAdaptiveRefPicMarkingModeFlag = rcDecRefPicMarking.m_bAdaptiveRefPicMarkingModeFlag;
}
ErrVal
DecRefPicMarking::write( HeaderSymbolWriteIf& rcWriteIf ) const
{
if( m_bDecRefBasePicMarking )
{
RNOK( rcWriteIf.writeFlag( m_bAdaptiveRefPicMarkingModeFlag, "DPRM: adaptive_ref_base_pic_marking_mode_flag" ) );
}
else
{
RNOK( rcWriteIf.writeFlag( m_bAdaptiveRefPicMarkingModeFlag, "DPRM: adaptive_ref_pic_marking_mode_flag" ) );
}
ROFRS ( m_bAdaptiveRefPicMarkingModeFlag, Err::m_nOK );
Bool bEnd = false;
for( UInt uiIndex = 0; !bEnd; uiIndex++ )
{
RNOK( get( uiIndex ).write( rcWriteIf, m_bDecRefBasePicMarking, bEnd ) );
}
return Err::m_nOK;
}
ErrVal
DecRefPicMarking::read( HeaderSymbolReadIf& rcReadIf )
{
if( m_bDecRefBasePicMarking )
{
RNOK( rcReadIf.getFlag( m_bAdaptiveRefPicMarkingModeFlag, "DPRM: adaptive_ref_base_pic_marking_mode_flag" ) );
}
else
{
RNOK( rcReadIf.getFlag( m_bAdaptiveRefPicMarkingModeFlag, "DPRM: adaptive_ref_pic_marking_mode_flag" ) );
}
ROFRS ( m_bAdaptiveRefPicMarkingModeFlag, Err::m_nOK );
Bool bEnd = false;
for( UInt uiIndex = 0; !bEnd; uiIndex++ )
{
RNOK( get( uiIndex ).read( rcReadIf, m_bDecRefBasePicMarking, bEnd ) );
}
return Err::m_nOK;
}
PredWeight::PredWeight()
: m_bLumaWeightFlag ( false )
, m_iLumaWeight ( 0 )
, m_iLumaOffset ( 0 )
, m_bChromaWeightFlag ( false )
, m_iChromaCbWeight ( 0 )
, m_iChromaCbOffset ( 0 )
, m_iChromaCrWeight ( 0 )
, m_iChromaCrOffset ( 0 )
{
}
PredWeight::PredWeight( const PredWeight& rcPredWeight )
: m_bLumaWeightFlag ( rcPredWeight.m_bLumaWeightFlag )
, m_iLumaWeight ( rcPredWeight.m_iLumaWeight )
, m_iLumaOffset ( rcPredWeight.m_iLumaOffset )
, m_bChromaWeightFlag ( rcPredWeight.m_bChromaWeightFlag )
, m_iChromaCbWeight ( rcPredWeight.m_iChromaCbWeight )
, m_iChromaCbOffset ( rcPredWeight.m_iChromaCbOffset )
, m_iChromaCrWeight ( rcPredWeight.m_iChromaCrWeight )
, m_iChromaCrOffset ( rcPredWeight.m_iChromaCrOffset )
{
}
PredWeight::~PredWeight()
{
}
Void
PredWeight::copy( const PredWeight& rcPredWeight )
{
m_bLumaWeightFlag = rcPredWeight.m_bLumaWeightFlag;
m_iLumaWeight = rcPredWeight.m_iLumaWeight;
m_iLumaOffset = rcPredWeight.m_iLumaOffset;
m_bChromaWeightFlag = rcPredWeight.m_bChromaWeightFlag;
m_iChromaCbWeight = rcPredWeight.m_iChromaCbWeight;
m_iChromaCbOffset = rcPredWeight.m_iChromaCbOffset;
m_iChromaCrWeight = rcPredWeight.m_iChromaCrWeight;
m_iChromaCrOffset = rcPredWeight.m_iChromaCrOffset;
}
ErrVal
PredWeight::write( HeaderSymbolWriteIf& rcWriteIf ) const
{
RNOK ( rcWriteIf.writeFlag( m_bLumaWeightFlag, "PWT: luma_weight_flag" ) );
if( m_bLumaWeightFlag )
{
RNOK( rcWriteIf.writeSvlc( m_iLumaWeight, "PWT: luma_weight" ) );
RNOK( rcWriteIf.writeSvlc( m_iLumaOffset, "PWT: luma_offset" ) );
}
RNOK ( rcWriteIf.writeFlag( m_bChromaWeightFlag, "PWT: chroma_weight_flag" ) );
if( m_bChromaWeightFlag )
{
RNOK( rcWriteIf.writeSvlc( m_iChromaCbWeight, "PWT: chroma_weight (Cb)" ) );
RNOK( rcWriteIf.writeSvlc( m_iChromaCbOffset, "PWT: chroma_offset (Cb)" ) );
RNOK( rcWriteIf.writeSvlc( m_iChromaCrWeight, "PWT: chroma_weight (Cr)" ) );
RNOK( rcWriteIf.writeSvlc( m_iChromaCrOffset, "PWT: chroma_offset (Cr)" ) );
}
return Err::m_nOK;
}
ErrVal
PredWeight::read( HeaderSymbolReadIf& rcReadIf, UInt uiLumaLog2WeightDenom, UInt uiChromaLog2WeightDenom )
{
RNOK ( rcReadIf.getFlag( m_bLumaWeightFlag, "PWT: luma_weight_flag" ) );
if( m_bLumaWeightFlag )
{
RNOK( rcReadIf.getSvlc( m_iLumaWeight, "PWT: luma_weight" ) );
RNOK( rcReadIf.getSvlc( m_iLumaOffset, "PWT: luma_offset" ) );
ROT ( m_iLumaWeight < -128 || m_iLumaWeight > 127 );
ROT ( m_iLumaOffset < -128 || m_iLumaOffset > 127 );
}
else
{
m_iLumaWeight = ( 1 << uiLumaLog2WeightDenom );
m_iLumaOffset = 0;
}
RNOK ( rcReadIf.getFlag( m_bChromaWeightFlag, "PWT: chroma_weight_flag" ) );
if( m_bChromaWeightFlag )
{
RNOK( rcReadIf.getSvlc( m_iChromaCbWeight, "PWT: chroma_weight (Cb)" ) );
RNOK( rcReadIf.getSvlc( m_iChromaCbOffset, "PWT: chroma_offset (Cb)" ) );
RNOK( rcReadIf.getSvlc( m_iChromaCrWeight, "PWT: chroma_weight (Cr)" ) );
RNOK( rcReadIf.getSvlc( m_iChromaCrOffset, "PWT: chroma_offset (Cr)" ) );
ROT ( m_iChromaCbWeight < -128 || m_iChromaCbWeight > 127 );
ROT ( m_iChromaCbOffset < -128 || m_iChromaCbOffset > 127 );
ROT ( m_iChromaCrWeight < -128 || m_iChromaCrWeight > 127 );
ROT ( m_iChromaCrOffset < -128 || m_iChromaCrOffset > 127 );
}
else
{
m_iChromaCbWeight = m_iChromaCrWeight = ( 1 << uiChromaLog2WeightDenom );
m_iChromaCbOffset = m_iChromaCrOffset = 0;
}
return Err::m_nOK;
}
Bool
PredWeight::operator == (const h264::PredWeight &rcPredWeight) const
{
ROFRS( m_bLumaWeightFlag == rcPredWeight.m_bLumaWeightFlag, false );
ROFRS( m_iLumaWeight == rcPredWeight.m_iLumaWeight, false );
ROFRS( m_iLumaOffset == rcPredWeight.m_iLumaOffset, false );
ROFRS( m_bChromaWeightFlag == rcPredWeight.m_bChromaWeightFlag, false );
ROFRS( m_iChromaCbWeight == rcPredWeight.m_iChromaCbWeight, false );
ROFRS( m_iChromaCbOffset == rcPredWeight.m_iChromaCbOffset, false );
ROFRS( m_iChromaCrWeight == rcPredWeight.m_iChromaCrWeight, false );
ROFRS( m_iChromaCrOffset == rcPredWeight.m_iChromaCrOffset, false );
return true;
}
Bool
PredWeight::operator != (const h264::PredWeight &rcPredWeight) const
{
return ! ( *this == rcPredWeight );
}
Int
PredWeight::xRandom( Int iMin, Int iMax )
{
Int iRange = iMax - iMin + 1;
Int iValue = rand() % iRange;
return iMin + iValue;
}
ErrVal
PredWeight::initRandomly()
{
m_bLumaWeightFlag = ( ( rand() & 1 ) == 0 );
m_bChromaWeightFlag = ( ( rand() & 1 ) == 0 );
if( m_bLumaWeightFlag )
{
m_iLumaWeight = xRandom( -64, 63 );
m_iLumaOffset = xRandom( -64, 63 );
}
if( m_bChromaWeightFlag )
{
m_iChromaCbWeight = xRandom( -64, 63 );
m_iChromaCbOffset = xRandom( -64, 63 );
m_iChromaCrWeight = xRandom( -64, 63 );
m_iChromaCrOffset = xRandom( -64, 63 );
}
return Err::m_nOK;
}
ErrVal
PredWeight::initWeights( Int iLumaWeight, Int iCbWeight, Int iCrWeight )
{
m_iLumaWeight = iLumaWeight;
m_iChromaCbWeight = iCbWeight;
m_iChromaCrWeight = iCrWeight;
return Err::m_nOK;
}
ErrVal
PredWeight::initOffsets( Int iLumaOffset, Int iCbOffset, Int iCrOffset )
{
m_iLumaOffset = iLumaOffset;
m_iChromaCbOffset = iCbOffset;
m_iChromaCrOffset = iCrOffset;
return Err::m_nOK;
}
ErrVal
PredWeight::setOffsets( const Double* padOffsets )
{
Int iLuma = (Int)padOffsets[ 0 ];
Int iCb = (Int)padOffsets[ 1 ];
Int iCr = (Int)padOffsets[ 2 ];
RNOK( initOffsets( iLuma, iCb, iCr ) );
setLumaWeightFlag ( iLuma != 0 );
setChromaWeightFlag ( iCb != 0 || iCr != 0 );
return Err::m_nOK;
}
ErrVal
PredWeight::setWeights( const Double* padWeights, Int iLumaScale, Int iChromaScale )
{
Int iLuma = (Int)padWeights[ 0 ];
Int iCb = (Int)padWeights[ 1 ];
Int iCr = (Int)padWeights[ 2 ];
RNOK( initWeights( iLuma, iCb, iCr ) );
setLumaWeightFlag ( iLuma != iLumaScale );
setChromaWeightFlag ( iCb != iChromaScale || iCr != iChromaScale );
return Err::m_nOK;
}
ErrVal
PredWeight::getOffsets( Double* padOffsets )
{
padOffsets[ 0 ] = (Double) m_iLumaOffset;
padOffsets[ 1 ] = (Double) m_iChromaCbOffset;
padOffsets[ 2 ] = (Double) m_iChromaCrOffset;
return Err::m_nOK;
}
ErrVal
PredWeight::getWeights( Double* padWeights )
{
padWeights[ 0 ] = (Double) m_iLumaWeight;
padWeights[ 1 ] = (Double) m_iChromaCbWeight;
padWeights[ 2 ] = (Double) m_iChromaCrWeight;
return Err::m_nOK;
}
Void
PredWeight::scaleL1Weight( Int iDistScaleFactor )
{
iDistScaleFactor >>= 2;
if( iDistScaleFactor > 128 || iDistScaleFactor < -64 )
{
iDistScaleFactor = 32;
}
m_iLumaWeight = iDistScaleFactor;
m_iChromaCbWeight = iDistScaleFactor;
m_iChromaCrWeight = iDistScaleFactor;
}
Void
PredWeight::scaleL0Weight( const PredWeight& rcPredWeightL1 )
{
m_iLumaWeight = 64 - rcPredWeightL1.m_iLumaWeight;
m_iChromaCbWeight = 64 - rcPredWeightL1.m_iChromaCbWeight;
m_iChromaCrWeight = 64 - rcPredWeightL1.m_iChromaCrWeight;
}
PredWeightTable::PredWeightTable()
{
}
PredWeightTable::PredWeightTable( const PredWeightTable& rcPredWeightTable )
: StatBuf<PredWeight,32>( rcPredWeightTable )
{
}
PredWeightTable::~PredWeightTable()
{
}
ErrVal
PredWeightTable::initRandomly()
{
for( UInt uiIndex = 0; uiIndex < size(); uiIndex++ )
{
RNOK( get( uiIndex ).initRandomly() );
}
return Err::m_nOK;
}
ErrVal
PredWeightTable::initDefaults( UInt uiLumaWeightDenom, UInt uiChromaWeightDenom )
{
Int iLumaWeight = ( 1 << uiLumaWeightDenom );
Int iChromaWeight = ( 1 << uiChromaWeightDenom );
Int iLumaOffset = 0;
Int iChromaOffset = 0;
for( UInt uiIndex = 0; uiIndex < size(); uiIndex++ )
{
RNOK( get( uiIndex ).initWeights( iLumaWeight, iChromaWeight, iChromaWeight ) );
RNOK( get( uiIndex ).initOffsets( iLumaOffset, iChromaOffset, iChromaOffset ) );
}
return Err::m_nOK;
}
ErrVal
PredWeightTable::setOffsets( const Double (*padOffsets)[3] )
{
for( UInt uiIndex = 0; uiIndex < size(); uiIndex++ )
{
RNOK( get( uiIndex ).setOffsets( padOffsets[ uiIndex ] ) );
}
return Err::m_nOK;
}
ErrVal
PredWeightTable::setWeights( const Double (*padWeights)[3], Int iLumaScale, Int iChromaScale )
{
for( UInt uiIndex = 0; uiIndex < size(); uiIndex++ )
{
RNOK( get( uiIndex ).setWeights( padWeights[ uiIndex ], iLumaScale, iChromaScale ) );
}
return Err::m_nOK;
}
Void
PredWeightTable::clear()
{
setAll( PredWeight() );
}
Void
PredWeightTable::copy( const PredWeightTable& rcPredWeightTable )
{
StatBuf<PredWeight,32>::copy( rcPredWeightTable );
}
ErrVal
PredWeightTable::write( HeaderSymbolWriteIf& rcWriteIf, UInt uiNumRefIdxActiveMinus1 ) const
{
for( UInt uiIndex = 0; uiIndex <= uiNumRefIdxActiveMinus1; uiIndex++ )
{
RNOK( get( uiIndex ).write( rcWriteIf ) );
}
return Err::m_nOK;
}
ErrVal
PredWeightTable::read( HeaderSymbolReadIf& rcReadIf, UInt uiNumRefIdxActiveMinus1, UInt uiLumaLog2WeightDenom, UInt uiChromaLog2WeightDenom )
{
for( UInt uiIndex = 0; uiIndex <= uiNumRefIdxActiveMinus1; uiIndex++ )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -