📄 vopsedec.no-opt
字号:
/*************************************************************************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)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 Fujitsu Laboratories Ltd. (contact: Eishi Morimatsu)and also edited by Takefumi Nagumo (nagumo@av.crl.sony.co.jp), Sony Corporation Sehoon Son (shson@unitel.co.kr) Samsung AITin 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: vopsedec.hAbstract: Decoder for one Video Object.Revision History: 09-30-97: merge error resilient changes from Toshiba by wchen@microsoft.com 11-30-97: added Spatial tools by Takefumi Nagumo(nagumo@av.crl.sony.co.jp) SONY corporation 12-20-97: Interlaced tools added by NextLevel Systems X. Chen (xchen@nlvl.com), B. Eifrig (beifrig@nlvl.com) Sep.06 1999 : RRV added by Eishi Morimatsu (Fujitsu Laboratories Ltd.) Feb.01 2000 : Bug fixed OBSS by Takefumi Nagumo (Sony) May.25 2000 : MB stuffing decoding on the last MB by Hideaki Kimata (NTT)*************************************************************************/#ifndef __VOPSEDEC_HPP_ #define __VOPSEDEC_HPP_// decoder.c relatedextern Bool main_short_video_header;// bitstrm.c related#ifdef MP4_STANDALONE#define MAX_BUFFER_SIZE (128*1024)#else#define MAX_BUFFER_SIZE (8*1024)#endif// Get the num-bit field of x starting from position p#define getbit(data, position, num) ((data >> (position + 1 - num)) & ~(~0 << num))extern Int m_lCounter;extern int nBytesAvailable;extern unsigned int g_bEOFReached;extern UInt m_uNumOfBitsInBuffer;extern Char m_chDecBuffer;extern int nTotalBytes;extern unsigned char MyBuffer[MAX_BUFFER_SIZE];extern UInt nSingBitRet;extern int g_nMP4VPTS;extern inline Void ReadFile();extern inline UInt getSingleBit ();//return 1 bit from the streamextern inline UInt getBits (UInt numBits);//return bits from the streamextern inline Int peekBits (UInt numBits); //peek bits from the streamextern inline Int peekBitsTillByteAlign (Int *nBitsToPeek) ; //peek 1-8 bits until the next byte alignmentextern inline Int peekBitsFromByteAlign (Int numBits) ; //peek from the stream at byte boundary#define MP4V_EOF() ((nBytesAvailable <= 0) ? (g_bEOFReached) : (0))#define MP4V_GETSINGLEBIT() \\if (m_uNumOfBitsInBuffer) \{ \ nSingBitRet = ((m_chDecBuffer&0x80) != 0);\ m_chDecBuffer = m_chDecBuffer << 1;\ m_uNumOfBitsInBuffer --;\}\else\{\ if(!nBytesAvailable)\ ReadFile();\\ m_chDecBuffer = MyBuffer[nTotalBytes-nBytesAvailable];\ nBytesAvailable--;\\ nSingBitRet = ((m_chDecBuffer&0x80) != 0);\ m_chDecBuffer = m_chDecBuffer << 1;\ m_uNumOfBitsInBuffer = 7;\}//return nSingBitRet;//((nSingBitRet) ? (1) : (0))#define MP4V_RETSINGLEBIT(nBitRet) \{\if (m_uNumOfBitsInBuffer) \{ \ *nBitRet =((m_chDecBuffer&0x80)!= 0);\ m_chDecBuffer = m_chDecBuffer << 1;\ m_uNumOfBitsInBuffer --;\}\else\{\ if(!nBytesAvailable)\ ReadFile();\\ m_chDecBuffer = MyBuffer[nTotalBytes-nBytesAvailable];\ nBytesAvailable--;\\ *nBitRet = ((m_chDecBuffer&0x80)!=0);\ m_chDecBuffer = m_chDecBuffer << 1;\ m_uNumOfBitsInBuffer = 7;\}\}#define MP4V_FLUSH(nExtraBits)\\ if(m_uNumOfBitsInBuffer==0)\ getBits (nExtraBits);\\ assert (m_uNumOfBitsInBuffer != 8);\ m_uNumOfBitsInBuffer = 0;#define MP4V_PEEKBITS(iBitsToRet, numBits)\{\ assert (numBits <= 32);\ Int nBitsToPeek = numBits - m_uNumOfBitsInBuffer;\ Int chNext, iNext;\\/* if (nBitsToPeek <= 0)*/\/* *iBitsToRet = getbit (m_chDecBuffer, 7, numBits); */\/* else*/\ {\ int nlocalBytes = nBytesAvailable;\\ if(!nBytesAvailable)\ {\ ReadFile();\ nlocalBytes = nBytesAvailable;\ }\ *iBitsToRet = getbit (m_chDecBuffer, 7, m_uNumOfBitsInBuffer);\ for (; nBitsToPeek > 0; nBitsToPeek -= 8)\ {\ if(!nBytesAvailable)\ {\ ReadFile();\ nlocalBytes = nBytesAvailable;\ }\ chNext = MyBuffer[nTotalBytes-nlocalBytes];\ iNext = chNext & 0x000000FF;\ nlocalBytes--;\\ if (nBitsToPeek < 8)\ {\ iNext = iNext >> (8 - nBitsToPeek);\ *iBitsToRet = iNext | ((*iBitsToRet) << nBitsToPeek);\ }\ else\ {\ *iBitsToRet = ((*iBitsToRet) << 8);\ *iBitsToRet |= iNext;\ }\ }\ }\}// huffman.c related#ifdef MP4V_NEW_VLD// Cache details for memory allocation#define CACHE_LINE_SIZE 64#define CACHE_LINE_MASK 0xFFFFFFC0// Maximum number of supported by the decoder#define MAX_VLD_TABLES 9// Individual ids for each table #define TABLE_ID_CBPY 0#define TABLE_ID_INTRADCY 1#define TABLE_ID_INTRADCC 2#define TABLE_ID_MBTYPEBVOP 3#define TABLE_ID_MCBPCINTRA 4#define TABLE_ID_MCBPCINTER 5#define TABLE_ID_MV 6#define TABLE_ID_DCT 7#define TABLE_ID_DCTINTRA 8// CBPY Table specific stuff#define MAX_SYMBOLS_FOR_CBPY 18#define MAX_SYMBOL_LENGTH_IN_CBPY 6// IntraDCY Table specific stuff#define MAX_SYMBOLS_FOR_INTRADCY 13#define MAX_SYMBOL_LENGTH_IN_INTRADCY 11// IntraDCc Table specific stuff#define MAX_SYMBOLS_FOR_INTRADCC 13#define MAX_SYMBOL_LENGTH_IN_INTRADCC 12// MbTypeBVOP Table specific stuff#define MAX_SYMBOLS_FOR_MBTYPEBVOP 4#define MAX_SYMBOL_LENGTH_IN_MBTYPEBVOP 4// MCBPCIntra Table specific stuff#define MAX_SYMBOLS_FOR_MCBPCINTRA 9#define MAX_SYMBOL_LENGTH_IN_MCBPCINTRA 9// MCBPCInter Table specific stuff#define MAX_SYMBOLS_FOR_MCBPCINTER 21#define MAX_SYMBOL_LENGTH_IN_MCBPCINTER 9// MV Table specific stuff#define MAX_SYMBOLS_FOR_MV 65#define MAX_SYMBOL_LENGTH_IN_MV 13// DCT Table specific stuff#define MAX_SYMBOLS_FOR_DCT 103#define MAX_SYMBOL_LENGTH_IN_DCT 12// DCTIntra Table specific stuff#define MAX_SYMBOLS_FOR_DCTINTRA 103#define MAX_SYMBOL_LENGTH_IN_DCTINTRA 12extern Char *g_OrgTables [MAX_VLD_TABLES];extern PNewVLDTable g_pTables [MAX_VLD_TABLES];#elseextern PPHUFFMAN_DEC_STRUCT m_pentrdecDCT;extern PPHUFFMAN_DEC_STRUCT m_pentrdecDCTIntra;extern PPHUFFMAN_DEC_STRUCT m_pentrdecMV;extern PPHUFFMAN_DEC_STRUCT m_pentrdecMCBPCintra;extern PPHUFFMAN_DEC_STRUCT m_pentrdecMCBPCinter;extern PPHUFFMAN_DEC_STRUCT m_pentrdecCBPY;extern PPHUFFMAN_DEC_STRUCT m_pentrdecIntraDCy;extern PPHUFFMAN_DEC_STRUCT m_pentrdecIntraDCc;extern PPHUFFMAN_DEC_STRUCT m_pentrdecMbTypeBVOP;extern Int nBitsRead;#endif#ifdef MP4V_DEBUGextern Int nBitsRead, nSymId;#endifextern Int nPeekedBits;// gmc_motion.c relatedextern Void globalmv(Int *, Int *, Int *, Int *, CoordI, CoordI, Int, Bool);// blkdec.c related#define GETCODEDBLOCKPATTERN(pMBMode, blkn) (pMBMode->m_rgbCodedBlockPattern[(UInt) blkn - 1])#define SETCODEDBLOCKPATTERN(pMBMode, blkn, bisCoded) (GETCODEDBLOCKPATTERN(pMBMode, blkn) = bisCoded)extern CVideoObject *g_pVO;extern CVideoObjectDecoder *g_pDecoder;extern VOLMode *g_pVOL; // vol modeextern VOPMode *g_pVOP; // vop mode// Block decoding functionsextern inline BlockMemory decideIntraPred (CMBMode*, Int *, Int, MacroBlockMemory* , MacroBlockMemory*, MacroBlockMemory*, MacroBlockMemory*, CMBMode*, CMBMode*, CMBMode*);extern inline Void decodeTextureIntraBlock (Int, Int, Int, MacroBlockMemory*, CMBMode*, BlockMemory, Int);extern Int decodeIntraDCmpeg (Bool bIsYBlk); //decode the intra-dc: mpeg2 methodextern Void decodeIntraTCOEF (Int*, Int, Int*);extern inline Void inverseDCACPred (CMBMode*, Int, Int*, Int, Int, BlockMemory, Int);extern Void decodeIntraVLCtableIndex (Int, Int*, Int*, Int*, Int); // return islastrun, run and level#ifdef MP4V_NEW_VLDextern Void decodeEscape_test (Int*, Int*, Int*, Int*, Int*, Bool);#elseextern Void decodeEscape (Int*, Int*, Int*, Int*, Int*, PPHUFFMAN_DEC_STRUCT, Bool);#endifextern Void decodeEscape_WithFastBS (Int*, Int*, Int*, Int*, Int*, PPHUFFMAN_DEC_STRUCT, Bool, UInt, UInt *);extern inline Void decodeTextureInterBlock (Int);extern Void decodeInterTCOEF (Int*, Int, Int*);extern Void decodeInterVLCtableIndex (Int, Int*, Int*, Bool*, Int); // return islastrun, run and level// mbdec.c related#define SETCBPYANDC(pmbmd, iCBPC, iCBPY)\ Int iBitPos = 3;\\ SETCODEDBLOCKPATTERN (pmbmd, U_BLOCK, (iCBPC >> 1) & 1);\ SETCODEDBLOCKPATTERN (pmbmd, V_BLOCK, iCBPC & 1);\\ for (iBlk = Y_BLOCK1; iBlk <= Y_BLOCK4; iBlk++)\ {\ SETCODEDBLOCKPATTERN (pmbmd, iBlk, (iCBPY >> iBitPos) & 1);\ iBitPos--;\ }#define DECODETEXTUREINTRAMB(pmbmd, iMBX, iMBY)\\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -