📄 mp4_enc.hpp
字号:
Ipp32s load_intra_quant_mat;
Ipp32s load_intra_quant_mat_len;
Ipp8u intra_quant_mat[64];
Ipp32s load_nonintra_quant_mat;
Ipp32s load_nonintra_quant_mat_len;
Ipp8u nonintra_quant_mat[64];
Ipp32s quarter_sample; // verid != 1
Ipp32s complexity_estimation_disable;
Ipp32s estimation_method;
Ipp32s shape_complexity_estimation_disable;
Ipp32s opaque;
Ipp32s transparent;
Ipp32s intra_cae;
Ipp32s inter_cae;
Ipp32s no_update;
Ipp32s upsampling;
Ipp32s texture_complexity_estimation_set_1_disable;
Ipp32s intra_blocks;
Ipp32s inter_blocks;
Ipp32s inter4v_blocks;
Ipp32s not_coded_blocks;
Ipp32s texture_complexity_estimation_set_2_disable;
Ipp32s dct_coefs;
Ipp32s dct_lines;
Ipp32s vlc_symbols;
Ipp32s vlc_bits;
Ipp32s motion_compensation_complexity_disable;
Ipp32s apm;
Ipp32s npm;
Ipp32s interpolate_mc_q;
Ipp32s forw_back_mc_q;
Ipp32s halfpel2;
Ipp32s halfpel4;
Ipp32s version2_complexity_estimation_disable; // verid != 1
Ipp32s sadct; // verid != 1
Ipp32s quarterpel; // verid != 1
Ipp32s resync_marker_disable;
Ipp32s data_partitioned;
Ipp32s reversible_vlc;
Ipp32s newpred_enable; // verid != 1
Ipp32s requested_upstream_message_type;// verid != 1
Ipp32s newpred_segment_type; // verid != 1
Ipp32s reduced_resolution_vop_enable; // verid != 1
Ipp32s scalability;
Ipp32s hierarchy_type;
Ipp32s ref_layer_id;
Ipp32s ref_layer_sampling_direct;
Ipp32s hor_sampling_factor_n;
Ipp32s hor_sampling_factor_m;
Ipp32s vert_sampling_factor_n;
Ipp32s vert_sampling_factor_m;
Ipp32s enhancement_type;
Ipp32s use_ref_shape;
Ipp32s use_ref_texture;
Ipp32s shape_hor_sampling_factor_n;
Ipp32s shape_hor_sampling_factor_m;
Ipp32s shape_vert_sampling_factor_n;
Ipp32s shape_vert_sampling_factor_m;
};
/* Group Of Video Object Plane Info */
struct mp4_GroupOfVideoObjectPlane {
Ipp32s time_code;
Ipp32s closed_gov;
Ipp32s broken_link;
};
/* StillTexture Object Info */
struct mp4_StillTextureObject {
Ipp32s dummy;
};
/* Mesh Object Info */
struct mp4_MeshObject {
Ipp32s dummy;
};
/* Face Object Info */
struct mp4_FaceObject {
Ipp32s dummy;
};
/* Visual Object Info */
struct mp4_VisualObject {
Ipp32s is_visual_object_identifier;
Ipp32s visual_object_verid;
Ipp32s visual_object_priority;
Ipp32s visual_object_type;
Ipp32s video_signal_type;
Ipp32s video_format;
Ipp32s video_range;
Ipp32s colour_description;
Ipp32s colour_primaries;
Ipp32s transfer_characteristics;
Ipp32s matrix_coefficients;
};
/* Visual Object Sequence Info */
struct mp4_VisualObjectSequence {
Ipp32s profile_and_level_indication;
};
struct mp4_Param
{
Ipp32s Width;
Ipp32s Height;
Ipp32s NumOfFrames;
Ipp32s TimeResolution;
Ipp32s TimeIncrement;
Ipp32s short_video_header;
Ipp32s load_intra_quant_mat;
Ipp32s load_intra_quant_mat_len;
Ipp8u intra_quant_mat[64];
Ipp32s load_nonintra_quant_mat;
Ipp32s load_nonintra_quant_mat_len;
Ipp8u nonintra_quant_mat[64];
Ipp32s quant_type;
Ipp32s quantIVOP, quantPVOP, quantBVOP;
Ipp32s IVOPdist, BVOPdist;
Ipp32s PVOPsearchWidth, PVOPsearchHeight;
Ipp32s BVOPsearchWidthForw, BVOPsearchHeightForw;
Ipp32s BVOPsearchWidthBack, BVOPsearchHeightBack;
Ipp32s MEalgorithm;
Ipp32s MEaccuracy;
Ipp32s ME4mv;
Ipp32s obmc_disable;
Ipp32s RoundingControl;
Ipp32s calcPSNR;
Ipp32s insertGOV;
Ipp32s repeatHeaders;
Ipp32s resync;
Ipp32s VideoPacketLenght;
Ipp32s data_partitioned;
Ipp32s reversible_vlc;
Ipp32s interlaced;
Ipp32s top_field_first;
Ipp32s alternate_vertical_scan_flag;
Ipp32s interlacedME;
Ipp32s sprite_enable;
Ipp32s sprite_width;
Ipp32s sprite_height;
Ipp32s sprite_left_coordinate;
Ipp32s sprite_top_coordinate;
Ipp32s no_of_sprite_warping_points;
Ipp32s sprite_warping_accuracy;
Ipp32s sprite_brightness_change;
Ipp32s *warping_mv_code_du;
Ipp32s *warping_mv_code_dv;
Ipp32s *brightness_change_factor;
Ipp8u *bsBuffer;
Ipp32s bsBuffSize;
Ipp32s padType;
Ipp32s RateControl;
Ipp32s BitRate;
Ipp32s SceneChangeThreshold;
Ipp8u profile_and_level;
};
struct mp4_VLC {
Ipp32s code;
Ipp32s len;
};
struct mp4_VLC_TCOEF {
int runMax[2];
const int *runOff[2];
const int *levMax[2];
const mp4_VLC *vlc;
};
struct mp4_Frame {
Ipp8u* ap;
Ipp8u* pY;
Ipp8u* pU;
Ipp8u* pV;
Ipp32s type;
Ipp32u mid;
Ipp64s time;
};
#if defined (_WIN32_WCE) && defined (_M_IX86) && defined (__stdcall)
#define _IPP_STDCALL_CDECL
#undef __stdcall
#endif
typedef IppStatus (__STDCALL *ippSAD_func) (const Ipp8u* pSrcCur, Ipp32s srcCurStep, const Ipp8u* pSrcRef, Ipp32s srcRefStep, Ipp32s* pDst, Ipp32s mcType);
typedef IppStatus (__STDCALL *ippCopy_func) (const Ipp8u* pSrc, Ipp32s srcStep, Ipp8u *pDst, Ipp32s dstStep, Ipp32s acc, Ipp32s rc);
#if defined (_IPP_STDCALL_CDECL)
#undef _IPP_STDCALL_CDECL
#define __stdcall __cdecl
#endif
struct mp4_MB_RC {
Ipp32s bpuAvg, bpsAvg, bpsEnc, sQuant;
Ipp8u *sBitPtr, *sBitPtr_1, *sBitPtr_2;
Ipp32s sBitOff, sBitOff_1, sBitOff_2;
};
struct mp4_Data_ME {
mp4_MacroBlock *MBcurr;
Ipp32s xMB, yMB;
#ifdef USE_ME_SADBUFF
Ipp32s *meBuff;
#endif
IppMotionVector mvPred[10];
Ipp32s numPred;
Ipp32s quant, fcode, flags, rt, method;
Ipp8u *pYc, *pYr, *pUc, *pUr, *pVc, *pVr;
Ipp32s stepL, stepC;
Ipp32s xL, xR, yT, yB;
Ipp32s thrDiff16x16, thrDiff8x8, thrDiff16x8;
//
Ipp32s bestDiff;
Ipp32s thrDiff;
Ipp32s xPos, yPos;
ippSAD_func sadFunc;
ippCopy_func copyQPFunc;
ippCopy_func copyHPFunc;
};
struct mp4_Slice {
Ipp32s startRow;
Ipp32s numRow;
Ipp32s gob_number; // for short_video_header
ippBitStream cBS, cBS_1, cBS_2;
Ipp32s quantSum;
Ipp32s numNotCodedMB;
Ipp32s numIntraMB;
mp4_MB_RC rc;
#ifdef USE_ME_SADBUFF
Ipp32s *meBuff;
#endif
};
#define YUV_CHROMA_420 0
#define YUV_CHROMA_422 1
#define YUV_CHROMA_444 2
enum {
MP4_STS_NODATA = -2,
MP4_STS_BUFFERED = -1,
MP4_STS_NOERR = 0,
MP4_STS_ERR_NOTINIT = 1,
MP4_STS_ERR_PARAM = 2,
MP4_STS_ERR_NOMEM = 3,
MP4_STS_ERR_BUFOVER = 4
};
class MPEG4_RC
{
protected :
Ipp32s mBitRate, mBitsDesiredFrame;
Ipp64s mBitsEncodedTotal, mBitsDesiredTotal;
bool mIsInit;
Ipp32s mQuantI, mQuantP, mQuantB, mQuantMax, mQuantMin, mQuantPrev;
Ipp32s mMethod, mRCfap, mRCqap, mRCbap, mRCq;
Ipp64f mRCqa, mRCfa;
public :
MPEG4_RC();
~MPEG4_RC();
void Init(Ipp32s qas, Ipp32s fas, Ipp32s bas, Ipp32s bitRate, Ipp64f fRate, Ipp32s fWidth, Ipp32s fHeight, Ipp32s qMin, Ipp32s qMax);
void Close();
void PostFrame(Ipp32s frameType, Ipp64s bEncoded);
Ipp32s GetQP(Ipp32s frameType);
void SetQP(Ipp32s frameType, Ipp32s qp);
Ipp32s GetInitQP(Ipp32s fWidth, Ipp32s fHeight);
};
class MPEG4_RC_MB
{
protected :
Ipp32s mBitRate, mBitsDesiredFrame;
Ipp64s mBitsEncodedTotal, mBitsDesiredTotal;
bool mIsInit;
Ipp32s mQuant, mQuantMax, mQuantMin, mNumMacroBlockPerRow, mNumMacroBlockPerCol, mIVOPdist, mDP;
Ipp32s GetInitQP(Ipp32s bitRate, Ipp64f frameRate, Ipp32s fWidth, Ipp32s fHeight);
public :
MPEG4_RC_MB();
~MPEG4_RC_MB();
void Init(Ipp32s bitRate, Ipp64f fRate, Ipp32s fWidth, Ipp32s fHeight, Ipp32s mbPerRow, Ipp32s mbPerCol, Ipp32s keyInt, Ipp32s dp, Ipp32s qMin, Ipp32s qMax);
void Close();
Ipp32s GetQP();
void Start(mp4_Slice *slice, Ipp32s frameType, Ipp32s quant);
void Update(mp4_Slice *slice, int *dquant, Ipp32s frameType);
void PostFrame(Ipp32s bpfEncoded, Ipp32s quantSum);
};
class ippVideoEncoderMPEG4
{
protected :
#ifdef _OMP_KARABAS
mp4_MacroBlockMT *MBinfoMT;
volatile Ipp32s* volatile mCurRowMT;
Ipp8u *mBuffer;
Ipp32s mThreadingAlg;
mp4_Slice *mSliceMT;
#ifdef _OPENMP
omp_lock_t *mLockMT;
#endif
#endif // _OMP_KARABAS
Ipp32s mNumThreads;
bool mIsInit;
ippBitStream cBS;
Ipp32s mbsAlloc;
Ipp32s mSourceFormat; // 4:2:0 supported only
Ipp32s mSourceWidth; // width
Ipp32s mSourceHeight; // height
Ipp32s mNumOfFrames;
Ipp32s mFrameCount;
Ipp32s mExpandSize;
Ipp32s mNumMacroBlockPerRow;
Ipp32s mNumMacroBlockPerCol;
Ipp32s mNumMacroBlockPerVOP;
Ipp32s mQuantIVOP, mQuantPVOP, mQuantBVOP, mQuantPrev;
Ipp32s mIVOPdist, mBVOPdist, mLastIVOP;
Ipp32s mPVOPsearchHor, mPVOPsearchVer;
Ipp32s mBVOPsearchHorForw, mBVOPsearchVerForw;
Ipp32s mBVOPsearchHorBack, mBVOPsearchVerBack;
Ipp32s mPVOPfcodeForw;
Ipp32s mBVOPfcodeForw;
Ipp32s mBVOPfcodeBack;
Ipp16s mDefDC;
Ipp32s mMEflags, mMEmethod;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -