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

📄 vopseenc.hpp

📁 《Visual C++小波变换技术与工程实践》靳济芳编著的光盘程序。
💻 HPP
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************

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
	(date: March, 1996)

and 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)

    Mathias Wien (wien@ient.rwth-aachen.de), RWTH Aachen / Robert BOSCH GmbH 

and also edited by
	Yoshinori Suzuki (Hitachi, Ltd.)

and also edited by
    Fujitsu Laboratories Ltd. (contact: Eishi Morimatsu)
    Sehoon Son (shson@unitel.co.kr) Samsung AIT

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:

	vopSeEnc.hpp

Abstract:

	Encoder for one VO.

Revision History:
	Sept. 30, 1997: Error resilient tools added by Toshiba
	Nov.  27, 1997: Spatial Scalable tools added 
						by Takefumi Nagumo(nagumo@av.crl.sony.co.jp) SONY corporation
	Dec 20, 1997:	Interlaced tools added by NextLevel Systems 
                    X. Chen (xchen@nlvl.com) B. Eifrig (beifrig@nlvl.com)
	Jun 16, 1998:	add Complexity Estimation syntax support
					Marc Mongenet (Marc.Mongenet@epfl.ch) - EPFL
    Feb.16, 1999:   add Quarter Sample 
                    Mathias Wien (wien@ient.rwth-aachen.de) 
	May  9, 1999:	tm5 rate control by DemoGraFX, duhoff@mediaone.net (added by mwi)
	Sep.06	1999 : RRV added by Eishi Morimatsu (Fujitsu Laboratories Ltd.) 

*************************************************************************/

#ifndef __VOPSEENC_HPP_ 
#define __VOPSEENC_HPP_

#ifndef SOURCE_FRAME_RATE				//assuming input source is always 30f/s
#define SOURCE_FRAME_RATE 30
#endif

#include "tm5rc.hpp"

class CFwdBlockDCT;

// HHI Schueuer:  scan selection classes to support the sadct
class CScanSelector {
public:
	virtual ~CScanSelector() {}

	//virtual const Int *select(const Int *scan, const Int *piCoeffWidths) { return scan; } 
	// Stefan Rauthenberg: <rauthenberg@HHI.DE> from the semantic point of view I'd prefer a return value of const Int* but 
	// this would cause conflicts with methods like decodeIntraTCOEF. 
	virtual Int *select(Int *scan, Bool bIsBoundary, Int iBlk) { return scan; } 
	// 09/19/99 HHI Schueuer
	virtual Int *select_DP(Int *scan, Bool bIsBoundary, Int iBlk, Int** rgiCurrMBCoeffWidth) {return scan; };
	// end 09/19/99
};

class CScanSelectorForSADCT: public CScanSelector {
public:
	CScanSelectorForSADCT(Int **rgiCurrMBCoeffWidth); 
	virtual ~CScanSelectorForSADCT();
	virtual Int *select(Int *scan, Bool bIsBoundary, Int iBlk);
	// 09/19/99 HHI Schueuer
	virtual Int *select_DP(Int *scan, Bool bIsBoundary, Int iBlk, Int** rgiCurrMBCoeffWidth);
	// end 09/19/99

private:
	Int **m_rgiCurrMBCoeffWidth;
	Int *m_adaptedScan;
};
// End HHI 

class CVideoObjectEncoder : public CVideoObject
{
friend class CSecurityDescriptor;
friend class CSessionEncoder;
// friend class CSessionEncoderTPS; ///// 97/12/22 // deleted by Sharp (98/2/12)
// friend class CVideoObjectEncoderTPS; ///// 97/12/22 // deleted by Sharp (98/2/12)
	friend class CEnhcBufferEncoder; // added by Sharp (98/2/10)
public:
	// Constructors
	~CVideoObjectEncoder ();
private:
  CVideoObjectEncoder ();				// default constructor - forbidden
public:
	CVideoObjectEncoder (
		UInt uiVOId,						// VO id
		VOLMode& volmd,						// VOL mode
		VOPMode& vopmd,						// VOP mode
		UInt nFirstFrame,					// number of total frames
		UInt nLastFrame,					// number of total frames
		Int iSessionWidth,					// session width, in case it's needed
		Int iSessionHeight,					// session height
		UInt uiRateControl,					// rate control type
		UInt uiBudget,						// bit budget for vop
		ostream* pstrmTrace,				// trace outstream
		UInt uiSprite,				// for sprite type // GMC
		UInt uiWarpAccuracy,				// for sprite warping
		Int iNumOfPnts,						// for sprite warping
		CSiteD** rgstDest,					// for sprite warping destination
		SptMode SpriteMode,					// sprite reconstruction mode
		CRct rctFrame,						// sprite warping source
		CRct rctSpt,                        // rct Sprite
		Int iMVFileUsage,					// 0==>no usage, 1==>read from MV file, 2==>write to MV file
		Char* pchMVFileName	    			// MV file name
	); // VOP mode

	// for back/forward shape
	CVideoObjectEncoder (
		UInt uiVOId,						// VO id
		VOLMode& volmd,						// VOL mode
		VOPMode& vopmd,						// VOP mode
		Int iSessionWidth,					// session width, in case it's needed
		Int iSessionHeight //,					// session height
	); // VOP mode

	// Attributes
	const COutBitStream* pOutStream () const {return m_pbitstrmOut;} // output bitstream
	const CStatistics& statVOL () const {return m_statsVOL;}
	const CStatistics& statVOP () const {return m_statsVOP;}

	// Operations
	Bool skipTest(
		Time t,
		VOPpredType vopPredType
	);
	Void swapSpatialScalabilityBVOP ();
	Void encode (
		Bool bVOP_Visible,				// whether the VOP at this time is encoded
		Time t,							// relative frame number for the current encoding
		VOPpredType vopPredType,
		const CVOPU8YUVBA* pvopfRefBaseLayer = NULL	//Reference image frm the base layer for spatial scalability
	);

// begin: added by Sharp (98/2/10)
	// for background composition
	Void BackgroundComposition (
				const Int width, Int height,
				const Int iFrame,	  
				const Int iPrev,	  
				const Int iNext,    
				const CVOPU8YUVBA* pvopcBuffP1,
				const CVOPU8YUVBA* pvopcBuffP2,
				const CVOPU8YUVBA* pvopcBuffB1,
				const CVOPU8YUVBA* pvopcBuffB2,
				const Char* pchReconYUVDir, Int iobj, const Char* pchPrefix, // for output file name
				FILE *pchfYUV  // added by Sharp (98/10/26)
	);
//OBSS_SAIT_991015
	//for base + enhancement layer composition(OBSS partial enhancement mode)
	Bool BackgroundComposition (
				const Int width, Int height,
				const Int iFrame,	  
				const CVOPU8YUVBA* pvopcBuffP1,
				const Char* pchReconYUVDir, Int iobj, const Char* pchPrefix, // for output file name
				FILE *pchfYUV,  // added by Sharp (98/10/26)
				FILE *pchfSeg
	);
//~OBSS_SAIT_991015
	Void set_LoadShape(
          Int* ieFramebShape, Int* ieFramefShape, // frame number for back/forward shape
          const Int iRate,	      // rate of enhancement layer
          const Int ieFrame,	      // current frame number
          const Int iFirstFrame,    // first frame number of sequence
          const Int iFirstFrameLoop // first frame number of the enhancement loop
        );
// end: added by Sharp (98/2/10)
///////////////// implementation /////////////////
///// 97/12/22 start
public:
	CVideoObjectEncoder* rgpbfShape [2]; // 0 : backward, 1: forward
///// 97/12/22 end

protected:
	//Time m_tIVOPCounter;
	//Time m_tEncodedVOPCounter;                      // for TPS only
	UInt m_nFirstFrame, m_nLastFrame, m_iBufferSize; //for rate control
	Int m_uiRateControl; // rate control type
	UInt m_uiGMCQP; // GMC_V2
	
	// bitstream stuff
	Char* m_pchBitsBuffer;
	COutBitStream* m_pbitstrmOut; // output bitstream
	Char* m_pchShapeBitsBuffer;
	COutBitStream* m_pbitstrmShape;
	COutBitStream* m_pbitstrmShapeMBOut;

//	Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC)
	Char** m_pchShapeBitsBuffer_DP;
	COutBitStream** m_pbitstrmShape_DP;
//	End Toshiba(1998-1-16:DP+RVLC)

	CEntropyEncoderSet* m_pentrencSet;
	
	// statistics 
	CStatistics m_statsVOL, m_statsVOP, m_statsMB;	// accumulated number of bits
	Double* m_rgdSNR;

	// for rate control
	CRCMode m_statRC;		// Rate control mode status
	TM5rc   m_tm5rc;
//	UInt m_uiTotalPrev;

	own CVOPU8YUVBA* m_pvopcOrig; // original reference VOP in a previous time
	own CVOPU8YUVBA* m_pvopcRefOrig0; // original reference VOP in a previous time
	own CVOPU8YUVBA* m_pvopcRefOrig1; // original reference VOP in a later time
	own CU8Image* m_puciRefQZoom0; // zoomed reference VOP in a previous time
	own CU8Image* m_puciRefQZoom1; // zoomed reference VOP in a later time

	// some fixed variables (VOL)
	Int m_iFrameWidthZoomYx2Minus2MB, m_iFrameWidthZoomYx2Minus2Blk;
	Int m_iFrameWidthZoomY, m_iFrameWidthZoomUV;

	// VOP variables
	CRct m_rctRefVOPZoom0, m_rctRefVOPZoom1;

	// for B-VOP
	// MB buffer data
	CU8Image *m_puciDirectPredMB, *m_puciInterpPredMB;
	PixelC *m_ppxlcDirectPredMBY, *m_ppxlcInterpPredMBY;

	CIntImage *m_piiDirectErrorMB, *m_piiInterpErrorMB;
	PixelI *m_ppxliDirectErrorMBY, *m_ppxliInterpErrorMBY;
	//moved to vopses.hpp
	//CVector m_vctDirectDeltaMV;	//MVDB for current MB
	
	// block data
	CFwdBlockDCT* m_pfdct;

	// error resilient variables
	Int m_iVopTimeIncr;
	UInt m_nBitsModuloBase;
	Int m_iVPCounter;//	Added for error resilient mode by Toshiba(1997-11-14)


	//	Added for data partitioning mode by Toshiba(1998-1-16)
	Int	m_numBitsVPMBnum;
	Int	m_numVideoPacket;
	//	End Toshiba(1998-1-16)

	// HHI Schueuer
	CScanSelector *m_pscanSelector;
	// end HHI

	// VO and VOL routines
	Void codeVOHead ();
	Void codeVOLHead (Int iSessionWidth, Int iSessionHeight);//, constt CRct& rctSprite);
	Void codeGOVHead (Time t);
	
// VOP routines
//	Void codeVOPHead (const CSiteD* rgstDest = NULL, CRct rctWarp = NULL);
	Int m_iMAD;  // for Rate Control
	Void codeVOPHead ();
	Void codeNonCodedVOPHead ();
	Void codeVOPHeadInitial();

	//Void decidePredType ();
	Void findTightBoundingBox ();
	Void findBestBoundingBox ();
	Void copyCurrToRefOrig1Y ();
	Void updateAllOrigRefVOPs ();
	Void biInterpolateY (
		const CVOPU8YUVBA* pvopcRefQ, const CRct& rctRefVOP, // reference VOP
		CU8Image* puciRefQZoom, const CRct& rctRefVOPZoom, Int iRoundingControl // reference zoomed VOP
	);

	Void encodeVOP ();
	Void encodeNSForIVOP ();
	Void encodeNSForIVOP_WithShape ();
	Void encodeNSForPVOP ();
	Void encodeNSForPVOP_WithShape ();
	Void encodeNSForBVOP ();
	Void encodeNSForBVOP_WithShape ();

    //classical sprite stuff
	Void encodeSptTrajectory (Time t, const CSiteD* rgstDest, const CRct& rctWarp); // code sprite info
	Void quantizeSptTrajectory (const CSiteD* rgstDest, CRct rctWarp);
	UInt codeWarpPoints ();
	//low latency sprite stuff
#define AVGPIECEMB 0
#define AVGUPDATEMB 1
	own CVOPU8YUVBA* m_pvopcSpt; // original sprite object
	//SptMode m_sptMode;  // sprite reconstruction mode : 0 -- basic sprite , 1 -- Object piece only, 2 -- Update piece only, 3 -- intermingled	
	CSiteD** m_pprgstDest; // destination sites
	Bool m_bSptZoom;  // the type of sprite warping(zoom/pan)
    Bool m_bSptHvPan; // the type of sprite warping(Horizontal or vertical panning)
	Bool m_bSptRightPiece; 	
	Int m_pSptmbBits[2]; // bits used by a sprite macroblock

⌨️ 快捷键说明

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