📄 vpu_api.h
字号:
// Copyright (c) 2006, Chips & Media. All rights reserved.
//-----------------------------------------------------------------------------
// Copyright (C) 2006-2007, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// File: vpu_api.h
// Purpose: Defines the structure and protoytpe of API for Video Codec module
//
//------------------------------------------------------------------------------
#ifndef __MX27_VPU_API_H__
#define __MX27_VPU_API_H__
#if __cplusplus
extern "C" {
#endif
#pragma warning(push)
#pragma warning(disable: 4115)
#pragma warning(disable: 4201)
#pragma warning(disable: 4204)
#pragma warning(disable: 4214)
#include <windows.h>
#pragma warning(pop)
//------------------------------------------------------------------------------
// MACRO DEFINITIONS
//------------------------------------------------------------------------------
#define MAX_NUM_INSTANCE 4
// The Software Event Name used by User
#define VPU_INT_PIC_RUN_NAME L"Vpu PIC Run Command"
//------------------------------------------------------------------------------
// Define Type Enumerations and Structure
//------------------------------------------------------------------------------
typedef unsigned char Uint8;
typedef unsigned long Uint32;
typedef unsigned short Uint16;
typedef Uint32 PhysicalAddress;
typedef PhysicalAddress *PPhysicalAddress;
//------------------------------------------------------------------------------
// common struct and definition
//------------------------------------------------------------------------------
typedef enum {
STD_MPEG4 = 0 ,
STD_H263,
STD_AVC
} CodStd;
typedef enum {
RETCODE_SUCCESS,
RETCODE_FAILURE,
RETCODE_INVALID_HANDLE,
RETCODE_INVALID_PARAM,
RETCODE_INVALID_COMMAND,
RETCODE_ROTATOR_OUTPUT_NOT_SET,
RETCODE_ROTATOR_STRIDE_NOT_SET,
RETCODE_FRAME_NOT_COMPLETE,
RETCODE_INVALID_FRAME_BUFFER,
RETCODE_INSUFFICIENT_FRAME_BUFFERS,
RETCODE_INVALID_STRIDE,
RETCODE_WRONG_CALL_SEQUENCE,
RETCODE_CALLED_BEFORE,
RETCODE_NOT_INITIALIZED,
RETCODE_DEBLOCKING_OUTPUT_NOT_SET,
RETCODE_FAILURE_TIMEOUT,
RETCODE_BUSY,
RETCODE_IDLE
} RetCode;
typedef enum {
ENABLE_ROTATION,
DISABLE_ROTATION,
ENABLE_MIRRORING,
DISABLE_MIRRORING,
SET_MIRROR_DIRECTION,
SET_ROTATION_ANGLE,
SET_ROTATOR_OUTPUT,
SET_ROTATOR_STRIDE,
ENC_GET_SPS_RBSP,
ENC_GET_PPS_RBSP,
DEC_SET_SPS_RBSP,
DEC_SET_PPS_RBSP,
ENC_PUT_MP4_HEADER,
ENC_PUT_AVC_HEADER,
ENC_SET_SEARCHRAM_PARAM,
ENC_GET_VOS_HEADER,
ENC_GET_VO_HEADER,
ENC_GET_VOL_HEADER,
ENC_SET_INTRA_MB_REFRESH_NUMBER,
ENC_ENABLE_HEC,
ENC_DISABLE_HEC,
ENC_SET_SLICE_INFO,
ENC_SET_GOP_NUMBER,
ENC_SET_INTRA_QP,
ENC_SET_BITRATE,
ENC_SET_FRAME_RATE
} CodecCommand;
typedef struct {
PhysicalAddress bufY;
PhysicalAddress bufCb;
PhysicalAddress bufCr;
} FrameBuffer;
typedef struct {
Uint32 left;
Uint32 top;
Uint32 right;
Uint32 bottom;
} Rect;
typedef enum {
MIRDIR_NONE,
MIRDIR_VER,
MIRDIR_HOR,
MIRDIR_HOR_VER
} MirrorDirection;
struct CodecInst;
//------------------------------------------------------------------------------
// decode struct and definition
//------------------------------------------------------------------------------
typedef struct CodecInst DecInst;
typedef DecInst * DecHandle;
typedef struct {
CodStd bitstreamFormat;
PhysicalAddress bitstreamBuffer;
Uint8 *virt_bitstreamBuffer;
int bitstreamBufferSize;
int qpReport;
int reorderEnable;
int filePlayEnable;
int picWidth;
int picHeight;
int dynamicAllocEnable;
int streamStartByteOffset;
PhysicalAddress psSaveBuffer;
int psSaveBufferSize;
} DecOpenParam;
typedef struct {
int picWidth; // {(PicX+15)/16} * 16
int picHeight; // {(PicY+15)/16} * 16
Uint32 frameRateInfo;
Uint32 picCropEnable;
Rect picCropRect;
int mp4_dataPartitionEnable;
int mp4_reversibleVlcEnable;
int mp4_shortVideoHeader;
int h263_annexJEnable;
int minFrameBufferCount;
int frameBufDelay;
int nextDecodedIdxNum;
int normalSliceSize;
int worstSliceSize;
} DecInitialInfo;
typedef struct{
PhysicalAddress sliceSaveBuffer;
int sliceSaveBufferSize;
} DecAvcSliceBufInfo;
typedef struct{
DecAvcSliceBufInfo avcSliceBufInfo;
} DecBufInfo;
typedef struct {
int prescanEnable;
int prescanMode;
int dispReorderBuf;
int iframeSearchEnable;
int skipframeMode;
int skipframeNum;
int chunkSize;
int picStartByteOffset;
PhysicalAddress picStreamBufferAddr;
} DecParam;
typedef struct {
int indexFrameDisplay;
int indexFrameDecoded;
int picType;
int numOfErrMBs;
PhysicalAddress phys_qpInfo;
Uint8 *virt_qpInfo;
int prescanresult;
int indexFrameNextDecoded[3];
int notSufficientPsBuffer;
int notSufficientSliceBuffer;
} DecOutputInfo;
typedef struct {
Uint32 * paraSet;
int size;
} DecParamSet;
typedef struct {
ULONG PhysAdd;
ULONG VirtAdd;
UINT Reserved; // Used by driver internally
} VPUMemAlloc;
//------------------------------------------------------------------------------
// encode struct and definition
//------------------------------------------------------------------------------
typedef struct CodecInst EncInst;
typedef EncInst * EncHandle;
typedef struct {
int mp4_dataPartitionEnable;
int mp4_reversibleVlcEnable;
int mp4_intraDcVlcThr;
int mp4_hecEnable;
int mp4_verid;
} EncMp4Param;
typedef struct{
int sliceMode;
int sliceSizeMode;
int sliceSize;
} EncSliceMode;
typedef struct {
int h263_annexJEnable;
int h263_annexKEnable;
int h263_annexTEnable;
} EncH263Param;
typedef struct {
int avc_constrainedIntraPredFlag;
int avc_disableDeblk;
int avc_deblkFilterOffsetAlpha;
int avc_deblkFilterOffsetBeta;
int avc_chromaQpOffset;
int avc_audEnable;
int avc_fmoEnable;
int avc_fmoSliceNum;
int avc_fmoType;
} EncAvcParam;
typedef struct {
CodStd bitstreamFormat;
PhysicalAddress bitstreamBuffer;
Uint32 bitstreamBufferSize;
Uint8 *virt_bitstreamBuffer;
int picWidth;
int picHeight;
Uint32 frameRateInfo;
int bitRate;
int initialDelay;
int vbvBufferSize;
int enableAutoSkip;
int gopSize;
EncSliceMode slicemode;
int intraRefresh;
int sliceReport;
int mbReport;
int mbQpReport;
int rcIntraQp;
int dynamicAllocEnable;
int ringBufferEnable;
union {
EncMp4Param mp4Param;
EncH263Param h263Param;
EncAvcParam avcParam;
} EncStdParam;
} EncOpenParam;
typedef struct {
int minFrameBufferCount;
} EncInitialInfo;
typedef struct {
FrameBuffer * sourceFrame;
int forceIPicture;
int skipPicture;
int quantParam;
PhysicalAddress picStreamBufferAddr;
int picStreamBufferSize;
int intraRefresh;
int hecEnable;
EncSliceMode slicemode;
} EncParam;
typedef struct {
PhysicalAddress bitstreamBuffer;
Uint32 bitstreamSize;
int bitstreamWrapAround;
int picType;
int numOfSlices;
Uint8 *sliceInfo;
Uint8 *mbInfo;
Uint8 *mbQpInfo;
} EncOutputInfo;
typedef struct {
Uint8 *paraSet;
int size;
} EncParamSet;
typedef struct {
PhysicalAddress searchRamAddr;
} SearchRamParam;
typedef struct {
PhysicalAddress PhysBuf;
Uint8 *VirtBuf;
int size;
int headerType;
} EncHeaderParam;
typedef enum {
VOL_HEADER,
VOS_HEADER,
VIS_HEADER
} Mp4HeaderType;
typedef enum {
SPS_RBSP,
PPS_RBSP
} AvcHeaderType;
typedef struct {
Uint32 gopNumber;
Uint32 intraQp;
Uint32 bitrate;
Uint32 framerate;
} stChangeRcPara;
//------------------------------------------------------------------------------
// MX27 CODEC API interfaces
//------------------------------------------------------------------------------
RetCode vpu_AllocPhysMem(Uint32 cbSize, VPUMemAlloc *pmemalloc);
RetCode vpu_FreePhysMem(VPUMemAlloc *pmemalloc);
BOOL vpu_ReleaseCodecMutex(void);
RetCode vpu_GetPhysAddrFromVirtAddr(void *lpvAddress, Uint32 cbSize, PhysicalAddress* lppAddress);
RetCode vpu_Init();
RetCode vpu_Deinit(void);
RetCode vpu_IsBusy(void);
RetCode vpu_GetVersionInfo( Uint32 *versionInfo );
// function for encode
RetCode vpu_EncOpen(EncHandle *pHandle, EncOpenParam *pop);
RetCode vpu_EncClose(EncHandle handle);
RetCode vpu_EncGetInitialInfo(EncHandle handle, EncInitialInfo * info);
RetCode vpu_EncRegisterFrameBuffer(EncHandle handle,
FrameBuffer * bufArray, int num, int stride);
RetCode vpu_EncGetBitstreamBuffer(EncHandle handle, PhysicalAddress * prdPrt,
PhysicalAddress * pwrPtr, Uint32 * size);
RetCode vpu_EncUpdateBitstreamBuffer(EncHandle handle, Uint32 size);
RetCode vpu_EncStartOneFrame(EncHandle handle, EncParam * param );
RetCode vpu_EncGetOutputInfo(EncHandle handle, EncOutputInfo * info);
RetCode vpu_EncGiveCommand(EncHandle handle, CodecCommand cmd, void * parameter);
// function for decode
RetCode vpu_DecOpen(DecHandle * pHandle, DecOpenParam * pop);
RetCode vpu_DecClose(DecHandle handle);
RetCode vpu_DecSetEscSeqInit(DecHandle handle, int escape );
RetCode vpu_DecGetInitialInfo(DecHandle handle, DecInitialInfo * info);
RetCode vpu_DecRegisterFrameBuffer(DecHandle handle, FrameBuffer * bufArray,
int num, int stride, DecBufInfo * pBufInfo);
RetCode vpu_DecGetBitstreamBuffer(DecHandle handle, PhysicalAddress * prdPrt,
PhysicalAddress * pwrPtr, Uint32 * size );
RetCode vpu_DecUpdateBitstreamBuffer(DecHandle handle, Uint32 size);
RetCode vpu_DecStartOneFrame(DecHandle handle, DecParam *param );
RetCode vpu_DecGetOutputInfo(DecHandle handle, DecOutputInfo * info);
RetCode vpu_DecBitBufferFlush(DecHandle handle);
RetCode vpu_DecGiveCommand(DecHandle handle, CodecCommand cmd, void * parameter);
#ifdef __cplusplus
}
#endif
#endif // __MX27_VPU_API_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -