/* SPDX-License-Identifier: LGPL-2.1 OR BSD-3-Clause */ //------------------------------------------------------------------------------ // File: main_helper.h // // Copyright (c) 2006, Chips & Media. All rights reserved. //------------------------------------------------------------------------------ #ifndef _MAIN_HELPER_H_ #define _MAIN_HELPER_H_ #include "config.h" #include "vpuapifunc.h" #include "vpuapi.h" #include "vputypes.h" #include "misc/debug.h" #ifdef PLATFORM_QNX #include #endif #ifdef SUPPORT_ENCODE_CUSTOM_HEADER #include "./misc/header_struct.h" #endif #define MATCH_OR_MISMATCH(_expected, _value, _ret) ((_ret=(_expected == _value)) ? "MATCH" : "MISMATCH") #if defined(WIN32) || defined(WIN64) /* ( _MSC_VER => 1200 ) 6.0 vs6 ( _MSC_VER => 1310 ) 7.1 vs2003 ( _MSC_VER => 1400 ) 8.0 vs2005 ( _MSC_VER => 1500 ) 9.0 vs2008 ( _MSC_VER => 1600 ) 10.0 vs2010 */ #if (_MSC_VER == 1200) #define strcasecmp stricmp #define strncasecmp strnicmp #else #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif #define inline _inline #if (_MSC_VER == 1600) #define strdup _strdup #endif #endif #define MAX_GETOPT_OPTIONS 100 //extension of option struct in getopt struct OptionExt { const char *name; int has_arg; int *flag; int val; const char *help; }; #define MAX_FILE_PATH 256 #define MAX_SRC_FILE_PATH 128 #define MAX_PIC_SKIP_NUM 5 #ifdef SUPPORT_SRC_BUF_CONTROL #define ENC_SRC_BUF_NUM 2000 #else #define ENC_SRC_BUF_NUM 16 //!< case of GOPsize = 8 (IBBBBBBBP), max src buffer num = 13 #endif #define EXTRA_SRC_BUFFER_NUM 0 #define VPU_WAIT_TIME_OUT 10 //should be less than normal decoding time to give a chance to fill stream. if this value happens some problem. we should fix VPU_WaitInterrupt function #define VPU_WAIT_TIME_OUT_CQ 1 #define PARALLEL_VPU_WAIT_TIME_OUT 1 //the value of timeout is 1 means we want to keep a waiting time to give a chance of an interrupt of the next core. extern char* productNameList[]; typedef union { struct { Uint32 ctu_force_mode : 2; //[ 1: 0] Uint32 ctu_coeff_drop : 1; //[ 2] Uint32 reserved : 5; //[ 7: 3] Uint32 sub_ctu_qp_0 : 6; //[13: 8] Uint32 sub_ctu_qp_1 : 6; //[19:14] Uint32 sub_ctu_qp_2 : 6; //[25:20] Uint32 sub_ctu_qp_3 : 6; //[31:26] Uint32 lambda_sad_0 : 8; //[39:32] Uint32 lambda_sad_1 : 8; //[47:40] Uint32 lambda_sad_2 : 8; //[55:48] Uint32 lambda_sad_3 : 8; //[63:56] } field; } EncCustomMap; // for wave520 custom map (1 CTU = 64bits) typedef enum { MODE_YUV_LOAD = 0, MODE_COMP_JYUV, MODE_SAVE_JYUV, MODE_COMP_CONV_YUV, MODE_SAVE_CONV_YUV, MODE_SAVE_LOAD_YUV, MODE_COMP_RECON, MODE_SAVE_RECON, MODE_COMP_ENCODED, MODE_SAVE_ENCODED } CompSaveMode; typedef struct { int picX; int picY; int internalBitDepth; int losslessEnable; int constIntraPredFlag; int gopSize; int numTemporalLayers; int decodingRefreshType; int intraQP; int intraPeriod; int frameRate; int confWinTop; int confWinBot; int confWinLeft; int confWinRight; int independSliceMode; int independSliceModeArg; int dependSliceMode; int dependSliceModeArg; int intraRefreshMode; int intraRefreshArg; int useRecommendEncParam; int scalingListEnable; int cuSizeMode; int tmvpEnable; int wppenable; int maxNumMerge; int dynamicMerge8x8Enable; int dynamicMerge16x16Enable; int dynamicMerge32x32Enable; int disableDeblk; int lfCrossSliceBoundaryEnable; int betaOffsetDiv2; int tcOffsetDiv2; int skipIntraTrans; int saoEnable; int intraInInterSliceEnable; int intraNxNEnable; int rcEnable; int bitRate; int intraQpOffset; int initBufLevelx8; int bitAllocMode; int fixedBitRatio[MAX_GOP_NUM]; int cuLevelRCEnable; int hvsQPEnable; int hvsQpScaleEnable; int hvsQpScale; int minQp; int maxQp; int maxDeltaQp; int initDelay; int transRate; int gopPresetIdx; // CUSTOM_GOP CustomGopParam gopParam; // ROI / CTU mode HevcCtuOptParam ctuOptParam; char roiFileName[MAX_FILE_PATH]; char ctuQpFileName[MAX_FILE_PATH]; // VUI HevcVuiParam vuiParam; Uint32 numUnitsInTick; Uint32 timeScale; Uint32 numTicksPocDiffOne; int encAUD; int encEOS; int encEOB; int chromaCbQpOffset; int chromaCrQpOffset; Uint32 initialRcQp; Uint32 nrYEnable; Uint32 nrCbEnable; Uint32 nrCrEnable; Uint32 nrNoiseEstEnable; Uint32 nrNoiseSigmaY; Uint32 nrNoiseSigmaCb; Uint32 nrNoiseSigmaCr; Uint32 nrIntraWeightY; Uint32 nrIntraWeightCb; Uint32 nrIntraWeightCr; Uint32 nrInterWeightY; Uint32 nrInterWeightCb; Uint32 nrInterWeightCr; Uint32 intraMinQp; Uint32 intraMaxQp; Uint32 useAsLongtermPeriod; Uint32 refLongtermPeriod; Uint32 vuiDataEnable; Uint32 vuiDataSize; char vuiDataFileName[MAX_FILE_PATH]; Uint32 hrdInVPS; Uint32 hrdInVUI; Uint32 hrdDataSize; char hrdDataFileName[MAX_FILE_PATH]; Uint32 prefixSeiEnable; Uint32 prefixSeiDataSize; Uint32 prefixSeiTimingFlag; char prefixSeiDataFileName[MAX_FILE_PATH]; Uint32 suffixSeiEnable; Uint32 suffixSeiDataSize; Uint32 suffixSeiTimingFlag; char suffixSeiDataFileName[MAX_FILE_PATH]; int forcedIdrHeaderEnable; // newly added for WAVE520 } HEVC_ENC_CFG; typedef struct { char SrcFileName[MAX_SRC_FILE_PATH]; char BitStreamFileName[MAX_FILE_PATH]; BOOL srcCbCrInterleave; int NumFrame; int PicX; int PicY; int FrameRate; // MPEG4 ONLY int VerId; int DataPartEn; int RevVlcEn; int ShortVideoHeader; int AnnexI; int AnnexJ; int AnnexK; int AnnexT; int IntraDcVlcThr; int VopQuant; int frameCroppingFlag; int frameCropLeft; int frameCropRight; int frameCropTop; int frameCropBottom; // H.264 ONLY int ConstIntraPredFlag; int DisableDeblk; int DeblkOffsetA; int DeblkOffsetB; int ChromaQpOffset; int PicQpY; // H.264 VUI information int VuiPresFlag; int VideoSignalTypePresFlag; char VideoFormat; char VideoFullRangeFlag; int ColourDescripPresFlag; char ColourPrimaries; char TransferCharacteristics; char MatrixCoeff; int NumReorderFrame; int MaxDecBuffering; int aud_en; int level; // COMMON int GopPicNum; int SliceMode; int SliceSizeMode; int SliceSizeNum; // COMMON - RC int RcEnable; int RcBitRate; int RcInitDelay; int RcBufSize; int IntraRefreshNum; int ConscIntraRefreshEnable; int frameSkipDisable; int ConstantIntraQPEnable; int MaxQpSetEnable; int MaxQp; //H.264 only int MaxDeltaQpSetEnable; int MaxDeltaQp; int MinQpSetEnable; int MinQp; int MinDeltaQpSetEnable; int MinDeltaQp; int intraCostWeight; //MP4 Only int RCIntraQP; int HecEnable; int GammaSetEnable; int Gamma; // NEW RC Scheme int rcIntervalMode; int RcMBInterval; int skipPicNums[MAX_PIC_SKIP_NUM]; int SearchRange; // for coda960 int MeUseZeroPmv; // will be removed. must be 264 = 0, mpeg4 = 1 263 = 0 int MeBlkModeEnable; // only api option int IDRInterval; int SrcBitDepth; HEVC_ENC_CFG hevcCfg; #ifdef AUTO_FRM_SKIP_DROP int enAutoFrmSkip; int enAutoFrmDrop; int vbvThreshold; int qpThreshold; int maxContinuosFrameSkipNum; int maxContinuosFrameDropNum; #endif int rcWeightFactor; } ENC_CFG; extern Uint32 randomSeed; /* yuv & md5 */ #define NO_COMPARE 0 #define YUV_COMPARE 1 #define MD5_COMPARE 2 #define STREAM_COMPARE 3 #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Performance report */ typedef void* PFCtx; PFCtx PFMonitorSetup( Uint32 coreIndex, Uint32 instanceIndex, Uint32 referenceClkInMHz, Uint32 fps, char* strLogDir ); void PFMonitorRelease( PFCtx context ); void PFMonitorUpdate( PFCtx context, Uint32 cycles ); void PrepareDecoderTest( DecHandle decHandle ); void PreparationWorkForDecTest( DecHandle decHandle ); void byte_swap( unsigned char* data, int len ); Int32 LoadFirmware( Int32 productId, Uint8** retFirmware, Uint32* retSizeInWord, const char* path ); void PrintDecSeqWarningMessages( Uint32 productId, DecInitialInfo* seqInfo ); void DisplayEncodedInformation( EncHandle handle, CodStd codec, Uint32 frameNo, EncOutputInfo* encodedInfo, ... ); void PrintEncSppStatus( Uint32 coreIdx, Uint32 productId ); void WriteRegVCE( Uint32 core_idx, Uint32 vce_core_idx, Uint32 vce_addr, Uint32 udata ); Uint32 ReadRegVCE( Uint32 core_idx, Uint32 vce_core_idx, Uint32 vce_addr ); /* * VPU Helper functions */ /************************************************************************/ /* Video */ /************************************************************************/ #define PUT_BYTE(_p, _b) \ *_p++ = (unsigned char)_b; #define PUT_BUFFER(_p, _buf, _len) \ osal_memcpy(_p, _buf, _len); \ _p += _len; #define PUT_LE32(_p, _var) \ *_p++ = (unsigned char)((_var)>>0); \ *_p++ = (unsigned char)((_var)>>8); \ *_p++ = (unsigned char)((_var)>>16); \ *_p++ = (unsigned char)((_var)>>24); #define PUT_BE32(_p, _var) \ *_p++ = (unsigned char)((_var)>>24); \ *_p++ = (unsigned char)((_var)>>16); \ *_p++ = (unsigned char)((_var)>>8); \ *_p++ = (unsigned char)((_var)>>0); #define PUT_LE16(_p, _var) \ *_p++ = (unsigned char)((_var)>>0); \ *_p++ = (unsigned char)((_var)>>8); #define PUT_BE16(_p, _var) \ *_p++ = (unsigned char)((_var)>>8); \ *_p++ = (unsigned char)((_var)>>0); Int32 ConvFOURCCToMp4Class( Int32 fourcc ); Int32 ConvFOURCCToCodStd( Uint32 fourcc ); Int32 ConvCodecIdToMp4Class( Uint32 codecId ); Int32 ConvCodecIdToCodStd( Int32 codecId ); Int32 ConvCodecIdToFourcc( Int32 codecId ); /*! * \brief wrapper function of StoreYuvImageBurstFormat() */ Uint8* GetYUVFromFrameBuffer( DecHandle decHandle, FrameBuffer* fb, VpuRect rcFrame, Uint32* retWidth, Uint32* retHeight, Uint32* retBpp, size_t* retSize ); /************************************************************************/ /* VpuMutex */ /************************************************************************/ typedef void* VpuMutex; VpuMutex VpuMutex_Create( void ); void VpuMutex_Destroy( VpuMutex handle ); BOOL VpuMutex_Lock( VpuMutex handle ); BOOL VpuMutex_Unlock( VpuMutex handle ); /************************************************************************/ /* Queue */ /************************************************************************/ typedef struct { void* data; } QueueData; typedef struct { Uint8* buffer; Uint32 size; Uint32 itemSize; Uint32 count; Uint32 front; Uint32 rear; VpuMutex lock; } Queue; Queue* Queue_Create( Uint32 itemCount, Uint32 itemSize ); Queue* Queue_Create_With_Lock( Uint32 itemCount, Uint32 itemSize ); void Queue_Destroy( Queue* queue ); /** * \brief Enqueue with deep copy */ BOOL Queue_Enqueue( Queue* queue, void* data ); /** * \brief Caller has responsibility for releasing the returned data */ void* Queue_Dequeue( Queue* queue ); void Queue_Flush( Queue* queue ); void* Queue_Peek( Queue* queue ); Uint32 Queue_Get_Cnt( Queue* queue ); /** * \brief @dstQ is NULL, it allocates Queue structure and then copy from @srcQ. */ Queue* Queue_Copy( Queue* dstQ, Queue* srcQ ); /************************************************************************/ /* VpuThread */ /************************************************************************/ typedef void* VpuThread; typedef void(*VpuThreadRunner)(void*); VpuThread VpuThread_Create( VpuThreadRunner func, void* arg ); BOOL VpuThread_Join( VpuThread thread ); /*! * \brief millisecond sleep */ void MSleep( Uint32 ms //!<< millisecond ); /************************************************************************/ /* ETC */ /************************************************************************/ Uint32 GetRandom( Uint32 start, Uint32 end ); #ifdef PLATFORM_WIN32 struct timezone { Int32 tz_minuteswest; /* minutes W of Greenwich */ BOOL tz_dsttime; /* type of dst correction */ }; Int32 gettimeofday( struct timeval* tv, struct timezone* tz ); #endif /************************************************************************/ /* MD5 */ /************************************************************************/ typedef struct MD5state_st { Uint32 A,B,C,D; Uint32 Nl,Nh; Uint32 data[16]; Uint32 num; } MD5_CTX; Int32 MD5_Init( MD5_CTX *c ); Int32 MD5_Update( MD5_CTX* c, const void* data, size_t len); Int32 MD5_Final( Uint8* md, MD5_CTX* c ); Uint8* MD5( const Uint8* d, size_t n, Uint8* md ); void plane_md5(MD5_CTX *md5_ctx, Uint8 *src, int src_x, int src_y, int out_x, int out_y, int stride, int bpp, Uint16 zero ); /************************************************************************/ /* Comparator */ /************************************************************************/ #define COMPARATOR_SKIP 0xF0F0F0F0 typedef enum { COMPARATOR_CONF_SET_GOLDEN_DATA_SIZE, COMPARATOR_CONF_SKIP_GOLDEN_DATA, /*!<< 2nd parameter pointer of Queue containing skip command */ COMPARATOR_CONF_SET_PICINFO, //!<< This command is followed by YUVInfo structure. } ComparatorConfType; typedef void* Comparator; typedef struct ComparatorImpl { void* context; char* filename; Uint32 curIndex; Uint32 numOfFrames; BOOL (*Create)(struct ComparatorImpl* impl, char* path); BOOL (*Destroy)(struct ComparatorImpl* impl); BOOL (*Compare)(struct ComparatorImpl* impl, void* data, Uint32 size); BOOL (*Configure)(struct ComparatorImpl* impl, ComparatorConfType type, void* val); BOOL (*Rewind)(struct ComparatorImpl* impl); BOOL eof; BOOL enableScanMode; BOOL usePrevDataOneTime; } ComparatorImpl; typedef struct { Uint32 totalFrames; ComparatorImpl* impl; } AbstractComparator; // YUV Comparator typedef struct { Uint32 width; Uint32 height; FrameBufferFormat format; BOOL cbcrInterleave; BOOL isVp9; } PictureInfo; Comparator Comparator_Create( Uint32 type, //!<< 1: yuv char* goldenPath, ... ); BOOL Comparator_Destroy( Comparator comp ); BOOL Comparator_Act( Comparator comp, void* data, Uint32 size ); BOOL Comparator_CheckFrameCount( Comparator comp ); BOOL Comparator_SetScanMode( Comparator comp, BOOL enable ); BOOL Comparator_Rewind( Comparator comp ); BOOL Comparator_CheckEOF( Comparator comp ); Queue* Comprator_MakeSkipData( Comparator comp, const char* skipCmd ); BOOL IsEndOfFile( FILE* fp ); /************************************************************************/ /* Bitstream Feeder */ /************************************************************************/ typedef enum { FEEDING_METHOD_FIXED_SIZE, FEEDING_METHOD_FRAME_SIZE, FEEDING_METHOD_SIZE_PLUS_ES, FEEDING_METHOD_MAX } FeedingMethod; typedef struct { void* data; Uint32 size; BOOL eos; //!<< End of stream } BSChunk; typedef void* BSFeeder; typedef void (*BSFeederHook)(BSFeeder feeder, void* data, Uint32 size, void* arg); /** * \brief BitstreamFeeder consumes bitstream and updates information of bitstream buffer of VPU. * \param handle handle of decoder * \param path bitstream path * \param method feeding method. see FeedingMethod. * \param loopCount If @loopCount is greater than 1 then BistreamFeeder reads the start of bitstream again * when it encounters the end of stream @loopCount times. * \param ... FEEDING_METHOD_FIXED_SIZE: * This value of parameter is size of chunk at a time. * If the size of chunk is equal to zero than the BitstreamFeeder reads bistream in random size.(1Byte ~ 4MB) * \return It returns the pointer of handle containing the context of the BitstreamFeeder. */ void* BitstreamFeeder_Create( const char* path, FeedingMethod method, PhysicalAddress base, Uint32 size, ... ); /** * \brief This is helper function set to simplify the flow that update bit-stream * to the VPU. */ Uint32 BitstreamFeeder_Act( DecHandle decHandle, BSFeeder feeder, EndianMode endian, vpu_buffer_t* buffer ); /** * \brief Set filling bitstream as ringbuffer mode or linebuffer mode. * \param mode 0 : auto * 1 : ringbuffer * 2 : linebuffer. */ #define BSF_FILLING_AUTO 0 #define BSF_FILLING_RINGBUFFER 1 #define BSF_FILLING_LINEBUFFER 2 /* BSF_FILLING_RINBGUFFER_WITH_ENDFLAG: * Scenario: * - Application writes 1 ~ 10 frames into bitstream buffer. * - Set stream end flag by using VPU_DecUpdateBitstreamBuffer(handle, 0). * - Application clears stream end flag by using VPU_DecUpdateBitstreamBuffer(handle, -1). * when indexFrameDisplay is equal to -1. * NOTE: * - Last frame cannot be a complete frame. */ #define BSF_FILLING_RINGBUFFER_WITH_ENDFLAG 3 void BitstreamFeeder_SetFillMode( BSFeeder feeder, Uint32 mode ); BOOL BitstreamFeeder_IsEos( BSFeeder feeder ); BOOL BitstreamFeeder_Destroy( BSFeeder feeder ); BOOL BitstreamFeeder_Rewind( BSFeeder feeder ); BOOL BitstreamFeeder_SetHook( BSFeeder feeder, BSFeederHook hookFunc, void* arg ); BOOL BitstreamFeeder_SetAutoUpdate( BSFeeder feeder, BOOL onoff ); /************************************************************************/ /* YUV Feeder */ /************************************************************************/ #define SOURCE_YUV 0 #define SOURCE_YUV_WITH_LOADER 2 #define SOURCE_YUV_WITH_BUFFER 3 #define JPEG_CREATE 0x01 //!<< This command is followed by yuvInfo structure. typedef struct { Uint32 cbcrInterleave; Uint32 nv21; Uint32 packedFormat; Uint32 srcFormat; Uint32 srcPlanar; Uint32 srcStride; Uint32 srcHeight; } YuvInfo; typedef void* YuvFeeder; typedef struct YuvFeederImpl { void* context; BOOL (*Create)(struct YuvFeederImpl* impl, const char* path, Uint32 packed, Uint32 fbStride, Uint32 fbHeight); BOOL (*Feed)(struct YuvFeederImpl* impl, Int32 coreIdx, FrameBuffer *fb, size_t picWidth, size_t picHeight, void* arg); BOOL (*Destroy)(struct YuvFeederImpl* impl); BOOL (*Configure)(struct YuvFeederImpl* impl, Uint32 cmd, YuvInfo yuv); } YuvFeederImpl; typedef struct { YuvFeederImpl* impl; Uint8 pYuv; } AbstractYuvFeeder; typedef struct { osal_file_t* fp; Uint8* pYuv; size_t fbStride; size_t cbcrInterleave; BOOL srcPlanar; } yuvContext; YuvFeeder YuvFeeder_Create( Uint32 type, const char* srcFilePath, YuvInfo yuvInfo ); BOOL YuvFeeder_Feed( YuvFeeder feeder, Uint32 coreIdx, FrameBuffer* fb, size_t picWidth, size_t picHeight, void* arg ); BOOL YuvFeeder_Destroy( YuvFeeder feeder ); /************************************************************************/ /* CNM video helper */ /************************************************************************/ /** * \param convertCbcrIntl If this value is TRUE, it stores YUV as NV12 or NV21 to @fb */ BOOL LoadYuvImageBurstFormat( Uint32 coreIdx, Uint8* src, size_t picWidth, size_t picHeight, FrameBuffer *fb, BOOL convertCbcrIntl ); void PreparationWorkForEncTest( EncHandle handle ); int ProcessEncodedBitstreamBurst( Uint32 core_idx, osal_file_t fp, int targetAddr, PhysicalAddress bsBufStartAddr, PhysicalAddress bsBufEndAddr, int size, int endian, Comparator comparator ); BOOL LoadTiledImageYuvBurst( Uint32 coreIdx, BYTE* pYuv, size_t picWidth, size_t picHeight, FrameBuffer* fb, TiledMapConfig mapCfg ); Uint32 StoreYuvImageBurstFormat( Uint32 coreIndex, FrameBuffer* fbSrc, TiledMapConfig mapCfg, Uint8* pDst, VpuRect cropRect, BOOL enableCrop ); /************************************************************************/ /* Bit Reader */ /************************************************************************/ #define BS_RESET_BUF 0 #define BS_RING_BUF 1 #define BUFFER_MODE_TYPE_LINEBUFFER 0 #define BUFFER_MODE_TYPE_RINGBUFFER 1 typedef void* BitstreamReader; typedef struct BitstreamReaderImpl { void* context; BOOL (*Create)(struct BitstreamReaderImpl* impl, const char* path); Uint32 (*Act)(struct BitstreamReaderImpl* impl, Int32 coreIdx, PhysicalAddress bitstreamBuffer, Uint32 bitstreamBufferSize, int endian, Comparator comparator); BOOL (*Destroy)(struct BitstreamReaderImpl* impl); BOOL (*Configure)(struct BitstreamReaderImpl* impl, Uint32 cmd, void* val); } BitstreamReaderImpl; /*! * \param type 0: Linebuffer, 1: Ringbuffer * \param path output filepath. * \param endian Endianness of bitstream buffer * \param handle Pointer of encoder handle */ BitstreamReader BitstreamReader_Create( Uint32 type, char* path, EndianMode endian, EncHandle* handle ); /*! * \param bitstreamBuffer base address of bitstream buffer * \param bitstreamBufferSize size of bitstream buffer */ BOOL BitstreamReader_Act( BitstreamReader reader, PhysicalAddress bitstreamBuffer, Uint32 bitstreamBufferSize, Uint32 defaultsize, Comparator comparator ); BOOL BitstreamReader_Destroy( BitstreamReader reader ); /*! * \param type 0: Linebuffer, 1: Ringbuffer * \param path output filepath. * \param endian Endianness of bitstream buffer * \param handle Pointer of encoder handle */ BitstreamReader BufferStreamReader_Create( Uint32 type, EndianMode endian, EncHandle* handle ); /*! * \param bitstreamBuffer base address of bitstream buffer * \param bitstreamBufferSize size of bitstream buffer */ Uint32 BufferStreamReader_Act( BitstreamReader reader, PhysicalAddress bitstreamBuffer, Uint32 bitstreamBufferSize, Uint32 defaultsize, Uint8* pBuffer, Comparator comparator ); BOOL BufferStreamReader_Destroy( BitstreamReader reader ); /************************************************************************/ /* Binary Reader */ /************************************************************************/ /************************************************************************/ /* Simple Renderer */ /************************************************************************/ typedef void* Renderer; typedef enum { RENDER_DEVICE_NULL, RENDER_DEVICE_FBDEV, RENDER_DEVICE_HDMI, RENDER_DEVICE_MAX } RenderDeviceType; typedef struct RenderDevice { void* context; DecHandle decHandle; BOOL (*Open)(struct RenderDevice* device); void (*Render)(struct RenderDevice* device, DecOutputInfo* fbInfo, Uint8* yuv, Uint32 width, Uint32 height); BOOL (*Close)(struct RenderDevice* device); } RenderDevice; Renderer SimpleRenderer_Create( DecHandle decHandle, RenderDeviceType deviceType, const char* yuvPath //!<< path to store yuv iamge. ); Uint32 SimpleRenderer_Act( Renderer renderer, DecOutputInfo* fbInfo, Uint8* pYuv, Uint32 width, Uint32 height ); void* SimpleRenderer_GetFreeFrameInfo( Renderer renderer ); /* \brief Flush display queues and clear display indexes */ void SimpleRenderer_Flush( Renderer renderer ); BOOL SimpleRenderer_Destroy( Renderer renderer ); BOOL SimpleRenderer_SetFrameRate( Renderer renderer, Uint32 fps ); /************************************************************************/ /* Etc */ /************************************************************************/ typedef struct { DecOutputInfo* buffer; int size; int count; int front; int rear; } frame_queue_item_t; frame_queue_item_t* frame_queue_init( Int32 count ); void frame_queue_deinit( frame_queue_item_t* queue ); Int32 frame_queue_enqueue( frame_queue_item_t* queue, DecOutputInfo data ); Int32 frame_queue_dequeue( frame_queue_item_t* queue, DecOutputInfo* data ); Int32 frame_queue_dequeue_all( frame_queue_item_t* queue ); Int32 frame_queue_peekqueue( frame_queue_item_t* queue, DecOutputInfo* data ); Int32 frame_queue_count( frame_queue_item_t* queue ); Int32 frame_queue_check_in_queue( frame_queue_item_t* queue, Int32 index ); /******************************************************************************* * DATATYPES AND FUNCTIONS RELATED TO REPORT *******************************************************************************/ typedef struct { osal_file_t fpPicDispInfoLogfile; osal_file_t fpPicTypeLogfile; osal_file_t fpSeqDispInfoLogfile; osal_file_t fpUserDataLogfile; osal_file_t fpSeqUserDataLogfile; // encoder report file osal_file_t fpEncSliceBndInfo; osal_file_t fpEncQpInfo; osal_file_t fpEncmvInfo; osal_file_t fpEncsliceInfo; // Report Information BOOL reportOpened; Int32 decIndex; vpu_buffer_t vb_rpt; BOOL userDataEnable; BOOL userDataReportMode; Int32 profile; Int32 level; } vpu_rpt_info_t; typedef struct VpuReportConfig_t { PhysicalAddress userDataBufAddr; BOOL userDataEnable; Int32 userDataReportMode; // (0 : Int32errupt mode, 1 Int32errupt disable mode) Int32 userDataBufSize; } VpuReportConfig_t; void OpenDecReport( Uint32 core_idx, VpuReportConfig_t* cfg ); void CloseDecReport( Uint32 core_idx ); void ConfigDecReport( Uint32 core_idx, DecHandle handle, CodStd bitstreamFormat ); void SaveDecReport( Uint32 core_idx, DecHandle handle, DecOutputInfo* pDecInfo, CodStd bitstreamFormat, Uint32 mbNumX, Uint32 mbNumY ); void CheckUserDataInterrupt( Uint32 core_idx, DecHandle handle, Int32 decodeIdx, CodStd bitstreamFormat, Int32 int_reason ); #define MAX_CFG (217) #define MAX_ROI_LEVEL (8) #define LOG2_CTB_SIZE (6) #define CTB_SIZE (1<