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

📄 mode.hpp

📁 visual c++小波技术和工程实践随书光盘
💻 HPP
📖 第 1 页 / 共 2 页
字号:
	Int iRoundingControlEncSwitch;
	ShapeBPredDir fShapeBPredDir;	//B-VOP形状编码的预测方向
	Int iVopConstantAlphaValue;		//用于二值或者灰度形状信息的编码
//OBSSFIX_MODE3
	Bool bBGComposition;
//~OBSSFIX_MODE3

	Int iOpaque;
	Int iTransparent;
	Int iIntraCAE;
	Int iInterCAE;
	Int iNoUpdate;
	Int iUpsampling;
	Int iIntraBlocks;
	Int iInterBlocks;
	Int iInter4vBlocks;
	Int iNotCodedBlocks;
	Int iDCTCoefs;
	Int iDCTLines;
	Int iVLCSymbols;
	Int iVLCBits;
	Int iAPM;
	Int iNPM;
	Int iInterpolateMCQ;
	Int iForwBackMCQ;
	Int iHalfpel2;
	Int iHalfpel4;
	Int iSadct;
	Int iQuarterpel;

	//运动信息编码部分
	MVInfo	mvInfoForward;		//前向运行信息
	MVInfo	mvInfoBackward;	//后向运行信息
	Int	iSearchRangeForward;		//前向运动预测的最大搜索范围
	Int	iSearchRangeBackward;	//后向运动预测的最大搜索范围

	Bool bInterlace;				//隔行扫描编码标志 
	Bool bTopFieldFirst;			//是否从顶端开始
	Bool bAlternateScan;			//逐行扫描方式
	Int  iDirectModeRadius;		//运动预测搜索模式
	//可缩放性编码部分
	Int iRefSelectCode;
	Int iLoadForShape;			//前向形状部分
	Int iLoadBakShape;			//后向形状部分
	Bool bShapeCodingType;		//视频对象平面形状编码类型:0为帧内编码;1为帧间编码。
	SptXmitMode SpriteXmitMode;	//sprite传送模式 

	int		m_iVopID;			//视频对象平面的编号
	int		m_iNumBitsVopID;	//编码数字
	int		m_iVopID4Prediction_Indication;
	int		m_iVopID4Prediction;

	RRVmodeStr	RRVmode;
} VOPMode;




class CMBMode // MacroBlock Mode
{
public:
	// Constructors
	~CMBMode ();
    //CMBMode () {}  // forbidden (SB)
	CMBMode (Int iAuxCompCount=0); 
	CMBMode (const CMBMode& md);

	// Operations
	Void setCodedBlockPattern (Int blkn, Bool bisCoded) 
								{m_rgbCodedBlockPattern[(UInt) blkn - 1] = bisCoded;}
	Void setCodedBlockPattern (const Bool* rgbblockNum);
	Void setMinError (Int blkn, Int iminError)
								{m_rgfltMinErrors[(UInt) blkn - 1] = (Float) iminError;}
	Void setMinError (const Float* pfltminError);
	Void operator = (const CMBMode& md);

	// Attributes
	Bool getCodedBlockPattern (Int blkn) const 
								{return m_rgbCodedBlockPattern[(UInt) blkn - 1];};
	Bool* getCodedBlockPattern () const {return m_rgbCodedBlockPattern;}
	Float getMinError (Int blkn) const
									{return m_rgfltMinErrors[(UInt) blkn - 1];};
	Float* getMinError () const {return m_rgfltMinErrors;}
  UInt    blkEnd() const {return m_uiNumBlks;}

	// Some extra data member
	TransparentStatus m_rgTranspStatus [11]; 
		// indicating the transparency status of the MB, either ALL, PARTIAL, or NONE transparent
		// 0: 16x16,  1-4: 8x8
	Int m_rgNumNonTranspPixels [11]; // number of non-transparent pixels

	/*BBM// Added for Boundary by Hyundai(1998-5-9)
        TransparentStatus m_rgTranspStatusBBM [11];
        Bool m_bMerged [7];
	// End of Hyundai(1998-5-9)*/

	// Added for field based MC padding by Hyundai(1998-5-9)
	TransparentStatus m_rgFieldTranspStatus [5];
	Bool m_rgbFieldPadded[5];
	// End of Hyundai(1998-5-9)

	Bool m_bPadded;				// to see whether this all-transparent has been padded
	Bool m_bSkip;				// is the Macroblock skiped. = COD in H.263
// GMC
	Bool m_bMCSEL;                          // whether the MB is the GMC macroblock
// ~GMC
	CODAlpha* m_pCODAlpha;		// alpha Macroblock coded status
	MBType m_mbType;			// macroblock type, DIRECT, FORWARD, BACKWARD, or INTERPOLATE
	DCTMode m_dctMd;			// is the Macroblock inter- or intra- coded
	ShapeMode m_shpmd;			//different context for the first MMR code

	ShapeSSMode m_shpssmd;		//context for the spatial scalable shape code		//OBSS_SAIT_991015

	Int m_intStepDelta;			// change of quantization stepsize = DQUANT in h.263
	Bool m_bhas4MVForward;		//whether the MB has four motion vectors (for forward vectors)
	Bool m_bhas4MVBackward;		//whether the MB has four motion vectors (for backward vectors)
	Bool m_bFieldMV;			// whether the MB is compensated by field motion vectors (for forward vectors) : yes=1
	Bool m_bForwardTop;			// TRUE iff Current Forward Top field MV references the BOTTOM field
	Bool m_bForwardBottom;		// TRUE iff Current Forward Bottom field MV references the BOTTOM field
	Bool m_bBackwardTop;		// TRUE iff Current Backward Top field MV references the BOTTOM field
	Bool m_bBackwardBottom;		// TRUE iff Current Backward Bottom field MV references the BOTTOM field
	Bool m_bFieldDCT;			// use field DCT or not : yes=1
	Bool m_bPerspectiveForward; //whether the MB uses forward perspective motion
	Bool m_bPerspectiveBackward;//whether the MB uses backward perspective motion
	Int  m_stepSize;				//qp for texture
	Int  m_stepSizeDelayed;		//qp delayed by 1 MB for intra_vlc_dc_thr switch
	Int  m_stepSizeAlpha;		//qp for alpha
	IntraPredDirection* m_preddir; // horizonal or vertical
	Bool m_bACPrediction;		// use AC prediction or not
	Bool* m_pbACPredictionAlpha;  // alpha version of above
	Bool m_bInterShapeCoding;	//use predicted binary shape
	Bool m_bCodeDcAsAc;			//code Intra DC with Ac VLC
	Bool m_bCodeDcAsAcAlpha;	// alpha version of above
	Bool m_bColocatedMBSkip;	// for B-VOP, colocated MB skipped or not
// GMC
	Bool m_bColocatedMBMCSEL;       // for B-VOP, colocated MB is a GMC macroblock or not
// ~GMC
	Int  m_iVideoPacketNumber;	//	Video Packet Number; added by Toshiba
	CVector m_vctDirectDeltaMV;	// delta vector for direct mode

// kimata
	Int  m_iNPSegmentNumber;

private:

	Bool* m_rgbCodedBlockPattern; //for each block, 1 = some non-DC components are coded
	Float* m_rgfltMinErrors; //mininal prediction errors for each luminance block
  Int m_iAuxCompCount; // number of alpha planes (MAC)
  UInt m_uiNumBlks;
};


class CDirectModeData // to handle data for direct mode in B-VOP
{
public:
	// Constructor
	~CDirectModeData ();
	CDirectModeData ();

	// Attributes
	UInt numMB () const {return m_uiNumMB;}
	UInt numMBX () const {return m_uiNumMBX;}
	UInt numMBY () const {return m_uiNumMBY;}
	Bool inBound (UInt iMbIdx) const; // check whether the index is inbound
	Bool inBound (UInt idX, UInt idY) const; // check whether the index is inbound
	CMBMode** mbMode () const {return m_ppmbmd;}
	const CMBMode* mbMode (UInt iMbIdx) const 
		{assert (inBound (iMbIdx)); return m_ppmbmd [iMbIdx];}
	const CMBMode* mbMode (UInt idX, UInt idY) const 
		{assert (inBound (idX, idY)); return m_ppmbmd [idX + idY * m_uiNumMBX];}
	CMotionVector** mv () const {return m_prgmv;}
	const CMotionVector* mv (UInt iMbIdx) const 
		{assert (inBound (iMbIdx)); return m_prgmv [iMbIdx];}
	const CMotionVector* mv (UInt idX, UInt idY) const 
		{assert (inBound (idX, idY)); return m_prgmv [idX + idY * m_uiNumMBX];}

	// Operations
	Void reassign (UInt numMBX, UInt numMBY, Int iAuxCompCount);
	Void assign (UInt imb, const CMBMode& mbmd, const CMotionVector* rgmv);

///////////////// implementation /////////////////

private:
	own CMBMode** m_ppmbmd;
	own CMotionVector** m_prgmv; // [m_uiNumMB][5]
	UInt m_uiNumMB, m_uiNumMBX, m_uiNumMBY;

	Void destroyMem ();

};

class CStatistics
{
public:

	//constructor 
	CStatistics ( Int iAuxCompCount );
  CStatistics ( const CStatistics& statSrc );
	~CStatistics ();

	//resultant
	Void print (Bool bVOPPrint = FALSE);
	CStatistics& operator = (const CStatistics& statSrc);

	//Operation
	Void operator += (const CStatistics& statSrc);
	Void reset ();
	UInt total ();
	UInt head ();
  Void setAuxCompCount(Int iAuxCompCount) {m_iAuxCompCount=iAuxCompCount;}

