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

📄 encoder.cpp

📁 网络MPEG4IP流媒体开发源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		assert (bNot8Bit==0 || bNot8Bit==1);		if(bNot8Bit==1)		{			assert(sizeof(PixelC)!=sizeof(unsigned char));		}		else		{			assert(sizeof(PixelC)==sizeof(unsigned char));		}		// NBIT: quant precision		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%d", &uiQuantPrecision) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		if (bNot8Bit==0) {			uiQuantPrecision = 5;		}		// NBIT: number of bits per pixel		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%d", &nBits) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		assert (nBits>=4 && nBits<=12);		if (bNot8Bit==0) {			nBits = 8;		}				// object indexes		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%u", &firstVO) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		nextValidLine (pfPara, pnLine);		if ( fscanf (pfPara, "%u", &lastVO) != 1)	{			fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);			exit(1);		}		assert (lastVO >= firstVO);		UInt nVO = lastVO - firstVO + 1;		// allocate per-vo parameters		rgiTemporalScalabilityType = new Int [nVO];		rgbSpatialScalability = new Bool [nVO];		rgbScalability = new Bool [nVO];		rgiEnhancementType = new Int [nVO];		rgfAlphaUsage = new AlphaUsage [nVO];		rgbShapeOnly = new Bool [nVO];		rgiBinaryAlphaTH = new Int [nVO];		rgbNoCrChange = new Bool [nVO];		rgiBinaryAlphaRR = new Int [nVO];		rgbRoundingControlDisable = new Bool [nVO];		rgiInitialRoundingType = new Int [nVO];		rgiNumPbetweenIVOP = new Int [nVO];		rgiNumBbetweenPVOP = new Int [nVO];		rgiGOVperiod = new Int [nVO];		rgbDeblockFilterDisable = new Bool [nVO];		rgiTSRate = new Int [nVO];		rgiEnhcTSRate = new Int [nVO];		rgfChrType = new ChromType [nVO];		rgbAllowSkippedPMBs = new Bool [nVO];		rgSpriteMode = new SptMode [nVO];		rgbDumpMB = new Bool [nVO];		rgbTrace = new Bool [nVO];		rguiSpriteUsage = new UInt [nVO]; 		rguiWarpingAccuracy = new UInt [nVO]; 		rgiNumPnts = new Int [nVO]; 				Int iL;		for(iL = BASE_LAYER; iL<=ENHN_LAYER; iL++)		{			// allocate per-layer parameters			rguiRateControl [iL] = new UInt [nVO];			rguiBitsBudget [iL] = new UInt [nVO];			rgbAdvPredDisable [iL] = new Bool [nVO];			rgbErrorResilientDisable [iL] = new Bool [nVO];			rgbDataPartitioning [iL] = new Bool [nVO];			rgbReversibleVlc [iL] = new Bool [nVO];			rgiVPBitTh [iL] = new Int [nVO];			rgbInterlacedCoding [iL] = new Bool [nVO];				rgfQuant [iL] = new Quantizer [nVO]; 			rgbLoadIntraMatrix [iL] = new Bool [nVO];			rgppiIntraQuantizerMatrix [iL] = new Int * [nVO];			rgbLoadInterMatrix [iL] = new Bool [nVO];			rgppiInterQuantizerMatrix [iL] = new Int * [nVO];			rgiIntraDCSwitchingThr [iL] = new Int [nVO]; 			rgiIStep [iL] = new Int [nVO]; 			rgiPStep [iL] = new Int [nVO]; 			rgiStepBCode [iL] = new Int [nVO]; 			rgbLoadIntraMatrixAlpha [iL] = new Bool [nVO]; 				rgppiIntraQuantizerMatrixAlpha [iL] = new Int * [nVO];			rgbLoadInterMatrixAlpha [iL] = new Bool [nVO]; 				rgppiInterQuantizerMatrixAlpha [iL] = new Int * [nVO];			rgiIStepAlpha [iL] = new Int [nVO]; 			rgiPStepAlpha [iL] = new Int [nVO]; 			rgiBStepAlpha [iL] = new Int [nVO]; 			rgbNoGrayQuantUpdate [iL] = new Bool [nVO];			rguiSearchRange [iL] = new UInt [nVO];			rgbOriginalME [iL] = new Bool [nVO];			rgbComplexityEstimationDisable [iL] = new Bool [nVO];			rgbOpaque [iL] = new Bool [nVO];			rgbTransparent [iL] = new Bool [nVO];			rgbIntraCAE [iL] = new Bool [nVO];			rgbInterCAE [iL] = new Bool [nVO];			rgbNoUpdate [iL] = new Bool [nVO];			rgbUpsampling [iL] = new Bool [nVO];			rgbIntraBlocks [iL] = new Bool [nVO];			rgbInterBlocks [iL] = new Bool [nVO];			rgbInter4vBlocks [iL] = new Bool [nVO];			rgbNotCodedBlocks [iL] = new Bool [nVO];			rgbDCTCoefs [iL] = new Bool [nVO];			rgbDCTLines [iL] = new Bool [nVO];			rgbVLCSymbols [iL] = new Bool [nVO];			rgbVLCBits [iL] = new Bool [nVO];			rgbAPM [iL] = new Bool [nVO];			rgbNPM [iL] = new Bool [nVO];			rgbInterpolateMCQ [iL] = new Bool [nVO];			rgbForwBackMCQ [iL] = new Bool [nVO];			rgbHalfpel2 [iL] = new Bool [nVO];			rgbHalfpel4 [iL] = new Bool [nVO];			rguiVolControlParameters [iL] = new UInt [nVO];			rguiChromaFormat [iL] = new UInt [nVO];			rguiLowDelay [iL] = new UInt [nVO];			rguiVBVParams [iL] = new UInt [nVO];			rguiBitRate [iL] = new UInt [nVO];			rguiVbvBufferSize [iL] = new UInt [nVO];			rguiVbvBufferOccupany [iL] = new UInt [nVO];			rgdFrameFrequency [iL] = new Double [nVO];			rgbTopFieldFirst [iL] = new Bool [nVO]; 			rgbAlternateScan [iL] = new Bool [nVO]; 			rgiDirectModeRadius [iL] = new Bool [nVO]; 			rgiMVFileUsage[iL] = new Int [nVO];			pchMVFileName[iL] = new char * [nVO];		}		for (iObj = 0; iObj < nVO; iObj++)		{			// per object alloc			rgppiIntraQuantizerMatrix [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiIntraQuantizerMatrix [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiInterQuantizerMatrix [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiInterQuantizerMatrix [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiIntraQuantizerMatrixAlpha [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiIntraQuantizerMatrixAlpha [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiInterQuantizerMatrixAlpha [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];			rgppiInterQuantizerMatrixAlpha [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE];		}		//scalability indicators: 1 = temporal, 2 = spatial scalability		nextValidLine (pfPara, pnLine);		bAnyScalability = FALSE;		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rgbScalability [iObj]) != 1)	{				fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			if (rgbScalability[iObj] == TEMPORAL_SCALABILITY || 				rgbScalability[iObj] == SPATIAL_SCALABILITY)				bAnyScalability = TRUE;			else				assert (rgbScalability[iObj] == NO_SCALABILITY);			if(rgbScalability[iObj] == SPATIAL_SCALABILITY || rgbScalability[iObj] == TEMPORAL_SCALABILITY) // modifiedy by Sharp(98/2/12)				rgbSpatialScalability[iObj] = TRUE; 			else 				rgbSpatialScalability[iObj] = FALSE; 		}		//coded added by Sony, only deals with ONE VO.		//Type option of Spatial Scalable Coding		//This parameter is used for dicision VOP prediction types of Enhancement layer in Spatial Scalable Coding		//If this option is set to 0, Enhancement layer is coded as "PPPPPP......",		//else if set to 1 ,It's coded as "PBBBB......."		nextValidLine(pfPara,pnLine);		assert (nVO == 1);		fscanf(pfPara,"%d",&iSpatialOption);		if(rgbScalability[0] == SPATIAL_SCALABILITY)			if (iSpatialOption == 1)					fprintf(stdout,"Enhancement layer is coded as \"PPPPP.....\"\n");			else if (iSpatialOption == 0)					fprintf(stdout,"Enhancement layer is coded as \"PBBBB.....\"\n");			else {				fprintf(stderr,"The parameter \"SpatialOption\" is not set correctly\n");				exit(1);			}		//Load enhancement layer (Spatial Scalable) size		nextValidLine(pfPara,pnLine);		fscanf(pfPara,"%d",&uiFrmWidth_SS);		fscanf(pfPara,"%d",&uiFrmHeight_SS);		//load upsampling factor 		nextValidLine(pfPara,pnLine);		fscanf(pfPara,"%d",&uiHor_sampling_n);		fscanf(pfPara,"%d",&uiHor_sampling_m);		nextValidLine(pfPara,pnLine);		fscanf(pfPara,"%d",&uiVer_sampling_n);		fscanf(pfPara,"%d",&uiVer_sampling_m);		// form of temporal scalability indicators		// case 0  Enhn    P   P   ....		//         Base  I   P   P ....		// case 1  Enhn    B B   B B   ....		//         Base  I     P     P ....		// case 2  Enhn    P   B   B   ....		//         Base  I   B   P   B ....		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rgiTemporalScalabilityType [iObj]) != 1)	{				fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			assert (rgiTemporalScalabilityType [iObj] == 0 || 				rgiTemporalScalabilityType [iObj] == 1 || 				rgiTemporalScalabilityType [iObj] == 2 ||				rgiTemporalScalabilityType [iObj] == 3 ||				rgiTemporalScalabilityType [iObj] == 4);		}		// enhancement_type for scalability		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rgiEnhancementType [iObj]) != 1)	{				fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			assert (rgiEnhancementType [iObj] == 0 || //  entire region of the base layer is enhanced	// begin: modified by Sharp (98/3/24)				rgiEnhancementType [iObj] == 1 ||  // partial region of the base layer is enhanced (with background composition)				rgiEnhancementType [iObj] == 2);  // partial region of the base layer is enhanced (without background composition)	// end: modified by Sharp (98/3/24)		}		// rate control flag		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%u", &rguiRateControl [BASE_LAYER] [iObj] ) != 1)	{				fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			assert (rguiRateControl [BASE_LAYER] [iObj]  == RC_MPEG4 || 					rguiRateControl [BASE_LAYER] [iObj]  == RC_TM5 ||					rguiRateControl [BASE_LAYER] [iObj]  == 0);		}		if (bAnyScalability)	{			for (iObj = 0; iObj < nVO; iObj++)	{				if (fscanf (pfPara, "%u", &rguiRateControl [ENHN_LAYER] [iObj]) != 1)	{					fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);					exit (1);				}				assert (rguiRateControl [ENHN_LAYER] [iObj]  == 0 || 						rguiRateControl [ENHN_LAYER] [iObj]  == RC_MPEG4 ||						rguiRateControl [ENHN_LAYER] [iObj]  == RC_TM5);			}		}		// bit budget for each object.		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rguiBitsBudget [BASE_LAYER] [iObj]) != 1)	{				fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}		}		if (bAnyScalability)	{			for (iObj = 0; iObj < nVO; iObj++)	{				if (fscanf (pfPara, "%d", &rguiBitsBudget [ENHN_LAYER] [iObj]) != 1)	{					fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);					exit (1);				}				assert (rguiBitsBudget [ENHN_LAYER] [iObj]  > 0);			}		}		// alpha usage for each object.  0: rectangle, 1: binary, 2: 8-bit, 3: shape only		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			UInt uiAlpha;			if (fscanf (pfPara, "%d", &uiAlpha) != 1)	{				fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			else {				assert (uiAlpha == 0 || uiAlpha == 1 || uiAlpha == 2 || uiAlpha == 3);				if(uiAlpha<3)				{					rgfAlphaUsage [iObj] = (AlphaUsage) uiAlpha;					rgbShapeOnly [iObj] = FALSE;				}				else				{					rgfAlphaUsage [iObj] = ONE_BIT;					rgbShapeOnly [iObj] = TRUE;				}			}		}		// binary shape rounding para		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rgiBinaryAlphaTH [iObj]) != 1)	{				fprintf	(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			assert (rgiBinaryAlphaTH [iObj] >= 0);		}		// binary shape size conversion flag		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rgbNoCrChange [iObj]) != 1)	{				fprintf	(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			assert (rgbNoCrChange [iObj] == TRUE || rgbNoCrChange [iObj] == FALSE); //boolean value			if (rgiBinaryAlphaTH [iObj] == 0)				assert (rgbNoCrChange [iObj] == TRUE); //MB-level size conversion of shape is off in lossless mode\n");		}		//	Added for error resilient mode by Toshiba(1997-11-14)		nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if (fscanf (pfPara, "%d", &rgiBinaryAlphaRR [iObj]) != 1)	{				fprintf	(stderr, "wrong parameter file format on line %d\n", *pnLine);				exit (1);			}			assert (rgiBinaryAlphaRR [iObj] >= 0);		}		// End Toshiba(1997-11-14)		// rounding control disable		if(iVersion > 812)			nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if(iVersion > 812)			{				if (fscanf (pfPara, "%d", &rgbRoundingControlDisable [iObj]) != 1)	{					fprintf(stderr, "wrong parameter file format on line %d\n", *pnLine);					exit (1);				}			}			else				rgbRoundingControlDisable [iObj] = 0;			assert (rgbRoundingControlDisable [iObj]  == 0 || rgbRoundingControlDisable [iObj] == 1);		}		if(iVersion > 812)			nextValidLine (pfPara, pnLine);		for (iObj = 0; iObj < nVO; iObj++)	{			if(iVersion > 812)

⌨️ 快捷键说明

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