⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encoder.cpp

📁 网络MPEG4IP流媒体开发源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				//rgSpriteMode[iObj] = -1;			}			readBoolParam(&par, "Trace.CreateFile.Enable", iObj, &rgbTrace[iObj]);			readBoolParam(&par, "Trace.DetailedDump.Enable", iObj, &rgbDumpMB[iObj]);#ifndef __TRACE_AND_STATS_			if(rgbTrace[iObj])			{				printf("Warning: this encoder will not generate trace information.\n");				printf("If you want trace information, re-compile with __TRACE_AND_STATS_ defined.\n");			}#endif			readBoolParam(&par, "Motion.SkippedMB.Enable", iObj, &rgbAllowSkippedPMBs[iObj]);			// parameters that can be different for each scalability layer			Int iLayer, iLayerCount;			if(rgbScalability[iObj]!=NO_SCALABILITY)				iLayerCount = 2;			else				iLayerCount = 1;			for(iLayer = 0; iLayer<iLayerCount; iLayer++)			{				Int iLayerObj = iObj + iLayer * nVO;				// rate control				GetSVal(&par, "RateControl.Type", iLayerObj, &pchTmp);				if(strcmp(pchTmp, "None")==0)					rguiRateControl [iLayer][iObj] = 0;				else if(strcmp(pchTmp, "MP4")==0)					rguiRateControl [iLayer][iObj] = RC_MPEG4;				else if(strcmp(pchTmp, "TM5")==0)					rguiRateControl [iLayer][iObj] = RC_TM5;				else					fatal_error("Unknown rate control type");				// bit budget				GetIVal(&par, "RateControl.BitsPerVOP", iLayerObj, (Int *)&(rguiBitsBudget[iLayer][iObj]));				Bool bRVLCEnable, bDPEnable, bVPEnable;				readBoolParam(&par, "ErrorResil.RVLC.Enable", iLayerObj, &bRVLCEnable);				readBoolParam(&par, "ErrorResil.DataPartition.Enable", iLayerObj, &bDPEnable);				readBoolParam(&par, "ErrorResil.VideoPacket.Enable", iLayerObj, &bVPEnable);								rgbErrorResilientDisable [iLayer][iObj] = bVPEnable ? (iLayer!=0) : TRUE;				rgbReversibleVlc [iLayer] [iObj] = bRVLCEnable ? (iLayer==0) : FALSE;				rgbDataPartitioning [iLayer][iObj] = bDPEnable ? (iLayer==0) : FALSE;				if(rgbErrorResilientDisable [BASE_LAYER][iObj])					rgiBinaryAlphaRR [iObj] = -1;				GetIVal(&par, "ErrorResil.VideoPacket.Length", iLayerObj, &rgiVPBitTh[iLayer][iObj]);				if(rgbErrorResilientDisable [iLayer][iObj])					rgiVPBitTh [iLayer][iObj] = -1;				readBoolParam(&par, "Motion.Interlaced.Enable", iLayerObj, &rgbInterlacedCoding [iLayer][iObj]);				GetSVal(&par, "Quant.Type", iLayerObj, &pchTmp);				if(strcmp(pchTmp, "H263")==0)					rgfQuant[iLayer][iObj] = Q_H263;				else if(strcmp(pchTmp, "MPEG")==0)					rgfQuant[iLayer][iObj] = Q_MPEG;				else					fatal_error("Unknown quantizer type");				readBoolParam(&par, "Texture.QuantMatrix.Intra.Enable", iLayerObj, &rgbLoadIntraMatrix [iLayer][iObj]);				if(rgbLoadIntraMatrix [iLayer][iObj])				{					Double *pdTmp;					Int iCount;					GetAVal(&par, "Texture.QuantMatrix.Intra", iLayerObj, &pdTmp, &iCount);					fatal_error("Wrong number of intra quant matrix values (should be 64)", iCount<=64);					Int i;					for(i=0; i<iCount; i++)						rgppiIntraQuantizerMatrix[iLayer][iObj][i] = (Int)pdTmp[i];					if(iCount<64)						rgppiIntraQuantizerMatrix[iLayer][iObj][iCount] = 0;				}				else					memcpy (rgppiIntraQuantizerMatrix [iLayer][iObj], rgiDefaultIntraQMatrix, BLOCK_SQUARE_SIZE * sizeof(Int));							readBoolParam(&par, "Texture.QuantMatrix.Inter.Enable", iLayerObj, &rgbLoadInterMatrix [iLayer][iObj]);				if(rgbLoadInterMatrix [iLayer][iObj])				{					Double *pdTmp;					Int iCount;					GetAVal(&par, "Texture.QuantMatrix.Inter", iLayerObj, &pdTmp, &iCount);					fatal_error("Wrong number of inter quant matrix values (should be 64)", iCount<=64);					Int i;					for(i=0; i<iCount; i++)						rgppiInterQuantizerMatrix[iLayer][iObj][i] = (Int)pdTmp[i];					if(iCount<64)						rgppiInterQuantizerMatrix[iLayer][iObj][iCount] = 0;				}				else					memcpy (rgppiInterQuantizerMatrix [iLayer][iObj], rgiDefaultInterQMatrix, BLOCK_SQUARE_SIZE * sizeof(Int));							GetIVal(&par, "Texture.IntraDCThreshold", iLayerObj, &rgiIntraDCSwitchingThr [iLayer] [iObj]);				fatal_error("Intra DC Threshold must be in range 0 - 7",					rgiIntraDCSwitchingThr [iLayer] [iObj] >= 0 && rgiIntraDCSwitchingThr [iLayer] [iObj] <= 7);							GetIVal(&par, "Texture.QuantStep.IVOP", iLayerObj, &rgiIStep [iLayer] [iObj]);				fatal_error("IVOP quantizer stepsize is out of range", 					rgiIStep [iLayer] [iObj] > 0 && rgiIStep [iLayer] [iObj] < (1<<uiQuantPrecision));				GetIVal(&par, "Texture.QuantStep.PVOP", iLayerObj, &rgiPStep [iLayer] [iObj]);				fatal_error("PVOP quantizer stepsize is out of range", 					rgiPStep [iLayer] [iObj] > 0 && rgiPStep [iLayer] [iObj] < (1<<uiQuantPrecision));				GetIVal(&par, "Texture.QuantStep.BVOP", iLayerObj, &rgiStepBCode [iLayer] [iObj]);				fatal_error("BVOP quantizer stepsize is out of range", 					rgiStepBCode [iLayer] [iObj] > 0 && rgiStepBCode [iLayer] [iObj] < (1<<uiQuantPrecision));				readBoolParam(&par, "Alpha.QuantMatrix.Intra.Enable", iLayerObj, &rgbLoadIntraMatrixAlpha [iLayer][iObj]);				if(rgbLoadIntraMatrixAlpha [iLayer][iObj])				{					Double *pdTmp;					Int iCount;					GetAVal(&par, "Alpha.QuantMatrix.Intra", iLayerObj, &pdTmp, &iCount);					fatal_error("Wrong number of alpha intra quant matrix values (should be 64)", iCount<=64);					Int i;					for(i=0; i<iCount; i++)						rgppiIntraQuantizerMatrixAlpha[iLayer][iObj][i] = (Int)pdTmp[i];					if(iCount<64)						rgppiIntraQuantizerMatrixAlpha[iLayer][iObj][iCount] = 0;				}				else					memcpy (rgppiIntraQuantizerMatrixAlpha [iLayer][iObj], rgiDefaultIntraQMatrixAlpha,						BLOCK_SQUARE_SIZE * sizeof(Int));							readBoolParam(&par, "Alpha.QuantMatrix.Inter.Enable", iLayerObj, &rgbLoadInterMatrixAlpha [iLayer][iObj]);				if(rgbLoadInterMatrixAlpha [iLayer][iObj])				{					Double *pdTmp;					Int iCount;					GetAVal(&par, "Alpha.QuantMatrix.Inter", iLayerObj, &pdTmp, &iCount);					fatal_error("Wrong number of alpha inter quant matrix values (should be 64)", iCount<=64);					Int i;					for(i=0; i<iCount; i++)						rgppiInterQuantizerMatrixAlpha[iLayer][iObj][i] = (Int)pdTmp[i];					if(iCount<64)						rgppiInterQuantizerMatrixAlpha[iLayer][iObj][iCount] = 0;				}				else					memcpy (rgppiInterQuantizerMatrixAlpha [iLayer][iObj], rgiDefaultInterQMatrixAlpha,						BLOCK_SQUARE_SIZE * sizeof(Int));								GetIVal(&par, "Alpha.QuantStep.IVOP", iLayerObj, &rgiIStepAlpha [iLayer] [iObj]);				fatal_error("IVOP alpha quantizer stepsize is out of range", 					rgiIStepAlpha [iLayer] [iObj] > 0 && rgiIStepAlpha [iLayer] [iObj] < 64);				GetIVal(&par, "Alpha.QuantStep.PVOP", iLayerObj, &rgiPStepAlpha [iLayer] [iObj]);				fatal_error("PVOP alpha quantizer stepsize is out of range", 					rgiPStepAlpha [iLayer] [iObj] > 0 && rgiPStepAlpha [iLayer] [iObj] < 64);				GetIVal(&par, "Alpha.QuantStep.BVOP", iLayerObj, &rgiBStepAlpha [iLayer] [iObj]);				fatal_error("BVOP alpha quantizer stepsize is out of range", 					rgiBStepAlpha [iLayer] [iObj] > 0 && rgiBStepAlpha [iLayer] [iObj] < 64);				readBoolParam(&par, "Alpha.QuantDecouple.Enable", iLayerObj, &rgbNoGrayQuantUpdate [iLayer] [iObj]);				Int iRate;				GetIVal(&par, "Source.SamplingRate", iLayerObj, &iRate);				fatal_error("Source sampling rate must be > 0", iRate>0);				if(iLayer==BASE_LAYER)					rgiTSRate[iObj] = iRate;				else					rgiEnhcTSRate[iObj] = iRate;				GetIVal(&par, "Motion.SearchRange", iLayerObj, (Int *)&rguiSearchRange[iLayer][iObj]);				fatal_error("Motion.SearchRange must be > 0", rguiSearchRange[iLayer][iObj]>0);				readBoolParam(&par, "Motion.UseSourceForME.Enable", iLayerObj, &rgbOriginalME [iLayer] [iObj]);				Bool bAdvPredEnable;				readBoolParam(&par, "Motion.AdvancedPrediction.Enable", iLayerObj, &bAdvPredEnable);				rgbAdvPredDisable [iLayer][iObj] = !bAdvPredEnable;				Bool bComplexityEnable;				readBoolParam(&par, "Complexity.Enable", iLayerObj, &bComplexityEnable);				rgbComplexityEstimationDisable[iLayer][iObj] = !bComplexityEnable;				if(bComplexityEnable)				{					readBoolParam(&par, "Complexity.Opaque.Enable", iLayerObj, &rgbOpaque[iLayer][iObj]);					readBoolParam(&par, "Complexity.Transparent.Enable", iLayerObj, &rgbTransparent[iLayer][iObj]);					readBoolParam(&par, "Complexity.IntraCAE.Enable", iLayerObj, &rgbIntraCAE[iLayer][iObj]);					readBoolParam(&par, "Complexity.InterCAE.Enable", iLayerObj, &rgbInterCAE[iLayer][iObj]);					readBoolParam(&par, "Complexity.NoUpdate.Enable", iLayerObj, &rgbNoUpdate[iLayer][iObj]);					readBoolParam(&par, "Complexity.UpSampling.Enable", iLayerObj, &rgbUpsampling[iLayer][iObj]);					readBoolParam(&par, "Complexity.IntraBlocks.Enable", iLayerObj, &rgbIntraBlocks[iLayer][iObj]);					readBoolParam(&par, "Complexity.InterBlocks.Enable", iLayerObj, &rgbInterBlocks[iLayer][iObj]);					readBoolParam(&par, "Complexity.Inter4VBlocks.Enable", iLayerObj, &rgbInter4vBlocks[iLayer][iObj]);					readBoolParam(&par, "Complexity.NotCodedBlocks.Enable", iLayerObj, &rgbNotCodedBlocks[iLayer][iObj]);					readBoolParam(&par, "Complexity.DCTCoefs.Enable", iLayerObj, &rgbDCTCoefs[iLayer][iObj]);					readBoolParam(&par, "Complexity.DCTLines.Enable", iLayerObj, &rgbDCTLines[iLayer][iObj]);					readBoolParam(&par, "Complexity.VLCSymbols.Enable", iLayerObj, &rgbVLCSymbols[iLayer][iObj]);					readBoolParam(&par, "Complexity.VLCBits.Enable", iLayerObj, &rgbVLCBits[iLayer][iObj]);					readBoolParam(&par, "Complexity.APM.Enable", iLayerObj, &rgbAPM[iLayer][iObj]);					readBoolParam(&par, "Complexity.NPM.Enable", iLayerObj, &rgbNPM[iLayer][iObj]);					readBoolParam(&par, "Complexity.InterpMCQ.Enable", iLayerObj, &rgbInterpolateMCQ[iLayer][iObj]);					readBoolParam(&par, "Complexity.ForwBackMCQ.Enable", iLayerObj, &rgbForwBackMCQ[iLayer][iObj]);					readBoolParam(&par, "Complexity.HalfPel2.Enable", iLayerObj, &rgbHalfpel2[iLayer][iObj]);					readBoolParam(&par, "Complexity.HalfPel4.Enable", iLayerObj, &rgbHalfpel4[iLayer][iObj]);				}				else				{					rgbOpaque[iLayer][iObj] = 0;					rgbTransparent[iLayer][iObj] = 0;					rgbIntraCAE[iLayer][iObj] = 0;					rgbInterCAE[iLayer][iObj] = 0;					rgbNoUpdate[iLayer][iObj] = 0;					rgbUpsampling[iLayer][iObj] = 0;					rgbIntraBlocks[iLayer][iObj] = 0;					rgbInterBlocks[iLayer][iObj] = 0;					rgbInter4vBlocks[iLayer][iObj] = 0;					rgbNotCodedBlocks[iLayer][iObj] = 0;					rgbDCTCoefs[iLayer][iObj] = 0;					rgbDCTLines[iLayer][iObj] = 0;					rgbVLCSymbols[iLayer][iObj] = 0;					rgbVLCBits[iLayer][iObj] = 0;					rgbAPM[iLayer][iObj] = 0;					rgbNPM[iLayer][iObj] = 0;					rgbInterpolateMCQ[iLayer][iObj] = 0;					rgbForwBackMCQ[iLayer][iObj] = 0;					rgbHalfpel2[iLayer][iObj] = 0;					rgbHalfpel4[iLayer][iObj] = 0;				}					GetDVal(&par, "Source.FrameRate", iLayerObj, &rgdFrameFrequency[iLayer][iObj]);				fatal_error("Source.FrameRate is invalid", rgdFrameFrequency[iLayer][iObj] > 0.0);				readBoolParam(&par, "Motion.Interlaced.TopFieldFirst.Enable", iLayerObj, &rgbTopFieldFirst [iLayer] [iObj]);								readBoolParam(&par, "Motion.Interlaced.AlternativeScan.Enable", iLayerObj, &rgbAlternateScan[iLayer][iObj]);				GetIVal(&par, "Motion.SearchRange.DirectMode", iLayerObj, &rgiDirectModeRadius[iLayer][iObj]);				GetSVal(&par, "Motion.ReadWriteMVs", iLayerObj, &pchTmp);				if(strcmp(pchTmp, "Off")==0)					rgiMVFileUsage[iLayer][iObj] = 0;				else if(strcmp(pchTmp, "Read")==0)					rgiMVFileUsage[iLayer][iObj] = 1;				else if(strcmp(pchTmp, "Write")==0)					rgiMVFileUsage[iLayer][iObj] = 2;				else					fatal_error("Unknown mode for Motion.ReadWriteMVs");				if(rgiMVFileUsage[iLayer][iObj]!=0)				{					GetSVal(&par, "Motion.ReadWriteMVs.Filename", iLayerObj, &pchTmp);					iLen = strlen(pchTmp) + 1;					pchMVFileName [iLayer] [iObj] = new char [iLen];					memcpy(pchMVFileName [iLayer] [iObj], pchTmp, iLen);				}				Bool bVolControlEnable;				readBoolParam(&par, "VOLControl.Enable", iLayerObj, &bVolControlEnable);				rguiVolControlParameters[iLayer][iObj] = (UInt)bVolControlEnable;				GetIVal(&par, "VOLControl.ChromaFormat", iLayerObj, (Int *)&rguiChromaFormat[iLayer][iObj]);				GetIVal(&par, "VOLControl.LowDelay", iObj, (Int *)&rguiLowDelay[iLayer][iObj]);				Bool bVBVParams;				readBoolParam(&par, "VOLControl.VBVParams.Enable", iLayerObj, &bVBVParams);				rguiVBVParams[iLayer][iObj] = (UInt)bVBVParams;				GetIVal(&par, "VOLControl.Bitrate", iLayerObj, (Int *)&rguiBitRate[iLayer][iObj]);				GetIVal(&par, "VOLControl.VBVBuffer.Size", iLayerObj, (Int *)&rguiVbvBufferSize[iLayer][iObj]);				GetIVal(&par, "VOLControl.VBVBuffer.Occupancy", iLayerObj, (Int *)&rguiVbvBufferOccupany[iLayer][iObj]);			}		}	}	else	{		// OLD STYLE PARAMETER FILE		ungetc(iCh, pfPara);		printf("Old style parameter file.\n");		// verify version number		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%u", &iVersion) != 1 )	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		if (iVersion != 813 && iVersion != 812 && iVersion != 814 && iVersion != 815)	{			// version 812 does not have rounding control flags			// version 813 does not have VOL control parameters			// version 814 does not have skipped mb enable			fprintf(stderr, "wrong parameter file version for %s\n",VERSION_STRING);			exit(1);		}	///// WAVELET VTC: begin ///////////////////////////////		// sarnoff: wavelet visual texture coding 		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%d", &iVTCFlag) != 1)	{			fprintf(stderr, "wrong parameter VTC flag on line %d\n", *pnLine);			assert (FALSE);		}		assert (iVTCFlag==0 || iVTCFlag==1);		// read VTC control file		char VTCCtlFile[80];		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%s", VTCCtlFile) != 1)	{			fprintf(stderr, "wrong parameter VTC flag on line %d\n", *pnLine);			assert (FALSE);		}		if (iVTCFlag==1) {			fclose(pfPara);			RunVTCCodec(VTCCtlFile);			return 0;		}	///// WAVELET VTC: end ///////////////////////////////				// frame size code		nextValidLine (pfPara, pnLine);		if (fscanf (pfPara, "%u", &uiFrmWidth) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		nextValidLine (pfPara, pnLine);		if (fscanf (pfPara, "%u", &uiFrmHeight) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		// first and last frame number		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%u", &firstFrm) != 1) {			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%u", &lastFrm) != 1) {			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		assert (lastFrm >= firstFrm);		// NBIT: not 8-bit flag		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%d", &bNot8Bit) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -