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

📄 encoder.cpp

📁 网络MPEG4IP流媒体开发源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*************************************************************************This software module was originally developed by 	Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation	Wei-ge Chen (wchen@microsoft.com), Microsoft Corporation	Bruce Lin (blin@microsoft.com), Microsoft Corporation	Chuang Gu (chuanggu@microsoft.com), Microsoft Corporation	Simon Winder (swinder@microsoft.com), Microsoft Corporation	(date: March, 1996)and edited by	Hiroyuki Katata (katata@imgsl.mkhar.sharp.co.jp), Sharp Corporation	Norio Ito (norio@imgsl.mkhar.sharp.co.jp), Sharp Corporation	Shuichi Watanabe (watanabe@imgsl.mkhar.sharp.co.jp), Sharp Corporation	(date: October, 1997)and also edited by	Xuemin Chen (xchen@nlvl.com). Next Level Systems, Inc.	Bob Eifrig (beifrig@nlvl.com) Next Level Systems, Inc.and also edited by	Wei Wu (weiwu@stallion.risc.rockwell.com) Rockwell Science Centerand also edited by	Yoshihiro Kikuchi (TOSHIBA CORPORATION)	Takeshi Nagai (TOSHIBA CORPORATION)	Toshiaki Watanabe (TOSHIBA CORPORATION)	Noboru Yamaguchi (TOSHIBA CORPORATION)    Marc Mongenet (Marc.Mongenet@epfl.ch), Swiss Federal Institute of Technology, Lausanne (EPFL)in the course of development of the MPEG-4 Video (ISO/IEC 14496-2). This software module is an implementation of a part of one or more MPEG-4 Video tools as specified by the MPEG-4 Video. ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-4 Video. Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-4 Video conforming products. Sharp retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1997.Module Name:	encoder.cppAbstract:	caller for encoderRevision History:	May 9, 1999:	tm5 rate control by DemoGraFX, duhoff@mediaone.net*************************************************************************/#include <stdio.h>#include <stdlib.h>#ifdef __PC_COMPILER_#include <windows.h>#include <mmsystem.h>#endif // __PC_COMPILER_#include "typeapi.h"#include "codehead.h"#include "paramset.h"#include "mode.hpp"#include "tm5rc.hpp"#include "fstream.h"#include "sesenc.hpp"// #include "encoder/tps_sesenc.hpp" // deleted by Sharp (98/2/12)///// WAVELET VTC: begin ////////////////////////////////#include "dataStruct.hpp"     // hjlee ///// WAVELET VTC: end ////////////////////////////////#ifndef __GLOBAL_VAR_#define __GLOBAL_VAR_#endif#include "global.hpp"#ifdef __MFC_#ifdef _DEBUG#undef THIS_FILEstatic char BASED_CODE THIS_FILE[] = __FILE__;#endif#define new DEBUG_NEW				   #endif // __MFC_#define _FOR_GSSP_#ifdef _FOR_GSSP_Int rgiDefaultIntraQMatrixAlpha [BLOCK_SQUARE_SIZE] = {	8,  17, 18, 19, 21, 23, 25, 27,	17, 18, 19, 21, 23, 25, 27, 28,	20, 21, 22, 23, 24, 26, 28, 30,	21, 22, 23, 24, 26, 28, 30, 32,	22, 23, 24, 26, 28, 30, 32, 35,	23, 24, 26, 28, 30, 32, 35, 38,	25, 26, 28, 30, 32, 35, 38, 41,	27, 28, 30, 32, 35, 38, 41, 45};Int rgiDefaultInterQMatrixAlpha [BLOCK_SQUARE_SIZE] = {	16, 17, 18, 19, 20, 21, 22, 23,	17, 18, 19, 20, 21, 22, 23, 24,	18, 19, 20, 21, 22, 23, 24, 25,	19, 20, 21, 22, 23, 24, 26, 27,	20, 21, 22, 23, 25, 26, 27, 28,	21, 22, 23, 24, 26, 27, 28, 30,	22, 23, 24, 26, 27, 28, 30, 31,	23, 24, 25, 27, 28, 30, 31, 33};#elseInt rgiDefaultIntraQMatrixAlpha [BLOCK_SQUARE_SIZE] = {	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16};Int rgiDefaultInterQMatrixAlpha [BLOCK_SQUARE_SIZE] = {	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16,	16, 16, 16, 16, 16, 16, 16, 16};#endifVoid nextValidLine (FILE *pfPara, UInt* pnLine);///// WAVELET VTC: begin ////////////////////////////////Void readVTCParam(CVTCEncoder *pvtcenc, FILE *pfPara, UInt* pnLine);///// WAVELET VTC: end ////////////////////////////////Void readBoolVOLFlag (Bool * rgbTable [2], UInt nVO, FILE * pfCfg, UInt * pnLine, Bool bAnyScalability);Void readItem(UInt *rguiTable [2], UInt nVO, FILE * pfCfg, UInt * pnLine, Bool bAnyScalability);Void RunVTCCodec(char *VTCCtlFile);Void GetIVal(CxParamSet *pPar, char *pchName, Int iInd, Int *piRtn);Void GetDVal(CxParamSet *pPar, char *pchName, Int iInd, Double *pdRtn);Void GetSVal(CxParamSet *pPar, char *pchName, Int iInd, char **ppchRtn);Void GetAVal(CxParamSet *pPar, char *pchName, Int iInd, Double **ppdRtn, Int *piCount);Void readBoolParam(CxParamSet *pPar, char *pchName, Int iInd, Bool *pbVal);Int bPrint = 0;#define VERSION_STRING "FDIS 1.02 (990812)"// please update version number when you// make changes in the following#define BASE_LAYER 0#define ENHN_LAYER 1#define NO_SCALABILITY		 0#define TEMPORAL_SCALABILITY 1#define SPATIAL_SCALABILITY  2int main (int argc, Char* argv[]){	UInt nLine = 1;	UInt* pnLine = &nLine;	FILE *pfPara;	if (argc != 2)	{		printf ("Usage: %s parameter_file\n       %s -version", argv [0], argv[0]);		exit (1);	}	if(argv[1][0]=='-' && argv[1][1]=='v')	{		printf("Microsoft MPEG-4 Visual CODEC %s\n",VERSION_STRING);		exit(0);	}	if ((pfPara = fopen (argv[1], "r")) == NULL ){		printf ("Parameter File Not Found\n");		exit (1);	}	// all the parameters to the encoder	Int iVersion;	Int iVTCFlag;	UInt uiFrmWidth, uiFrmHeight;	UInt firstFrm, lastFrm;	Bool bNot8Bit;	UInt uiQuantPrecision;	UInt nBits;	UInt firstVO, lastVO;	UInt nVO = 0;	UInt uiFrmWidth_SS,uiFrmHeight_SS;	UInt uiHor_sampling_m,uiHor_sampling_n;	UInt uiVer_sampling_m,uiVer_sampling_n;	Bool bAnyScalability = FALSE;	Int iSpatialOption;	char *pchPrefix;			char *pchBmpDir;	char *pchOutBmpDir;	char *pchOutStrFile;	char *pchSptDir;	char *pchSptPntDir;		Int *rgiTemporalScalabilityType;	Bool *rgbSpatialScalability;	Bool *rgbScalability;	Int *rgiEnhancementType;	AlphaUsage *rgfAlphaUsage;	Bool *rgbShapeOnly;	Int *rgiBinaryAlphaTH;	Int *rgbNoCrChange;	Int *rgiBinaryAlphaRR;	Bool *rgbRoundingControlDisable;	Int *rgiInitialRoundingType;	Int *rgiNumPbetweenIVOP;	Int *rgiNumBbetweenPVOP;	Int *rgiGOVperiod;	Bool *rgbDeblockFilterDisable;	Int *rgiTSRate;	Int *rgiEnhcTSRate;	ChromType *rgfChrType;	Bool *rgbAllowSkippedPMBs;	SptMode *rgSpriteMode;	Bool *rgbDumpMB;	Bool *rgbTrace;	UInt *rguiSpriteUsage; 	UInt *rguiWarpingAccuracy; 	Int *rgiNumPnts;		UInt *rguiRateControl [2];	UInt *rguiBitsBudget [2];	Bool *rgbAdvPredDisable [2];	Bool *rgbErrorResilientDisable [2];	Bool *rgbDataPartitioning [2];	Bool *rgbReversibleVlc [2];	Int *rgiVPBitTh [2];	Bool *rgbInterlacedCoding [2];	Quantizer* rgfQuant [2];	Bool *rgbLoadIntraMatrix [2];	Int **rgppiIntraQuantizerMatrix [2];	Bool *rgbLoadInterMatrix [2];	Int **rgppiInterQuantizerMatrix [2];	Bool *rgiIntraDCSwitchingThr [2];	Int *rgiIStep [2];	Int *rgiPStep [2];	Int *rgiStepBCode [2];	Bool *rgbLoadIntraMatrixAlpha [2];	Int **rgppiIntraQuantizerMatrixAlpha [2];	Bool *rgbLoadInterMatrixAlpha [2];	Int **rgppiInterQuantizerMatrixAlpha [2];	Int *rgiIStepAlpha [2];			Int *rgiPStepAlpha [2];	Int *rgiBStepAlpha [2];	Bool *rgbNoGrayQuantUpdate [2];	UInt *rguiSearchRange [2];	Bool *rgbOriginalME [2];	Bool *rgbComplexityEstimationDisable [2];	Bool *rgbOpaque [2];	Bool *rgbTransparent [2];	Bool *rgbIntraCAE [2];	Bool *rgbInterCAE [2];	Bool *rgbNoUpdate [2];	Bool *rgbUpsampling [2];	Bool *rgbIntraBlocks [2];	Bool *rgbInterBlocks [2];	Bool *rgbInter4vBlocks [2];	Bool *rgbNotCodedBlocks [2];	Bool *rgbDCTCoefs [2];	Bool *rgbDCTLines [2];	Bool *rgbVLCSymbols [2];	Bool *rgbVLCBits [2];	Bool *rgbAPM [2];	Bool *rgbNPM [2];	Bool *rgbInterpolateMCQ [2];	Bool *rgbForwBackMCQ [2];	Bool *rgbHalfpel2 [2];	Bool *rgbHalfpel4 [2];	UInt *rguiVolControlParameters[2];	UInt *rguiChromaFormat[2];	UInt *rguiLowDelay[2];	UInt *rguiVBVParams[2];	UInt *rguiBitRate[2];	UInt *rguiVbvBufferSize[2];	UInt *rguiVbvBufferOccupany[2];	Double *rgdFrameFrequency[2];	Bool *rgbTopFieldFirst [2];	Bool *rgbAlternateScan [2];	Int *rgiDirectModeRadius [2];	Int *rgiMVFileUsage[2];	char **pchMVFileName[2];	UInt iObj;	Int iCh = getc(pfPara);	if(iCh=='!')	{		// NEW STYLE PARAMETER FILE		printf("New style parameter file.\n");		CxParamSet par;		char rgBuf[80];		char *pch = fgets(rgBuf, 79, pfPara);		if(pch==NULL)			fatal_error("Can't read magic number in parameter file");		//if(strcmp("!!MS!!!\n", rgBuf)!=0)		//	fatal_error("Bad magic number at start of parameter file");		int iLine;		int er = par.Load(pfPara, &iLine);		if(er!=ERES_OK)			exit(printf("error %d at line %d of parameter file\n",er, iLine));				fclose(pfPara);		// process the parameters		GetIVal(&par, "Version", -1, &iVersion);		if(iVersion!=901)			fatal_error("Incorrect parameter file version number for this compilation");		GetIVal(&par, "VTC.Enable", -1, &iVTCFlag);		if(iVTCFlag)		{			char *VTCCtlFile;			GetSVal(&par, "VTC.Filename", -1, &VTCCtlFile);			RunVTCCodec(VTCCtlFile);			return 0;		}		GetIVal(&par, "Source.Width", -1, (Int *)&uiFrmWidth);		GetIVal(&par, "Source.Height", -1, (Int *)&uiFrmHeight);		GetIVal(&par, "Source.FirstFrame", -1, (Int *)&firstFrm);		GetIVal(&par, "Source.LastFrame", -1, (Int *)&lastFrm);		fatal_error("Last frame number cannot be smaller than first frame number", lastFrm >= firstFrm);		GetIVal(&par, "Source.BitsPerPel", -1, (Int *)&nBits);		readBoolParam(&par, "Not8Bit.Enable", -1, &bNot8Bit);		GetIVal(&par, "Not8Bit.QuantPrecision", -1, (Int *)&uiQuantPrecision);		if(bNot8Bit)			fatal_error("When Not8Bit is enabled, the __NBIT_ compile flag must be used.", sizeof(PixelC)!=sizeof(char));		else			fatal_error("When Not8Bit is disabled, the __NBIT_ compile flag must not be used.", sizeof(PixelC)==sizeof(char));		if(bNot8Bit==0)

⌨️ 快捷键说明

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