📄 umc_h264_defs.h
字号:
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2003-2007 Intel Corporation. All Rights Reserved.
//
//
*/
#ifndef __UMC_H264_DEFS_H__
#define __UMC_H264_DEFS_H__
#include "ippdefs.h"
#include "ippvc.h"
#include "ipps.h"
#include "umc_h264_config.h"
namespace UMC_H264_ENCODER
{
#define MAX_SAD 0x7FFFFFFF
#define MAX_MV_INT 127
#if (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && !defined(_WIN32_WCE)
#define __ALIGN16 __declspec (align(16))
#else
#define __ALIGN16
#endif
#define GetMBFieldDecodingFlag(x) (((x).mb_aux_fields)&1)
#define GetMB8x8TSFlag(x) (((x).mb_aux_fields&2)>>1)
#define GetMB8x8TSPackFlag(x) (((x).mb_aux_fields&4)>>2)
#define pGetMBFieldDecodingFlag(x) (((x)->mb_aux_fields)&1)
#define pGetMB8x8TSFlag(x) (((x)->mb_aux_fields&2)>>1)
#define pGetMB8x8TSPackFlag(x) (((x)->mb_aux_fields&4)>>2)
#define pSetMBFieldDecodingFlag(x,y) \
(((x)->mb_aux_fields) &= ~1); \
(((x)->mb_aux_fields) |= (y))
#define SetMBFieldDecodingFlag(x,y) \
(((x).mb_aux_fields) &= ~1); \
(((x).mb_aux_fields) |= (y))
#define pSetMB8x8TSFlag(x,y) \
(((x)->mb_aux_fields) &= ~2); \
(((x)->mb_aux_fields) |= ((y)<<1))
#define SetMB8x8TSFlag(x,y) \
(((x).mb_aux_fields) &= ~2); \
(((x).mb_aux_fields) |= ((y)<<1))
#define pSetMB8x8TSPackFlag(s,val) \
(s)->mb_aux_fields &= ~4; \
(s)->mb_aux_fields |= (val)<<2
#define SetMB8x8TSPackFlag(s,val) \
(s).mb_aux_fields &= ~4; \
(s).mb_aux_fields |= (val)<<2
typedef Ipp32s H264MBAddr;
#define BLOCK_IS_ON_LEFT_EDGE(x) (!((x)&3))
#define BLOCK_IS_ON_RIGHT_EDGE(x) (!((x + 1)&3))
#define BLOCK_IS_ON_TOP_EDGE(x) ((x)<4)
#define CHROMA_BLOCK_IS_ON_LEFT_EDGE(x) (!((x)&1))
#define CHROMA_BLOCK_IS_ON_TOP_EDGE(x) ((x)<18 || (x)==20 || (x)==21)
#define CHROMA_BLOCK_IS_ON_TOP_EDGE_C(x) (!((x)&2))
enum {
ALIGN_VALUE = 16
};
typedef enum {
D_DIR_FWD = 0,
D_DIR_BWD,
D_DIR_BIDIR,
D_DIR_DIRECT,
D_DIR_DIRECT_SPATIAL_FWD,
D_DIR_DIRECT_SPATIAL_BWD,
D_DIR_DIRECT_SPATIAL_BIDIR,
} Direction_t;
///////////////// H.264 Structures
template <class CoeffsType> class T_RLE_Data {
public:
// Note: uNumCoeffs and uTotalZeros are not redundant because
// this struct covers blocks with 4, 15 and 16 possible coded coeffs.
Ipp8u uTrailing_Ones; // Up to 3 trailing ones are allowed (not in iLevels below)
Ipp8u uTrailing_One_Signs; // Packed into up to 3 lsb, (1==neg)
Ipp8u uNumCoeffs; // Total Number of non-zero coeffs (including Trailing Ones)
Ipp8u uTotalZeros; // Total Number of zero coeffs
CoeffsType iLevels[64]; // Up to 64 Coded coeffs are possible, in reverse zig zag order
Ipp8u uRuns[64]; // Up to 64 Runs are recorded, including Trailing Ones, in rev zig zag order
};
template <class CoeffsType> class T_Block_CABAC_Data {
public:
Ipp8u uBlockType;
Ipp8u uNumSigCoeffs;
Ipp8u uLastCoeff;
Ipp8u uFirstCoeff;
Ipp8u uFirstSignificant;
Ipp8u uLastSignificant;
CoeffsType uSignificantLevels[64];
Ipp8u uSignificantSigns[64];
Ipp8u uSignificantMap[64];
Ipp32s CtxBlockCat;
};
struct H264MotionVector
{
Ipp16s mvx;
Ipp16s mvy;
bool is_zero() const
{ return ((mvx|mvy) == 0); }
Ipp32s operator == (const H264MotionVector &mv) const
{ return mvx == mv.mvx && mvy == mv.mvy; };
Ipp32s operator != (const H264MotionVector &mv) const
{ return !(*this == mv); };
};//4bytes
typedef Ipp8s T_RefIdx;
struct H264MacroblockRefIdxs
{
T_RefIdx RefIdxs[16]; // 16 bytes
};//16bytes
struct H264MacroblockMVFlags
{
Ipp8s MVFlags[16]; // 16 bytes
};//16bytes
struct H264MacroblockMVs
{
H264MotionVector MotionVectors[16]; //64 bytes
};//64bytes
// Advanced Intra mode
typedef Ipp8s T_AIMode;
struct H264MacroblockIntraTypes
{
T_AIMode intra_types[16];
}; // bytes
struct H264MacroblockCoeffsInfo
{
Ipp8u numCoeff [48]; //24 bytes
Ipp8u lumaAC;
Ipp8u chromaNC;
Ipp8u dummy[6];
}; // 32 bytes
typedef Ipp8u MBTypeValue;
typedef Ipp8u SBTypeValue;
struct H264MacroblockGlobalInfo
{
Ipp8u sbtype[4];
Ipp16s slice_id;
MBTypeValue mbtype;
Ipp8u mb_aux_fields; // 2nd bit is transform_8x8_size_flag.
}; //8 bytes
struct H264MacroblockLocalInfo
{
Ipp32u cbp_luma;
Ipp32u cbp_chroma;
Ipp32u cbp_bits;
Ipp32u cbp_bits_chroma;
Ipp8u sbdir[4];
Ipp8u cbp;
Ipp8u intra_16x16_mode; //it's instead decoder Ipp8u mbtypeBS;
Ipp8u intra_chroma_mode;
Ipp8s QP;
Ipp32u best_distortion;
};//16 btytes
struct H264BlockLocation
{
H264MBAddr mb_num;
H264MBAddr block_num;
};//8 bytes
struct H264MacroblockNeighboursInfo
{
H264MBAddr mb_A;
H264MBAddr mb_B;
H264MBAddr mb_C;
H264MBAddr mb_D;
};//32 bytes
struct H264BlockNeighboursInfo
{
H264BlockLocation mbs_left[4];
H264BlockLocation mb_above;
H264BlockLocation mb_above_right;
H264BlockLocation mb_above_left;
H264BlockLocation mbs_left_chroma[2][2];
H264BlockLocation mb_above_chroma[2];
H264BlockLocation dummy[2];
};//128bytes
//this structure is present in each frame
struct H264GlobalMacroblocksDescriptor
{
H264MacroblockMVs *MV[2];//MotionVectors L0 L1
H264MacroblockRefIdxs *RefIdxs[2];//Reference Indices L0 l1
H264MacroblockGlobalInfo *mbs;//macroblocks
};
//this structure is one for all
struct H264LocalMacroblockDescriptor
{
H264MacroblockMVs *MVDeltas[2];//MotionVectors Deltas L0 and L1
H264MacroblockIntraTypes* intra_types;
H264MacroblockMVFlags *MVFlags[2];//MotionVectors Flags L0 and L1
H264MacroblockCoeffsInfo *MacroblockCoeffsInfo; //info about num_coeffs in each block in the current picture
H264MacroblockLocalInfo *mbs;//reconstuction info
};
enum MB_Neighbourings{
MB_A = 0,
MB_B,
MB_C,
MB_D,
MB_ALL_NEIGHBOURS,
};
template <class PixType, class CoeffsType>
class CH264pBs;
template <class PixType, class CoeffsType>
struct MBDissection{
Ipp32u ssd;
Ipp32u sad;
Ipp32u bits;
Ipp32u skip_run;
Ipp32u cbp;
Ipp32u cbp_chroma;
Ipp32u cbpcbp;
Ipp8u chroma_mode;
H264MotionVector MBmvs[16*4];
T_RefIdx MBridx[16*2];
H264MacroblockLocalInfo locInfo;
H264MacroblockGlobalInfo globInfo;
H264MacroblockCoeffsInfo coeffInfo;
Ipp8s intra_types[16]; // mode+probability
Ipp8u stream[1024];
Ipp32s stream_size;
Ipp32s stream_offset;
PixType* prediction;
PixType* reconstruct;
CoeffsType* transform;
CoeffsType* dc;
CH264pBs<PixType,CoeffsType>* bitstream;
};
template <class PixType, class CoeffsType>
struct Macroblock
{
Ipp32u uMB; //MacroBlock address
PixType* mbPtr; //Pointer to macroblock data in original frame
Ipp32s mbPitchPixels;
Ipp32s lambda;
H264MacroblockLocalInfo *LocalMacroblockInfo;
H264MacroblockLocalInfo *LocalMacroblockPairInfo;
H264MacroblockGlobalInfo *GlobalMacroblockInfo;
H264MacroblockGlobalInfo *GlobalMacroblockPairInfo;
H264MacroblockCoeffsInfo *MacroblockCoeffsInfo;
T_AIMode *intra_types; // 16 elements
MBDissection<PixType,CoeffsType>* mbpack; //mb that should be packed
MBDissection<PixType,CoeffsType> mb4x4;
MBDissection<PixType,CoeffsType> mb8x8;
MBDissection<PixType,CoeffsType> mb16x16;
MBDissection<PixType,CoeffsType> mbInter;
MBDissection<PixType,CoeffsType> mbChromaInter;
MBDissection<PixType,CoeffsType> mbChromaIntra;
MBDissection<PixType,CoeffsType> mb[4];
};
template <class PixType, class CoeffsType>
struct H264CurrentMacroblockDescriptor : public Macroblock<PixType, CoeffsType>
{
H264MacroblockMVs *MVs[4]; //MV L0,L1, MVDeltas 0,1
H264MacroblockMVFlags *MVFlags[2]; //MVFlags L0, L1
H264MacroblockRefIdxs *RefIdxs[2]; //RefIdx L0, L1
H264MacroblockNeighboursInfo CurrentMacroblockNeighbours; //mb neighbouring info
H264BlockNeighboursInfo CurrentBlockNeighbours; //block neighbouring info (if mbaff turned off remained static)
};
} // end namespace UMC_H264_ENCODER
#endif // __UMC_H264_DEFS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -