📄 h261_enc.hpp
字号:
/* /////////////////////////////////////////////////////////////////////////// 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) 2005 Intel Corporation. All Rights Reserved.//// Description: class ippVideoEncoderH261 (based on class ippVideoEncoder)//*/#include "h261_enc_bitstream.hpp"#include "ippdefs.h"#include "ipps.h"#include "ippi.h"#include "ippvc.h"#include "vm_debug.h"#pragma warning(disable : 4514) // unreferenced inline function has been removed#define MTYPE_MQUANT 1#define MTYPE_MVD 2#define MTYPE_TCOEFF 4#define MTYPE_FIL 8#define MTYPE_INTRA 16enum { H261_PIC_TYPE_I = 0, H261_PIC_TYPE_P = 1};/* MacroBlock Info */struct h261_MacroBlock { Ipp8u type; Ipp8u not_coded; IppMotionVector mv;};typedef struct { Ipp8u val; Ipp8u len;} VLCcode;/* Video Frame Info */struct h261_VideoFrame { int frame_quant; int temporal_reference; int split_screen_indicator; int document_camera_indicator; int freeze_picture_release; int source_format; int still_image_mode; int picture_coding_type; int gob_number; int num_gobs_in_frame;// int gob_frame_id;// int prev_mba;};struct h261_Param{ char SourceFileName[1024]; int Width; int Height; int quantIFrame, quantPFrame; int IFramedist; int PFramesearchWidth, PFramesearchHeight; int MEalgorithm; int calcPSNR; Ipp8u *bsBuffer; int bsBuffSize;};#define H261_ERROR_NOERR 0#define H261_ERROR_NOTINIT 1#define H261_ERROR_PARAM 2#define H261_ERROR_NOMEM 3class ippVideoEncoderH261{public : Ipp8u *mCurrPtrY, *mCurrPtrU, *mCurrPtrV; Ipp8u *mForwPtrY, *mForwPtrU, *mForwPtrV; int mSourceWidth; // width int mSourceHeight; // height int mStepLuma; int mStepChroma; int mFrameCount; Ipp64s mPSNR_Y, mPSNR_U, mPSNR_V; ippBitStreamH cBS;protected : bool mIsInit; int mError; int mbsAlloc; int mNumMacroBlockPerFrame; int mLumaPlaneSize; int mChromaPlaneSize; int mPlanes; Ipp8u **mPtrY, **mPtrU, **mPtrV; Ipp8u **mPtrYUV; int mQuantIFrame, mQuantPFrame; int mIFramedist; int mPFramesearchHor, mPFramesearchVer; int mMEalgorithm; Ipp32s *mMEfastSAD; int mMEfastSADsize; int mMEthrSAD16x16, mMEthrSAD8x8; int mCalcPSNR; h261_VideoFrame Frame; h261_MacroBlock *MBinfo; static const VLCcode mVLC_MBA[34]; static const Ipp8u mLen_MType[16]; static const VLCcode mVLC_MVD[17]; static const VLCcode mVLC_CBP[63];public : ippVideoEncoderH261() { mIsInit = false; mError = H261_ERROR_NOTINIT; }; ippVideoEncoderH261(h261_Param *par); ~ippVideoEncoderH261(); int Init(h261_Param *par); void Close(); int GetError() { return mError; }; void EncodeFrame(); void ErrorMessage(vm_char *msg);protected : void EncodeStartCode(Ipp8u sc); void EncodeZeroBitsAlign(); void EncodeStuffingBitsAlign(); void EncodeVideoPacketHeader(int mbn); void EncodePicture_Header(); void EncodeGOB_Header(); void EncodeMBA(Ipp8u mba); void EncodeMType(Ipp8u mtype); void EncodeMVD(IppMotionVector mvd); void EncodeCBP(Ipp8u cbp); void EncodeIFrame(); void EncodePFrame(); void EncodeMacroBlockIntra_H261(Ipp16s *coeffs, int *nzCount); void EncodeMacroBlockInter_H261(Ipp16s *coeffs, int *nzCount); void TransMacroBlockIntra_H261(Ipp8u *py, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, int *nzCount, int quant);// int TransMacroBlockInter_H261_(Ipp16s *coeffMB, Ipp32s *nzCount, int quant); int TransMacroBlockInter_H261(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp16s *coeffMB, int *nzCount, int quant, Ipp8u *mcPred, Ipp32s lumaErr, Ipp32s sU, Ipp32s sV); void ReconMacroBlockNotCoded(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred); void ReconMacroBlockIntra_H261(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, int quant, int *nzCount); void ReconMacroBlockInter_H261(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred, Ipp16s *coeffMB, int quant, int *nzCount); void ME_SAD_16x16(Ipp8u *pCur, Ipp8u *pRef, int step, int xL, int xR, int yT, int yB, Ipp32s *bestSAD, IppMotionVector *mv);};#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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -