📄 gopencoder.cpp
字号:
ErrVal
MCTFEncoder::initParameterSets( const SequenceParameterSet& rcSPS,
const PictureParameterSet& rcPPSLP,
const PictureParameterSet& rcPPSHP )
{
//===== set references =====
m_pcSPS = &rcSPS;
m_pcPPSLP = &rcPPSLP;
m_pcPPSHP = &rcPPSHP;
m_pcSPS_FGS = &rcSPS;
m_pcPPSLP_FGS = &rcPPSLP;
m_pcPPSHP_FGS = &rcPPSHP;
//===== get and set relevant parameters =====
UInt uiMaxDPBSize = rcSPS.getMaxDPBSize ();
m_uiFrameWidthInMb = rcSPS.getFrameWidthInMbs ();
m_uiFrameHeightInMb = rcSPS.getFrameHeightInMbs ();
m_uiMbNumber = m_uiFrameWidthInMb * m_uiFrameHeightInMb;
m_uiMaxGOPSize = downround2powerof2( uiMaxDPBSize );
//===== re-allocate dynamic memory =====
RNOK( xDeleteData() );
RNOK( xCreateData( rcSPS ) );
//===== initialize some parameters =====
m_bInitDone = true;
m_bFirstGOPCoded = false;
m_uiFrameCounter = 0;
m_uiFrameNum = 0;
m_uiGOPNumber = 0;
::memset( m_abIsRef, 0x00, sizeof( m_abIsRef ) );
return Err::m_nOK;
}
ErrVal
MCTFEncoder::addParameterSetBits( UInt uiParameterSetBits )
{
m_uiParameterSetBits += uiParameterSetBits;
return Err::m_nOK;
}
ErrVal
MCTFEncoder::xCreateData( const SequenceParameterSet& rcSPS )
{
UInt uiIndex;
//========== CREATE FRAME MEMORIES ==========
ROFS ( ( m_papcFrame = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
ROFS ( ( m_papcOrgFrame = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
if( m_uiClosedLoopMode == 2 )
{
ROFS ( ( m_papcBQFrame = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
}
if( m_uiQualityLevelForPrediction < 3 || m_bUseDiscardableUnit) //JVT-P031
{
ROFS ( ( m_papcCLRecFrame = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
}
ROFS ( ( m_papcResidual = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
ROFS ( ( m_papcSubband = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
//-- JVT-R091
ROFS ( ( m_papcSmoothedFrame = new IntFrame* [ m_uiMaxGOPSize + 1 ] ) );
//--
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
ROFS ( ( m_papcFrame [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
ROFS ( ( m_papcOrgFrame [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvFullPelBufferCtrl ) ) );
if( m_papcBQFrame )
{
ROFS(( m_papcBQFrame [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvFullPelBufferCtrl ) ) );
}
if( m_papcCLRecFrame )
{
ROFS(( m_papcCLRecFrame [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
}
//-- JVT-R091
if ( m_papcSmoothedFrame )
{
ROFS(( m_papcSmoothedFrame [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
}
//--
ROFS ( ( m_papcResidual [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
ROFS ( ( m_papcSubband [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_papcFrame [ uiIndex ] ->init () );
RNOK ( m_papcOrgFrame [ uiIndex ] ->init () );
if( m_papcBQFrame )
{
RNOK( m_papcBQFrame [ uiIndex ] ->init () );
}
if( m_papcCLRecFrame )
{
RNOK( m_papcCLRecFrame [ uiIndex ] ->init () );
}
//-- JVT-R091
if ( m_papcSmoothedFrame )
{
RNOK( m_papcSmoothedFrame [ uiIndex ] ->init () );
}
//--
RNOK ( m_papcResidual [ uiIndex ] ->init () );
RNOK ( m_papcSubband [ uiIndex ] ->init () );
}
for( uiIndex = 0; uiIndex < NUM_TMP_FRAMES; uiIndex++ )
{
ROFS ( ( m_apcFrameTemp [ uiIndex ] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_apcFrameTemp [ uiIndex ] ->init () );
}
for( uiIndex = 0; uiIndex < 2; uiIndex++ )
{
for( UInt uiLayerIdx = 0; uiLayerIdx < 4; uiLayerIdx ++ )
{
ROFS ( ( m_aapcFGSRecon[uiIndex][uiLayerIdx] = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_aapcFGSRecon[uiIndex][uiLayerIdx] ->init () );
}
}
ROFS ( ( m_aapcFGSPredFrame = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_aapcFGSPredFrame ->init () );
ROFS ( ( m_pcLowPassBaseReconstruction = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_pcLowPassBaseReconstruction ->init () );
ROFS ( ( m_pcAnchorFrameOriginal = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_pcAnchorFrameOriginal ->init () );
ROFS ( ( m_pcAnchorFrameReconstructed = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_pcAnchorFrameReconstructed ->init () );
ROFS ( ( m_pcBaseLayerFrame = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_pcBaseLayerFrame ->init () );
ROFS ( ( m_pcBaseLayerResidual = new IntFrame( *m_pcYuvFullPelBufferCtrl,
*m_pcYuvHalfPelBufferCtrl ) ) );
RNOK ( m_pcBaseLayerResidual ->init () );
//========== CREATE MACROBLOCK DATA MEMORIES ==========
ROFS ( ( m_pacControlData = new ControlData[ m_uiMaxGOPSize + 1 ] ) );
ROFS ( ( m_pacControlDataEL = new ControlData[ m_uiMaxGOPSize + 1 ] ) );
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
MbDataCtrl* pcMbDataCtrl = 0;
ROFS ( ( pcMbDataCtrl = new MbDataCtrl () ) );
RNOK ( pcMbDataCtrl ->init ( rcSPS ) );
RNOK ( m_pacControlData[ uiIndex ] . setMbDataCtrl ( pcMbDataCtrl ) );
RNOK ( m_pacControlData[ uiIndex ] .initFGSData ( m_uiFrameWidthInMb * m_uiFrameHeightInMb ) );
MbDataCtrl* pcMbDataCtrlEL = 0;
ROFS ( ( pcMbDataCtrlEL = new MbDataCtrl () ) );
RNOK ( pcMbDataCtrlEL ->init ( rcSPS ) );
RNOK ( m_pacControlDataEL[ uiIndex ] . setMbDataCtrl ( pcMbDataCtrlEL ) );
RNOK ( m_pacControlDataEL[ uiIndex ] .initFGSData ( m_uiFrameWidthInMb * m_uiFrameHeightInMb ) );
Bool bLowPass = ( ( uiIndex % ( 1 << m_uiDecompositionStages ) ) == 0 );
SliceHeader* pcSliceHeader = 0;
ROFS ( ( pcSliceHeader = new SliceHeader ( *m_pcSPS, bLowPass ? *m_pcPPSLP : *m_pcPPSHP ) ) );
RNOK ( m_pacControlData[ uiIndex ] . setSliceHeader ( pcSliceHeader ) );
// ICU/ETRI FGS_MOT_USE
SliceHeader* pcSliceHeaderEL = 0;
ROFS ( ( pcSliceHeaderEL = new SliceHeader ( *m_pcSPS, bLowPass ? *m_pcPPSLP : *m_pcPPSHP ) ) );
RNOK ( m_pacControlDataEL[ uiIndex ] . setSliceHeader ( pcSliceHeaderEL ) );
if( m_uiClosedLoopMode == 2 )
{
RNOK( m_pacControlData[ uiIndex ] .initBQData ( m_uiFrameWidthInMb * m_uiFrameHeightInMb ) );
// ICU/ETRI FGS_MOT_USE
RNOK( m_pacControlDataEL[ uiIndex ] .initBQData ( m_uiFrameWidthInMb * m_uiFrameHeightInMb ) );
}
m_pacControlData[ uiIndex ].getMbDataCtrl()->initFgsBQData(m_uiFrameWidthInMb * m_uiFrameHeightInMb);
m_pacControlDataEL[ uiIndex ].getMbDataCtrl()->initFgsBQData(m_uiFrameWidthInMb * m_uiFrameHeightInMb);
}
ROFS ( ( m_pcBaseLayerCtrl = new MbDataCtrl() ) );
RNOK ( m_pcBaseLayerCtrl ->init ( rcSPS ) );
ROFS ( ( m_pcBaseLayerCtrlEL = new MbDataCtrl() ) );
RNOK ( m_pcBaseLayerCtrlEL ->init ( rcSPS ) );
//========== CREATE UPDATE WEIGHTS ARRAY and WRITE BUFFER ==========
UInt uiNum4x4Blocks = m_uiFrameWidthInMb * m_uiFrameHeightInMb * 4 * 4;
m_uiWriteBufferSize = 3 * ( uiNum4x4Blocks * 4 * 4 );
ROFS( ( m_pucWriteBuffer = new UChar [ m_uiWriteBufferSize ] ) );
ROT ( m_cDownConvert .init ( m_uiFrameWidthInMb<<4, m_uiFrameHeightInMb<<4 ) );
RNOK( m_pcRQFGSEncoder ->initSPS( rcSPS ) );
//S051{
ROFRS( m_auiFrameBits = new UInt[m_uiTotalFrame], Err::m_nERR );
memset( m_auiFrameBits,0,sizeof(UInt)*m_uiTotalFrame);
if(m_bEncSIP)
{
FILE* file=fopen(m_cInSIPFileName.c_str(),"rt");
if(file==NULL)
{
printf("\nCan't open SIP file %s",m_cInSIPFileName.c_str());
return Err::m_nOK;
}
while(!feof(file))
{
UInt tmp;
fscanf(file,"%d",&tmp);
m_cPOCList.push_back(tmp);
}
fclose(file);
}
//S051}
return Err::m_nOK;
}
ErrVal
MCTFEncoder::xDeleteData()
{
UInt uiIndex;
//========== DELETE FRAME MEMORIES ==========
if( m_papcFrame )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcFrame[ uiIndex ] )
{
//JVT-R057 LA-RDO{
if(m_bLARDOEnable)
m_papcFrame[uiIndex]->uninitChannelDistortion();
//JVT-R057 LA-RDO}
RNOK( m_papcFrame[ uiIndex ]->uninit() );
delete m_papcFrame[ uiIndex ];
m_papcFrame[ uiIndex ] = 0;
}
}
delete [] m_papcFrame;
m_papcFrame = 0;
}
if( m_papcOrgFrame )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcOrgFrame[ uiIndex ] )
{
RNOK( m_papcOrgFrame[ uiIndex ]->uninit() );
delete m_papcOrgFrame[ uiIndex ];
m_papcOrgFrame[ uiIndex ] = 0;
}
}
delete [] m_papcOrgFrame;
m_papcOrgFrame = 0;
}
if( m_papcBQFrame )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcBQFrame[ uiIndex ] )
{
RNOK( m_papcBQFrame[ uiIndex ]->uninit() );
delete m_papcBQFrame[ uiIndex ];
m_papcBQFrame[ uiIndex ] = 0;
}
}
delete [] m_papcBQFrame;
m_papcBQFrame = 0;
}
if( m_papcCLRecFrame )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcCLRecFrame[ uiIndex ] )
{
RNOK( m_papcCLRecFrame[ uiIndex ]->uninit() );
delete m_papcCLRecFrame[ uiIndex ];
m_papcCLRecFrame[ uiIndex ] = 0;
}
}
delete [] m_papcCLRecFrame;
m_papcCLRecFrame = 0;
}
//-- JVT-R091
if ( m_papcSmoothedFrame )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcSmoothedFrame[ uiIndex ] )
{
RNOK( m_papcSmoothedFrame[ uiIndex ]->uninit() );
delete m_papcSmoothedFrame[ uiIndex ];
m_papcSmoothedFrame[ uiIndex ] = 0;
}
}
delete [] m_papcSmoothedFrame;
m_papcSmoothedFrame = 0;
}
//--
if( m_papcResidual )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcResidual[ uiIndex ] )
{
RNOK( m_papcResidual[ uiIndex ]->uninit() );
delete m_papcResidual[ uiIndex ];
m_papcResidual[ uiIndex ] = 0;
}
}
delete [] m_papcResidual;
m_papcResidual = 0;
}
if( m_papcSubband )
{
for( uiIndex = 0; uiIndex <= m_uiMaxGOPSize; uiIndex++ )
{
if( m_papcSubband[ uiIndex ] )
{
RNOK( m_papcSubband[ uiIndex ]->uninit() );
delete m_papcSubband[ uiIndex ];
m_papcSubband[ uiIndex ] = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -