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

📄 vopseenc.cpp

📁 网络MPEG4IP流媒体开发源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		if (m_volmd.bLoadIntraMatrix) {			UInt i = 0;			do {				m_pbitstrmOut -> putBits (m_volmd.rgiIntraQuantizerMatrix [grgiStandardZigzag[i]], NUMBITS_QMATRIX, "VOL_Quant_Matrix(intra)");				m_statsVOL.nBitsHead += NUMBITS_QMATRIX;			} while (m_volmd.rgiIntraQuantizerMatrix [grgiStandardZigzag[i]] != 0 && ++i < BLOCK_SQUARE_SIZE);			for (UInt j = i; j < BLOCK_SQUARE_SIZE; j++) {				m_volmd.rgiIntraQuantizerMatrix [grgiStandardZigzag[j]] = m_volmd.rgiIntraQuantizerMatrix [grgiStandardZigzag[i - 1]];			}		}		m_pbitstrmOut -> putBits (m_volmd.bLoadInterMatrix, 1, "VOL_Load_Q_Matrix (inter)");		m_statsVOL.nBitsHead++;		if (m_volmd.bLoadInterMatrix) {			UInt i = 0;			do {				m_pbitstrmOut -> putBits (m_volmd.rgiInterQuantizerMatrix [grgiStandardZigzag[i]], NUMBITS_QMATRIX, "VOL_Quant_Matrix(intra)");				m_statsVOL.nBitsHead += NUMBITS_QMATRIX;			} while (m_volmd.rgiInterQuantizerMatrix [grgiStandardZigzag[i]] != 0 && ++i < BLOCK_SQUARE_SIZE);			for (UInt j = i; j < BLOCK_SQUARE_SIZE; j++) {				m_volmd.rgiInterQuantizerMatrix [grgiStandardZigzag[j]] = m_volmd.rgiInterQuantizerMatrix [grgiStandardZigzag[i - 1]];			}		}		if (m_volmd.fAUsage == EIGHT_BIT)	{			m_pbitstrmOut -> putBits (m_volmd.bLoadIntraMatrixAlpha, 1, "VOL_Load_Alpha_Q_Matrix (intra)");			m_statsVOL.nBitsHead++;			if (m_volmd.bLoadIntraMatrixAlpha) {				for (UInt i = 0; i < BLOCK_SQUARE_SIZE; i++) {					m_pbitstrmOut -> putBits (m_volmd.rgiIntraQuantizerMatrixAlpha [grgiStandardZigzag[i]], NUMBITS_QMATRIX, "VOL_Alpha_Quant_Matrix(intra)");					m_statsVOL.nBitsHead += NUMBITS_QMATRIX;				}			}			m_pbitstrmOut -> putBits (m_volmd.bLoadInterMatrixAlpha, 1, "VOL_Load_Alpha_Q_Matrix (inter)");			m_statsVOL.nBitsHead++;			if (m_volmd.bLoadInterMatrixAlpha) {				for (UInt i = 0; i < BLOCK_SQUARE_SIZE; i++) {					m_pbitstrmOut -> putBits (m_volmd.rgiInterQuantizerMatrixAlpha [grgiStandardZigzag[i]], NUMBITS_QMATRIX, "VOL_Alpha_Quant_Matrix(inter)");					m_statsVOL.nBitsHead += NUMBITS_QMATRIX;				}			}		}	}	// START: Complexity Estimation syntax support - Marc Mongenet (EPFL) - 16 Jun 1998	m_pbitstrmOut -> putBits (m_volmd.bComplexityEstimationDisable,							  1, "complexity_estimation_disable");	m_statsVOL.nBitsHead += 1;	if (! m_volmd.bComplexityEstimationDisable) {		m_volmd.iEstimationMethod = 0; // only known estimation method at now (18 Jun 1998)		m_volmd.bShapeComplexityEstimationDisable =		  !(m_volmd.bOpaque ||			m_volmd.bTransparent ||			m_volmd.bIntraCAE ||			m_volmd.bInterCAE ||			m_volmd.bNoUpdate ||			m_volmd.bUpsampling);		m_volmd.bTextureComplexityEstimationSet1Disable =		  !(m_volmd.bIntraBlocks ||			m_volmd.bInterBlocks ||			m_volmd.bInter4vBlocks ||			m_volmd.bNotCodedBlocks);		m_volmd.bTextureComplexityEstimationSet2Disable =		  !(m_volmd.bDCTCoefs ||			m_volmd.bDCTLines ||			m_volmd.bVLCSymbols ||			m_volmd.bVLCBits);		m_volmd.bMotionCompensationComplexityDisable =		  !(m_volmd.bAPM ||			m_volmd.bNPM ||			m_volmd.bInterpolateMCQ ||			m_volmd.bForwBackMCQ ||			m_volmd.bHalfpel2 ||			m_volmd.bHalfpel4);		assert (m_volmd.iEstimationMethod == 0);		m_pbitstrmOut -> putBits (m_volmd.iEstimationMethod, 2, "estimation_method");		m_statsVOL.nBitsHead += 2;		m_pbitstrmOut -> putBits (m_volmd.bShapeComplexityEstimationDisable,								  1, "shape_complexity_estimation_disable");		m_statsVOL.nBitsHead += 1;		if (! m_volmd.bShapeComplexityEstimationDisable) {			m_pbitstrmOut -> putBits (m_volmd.bOpaque, 1, "opaque");			m_pbitstrmOut -> putBits (m_volmd.bTransparent, 1, "transparent");			m_pbitstrmOut -> putBits (m_volmd.bIntraCAE, 1, "intra_cae");			m_pbitstrmOut -> putBits (m_volmd.bInterCAE, 1, "inter_cae");			m_pbitstrmOut -> putBits (m_volmd.bNoUpdate, 1, "no_update");			m_pbitstrmOut -> putBits (m_volmd.bUpsampling, 1, "upsampling");			m_statsVOL.nBitsHead += 6;		}		m_pbitstrmOut -> putBits (m_volmd.bTextureComplexityEstimationSet1Disable,								  1, "texture_complexity_estimation_set_1_disable");		m_statsVOL.nBitsHead += 1;		if (! m_volmd.bTextureComplexityEstimationSet1Disable) {			m_pbitstrmOut -> putBits (m_volmd.bIntraBlocks, 1, "intra_blocks");			m_pbitstrmOut -> putBits (m_volmd.bInterBlocks, 1, "inter_blocks");			m_pbitstrmOut -> putBits (m_volmd.bInter4vBlocks, 1, "inter4v_blocks");			m_pbitstrmOut -> putBits (m_volmd.bNotCodedBlocks, 1, "not_coded_blocks");			m_statsVOL.nBitsHead += 4;		}		m_pbitstrmOut -> putBits (1, 1, "Marker_Bit");		m_statsVOL.nBitsStuffing ++;		m_pbitstrmOut -> putBits (m_volmd.bTextureComplexityEstimationSet2Disable,								  1, "texture_complexity_estimation_set_2_disable");		m_statsVOL.nBitsHead += 1;		if (! m_volmd.bTextureComplexityEstimationSet2Disable) {			m_pbitstrmOut -> putBits (m_volmd.bDCTCoefs, 1, "dct_coefs");			m_pbitstrmOut -> putBits (m_volmd.bDCTLines, 1, "dct_lines");			m_pbitstrmOut -> putBits (m_volmd.bVLCSymbols, 1, "vlc_symbols");			m_pbitstrmOut -> putBits (m_volmd.bVLCBits, 1, "vlc_bits");			m_statsVOL.nBitsHead += 4;		}		m_pbitstrmOut -> putBits (m_volmd.bMotionCompensationComplexityDisable,								  1, "motion_compensation_complexity_disable");		m_statsVOL.nBitsHead += 1;		if (! m_volmd.bMotionCompensationComplexityDisable) {			m_pbitstrmOut -> putBits (m_volmd.bAPM, 1, "apm");			m_pbitstrmOut -> putBits (m_volmd.bNPM, 1, "npm");			m_pbitstrmOut -> putBits (m_volmd.bInterpolateMCQ, 1, "interpolate_mc_q");			m_pbitstrmOut -> putBits (m_volmd.bForwBackMCQ, 1, "forw_back_mc_q");			m_pbitstrmOut -> putBits (m_volmd.bHalfpel2, 1, "halfpel2");			m_pbitstrmOut -> putBits (m_volmd.bHalfpel4, 1, "halfpel4");			m_statsVOL.nBitsHead += 6;		}		m_pbitstrmOut -> putBits (1, 1, "Marker_Bit");		m_statsVOL.nBitsStuffing ++;	}	// END: Complexity Estimation syntax support	m_pbitstrmOut -> putBits (0, 1, "VOL_resync_marker_disable");	m_statsVOL.nBitsHead ++;	//	Modified by Toshiba(1998-4-7)	m_pbitstrmOut -> putBits (m_volmd.bDataPartitioning, 1, "VOL_data_partitioning");	m_statsVOL.nBitsHead ++;	if( m_volmd.bDataPartitioning )	{		m_pbitstrmOut -> putBits (m_volmd.bReversibleVlc, 1, "VOL_reversible_vlc");		m_statsVOL.nBitsHead ++;	}	//	End Toshiba	m_pbitstrmOut -> putBits (m_volmd.volType == ENHN_LAYER, 1, "VOL_Scalability");	m_statsVOL.nBitsHead++;	if (m_volmd.volType == ENHN_LAYER)	{//#ifdef _Scalable_SONY_		m_pbitstrmOut -> putBits (m_volmd.iHierarchyType, 1, "VOL_Hierarchy_Type");//#endif _Scalable_SONY_		m_pbitstrmOut -> putBits (0, 4, "VOL_Ref_Layer_Id");		m_pbitstrmOut -> putBits (0, 1, "VOL_Ref_Layer_Sampling_Dir");/*Added*/		m_pbitstrmOut -> putBits (m_volmd.ihor_sampling_factor_n, 5, "VOL_Horizontal_Sampling_Factor");			//The vm is not very clear about this.		m_pbitstrmOut -> putBits (m_volmd.ihor_sampling_factor_m, 5, "VOL_Horizontal_Sampling_Factor_Ref");		//Always 1		m_pbitstrmOut -> putBits (m_volmd.iver_sampling_factor_n, 5, "VOL_Vertical_Sampling_Factor");			//The vm is not very clear about this.		m_pbitstrmOut -> putBits (m_volmd.iver_sampling_factor_m, 5, "VOL_Vertical_Sampling_Factor_Ref");		//Always 1		m_pbitstrmOut -> putBits (m_volmd.iEnhnType!=0?1:0, 1, "VOL_Ehnancement_Type"); // enhancement_type for scalability // modified by Sharp (98/3/24)		m_statsVOL.nBitsHead += 26;	}// Begin: modified by Hughes	  4/9/98	  per clause 2.1.7. in N2171 document//	m_pbitstrmOut -> putBits ((Int) 0, 1, "VOL_Random_Access");		//isn't this a system level flg?//	m_statsVOL.nBitsHead++;// End: modified by Hughes	  4/9/98	cout << "VOL Overhead" << "\t\t" << m_statsVOL.nBitsHead << "\n\n";	cout.flush ();}//encode GOV header, modified by SONY 980212Void CVideoObjectEncoder::codeGOVHead (Time t){	cout << "GOV Header (t=" << t << ")\n\n";	m_pbitstrmOut->reset ();				// Start code	m_pbitstrmOut -> putBits (START_CODE_PREFIX, NUMBITS_START_CODE_PREFIX, "GOV_Start_Code");	m_pbitstrmOut -> putBits (GOV_START_CODE, NUMBITS_GOV_START_CODE, "GOV_Start_Code");	m_statsVOL.nBitsHead += NUMBITS_START_CODE_PREFIX + NUMBITS_GOV_START_CODE;	// Time code/*modified by SONY (98/03/30) *//*	Time tGOVCode = ((Int)(t * m_volmd.iClockRate / m_volmd.dFrameHz)) / m_volmd.iClockRate;*//*modified by SONY (98/03/30) End*//*              ORIGINAL	Time tGOVCode = ((Int)(t * m_volmd.iClockRate / m_volmd.dFrameHz) - m_volmd.iBbetweenP) / m_volmd.iClockRate;*/	// modified by swinder 980511	Time tGOVCode = (Time)(t / m_volmd.dFrameHz);	// this is because t is the source frame count and dFrameHz is the source frame rate,	// tGOVCode is therefore in seconds rounded down. I see no reason for clock rate to be	// used here - swinder	if(tGOVCode<0) tGOVCode=0;	Time tCodeHou = (tGOVCode / 3600)%24;	Time tCodeMin = (tGOVCode / 60) % 60;	Time tCodeSec = tGOVCode % 60;	m_pbitstrmOut -> putBits (tCodeHou, NUMBITS_GOV_TIMECODE_HOUR, "GOV_Time_Code_Hour");	m_statsVOL.nBitsHead += NUMBITS_GOV_TIMECODE_HOUR;	m_pbitstrmOut -> putBits (tCodeMin, NUMBITS_GOV_TIMECODE_MIN, "GOV_Time_Code_Min");	m_statsVOL.nBitsHead += NUMBITS_GOV_TIMECODE_MIN;	m_pbitstrmOut -> putBits (MARKER_BIT, 1, "Marker_Bit");	m_statsVOL.nBitsStuffing += 1;	m_pbitstrmOut -> putBits (tCodeSec, NUMBITS_GOV_TIMECODE_SEC, "GOV_Time_Code_Sec");	m_statsVOL.nBitsHead += NUMBITS_GOV_TIMECODE_SEC;	Int iClosedGOV;	if ((m_vopmd.vopPredType==IVOP)&&(m_volmd.iBbetweenP==0))		iClosedGOV=1;	else		iClosedGOV=0;	m_pbitstrmOut -> putBits (iClosedGOV, 1, "GOV_Closed");	m_statsVOL.nBitsHead += 1;	m_pbitstrmOut -> putBits (0, 1, "GOV_Broken_Link");	m_statsVOL.nBitsHead += 1;		m_statsVOL.nBitsStuffing += m_pbitstrmOut->flush ();	//m_pbitstrmOut -> putBits (15, 4, "byte_align");	//m_statsVOL.nBitsHead += 4;		m_tModuloBaseDisp = tGOVCode;	m_tModuloBaseDecd = tGOVCode;}//980212Void CVideoObjectEncoder::codeVOPHeadInitial(){	// Start code		m_pbitstrmOut -> putBits (START_CODE_PREFIX, NUMBITS_START_CODE_PREFIX, "VOP_Start_Code");	m_pbitstrmOut -> putBits (VOP_START_CODE, NUMBITS_VOP_START_CODE, "VOP_Start_Code");	m_statsVOP.nBitsHead += NUMBITS_START_CODE_PREFIX + NUMBITS_VOP_START_CODE;	// prediction type	m_pbitstrmOut -> putBits (m_vopmd.vopPredType, NUMBITS_VOP_PRED_TYPE, "VOP_Pred_Type");	m_statsVOP.nBitsHead += NUMBITS_VOP_PRED_TYPE;	// Time reference	Time tCurrSec = (Int)(m_t / m_volmd.dFrameHz);		// current time in seconds//	Time tCurrSec = m_t / SOURCE_FRAME_RATE;		    // current time in seconds	m_nBitsModuloBase = tCurrSec - (((m_vopmd.vopPredType != BVOP) ||		(m_vopmd.vopPredType == BVOP && m_volmd.volType == ENHN_LAYER )) ?			m_tModuloBaseDecd : m_tModuloBaseDisp);	assert(m_nBitsModuloBase<=31);	m_pbitstrmOut -> putBits ((Int) 0xFFFFFFFE, (UInt) m_nBitsModuloBase + 1, "VOP_Modulo_Time_Base");	m_statsVOP.nBitsHead += m_nBitsModuloBase + 1;	m_iVopTimeIncr = (Int)(m_t * m_volmd.iClockRate / m_volmd.dFrameHz - tCurrSec * m_volmd.iClockRate);//	m_iVopTimeIncr = m_t * m_volmd.iClockRate / SOURCE_FRAME_RATE - tCurrSec * m_volmd.iClockRate;	m_pbitstrmOut->putBits ((Int) 1, 1, "Marker"); // marker bit	Added for error resilient mode by Toshiba(1997-11-14)	m_statsVOP.nBitsStuffing ++;	m_pbitstrmOut -> putBits (m_iVopTimeIncr, m_iNumBitsTimeIncr, "VOP_Time_Incr");	m_statsVOP.nBitsHead += m_iNumBitsTimeIncr;// Modified for error resilient mode by Toshiba(1997-11-14)	m_pbitstrmOut->putBits ((Int) 1, 1, "Marker"); // marker bit	m_statsVOP.nBitsStuffing ++;	if ( m_vopmd.vopPredType != BVOP ||		(m_vopmd.vopPredType == BVOP && m_volmd.volType == ENHN_LAYER ))	{	//update modulo time base		m_tModuloBaseDisp = m_tModuloBaseDecd;							//of the most recently displayed I/Pvop		m_tModuloBaseDecd = tCurrSec;							//of the most recently decoded I/Pvop	}}Void CVideoObjectEncoder::codeNonCodedVOPHead (){	codeVOPHeadInitial();	m_pbitstrmOut -> putBits (0, 1, "VOP_Coded");	m_statsVOP.nBitsHead++;}Void CVideoObjectEncoder::codeVOPHead (){	codeVOPHeadInitial();	m_pbitstrmOut -> putBits (1, 1, "VOP_Coded");	m_statsVOP.nBitsHead++;	if(m_volmd.bShapeOnly==FALSE)	{		if (m_vopmd.vopPredType == PVOP) {			m_pbitstrmOut -> putBits (m_vopmd.iRoundingControl, 1, "VOP_Rounding_Type");			m_statsVOP.nBitsHead++;		}	}	if (m_volmd.fAUsage != RECTANGLE) {		if (!(m_uiSprite == 1 && m_vopmd.vopPredType == IVOP)) {			m_pbitstrmOut->putBits (m_rctCurrVOPY.width, NUMBITS_VOP_WIDTH, "VOP_Width");			m_pbitstrmOut->putBits ((Int) 1, 1, "Marker"); // marker bit			m_pbitstrmOut->putBits (m_rctCurrVOPY.height (), NUMBITS_VOP_HEIGHT, "VOP_Height");			m_pbitstrmOut->putBits ((Int) 1, 1, "Marker"); // marker bit			m_statsVOP.nBitsHead += NUMBITS_VOP_WIDTH + NUMBITS_VOP_HEIGHT;			m_statsVOP.nBitsStuffing += 2;			if (m_rctCurrVOPY.left >= 0) {				m_pbitstrmOut -> putBits (m_rctCurrVOPY.left, NUMBITS_VOP_HORIZONTAL_SPA_REF, "VOP_Hori_Ref");			} else {				m_pbitstrmOut -> putBits (m_rctCurrVOPY.left & 0x00001FFFF, NUMBITS_VOP_HORIZONTAL_SPA_REF, "VOP_Hori_Ref");			}			m_pbitstrmOut->putBits ((Int) 1, 1, "Marker"); // marker bit			if (m_rctCurrVOPY.top >= 0) {				m_pbitstrmOut -> putBits (m_rctCurrVOPY.top, NUMBITS_VOP_VERTICAL_SPA_REF, "VOP_Vert_Ref");			} else {				m_pbitstrmOut -> putBits (m_rctCurrVOPY.top & 0x00001FFFF, NUMBITS_VOP_VERTICAL_SPA_REF, "VOP_Vert_Ref");			}			m_statsVOP.nBitsHead += NUMBITS_VOP_HORIZONTAL_SPA_REF + NUMBITS_VOP_VERTICAL_SPA_REF;			m_statsVOP.nBitsStuffing += 1;		}		if ( m_volmd.volType == ENHN_LAYER && m_volmd.iEnhnType == 1 ) {			m_pbitstrmOut->putBits (1, 1, "Background Composition");			m_statsVOP.nBitsHead++;		}// begin: added by Sharp (98/3/24)		else if ( m_volmd.volType == ENHN_LAYER && m_volmd.iEnhnType == 2 ) {			m_pbitstrmOut->putBits (0, 1, "Background Composition");			m_statsVOP.nBitsHead++;		}// end: added by Sharp (98/3/24)		m_pbitstrmOut->putBits (m_volmd.bNoCrChange, 1, "VOP_CR_Change_Disable");		m_statsVOP.nBitsHead++;        // tentative solution for normal sprite bitstream exchange		m_pbitstrmOut->putBits (0, 1, "VOP_Constant_Alpha");		m_statsVOP.nBitsHead++;	}

⌨️ 快捷键说明

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