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

📄 ddecode.c

📁 魔兽2Linux版
💻 C
📖 第 1 页 / 共 2 页
字号:
//==========================================================================////  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR//  PURPOSE.////  Copyright (c) 1999 - 2001  On2 Technologies Inc. All Rights Reserved.////--------------------------------------------------------------------------/******************************************************************************   Module Title :     DDecode.C**   Description  :     Video CODEC: Top level decode module.********************************************************************************//*****************************************************************************  Header Files******************************************************************************/#define STRICT              /* Strict type checking. */#include "BlockMapping.h"#include "pbdll.h"#include "codec_common_interface.h"#include <string.h>/*****************************************************************************  Module constants.******************************************************************************/        /*****************************************************************************  Exported Global Variables******************************************************************************//*****************************************************************************  Exported Functions******************************************************************************//*****************************************************************************  Module Statics******************************************************************************/              void DecodeModes( PB_INSTANCE *pbi, UINT32 SBRows, UINT32 SBCols, UINT32 HExtra, UINT32 VExtra );void DecodeMVectors ( PB_INSTANCE *pbi, UINT32 SBRows, UINT32 SBCols, UINT32 HExtra, UINT32 VExtra );INT32 ExtractMVectorComponentA(PB_INSTANCE *pbi);INT32 ExtractMVectorComponentB(PB_INSTANCE *pbi);// Mode coding schemesCODING_MODE  ModeAlphabet[MODE_METHODS-1][MAX_MODES] = {       {    (CODING_MODE)0,(CODING_MODE)0,(CODING_MODE)0,(CODING_MODE)0,(CODING_MODE)0,(CODING_MODE)0,(CODING_MODE)0,(CODING_MODE)0 },     // Reserved for custom alphabet.        // Last motion vector dominates    {    CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,  CODE_INTER_PLUS_MV,     CODE_INTER_NO_MV,              CODE_INTRA,            CODE_USING_GOLDEN,      CODE_GOLDEN_MV,         CODE_INTER_FOURMV },    {    CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,  CODE_INTER_NO_MV,       CODE_INTER_PLUS_MV,              CODE_INTRA,            CODE_USING_GOLDEN,      CODE_GOLDEN_MV,         CODE_INTER_FOURMV },             {    CODE_INTER_LAST_MV,    CODE_INTER_PLUS_MV,     CODE_INTER_PRIOR_LAST,  CODE_INTER_NO_MV,              CODE_INTRA,            CODE_USING_GOLDEN,      CODE_GOLDEN_MV,         CODE_INTER_FOURMV },    {    CODE_INTER_LAST_MV,    CODE_INTER_PLUS_MV,     CODE_INTER_NO_MV,       CODE_INTER_PRIOR_LAST,              CODE_INTRA,            CODE_USING_GOLDEN,      CODE_GOLDEN_MV,         CODE_INTER_FOURMV },    //   No motion vector dominates    {    CODE_INTER_NO_MV,      CODE_INTER_LAST_MV,     CODE_INTER_PRIOR_LAST,  CODE_INTER_PLUS_MV,              CODE_INTRA,            CODE_USING_GOLDEN,      CODE_GOLDEN_MV,         CODE_INTER_FOURMV },        {    CODE_INTER_NO_MV,      CODE_USING_GOLDEN,      CODE_INTER_LAST_MV,     CODE_INTER_PRIOR_LAST,                CODE_INTER_PLUS_MV,    CODE_INTRA,             CODE_GOLDEN_MV,         CODE_INTER_FOURMV },};/*****************************************************************************  Imports******************************************************************************/  /**************************************************************************** *  *  ROUTINE       :     DecodeData * *  INPUTS        :      * *  OUTPUTS       :     None. * *  RETURNS       :     None. * *  FUNCTION      :     Decodes and displays the video stream. * *  SPECIAL NOTES :     None.  * * *  ERRORS        :     None. * ****************************************************************************/void DecodeData(PB_INSTANCE *pbi){       UINT32 i;    UINT32 YHExtra = pbi->HFragments%4;    UINT32 YVExtra = pbi->VFragments%4;    //UINT32 UvHExtra = (pbi->HFragments/2)%4;    //UINT32 UvVExtra = (pbi->VFragments/2)%4;    // Bail out immediately if a decode error has already been reported.    if ( pbi->DecoderErrorCode != NO_DECODER_ERROR )        return;    /* Clear down the macro block level mode and MV arrays. */    for ( i = 0; i < pbi->UnitFragments; i++ )    {        pbi->FragCodingMethod[i] = CODE_INTER_NO_MV;     // Default coding mode        pbi->FragMVect[i].x = 0;        pbi->FragMVect[i].y = 0;    }    // Zero Decoder EOB run count     pbi->EOB_Run = 0;    // Make a not of the number of coded blocks this frame    pbi->CodedBlocksThisFrame = pbi->CodedBlockIndex;	// Decode the modes data	DecodeModes( pbi, pbi->YSBRows, pbi->YSBCols, YHExtra, YVExtra );	// Unpack and decode the motion vectors.	DecodeMVectors ( pbi, pbi->YSBRows, pbi->YSBCols, YHExtra, YVExtra );	// Unpack and decode the actual video data.    pbi->UnPackVideo(pbi);	// Reconstruct and display the frame    ReconRefFrames(pbi);}/**************************************************************************** *  *  ROUTINE       :     DecodeModes * *  INPUTS        :     None.  *                       *  OUTPUTS       :     Reconstructed frame. * *  RETURNS       :     None. * *  FUNCTION      :     Decodes the coding mode list for this frame. * *  SPECIAL NOTES :     None.  * * *  ERRORS        :     None. * ****************************************************************************/void DecodeModes( PB_INSTANCE *pbi, UINT32 SBRows, UINT32 SBCols, UINT32 HExtra __attribute__((unused)), UINT32 VExtra __attribute__((unused)) ){	INT32	FragIndex;			// Fragment number	UINT32	MB;	    			// Macro-Block, Block indices	UINT32	SBrow;				// Super-Block row number	UINT32	SBcol;				// Super-Block row number	UINT32	SB=0;			    // Super-Block index    CODING_MODE  CodingMethod;  // Temp Storage for coding mode.    UINT32  UVRow;    UINT32  UVColumn;    UINT32  UVFragOffset;        UINT32  CodingScheme;       // Coding scheme used to code modes.    UINT32  MBListIndex = 0;    UINT32  i;    // If the frame is an intra frame then all blocks have mode intra.    if ( GetFrameType(pbi) == BASE_FRAME )    {        for ( i = 0; i < pbi->UnitFragments; i++ )        {            pbi->FragCodingMethod[i] = CODE_INTRA;        }    }    else    {        UINT32  ModeEntry;                            // Mode bits read          // Read the coding method        CodingScheme = bitread( &pbi->br,  MODE_METHOD_BITS );          // If the coding method is method 0 then we have to read in a custom coding scheme        if ( CodingScheme == 0 )        {            // Read the coding scheme.            for ( i = 0; i < MAX_MODES; i++ )            {                ModeAlphabet[0][ bitread( &pbi->br,  MODE_BITS) ] = (CODING_MODE)i;            }        }	    // Unravel the quad-tree	    for ( SBrow=0; SBrow<SBRows; SBrow++ )	    {		    for ( SBcol=0; SBcol<SBCols; SBcol++ )		    {				for ( MB=0; MB<4; MB++ )				{					// There may be MB's lying out of frame					// which must be ignored. For these MB's					// top left block will have a negative Fragment Index.    				if ( QuadMapToMBTopLeft(pbi->BlockMap, SB,MB) >= 0 )					{						// Is the Macro-Block coded:						if ( pbi->MBCodedFlags[MBListIndex++] )						{                            // Upack the block level modes and motion vectors                            FragIndex = QuadMapToMBTopLeft( pbi->BlockMap, SB, MB );                                                    // Unpack the mode.                            if ( CodingScheme == (MODE_METHODS-1) )                            {                                // This is the fall back coding scheme.                                // Simply MODE_BITS bits per mode entry.                                CodingMethod = (CODING_MODE)bitread( &pbi->br,  MODE_BITS );                            }                            else                            {                                ModeEntry = FrArrayUnpackMode(pbi);                                CodingMethod =  ModeAlphabet[CodingScheme][ ModeEntry ];                            }                            // Note the coding mode for each block in macro block.                            pbi->FragCodingMethod[FragIndex] = CodingMethod;                            pbi->FragCodingMethod[FragIndex + 1] = CodingMethod;                            pbi->FragCodingMethod[FragIndex + pbi->HFragments] = CodingMethod;                            pbi->FragCodingMethod[FragIndex + pbi->HFragments + 1] = CodingMethod;                            // Matching fragments in the U and V planes                            UVRow = (FragIndex / (pbi->HFragments * 2));                            UVColumn = (FragIndex % pbi->HFragments) / 2;                            UVFragOffset = (UVRow * (pbi->HFragments / 2)) + UVColumn;                            pbi->FragCodingMethod[pbi->YPlaneFragments + UVFragOffset] = CodingMethod;                            pbi->FragCodingMethod[pbi->YPlaneFragments + pbi->UVPlaneFragments + UVFragOffset] = CodingMethod;						}					}			    }			    // Next Super-Block			    SB++;		    }	    }    }}/**************************************************************************** *  *  ROUTINE       :     DecodeMVectors * *  INPUTS        :     None.  *                       *  OUTPUTS       :     None. * *  RETURNS       :     None. * *  FUNCTION      :     Decodes the motion vectors for this frame. * *  SPECIAL NOTES :     None.  * * *  ERRORS        :     None. * ****************************************************************************/void DecodeMVectors ( PB_INSTANCE *pbi, UINT32 SBRows, UINT32 SBCols, UINT32 HExtra __attribute__((unused)), UINT32 VExtra __attribute__((unused)) ){	INT32	FragIndex;			// Fragment number	UINT32	MB;		    		// Macro-Block, Block indices	UINT32	SBrow;				// Super-Block row number	UINT32	SBcol;				// Super-Block row number	UINT32	SB=0;			    // Super-Block index    UINT32  CodingMethod;       // Temp Storage for coding mode.    MOTION_VECTOR MVect[6];     // temp storage for motion vector    MOTION_VECTOR TmpMVect;    MOTION_VECTOR LastInterMV;      // storage for last used Inter frame MB motion vector    MOTION_VECTOR PriorLastInterMV; // storage for previous last used Inter frame MB motion vector	INT32 (*ExtractMVectorComponent)(PB_INSTANCE *pbi);

⌨️ 快捷键说明

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