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

📄 mbheaddec.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************This software module was originally developed by 	Wei-ge Chen (wchen@microsoft.com), Microsoft Corporation	Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation	Simon Winder (swinder@microsoft.com), Microsoft Corporation	(date: July, 1997)and edited by	Yoshihiro Kikuchi (TOSHIBA CORPORATION)	Takeshi Nagai (TOSHIBA CORPORATION)	Toshiaki Watanabe (TOSHIBA CORPORATION)	Noboru Yamaguchi (TOSHIBA CORPORATION)and also edited by	Dick van Smirren (D.vanSmirren@research.kpn.com), KPN Research	Cor Quist (C.P.Quist@research.kpn.com), KPN Research	(date: July, 1998)and also edited by	Yoshinori Suzuki (Hitachi, Ltd.)and also edited by	Hideaki Kimata (NTT)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. Microsoft 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) 1996, 1997.Module Name:	MBHeadDec.cppAbstract:	MacroBlock overhead decoderRevision History:	This software module was 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)	for object based temporal scalability.    	Dec 20, 1997:	Interlaced tools added by NextLevel Systems (GI)                    X. Chen (xchen@nlvl.com), B. Eifrig (beifrig@nlvl.com)	Feb. 24, 1999:	GMC added by Y. Suzuki (Hitachi, Ltd.)	Mar.13	2000 : MB stuffing decoding added by Hideaki Kimata (NTT)	May.25  2000 : MB stuffing decoding on the last MB by Hideaki Kimata (NTT)*************************************************************************/#include "typeapi.h"#include "codehead.h"#include "mode.hpp"#include "global.hpp"#include "entropy/bitstrm.hpp"#include "entropy/entropy.hpp"#include "entropy/huffman.hpp"#include "vopses.hpp"#include "vopsedec.hpp"#ifdef __MFC_#ifdef _DEBUG#undef THIS_FILEstatic char BASED_CODE THIS_FILE[] = __FILE__;#endif#define new DEBUG_NEW				   #endif // __MFC_#define ASSERT(a) if (!(a)) { printf("iso mbheaddec throw %d\n", __LINE__);throw((int)__LINE__);}Void CVideoObjectDecoder::skipAnyStuffing(){	if(m_vopmd.vopPredType==IVOP)	{		// stuffing mb "000000001"		while(m_pbitstrmIn->peekBits(9) == 1)			m_pbitstrmIn->getBits(9);	}	else	{		// no-skip, followed by stuffing mb "000000001"		while(m_pbitstrmIn->peekBits(10) == 1)			m_pbitstrmIn->getBits(10);	}}Void CVideoObjectDecoder::decodeMBTextureHeadOfIVOP (CMBMode* pmbmd, Int& iCurrentQP, Bool *pbRestart){	assert (pmbmd->m_rgTranspStatus [0] != ALL);	Int iBlk = 0, cNonTrnspBlk = 0;	for (iBlk = (Int) Y_BLOCK1; iBlk <= (Int) Y_BLOCK4; iBlk++) {		if (pmbmd->m_rgTranspStatus [iBlk] != ALL)				cNonTrnspBlk++;	}	Int iCBPC = 0;	Int iCBPY = 0;	Int iMCBPC = 8;			while (iMCBPC == 8) {		iMCBPC = m_pentrdecSet->m_pentrdecMCBPCintra->decodeSymbol ();	};	assert (iMCBPC >= 0 && iMCBPC <= 8);	pmbmd->m_dctMd = INTRA;	pmbmd->m_bSkip = FALSE;  //reset for direct mode 	pmbmd->m_bMCSEL = FALSE; //reset for direct mode 	pmbmd->m_bFieldMV = 0;	pmbmd->m_intStepDelta = 0;	if (iMCBPC > 3)		pmbmd->m_dctMd = INTRAQ;	iCBPC = iMCBPC % 4;    if (!short_video_header) {		pmbmd->m_bACPrediction = m_pbitstrmIn->getBits(1);	}	switch (cNonTrnspBlk) {	case 1:		iCBPY = m_pentrdecSet->m_pentrdecCBPY1->decodeSymbol ();		break;	case 2:		iCBPY = m_pentrdecSet->m_pentrdecCBPY2->decodeSymbol ();		break;	case 3:		iCBPY = m_pentrdecSet->m_pentrdecCBPY3->decodeSymbol ();		break;	case 4:		iCBPY = m_pentrdecSet->m_pentrdecCBPY->decodeSymbol ();		break;	default:		assert (FALSE);	}	//fprintf(stderr,"CBPY=%d\n",iCBPY);	setCBPYandC (pmbmd, iCBPC, iCBPY, cNonTrnspBlk);	if (pmbmd->m_dctMd == INTRAQ)	{		Int iDQUANT = m_pbitstrmIn->getBits (2);		switch (iDQUANT) {		case 0:			pmbmd->m_intStepDelta = -1;			break;		case 1:			pmbmd->m_intStepDelta = -2;			break;		case 2:			pmbmd->m_intStepDelta = 1;			break;		case 3:			pmbmd->m_intStepDelta = 2;			break;		default:			assert (FALSE);		}		iCurrentQP += pmbmd->m_intStepDelta;		Int iQuantMax = (1<<m_volmd.uiQuantPrecision) - 1;		iCurrentQP = checkrange (iCurrentQP, 1, iQuantMax);	}	pmbmd->m_stepSize = iCurrentQP;	if (m_vopmd.bInterlace)		pmbmd->m_bFieldDCT = m_pbitstrmIn->getBits (1); // get dct_type	setDCVLCMode(pmbmd, pbRestart);	//printf("(%d:%d.%d)", pmbmd->m_stepSize,iMCBPC,pmbmd->m_bCodeDcAsAc);}Void CVideoObjectDecoder::decodeMBAlphaHeadOfIVOP (CMBMode* pmbmd, Int iCurrQP, Int iCurrQPA, Int iVopQP, Int iVopQPA, Int iAuxComp){	// update alpha quantiser	if(!m_volmd.bNoGrayQuantUpdate)	{		iCurrQPA = (iCurrQP * iVopQPA) / iVopQP;		if(iCurrQPA<1)			iCurrQPA = 1;	}	pmbmd->m_stepSizeAlpha = iCurrQPA;	assert (pmbmd->m_rgTranspStatus [0] != ALL);	// coded	Int iCODA = m_pbitstrmIn->getBits (1);	pmbmd->m_pCODAlpha[iAuxComp] = iCODA ? ALPHA_ALL255 : ALPHA_CODED;	if(iCODA)		return;	// intra prediction for ac	pmbmd->m_pbACPredictionAlpha[iAuxComp] = m_pbitstrmIn->getBits (1);	// decode CBPA	Int iBlk = 0, cNonTrnspBlk = 0;	for (iBlk = (Int) Y_BLOCK1; iBlk <= (Int) Y_BLOCK4; iBlk++) {		if (pmbmd->m_rgTranspStatus [iBlk] != ALL)				cNonTrnspBlk++;	}	Int iCBPA = 0;	switch (cNonTrnspBlk) {	case 1:		iCBPA = 1 - m_pentrdecSet->m_pentrdecCBPY1->decodeSymbol ();		break;	case 2:		iCBPA = 3 - m_pentrdecSet->m_pentrdecCBPY2->decodeSymbol ();		break;	case 3:		iCBPA = 7 - m_pentrdecSet->m_pentrdecCBPY3->decodeSymbol ();		break;	case 4:		iCBPA = 15 - m_pentrdecSet->m_pentrdecCBPY->decodeSymbol ();		break;	default:		assert (FALSE);	}	Int iBitPos = 1;	for (iBlk = A_BLOCK1; iBlk <= A_BLOCK4; iBlk++)	{		if (pmbmd->m_rgTranspStatus [iBlk - 6] != ALL)	{			pmbmd->setCodedBlockPattern (			  iBlk+iAuxComp*4, 				(iCBPA >> (cNonTrnspBlk - iBitPos)) & 1			);			iBitPos++;		}		else			pmbmd->setCodedBlockPattern (iBlk+iAuxComp*4, 0);	}}// InterVoid CVideoObjectDecoder::decodeMBTextureHeadOfPVOP (CMBMode* pmbmd, Int& iCurrentQP, Bool *pbRestart){	assert (pmbmd->m_rgTranspStatus [0] != ALL);	Int iBlk = 0, cNonTrnspBlk = 0;	for (iBlk = (Int) Y_BLOCK1; iBlk <= (Int) Y_BLOCK4; iBlk++) {		if (pmbmd->m_rgTranspStatus [iBlk] != ALL)				cNonTrnspBlk++;	}	Int iCBPC = 0;	Int iCBPY = 0;	Int iMCBPC =0;	do {		pmbmd->m_bSkip = m_pbitstrmIn->getBits (1);		if (!pmbmd->m_bSkip) {			iMCBPC = m_pentrdecSet->m_pentrdecMCBPCinter->decodeSymbol ();			assert (iMCBPC >= 0 && iMCBPC <= 20);			}	} while((!pmbmd->m_bSkip) && (iMCBPC == 20));	if (!pmbmd->m_bSkip) {		Int iMBtype = iMCBPC / 4; //per H.263's MBtype		pmbmd -> m_bFieldMV = FALSE;		switch (iMBtype) {					case 0:			pmbmd->m_dctMd = INTER;			pmbmd -> m_bhas4MVForward = FALSE;			break;		case 1:			pmbmd->m_dctMd = INTERQ;			pmbmd -> m_bhas4MVForward = FALSE;			break;		case 2:			pmbmd -> m_dctMd = INTER;			pmbmd -> m_bhas4MVForward = TRUE;			break;		case 3:			pmbmd->m_dctMd = INTRA;			break;		case 4:			pmbmd->m_dctMd = INTRAQ;			break;		default:			assert (FALSE);		}		iCBPC = iMCBPC % 4;// GMC		pmbmd->m_bMCSEL = FALSE;		if((pmbmd->m_dctMd == INTER || pmbmd->m_dctMd == INTERQ) && (pmbmd -> m_bhas4MVForward == FALSE) && (m_uiSprite == 2 && m_vopmd.vopPredType == SPRITE))		{			pmbmd->m_bMCSEL = m_pbitstrmIn->getBits (1);		}// ~GMC		if (pmbmd->m_dctMd == INTRA || pmbmd->m_dctMd == INTRAQ)	{			if (!short_video_header) {  				pmbmd->m_bACPrediction = m_pbitstrmIn->getBits (1); 			} 						switch (cNonTrnspBlk) {			case 1:				iCBPY = m_pentrdecSet->m_pentrdecCBPY1->decodeSymbol ();				break;			case 2:				iCBPY = m_pentrdecSet->m_pentrdecCBPY2->decodeSymbol ();				break;			case 3:				iCBPY = m_pentrdecSet->m_pentrdecCBPY3->decodeSymbol ();				break;			case 4:				iCBPY = m_pentrdecSet->m_pentrdecCBPY->decodeSymbol ();				break;			default:				assert (FALSE);			}		}		else {			switch (cNonTrnspBlk) {			case 1:				iCBPY = 1 - m_pentrdecSet->m_pentrdecCBPY1->decodeSymbol ();				break;			case 2:				iCBPY = 3 - m_pentrdecSet->m_pentrdecCBPY2->decodeSymbol ();				break;

⌨️ 快捷键说明

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