main() // 主函数
//给H264AVCEncoderTest* pcH264AVCEncoderTest分配空间,后面函数用它调用
H264AVCEncoderTest::create()
//初始化pcH264AVCEncoderTest的成员,主要是编码器的参数配置
pcH264AVCEncoderTest->init()
//给EncoderCodingParameter* m_pcEncoderCodingParameter分配空间
//它是H264AVCEncoderTest *pcH264AVCEncoderTest的成员
EncoderCodingParameter::create( m_pcEncoderCodingParameter )//编码参数
//解析输入命令行,并把相应参数写入EncoderCodingParameter的基类CodingParameter的成员中
m_pcEncoderCodingParameter->init()
//读取配置文件
xReadFromFile( cFilename, rcBitstreamFile )
fopen( rcFilename.c_str(), “r”);encoder.cfg
//先创建每个参数
m_pEncoderLines[uiParLnCount++] = new EncoderConfigLineXXX
//从配置文件里读一行,重复直到文件末尾
xReadLine( f, acTags )
//查找读到的参数对应的m_pEncoderLines,更新值
fclose( f );
//从上面的配置文件读到的参数中得到有几层,和每层配置文件路径
//对每一层
setDependencyId(ui);//设置Did
//读取每一层的配置文件读到如下类中
//EncoderCodingParameter::LayerParametersm_acLayerParameters[n]
xReadLayerFromFile( acLayerConfigName[ui], getLayerParameters(ui) )
//打开配置文件layerX.cfg
//分配空间并初始化参数m_pLayerLines[] ,也是CodingParameter成员
//读取配置文件每行,并更新对应m_pLayerLines的值
//初始化ScalingList
xReadScalMat()
//设置输入输出文件路径
rcLayer.setInputFilename ( (Char*)cInputFilename.c_str() );
rcLayer.setOutputFilename ( (Char*)cOutputFilename.c_str() );
//初始化每个LayerParameters::ResizeParametersm_cResizeParameters
//读取SliceGroup的配置文件
xReadSliceGroupCfg( rcLayer)
//读取ROI配置文件
xReadROICfg( rcLayer)
//关闭配置文件
//设置CGS/MGS的Dependency_Id和Quality_id
//由BaseLayer更新当前Layer的ResizeParameter———-ESS
//对每一层rcLayer = m_pcEncoderCodingParameter->getLayerParameters( uiLayer );
//创建并打开重建输出文件
WriteYuvToFile::create( m_apcWriteYuv[uiLayer] )
m_apcWriteYuv[uiLayer]->init( rcLayer.getOutputFilename() )
//创建并打开读入的视频文件
ReadYuvFile ::create( m_apcReadYuv [uiLayer] )
m_apcReadYuv[uiLayer]->init()
//创建并打开码流文件
WriteBitstreamToFile::create ( m_pcWriteBitstreamToFile )
m_pcWriteBitstreamToFile->init ( m_cEncoderIoParameter.cBitstreamFilename )
注意:
以上三个文件都是H264AVCEncoderTest类的成员
WriteBitstreamToFile* m_pcWriteBitstreamToFile;
WriteYuvToFile* m_apcWriteYuv [MAX_LAYERS];
ReadYuvFile* m_apcReadYuv [MAX_LAYERS];
也用到了辅助IO的成员
EncoderIoParameterm_cEncoderIoParameter;
//给编码器分配空间:它是H264AVCEncoderTest *pcH264AVCEncoderTest的成员
h264::CreaterH264AVCEncoder::create( m_pcH264AVCEncoder )
ParameterSetMng ::create( m_pcParameterSetMng )
BitWriteBuffer ::create( m_pcBitWriteBuffer )
BitCounter ::create( m_pcBitCounter )
NalUnitEncoder ::create( m_pcNalUnitEncoder)
SliceEncoder ::create( m_pcSliceEncoder )
UvlcWriter ::create( m_pcUvlcWriter )
UvlcWriter ::create( m_pcUvlcTester, false )
CabacWriter ::create( m_pcCabacWriter )
MbCoder ::create( m_pcMbCoder )
MbEncoder ::create( m_pcMbEncoder )
LoopFilter ::create( m_pcLoopFilter )
IntraPredictionSearch ::create( m_pcIntraPrediction )
MotionEstimationQuarterPel ::create( m_pcMotionEstimation )
H264AVCEncoder ::create( m_pcH264AVCEncoder )
ControlMngH264AVCEncoder ::create( m_pcControlMng )
ReconstructionBypass ::create( m_pcReconstructionBypass )
QuarterPelFilter ::create( m_pcQuarterPelFilter )
Transform ::create( m_pcTransform )
SampleWeighting ::create( m_pcSampleWeighting )
XDistortion ::create( m_pcXDistortion )
PicEncoder ::create( m_pcPicEncoder )
//每一层的编码器
for( UIntuiLayer = 0; uiLayer