	//data members
	UInt nBitsHead;
	UInt nBitsY;
	UInt nBitsCr;
	UInt nBitsCb;
	UInt nBitsA;
	UInt nBitsShapeMode;
	UInt nBitsCOD;
	UInt nBitsCBPY;
	UInt nBitsMCBPC;
// GMC
	UInt nBitsMCSEL;
// ~GMC
	UInt nBitsDQUANT;
	UInt nBitsMODB;
	UInt nBitsCBPB;
	UInt nBitsMBTYPE;
	UInt nBitsIntraPred;	//intra ac/dc switch
	UInt nBitsNoDCT;		//no. of DCT in sepr m-s-t mode
	UInt nBitsCODA;
	UInt nBitsCBPA;
	UInt nBitsMODBA;
	UInt nBitsCBPBA;
	UInt nBitsStuffing;
	UInt nSkipMB;
// GMC
	UInt nMCSELMB;
// ~GMC
	UInt nInterMB;
	UInt nInter4VMB;
	UInt nIntraMB;
	UInt nDirectMB;
	UInt nForwardMB;
	UInt nBackwardMB;
	UInt nInterpolateMB;
	UInt nBitsInterlace;	// incl all interlaced info in MB header
	UInt nFieldForwardMB;
	UInt nFieldBackwardMB;
	UInt nFieldInterpolateMB;
	UInt nFieldDirectMB;
	UInt nFieldDCTMB;
	UInt nVOPs;				// VOP counter for normalizing statistics
	UInt nBitsMV;
	UInt nBitsShape;
	UInt nBitsTotal;
	Double dSNRY;
	Double dSNRU;
	Double dSNRV;
	Double* dSNRA;
	UInt nQMB;
	UInt nQp;

private:
  CStatistics () {}

	UInt nBitsTexture;
  Int  m_iAuxCompCount;
};

class CRCMode
{
public:

	//constructor 
	CRCMode () {};
	~CRCMode () {};

	//resultant
	UInt updateQuanStepsize ();	// Target bits and quantization level calculation
	Bool skipNextFrame () const {return m_skipNextFrame;}
	Bool firstFrame () const {return m_bfirstFrame;}
	UInt noCodedFrame () const {return m_Nc;}  // return the coded P frames

	//Operation
	Void resetSkipMode () {m_skipNextFrame = FALSE; m_bfirstFrame = TRUE;}
	Void resetFirstFrame () {m_bfirstFrame = FALSE;}
	Bool skipThisFrame ();
	Void reset (UInt uiFirstFrame, UInt uiLastFrame, UInt uiTemporalRate, 
				UInt uiBufferSize, Double mad, UInt uiBitsFirstFrame, Double dFrameHz);
	Void setMad (Double mad) {m_Ep = m_Ec; m_Ec = mad;}
	Void setQc (UInt QStep) {m_Qc = QStep;}
	Void updateRCModel (UInt uiBitsTotalCurr, UInt uiBitsHeadCurr);		// Update RD model

private:

	Void RCModelEstimator (UInt nWindowSize);	// Rate Control: RD model estimator

	Double m_X1;// 1st order coefficient
	Double m_X2;// 2nd order coefficient
	UInt m_Rs;	// bit rate for sequence. e.g. 24000 bits/sec	
	UInt m_Rf;	// bits used for the first frame, e.g. 10000 bits
	UInt m_Rc;	// bits used for the current frame after encoding
	UInt m_Rp;	// bits to be removed from the buffer per picture
	Double m_Ts;// number of seconds for the sequence, e.g. 10 sec
	Double m_Ec;// mean absolute difference for the current frame after motion compensation
	Double m_Ep;// mean absolute difference for the previous frame after motion compensation
	UInt m_Qc;	// quantization level used for the current frame
	UInt m_Qp;	// quantization level used for the previous frame
	UInt m_Nr;	// number of P frames remaining for encoding
	UInt m_Nc;	// number of P frames coded
	UInt m_Ns;	// distance between encoded frames
	Int m_Rr;	// number of bits remaining for encoding this sequence 
	UInt m_T;	// target bit to be used for the current frame
	UInt m_S;	// number of bits used for encoding the previous frame
	UInt m_Hc;	// header and motion vector bits used in the current frame
	UInt m_Hp;	// header and motion vector bits used in the previous frame
	UInt m_Bs;	// buffer size 
	Int m_B;	// current buffer level
	Bool m_skipNextFrame;						// TRUE if buffer is full
	Bool m_bfirstFrame;							// TRUE if this is the first frame
	UInt m_rgQp[RC_MAX_SLIDING_WINDOW];			// quantization levels for the past frames
	Double m_rgRp[RC_MAX_SLIDING_WINDOW];		// scaled encoding complexity used for the past frames;
	Bool m_rgRejected[RC_MAX_SLIDING_WINDOW];	// outliers
};

#endif	//__MODE_H

⌨️ 快捷键说明

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