📄 h263_enc.hpp
字号:
int mbsAlloc; int mExpandSize; int mNumMacroBlockPerRow; int mNumMacroBlockPerCol; int mNumMacroBlockPerVOP; int mLumaPlaneSize; int mChromaPlaneSize; int mPlanes; int mExpandSizeA; Ipp8u **mPtrY, **mPtrU, **mPtrV; Ipp8u **mPtreY, **mPtreU, **mPtreV; int mQuantIVOP, mQuantPVOP, mQuantBVOP; int mIVOPdist, mPVOPdist, mBVOPdist, mLastIVOP; int mPVOPsearchHor, mPVOPsearchVer;// int mBVOPsearchHorForw, mBVOPsearchVerForw;// int mBVOPsearchHorBack, mBVOPsearchVerBack;// int mPVOPfcodeForw;// int mBVOPfcodeForw;// int mBVOPfcodeBack; int mMEaccuracy; int mMEalgorithm; int mMEfastHP; Ipp32s *mMEfastSAD; int mMEfastSADsize; int mMEthrSAD16x16, mMEthrSAD8x8, mMEthrSAD16x8; int mME4mv; int mCalcPSNR; int mMBNlength; int mVideoPacketLength; int mInterlacedME; Ipp64s mVOPtime, mSyncTime; int mNumBVOP, mIndxBVOP, mTRB, mTRD, mSyncTimeB; int mRateControl; int mBitRate; Ipp64s mBitsEncoded; Ipp32s mBitsPerFrameRC; //, mMaxFrameSize; Ipp64s mBitsDesiredRC; int mSceneChangeThreshold, mNumIntraMB; h263_VideoObjectLayer VOL; h263_VideoObjectPlane VOP; static const h263_VLC mVLC_CBPY_TB8[16]; static const h263_VLC mVLC_MCBPC_TB7[20]; static const h263_VLC mVLC_MVD_TB12[65]; // info for each macroblock h263_MacroBlock *MBinfo; // additional buffers for data_partitioned Ipp8u *mBuffer_1; Ipp8u *mBuffer_2; // buffers for RPT support Ipp8u *mMBquant; IppMotionVector *mMBpredMV; Ipp32u *mMBpos;public : ippVideoEncoderH263() { mIsInit = false; }; ippVideoEncoderH263(h263_Param *par); ~ippVideoEncoderH263(); int Init(h263_Param *par); void Close(); int GetAverageQuant() { return (int)mQuantAvg; }; int GetNumMacroBlockPerRow() { return mNumMacroBlockPerRow; }; int GetNumMacroBlockPerCol() { return mNumMacroBlockPerCol; }; int GetFrameType() { return VOP.picture_coding_type; }; Ipp64s GetBitsEncoded() { return mBitsEncoded; }; void GetMSE(Ipp64s *y, Ipp64s *u, Ipp64s *v) { *y = mPSNR_Y; *u = mPSNR_U; *v = mPSNR_V; }; int GetFrameWriteInfo(Ipp8u **pY, Ipp8u **pU, Ipp8u **pV, int *stepLuma, int *stepChroma); void InitBuffer(Ipp8u *ptr, int size) { cBS.Init(ptr, size); }; Ipp8u* GetBufferPtr() { return cBS.GetPtr(); }; int GetBufferFullness() { return cBS.GetFullness(); }; void GetBufferPos(Ipp8u **ptr, int *bitOff) { cBS.GetPos(ptr, bitOff); }; void ResetBuffer() { cBS.Reset(); }; int EncodeFrame(int noMoreData); // for RTP support Ipp8u* GetFrameQuant() { return mMBquant; }; IppMotionVector* GetFrameMVpred() { return mMBpredMV; }; Ipp32u* GetFrameMBpos() { return mMBpos; };protected : int EncodeVOP(int vopType, int nt); void ErrorMessage(const vm_char *msg); void EncodeZeroBitsAlign(); void EncodeStuffingBitsAlign(); void EncodePicture_Header(); void EncodeIVOP(); void EncodePVOP();// void EncodeBVOP(); void EncodeMCBPC_I(int mbtype, int mcbpc); void EncodeAdvIntraPredMode(int scan); void EncodeCBPY_I(int pat); void EncodeMCBPC_P(int mbtype, int mcbpc); void EncodeCBPY_P(int mbtype, int pat); void EncodeMacroBlockIntra_H263(Ipp16s *coeffs, int pattern, int *nzCount, int scan); void EncodeMacroBlockInter_H263(Ipp16s *coeffs, int pattern, int *nzCount); void EncodeMV(IppMotionVector *mv, int mbType); void ExpandFrame(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV); void PredictMV(h263_MacroBlock *MBcurr, int frGOB, int i, int j, int adv, IppMotionVector *mvPred); void Predict3MV(h263_MacroBlock *MBcurr, int frGOB, int i, int j, IppMotionVector *mvPred, IppMotionVector *mvCurr); void me4MV_Neighbours(h263_MacroBlock *MBcurr, int frGOB, int i, int j, IppMotionVector *mvPred); void ChooseAdvIntraPred(h263_MacroBlock *MBcurr, Ipp16s *coeffs, int *predDir); void PredictAdvIntra(h263_MacroBlock *MBcurr, Ipp16s *coeffs, int scan); int PredictReconstructAdvIntra(Ipp8u *pF[6], h263_MacroBlock *MBcurr, Ipp16s *coeffs, int *nzCount, int quant, int scan); void DCT8x8MacroBlock_H263(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB); int QuantMacroBlockIntra_H263(Ipp16s *coeffMB, Ipp32s *nzCount, int quant); int TransMacroBlockInter_H263(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, Ipp32s *nzCount, int quant, Ipp8u *mcPred, int lumaErr); void ReconMacroBlockNotCoded(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred); void OBMC_Macroblock(h263_MacroBlock *pMBinfo, IppMotionVector *mvCur, int colNum, int rowNum, IppiRect limitRectL, Ipp8u *pYr, int stepYr, Ipp8u *pYc, int stepYc); void ReconMacroBlockIntra_H263(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, int quant, int pattern); void ReconBlockIntra_AdvI_H263(Ipp8u *p, int step, Ipp16s *coef, h263_Block *bCurr, int quant, int pattern, int scan); void ReconMacroBlockInter_H263(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred, Ipp16s *coeffMB, int quant, int pattern); void ReconMacroBlockIntra_H263(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, int quant, h263_MacroBlock *MBcurr, int pattern, int dct_type); void ME_SAD_16x16(Ipp8u *pCur, Ipp8u *pRef, int step, int xL, int xR, int yT, int yB, int *bestSAD, IppMotionVector *mv); void ME_SAD_8x8(Ipp8u *pCur, Ipp8u *pRef, int step, int xL, int xR, int yT, int yB, int *bestSAD, IppMotionVector *mv, IppMotionVector *mv4, int x, int y, IppMotionVector *mvNeighb); void PostFrameRC(Ipp32s bpfEncoded);};#if defined(__INTEL_COMPILER) && !defined(_WIN32_WCE) #define __ALIGN16(type, name, size) \ __declspec (align(16)) type name[size]#else #if defined(_WIN64) || defined(WIN64) || defined(LINUX64) #define __ALIGN16(type, name, size) \ Ipp8u _a16_##name[(size)*sizeof(type)+15]; type *name = (type*)(((Ipp64s)(_a16_##name) + 15) & ~15) #else #define __ALIGN16(type, name, size) \ Ipp8u _a16_##name[(size)*sizeof(type)+15]; type *name = (type*)(((Ipp32s)(_a16_##name) + 15) & ~15) #endif#endif#define h263_Div2(a) ((a) >= 0 ? ((a) >> 1) : (((a)+1) >> 1))#define h263_Div2Round(a) (((a) >> 1) | ((a) & 1))#define h263_DivRoundInf(a, b) ((a) < 0 ? (((a) - ((b) >> 1)) / (b)) : (((a) + ((b) >> 1)) / (b)))#define h263_Clip(a, l, r) if (a < (l)) a = l; else if (a > (r)) a = r;#define h263_ClipL(a, l) if (a < (l)) a = l;#define h263_ClipR(a, r) if (a > (r)) a = r;#define h263_Zero8_16s(pDst) \ ((Ipp32u*)pDst)[0] = ((Ipp32u*)pDst)[1] = ((Ipp32u*)pDst)[2] = ((Ipp32u*)pDst)[3] = 0;#ifdef USE_INTRINSIC#define h263_Zero4MV(mv) \ memset(mv, 0, 4 * sizeof(IppMotionVector));#define h263_Zero64_16s(pDst) \{ \ __m128i _p_val = _mm_setzero_si128(); \ ((__m128i*)(pDst))[0] = _p_val; \ ((__m128i*)(pDst))[1] = _p_val; \ ((__m128i*)(pDst))[2] = _p_val; \ ((__m128i*)(pDst))[3] = _p_val; \ ((__m128i*)(pDst))[4] = _p_val; \ ((__m128i*)(pDst))[5] = _p_val; \ ((__m128i*)(pDst))[6] = _p_val; \ ((__m128i*)(pDst))[7] = _p_val; \}#define h263_Set64_16s(val, pDst) \{ \ __m128i _p_val = _mm_set1_epi16((Ipp16s)(val)); \ ((__m128i*)(pDst))[0] = _p_val; \ ((__m128i*)(pDst))[1] = _p_val; \ ((__m128i*)(pDst))[2] = _p_val; \ ((__m128i*)(pDst))[3] = _p_val; \ ((__m128i*)(pDst))[4] = _p_val; \ ((__m128i*)(pDst))[5] = _p_val; \ ((__m128i*)(pDst))[6] = _p_val; \ ((__m128i*)(pDst))[7] = _p_val; \}#else#define h263_Zero4MV(mv) \ *((Ipp32u*)&mv[0]) = *((Ipp32u*)&mv[1]) = *((Ipp32u*)&mv[2]) = *((Ipp32u*)&mv[3]) = 0#define h263_Zero64_16s(pDst) \{ \ int i; \ for (i = 0; i < 16; i += 4) {\ ((Ipp64u*)(pDst))[i] = 0; \ ((Ipp64u*)(pDst))[i+1] = 0; \ ((Ipp64u*)(pDst))[i+2] = 0; \ ((Ipp64u*)(pDst))[i+3] = 0; \ } \}#define h263_Set64_16s(val, pDst) \{ \ int i; \ Ipp32u v; \ v = ((val) << 16) + (Ipp16u)(val); \ for (i = 0; i < 32; i += 8) { \ ((Ipp32u*)(pDst))[i] = v; \ ((Ipp32u*)(pDst))[i+1] = v; \ ((Ipp32u*)(pDst))[i+2] = v; \ ((Ipp32u*)(pDst))[i+3] = v; \ ((Ipp32u*)(pDst))[i+4] = v; \ ((Ipp32u*)(pDst))[i+5] = v; \ ((Ipp32u*)(pDst))[i+6] = v; \ ((Ipp32u*)(pDst))[i+7] = v; \ } \}#endifinline void h263_Swap(Ipp8u* &a, Ipp8u* &b){ Ipp8u *t; t = a; a = b; b = t;}#define limitMV(dx, xmin, xmax, mvd) \{ \ if ((dx) < (xmin)) \ mvd = (Ipp16s)(xmin); \ else if ((dx) >= (xmax)) \ mvd = (Ipp16s)(xmax); \ else \ mvd = (Ipp16s)(dx); \}inline void h263_LimitMV(const IppMotionVector *pSrcMV, IppMotionVector *pDstMV, const IppiRect *limitRect, int x, int y, int size){ limitMV(pSrcMV->dx, (limitRect->x - x) << 1, (limitRect->x - x + limitRect->width - size) << 1, pDstMV->dx); limitMV(pSrcMV->dy, (limitRect->y - y) << 1, (limitRect->y - y + limitRect->height - size) << 1, pDstMV->dy);}inline void h263_Limit4MV(const IppMotionVector *pSrcMV, IppMotionVector *pDstMV, const IppiRect *limitRect, int x, int y, int size){ h263_LimitMV(&pSrcMV[0], &pDstMV[0], limitRect, x , y, size); h263_LimitMV(&pSrcMV[1], &pDstMV[1], limitRect, x + size, y, size); h263_LimitMV(&pSrcMV[2], &pDstMV[2], limitRect, x , y + size, size); h263_LimitMV(&pSrcMV[3], &pDstMV[3], limitRect, x + size, y + size, size);}extern const Ipp8u h263_cCbCrMvRound16_[];extern const Ipp8u h263_DCScalerLuma_[];extern const Ipp8u h263_DCScalerChroma_[];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -