📄 mae_pass_thru.c
字号:
/* <LIC_AMD_STD> * Copyright (C) 2003-2005 Advanced Micro Devices, Inc. All Rights Reserved. * * Unless otherwise designated in writing, this software and any related * documentation are the confidential proprietary information of AMD. * THESE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY * UNLESS OTHERWISE NOTED IN WRITING, EXPRESS OR IMPLIED WARRANTY OF ANY * KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, * NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE AND IN NO * EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER. * * AMD does not assume any responsibility for any errors which may appear * in the Materials nor any responsibility to support or update the * Materials. AMD retains the right to modify the Materials at any time, * without notice, and is not obligated to provide such modified * Materials to you. AMD is not obligated to furnish, support, or make * any further information available to you. * </LIC_AMD_STD> *//* <CTL_AMD_STD> * </CTL_AMD_STD> *//* <DOC_AMD_STD> * </DOC_AMD_STD> */// ***************************************************************************// pragmas// ***************************************************************************// ***************************************************************************// includes// ***************************************************************************#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <header.h>#include "mae_fe.h"#include "mae_fe_mcomp.h"#ifndef UNDER_CE#include "mae_vpi.h"#include "mae_global.h"#endif //!UNDER_CE#include "mae_pass_thru.h"// ***************************************************************************// types// ***************************************************************************// Use the MAI Renderer only if we are not in STANDALONE mode#ifndef MP4_STANDALONE#define USE_MAI_RENDERER 1#endif#define MAE_HEADERS_SIZE 16 // 16 bytes = (sizeof(header_words))#ifndef INLINE_MV_CLIPPING#define MP4V_LIMITTOHPEL_Y(xpos, ypos, x, y, width,height,index)\{\ int xpos2 = xpos+xpos;\ int ypos2 = ypos+ypos; \ if (g_pHeader3->mbtype == MBT_16x16) \ { /* Left */ \ if ((xpos2 + *x) < -32) \ *x = -32 - xpos2; \ /* Right */ \ else if ( ((xpos2 + *x)>>1) > width - 1 ) \ *x = ((width - 1)<<1) - xpos2; \ /* Top */ \ if ((ypos2 + *y) < -32) \ *y = -32 - ypos2; \ /* Bottom */ \ else if ( ((ypos2 + *y)>>1) > height - 1 )\ *y = ((height - 1)<<1) - ypos2; \ } \ else if (g_pHeader3->mbtype == MBT_8x8)\ { \ int lumaAdjustment; \ /* Left */ \ lumaAdjustment = (index & 1) << 4; \ if (((xpos2 + *x) + lumaAdjustment) < -16)\ *x = -16 - xpos2 - lumaAdjustment; \ else { \ /* Right */ \ lumaAdjustment >>= 1; \ if ((((xpos2 + *x) >> 1) + lumaAdjustment) > width - 1)\ *x = (width - 1 - lumaAdjustment)*2 - xpos2;\ } \ /* Top */ \ lumaAdjustment = ((index >> 1) & 0x1) << 4;\ if (((ypos2 + *y) + lumaAdjustment) < -16)\ *y = -16 - ypos2 - lumaAdjustment; \ else { \ /* Bottom */ \ lumaAdjustment >>= 1; \ if ((((ypos2 + *y) >> 1) + lumaAdjustment) > height - 1)\ *y = (height - 1 - lumaAdjustment)*2 - ypos2;\ } \ } \}#define MP4V_LimitToHPel_UV(xpos, ypos, x, y, width, height, index)\{\ int xpos2 = xpos+xpos;\ int ypos2 = ypos+ypos; \ if (g_pHeader3->mbtype == MBT_16x16)\ {\ if ((xpos2 + *x) < -16)\ *x = -16 - xpos2;\\ else if ( ((xpos2 + *x)>>1) > width - 1 )\ *x = ((width - 1)<<1) - xpos2;\\ if ((ypos2 + *y) < -16)\ *y = -16 - ypos2;\\ else if ( (( ypos2 + *y)>>1) > height - 1 )\ *y = ((height - 1)<<1) - ypos2;\ }\ else if (g_pHeader3->mbtype == MBT_8x8)\ {\ if ((xpos2 + *x) < -16)\ *x = -16 - xpos2;\\ else if ( ((xpos2 + *x)>>1) > width - 1 )\ *x = ((width - 1)<<1) - xpos2;\\ if ((ypos2 + *y) < -16)\ *y = -16 - ypos2;\\ else if ( ((ypos2 + *y)>>1) > height - 1 )\ *y = ((height - 1)<<1) - ypos2;\ }\}#define MP4V_LimitToQPel(xpos, ypos, x, y, width, height, index)\{\ int xpos4 = xpos<<2; \ int ypos4 = ypos<<2; \ if (g_pHeader3->mbtype == MBT_16x16) \ { /* left */ \ if ((xpos4 + *x) < -64) \ *x = -64 - xpos4; \ /* right */ \ else if ( ((xpos4 + *x) >> 2) > (width - 1) ) \ *x = ((width - 1)<<2) - xpos4; \ /* top */ \ if ((ypos4 + *y) < -64) \ *y = -64 - ypos4; \ /* bottom */ \ if ( ((ypos4 + *y) >> 2) > (height - 1) ) \ *y = ((height - 1)<<2) - ypos4; \ } \ else if (g_pHeader3->mbtype == MBT_8x8) \ { \ int lumaAdjustment; \ \ lumaAdjustment = (index & 1) << 5; \ if (((xpos4 + *x) + lumaAdjustment) < -32) \ *x = -32 - xpos4 - lumaAdjustment; \ else { \ lumaAdjustment = (index & 1) <<3; \ if ((((xpos4 + *x) >> 2) + lumaAdjustment) > (width - 1))\ *x = ((width - 1 - lumaAdjustment)<<2) - xpos4;\ } \ \ lumaAdjustment = ((index >> 1) & 0x1) << 5;\ if (((ypos4 + *y) + lumaAdjustment) < -32) \ *y = -32 - ypos4 - lumaAdjustment; \ else { \ lumaAdjustment = ((index >> 1) & 0x1) << 3;\ if ((((ypos4 + *y) >> 2) + lumaAdjustment) > height - 1)\ *y = (height - 1 - lumaAdjustment)*4 - ypos4;\ } \ } \}/*#ifdef ENABLE_INTERLACING // For MP4V_LIMITTOHPEL_Y else if (g_pHeader3->mbtype == MBT_16x8)\ { if ((xpos2 + *x) < -32) \ *x = -32 - xpos2; \ else if ( ((xpos2 + *x)>>1) > width - 1 ) \ *x = ((width - 1)<<1) - xpos2; \ if ( ypos + (*y>>2) < -8 ) \ *y = -32 - (ypos2 + ypos2); \ else if ( ypos + (*y>>2) > height - 1 ) \ *y =((height - 1)<<2) - (ypos2 + ypos2);\ } \#ifdef ENABLE_INTERLACING // For MP4V_LIMITTOHPEL_UV else if (g_pHeader3->mbtype == MBT_16x8)\ {\ if ((xpos2 + *x) < -16)\ *x = -16 - xpos2;\\ else if ( ((xpos2 + *x)>>1) > width - 1 )\ *x = ((width - 1)<<1) - xpos2;\\ if ( ypos + (*y>>2) < -4)\ *y = -16 - (ypos2 + ypos2);\\ else if ( ypos + (*y>>2) > height - 1 )\ *y = ((height - 1)<<2) - (ypos2 + ypos2);\ }\#ifdef ENABLE_INTERLACING // For MP4V_LimitToQPel else if (g_pHeader3->mbtype == MBT_16x8) \ { if ((xpos4 + *x) < -64) \ *x = -64 - xpos4; \ else if ( ((xpos4 + *x) >> 2) > (width - 1) ) \ *x = ((width - 1)<<2) - xpos4; \ if ( ypos + (*y>>3) < -8 ) \ *y = -64 - (ypos4 + ypos4); \ else if ( ypos + (*y>>3) > height - 1 ) \ *y = ((height - 1)<<3) - (ypos4 + ypos4); \ } \*/#endif// ***************************************************************************// data// ***************************************************************************char gFileName[MAX_FILE_SIZE];const char *gFileExt;int nFileUpdates =NO_DUMP_ALL; // Mask file writesint nBldOpt = USE_MAE; // REF or MAE usageint nFlipToRef = NO_FLIP; // Flip to reference mode for some MBsint m_iSizeYPlane, m_iSizeUVPlane;int nShortRun = 0; // Default to a full decode run (value = 0)char *nFlipArray = NULL;// Nothingint bSpecialDump = 0;#ifndef NEW_MAE_DRIVERreg_info xMAERegs;reg_info *pMAERegs = &xMAERegs;#endifwrap_context *pMAEContext;int16 *g_pIQOutput;// Global pointers for the individual header words_header_word0 *g_pHeader0;_header_word1 *g_pHeader1;_header_word2 *g_pHeader2;_header_word3 *g_pHeader3;// Store the CBP bits for each block in the order // Y0, Y1, Y2, Y3, Cb0 & Cr0 (Cb1 & Cr1 not needed as of now)int BITS_FOR_CBP[V_CHROMA_BLOCK] = {0x80, 0x40, 0x20, 0x10, 0x8, 0x4}; // Number of blocks that are codedint nCodedBlocks, g_nMB = 0, g_NumWMs = 0, g_NumMVs = 0, g_UVMVId = 0, g_UVMVId2 = 0; // MotionVector global pointeruint32 *g_pMV;// Reference pointersunsigned char *m_pMAERef0Y, *m_pMAERef1Y;#ifdef MP4_STANDALONE// Input file handleFILE* g_InFile;// ~HV - Perf Changes#endif// Temporal number, Consecutive B-Frames, the current frame number and bytes used (for MAE-Wrapper)int m_iTemporalNumber, m_iNumBFrames, MP4V_iFrameNumber, MP4V_nBytesUsed, g_iVOPIncFactor;int iPicWidth, iPicHeight, iChoppedHeight;int nIFYLoc, nIFUVLoc; // Private prototypes#ifdef ENABLE_INTERLACINGunsigned char CheckForFlip(CachedFILE, unsigned char);#endifint8 *xBlockData;// ***************************************************************************// function implementations
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -