📄 mp4.h
字号:
// for interlaced B-VOP direct mode int Tframe; IppMotionVector* FieldMV; // for B-VOP direct mode int TRB, TRD; // time increment of past and future VOP for B-VOP Ipp64s rTime, nTime; // VOP global time Ipp64s vop_sync_time, vop_sync_time_b; // Shape Info mp4_ShapeInfo *ShapeInfo;} mp4_VideoObject;/* StillTexture Object Info */typedef struct _mp4_StillTextureObject { int dummy;} mp4_StillTextureObject;/* Mesh Object Info */typedef struct _mp4_MeshObject { int dummy;} mp4_MeshObject;/* Face Object Info */typedef struct _mp4_FaceObject { int dummy;} mp4_FaceObject;/* video_signal_type Info */typedef struct _mp4_VideoSignalType { int is_video_signal_type; int video_format; int video_range; int is_colour_description; int colour_primaries; int transfer_characteristics; int matrix_coefficients;} mp4_VideoSignalType;/* Visual Object Info */typedef struct _mp4_VisualObject { int is_identifier; int verid; int priority; int type; mp4_VideoSignalType VideoSignalType; mp4_VideoObject VideoObject; mp4_StillTextureObject StillTextureObject; mp4_MeshObject MeshObject; mp4_FaceObject FaceObject; mp4_Frame sFrame; // static sprite mp4_Frame cFrame; // current mp4_Frame rFrame; // reference in past mp4_Frame nFrame; // reference in future mp4_Frame *vFrame; // frame for display int frameCount; int frameInterval; int frameScale; mp4_Statistic Statistic;} mp4_VisualObject;#ifdef _OMP_KARABAS/* MacroBlock Info for MT */typedef struct _mp4_MacroBlockMT { Ipp16s dctCoeffs[64*6]; IppMotionVector mvF[4]; // B-VOP IppMotionVector mvB[4]; // B-VOP int lnz[6]; Ipp8u pat; Ipp8u mb_type; // B-VOP Ipp8u dct_type; // interlaced Ipp8u field_info; // interlaced Ipp8u mcsel; // S(GMC)-VOP Ipp8u dummy[3]; // align 16} mp4_MacroBlockMT;#endif // _OMP_KARABAS/* Full Info */typedef struct _mp4_Info { int ftype; // 0 - raw, 1 - mp4, 2 - avi int ftype_f; // ftype == 1 (0 - QuickTime(tm)), ftype == 2 (0 - DivX(tm) v. < 5, XVID, 1 - DivX(tm) v. >= 5) int *fmp4sz; // sample size in mp4 files int *fmp4so; // sample offset in mp4 files int read; // bytes read FILE* stream; Ipp8u* buffer; /* buffer header for saving MPEG-4 stream */ size_t buflen; /* total buffer length */ size_t len; /* valid data in buf_head[], counter from head */ Ipp8u* bufptr; /* current frame, point to header or data */ int bitoff; /* mostly point to next frame header or PSC */ int profile_and_level_indication; mp4_VisualObject VisualObject;#ifdef _OMP_KARABAS mp4_MacroBlockMT* pMBinfoMT; /* OpenMP buffer */ int num_threads; /* OpenMP number of threads */#endif // _OMP_KARABAS} mp4_Info;/* bitstream functions */extern mp4_Status mp4_InitStream(mp4_Info* pInfo, char *fname);extern mp4_Status mp4_CloseStream(mp4_Info* pInfo);extern mp4_Status mp4_InitBuffer(mp4_Info* pInfo, int bSize);extern mp4_Status mp4_CloseBuffer(mp4_Info* pInfo);extern int mp4_ReadStreamChunk(mp4_Info* pInfo, int size);extern int mp4_RemainStream(mp4_Info* pInfo);extern int mp4_ReadStream(mp4_Info* pInfo, int size);extern int mp4_LoadStream(mp4_Info* pInfo);extern int mp4_ReloadStream(mp4_Info* pInfo);extern Ipp8u* mp4_FindStartCodePtr(mp4_Info* pInfo);extern Ipp8u* mp4_FindStartCodeOrShortPtr(mp4_Info* pInfo);extern int mp4_SeekStartCodePtr(mp4_Info* pInfo);extern int mp4_SeekStartCodeOrShortPtr(mp4_Info* pInfo);extern int mp4_SeekStartCodeValue(mp4_Info* pInfo, Ipp8u code);extern Ipp8u* mp4_FindShortVideoStartMarkerPtr(mp4_Info* pInfo);extern int mp4_SeekShortVideoStartMarker(mp4_Info* pInfo);extern int mp4_CheckResyncMarker(mp4_Info* pInfo, int rml);/* tables */typedef struct _mp4_VLC1 { Ipp8u code; Ipp8u len;} mp4_VLC1;extern const Ipp8u mp4_DefaultIntraQuantMatrix[];extern const Ipp8u mp4_DefaultNonIntraQuantMatrix[];extern const Ipp8u mp4_ClassicalZigzag[];extern const Ipp8u mp4_DCScalerLuma[];extern const Ipp8u mp4_DCScalerChroma[];extern const Ipp8u mp4_cCbCrMvRound16[];extern const Ipp8u mp4_cCbCrMvRound12[];extern const Ipp8u mp4_cCbCrMvRound8[];extern const Ipp8u mp4_cCbCrMvRound4[];extern const Ipp8s mp4_dquant[];extern const mp4_VLC1 mp4_cbpy1[];extern const mp4_VLC1 mp4_cbpy2[];extern const mp4_VLC1 mp4_cbpy3[];extern const mp4_VLC1 mp4_cbpy4[];extern const mp4_VLC1* mp4_cbpy_t[];extern const Ipp8u mp4_cbpy_b[];extern const int mp4_DC_vlc_Threshold[];extern const Ipp8u mp4_PVOPmb_type[];extern const Ipp8u mp4_PVOPmb_cbpc[];extern const Ipp8u mp4_PVOPmb_bits[];extern const mp4_VLC1 mp4_BVOPmb_type[];extern const mp4_VLC1 mp4_MVD_B12_1[];extern const mp4_VLC1 mp4_MVD_B12_2[];extern const int mp4_H263_width[];extern const int mp4_H263_height[];extern const int mp4_H263_mbgob[];extern const int mp4_H263_gobvop[];extern const Ipp8u mp4_aux_comp_count[];extern const Ipp8u mp4_aux_comp_is_alpha[];extern const Ipp8u mp4_BABtypeIntra[][3];extern const Ipp32s mp4_DivIntraDivisor[];// project functions//extern void mp4_Error(char *str);#define mp4_Error(str)extern mp4_Status mp4_InitDecoder(mp4_Info *pInfo, char *mp4FileName);extern mp4_Status mp4_CloseDecoder(mp4_Info *pInfo);extern mp4_Status mp4_InitVOL(mp4_Info *pInfo);extern mp4_Status mp4_FreeVOL(mp4_Info *pInfo);extern mp4_Status mp4_Decoder(mp4_Info *pInfo);//extern void mp4_ShowFrame(mp4_Frame *frame);#define mp4_ShowFrame(frame)extern mp4_Status mp4_Parse_VisualObject(mp4_Info* pInfo);extern mp4_Status mp4_Parse_VideoObject(mp4_Info* pInfo);extern mp4_Status mp4_Parse_GroupOfVideoObjectPlane(mp4_Info* pInfo);extern mp4_Status mp4_Parse_VideoObjectPlane(mp4_Info* pInfo);extern mp4_Status mp4_DecodeVideoObjectPlane(mp4_Info* pInfo);extern mp4_Status mp4_DecodeVideoPacket(mp4_Info* pInfo, int *quant_scale, int *found);extern mp4_Status mp4_InitVOPShape(mp4_Info *pInfo);extern mp4_Status mp4_FreeVOPShape(mp4_Info *pInfo);#ifdef _OMP_KARABAS#ifdef _OPENMP#include <omp.h>#endifextern int mp4_GetNumOfThreads(void);#endif // _OMP_KARABAS#ifndef MP4_USE_INLINE_BITS_FUNCextern Ipp32u mp4_ShowBits(mp4_Info* pInfo, int n);extern Ipp32u mp4_ShowBit(mp4_Info* pInfo);extern Ipp32u mp4_ShowBits9(mp4_Info* pInfo, int n);extern void mp4_FlushBits(mp4_Info* pInfo, int n);extern Ipp32u mp4_GetBits(mp4_Info* pInfo, int n);//extern Ipp32u mp4_GetBit(mp4_Info* pInfo);extern Ipp32u mp4_GetBits9(mp4_Info* pInfo, int n);extern void mp4_AlignBits(mp4_Info* pInfo);extern void mp4_AlignBits7F(mp4_Info* pInfo);extern Ipp32u mp4_ShowBitsAlign(mp4_Info* pInfo, int n);extern Ipp32u mp4_ShowBitsAlign7F(mp4_Info* pInfo, int n);#else__INLINE Ipp32u mp4_ShowBits(mp4_Info* pInfo, int n){ Ipp8u* ptr = pInfo->bufptr; Ipp32u tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); tmp <<= pInfo->bitoff; tmp >>= 32 - n; return tmp;}__INLINE Ipp32u mp4_ShowBit(mp4_Info* pInfo){ Ipp32u tmp = pInfo->bufptr[0]; tmp >>= 7 - pInfo->bitoff; return (tmp & 1);}__INLINE Ipp32u mp4_ShowBits9(mp4_Info* pInfo, int n){ Ipp8u* ptr = pInfo->bufptr; Ipp32u tmp = (ptr[0] << 8) | ptr[1]; tmp <<= (pInfo->bitoff + 16); tmp >>= 32 - n; return tmp;}__INLINE void mp4_FlushBits(mp4_Info* pInfo, int n){ n = n + pInfo->bitoff; pInfo->bufptr += n >> 3; pInfo->bitoff = n & 7;}__INLINE Ipp32u mp4_GetBits(mp4_Info* pInfo, int n){ Ipp8u* ptr = pInfo->bufptr; Ipp32u tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); tmp <<= pInfo->bitoff; tmp >>= 32 - n; n = n + pInfo->bitoff; pInfo->bufptr += n >> 3; pInfo->bitoff = n & 7; return tmp;}__INLINE Ipp32u mp4_GetBits9(mp4_Info* pInfo, int n){ Ipp8u* ptr = pInfo->bufptr; Ipp32u tmp = (ptr[0] << 8) | ptr[1]; tmp <<= (pInfo->bitoff + 16); tmp >>= 32 - n; n = n + pInfo->bitoff; pInfo->bufptr += n >> 3; pInfo->bitoff = n & 7; return tmp;}__INLINE void mp4_AlignBits(mp4_Info* pInfo){ if (pInfo->bitoff > 0) { pInfo->bitoff = 0; (pInfo->bufptr)++; }}__INLINE void mp4_AlignBits7F(mp4_Info* pInfo){ if (pInfo->bitoff > 0) { pInfo->bitoff = 0; (pInfo->bufptr)++; } else { if (*pInfo->bufptr == 0x7F) (pInfo->bufptr)++; }}__INLINE Ipp32u mp4_ShowBitsAlign(mp4_Info* pInfo, int n){ Ipp8u* ptr = pInfo->bitoff ? (pInfo->bufptr + 1) : pInfo->bufptr; Ipp32u tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); tmp >>= 32 - n; return tmp;}__INLINE Ipp32u mp4_ShowBitsAlign7F(mp4_Info* pInfo, int n){ Ipp8u* ptr = pInfo->bitoff ? (pInfo->bufptr + 1) : pInfo->bufptr; Ipp32u tmp; if (!pInfo->bitoff) { if (*ptr == 0x7F) ptr ++; } tmp = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); tmp >>= 32 - n; return tmp;}#endif // MP4_USE_INLINE_BITS_FUNC__INLINE Ipp32u mp4_GetBit(mp4_Info* pInfo){ Ipp32u tmp = pInfo->bufptr[0]; if (pInfo->bitoff != 7) { tmp >>= 7 - pInfo->bitoff; pInfo->bitoff ++; } else { pInfo->bitoff = 0; pInfo->bufptr ++; } return (tmp & 1);}__INLINE int mp4_GetMarkerBit(mp4_Info* pInfo) { if (!mp4_GetBit(pInfo)) { mp4_Error("Error in video_header: wrong marker bit"); return 0; } return 1;}#ifdef __cplusplus}#endif#endif //_MP4_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -