Merge pull request #21 from ethanhugg/astyle

Pretty printed the C++ code with astyle
This commit is contained in:
ekr 2013-12-12 14:44:37 -08:00
commit fd420e071b
225 changed files with 47496 additions and 50993 deletions

9
build/astyle.cfg Normal file
View File

@ -0,0 +1,9 @@
--style=google
--indent=spaces=2
--max-code-length=120
--pad-oper
--align-pointer=type
--align-reference=type
--unpad-paren
--pad-first-paren-out
--lineend=linux

View File

@ -78,12 +78,12 @@ typedef HANDLE WELS_EVENT;
#include <fcntl.h>
typedef pthread_t WELS_THREAD_HANDLE;
typedef void* (*LPWELS_THREAD_ROUTINE) ( void * );
typedef void* (*LPWELS_THREAD_ROUTINE) (void*);
typedef pthread_mutex_t WELS_MUTEX;
typedef sem_t WELS_EVENT;
typedef sem_t WELS_EVENT;
#define WELS_THREAD_ROUTINE_TYPE void *
#define WELS_THREAD_ROUTINE_TYPE void *
#define WELS_THREAD_ROUTINE_RETURN(rc) return (void*)rc;
#endif//__GNUC__
@ -93,55 +93,56 @@ typedef sem_t WELS_EVENT;
typedef int32_t WELS_THREAD_ERROR_CODE;
typedef int32_t WELS_THREAD_ATTR;
typedef struct _WelsLogicalProcessorInfo
{
int32_t ProcessorCount;
typedef struct _WelsLogicalProcessorInfo {
int32_t ProcessorCount;
} WelsLogicalProcessInfo;
#define WELS_THREAD_ERROR_OK 0
#define WELS_THREAD_ERROR_GENERIAL ((uint32_t)(-1))
#define WELS_THREAD_ERROR_WAIT_OBJECT_0 0
#define WELS_THREAD_ERROR_WAIT_TIMEOUT ((uint32_t)0x00000102L)
#define WELS_THREAD_ERROR_WAIT_TIMEOUT ((uint32_t)0x00000102L)
#define WELS_THREAD_ERROR_WAIT_FAILED WELS_THREAD_ERROR_GENERIAL
void WelsSleep( uint32_t dwMilliseconds );
WELS_THREAD_ERROR_CODE WelsMutexInit( WELS_MUTEX * mutex );
WELS_THREAD_ERROR_CODE WelsMutexLock( WELS_MUTEX * mutex );
WELS_THREAD_ERROR_CODE WelsMutexUnlock( WELS_MUTEX * mutex );
WELS_THREAD_ERROR_CODE WelsMutexDestroy( WELS_MUTEX * mutex );
void WelsSleep (uint32_t dwMilliseconds);
WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex);
WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex);
WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex);
WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex);
#ifdef __GNUC__
WELS_THREAD_ERROR_CODE WelsEventOpen( WELS_EVENT **p_event, str_t *event_name );
WELS_THREAD_ERROR_CODE WelsEventClose( WELS_EVENT *event, str_t *event_name );
WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT** p_event, str_t* event_name);
WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, str_t* event_name);
#endif//__GNUC__
WELS_THREAD_ERROR_CODE WelsEventInit( WELS_EVENT *event );
WELS_THREAD_ERROR_CODE WelsEventDestroy( WELS_EVENT * event );
WELS_THREAD_ERROR_CODE WelsEventSignal( WELS_EVENT * event );
WELS_THREAD_ERROR_CODE WelsEventReset( WELS_EVENT * event );
WELS_THREAD_ERROR_CODE WelsEventWait( WELS_EVENT * event );
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut( WELS_EVENT * event, uint32_t dwMilliseconds );
WELS_THREAD_ERROR_CODE WelsEventInit (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventDestroy (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventReset (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds);
#ifdef WIN32
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking( uint32_t nCount, WELS_EVENT *event_list, uint32_t dwMilliseconds );
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking( uint32_t nCount, WELS_EVENT *event_list );
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT* event_list,
uint32_t dwMilliseconds);
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT* event_list);
#else
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking( uint32_t nCount, WELS_EVENT **event_list, uint32_t dwMilliseconds );
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking( uint32_t nCount, WELS_EVENT **event_list );
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT** event_list,
uint32_t dwMilliseconds);
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT** event_list);
#endif//WIN32
WELS_THREAD_ERROR_CODE WelsThreadCreate( WELS_THREAD_HANDLE * thread, LPWELS_THREAD_ROUTINE routine,
void * arg, WELS_THREAD_ATTR attr);
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
void* arg, WELS_THREAD_ATTR attr);
WELS_THREAD_ERROR_CODE WelsSetThreadCancelable();
WELS_THREAD_ERROR_CODE WelsThreadJoin( WELS_THREAD_HANDLE thread );
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread);
WELS_THREAD_ERROR_CODE WelsThreadCancel( WELS_THREAD_HANDLE thread );
WELS_THREAD_ERROR_CODE WelsThreadCancel (WELS_THREAD_HANDLE thread);
WELS_THREAD_ERROR_CODE WelsThreadDestroy( WELS_THREAD_HANDLE *thread );
WELS_THREAD_ERROR_CODE WelsThreadDestroy (WELS_THREAD_HANDLE* thread);
WELS_THREAD_HANDLE WelsThreadSelf();
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo(WelsLogicalProcessInfo * pInfo);
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* pInfo);
#ifdef __cplusplus

File diff suppressed because it is too large Load Diff

View File

@ -36,91 +36,89 @@
#include "codec_app_def.h"
#include "codec_def.h"
class ISVCEncoder
{
public:
/*
* return: CM_RETURN: 0 - success; otherwise - failed;
*/
virtual int Initialize(SVCEncodingParam* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
virtual int Initialize(void* pParam, const INIT_TYPE kiInitType = INIT_TYPE_CONFIG_BASED) = 0;
virtual int Uninitialize() = 0;
/*
* return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid]
*/
virtual int EncodeFrame(const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0;
virtual int EncodeFrame(const SSourcePicture ** kppSrcPicList, int nSrcPicNum, SFrameBSInfo * pBsInfo) = 0;
/*
* return: 0 - success; otherwise - failed;
*/
virtual int PauseFrame(const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0;
/*
* return: 0 - success; otherwise - failed;
*/
virtual int ForceIntraFrame(bool bIDR) = 0;
/************************************************************************
* InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,..
************************************************************************/
/*
* return: CM_RETURN: 0 - success; otherwise - failed;
*/
virtual int SetOption(ENCODER_OPTION eOptionId, void* pOption) = 0;
virtual int GetOption(ENCODER_OPTION eOptionId, void* pOption) = 0;
class ISVCEncoder {
public:
/*
* return: CM_RETURN: 0 - success; otherwise - failed;
*/
virtual int Initialize (SVCEncodingParam* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
virtual int Initialize (void* pParam, const INIT_TYPE kiInitType = INIT_TYPE_CONFIG_BASED) = 0;
virtual int Uninitialize() = 0;
/*
* return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid]
*/
virtual int EncodeFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0;
virtual int EncodeFrame (const SSourcePicture** kppSrcPicList, int nSrcPicNum, SFrameBSInfo* pBsInfo) = 0;
/*
* return: 0 - success; otherwise - failed;
*/
virtual int PauseFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0;
/*
* return: 0 - success; otherwise - failed;
*/
virtual int ForceIntraFrame (bool bIDR) = 0;
/************************************************************************
* InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,..
************************************************************************/
/*
* return: CM_RETURN: 0 - success; otherwise - failed;
*/
virtual int SetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
virtual int GetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
};
class ISVCDecoder
{
public:
virtual long Initialize(void* pParam, const INIT_TYPE iInitType) = 0;
virtual long Uninitialize() = 0;
class ISVCDecoder {
public:
virtual long Initialize (void* pParam, const INIT_TYPE iInitType) = 0;
virtual long Uninitialize() = 0;
virtual DECODING_STATE DecodeFrame( const unsigned char* pSrc,
const int iSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight ) = 0;
virtual DECODING_STATE DecodeFrame (const unsigned char* pSrc,
const int iSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight) = 0;
/*
* src must be 4 byte aligned, recommend 16 byte aligned. the available src size must be multiple of 4.
*/
virtual DECODING_STATE DecodeFrame( const unsigned char* pSrc,
const int iSrcLen,
void ** ppDst,
SBufferInfo* pDstInfo) = 0;
/*
* src must be 4 byte aligned, recommend 16 byte aligned. the available src size must be multiple of 4.
*/
virtual DECODING_STATE DecodeFrame (const unsigned char* pSrc,
const int iSrcLen,
void** ppDst,
SBufferInfo* pDstInfo) = 0;
/*
* src must be 4 byte aligned, recommend 16 byte aligned. the available src size must be multiple of 4.
*/
virtual DECODING_STATE DecodeFrameEx( const unsigned char * pSrc,
const int iSrcLen,
unsigned char * pDst,
int iDstStride,
int & iDstLen,
int & iWidth,
int & iHeight,
int & iColorFormat) = 0;
/*
* src must be 4 byte aligned, recommend 16 byte aligned. the available src size must be multiple of 4.
*/
virtual DECODING_STATE DecodeFrameEx (const unsigned char* pSrc,
const int iSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& iColorFormat) = 0;
/*************************************************************************
* OutDataFormat
*************************************************************************/
virtual long SetOption(DECODER_OPTION eOptionId, void* pOption) = 0;
virtual long GetOption(DECODER_OPTION eOptionId, void* pOption) = 0;
/*************************************************************************
* OutDataFormat
*************************************************************************/
virtual long SetOption (DECODER_OPTION eOptionId, void* pOption) = 0;
virtual long GetOption (DECODER_OPTION eOptionId, void* pOption) = 0;
};
extern "C"
extern "C"
{
int CreateSVCEncoder(ISVCEncoder** ppEncoder);
void DestroySVCEncoder(ISVCEncoder* pEncoder);
int CreateSVCEncoder (ISVCEncoder** ppEncoder);
void DestroySVCEncoder (ISVCEncoder* pEncoder);
long CreateDecoder(ISVCDecoder** ppDecoder);
void DestroyDecoder(ISVCDecoder* pDecoder);
long CreateDecoder (ISVCDecoder** ppDecoder);
void DestroyDecoder (ISVCDecoder* pDecoder);
}
#endif//WELS_VIDEO_CODEC_SVC_API_H__

View File

@ -50,241 +50,230 @@
#define SAVED_NALUNIT_NUM_TMP ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) //SPS/PPS + SEI/SSEI + PADDING_NAL
#define MAX_SLICES_NUM_TMP ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM_TMP ) / 3 )
typedef enum
{
/* Errors derived from bitstream parsing */
dsErrorFree = 0x00, /* Bitstream error-free */
dsFramePending = 0x01, /* Need more throughput to generate a frame output, */
dsRefLost = 0x02, /* layer lost at reference frame with temporal id 0 */
dsBitstreamError = 0x04, /* Error bitstreams(maybe broken internal frame) the decoder cared */
dsDepLayerLost = 0x08, /* Dependented layer is ever lost */
dsNoParamSets = 0x10, /* No parameter set NALs involved */
/* Errors derived from logic level */
dsInvalidArgument = 0x1000, /* Invalid argument specified */
dsInitialOptExpected= 0x2000, /* Initializing operation is expected */
dsOutOfMemory = 0x4000, /* Out of memory due to new request */
/* ANY OTHERS? */
dsDstBufNeedExpand = 0x8000 /* Actual picture size exceeds size of dst pBuffer feed in decoder, so need expand its size */
}DECODING_STATE;
typedef enum {
/* Errors derived from bitstream parsing */
dsErrorFree = 0x00, /* Bitstream error-free */
dsFramePending = 0x01, /* Need more throughput to generate a frame output, */
dsRefLost = 0x02, /* layer lost at reference frame with temporal id 0 */
dsBitstreamError = 0x04, /* Error bitstreams(maybe broken internal frame) the decoder cared */
dsDepLayerLost = 0x08, /* Dependented layer is ever lost */
dsNoParamSets = 0x10, /* No parameter set NALs involved */
/* Errors derived from logic level */
dsInvalidArgument = 0x1000, /* Invalid argument specified */
dsInitialOptExpected = 0x2000, /* Initializing operation is expected */
dsOutOfMemory = 0x4000, /* Out of memory due to new request */
/* ANY OTHERS? */
dsDstBufNeedExpand = 0x8000 /* Actual picture size exceeds size of dst pBuffer feed in decoder, so need expand its size */
} DECODING_STATE;
/* Option types introduced in SVC encoder application */
typedef enum
{
ENCODER_OPTION_DATAFORMAT = 0,
ENCODER_OPTION_IDR_INTERVAL,
ENCODER_OPTION_SVC_ENCODE_PARAM,
ENCODER_OPTION_FRAME_RATE,
ENCODER_OPTION_iBitRate,
ENCODER_OPTION_INTER_SPATIAL_PRED,
ENCODER_OPTION_RC_MODE,
ENCODER_PADDING_PADDING,
typedef enum {
ENCODER_OPTION_DATAFORMAT = 0,
ENCODER_OPTION_IDR_INTERVAL,
ENCODER_OPTION_SVC_ENCODE_PARAM,
ENCODER_OPTION_FRAME_RATE,
ENCODER_OPTION_iBitRate,
ENCODER_OPTION_INTER_SPATIAL_PRED,
ENCODER_OPTION_RC_MODE,
ENCODER_PADDING_PADDING,
ENCODER_LTR_RECOVERY_REQUEST,
ENCODER_LTR_MARKING_FEEDBACK,
ENCOCER_LTR_MARKING_PERIOD,
ENCODER_OPTION_LTR,
ENCODER_OPTION_ENABLE_SSEI, //disable SSEI: true--disable ssei; false--enable ssei
ENCODER_OPTION_ENABLE_PREFIX_NAL_ADDING, //enable prefix: true--enable prefix; false--disable prefix
ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, //disable pSps/pPps id addition: true--disable pSps/pPps id; false--enable pSps/pPps id addistion
ENCODER_LTR_RECOVERY_REQUEST,
ENCODER_LTR_MARKING_FEEDBACK,
ENCOCER_LTR_MARKING_PERIOD,
ENCODER_OPTION_LTR,
ENCODER_OPTION_CURRENT_PATH
ENCODER_OPTION_ENABLE_SSEI, //disable SSEI: true--disable ssei; false--enable ssei
ENCODER_OPTION_ENABLE_PREFIX_NAL_ADDING, //enable prefix: true--enable prefix; false--disable prefix
ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, //disable pSps/pPps id addition: true--disable pSps/pPps id; false--enable pSps/pPps id addistion
ENCODER_OPTION_CURRENT_PATH
} ENCODER_OPTION;
/* Option types introduced in SVC decoder application */
typedef enum
{
DECODER_OPTION_DATAFORMAT = 0, /* Set color space of decoding output frame */
DECODER_OPTION_TRUNCATED_MODE, /* Used in decoding bitstream of non integrated frame, only truncated working mode is supported by tune, so skip it */
DECODER_OPTION_END_OF_STREAM, /* Indicate bitstream of the final frame to be decoded */
DECODER_OPTION_VCL_NAL, //feedback whether or not have VCL NAL in current AU for application layer
DECODER_OPTION_TEMPORAL_ID, //feedback temporal id for application layer
DECODER_OPTION_MODE, // indicates the decoding mode
DECODER_OPTION_OUTPUT_PROPERTY,
DECODER_OPTION_FRAME_NUM, //feedback current decoded frame number
DECODER_OPTION_IDR_PIC_ID, // feedback current frame belong to which IDR period
DECODER_OPTION_LTR_MARKING_FLAG, // feedback wether current frame mark a LTR
DECODER_OPTION_LTR_MARKED_FRAME_NUM, // feedback frame num marked by current Frame
DECODER_OPTION_DEVICE_INFO,
typedef enum {
DECODER_OPTION_DATAFORMAT = 0, /* Set color space of decoding output frame */
DECODER_OPTION_TRUNCATED_MODE, /* Used in decoding bitstream of non integrated frame, only truncated working mode is supported by tune, so skip it */
DECODER_OPTION_END_OF_STREAM, /* Indicate bitstream of the final frame to be decoded */
DECODER_OPTION_VCL_NAL, //feedback whether or not have VCL NAL in current AU for application layer
DECODER_OPTION_TEMPORAL_ID, //feedback temporal id for application layer
DECODER_OPTION_MODE, // indicates the decoding mode
DECODER_OPTION_OUTPUT_PROPERTY,
DECODER_OPTION_FRAME_NUM, //feedback current decoded frame number
DECODER_OPTION_IDR_PIC_ID, // feedback current frame belong to which IDR period
DECODER_OPTION_LTR_MARKING_FLAG, // feedback wether current frame mark a LTR
DECODER_OPTION_LTR_MARKED_FRAME_NUM, // feedback frame num marked by current Frame
DECODER_OPTION_DEVICE_INFO,
} DECODER_OPTION;
typedef enum //feedback that whether or not have VCL NAL in current AU
{
FEEDBACK_NON_VCL_NAL = 0,
FEEDBACK_VCL_NAL,
FEEDBACK_UNKNOWN_NAL
typedef enum { //feedback that whether or not have VCL NAL in current AU
FEEDBACK_NON_VCL_NAL = 0,
FEEDBACK_VCL_NAL,
FEEDBACK_UNKNOWN_NAL
} FEEDBACK_VCL_NAL_IN_AU;
typedef enum //feedback the iTemporalId in current AU if have VCL NAL
{
FEEDBACK_TEMPORAL_ID_0 = 0,
FEEDBACK_TEMPORAL_ID_1,
FEEDBACK_TEMPORAL_ID_2,
FEEDBACK_TEMPORAL_ID_3,
FEEDBACK_TEMPORAL_ID_4,
FEEDBACK_UNKNOWN_TEMPORAL_ID
typedef enum { //feedback the iTemporalId in current AU if have VCL NAL
FEEDBACK_TEMPORAL_ID_0 = 0,
FEEDBACK_TEMPORAL_ID_1,
FEEDBACK_TEMPORAL_ID_2,
FEEDBACK_TEMPORAL_ID_3,
FEEDBACK_TEMPORAL_ID_4,
FEEDBACK_UNKNOWN_TEMPORAL_ID
} FEEDBACK_TEMPORAL_ID;
/* Type of layer being encoded */
typedef enum
{
NON_VIDEO_CODING_LAYER = 0,
VIDEO_CODING_LAYER = 1
typedef enum {
NON_VIDEO_CODING_LAYER = 0,
VIDEO_CODING_LAYER = 1
} LAYER_TYPE;
/* SVC Encoder/Decoder Initializing Parameter Types */
typedef enum
{
INIT_TYPE_PARAMETER_BASED = 0, // For SVC DEMO Application
INIT_TYPE_CONFIG_BASED, // For SVC CONSOLE Application
}INIT_TYPE;
typedef enum {
INIT_TYPE_PARAMETER_BASED = 0, // For SVC DEMO Application
INIT_TYPE_CONFIG_BASED, // For SVC CONSOLE Application
} INIT_TYPE;
//enumerate the type of video bitstream which is provided to decoder
typedef enum
{
VIDEO_BITSTREAM_AVC = 0,
VIDEO_BITSTREAM_SVC = 1,
VIDEO_BITSTREAM_DEFAULT = VIDEO_BITSTREAM_SVC,
}VIDEO_BITSTREAM_TYPE;
typedef enum {
VIDEO_BITSTREAM_AVC = 0,
VIDEO_BITSTREAM_SVC = 1,
VIDEO_BITSTREAM_DEFAULT = VIDEO_BITSTREAM_SVC,
} VIDEO_BITSTREAM_TYPE;
typedef enum
{
NO_RECOVERY_REQUSET = 0,
LTR_RECOVERY_REQUEST = 1,
IDR_RECOVERY_REQUEST = 2,
NO_LTR_MARKING_FEEDBACK =3,
LTR_MARKING_SUCCESS = 4,
LTR_MARKING_FAILED = 5,
}KEY_FRAME_REQUEST_TYPE;
typedef enum {
NO_RECOVERY_REQUSET = 0,
LTR_RECOVERY_REQUEST = 1,
IDR_RECOVERY_REQUEST = 2,
NO_LTR_MARKING_FEEDBACK = 3,
LTR_MARKING_SUCCESS = 4,
LTR_MARKING_FAILED = 5,
} KEY_FRAME_REQUEST_TYPE;
typedef struct
{
unsigned int uiFeedbackType; //IDR request or LTR recovery request
unsigned int uiIDRPicId; // distinguish request from different IDR
int iLastCorrectFrameNum;
int iCurrentFrameNum; //specify current decoder frame_num.
}SLTRRecoverRequest;
typedef struct {
unsigned int uiFeedbackType; //IDR request or LTR recovery request
unsigned int uiIDRPicId; // distinguish request from different IDR
int iLastCorrectFrameNum;
int iCurrentFrameNum; //specify current decoder frame_num.
} SLTRRecoverRequest;
typedef struct
{
unsigned int uiFeedbackType; //mark failed or successful
unsigned int uiIDRPicId; // distinguish request from different IDR
int iLTRFrameNum; //specify current decoder frame_num
}SLTRMarkingFeedback;
typedef struct {
unsigned int uiFeedbackType; //mark failed or successful
unsigned int uiIDRPicId; // distinguish request from different IDR
int iLTRFrameNum; //specify current decoder frame_num
} SLTRMarkingFeedback;
#pragma pack(1)
typedef struct
{
//# 0 SM_SINGLE_SLICE | SliceNum==1
//# 1 SM_FIXEDSLCNUM_SLICE | according to SliceNum | Enabled dynamic slicing for multi-thread
//# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
//# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
//# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
unsigned int uiSliceMode; //by default, uiSliceMode will be 0
struct {
unsigned int uiSliceMbNum[MAX_SLICES_NUM_TMP]; //here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
unsigned int uiSliceNum;
unsigned int uiSliceSizeConstraint;
} sSliceArgument;//not all the elements in this argument will be used, how it will be used depends on uiSliceMode; see below
typedef struct {
//# 0 SM_SINGLE_SLICE | SliceNum==1
//# 1 SM_FIXEDSLCNUM_SLICE | according to SliceNum | Enabled dynamic slicing for multi-thread
//# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
//# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
//# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
unsigned int uiSliceMode; //by default, uiSliceMode will be 0
struct {
unsigned int
uiSliceMbNum[MAX_SLICES_NUM_TMP]; //here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
unsigned int uiSliceNum;
unsigned int uiSliceSizeConstraint;
} sSliceArgument;//not all the elements in this argument will be used, how it will be used depends on uiSliceMode; see below
} SSliceConfig;
typedef struct {
int iVideoWidth; // video size in cx specified for a layer
int iVideoHeight; // video size in cy specified for a layer
float fFrameRate; // frame rate specified for a layer
int iQualityLayerNum; // layer number at quality level
int iSpatialBitrate; // target bitrate for a spatial layer
int iCgsSnrRefined; // 0: SNR layers all MGS; 1: SNR layers all CGS
int iInterSpatialLayerPredFlag; // 0: diabled [independency spatial layer coding]; 1: enabled [base spatial layer dependency coding]
int iVideoWidth; // video size in cx specified for a layer
int iVideoHeight; // video size in cy specified for a layer
float fFrameRate; // frame rate specified for a layer
int iQualityLayerNum; // layer number at quality level
int iSpatialBitrate; // target bitrate for a spatial layer
int iCgsSnrRefined; // 0: SNR layers all MGS; 1: SNR layers all CGS
int iInterSpatialLayerPredFlag; // 0: diabled [independency spatial layer coding]; 1: enabled [base spatial layer dependency coding]
int iQualityBitrate[MAX_QUALITY_LAYER_NUM]; // target bitrate for a quality layer
SSliceConfig sSliceCfg;
int iQualityBitrate[MAX_QUALITY_LAYER_NUM]; // target bitrate for a quality layer
SSliceConfig sSliceCfg;
} SSpatialLayerConfig;
/* SVC Encoding Parameters */
typedef struct {
int iPicWidth; // width of picture in samples
int iPicHeight; // height of picture in samples
int iTargetBitrate; // target bitrate desired
int iTemporalLayerNum; // layer number at temporal level
int iSpatialLayerNum; // layer number at spatial level
int iPicWidth; // width of picture in samples
int iPicHeight; // height of picture in samples
int iTargetBitrate; // target bitrate desired
int iTemporalLayerNum; // layer number at temporal level
int iSpatialLayerNum; // layer number at spatial level
float fFrameRate; // input maximal frame rate
int iInputCsp; // color space of input sequence
int iKeyPicCodingMode;// mode of key picture coding
int iIntraPeriod; // period of Intra frame
bool bEnableSpsPpsIdAddition;
bool bPrefixNalAddingCtrl;
bool bEnableDenoise; // denoise control
bool bEnableBackgroundDetection; // background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
bool bEnableAdaptiveQuant; // adaptive quantization control
bool bEnableCropPic; // enable cropping source picture. 8/25/2010
// FALSE: Streaming Video Sharing; TRUE: Video Conferencing Meeting;
bool bEnableLongTermReference; // 0: on, 1: off
int iLtrMarkPeriod;
float fFrameRate; // input maximal frame rate
int iRCMode; // RC mode
int iTemporalBitrate[MAX_TEMPORAL_LAYER_NUM]; // target bitrate specified for a temporal level
int iPaddingFlag; // 0:disable padding;1:padding
int iInputCsp; // color space of input sequence
int iKeyPicCodingMode;// mode of key picture coding
int iIntraPeriod; // period of Intra frame
bool bEnableSpsPpsIdAddition;
bool bPrefixNalAddingCtrl;
bool bEnableDenoise; // denoise control
bool bEnableBackgroundDetection; // background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
bool bEnableAdaptiveQuant; // adaptive quantization control
bool bEnableCropPic; // enable cropping source picture. 8/25/2010
// FALSE: Streaming Video Sharing; TRUE: Video Conferencing Meeting;
bool bEnableLongTermReference; // 0: on, 1: off
int iLtrMarkPeriod;
int iRCMode; // RC mode
int iTemporalBitrate[MAX_TEMPORAL_LAYER_NUM]; // target bitrate specified for a temporal level
int iPaddingFlag; // 0:disable padding;1:padding
SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
} SVCEncodingParam, *PSVCEncodingParam;
//Define a new struct to show the property of video bitstream.
typedef struct {
unsigned int size; //size of the struct
VIDEO_BITSTREAM_TYPE eVideoBsType;
unsigned int size; //size of the struct
VIDEO_BITSTREAM_TYPE eVideoBsType;
} SVideoProperty;
/* SVC Decoding Parameters, reserved here and potential applicable in the future */
typedef struct TagSVCDecodingParam{
char *pFileNameRestructed; // File name of restructed frame used for PSNR calculation based debug
int iOutputColorFormat; // color space format to be outputed, EVideoFormatType specified in codec_def.h
unsigned int uiCpuLoad; // CPU load
unsigned char uiTargetDqLayer; // Setting target dq layer id
typedef struct TagSVCDecodingParam {
char* pFileNameRestructed; // File name of restructed frame used for PSNR calculation based debug
unsigned char uiEcActiveFlag; // Whether active error concealment feature in decoder
int iOutputColorFormat; // color space format to be outputed, EVideoFormatType specified in codec_def.h
unsigned int uiCpuLoad; // CPU load
unsigned char uiTargetDqLayer; // Setting target dq layer id
SVideoProperty sVideoProperty;
unsigned char uiEcActiveFlag; // Whether active error concealment feature in decoder
SVideoProperty sVideoProperty;
} SDecodingParam, *PDecodingParam;
/* Bitstream inforamtion of a layer being encoded */
typedef struct {
unsigned char uiTemporalId;
unsigned char uiSpatialId;
unsigned char uiQualityId;
unsigned char uiTemporalId;
unsigned char uiSpatialId;
unsigned char uiQualityId;
unsigned char uiPriorityId; //ignore it currently
unsigned char uiPriorityId; //ignore it currently
unsigned char uiLayerType;
unsigned char uiLayerType;
int iNalCount; // Count number of NAL coded already
int iNalLengthInByte[MAX_NAL_UNITS_IN_LAYER]; // Length of NAL size in byte from 0 to iNalCount-1
unsigned char* pBsBuf; // Buffer of bitstream contained
int iNalCount; // Count number of NAL coded already
int iNalLengthInByte[MAX_NAL_UNITS_IN_LAYER]; // Length of NAL size in byte from 0 to iNalCount-1
unsigned char* pBsBuf; // Buffer of bitstream contained
} SLayerBSInfo, *PLayerBSInfo;
typedef struct {
int iTemporalId; // Temporal ID
unsigned char uiFrameType;
int iTemporalId; // Temporal ID
unsigned char uiFrameType;
int iLayerNum;
SLayerBSInfo sLayerInfo[MAX_LAYER_NUM_OF_FRAME];
int iLayerNum;
SLayerBSInfo sLayerInfo[MAX_LAYER_NUM_OF_FRAME];
} SFrameBSInfo, *PFrameBSInfo;
typedef struct Source_Picture_s {
int iColorFormat; // color space type
int iStride[4]; // stride for each plane pData
unsigned char *pData[4]; // plane pData
int iPicWidth; // luma picture width in x coordinate
int iPicHeight; // luma picture height in y coordinate
typedef struct Source_Picture_s {
int iColorFormat; // color space type
int iStride[4]; // stride for each plane pData
unsigned char* pData[4]; // plane pData
int iPicWidth; // luma picture width in x coordinate
int iPicHeight; // luma picture height in y coordinate
} SSourcePicture;

View File

@ -37,75 +37,70 @@
#pragma once
#endif//WIN32
typedef enum
{
/*rgb color formats*/
videoFormatRGB = 1,
videoFormatRGBA = 2,
videoFormatRGB555 = 3,
videoFormatRGB565 = 4,
videoFormatBGR = 5,
videoFormatBGRA = 6,
videoFormatABGR = 7,
videoFormatARGB = 8,
typedef enum {
/*rgb color formats*/
videoFormatRGB = 1,
videoFormatRGBA = 2,
videoFormatRGB555 = 3,
videoFormatRGB565 = 4,
videoFormatBGR = 5,
videoFormatBGRA = 6,
videoFormatABGR = 7,
videoFormatARGB = 8,
/*yuv color formats*/
videoFormatYUY2 = 20,
videoFormatYVYU = 21,
videoFormatUYVY = 22,
videoFormatI420 = 23, //same as IYUV
videoFormatYV12 = 24,
videoFormatInternal = 25, // Only Used for SVC decoder testbed
videoFormatNV12 = 26, // new format for output by DXVA decoding
videoFormatVFlip = 0x80000000
}EVideoFormatType;
/*yuv color formats*/
videoFormatYUY2 = 20,
videoFormatYVYU = 21,
videoFormatUYVY = 22,
videoFormatI420 = 23, //same as IYUV
videoFormatYV12 = 24,
videoFormatInternal = 25, // Only Used for SVC decoder testbed
typedef enum
{
videoFrameTypeInvalid, /* Encoder not ready or parameters are invalidate */
videoFrameTypeIDR, /* This type is only available for H264 if this frame is key frame, then return this type */
videoFrameTypeI, /* I frame type */
videoFrameTypeP, /* P frame type */
videoFrameTypeSkip, /* Skip the frame based encoder kernel */
videoFrameTypeIPMixed, /* Frame type introduced I and P slices are mixing */
}EVideoFrameType;
videoFormatNV12 = 26, // new format for output by DXVA decoding
typedef enum
{
cmResultSuccess,
cmInitParaError, /*Parameters are invalid */
cmMachPerfIsBad, /*The performance of machine is not enough to support
H264 CODEC, in this case, suggestion user use h263
videoFormatVFlip = 0x80000000
} EVideoFormatType;
typedef enum {
videoFrameTypeInvalid, /* Encoder not ready or parameters are invalidate */
videoFrameTypeIDR, /* This type is only available for H264 if this frame is key frame, then return this type */
videoFrameTypeI, /* I frame type */
videoFrameTypeP, /* P frame type */
videoFrameTypeSkip, /* Skip the frame based encoder kernel */
videoFrameTypeIPMixed, /* Frame type introduced I and P slices are mixing */
} EVideoFrameType;
typedef enum {
cmResultSuccess,
cmInitParaError, /*Parameters are invalid */
cmMachPerfIsBad, /*The performance of machine is not enough to support
H264 CODEC, in this case, suggestion user use h263
or set fps to low like 5fps or more low*/
cmUnkonwReason,
cmMallocMemeError, /*Malloc a memory error*/
cmInitExpected, /*Initial action is expected*/
}CM_RETURN;
cmUnkonwReason,
cmMallocMemeError, /*Malloc a memory error*/
cmInitExpected, /*Initial action is expected*/
} CM_RETURN;
/* nal unit type */
enum ENalUnitType
{
NAL_UNKNOWN = 0,
NAL_SLICE = 1,
NAL_SLICE_DPA = 2,
NAL_SLICE_DPB = 3,
NAL_SLICE_DPC = 4,
NAL_SLICE_IDR = 5, /* ref_idc != 0 */
NAL_SEI = 6, /* ref_idc == 0 */
NAL_SPS = 7,
NAL_PPS = 8
/* ref_idc == 0 for 6,9,10,11,12 */
enum ENalUnitType {
NAL_UNKNOWN = 0,
NAL_SLICE = 1,
NAL_SLICE_DPA = 2,
NAL_SLICE_DPB = 3,
NAL_SLICE_DPC = 4,
NAL_SLICE_IDR = 5, /* ref_idc != 0 */
NAL_SEI = 6, /* ref_idc == 0 */
NAL_SPS = 7,
NAL_PPS = 8
/* ref_idc == 0 for 6,9,10,11,12 */
};
/* NRI: eNalRefIdc */
enum ENalPriority
{
NAL_PRIORITY_DISPOSABLE = 0,
NAL_PRIORITY_LOW = 1,
NAL_PRIORITY_HIGH = 2,
NAL_PRIORITY_HIGHEST = 3,
enum ENalPriority {
NAL_PRIORITY_DISPOSABLE = 0,
NAL_PRIORITY_LOW = 1,
NAL_PRIORITY_HIGH = 2,
NAL_PRIORITY_HIGHEST = 3,
};
#define IS_PARAMETER_SET_NAL(eNalRefIdc, eNalType) \
@ -121,31 +116,31 @@ enum ENalPriority
/* Error Tools definition */
typedef unsigned short ERR_TOOL;
enum{
ET_NONE = 0x00, // NONE Error Tools
ET_IP_SCALE = 0x01, // IP Scalable
ET_FMO = 0x02, // Flexible Macroblock Ordering
ET_IR_R1 = 0x04, // Intra Refresh in predifined 2% MB
ET_IR_R2 = 0x08, // Intra Refresh in predifined 5% MB
ET_IR_R3 = 0x10, // Intra Refresh in predifined 10% MB
ET_FEC_HALF = 0x20, // Forward Error Correction in 50% redundency mode
ET_FEC_FULL = 0x40, // Forward Error Correction in 100% redundency mode
ET_RFS = 0x80, // Reference Frame Selection
enum {
ET_NONE = 0x00, // NONE Error Tools
ET_IP_SCALE = 0x01, // IP Scalable
ET_FMO = 0x02, // Flexible Macroblock Ordering
ET_IR_R1 = 0x04, // Intra Refresh in predifined 2% MB
ET_IR_R2 = 0x08, // Intra Refresh in predifined 5% MB
ET_IR_R3 = 0x10, // Intra Refresh in predifined 10% MB
ET_FEC_HALF = 0x20, // Forward Error Correction in 50% redundency mode
ET_FEC_FULL = 0x40, // Forward Error Correction in 100% redundency mode
ET_RFS = 0x80, // Reference Frame Selection
};
/* information of coded Slice(=NAL)(s) */
typedef struct SliceInformation
{
unsigned char* pBufferOfSlices; // base buffer of coded slice(s)
int iCodedSliceCount; // number of coded slices
unsigned int* pLengthOfSlices; // array of slices length accordingly by number of slice
int iFecType; // FEC type[0, 50%FEC, 100%FEC]
unsigned char uiSliceIdx; // index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0]
unsigned char uiSliceCount; // count number of slice in frame [FMO: 2-8; No FMO: 1]
char iFrameIndex; // index of frame[-1, .., idr_interval-1]
unsigned char uiNalRefIdc; // NRI, priority level of slice(NAL)
unsigned char uiNalType; // NAL type
unsigned char uiContainingFinalNal; // whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
typedef struct SliceInformation {
unsigned char* pBufferOfSlices; // base buffer of coded slice(s)
int iCodedSliceCount; // number of coded slices
unsigned int* pLengthOfSlices; // array of slices length accordingly by number of slice
int iFecType; // FEC type[0, 50%FEC, 100%FEC]
unsigned char uiSliceIdx; // index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0]
unsigned char uiSliceCount; // count number of slice in frame [FMO: 2-8; No FMO: 1]
char iFrameIndex; // index of frame[-1, .., idr_interval-1]
unsigned char uiNalRefIdc; // NRI, priority level of slice(NAL)
unsigned char uiNalType; // NAL type
unsigned char
uiContainingFinalNal; // whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
} SliceInfo, *PSliceInfo;
@ -161,90 +156,84 @@ typedef struct SliceInformation
/* thresholds of the initial, maximal and minimal rate */
typedef struct {
int iWidth; // frame width
int iHeight; // frame height
int iThresholdOfInitRate; // threshold of initial rate
int iThresholdOfMaxRate; // threshold of maximal rate
int iThresholdOfMinRate; // threshold of minimal rate
int iMinThresholdFrameRate; //min frame rate min
int iSkipFrameRate; //skip to frame rate min
int iSkipFrameStep; //how many frames to skip
}SRateThresholds, *PRateThresholds;
int iWidth; // frame width
int iHeight; // frame height
int iThresholdOfInitRate; // threshold of initial rate
int iThresholdOfMaxRate; // threshold of maximal rate
int iThresholdOfMinRate; // threshold of minimal rate
int iMinThresholdFrameRate; //min frame rate min
int iSkipFrameRate; //skip to frame rate min
int iSkipFrameStep; //how many frames to skip
} SRateThresholds, *PRateThresholds;
/*new interface*/
typedef struct WelsDeviceInfo
{
int bSupport; /* a logic flag provided by decoder which indicates whether GPU decoder can work based on the following device info. */
char Vendor[128]; // vendor name
char Device[128]; // device name
char Driver[128]; // driver version
char DriverDate[128]; // driver release date
typedef struct WelsDeviceInfo {
int bSupport; /* a logic flag provided by decoder which indicates whether GPU decoder can work based on the following device info. */
char Vendor[128]; // vendor name
char Device[128]; // device name
char Driver[128]; // driver version
char DriverDate[128]; // driver release date
} Device_Info;
typedef enum TagBufferProperty
{
BUFFER_HOST = 0, // host memory
BUFFER_DEVICE = 1, // device memory including surface and shared handle
// for DXVA: shared handle
// for VDA : iosurface
//SURFACE_DEVICE , // surface
//SHARED_HANDLE // shared handle
}EBufferProperty;
typedef enum TagBufferProperty {
BUFFER_HOST = 0, // host memory
BUFFER_DEVICE = 1, // device memory including surface and shared handle
// for DXVA: shared handle
// for VDA : iosurface
typedef enum TagDecodeMode
{
AUTO_MODE = 0, // decided by decoder itself, dynamic mode switch, delayed switch
SW_MODE = 1, // decoded by CPU, instant switch
GPU_MODE = 2, // decoded by GPU, instant switch
SWITCH_MODE =3 // switch to the other mode, forced mode switch, delayed switch
}EDecodeMode;
//SURFACE_DEVICE , // surface
//SHARED_HANDLE // shared handle
} EBufferProperty;
typedef struct TagSysMemBuffer
{
int iWidth; //width of decoded pic for display
int iHeight; //height of decoded pic for display
int iFormat; // type is "EVideoFormatType"
int iStride[2]; //stride of 2 component
}SSysMEMBuffer;
typedef enum TagDecodeMode {
AUTO_MODE = 0, // decided by decoder itself, dynamic mode switch, delayed switch
SW_MODE = 1, // decoded by CPU, instant switch
GPU_MODE = 2, // decoded by GPU, instant switch
SWITCH_MODE = 3 // switch to the other mode, forced mode switch, delayed switch
} EDecodeMode;
typedef struct TagVideoMemBuffer
{
int iSurfaceWidth; // used for surface create
int iSurfaceHeight;
int D3Dformat; //type is "D3DFORMAT"
int D3DPool; // type is "D3DPOOL";
int iLeftTopX;
int iLeftTopY;
int iRightBottomX;
int iRightBottomY;
}SVideoMemBuffer;
typedef struct TagSysMemBuffer {
int iWidth; //width of decoded pic for display
int iHeight; //height of decoded pic for display
int iFormat; // type is "EVideoFormatType"
int iStride[2]; //stride of 2 component
} SSysMEMBuffer;
typedef struct TagBufferInfo
{
EBufferProperty eBufferProperty; //0: host memory; 1: device memory;
int iBufferStatus; // 0: one frame data is not ready; 1: one frame data is ready
EDecodeMode eWorkMode; //indicate what the real working mode in decoder
union {
SSysMEMBuffer sSystemBuffer;
SVideoMemBuffer sVideoBuffer;
}UsrData;
}SBufferInfo;
typedef struct TagVideoMemBuffer {
int iSurfaceWidth; // used for surface create
int iSurfaceHeight;
int D3Dformat; //type is "D3DFORMAT"
int D3DPool; // type is "D3DPOOL";
int iLeftTopX;
int iLeftTopY;
int iRightBottomX;
int iRightBottomY;
} SVideoMemBuffer;
typedef struct TagBufferInfo {
EBufferProperty eBufferProperty; //0: host memory; 1: device memory;
int iBufferStatus; // 0: one frame data is not ready; 1: one frame data is ready
EDecodeMode eWorkMode; //indicate what the real working mode in decoder
union {
SSysMEMBuffer sSystemBuffer;
SVideoMemBuffer sVideoBuffer;
} UsrData;
} SBufferInfo;
/* Constants related to transmission rate at various resolutions */
static const SRateThresholds ksRateThrMap[4] = {
// initial-maximal-minimal
{CIF_WIDTH, CIF_HEIGHT, 225000, 384000, 96000, 3, 1, 1}, // CIF
{QVGA_WIDTH, QVGA_HEIGHT, 192000, 320000, 80000, -1, -1, -1}, // QVGA
{QCIF_WIDTH, QCIF_HEIGHT, 150000, 256000, 64000, 8, 4, 2}, // QCIF
{SQCIF_WIDTH, SQCIF_HEIGHT, 120000, 192000, 48000, 5, 3, 1} // SQCIF
// initial-maximal-minimal
{CIF_WIDTH, CIF_HEIGHT, 225000, 384000, 96000, 3, 1, 1}, // CIF
{QVGA_WIDTH, QVGA_HEIGHT, 192000, 320000, 80000, -1, -1, -1}, // QVGA
{QCIF_WIDTH, QCIF_HEIGHT, 150000, 256000, 64000, 8, 4, 2}, // QCIF
{SQCIF_WIDTH, SQCIF_HEIGHT, 120000, 192000, 48000, 5, 3, 1} // SQCIF
};
// In a GOP, multiple of the key frame number, derived from
// In a GOP, multiple of the key frame number, derived from
// the number of layers(index or array below)
static const char kiKeyNumMultiple[] = {
1, 1, 2, 4, 8, 16,
1, 1, 2, 4, 8, 16,
};
#pragma pack()

View File

@ -37,13 +37,13 @@
static int32_t g_TraceLevel = 0;
void WelsStderrSetTraceLevel(int32_t level) {
void WelsStderrSetTraceLevel (int32_t level) {
g_TraceLevel = level;
}
int32_t welsStderrLevelTrace(int32_t level, const str_t* format, va_list ap) {
int32_t welsStderrLevelTrace (int32_t level, const str_t* format, va_list ap) {
if (level < g_TraceLevel) {
vfprintf(stderr, format, ap);
vfprintf (stderr, format, ap);
}
return 0;
}

View File

@ -36,24 +36,24 @@
#define WELS_LOGGING_H__
// API surface.
void WelsStderrSetTraceLevel(int32_t level);
void WelsStderrSetTraceLevel (int32_t level);
// Internal details.
int32_t welsStderrLevelTrace(int32_t level, const str_t* format, va_list ap);
int32_t welsStderrLevelTrace (int32_t level, const str_t* format, va_list ap);
template<int level> int32_t welsStderrTrace(
template<int level> int32_t welsStderrTrace (
#ifndef WIN32
const str_t *dllname,
const str_t* dllname,
#endif
const str_t* format, ...) {
#ifndef WIN32
(void)dllname; // Unused.
#endif
va_list ap;
va_start(ap, format);
welsStderrLevelTrace(level, format, ap);
va_end(ap);
va_start (ap, format);
welsStderrLevelTrace (level, format, ap);
va_end (ap);
return 0;
}

View File

@ -1,143 +1,139 @@
/*!
* \copy
* Copyright (c) 2010-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \file d3d9_utils.h
*
* \brief interface of d3d9 render module
*
* \date Created 12/14/2010
*
* \description : 1. Rendering in Vista and upper : D3D9Ex method, support host memory / shared surface input
* 2. Rendering in XP : D3D9 method w/o device lost handling, support host memory input
* 3. File Dump : support host memory / shared surface input
*
*************************************************************************************
*/
#ifndef WELS_D3D9_UTILS_H__
#define WELS_D3D9_UTILS_H__
//#pragma once // do not use this due cross platform, esp for Solaris
#include <stdio.h>
#include "codec_def.h"
#if defined(_MSC_VER) && (_MSC_VER>=1500) // vs2008 and upper
#define ENABLE_DISPLAY_MODULE // enable/disable the render feature
#endif
#ifdef ENABLE_DISPLAY_MODULE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <d3d9.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CD3D9Utils
{
public:
CD3D9Utils();
~CD3D9Utils();
public:
HRESULT Init(BOOL bWindowed);
HRESULT Uninit(void);
HRESULT Process(void *pDst[3], SBufferInfo *Info, FILE *pFile = NULL);
private:
HRESULT InitResource(void *pSharedHandle, SBufferInfo *pInfo);
HRESULT Render(void *pDst[3], SBufferInfo *pInfo);
HRESULT Dump(void *pDst[3], SBufferInfo *pInfo, FILE *pFile);
private:
HMODULE m_hDll;
HWND m_hWnd;
unsigned char *m_pDumpYUV;
BOOL m_bInitDone;
LPDIRECT3D9 m_lpD3D9;
LPDIRECT3DDEVICE9 m_lpD3D9Device;
D3DPRESENT_PARAMETERS m_d3dpp;
LPDIRECT3DSURFACE9 m_lpD3D9RawSurfaceShare;
};
class CD3D9ExUtils
{
public:
CD3D9ExUtils();
~CD3D9ExUtils();
public:
HRESULT Init(BOOL bWindowed);
HRESULT Uninit(void);
HRESULT Process(void *dst[3], SBufferInfo *Info, FILE *fp = NULL);
private:
HRESULT InitResource(void *pSharedHandle, SBufferInfo *Info);
HRESULT Render(void *pDst[3], SBufferInfo *Info);
HRESULT Dump(void *pDst[3], SBufferInfo *Info, FILE *fp);
private:
HMODULE m_hDll;
HWND m_hWnd;
unsigned char *m_pDumpYUV;
BOOL m_bInitDone;
LPDIRECT3D9EX m_lpD3D9;
LPDIRECT3DDEVICE9EX m_lpD3D9Device;
D3DPRESENT_PARAMETERS m_d3dpp;
LPDIRECT3DSURFACE9 m_lpD3D9RawSurfaceShare;
};
#endif
typedef enum
{
OS_UNSUPPORTED = 0,
OS_XP,
OS_VISTA_UPPER
};
class CUtils
{
public:
CUtils();
~CUtils();
int Process(void *dst[3], SBufferInfo *Info, FILE *fp);
private:
int CheckOS(void);
private:
int iOSType;
void *hHandle;
};
#endif//WELS_D3D9_UTILS_H__
/*!
* \copy
* Copyright (c) 2010-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \file d3d9_utils.h
*
* \brief interface of d3d9 render module
*
* \date Created 12/14/2010
*
* \description : 1. Rendering in Vista and upper : D3D9Ex method, support host memory / shared surface input
* 2. Rendering in XP : D3D9 method w/o device lost handling, support host memory input
* 3. File Dump : support host memory / shared surface input
*
*************************************************************************************
*/
#ifndef WELS_D3D9_UTILS_H__
#define WELS_D3D9_UTILS_H__
//#pragma once // do not use this due cross platform, esp for Solaris
#include <stdio.h>
#include "codec_def.h"
#if defined(_MSC_VER) && (_MSC_VER>=1500) // vs2008 and upper
#define ENABLE_DISPLAY_MODULE // enable/disable the render feature
#endif
#ifdef ENABLE_DISPLAY_MODULE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <d3d9.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CD3D9Utils {
public:
CD3D9Utils();
~CD3D9Utils();
public:
HRESULT Init (BOOL bWindowed);
HRESULT Uninit (void);
HRESULT Process (void* pDst[3], SBufferInfo* Info, FILE* pFile = NULL);
private:
HRESULT InitResource (void* pSharedHandle, SBufferInfo* pInfo);
HRESULT Render (void* pDst[3], SBufferInfo* pInfo);
HRESULT Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFile);
private:
HMODULE m_hDll;
HWND m_hWnd;
unsigned char* m_pDumpYUV;
BOOL m_bInitDone;
LPDIRECT3D9 m_lpD3D9;
LPDIRECT3DDEVICE9 m_lpD3D9Device;
D3DPRESENT_PARAMETERS m_d3dpp;
LPDIRECT3DSURFACE9 m_lpD3D9RawSurfaceShare;
};
class CD3D9ExUtils {
public:
CD3D9ExUtils();
~CD3D9ExUtils();
public:
HRESULT Init (BOOL bWindowed);
HRESULT Uninit (void);
HRESULT Process (void* dst[3], SBufferInfo* Info, FILE* fp = NULL);
private:
HRESULT InitResource (void* pSharedHandle, SBufferInfo* Info);
HRESULT Render (void* pDst[3], SBufferInfo* Info);
HRESULT Dump (void* pDst[3], SBufferInfo* Info, FILE* fp);
private:
HMODULE m_hDll;
HWND m_hWnd;
unsigned char* m_pDumpYUV;
BOOL m_bInitDone;
LPDIRECT3D9EX m_lpD3D9;
LPDIRECT3DDEVICE9EX m_lpD3D9Device;
D3DPRESENT_PARAMETERS m_d3dpp;
LPDIRECT3DSURFACE9 m_lpD3D9RawSurfaceShare;
};
#endif
typedef enum {
OS_UNSUPPORTED = 0,
OS_XP,
OS_VISTA_UPPER
};
class CUtils {
public:
CUtils();
~CUtils();
int Process (void* dst[3], SBufferInfo* Info, FILE* fp);
private:
int CheckOS (void);
private:
int iOSType;
void* hHandle;
};
#endif//WELS_D3D9_UTILS_H__

View File

@ -46,8 +46,8 @@
bool load_bundle_welsdec();
void free_bundle_welsdec();
bool get_functions_address_free_decoder(ISVCDecoder* pDecoder);
bool get_functions_address_create_decoder(ISVCDecoder** ppDecoder);
bool get_functions_address_free_decoder (ISVCDecoder* pDecoder);
bool get_functions_address_create_decoder (ISVCDecoder** ppDecoder);

View File

@ -44,22 +44,21 @@
#include <string>
using namespace std;
class CReadConfig
{
public:
CReadConfig( const char *kpConfigFileName );
virtual ~CReadConfig();
long ReadLine( string* val, const int kiValSize = 4 );
const bool EndOfFile();
const int GetLines();
const bool ExistFile();
const string& GetFileName();
private:
FILE *m_pCfgFile;
string m_strCfgFileName;
unsigned long m_ulLines;
class CReadConfig {
public:
CReadConfig (const char* kpConfigFileName);
virtual ~CReadConfig();
long ReadLine (string* val, const int kiValSize = 4);
const bool EndOfFile();
const int GetLines();
const bool ExistFile();
const string& GetFileName();
private:
FILE* m_pCfgFile;
string m_strCfgFileName;
unsigned long m_ulLines;
};
#endif // READ_CONFIG_H__

File diff suppressed because it is too large Load Diff

View File

@ -50,8 +50,8 @@
#include "d3d9_utils.h"
#include "logging.h"
typedef long (*PCreateDecoderFunc) (ISVCDecoder** ppDecoder);
typedef void_t (*PDestroyDecoderFunc)(ISVCDecoder* pDecoder);
typedef long (*PCreateDecoderFunc) (ISVCDecoder** ppDecoder);
typedef void_t (*PDestroyDecoderFunc) (ISVCDecoder* pDecoder);
using namespace std;
@ -60,485 +60,438 @@ using namespace std;
//#define STICK_STREAM_SIZE // For Demo interfaces test with track file of integrated frames
void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName, int32_t& iWidth, int32_t& iHeight, void_t* pOptionFileName )
{
FILE *pH264File = NULL;
FILE *pYuvFile = NULL;
FILE *pOptionFile = NULL;
int64_t iStart = 0, iEnd = 0, iTotal = 0;
int32_t iSliceSize;
int32_t iSliceIndex = 0;
uint8_t* pBuf = NULL;
uint8_t uiStartCode[4] = {0, 0, 0, 1};
void_t H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName,
int32_t& iWidth, int32_t& iHeight, void_t* pOptionFileName) {
FILE* pH264File = NULL;
FILE* pYuvFile = NULL;
FILE* pOptionFile = NULL;
int64_t iStart = 0, iEnd = 0, iTotal = 0;
int32_t iSliceSize;
int32_t iSliceIndex = 0;
uint8_t* pBuf = NULL;
uint8_t uiStartCode[4] = {0, 0, 0, 1};
void_t *pData[3] = {NULL};
uint8_t *pDst[3] = {NULL};
SBufferInfo sDstBufInfo;
void_t* pData[3] = {NULL};
uint8_t* pDst[3] = {NULL};
SBufferInfo sDstBufInfo;
int32_t iBufPos = 0;
int32_t iFileSize;
int32_t i = 0;
int32_t iLastWidth = 0, iLastHeight = 0;
int32_t iFrameCount = 0;
int32_t iEndOfStreamFlag = 0;
int32_t iColorFormat = videoFormatInternal;
static int32_t iFrameNum = 0;
int32_t iBufPos = 0;
int32_t iFileSize;
int32_t i = 0;
int32_t iLastWidth = 0, iLastHeight = 0;
int32_t iFrameCount = 0;
int32_t iEndOfStreamFlag = 0;
int32_t iColorFormat = videoFormatInternal;
static int32_t iFrameNum = 0;
EDecodeMode eDecoderMode = AUTO_MODE;
EBufferProperty eOutputProperty = BUFFER_DEVICE;
CUtils cOutputModule;
double dElapsed = 0;
EDecodeMode eDecoderMode = AUTO_MODE;
EBufferProperty eOutputProperty = BUFFER_DEVICE;
if (pDecoder == NULL) return;
if (kpH264FileName)
{
pH264File = fopen(kpH264FileName,"rb");
if (pH264File == NULL){
fprintf(stderr, "Can not open h264 source file, check its legal path related please..\n");
return;
}
fprintf(stderr, "H264 source file name: %s..\n",kpH264FileName);
}
else
{
fprintf(stderr, "Can not find any h264 bitstream file to read..\n");
fprintf(stderr, "----------------decoder return------------------------\n" );
return;
}
CUtils cOutputModule;
double dElapsed = 0;
if (kpOuputFileName){
pYuvFile = fopen(kpOuputFileName, "wb");
if (pYuvFile == NULL){
fprintf(stderr, "Can not open yuv file to output result of decoding..\n");
// any options
//return; // can let decoder work in quiet mode, no writing any output
}
else
fprintf(stderr, "Sequence output file name: %s..\n", kpOuputFileName);
}
else{
fprintf(stderr, "Can not find any output file to write..\n");
// any options
}
if (pOptionFileName){
pOptionFile = fopen((char*)pOptionFileName, "wb");
if ( pOptionFile == NULL ){
fprintf(stderr, "Can not open optional file for write..\n");
}
else
fprintf(stderr, "Extra optional file: %s..\n", (char*)pOptionFileName);
}
if (pDecoder == NULL) return;
if (kpH264FileName) {
pH264File = fopen (kpH264FileName, "rb");
if (pH264File == NULL) {
fprintf (stderr, "Can not open h264 source file, check its legal path related please..\n");
return;
}
fprintf (stderr, "H264 source file name: %s..\n", kpH264FileName);
} else {
fprintf (stderr, "Can not find any h264 bitstream file to read..\n");
fprintf (stderr, "----------------decoder return------------------------\n");
return;
}
printf( "------------------------------------------------------\n" );
if (kpOuputFileName) {
pYuvFile = fopen (kpOuputFileName, "wb");
if (pYuvFile == NULL) {
fprintf (stderr, "Can not open yuv file to output result of decoding..\n");
// any options
//return; // can let decoder work in quiet mode, no writing any output
} else
fprintf (stderr, "Sequence output file name: %s..\n", kpOuputFileName);
} else {
fprintf (stderr, "Can not find any output file to write..\n");
// any options
}
fseek(pH264File, 0L, SEEK_END);
iFileSize = ftell(pH264File);
if (iFileSize<=0) {
fprintf(stderr, "Current Bit Stream File is too small, read error!!!!\n");
goto label_exit;
}
fseek(pH264File, 0L, SEEK_SET);
if (pOptionFileName) {
pOptionFile = fopen ((char*)pOptionFileName, "wb");
if (pOptionFile == NULL) {
fprintf (stderr, "Can not open optional file for write..\n");
} else
fprintf (stderr, "Extra optional file: %s..\n", (char*)pOptionFileName);
}
pBuf = new uint8_t[iFileSize+4];
if (pBuf == NULL){
fprintf(stderr, "new buffer failed!\n");
goto label_exit;
}
printf ("------------------------------------------------------\n");
fread(pBuf, 1, iFileSize, pH264File);
memcpy(pBuf+iFileSize, &uiStartCode[0], 4);//confirmed_safe_unsafe_usage
fseek (pH264File, 0L, SEEK_END);
iFileSize = ftell (pH264File);
if (iFileSize <= 0) {
fprintf (stderr, "Current Bit Stream File is too small, read error!!!!\n");
goto label_exit;
}
fseek (pH264File, 0L, SEEK_SET);
if( pDecoder->SetOption( DECODER_OPTION_DATAFORMAT, &iColorFormat ) ){
fprintf(stderr, "SetOption() failed, opt_id : %d ..\n", DECODER_OPTION_DATAFORMAT);
goto label_exit;
}
pBuf = new uint8_t[iFileSize + 4];
if (pBuf == NULL) {
fprintf (stderr, "new buffer failed!\n");
goto label_exit;
}
if( pDecoder->SetOption( DECODER_OPTION_MODE, &eDecoderMode ) ){
fprintf(stderr, "SetOption() failed, opt_id : %d ..\n", DECODER_OPTION_MODE);
goto label_exit;
}
fread (pBuf, 1, iFileSize, pH264File);
memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage
// set the output buffer property
if(pYuvFile)
{
pDecoder->SetOption( DECODER_OPTION_OUTPUT_PROPERTY, &eOutputProperty );
}
if (pDecoder->SetOption (DECODER_OPTION_DATAFORMAT, &iColorFormat)) {
fprintf (stderr, "SetOption() failed, opt_id : %d ..\n", DECODER_OPTION_DATAFORMAT);
goto label_exit;
}
if (pDecoder->SetOption (DECODER_OPTION_MODE, &eDecoderMode)) {
fprintf (stderr, "SetOption() failed, opt_id : %d ..\n", DECODER_OPTION_MODE);
goto label_exit;
}
// set the output buffer property
if (pYuvFile) {
pDecoder->SetOption (DECODER_OPTION_OUTPUT_PROPERTY, &eOutputProperty);
}
#if defined ( STICK_STREAM_SIZE )
FILE *fpTrack = fopen("3.len", "rb");
FILE* fpTrack = fopen ("3.len", "rb");
#endif// STICK_STREAM_SIZE
while ( true ) {
if ( iBufPos >= iFileSize ){
iEndOfStreamFlag = true;
if ( iEndOfStreamFlag )
pDecoder->SetOption( DECODER_OPTION_END_OF_STREAM, (void_t*)&iEndOfStreamFlag );
break;
}
while (true) {
if (iBufPos >= iFileSize) {
iEndOfStreamFlag = true;
if (iEndOfStreamFlag)
pDecoder->SetOption (DECODER_OPTION_END_OF_STREAM, (void_t*)&iEndOfStreamFlag);
break;
}
#if defined ( STICK_STREAM_SIZE )
if ( fpTrack )
fread(&iSliceSize, 1, sizeof(int32_t), fpTrack);
if (fpTrack)
fread (&iSliceSize, 1, sizeof (int32_t), fpTrack);
#else
for (i=0; i<iFileSize; i++) {
if (pBuf[iBufPos+i]==0 && pBuf[iBufPos+i+1]==0 && pBuf[iBufPos+i+2]==0 &&
pBuf[iBufPos+i+3]==1 && i>0) {
break;
}
}
iSliceSize = i;
for (i = 0; i < iFileSize; i++) {
if (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 &&
pBuf[iBufPos + i + 3] == 1 && i > 0) {
break;
}
}
iSliceSize = i;
#endif
//for coverage test purpose
int32_t iOutputColorFormat;
pDecoder->GetOption(DECODER_OPTION_DATAFORMAT, &iOutputColorFormat);
int32_t iEndOfStreamFlag;
pDecoder->GetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
int32_t iCurIdrPicId;
pDecoder->GetOption(DECODER_OPTION_IDR_PIC_ID, &iCurIdrPicId);
int32_t iFrameNum;
pDecoder->GetOption(DECODER_OPTION_FRAME_NUM, &iFrameNum);
int32_t bCurAuContainLtrMarkSeFlag;
pDecoder->GetOption(DECODER_OPTION_LTR_MARKING_FLAG, &bCurAuContainLtrMarkSeFlag);
int32_t iFrameNumOfAuMarkedLtr;
pDecoder->GetOption(DECODER_OPTION_LTR_MARKED_FRAME_NUM, &iFrameNumOfAuMarkedLtr);
int32_t iFeedbackVclNalInAu;
pDecoder->GetOption(DECODER_OPTION_VCL_NAL, &iFeedbackVclNalInAu);
int32_t iFeedbackTidInAu;
pDecoder->GetOption(DECODER_OPTION_TEMPORAL_ID, &iFeedbackTidInAu);
int32_t iSetMode;
pDecoder->GetOption(DECODER_OPTION_MODE, &iSetMode);
int32_t iDeviceInfo;
pDecoder->GetOption(DECODER_OPTION_DEVICE_INFO, &iDeviceInfo);
int32_t iOutputColorFormat;
pDecoder->GetOption (DECODER_OPTION_DATAFORMAT, &iOutputColorFormat);
int32_t iEndOfStreamFlag;
pDecoder->GetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
int32_t iCurIdrPicId;
pDecoder->GetOption (DECODER_OPTION_IDR_PIC_ID, &iCurIdrPicId);
int32_t iFrameNum;
pDecoder->GetOption (DECODER_OPTION_FRAME_NUM, &iFrameNum);
int32_t bCurAuContainLtrMarkSeFlag;
pDecoder->GetOption (DECODER_OPTION_LTR_MARKING_FLAG, &bCurAuContainLtrMarkSeFlag);
int32_t iFrameNumOfAuMarkedLtr;
pDecoder->GetOption (DECODER_OPTION_LTR_MARKED_FRAME_NUM, &iFrameNumOfAuMarkedLtr);
int32_t iFeedbackVclNalInAu;
pDecoder->GetOption (DECODER_OPTION_VCL_NAL, &iFeedbackVclNalInAu);
int32_t iFeedbackTidInAu;
pDecoder->GetOption (DECODER_OPTION_TEMPORAL_ID, &iFeedbackTidInAu);
int32_t iSetMode;
pDecoder->GetOption (DECODER_OPTION_MODE, &iSetMode);
int32_t iDeviceInfo;
pDecoder->GetOption (DECODER_OPTION_DEVICE_INFO, &iDeviceInfo);
//~end for
iStart = WelsTime();
pData[0] = NULL;
pData[1] = NULL;
pData[2] = NULL;
memset(&sDstBufInfo, 0, sizeof(SBufferInfo));
iStart = WelsTime();
pData[0] = NULL;
pData[1] = NULL;
pData[2] = NULL;
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
pDecoder->DecodeFrame( pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo );
if(sDstBufInfo.iBufferStatus == 1)
{
pDst[0] = (uint8_t *)pData[0];
pDst[1] = (uint8_t *)pData[1];
pDst[2] = (uint8_t *)pData[2];
}
iEnd = WelsTime();
iTotal += iEnd - iStart;
if ( (sDstBufInfo.iBufferStatus==1) )
{
iFrameNum++;
cOutputModule.Process((void_t **)pDst, &sDstBufInfo, pYuvFile);
if (sDstBufInfo.eBufferProperty == BUFFER_HOST)
{
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
}
else
{
iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
}
if ( pOptionFile != NULL )
{
if ( iWidth != iLastWidth && iHeight != iLastHeight )
{
fwrite(&iFrameCount, sizeof(iFrameCount), 1, pOptionFile);
fwrite(&iWidth , sizeof(iWidth) , 1, pOptionFile);
fwrite(&iHeight, sizeof(iHeight), 1, pOptionFile);
iLastWidth = iWidth;
iLastHeight = iHeight;
}
}
++ iFrameCount;
}
pDecoder->DecodeFrame (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo);
iBufPos += iSliceSize;
++ iSliceIndex;
}
if (sDstBufInfo.iBufferStatus == 1) {
pDst[0] = (uint8_t*)pData[0];
pDst[1] = (uint8_t*)pData[1];
pDst[2] = (uint8_t*)pData[2];
}
iEnd = WelsTime();
iTotal += iEnd - iStart;
if ((sDstBufInfo.iBufferStatus == 1)) {
iFrameNum++;
cOutputModule.Process ((void_t**)pDst, &sDstBufInfo, pYuvFile);
if (sDstBufInfo.eBufferProperty == BUFFER_HOST) {
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
} else {
iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
}
// Get pending last frame
pData[0] = NULL;
pData[1] = NULL;
pData[2] = NULL;
memset(&sDstBufInfo, 0, sizeof(SBufferInfo));
if (pOptionFile != NULL) {
if (iWidth != iLastWidth && iHeight != iLastHeight) {
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile);
iLastWidth = iWidth;
iLastHeight = iHeight;
}
}
++ iFrameCount;
}
pDecoder->DecodeFrame( NULL, 0, pData, &sDstBufInfo );
if(sDstBufInfo.iBufferStatus == 1)
{
pDst[0] = (uint8_t *)pData[0];
pDst[1] = (uint8_t *)pData[1];
pDst[2] = (uint8_t *)pData[2];
}
iBufPos += iSliceSize;
++ iSliceIndex;
}
if ((sDstBufInfo.iBufferStatus==1))
{
cOutputModule.Process((void_t **)pDst, &sDstBufInfo, pYuvFile);
if (sDstBufInfo.eBufferProperty == BUFFER_HOST)
{
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
}
else
{
iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
}
if ( pOptionFile != NULL )
{
/* Anyway, we need write in case of final frame decoding */
fwrite(&iFrameCount, sizeof(iFrameCount), 1, pOptionFile);
fwrite(&iWidth , sizeof(iWidth) , 1, pOptionFile);
fwrite(&iHeight, sizeof(iHeight), 1, pOptionFile);
iLastWidth = iWidth;
iLastHeight = iHeight;
}
++ iFrameCount;
}
// Get pending last frame
pData[0] = NULL;
pData[1] = NULL;
pData[2] = NULL;
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
pDecoder->DecodeFrame (NULL, 0, pData, &sDstBufInfo);
if (sDstBufInfo.iBufferStatus == 1) {
pDst[0] = (uint8_t*)pData[0];
pDst[1] = (uint8_t*)pData[1];
pDst[2] = (uint8_t*)pData[2];
}
if ((sDstBufInfo.iBufferStatus == 1)) {
cOutputModule.Process ((void_t**)pDst, &sDstBufInfo, pYuvFile);
if (sDstBufInfo.eBufferProperty == BUFFER_HOST) {
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
} else {
iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
}
if (pOptionFile != NULL) {
/* Anyway, we need write in case of final frame decoding */
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile);
iLastWidth = iWidth;
iLastHeight = iHeight;
}
++ iFrameCount;
}
#if defined ( STICK_STREAM_SIZE )
if ( fpTrack ){
fclose( fpTrack );
fpTrack = NULL;
}
if (fpTrack) {
fclose (fpTrack);
fpTrack = NULL;
}
#endif// STICK_STREAM_SIZE
dElapsed = iTotal / 1e6;
fprintf( stderr, "-------------------------------------------------------\n" );
fprintf( stderr, "iWidth: %d\nheight: %d\nFrames: %d\ndecode time: %f sec\nFPS: %f fps\n",
iWidth, iHeight, iFrameCount, dElapsed, (iFrameCount * 1.0)/dElapsed );
fprintf( stderr, "-------------------------------------------------------\n" );
// coverity scan uninitial
dElapsed = iTotal / 1e6;
fprintf (stderr, "-------------------------------------------------------\n");
fprintf (stderr, "iWidth: %d\nheight: %d\nFrames: %d\ndecode time: %f sec\nFPS: %f fps\n",
iWidth, iHeight, iFrameCount, dElapsed, (iFrameCount * 1.0) / dElapsed);
fprintf (stderr, "-------------------------------------------------------\n");
// coverity scan uninitial
label_exit:
if (pBuf)
{
delete[] pBuf;
pBuf = NULL;
}
if ( pH264File )
{
fclose(pH264File);
pH264File = NULL;
}
if ( pYuvFile )
{
fclose(pYuvFile);
pYuvFile = NULL;
}
if ( pOptionFile )
{
fclose(pOptionFile);
pOptionFile = NULL;
}
if (pBuf) {
delete[] pBuf;
pBuf = NULL;
}
if (pH264File) {
fclose (pH264File);
pH264File = NULL;
}
if (pYuvFile) {
fclose (pYuvFile);
pYuvFile = NULL;
}
if (pOptionFile) {
fclose (pOptionFile);
pOptionFile = NULL;
}
}
int32_t main(int32_t iArgC, char* pArgV[])
{
ISVCDecoder *pDecoder = NULL;
int32_t main (int32_t iArgC, char* pArgV[]) {
ISVCDecoder* pDecoder = NULL;
SDecodingParam sDecParam = {0};
string strInputFile(""), strOutputFile(""), strOptionFile("");
SDecodingParam sDecParam = {0};
string strInputFile (""), strOutputFile (""), strOptionFile ("");
sDecParam.sVideoProperty.size = sizeof( sDecParam.sVideoProperty );
sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty);
if (iArgC < 2)
{
printf( "usage 1: h264dec.exe welsdec.cfg\n" );
printf( "usage 2: h264dec.exe welsdec.264 out.yuv\n" );
printf( "usage 3: h264dec.exe welsdec.264\n" );
return 1;
}
else if (iArgC == 2)
{
if (strstr(pArgV[1], ".cfg")) // read config file //confirmed_safe_unsafe_usage
{
CReadConfig cReadCfg(pArgV[1]);
string strTag[4];
string strReconFile("");
if (iArgC < 2) {
printf ("usage 1: h264dec.exe welsdec.cfg\n");
printf ("usage 2: h264dec.exe welsdec.264 out.yuv\n");
printf ("usage 3: h264dec.exe welsdec.264\n");
return 1;
} else if (iArgC == 2) {
if (strstr (pArgV[1], ".cfg")) { // read config file //confirmed_safe_unsafe_usage
CReadConfig cReadCfg (pArgV[1]);
string strTag[4];
string strReconFile ("");
if ( !cReadCfg.ExistFile() ){
printf("Specified file: %s not exist, maybe invalid path or parameter settting.\n", cReadCfg.GetFileName().c_str());
return 1;
}
memset(&sDecParam, 0, sizeof(sDecParam));
if (!cReadCfg.ExistFile()) {
printf ("Specified file: %s not exist, maybe invalid path or parameter settting.\n", cReadCfg.GetFileName().c_str());
return 1;
}
memset (&sDecParam, 0, sizeof (sDecParam));
while ( !cReadCfg.EndOfFile() ){
long nRd = cReadCfg.ReadLine(&strTag[0]);
if (nRd > 0){
if (strTag[0].compare("InputFile") == 0){
strInputFile = strTag[1];
}
else if (strTag[0].compare("OutputFile") == 0){
strOutputFile = strTag[1];
}
else if (strTag[0].compare("RestructionFile") == 0){
strReconFile = strTag[1];
int32_t iLen = strReconFile.length();
sDecParam.pFileNameRestructed = new char[iLen + 1];
if (sDecParam.pFileNameRestructed != NULL){
sDecParam.pFileNameRestructed[iLen] = 0;
}
strncpy(sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen);//confirmed_safe_unsafe_usage
}
else if (strTag[0].compare("TargetDQID") == 0){
sDecParam.uiTargetDqLayer = (uint8_t)atol(strTag[1].c_str());
}
else if (strTag[0].compare("OutColorFormat") == 0){
sDecParam.iOutputColorFormat = atol(strTag[1].c_str());
}
else if (strTag[0].compare("ErrorConcealmentFlag") == 0){
sDecParam.uiEcActiveFlag = (uint8_t)atol(strTag[1].c_str());
}
else if (strTag[0].compare("CPULoad") == 0){
sDecParam.uiCpuLoad = (uint32_t)atol(strTag[1].c_str());
}
else if (strTag[0].compare("VideoBitstreamType") == 0){
sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol(strTag[1].c_str());
}
}
}
if (strOutputFile.empty())
{
printf( "No output file specified in configuration file.\n" );
return 1;
}
}
else if (strstr(pArgV[1], ".264")) // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
{
strInputFile = pArgV[1];
memset(&sDecParam, 0, sizeof(sDecParam));
sDecParam.iOutputColorFormat = videoFormatI420;
sDecParam.uiTargetDqLayer = (uint8_t)-1;
sDecParam.uiEcActiveFlag = 1;
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
}
}
else //iArgC > 2
{
strInputFile = pArgV[1];
strOutputFile = pArgV[2];
memset(&sDecParam, 0, sizeof(sDecParam));
sDecParam.iOutputColorFormat = videoFormatI420;
sDecParam.uiTargetDqLayer = (uint8_t)-1;
sDecParam.uiEcActiveFlag = 1;
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
if (iArgC > 3) {
// Basic option parser. Note that this is not safe about the
// number of remaining arguments.
// TODO: rewrite
for (int i = 3; i < iArgC; i++) {
char *cmd = pArgV[i];
while (!cReadCfg.EndOfFile()) {
long nRd = cReadCfg.ReadLine (&strTag[0]);
if (nRd > 0) {
if (strTag[0].compare ("InputFile") == 0) {
strInputFile = strTag[1];
} else if (strTag[0].compare ("OutputFile") == 0) {
strOutputFile = strTag[1];
} else if (strTag[0].compare ("RestructionFile") == 0) {
strReconFile = strTag[1];
int32_t iLen = strReconFile.length();
sDecParam.pFileNameRestructed = new char[iLen + 1];
if (sDecParam.pFileNameRestructed != NULL) {
sDecParam.pFileNameRestructed[iLen] = 0;
}
if( !strcmp(cmd, "-options") ) {
strOutputFile = pArgV[i+1];
i += 2;
} else if( !strcmp(cmd, "-trace") ) {
WelsStderrSetTraceLevel(atoi(pArgV[i + 1]));
i += 2;
} else {
i++;
}
}
}
strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage
} else if (strTag[0].compare ("TargetDQID") == 0) {
sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str());
} else if (strTag[0].compare ("OutColorFormat") == 0) {
sDecParam.iOutputColorFormat = atol (strTag[1].c_str());
} else if (strTag[0].compare ("ErrorConcealmentFlag") == 0) {
sDecParam.uiEcActiveFlag = (uint8_t)atol (strTag[1].c_str());
} else if (strTag[0].compare ("CPULoad") == 0) {
sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str());
} else if (strTag[0].compare ("VideoBitstreamType") == 0) {
sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str());
}
}
}
if (strOutputFile.empty()) {
printf ("No output file specified in configuration file.\n");
return 1;
}
} else if (strstr (pArgV[1],
".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
strInputFile = pArgV[1];
memset (&sDecParam, 0, sizeof (sDecParam));
sDecParam.iOutputColorFormat = videoFormatI420;
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
sDecParam.uiEcActiveFlag = 1;
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
}
} else { //iArgC > 2
strInputFile = pArgV[1];
strOutputFile = pArgV[2];
memset (&sDecParam, 0, sizeof (sDecParam));
sDecParam.iOutputColorFormat = videoFormatI420;
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
sDecParam.uiEcActiveFlag = 1;
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
if (iArgC > 3) {
// Basic option parser. Note that this is not safe about the
// number of remaining arguments.
// TODO: rewrite
for (int i = 3; i < iArgC; i++) {
char* cmd = pArgV[i];
if (!strcmp (cmd, "-options")) {
strOutputFile = pArgV[i + 1];
i += 2;
} else if (!strcmp (cmd, "-trace")) {
WelsStderrSetTraceLevel (atoi (pArgV[i + 1]));
i += 2;
} else {
i++;
}
}
}
if (strOutputFile.empty()) {
printf ("No output file specified in configuration file.\n");
return 1;
}
}
if (strInputFile.empty()) {
printf ("No input file specified in configuration file.\n");
return 1;
}
if (strOutputFile.empty())
{
printf( "No output file specified in configuration file.\n" );
return 1;
}
}
if (strInputFile.empty())
{
printf( "No input file specified in configuration file.\n" );
return 1;
}
#if defined(_MSC_VER)
HMODULE hModule = LoadLibraryA(".\\welsdec.dll");
HMODULE hModule = LoadLibraryA (".\\welsdec.dll");
PCreateDecoderFunc pCreateDecoderFunc = NULL;
PDestroyDecoderFunc pDestroyDecoderFunc = NULL;
PCreateDecoderFunc pCreateDecoderFunc = NULL;
PDestroyDecoderFunc pDestroyDecoderFunc = NULL;
pCreateDecoderFunc = (PCreateDecoderFunc)::GetProcAddress(hModule, "CreateDecoder");
pDestroyDecoderFunc = (PDestroyDecoderFunc)::GetProcAddress(hModule, "DestroyDecoder");
pCreateDecoderFunc = (PCreateDecoderFunc)::GetProcAddress (hModule, "CreateDecoder");
pDestroyDecoderFunc = (PDestroyDecoderFunc)::GetProcAddress (hModule, "DestroyDecoder");
if ((hModule != NULL) && (pCreateDecoderFunc != NULL) && (pDestroyDecoderFunc != NULL))
{
printf("load library sw function successfully\n");
if ((hModule != NULL) && (pCreateDecoderFunc != NULL) && (pDestroyDecoderFunc != NULL)) {
printf ("load library sw function successfully\n");
if ( pCreateDecoderFunc( &pDecoder ) || (NULL == pDecoder) )
{
printf( "Create Decoder failed.\n" );
return 1;
}
}
else
{
printf("load library sw function failed\n");
return 1;
}
if (pCreateDecoderFunc (&pDecoder) || (NULL == pDecoder)) {
printf ("Create Decoder failed.\n");
return 1;
}
} else {
printf ("load library sw function failed\n");
return 1;
}
#else
if ( CreateDecoder( &pDecoder ) || (NULL == pDecoder) )
{
printf( "Create Decoder failed.\n" );
return 1;
}
if (CreateDecoder (&pDecoder) || (NULL == pDecoder)) {
printf ("Create Decoder failed.\n");
return 1;
}
#endif
if ( pDecoder->Initialize( &sDecParam, INIT_TYPE_PARAMETER_BASED ) )
{
printf( "Decoder initialization failed.\n" );
return 1;
}
int32_t iWidth = 0;
int32_t iHeight= 0;
if (pDecoder->Initialize (&sDecParam, INIT_TYPE_PARAMETER_BASED)) {
printf ("Decoder initialization failed.\n");
return 1;
}
int32_t iWidth = 0;
int32_t iHeight = 0;
H264DecodeInstance (pDecoder, strInputFile.c_str(), strOutputFile.c_str(), iWidth, iHeight,
(!strOptionFile.empty() ? (void_t*) (const_cast<char*> (strOptionFile.c_str())) : NULL));
if (sDecParam.pFileNameRestructed != NULL) {
delete []sDecParam.pFileNameRestructed;
sDecParam.pFileNameRestructed = NULL;
}
if (pDecoder) {
pDecoder->Uninitialize();
H264DecodeInstance( pDecoder, strInputFile.c_str(), strOutputFile.c_str(), iWidth, iHeight, (!strOptionFile.empty() ? (void_t*)(const_cast<char*>(strOptionFile.c_str())) : NULL) );
if (sDecParam.pFileNameRestructed != NULL){
delete []sDecParam.pFileNameRestructed;
sDecParam.pFileNameRestructed = NULL;
}
if ( pDecoder ){
pDecoder->Uninitialize();
#if defined(_MSC_VER)
pDestroyDecoderFunc( pDecoder );
pDestroyDecoderFunc (pDecoder);
#else
DestroyDecoder(pDecoder);
DestroyDecoder (pDecoder);
#endif
}
}
return 0;
return 0;
}

View File

@ -36,7 +36,7 @@
* \date Created on 03/15/2011
*
* \description : 1. Load bundle: welsdec.bundle
* 2. Load address of function
* 2. Load address of function
* 3. Create or destroy decoder
*
*************************************************************************************
@ -55,8 +55,8 @@
#include "dec_console.h"
#include "codec_api.h"
typedef long (*LPCreateWelsCSDecoder)(ISVCDecoder** ppDecoder);
typedef void (*LPDestroyWelsCSDecoder)(ISVCDecoder* pDecoder);
typedef long (*LPCreateWelsCSDecoder) (ISVCDecoder** ppDecoder);
typedef void (*LPDestroyWelsCSDecoder) (ISVCDecoder* pDecoder);
typedef long (*LPCreateVHDController)();
@ -70,200 +70,170 @@ CFBundleRef g_at264ModuleHWD = nil;
////////////////////////////////////////////////////////////////////////////////////////
int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
{
if(lpModulePath == NULL || iPathMax <= 0)
{
return -1;
}
memset(lpModulePath, 0, iPathMax);
char cCurrentPath[PATH_MAX];
memset(cCurrentPath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr((void*)&sDummy, &dlInfo);
strlcpy(cCurrentPath, dlInfo.dli_fname, PATH_MAX);
int GetCurrentModulePath (char* lpModulePath, const int iPathMax) {
if (lpModulePath == NULL || iPathMax <= 0) {
return -1;
}
memset (lpModulePath, 0, iPathMax);
char cCurrentPath[PATH_MAX];
memset (cCurrentPath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr ((void*)&sDummy, &dlInfo);
strlcpy (cCurrentPath, dlInfo.dli_fname, PATH_MAX);
#if defined(__apple__)
// whether is self a framework ?
int locateNumber = 1;
struct FSRef currentPath;
OSStatus iStatus = FSPathMakeRef((unsigned char*)cCurrentPath, &currentPath, NULL);
if(noErr == iStatus)
{
LSItemInfoRecord info;
iStatus = LSCopyItemInfoForRef(&currentPath, kLSRequestExtension, &info);
if(noErr == iStatus && NULL == info.extension)
{
locateNumber = 4;
}
}
// whether is self a framework ?
int locateNumber = 1;
struct FSRef currentPath;
OSStatus iStatus = FSPathMakeRef ((unsigned char*)cCurrentPath, &currentPath, NULL);
if (noErr == iStatus) {
LSItemInfoRecord info;
iStatus = LSCopyItemInfoForRef (&currentPath, kLSRequestExtension, &info);
if (noErr == iStatus && NULL == info.extension) {
locateNumber = 4;
}
}
#else
int locateNumber = 1;
int locateNumber = 1;
#endif
std::string strPath(cCurrentPath);
int pos = std::string::npos;
for(int i = 0; i < locateNumber; i++)
{
pos = strPath.rfind('/');
if(std::string::npos == pos)
{
break;
}
strPath.erase(pos);
}
if(std::string::npos == pos)
{
return -2;
}
cCurrentPath[pos] = 0;
strlcpy(lpModulePath, cCurrentPath, iPathMax);
strlcat(lpModulePath, "/", iPathMax);
return 0;
std::string strPath (cCurrentPath);
int pos = std::string::npos;
for (int i = 0; i < locateNumber; i++) {
pos = strPath.rfind ('/');
if (std::string::npos == pos) {
break;
}
strPath.erase (pos);
}
if (std::string::npos == pos) {
return -2;
}
cCurrentPath[pos] = 0;
strlcpy (lpModulePath, cCurrentPath, iPathMax);
strlcat (lpModulePath, "/", iPathMax);
return 0;
}
CFBundleRef LoadBundle(const char* lpBundlePath)
{
if(lpBundlePath == NULL)
{
return NULL;
}
CFStringRef bundlePath = CFStringCreateWithCString(kCFAllocatorSystemDefault, lpBundlePath, CFStringGetSystemEncoding());
if(NULL == bundlePath)
{
return NULL;
}
CFURLRef bundleURL = CFURLCreateWithString(kCFAllocatorSystemDefault, bundlePath, NULL);
if(NULL == bundleURL)
{
return NULL;
}
#endif
// 2.get bundle ref
CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
CFRelease(bundleURL);
if(NULL != bundleRef)
{
}
CFBundleRef LoadBundle (const char* lpBundlePath) {
if (lpBundlePath == NULL) {
return NULL;
}
return bundleRef;
CFStringRef bundlePath = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpBundlePath,
CFStringGetSystemEncoding());
if (NULL == bundlePath) {
return NULL;
}
CFURLRef bundleURL = CFURLCreateWithString (kCFAllocatorSystemDefault, bundlePath, NULL);
if (NULL == bundleURL) {
return NULL;
}
#endif
// 2.get bundle ref
CFBundleRef bundleRef = CFBundleCreate (kCFAllocatorSystemDefault, bundleURL);
CFRelease (bundleURL);
if (NULL != bundleRef) {
}
return bundleRef;
}
void* GetProcessAddress(CFBundleRef bundleRef, const char* lpProcName)
{
void *processAddress = NULL;
if(NULL != bundleRef)
{
CFStringRef cfProcName = CFStringCreateWithCString(kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
processAddress = CFBundleGetFunctionPointerForName(bundleRef, cfProcName);
CFRelease(cfProcName);
}
return processAddress;
void* GetProcessAddress (CFBundleRef bundleRef, const char* lpProcName) {
void* processAddress = NULL;
if (NULL != bundleRef) {
CFStringRef cfProcName = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
processAddress = CFBundleGetFunctionPointerForName (bundleRef, cfProcName);
CFRelease (cfProcName);
}
return processAddress;
}
////////////////////////
bool load_bundle_welsdec()
{
char achPath[512] = {0};
GetCurrentModulePath(achPath, 512);
strlcat(achPath, H264DecoderDLL, 512);
g_at264Module = LoadBundle(achPath);
if (g_at264Module == NULL)
return false;
bool load_bundle_welsdec() {
return true;
char achPath[512] = {0};
GetCurrentModulePath (achPath, 512);
strlcat (achPath, H264DecoderDLL, 512);
g_at264Module = LoadBundle (achPath);
if (g_at264Module == NULL)
return false;
return true;
}
void free_bundle_welsdec()
{
if(g_at264Module != NULL)
{
CFBundleUnloadExecutable(g_at264Module);
}
void free_bundle_welsdec() {
if (g_at264Module != NULL) {
CFBundleUnloadExecutable (g_at264Module);
}
}
bool get_functions_address_create_decoder(ISVCDecoder** ppDecoder)
{
if(!g_at264Module)
return false;
LPCreateWelsCSDecoder pfuncCreateSWDec =
(LPCreateWelsCSDecoder)GetProcessAddress(g_at264Module, "CreateSVCDecoder");
LPCreateVHDController pfuncCreateHWDec =
(LPCreateVHDController)GetProcessAddress(g_at264Module, "CreateSVCVHDController");
bool get_functions_address_create_decoder (ISVCDecoder** ppDecoder) {
if (!g_at264Module)
return false;
LPCreateWelsCSDecoder pfuncCreateSWDec =
(LPCreateWelsCSDecoder)GetProcessAddress (g_at264Module, "CreateSVCDecoder");
LPCreateVHDController pfuncCreateHWDec =
(LPCreateVHDController)GetProcessAddress (g_at264Module, "CreateSVCVHDController");
if (pfuncCreateSWDec != NULL) {
pfuncCreateSWDec (ppDecoder);
} else {
return false;
}
if (pfuncCreateHWDec != NULL) {
pfuncCreateHWDec();
} else {
return false;
}
return true;
if(pfuncCreateSWDec != NULL)
{
pfuncCreateSWDec( ppDecoder );
}
else
{
return false;
}
if(pfuncCreateHWDec != NULL)
{
pfuncCreateHWDec();
}
else
{
return false;
}
return true;
}
bool get_functions_address_free_decoder(ISVCDecoder* pDecoder)
{
if(!g_at264Module)
return false;
LPDestroyWelsCSDecoder pfuncDestroySWDec =
(LPDestroyWelsCSDecoder)GetProcessAddress(g_at264Module, "DestroySVCDecoder");
LPDestroyVHDController pfuncDestroyHWDec =
(LPDestroyVHDController)GetProcessAddress(g_at264Module, "DestroySVCVHDController");
if(pfuncDestroySWDec != NULL)
{
pfuncDestroySWDec( pDecoder );
}
else
{
return false;
}
if(pfuncDestroyHWDec != NULL)
{
pfuncDestroyHWDec();
}
else
{
return false;
}
bool get_functions_address_free_decoder (ISVCDecoder* pDecoder) {
if (!g_at264Module)
return false;
return true;
LPDestroyWelsCSDecoder pfuncDestroySWDec =
(LPDestroyWelsCSDecoder)GetProcessAddress (g_at264Module, "DestroySVCDecoder");
LPDestroyVHDController pfuncDestroyHWDec =
(LPDestroyVHDController)GetProcessAddress (g_at264Module, "DestroySVCVHDController");
if (pfuncDestroySWDec != NULL) {
pfuncDestroySWDec (pDecoder);
} else {
return false;
}
if (pfuncDestroyHWDec != NULL) {
pfuncDestroyHWDec();
} else {
return false;
}
return true;
}

View File

@ -46,83 +46,75 @@
#include "read_config.h"
CReadConfig::CReadConfig( const char *kpConfigFileName )
: m_pCfgFile(0)
, m_strCfgFileName(kpConfigFileName)
, m_ulLines(0)
{
if ( strlen(kpConfigFileName) > 0 ){ // FIXME: To check validation in configure file name
m_pCfgFile = fopen(kpConfigFileName, "r");
}
CReadConfig::CReadConfig (const char* kpConfigFileName)
: m_pCfgFile (0)
, m_strCfgFileName (kpConfigFileName)
, m_ulLines (0) {
if (strlen (kpConfigFileName) > 0) { // FIXME: To check validation in configure file name
m_pCfgFile = fopen (kpConfigFileName, "r");
}
}
CReadConfig::~CReadConfig()
{
if ( m_pCfgFile ){
fclose( m_pCfgFile );
m_pCfgFile = NULL;
}
}
long CReadConfig::ReadLine( string* pStr, const int kiValSize/* = 4*/ )
{
if ( m_pCfgFile == NULL || pStr == NULL || kiValSize <= 1)
return 0;
string *strTags = &pStr[0];
int iTagNum = 0, iNum = 0;
bool bCommentFlag = false;
while (iNum < kiValSize) {
pStr[iNum] = "";
++ iNum;
}
do {
const char kChar = (char)fgetc(m_pCfgFile);
if ( kChar == '\n' || feof(m_pCfgFile) ){
++ m_ulLines;
break;
}
if ( kChar == '#' )
bCommentFlag = true;
if ( !bCommentFlag ){
if ( kChar == '\t' || kChar == ' ' ){
if ( iTagNum >= kiValSize )
break;
if ( !(*strTags).empty() ){
++ iTagNum;
strTags = &pStr[iTagNum];
}
}
else
*strTags += kChar;
}
} while(true);
return 1+iTagNum;
CReadConfig::~CReadConfig() {
if (m_pCfgFile) {
fclose (m_pCfgFile);
m_pCfgFile = NULL;
}
}
const bool CReadConfig::EndOfFile()
{
if (m_pCfgFile == NULL)
return true;
return feof(m_pCfgFile) ? true : false;
long CReadConfig::ReadLine (string* pStr, const int kiValSize/* = 4*/) {
if (m_pCfgFile == NULL || pStr == NULL || kiValSize <= 1)
return 0;
string* strTags = &pStr[0];
int iTagNum = 0, iNum = 0;
bool bCommentFlag = false;
while (iNum < kiValSize) {
pStr[iNum] = "";
++ iNum;
}
do {
const char kChar = (char)fgetc (m_pCfgFile);
if (kChar == '\n' || feof (m_pCfgFile)) {
++ m_ulLines;
break;
}
if (kChar == '#')
bCommentFlag = true;
if (!bCommentFlag) {
if (kChar == '\t' || kChar == ' ') {
if (iTagNum >= kiValSize)
break;
if (! (*strTags).empty()) {
++ iTagNum;
strTags = &pStr[iTagNum];
}
} else
*strTags += kChar;
}
} while (true);
return 1 + iTagNum;
}
const int CReadConfig::GetLines()
{
return m_ulLines;
const bool CReadConfig::EndOfFile() {
if (m_pCfgFile == NULL)
return true;
return feof (m_pCfgFile) ? true : false;
}
const bool CReadConfig::ExistFile()
{
return (m_pCfgFile != NULL);
const int CReadConfig::GetLines() {
return m_ulLines;
}
const string& CReadConfig::GetFileName()
{
return m_strCfgFileName;
const bool CReadConfig::ExistFile() {
return (m_pCfgFile != NULL);
}
const string& CReadConfig::GetFileName() {
return m_strCfgFileName;
}

View File

@ -45,37 +45,34 @@
#include "wels_const.h"
using namespace std;
typedef struct tagFilesSet
{
string strBsFile;
string strSeqFile; // for cmd lines
struct
{
string strLayerCfgFile;
string strSeqFile;
} sSpatialLayers[MAX_DEPENDENCY_LAYER];
typedef struct tagFilesSet {
string strBsFile;
string strSeqFile; // for cmd lines
struct {
string strLayerCfgFile;
string strSeqFile;
} sSpatialLayers[MAX_DEPENDENCY_LAYER];
} SFilesSet;
class CReadConfig
{
public:
CReadConfig();
CReadConfig( const char *pConfigFileName );
CReadConfig( const string& pConfigFileName );
virtual ~CReadConfig();
void Openf(const char * strFile);
long ReadLine( string* strVal, const int iValSize = 4 );
const bool EndOfFile();
const int GetLines();
const bool ExistFile();
const string& GetFileName();
private:
FILE *m_pCfgFile;
string m_strCfgFileName;
unsigned long m_iLines;
class CReadConfig {
public:
CReadConfig();
CReadConfig (const char* pConfigFileName);
CReadConfig (const string& pConfigFileName);
virtual ~CReadConfig();
void Openf (const char* strFile);
long ReadLine (string* strVal, const int iValSize = 4);
const bool EndOfFile();
const int GetLines();
const bool ExistFile();
const string& GetFileName();
private:
FILE* m_pCfgFile;
string m_strCfgFileName;
unsigned long m_iLines;
};
#endif // READ_CONFIG_H__

View File

@ -39,111 +39,99 @@
#include "bundleloader.h"
#include "codec_api.h"
typedef long (*LPCreateWelsCSEncoder)(ISVCEncoder** ppEncoder);
typedef void (*LPDestroyWelsCSEncoder)(ISVCEncoder* pEncoder);
typedef long (*LPCreateWelsCSEncoder) (ISVCEncoder** ppEncoder);
typedef void (*LPDestroyWelsCSEncoder) (ISVCEncoder* pEncoder);
CFBundleRef g_at264Module = nil;
const char H264EncoderDLL[] = "welsenc.bundle";
int WelsEncGetCurrentModulePath(char* lpModulePath, const int iPathMax)
{
if(lpModulePath == NULL || iPathMax <= 0)
{
return -1;
}
memset(lpModulePath, 0, iPathMax);
char cCurrentPath[PATH_MAX];
memset(cCurrentPath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr((void*)&sDummy, &dlInfo);
strlcpy(cCurrentPath, dlInfo.dli_fname, PATH_MAX);
int locateNumber = 1;
std::string strPath(cCurrentPath);
int pos = std::string::npos;
for(int i = 0; i < locateNumber; i++)
{
pos = strPath.rfind('/');
if(std::string::npos == pos)
{
break;
}
strPath.erase(pos);
}
if(std::string::npos == pos)
{
return -2;
}
cCurrentPath[pos] = 0;
strlcpy(lpModulePath, cCurrentPath, iPathMax);
strlcat(lpModulePath, "/", iPathMax);
return 0;
int WelsEncGetCurrentModulePath (char* lpModulePath, const int iPathMax) {
if (lpModulePath == NULL || iPathMax <= 0) {
return -1;
}
memset (lpModulePath, 0, iPathMax);
char cCurrentPath[PATH_MAX];
memset (cCurrentPath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr ((void*)&sDummy, &dlInfo);
strlcpy (cCurrentPath, dlInfo.dli_fname, PATH_MAX);
int locateNumber = 1;
std::string strPath (cCurrentPath);
int pos = std::string::npos;
for (int i = 0; i < locateNumber; i++) {
pos = strPath.rfind ('/');
if (std::string::npos == pos) {
break;
}
strPath.erase (pos);
}
if (std::string::npos == pos) {
return -2;
}
cCurrentPath[pos] = 0;
strlcpy (lpModulePath, cCurrentPath, iPathMax);
strlcat (lpModulePath, "/", iPathMax);
return 0;
}
int32_t WelsEncBundleLoad()
{
char achPath[512] = {0};
WelsEncGetCurrentModulePath(achPath, 512);
strlcat(achPath, H264EncoderDLL, 512);
g_at264Module = LoadBundle(achPath);
if (g_at264Module == NULL)
return 1;
else
return 0;
int32_t WelsEncBundleLoad() {
char achPath[512] = {0};
WelsEncGetCurrentModulePath (achPath, 512);
strlcat (achPath, H264EncoderDLL, 512);
g_at264Module = LoadBundle (achPath);
if (g_at264Module == NULL)
return 1;
else
return 0;
}
void WelsEncBundleFree()
{
if(g_at264Module != NULL)
{
CFBundleUnloadExecutable(g_at264Module);
}
void WelsEncBundleFree() {
if (g_at264Module != NULL) {
CFBundleUnloadExecutable (g_at264Module);
}
}
int32_t WelsEncBundleCreateEncoder(ISVCEncoder** ppEncoder)
{
if(!g_at264Module)
return 1;
LPCreateWelsCSEncoder pfuncCreateCSEnc =
(LPCreateWelsCSEncoder)GetProcessAddress(g_at264Module, "CreateSVCEncoder");
if(pfuncCreateCSEnc != NULL)
{
return (pfuncCreateCSEnc( ppEncoder ));
}
return 1;
int32_t WelsEncBundleCreateEncoder (ISVCEncoder** ppEncoder) {
if (!g_at264Module)
return 1;
LPCreateWelsCSEncoder pfuncCreateCSEnc =
(LPCreateWelsCSEncoder)GetProcessAddress (g_at264Module, "CreateSVCEncoder");
if (pfuncCreateCSEnc != NULL) {
return (pfuncCreateCSEnc (ppEncoder));
}
return 1;
}
int32_t WelsEncBundleDestroyEncoder(ISVCEncoder* pEncoder)
{
if(!g_at264Module)
return 1;
LPDestroyWelsCSEncoder pfuncDestroyCSEnc =
(LPDestroyWelsCSEncoder)GetProcessAddress(g_at264Module, "DestroySVCEncoder");
if(pfuncDestroyCSEnc != NULL){
pfuncDestroyCSEnc( pEncoder );
return 0;
}
else
return 1;
int32_t WelsEncBundleDestroyEncoder (ISVCEncoder* pEncoder) {
if (!g_at264Module)
return 1;
LPDestroyWelsCSEncoder pfuncDestroyCSEnc =
(LPDestroyWelsCSEncoder)GetProcessAddress (g_at264Module, "DestroySVCEncoder");
if (pfuncDestroyCSEnc != NULL) {
pfuncDestroyCSEnc (pEncoder);
return 0;
} else
return 1;
}

View File

@ -1,160 +1,147 @@
/*!
* \copy
* Copyright (c) 2008-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* read_config.h
*
* Abstract
* Class for reading parameter settings in a configure file.
*
* History
* 08/18/2008 Created
*
*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "read_config.h"
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996)
#endif
CReadConfig::CReadConfig()
: m_pCfgFile( NULL )
, m_strCfgFileName("")
, m_iLines( 0 )
{
}
CReadConfig::CReadConfig( const char *kpConfigFileName )
: m_pCfgFile(0)
, m_strCfgFileName(kpConfigFileName)
, m_iLines(0)
{
if ( strlen(kpConfigFileName) > 0 ){ // confirmed_safe_unsafe_usage
m_pCfgFile = fopen(kpConfigFileName, "r");
}
}
CReadConfig::CReadConfig( const string& kpConfigFileName )
: m_pCfgFile(0)
, m_strCfgFileName(kpConfigFileName)
, m_iLines(0)
{
if ( kpConfigFileName.length() > 0 )
{
m_pCfgFile = fopen(kpConfigFileName.c_str(), "r");
}
}
CReadConfig::~CReadConfig()
{
if ( m_pCfgFile ){
fclose( m_pCfgFile );
m_pCfgFile = NULL;
}
}
void CReadConfig::Openf(const char *kpStrFile)
{
if ( kpStrFile != NULL && strlen(kpStrFile) > 0 ) // confirmed_safe_unsafe_usage
{
m_strCfgFileName = kpStrFile;
m_pCfgFile = fopen(kpStrFile, "r");
}
}
long CReadConfig::ReadLine( string* pVal, const int kiValSize/* = 4*/ )
{
if ( m_pCfgFile == NULL || pVal == NULL || kiValSize <= 1)
return 0;
string *strTags = &pVal[0];
int nTagNum = 0, n = 0;
bool bCommentFlag = false;
while (n < kiValSize) {
pVal[n] = "";
++ n;
}
do {
const char kCh = (char)fgetc(m_pCfgFile);
if ( kCh == '\n' || feof(m_pCfgFile) ){
++ m_iLines;
break;
}
if ( kCh == '#' )
bCommentFlag = true;
if ( !bCommentFlag ){
if ( kCh == '\t' || kCh == ' ' ){
if ( nTagNum >= kiValSize )
break;
if ( !(*strTags).empty() ){
++ nTagNum;
strTags = &pVal[nTagNum];
}
}
else
*strTags += kCh;
}
} while(true);
return 1+nTagNum;
}
const bool CReadConfig::EndOfFile()
{
if (m_pCfgFile == NULL)
return true;
return feof(m_pCfgFile) ? true : false;
}
const int CReadConfig::GetLines()
{
return m_iLines;
}
const bool CReadConfig::ExistFile()
{
return (m_pCfgFile != NULL);
}
const string& CReadConfig::GetFileName()
{
return m_strCfgFileName;
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
/*!
* \copy
* Copyright (c) 2008-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* read_config.h
*
* Abstract
* Class for reading parameter settings in a configure file.
*
* History
* 08/18/2008 Created
*
*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "read_config.h"
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996)
#endif
CReadConfig::CReadConfig()
: m_pCfgFile (NULL)
, m_strCfgFileName ("")
, m_iLines (0) {
}
CReadConfig::CReadConfig (const char* kpConfigFileName)
: m_pCfgFile (0)
, m_strCfgFileName (kpConfigFileName)
, m_iLines (0) {
if (strlen (kpConfigFileName) > 0) { // confirmed_safe_unsafe_usage
m_pCfgFile = fopen (kpConfigFileName, "r");
}
}
CReadConfig::CReadConfig (const string& kpConfigFileName)
: m_pCfgFile (0)
, m_strCfgFileName (kpConfigFileName)
, m_iLines (0) {
if (kpConfigFileName.length() > 0) {
m_pCfgFile = fopen (kpConfigFileName.c_str(), "r");
}
}
CReadConfig::~CReadConfig() {
if (m_pCfgFile) {
fclose (m_pCfgFile);
m_pCfgFile = NULL;
}
}
void CReadConfig::Openf (const char* kpStrFile) {
if (kpStrFile != NULL && strlen (kpStrFile) > 0) { // confirmed_safe_unsafe_usage
m_strCfgFileName = kpStrFile;
m_pCfgFile = fopen (kpStrFile, "r");
}
}
long CReadConfig::ReadLine (string* pVal, const int kiValSize/* = 4*/) {
if (m_pCfgFile == NULL || pVal == NULL || kiValSize <= 1)
return 0;
string* strTags = &pVal[0];
int nTagNum = 0, n = 0;
bool bCommentFlag = false;
while (n < kiValSize) {
pVal[n] = "";
++ n;
}
do {
const char kCh = (char)fgetc (m_pCfgFile);
if (kCh == '\n' || feof (m_pCfgFile)) {
++ m_iLines;
break;
}
if (kCh == '#')
bCommentFlag = true;
if (!bCommentFlag) {
if (kCh == '\t' || kCh == ' ') {
if (nTagNum >= kiValSize)
break;
if (! (*strTags).empty()) {
++ nTagNum;
strTags = &pVal[nTagNum];
}
} else
*strTags += kCh;
}
} while (true);
return 1 + nTagNum;
}
const bool CReadConfig::EndOfFile() {
if (m_pCfgFile == NULL)
return true;
return feof (m_pCfgFile) ? true : false;
}
const int CReadConfig::GetLines() {
return m_iLines;
}
const bool CReadConfig::ExistFile() {
return (m_pCfgFile != NULL);
}
const string& CReadConfig::GetFileName() {
return m_strCfgFileName;
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@
*
* \brief common flag definitions
*
* \date 7/6/2009 Created
* \date 7/6/2009 Created
*************************************************************************************
*/
#ifndef WELS_AS264_COMMON_H__
@ -47,15 +47,15 @@ extern "C" {
#ifdef X86_ASM
void MemZeroUnalign32Bytes(void *pSrc);
void MemZeroAlign32Bytes(void *pSrc);
void MemZeroUnalign16Bytes(void *pSrc);
void MemZeroAlign16Bytes(void *pSrc);
void MemZeroAlign128Bytes(void *pSrc);
void MemZeroUnalign128Bytes(void *pSrc);
void MemZeroAlign256Bytes(void *pSrc);
void MemZeroAlign240Bytes(void *pSrc);
void MmPrefetch0(char const *kpA);
void MemZeroUnalign32Bytes (void* pSrc);
void MemZeroAlign32Bytes (void* pSrc);
void MemZeroUnalign16Bytes (void* pSrc);
void MemZeroAlign16Bytes (void* pSrc);
void MemZeroAlign128Bytes (void* pSrc);
void MemZeroUnalign128Bytes (void* pSrc);
void MemZeroAlign256Bytes (void* pSrc);
void MemZeroAlign240Bytes (void* pSrc);
void MmPrefetch0 (char const* kpA);
#endif// X86_ASM

View File

@ -48,13 +48,13 @@
namespace WelsDec {
/*!
/*!
*************************************************************************************
* \brief Start Code Prefix (0x 00 00 00 01) detection
*
* \param pBuf bitstream payload buffer
* \param pOffset offset between NAL rbsp and original bitsteam that
* start code prefix is seperated from.
* start code prefix is seperated from.
* \param iBufSize count size of buffer
*
* \return RBSP buffer of start code prefix exclusive
@ -62,9 +62,9 @@ namespace WelsDec {
* \note N/A
*************************************************************************************
*/
uint8_t* DetectStartCodePrefix( const uint8_t *kpBuf, int32_t *pOffset, int32_t iBufSize );
uint8_t* DetectStartCodePrefix (const uint8_t* kpBuf, int32_t* pOffset, int32_t iBufSize);
/*!
/*!
*************************************************************************************
* \brief to parse network abstraction layer unit,
* escape emulation_prevention_three_byte within it
@ -74,31 +74,33 @@ uint8_t* DetectStartCodePrefix( const uint8_t *kpBuf, int32_t *pOffset, int32_t
* \param pNalUnitHeader parsed result of NAL Unit Header to output
* \param pSrcRbsp bitstream buffer to input
* \param iSrcRbspLen length size of bitstream buffer payload
* \param pSrcNal
* \param iSrcNalLen
* \param pSrcNal
* \param iSrcNalLen
* \param pConsumedBytes consumed bytes during parsing
*
* \return decoded bytes payload, might be (pSrcRbsp+1) if no escapes
* \return decoded bytes payload, might be (pSrcRbsp+1) if no escapes
*
* \note N/A
*************************************************************************************
*/
uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeader, uint8_t *pSrcRbsp, int32_t iSrcRbspLen, uint8_t *pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes );
uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeader, uint8_t* pSrcRbsp,
int32_t iSrcRbspLen, uint8_t* pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes);
int32_t ParseNonVclNal( PWelsDecoderContext pCtx, uint8_t *pRbsp, const int32_t kiSrcLen );
int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen);
void_t ParseRefBasePicMarking ( PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking );
void_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking);
void_t ParsePrefixNalUnit ( PWelsDecoderContext pCtx, PBitStringAux pBs );
void_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs);
bool_t CheckAccessUnitBoundary( const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps );
bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt, PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader );
/*!
bool_t CheckAccessUnitBoundary (const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps);
bool_t CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader);
/*!
*************************************************************************************
* \brief to parse Sequence Parameter Set (SPS)
*
* \param pCtx Decoder context
* \param pBsAux bitstream reader auxiliary
* \param pBsAux bitstream reader auxiliary
* \param pPicWidth picture width current Sps represented
* \param pPicHeight picture height current Sps represented
*
@ -108,15 +110,15 @@ bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHea
* \note Call it in case eNalUnitType is SPS.
*************************************************************************************
*/
int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicWidth, int32_t *pPicHeight );
int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicWidth, int32_t* pPicHeight);
/*!
/*!
*************************************************************************************
* \brief to parse Picture Parameter Set (PPS)
*
* \param pCtx Decoder context
* \param pPpsList pps list
* \param pBsAux bitstream reader auxiliary
* \param pBsAux bitstream reader auxiliary
*
* \return 0 - successed
* 1 - failed
@ -124,14 +126,14 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
* \note Call it in case eNalUnitType is PPS.
*************************************************************************************
*/
int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux );
int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux);
/*!
/*!
*************************************************************************************
* \brief to parse SEI message payload
*
* \param pSei sei message to be parsed output
* \param pBsAux bitstream reader auxiliary
* \param pBsAux bitstream reader auxiliary
*
* \return 0 - successed
* 1 - failed
@ -139,7 +141,7 @@ int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux
* \note Call it in case eNalUnitType is NAL_UNIT_SEI.
*************************************************************************************
*/
int32_t ParseSei( void_t *pSei, PBitStringAux pBsAux ); // reserved Sei_Msg type
int32_t ParseSei (void_t* pSei, PBitStringAux pBsAux); // reserved Sei_Msg type
/*!
*************************************************************************************
@ -150,7 +152,7 @@ int32_t ParseSei( void_t *pSei, PBitStringAux pBsAux ); // reserved Sei_Msg type
* \return count number of fmo context units are reset
*************************************************************************************
*/
int32_t ResetFmoList( PWelsDecoderContext pCtx );
int32_t ResetFmoList (PWelsDecoderContext pCtx);
} // namespace WelsDec

View File

@ -30,7 +30,7 @@
*
*/
//bit_stream.h - bit-stream reading and / writing auxiliary data
//bit_stream.h - bit-stream reading and / writing auxiliary data
#ifndef WELS_BIT_STREAM_H__
#define WELS_BIT_STREAM_H__
@ -42,16 +42,16 @@ namespace WelsDec {
* Bit-stream auxiliary reading / writing
*/
typedef struct TagBitStringAux {
uint8_t *pStartBuf; // buffer to start position
uint8_t *pEndBuf; // buffer + length
int32_t iBits; // count bits of overall bitstreaming input
uint8_t* pStartBuf; // buffer to start position
uint8_t* pEndBuf; // buffer + length
int32_t iBits; // count bits of overall bitstreaming input
int32_t iIndex; //only for cavlc usage
uint8_t *pCurBuf; // current reading position
uint32_t uiCurBits;
int32_t iLeftBits; // count number of available bits left ([1, 8]),
// need pointer to next byte start position in case 0 bit left then 8 instead
}SBitStringAux, *PBitStringAux;
int32_t iIndex; //only for cavlc usage
uint8_t* pCurBuf; // current reading position
uint32_t uiCurBits;
int32_t iLeftBits; // count number of available bits left ([1, 8]),
// need pointer to next byte start position in case 0 bit left then 8 instead
} SBitStringAux, *PBitStringAux;
//#pragma pack()
@ -64,11 +64,11 @@ typedef struct TagBitStringAux {
*
* \return size of buffer data in byte; failed in -1 return
*/
int32_t InitBits( PBitStringAux pBitString, const uint8_t *kpBuf, const int32_t kiSize );
int32_t InitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32_t kiSize);
void_t InitReadBits( PBitStringAux pBitString );
void_t InitReadBits (PBitStringAux pBitString);
uint32_t EndianFix(uint32_t uiX);
uint32_t EndianFix (uint32_t uiX);

View File

@ -55,19 +55,19 @@ extern "C" {
*/
int32_t WelsCPUIdVerify();
void_t WelsCPUId( uint32_t uiIndex, uint32_t *pFeatureA, uint32_t *pFeatureB, uint32_t *pFeatureC, uint32_t *pFeatureD );
void_t WelsCPUId (uint32_t uiIndex, uint32_t* pFeatureA, uint32_t* pFeatureB, uint32_t* pFeatureC, uint32_t* pFeatureD);
int32_t WelsCPUSupportAVX( uint32_t eax, uint32_t ecx );
int32_t WelsCPUSupportFMA( uint32_t eax, uint32_t ecx );
int32_t WelsCPUSupportAVX (uint32_t eax, uint32_t ecx);
int32_t WelsCPUSupportFMA (uint32_t eax, uint32_t ecx);
void_t WelsEmms();
uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors );
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
/*
* clear FPU registers states for potential float based calculation if support
*/
void WelsCPURestore( const uint32_t kuiCPU );
void WelsCPURestore (const uint32_t kuiCPU);
#endif

View File

@ -42,7 +42,7 @@
/*
* WELS CPU feature flags
*/
*/
#define WELS_CPU_MMX 0x00000001 /* mmx */
#define WELS_CPU_MMXEXT 0x00000002 /* mmx-ext*/
#define WELS_CPU_SSE 0x00000004 /* sse */

View File

@ -73,26 +73,26 @@ typedef FILE WelsFileHandle;
#ifdef WIN32
typedef struct _timeb SWelsTime;
#else
#else
typedef struct timeb SWelsTime;
#endif
int32_t WelsSnprintf( str_t * buffer, int32_t sizeOfBuffer, const str_t * format, ... );
str_t * WelsStrncpy(str_t * dest, int32_t sizeInBytes, const str_t * src, int32_t count);
str_t * WelsStrcat(str_t * dest, int32_t sizeInBytes, str_t * src);
int32_t WelsStrnlen(const str_t * str, int32_t maxlen);
int32_t WelsVsprintf(str_t * buffer, int32_t sizeOfBuffer, const str_t * format, va_list argptr);
int32_t WelsSnprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, ...);
str_t* WelsStrncpy (str_t* dest, int32_t sizeInBytes, const str_t* src, int32_t count);
str_t* WelsStrcat (str_t* dest, int32_t sizeInBytes, str_t* src);
int32_t WelsStrnlen (const str_t* str, int32_t maxlen);
int32_t WelsVsprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, va_list argptr);
WelsFileHandle * WelsFopen(const str_t * filename, const str_t * mode);
int32_t WelsFclose(WelsFileHandle * fp);
int32_t WelsFread(void * buffer, int32_t size, int32_t count, WelsFileHandle * fp);
int32_t WelsFwrite(const void * buffer, int32_t size, int32_t count, WelsFileHandle * fp);
int32_t WelsFseek(WelsFileHandle * fp, int32_t offset, int32_t origin);
int32_t WelsFflush(WelsFileHandle * fp);
WelsFileHandle* WelsFopen (const str_t* filename, const str_t* mode);
int32_t WelsFclose (WelsFileHandle* fp);
int32_t WelsFread (void* buffer, int32_t size, int32_t count, WelsFileHandle* fp);
int32_t WelsFwrite (const void* buffer, int32_t size, int32_t count, WelsFileHandle* fp);
int32_t WelsFseek (WelsFileHandle* fp, int32_t offset, int32_t origin);
int32_t WelsFflush (WelsFileHandle* fp);
int32_t WelsGetTimeOfDay(SWelsTime * tp);
int32_t WelsStrftime(str_t * buffer, int32_t size, const str_t * format, const SWelsTime * tp);
uint16_t WelsGetMillsecond(const SWelsTime * tp);
int32_t WelsGetTimeOfDay (SWelsTime* tp);
int32_t WelsStrftime (str_t* buffer, int32_t size, const str_t* format, const SWelsTime* tp);
uint16_t WelsGetMillsecond (const SWelsTime* tp);
#ifdef __cplusplus

View File

@ -48,7 +48,7 @@
namespace WelsDec {
/*!
* \brief deblocking module initialize
* \brief deblocking module initialize
*
* \param pf
* cpu
@ -56,7 +56,7 @@ namespace WelsDec {
* \return NONE
*/
void_t DeblockingInit( PDeblockingFunc pDeblockingFunc, int32_t iCpu );
void_t DeblockingInit (PDeblockingFunc pDeblockingFunc, int32_t iCpu);
/*!
@ -66,7 +66,7 @@ void_t DeblockingInit( PDeblockingFunc pDeblockingFunc, int32_t iCpu );
*
* \return NONE
*/
void_t WelsDeblockingFilterSlice( PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb );
void_t WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb);
/*!
* \brief pixel deblocking filtering
@ -79,42 +79,46 @@ void_t WelsDeblockingFilterSlice( PWelsDecoderContext pCtx, PDeblockingFilterMbF
* \return NONE
*/
uint32_t DeblockingBsMarginalMBAvcbase( PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy);
uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy);
int32_t DeblockingAvailableNoInterlayer( PDqLayer pCurDqLayer, int32_t iFilterIdc );
int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc);
void_t DeblockingIntraMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag );
void_t DeblockingInterMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], int32_t iBoundryFlag );
void_t DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag);
void_t DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], int32_t iBoundryFlag);
void_t WelsDeblockingMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag );
void_t WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag);
void_t DeblockLumaLt4V_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void_t DeblockLumaEq4V_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void_t DeblockLumaLt4V_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void_t DeblockLumaEq4V_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void_t DeblockLumaLt4H_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void_t DeblockLumaEq4H_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void_t DeblockLumaLt4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void_t DeblockLumaEq4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void_t DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void_t DeblockChromaEq4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void_t DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTc);
void_t DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void_t DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void_t DeblockChromaEq4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void_t DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTc);
void_t DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#ifdef X86_ASM
void DeblockLumaLt4V_sse2( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockLumaEq4V_sse2( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void DeblockLumaTransposeH2V_sse2(uint8_t * pPixY, int32_t iStride, uint8_t * pDst);
void DeblockLumaTransposeV2H_sse2(uint8_t * pPixY, int32_t iStride, uint8_t * pSrc);
void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc);
void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaEq4V_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
void DeblockChromaEq4H_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
void DeblockLumaLt4V_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4V_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockLumaTransposeH2V_sse2 (uint8_t* pPixY, int32_t iStride, uint8_t* pDst);
void DeblockLumaTransposeV2H_sse2 (uint8_t* pPixY, int32_t iStride, uint8_t* pSrc);
void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaEq4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
void DeblockChromaEq4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
#endif
#if defined(__cplusplus)
}

View File

@ -49,92 +49,92 @@ namespace WelsDec {
///////////////////////////////////DQ Layer level///////////////////////////////////
typedef struct TagDqLayer SDqLayer;
typedef SDqLayer* PDqLayer;
typedef struct TagLayerInfo{
SNalUnitHeaderExt sNalHeaderExt;
SSlice sSliceInLayer; // Here Slice identify to Frame on concept
PSubsetSps pSubsetSps; // current pSubsetSps used, memory alloc in external
PSps pSps; // current sps based avc used, memory alloc in external
PPps pPps; // current pps used
typedef struct TagLayerInfo {
SNalUnitHeaderExt sNalHeaderExt;
SSlice sSliceInLayer; // Here Slice identify to Frame on concept
PSubsetSps pSubsetSps; // current pSubsetSps used, memory alloc in external
PSps pSps; // current sps based avc used, memory alloc in external
PPps pPps; // current pps used
} SLayerInfo, *PLayerInfo;
/* Layer Representation */
struct TagDqLayer{
SLayerInfo sLayerInfo;
uint8_t *pCsData[3]; // pointer to reconstructed picture data
int32_t iCsStride[3]; // Cs stride
PBitStringAux pBitStringAux; // pointer to SBitStringAux
PFmo pFmo; // Current fmo context pointer used
int8_t *pMbType;
int32_t *pSliceIdc; // using int32_t for slice_idc
int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM];
int8_t *pLumaQp;
int8_t *pChromaQp;
int8_t *pCbp;
int8_t (*pNzc)[24];
int8_t (*pNzcRs)[24];
int8_t *pResidualPredFlag;
int8_t *pInterPredictionDoneFlag;
int16_t (*pScaledTCoeff)[MB_COEFF_LIST_SIZE];
int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t (*pIntra4x4FinalMode)[MB_BLOCK4x4_NUM];
int8_t *pChromaPredMode;
//uint8_t (*motion_pred_flag[LIST_A])[MB_PARTITION_SIZE]; // 8x8
int8_t (*pSubMbType)[MB_SUB_PARTITION_SIZE];
int32_t iLumaStride;
int32_t iChromaStride;
uint8_t *pPred[3];
int32_t iMbX;
int32_t iMbY;
int32_t iMbXyIndex;
int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth
int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight;
struct TagDqLayer {
SLayerInfo sLayerInfo;
/* Common syntax elements across all slices of a DQLayer */
int32_t iSliceIdcBackup;
uint32_t uiSpsId;
uint32_t uiPpsId;
uint32_t uiDisableInterLayerDeblockingFilterIdc;
int32_t iInterLayerSliceAlphaC0Offset;
int32_t iInterLayerSliceBetaOffset;
//SPosOffset sScaledRefLayer;
int32_t iSliceGroupChangeCycle;
PRefPicListReorderSyn pRefPicListReordering;
PRefPicMarking pRefPicMarking; // Decoded reference picture marking syntaxs
PRefBasePicMarking pRefPicBaseMarking;
uint8_t* pCsData[3]; // pointer to reconstructed picture data
int32_t iCsStride[3]; // Cs stride
PBitStringAux pBitStringAux; // pointer to SBitStringAux
PFmo pFmo; // Current fmo context pointer used
int8_t* pMbType;
int32_t* pSliceIdc; // using int32_t for slice_idc
int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM];
int8_t* pLumaQp;
int8_t* pChromaQp;
int8_t* pCbp;
int8_t (*pNzc)[24];
int8_t (*pNzcRs)[24];
int8_t* pResidualPredFlag;
int8_t* pInterPredictionDoneFlag;
int16_t (*pScaledTCoeff)[MB_COEFF_LIST_SIZE];
int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t (*pIntra4x4FinalMode)[MB_BLOCK4x4_NUM];
int8_t* pChromaPredMode;
//uint8_t (*motion_pred_flag[LIST_A])[MB_PARTITION_SIZE]; // 8x8
int8_t (*pSubMbType)[MB_SUB_PARTITION_SIZE];
int32_t iLumaStride;
int32_t iChromaStride;
uint8_t* pPred[3];
int32_t iMbX;
int32_t iMbY;
int32_t iMbXyIndex;
int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth
int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight;
PPicture pRef; // reference picture pointer
PPicture pDec; // reconstruction picture pointer for layer
/* Common syntax elements across all slices of a DQLayer */
int32_t iSliceIdcBackup;
uint32_t uiSpsId;
uint32_t uiPpsId;
uint32_t uiDisableInterLayerDeblockingFilterIdc;
int32_t iInterLayerSliceAlphaC0Offset;
int32_t iInterLayerSliceBetaOffset;
//SPosOffset sScaledRefLayer;
int32_t iSliceGroupChangeCycle;
PRefPicListReorderSyn pRefPicListReordering;
PRefPicMarking pRefPicMarking; // Decoded reference picture marking syntaxs
PRefBasePicMarking pRefPicBaseMarking;
bool_t bStoreRefBasePicFlag; // iCurTid == 0 && iCurQid = 0 && bEncodeKeyPic = 1
bool_t bTCoeffLevelPredFlag;
bool_t bConstrainedIntraResamplingFlag;
uint8_t uiRefLayerDqId;
uint8_t uiRefLayerChromaPhaseXPlus1Flag;
uint8_t uiRefLayerChromaPhaseYPlus1;
uint8_t uiLayerDqId; // dq_id of current layer
bool_t bUseRefBasePicFlag; // whether reference pic or reference base pic is referred?
PPicture pRef; // reference picture pointer
PPicture pDec; // reconstruction picture pointer for layer
bool_t bStoreRefBasePicFlag; // iCurTid == 0 && iCurQid = 0 && bEncodeKeyPic = 1
bool_t bTCoeffLevelPredFlag;
bool_t bConstrainedIntraResamplingFlag;
uint8_t uiRefLayerDqId;
uint8_t uiRefLayerChromaPhaseXPlus1Flag;
uint8_t uiRefLayerChromaPhaseYPlus1;
uint8_t uiLayerDqId; // dq_id of current layer
bool_t bUseRefBasePicFlag; // whether reference pic or reference base pic is referred?
};
typedef struct TagGpuAvcLayer{
SLayerInfo sLayerInfo;
PBitStringAux pBitStringAux; // pointer to SBitStringAux
typedef struct TagGpuAvcLayer {
SLayerInfo sLayerInfo;
PBitStringAux pBitStringAux; // pointer to SBitStringAux
int8_t *pMbType;
int32_t *pSliceIdc; // using int32_t for slice_idc
int8_t *pLumaQp;
int8_t *pCbp;
int8_t (*pNzc)[24];
int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t* pMbType;
int32_t* pSliceIdc; // using int32_t for slice_idc
int8_t* pLumaQp;
int8_t* pCbp;
int8_t (*pNzc)[24];
int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int32_t iMbX;
int32_t iMbY;
int32_t iMbXyIndex;
int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth
int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight;
int32_t iMbX;
int32_t iMbY;
int32_t iMbXyIndex;
int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth
int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight;
}SGpuAvcDqLayer, *PGpuAvcDqLayer;
} SGpuAvcDqLayer, *PGpuAvcDqLayer;
///////////////////////////////////////////////////////////////////////

View File

@ -52,33 +52,30 @@ namespace WelsDec {
iCurBits |= ((pBufPtr[0] << 8) | pBufPtr[1]) << (iLeftBits); \
iLeftBits -= 16; \
pBufPtr +=2; \
}
}
#define NEED_BITS(iCurBits, pBufPtr, iLeftBits) { \
if( iLeftBits > 0 ) { \
GET_WORD(iCurBits, pBufPtr, iLeftBits); \
} \
}
#define UBITS(iCurBits, iNumBits) (iCurBits>>(32-(iNumBits)))
}
#define UBITS(iCurBits, iNumBits) (iCurBits>>(32-(iNumBits)))
#define DUMP_BITS(iCurBits, pBufPtr, iLeftBits, iNumBits) { \
iCurBits <<= (iNumBits); \
iLeftBits += (iNumBits); \
NEED_BITS(iCurBits, pBufPtr, iLeftBits); \
}
}
static inline int32_t ShowBits( PBitStringAux pBs, int32_t iNumBits )
{
return UBITS( pBs->uiCurBits, iNumBits );
}
static inline void_t FlushBits( PBitStringAux pBs, int32_t iNumBits )
{
DUMP_BITS( pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iNumBits );
}
static inline int32_t BsGetBits( PBitStringAux pBs, int32_t iNumBits )
{
int32_t iRc = UBITS( pBs->uiCurBits, iNumBits );
DUMP_BITS( pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iNumBits );
return iRc;
}
static inline int32_t ShowBits (PBitStringAux pBs, int32_t iNumBits) {
return UBITS (pBs->uiCurBits, iNumBits);
}
static inline void_t FlushBits (PBitStringAux pBs, int32_t iNumBits) {
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iNumBits);
}
static inline int32_t BsGetBits (PBitStringAux pBs, int32_t iNumBits) {
int32_t iRc = UBITS (pBs->uiCurBits, iNumBits);
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iNumBits);
return iRc;
}
/*
* Exponential Golomb codes decoding routines
@ -90,152 +87,129 @@ extern const uint8_t g_kuiInterCbpTable[48];
extern const uint8_t g_kuiLeadingZeroTable[256];
static const uint32_t g_kuiPrefix8BitsTable[16] =
{
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
static const uint32_t g_kuiPrefix8BitsTable[16] = {
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
};
static inline uint32_t GetPrefixBits(uint32_t uiValue)
{
uint32_t iNumBit = 0;
static inline uint32_t GetPrefixBits (uint32_t uiValue) {
uint32_t iNumBit = 0;
if (uiValue & 0xffff0000)
{
uiValue >>= 16;
iNumBit += 16;
}
if (uiValue & 0xff00)
{
uiValue >>= 8;
iNumBit += 8;
}
if (uiValue & 0xffff0000) {
uiValue >>= 16;
iNumBit += 16;
}
if (uiValue & 0xff00) {
uiValue >>= 8;
iNumBit += 8;
}
if (uiValue & 0xf0)
{
uiValue >>= 4;
iNumBit += 4;
}
iNumBit += g_kuiPrefix8BitsTable[uiValue];
if (uiValue & 0xf0) {
uiValue >>= 4;
iNumBit += 4;
}
iNumBit += g_kuiPrefix8BitsTable[uiValue];
return (32-iNumBit);
return (32 - iNumBit);
}
/*
* Read one bit from bit stream followed
*/
static inline uint32_t BsGetOneBit(PBitStringAux pBs)
{
return ( BsGetBits(pBs, 1) );
static inline uint32_t BsGetOneBit (PBitStringAux pBs) {
return (BsGetBits (pBs, 1));
}
static inline int32_t GetLeadingZeroBits( uint32_t iCurBits ) //<=16 bits
{
int32_t iValue;
static inline int32_t GetLeadingZeroBits (uint32_t iCurBits) { //<=16 bits
int32_t iValue;
iValue = UBITS( iCurBits, 8 );//ShowBits( bs, 8 );
if( iValue )
{
return g_kuiLeadingZeroTable[iValue];
}
iValue = UBITS( iCurBits, 16 );//ShowBits( bs, 16 );
if( iValue )
{
return (g_kuiLeadingZeroTable[iValue] + 8);
}
//ASSERT(FALSE); // should not go here
return -1;
iValue = UBITS (iCurBits, 8); //ShowBits( bs, 8 );
if (iValue) {
return g_kuiLeadingZeroTable[iValue];
}
static inline uint32_t BsGetUe( PBitStringAux pBs )
{
uint32_t iValue = 0;
int32_t iLeadingZeroBits = GetLeadingZeroBits( pBs->uiCurBits );
iValue = UBITS (iCurBits, 16); //ShowBits( bs, 16 );
if (iValue) {
return (g_kuiLeadingZeroTable[iValue] + 8);
}
if ( iLeadingZeroBits == -1 ) //bistream error
{
return 0xffffffff;//-1
}
DUMP_BITS( pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits + 1 );
//ASSERT(FALSE); // should not go here
return -1;
}
if( iLeadingZeroBits )
{
iValue = UBITS( pBs->uiCurBits, iLeadingZeroBits );
DUMP_BITS( pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits );
}
static inline uint32_t BsGetUe (PBitStringAux pBs) {
uint32_t iValue = 0;
int32_t iLeadingZeroBits = GetLeadingZeroBits (pBs->uiCurBits);
return ((1<<iLeadingZeroBits) - 1 + iValue);
if (iLeadingZeroBits == -1) { //bistream error
return 0xffffffff;//-1
}
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits + 1);
if (iLeadingZeroBits) {
iValue = UBITS (pBs->uiCurBits, iLeadingZeroBits);
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits);
}
return ((1 << iLeadingZeroBits) - 1 + iValue);
}
/*
* Read signed exp golomb codes
*/
static inline int32_t BsGetSe(PBitStringAux pBs)
{
uint32_t uiCodeNum;
uiCodeNum = BsGetUe( pBs );
static inline int32_t BsGetSe (PBitStringAux pBs) {
uint32_t uiCodeNum;
if(uiCodeNum&0x01)
{
return (int32_t)((uiCodeNum+1)>>1);
}
else
{
return NEG_NUM( (int32_t)(uiCodeNum>>1) );
}
uiCodeNum = BsGetUe (pBs);
if (uiCodeNum & 0x01) {
return (int32_t) ((uiCodeNum + 1) >> 1);
} else {
return NEG_NUM ((int32_t) (uiCodeNum >> 1));
}
}
/*
* Read truncated exp golomb codes
*/
static inline uint32_t BsGetTe(PBitStringAux pBs, uint8_t uiRange)
{
if ( 1 == uiRange )
{
return BsGetOneBit(pBs)^1;
}
else
{
return BsGetUe(pBs);
}
static inline uint32_t BsGetTe (PBitStringAux pBs, uint8_t uiRange) {
if (1 == uiRange) {
return BsGetOneBit (pBs) ^ 1;
} else {
return BsGetUe (pBs);
}
}
/*
* Get unsigned truncated exp golomb code.
*/
static inline int32_t BsGetTe0(PBitStringAux pBs, int32_t iRange)
{
if(iRange==1)
return 0;
else if(iRange==2)
return BsGetOneBit(pBs)^1;
else
return BsGetUe(pBs);
static inline int32_t BsGetTe0 (PBitStringAux pBs, int32_t iRange) {
if (iRange == 1)
return 0;
else if (iRange == 2)
return BsGetOneBit (pBs) ^ 1;
else
return BsGetUe (pBs);
}
/*
* Get number of trailing bits
*/
static inline int32_t BsGetTrailingBits( uint8_t *pBuf )
{
// TODO
uint32_t uiValue = *pBuf;
int32_t iRetNum = 1;
do
{
if (uiValue&1)
return iRetNum;
uiValue >>= 1;
++ iRetNum;
} while(iRetNum < 9);
return 0;
static inline int32_t BsGetTrailingBits (uint8_t* pBuf) {
// TODO
uint32_t uiValue = *pBuf;
int32_t iRetNum = 1;
do {
if (uiValue & 1)
return iRetNum;
uiValue >>= 1;
++ iRetNum;
} while (iRetNum < 9);
return 0;
}
} // namespace WelsDec

View File

@ -38,23 +38,23 @@
namespace WelsDec {
void_t InitDctClipTable(void_t);
void_t InitDctClipTable (void_t);
void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs);
void_t IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#if defined(X86_ASM)
void_t IdctResAddPred_mmx(uint8_t *pPred, const int32_t kiStride, int16_t *pRs);
void_t IdctResAddPred_mmx (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
#endif//X86_ASM
#if defined(__cplusplus)
}
#endif//__cplusplus
void_t GetI4LumaIChromaAddrTable(int32_t *pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride);
void_t GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride);
} // namespace WelsDec

View File

@ -37,32 +37,32 @@
namespace WelsDec {
void_t WelsBlockInit(int16_t* pBlock, int32_t iWidth, int32_t iHeight, int32_t iStride, uint8_t uiVal);
void_t WelsBlockInit (int16_t* pBlock, int32_t iWidth, int32_t iHeight, int32_t iStride, uint8_t uiVal);
int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx);
int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur);
int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx);
int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur);
int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx);
int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur);
int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx);
int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur);
typedef int32_t (*PWelsDecMbCavlcFunc) (PWelsDecoderContext pCtx, PNalUnit pNalCur);
int32_t WelsTargetSliceConstruction(PWelsDecoderContext pCtx); //construction based on slice
int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx); //construction based on slice
int32_t WelsDecodeSlice(PWelsDecoderContext pCtx, bool_t bFirstSliceInLayer, PNalUnit pNalCur);
int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool_t bFirstSliceInLayer, PNalUnit pNalCur);
int32_t WelsTargetMbConstruction(PWelsDecoderContext pCtx);
int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx);
int32_t WelsMbIntraPredictionConstruction(PWelsDecoderContext pCtx, PDqLayer pCurLayer, bool_t bOutput);
int32_t WelsMbInterSampleConstruction( PWelsDecoderContext pCtx, PDqLayer pCurLayer,
uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC );
int32_t WelsMbInterConstruction(PWelsDecoderContext pCtx, PDqLayer pCurLayer);
void_t WelsLumaDcDequantIdct(int16_t *pBlock, int32_t iQp);
int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
void_t WelsMbCopy( uint8_t *pDst, int32_t iStrideDst, uint8_t *pSrc, int32_t iStrideSrc,
int32_t iHeight, int32_t iWidth );
int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, bool_t bOutput);
int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer,
uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC);
int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
void_t WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp);
int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
void_t WelsMbCopy (uint8_t* pDst, int32_t iStrideDst, uint8_t* pSrc, int32_t iStrideSrc,
int32_t iHeight, int32_t iWidth);
void_t WelsChromaDcIdct( int16_t *pBlock );
void_t WelsChromaDcIdct (int16_t* pBlock);
#ifdef __cplusplus
extern "C" {
@ -70,18 +70,18 @@ extern "C" {
#ifdef X86_ASM
void_t WelsResBlockZero16x16_sse2 (int16_t* pBlock, int32_t iStride);
void_t WelsResBlockZero8x8_sse2 (int16_t* pBlock, int32_t iStride);
void_t WelsResBlockZero8x8_sse2 (int16_t* pBlock, int32_t iStride);
#endif
#ifdef __cplusplus
}
#endif//__cplusplus
void_t WelsBlockZero16x16_c(int16_t * pBlock, int32_t iStride);
void_t WelsBlockZero8x8_c (int16_t * pBlock, int32_t iStride);
void_t SetNonZeroCount_c (int16_t * pBlock, int8_t * pNonZeroCount);
void_t WelsBlockZero16x16_c (int16_t* pBlock, int32_t iStride);
void_t WelsBlockZero8x8_c (int16_t* pBlock, int32_t iStride);
void_t SetNonZeroCount_c (int16_t* pBlock, int8_t* pNonZeroCount);
void_t WelsBlockFuncInit(SBlockFunc *pFunc, int32_t iCpu);
void_t WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu);
} // namespace WelsDec

View File

@ -50,15 +50,15 @@ extern "C" {
#endif//__cplusplus
/*!
* \brief configure decoder parameters
* \brief configure decoder parameters
*/
int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam );
int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const void_t* kpParam);
/*!
/*!
*************************************************************************************
* \brief Initialize Wels decoder parameters and memory
*
* \param pCtx input context to be initialized at first stage
* \param pCtx input context to be initialized at first stage
* \param pTraceHandle handle for trace
* \param pLo log info pointer
*
@ -68,22 +68,22 @@ int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam );
* \note N/A
*************************************************************************************
*/
int32_t WelsInitDecoder( PWelsDecoderContext pCtx, void_t * pTraceHandle, PWelsLogCallbackFunc pLog );
int32_t WelsInitDecoder (PWelsDecoderContext pCtx, void_t* pTraceHandle, PWelsLogCallbackFunc pLog);
/*!
/*!
*************************************************************************************
* \brief Uninitialize Wels decoder parameters and memory
*
* \param pCtx input context to be uninitialized at release stage
* \param pCtx input context to be uninitialized at release stage
*
* \return NONE
*
* \note N/A
*************************************************************************************
*/
void_t WelsEndDecoder( PWelsDecoderContext pCtx );
void_t WelsEndDecoder (PWelsDecoderContext pCtx);
/*!
/*!
*************************************************************************************
* \brief First entrance to decoding core interface.
*
@ -100,24 +100,24 @@ void_t WelsEndDecoder( PWelsDecoderContext pCtx );
*************************************************************************************
*/
int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const int32_t kiBsLen,
uint8_t **ppDst, SBufferInfo* pDstBufInfo);
int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen,
uint8_t** ppDst, SBufferInfo* pDstBufInfo);
/*
* request memory blocks for decoder avc part
*/
int32_t WelsRequestMem( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight );
int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight);
/*
* free memory blocks in avc
*/
void_t WelsFreeMem( PWelsDecoderContext pCtx );
void_t WelsFreeMem (PWelsDecoderContext pCtx);
/*
* set colorspace format in decoder
*/
int32_t DecoderSetCsp(PWelsDecoderContext pCtx, const int32_t kiColorFormat);
int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat);
/*!
* \brief make sure synchonozization picture resolution (get from slice header) among different parts (i.e, memory related and so on)
@ -125,22 +125,22 @@ int32_t DecoderSetCsp(PWelsDecoderContext pCtx, const int32_t kiColorFormat);
* ( MB coordinate and parts of data within decoder context structure )
* \param pCtx Wels decoder context
* \param iMbWidth MB width
* \pram iMbHeight MB height
* \pram iMbHeight MB height
* \return 0 - successful; none 0 - something wrong
*/
int32_t SyncPictureResolutionExt( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight );
int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight);
/*!
* \brief update maximal picture width and height if applicable when receiving a SPS NAL
*/
void_t UpdateMaxPictureResolution( PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight );
void_t UpdateMaxPictureResolution (PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight);
void_t AssignFuncPointerForRec( PWelsDecoderContext pCtx );
void_t AssignFuncPointerForRec (PWelsDecoderContext pCtx);
void_t ResetParameterSetsState( PWelsDecoderContext pCtx );
void_t ResetParameterSetsState (PWelsDecoderContext pCtx);
void_t GetVclNalTemporalId( PWelsDecoderContext pCtx );//get the info that whether or not have VCL NAL in current AU,
//and if YES, get the temporal ID
void_t GetVclNalTemporalId (PWelsDecoderContext pCtx); //get the info that whether or not have VCL NAL in current AU,
//and if YES, get the temporal ID
#ifdef __cplusplus
}

View File

@ -60,14 +60,13 @@ namespace WelsDec {
//#define MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
typedef struct TagDataBuffer
{
uint8_t* pHead;
uint8_t* pEnd;
typedef struct TagDataBuffer {
uint8_t* pHead;
uint8_t* pEnd;
uint8_t* pStartPos;
uint8_t* pCurPos;
}SDataBuffer;
uint8_t* pStartPos;
uint8_t* pCurPos;
} SDataBuffer;
//#ifdef __cplusplus
//extern "C" {
@ -76,258 +75,266 @@ typedef struct TagDataBuffer
//#pragma pack(1)
/*
* Need move below structures to function pointer to seperate module/file later
* Need move below structures to function pointer to seperate module/file later
*/
//typedef int32_t (*rec_mb) (Mb *cur_mb, PWelsDecoderContext pCtx);
/*typedef for get intra predictor func pointer*/
typedef void_t (*PGetIntraPredFunc)(uint8_t *pPred, const int32_t kiLumaStride);
typedef void_t (*PIdctResAddPredFunc)(uint8_t *pPred, const int32_t kiStride, int16_t *pRs);
typedef void_t (*PExpandPictureFunc)( uint8_t *pDst, const int32_t kiStride, const int32_t kiPicWidth, const int32_t kiPicHeight );
typedef void_t (*PGetIntraPredFunc) (uint8_t* pPred, const int32_t kiLumaStride);
typedef void_t (*PIdctResAddPredFunc) (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
typedef void_t (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
const int32_t kiPicHeight);
/**/
typedef struct TagRefPic {
PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT];
PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT];
uint8_t uiRefCount[LIST_A];
uint8_t uiShortRefCount[LIST_A];
uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module
int32_t iMaxLongTermFrameIdx;
PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT];
PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT];
uint8_t uiRefCount[LIST_A];
uint8_t uiShortRefCount[LIST_A];
uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module
int32_t iMaxLongTermFrameIdx;
} SRefPic, *PRefPic;
typedef void_t (*PWelsMcFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
typedef struct TagMcFunc{
PWelsMcFunc pMcLumaFunc;
PWelsMcFunc pMcChromaFunc;
}SMcFunc;
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
typedef struct TagMcFunc {
PWelsMcFunc pMcLumaFunc;
PWelsMcFunc pMcChromaFunc;
} SMcFunc;
//deblock module defination
struct TagDeblockingFunc;
typedef struct tagDeblockingFilter {
uint8_t *pCsData[3]; // pointer to reconstructed picture data
int32_t iCsStride[2]; // Cs stride
ESliceType eSliceType;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
int8_t iChromaQP;
int8_t iLumaQP;
struct TagDeblockingFunc *pLoopf;
}SDeblockingFilter, *PDeblockingFilter;
uint8_t* pCsData[3]; // pointer to reconstructed picture data
int32_t iCsStride[2]; // Cs stride
ESliceType eSliceType;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
int8_t iChromaQP;
int8_t iLumaQP;
struct TagDeblockingFunc* pLoopf;
} SDeblockingFilter, *PDeblockingFilter;
typedef void_t (*PDeblockingFilterMbFunc)( PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag );
typedef void_t (*PLumaDeblockingLT4Func)( uint8_t *iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc );
typedef void_t (*PLumaDeblockingEQ4Func)( uint8_t *iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
typedef void_t (*PChromaDeblockingLT4Func)( uint8_t *iSampleCb, uint8_t *iSampleCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc );
typedef void_t (*PChromaDeblockingEQ4Func)( uint8_t *iSampleCb, uint8_t *iSampleCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
typedef void_t (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag);
typedef void_t (*PLumaDeblockingLT4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* iTc);
typedef void_t (*PLumaDeblockingEQ4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
typedef void_t (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
int32_t iBeta, int8_t* iTc);
typedef void_t (*PChromaDeblockingEQ4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
int32_t iBeta);
typedef struct TagDeblockingFunc {
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Ver;
PLumaDeblockingLT4Func pfLumaDeblockingLT4Hor;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Hor;
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Ver;
PLumaDeblockingLT4Func pfLumaDeblockingLT4Hor;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Hor;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Ver;
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Ver;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Hor;
PChromaDeblockingEQ4Func pfChromaDeblockinEQ4Hor;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Ver;
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Ver;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Hor;
PChromaDeblockingEQ4Func pfChromaDeblockinEQ4Hor;
} SDeblockingFunc, *PDeblockingFunc;
typedef void_t (*PWelsBlockAddStrideFunc)(uint8_t *pDest, uint8_t *pPred, int16_t *pRes, int32_t iPredStride, int32_t iResStride);
typedef void_t (*PWelsBlockAddStrideFunc) (uint8_t* pDest, uint8_t* pPred, int16_t* pRes, int32_t iPredStride,
int32_t iResStride);
typedef void_t (*PWelsBlockZeroFunc) (int16_t* pBlock, int32_t iStride);
typedef void_t (*PWelsNonZeroCountFunc) (int16_t *pBlock, int8_t *pNonZeroCount);
typedef void_t (*PWelsSimpleIdct4x4AddFunc) (int16_t *pDest, int16_t *pSrc, int32_t iStride);
typedef void_t (*PWelsNonZeroCountFunc) (int16_t* pBlock, int8_t* pNonZeroCount);
typedef void_t (*PWelsSimpleIdct4x4AddFunc) (int16_t* pDest, int16_t* pSrc, int32_t iStride);
typedef struct TagBlockFunc {
PWelsBlockZeroFunc pWelsBlockZero16x16Func;
PWelsBlockZeroFunc pWelsBlockZero8x8Func;
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
PWelsBlockZeroFunc pWelsBlockZero16x16Func;
PWelsBlockZeroFunc pWelsBlockZero8x8Func;
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
} SBlockFunc;
typedef void_t ( *PWelsFillNeighborMbInfoIntra4x4Func )( PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, PDqLayer pCurLayer );
typedef int32_t (*PWelsParseIntra4x4ModeFunc) ( PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, PDqLayer pCurDqLayer);
typedef int32_t (*PWelsParseIntra16x16ModeFunc) ( PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
typedef void_t (*PWelsFillNeighborMbInfoIntra4x4Func) (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int8_t* pIntraPredMode, PDqLayer pCurLayer);
typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
PDqLayer pCurDqLayer);
typedef int32_t (*PWelsParseIntra16x16ModeFunc) (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
typedef struct TagExpandPicFunc{
PExpandPictureFunc pExpandLumaPicture;
PExpandPictureFunc pExpandChromaPicture[2];
}SExpandPicFunc;
typedef struct TagExpandPicFunc {
PExpandPictureFunc pExpandLumaPicture;
PExpandPictureFunc pExpandChromaPicture[2];
} SExpandPicFunc;
/*
* SWelsDecoderContext: to maintail all modules data over decoder@framework
*/
typedef struct TagWelsDecoderContext {
// Input
void_t *pArgDec; // structured arguments for decoder, reserved here for extension in the future
typedef struct TagWelsDecoderContext {
// Input
void_t* pArgDec; // structured arguments for decoder, reserved here for extension in the future
SDataBuffer sRawData;
SDataBuffer sRawData;
// Configuration
SDecodingParam *pParam;
uint32_t uiCpuFlag; // CPU compatibility detected
int32_t iDecoderMode; // indicate decoder running mode
int32_t iSetMode; // indicate decoder mode set from upper layer, this is read-only for decoder internal
int32_t iDecoderOutputProperty; // indicate the output buffer property
int32_t iModeSwitchType; // 1: optimal decision; 2: forced switch to the other mode; 0: no switch
int32_t iOutputColorFormat; // color space format to be outputed
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
bool_t bErrorResilienceFlag; // error resilience flag
bool_t bHaveGotMemory; // global memory for decoder context related ever requested?
int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output
int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output
int32_t iMaxWidthInSps; // maximal width of pixel in SPS sets
int32_t iMaxHeightInSps; // maximal height of pixel in SPS sets
// Configuration
SDecodingParam* pParam;
uint32_t uiCpuFlag; // CPU compatibility detected
int32_t iDecoderMode; // indicate decoder running mode
int32_t iSetMode; // indicate decoder mode set from upper layer, this is read-only for decoder internal
int32_t iDecoderOutputProperty; // indicate the output buffer property
int32_t iModeSwitchType; // 1: optimal decision; 2: forced switch to the other mode; 0: no switch
// Derived common elements
SNalUnitHeader sCurNalHead;
ESliceType eSliceType; // Slice type
int32_t iFrameNum;
int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
bool_t bLastHasMmco5; //
int32_t iErrorCode; // error code return while decoding in case packets lost
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
PFmo pFmo; // current fmo context after parsed slice_header
int32_t iActiveFmoNum; // active count number of fmo context in list
int32_t iOutputColorFormat; // color space format to be outputed
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
bool_t bErrorResilienceFlag; // error resilience flag
bool_t bHaveGotMemory; // global memory for decoder context related ever requested?
/*needed info by decode slice level and mb level*/
int32_t iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output
int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output
int32_t iMaxWidthInSps; // maximal width of pixel in SPS sets
int32_t iMaxHeightInSps; // maximal height of pixel in SPS sets
struct
{
int8_t *pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
int8_t *pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
int8_t *pChromaQp[LAYER_NUM_EXCHANGEABLE]; /*mb chroma_qp*/
int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
int8_t *pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
int8_t *pCbp[LAYER_NUM_EXCHANGEABLE];
uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE];
int32_t *pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc
int8_t *pResidualPredFlag[LAYER_NUM_EXCHANGEABLE];
int8_t *pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE];
int16_t iMbWidth;
int16_t iMbHeight;
}sMb;
// Derived common elements
SNalUnitHeader sCurNalHead;
ESliceType eSliceType; // Slice type
int32_t iFrameNum;
int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
bool_t bLastHasMmco5; //
int32_t iErrorCode; // error code return while decoding in case packets lost
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
PFmo pFmo; // current fmo context after parsed slice_header
int32_t iActiveFmoNum; // active count number of fmo context in list
/*needed info by decode slice level and mb level*/
int32_t
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
struct {
int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
int8_t* pChromaQp[LAYER_NUM_EXCHANGEABLE]; /*mb chroma_qp*/
int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
int8_t* pCbp[LAYER_NUM_EXCHANGEABLE];
uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE];
int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc
int8_t* pResidualPredFlag[LAYER_NUM_EXCHANGEABLE];
int8_t* pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE];
int16_t iMbWidth;
int16_t iMbHeight;
} sMb;
// reconstruction picture
PPicture pDec; //pointer to current picture being reconstructed
// reconstruction picture
PPicture pDec; //pointer to current picture being reconstructed
// reference pictures
SRefPic sRefPic;
// reference pictures
SRefPic sRefPic;
SVlcTable sVlcTable; // vlc table
SBitStringAux sBs;
SVlcTable sVlcTable; // vlc table
/* Global memory external */
SBitStringAux sBs;
SPosOffset sFrameCrop;
/* Global memory external */
SPosOffset sFrameCrop;
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
int32_t iSpsTotalNum; //the number of SPS in current IDR interval
int32_t iSubspsTotalNum; //the number of subsps in current IDR interval
int32_t iPpsTotalNum; //the number of PPS in current IDR interval.
int32_t iSpsTotalNum; //the number of SPS in current IDR interval
int32_t iSubspsTotalNum; //the number of subsps in current IDR interval
int32_t iPpsTotalNum; //the number of PPS in current IDR interval.
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
SSps sSpsBuffer[MAX_SPS_COUNT];
SPps sPpsBuffer[MAX_PPS_COUNT];
PSliceHeader pSliceHeader;
SSps sSpsBuffer[MAX_SPS_COUNT];
SPps sPpsBuffer[MAX_PPS_COUNT];
PSliceHeader pSliceHeader;
PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding.
int32_t iPicQueueNumber;
SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT];
SNalUnit sPrefixNal;
PAccessUnit pAccessUnitList; // current access unit list to be performed
PSps pSps; // used by current AU
PPps pPps; // used by current AU
// Memory for pAccessUnitList is dynamically held till decoder destruction.
PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
uint8_t *pCsListXchg[LAYER_NUM_EXCHANGEABLE][3]; // Constructed picture buffer: 0- cur layer, 1- ref layer;
int16_t *pRsListXchg[LAYER_NUM_EXCHANGEABLE][3];// Residual picture buffer: 0- cur layer, 1- ref layer;
PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding.
int32_t iPicQueueNumber;
int32_t iCsStride[3]; // strides for Cs
int32_t iRsStride[3]; // strides for Rs
SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT];
SNalUnit sPrefixNal;
int32_t iPicWidthReq; // picture width have requested the memory
int32_t iPicHeightReq; // picture height have requested the memory
PAccessUnit pAccessUnitList; // current access unit list to be performed
PSps pSps; // used by current AU
PPps pPps; // used by current AU
// Memory for pAccessUnitList is dynamically held till decoder destruction.
PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
uint8_t* pCsListXchg[LAYER_NUM_EXCHANGEABLE][3]; // Constructed picture buffer: 0- cur layer, 1- ref layer;
int16_t* pRsListXchg[LAYER_NUM_EXCHANGEABLE][3];// Residual picture buffer: 0- cur layer, 1- ref layer;
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
bool_t bAvcBasedFlag; // For decoding bitstream:
bool_t bEndOfStreamFlag; // Flag on end of stream requested by external application layer
bool_t bInitialDqLayersMem; // dq layers related memory is available?
int32_t iCsStride[3]; // strides for Cs
int32_t iRsStride[3]; // strides for Rs
bool_t bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
// for EC parameter sets
bool_t bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
bool_t bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
bool_t bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
int32_t iPicWidthReq; // picture width have requested the memory
int32_t iPicHeightReq; // picture height have requested the memory
bool_t bSpsAvailFlags[MAX_SPS_COUNT];
bool_t bSubspsAvailFlags[MAX_SPS_COUNT];
bool_t bPpsAvailFlags[MAX_PPS_COUNT];
bool_t bReferenceLostAtT0Flag;
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
bool_t bAvcBasedFlag; // For decoding bitstream:
bool_t bEndOfStreamFlag; // Flag on end of stream requested by external application layer
bool_t bInitialDqLayersMem; // dq layers related memory is available?
bool_t bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
// for EC parameter sets
bool_t bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
bool_t bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
bool_t bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
bool_t bSpsAvailFlags[MAX_SPS_COUNT];
bool_t bSubspsAvailFlags[MAX_SPS_COUNT];
bool_t bPpsAvailFlags[MAX_PPS_COUNT];
bool_t bReferenceLostAtT0Flag;
#ifdef LONG_TERM_REF
bool_t bParamSetsLostFlag; //sps or pps do not exist or not correct
bool_t bParamSetsLostFlag; //sps or pps do not exist or not correct
bool_t bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
bool_t
bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
uint16_t uiCurIdrPicId;
uint16_t uiCurIdrPicId;
#endif
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
PIdctResAddPredFunc pIdctResAddPredFunc;
SMcFunc sMcFunc;
/* For Deblocking */
SDeblockingFunc sDeblockingFunc;
SExpandPicFunc sExpandPicFunc;
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
PIdctResAddPredFunc pIdctResAddPredFunc;
SMcFunc sMcFunc;
/* For Deblocking */
SDeblockingFunc sDeblockingFunc;
SExpandPicFunc sExpandPicFunc;
/* For Block */
SBlockFunc sBlockFunc;
/* For EC */
int32_t iCurSeqIntervalTargetDependId;
int32_t iCurSeqIntervalMaxPicWidth;
int32_t iCurSeqIntervalMaxPicHeight;
PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
PWelsParseIntra4x4ModeFunc pParseIntra4x4ModeFunc;
PWelsParseIntra16x16ModeFunc pParseIntra16x16ModeFunc;
/* For Block */
SBlockFunc sBlockFunc;
/* For EC */
int32_t iCurSeqIntervalTargetDependId;
int32_t iCurSeqIntervalMaxPicWidth;
int32_t iCurSeqIntervalMaxPicHeight;
//feedback whether or not have VCL in current AU, and the temporal ID
int32_t iFeedbackVclNalInAu;
int32_t iFeedbackTidInAu;
PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
PWelsParseIntra4x4ModeFunc pParseIntra4x4ModeFunc;
PWelsParseIntra16x16ModeFunc pParseIntra16x16ModeFunc;
//feedback whether or not have VCL in current AU, and the temporal ID
int32_t iFeedbackVclNalInAu;
int32_t iFeedbackTidInAu;
bool_t bAuReadyFlag; // TRUE: one au is ready for decoding; FALSE: default value
//trace handle
void_t* pTraceHandle;
bool_t bAuReadyFlag; // TRUE: one au is ready for decoding; FALSE: default value
//trace handle
void_t * pTraceHandle;
#ifdef NO_WAITING_AU
//Save the last nal header info
SNalUnitHeaderExt sLastNalHdrExt;
SSliceHeader sLastSliceHeader;
//Save the last nal header info
SNalUnitHeaderExt sLastNalHdrExt;
SSliceHeader sLastSliceHeader;
#endif
}SWelsDecoderContext, *PWelsDecoderContext;
} SWelsDecoderContext, *PWelsDecoderContext;
//#pragma pack()

View File

@ -32,7 +32,7 @@
* decoder_core.h
*
* Abstract
* Encapsulative core interfaces
* Encapsulative core interfaces
*
* History
* 07/10/2008 Created
@ -57,24 +57,24 @@ namespace WelsDec {
* return:
* 0 - success; otherwise returned error_no defined in error_no.h.
*/
int32_t WelsInitMemory( PWelsDecoderContext pCtx );
int32_t WelsInitMemory (PWelsDecoderContext pCtx);
/*
* WelsFreeMemory
* Free memory introduced in WelsInitMemory at destruction of decoder.
*
*
*/
void_t WelsFreeMemory( PWelsDecoderContext pCtx );
void_t WelsFreeMemory (PWelsDecoderContext pCtx);
/*!
* \brief request memory when maximal picture width and height are available
* \brief request memory when maximal picture width and height are available
*/
int32_t InitialDqLayersContext ( PWelsDecoderContext pCtx, const int32_t kiMaxWidth, const int32_t kiMaxHeight );
int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWidth, const int32_t kiMaxHeight);
/*!
* \brief free dq layer context memory related
* \brief free dq layer context memory related
*/
void_t UninitialDqLayersContext ( PWelsDecoderContext pCtx );
void_t UninitialDqLayersContext (PWelsDecoderContext pCtx);
/*
* DecodeNalHeaderExt
@ -83,19 +83,19 @@ void_t UninitialDqLayersContext ( PWelsDecoderContext pCtx );
* pNal: target NALUnit ptr
* pSrc: NAL Unit bitstream
*/
void_t DecodeNalHeaderExt( PNalUnit pNal, uint8_t* pSrc );
void_t DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc);
/*
* ParseSliceHeaderSyntaxs
* Parse slice header of bitstream
*/
int32_t ParseSliceHeaderSyntaxs ( PWelsDecoderContext pCtx, PBitStringAux pBs, const bool_t kbExtensionFlag );
int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool_t kbExtensionFlag);
/*
* Copy relative syntax elements of NALUnitHeaderExt, sRefPicBaseMarking and bStoreRefBasePicFlag in prefix nal unit.
* pSrc: mark as decoded prefix NAL
* pDst: succeeded VCL NAL based AVC (I/P Slice)
*/
bool_t PrefetchNalHeaderExtSyntax ( PWelsDecoderContext pCtx, PNalUnit const kpDst, PNalUnit const kpSrc);
bool_t PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kpDst, PNalUnit const kpSrc);
/*
@ -110,26 +110,27 @@ bool_t PrefetchNalHeaderExtSyntax ( PWelsDecoderContext pCtx, PNalUnit const kpD
* return:
* 0 - success; otherwise returned error_no defined in error_no.h
*/
int32_t ConstructAccessUnit( PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo *pDstInfo);
int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo);
/*
* DecodeCurrentAccessUnit
* Decode current access unit when current AU is completed.
*/
int32_t DecodeCurrentAccessUnit( PWelsDecoderContext pCtx, uint8_t **ppDst, int32_t *iDstLen, int32_t *pWidth, int32_t *pHeight, SBufferInfo *pDstInfo );
int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* iDstLen, int32_t* pWidth,
int32_t* pHeight, SBufferInfo* pDstInfo);
/*
* Prepare current dq layer context initialization.
*/
void_t WelsDqLayerDecodeStart ( PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pSps, PPps pPps );
void_t WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pSps, PPps pPps);
int32_t WelsDecodeAccessUnitStart ( PWelsDecoderContext pCtx );
void_t WelsDecodeAccessUnitEnd ( PWelsDecoderContext pCtx );
int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx);
void_t WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx);
void_t ForceResetCurrentAccessUnit( PAccessUnit pAu );
void_t ForceClearCurrentNal( PAccessUnit pAu );
void_t ForceResetCurrentAccessUnit (PAccessUnit pAu);
void_t ForceClearCurrentNal (PAccessUnit pAu);
} // namespace WelsDec

View File

@ -42,15 +42,14 @@
namespace WelsDec {
typedef enum TagWelsErr
{
ERR_NONE = 0,
ERR_INVALID_PARAMETERS = 1,
ERR_MALLOC_FAILED = 2,
ERR_API_FAILED = 3,
ERR_BOUND = 31,
}EWelsErr;
typedef enum TagWelsErr {
ERR_NONE = 0,
ERR_INVALID_PARAMETERS = 1,
ERR_MALLOC_FAILED = 2,
ERR_API_FAILED = 3,
ERR_BOUND = 31,
} EWelsErr;
/*
* Specified error format:
@ -62,14 +61,14 @@ typedef enum TagWelsErr
/* ERR_LEVEL */
//-----------------------------------------------------------------------------------------------------------
enum{
ERR_LEVEL_ACCESS_UNIT = 1,
ERR_LEVEL_NAL_UNIT_HEADER,
ERR_LEVEL_PREFIX_NAL,
ERR_LEVEL_PARAM_SETS,
ERR_LEVEL_SLICE_HEADER,
ERR_LEVEL_SLICE_DATA,
ERR_LEVEL_MB_DATA,
enum {
ERR_LEVEL_ACCESS_UNIT = 1,
ERR_LEVEL_NAL_UNIT_HEADER,
ERR_LEVEL_PREFIX_NAL,
ERR_LEVEL_PARAM_SETS,
ERR_LEVEL_SLICE_HEADER,
ERR_LEVEL_SLICE_DATA,
ERR_LEVEL_MB_DATA,
};
//-----------------------------------------------------------------------------------------------------------
@ -79,88 +78,88 @@ enum{
#define ERR_INFO_COMMON_BASE 1
#define ERR_INFO_SYNTAX_BASE 1001
#define ERR_INFO_LOGIC_BASE 10001
enum{
/* Error from common system level: 1-1000 */
ERR_INFO_OUT_OF_MEMORY = ERR_INFO_COMMON_BASE,
ERR_INFO_INVALID_ACCESS,
ERR_INFO_INVALID_PTR,
ERR_INFO_INVALID_PARAM,
ERR_INFO_FILE_NO_FOUND,
ERR_INFO_PATH_NO_FOUND,
ERR_INFO_ACCESS_DENIED,
ERR_INFO_NOT_READY,
ERR_INFO_WRITE_FAULT,
ERR_INFO_READ_FAULT,
/* Error from H.264 syntax elements parser: 1001-10000 */
ERR_INFO_NO_PREFIX_CODE = ERR_INFO_SYNTAX_BASE, // No start prefix code indication
ERR_INFO_NO_PARAM_SETS, // No SPS and/ PPS before sequence header
ERR_INFO_PARAM_SETS_NOT_INTEGRATED, // Parameters sets (sps/pps) are not integrated at all before to decode VCL nal
ERR_INFO_SPS_ID_OVERFLOW,
ERR_INFO_PPS_ID_OVERFLOW,
ERR_INFO_INVALID_PROFILE_IDC,
ERR_INFO_UNMATCHED_LEVEL_IDC,
ERR_INFO_INVALID_POC_TYPE,
ERR_INFO_REF_COUNT_OVERFLOW,
ERR_INFO_CROPPING_NO_SUPPORTED,
ERR_INFO_INVALID_SLICEGROUP,
ERR_INFO_INVALID_SLICEGROUP_MAP_TYPE,
ERR_INFO_INVALID_FRAME_NUM,
ERR_INFO_FMO_INIT_FAIL,
ERR_INFO_SLICE_TYPE_OVERFLOW,
ERR_INFO_INVALID_QP,
ERR_INFO_INVALID_DBLOCKING_IDC,
ERR_INFO_INVALID_MB_TYPE,
ERR_INFO_INVALID_SUB_MB_TYPE,
ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA,
ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA,
ERR_INFO_INVALID_REF_INDEX,
ERR_INFO_INVALID_CBP,
ERR_INFO_DQUANT_OUT_OF_RANGE,
ERR_INFO_CAVLC_INVALID_PREFIX,
ERR_INFO_CAVLC_INVALID_TOTAL_COEFF,
ERR_INFO_CAVLC_INVALID_ZERO_LEFT,
ERR_INFO_MV_OUT_OF_RANGE,
enum {
/* Error from common system level: 1-1000 */
ERR_INFO_OUT_OF_MEMORY = ERR_INFO_COMMON_BASE,
ERR_INFO_INVALID_ACCESS,
ERR_INFO_INVALID_PTR,
ERR_INFO_INVALID_PARAM,
ERR_INFO_FILE_NO_FOUND,
ERR_INFO_PATH_NO_FOUND,
ERR_INFO_ACCESS_DENIED,
ERR_INFO_NOT_READY,
ERR_INFO_WRITE_FAULT,
ERR_INFO_READ_FAULT,
/* Error from H.264 syntax elements parser: 1001-10000 */
ERR_INFO_NO_PREFIX_CODE = ERR_INFO_SYNTAX_BASE, // No start prefix code indication
ERR_INFO_NO_PARAM_SETS, // No SPS and/ PPS before sequence header
ERR_INFO_PARAM_SETS_NOT_INTEGRATED, // Parameters sets (sps/pps) are not integrated at all before to decode VCL nal
ERR_INFO_SPS_ID_OVERFLOW,
ERR_INFO_PPS_ID_OVERFLOW,
ERR_INFO_INVALID_PROFILE_IDC,
ERR_INFO_UNMATCHED_LEVEL_IDC,
ERR_INFO_INVALID_POC_TYPE,
ERR_INFO_REF_COUNT_OVERFLOW,
ERR_INFO_CROPPING_NO_SUPPORTED,
ERR_INFO_INVALID_SLICEGROUP,
ERR_INFO_INVALID_SLICEGROUP_MAP_TYPE,
ERR_INFO_INVALID_FRAME_NUM,
ERR_INFO_FMO_INIT_FAIL,
ERR_INFO_SLICE_TYPE_OVERFLOW,
ERR_INFO_INVALID_QP,
ERR_INFO_INVALID_DBLOCKING_IDC,
ERR_INFO_INVALID_MB_TYPE,
ERR_INFO_INVALID_SUB_MB_TYPE,
ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA,
ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA,
ERR_INFO_INVALID_REF_INDEX,
ERR_INFO_INVALID_CBP,
ERR_INFO_DQUANT_OUT_OF_RANGE,
ERR_INFO_CAVLC_INVALID_PREFIX,
ERR_INFO_CAVLC_INVALID_TOTAL_COEFF,
ERR_INFO_CAVLC_INVALID_ZERO_LEFT,
ERR_INFO_MV_OUT_OF_RANGE,
ERR_INFO_INVALID_I4x4_PRED_MODE,
ERR_INFO_INVALID_I16x16_PRED_MODE,
ERR_INFO_INVALID_I_CHROMA_PRED_MODE,
ERR_INFO_INVALID_I4x4_PRED_MODE,
ERR_INFO_INVALID_I16x16_PRED_MODE,
ERR_INFO_INVALID_I_CHROMA_PRED_MODE,
ERR_INFO_UNSUPPORTED_NON_BASELINE,
ERR_INFO_UNSUPPORTED_FMOTYPE,
ERR_INFO_UNSUPPORTED_MBAFF,
ERR_INFO_UNSUPPORTED_ILP,
ERR_INFO_UNSUPPORTED_CABAC_EL,
ERR_INFO_UNSUPPORTED_SPSI,
ERR_INFO_UNSUPPORTED_MGS,
ERR_INFO_UNSUPPORTED_BIPRED,
ERR_INFO_UNSUPPORTED_WP,
ERR_INFO_UNSUPPORTED_NON_BASELINE,
ERR_INFO_UNSUPPORTED_FMOTYPE,
ERR_INFO_UNSUPPORTED_MBAFF,
ERR_INFO_UNSUPPORTED_ILP,
ERR_INFO_UNSUPPORTED_CABAC_EL,
ERR_INFO_UNSUPPORTED_SPSI,
ERR_INFO_UNSUPPORTED_MGS,
ERR_INFO_UNSUPPORTED_BIPRED,
ERR_INFO_UNSUPPORTED_WP,
ERR_INFO_FRAMES_LOST,
ERR_INFO_DEPENDENCY_SPATIAL_LAYER_LOST,
ERR_INFO_DEPENDENCY_QUALIT_LAYER_LOST,
ERR_INFO_REFERENCE_PIC_LOST,
ERR_INFO_INVALID_REORDERING,
ERR_INFO_INVALID_MARKING,
ERR_INFO_FRAMES_LOST,
ERR_INFO_DEPENDENCY_SPATIAL_LAYER_LOST,
ERR_INFO_DEPENDENCY_QUALIT_LAYER_LOST,
ERR_INFO_REFERENCE_PIC_LOST,
ERR_INFO_INVALID_REORDERING,
ERR_INFO_INVALID_MARKING,
ERR_INFO_FMO_NOT_SUPPORTED_IN_BASE_LAYER,
ERR_INFO_INVALID_ESS,
ERR_INFO_INVALID_SLICE_TYPE,
ERR_INFO_INVALID_REF_MARKING,
ERR_INFO_INVALID_REF_REORDERING,
/* Error from corresponding logic, 10001-65535 */
ERR_INFO_NO_IDR_PIC = ERR_INFO_LOGIC_BASE, // NO IDR picture available before sequence header
ERR_INFO_EC_NO_NEIGHBOUR_MBS,
ERR_INFO_EC_UNEXPECTED_MB_TYPE,
ERR_INFO_EC_NO_ENOUGH_NEIGHBOUR_MBS,
//for LTR
ERR_INFO_INVALID_MMCO_OPCODE_BASE,
ERR_INFO_INVALID_MMCO_SHORT2UNUSED,
EER_INFO_INVALID_MMCO_LONG2UNUSED,
ERR_INFO_INVALID_MMCO_SHOART2LONG,
ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW,
ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH,
ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX,
ERR_INFO_FMO_NOT_SUPPORTED_IN_BASE_LAYER,
ERR_INFO_INVALID_ESS,
ERR_INFO_INVALID_SLICE_TYPE,
ERR_INFO_INVALID_REF_MARKING,
ERR_INFO_INVALID_REF_REORDERING,
/* Error from corresponding logic, 10001-65535 */
ERR_INFO_NO_IDR_PIC = ERR_INFO_LOGIC_BASE, // NO IDR picture available before sequence header
ERR_INFO_EC_NO_NEIGHBOUR_MBS,
ERR_INFO_EC_UNEXPECTED_MB_TYPE,
ERR_INFO_EC_NO_ENOUGH_NEIGHBOUR_MBS,
//for LTR
ERR_INFO_INVALID_MMCO_OPCODE_BASE,
ERR_INFO_INVALID_MMCO_SHORT2UNUSED,
EER_INFO_INVALID_MMCO_LONG2UNUSED,
ERR_INFO_INVALID_MMCO_SHOART2LONG,
ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW,
ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH,
ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX,
};
//-----------------------------------------------------------------------------------------------------------

View File

@ -45,25 +45,26 @@
namespace WelsDec {
void_t ExpandReferencingPicture(PPicture pPic, PExpandPictureFunc pExpandPictureLuma, PExpandPictureFunc pExpandPictureChroma[2]);
void_t ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpandPictureLuma,
PExpandPictureFunc pExpandPictureChroma[2]);
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#if defined(X86_ASM)
void_t ExpandPictureLuma_sse2( uint8_t *pDst,
const int32_t kiStride,
const int32_t kiPicWidth,
const int32_t kiPicHeight );
void_t ExpandPictureChromaAlign_sse2( uint8_t *pDst,
const int32_t kiStride,
const int32_t kiPicWidth,
const int32_t kiPicHeight );
void_t ExpandPictureChromaUnalign_sse2( uint8_t *pDst,
const int32_t kiStride,
const int32_t kiPicWidth,
const int32_t kiPicHeight );
void_t ExpandPictureLuma_sse2 (uint8_t* pDst,
const int32_t kiStride,
const int32_t kiPicWidth,
const int32_t kiPicHeight);
void_t ExpandPictureChromaAlign_sse2 (uint8_t* pDst,
const int32_t kiStride,
const int32_t kiPicWidth,
const int32_t kiPicHeight);
void_t ExpandPictureChromaUnalign_sse2 (uint8_t* pDst,
const int32_t kiStride,
const int32_t kiPicWidth,
const int32_t kiPicHeight);
#endif//X86_ASM
#if defined(__cplusplus)
@ -71,7 +72,7 @@ void_t ExpandPictureChromaUnalign_sse2( uint8_t *pDst,
#endif//__cplusplus
//
void_t InitExpandPictureFunc( SExpandPicFunc *pExpandPicFunc, const uint32_t kuiCpuFlags );
void_t InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCpuFlags);
} // namespace WelsDec

View File

@ -50,16 +50,16 @@ namespace WelsDec {
#define MB_XY_T int16_t
#endif//MB_XY_T
/*!
* \brief Wels Flexible Macroblock Ordering (FMO)
/*!
* \brief Wels Flexible Macroblock Ordering (FMO)
*/
typedef struct TagFmo{
uint8_t *pMbAllocMap;
int32_t iCountMbNum;
int32_t iSliceGroupCount;
int32_t iSliceGroupType;
bool_t bActiveFlag;
uint8_t uiReserved[3]; // reserved padding bytes
typedef struct TagFmo {
uint8_t* pMbAllocMap;
int32_t iCountMbNum;
int32_t iSliceGroupCount;
int32_t iSliceGroupType;
bool_t bActiveFlag;
uint8_t uiReserved[3]; // reserved padding bytes
} SFmo, *PFmo;
@ -73,7 +73,7 @@ typedef struct TagFmo{
*
* \return 0 - successful; none 0 - failed;
*/
int32_t InitFmo( PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight );
int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight);
/*!
* \brief Uninitialize Wels Flexible Macroblock Ordering (FMO) list
@ -84,7 +84,7 @@ int32_t InitFmo( PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki
*
* \return NONE
*/
void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail );
void_t UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail);
/*!
* \brief update/insert FMO parameter unit
@ -96,7 +96,7 @@ void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail );
*
* \return true - update/insert successfully; false - failed;
*/
bool_t FmoParamUpdate( PFmo pFmo, PSps pSps, PPps pPps, int32_t *pActiveFmoNum );
bool_t FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum);
/*!
* \brief Get successive mb to be processed with given current mb_xy
@ -106,7 +106,7 @@ bool_t FmoParamUpdate( PFmo pFmo, PSps pSps, PPps pPps, int32_t *pActiveFmoNum )
*
* \return iNextMb - successful; -1 - failed;
*/
MB_XY_T FmoNextMb( PFmo pFmo, const MB_XY_T kiMbXy );
MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy);
} // namespace WelsDec

View File

@ -47,65 +47,65 @@
namespace WelsDec {
void_t WelsI4x4LumaPredV_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredH_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDc_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDcTop_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDcNA_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDL_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDLTop_c(uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDR_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVL_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVLTop_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVR_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHU_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHD_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredV_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredH_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVL_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredV_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredH_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredPlane_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDc_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDcLeft_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDcTop_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDcNA_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDc_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDcTop_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDcNA_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredV_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredH_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredPlane_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDc_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcTop_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcNA_c (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredV_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredH_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredPlane_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDc_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride);
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#if defined(X86_ASM)
void_t WelsI16x16LumaPredPlane_sse2(uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredH_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredV_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDc_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcTop_sse2(uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcNA_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredPlane_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredH_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredV_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDc_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcTop_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI16x16LumaPredDcNA_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDcTop_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredPlane_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDc_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredH_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredV_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDcLeft_mmx(uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDcNA_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsIChromaPredDcTop_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredPlane_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDc_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredH_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredV_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDcLeft_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsIChromaPredDcNA_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredH_sse2 (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDc_sse2(uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDR_mmx(uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHD_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHU_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVR_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDL_mmx(uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVL_mmx (uint8_t *pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredH_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDc_sse2 (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDR_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHD_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredHU_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVR_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredDDL_mmx (uint8_t* pPred, const int32_t kiStride);
void_t WelsI4x4LumaPredVL_mmx (uint8_t* pPred, const int32_t kiStride);
#endif//X86_ASM
#if defined(__cplusplus)

View File

@ -37,26 +37,32 @@
#ifdef __GNUC__
struct tagUnaligned_64 { uint64_t l; } __attribute__((packed));
struct tagUnaligned_32 { uint32_t l; } __attribute__((packed));
struct tagUnaligned_16 { uint16_t l; } __attribute__((packed));
#define LD16(a) (((struct tagUnaligned_16 *) (a))->l)
#define LD32(a) (((struct tagUnaligned_32 *) (a))->l)
#define LD64(a) (((struct tagUnaligned_64 *) (a))->l)
//#define _USE_STRUCT_INT_CVT
struct tagUnaligned_64 {
uint64_t l;
} __attribute__ ((packed));
struct tagUnaligned_32 {
uint32_t l;
} __attribute__ ((packed));
struct tagUnaligned_16 {
uint16_t l;
} __attribute__ ((packed));
#define LD16(a) (((struct tagUnaligned_16 *) (a))->l)
#define LD32(a) (((struct tagUnaligned_32 *) (a))->l)
#define LD64(a) (((struct tagUnaligned_64 *) (a))->l)
//#define _USE_STRUCT_INT_CVT
// #ifdef _USE_STRUCT_INT_CVT
#define ST16(a, b) (((struct tagUnaligned_16 *) (a))->l) = (b)
#define ST32(a, b) (((struct tagUnaligned_32 *) (a))->l) = (b)
#define ST64(a, b) (((struct tagUnaligned_64 *) (a))->l) = (b)
#define ST16(a, b) (((struct tagUnaligned_16 *) (a))->l) = (b)
#define ST32(a, b) (((struct tagUnaligned_32 *) (a))->l) = (b)
#define ST64(a, b) (((struct tagUnaligned_64 *) (a))->l) = (b)
// #else
// inline void_t __ST16(void_t *dst, uint16_t v) { memcpy(dst, &v, 2); }
// inline void_t __ST32(void_t *dst, uint32_t v) { memcpy(dst, &v, 4); }
//inline void_t __ST64(void_t *dst, uint64_t v) { memcpy(dst, &v, 8); }
//inline void_t __ST64(void_t *dst, uint64_t v) { memcpy(dst, &v, 8); }
// #endif
#else
//#define INTD16(a) (*((int16_t*)(a)))
//#define INTD32(a) (*((int32_t*)(a)))
//#define INTD64(a) (*((int64_t*)(a)))

View File

@ -42,7 +42,7 @@
#include <math.h>
#include <assert.h>
#include "typedefs.h"
#include "typedefs.h"
namespace WelsDec {
@ -59,32 +59,32 @@ namespace WelsDec {
_tp _nm ## _tEmP[(_sz)+(_al)-1]; \
_tp *_nm = _nm ## _tEmP + ((_al)-1) - (((int32_t)(_nm ## _tEmP + ((_al)-1)) & ((_al)-1))/sizeof(_tp))
#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
///////////// from encoder
#if defined(_MSC_VER)
#define inline __inline
#define __FASTCALL __fastcall
#define inline __inline
#define __FASTCALL __fastcall
// #define __align8(t,v) __declspec(align(8)) t v
#define __align16(t,v) __declspec(align(16)) t v
#define __align16(t,v) __declspec(align(16)) t v
#elif defined(__GNUC__)
#if !defined(MAC_POWERPC) && !defined(UNIX) && !defined(ANDROID_NDK) && !defined(APPLE_IOS)
#define __FASTCALL __attribute__ ((fastcall))// linux, centos, mac_x86 can be used
#define __FASTCALL __attribute__ ((fastcall))// linux, centos, mac_x86 can be used
#else
#define __FASTCALL // mean NULL for mac_ppc, solaris(sparc/x86)
#define __FASTCALL // mean NULL for mac_ppc, solaris(sparc/x86)
#endif//MAC_POWERPC
// #define __align8(t,v) t v __attribute__ ((aligned (8)))
#define __align16(t,v) t v __attribute__ ((aligned (16)))
#define __align16(t,v) t v __attribute__ ((aligned (16)))
#if defined(APPLE_IOS)
#define inline //For iOS platform
#if defined(APPLE_IOS)
#define inline //For iOS platform
#endif
#endif//_MSC_VER
@ -143,45 +143,42 @@ namespace WelsDec {
nC += (uint8_t)(nA == -1 && nB == -1); \
}
static __inline int32_t CeilLog2( int32_t i )
{
int32_t s = 0; i--;
while( i > 0 )
{
s++;
i >>= 1;
}
return s;
static __inline int32_t CeilLog2 (int32_t i) {
int32_t s = 0;
i--;
while (i > 0) {
s++;
i >>= 1;
}
return s;
}
/*
the second path will degrades the performance
*/
#if 1
static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
{
int32_t iMin = iX, iMax = iX;
if ( iY < iMin )
iMin = iY;
else
iMax = iY;
static inline int32_t WelsMedian (int32_t iX, int32_t iY, int32_t iZ) {
int32_t iMin = iX, iMax = iX;
if ( iZ < iMin )
iMin = iZ;
else if ( iZ > iMax )
iMax = iZ;
if (iY < iMin)
iMin = iY;
else
iMax = iY;
return (iX + iY + iZ) - (iMin + iMax);
if (iZ < iMin)
iMin = iZ;
else if (iZ > iMax)
iMax = iZ;
return (iX + iY + iZ) - (iMin + iMax);
}
#else
static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
{
int32_t iTmp = (iX-iY)&((iX-iY)>>31);
iX -= iTmp;
iY += iTmp;
iY -= (iY-iZ)&((iY-iZ)>>31);
iY += (iX-iY)&((iX-iY)>>31);
return iY;
static inline int32_t WelsMedian (int32_t iX, int32_t iY, int32_t iZ) {
int32_t iTmp = (iX - iY) & ((iX - iY) >> 31);
iX -= iTmp;
iY += iTmp;
iY -= (iY - iZ) & ((iY - iZ) >> 31);
iY += (iX - iY) & ((iX - iY) >> 31);
return iY;
}
#endif
@ -222,7 +219,7 @@ static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
#endif//#if WELS_VERIFY_RETURN_IF
/*
* Description: to check variable validation and return the specified result
* Description: to check variable validation and return the specified result
* with correspoinding process advance.
* result: value to be return
* case_if: negative condition to be verified
@ -281,7 +278,7 @@ static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
* Description: to safe free an array ptr with free function pointer
* arr: pointer to an array, something like "**p";
* num: number of elements in array
* free_fn: free function pointer
* free_fn: free function pointer
*/
#ifndef WELS_SAFE_FREE_ARR
#define WELS_SAFE_FREE_ARR(pArray, iNum, fFreeFunc) \

View File

@ -47,32 +47,32 @@
namespace WelsDec {
typedef enum TagRemoveFlag{
REMOVE_TARGET = 0,
REMOVE_BASE = 1,
REMOVE_BASE_FIRST = 2
}ERemoveFlag;
typedef enum TagRemoveFlag {
REMOVE_TARGET = 0,
REMOVE_BASE = 1,
REMOVE_BASE_FIRST = 2
} ERemoveFlag;
void_t WelsResetRefPic (PWelsDecoderContext pCtx);
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc);
int32_t WelsReorderRefList(PWelsDecoderContext pCtx);
int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag);
void_t WelsResetRefPic (PWelsDecoderContext pCtx);
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc);
int32_t WelsReorderRefList (PWelsDecoderContext pCtx);
int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag);
static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);
static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
static PPicture WelsDelShortFromListSetUnref(PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);
static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);
static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);
static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking);
static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking);
static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool_t bRefBasePic,
int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx);
static int32_t SlidingWindow(PWelsDecoderContext pCtx);
static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking);
static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking);
static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool_t bRefBasePic,
int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx);
static int32_t SlidingWindow (PWelsDecoderContext pCtx);
static int32_t AddShortTermToList(PRefPic pRefPic, PPicture pPic);
static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic);
static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx);
static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
} // namespace WelsDec

View File

@ -48,7 +48,7 @@ namespace WelsDec {
*/
/*
* Cache for Luma Cache for Chroma(Cb, Cr)
*
*
* TL T T T T TL T T
* L - - - - L - -
* L - - - - L - - TR
@ -66,18 +66,17 @@ extern const uint8_t g_kuiCacheNzcScanIdx[24];
extern const uint8_t g_kuiScan4[16];
typedef struct TagNeighborAvail
{
int32_t iTopAvail;
int32_t iLeftAvail;
int32_t iRightTopAvail;
int32_t iLeftTopAvail; //used for check intra_pred_mode avail or not //1: avail; 0: unavail
typedef struct TagNeighborAvail {
int32_t iTopAvail;
int32_t iLeftAvail;
int32_t iRightTopAvail;
int32_t iLeftTopAvail; //used for check intra_pred_mode avail or not //1: avail; 0: unavail
int32_t iLeftType;
int32_t iTopType;
int32_t iLeftTopType;
int32_t iRightTopType;
}SNeighAvail, *PNeighAvail;
int32_t iLeftType;
int32_t iTopType;
int32_t iLeftTopType;
int32_t iRightTopType;
} SNeighAvail, *PNeighAvail;
} // namespace WelsDec

View File

@ -39,7 +39,7 @@
namespace WelsDec {
void_t InitMcFunc(SMcFunc *pMcFunc, int32_t iCpu);
void_t InitMcFunc (SMcFunc* pMcFunc, int32_t iCpu);
#if defined(__cplusplus)
extern "C" {
@ -49,24 +49,39 @@ extern "C" {
// MMXEXT definition //
//***************************************************************************//
#if defined(X86_ASM)
typedef void_t (*PMcChromaWidthExtFunc)( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD, int32_t iHeight );
extern void_t McHorVer20WidthEq4_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McChromaWidthEq4_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD, int32_t iHeight );
extern void_t McCopyWidthEq4_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McCopyWidthEq8_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t PixelAvgWidthEq4_mmx (uint8_t *pDst, int32_t iDstStride, uint8_t *pSrcA, int32_t iSrcAStride, uint8_t *pSrcB, int32_t iSrcBStride, int32_t iHeight);
extern void_t PixelAvgWidthEq8_mmx (uint8_t *pDst, int32_t iDstStride, uint8_t *pSrcA, int32_t iSrcAStride, uint8_t *pSrcB, int32_t iSrcBStride, int32_t iHeight);
typedef void_t (*PMcChromaWidthExtFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
const uint8_t* kpABCD, int32_t iHeight);
extern void_t McHorVer20WidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McChromaWidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
const uint8_t* kpABCD, int32_t iHeight);
extern void_t McCopyWidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McCopyWidthEq8_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t PixelAvgWidthEq4_mmx (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight);
extern void_t PixelAvgWidthEq8_mmx (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight);
//***************************************************************************//
// SSE2 definition //
//***************************************************************************//
extern void_t McChromaWidthEq8_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t* kpABCD, int32_t iHeight );
extern void_t McCopyWidthEq16_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McHorVer20WidthEq8_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McHorVer20WidthEq16_sse2(uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McHorVer02WidthEq8_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McHorVer22Width8HorFirst_sse2(uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
extern void_t McHorVer22VerLast_sse2(uint8_t * pTap, int32_t iTapStride, uint8_t * pDst,int32_t iDstStride,int32_t iWidth,int32_t iHeight);
extern void_t PixelAvgWidthEq16_sse2 (uint8_t *pDst, int32_t iDstStride, uint8_t *pSrcA, int32_t iSrcAStride, uint8_t *pSrcB, int32_t iSrcBStride, int32_t iHeight);
extern void_t McChromaWidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
const uint8_t* kpABCD, int32_t iHeight);
extern void_t McCopyWidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McHorVer20WidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McHorVer20WidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McHorVer02WidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McHorVer22Width8HorFirst_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int32_t iHeight);
extern void_t McHorVer22VerLast_sse2 (uint8_t* pTap, int32_t iTapStride, uint8_t* pDst, int32_t iDstStride,
int32_t iWidth, int32_t iHeight);
extern void_t PixelAvgWidthEq16_sse2 (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight);
#endif //X86_ASM

View File

@ -64,31 +64,30 @@ extern "C" {
* \return time elapsed since run (unit: microsecond)
*/
int64_t WelsTime( void_t )
{
int64_t WelsTime (void_t) {
#if !(defined(_MSC_VER) || defined(__MINGW32__))
struct timeval tv_date;
gettimeofday( &tv_date, NULL );
return( (int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec );
struct timeval tv_date;
gettimeofday (&tv_date, NULL);
return ((int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec);
#else
#if defined (WIN32)
static int64_t iMtimeFreq = 0;
int64_t iMtimeCur = 0;
int64_t iResult = 0;
if ( !iMtimeFreq ){
QueryPerformanceFrequency((LARGE_INTEGER *)&iMtimeFreq);
if ( !iMtimeFreq )
iMtimeFreq = 1;
}
QueryPerformanceCounter((LARGE_INTEGER *)&iMtimeCur);
iResult = (int64_t)((double)iMtimeCur * 1e6 / (double)iMtimeFreq + 0.5);
return iResult;
static int64_t iMtimeFreq = 0;
int64_t iMtimeCur = 0;
int64_t iResult = 0;
if (!iMtimeFreq) {
QueryPerformanceFrequency ((LARGE_INTEGER*)&iMtimeFreq);
if (!iMtimeFreq)
iMtimeFreq = 1;
}
QueryPerformanceCounter ((LARGE_INTEGER*)&iMtimeCur);
iResult = (int64_t) ((double)iMtimeCur * 1e6 / (double)iMtimeFreq + 0.5);
return iResult;
#else
struct _timeb sTime;
_ftime(&sTime);
return ((int64_t)sTime.time * (1000) + (int64_t)sTime.millitm) * (1000);
struct _timeb sTime;
_ftime (&sTime);
return ((int64_t)sTime.time * (1000) + (int64_t)sTime.millitm) * (1000);
#endif//#if WIN32
#endif//!(defined(_MSC_VER) || defined(__MINGW32__))
}

View File

@ -50,7 +50,7 @@ extern "C" {
/*!
/*!
*************************************************************************************
* \brief malloc with zero filled utilization in Wels
*
@ -61,13 +61,13 @@ extern "C" {
* \note N/A
*************************************************************************************
*/
void_t * WelsMalloc( const uint32_t kuiSize, const str_t *kpTag );
void_t* WelsMalloc (const uint32_t kuiSize, const str_t* kpTag);
/*!
/*!
*************************************************************************************
* \brief free utilization in Wels
*
* \param pPtr data pointer to be free.
* \param pPtr data pointer to be free.
* i.e, uint8_t *pPtr = actual data to be free, argv = &pPtr.
*
* \return NONE
@ -75,7 +75,7 @@ void_t * WelsMalloc( const uint32_t kuiSize, const str_t *kpTag );
* \note N/A
*************************************************************************************
*/
void_t WelsFree( void_t * pPtr, const str_t *kpTag );
void_t WelsFree (void_t* pPtr, const str_t* kpTag);
#define WELS_SAFE_FREE(pPtr, pTag) if (pPtr) { WelsFree(pPtr, pTag); pPtr = NULL; }

View File

@ -47,16 +47,16 @@
namespace WelsDec {
int32_t MemInitNalList(PAccessUnit *ppAu, const uint32_t kuiSize);
int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize);
int32_t MemFreeNalList(PAccessUnit *ppAu);
int32_t MemFreeNalList (PAccessUnit* ppAu);
/*
* MemGetNextNal
* Get next NAL Unit for using.
* Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit
*/
PNalUnit MemGetNextNal(PAccessUnit *ppAu);
PNalUnit MemGetNextNal (PAccessUnit* ppAu);
} // namespace WelsDec

View File

@ -47,51 +47,53 @@ namespace WelsDec {
/*!
* \brief update mv and ref_index cache for current MB, only for P_16x16 (SKIP inclusive)
* \param
* \param
* \param
* \param
*/
void_t UpdateP16x16MotionInfo(PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]);
void_t UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]);
/*!
* \brief update mv and ref_index cache for current MB, only for P_16x8
* \param
* \param
/*!
* \brief update mv and ref_index cache for current MB, only for P_16x8
* \param
* \param
*/
void_t UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
/*!
* \brief update mv and ref_index cache for current MB, only for P_8x16
* \param
* \param
*/
void_t UpdateP16x8MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
void_t UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
/*!
* \brief update mv and ref_index cache for current MB, only for P_8x16
* \param
* \param
*/
void_t UpdateP8x16MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
/*!
* \brief get the motion predictor for 4*4 or 8*8 or 16*16 block
* \param
* \param
* \param output mvp_x and mvp_y
*/
void_t PredMv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]);
void_t PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]);
/*!
* \brief get the motion predictor for inter16x8 MB
* \param
* \param
* \param output mvp_x and mvp_y
*/
void_t PredInter16x8Mv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]);
void_t PredInter16x8Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]);
/*!
* \brief get the motion predictor for inter8x16 MB
* \param
* \param
* \param output mvp_x and mvp_y
*/
void_t PredInter8x16Mv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]);
void_t PredInter8x16Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]);
} // namespace WelsDec

View File

@ -45,42 +45,42 @@ namespace WelsDec {
///////////////////////////////////NAL Unit prefix/headers///////////////////////////////////
/* NAL Unix Header in AVC, refer to Page 56 in JVT X201wcm */
typedef struct TagNalUnitHeader{
uint8_t uiForbiddenZeroBit;
uint8_t uiNalRefIdc;
ENalUnitType eNalUnitType;
uint8_t uiReservedOneByte; // only padding usage
}SNalUnitHeader, *PNalUnitHeader;
typedef struct TagNalUnitHeader {
uint8_t uiForbiddenZeroBit;
uint8_t uiNalRefIdc;
ENalUnitType eNalUnitType;
uint8_t uiReservedOneByte; // only padding usage
} SNalUnitHeader, *PNalUnitHeader;
/* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */
typedef struct TagNalUnitHeaderExt{
SNalUnitHeader sNalUnitHeader;
// uint8_t reserved_one_bit;
bool_t bIdrFlag;
uint8_t uiPriorityId;
int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder
uint8_t uiDependencyId;
typedef struct TagNalUnitHeaderExt {
SNalUnitHeader sNalUnitHeader;
uint8_t uiQualityId;
uint8_t uiTemporalId;
bool_t bUseRefBasePicFlag;
bool_t bDiscardableFlag;
bool_t bOutputFlag;
uint8_t uiReservedThree2Bits;
// Derived variable(s)
uint8_t uiLayerDqId;
bool_t bNalExtFlag;
}SNalUnitHeaderExt, *PNalUnitHeaderExt;
// uint8_t reserved_one_bit;
bool_t bIdrFlag;
uint8_t uiPriorityId;
int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder
uint8_t uiDependencyId;
uint8_t uiQualityId;
uint8_t uiTemporalId;
bool_t bUseRefBasePicFlag;
bool_t bDiscardableFlag;
bool_t bOutputFlag;
uint8_t uiReservedThree2Bits;
// Derived variable(s)
uint8_t uiLayerDqId;
bool_t bNalExtFlag;
} SNalUnitHeaderExt, *PNalUnitHeaderExt;
/* Prefix NAL Unix syntax, refer to Page 392 in JVT X201wcm */
typedef struct TagPrefixNalUnit{
SRefBasePicMarking sRefPicBaseMarking;
bool_t bStoreRefBasePicFlag;
bool_t bPrefixNalUnitAdditionalExtFlag;
bool_t bPrefixNalUnitExtFlag;
}SPrefixNalUnit, *PPrefixNalUnit;
typedef struct TagPrefixNalUnit {
SRefBasePicMarking sRefPicBaseMarking;
bool_t bStoreRefBasePicFlag;
bool_t bPrefixNalUnitAdditionalExtFlag;
bool_t bPrefixNalUnitExtFlag;
} SPrefixNalUnit, *PPrefixNalUnit;
//#pragma pack()

View File

@ -44,35 +44,35 @@ namespace WelsDec {
///////////////////////////////////NAL UNIT level///////////////////////////////////
/* NAL Unit Structure */
typedef struct TagNalUnit{
SNalUnitHeaderExt sNalHeaderExt;
union{
struct SVclNal{
SSliceHeaderExt sSliceHeaderExt;
SBitStringAux sSliceBitsRead;
uint8_t *pNalPos; // save the address of slice nal for GPU function
int32_t iNalLength; // save the nal length for GPU function
bool_t bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
}SNalUnit, *PNalUnit;
typedef struct TagNalUnit {
SNalUnitHeaderExt sNalHeaderExt;
union {
struct SVclNal {
SSliceHeaderExt sSliceHeaderExt;
SBitStringAux sSliceBitsRead;
uint8_t* pNalPos; // save the address of slice nal for GPU function
int32_t iNalLength; // save the nal length for GPU function
bool_t bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
} SNalUnit, *PNalUnit;
///////////////////////////////////ACCESS Unit level///////////////////////////////////
/* Access Unit structure */
typedef struct TagAccessUnits{
PNalUnit *pNalUnitsList; // list of NAL Units pointer in this AU
uint32_t uiAvailUnitsNum; // Number of NAL Units available in each AU list based current bitstream,
uint32_t uiActualUnitsNum; // actual number of NAL units belong to current au
// While available number exceeds count size below, need realloc extra NAL Units for list space.
uint32_t uiCountUnitsNum; // Count size number of malloced NAL Units in each AU list
uint32_t uiStartPos;
uint32_t uiEndPos;
bool_t bCompletedAuFlag; // Indicate whether it is a completed AU
}SAccessUnit, *PAccessUnit;
typedef struct TagAccessUnits {
PNalUnit* pNalUnitsList; // list of NAL Units pointer in this AU
uint32_t uiAvailUnitsNum; // Number of NAL Units available in each AU list based current bitstream,
uint32_t uiActualUnitsNum; // actual number of NAL units belong to current au
// While available number exceeds count size below, need realloc extra NAL Units for list space.
uint32_t uiCountUnitsNum; // Count size number of malloced NAL Units in each AU list
uint32_t uiStartPos;
uint32_t uiEndPos;
bool_t bCompletedAuFlag; // Indicate whether it is a completed AU
} SAccessUnit, *PAccessUnit;
} // namespace WelsDec

View File

@ -42,54 +42,54 @@ namespace WelsDec {
//#pragma pack(1)
/* Sequence Parameter Set, refer to Page 57 in JVT X201wcm */
typedef struct TagSps{
int32_t iSpsId;
uint32_t iMbWidth;
uint32_t iMbHeight;
uint32_t uiTotalMbCount; //used in decode_slice_data()
uint32_t uiLog2MaxFrameNum;
uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
int32_t iOffsetForNonRefPic;
typedef struct TagSps {
int32_t iSpsId;
uint32_t iMbWidth;
uint32_t iMbHeight;
uint32_t uiTotalMbCount; //used in decode_slice_data()
int32_t iOffsetForTopToBottomField;
int32_t iNumRefFramesInPocCycle;
int8_t iOffsetForRefFrame[256];
int32_t iNumRefFrames;
SPosOffset sFrameCrop;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
uint8_t uiChromaFormatIdc;
uint8_t uiChromaArrayType;
uint8_t uiBitDepthLuma;
uint8_t uiBitDepthChroma;
/* TO BE CONTINUE: POC type 1 */
bool_t bDeltaPicOrderAlwaysZeroFlag;
bool_t bGapsInFrameNumValueAllowedFlag;
uint32_t uiLog2MaxFrameNum;
uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
int32_t iOffsetForNonRefPic;
bool_t bFrameMbsOnlyFlag;
bool_t bMbaffFlag; // MB Adapative Frame Field
bool_t bDirect8x8InferenceFlag;
bool_t bFrameCroppingFlag;
int32_t iOffsetForTopToBottomField;
int32_t iNumRefFramesInPocCycle;
int8_t iOffsetForRefFrame[256];
int32_t iNumRefFrames;
bool_t bVuiParamPresentFlag;
SPosOffset sFrameCrop;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
uint8_t uiChromaFormatIdc;
uint8_t uiChromaArrayType;
uint8_t uiBitDepthLuma;
uint8_t uiBitDepthChroma;
/* TO BE CONTINUE: POC type 1 */
bool_t bDeltaPicOrderAlwaysZeroFlag;
bool_t bGapsInFrameNumValueAllowedFlag;
bool_t bFrameMbsOnlyFlag;
bool_t bMbaffFlag; // MB Adapative Frame Field
bool_t bDirect8x8InferenceFlag;
bool_t bFrameCroppingFlag;
bool_t bVuiParamPresentFlag;
// bool_t bTimingInfoPresentFlag;
// bool_t bFixedFrameRateFlag;
bool_t bConstraintSet0Flag;
bool_t bConstraintSet1Flag;
bool_t bConstraintSet2Flag;
bool_t bConstraintSet3Flag;
bool_t bSeparateColorPlaneFlag;
bool_t bQpPrimeYZeroTransfBypassFlag;
bool_t bSeqScalingMatrixPresentFlag;
bool_t bSeqScalingListPresentFlag[12];
}SSps, *PSps;
bool_t bConstraintSet0Flag;
bool_t bConstraintSet1Flag;
bool_t bConstraintSet2Flag;
bool_t bConstraintSet3Flag;
bool_t bSeparateColorPlaneFlag;
bool_t bQpPrimeYZeroTransfBypassFlag;
bool_t bSeqScalingMatrixPresentFlag;
bool_t bSeqScalingListPresentFlag[12];
} SSps, *PSps;
/* Sequence Parameter Set extension syntax, refer to Page 58 in JVT X201wcm */
@ -98,72 +98,72 @@ typedef struct TagSps{
// uint32_t uiAuxFormatIdc;
// int32_t iAlphaOpaqueValue;
// int32_t iAlphaTransparentValue;
// uint8_t uiBitDepthAux;
// bool_t bAlphaIncrFlag;
// bool_t bAdditionalExtFlag;
//}SSpsExt, *PSpsExt;
/* Sequence Parameter Set extension syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSpsSvcExt{
SPosOffset sSeqScaledRefLayer;
uint8_t uiExtendedSpatialScalability; // ESS
uint8_t uiChromaPhaseXPlus1Flag;
uint8_t uiChromaPhaseYPlus1;
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
bool_t bInterLayerDeblockingFilterCtrlPresentFlag;
bool_t bSeqTCoeffLevelPredFlag;
bool_t bAdaptiveTCoeffLevelPredFlag;
bool_t bSliceHeaderRestrictionFlag;
}SSpsSvcExt, *PSpsSvcExt;
typedef struct TagSpsSvcExt {
SPosOffset sSeqScaledRefLayer;
uint8_t uiExtendedSpatialScalability; // ESS
uint8_t uiChromaPhaseXPlus1Flag;
uint8_t uiChromaPhaseYPlus1;
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
bool_t bInterLayerDeblockingFilterCtrlPresentFlag;
bool_t bSeqTCoeffLevelPredFlag;
bool_t bAdaptiveTCoeffLevelPredFlag;
bool_t bSliceHeaderRestrictionFlag;
} SSpsSvcExt, *PSpsSvcExt;
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSubsetSps{
SSps sSps;
SSpsSvcExt sSpsSvcExt;
bool_t bSvcVuiParamPresentFlag;
bool_t bAdditionalExtension2Flag;
bool_t bAdditionalExtension2DataFlag;
}SSubsetSps, *PSubsetSps;
typedef struct TagSubsetSps {
SSps sSps;
SSpsSvcExt sSpsSvcExt;
bool_t bSvcVuiParamPresentFlag;
bool_t bAdditionalExtension2Flag;
bool_t bAdditionalExtension2DataFlag;
} SSubsetSps, *PSubsetSps;
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
typedef struct TagPps{
int32_t iSpsId;
int32_t iPpsId;
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* slice_group_map_type = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 3, 4 or 5 */
uint32_t uiSliceGroupChangeRate;
/* slice_group_map_type = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
uint32_t uiNumRefIdxL0Active;
uint32_t uiNumRefIdxL1Active;
int32_t iPicInitQp;
int32_t iPicInitQs;
int32_t iChromaQpIndexOffset;
typedef struct TagPps {
int32_t iSpsId;
int32_t iPpsId;
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* slice_group_map_type = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 3, 4 or 5 */
uint32_t uiSliceGroupChangeRate;
/* slice_group_map_type = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
uint32_t uiNumRefIdxL0Active;
uint32_t uiNumRefIdxL1Active;
int32_t iPicInitQp;
int32_t iPicInitQs;
int32_t iChromaQpIndexOffset;
bool_t bEntropyCodingModeFlag;
bool_t bPicOrderPresentFlag;
/* slice_group_map_type = 3, 4 or 5 */
bool_t bSliceGroupChangeDirectionFlag;
bool_t bDeblockingFilterControlPresentFlag;
bool_t bConstainedIntraPredFlag;
bool_t bRedundantPicCntPresentFlag;
bool_t bWeightedPredFlag;
uint8_t uiWeightedBipredIdc;
bool_t bEntropyCodingModeFlag;
bool_t bPicOrderPresentFlag;
/* slice_group_map_type = 3, 4 or 5 */
bool_t bSliceGroupChangeDirectionFlag;
bool_t bDeblockingFilterControlPresentFlag;
bool_t bConstainedIntraPredFlag;
bool_t bRedundantPicCntPresentFlag;
bool_t bWeightedPredFlag;
uint8_t uiWeightedBipredIdc;
} SPps, *PPps;
//#pragma pack()

View File

@ -38,7 +38,7 @@
*************************************************************************************
*/
#ifndef WELS_PARSE_MB_SYN_CAVLC_H__
#define WELS_PARSE_MB_SYN_CAVLC_H__
@ -50,162 +50,166 @@
namespace WelsDec {
#define I16_LUMA_DC 1
#define I16_LUMA_AC 2
#define I16_LUMA_AC 2
#define LUMA_DC_AC 3
#define CHROMA_DC 4
#define CHROMA_AC 5
typedef struct TagReadBitsCache
{
uint32_t uiCache32Bit;
uint8_t uiRemainBits;
uint8_t *pBuf;
}SReadBitsCache;
typedef struct TagReadBitsCache {
uint32_t uiCache32Bit;
uint8_t uiRemainBits;
uint8_t* pBuf;
} SReadBitsCache;
#define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); }
#define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; }
static const uint8_t g_kuiZigzagScan[16]={//4*4block residual zig-zag scan order
0, 1, 4, 8,
5, 2, 3, 6,
9, 12, 13, 10,
7, 11, 14, 15,
static const uint8_t g_kuiZigzagScan[16] = { //4*4block residual zig-zag scan order
0, 1, 4, 8,
5, 2, 3, 6,
9, 12, 13, 10,
7, 11, 14, 15,
};
typedef struct TagI16PredInfo{
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
typedef struct TagI16PredInfo {
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
} SI16PredInfo;
static const SI16PredInfo g_ksI16PredInfo[4] = {
{I16_PRED_V, 0, 1, 0},
{I16_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I16_PRED_P, 1, 1, 1},
{I16_PRED_V, 0, 1, 0},
{I16_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I16_PRED_P, 1, 1, 1},
};
static const SI16PredInfo g_ksChromaPredInfo[4] = {
{ 0, 0, 0, 0},
{C_PRED_H, 1, 0, 0},
{C_PRED_V, 0, 1, 0},
{C_PRED_P, 1, 1, 1},
{ 0, 0, 0, 0},
{C_PRED_H, 1, 0, 0},
{C_PRED_V, 0, 1, 0},
{C_PRED_P, 1, 1, 1},
};
typedef struct TagI4PredInfo {
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
// int8_t right_top_avail; //when right_top unavailable but top avail, we can pad the right-top with the rightmost pixel of top
} SI4PredInfo;
static const SI4PredInfo g_ksI4PredInfo[9] = {
{ I4_PRED_V, 0, 1, 0},
{ I4_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I4_PRED_DDL, 0, 1, 0},
{I4_PRED_DDR, 1, 1, 1},
{ I4_PRED_VR, 1, 1, 1},
{ I4_PRED_HD, 1, 1, 1},
{ I4_PRED_VL, 0, 1, 0},
{ I4_PRED_HU, 1, 0, 0},
{ I4_PRED_V, 0, 1, 0},
{ I4_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I4_PRED_DDL, 0, 1, 0},
{I4_PRED_DDR, 1, 1, 1},
{ I4_PRED_VR, 1, 1, 1},
{ I4_PRED_HD, 1, 1, 1},
{ I4_PRED_VL, 0, 1, 0},
{ I4_PRED_HU, 1, 0, 0},
};
static const uint8_t g_kuiI16CbpTable[6] = {0, 16, 32, 15, 31, 47}; //reference to JM
typedef struct TagPartMbInfo{
MbType iType;
int8_t iPartCount; //P_16*16, P_16*8, P_8*16, P_8*8 based on 8*8 block; P_8*4, P_4*8, P_4*4 based on 4*4 block
int8_t iPartWidth; //based on 4*4 block
} SPartMbInfo;
static const SPartMbInfo g_ksInterMbTypeInfo[5]={
typedef struct TagPartMbInfo {
MbType iType;
int8_t iPartCount; //P_16*16, P_16*8, P_8*16, P_8*8 based on 8*8 block; P_8*4, P_4*8, P_4*4 based on 4*4 block
int8_t iPartWidth; //based on 4*4 block
} SPartMbInfo;
static const SPartMbInfo g_ksInterMbTypeInfo[5] = {
{MB_TYPE_16x16, 1, 4},
{MB_TYPE_16x8, 2, 4},
{MB_TYPE_8x16, 2, 2},
{MB_TYPE_8x8, 4, 4},
{MB_TYPE_8x8_REF0, 4, 4}, //ref0--ref_idx not present in bit-stream and default as 0
};
static const SPartMbInfo g_ksInterSubMbTypeInfo[4]={
static const SPartMbInfo g_ksInterSubMbTypeInfo[4] = {
{SUB_MB_TYPE_8x8, 1, 2},
{SUB_MB_TYPE_8x4, 2, 2},
{SUB_MB_TYPE_4x8, 2, 1},
{SUB_MB_TYPE_4x4, 4, 1},
};
void_t GetNeighborAvailMbType (PNeighAvail pNeighAvail, PDqLayer pCurLayer);
void_t WelsFillCacheNonZeroCount (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer);
void_t WelsFillCacheConstrain0Intra4x4(PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, PDqLayer pCurLayer);
void_t WelsFillCacheConstrain1Intra4x4(PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, PDqLayer pCurLayer);
void_t WelsFillCacheInter (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
void_t GetNeighborAvailMbType (PNeighAvail pNeighAvail, PDqLayer pCurLayer);
void_t WelsFillCacheNonZeroCount (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer);
void_t WelsFillCacheConstrain0Intra4x4 (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
PDqLayer pCurLayer);
void_t WelsFillCacheConstrain1Intra4x4 (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
PDqLayer pCurLayer);
void_t WelsFillCacheInter (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
void_t PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]);
void_t PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]);
/*!
* \brief check iPredMode for intra16x16 eligible or not
* \param input : current iPredMode
* \param output: 0 indicating decoding correctly; -1 means error occurence
*/
int32_t CheckIntra16x16PredMode(uint8_t uiSampleAvail, int8_t* pMode);
int32_t CheckIntra16x16PredMode (uint8_t uiSampleAvail, int8_t* pMode);
/*!
* \brief check iPredMode for intra4x4 eligible or not
* \param input : current iPredMode
* \param output: 0 indicating decoding correctly; -1 means error occurence
*/
int32_t CheckIntra4x4PredMode(int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex);
int32_t CheckIntra4x4PredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex);
/*!
* \brief check iPredMode for chroma eligible or not
* \param input : current iPredMode
* \param output: 0 indicating decoding correctly; -1 means error occurence
*/
int32_t CheckIntraChromaPredMode(uint8_t uiSampleAvail, int8_t* pMode);
int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode);
/*!
* \brief predict the mode of intra4x4
* \param input : current intra4x4 block index
* \param output: mode index
*/
int32_t PredIntra4x4Mode(int8_t* pIntraPredMode, int32_t iIdx4);
int32_t PredIntra4x4Mode (int8_t* pIntraPredMode, int32_t iIdx4);
void_t BsStartCavlc( PBitStringAux pBs );
void_t BsEndCavlc( PBitStringAux pBs );
void_t BsStartCavlc (PBitStringAux pBs);
void_t BsEndCavlc (PBitStringAux pBs);
int32_t WelsResidualBlockCavlc( SVlcTable* pVlcTable,
uint8_t* pNonZeroCountCache,
PBitStringAux pBs,
/*int16_t* coeff_level,*/
int32_t iIndex,
int32_t iMaxNumCoeff,
const uint8_t *kpZigzagTable,
int32_t iResidualProperty,
/*short *tCoeffLevel,*/
int16_t *pTCoeff,
int32_t iMbMode,
uint8_t uiQp,
PWelsDecoderContext pCtx);
int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable,
uint8_t* pNonZeroCountCache,
PBitStringAux pBs,
/*int16_t* coeff_level,*/
int32_t iIndex,
int32_t iMaxNumCoeff,
const uint8_t* kpZigzagTable,
int32_t iResidualProperty,
/*short *tCoeffLevel,*/
int16_t* pTCoeff,
int32_t iMbMode,
uint8_t uiQp,
PWelsDecoderContext pCtx);
/*!
* \brief parsing intra mode
* \brief parsing intra mode
* \param input : current mb, bit-stream
* \param output: 0 indicating decoding correctly; -1 means error
*/
int32_t ParseIntra4x4ModeConstrain0 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, PDqLayer pCurDqLayer);
int32_t ParseIntra4x4ModeConstrain1 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, PDqLayer pCurDqLayer);
int32_t ParseIntra16x16ModeConstrain0(PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
int32_t ParseIntra16x16ModeConstrain1(PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
int32_t ParseIntra4x4ModeConstrain0 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
PDqLayer pCurDqLayer);
int32_t ParseIntra4x4ModeConstrain1 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
PDqLayer pCurDqLayer);
int32_t ParseIntra16x16ModeConstrain0 (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
int32_t ParseIntra16x16ModeConstrain1 (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
/*!
* \brief parsing inter info (including ref_index and mvd)
* \brief parsing inter info (including ref_index and mvd)
* \param input : decoding context, current mb, bit-stream
* \param output: 0 indicating decoding correctly; -1 means error
*/
int32_t ParseInterInfo(PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PBitStringAux pBs);
int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
PBitStringAux pBs);
//#pragma pack()

View File

@ -44,17 +44,17 @@ namespace WelsDec {
#define PICTURE_RESOLUTION_ALIGNMENT 32
typedef struct TagPicBuff{
PPicture* ppPic;
int32_t iCapacity; // capacity size of queue
int32_t iCurrentIdx;
}SPicBuff, *PPicBuff;
typedef struct TagPicBuff {
PPicture* ppPic;
int32_t iCapacity; // capacity size of queue
int32_t iCurrentIdx;
} SPicBuff, *PPicBuff;
/*
* Interfaces
*/
PPicture PrefetchPic( PPicBuff pPicBuff ); // To get current node applicable
PPicture PrefetchPic (PPicBuff pPicBuff); // To get current node applicable
} // namespace WelsDec

View File

@ -44,41 +44,41 @@ namespace WelsDec {
* Reconstructed Picture definition
* It is used to express reference picture, also consequent reconstruction picture for output
*/
typedef struct TagPicture{
/************************************payload data*********************************/
uint8_t *pBuffer[4]; // pointer to the first allocated byte, basical offset of buffer, dimension:
uint8_t *pData[4]; // pointer to picture planes respectively
int32_t iLinesize[4];// linesize of picture planes respectively used currently
int32_t iPlanes; // How many planes are introduced due to color space format?
// picture information
/*******************************from other standard syntax****************************/
/*from sps*/
int32_t iWidthInPixel; // picture width in pixel
int32_t iHeightInPixel;// picture height in pixel
/*from slice header*/
int32_t iFramePoc; // frame POC
typedef struct TagPicture {
/************************************payload data*********************************/
uint8_t* pBuffer[4]; // pointer to the first allocated byte, basical offset of buffer, dimension:
uint8_t* pData[4]; // pointer to picture planes respectively
int32_t iLinesize[4];// linesize of picture planes respectively used currently
int32_t iPlanes; // How many planes are introduced due to color space format?
// picture information
/*******************************sef_definition for misc use****************************/
bool_t bUsedAsRef; //for ref pic management
bool_t bIsLongRef; // long term reference frame flag //for ref pic management
uint8_t uiRefCount;
bool_t bAvailableFlag; // indicate whether it is available in this picture memory block.
/*******************************from other standard syntax****************************/
/*from sps*/
int32_t iWidthInPixel; // picture width in pixel
int32_t iHeightInPixel;// picture height in pixel
/*from slice header*/
int32_t iFramePoc; // frame POC
/*******************************for future use****************************/
uint8_t uiTemporalId;
uint8_t uiSpatialId;
uint8_t uiQualityId;
bool_t bRefBaseFlag;
int32_t iFrameNum; // frame number //for ref pic management
int32_t iLongTermFrameIdx; //id for long term ref pic
/*******************************sef_definition for misc use****************************/
bool_t bUsedAsRef; //for ref pic management
bool_t bIsLongRef; // long term reference frame flag //for ref pic management
uint8_t uiRefCount;
bool_t bAvailableFlag; // indicate whether it is available in this picture memory block.
int32_t iTotalNumMbRec; //show how many MB constructed
/*******************************for future use****************************/
uint8_t uiTemporalId;
uint8_t uiSpatialId;
uint8_t uiQualityId;
bool_t bRefBaseFlag;
int32_t iSpsId; //against mosaic caused by cross-IDR interval reference.
int32_t iPpsId;
}SPicture, *PPicture; // "Picture" declaration is comflict with Mac system
int32_t iFrameNum; // frame number //for ref pic management
int32_t iLongTermFrameIdx; //id for long term ref pic
int32_t iTotalNumMbRec; //show how many MB constructed
int32_t iSpsId; //against mosaic caused by cross-IDR interval reference.
int32_t iPpsId;
} SPicture, *PPicture; // "Picture" declaration is comflict with Mac system
} // namespace WelsDec

View File

@ -51,22 +51,22 @@
namespace WelsDec {
void_t WelsFillRecNeededMbInfo(PWelsDecoderContext pCtx, bool_t bOutput, PDqLayer pCurLayer);
void_t WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool_t bOutput, PDqLayer pCurLayer);
int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI4x4Chroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer);
int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer);
int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
void_t GetInterPred (uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDecoderContext pCtx);
void_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx);
void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iSrcStride, int32_t iSrcOffset,
int32_t iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight);
void_t FillBufForMc (uint8_t* pBuf, int32_t iBufStride, uint8_t* pSrc, int32_t iSrcStride, int32_t iSrcOffset,
int32_t iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight);
} // namespace WelsDec

View File

@ -48,158 +48,158 @@ namespace WelsDec {
* Reference picture list reordering syntax, refer to page 64 in JVT X201wcm
*/
typedef struct TagRefPicListReorderSyntax {
struct {
uint32_t uiAbsDiffPicNumMinus1;
uint16_t uiLongTermPicNum;
uint16_t uiReorderingOfPicNumsIdc;
} sReorderingSyn[LIST_A][MAX_REF_PIC_COUNT];
bool_t bRefPicListReorderingFlag[LIST_A];
}SRefPicListReorderSyn, *PRefPicListReorderSyn;
struct {
uint32_t uiAbsDiffPicNumMinus1;
uint16_t uiLongTermPicNum;
uint16_t uiReorderingOfPicNumsIdc;
} sReorderingSyn[LIST_A][MAX_REF_PIC_COUNT];
bool_t bRefPicListReorderingFlag[LIST_A];
} SRefPicListReorderSyn, *PRefPicListReorderSyn;
/*
* Prediction weight table syntax, refer to page 65 in JVT X201wcm
*/
typedef struct TagPredWeightTabSyntax{
uint32_t uiLumaLog2WeightDenom;
uint32_t uiChromaLog2WeightDenom;
struct{
int32_t iLumaWeight[MAX_REF_PIC_COUNT];
int32_t iLumaOffset[MAX_REF_PIC_COUNT];
int32_t iChromaWeight[MAX_REF_PIC_COUNT][2];
int32_t iChromaOffset[MAX_REF_PIC_COUNT][2];
bool_t bLumaWeightFlag;
bool_t bChromaWeightFlag;
}sPredList[LIST_A];
}SPredWeightTabSyn;
typedef struct TagPredWeightTabSyntax {
uint32_t uiLumaLog2WeightDenom;
uint32_t uiChromaLog2WeightDenom;
struct {
int32_t iLumaWeight[MAX_REF_PIC_COUNT];
int32_t iLumaOffset[MAX_REF_PIC_COUNT];
int32_t iChromaWeight[MAX_REF_PIC_COUNT][2];
int32_t iChromaOffset[MAX_REF_PIC_COUNT][2];
bool_t bLumaWeightFlag;
bool_t bChromaWeightFlag;
} sPredList[LIST_A];
} SPredWeightTabSyn;
/* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */
typedef struct TagRefPicMarking {
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
int32_t iDiffOfPicNum;
uint32_t uiLongTermPicNum;
int32_t iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx;
} sMmcoRef[MAX_MMCO_COUNT];
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
int32_t iDiffOfPicNum;
uint32_t uiLongTermPicNum;
int32_t iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx;
} sMmcoRef[MAX_MMCO_COUNT];
bool_t bNoOutputOfPriorPicsFlag;
bool_t bLongTermRefFlag;
bool_t bAdaptiveRefPicMarkingModeFlag;
bool_t bNoOutputOfPriorPicsFlag;
bool_t bLongTermRefFlag;
bool_t bAdaptiveRefPicMarkingModeFlag;
} SRefPicMarking, *PRefPicMarking;
/* Decode reference base picture marking syntax in Page 396 of JVT X201wcm */
typedef struct TagRefBasePicMarkingSyn {
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
uint32_t uiDiffOfPicNums;
uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum.
} mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
uint32_t uiDiffOfPicNums;
uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum.
} mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame
bool_t bAdaptiveRefBasePicMarkingModeFlag;
bool_t bAdaptiveRefBasePicMarkingModeFlag;
} SRefBasePicMarking, *PRefBasePicMarking;
/* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */
typedef struct TagSliceHeaders{
/*****************************slice header syntax and generated****************************/
int32_t iFirstMbInSlice;
int32_t iFrameNum;
int32_t iPicOrderCntLsb;
int32_t iDeltaPicOrderCntBottom;
int32_t iDeltaPicOrderCnt[2];
int32_t iRedundantPicCnt;
int32_t uiRefCount[LIST_A];
int32_t iSliceQpDelta; //no use for iSliceQp is used directly
int32_t iSliceQp;
int32_t iSliceQsDelta; // For SP/SI slices
uint32_t uiDisableDeblockingFilterIdc;
int32_t iSliceAlphaC0Offset;
int32_t iSliceBetaOffset;
int32_t iSliceGroupChangeCycle;
typedef struct TagSliceHeaders {
/*****************************slice header syntax and generated****************************/
int32_t iFirstMbInSlice;
int32_t iFrameNum;
int32_t iPicOrderCntLsb;
int32_t iDeltaPicOrderCntBottom;
int32_t iDeltaPicOrderCnt[2];
int32_t iRedundantPicCnt;
int32_t uiRefCount[LIST_A];
int32_t iSliceQpDelta; //no use for iSliceQp is used directly
int32_t iSliceQp;
int32_t iSliceQsDelta; // For SP/SI slices
uint32_t uiDisableDeblockingFilterIdc;
int32_t iSliceAlphaC0Offset;
int32_t iSliceBetaOffset;
int32_t iSliceGroupChangeCycle;
PSps pSps;
PPps pPps;
int32_t iSpsId;
int32_t iPpsId;
PSps pSps;
PPps pPps;
int32_t iSpsId;
int32_t iPpsId;
/*********************got from other layer for efficency if possible*********************/
SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs
SPredWeightTabSyn sPredWeightTable;
int32_t iCabacInitIdc;
int32_t iMbWidth; //from?
int32_t iMbHeight; //from?
SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs
/*********************got from other layer for efficency if possible*********************/
SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs
SPredWeightTabSyn sPredWeightTable;
int32_t iCabacInitIdc;
int32_t iMbWidth; //from?
int32_t iMbHeight; //from?
SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs
uint16_t uiIdrPicId;
ESliceType eSliceType;
bool_t bNumRefIdxActiveOverrideFlag;
bool_t bFieldPicFlag; //not supported in base profile
bool_t bBottomFiledFlag; //not supported in base profile
uint8_t uiPadding1Byte;
bool_t bSpForSwitchFlag; // For SP/SI slices
int16_t iPadding2Bytes;
}SSliceHeader, *PSliceHeader;
uint16_t uiIdrPicId;
ESliceType eSliceType;
bool_t bNumRefIdxActiveOverrideFlag;
bool_t bFieldPicFlag; //not supported in base profile
bool_t bBottomFiledFlag; //not supported in base profile
uint8_t uiPadding1Byte;
bool_t bSpForSwitchFlag; // For SP/SI slices
int16_t iPadding2Bytes;
} SSliceHeader, *PSliceHeader;
/* Slice header in scalable extension syntax, refer to Page 394 in JVT X201wcm */
typedef struct TagSliceHeaderExt{
SSliceHeader sSliceHeader;
PSubsetSps pSubsetSps;
uint32_t uiNumMbsInSlice;
uint32_t uiDisableInterLayerDeblockingFilterIdc;
int32_t iInterLayerSliceAlphaC0Offset;
int32_t iInterLayerSliceBetaOffset;
//SPosOffset sScaledRefLayer;
int32_t iScaledRefLayerPicWidthInSampleLuma;
int32_t iScaledRefLayerPicHeightInSampleLuma;
typedef struct TagSliceHeaderExt {
SSliceHeader sSliceHeader;
PSubsetSps pSubsetSps;
SRefBasePicMarking sRefBasePicMarking;
bool_t bBasePredWeightTableFlag;
bool_t bStoreRefBasePicFlag;
bool_t bConstrainedIntraResamplingFlag;
bool_t bSliceSkipFlag;
bool_t bAdaptiveBaseModeFlag;
bool_t bDefaultBaseModeFlag;
bool_t bAdaptiveMotionPredFlag;
bool_t bDefaultMotionPredFlag;
bool_t bAdaptiveResidualPredFlag;
bool_t bDefaultResidualPredFlag;
bool_t bTCoeffLevelPredFlag;
uint8_t uiRefLayerChromaPhaseXPlus1Flag;
uint8_t uiRefLayerChromaPhaseYPlus1;
uint8_t uiRefLayerDqId;
uint8_t uiScanIdxStart;
uint8_t uiScanIdxEnd;
}SSliceHeaderExt, *PSliceHeaderExt;
uint32_t uiNumMbsInSlice;
uint32_t uiDisableInterLayerDeblockingFilterIdc;
int32_t iInterLayerSliceAlphaC0Offset;
int32_t iInterLayerSliceBetaOffset;
//SPosOffset sScaledRefLayer;
int32_t iScaledRefLayerPicWidthInSampleLuma;
int32_t iScaledRefLayerPicHeightInSampleLuma;
SRefBasePicMarking sRefBasePicMarking;
bool_t bBasePredWeightTableFlag;
bool_t bStoreRefBasePicFlag;
bool_t bConstrainedIntraResamplingFlag;
bool_t bSliceSkipFlag;
bool_t bAdaptiveBaseModeFlag;
bool_t bDefaultBaseModeFlag;
bool_t bAdaptiveMotionPredFlag;
bool_t bDefaultMotionPredFlag;
bool_t bAdaptiveResidualPredFlag;
bool_t bDefaultResidualPredFlag;
bool_t bTCoeffLevelPredFlag;
uint8_t uiRefLayerChromaPhaseXPlus1Flag;
uint8_t uiRefLayerChromaPhaseYPlus1;
uint8_t uiRefLayerDqId;
uint8_t uiScanIdxStart;
uint8_t uiScanIdxEnd;
} SSliceHeaderExt, *PSliceHeaderExt;
typedef struct TagSlice{
/*******************************slice_header****************************/
SSliceHeaderExt sSliceHeaderExt;
/*******************************use for future****************************/
// for Macroblock coding within slice
int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
typedef struct TagSlice {
/*******************************slice_header****************************/
SSliceHeaderExt sSliceHeaderExt;
/*******************************slice_data****************************/
/*slice_data_ext()*/
int32_t iMbSkipRun;
int32_t iTotalMbInCurSlice; //record the total number of MB in current slice.
/*slice_data_ext() generate*/
/*******************************misc use****************************/
bool_t bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
/*************got from other layer for effiency if possible***************/
/*from lower layer: slice header*/
uint8_t eSliceType;
uint8_t uiPadding[2];
}SSlice, *PSlice;
/*******************************use for future****************************/
// for Macroblock coding within slice
int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
/*******************************slice_data****************************/
/*slice_data_ext()*/
int32_t iMbSkipRun;
int32_t iTotalMbInCurSlice; //record the total number of MB in current slice.
/*slice_data_ext() generate*/
/*******************************misc use****************************/
bool_t bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
/*************got from other layer for effiency if possible***************/
/*from lower layer: slice header*/
uint8_t eSliceType;
uint8_t uiPadding[2];
} SSlice, *PSlice;
} // namespace WelsDec

View File

@ -47,7 +47,7 @@
#else
// FIXME: all singed type should be declared explicit, for example, int8_t should be declared as signed char.
// FIXME: all singed type should be declared explicit, for example, int8_t should be declared as signed char.
typedef signed char int8_t ;
typedef unsigned char uint8_t ;
typedef short int16_t ;
@ -59,7 +59,7 @@ typedef unsigned __int64 uint64_t;
#endif // _MSC_VER defined
// FIXME: all string type should be declared explicit as char.
// FIXME: all string type should be declared explicit as char.
typedef char str_t;
typedef float real32_t;

View File

@ -59,16 +59,17 @@ extern uint32_t g_uiCacheLineSize;
* Function pointer declaration for various tool sets
*/
// wels log output
typedef void_t (*PWelsLogCallbackFunc)(void_t *pPtr, const int32_t kiLevel, const char *kpFmt, va_list pArgv);
typedef void_t (*PWelsLogCallbackFunc) (void_t* pPtr, const int32_t kiLevel, const char* kpFmt, va_list pArgv);
extern PWelsLogCallbackFunc g_pLog;
#ifdef __GNUC__
extern void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
extern void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...) __attribute__ ((__format__ (__printf__, 3,
4)));
#else
extern void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...);
extern void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...);
#endif
#define DECODER_MODE_NAME(a) ((a == SW_MODE)?"SW_MODE":((a == GPU_MODE)?"GPU_MODE":((a == AUTO_MODE)?"AUTO_MODE":"SWITCH_MODE")))
#define OUTPUT_PROPERTY_NAME(a) ((a == 0)?"system_memory":"video_memory")
#define BUFFER_STATUS_NAME(a) ((a == 0)?"unvalid":"valid")
@ -79,15 +80,15 @@ extern void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...);
*/
typedef int32_t WelsLogLevel;
enum{
WELS_LOG_QUIET = 0x00, // Quiet mode
WELS_LOG_ERROR = 1 << 0, // Error log level
WELS_LOG_WARNING = 1 << 1, // Warning log level
WELS_LOG_INFO = 1 << 2, // Information log level
WELS_LOG_DEBUG = 1 << 3, // Debug log level
WELS_LOG_RESV = 1 << 4, // Resversed log level
WELS_LOG_LEVEL_COUNT= 5,
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG // Default log level in Wels codec
enum {
WELS_LOG_QUIET = 0x00, // Quiet mode
WELS_LOG_ERROR = 1 << 0, // Error log level
WELS_LOG_WARNING = 1 << 1, // Warning log level
WELS_LOG_INFO = 1 << 2, // Information log level
WELS_LOG_DEBUG = 1 << 3, // Debug log level
WELS_LOG_RESV = 1 << 4, // Resversed log level
WELS_LOG_LEVEL_COUNT = 5,
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG // Default log level in Wels codec
};
#ifdef __cplusplus

View File

@ -38,13 +38,12 @@
namespace WelsDec {
typedef struct TagVlcTable
{
const uint8_t (*kpCoeffTokenVlcTable[4][8])[2];
const uint8_t (*kpChromaCoeffTokenVlcTable)[2];
const uint8_t (*kpZeroTable[7])[2];
const uint8_t (*kpTotalZerosTable[2][15])[2];
}SVlcTable;
typedef struct TagVlcTable {
const uint8_t (*kpCoeffTokenVlcTable[4][8])[2];
const uint8_t (*kpChromaCoeffTokenVlcTable)[2];
const uint8_t (*kpZeroTable[7])[2];
const uint8_t (*kpTotalZerosTable[2][15])[2];
} SVlcTable;
// for data sharing cross modules and try to reduce size of binary generated
extern const uint8_t g_kuiVlcChromaTable[256][2];
@ -114,60 +113,59 @@ extern const uint8_t g_kuiZeroLeftBitNumMap[16];
}
#endif
static inline void_t InitVlcTable(SVlcTable * pVlcTable)
{
pVlcTable->kpChromaCoeffTokenVlcTable = g_kuiVlcChromaTable;
pVlcTable->kpCoeffTokenVlcTable[0][0] = g_kuiVlcTable_0;
pVlcTable->kpCoeffTokenVlcTable[0][1] = g_kuiVlcTable_1;
pVlcTable->kpCoeffTokenVlcTable[0][2] = g_kuiVlcTable_2;
pVlcTable->kpCoeffTokenVlcTable[0][3] = g_kuiVlcTable_3;
pVlcTable->kpCoeffTokenVlcTable[1][0] = g_kuiVlcTable_0_0;
pVlcTable->kpCoeffTokenVlcTable[1][1] = g_kuiVlcTable_0_1;
pVlcTable->kpCoeffTokenVlcTable[1][2] = g_kuiVlcTable_0_2;
pVlcTable->kpCoeffTokenVlcTable[1][3] = g_kuiVlcTable_0_3;
pVlcTable->kpCoeffTokenVlcTable[2][0] = g_kuiVlcTable_1_0;
pVlcTable->kpCoeffTokenVlcTable[2][1] = g_kuiVlcTable_1_1;
pVlcTable->kpCoeffTokenVlcTable[2][2] = g_kuiVlcTable_1_2;
pVlcTable->kpCoeffTokenVlcTable[2][3] = g_kuiVlcTable_1_3;
pVlcTable->kpCoeffTokenVlcTable[3][0] = g_kuiVlcTable_2_0;
pVlcTable->kpCoeffTokenVlcTable[3][1] = g_kuiVlcTable_2_1;
pVlcTable->kpCoeffTokenVlcTable[3][2] = g_kuiVlcTable_2_2;
pVlcTable->kpCoeffTokenVlcTable[3][3] = g_kuiVlcTable_2_3;
pVlcTable->kpCoeffTokenVlcTable[3][4] = g_kuiVlcTable_2_4;
pVlcTable->kpCoeffTokenVlcTable[3][5] = g_kuiVlcTable_2_5;
pVlcTable->kpCoeffTokenVlcTable[3][6] = g_kuiVlcTable_2_6;
pVlcTable->kpCoeffTokenVlcTable[3][7] = g_kuiVlcTable_2_7;
pVlcTable->kpZeroTable[0] = g_kuiZeroLeftTable0;
pVlcTable->kpZeroTable[1] = g_kuiZeroLeftTable1;
pVlcTable->kpZeroTable[2] = g_kuiZeroLeftTable2;
pVlcTable->kpZeroTable[3] = g_kuiZeroLeftTable3;
pVlcTable->kpZeroTable[4] = g_kuiZeroLeftTable4;
pVlcTable->kpZeroTable[5] = g_kuiZeroLeftTable5;
pVlcTable->kpZeroTable[6] = g_kuiZeroLeftTable6;
static inline void_t InitVlcTable (SVlcTable* pVlcTable) {
pVlcTable->kpChromaCoeffTokenVlcTable = g_kuiVlcChromaTable;
pVlcTable->kpTotalZerosTable[0][0] = g_kuiTotalZerosTable0;
pVlcTable->kpTotalZerosTable[0][1] = g_kuiTotalZerosTable1;
pVlcTable->kpTotalZerosTable[0][2] = g_kuiTotalZerosTable2;
pVlcTable->kpTotalZerosTable[0][3] = g_kuiTotalZerosTable3;
pVlcTable->kpTotalZerosTable[0][4] = g_kuiTotalZerosTable4;
pVlcTable->kpTotalZerosTable[0][5] = g_kuiTotalZerosTable5;
pVlcTable->kpTotalZerosTable[0][6] = g_kuiTotalZerosTable6;
pVlcTable->kpTotalZerosTable[0][7] = g_kuiTotalZerosTable7;
pVlcTable->kpTotalZerosTable[0][8] = g_kuiTotalZerosTable8;
pVlcTable->kpTotalZerosTable[0][9] = g_kuiTotalZerosTable9;
pVlcTable->kpTotalZerosTable[0][10] = g_kuiTotalZerosTable10;
pVlcTable->kpTotalZerosTable[0][11] = g_kuiTotalZerosTable11;
pVlcTable->kpTotalZerosTable[0][12] = g_kuiTotalZerosTable12;
pVlcTable->kpTotalZerosTable[0][13] = g_kuiTotalZerosTable13;
pVlcTable->kpTotalZerosTable[0][14] = g_kuiTotalZerosTable14;
pVlcTable->kpTotalZerosTable[1][0] = g_kuiTotalZerosChromaTable0;
pVlcTable->kpTotalZerosTable[1][1] = g_kuiTotalZerosChromaTable1;
pVlcTable->kpTotalZerosTable[1][2] = g_kuiTotalZerosChromaTable2;
pVlcTable->kpCoeffTokenVlcTable[0][0] = g_kuiVlcTable_0;
pVlcTable->kpCoeffTokenVlcTable[0][1] = g_kuiVlcTable_1;
pVlcTable->kpCoeffTokenVlcTable[0][2] = g_kuiVlcTable_2;
pVlcTable->kpCoeffTokenVlcTable[0][3] = g_kuiVlcTable_3;
pVlcTable->kpCoeffTokenVlcTable[1][0] = g_kuiVlcTable_0_0;
pVlcTable->kpCoeffTokenVlcTable[1][1] = g_kuiVlcTable_0_1;
pVlcTable->kpCoeffTokenVlcTable[1][2] = g_kuiVlcTable_0_2;
pVlcTable->kpCoeffTokenVlcTable[1][3] = g_kuiVlcTable_0_3;
pVlcTable->kpCoeffTokenVlcTable[2][0] = g_kuiVlcTable_1_0;
pVlcTable->kpCoeffTokenVlcTable[2][1] = g_kuiVlcTable_1_1;
pVlcTable->kpCoeffTokenVlcTable[2][2] = g_kuiVlcTable_1_2;
pVlcTable->kpCoeffTokenVlcTable[2][3] = g_kuiVlcTable_1_3;
pVlcTable->kpCoeffTokenVlcTable[3][0] = g_kuiVlcTable_2_0;
pVlcTable->kpCoeffTokenVlcTable[3][1] = g_kuiVlcTable_2_1;
pVlcTable->kpCoeffTokenVlcTable[3][2] = g_kuiVlcTable_2_2;
pVlcTable->kpCoeffTokenVlcTable[3][3] = g_kuiVlcTable_2_3;
pVlcTable->kpCoeffTokenVlcTable[3][4] = g_kuiVlcTable_2_4;
pVlcTable->kpCoeffTokenVlcTable[3][5] = g_kuiVlcTable_2_5;
pVlcTable->kpCoeffTokenVlcTable[3][6] = g_kuiVlcTable_2_6;
pVlcTable->kpCoeffTokenVlcTable[3][7] = g_kuiVlcTable_2_7;
pVlcTable->kpZeroTable[0] = g_kuiZeroLeftTable0;
pVlcTable->kpZeroTable[1] = g_kuiZeroLeftTable1;
pVlcTable->kpZeroTable[2] = g_kuiZeroLeftTable2;
pVlcTable->kpZeroTable[3] = g_kuiZeroLeftTable3;
pVlcTable->kpZeroTable[4] = g_kuiZeroLeftTable4;
pVlcTable->kpZeroTable[5] = g_kuiZeroLeftTable5;
pVlcTable->kpZeroTable[6] = g_kuiZeroLeftTable6;
pVlcTable->kpTotalZerosTable[0][0] = g_kuiTotalZerosTable0;
pVlcTable->kpTotalZerosTable[0][1] = g_kuiTotalZerosTable1;
pVlcTable->kpTotalZerosTable[0][2] = g_kuiTotalZerosTable2;
pVlcTable->kpTotalZerosTable[0][3] = g_kuiTotalZerosTable3;
pVlcTable->kpTotalZerosTable[0][4] = g_kuiTotalZerosTable4;
pVlcTable->kpTotalZerosTable[0][5] = g_kuiTotalZerosTable5;
pVlcTable->kpTotalZerosTable[0][6] = g_kuiTotalZerosTable6;
pVlcTable->kpTotalZerosTable[0][7] = g_kuiTotalZerosTable7;
pVlcTable->kpTotalZerosTable[0][8] = g_kuiTotalZerosTable8;
pVlcTable->kpTotalZerosTable[0][9] = g_kuiTotalZerosTable9;
pVlcTable->kpTotalZerosTable[0][10] = g_kuiTotalZerosTable10;
pVlcTable->kpTotalZerosTable[0][11] = g_kuiTotalZerosTable11;
pVlcTable->kpTotalZerosTable[0][12] = g_kuiTotalZerosTable12;
pVlcTable->kpTotalZerosTable[0][13] = g_kuiTotalZerosTable13;
pVlcTable->kpTotalZerosTable[0][14] = g_kuiTotalZerosTable14;
pVlcTable->kpTotalZerosTable[1][0] = g_kuiTotalZerosChromaTable0;
pVlcTable->kpTotalZerosTable[1][1] = g_kuiTotalZerosChromaTable1;
pVlcTable->kpTotalZerosTable[1][2] = g_kuiTotalZerosChromaTable2;
}

View File

@ -47,61 +47,60 @@ extern const uint8_t g_kuiChromaQp[52];
extern const uint8_t g_kuiScan8[24];
extern const uint8_t g_kuiLumaDcZigzagScan[16];
extern const uint8_t g_kuiChromaDcScan[4];
extern __align16( const uint16_t, g_kuiDequantCoeff[52][8]);
extern __align16 (const uint16_t, g_kuiDequantCoeff[52][8]);
/* Profile IDC */
typedef uint8_t ProfileIdc;
enum{
PRO_BASELINE = 66,
PRO_MAIN = 77,
PRO_EXTENDED = 88,
PRO_HIGH = 100,
PRO_HIGH10 = 110,
PRO_HIGH422 = 122,
PRO_HIGH444 = 144,
PRO_CAVLC444 = 244,
PRO_SCALABLE_BASELINE = 83,
PRO_SCALABLE_HIGH = 86,
enum {
PRO_BASELINE = 66,
PRO_MAIN = 77,
PRO_EXTENDED = 88,
PRO_HIGH = 100,
PRO_HIGH10 = 110,
PRO_HIGH422 = 122,
PRO_HIGH444 = 144,
PRO_CAVLC444 = 244,
PRO_SCALABLE_BASELINE = 83,
PRO_SCALABLE_HIGH = 86,
};
/*
* NAL Unit Type (5 Bits)
*/
typedef enum TagNalUnitType
{
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
NAL_UNIT_CODED_SLICE_DPB = 3,
NAL_UNIT_CODED_SLICE_DPC = 4,
NAL_UNIT_CODED_SLICE_IDR = 5,
NAL_UNIT_SEI = 6,
NAL_UNIT_SPS = 7,
NAL_UNIT_PPS = 8,
NAL_UNIT_AU_DELIMITER = 9,
NAL_UNIT_END_OF_SEQ = 10,
NAL_UNIT_END_OF_STR = 11,
NAL_UNIT_FILLER_DATA = 12,
NAL_UNIT_SPS_EXT = 13,
NAL_UNIT_PREFIX = 14,
NAL_UNIT_SUBSET_SPS = 15,
NAL_UNIT_RESV_16 = 16,
NAL_UNIT_RESV_17 = 17,
NAL_UNIT_RESV_18 = 18,
NAL_UNIT_AUX_CODED_SLICE = 19,
NAL_UNIT_CODED_SLICE_EXT = 20,
NAL_UNIT_RESV_21 = 21,
NAL_UNIT_RESV_22 = 22,
NAL_UNIT_RESV_23 = 23,
NAL_UNIT_UNSPEC_24 = 24,
NAL_UNIT_UNSPEC_25 = 25,
NAL_UNIT_UNSPEC_26 = 26,
NAL_UNIT_UNSPEC_27 = 27,
NAL_UNIT_UNSPEC_28 = 28,
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
}ENalUnitType;
typedef enum TagNalUnitType {
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
NAL_UNIT_CODED_SLICE_DPB = 3,
NAL_UNIT_CODED_SLICE_DPC = 4,
NAL_UNIT_CODED_SLICE_IDR = 5,
NAL_UNIT_SEI = 6,
NAL_UNIT_SPS = 7,
NAL_UNIT_PPS = 8,
NAL_UNIT_AU_DELIMITER = 9,
NAL_UNIT_END_OF_SEQ = 10,
NAL_UNIT_END_OF_STR = 11,
NAL_UNIT_FILLER_DATA = 12,
NAL_UNIT_SPS_EXT = 13,
NAL_UNIT_PREFIX = 14,
NAL_UNIT_SUBSET_SPS = 15,
NAL_UNIT_RESV_16 = 16,
NAL_UNIT_RESV_17 = 17,
NAL_UNIT_RESV_18 = 18,
NAL_UNIT_AUX_CODED_SLICE = 19,
NAL_UNIT_CODED_SLICE_EXT = 20,
NAL_UNIT_RESV_21 = 21,
NAL_UNIT_RESV_22 = 22,
NAL_UNIT_RESV_23 = 23,
NAL_UNIT_UNSPEC_24 = 24,
NAL_UNIT_UNSPEC_25 = 25,
NAL_UNIT_UNSPEC_26 = 26,
NAL_UNIT_UNSPEC_27 = 27,
NAL_UNIT_UNSPEC_28 = 28,
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
} ENalUnitType;
static const uint8_t g_kuiEmulationPreventionThreeByte = 0x03;
@ -109,27 +108,27 @@ static const uint8_t g_kuiEmulationPreventionThreeByte = 0x03;
* NAL Reference IDC (2 Bits)
*/
typedef uint8_t NalRefIdc;
enum{
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
enum {
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
};
/*
* VCL TYPE
* VCL TYPE
*/
typedef uint8_t VclType;
enum{
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
enum {
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
};
/*
* vcl type map for given NAL unit type and corresponding H264 type
*/
extern const VclType g_kuiVclTypeMap[32][2];
extern const VclType g_kuiVclTypeMap[32][2];
#define IS_VCL_NAL(t, ext_idx) (g_kuiVclTypeMap[t][ext_idx] == VCL)
#define IS_PARAM_SETS_NALS(t) ( (t) == NAL_UNIT_SPS || (t) == NAL_UNIT_PPS || (t) == NAL_UNIT_SUBSET_SPS )
@ -147,68 +146,67 @@ extern const VclType g_kuiVclTypeMap[32][2];
* Need trim when eSliceType > 4 as fixed SliceType(eSliceType-4),
* meaning mapped version after eSliceType minus 4.
*/
typedef enum TagSliceType{
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE= 3,
SI_SLICE= 4,
UNKNOWN_SLICE= 5
}ESliceType;
typedef enum TagSliceType {
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
} ESliceType;
/* Slice Types in scalable extension */
typedef uint8_t SliceTypeExt;
enum{
EP_SLICE = 0, // EP_SLICE: 0, 5
EB_SLICE = 1, // EB_SLICE: 1, 6
EI_SLICE = 2 // EI_SLICE: 2, 7
enum {
EP_SLICE = 0, // EP_SLICE: 0, 5
EB_SLICE = 1, // EB_SLICE: 1, 6
EI_SLICE = 2 // EI_SLICE: 2, 7
};
/* List Index */
typedef uint8_t ListIndex;
enum{
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
enum {
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
};
/* Picture Size */
typedef struct TagPictureSize{
int32_t iWidth;
int32_t iHeight;
}SPictureSize;
typedef struct TagPictureSize {
int32_t iWidth;
int32_t iHeight;
} SPictureSize;
/* Motion Vector components */
typedef uint8_t MvComp;
enum{
MV_X = 0,
MV_Y = 1,
MV_A = 2
enum {
MV_X = 0,
MV_Y = 1,
MV_A = 2
};
/* Chroma Components */
typedef uint8_t ChromaComp;
enum{
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
enum {
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
};
/* Position Offset structure */
typedef struct TagPosOffset{
int32_t iLeftOffset;
int32_t iTopOffset;
int32_t iRightOffset;
int32_t iBottomOffset;
}SPosOffset;
typedef struct TagPosOffset {
int32_t iLeftOffset;
int32_t iTopOffset;
int32_t iRightOffset;
int32_t iBottomOffset;
} SPosOffset;
enum EMbPosition //
{
MB_LEFT = 0x01, // A
MB_TOP = 0x02, // B
MB_TOPRIGHT = 0x04, // C
MB_TOPLEFT = 0x08, // D,
MB_PRIVATE = 0x10,
enum EMbPosition { //
MB_LEFT = 0x01, // A
MB_TOP = 0x02, // B
MB_TOPRIGHT = 0x04, // C
MB_TOPLEFT = 0x08, // D,
MB_PRIVATE = 0x10,
};
/* MB Type & Sub-MB Type */
typedef int32_t MbType;
@ -246,14 +244,14 @@ typedef int32_t SubMbType;
/*
* Memory Management Control Operation (MMCO) code
*/
enum{
MMCO_END =0,
MMCO_SHORT2UNUSED =1,
MMCO_LONG2UNUSED =2,
MMCO_SHORT2LONG =3,
MMCO_SET_MAX_LONG =4,
MMCO_RESET =5,
MMCO_LONG =6
enum {
MMCO_END = 0,
MMCO_SHORT2UNUSED = 1,
MMCO_LONG2UNUSED = 2,
MMCO_SHORT2LONG = 3,
MMCO_SET_MAX_LONG = 4,
MMCO_RESET = 5,
MMCO_LONG = 6
};
/////////intra16x16 Luma
@ -291,7 +289,7 @@ enum{
#define C_PRED_DC_L 4
#define C_PRED_DC_T 5
#define C_PRED_DC_128 6
#define C_PRED_DC_128 6
} // namespace WelsDec

View File

@ -34,7 +34,7 @@
#ifndef WELS_CONSTANCE_H__
#define WELS_CONSTANCE_H__
// Miscellaneous sizing infos
// Miscellaneous sizing infos
#ifndef MAX_FNAME_LEN
#define MAX_FNAME_LEN 256 // maximal length of file name in char size
#endif//MAX_FNAME_LEN
@ -95,10 +95,10 @@
#define MAX_ACCESS_UINT_CAPACITY 1048576 // Maximal AU capacity in bytes: (1<<20) = 1024 KB predefined
enum {
BASE_MB = 0,
NON_AVC_REWRITE_ENHANCE_MB =1,
AVC_REWRITE_ENHANCE_MB = 2
BASE_MB = 0,
NON_AVC_REWRITE_ENHANCE_MB = 1,
AVC_REWRITE_ENHANCE_MB = 2
};
#endif//WELS_CONSTANCE_H__

File diff suppressed because it is too large Load Diff

View File

@ -43,53 +43,47 @@
namespace WelsDec {
#ifdef WORDS_BIGENDIAN
inline uint32_t EndianFix(uint32_t uiX)
{
return uiX;
inline uint32_t EndianFix (uint32_t uiX) {
return uiX;
}
#else //WORDS_BIGENDIAN
#ifdef _MSC_VER
inline uint32_t EndianFix(uint32_t uiX)
{
__asm
{
mov eax, uiX
bswap eax
mov uiX, eax
}
return uiX;
inline uint32_t EndianFix (uint32_t uiX) {
__asm {
mov eax, uiX
bswap eax
mov uiX, eax
}
return uiX;
}
#else //_MSC_VER
inline uint32_t EndianFix(uint32_t uiX)
{
inline uint32_t EndianFix (uint32_t uiX) {
#ifdef ARM_ARCHv7
__asm__ __volatile__("rev %0, %0":"+r"(uiX)); //Just for the ARMv7
__asm__ __volatile__ ("rev %0, %0":"+r" (uiX)); //Just for the ARMv7
#elif defined (X86_ARCH)
__asm__ __volatile__("bswap %0":"+r"(uiX));
__asm__ __volatile__ ("bswap %0":"+r" (uiX));
#else
uiX = ((uiX & 0xff000000)>> 24) | ((uiX & 0xff0000) >> 8) |
((uiX & 0xff00) << 8) | ((uiX&0xff) << 24);
#endif
return uiX;
uiX = ((uiX & 0xff000000) >> 24) | ((uiX & 0xff0000) >> 8) |
((uiX & 0xff00) << 8) | ((uiX & 0xff) << 24);
#endif
return uiX;
}
#endif //_MSC_VER
#endif //WORDS_BIGENDIAN
inline uint32_t GetValue4Bytes( uint8_t* pDstNal )
{
uint32_t uiValue = 0;
uiValue = (pDstNal[0]<<24) | (pDstNal[1]<<16) | (pDstNal[2]<<8) | (pDstNal[3]);
return uiValue;
inline uint32_t GetValue4Bytes (uint8_t* pDstNal) {
uint32_t uiValue = 0;
uiValue = (pDstNal[0] << 24) | (pDstNal[1] << 16) | (pDstNal[2] << 8) | (pDstNal[3]);
return uiValue;
}
void_t InitReadBits( PBitStringAux pBitString )
{
pBitString->uiCurBits = GetValue4Bytes( pBitString->pCurBuf );
pBitString->pCurBuf += 4;
pBitString->iLeftBits = -16;
void_t InitReadBits (PBitStringAux pBitString) {
pBitString->uiCurBits = GetValue4Bytes (pBitString->pCurBuf);
pBitString->pCurBuf += 4;
pBitString->iLeftBits = -16;
}
/*!
@ -101,22 +95,21 @@ void_t InitReadBits( PBitStringAux pBitString )
*
* \return size of buffer data in byte; failed in -1 return
*/
int32_t InitBits( PBitStringAux pBitString, const uint8_t *kpBuf, const int32_t kiSize )
{
const int32_t kiSizeBuf = (kiSize + 7) >> 3;
uint8_t *pTmp = (uint8_t *)kpBuf;
int32_t InitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32_t kiSize) {
const int32_t kiSizeBuf = (kiSize + 7) >> 3;
uint8_t* pTmp = (uint8_t*)kpBuf;
if ( NULL == pTmp )
return -1;
if (NULL == pTmp)
return -1;
pBitString->pStartBuf = pTmp; // buffer to start position
pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length
pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex;
pBitString->pStartBuf = pTmp; // buffer to start position
pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length
pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex;
pBitString->pCurBuf = pBitString->pStartBuf;
InitReadBits( pBitString );
pBitString->pCurBuf = pBitString->pStartBuf;
InitReadBits (pBitString);
return kiSizeBuf;
return kiSizeBuf;
}
} // namespace WelsDec

View File

@ -50,160 +50,143 @@ namespace WelsDec {
#if defined(X86_ASM)
uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
{
uint32_t uiCPU = 0;
uint32_t uiFeatureA = 0, uiFeatureB = 0, uiFeatureC = 0, uiFeatureD = 0;
int32_t CacheLineSize = 0;
int8_t chVenderName[16] = { 0 };
if( !WelsCPUIdVerify() )
{
/* cpuid is not supported in cpu */
return 0;
}
WelsCPUId( 0, &uiFeatureA, (uint32_t*)&chVenderName[0],(uint32_t*)&chVenderName[8],(uint32_t*)&chVenderName[4] );
if( uiFeatureA == 0 )
{
/* maximum input value for basic cpuid information */
return 0;
}
WelsCPUId( 1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD );
if( (uiFeatureD & 0x00800000) == 0 )
{
/* Basic MMX technology is not support in cpu, mean nothing for us so return here */
return 0;
}
uiCPU = WELS_CPU_MMX;
if( uiFeatureD & 0x02000000 )
{
/* SSE technology is identical to AMD MMX extensions */
uiCPU |= WELS_CPU_MMXEXT|WELS_CPU_SSE;
}
if( uiFeatureD & 0x04000000 )
{
/* SSE2 support here */
uiCPU |= WELS_CPU_SSE2;
}
if ( uiFeatureD & 0x00000001 )
{
/* x87 FPU on-chip checking */
uiCPU |= WELS_CPU_FPU;
}
if ( uiFeatureD & 0x00008000 )
{
/* CMOV instruction checking */
uiCPU |= WELS_CPU_CMOV;
}
if ( !strcmp((const str_t*)chVenderName,CPU_Vender_INTEL) ) // confirmed_safe_unsafe_usage
{
if ( uiFeatureD & 0x10000000 )
{
/* Multi-Threading checking: contains of multiple logic processors */
uiCPU |= WELS_CPU_HTT;
}
}
if( uiFeatureC & 0x00000001 ){
/* SSE3 support here */
uiCPU |= WELS_CPU_SSE3;
}
if( uiFeatureC & 0x00000200 ){
/* SSSE3 support here */
uiCPU |= WELS_CPU_SSSE3;
}
if( uiFeatureC & 0x00080000 ){
/* SSE4.1 support here, 45nm Penryn processor */
uiCPU |= WELS_CPU_SSE41;
}
if( uiFeatureC & 0x00100000 ){
/* SSE4.2 support here, next generation Nehalem processor */
uiCPU |= WELS_CPU_SSE42;
}
if ( WelsCPUSupportAVX( uiFeatureA, uiFeatureC ) )
{
/* AVX supported */
uiCPU |= WELS_CPU_AVX;
}
if ( WelsCPUSupportFMA( uiFeatureA, uiFeatureC ) )
{
/* AVX FMA supported */
uiCPU |= WELS_CPU_FMA;
}
if ( uiFeatureC & 0x02000000 )
{
/* AES checking */
uiCPU |= WELS_CPU_AES;
}
if ( uiFeatureC & 0x00400000 )
{
/* MOVBE checking */
uiCPU |= WELS_CPU_MOVBE;
}
if ( pNumberOfLogicProcessors != NULL )
{
// HTT enabled on chip
*pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
}
WelsCPUId( 0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD );
if( (!strcmp((const str_t*)chVenderName,CPU_Vender_AMD)) && (uiFeatureA>=0x80000001) ){ // confirmed_safe_unsafe_usage
WelsCPUId(0x80000001, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD );
if( uiFeatureD&0x00400000 ){
uiCPU |= WELS_CPU_MMXEXT;
}
if( uiFeatureD&0x80000000 ){
uiCPU |= WELS_CPU_3DNOW;
}
}
if( !strcmp((const str_t*)chVenderName,CPU_Vender_INTEL) ){ // confirmed_safe_unsafe_usage
int32_t family, model;
WelsCPUId(1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
family = ((uiFeatureA>>8)&0xf) + ((uiFeatureA>>20)&0xff);
model = ((uiFeatureA>>4)&0xf) + ((uiFeatureA>>12)&0xf0);
if( (family==6) && (model==9 || model==13 || model==14) ){
uiCPU &= ~(WELS_CPU_SSE2|WELS_CPU_SSE3);
}
}
// get cache line size
if( (!strcmp((const str_t*)chVenderName,CPU_Vender_INTEL)) || !(strcmp((const str_t*)chVenderName,CPU_Vender_CYRIX)) ){ // confirmed_safe_unsafe_usage
WelsCPUId(1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
CacheLineSize = (uiFeatureB&0xff00)>>5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
if( CacheLineSize == 128 ){
uiCPU |= WELS_CPU_CACHELINE_128;
}
else if( CacheLineSize == 64 ){
uiCPU |= WELS_CPU_CACHELINE_64;
}
else if( CacheLineSize == 32 ){
uiCPU |= WELS_CPU_CACHELINE_32;
}
else if( CacheLineSize == 16 ){
uiCPU |= WELS_CPU_CACHELINE_16;
}
}
return uiCPU;
}
void WelsCPURestore( const uint32_t kuiCPU )
{
if( kuiCPU & (WELS_CPU_MMX|WELS_CPU_MMXEXT|WELS_CPU_3DNOW|WELS_CPU_3DNOWEXT) )
{
WelsEmms();
}
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uint32_t uiCPU = 0;
uint32_t uiFeatureA = 0, uiFeatureB = 0, uiFeatureC = 0, uiFeatureD = 0;
int32_t CacheLineSize = 0;
int8_t chVenderName[16] = { 0 };
if (!WelsCPUIdVerify()) {
/* cpuid is not supported in cpu */
return 0;
}
WelsCPUId (0, &uiFeatureA, (uint32_t*)&chVenderName[0], (uint32_t*)&chVenderName[8], (uint32_t*)&chVenderName[4]);
if (uiFeatureA == 0) {
/* maximum input value for basic cpuid information */
return 0;
}
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
if ((uiFeatureD & 0x00800000) == 0) {
/* Basic MMX technology is not support in cpu, mean nothing for us so return here */
return 0;
}
uiCPU = WELS_CPU_MMX;
if (uiFeatureD & 0x02000000) {
/* SSE technology is identical to AMD MMX extensions */
uiCPU |= WELS_CPU_MMXEXT | WELS_CPU_SSE;
}
if (uiFeatureD & 0x04000000) {
/* SSE2 support here */
uiCPU |= WELS_CPU_SSE2;
}
if (uiFeatureD & 0x00000001) {
/* x87 FPU on-chip checking */
uiCPU |= WELS_CPU_FPU;
}
if (uiFeatureD & 0x00008000) {
/* CMOV instruction checking */
uiCPU |= WELS_CPU_CMOV;
}
if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
if (uiFeatureD & 0x10000000) {
/* Multi-Threading checking: contains of multiple logic processors */
uiCPU |= WELS_CPU_HTT;
}
}
if (uiFeatureC & 0x00000001) {
/* SSE3 support here */
uiCPU |= WELS_CPU_SSE3;
}
if (uiFeatureC & 0x00000200) {
/* SSSE3 support here */
uiCPU |= WELS_CPU_SSSE3;
}
if (uiFeatureC & 0x00080000) {
/* SSE4.1 support here, 45nm Penryn processor */
uiCPU |= WELS_CPU_SSE41;
}
if (uiFeatureC & 0x00100000) {
/* SSE4.2 support here, next generation Nehalem processor */
uiCPU |= WELS_CPU_SSE42;
}
if (WelsCPUSupportAVX (uiFeatureA, uiFeatureC)) {
/* AVX supported */
uiCPU |= WELS_CPU_AVX;
}
if (WelsCPUSupportFMA (uiFeatureA, uiFeatureC)) {
/* AVX FMA supported */
uiCPU |= WELS_CPU_FMA;
}
if (uiFeatureC & 0x02000000) {
/* AES checking */
uiCPU |= WELS_CPU_AES;
}
if (uiFeatureC & 0x00400000) {
/* MOVBE checking */
uiCPU |= WELS_CPU_MOVBE;
}
if (pNumberOfLogicProcessors != NULL) {
// HTT enabled on chip
*pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
}
WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_AMD))
&& (uiFeatureA >= 0x80000001)) { // confirmed_safe_unsafe_usage
WelsCPUId (0x80000001, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
if (uiFeatureD & 0x00400000) {
uiCPU |= WELS_CPU_MMXEXT;
}
if (uiFeatureD & 0x80000000) {
uiCPU |= WELS_CPU_3DNOW;
}
}
if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
int32_t family, model;
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
family = ((uiFeatureA >> 8) & 0xf) + ((uiFeatureA >> 20) & 0xff);
model = ((uiFeatureA >> 4) & 0xf) + ((uiFeatureA >> 12) & 0xf0);
if ((family == 6) && (model == 9 || model == 13 || model == 14)) {
uiCPU &= ~ (WELS_CPU_SSE2 | WELS_CPU_SSE3);
}
}
// get cache line size
if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL))
|| ! (strcmp ((const str_t*)chVenderName, CPU_Vender_CYRIX))) { // confirmed_safe_unsafe_usage
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
CacheLineSize = (uiFeatureB & 0xff00) >>
5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
if (CacheLineSize == 128) {
uiCPU |= WELS_CPU_CACHELINE_128;
} else if (CacheLineSize == 64) {
uiCPU |= WELS_CPU_CACHELINE_64;
} else if (CacheLineSize == 32) {
uiCPU |= WELS_CPU_CACHELINE_32;
} else if (CacheLineSize == 16) {
uiCPU |= WELS_CPU_CACHELINE_16;
}
}
return uiCPU;
}
void WelsCPURestore (const uint32_t kuiCPU) {
if (kuiCPU & (WELS_CPU_MMX | WELS_CPU_MMXEXT | WELS_CPU_3DNOW | WELS_CPU_3DNOWEXT)) {
WelsEmms();
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -38,97 +38,90 @@
namespace WelsDec {
#define MAX_NEG_CROP 1024
uint8_t g_ClipTable[256 + 2 * MAX_NEG_CROP]; //the front 1024 is 0, the back 1024 is 255, the middle 256 elements is 0-255
uint8_t g_ClipTable[256 + 2 *
MAX_NEG_CROP]; //the front 1024 is 0, the back 1024 is 255, the middle 256 elements is 0-255
/* init pClip table to pClip the final dct data */
void_t InitDctClipTable(void_t)
{
uint8_t *p = &g_ClipTable[0];
const int32_t kiLength = MAX_NEG_CROP * sizeof(uint8_t);
int32_t i = 0;
do
{
const int32_t kiIdx = MAX_NEG_CROP + i;
void_t InitDctClipTable (void_t) {
uint8_t* p = &g_ClipTable[0];
const int32_t kiLength = MAX_NEG_CROP * sizeof (uint8_t);
int32_t i = 0;
p[kiIdx] = i;
p[1+kiIdx] = 1+i;
p[2+kiIdx] = 2+i;
p[3+kiIdx] = 3+i;
do {
const int32_t kiIdx = MAX_NEG_CROP + i;
i += 4;
} while(i < 256);
p[kiIdx] = i;
p[1 + kiIdx] = 1 + i;
p[2 + kiIdx] = 2 + i;
p[3 + kiIdx] = 3 + i;
memset( p, 0, kiLength);
memset( p + MAX_NEG_CROP + 256, 0xFF, kiLength);
i += 4;
} while (i < 256);
memset (p, 0, kiLength);
memset (p + MAX_NEG_CROP + 256, 0xFF, kiLength);
}
//NOTE::: p_RS should NOT be modified and it will lead to mismatch with JSVM.
// so should allocate kA array to store the temporary value (idct).
void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs)
{
int16_t iSrc[16];
void_t IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
int16_t iSrc[16];
uint8_t *pDst = pPred;
const int32_t kiStride2 = kiStride<<1;
const int32_t kiStride3 = kiStride + kiStride2;
uint8_t *pClip = &g_ClipTable[MAX_NEG_CROP];
int32_t i;
uint8_t* pDst = pPred;
const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* pClip = &g_ClipTable[MAX_NEG_CROP];
int32_t i;
for(i=0; i<4; i++)
{
const int32_t kiY = i<<2;
const int32_t kiT0 = pRs[kiY] + pRs[kiY+2];
const int32_t kiT1 = pRs[kiY] - pRs[kiY+2];
const int32_t kiT2 = (pRs[kiY+1]>>1) - pRs[kiY+3];
const int32_t kiT3 = pRs[kiY+1] + (pRs[kiY+3]>>1);
for (i = 0; i < 4; i++) {
const int32_t kiY = i << 2;
const int32_t kiT0 = pRs[kiY] + pRs[kiY + 2];
const int32_t kiT1 = pRs[kiY] - pRs[kiY + 2];
const int32_t kiT2 = (pRs[kiY + 1] >> 1) - pRs[kiY + 3];
const int32_t kiT3 = pRs[kiY + 1] + (pRs[kiY + 3] >> 1);
iSrc[kiY] = kiT0 + kiT3;
iSrc[kiY+1] = kiT1 + kiT2;
iSrc[kiY+2] = kiT1 - kiT2;
iSrc[kiY+3] = kiT0 - kiT3;
}
iSrc[kiY] = kiT0 + kiT3;
iSrc[kiY + 1] = kiT1 + kiT2;
iSrc[kiY + 2] = kiT1 - kiT2;
iSrc[kiY + 3] = kiT0 - kiT3;
}
for(i=0; i<4; i++)
{
int32_t kT1 = iSrc[i] + iSrc[i+8];
int32_t kT2 = iSrc[i+4] + (iSrc[i+12]>>1);
int32_t kT3 = (32 + kT1 + kT2) >> 6;
int32_t kT4 = (32 + kT1 - kT2) >> 6;
pDst[i] = pClip[ kT3 + pPred[i] ];
pDst[i+kiStride3] = pClip[ kT4 + pPred[i+kiStride3] ];
for (i = 0; i < 4; i++) {
int32_t kT1 = iSrc[i] + iSrc[i + 8];
int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1);
int32_t kT3 = (32 + kT1 + kT2) >> 6;
int32_t kT4 = (32 + kT1 - kT2) >> 6;
kT1 = iSrc[i] - iSrc[i+8];
kT2 = (iSrc[i+4]>>1) - iSrc[i+12];
pDst[i+kiStride] = pClip[ ((32 + kT1 + kT2) >> 6) + pDst[i+kiStride] ];
pDst[i+kiStride2] = pClip[ ((32 + kT1 - kT2) >> 6) + pDst[i+kiStride2] ];
}
pDst[i] = pClip[ kT3 + pPred[i] ];
pDst[i + kiStride3] = pClip[ kT4 + pPred[i + kiStride3] ];
kT1 = iSrc[i] - iSrc[i + 8];
kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12];
pDst[i + kiStride] = pClip[ ((32 + kT1 + kT2) >> 6) + pDst[i + kiStride] ];
pDst[i + kiStride2] = pClip[ ((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2] ];
}
}
void_t GetI4LumaIChromaAddrTable(int32_t *pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride)
{
int32_t *pOffset = pBlockOffset;
int32_t i;
const uint8_t kuiScan0 = g_kuiScan8[0];
void_t GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) {
int32_t* pOffset = pBlockOffset;
int32_t i;
const uint8_t kuiScan0 = g_kuiScan8[0];
for(i=0; i<16; i++)
{
const uint32_t kuiA = g_kuiScan8[i] - kuiScan0;
const uint32_t kuiX = kuiA & 0x07;
const uint32_t kuiY = kuiA >> 3;
for (i = 0; i < 16; i++) {
const uint32_t kuiA = g_kuiScan8[i] - kuiScan0;
const uint32_t kuiX = kuiA & 0x07;
const uint32_t kuiY = kuiA >> 3;
pOffset[i]= (kuiX + kiYStride* kuiY) << 2;
}
pOffset[i] = (kuiX + kiYStride * kuiY) << 2;
}
for(i=0; i<4; i++)
{
const uint32_t kuiA = g_kuiScan8[i] - kuiScan0;
for (i = 0; i < 4; i++) {
const uint32_t kuiA = g_kuiScan8[i] - kuiScan0;
pOffset[16+i]=
pOffset[20+i]= ((kuiA & 0x07) + (kiUVStride/*>>1*/) * (kuiA >> 3)) << 2;
}
pOffset[16 + i] =
pOffset[20 + i] = ((kuiA & 0x07) + (kiUVStride/*>>1*/) * (kuiA >> 3)) << 2;
}
}
} // namespace WelsDec

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -39,127 +39,121 @@
namespace WelsDec {
// rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009
static inline void_t ExpandPictureLuma_c( uint8_t *pDst, const int32_t kiStride, const int32_t kiPicWidth, const int32_t kiPicHeight )
{
uint8_t *pTmp = pDst;
uint8_t *pDstLastLine = pTmp + (kiPicHeight-1) * kiStride;
const int32_t kiPaddingLen = PADDING_LENGTH;
const uint8_t kuiTopLeft = pTmp[0];
const uint8_t kuiTopRight = pTmp[kiPicWidth-1];
const uint8_t kuiBottomLeft = pDstLastLine[0];
const uint8_t kuiBottomRight= pDstLastLine[kiPicWidth-1];
int32_t i = 0;
static inline void_t ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
const int32_t kiPicHeight) {
uint8_t* pTmp = pDst;
uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride;
const int32_t kiPaddingLen = PADDING_LENGTH;
const uint8_t kuiTopLeft = pTmp[0];
const uint8_t kuiTopRight = pTmp[kiPicWidth - 1];
const uint8_t kuiBottomLeft = pDstLastLine[0];
const uint8_t kuiBottomRight = pDstLastLine[kiPicWidth - 1];
int32_t i = 0;
do {
const int32_t kiStrides = (1+i) * kiStride;
uint8_t* pTop = pTmp - kiStrides;
uint8_t* pBottom = pDstLastLine + kiStrides;
// pad pTop and pBottom
memcpy(pTop, pTmp, kiPicWidth);
memcpy(pBottom, pDstLastLine, kiPicWidth);
// pad corners
memset(pTop-kiPaddingLen, kuiTopLeft, kiPaddingLen); //pTop left
memset(pTop+kiPicWidth, kuiTopRight, kiPaddingLen); //pTop right
memset(pBottom-kiPaddingLen, kuiBottomLeft, kiPaddingLen); //pBottom left
memset(pBottom+kiPicWidth, kuiBottomRight, kiPaddingLen); //pBottom right
++ i;
} while( i < kiPaddingLen );
do {
const int32_t kiStrides = (1 + i) * kiStride;
uint8_t* pTop = pTmp - kiStrides;
uint8_t* pBottom = pDstLastLine + kiStrides;
// pad left and right
i = 0;
do {
memset(pTmp-kiPaddingLen, pTmp[0], kiPaddingLen);
memset(pTmp+kiPicWidth, pTmp[kiPicWidth-1], kiPaddingLen);
// pad pTop and pBottom
memcpy (pTop, pTmp, kiPicWidth);
memcpy (pBottom, pDstLastLine, kiPicWidth);
pTmp += kiStride;
++ i;
} while( i < kiPicHeight );
// pad corners
memset (pTop - kiPaddingLen, kuiTopLeft, kiPaddingLen); //pTop left
memset (pTop + kiPicWidth, kuiTopRight, kiPaddingLen); //pTop right
memset (pBottom - kiPaddingLen, kuiBottomLeft, kiPaddingLen); //pBottom left
memset (pBottom + kiPicWidth, kuiBottomRight, kiPaddingLen); //pBottom right
++ i;
} while (i < kiPaddingLen);
// pad left and right
i = 0;
do {
memset (pTmp - kiPaddingLen, pTmp[0], kiPaddingLen);
memset (pTmp + kiPicWidth, pTmp[kiPicWidth - 1], kiPaddingLen);
pTmp += kiStride;
++ i;
} while (i < kiPicHeight);
}
static inline void_t ExpandPictureChroma_c( uint8_t *pDst, const int32_t kiStride, const int32_t kiPicWidth, const int32_t kiPicHeight )
{
uint8_t *pTmp = pDst;
uint8_t *pDstLastLine = pTmp + (kiPicHeight-1) * kiStride;
const int32_t kiPaddingLen = (PADDING_LENGTH>>1);
const uint8_t kuiTopLeft = pTmp[0];
const uint8_t kuiTopRight = pTmp[kiPicWidth-1];
const uint8_t kuiBottomLeft = pDstLastLine[0];
const uint8_t kuiBottomRight= pDstLastLine[kiPicWidth-1];
int32_t i = 0;
do {
const int32_t kiStrides = (1+i) * kiStride;
uint8_t* pTop = pTmp - kiStrides;
uint8_t* pBottom = pDstLastLine + kiStrides;
// pad pTop and pBottom
memcpy(pTop, pTmp, kiPicWidth);
memcpy(pBottom, pDstLastLine, kiPicWidth);
// pad corners
memset(pTop-kiPaddingLen, kuiTopLeft, kiPaddingLen); //pTop left
memset(pTop+kiPicWidth, kuiTopRight, kiPaddingLen); //pTop right
memset(pBottom-kiPaddingLen, kuiBottomLeft, kiPaddingLen); //pBottom left
memset(pBottom+kiPicWidth, kuiBottomRight, kiPaddingLen); //pBottom right
++ i;
} while( i < kiPaddingLen );
// pad left and right
i = 0;
do {
memset(pTmp-kiPaddingLen, pTmp[0], kiPaddingLen);
memset(pTmp+kiPicWidth, pTmp[kiPicWidth-1], kiPaddingLen);
pTmp += kiStride;
++ i;
} while( i < kiPicHeight );
static inline void_t ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
const int32_t kiPicHeight) {
uint8_t* pTmp = pDst;
uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride;
const int32_t kiPaddingLen = (PADDING_LENGTH >> 1);
const uint8_t kuiTopLeft = pTmp[0];
const uint8_t kuiTopRight = pTmp[kiPicWidth - 1];
const uint8_t kuiBottomLeft = pDstLastLine[0];
const uint8_t kuiBottomRight = pDstLastLine[kiPicWidth - 1];
int32_t i = 0;
do {
const int32_t kiStrides = (1 + i) * kiStride;
uint8_t* pTop = pTmp - kiStrides;
uint8_t* pBottom = pDstLastLine + kiStrides;
// pad pTop and pBottom
memcpy (pTop, pTmp, kiPicWidth);
memcpy (pBottom, pDstLastLine, kiPicWidth);
// pad corners
memset (pTop - kiPaddingLen, kuiTopLeft, kiPaddingLen); //pTop left
memset (pTop + kiPicWidth, kuiTopRight, kiPaddingLen); //pTop right
memset (pBottom - kiPaddingLen, kuiBottomLeft, kiPaddingLen); //pBottom left
memset (pBottom + kiPicWidth, kuiBottomRight, kiPaddingLen); //pBottom right
++ i;
} while (i < kiPaddingLen);
// pad left and right
i = 0;
do {
memset (pTmp - kiPaddingLen, pTmp[0], kiPaddingLen);
memset (pTmp + kiPicWidth, pTmp[kiPicWidth - 1], kiPaddingLen);
pTmp += kiStride;
++ i;
} while (i < kiPicHeight);
}
void_t InitExpandPictureFunc( SExpandPicFunc *pExpandPicFunc, const uint32_t kuiCpuFlags )
{
pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_c;
pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChroma_c;
pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChroma_c;
void_t InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCpuFlags) {
pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_c;
pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChroma_c;
pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChroma_c;
#if defined(X86_ASM)
if ( (kuiCpuFlags & WELS_CPU_SSE2) == WELS_CPU_SSE2 )
{
pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_sse2;
pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChromaUnalign_sse2;
pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChromaAlign_sse2;
}
if ((kuiCpuFlags & WELS_CPU_SSE2) == WELS_CPU_SSE2) {
pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_sse2;
pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChromaUnalign_sse2;
pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChromaAlign_sse2;
}
#endif//X86_ASM
}
void_t ExpandReferencingPicture(PPicture pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChroma[2])
{
/*local variable*/
uint8_t *pPicY = pPic->pData[0];
uint8_t *pPicCb = pPic->pData[1];
uint8_t *pPicCr = pPic->pData[2];
const int32_t kiWidthY = pPic->iWidthInPixel;
const int32_t kiHeightY = pPic->iHeightInPixel;
const int32_t kiWidthUV = kiWidthY >> 1;
const int32_t kiHeightUV= kiHeightY >> 1;
pExpLuma(pPicY, pPic->iLinesize[0], kiWidthY, kiHeightY);
if ( kiWidthUV >= 16 )
{
// fix coding picture size as 16x16 issues 7/27/2010
const bool_t kbChrAligned= /*(kiWidthUV >= 16) && */((kiWidthUV & 0x0F) == 0); // chroma planes: (16+kiWidthUV) & 15
pExpChroma[kbChrAligned](pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV);
pExpChroma[kbChrAligned](pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV);
}
else
{
// fix coding picture size as 16x16 issues 7/27/2010
ExpandPictureChroma_c(pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV);
ExpandPictureChroma_c(pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV);
}
void_t ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChroma[2]) {
/*local variable*/
uint8_t* pPicY = pPic->pData[0];
uint8_t* pPicCb = pPic->pData[1];
uint8_t* pPicCr = pPic->pData[2];
const int32_t kiWidthY = pPic->iWidthInPixel;
const int32_t kiHeightY = pPic->iHeightInPixel;
const int32_t kiWidthUV = kiWidthY >> 1;
const int32_t kiHeightUV = kiHeightY >> 1;
pExpLuma (pPicY, pPic->iLinesize[0], kiWidthY, kiHeightY);
if (kiWidthUV >= 16) {
// fix coding picture size as 16x16 issues 7/27/2010
const bool_t kbChrAligned = /*(kiWidthUV >= 16) && */ ((kiWidthUV & 0x0F) == 0); // chroma planes: (16+kiWidthUV) & 15
pExpChroma[kbChrAligned] (pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV);
pExpChroma[kbChrAligned] (pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV);
} else {
// fix coding picture size as 16x16 issues 7/27/2010
ExpandPictureChroma_c (pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV);
ExpandPictureChroma_c (pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV);
}
}
} // namespace WelsDec

View File

@ -39,7 +39,7 @@
*/
#include <string.h>
#include "fmo.h"
#include "fmo.h"
#include "macros.h"
#include "utils.h"
#include "mem_align.h"
@ -50,41 +50,39 @@ namespace WelsDec {
* \brief Generate MB allocated map for interleaved slice group (TYPE 0)
*
* \param pFmo fmo context
* \param pPps pps context
* \param pPps pps context
*
* \return 0 - successful; none 0 - failed
*/
static inline int32_t FmoGenerateMbAllocMapType0( PFmo pFmo, PPps pPps )
{
uint32_t uiNumSliceGroups = 0;
int32_t iMbNum = 0;
int32_t i = 0;
static inline int32_t FmoGenerateMbAllocMapType0 (PFmo pFmo, PPps pPps) {
uint32_t uiNumSliceGroups = 0;
int32_t iMbNum = 0;
int32_t i = 0;
WELS_VERIFY_RETURN_IF( 1, ( NULL == pFmo || NULL == pPps ) )
uiNumSliceGroups = pPps->uiNumSliceGroups;
iMbNum = pFmo->iCountMbNum;
WELS_VERIFY_RETURN_IF( 1, ( NULL == pFmo->pMbAllocMap || iMbNum <= 0 || uiNumSliceGroups >= MAX_SLICEGROUP_IDS ) )
do
{
uint8_t uiGroup = 0;
do {
const int32_t kiRunIdx = pPps->uiRunLength[uiGroup];
int32_t j = 0;
do {
pFmo->pMbAllocMap[i+j] = uiGroup;
++ j;
} while(j < kiRunIdx && i + j < iMbNum);
i += kiRunIdx;
++ uiGroup;
} while(uiGroup < uiNumSliceGroups && i < iMbNum);
}while(i < iMbNum);
return 0; // well here
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == pPps))
uiNumSliceGroups = pPps->uiNumSliceGroups;
iMbNum = pFmo->iCountMbNum;
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap || iMbNum <= 0 || uiNumSliceGroups >= MAX_SLICEGROUP_IDS))
do {
uint8_t uiGroup = 0;
do {
const int32_t kiRunIdx = pPps->uiRunLength[uiGroup];
int32_t j = 0;
do {
pFmo->pMbAllocMap[i + j] = uiGroup;
++ j;
} while (j < kiRunIdx && i + j < iMbNum);
i += kiRunIdx;
++ uiGroup;
} while (uiGroup < uiNumSliceGroups && i < iMbNum);
} while (i < iMbNum);
return 0; // well here
}
/*!
* \brief Generate MB allocated map for dispersed slice group (TYPE 1)
* \brief Generate MB allocated map for dispersed slice group (TYPE 1)
*
* \param pFmo fmo context
* \param pPps pps context
@ -92,98 +90,93 @@ static inline int32_t FmoGenerateMbAllocMapType0( PFmo pFmo, PPps pPps )
*
* \return 0 - successful; none 0 - failed
*/
static inline int32_t FmoGenerateMbAllocMapType1( PFmo pFmo, PPps pPps, const int32_t kiMbWidth )
{
uint32_t uiNumSliceGroups = 0;
int32_t iMbNum = 0;
int16_t i = 0;
WELS_VERIFY_RETURN_IF( 1, ( NULL == pFmo || NULL == pPps ) )
uiNumSliceGroups = pPps->uiNumSliceGroups;
iMbNum = pFmo->iCountMbNum;
WELS_VERIFY_RETURN_IF( 1, ( NULL == pFmo->pMbAllocMap || iMbNum <= 0 || kiMbWidth == 0 || uiNumSliceGroups >= MAX_SLICEGROUP_IDS ) )
do
{
pFmo->pMbAllocMap[i] = (uint8_t)(((i % kiMbWidth)+(((i / kiMbWidth)*uiNumSliceGroups)>>1)) % uiNumSliceGroups);
++ i;
}while (i < iMbNum);
return 0; // well here
static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const int32_t kiMbWidth) {
uint32_t uiNumSliceGroups = 0;
int32_t iMbNum = 0;
int16_t i = 0;
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == pPps))
uiNumSliceGroups = pPps->uiNumSliceGroups;
iMbNum = pFmo->iCountMbNum;
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap || iMbNum <= 0 || kiMbWidth == 0
|| uiNumSliceGroups >= MAX_SLICEGROUP_IDS))
do {
pFmo->pMbAllocMap[i] = (uint8_t) (((i % kiMbWidth) + (((i / kiMbWidth) * uiNumSliceGroups) >> 1)) % uiNumSliceGroups);
++ i;
} while (i < iMbNum);
return 0; // well here
}
/*!
* \brief Generate MB allocated map for various type of slice group cases (TYPE 0, .., 6)
*
* \param pFmo fmo context
* \param pFmo fmo context
* \param pPps pps context
* \param kiMbWidth MB width
* \param kiMbHeight MB height
*
* \return 0 - successful; none 0 - failed
* \return 0 - successful; none 0 - failed
*/
static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth, const int32_t kiMbHeight )
{
int32_t iNumMb = 0;
int32_t iErr = 0;
bool_t bResolutionChanged = false;
static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth,
const int32_t kiMbHeight) {
int32_t iNumMb = 0;
int32_t iErr = 0;
bool_t bResolutionChanged = false;
// the cases we would not like
WELS_VERIFY_RETURN_IF( 1, ( NULL == pFmo || NULL == kpPps ) )
iNumMb = pFmo->iCountMbNum;
// the cases we would not like
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == kpPps))
iNumMb = kiMbWidth * kiMbHeight;
if ( 0 == iNumMb )
return 1;
iNumMb = pFmo->iCountMbNum;
iNumMb = kiMbWidth * kiMbHeight;
if (0 == iNumMb)
return 1;
WelsFree(pFmo->pMbAllocMap, "_fmo->pMbAllocMap");
pFmo->pMbAllocMap = (uint8_t *)WelsMalloc( iNumMb * sizeof(uint8_t), "_fmo->pMbAllocMap" );
WELS_VERIFY_RETURN_IF( 1, (NULL == pFmo->pMbAllocMap) ) // out of memory
pFmo->iCountMbNum = iNumMb;
WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap");
pFmo->pMbAllocMap = (uint8_t*)WelsMalloc (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory
if ( kpPps->uiNumSliceGroups < 2 && iNumMb > 0) // only one slice group, exactly it is single slice based
{
memset ( pFmo->pMbAllocMap, 0, iNumMb * sizeof(int8_t)); // for safe
pFmo->iSliceGroupCount = 1;
return 0;
}
if ( bResolutionChanged || ((int32_t)kpPps->uiSliceGroupMapType != pFmo->iSliceGroupType)
|| ((int32_t)kpPps->uiNumSliceGroups != pFmo->iSliceGroupCount) )
{
switch ( kpPps->uiSliceGroupMapType )
{
case 0:
iErr = FmoGenerateMbAllocMapType0( pFmo, kpPps );
break;
case 1:
iErr = FmoGenerateMbAllocMapType1( pFmo, kpPps, kiMbWidth );
break;
case 2:
case 3:
case 4:
case 5:
case 6:
// Reserve for others slice group type
iErr = 1;
break;
default:
return 1;
}
}
if ( 0 == iErr ) // well now
{
pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups;
pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType;
}
pFmo->iCountMbNum = iNumMb;
return iErr;
if (kpPps->uiNumSliceGroups < 2 && iNumMb > 0) { // only one slice group, exactly it is single slice based
memset (pFmo->pMbAllocMap, 0, iNumMb * sizeof (int8_t)); // for safe
pFmo->iSliceGroupCount = 1;
return 0;
}
if (bResolutionChanged || ((int32_t)kpPps->uiSliceGroupMapType != pFmo->iSliceGroupType)
|| ((int32_t)kpPps->uiNumSliceGroups != pFmo->iSliceGroupCount)) {
switch (kpPps->uiSliceGroupMapType) {
case 0:
iErr = FmoGenerateMbAllocMapType0 (pFmo, kpPps);
break;
case 1:
iErr = FmoGenerateMbAllocMapType1 (pFmo, kpPps, kiMbWidth);
break;
case 2:
case 3:
case 4:
case 5:
case 6:
// Reserve for others slice group type
iErr = 1;
break;
default:
return 1;
}
}
if (0 == iErr) { // well now
pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups;
pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType;
}
return iErr;
}
/*!
@ -196,9 +189,8 @@ static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const
*
* \return 0 - successful; none 0 - failed;
*/
int32_t InitFmo( PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight )
{
return FmoGenerateSliceGroup( pFmo, pPps, kiMbWidth, kiMbHeight );
int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight) {
return FmoGenerateSliceGroup (pFmo, pPps, kiMbWidth, kiMbHeight);
}
@ -211,35 +203,32 @@ int32_t InitFmo( PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki
*
* \return NONE
*/
void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail )
{
PFmo pIter = pFmo;
int32_t i = 0;
int32_t iFreeNodes = 0;
void_t UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) {
PFmo pIter = pFmo;
int32_t i = 0;
int32_t iFreeNodes = 0;
if ( NULL == pIter || kiAvail <= 0 || kiCnt < kiAvail )
return;
if (NULL == pIter || kiAvail <= 0 || kiCnt < kiAvail)
return;
while ( i < kiCnt ) {
if ( pIter != NULL && pIter->bActiveFlag )
{
if ( NULL != pIter->pMbAllocMap )
{
WelsFree( pIter->pMbAllocMap, "pIter->pMbAllocMap" );
while (i < kiCnt) {
if (pIter != NULL && pIter->bActiveFlag) {
if (NULL != pIter->pMbAllocMap) {
WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap");
pIter->pMbAllocMap = NULL;
}
pIter->iSliceGroupCount = 0;
pIter->iSliceGroupType = -1;
pIter->iCountMbNum = 0;
pIter->bActiveFlag = false;
++ iFreeNodes;
if ( iFreeNodes >= kiAvail )
break;
}
++ pIter;
++ i;
}
pIter->pMbAllocMap = NULL;
}
pIter->iSliceGroupCount = 0;
pIter->iSliceGroupType = -1;
pIter->iCountMbNum = 0;
pIter->bActiveFlag = false;
++ iFreeNodes;
if (iFreeNodes >= kiAvail)
break;
}
++ pIter;
++ i;
}
}
/*!
@ -252,14 +241,14 @@ void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail )
*
* \return true - changed or not initialized yet; false - not change at all
*/
bool_t FmoParamSetsChanged( PFmo pFmo, const int32_t kiCountNumMb, const int32_t kiSliceGroupType, const int32_t kiSliceGroupCount )
{
WELS_VERIFY_RETURN_IF( false, (NULL == pFmo) )
return ( (!pFmo->bActiveFlag)
|| (kiCountNumMb != pFmo->iCountMbNum)
|| (kiSliceGroupType != pFmo->iSliceGroupType)
|| (kiSliceGroupCount != pFmo->iSliceGroupCount) );
bool_t FmoParamSetsChanged (PFmo pFmo, const int32_t kiCountNumMb, const int32_t kiSliceGroupType,
const int32_t kiSliceGroupCount) {
WELS_VERIFY_RETURN_IF (false, (NULL == pFmo))
return ((!pFmo->bActiveFlag)
|| (kiCountNumMb != pFmo->iCountMbNum)
|| (kiSliceGroupType != pFmo->iSliceGroupType)
|| (kiSliceGroupCount != pFmo->iSliceGroupCount));
}
/*!
@ -272,51 +261,44 @@ bool_t FmoParamSetsChanged( PFmo pFmo, const int32_t kiCountNumMb, const int32_t
*
* \return true - update/insert successfully; false - failed;
*/
bool_t FmoParamUpdate( PFmo pFmo, PSps pSps, PPps pPps, int32_t *pActiveFmoNum )
{
const uint32_t kuiMbWidth = pSps->iMbWidth;
const uint32_t kuiMbHeight= pSps->iMbHeight;
bool_t FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) {
const uint32_t kuiMbWidth = pSps->iMbWidth;
const uint32_t kuiMbHeight = pSps->iMbHeight;
if ( FmoParamSetsChanged( pFmo,
kuiMbWidth * kuiMbHeight,
pPps->uiSliceGroupMapType,
pPps->uiNumSliceGroups ) )
{
if (FmoParamSetsChanged (pFmo,
kuiMbWidth * kuiMbHeight,
pPps->uiSliceGroupMapType,
pPps->uiNumSliceGroups)) {
if ( InitFmo( pFmo, pPps, kuiMbWidth, kuiMbHeight ) )
{
return false;
}
else
{
if ( !pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT )
{
++ (*pActiveFmoNum);
pFmo->bActiveFlag = true;
}
}
}
if (InitFmo (pFmo, pPps, kuiMbWidth, kuiMbHeight)) {
return false;
} else {
if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) {
++ (*pActiveFmoNum);
pFmo->bActiveFlag = true;
}
}
}
return true;
return true;
}
/*!
* \brief Convert kMbXy to slice group idc correspondingly
*
* \param pFmo Wels fmo context
* \param kMbXy kMbXy to be converted
* \param kMbXy kMbXy to be converted
*
* \return slice group idc - successful; -1 - failed;
*/
int32_t FmoMbToSliceGroup( PFmo pFmo, const MB_XY_T kiMbXy )
{
const int32_t kiMbNum = pFmo->iCountMbNum;
const uint8_t* kpMbMap = pFmo->pMbAllocMap;
if ( kiMbXy < 0 || kiMbXy >= kiMbNum || kpMbMap == NULL)
return -1;
return kpMbMap[ kiMbXy ];
int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) {
const int32_t kiMbNum = pFmo->iCountMbNum;
const uint8_t* kpMbMap = pFmo->pMbAllocMap;
if (kiMbXy < 0 || kiMbXy >= kiMbNum || kpMbMap == NULL)
return -1;
return kpMbMap[ kiMbXy ];
}
/*!
@ -327,29 +309,28 @@ int32_t FmoMbToSliceGroup( PFmo pFmo, const MB_XY_T kiMbXy )
*
* \return iNextMb - successful; -1 - failed;
*/
MB_XY_T FmoNextMb( PFmo pFmo, const MB_XY_T kiMbXy )
{
const int32_t kiTotalMb = pFmo->iCountMbNum;
const uint8_t* kpMbMap = pFmo->pMbAllocMap;
MB_XY_T iNextMb = kiMbXy;
const uint8_t kuiSliceGroupIdc = (uint8_t)FmoMbToSliceGroup( pFmo, kiMbXy );
if (kuiSliceGroupIdc == (uint8_t)(-1))
return -1;
do {
++ iNextMb;
if (iNextMb >= kiTotalMb){
iNextMb = -1;
break;
}
if (kpMbMap[iNextMb] == kuiSliceGroupIdc){
break;
}
} while( 1 );
// -1: No further MB in this slice (could be end of picture)
return iNextMb;
MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy) {
const int32_t kiTotalMb = pFmo->iCountMbNum;
const uint8_t* kpMbMap = pFmo->pMbAllocMap;
MB_XY_T iNextMb = kiMbXy;
const uint8_t kuiSliceGroupIdc = (uint8_t)FmoMbToSliceGroup (pFmo, kiMbXy);
if (kuiSliceGroupIdc == (uint8_t) (-1))
return -1;
do {
++ iNextMb;
if (iNextMb >= kiTotalMb) {
iNextMb = -1;
break;
}
if (kpMbMap[iNextMb] == kuiSliceGroupIdc) {
break;
}
} while (1);
// -1: No further MB in this slice (could be end of picture)
return iNextMb;
}
} // namespace WelsDec

File diff suppressed because it is too large Load Diff

View File

@ -47,529 +47,511 @@
namespace WelsDec {
static void_t SetUnRef(PPicture pRef)
{
if( NULL != pRef)
{
pRef->bUsedAsRef = false;
pRef->bIsLongRef = false;
pRef->iFrameNum = -1;
pRef->iFramePoc = 0;
pRef->iLongTermFrameIdx = -1;
pRef->bRefBaseFlag = 0;
pRef->uiQualityId = -1;
pRef->uiTemporalId = -1;
pRef->uiSpatialId = -1;
pRef->iSpsId = -1;
}
static void_t SetUnRef (PPicture pRef) {
if (NULL != pRef) {
pRef->bUsedAsRef = false;
pRef->bIsLongRef = false;
pRef->iFrameNum = -1;
pRef->iFramePoc = 0;
pRef->iLongTermFrameIdx = -1;
pRef->bRefBaseFlag = 0;
pRef->uiQualityId = -1;
pRef->uiTemporalId = -1;
pRef->uiSpatialId = -1;
pRef->iSpsId = -1;
}
}
//reset pRefList when
// 1.sps arrived that is new sequence starting
// 2.IDR NAL i.e. 1st layer in IDR AU
void_t WelsResetRefPic(PWelsDecoderContext pCtx)
{
int32_t i = 0;
PRefPic pRefPic = &pCtx->sRefPic;
pCtx->sRefPic.uiLongRefCount[0] = pCtx->sRefPic.uiShortRefCount[0] = 0;
void_t WelsResetRefPic (PWelsDecoderContext pCtx) {
int32_t i = 0;
PRefPic pRefPic = &pCtx->sRefPic;
pCtx->sRefPic.uiLongRefCount[0] = pCtx->sRefPic.uiShortRefCount[0] = 0;
pRefPic->uiRefCount[LIST_0] = 0;
for(i=0; i < MAX_SHORT_REF_COUNT; i++) {
if ( pRefPic->pShortRefList[LIST_0][i] != NULL){
SetUnRef(pRefPic->pShortRefList[LIST_0][i]);
pRefPic->pShortRefList[LIST_0][i] = NULL;
}
}
pRefPic->uiShortRefCount[LIST_0] = 0;
pRefPic->uiRefCount[LIST_0] = 0;
for(i=0; i < MAX_LONG_REF_COUNT; i++){
if (pRefPic->pLongRefList[LIST_0][i] != NULL) {
SetUnRef(pRefPic->pLongRefList[LIST_0][i]);
pRefPic->pLongRefList[LIST_0][i] = NULL;
}
}
pRefPic->uiLongRefCount[LIST_0] = 0;
for (i = 0; i < MAX_SHORT_REF_COUNT; i++) {
if (pRefPic->pShortRefList[LIST_0][i] != NULL) {
SetUnRef (pRefPic->pShortRefList[LIST_0][i]);
pRefPic->pShortRefList[LIST_0][i] = NULL;
}
}
pRefPic->uiShortRefCount[LIST_0] = 0;
for (i = 0; i < MAX_LONG_REF_COUNT; i++) {
if (pRefPic->pLongRefList[LIST_0][i] != NULL) {
SetUnRef (pRefPic->pLongRefList[LIST_0][i]);
pRefPic->pLongRefList[LIST_0][i] = NULL;
}
}
pRefPic->uiLongRefCount[LIST_0] = 0;
}
/**
* fills the pRefPic.pRefList.
*/
int32_t WelsInitRefList(PWelsDecoderContext pCtx, int32_t iPoc)
{
int32_t i,j, iCount=0;
const bool_t kbUseRefBasePicFlag = pCtx->pCurDqLayer->bUseRefBasePicFlag;
PPicture* ppShoreRefList = pCtx->sRefPic.pShortRefList[LIST_0];
PPicture* ppLongRefList = pCtx->sRefPic.pLongRefList[LIST_0];
memset(pCtx->sRefPic.pRefList[LIST_0],0,MAX_REF_PIC_COUNT*sizeof(PPicture));
//short
for(i=0; i<pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i){
if( kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag ) {
pCtx->sRefPic.pRefList[LIST_0][iCount++ ]= ppShoreRefList[i];
}else{
for ( j = 0;j<pCtx->sRefPic.uiShortRefCount[LIST_0];++j)
{
if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum && ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag)
{
break;
}
}
if (j == pCtx->sRefPic.uiShortRefCount[LIST_0])
{
pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i];
}
}
}
//long
j = 0;
for(i=0; i< pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i){
if(kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag){
pCtx->sRefPic.pRefList[LIST_0][iCount++ ]= ppLongRefList[i];
}else{
for ( j = 0;j<pCtx->sRefPic.uiLongRefCount[LIST_0];++j)
{
if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx && ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag)
{
break;
}
}
if (j == pCtx->sRefPic.uiLongRefCount[LIST_0])
{
pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i];
}
}
}
pCtx->sRefPic.uiRefCount[LIST_0] = iCount;
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) {
int32_t i, j, iCount = 0;
const bool_t kbUseRefBasePicFlag = pCtx->pCurDqLayer->bUseRefBasePicFlag;
PPicture* ppShoreRefList = pCtx->sRefPic.pShortRefList[LIST_0];
PPicture* ppLongRefList = pCtx->sRefPic.pLongRefList[LIST_0];
memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture));
//short
for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) {
if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) {
pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
} else {
for (j = 0; j < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++j) {
if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum
&& ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
break;
}
}
if (j == pCtx->sRefPic.uiShortRefCount[LIST_0]) {
pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i];
}
}
}
return ERR_NONE;
//long
j = 0;
for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) {
if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) {
pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i];
} else {
for (j = 0; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) {
if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx
&& ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
break;
}
}
if (j == pCtx->sRefPic.uiLongRefCount[LIST_0]) {
pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i];
}
}
}
pCtx->sRefPic.uiRefCount[LIST_0] = iCount;
return ERR_NONE;
}
int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
{
PRefPicListReorderSyn pRefPicListReorderSyn = pCtx->pCurDqLayer->pRefPicListReordering;
PNalUnitHeaderExt pNalHeaderExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
PSliceHeader pSliceHeader = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader;
PPicture pPic = NULL;
PPicture* ppRefList = pCtx->sRefPic.pRefList[LIST_0];
int32_t iRefCount = pCtx->sRefPic.uiRefCount[LIST_0];
int32_t iPredFrameNum = pSliceHeader->iFrameNum;
int32_t iMaxPicNum = 1<<pSliceHeader->pSps->uiLog2MaxFrameNum;
int32_t iAbsDiffPicNum = -1;
int32_t iReorderingIndex = 0;
int32_t i = 0;
int32_t WelsReorderRefList (PWelsDecoderContext pCtx) {
PRefPicListReorderSyn pRefPicListReorderSyn = pCtx->pCurDqLayer->pRefPicListReordering;
PNalUnitHeaderExt pNalHeaderExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
PSliceHeader pSliceHeader = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader;
PPicture pPic = NULL;
PPicture* ppRefList = pCtx->sRefPic.pRefList[LIST_0];
int32_t iRefCount = pCtx->sRefPic.uiRefCount[LIST_0];
int32_t iPredFrameNum = pSliceHeader->iFrameNum;
int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum;
int32_t iAbsDiffPicNum = -1;
int32_t iReorderingIndex = 0;
int32_t i = 0;
if(pCtx->eSliceType == I_SLICE || pCtx->eSliceType == SI_SLICE) {
return ERR_NONE;
}
if (pCtx->eSliceType == I_SLICE || pCtx->eSliceType == SI_SLICE) {
return ERR_NONE;
}
if ( iRefCount <= 0 )
{
pCtx->iErrorCode = dsNoParamSets; //No any reference for decoding, SHOULD request IDR
return ERR_INFO_REFERENCE_PIC_LOST;
}
if (iRefCount <= 0) {
pCtx->iErrorCode = dsNoParamSets; //No any reference for decoding, SHOULD request IDR
return ERR_INFO_REFERENCE_PIC_LOST;
}
if (pRefPicListReorderSyn->bRefPicListReorderingFlag[LIST_0]){
while (pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc != 3)
{
uint16_t uiReorderingOfPicNumsIdc = pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc;
if (uiReorderingOfPicNumsIdc <2){
iAbsDiffPicNum = pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiAbsDiffPicNumMinus1 + 1;
if (pRefPicListReorderSyn->bRefPicListReorderingFlag[LIST_0]) {
while (pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc != 3) {
uint16_t uiReorderingOfPicNumsIdc =
pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc;
if (uiReorderingOfPicNumsIdc < 2) {
iAbsDiffPicNum = pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiAbsDiffPicNumMinus1 + 1;
if (uiReorderingOfPicNumsIdc == 0){
iPredFrameNum -= iAbsDiffPicNum;
}else{
iPredFrameNum += iAbsDiffPicNum;
}
iPredFrameNum &= iMaxPicNum-1;
if (uiReorderingOfPicNumsIdc == 0) {
iPredFrameNum -= iAbsDiffPicNum;
} else {
iPredFrameNum += iAbsDiffPicNum;
}
iPredFrameNum &= iMaxPicNum - 1;
for( i= iRefCount-1; i>=iReorderingIndex; i--){
if (ppRefList[i]->iFrameNum == iPredFrameNum && !ppRefList[i]->bIsLongRef)
{
if( ( pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId ) && ( pSliceHeader->iSpsId != ppRefList[i]->iSpsId ) )//check;
{
WelsLog( pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",pSliceHeader->iSpsId, ppRefList[i]->iSpsId );
pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
return ERR_INFO_REFERENCE_PIC_LOST;
}else{
break;
}
}
}
}else if (uiReorderingOfPicNumsIdc == 2){
for( i = iRefCount -1; i>=iReorderingIndex; i--){
if( ppRefList[i]->bIsLongRef && ppRefList[i]->iLongTermFrameIdx == pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiLongTermPicNum )
{
if ( ( pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId ) && ( pSliceHeader->iSpsId != ppRefList[i]->iSpsId ) )//check;
{
WelsLog( pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",pSliceHeader->iSpsId, ppRefList[i]->iSpsId );
pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
return ERR_INFO_REFERENCE_PIC_LOST;
}else{
break;
}
}
}
}
if (i < 0) {
return ERR_INFO_REFERENCE_PIC_LOST;
}
pPic = ppRefList[i];
memmove(&ppRefList[1+iReorderingIndex], &ppRefList[iReorderingIndex], (i-iReorderingIndex)*sizeof(PPicture));//confirmed_safe_unsafe_usage
ppRefList[iReorderingIndex]= pPic;
iReorderingIndex++;
}
}
return ERR_NONE;
}
int32_t WelsMarkAsRef(PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag)
{
PRefPic pRefPic = &pCtx->sRefPic;
PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;
PRefBasePicMarking pRefPicBaseMarking =pCtx->pCurDqLayer->pRefPicBaseMarking;
PAccessUnit pCurAU = pCtx->pAccessUnitList;
bool_t bIsIDRAU = FALSE;
uint32_t j;
int32_t iRet = ERR_NONE;
if(pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames<2)){
return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH;
}
pCtx->pDec->bUsedAsRef = TRUE;
pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId;
pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag;
for( j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++ ) {
if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType== NAL_UNIT_CODED_SLICE_IDR|| pCurAU->pNalUnitsList[j]->sNalHeaderExt.bIdrFlag) {
bIsIDRAU = TRUE;
break;
}
}
if(bIsIDRAU){
if (pRefPicMarking->bLongTermRefFlag){
pCtx->sRefPic.iMaxLongTermFrameIdx = 0;
AddLongTermToList(pRefPic,pCtx->pDec,0);
}else{
pCtx->sRefPic.iMaxLongTermFrameIdx = -1;
}
}else{
if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag){
iRet = MMCOBase(pCtx,pRefPicBaseMarking);
}
if (iRet != ERR_NONE){
return iRet;
}
if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag){
iRet = MMCO(pCtx,pRefPicMarking);
if( pCtx->bLastHasMmco5 )
{
pCtx->pDec->iFrameNum = 0;
pCtx->pDec->iFramePoc = 0;
for (i = iRefCount - 1; i >= iReorderingIndex; i--) {
if (ppRefList[i]->iFrameNum == iPredFrameNum && !ppRefList[i]->bIsLongRef) {
if ((pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId)
&& (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check;
WelsLog (pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",
pSliceHeader->iSpsId, ppRefList[i]->iSpsId);
pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
return ERR_INFO_REFERENCE_PIC_LOST;
} else {
break;
}
if (pRefPic->uiLongRefCount[LIST_0]+pRefPic->uiShortRefCount[LIST_0] > pCtx->pSps->iNumRefFrames){
return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
}
}else{
iRet = SlidingWindow(pCtx);
}
}
if (!pCtx->pDec->bIsLongRef){
AddShortTermToList(pRefPic,pCtx->pDec);
}
}
}
return iRet;
} else if (uiReorderingOfPicNumsIdc == 2) {
for (i = iRefCount - 1; i >= iReorderingIndex; i--) {
if (ppRefList[i]->bIsLongRef
&& ppRefList[i]->iLongTermFrameIdx ==
pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiLongTermPicNum) {
if ((pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId)
&& (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check;
WelsLog (pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",
pSliceHeader->iSpsId, ppRefList[i]->iSpsId);
pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
return ERR_INFO_REFERENCE_PIC_LOST;
} else {
break;
}
}
}
}
if (i < 0) {
return ERR_INFO_REFERENCE_PIC_LOST;
}
pPic = ppRefList[i];
memmove (&ppRefList[1 + iReorderingIndex], &ppRefList[iReorderingIndex],
(i - iReorderingIndex)*sizeof (PPicture)); //confirmed_safe_unsafe_usage
ppRefList[iReorderingIndex] = pPic;
iReorderingIndex++;
}
}
return ERR_NONE;
}
static int32_t MMCOBase(PWelsDecoderContext pCtx,PRefBasePicMarking pRefPicBaseMarking)
{
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
int32_t i = 0;
int32_t iRet = ERR_NONE;
int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag) {
PRefPic pRefPic = &pCtx->sRefPic;
PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;
PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking;
PAccessUnit pCurAU = pCtx->pAccessUnitList;
bool_t bIsIDRAU = FALSE;
uint32_t j;
for ( i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++){
uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType;
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) &((1<<pSps->uiLog2MaxFrameNum)-1);
uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum;
if ( uiMmcoType > MMCO_LONG2UNUSED) {
return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
}
iRet = MMCOProcess(pCtx,uiMmcoType,TRUE,iShortFrameNum,uiLongTermPicNum,0,0);
int32_t iRet = ERR_NONE;
if (pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames < 2)) {
return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH;
}
if (iRet != ERR_NONE){
return iRet;
}
}
pCtx->pDec->bUsedAsRef = TRUE;
pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId;
pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag;
return ERR_NONE;
for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) {
if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR
|| pCurAU->pNalUnitsList[j]->sNalHeaderExt.bIdrFlag) {
bIsIDRAU = TRUE;
break;
}
}
if (bIsIDRAU) {
if (pRefPicMarking->bLongTermRefFlag) {
pCtx->sRefPic.iMaxLongTermFrameIdx = 0;
AddLongTermToList (pRefPic, pCtx->pDec, 0);
} else {
pCtx->sRefPic.iMaxLongTermFrameIdx = -1;
}
} else {
if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag) {
iRet = MMCOBase (pCtx, pRefPicBaseMarking);
}
if (iRet != ERR_NONE) {
return iRet;
}
if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {
iRet = MMCO (pCtx, pRefPicMarking);
if (pCtx->bLastHasMmco5) {
pCtx->pDec->iFrameNum = 0;
pCtx->pDec->iFramePoc = 0;
}
if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] > pCtx->pSps->iNumRefFrames) {
return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
}
} else {
iRet = SlidingWindow (pCtx);
}
}
if (!pCtx->pDec->bIsLongRef) {
AddShortTermToList (pRefPic, pCtx->pDec);
}
return iRet;
}
static int32_t MMCO(PWelsDecoderContext pCtx,PRefPicMarking pRefPicMarking)
{
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
int32_t i = 0;
int32_t iRet = ERR_NONE;
for ( i = 0; pRefPicMarking->sMmcoRef[i].uiMmcoType != MMCO_END; i++){
uint32_t uiMmcoType = pRefPicMarking->sMmcoRef[i].uiMmcoType;
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicMarking->sMmcoRef[i].iDiffOfPicNum) & ((1<<pSps->uiLog2MaxFrameNum)-1);
uint32_t uiLongTermPicNum = pRefPicMarking->sMmcoRef[i].uiLongTermPicNum;
int32_t iLongTermFrameIdx = pRefPicMarking->sMmcoRef[i].iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx = pRefPicMarking->sMmcoRef[i].iMaxLongTermFrameIdx;
if ( uiMmcoType > MMCO_LONG) {
return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
}
iRet = MMCOProcess(pCtx,uiMmcoType,FALSE,iShortFrameNum,uiLongTermPicNum,iLongTermFrameIdx,iMaxLongTermFrameIdx);
if (iRet != ERR_NONE){
return iRet;
}
}
static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking) {
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
int32_t i = 0;
int32_t iRet = ERR_NONE;
return ERR_NONE;
for (i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++) {
uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType;
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) & ((
1 << pSps->uiLog2MaxFrameNum) - 1);
uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum;
if (uiMmcoType > MMCO_LONG2UNUSED) {
return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
}
iRet = MMCOProcess (pCtx, uiMmcoType, TRUE, iShortFrameNum, uiLongTermPicNum, 0, 0);
if (iRet != ERR_NONE) {
return iRet;
}
}
return ERR_NONE;
}
static int32_t MMCOProcess( PWelsDecoderContext pCtx,uint32_t uiMmcoType,bool_t bRefBasePic,
int32_t iShortFrameNum,uint32_t uiLongTermPicNum ,int32_t iLongTermFrameIdx,int32_t iMaxLongTermFrameIdx )
{
PRefPic pRefPic = &pCtx->sRefPic;
PPicture pPic = NULL;
int32_t i = 0;
int32_t iRet = ERR_NONE;
switch (uiMmcoType)
{
case MMCO_SHORT2UNUSED:
pPic = WelsDelShortFromListSetUnref(pRefPic,iShortFrameNum,(ERemoveFlag) bRefBasePic);
break;
case MMCO_LONG2UNUSED:
pPic = WelsDelLongFromListSetUnref(pRefPic,uiLongTermPicNum,(ERemoveFlag) bRefBasePic);
break;
case MMCO_SHORT2LONG:
if(iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx){
return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
}
pPic = WelsDelShortFromList(pRefPic,iShortFrameNum,REMOVE_TARGET);
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_TARGET);
static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) {
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
int32_t i = 0;
int32_t iRet = ERR_NONE;
for (i = 0; pRefPicMarking->sMmcoRef[i].uiMmcoType != MMCO_END; i++) {
uint32_t uiMmcoType = pRefPicMarking->sMmcoRef[i].uiMmcoType;
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicMarking->sMmcoRef[i].iDiffOfPicNum) & ((
1 << pSps->uiLog2MaxFrameNum) - 1);
uint32_t uiLongTermPicNum = pRefPicMarking->sMmcoRef[i].uiLongTermPicNum;
int32_t iLongTermFrameIdx = pRefPicMarking->sMmcoRef[i].iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx = pRefPicMarking->sMmcoRef[i].iMaxLongTermFrameIdx;
if (uiMmcoType > MMCO_LONG) {
return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
}
iRet = MMCOProcess (pCtx, uiMmcoType, FALSE, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);
if (iRet != ERR_NONE) {
return iRet;
}
}
WelsDelShortFromList(pRefPic,iShortFrameNum,REMOVE_BASE);
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_BASE);
return ERR_NONE;
}
static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool_t bRefBasePic,
int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {
PRefPic pRefPic = &pCtx->sRefPic;
PPicture pPic = NULL;
int32_t i = 0;
int32_t iRet = ERR_NONE;
switch (uiMmcoType) {
case MMCO_SHORT2UNUSED:
pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic);
break;
case MMCO_LONG2UNUSED:
pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum, (ERemoveFlag) bRefBasePic);
break;
case MMCO_SHORT2LONG:
if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
}
pPic = WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_TARGET);
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_BASE);
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
#ifdef LONG_TERM_REF
pCtx->bCurAuContainLtrMarkSeFlag = true;
pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum;
WelsLog( pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_SHORT2LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNumOfAuMarkedLtr );
pCtx->bCurAuContainLtrMarkSeFlag = true;
pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum;
WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_SHORT2LONG:::LTR marking....iFrameNum: %d\n",
pCtx->iFrameNumOfAuMarkedLtr);
#endif
MarkAsLongTerm(pRefPic,iShortFrameNum,iLongTermFrameIdx);
break;
case MMCO_SET_MAX_LONG:
pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx;
for (i = 0 ;i <pRefPic->uiLongRefCount[LIST_0];i++) {
if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
WelsDelLongFromListSetUnref(pRefPic,pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx,REMOVE_BASE_FIRST);
}
}
break;
case MMCO_RESET:
WelsResetRefPic(pCtx);
pCtx->bLastHasMmco5 = true;
break;
case MMCO_LONG:
if(iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx){
return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
}
MarkAsLongTerm (pRefPic, iShortFrameNum, iLongTermFrameIdx);
break;
case MMCO_SET_MAX_LONG:
pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx;
for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx, REMOVE_BASE_FIRST);
}
}
break;
case MMCO_RESET:
WelsResetRefPic (pCtx);
pCtx->bLastHasMmco5 = true;
break;
case MMCO_LONG:
if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
}
#ifdef LONG_TERM_REF
pCtx->bCurAuContainLtrMarkSeFlag = true;
pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum;
WelsLog( pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum );
pCtx->bCurAuContainLtrMarkSeFlag = true;
pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum;
WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum);
#endif
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_TARGET);
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_BASE);
iRet = AddLongTermToList(pRefPic,pCtx->pDec,iLongTermFrameIdx);
break;
default :
break;
}
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx);
break;
default :
break;
}
return iRet;
return iRet;
}
static int32_t SlidingWindow( PWelsDecoderContext pCtx )
{
PRefPic pRefPic = &pCtx->sRefPic;
PPicture pPic = NULL;
int32_t i = 0;
static int32_t SlidingWindow (PWelsDecoderContext pCtx) {
PRefPic pRefPic = &pCtx->sRefPic;
PPicture pPic = NULL;
int32_t i = 0;
if (pCtx->sRefPic.uiShortRefCount[LIST_0] +pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames){
for ( i = pRefPic->uiShortRefCount[LIST_0] -1;i>=0;i--){
pPic = WelsDelShortFromList(pRefPic,pRefPic->pShortRefList[LIST_0][i]->iFrameNum,REMOVE_BASE_FIRST);
if (pPic){
SetUnRef(pPic);
break;
}else{
return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
}
}
}
return ERR_NONE;
if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {
for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {
pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum, REMOVE_BASE_FIRST);
if (pPic) {
SetUnRef (pPic);
break;
} else {
return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
}
}
}
return ERR_NONE;
}
static PPicture WelsDelShortFromList(PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag)
{
int32_t i = 0;
int32_t iMoveSize = 0;
PPicture pPic = NULL;
static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
int32_t i = 0;
int32_t iMoveSize = 0;
PPicture pPic = NULL;
for(i=0; i<pRefPic->uiShortRefCount[LIST_0]; i++){
if( pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum)
{
if( ( eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag )
||( eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
||(eRemoveFlag == REMOVE_BASE_FIRST ) )
{
iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
pPic = pRefPic->pShortRefList[LIST_0][i];
pRefPic->pShortRefList[LIST_0][i]= NULL;
if (iMoveSize > 0){
memmove(&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i+1], iMoveSize * sizeof(PPicture));//confirmed_safe_unsafe_usage
}
pRefPic->uiShortRefCount[LIST_0]--;
pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
break;
}
}
}
for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {
if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) {
if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
|| (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
|| (eRemoveFlag == REMOVE_BASE_FIRST)) {
iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
pPic = pRefPic->pShortRefList[LIST_0][i];
pRefPic->pShortRefList[LIST_0][i] = NULL;
if (iMoveSize > 0) {
memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
}
pRefPic->uiShortRefCount[LIST_0]--;
pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
break;
}
}
}
return pPic;
return pPic;
}
static PPicture WelsDelShortFromListSetUnref(PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag)
{
PPicture pPic = WelsDelShortFromList(pRefPic,iFrameNum,eRemoveFlag);
if (pPic){
SetUnRef(pPic);
}
return pPic;
static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag);
if (pPic) {
SetUnRef (pPic);
}
return pPic;
}
static PPicture WelsDelLongFromList(PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag)
{
PPicture pPic = NULL;
int32_t i = 0;
for ( i = 0;i<pRefPic->uiLongRefCount[LIST_0];i++)
{
pPic = pRefPic->pLongRefList[LIST_0][i];
if ( pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx)
{
if( ((eRemoveFlag == REMOVE_TARGET) && !(pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE) && pPic->bRefBaseFlag) )
{
int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
pPic->bUsedAsRef = FALSE;
pPic->bIsLongRef = FALSE;
if (iMoveSize > 0){
memmove(&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i+1], iMoveSize * sizeof(PPicture));//confirmed_safe_unsafe_usage
}
pRefPic->uiLongRefCount[LIST_0]--;
pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
return pPic;
}
}
}
return NULL;
static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
PPicture pPic = NULL;
int32_t i = 0;
for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
pPic = pRefPic->pLongRefList[LIST_0][i];
if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {
if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE)
&& pPic->bRefBaseFlag)) {
int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
pPic->bUsedAsRef = FALSE;
pPic->bIsLongRef = FALSE;
if (iMoveSize > 0) {
memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
}
pRefPic->uiLongRefCount[LIST_0]--;
pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
return pPic;
}
}
}
return NULL;
}
static PPicture WelsDelLongFromListSetUnref(PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag)
{
PPicture pPic = WelsDelLongFromList(pRefPic,uiLongTermFrameIdx,eRemoveFlag);
if (pPic){
SetUnRef(pPic);
}
return pPic;
static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag);
if (pPic) {
SetUnRef (pPic);
}
return pPic;
}
static int32_t AddShortTermToList(PRefPic pRefPic,PPicture pPic)
{
pPic->bUsedAsRef = TRUE;
pPic->bIsLongRef = FALSE;
pPic->iLongTermFrameIdx = -1;
if (pRefPic->uiShortRefCount[LIST_0]>0) {
memmove(&pRefPic->pShortRefList[LIST_0][1],&pRefPic->pShortRefList[LIST_0][0],pRefPic->uiShortRefCount[LIST_0]*sizeof(PPicture));//confirmed_safe_unsafe_usage
}
pRefPic->pShortRefList[LIST_0][0] = pPic;
pRefPic->uiShortRefCount[LIST_0]++;
return ERR_NONE;
static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic) {
pPic->bUsedAsRef = TRUE;
pPic->bIsLongRef = FALSE;
pPic->iLongTermFrameIdx = -1;
if (pRefPic->uiShortRefCount[LIST_0] > 0) {
memmove (&pRefPic->pShortRefList[LIST_0][1], &pRefPic->pShortRefList[LIST_0][0],
pRefPic->uiShortRefCount[LIST_0]*sizeof (PPicture));//confirmed_safe_unsafe_usage
}
pRefPic->pShortRefList[LIST_0][0] = pPic;
pRefPic->uiShortRefCount[LIST_0]++;
return ERR_NONE;
}
static int32_t AddLongTermToList(PRefPic pRefPic,PPicture pPic, int32_t iLongTermFrameIdx)
{
int32_t i = 0;
static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx) {
int32_t i = 0;
pPic->bUsedAsRef = TRUE;
pPic->bIsLongRef = TRUE;
pPic->iLongTermFrameIdx = iLongTermFrameIdx;
if (pRefPic->uiLongRefCount[LIST_0] == 0){
pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = pPic;
}else if (pRefPic->uiLongRefCount[LIST_0] >0){
for ( i = 0; i<pRefPic->uiLongRefCount[LIST_0];i++){
if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pPic->iLongTermFrameIdx) {
break;
}
}
memmove(&pRefPic->pLongRefList[LIST_0][i+1],&pRefPic->pLongRefList[LIST_0][i],(pRefPic->uiLongRefCount[LIST_0]-i)*sizeof(PPicture));//confirmed_safe_unsafe_usage
pRefPic->pLongRefList[LIST_0][i] = pPic;
}else{
return ERR_INFO_REF_COUNT_OVERFLOW;
}
pPic->bUsedAsRef = TRUE;
pPic->bIsLongRef = TRUE;
pPic->iLongTermFrameIdx = iLongTermFrameIdx;
if (pRefPic->uiLongRefCount[LIST_0] == 0) {
pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = pPic;
} else if (pRefPic->uiLongRefCount[LIST_0] > 0) {
for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pPic->iLongTermFrameIdx) {
break;
}
}
memmove (&pRefPic->pLongRefList[LIST_0][i + 1], &pRefPic->pLongRefList[LIST_0][i],
(pRefPic->uiLongRefCount[LIST_0] - i)*sizeof (PPicture)); //confirmed_safe_unsafe_usage
pRefPic->pLongRefList[LIST_0][i] = pPic;
} else {
return ERR_INFO_REF_COUNT_OVERFLOW;
}
pRefPic->uiLongRefCount[LIST_0]++;
return ERR_NONE;
pRefPic->uiLongRefCount[LIST_0]++;
return ERR_NONE;
}
static int32_t AssignLongTermIdx(PRefPic pRefPic,int32_t iFrameNum,int32_t iLongTermFrameIdx )
{
PPicture pPic = NULL;
int32_t iRet = ERR_NONE;
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_TARGET);
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_BASE);
static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
PPicture pPic = NULL;
int32_t iRet = ERR_NONE;
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
pPic = WelsDelShortFromList(pRefPic,iFrameNum,REMOVE_TARGET);
if (pPic){
iRet = AddLongTermToList(pRefPic,pPic,iLongTermFrameIdx);
}else{
return ERR_INFO_INVALID_REF_MARKING;
}
pPic = NULL;
pPic = WelsDelShortFromList(pRefPic,iFrameNum,REMOVE_BASE);
if (pPic){
iRet = AddLongTermToList(pRefPic,pPic,iLongTermFrameIdx);
}
pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_TARGET);
if (pPic) {
iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
} else {
return ERR_INFO_INVALID_REF_MARKING;
}
return iRet;
pPic = NULL;
pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_BASE);
if (pPic) {
iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
}
return iRet;
}
static int32_t MarkAsLongTerm( PRefPic pRefPic,int32_t iFrameNum, int32_t iLongTermFrameIdx )
{
PPicture pPic = NULL;
int32_t i = 0;
int32_t iRet = ERR_NONE;
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_TARGET);
WelsDelLongFromListSetUnref(pRefPic,iLongTermFrameIdx,REMOVE_BASE);
static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
PPicture pPic = NULL;
int32_t i = 0;
int32_t iRet = ERR_NONE;
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
for (i = 0; i<pRefPic->uiRefCount[LIST_0];i++) {
pPic = pRefPic->pRefList[LIST_0][i];
if ( pPic->iFrameNum == iFrameNum && !pPic->bIsLongRef){
iRet = AddLongTermToList(pRefPic,pPic,iLongTermFrameIdx);
}
}
return iRet;
for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++) {
pPic = pRefPic->pRefList[LIST_0][i];
if (pPic->iFrameNum == iFrameNum && !pPic->bIsLongRef) {
iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
}
}
return iRet;
}
} // namespace WelsDec

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +1,109 @@
/*!
* \copy
* Copyright (c) 2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "mem_align.h"
#include "crt_util_safe_x.h"
namespace WelsDec {
//#define MEMORY_CHECK
#ifdef MEMORY_CHECK
WelsFileHandle * pMemCheckMalloc = NULL;
WelsFileHandle * pMemCheckFree = NULL;
int32_t iCountMalloc = 0;
#endif
//
/////////////////////////////////////////////////////////////////////////////////
#define ALIGNBYTES (16)
/////////////////////////////////////////////////////////////////////////////////
void_t * WelsMalloc( const uint32_t kuiSize, const str_t *kpTag )
{
const int32_t kiSizeVoidPtr = sizeof( void_t ** );
const int32_t kiSizeInt = sizeof( int32_t );
#ifdef HAVE_CACHE_LINE_ALIGN
const int32_t kiAlignBytes = ALIGNBYTES - 1;
#else
const int32_t kiAlignBytes = 15;
#endif// HAVE_CACHE_LINE_ALIGN
uint8_t* pBuf = (uint8_t *) malloc( kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt );
uint8_t* pAlignBuf;
#ifdef MEMORY_CHECK
if( pMemCheckMalloc == NULL ){
pMemCheckMalloc = WelsFopen(".\\mem_check_malloc.txt", "at+");
pMemCheckFree = WelsFopen(".\\mem_check_free.txt", "at+");
}
if ( kpTag != NULL )
{
if ( pMemCheckMalloc != NULL )
{
fprintf( pMemCheckMalloc, "0x%x, size: %d , malloc %s\n", (void_t *)pBuf, (kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt), kpTag );
}
if ( pMemCheckMalloc != NULL )
{
fflush( pMemCheckMalloc );
}
}
#endif
if ( NULL == pBuf )
return NULL;
// to fill zero values
memset( pBuf, 0, kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt );
pAlignBuf = pBuf + kiAlignBytes + kiSizeVoidPtr + kiSizeInt;
pAlignBuf -= (int32_t) pAlignBuf & kiAlignBytes;
*( (void_t **) ( pAlignBuf - kiSizeVoidPtr ) ) = pBuf;
*( (int32_t *) ( pAlignBuf - (kiSizeVoidPtr + kiSizeInt) ) ) = kuiSize;
return (pAlignBuf);
}
/////////////////////////////////////////////////////////////////////////////
void_t WelsFree( void_t* pPtr, const str_t *kpTag )
{
if( pPtr )
{
#ifdef MEMORY_CHECK
if ( NULL != pMemCheckFree && kpTag != NULL )
{
fprintf( pMemCheckFree, "0x%x, free %s\n", (void_t *)(*( ( ( void_t **) pPtr ) - 1 )), kpTag );
fflush( pMemCheckFree );
}
#endif
free( *( ( ( void_t **) pPtr ) - 1 ) );
}
}
/////////////////////////////////////////////////////////////////////////////
} // namespace WelsDec
/*!
* \copy
* Copyright (c) 2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "mem_align.h"
#include "crt_util_safe_x.h"
namespace WelsDec {
//#define MEMORY_CHECK
#ifdef MEMORY_CHECK
WelsFileHandle* pMemCheckMalloc = NULL;
WelsFileHandle* pMemCheckFree = NULL;
int32_t iCountMalloc = 0;
#endif
//
/////////////////////////////////////////////////////////////////////////////////
#define ALIGNBYTES (16)
/////////////////////////////////////////////////////////////////////////////////
void_t* WelsMalloc (const uint32_t kuiSize, const str_t* kpTag) {
const int32_t kiSizeVoidPtr = sizeof (void_t**);
const int32_t kiSizeInt = sizeof (int32_t);
#ifdef HAVE_CACHE_LINE_ALIGN
const int32_t kiAlignBytes = ALIGNBYTES - 1;
#else
const int32_t kiAlignBytes = 15;
#endif// HAVE_CACHE_LINE_ALIGN
uint8_t* pBuf = (uint8_t*) malloc (kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
uint8_t* pAlignBuf;
#ifdef MEMORY_CHECK
if (pMemCheckMalloc == NULL) {
pMemCheckMalloc = WelsFopen (".\\mem_check_malloc.txt", "at+");
pMemCheckFree = WelsFopen (".\\mem_check_free.txt", "at+");
}
if (kpTag != NULL) {
if (pMemCheckMalloc != NULL) {
fprintf (pMemCheckMalloc, "0x%x, size: %d , malloc %s\n", (void_t*)pBuf,
(kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt), kpTag);
}
if (pMemCheckMalloc != NULL) {
fflush (pMemCheckMalloc);
}
}
#endif
if (NULL == pBuf)
return NULL;
// to fill zero values
memset (pBuf, 0, kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
pAlignBuf = pBuf + kiAlignBytes + kiSizeVoidPtr + kiSizeInt;
pAlignBuf -= (int32_t) pAlignBuf & kiAlignBytes;
* ((void_t**) (pAlignBuf - kiSizeVoidPtr)) = pBuf;
* ((int32_t*) (pAlignBuf - (kiSizeVoidPtr + kiSizeInt))) = kuiSize;
return (pAlignBuf);
}
/////////////////////////////////////////////////////////////////////////////
void_t WelsFree (void_t* pPtr, const str_t* kpTag) {
if (pPtr) {
#ifdef MEMORY_CHECK
if (NULL != pMemCheckFree && kpTag != NULL) {
fprintf (pMemCheckFree, "0x%x, free %s\n", (void_t*) (* (((void_t**) pPtr) - 1)), kpTag);
fflush (pMemCheckFree);
}
#endif
free (* (((void_t**) pPtr) - 1));
}
}
/////////////////////////////////////////////////////////////////////////////
} // namespace WelsDec

View File

@ -44,86 +44,81 @@
namespace WelsDec {
int32_t MemInitNalList(PAccessUnit *ppAu, const uint32_t kuiSize){
uint32_t uiIdx = 0;
uint8_t *pBase = NULL, *pPtr = NULL;
const uint32_t kuiSizeAu = sizeof(SAccessUnit);
const uint32_t kuiSizeNalUnitPtr= kuiSize*sizeof(PNalUnit);
const uint32_t kuiSizeNalUnit = sizeof(SNalUnit);
const uint32_t kuiCountSize = (kuiSizeAu + kuiSizeNalUnitPtr + kuiSize * kuiSizeNalUnit) * sizeof(uint8_t);
if (kuiSize == 0)
return 1;
int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) {
uint32_t uiIdx = 0;
uint8_t* pBase = NULL, *pPtr = NULL;
const uint32_t kuiSizeAu = sizeof (SAccessUnit);
const uint32_t kuiSizeNalUnitPtr = kuiSize * sizeof (PNalUnit);
const uint32_t kuiSizeNalUnit = sizeof (SNalUnit);
const uint32_t kuiCountSize = (kuiSizeAu + kuiSizeNalUnitPtr + kuiSize * kuiSizeNalUnit) * sizeof (uint8_t);
if ( *ppAu != NULL ){
MemFreeNalList(ppAu);
}
if (kuiSize == 0)
return 1;
pBase = (uint8_t *)WelsMalloc( kuiCountSize, "Access Unit" );
if ( pBase == NULL )
return 1;
pPtr = pBase;
*ppAu = (PAccessUnit)pPtr;
pPtr += kuiSizeAu;
(*ppAu)->pNalUnitsList = (PNalUnit*)pPtr;
pPtr += kuiSizeNalUnitPtr;
do {
(*ppAu)->pNalUnitsList[uiIdx] = (PNalUnit)pPtr;
pPtr += kuiSizeNalUnit;
++ uiIdx;
} while(uiIdx < kuiSize);
if (*ppAu != NULL) {
MemFreeNalList (ppAu);
}
(*ppAu)->uiCountUnitsNum = kuiSize;
(*ppAu)->uiAvailUnitsNum = 0;
(*ppAu)->uiActualUnitsNum = 0;
(*ppAu)->uiEndPos = 0;
(*ppAu)->bCompletedAuFlag = false;
pBase = (uint8_t*)WelsMalloc (kuiCountSize, "Access Unit");
if (pBase == NULL)
return 1;
pPtr = pBase;
*ppAu = (PAccessUnit)pPtr;
pPtr += kuiSizeAu;
(*ppAu)->pNalUnitsList = (PNalUnit*)pPtr;
pPtr += kuiSizeNalUnitPtr;
do {
(*ppAu)->pNalUnitsList[uiIdx] = (PNalUnit)pPtr;
pPtr += kuiSizeNalUnit;
++ uiIdx;
} while (uiIdx < kuiSize);
return 0;
(*ppAu)->uiCountUnitsNum = kuiSize;
(*ppAu)->uiAvailUnitsNum = 0;
(*ppAu)->uiActualUnitsNum = 0;
(*ppAu)->uiEndPos = 0;
(*ppAu)->bCompletedAuFlag = false;
return 0;
}
int32_t MemFreeNalList(PAccessUnit *ppAu)
{
if (ppAu != NULL){
PAccessUnit pAu = *ppAu;
if (pAu != NULL)
{
WelsFree(pAu, "Access Unit");
*ppAu = NULL;
}
}
return 0;
int32_t MemFreeNalList (PAccessUnit* ppAu) {
if (ppAu != NULL) {
PAccessUnit pAu = *ppAu;
if (pAu != NULL) {
WelsFree (pAu, "Access Unit");
*ppAu = NULL;
}
}
return 0;
}
int32_t ExpandNalUnitList(PAccessUnit *ppAu, const int32_t kiOrgSize, const int32_t kiExpSize)
{
if ( kiExpSize <= kiOrgSize )
return 1;
else
{
PAccessUnit pTmp = NULL;
int32_t iIdx = 0;
int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int32_t kiExpSize) {
if (kiExpSize <= kiOrgSize)
return 1;
else {
PAccessUnit pTmp = NULL;
int32_t iIdx = 0;
if ( MemInitNalList( &pTmp, kiExpSize ) ) // request new list with expanding
return 1;
if (MemInitNalList (&pTmp, kiExpSize)) // request new list with expanding
return 1;
do
{
memcpy(pTmp->pNalUnitsList[iIdx], (*ppAu)->pNalUnitsList[iIdx], sizeof(SNalUnit) );//confirmed_safe_unsafe_usage
++ iIdx;
}while(iIdx < kiOrgSize);
do {
memcpy (pTmp->pNalUnitsList[iIdx], (*ppAu)->pNalUnitsList[iIdx], sizeof (SNalUnit)); //confirmed_safe_unsafe_usage
++ iIdx;
} while (iIdx < kiOrgSize);
pTmp->uiCountUnitsNum = kiExpSize;
pTmp->uiAvailUnitsNum = (*ppAu)->uiAvailUnitsNum;
pTmp->uiActualUnitsNum = (*ppAu)->uiActualUnitsNum;
pTmp->uiEndPos = (*ppAu)->uiEndPos;
pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag;
pTmp->uiCountUnitsNum = kiExpSize;
pTmp->uiAvailUnitsNum = (*ppAu)->uiAvailUnitsNum;
pTmp->uiActualUnitsNum = (*ppAu)->uiActualUnitsNum;
pTmp->uiEndPos = (*ppAu)->uiEndPos;
pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag;
MemFreeNalList( ppAu ); // free old list
*ppAu = pTmp;
return 0;
}
MemFreeNalList (ppAu); // free old list
*ppAu = pTmp;
return 0;
}
}
/*
@ -131,23 +126,22 @@ int32_t ExpandNalUnitList(PAccessUnit *ppAu, const int32_t kiOrgSize, const int3
* Get next NAL Unit for using.
* Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit
*/
PNalUnit MemGetNextNal(PAccessUnit *ppAu){
PAccessUnit pAu = *ppAu;
PNalUnit pNu = NULL;
if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) // need expand list
{
const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU>>1);
if ( ExpandNalUnitList(ppAu, pAu->uiCountUnitsNum, kuiExpandingSize) )
return NULL; // out of memory
pAu = *ppAu;
}
PNalUnit MemGetNextNal (PAccessUnit* ppAu) {
PAccessUnit pAu = *ppAu;
PNalUnit pNu = NULL;
pNu = pAu->pNalUnitsList[pAu->uiAvailUnitsNum++]; // ready for next nal position
if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list
const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU >> 1);
if (ExpandNalUnitList (ppAu, pAu->uiCountUnitsNum, kuiExpandingSize))
return NULL; // out of memory
pAu = *ppAu;
}
memset(pNu, 0, sizeof(SNalUnit)); // Please do not remove this for cache intend!!
return pNu;
pNu = pAu->pNalUnitsList[pAu->uiAvailUnitsNum++]; // ready for next nal position
memset (pNu, 0, sizeof (SNalUnit)); // Please do not remove this for cache intend!!
return pNu;
}
} // namespace WelsDec

View File

@ -45,207 +45,179 @@
namespace WelsDec {
//basic iMVs prediction unit for iMVs partition width (4, 2, 1)
void_t PredMv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2])
{
const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1;
const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6;
const uint8_t kuiRightTopIdx= kuiTopIdx + iPartWidth;
const uint8_t kuiLeftTopIdx = kuiTopIdx - 1;
void_t PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]) {
const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1;
const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6;
const uint8_t kuiRightTopIdx = kuiTopIdx + iPartWidth;
const uint8_t kuiLeftTopIdx = kuiTopIdx - 1;
const int8_t kiLeftRef = iRefIndex[0][kuiLeftIdx];
const int8_t kiTopRef = iRefIndex[0][ kuiTopIdx];
const int8_t kiRightTopRef = iRefIndex[0][kuiRightTopIdx];
const int8_t kiLeftTopRef = iRefIndex[0][ kuiLeftTopIdx];
int8_t iDiagonalRef = kiRightTopRef;
const int8_t kiLeftRef = iRefIndex[0][kuiLeftIdx];
const int8_t kiTopRef = iRefIndex[0][ kuiTopIdx];
const int8_t kiRightTopRef = iRefIndex[0][kuiRightTopIdx];
const int8_t kiLeftTopRef = iRefIndex[0][ kuiLeftTopIdx];
int8_t iDiagonalRef = kiRightTopRef;
int8_t iMatchRef = 0;
int8_t iMatchRef = 0;
int16_t iAMV[2], iBMV[2], iCMV[2];
int16_t iAMV[2], iBMV[2], iCMV[2];
*(int32_t*)iAMV = INTD32(iMotionVector[0][ kuiLeftIdx]);
*(int32_t*)iBMV = INTD32(iMotionVector[0][ kuiTopIdx]);
*(int32_t*)iCMV = INTD32(iMotionVector[0][kuiRightTopIdx]);
* (int32_t*)iAMV = INTD32 (iMotionVector[0][ kuiLeftIdx]);
* (int32_t*)iBMV = INTD32 (iMotionVector[0][ kuiTopIdx]);
* (int32_t*)iCMV = INTD32 (iMotionVector[0][kuiRightTopIdx]);
if (REF_NOT_AVAIL == iDiagonalRef)
{
iDiagonalRef = kiLeftTopRef;
*(int32_t*)iCMV = INTD32(iMotionVector[0][kuiLeftTopIdx]);
}
if (REF_NOT_AVAIL == iDiagonalRef) {
iDiagonalRef = kiLeftTopRef;
* (int32_t*)iCMV = INTD32 (iMotionVector[0][kuiLeftTopIdx]);
}
iMatchRef = (iRef == kiLeftRef) + (iRef == kiTopRef) + (iRef == iDiagonalRef);
iMatchRef = (iRef == kiLeftRef) + (iRef == kiTopRef) + (iRef == iDiagonalRef);
if (REF_NOT_AVAIL == kiTopRef && REF_NOT_AVAIL == iDiagonalRef && kiLeftRef >= REF_NOT_IN_LIST)
{
ST32(iMVP, LD32(iAMV));
return;
}
if (REF_NOT_AVAIL == kiTopRef && REF_NOT_AVAIL == iDiagonalRef && kiLeftRef >= REF_NOT_IN_LIST) {
ST32 (iMVP, LD32 (iAMV));
return;
}
if (1 == iMatchRef)
{
if (iRef == kiLeftRef)
{
ST32(iMVP, LD32(iAMV));
}
else if (iRef == kiTopRef)
{
ST32(iMVP, LD32(iBMV));
}
else
{
ST32(iMVP, LD32(iCMV));
}
}
else
{
iMVP[0] = WelsMedian(iAMV[0], iBMV[0], iCMV[0]);
iMVP[1] = WelsMedian(iAMV[1], iBMV[1], iCMV[1]);
}
if (1 == iMatchRef) {
if (iRef == kiLeftRef) {
ST32 (iMVP, LD32 (iAMV));
} else if (iRef == kiTopRef) {
ST32 (iMVP, LD32 (iBMV));
} else {
ST32 (iMVP, LD32 (iCMV));
}
} else {
iMVP[0] = WelsMedian (iAMV[0], iBMV[0], iCMV[0]);
iMVP[1] = WelsMedian (iAMV[1], iBMV[1], iCMV[1]);
}
}
void_t PredInter8x16Mv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2])
{
if (0 == iPartIdx)
{
const int8_t kiLeftRef = iRefIndex[0][6];
if (iRef == kiLeftRef)
{
ST32( iMVP, LD32(&iMotionVector[0][6][0]) );
return;
}
}
else // 1 == iPartIdx
{
int8_t iDiagonalRef = iRefIndex[0][5]; //top-right
int8_t index = 5;
if (REF_NOT_AVAIL == iDiagonalRef)
{
iDiagonalRef = iRefIndex[0][2]; //top-left for 8*8 block(index 1)
index = 2;
}
if (iRef == iDiagonalRef)
{
ST32( iMVP, LD32(&iMotionVector[0][index][0]) );
return;
}
}
void_t PredInter8x16Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]) {
if (0 == iPartIdx) {
const int8_t kiLeftRef = iRefIndex[0][6];
if (iRef == kiLeftRef) {
ST32 (iMVP, LD32 (&iMotionVector[0][6][0]));
return;
}
} else { // 1 == iPartIdx
int8_t iDiagonalRef = iRefIndex[0][5]; //top-right
int8_t index = 5;
if (REF_NOT_AVAIL == iDiagonalRef) {
iDiagonalRef = iRefIndex[0][2]; //top-left for 8*8 block(index 1)
index = 2;
}
if (iRef == iDiagonalRef) {
ST32 (iMVP, LD32 (&iMotionVector[0][index][0]));
return;
}
}
PredMv(iMotionVector, iRefIndex, iPartIdx, 2, iRef, iMVP);
PredMv (iMotionVector, iRefIndex, iPartIdx, 2, iRef, iMVP);
}
void_t PredInter16x8Mv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2])
{
if (0 == iPartIdx)
{
const int8_t kiTopRef = iRefIndex[0][1];
if (iRef == kiTopRef)
{
ST32(iMVP, LD32(&iMotionVector[0][1][0]));
return;
}
}
else // 8 == iPartIdx
{
const int8_t kiLeftRef = iRefIndex[0][18];
if (iRef == kiLeftRef)
{
ST32(iMVP, LD32(&iMotionVector[0][18][0]));
return;
}
}
void_t PredInter16x8Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]) {
if (0 == iPartIdx) {
const int8_t kiTopRef = iRefIndex[0][1];
if (iRef == kiTopRef) {
ST32 (iMVP, LD32 (&iMotionVector[0][1][0]));
return;
}
} else { // 8 == iPartIdx
const int8_t kiLeftRef = iRefIndex[0][18];
if (iRef == kiLeftRef) {
ST32 (iMVP, LD32 (&iMotionVector[0][18][0]));
return;
}
}
PredMv(iMotionVector, iRefIndex, iPartIdx, 4, iRef, iMVP);
PredMv (iMotionVector, iRefIndex, iPartIdx, 4, iRef, iMVP);
}
//update iMVs and iRefIndex cache for current MB, only for P_16*16 (SKIP inclusive)
/* can be further optimized */
void_t UpdateP16x16MotionInfo( PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2])
{
const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32(iMVs);
int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
for (i = 0; i < 16; i+=4)
{
//mb
const uint8_t kuiScan4Idx = g_kuiScan4[i];
const uint8_t kuiScan4IdxPlus4= 4 + kuiScan4Idx;
void_t UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]) {
const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32 (iMVs);
int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
ST16( &pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4Idx ], kiRef2 );
ST16( &pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4IdxPlus4], kiRef2 );
ST32( pCurDqLayer->pMv[0][iMbXy][ kuiScan4Idx ], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][1+kuiScan4Idx ], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][ kuiScan4IdxPlus4], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][1+kuiScan4IdxPlus4], kiMV32 );
}
for (i = 0; i < 16; i += 4) {
//mb
const uint8_t kuiScan4Idx = g_kuiScan4[i];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
ST16 (&pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4Idx ], kiRef2);
ST16 (&pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4IdxPlus4], kiRef2);
ST32 (pCurDqLayer->pMv[0][iMbXy][ kuiScan4Idx ], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][1 + kuiScan4Idx ], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][ kuiScan4IdxPlus4], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
}
}
//update iRefIndex and iMVs of Mb, only for P16x8
//update iRefIndex and iMVs of Mb, only for P16x8
/*need further optimization, mb_cache not work */
void_t UpdateP16x8MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2])
{
const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32(iMVs);
int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
for (i = 0; i < 2; i++, iPartIdx+=4)
{
const uint8_t kuiScan4Idx = g_kuiScan4[iPartIdx];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
const uint8_t kuiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx;
void_t UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]) {
const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32 (iMVs);
int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
for (i = 0; i < 2; i++, iPartIdx += 4) {
const uint8_t kuiScan4Idx = g_kuiScan4[iPartIdx];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
const uint8_t kuiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx;
//mb
ST16( &pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4Idx ], kiRef2 );
ST16( &pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4IdxPlus4], kiRef2 );
ST32( pCurDqLayer->pMv[0][iMbXy][ kuiScan4Idx ], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][1+kuiScan4Idx ], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][ kuiScan4IdxPlus4], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][1+kuiScan4IdxPlus4], kiMV32 );
//cache
ST16( &iRefIndex[0][kuiCacheIdx ], kiRef2 );
ST16( &iRefIndex[0][kuiCacheIdxPlus6], kiRef2 );
ST32( iMotionVector[0][ kuiCacheIdx ], kiMV32 );
ST32( iMotionVector[0][1+kuiCacheIdx ], kiMV32 );
ST32( iMotionVector[0][ kuiCacheIdxPlus6], kiMV32 );
ST32( iMotionVector[0][1+kuiCacheIdxPlus6], kiMV32 );
}
//mb
ST16 (&pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4Idx ], kiRef2);
ST16 (&pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4IdxPlus4], kiRef2);
ST32 (pCurDqLayer->pMv[0][iMbXy][ kuiScan4Idx ], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][1 + kuiScan4Idx ], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][ kuiScan4IdxPlus4], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
//cache
ST16 (&iRefIndex[0][kuiCacheIdx ], kiRef2);
ST16 (&iRefIndex[0][kuiCacheIdxPlus6], kiRef2);
ST32 (iMotionVector[0][ kuiCacheIdx ], kiMV32);
ST32 (iMotionVector[0][1 + kuiCacheIdx ], kiMV32);
ST32 (iMotionVector[0][ kuiCacheIdxPlus6], kiMV32);
ST32 (iMotionVector[0][1 + kuiCacheIdxPlus6], kiMV32);
}
}
//update iRefIndex and iMVs of both Mb and Mb_cache, only for P8x16
void_t UpdateP8x16MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2])
{
const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32(iMVs);
int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
for (i = 0; i < 2; i++, iPartIdx+=8)
{
const uint8_t kuiScan4Idx = g_kuiScan4[iPartIdx];
const uint8_t kuiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
const uint8_t kuiScan4IdxPlus4= 4 + kuiScan4Idx;
const uint8_t kuiCacheIdxPlus6= 6 + kuiCacheIdx;
void_t UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]) {
const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32 (iMVs);
int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
//mb
ST16( &pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4Idx ], kiRef2 );
ST16( &pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4IdxPlus4], kiRef2 );
ST32( pCurDqLayer->pMv[0][iMbXy][ kuiScan4Idx ], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][1+kuiScan4Idx ], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][ kuiScan4IdxPlus4], kiMV32 );
ST32( pCurDqLayer->pMv[0][iMbXy][1+kuiScan4IdxPlus4], kiMV32 );
//cache
ST16( &iRefIndex[0][kuiCacheIdx ], kiRef2 );
ST16( &iRefIndex[0][kuiCacheIdxPlus6], kiRef2 );
ST32( iMotionVector[0][ kuiCacheIdx ], kiMV32 );
ST32( iMotionVector[0][1+kuiCacheIdx ], kiMV32 );
ST32( iMotionVector[0][ kuiCacheIdxPlus6], kiMV32 );
ST32( iMotionVector[0][1+kuiCacheIdxPlus6], kiMV32 );
}
for (i = 0; i < 2; i++, iPartIdx += 8) {
const uint8_t kuiScan4Idx = g_kuiScan4[iPartIdx];
const uint8_t kuiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx;
//mb
ST16 (&pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4Idx ], kiRef2);
ST16 (&pCurDqLayer->pRefIndex[0][iMbXy][kuiScan4IdxPlus4], kiRef2);
ST32 (pCurDqLayer->pMv[0][iMbXy][ kuiScan4Idx ], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][1 + kuiScan4Idx ], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][ kuiScan4IdxPlus4], kiMV32);
ST32 (pCurDqLayer->pMv[0][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
//cache
ST16 (&iRefIndex[0][kuiCacheIdx ], kiRef2);
ST16 (&iRefIndex[0][kuiCacheIdxPlus6], kiRef2);
ST32 (iMotionVector[0][ kuiCacheIdx ], kiMV32);
ST32 (iMotionVector[0][1 + kuiCacheIdx ], kiMV32);
ST32 (iMotionVector[0][ kuiCacheIdxPlus6], kiMV32);
ST32 (iMotionVector[0][1 + kuiCacheIdxPlus6], kiMV32);
}
}
} // namespace WelsDec

File diff suppressed because it is too large Load Diff

View File

@ -48,13 +48,13 @@
namespace WelsDec {
void_t FreePicture( PPicture pPic );
void_t FreePicture (PPicture pPic);
///////////////////////////////////Recycled queue management for pictures///////////////////////////////////
/* ______________________________________
-->| P0 | P1 | P2 | P3 | P4 | .. | Pn-1 |-->
--------------------------------------
--------------------------------------
*
* How does it work?
* node <- next; ++ next;
@ -63,104 +63,94 @@ void_t FreePicture( PPicture pPic );
PPicture AllocPicture( PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight )
{
PPicture pPic = NULL;
int32_t iPicWidth = 0;
int32_t iPicHeight= 0;
PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight) {
PPicture pPic = NULL;
int32_t iPicWidth = 0;
int32_t iPicHeight = 0;
int32_t iPicChromaWidth = 0;
int32_t iPicChromaHeight = 0;
int32_t iLumaSize = 0;
int32_t iChromaSize = 0;
int32_t iPicChromaWidth = 0;
int32_t iPicChromaHeight = 0;
int32_t iLumaSize = 0;
int32_t iChromaSize = 0;
pPic = (PPicture) WelsMalloc( sizeof(SPicture), "PPicture" );
WELS_VERIFY_RETURN_IF( NULL, NULL == pPic );
memset(pPic, 0, sizeof(SPicture) );
iPicWidth = WELS_ALIGN(kiPicWidth + (PADDING_LENGTH<<1), PICTURE_RESOLUTION_ALIGNMENT);
iPicHeight = WELS_ALIGN(kiPicHeight + (PADDING_LENGTH<<1), PICTURE_RESOLUTION_ALIGNMENT);
iPicChromaWidth = iPicWidth >> 1;
iPicChromaHeight = iPicHeight >> 1;
iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight;
if(pCtx->iDecoderMode == SW_MODE)
{
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc( iLumaSize /* luma */
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]" ) );
pPic = (PPicture) WelsMalloc (sizeof (SPicture), "PPicture");
WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
WELS_VERIFY_RETURN_PROC_IF( NULL, NULL == pPic->pBuffer[0], FreePicture(pPic) );
pPic->iLinesize[0] = iPicWidth;
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize;
pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize;
pPic->pData[0] = pPic->pBuffer[0] + (1+pPic->iLinesize[0]) * PADDING_LENGTH;
pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/( ((1+pPic->iLinesize[1]) * PADDING_LENGTH) >> 1 );
pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/( ((1+pPic->iLinesize[2]) * PADDING_LENGTH) >> 1 );
}
memset (pPic, 0, sizeof (SPicture));
iPicWidth = WELS_ALIGN (kiPicWidth + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT);
iPicHeight = WELS_ALIGN (kiPicHeight + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT);
iPicChromaWidth = iPicWidth >> 1;
iPicChromaHeight = iPicHeight >> 1;
iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight;
if (pCtx->iDecoderMode == SW_MODE) {
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc (iLumaSize /* luma */
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic));
pPic->iLinesize[0] = iPicWidth;
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize;
pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize;
pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH;
pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1);
pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1);
}
pPic->iPlanes = 3; // yv12 in default
pPic->iWidthInPixel = kiPicWidth;
pPic->iHeightInPixel= kiPicHeight;
pPic->iFrameNum = -1;
pPic->bAvailableFlag= true;
pPic->iPlanes = 3; // yv12 in default
pPic->iWidthInPixel = kiPicWidth;
pPic->iHeightInPixel = kiPicHeight;
pPic->iFrameNum = -1;
pPic->bAvailableFlag = true;
return pPic;
return pPic;
}
void_t FreePicture( PPicture pPic )
{
if ( NULL != pPic )
{
void_t FreePicture (PPicture pPic) {
if (NULL != pPic) {
if ( pPic->pBuffer[0] )
{
WelsFree( pPic->pBuffer[0], "pPic->pBuffer[0]" );
}
if (pPic->pBuffer[0]) {
WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]");
}
WelsFree( pPic, "pPic" );
WelsFree (pPic, "pPic");
pPic = NULL;
}
pPic = NULL;
}
}
PPicture PrefetchPic( PPicBuff pPicBuf )
{
int32_t iPicIdx = 0;
PPicture pPic = NULL;
PPicture PrefetchPic (PPicBuff pPicBuf) {
int32_t iPicIdx = 0;
PPicture pPic = NULL;
if (pPicBuf->iCapacity == 0)
{
return NULL;
}
if (pPicBuf->iCapacity == 0) {
return NULL;
}
for ( iPicIdx = pPicBuf->iCurrentIdx+1; iPicIdx<pPicBuf->iCapacity ;++iPicIdx)
{
if (pPicBuf->ppPic[iPicIdx] !=NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef)
{
pPic = pPicBuf->ppPic[iPicIdx];
break;
}
}
if (pPic !=NULL)
{
pPicBuf->iCurrentIdx = iPicIdx;
return pPic;
}
for ( iPicIdx = 0 ; iPicIdx<pPicBuf->iCurrentIdx ;++iPicIdx)
{
if (pPicBuf->ppPic[iPicIdx] !=NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef)
{
pPic = pPicBuf->ppPic[iPicIdx];
break;
}
}
pPicBuf->iCurrentIdx = iPicIdx;
return pPic;
for (iPicIdx = pPicBuf->iCurrentIdx + 1; iPicIdx < pPicBuf->iCapacity ; ++iPicIdx) {
if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag
&& !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) {
pPic = pPicBuf->ppPic[iPicIdx];
break;
}
}
if (pPic != NULL) {
pPicBuf->iCurrentIdx = iPicIdx;
return pPic;
}
for (iPicIdx = 0 ; iPicIdx < pPicBuf->iCurrentIdx ; ++iPicIdx) {
if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag
&& !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) {
pPic = pPicBuf->ppPic[iPicIdx];
break;
}
}
pPicBuf->iCurrentIdx = iPicIdx;
return pPic;
}
} // namespace WelsDec

View File

@ -49,541 +49,508 @@
namespace WelsDec {
void_t WelsFillRecNeededMbInfo(PWelsDecoderContext pCtx, bool_t bOutput, PDqLayer pCurLayer)
{
PPicture pCurPic = pCtx->pDec;
int32_t iLumaStride = pCurPic->iLinesize[0];
int32_t iChromaStride = pCurPic->iLinesize[1];
int32_t iMbX = pCurLayer->iMbX;
int32_t iMbY = pCurLayer->iMbY;
pCurLayer->iLumaStride= iLumaStride;
pCurLayer->iChromaStride= iChromaStride;
if(bOutput)
{
pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX)<<4);
pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX)<<3);
pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX)<<3);
}
void_t WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool_t bOutput, PDqLayer pCurLayer) {
PPicture pCurPic = pCtx->pDec;
int32_t iLumaStride = pCurPic->iLinesize[0];
int32_t iChromaStride = pCurPic->iLinesize[1];
int32_t iMbX = pCurLayer->iMbX;
int32_t iMbY = pCurLayer->iMbY;
pCurLayer->iLumaStride = iLumaStride;
pCurLayer->iChromaStride = iChromaStride;
if (bOutput) {
pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
}
}
int32_t RecI4x4Mb(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
{
RecI4x4Luma(iMBXY, pCtx, pScoeffLevel, pDqLayer);
RecI4x4Chroma( iMBXY, pCtx, pScoeffLevel, pDqLayer);
return ERR_NONE;
int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
return ERR_NONE;
}
int32_t RecI4x4Luma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
{
/*****get local variable from outer variable********/
/*prediction info*/
uint8_t *pPred = pDqLayer->pPred[0];
int32_t iLumaStride = pDqLayer->iLumaStride;
int32_t *pBlockOffset = pCtx->iDecBlockOffsetArray;
PGetIntraPredFunc *pGetI4x4LumaPredFunc = pCtx->pGetI4x4LumaPredFunc;
int8_t *pIntra4x4PredMode = pDqLayer->pIntra4x4FinalMode[iMBXY];
int16_t *pRS = pScoeffLevel;
/*itransform info*/
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
/*************local variable********************/
uint8_t i = 0;
/*************real process*********************/
for(i=0; i<16; i++)
{
uint8_t *pPredI4x4 = pPred + pBlockOffset[i];
uint8_t uiMode= pIntra4x4PredMode[g_kuiScan4[i]];
pGetI4x4LumaPredFunc[uiMode](pPredI4x4, iLumaStride);
if ( pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]] )
{
int16_t *pRSI4x4 = &pRS[i<<4];
pIdctResAddPredFunc(pPredI4x4, iLumaStride, pRSI4x4);
}
}
return ERR_NONE;
int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
/*****get local variable from outer variable********/
/*prediction info*/
uint8_t* pPred = pDqLayer->pPred[0];
int32_t iLumaStride = pDqLayer->iLumaStride;
int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;
PGetIntraPredFunc* pGetI4x4LumaPredFunc = pCtx->pGetI4x4LumaPredFunc;
int8_t* pIntra4x4PredMode = pDqLayer->pIntra4x4FinalMode[iMBXY];
int16_t* pRS = pScoeffLevel;
/*itransform info*/
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
/*************local variable********************/
uint8_t i = 0;
/*************real process*********************/
for (i = 0; i < 16; i++) {
uint8_t* pPredI4x4 = pPred + pBlockOffset[i];
uint8_t uiMode = pIntra4x4PredMode[g_kuiScan4[i]];
pGetI4x4LumaPredFunc[uiMode] (pPredI4x4, iLumaStride);
if (pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]]) {
int16_t* pRSI4x4 = &pRS[i << 4];
pIdctResAddPredFunc (pPredI4x4, iLumaStride, pRSI4x4);
}
}
return ERR_NONE;
}
int32_t RecI4x4Chroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
{
int32_t iChromaStride = pCtx->pCurDqLayer->iCsStride[1];
int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
int32_t iChromaStride = pCtx->pCurDqLayer->iCsStride[1];
int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
PGetIntraPredFunc *pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;
int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
uint8_t *pPred = pDqLayer->pPred[1];
PGetIntraPredFunc* pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;
pGetIChromaPredFunc[iChromaPredMode](pPred, iChromaStride);
pPred = pDqLayer->pPred[2];
pGetIChromaPredFunc[iChromaPredMode](pPred, iChromaStride);
RecChroma(iMBXY, pCtx, pScoeffLevel, pDqLayer);
uint8_t* pPred = pDqLayer->pPred[1];
return ERR_NONE;
pGetIChromaPredFunc[iChromaPredMode] (pPred, iChromaStride);
pPred = pDqLayer->pPred[2];
pGetIChromaPredFunc[iChromaPredMode] (pPred, iChromaStride);
RecChroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
return ERR_NONE;
}
int32_t RecI16x16Mb(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
{
/*decoder use, encoder no use*/
int8_t iI16x16PredMode = pDqLayer->pIntraPredMode[iMBXY][7];
int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
PGetIntraPredFunc *pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;
PGetIntraPredFunc *pGetI16x16LumaPredFunc = pCtx->pGetI16x16LumaPredFunc;
int32_t iUVStride = pCtx->pCurDqLayer->iCsStride[1];
/*common use by decoder&encoder*/
int32_t iYStride = pDqLayer->iLumaStride;
int32_t *pBlockOffset = pCtx->iDecBlockOffsetArray;
int16_t *pRS = pScoeffLevel;
uint8_t *pPred = pDqLayer->pPred[0];
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
uint8_t i = 0;
/*decode i16x16 y*/
pGetI16x16LumaPredFunc[iI16x16PredMode](pPred, iYStride);
/*1 mb is divided 16 4x4_block to idct*/
for(i=0; i<16; i++)
{
int16_t *pRSI4x4 = pRS + (i<<4);
uint8_t *pPredI4x4 = pPred + pBlockOffset[i];
if ( pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]] || pRSI4x4[0] )
{
pIdctResAddPredFunc(pPredI4x4, iYStride, pRSI4x4);
}
}
/*decode intra mb cb&cr*/
pPred = pDqLayer->pPred[1];
pGetIChromaPredFunc[iChromaPredMode](pPred, iUVStride);
pPred = pDqLayer->pPred[2];
pGetIChromaPredFunc[iChromaPredMode](pPred, iUVStride);
RecChroma(iMBXY, pCtx, pScoeffLevel,pDqLayer);
return ERR_NONE;
int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
/*decoder use, encoder no use*/
int8_t iI16x16PredMode = pDqLayer->pIntraPredMode[iMBXY][7];
int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
PGetIntraPredFunc* pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;
PGetIntraPredFunc* pGetI16x16LumaPredFunc = pCtx->pGetI16x16LumaPredFunc;
int32_t iUVStride = pCtx->pCurDqLayer->iCsStride[1];
/*common use by decoder&encoder*/
int32_t iYStride = pDqLayer->iLumaStride;
int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;
int16_t* pRS = pScoeffLevel;
uint8_t* pPred = pDqLayer->pPred[0];
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
uint8_t i = 0;
/*decode i16x16 y*/
pGetI16x16LumaPredFunc[iI16x16PredMode] (pPred, iYStride);
/*1 mb is divided 16 4x4_block to idct*/
for (i = 0; i < 16; i++) {
int16_t* pRSI4x4 = pRS + (i << 4);
uint8_t* pPredI4x4 = pPred + pBlockOffset[i];
if (pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]] || pRSI4x4[0]) {
pIdctResAddPredFunc (pPredI4x4, iYStride, pRSI4x4);
}
}
/*decode intra mb cb&cr*/
pPred = pDqLayer->pPred[1];
pGetIChromaPredFunc[iChromaPredMode] (pPred, iUVStride);
pPred = pDqLayer->pPred[2];
pGetIChromaPredFunc[iChromaPredMode] (pPred, iUVStride);
RecChroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
return ERR_NONE;
}
typedef struct TagMCRefMember {
uint8_t* pDstY;
uint8_t* pDstU;
uint8_t* pDstV;
uint8_t* pDstY;
uint8_t* pDstU;
uint8_t* pDstV;
uint8_t* pSrcY;
uint8_t* pSrcU;
uint8_t* pSrcV;
uint8_t* pSrcY;
uint8_t* pSrcU;
uint8_t* pSrcV;
int32_t iSrcLineLuma;
int32_t iSrcLineChroma;
int32_t iSrcLineLuma;
int32_t iSrcLineChroma;
int32_t iDstLineLuma;
int32_t iDstLineChroma;
int32_t iDstLineLuma;
int32_t iDstLineChroma;
int32_t iPicWidth;
int32_t iPicHeight;
}sMCRefMember;
int32_t iPicWidth;
int32_t iPicHeight;
} sMCRefMember;
//according to current 8*8 block ref_index to gain reference picture
static inline void_t GetRefPic(sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList, int32_t iIndex)
{
PPicture pRefPic;
static inline void_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList,
int32_t iIndex) {
PPicture pRefPic;
int8_t iRefIdx = pRefIdxList[iIndex];
pRefPic = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
int8_t iRefIdx = pRefIdxList[iIndex];
pRefPic = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
pMCRefMem->iSrcLineLuma = pRefPic->iLinesize[0];
pMCRefMem->iSrcLineChroma = pRefPic->iLinesize[1];
pMCRefMem->iSrcLineLuma = pRefPic->iLinesize[0];
pMCRefMem->iSrcLineChroma = pRefPic->iLinesize[1];
pMCRefMem->pSrcY = pRefPic->pData[0];
pMCRefMem->pSrcU = pRefPic->pData[1];
pMCRefMem->pSrcV = pRefPic->pData[2];
pMCRefMem->pSrcY = pRefPic->pData[0];
pMCRefMem->pSrcU = pRefPic->pData[1];
pMCRefMem->pSrcV = pRefPic->pData[2];
}
#ifndef MC_FLOW_SIMPLE_JUDGE
#define MC_FLOW_SIMPLE_JUDGE 1
#endif //MC_FLOW_SIMPLE_JUDGE
static inline void_t BaseMC(sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2])
{
int32_t iExpandWidth = PADDING_LENGTH;
int32_t iExpandHeight = PADDING_LENGTH;
static inline void_t BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
int32_t iExpandWidth = PADDING_LENGTH;
int32_t iExpandHeight = PADDING_LENGTH;
int16_t iMVX = iMVs[0] >> 2;
int16_t iMVY = iMVs[1] >> 2;
int32_t iMVOffsetLuma = iMVX + iMVY * pMCRefMem->iSrcLineLuma;
int32_t iMVOffsetChroma = (iMVX>>1) + (iMVY>>1) * pMCRefMem->iSrcLineChroma;
int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel
int32_t iFullMVy = (iYOffset << 2) + iMVs[1];
int32_t iIntMVx = iFullMVx >> 2;//integer pixel
int32_t iIntMVy = iFullMVy >> 2;
int16_t iMVX = iMVs[0] >> 2;
int16_t iMVY = iMVs[1] >> 2;
int32_t iMVOffsetLuma = iMVX + iMVY * pMCRefMem->iSrcLineLuma;
int32_t iMVOffsetChroma = (iMVX >> 1) + (iMVY >> 1) * pMCRefMem->iSrcLineChroma;
int32_t iSrcPixOffsetLuma = iXOffset + iYOffset * pMCRefMem->iSrcLineLuma;
int32_t iSrcPixOffsetChroma = (iXOffset>>1) + (iYOffset>>1) * pMCRefMem->iSrcLineChroma;
int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel
int32_t iFullMVy = (iYOffset << 2) + iMVs[1];
int32_t iIntMVx = iFullMVx >> 2;//integer pixel
int32_t iIntMVy = iFullMVy >> 2;
int32_t iBlkWidthChroma = iBlkWidth >> 1;
int32_t iBlkHeightChroma = iBlkHeight >> 1;
int32_t iPicWidthChroma = pMCRefMem->iPicWidth >> 1;
int32_t iPicHeightChroma = pMCRefMem->iPicHeight >> 1;
int32_t iSrcPixOffsetLuma = iXOffset + iYOffset * pMCRefMem->iSrcLineLuma;
int32_t iSrcPixOffsetChroma = (iXOffset >> 1) + (iYOffset >> 1) * pMCRefMem->iSrcLineChroma;
//the offset only for luma padding if MV violation as there was 5-tap (-2, -1, 0, 1, 2) filter for luma (horizon and vertical)
int32_t iPadOffset = 2 + (pMCRefMem->iSrcLineLuma << 1); //(-2, -2) pixel location as the starting point
int32_t iBlkWidthChroma = iBlkWidth >> 1;
int32_t iBlkHeightChroma = iBlkHeight >> 1;
int32_t iPicWidthChroma = pMCRefMem->iPicWidth >> 1;
int32_t iPicHeightChroma = pMCRefMem->iPicHeight >> 1;
uint8_t* pSrcY = pMCRefMem->pSrcY + iSrcPixOffsetLuma;
uint8_t* pSrcU = pMCRefMem->pSrcU + iSrcPixOffsetChroma;
uint8_t* pSrcV = pMCRefMem->pSrcV + iSrcPixOffsetChroma;
uint8_t* pDstY = pMCRefMem->pDstY;
uint8_t* pDstU = pMCRefMem->pDstU;
uint8_t* pDstV = pMCRefMem->pDstV;
bool_t bExpand = false;
//the offset only for luma padding if MV violation as there was 5-tap (-2, -1, 0, 1, 2) filter for luma (horizon and vertical)
int32_t iPadOffset = 2 + (pMCRefMem->iSrcLineLuma << 1); //(-2, -2) pixel location as the starting point
FORCE_STACK_ALIGN_1D( uint8_t, uiExpandBuf, (PADDING_LENGTH+6)*(PADDING_LENGTH+6), 16 );
if (iFullMVx & 0x07)
{
iExpandWidth -= 3;
}
if (iFullMVy & 0x07)
{
iExpandHeight -= 3;
}
uint8_t* pSrcY = pMCRefMem->pSrcY + iSrcPixOffsetLuma;
uint8_t* pSrcU = pMCRefMem->pSrcU + iSrcPixOffsetChroma;
uint8_t* pSrcV = pMCRefMem->pSrcV + iSrcPixOffsetChroma;
uint8_t* pDstY = pMCRefMem->pDstY;
uint8_t* pDstU = pMCRefMem->pDstU;
uint8_t* pDstV = pMCRefMem->pDstV;
bool_t bExpand = false;
FORCE_STACK_ALIGN_1D (uint8_t, uiExpandBuf, (PADDING_LENGTH + 6) * (PADDING_LENGTH + 6), 16);
if (iFullMVx & 0x07) {
iExpandWidth -= 3;
}
if (iFullMVy & 0x07) {
iExpandHeight -= 3;
}
#ifdef MC_FLOW_SIMPLE_JUDGE
if (iIntMVx < -iExpandWidth ||
iIntMVy < -iExpandHeight ||
iIntMVx + iBlkWidth > pMCRefMem->iPicWidth - 1 + iExpandWidth ||
iIntMVy + iBlkHeight > pMCRefMem->iPicHeight - 1 + iExpandHeight)
if (iIntMVx < -iExpandWidth ||
iIntMVy < -iExpandHeight ||
iIntMVx + iBlkWidth > pMCRefMem->iPicWidth - 1 + iExpandWidth ||
iIntMVy + iBlkHeight > pMCRefMem->iPicHeight - 1 + iExpandHeight)
#else
if (iIntMVx < -iExpandWidth ||
iIntMVy < -iExpandHeight ||
iIntMVx + PADDING_LENGTH > pMCRefMem->iPicWidth + iExpandWidth ||
iIntMVy + PADDING_LENGTH > pMCRefMem->iPicHeight + iExpandHeight)
if (iIntMVx < -iExpandWidth ||
iIntMVy < -iExpandHeight ||
iIntMVx + PADDING_LENGTH > pMCRefMem->iPicWidth + iExpandWidth ||
iIntMVy + PADDING_LENGTH > pMCRefMem->iPicHeight + iExpandHeight)
#endif
{
FillBufForMc(uiExpandBuf, 21, pSrcY, pMCRefMem->iSrcLineLuma, iMVOffsetLuma-iPadOffset,
iBlkWidth+5, iBlkHeight+5, iIntMVx-2, iIntMVy-2, pMCRefMem->iPicWidth, pMCRefMem->iPicHeight);
pMCFunc->pMcLumaFunc(uiExpandBuf+44, 21, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth, iBlkHeight);//44=2+2*21
bExpand = true;
}
else
{
pSrcY += iMVOffsetLuma;
pMCFunc->pMcLumaFunc(pSrcY, pMCRefMem->iSrcLineLuma, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth, iBlkHeight);
}
{
FillBufForMc (uiExpandBuf, 21, pSrcY, pMCRefMem->iSrcLineLuma, iMVOffsetLuma - iPadOffset,
iBlkWidth + 5, iBlkHeight + 5, iIntMVx - 2, iIntMVy - 2, pMCRefMem->iPicWidth, pMCRefMem->iPicHeight);
pMCFunc->pMcLumaFunc (uiExpandBuf + 44, 21, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth,
iBlkHeight); //44=2+2*21
bExpand = true;
} else {
pSrcY += iMVOffsetLuma;
pMCFunc->pMcLumaFunc (pSrcY, pMCRefMem->iSrcLineLuma, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth,
iBlkHeight);
}
if (bExpand)
{
FillBufForMc(uiExpandBuf, 21, pSrcU, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma+1, iBlkHeightChroma+1, iFullMVx>>3, iFullMVy>>3, iPicWidthChroma, iPicHeightChroma);
pMCFunc->pMcChromaFunc(uiExpandBuf, 21, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
FillBufForMc(uiExpandBuf, 21, pSrcV, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma+1, iBlkHeightChroma+1, iFullMVx>>3, iFullMVy>>3, iPicWidthChroma, iPicHeightChroma);
pMCFunc->pMcChromaFunc(uiExpandBuf, 21, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
}
else
{
pSrcU += iMVOffsetChroma;
pSrcV += iMVOffsetChroma;
pMCFunc->pMcChromaFunc(pSrcU, pMCRefMem->iSrcLineChroma, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
pMCFunc->pMcChromaFunc(pSrcV, pMCRefMem->iSrcLineChroma, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
}
if (bExpand) {
FillBufForMc (uiExpandBuf, 21, pSrcU, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma + 1,
iBlkHeightChroma + 1, iFullMVx >> 3, iFullMVy >> 3, iPicWidthChroma, iPicHeightChroma);
pMCFunc->pMcChromaFunc (uiExpandBuf, 21, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma,
iBlkHeightChroma);
FillBufForMc (uiExpandBuf, 21, pSrcV, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma + 1,
iBlkHeightChroma + 1, iFullMVx >> 3, iFullMVy >> 3, iPicWidthChroma, iPicHeightChroma);
pMCFunc->pMcChromaFunc (uiExpandBuf, 21, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma,
iBlkHeightChroma);
} else {
pSrcU += iMVOffsetChroma;
pSrcV += iMVOffsetChroma;
pMCFunc->pMcChromaFunc (pSrcU, pMCRefMem->iSrcLineChroma, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,
iBlkWidthChroma, iBlkHeightChroma);
pMCFunc->pMcChromaFunc (pSrcV, pMCRefMem->iSrcLineChroma, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,
iBlkWidthChroma, iBlkHeightChroma);
}
}
void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDecoderContext pCtx)
{
sMCRefMember pMCRefMem;
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
SMcFunc* pMCFunc = &pCtx->sMcFunc;
void_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {
sMCRefMember pMCRefMem;
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
SMcFunc* pMCFunc = &pCtx->sMcFunc;
int32_t iMBXY = pCurDqLayer->iMbXyIndex;
int32_t iMBXY = pCurDqLayer->iMbXyIndex;
int16_t iMVs[2] = {0};
int32_t iMBType = pCurDqLayer->pMbType[iMBXY];
int16_t iMVs[2] = {0};
int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;
int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;
int32_t iMBType = pCurDqLayer->pMbType[iMBXY];
int32_t iDstLineLuma = pCtx->pDec->iLinesize[0];
int32_t iDstLineChroma = pCtx->pDec->iLinesize[1];
int32_t iBlk8X, iBlk8Y, iBlk4X, iBlk4Y, i, j, iIIdx, iJIdx;
int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;
int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;
pMCRefMem.iPicWidth = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbWidth<<4);
pMCRefMem.iPicHeight = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbHeight<<4);
int32_t iDstLineLuma = pCtx->pDec->iLinesize[0];
int32_t iDstLineChroma = pCtx->pDec->iLinesize[1];
pMCRefMem.pDstY = pPredY;
pMCRefMem.pDstU = pPredCb;
pMCRefMem.pDstV = pPredCr;
int32_t iBlk8X, iBlk8Y, iBlk4X, iBlk4Y, i, j, iIIdx, iJIdx;
pMCRefMem.iDstLineLuma = iDstLineLuma;
pMCRefMem.iDstLineChroma = iDstLineChroma;
switch(iMBType)
{
case MB_TYPE_SKIP:
case MB_TYPE_16x16:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
GetRefPic( &pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0 );
BaseMC(&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
break;
case MB_TYPE_16x8:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
GetRefPic( &pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0 );
BaseMC(&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);
pMCRefMem.iPicWidth = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbWidth << 4);
pMCRefMem.iPicHeight = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbHeight << 4);
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];
GetRefPic( &pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8 );
pMCRefMem.pDstY = pPredY + (iDstLineLuma << 3);
pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);
pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);
BaseMC(&pMCRefMem, iMBOffsetX, iMBOffsetY+8, pMCFunc, 16, 8, iMVs);
break;
case MB_TYPE_8x16:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
GetRefPic( &pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0 );
BaseMC(&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);
pMCRefMem.pDstY = pPredY;
pMCRefMem.pDstU = pPredCb;
pMCRefMem.pDstV = pPredCr;
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];
GetRefPic( &pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 2 );
pMCRefMem.pDstY = pPredY + 8;
pMCRefMem.pDstU = pPredCb + 4;
pMCRefMem.pDstV = pPredCr + 4;
BaseMC(&pMCRefMem, iMBOffsetX+8, iMBOffsetY, pMCFunc, 8, 16, iMVs);
break;
case MB_TYPE_8x8:
case MB_TYPE_8x8_REF0:
{
uint32_t iSubMBType;
int32_t iXOffset, iYOffset;
uint8_t *pDstY, *pDstU, *pDstV;
for (i = 0; i < 4; i++)
{
iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];
iBlk8X = (i&1) << 3;
iBlk8Y = (i>>1) << 3;
iXOffset = iMBOffsetX + iBlk8X;
iYOffset = iMBOffsetY + iBlk8Y;
pMCRefMem.iDstLineLuma = iDstLineLuma;
pMCRefMem.iDstLineChroma = iDstLineChroma;
switch (iMBType) {
case MB_TYPE_SKIP:
case MB_TYPE_16x16:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
break;
case MB_TYPE_16x8:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);
iIIdx = ((i>>1)<<3) +((i&1)<<1);
GetRefPic( &pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx );
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8);
pMCRefMem.pDstY = pPredY + (iDstLineLuma << 3);
pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);
pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs);
break;
case MB_TYPE_8x16:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);
pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;
pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
pDstV = pPredCr + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
pMCRefMem.pDstY = pDstY;
pMCRefMem.pDstU = pDstU;
pMCRefMem.pDstV = pDstV;
switch(iSubMBType)
{
case SUB_MB_TYPE_8x8:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
BaseMC( &pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs );
break;
case SUB_MB_TYPE_8x4:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
BaseMC(&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 2);
pMCRefMem.pDstY = pPredY + 8;
pMCRefMem.pDstU = pPredCb + 4;
pMCRefMem.pDstV = pPredCr + 4;
BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);
break;
case MB_TYPE_8x8:
case MB_TYPE_8x8_REF0: {
uint32_t iSubMBType;
int32_t iXOffset, iYOffset;
uint8_t* pDstY, *pDstU, *pDstV;
for (i = 0; i < 4; i++) {
iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];
iBlk8X = (i & 1) << 3;
iBlk8Y = (i >> 1) << 3;
iXOffset = iMBOffsetX + iBlk8X;
iYOffset = iMBOffsetY + iBlk8Y;
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx+4][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx+4][1];
pMCRefMem.pDstY += (iDstLineLuma << 2);
pMCRefMem.pDstU += (iDstLineChroma << 1);
pMCRefMem.pDstV += (iDstLineChroma << 1);
BaseMC(&pMCRefMem, iXOffset, iYOffset+4, pMCFunc, 8, 4, iMVs);
break;
case SUB_MB_TYPE_4x8:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
BaseMC(&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx);
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx+1][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx+1][1];
pMCRefMem.pDstY += 4;
pMCRefMem.pDstU += 2;
pMCRefMem.pDstV += 2;
BaseMC(&pMCRefMem, iXOffset+4, iYOffset, pMCFunc, 4, 8, iMVs);
break;
case SUB_MB_TYPE_4x4:
{
for (j = 0; j < 4; j++)
{
int32_t iUVLineStride;
iJIdx = ((j>>1)<<2) + (j&1);
pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;
pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
pDstV = pPredCr + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
pMCRefMem.pDstY = pDstY;
pMCRefMem.pDstU = pDstU;
pMCRefMem.pDstV = pDstV;
switch (iSubMBType) {
case SUB_MB_TYPE_8x8:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
break;
case SUB_MB_TYPE_8x4:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
iBlk4X = (j&1) << 2;
iBlk4Y = (j>>1) << 2;
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1];
pMCRefMem.pDstY += (iDstLineLuma << 2);
pMCRefMem.pDstU += (iDstLineChroma << 1);
pMCRefMem.pDstV += (iDstLineChroma << 1);
BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
break;
case SUB_MB_TYPE_4x8:
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;
pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;
pMCRefMem.pDstU = pDstU + iUVLineStride;
pMCRefMem.pDstV = pDstV + iUVLineStride;
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1];
pMCRefMem.pDstY += 4;
pMCRefMem.pDstU += 2;
pMCRefMem.pDstV += 2;
BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
break;
case SUB_MB_TYPE_4x4: {
for (j = 0; j < 4; j++) {
int32_t iUVLineStride;
iJIdx = ((j >> 1) << 2) + (j & 1);
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx+iJIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx+iJIdx][1];
BaseMC(&pMCRefMem, iXOffset+iBlk4X, iYOffset+iBlk4Y, pMCFunc, 4, 4, iMVs);
}
}
break;
default:
break;
}
}
}
break;
default:
break;
}
iBlk4X = (j & 1) << 2;
iBlk4Y = (j >> 1) << 2;
iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;
pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;
pMCRefMem.pDstU = pDstU + iUVLineStride;
pMCRefMem.pDstV = pDstV + iUVLineStride;
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];
BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
}
}
break;
default:
break;
}
}
}
break;
default:
break;
}
}
int32_t RecChroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
{
int32_t iChromaStride = pCtx->pCurDqLayer->iCsStride[1];
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
int32_t iChromaStride = pCtx->pCurDqLayer->iCsStride[1];
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
uint8_t i=0, j=0;
uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4;
if ( 1 == uiCbpC || 2 == uiCbpC )
{
WelsChromaDcIdct( pScoeffLevel + 256 ); // 256 = 16*16
WelsChromaDcIdct( pScoeffLevel + 320 ); // 256 = 16*16
for(i=0; i<2; i++)
{
int16_t *pRS = pScoeffLevel + 256 + (i << 6);
uint8_t *pPred = pDqLayer->pPred[i+1];
int32_t *pBlockOffset = i==0 ? &pCtx->iDecBlockOffsetArray[16] : &pCtx->iDecBlockOffsetArray[20];
/*1 chroma is divided 4 4x4_block to idct*/
for(j=0; j<4; j++)
{
int16_t *pRSI4x4 = &pRS[j<<4];
uint8_t *pPredI4x4 = pPred + pBlockOffset[j];
if ( pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[16+(i<<2)+j]] || pRSI4x4[0] )
{
pIdctResAddPredFunc(pPredI4x4, iChromaStride, pRSI4x4);
}
}
}
}
return ERR_NONE;
uint8_t i = 0, j = 0;
uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4;
if (1 == uiCbpC || 2 == uiCbpC) {
WelsChromaDcIdct (pScoeffLevel + 256); // 256 = 16*16
WelsChromaDcIdct (pScoeffLevel + 320); // 256 = 16*16
for (i = 0; i < 2; i++) {
int16_t* pRS = pScoeffLevel + 256 + (i << 6);
uint8_t* pPred = pDqLayer->pPred[i + 1];
int32_t* pBlockOffset = i == 0 ? &pCtx->iDecBlockOffsetArray[16] : &pCtx->iDecBlockOffsetArray[20];
/*1 chroma is divided 4 4x4_block to idct*/
for (j = 0; j < 4; j++) {
int16_t* pRSI4x4 = &pRS[j << 4];
uint8_t* pPredI4x4 = pPred + pBlockOffset[j];
if (pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[16 + (i << 2) + j]] || pRSI4x4[0]) {
pIdctResAddPredFunc (pPredI4x4, iChromaStride, pRSI4x4);
}
}
}
}
return ERR_NONE;
}
void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iSrcStride, int32_t iSrcOffset,
int32_t iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight)
{
int32_t iY;
int32_t iStartY, iStartX, iEndY, iEndX;
int32_t iOffsetAdj = 0;
int32_t iAddrSrc, iAddrBuf;
int32_t iNum, iNum1;
uint8_t *pBufSrc, *pBufDst;
uint8_t *pBufSrc1, *pBufDst1;
void_t FillBufForMc (uint8_t* pBuf, int32_t iBufStride, uint8_t* pSrc, int32_t iSrcStride, int32_t iSrcOffset,
int32_t iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight) {
int32_t iY;
int32_t iStartY, iStartX, iEndY, iEndX;
int32_t iOffsetAdj = 0;
int32_t iAddrSrc, iAddrBuf;
int32_t iNum, iNum1;
uint8_t* pBufSrc, *pBufDst;
uint8_t* pBufSrc1, *pBufDst1;
if( iSrcY >= iPicHeight )
{
iOffsetAdj += ( iPicHeight - 1 - iSrcY ) * iSrcStride;
iSrcY = iPicHeight - 1;
}
else if( iSrcY <= -iBlockHeight )
{
iOffsetAdj += ( 1 - iBlockHeight - iSrcY ) * iSrcStride;
iSrcY = 1 - iBlockHeight;
}
if( iSrcX >= iPicWidth )
{
iOffsetAdj += ( iPicWidth - 1 - iSrcX );
iSrcX = iPicWidth - 1;
}
else if( iSrcX <= -iBlockWidth )
{
iOffsetAdj += ( 1 - iBlockWidth - iSrcX );
iSrcX = 1 - iBlockWidth;
}
if (iSrcY >= iPicHeight) {
iOffsetAdj += (iPicHeight - 1 - iSrcY) * iSrcStride;
iSrcY = iPicHeight - 1;
} else if (iSrcY <= -iBlockHeight) {
iOffsetAdj += (1 - iBlockHeight - iSrcY) * iSrcStride;
iSrcY = 1 - iBlockHeight;
}
if (iSrcX >= iPicWidth) {
iOffsetAdj += (iPicWidth - 1 - iSrcX);
iSrcX = iPicWidth - 1;
} else if (iSrcX <= -iBlockWidth) {
iOffsetAdj += (1 - iBlockWidth - iSrcX);
iSrcX = 1 - iBlockWidth;
}
iOffsetAdj += iSrcOffset;
iOffsetAdj += iSrcOffset;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) > (b) ? (b) : (a))
iStartY = MAX(0, -iSrcY);
iStartX = MAX(0, -iSrcX);
iEndY = MIN(iBlockHeight, iPicHeight - iSrcY);
iEndX = MIN(iBlockWidth, iPicWidth - iSrcX);
// copy existing part
iAddrSrc = iStartX + iStartY * iSrcStride;
iAddrBuf = iStartX + iStartY * iBufStride;
iNum = iEndX - iStartX;
for( iY = iStartY; iY < iEndY; iY++ )
{
memcpy( pBuf + iAddrBuf, pSrc + iOffsetAdj + iAddrSrc, iNum );
iAddrSrc += iSrcStride;
iAddrBuf += iBufStride;
}
//top
pBufSrc = pBuf + iStartX + iStartY * iBufStride;
pBufDst = pBuf + iStartX;
iNum = iEndX - iStartX;
for( iY = 0; iY < iStartY; iY++ )
{
memcpy( pBufDst, pBufSrc, iNum );
pBufDst += iBufStride;
}
//bottom
pBufSrc = pBuf + iStartX + ( iEndY - 1 ) * iBufStride;
pBufDst = pBuf + iStartX + iEndY * iBufStride;
iNum = iEndX - iStartX;
for( iY = iEndY; iY < iBlockHeight; iY++ )
{
memcpy( pBufDst, pBufSrc, iNum );
pBufDst += iBufStride;
}
pBufSrc = pBuf + iStartX;
pBufDst = pBuf;
iNum = iStartX;
iStartY = MAX (0, -iSrcY);
iStartX = MAX (0, -iSrcX);
iEndY = MIN (iBlockHeight, iPicHeight - iSrcY);
iEndX = MIN (iBlockWidth, iPicWidth - iSrcX);
pBufSrc1 = pBuf + iEndX - 1;
pBufDst1 = pBuf + iEndX;
iNum1 = iBlockWidth - iEndX;
for( iY=0; iY<iBlockHeight; iY++ )
{
//left
memset( pBufDst, pBufSrc[0], iNum );
pBufDst += iBufStride;
pBufSrc += iBufStride;
//right
memset( pBufDst1, pBufSrc1[0], iNum1 );
pBufDst1 += iBufStride;
pBufSrc1 += iBufStride;
}
// copy existing part
iAddrSrc = iStartX + iStartY * iSrcStride;
iAddrBuf = iStartX + iStartY * iBufStride;
iNum = iEndX - iStartX;
for (iY = iStartY; iY < iEndY; iY++) {
memcpy (pBuf + iAddrBuf, pSrc + iOffsetAdj + iAddrSrc, iNum);
iAddrSrc += iSrcStride;
iAddrBuf += iBufStride;
}
//top
pBufSrc = pBuf + iStartX + iStartY * iBufStride;
pBufDst = pBuf + iStartX;
iNum = iEndX - iStartX;
for (iY = 0; iY < iStartY; iY++) {
memcpy (pBufDst, pBufSrc, iNum);
pBufDst += iBufStride;
}
//bottom
pBufSrc = pBuf + iStartX + (iEndY - 1) * iBufStride;
pBufDst = pBuf + iStartX + iEndY * iBufStride;
iNum = iEndX - iStartX;
for (iY = iEndY; iY < iBlockHeight; iY++) {
memcpy (pBufDst, pBufSrc, iNum);
pBufDst += iBufStride;
}
pBufSrc = pBuf + iStartX;
pBufDst = pBuf;
iNum = iStartX;
pBufSrc1 = pBuf + iEndX - 1;
pBufDst1 = pBuf + iEndX;
iNum1 = iBlockWidth - iEndX;
for (iY = 0; iY < iBlockHeight; iY++) {
//left
memset (pBufDst, pBufSrc[0], iNum);
pBufDst += iBufStride;
pBufSrc += iBufStride;
//right
memset (pBufDst1, pBufSrc1[0], iNum1);
pBufDst1 += iBufStride;
pBufSrc1 += iBufStride;
}
}
} // namespace WelsDec

View File

@ -37,7 +37,7 @@
*
*************************************************************************************
*/
#include <string.h>
#include <stdlib.h>
#include <math.h>
@ -68,15 +68,14 @@ PWelsLogCallbackFunc g_pLog = NULL;
void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...)
{
va_list pVl;
void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...) {
va_list pVl;
PWelsDecoderContext pCtx = (PWelsDecoderContext)pPtr;
PWelsDecoderContext pCtx = (PWelsDecoderContext)pPtr;
va_start(pVl, kpFmt);
g_pLog(pCtx->pTraceHandle, iLevel, kpFmt, pVl);
va_end(pVl);
va_start (pVl, kpFmt);
g_pLog (pCtx->pTraceHandle, iLevel, kpFmt, pVl);
va_end (pVl);
}
@ -84,122 +83,106 @@ void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...)
#if defined(_MSC_VER) && (_MSC_VER>=1500)
int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
{
va_list pArgPtr;
int32_t iRc;
int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
va_list pArgPtr;
int32_t iRc;
va_start(pArgPtr, kpFormat);
va_start (pArgPtr, kpFormat);
iRc = vsnprintf_s(pBuffer, iSizeOfBuffer, _TRUNCATE, kpFormat, pArgPtr);
iRc = vsnprintf_s (pBuffer, iSizeOfBuffer, _TRUNCATE, kpFormat, pArgPtr);
va_end(pArgPtr);
va_end (pArgPtr);
return iRc;
return iRc;
}
str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
{
strncpy_s(pDest, iSizeInBytes, kpSrc, iCount);
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
strncpy_s (pDest, iSizeInBytes, kpSrc, iCount);
return pDest;
return pDest;
}
int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
{
return strnlen_s(kpStr, iMaxlen);
int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
return strnlen_s (kpStr, iMaxlen);
}
int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
{
return vsprintf_s(pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
return vsprintf_s (pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
}
WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
{
WelsFileHandle* pFp = NULL;
if( fopen_s(&pFp, kpFilename, kpMode) != 0 ){
return NULL;
}
WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
WelsFileHandle* pFp = NULL;
if (fopen_s (&pFp, kpFilename, kpMode) != 0) {
return NULL;
}
return pFp;
return pFp;
}
int32_t WelsFclose(WelsFileHandle* pFp)
{
return fclose(pFp);
int32_t WelsFclose (WelsFileHandle* pFp) {
return fclose (pFp);
}
int32_t WelsGetTimeOfDay(SWelsTime * pTp)
{
return _ftime_s(pTp);
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
return _ftime_s (pTp);
}
int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
{
struct tm sTimeNow;
int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
struct tm sTimeNow;
localtime_s(&sTimeNow, &kpTp->time);
localtime_s (&sTimeNow, &kpTp->time);
return strftime(pBuffer, iSize, kpFormat, &sTimeNow);
return strftime (pBuffer, iSize, kpFormat, &sTimeNow);
}
#else
#else
int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
{
va_list pArgPtr;
int32_t iRc;
int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
va_list pArgPtr;
int32_t iRc;
va_start(pArgPtr, kpFormat);
va_start (pArgPtr, kpFormat);
iRc = vsprintf(pBuffer, kpFormat, pArgPtr);//confirmed_safe_unsafe_usage
iRc = vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
va_end(pArgPtr);
va_end (pArgPtr);
return iRc;
return iRc;
}
str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
{
strncpy(pDest, kpSrc, iCount);//confirmed_safe_unsafe_usage
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
strncpy (pDest, kpSrc, iCount); //confirmed_safe_unsafe_usage
return pDest;
return pDest;
}
int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
{
return strlen(kpStr);//confirmed_safe_unsafe_usage
int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
return strlen (kpStr); //confirmed_safe_unsafe_usage
}
int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
{
return vsprintf(pBuffer, kpFormat, pArgPtr);//confirmed_safe_unsafe_usage
int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
return vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
}
WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
{
return fopen(kpFilename, kpMode);
WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
return fopen (kpFilename, kpMode);
}
int32_t WelsFclose(WelsFileHandle* pFp)
{
return fclose(pFp);
int32_t WelsFclose (WelsFileHandle* pFp) {
return fclose (pFp);
}
int32_t WelsGetTimeOfDay(SWelsTime * pTp)
{
return _ftime(pTp);
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
return _ftime (pTp);
}
int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
{
struct tm * pTnow;
int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
struct tm* pTnow;
pTnow = localtime(&kpTp->time);
pTnow = localtime (&kpTp->time);
return strftime(pBuffer, iSize, kpFormat, pTnow);
return strftime (pBuffer, iSize, kpFormat, pTnow);
}
@ -207,101 +190,89 @@ int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, con
#else //GCC
int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
{
va_list pArgPtr;
int32_t iRc;
int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
va_list pArgPtr;
int32_t iRc;
va_start(pArgPtr, kpFormat);
va_start (pArgPtr, kpFormat);
iRc = vsnprintf(pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
iRc = vsnprintf (pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
va_end(pArgPtr);
va_end (pArgPtr);
return iRc;
return iRc;
}
str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
{
return strncpy(pDest, kpSrc, iCount);//confirmed_safe_unsafe_usage
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
return strncpy (pDest, kpSrc, iCount); //confirmed_safe_unsafe_usage
}
#if !defined(MACOS) && !defined(UNIX) && !defined(APPLE_IOS)
int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
{
return strnlen(kpStr, iMaxlen);//confirmed_safe_unsafe_usage
int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
return strnlen (kpStr, iMaxlen); //confirmed_safe_unsafe_usage
}
#else
int32_t WelsStrnlen(const str_t *kpString, int32_t iMaxlen)
{
// In mac os, there is no strnlen in string.h, we can only use strlen instead of strnlen or
// implement strnlen by ourself
int32_t WelsStrnlen (const str_t* kpString, int32_t iMaxlen) {
// In mac os, there is no strnlen in string.h, we can only use strlen instead of strnlen or
// implement strnlen by ourself
#if 1
return strlen(pString);//confirmed_safe_unsafe_usage
#else
const str_t *kpSrc;
for (kpSrc = kpString; iMaxlen-- && *kpSrc != '\0'; ++kpSrc)
return kpSrc - kpString;
return strlen (pString); //confirmed_safe_unsafe_usage
#else
const str_t* kpSrc;
for (kpSrc = kpString; iMaxlen-- && *kpSrc != '\0'; ++kpSrc)
return kpSrc - kpString;
#endif
}
#endif
int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
{
return vsprintf(pBuffer, kpFormat, pArgPtr);//confirmed_safe_unsafe_usage
int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
return vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
}
WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
{
return fopen(kpFilename, kpMode);
WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
return fopen (kpFilename, kpMode);
}
int32_t WelsFclose(WelsFileHandle * pFp)
{
return fclose(pFp);
int32_t WelsFclose (WelsFileHandle* pFp) {
return fclose (pFp);
}
int32_t WelsGetTimeOfDay(SWelsTime * pTp)
{
struct timeval sTv;
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
struct timeval sTv;
if( gettimeofday(&sTv, NULL) ){
return -1;
}
if (gettimeofday (&sTv, NULL)) {
return -1;
}
pTp->time = sTv.tv_sec;
pTp->millitm = (uint16_t)sTv.tv_usec/1000;
pTp->time = sTv.tv_sec;
pTp->millitm = (uint16_t)sTv.tv_usec / 1000;
return 0;
return 0;
}
int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
{
struct tm * pTnow;
pTnow = localtime(&kpTp->time);
int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
struct tm* pTnow;
return strftime(pBuffer, iSize, kpFormat, pTnow);
pTnow = localtime (&kpTp->time);
return strftime (pBuffer, iSize, kpFormat, pTnow);
}
#endif
int32_t WelsFwrite(const void_t * kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp)
{
return fwrite(kpBuffer, iSize, iCount, pFp);
int32_t WelsFwrite (const void_t* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
return fwrite (kpBuffer, iSize, iCount, pFp);
}
uint16_t WelsGetMillsecond(const SWelsTime * kpTp)
{
return kpTp->millitm;
uint16_t WelsGetMillsecond (const SWelsTime* kpTp) {
return kpTp->millitm;
}
int32_t WelsFflush(WelsFileHandle* pFp)
{
return fflush(pFp);
int32_t WelsFflush (WelsFileHandle* pFp) {
return fflush (pFp);
}
} // namespace WelsDec

View File

@ -40,132 +40,124 @@
namespace WelsDec {
#ifdef WIN32
typedef int ( *CM_WELS_TRACE)( const char* kpFormat, ...);
typedef int (*CM_WELS_TRACE) (const char* kpFormat, ...);
#else
typedef int ( *CM_WELS_TRACE)( const char* kpDllName, const char* kpFormat, ...);
typedef int (*CM_WELS_TRACE) (const char* kpDllName, const char* kpFormat, ...);
#endif
typedef enum {
Wels_Trace_Type = 0,
Wels_Trace_Type_File = 1,
Wels_Trace_Type_WinDgb = 2,
Wels_Trace_Type = 0,
Wels_Trace_Type_File = 1,
Wels_Trace_Type_WinDgb = 2,
} EWelsTraceType;
class IWelsTrace
{
public:
enum {
WELS_LOG_QUIET = 0,
WELS_LOG_ERROR = 1 << 0,
WELS_LOG_WARNING = 1 << 1,
WELS_LOG_INFO = 1 << 2,
WELS_LOG_DEBUG = 1 << 3,
WELS_LOG_RESV = 1 << 4,
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG,
class IWelsTrace {
public:
enum {
WELS_LOG_QUIET = 0,
WELS_LOG_ERROR = 1 << 0,
WELS_LOG_WARNING = 1 << 1,
WELS_LOG_INFO = 1 << 2,
WELS_LOG_DEBUG = 1 << 3,
WELS_LOG_RESV = 1 << 4,
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG,
MAX_LOG_SIZE = 1024,
};
MAX_LOG_SIZE = 1024,
};
virtual ~IWelsTrace() {};
virtual ~IWelsTrace() {};
virtual int32_t SetTraceLevel(int32_t iLevel) = 0;
virtual int32_t Trace(const int32_t kLevel, const str_t * kpFormat, va_list pVl) = 0;
virtual int32_t SetTraceLevel (int32_t iLevel) = 0;
virtual int32_t Trace (const int32_t kLevel, const str_t* kpFormat, va_list pVl) = 0;
static void_t WelsTrace(void_t* pObject, const int32_t kLevel, const str_t * kpFormat, va_list pVl)
{
IWelsTrace * pThis = (IWelsTrace*)(pObject);
static void_t WelsTrace (void_t* pObject, const int32_t kLevel, const str_t* kpFormat, va_list pVl) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
if( pThis ){
pThis->Trace(kLevel, kpFormat, pVl);
}
}
if (pThis) {
pThis->Trace (kLevel, kpFormat, pVl);
}
}
static void_t WelsVTrace(void_t *pObject, const int32_t kLevel, const str_t *kpFormat, ...)
{
IWelsTrace * pThis = (IWelsTrace *)(pObject);
static void_t WelsVTrace (void_t* pObject, const int32_t kLevel, const str_t* kpFormat, ...) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
va_list argptr;
va_list argptr;
va_start(argptr, kpFormat);
va_start (argptr, kpFormat);
if( pThis ){
pThis->Trace(kLevel, kpFormat, argptr);
}
if (pThis) {
pThis->Trace (kLevel, kpFormat, argptr);
}
va_end(argptr);
}
va_end (argptr);
}
};
class CWelsTraceBase : public IWelsTrace
{
public:
virtual int32_t SetTraceLevel(int32_t iLevel);
virtual int32_t Trace(const int32_t kLevel, const str_t * kpFormat, va_list pVl);
class CWelsTraceBase : public IWelsTrace {
public:
virtual int32_t SetTraceLevel (int32_t iLevel);
virtual int32_t Trace (const int32_t kLevel, const str_t* kpFormat, va_list pVl);
virtual int32_t WriteString(int32_t iLevel, const str_t * pStr) = 0;
protected:
CWelsTraceBase()
{
m_iLevel = WELS_LOG_DEFAULT;
};
private:
int32_t m_iLevel;
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr) = 0;
protected:
CWelsTraceBase() {
m_iLevel = WELS_LOG_DEFAULT;
};
class CWelsTraceFile : public CWelsTraceBase
{
public:
CWelsTraceFile(const str_t * filename = (const str_t *)"wels_decoder_trace.txt");
virtual ~CWelsTraceFile();
private:
int32_t m_iLevel;
};
public:
virtual int32_t WriteString(int32_t iLevel, const str_t * pStr);
class CWelsTraceFile : public CWelsTraceBase {
public:
CWelsTraceFile (const str_t* filename = (const str_t*)"wels_decoder_trace.txt");
virtual ~CWelsTraceFile();
private:
WelsFileHandle* m_pTraceFile;
public:
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr);
private:
WelsFileHandle* m_pTraceFile;
};
#ifdef WIN32
class CWelsTraceWinDgb : public CWelsTraceBase
{
public:
CWelsTraceWinDgb() {};
virtual ~CWelsTraceWinDgb() {};
class CWelsTraceWinDgb : public CWelsTraceBase {
public:
CWelsTraceWinDgb() {};
virtual ~CWelsTraceWinDgb() {};
public:
virtual int32_t WriteString(int32_t iLevel, const str_t * pStr);
public:
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr);
};
#endif
class CWelsCodecTrace : public CWelsTraceBase
{
public:
CWelsCodecTrace() ;
virtual ~CWelsCodecTrace();
class CWelsCodecTrace : public CWelsTraceBase {
public:
CWelsCodecTrace() ;
virtual ~CWelsCodecTrace();
public:
virtual int32_t WriteString(int32_t iLevel, const str_t * pStr);
public:
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr);
protected:
int32_t LoadWelsTraceModule();
int32_t UnloadWelsTraceModule();
protected:
int32_t LoadWelsTraceModule();
int32_t UnloadWelsTraceModule();
private:
void_t * m_hTraceHandle;
private:
void_t* m_hTraceHandle;
CM_WELS_TRACE m_fpDebugTrace;
CM_WELS_TRACE m_fpInfoTrace;
CM_WELS_TRACE m_fpWarnTrace;
CM_WELS_TRACE m_fpErrorTrace;
CM_WELS_TRACE m_fpDebugTrace;
CM_WELS_TRACE m_fpInfoTrace;
CM_WELS_TRACE m_fpWarnTrace;
CM_WELS_TRACE m_fpErrorTrace;
};
IWelsTrace * CreateWelsTrace(EWelsTraceType eType, void_t * pParam = NULL);
IWelsTrace* CreateWelsTrace (EWelsTraceType eType, void_t* pParam = NULL);
} // namespace WelsDec

View File

@ -58,62 +58,61 @@ namespace WelsDec {
//#define OUTPUT_BIT_STREAM ////for test to output bitstream
class CWelsDecoder : public ISVCDecoder
{
public:
CWelsDecoder(void_t);
virtual ~CWelsDecoder();
class CWelsDecoder : public ISVCDecoder {
public:
CWelsDecoder (void_t);
virtual ~CWelsDecoder();
virtual long Initialize(void_t* pParam, const INIT_TYPE keInitType);
virtual long Uninitialize();
/***************************************************************************
* Description:
* Decompress one frame, and output RGB24 or YV12 decoded stream and its length.
* Input parameters:
* Parameter TYPE Description
* pSrc unsigned char* the h264 stream to decode
* srcLength int the length of h264 steam
* pDst unsigned char* buffer pointer of decoded data
* pDstInfo SBufferInfo& information provided to API including width, height, SW/HW option, etc
*
* return: if decode frame success return 0, otherwise corresponding error returned.
/***************************************************************************/
virtual DECODING_STATE DecodeFrame( const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight );
virtual long Initialize (void_t* pParam, const INIT_TYPE keInitType);
virtual long Uninitialize();
virtual DECODING_STATE DecodeFrame( const unsigned char* kpSrc,
const int kiSrcLen,
void_t ** ppDst,
SBufferInfo* pDstInfo);
virtual DECODING_STATE DecodeFrameEx( const unsigned char * kpSrc,
const int kiSrcLen,
unsigned char * pDst,
int iDstStride,
int & iDstLen,
int & iWidth,
int & iHeight,
int & color_format);
/***************************************************************************
* Description:
* Decompress one frame, and output RGB24 or YV12 decoded stream and its length.
* Input parameters:
* Parameter TYPE Description
* pSrc unsigned char* the h264 stream to decode
* srcLength int the length of h264 steam
* pDst unsigned char* buffer pointer of decoded data
* pDstInfo SBufferInfo& information provided to API including width, height, SW/HW option, etc
*
* return: if decode frame success return 0, otherwise corresponding error returned.
/***************************************************************************/
virtual DECODING_STATE DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight);
virtual long SetOption(DECODER_OPTION eOptID, void_t* pOption);
virtual long GetOption(DECODER_OPTION eOptID, void_t* pOption);
virtual DECODING_STATE DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
void_t** ppDst,
SBufferInfo* pDstInfo);
virtual DECODING_STATE DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& color_format);
virtual long SetOption (DECODER_OPTION eOptID, void_t* pOption);
virtual long GetOption (DECODER_OPTION eOptID, void_t* pOption);
private:
PWelsDecoderContext m_pDecContext;
IWelsTrace* m_pTrace;
void_t InitDecoder (void_t);
void_t UninitDecoder (void_t);
private:
PWelsDecoderContext m_pDecContext;
IWelsTrace *m_pTrace;
void_t InitDecoder( void_t );
void_t UninitDecoder( void_t );
#ifdef OUTPUT_BIT_STREAM
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
#endif//OUTPUT_BIT_STREAM
};
} // namespace WelsDec

View File

@ -4,7 +4,7 @@
//
// Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101

View File

@ -59,371 +59,339 @@
namespace WelsDec {
#ifdef MACOS
static CFBundleRef LoadLibrary(const char* lpszbundle)
{
// 1.get bundle path
char cBundlePath[PATH_MAX];
memset(cBundlePath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr((void_t*)&sDummy, &dlInfo);
strlcpy(cBundlePath, dlInfo.dli_fname, PATH_MAX);
char * pPath = NULL;
for(int i = 4; i > 0; i--)
{
pPath = strrchr(cBundlePath,'/');//confirmed_safe_unsafe_usage
if(pPath)
{
*pPath = 0;
}
else
{
break;
}
}
if(pPath)
{
strlcat(cBundlePath, "/", PATH_MAX);
}
else
{
return NULL;
}
strlcat(cBundlePath, lpszbundle, PATH_MAX);
FSRef bundlePath;
OSStatus iStatus = FSPathMakeRef((unsigned char*)cBundlePath, &bundlePath, NULL);
if(noErr != iStatus)
return NULL;
CFURLRef bundleURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &bundlePath);
if(NULL == bundleURL)
return NULL;
// 2.get bundle ref
CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
CFRelease(bundleURL);
static CFBundleRef LoadLibrary (const char* lpszbundle) {
// 1.get bundle path
char cBundlePath[PATH_MAX];
memset (cBundlePath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr ((void_t*)&sDummy, &dlInfo);
strlcpy (cBundlePath, dlInfo.dli_fname, PATH_MAX);
char* pPath = NULL;
for (int i = 4; i > 0; i--) {
pPath = strrchr (cBundlePath, '/'); //confirmed_safe_unsafe_usage
if (pPath) {
*pPath = 0;
} else {
break;
}
}
if (pPath) {
strlcat (cBundlePath, "/", PATH_MAX);
} else {
return NULL;
}
strlcat (cBundlePath, lpszbundle, PATH_MAX);
FSRef bundlePath;
OSStatus iStatus = FSPathMakeRef ((unsigned char*)cBundlePath, &bundlePath, NULL);
if (noErr != iStatus)
return NULL;
CFURLRef bundleURL = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &bundlePath);
if (NULL == bundleURL)
return NULL;
// 2.get bundle ref
CFBundleRef bundleRef = CFBundleCreate (kCFAllocatorSystemDefault, bundleURL);
CFRelease (bundleURL);
// Boolean bReturn = FALSE;
if(NULL != bundleRef)
{
// bReturn = CFBundleLoadExecutable(bundleRef);
}
return bundleRef;
if (NULL != bundleRef) {
// bReturn = CFBundleLoadExecutable(bundleRef);
}
return bundleRef;
}
static Boolean FreeLibrary(CFBundleRef bundle)
{
if(NULL != bundle)
{
// CFBundleUnloadExecutable(bundle);
CFRelease(bundle);
}
return TRUE;
static Boolean FreeLibrary (CFBundleRef bundle) {
if (NULL != bundle) {
// CFBundleUnloadExecutable(bundle);
CFRelease (bundle);
}
return TRUE;
}
static void_t* GetProcessAddress(CFBundleRef bundle, const char* lpszprocname)
{
if(NULL == bundle)
return NULL;
CFStringRef cfprocname = CFStringCreateWithCString(NULL,lpszprocname,CFStringGetSystemEncoding());
void_t *processAddress = CFBundleGetFunctionPointerForName(bundle,cfprocname);
CFRelease(cfprocname);
return processAddress;
static void_t* GetProcessAddress (CFBundleRef bundle, const char* lpszprocname) {
if (NULL == bundle)
return NULL;
CFStringRef cfprocname = CFStringCreateWithCString (NULL, lpszprocname, CFStringGetSystemEncoding());
void_t* processAddress = CFBundleGetFunctionPointerForName (bundle, cfprocname);
CFRelease (cfprocname);
return processAddress;
}
#endif
int32_t CWelsTraceBase::SetTraceLevel(int iLevel)
{
m_iLevel = iLevel;
int32_t CWelsTraceBase::SetTraceLevel (int iLevel) {
m_iLevel = iLevel;
return 0;
return 0;
}
int32_t CWelsTraceBase::Trace(const int kLevel, const str_t *kpFormat, va_list pVl)
{
if( kLevel & m_iLevel ){
str_t chWStrFormat[MAX_LOG_SIZE] = {0};
str_t chBuf[MAX_LOG_SIZE] = {0};
str_t chResult[MAX_LOG_SIZE] = {0};
const int32_t kLen = WelsStrnlen((const str_t *)"[DECODER]: ", MAX_LOG_SIZE);
int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) {
if (kLevel & m_iLevel) {
str_t chWStrFormat[MAX_LOG_SIZE] = {0};
str_t chBuf[MAX_LOG_SIZE] = {0};
str_t chResult[MAX_LOG_SIZE] = {0};
const int32_t kLen = WelsStrnlen ((const str_t*)"[DECODER]: ", MAX_LOG_SIZE);
WelsStrncpy(chWStrFormat, MAX_LOG_SIZE, (const str_t *)kpFormat, WelsStrnlen((const str_t *)kpFormat, MAX_LOG_SIZE));
WelsStrncpy (chWStrFormat, MAX_LOG_SIZE, (const str_t*)kpFormat, WelsStrnlen ((const str_t*)kpFormat, MAX_LOG_SIZE));
WelsStrncpy(chBuf, MAX_LOG_SIZE, (const str_t *)"[DECODER]: ", kLen);
WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ", kLen);
WelsVsprintf((chBuf + kLen), MAX_LOG_SIZE - kLen, (const str_t *)kpFormat, pVl);
WelsStrncpy(chResult, MAX_LOG_SIZE, (const str_t *)chBuf, WelsStrnlen((const str_t *)chBuf, MAX_LOG_SIZE));
WelsVsprintf ((chBuf + kLen), MAX_LOG_SIZE - kLen, (const str_t*)kpFormat, pVl);
WelsStrncpy (chResult, MAX_LOG_SIZE, (const str_t*)chBuf, WelsStrnlen ((const str_t*)chBuf, MAX_LOG_SIZE));
WriteString(kLevel, chResult);
}
WriteString (kLevel, chResult);
}
return 0;
return 0;
}
CWelsTraceFile::CWelsTraceFile(const str_t * pFileName)
{
m_pTraceFile = WelsFopen(pFileName, (const str_t *)"wt");
CWelsTraceFile::CWelsTraceFile (const str_t* pFileName) {
m_pTraceFile = WelsFopen (pFileName, (const str_t*)"wt");
}
CWelsTraceFile::~CWelsTraceFile()
{
if( m_pTraceFile ){
WelsFclose(m_pTraceFile);
m_pTraceFile = NULL;
}
CWelsTraceFile::~CWelsTraceFile() {
if (m_pTraceFile) {
WelsFclose (m_pTraceFile);
m_pTraceFile = NULL;
}
}
int32_t CWelsTraceFile::WriteString(int32_t iLevel, const str_t * pStr)
{
int iRC = 0;
const static str_t chEnter[16] = "\n";
if( m_pTraceFile ){
iRC += WelsFwrite(pStr, 1, WelsStrnlen(pStr, MAX_LOG_SIZE), m_pTraceFile);
iRC += WelsFwrite(chEnter, 1, WelsStrnlen(chEnter, 16), m_pTraceFile);
WelsFflush(m_pTraceFile);
}
return iRC;
int32_t CWelsTraceFile::WriteString (int32_t iLevel, const str_t* pStr) {
int iRC = 0;
const static str_t chEnter[16] = "\n";
if (m_pTraceFile) {
iRC += WelsFwrite (pStr, 1, WelsStrnlen (pStr, MAX_LOG_SIZE), m_pTraceFile);
iRC += WelsFwrite (chEnter, 1, WelsStrnlen (chEnter, 16), m_pTraceFile);
WelsFflush (m_pTraceFile);
}
return iRC;
}
#ifdef WIN32
int32_t CWelsTraceWinDgb::WriteString(int32_t iLevel, const str_t * pStr)
{
OutputDebugStringA(pStr);
int32_t CWelsTraceWinDgb::WriteString (int32_t iLevel, const str_t* pStr) {
OutputDebugStringA (pStr);
return WelsStrnlen(pStr, MAX_LOG_SIZE);//strnlen(pStr, MAX_LOG_SIZE);
return WelsStrnlen (pStr, MAX_LOG_SIZE); //strnlen(pStr, MAX_LOG_SIZE);
}
#endif
CWelsCodecTrace::CWelsCodecTrace()
{
m_hTraceHandle = NULL;
m_fpDebugTrace = NULL;
m_fpInfoTrace = NULL;
m_fpWarnTrace = NULL;
m_fpErrorTrace = NULL;
CWelsCodecTrace::CWelsCodecTrace() {
m_hTraceHandle = NULL;
m_fpDebugTrace = NULL;
m_fpInfoTrace = NULL;
m_fpWarnTrace = NULL;
m_fpErrorTrace = NULL;
LoadWelsTraceModule();
LoadWelsTraceModule();
}
CWelsCodecTrace::~CWelsCodecTrace()
{
UnloadWelsTraceModule();
CWelsCodecTrace::~CWelsCodecTrace() {
UnloadWelsTraceModule();
}
int32_t CWelsCodecTrace::LoadWelsTraceModule()
{
int32_t CWelsCodecTrace::LoadWelsTraceModule() {
#ifdef NO_DYNAMIC_VP
m_fpDebugTrace = welsStderrTrace<WELS_LOG_DEBUG>;
m_fpInfoTrace = welsStderrTrace<WELS_LOG_INFO>;
m_fpWarnTrace = welsStderrTrace<WELS_LOG_WARNING>;
m_fpErrorTrace = welsStderrTrace<WELS_LOG_ERROR>;
m_fpDebugTrace = welsStderrTrace<WELS_LOG_DEBUG>;
m_fpInfoTrace = welsStderrTrace<WELS_LOG_INFO>;
m_fpWarnTrace = welsStderrTrace<WELS_LOG_WARNING>;
m_fpErrorTrace = welsStderrTrace<WELS_LOG_ERROR>;
#else
#if defined WIN32
HMODULE hHandle = ::LoadLibrary("welstrace.dll");
#if defined WIN32
HMODULE hHandle = ::LoadLibrary ("welstrace.dll");
// HMODULE handle = ::LoadLibrary("contrace.dll"); // for c7 trace
if ( NULL == hHandle )
return -1;
if (NULL == hHandle)
return -1;
CHAR chPath[ _MAX_PATH]= {0};
GetModuleFileName( (HMODULE)hHandle, chPath, _MAX_PATH);
CHAR chPath[ _MAX_PATH] = {0};
GetModuleFileName ((HMODULE)hHandle, chPath, _MAX_PATH);
m_hTraceHandle = ::LoadLibrary(chPath);
OutputDebugStringA(chPath);
if( m_hTraceHandle) {
m_fpDebugTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSDEBUGA");
m_fpInfoTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSINFOA");
m_fpWarnTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSWARNA");
m_fpErrorTrace = ( CM_WELS_TRACE)::GetProcAddress( ( HMODULE)m_hTraceHandle, "WELSERRORA");
}
m_hTraceHandle = ::LoadLibrary (chPath);
// coverity scan uninitial
if (hHandle != NULL)
{
::FreeLibrary(hHandle);
hHandle = NULL;
}
OutputDebugStringA (chPath);
if (m_hTraceHandle) {
m_fpDebugTrace = (CM_WELS_TRACE)::GetProcAddress ((HMODULE)m_hTraceHandle, "WELSDEBUGA");
m_fpInfoTrace = (CM_WELS_TRACE)::GetProcAddress ((HMODULE)m_hTraceHandle, "WELSINFOA");
m_fpWarnTrace = (CM_WELS_TRACE)::GetProcAddress ((HMODULE)m_hTraceHandle, "WELSWARNA");
m_fpErrorTrace = (CM_WELS_TRACE)::GetProcAddress ((HMODULE)m_hTraceHandle, "WELSERRORA");
}
// coverity scan uninitial
if (hHandle != NULL) {
::FreeLibrary (hHandle);
hHandle = NULL;
}
#elif defined MACOS
m_hTraceHandle = LoadLibrary("welstrace.bundle");
if(m_hTraceHandle) {
m_fpDebugTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSDEBUG2");
m_fpInfoTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSINFO2");
m_fpWarnTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSWARN2");
m_fpErrorTrace = ( CM_WELS_TRACE)GetProcessAddress( (CFBundleRef)m_hTraceHandle, "WELSERROR2");
}
m_hTraceHandle = LoadLibrary ("welstrace.bundle");
if (m_hTraceHandle) {
m_fpDebugTrace = (CM_WELS_TRACE)GetProcessAddress ((CFBundleRef)m_hTraceHandle, "WELSDEBUG2");
m_fpInfoTrace = (CM_WELS_TRACE)GetProcessAddress ((CFBundleRef)m_hTraceHandle, "WELSINFO2");
m_fpWarnTrace = (CM_WELS_TRACE)GetProcessAddress ((CFBundleRef)m_hTraceHandle, "WELSWARN2");
m_fpErrorTrace = (CM_WELS_TRACE)GetProcessAddress ((CFBundleRef)m_hTraceHandle, "WELSERROR2");
}
#elif defined LINUX || defined SOLARIS || defined UNIX
//#else
// CCmString cmPath;
str_t chPath[255]= {0};
Dl_info sDlInfo;
static int iMmTPAddress;
dladdr( &iMmTPAddress, &sDlInfo);
str_t chPath[255] = {0};
Dl_info sDlInfo;
static int iMmTPAddress;
dladdr (&iMmTPAddress, &sDlInfo);
if (NULL == sDlInfo.dli_fname)
return -1;
WelsStrncpy(chPath, 255, (const str_t*)sDlInfo.dli_fname, WelsStrnlen((const str_t*)sDlInfo.dli_fname, 255));
str_t* p = strrchr(chPath, '/');//confirmed_safe_unsafe_usage
if ( NULL == p )
return -1;
const int iLenTraceName = WelsStrnlen((const str_t*)"/libwelstrace.so", 15);
const int iCurPos = p - chPath;
if ( iCurPos + iLenTraceName < 255 )
WelsStrncpy(p, 254-iCurPos, (const str_t*)"/libwelstrace.so", iLenTraceName );
else
return -1;
if (NULL == sDlInfo.dli_fname)
return -1;
WelsStrncpy (chPath, 255, (const str_t*)sDlInfo.dli_fname, WelsStrnlen ((const str_t*)sDlInfo.dli_fname, 255));
str_t* p = strrchr (chPath, '/'); //confirmed_safe_unsafe_usage
if (NULL == p)
return -1;
const int iLenTraceName = WelsStrnlen ((const str_t*)"/libwelstrace.so", 15);
const int iCurPos = p - chPath;
if (iCurPos + iLenTraceName < 255)
WelsStrncpy (p, 254 - iCurPos, (const str_t*)"/libwelstrace.so", iLenTraceName);
else
return -1;
m_hTraceHandle = dlopen( chPath, RTLD_LAZY);
if (m_hTraceHandle == NULL)
{
WelsFileHandle* fp = WelsFopen((const str_t*)"/tmp/trace.txt", (const str_t*)"a");
if(fp)
{
fprintf(fp, "welsCodecTrace::welsCodecTrace ===> dlopen %s fail, %s\n", chPath, dlerror());
WelsFclose(fp);
}
return -1;
}
if (m_hTraceHandle) {
m_fpDebugTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSDEBUG2");
m_fpInfoTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSINFO2");
m_fpWarnTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSWARN2");
m_fpErrorTrace = ( CM_WELS_TRACE)dlsym( m_hTraceHandle, "WELSERROR2");
if(m_fpDebugTrace == NULL)
{
WelsFileHandle* fp = WelsFopen((const str_t*)"/tmp/trace.txt", (const str_t*)"a");
if(fp)
{
printf("welsCodecTrace::welsCodecTrace ===> dlsym failed (WELSDEBUG2) , dlerror = %s\n", dlerror());
WelsFclose(fp);
}
return -1;
}
}
m_hTraceHandle = dlopen (chPath, RTLD_LAZY);
if (m_hTraceHandle == NULL) {
WelsFileHandle* fp = WelsFopen ((const str_t*)"/tmp/trace.txt", (const str_t*)"a");
if (fp) {
fprintf (fp, "welsCodecTrace::welsCodecTrace ===> dlopen %s fail, %s\n", chPath, dlerror());
WelsFclose (fp);
}
return -1;
}
if (m_hTraceHandle) {
m_fpDebugTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSDEBUG2");
m_fpInfoTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSINFO2");
m_fpWarnTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSWARN2");
m_fpErrorTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSERROR2");
if (m_fpDebugTrace == NULL) {
WelsFileHandle* fp = WelsFopen ((const str_t*)"/tmp/trace.txt", (const str_t*)"a");
if (fp) {
printf ("welsCodecTrace::welsCodecTrace ===> dlsym failed (WELSDEBUG2) , dlerror = %s\n", dlerror());
WelsFclose (fp);
}
return -1;
}
}
#endif
#endif // NO_DYNAMIC_VP
return 0;
return 0;
}
int32_t CWelsCodecTrace::UnloadWelsTraceModule()
{
int32_t CWelsCodecTrace::UnloadWelsTraceModule() {
#if defined WIN32
if( m_hTraceHandle) {
::FreeLibrary( ( HMODULE)m_hTraceHandle);
}
if (m_hTraceHandle) {
::FreeLibrary ((HMODULE)m_hTraceHandle);
}
#elif defined MACOS
if (m_hTraceHandle) {
FreeLibrary( (CFBundleRef)m_hTraceHandle);
}
if (m_hTraceHandle) {
FreeLibrary ((CFBundleRef)m_hTraceHandle);
}
#elif defined LINUX || defined SOLARIS || defined UNIX
if (m_hTraceHandle) {
::dlclose( m_hTraceHandle);
}
if (m_hTraceHandle) {
::dlclose (m_hTraceHandle);
}
#endif
m_hTraceHandle = NULL;
m_fpDebugTrace = NULL;
m_fpInfoTrace = NULL;
m_fpWarnTrace = NULL;
m_fpErrorTrace = NULL;
return 0;
m_hTraceHandle = NULL;
m_fpDebugTrace = NULL;
m_fpInfoTrace = NULL;
m_fpWarnTrace = NULL;
m_fpErrorTrace = NULL;
return 0;
}
int32_t CWelsCodecTrace::WriteString(int32_t iLevel, const str_t * pStr)
{
int32_t CWelsCodecTrace::WriteString (int32_t iLevel, const str_t* pStr) {
#ifndef NO_DYNAMIC_VP
if( m_hTraceHandle )
if (m_hTraceHandle)
#endif
{
{
#ifdef WIN32
switch(iLevel)
{
case WELS_LOG_ERROR:
if(m_fpErrorTrace)
m_fpErrorTrace("%s", pStr);
break;
case WELS_LOG_WARNING:
if(m_fpWarnTrace)
m_fpWarnTrace("%s", pStr);
break;
case WELS_LOG_INFO:
if(m_fpInfoTrace)
m_fpInfoTrace("%s", pStr);
break;
case WELS_LOG_DEBUG:
if(m_fpDebugTrace)
m_fpDebugTrace("%s", pStr);
break;
default:
if(m_fpDebugTrace)
m_fpInfoTrace("%s", pStr);
break;
}
switch (iLevel) {
case WELS_LOG_ERROR:
if (m_fpErrorTrace)
m_fpErrorTrace ("%s", pStr);
break;
case WELS_LOG_WARNING:
if (m_fpWarnTrace)
m_fpWarnTrace ("%s", pStr);
break;
case WELS_LOG_INFO:
if (m_fpInfoTrace)
m_fpInfoTrace ("%s", pStr);
break;
case WELS_LOG_DEBUG:
if (m_fpDebugTrace)
m_fpDebugTrace ("%s", pStr);
break;
default:
if (m_fpDebugTrace)
m_fpInfoTrace ("%s", pStr);
break;
}
#else
switch(iLevel)
{
case WELS_LOG_ERROR:
if(m_fpErrorTrace)
m_fpErrorTrace("CODEC", "%s", pStr);
break;
case WELS_LOG_WARNING:
if(m_fpWarnTrace)
m_fpWarnTrace("CODEC", "%s", pStr);
break;
case WELS_LOG_INFO:
if(m_fpInfoTrace)
m_fpInfoTrace("CODEC", "%s", pStr);
break;
case WELS_LOG_DEBUG:
if(m_fpInfoTrace)
m_fpInfoTrace("CODEC", "%s", pStr);
break;
default:
if(m_fpInfoTrace)
m_fpInfoTrace("CODEC", "%s", pStr);
break;
}
switch (iLevel) {
case WELS_LOG_ERROR:
if (m_fpErrorTrace)
m_fpErrorTrace ("CODEC", "%s", pStr);
break;
case WELS_LOG_WARNING:
if (m_fpWarnTrace)
m_fpWarnTrace ("CODEC", "%s", pStr);
break;
case WELS_LOG_INFO:
if (m_fpInfoTrace)
m_fpInfoTrace ("CODEC", "%s", pStr);
break;
case WELS_LOG_DEBUG:
if (m_fpInfoTrace)
m_fpInfoTrace ("CODEC", "%s", pStr);
break;
default:
if (m_fpInfoTrace)
m_fpInfoTrace ("CODEC", "%s", pStr);
break;
}
#endif
}
}
return 0;
return 0;
}
IWelsTrace * CreateWelsTrace(EWelsTraceType eType, void_t * pParam)
{
IWelsTrace * pTrace = NULL;
switch(eType)
{
case Wels_Trace_Type:
pTrace = new CWelsCodecTrace();
break;
case Wels_Trace_Type_File:
pTrace = new CWelsTraceFile();
break;
IWelsTrace* CreateWelsTrace (EWelsTraceType eType, void_t* pParam) {
IWelsTrace* pTrace = NULL;
switch (eType) {
case Wels_Trace_Type:
pTrace = new CWelsCodecTrace();
break;
case Wels_Trace_Type_File:
pTrace = new CWelsTraceFile();
break;
#ifdef WIN32
case Wels_Trace_Type_WinDgb:
pTrace = new CWelsTraceWinDgb();
break;
case Wels_Trace_Type_WinDgb:
pTrace = new CWelsTraceWinDgb();
break;
#endif
default:
break;
}
default:
break;
}
return pTrace;
return pTrace;
}
} // namespace WelsDec

View File

@ -76,420 +76,375 @@ namespace WelsDec {
/***************************************************************************
* Description:
* class CWelsDecoder constructor function, do initialization and
* class CWelsDecoder constructor function, do initialization and
* alloc memory required
*
* Input parameters: none
*
* return: none
/***************************************************************************/
CWelsDecoder::CWelsDecoder(void_t)
: m_pDecContext( NULL ),
m_pTrace( NULL )
{
CWelsDecoder::CWelsDecoder (void_t)
: m_pDecContext (NULL),
m_pTrace (NULL) {
#ifdef OUTPUT_BIT_STREAM
str_t chFileName[1024] = { 0 }; //for .264
int iBufUsed = 0;
int iBufLeft = 1023;
str_t chFileName[1024] = { 0 }; //for .264
int iBufUsed = 0;
int iBufLeft = 1023;
str_t chFileNameSize[1024] = { 0 }; //for .len
int iBufUsedSize = 0;
int iBufLeftSize = 1023;
str_t chFileNameSize[1024] = { 0 }; //for .len
int iBufUsedSize = 0;
int iBufLeftSize = 1023;
#endif//OUTPUT_BIT_STREAM
m_pTrace = CreateWelsTrace(Wels_Trace_Type);
m_pTrace = CreateWelsTrace (Wels_Trace_Type);
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO,"CWelsDecoder::CWelsDecoder() entry");
#ifdef OUTPUT_BIT_STREAM
SWelsTime sCurTime;
SWelsTime sCurTime;
WelsGetTimeOfDay(&sCurTime);
iBufUsed += WelsSnprintf(chFileName, iBufLeft, "bs_0x%p_", (void_t*)this);
iBufUsedSize += WelsSnprintf(chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
WelsGetTimeOfDay (&sCurTime);
iBufLeft -= iBufUsed;
if ( iBufLeft > iBufUsed )
{
iBufUsed += WelsStrftime(&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
iBufLeft -= iBufUsed;
}
iBufUsed += WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void_t*)this);
iBufUsedSize += WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
iBufLeftSize -= iBufUsedSize;
if ( iBufLeftSize> iBufUsedSize )
{
iBufUsedSize += WelsStrftime(&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
iBufLeftSize -= iBufUsedSize;
}
iBufLeft -= iBufUsed;
if (iBufLeft > iBufUsed) {
iBufUsed += WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
iBufLeft -= iBufUsed;
}
if ( iBufLeft > iBufUsed )
{
iBufUsed += WelsSnprintf(&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond(&sCurTime));
iBufLeft -= iBufUsed;
}
iBufLeftSize -= iBufUsedSize;
if (iBufLeftSize > iBufUsedSize) {
iBufUsedSize += WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
iBufLeftSize -= iBufUsedSize;
}
if ( iBufLeftSize > iBufUsedSize )
{
iBufUsedSize += WelsSnprintf(&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", WelsGetMillsecond(&sCurTime));
iBufLeftSize -= iBufUsedSize;
}
if (iBufLeft > iBufUsed) {
iBufUsed += WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime));
iBufLeft -= iBufUsed;
}
m_pFBS = WelsFopen(chFileName, "wb");
m_pFBSSize = WelsFopen(chFileNameSize, "wb");
if (iBufLeftSize > iBufUsedSize) {
iBufUsedSize += WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",
WelsGetMillsecond (&sCurTime));
iBufLeftSize -= iBufUsedSize;
}
m_pFBS = WelsFopen (chFileName, "wb");
m_pFBSSize = WelsFopen (chFileNameSize, "wb");
#endif//OUTPUT_BIT_STREAM
}
/***************************************************************************
* Description:
* class CWelsDecoder destructor function, destroy allocced memory
*
*
* Input parameters: none
*
* return: none
/***************************************************************************/
CWelsDecoder::~CWelsDecoder()
{
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
CWelsDecoder::~CWelsDecoder() {
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
UninitDecoder();
UninitDecoder();
#ifdef OUTPUT_BIT_STREAM
if ( m_pFBS )
{
WelsFclose( m_pFBS );
m_pFBS = NULL;
}
if ( m_pFBSSize )
{
WelsFclose( m_pFBSSize );
m_pFBSSize = NULL;
}
if (m_pFBS) {
WelsFclose (m_pFBS);
m_pFBS = NULL;
}
if (m_pFBSSize) {
WelsFclose (m_pFBSSize);
m_pFBSSize = NULL;
}
#endif//OUTPUT_BIT_STREAM
if( NULL != m_pTrace ){
delete m_pTrace;
m_pTrace = NULL;
}
if (NULL != m_pTrace) {
delete m_pTrace;
m_pTrace = NULL;
}
}
long CWelsDecoder::Initialize(void_t* pParam, const INIT_TYPE keInitType)
{
if ( pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED ){
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
return cmInitParaError;
}
long CWelsDecoder::Initialize (void_t* pParam, const INIT_TYPE keInitType) {
if (pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED) {
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
return cmInitParaError;
}
// H.264 decoder initialization,including memory allocation,then open it ready to decode
InitDecoder();
// H.264 decoder initialization,including memory allocation,then open it ready to decode
InitDecoder();
DecoderConfigParam( m_pDecContext, pParam );
return cmResultSuccess;
DecoderConfigParam (m_pDecContext, pParam);
return cmResultSuccess;
}
long CWelsDecoder::Uninitialize()
{
UninitDecoder();
return ERR_NONE;
long CWelsDecoder::Uninitialize() {
UninitDecoder();
return ERR_NONE;
}
void_t CWelsDecoder::UninitDecoder( void_t )
{
if ( NULL == m_pDecContext )
return;
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
void_t CWelsDecoder::UninitDecoder (void_t) {
if (NULL == m_pDecContext)
return;
WelsEndDecoder( m_pDecContext );
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
if ( NULL != m_pDecContext )
{
WelsFree( m_pDecContext, "m_pDecContext" );
WelsEndDecoder (m_pDecContext);
m_pDecContext = NULL;
}
if (NULL != m_pDecContext) {
WelsFree (m_pDecContext, "m_pDecContext");
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder()..");
m_pDecContext = NULL;
}
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder()..");
}
// the return value of this function is not suitable, it need report failure info to upper layer.
void_t CWelsDecoder::InitDecoder( void_t )
{
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder()..");
void_t CWelsDecoder::InitDecoder (void_t) {
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder()..");
m_pDecContext = (PWelsDecoderContext)WelsMalloc( sizeof(SWelsDecoderContext), "m_pDecContext" );
WelsInitDecoder( m_pDecContext, m_pTrace, IWelsTrace::WelsTrace );
m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left");
WelsInitDecoder (m_pDecContext, m_pTrace, IWelsTrace::WelsTrace);
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left");
}
/*
* Set Option
* Set Option
*/
long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)
{
int iVal = 0;
if ( m_pDecContext == NULL )
return dsInitialOptExpected;
if ( eOptID == DECODER_OPTION_DATAFORMAT ) // Set color space of decoding output frame
{
if ( pOption == NULL )
return cmInitParaError;
iVal = *((int*)pOption); // is_rgb
return DecoderSetCsp( m_pDecContext, iVal );
}
else if ( eOptID == DECODER_OPTION_END_OF_STREAM ) // Indicate bit-stream of the final frame to be decoded
{
if ( pOption == NULL )
return cmInitParaError;
iVal = *((int*)pOption); // boolean value for whether enabled End Of Stream flag
long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void_t* pOption) {
int iVal = 0;
m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
return cmResultSuccess;
}
else if ( eOptID == DECODER_OPTION_MODE)
{
if ( pOption == NULL )
return cmInitParaError;
if (m_pDecContext == NULL)
return dsInitialOptExpected;
iVal = *((int *)pOption);
if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame
if (pOption == NULL)
return cmInitParaError;
m_pDecContext->iSetMode = iVal;
if(iVal == SW_MODE)
{
m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
}
else
{
iVal = * ((int*)pOption); // is_rgb
return DecoderSetCsp (m_pDecContext, iVal);
} else if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded
if (pOption == NULL)
return cmInitParaError;
iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
return cmResultSuccess;
} else if (eOptID == DECODER_OPTION_MODE) {
if (pOption == NULL)
return cmInitParaError;
iVal = * ((int*)pOption);
m_pDecContext->iSetMode = iVal;
if (iVal == SW_MODE) {
m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
} else {
#if !defined(__APPLE__)
m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
#else
m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;
m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;
#endif
}
return cmResultSuccess;
}
else if ( eOptID == DECODER_OPTION_OUTPUT_PROPERTY)
{
if ( pOption == NULL)
return cmInitParaError;
iVal = *((int *)pOption);
if( m_pDecContext->iSetMode != SW_MODE)
m_pDecContext->iDecoderOutputProperty = iVal;
}
}
return cmResultSuccess;
} else if (eOptID == DECODER_OPTION_OUTPUT_PROPERTY) {
if (pOption == NULL)
return cmInitParaError;
iVal = * ((int*)pOption);
if (m_pDecContext->iSetMode != SW_MODE)
m_pDecContext->iDecoderOutputProperty = iVal;
}
return cmInitParaError;
return cmInitParaError;
}
/*
* Get Option
*/
long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
{
int iVal = 0;
if ( m_pDecContext == NULL )
return cmInitExpected;
if ( pOption == NULL )
return cmInitParaError;
if ( DECODER_OPTION_DATAFORMAT == eOptID ){
iVal = m_pDecContext->iOutputColorFormat;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_END_OF_STREAM == eOptID ){
iVal = m_pDecContext->bEndOfStreamFlag;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
#ifdef LONG_TERM_REF
else if ( DECODER_OPTION_IDR_PIC_ID == eOptID ){
iVal = m_pDecContext->uiCurIdrPicId;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_FRAME_NUM == eOptID)
{
iVal = m_pDecContext->iFrameNum;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_LTR_MARKING_FLAG == eOptID )
{
iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID )
{
iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
#endif
else if ( DECODER_OPTION_VCL_NAL == eOptID ) //feedback whether or not have VCL NAL in current AU
{
iVal = m_pDecContext->iFeedbackVclNalInAu;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_TEMPORAL_ID == eOptID ) //if have VCL NAL in current AU, then feedback the temporal ID
{
iVal = m_pDecContext->iFeedbackTidInAu;
*((int*)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_MODE == eOptID )
{
if ( pOption == NULL )
return cmInitParaError;
iVal = m_pDecContext->iSetMode;
*((int *)pOption) = iVal;
return cmResultSuccess;
}
else if ( DECODER_OPTION_DEVICE_INFO == eOptID )
{
if ( pOption == NULL )
return cmInitParaError;
long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void_t* pOption) {
int iVal = 0;
return cmResultSuccess;
}
return cmInitParaError;
if (m_pDecContext == NULL)
return cmInitExpected;
if (pOption == NULL)
return cmInitParaError;
if (DECODER_OPTION_DATAFORMAT == eOptID) {
iVal = m_pDecContext->iOutputColorFormat;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_END_OF_STREAM == eOptID) {
iVal = m_pDecContext->bEndOfStreamFlag;
* ((int*)pOption) = iVal;
return cmResultSuccess;
}
#ifdef LONG_TERM_REF
else if (DECODER_OPTION_IDR_PIC_ID == eOptID) {
iVal = m_pDecContext->uiCurIdrPicId;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_FRAME_NUM == eOptID) {
iVal = m_pDecContext->iFrameNum;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) {
iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) {
iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
* ((int*)pOption) = iVal;
return cmResultSuccess;
}
#endif
else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU
iVal = m_pDecContext->iFeedbackVclNalInAu;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID
iVal = m_pDecContext->iFeedbackTidInAu;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_MODE == eOptID) {
if (pOption == NULL)
return cmInitParaError;
iVal = m_pDecContext->iSetMode;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_DEVICE_INFO == eOptID) {
if (pOption == NULL)
return cmInitParaError;
return cmResultSuccess;
}
return cmInitParaError;
}
DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
const int kiSrcLen,
void_t ** ppDst,
SBufferInfo* pDstInfo)
{
if ( kiSrcLen > 0 && kpSrc != NULL )
{
DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
void_t** ppDst,
SBufferInfo* pDstInfo) {
if (kiSrcLen > 0 && kpSrc != NULL) {
#ifdef OUTPUT_BIT_STREAM
if ( m_pFBS )
{
WelsFwrite( kpSrc, sizeof(unsigned char), kiSrcLen, m_pFBS );
WelsFflush( m_pFBS );
}
if ( m_pFBSSize )
{
WelsFwrite( &kiSrcLen, sizeof(int), 1, m_pFBSSize );
WelsFflush( m_pFBSSize );
}
if (m_pFBS) {
WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);
WelsFflush (m_pFBS);
}
if (m_pFBSSize) {
WelsFwrite (&kiSrcLen, sizeof (int), 1, m_pFBSSize);
WelsFflush (m_pFBSSize);
}
#endif//OUTPUT_BIT_STREAM
m_pDecContext->bEndOfStreamFlag = false;
}
else
{ //For application MODE, the error detection should be added for safe.
//But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
m_pDecContext->bEndOfStreamFlag = true;
}
ppDst[0] = ppDst[1] = ppDst[2] = NULL;
m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
memset(pDstInfo,0,sizeof(SBufferInfo));
pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
m_pDecContext->bEndOfStreamFlag = false;
} else {
//For application MODE, the error detection should be added for safe.
//But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
m_pDecContext->bEndOfStreamFlag = true;
}
ppDst[0] = ppDst[1] = ppDst[2] = NULL;
m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
memset (pDstInfo, 0, sizeof (SBufferInfo));
pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
#ifdef LONG_TERM_REF
m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
m_pDecContext->bCurAuContainLtrMarkSeFlag = false;
m_pDecContext->iFrameNumOfAuMarkedLtr = 0;
m_pDecContext->iFrameNum = -1; //initialize
m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
m_pDecContext->bCurAuContainLtrMarkSeFlag = false;
m_pDecContext->iFrameNumOfAuMarkedLtr = 0;
m_pDecContext->iFrameNum = -1; //initialize
#endif
m_pDecContext->iFeedbackTidInAu = -1; //initialize
WelsDecodeBs( m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst, pDstInfo); //iErrorCode has been modified in this function
pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
m_pDecContext->iFeedbackTidInAu = -1; //initialize
if ( m_pDecContext->iErrorCode )
{
ENalUnitType eNalType = NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst,
pDstInfo); //iErrorCode has been modified in this function
eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
//for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
if ( (IS_PARAM_SETS_NALS(eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
(VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType) )
{
pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
if (m_pDecContext->iErrorCode) {
ENalUnitType eNalType =
NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
//for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
(VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) {
#ifdef LONG_TERM_REF
m_pDecContext->bParamSetsLostFlag = true;
m_pDecContext->bParamSetsLostFlag = true;
#else
m_pDecContext->bReferenceLostAtT0Flag = true;
m_pDecContext->bReferenceLostAtT0Flag = true;
#endif
ResetParameterSetsState( m_pDecContext ); //initial SPS&PPS ready flag
}
ResetParameterSetsState (m_pDecContext); //initial SPS&PPS ready flag
}
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode);
return (DECODING_STATE)m_pDecContext->iErrorCode;
}
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n",
m_pDecContext->iErrorCode);
return (DECODING_STATE)m_pDecContext->iErrorCode;
}
return dsErrorFree;
return dsErrorFree;
}
DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight )
{
DECODING_STATE eDecState = dsErrorFree;
SBufferInfo DstInfo;
DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight) {
DECODING_STATE eDecState = dsErrorFree;
SBufferInfo DstInfo;
memset(&DstInfo, 0, sizeof(SBufferInfo));
DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];
DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
DstInfo.eBufferProperty = BUFFER_HOST;
memset (&DstInfo, 0, sizeof (SBufferInfo));
DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];
DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
DstInfo.eBufferProperty = BUFFER_HOST;
eDecState = DecodeFrame(kpSrc, kiSrcLen, (void_t **)ppDst, &DstInfo);
if (eDecState == dsErrorFree)
{
pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;
}
eDecState = DecodeFrame (kpSrc, kiSrcLen, (void_t**)ppDst, &DstInfo);
if (eDecState == dsErrorFree) {
pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;
}
return eDecState;
return eDecState;
}
DECODING_STATE CWelsDecoder::DecodeFrameEx(const unsigned char * kpSrc,
const int kiSrcLen,
unsigned char * pDst,
int iDstStride,
int & iDstLen,
int & iWidth,
int & iHeight,
int & iColorFormat )
{
DECODING_STATE state = dsErrorFree;
DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& iColorFormat) {
DECODING_STATE state = dsErrorFree;
return state;
return state;
}
@ -504,29 +459,27 @@ using namespace WelsDec;
* CreateDecoder
* @return: success in return 0, otherwise failed.
*/
long CreateDecoder( ISVCDecoder** ppDecoder )
{
long CreateDecoder (ISVCDecoder** ppDecoder) {
if ( NULL == ppDecoder ){
return ERR_INVALID_PARAMETERS;
}
if (NULL == ppDecoder) {
return ERR_INVALID_PARAMETERS;
}
*ppDecoder = new CWelsDecoder();
*ppDecoder = new CWelsDecoder();
if ( NULL == *ppDecoder ){
return ERR_MALLOC_FAILED;
}
if (NULL == *ppDecoder) {
return ERR_MALLOC_FAILED;
}
return ERR_NONE;
return ERR_NONE;
}
/*
* DestroyDecoder
*/
void_t DestroyDecoder( ISVCDecoder* pDecoder )
{
if ( NULL != pDecoder ){
delete (CWelsDecoder *)pDecoder;
pDecoder = NULL;
}
void_t DestroyDecoder (ISVCDecoder* pDecoder) {
if (NULL != pDecoder) {
delete (CWelsDecoder*)pDecoder;
pDecoder = NULL;
}
}

View File

@ -1,306 +1,288 @@
/*!
* \copy
* Copyright (c) 2004-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* \file : IWelsVP.h
*
* \brief : Interface of wels video processor class
*
* \date : 2011/01/04
*
* \description : 1. should support both C/C++ style interface
* 2. should concern with the feature extension requirement
* 3. should care the usage of "char"==>
* 1) value char : signed char/unsigned char
* 2) string char : char
*
*************************************************************************************
*/
#ifndef _IWELSVP_H_
#define _IWELSVP_H_
#ifdef _WIN32
#define WELSAPI __stdcall
#else
#define WELSAPI
#endif
#define WELSVP_MAJOR_VERSION 1
#define WELSVP_MINOR_VERSION 1
#define WELSVP_VERSION ((WELSVP_MAJOR_VERSION << 8) + WELSVP_MINOR_VERSION)
typedef enum
{
RET_SUCCESS = 0,
RET_FAILED = -1,
RET_INVALIDPARAM = -2,
RET_OUTOFMEMORY = -3,
RET_NOTSUPPORTED = -4,
RET_UNEXPECTED = -5,
RET_NEEDREINIT = -6
} EResult;
typedef enum
{
VIDEO_FORMAT_NULL = 0, /* invalid format */
/*rgb color formats*/
VIDEO_FORMAT_RGB = 1, /* rgb 24bits */
VIDEO_FORMAT_RGBA = 2, /* rgba */
VIDEO_FORMAT_RGB555 = 3, /* rgb555 */
VIDEO_FORMAT_RGB565 = 4, /* rgb565 */
VIDEO_FORMAT_BGR = 5, /* bgr 24bits */
VIDEO_FORMAT_BGRA = 6, /* bgr 32bits */
VIDEO_FORMAT_ABGR = 7, /* abgr */
VIDEO_FORMAT_ARGB = 8, /* argb */
/*yuv color formats*/
VIDEO_FORMAT_YUY2 = 20, /* yuy2 */
VIDEO_FORMAT_YVYU = 21, /* yvyu */
VIDEO_FORMAT_UYVY = 22, /* uyvy */
VIDEO_FORMAT_I420 = 23, /* yuv 4:2:0 planar */
VIDEO_FORMAT_YV12 = 24, /* yuv 4:2:0 planar */
VIDEO_FORMAT_INTERNAL = 25, /* Only Used for SVC decoder testbed */
VIDEO_FORMAT_NV12 = 26, /* y planar + uv packed */
VIDEO_FORMAT_I422 = 27, /* yuv 4:2:2 planar */
VIDEO_FORMAT_I444 = 28, /* yuv 4:4:4 planar */
VIDEO_FORMAT_YUYV = 20, /* yuv 4:2:2 packed */
VIDEO_FORMAT_RGB24 = 1,
VIDEO_FORMAT_RGB32 = 2,
VIDEO_FORMAT_RGB24_INV = 5,
VIDEO_FORMAT_RGB32_INV = 6,
VIDEO_FORMAT_RGB555_INV = 7,
VIDEO_FORMAT_RGB565_INV = 8,
VIDEO_FORMAT_YUV2 = 21,
VIDEO_FORMAT_420 = 23,
VIDEO_FORMAT_VFlip = 0x80000000
} EVideoFormat;
typedef enum
{
BUFFER_HOSTMEM = 0,
BUFFER_SURFACE
} EPixMapBufferProperty;
typedef struct
{
int iRectTop;
int iRectLeft;
int iRectWidth;
int iRectHeight;
} SRect;
typedef struct
{
void *pPixel[3];
int iSizeInBits;
int iStride[3];
SRect sRect;
EVideoFormat eFormat;
EPixMapBufferProperty eProperty;//not use? to remove? but how about the size of SPixMap?
} SPixMap;
typedef enum
{
METHOD_NULL = 0,
METHOD_COLORSPACE_CONVERT ,//not support yet
METHOD_DENOISE ,
METHOD_SCENE_CHANGE_DETECTION ,
METHOD_DOWNSAMPLE ,
METHOD_VAA_STATISTICS ,
METHOD_BACKGROUND_DETECTION ,
METHOD_ADAPTIVE_QUANT ,
METHOD_COMPLEXITY_ANALYSIS ,
METHOD_IMAGE_ROTATE ,
METHOD_MASK
} EMethods;
//-----------------------------------------------------------------//
// Algorithm parameters define
//-----------------------------------------------------------------//
typedef struct
{
int bSceneChangeFlag; // 0:false ; 1:true
} SSceneChangeResult;
typedef enum
{
SIMILAR_SCENE, //similar scene
MEDIUM_CHANGED_SCENE, //medium changed scene
LARGE_CHANGED_SCENE, //large changed scene
} ESceneChangeIdc;
typedef struct
{
unsigned char *pCurY; // Y data of current frame
unsigned char *pRefY; // Y data of pRef frame for diff calc
int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together
int *pSsd16x16; // sum of square difference of 16x16
int *pSum16x16; // sum of 16x16
int *pSumOfSquare16x16; // sum of square of 16x16
int (*pSumOfDiff8x8)[4];
unsigned char (*pMad8x8)[4];
int iFrameSad; // sad of frame
} SVAACalcResult;
typedef struct
{
int iCalcVar;
int iCalcBgd;
int iCalcSsd;
int iReserved;
SVAACalcResult *pCalcResult;
} SVAACalcParam;
typedef struct
{
signed char *pBackgroundMbFlag;
SVAACalcResult *pCalcRes;
} SBGDInterface;
typedef enum
{
AQ_QUALITY_MODE, //Quality mode
AQ_BITRATE_MODE, //Bitrate mode
}EAQModes;
typedef struct
{
unsigned short uiMotionIndex;
unsigned short uiTextureIndex;
} SMotionTextureUnit;
typedef struct
{
int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode
SVAACalcResult *pCalcResult;
SMotionTextureUnit *pMotionTextureUnit;
signed char *pMotionTextureIndexToDeltaQp;
double dAverMotionTextureIndexToDeltaQp;
} SAdaptiveQuantizationParam;
typedef enum
{
FRAME_SAD = 0,
GOM_SAD = -1,
GOM_VAR = -2
} EComplexityAnalysisMode;
typedef struct
{
int iComplexityAnalysisMode;
int iCalcBgd;
int iMbNumInGom;
int iFrameComplexity;
int *pGomComplexity;
int *pGomForegroundBlockNum;
signed char *pBackgroundMbFlag;
unsigned int *uiRefMbType;
SVAACalcResult *pCalcResult;
} SComplexityAnalysisParam;
/////////////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
void *pCtx;
EResult (*Init) (void *pCtx, int iType, void *pCfg);
EResult (*Uninit) (void *pCtx, int iType);
EResult (*Flush) (void *pCtx, int iType);
EResult (*Process) (void *pCtx, int iType, SPixMap *pSrc, SPixMap *dst);
EResult (*Get) (void *pCtx, int iType, void *pParam);
EResult (*Set) (void *pCtx, int iType, void *pParam);
EResult (*SpecialFeature) (void *pCtx, int iType, void *pIn, void *pOut);
} IWelsVPc;
#if defined(__cplusplus) && !defined(CINTERFACE) /* C++ style interface */
class IWelsVP
{
public:
virtual ~IWelsVP() {}
public:
virtual EResult Init (int iType, void *pCfg) = 0;
virtual EResult Uninit (int iType) = 0;
virtual EResult Flush (int iType) = 0;
virtual EResult Process (int iType, SPixMap *pSrc, SPixMap *dst) = 0;
virtual EResult Get (int iType, void *pParam) = 0;
virtual EResult Set (int iType, void *pParam) = 0;
virtual EResult SpecialFeature (int iType, void *pIn, void *pOut) = 0;
};
/* Recommend to invoke the interface via the micro for convenient */
#define IWelsVPFunc_Init(p, a, b) (p)->Init(a, b)
#define IWelsVPFunc_Uninit(p, a) (p)->Uninit(a)
#define IWelsVPFunc_Flush(p, a) (p)->Flush(a)
#define IWelsVPFunc_Process(p, a, b, c) (p)->Process(a, b, c)
#define IWelsVPFunc_Get(p, a, b) (p)->Get(a, b)
#define IWelsVPFunc_Set(p, a, b) (p)->Set(a, b)
#define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(a, b, c)
/* C++ interface version */
#define WELSVP_INTERFACE_VERION (0x8000 + (WELSVP_VERSION & 0x7fff))
#define WELSVP_EXTERNC_BEGIN extern "C" {
#define WELSVP_EXTERNC_END }
#else /* C style interface */
/* Recommend to invoke the interface via the micro for convenient */
#define IWelsVPFunc_Init(p, a, b) (p)->Init(p->h, a, b)
#define IWelsVPFunc_Uninit(p, a) (p)->Uninit(p->h, a)
#define IWelsVPFunc_Flush(p, a) (p)->Flush(p->h, a)
#define IWelsVPFunc_Process(p, a, b, c) (p)->Process(p->h, a, b, c)
#define IWelsVPFunc_Get(p, a, b) (p)->Get(p->h, a, b)
#define IWelsVPFunc_Set(p, a, b) (p)->Set(p->h, a, b)
#define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(p->h, a, b, c)
/* C interface version */
#define WELSVP_INTERFACE_VERION (0x0001 + (WELSVP_VERSION & 0x7fff))
#define WELSVP_EXTERNC_BEGIN
#define WELSVP_EXTERNC_END
#endif
WELSVP_EXTERNC_BEGIN
EResult WELSAPI CreateVpInterface (void **ppCtx, int iVersion /*= WELSVP_INTERFACE_VERION*/);
EResult WELSAPI DestroyVpInterface (void *pCtx , int iVersion /*= WELSVP_INTERFACE_VERION*/);
WELSVP_EXTERNC_END
//////////////////////////////////////////////////////////////////////////////////////////////
#endif // _IWELSVP_H_
/*!
* \copy
* Copyright (c) 2004-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* \file : IWelsVP.h
*
* \brief : Interface of wels video processor class
*
* \date : 2011/01/04
*
* \description : 1. should support both C/C++ style interface
* 2. should concern with the feature extension requirement
* 3. should care the usage of "char"==>
* 1) value char : signed char/unsigned char
* 2) string char : char
*
*************************************************************************************
*/
#ifndef _IWELSVP_H_
#define _IWELSVP_H_
#ifdef _WIN32
#define WELSAPI __stdcall
#else
#define WELSAPI
#endif
#define WELSVP_MAJOR_VERSION 1
#define WELSVP_MINOR_VERSION 1
#define WELSVP_VERSION ((WELSVP_MAJOR_VERSION << 8) + WELSVP_MINOR_VERSION)
typedef enum {
RET_SUCCESS = 0,
RET_FAILED = -1,
RET_INVALIDPARAM = -2,
RET_OUTOFMEMORY = -3,
RET_NOTSUPPORTED = -4,
RET_UNEXPECTED = -5,
RET_NEEDREINIT = -6
} EResult;
typedef enum {
VIDEO_FORMAT_NULL = 0, /* invalid format */
/*rgb color formats*/
VIDEO_FORMAT_RGB = 1, /* rgb 24bits */
VIDEO_FORMAT_RGBA = 2, /* rgba */
VIDEO_FORMAT_RGB555 = 3, /* rgb555 */
VIDEO_FORMAT_RGB565 = 4, /* rgb565 */
VIDEO_FORMAT_BGR = 5, /* bgr 24bits */
VIDEO_FORMAT_BGRA = 6, /* bgr 32bits */
VIDEO_FORMAT_ABGR = 7, /* abgr */
VIDEO_FORMAT_ARGB = 8, /* argb */
/*yuv color formats*/
VIDEO_FORMAT_YUY2 = 20, /* yuy2 */
VIDEO_FORMAT_YVYU = 21, /* yvyu */
VIDEO_FORMAT_UYVY = 22, /* uyvy */
VIDEO_FORMAT_I420 = 23, /* yuv 4:2:0 planar */
VIDEO_FORMAT_YV12 = 24, /* yuv 4:2:0 planar */
VIDEO_FORMAT_INTERNAL = 25, /* Only Used for SVC decoder testbed */
VIDEO_FORMAT_NV12 = 26, /* y planar + uv packed */
VIDEO_FORMAT_I422 = 27, /* yuv 4:2:2 planar */
VIDEO_FORMAT_I444 = 28, /* yuv 4:4:4 planar */
VIDEO_FORMAT_YUYV = 20, /* yuv 4:2:2 packed */
VIDEO_FORMAT_RGB24 = 1,
VIDEO_FORMAT_RGB32 = 2,
VIDEO_FORMAT_RGB24_INV = 5,
VIDEO_FORMAT_RGB32_INV = 6,
VIDEO_FORMAT_RGB555_INV = 7,
VIDEO_FORMAT_RGB565_INV = 8,
VIDEO_FORMAT_YUV2 = 21,
VIDEO_FORMAT_420 = 23,
VIDEO_FORMAT_VFlip = 0x80000000
} EVideoFormat;
typedef enum {
BUFFER_HOSTMEM = 0,
BUFFER_SURFACE
} EPixMapBufferProperty;
typedef struct {
int iRectTop;
int iRectLeft;
int iRectWidth;
int iRectHeight;
} SRect;
typedef struct {
void* pPixel[3];
int iSizeInBits;
int iStride[3];
SRect sRect;
EVideoFormat eFormat;
EPixMapBufferProperty eProperty;//not use? to remove? but how about the size of SPixMap?
} SPixMap;
typedef enum {
METHOD_NULL = 0,
METHOD_COLORSPACE_CONVERT ,//not support yet
METHOD_DENOISE ,
METHOD_SCENE_CHANGE_DETECTION ,
METHOD_DOWNSAMPLE ,
METHOD_VAA_STATISTICS ,
METHOD_BACKGROUND_DETECTION ,
METHOD_ADAPTIVE_QUANT ,
METHOD_COMPLEXITY_ANALYSIS ,
METHOD_IMAGE_ROTATE ,
METHOD_MASK
} EMethods;
//-----------------------------------------------------------------//
// Algorithm parameters define
//-----------------------------------------------------------------//
typedef struct {
int bSceneChangeFlag; // 0:false ; 1:true
} SSceneChangeResult;
typedef enum {
SIMILAR_SCENE, //similar scene
MEDIUM_CHANGED_SCENE, //medium changed scene
LARGE_CHANGED_SCENE, //large changed scene
} ESceneChangeIdc;
typedef struct {
unsigned char* pCurY; // Y data of current frame
unsigned char* pRefY; // Y data of pRef frame for diff calc
int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together
int* pSsd16x16; // sum of square difference of 16x16
int* pSum16x16; // sum of 16x16
int* pSumOfSquare16x16; // sum of square of 16x16
int (*pSumOfDiff8x8)[4];
unsigned char (*pMad8x8)[4];
int iFrameSad; // sad of frame
} SVAACalcResult;
typedef struct {
int iCalcVar;
int iCalcBgd;
int iCalcSsd;
int iReserved;
SVAACalcResult* pCalcResult;
} SVAACalcParam;
typedef struct {
signed char* pBackgroundMbFlag;
SVAACalcResult* pCalcRes;
} SBGDInterface;
typedef enum {
AQ_QUALITY_MODE, //Quality mode
AQ_BITRATE_MODE, //Bitrate mode
} EAQModes;
typedef struct {
unsigned short uiMotionIndex;
unsigned short uiTextureIndex;
} SMotionTextureUnit;
typedef struct {
int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode
SVAACalcResult* pCalcResult;
SMotionTextureUnit* pMotionTextureUnit;
signed char* pMotionTextureIndexToDeltaQp;
double dAverMotionTextureIndexToDeltaQp;
} SAdaptiveQuantizationParam;
typedef enum {
FRAME_SAD = 0,
GOM_SAD = -1,
GOM_VAR = -2
} EComplexityAnalysisMode;
typedef struct {
int iComplexityAnalysisMode;
int iCalcBgd;
int iMbNumInGom;
int iFrameComplexity;
int* pGomComplexity;
int* pGomForegroundBlockNum;
signed char* pBackgroundMbFlag;
unsigned int* uiRefMbType;
SVAACalcResult* pCalcResult;
} SComplexityAnalysisParam;
/////////////////////////////////////////////////////////////////////////////////////////////
typedef struct {
void* pCtx;
EResult (*Init) (void* pCtx, int iType, void* pCfg);
EResult (*Uninit) (void* pCtx, int iType);
EResult (*Flush) (void* pCtx, int iType);
EResult (*Process) (void* pCtx, int iType, SPixMap* pSrc, SPixMap* dst);
EResult (*Get) (void* pCtx, int iType, void* pParam);
EResult (*Set) (void* pCtx, int iType, void* pParam);
EResult (*SpecialFeature) (void* pCtx, int iType, void* pIn, void* pOut);
} IWelsVPc;
#if defined(__cplusplus) && !defined(CINTERFACE) /* C++ style interface */
class IWelsVP {
public:
virtual ~IWelsVP() {}
public:
virtual EResult Init (int iType, void* pCfg) = 0;
virtual EResult Uninit (int iType) = 0;
virtual EResult Flush (int iType) = 0;
virtual EResult Process (int iType, SPixMap* pSrc, SPixMap* dst) = 0;
virtual EResult Get (int iType, void* pParam) = 0;
virtual EResult Set (int iType, void* pParam) = 0;
virtual EResult SpecialFeature (int iType, void* pIn, void* pOut) = 0;
};
/* Recommend to invoke the interface via the micro for convenient */
#define IWelsVPFunc_Init(p, a, b) (p)->Init(a, b)
#define IWelsVPFunc_Uninit(p, a) (p)->Uninit(a)
#define IWelsVPFunc_Flush(p, a) (p)->Flush(a)
#define IWelsVPFunc_Process(p, a, b, c) (p)->Process(a, b, c)
#define IWelsVPFunc_Get(p, a, b) (p)->Get(a, b)
#define IWelsVPFunc_Set(p, a, b) (p)->Set(a, b)
#define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(a, b, c)
/* C++ interface version */
#define WELSVP_INTERFACE_VERION (0x8000 + (WELSVP_VERSION & 0x7fff))
#define WELSVP_EXTERNC_BEGIN extern "C" {
#define WELSVP_EXTERNC_END }
#else /* C style interface */
/* Recommend to invoke the interface via the micro for convenient */
#define IWelsVPFunc_Init(p, a, b) (p)->Init(p->h, a, b)
#define IWelsVPFunc_Uninit(p, a) (p)->Uninit(p->h, a)
#define IWelsVPFunc_Flush(p, a) (p)->Flush(p->h, a)
#define IWelsVPFunc_Process(p, a, b, c) (p)->Process(p->h, a, b, c)
#define IWelsVPFunc_Get(p, a, b) (p)->Get(p->h, a, b)
#define IWelsVPFunc_Set(p, a, b) (p)->Set(p->h, a, b)
#define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(p->h, a, b, c)
/* C interface version */
#define WELSVP_INTERFACE_VERION (0x0001 + (WELSVP_VERSION & 0x7fff))
#define WELSVP_EXTERNC_BEGIN
#define WELSVP_EXTERNC_END
#endif
WELSVP_EXTERNC_BEGIN
EResult WELSAPI CreateVpInterface (void** ppCtx, int iVersion /*= WELSVP_INTERFACE_VERION*/);
EResult WELSAPI DestroyVpInterface (void* pCtx , int iVersion /*= WELSVP_INTERFACE_VERION*/);
WELSVP_EXTERNC_END
//////////////////////////////////////////////////////////////////////////////////////////////
#endif // _IWELSVP_H_

View File

@ -1,121 +1,121 @@
/*!
* \copy
* Copyright (c) 2011-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* \file array_stack_align.h
*
* \brief promised alignment of array pData declaration on stack
* multidimensional array can be extended if applicable need
*
* \date 8/8/2011 Created
* 8/12/2011 functionality implementation for multidimensional array
* 8/26/2011 better solution with reducing extra memory used,
* stack size is adaptively reduced by _tp & _al
*
*************************************************************************************
*/
#ifndef ARRAY_STACK_ALIGN_H__
#define ARRAY_STACK_ALIGN_H__
#include <assert.h>
#include "typedefs.h"
/*
* ENFORCE_STACK_ALIGN_1D: force 1 dimension local pData aligned in stack
* _tp: type
* _nm: var name
* _sz: size
* _al: align bytes
* auxiliary var: _nm ## _tEmP
* NOTE: _al should be power-of-2 and >= sizeof(_tp), before considering to use such macro
*/
//#define ENFORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
//_tp _nm ## _tEmP[(_sz)+(_al)-1]; \
//_tp *_nm = _nm ## _tEmP + ((_al)-1); \
//_nm -= (((int32_t)_nm & ((_al)-1))/sizeof(_tp));
/* Another better solution with reducing extra memory used */
#define ENFORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_sz)+(_al)/sizeof(_tp)-1]; \
_tp *_nm = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm -= (((int32_t)_nm & ((_al)-1))/sizeof(_tp));
/*
* ENFORCE_STACK_ALIGN_2D: force 2 dimension local pData aligned in stack
* _tp: type
* _nm: var name
* _cx, _cy: size in x, y dimension
* _al: align bytes
* auxiliary var: _nm ## _tEmP, _nm ## _tEmP_al
* NOTE: _al should be power-of-2 and >= sizeof(_tp), before considering to use such macro
*/
//#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
//_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)-1]; \
//_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)-1); \
//_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
//_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
/* Another better solution with reducing extra memory used */
#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
/*
* ENFORCE_STACK_ALIGN_3D: force 3 dimension local pData aligned in stack
* _tp: type
* _nm: var name
* _cx, _cy, _cz: size in x, y, z dimension
* _al: align bytes
* auxiliary var: _nm ## _tEmP, _nm ## _tEmP_al
* NOTE: _al should be power-of-2 and >= sizeof(_tp), before considering to use such macro
*/
//#define ENFORCE_STACK_ALIGN_3D(_tp, _nm, _cx, _cy, _cz, _al) \
//_tp _nm ## _tEmP[(_cx)*(_cy)*(_cz)+(_al)-1]; \
//_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)-1); \
//_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
//_tp (*_nm)[(_cy)][(_cz)] = (_tp (*)[(_cy)][(_cz)])_nm ## _tEmP_al;
/* Another better solution with reducing extra memory used */
#define ENFORCE_STACK_ALIGN_3D(_tp, _nm, _cx, _cy, _cz, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_cx)*(_cy)*(_cz)+(_al)/sizeof(_tp)-1]; \
_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
_tp (*_nm)[(_cy)][(_cz)] = (_tp (*)[(_cy)][(_cz)])_nm ## _tEmP_al;
#endif//ARRAY_STACK_ALIGN_H__
/*!
* \copy
* Copyright (c) 2011-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* \file array_stack_align.h
*
* \brief promised alignment of array pData declaration on stack
* multidimensional array can be extended if applicable need
*
* \date 8/8/2011 Created
* 8/12/2011 functionality implementation for multidimensional array
* 8/26/2011 better solution with reducing extra memory used,
* stack size is adaptively reduced by _tp & _al
*
*************************************************************************************
*/
#ifndef ARRAY_STACK_ALIGN_H__
#define ARRAY_STACK_ALIGN_H__
#include <assert.h>
#include "typedefs.h"
/*
* ENFORCE_STACK_ALIGN_1D: force 1 dimension local pData aligned in stack
* _tp: type
* _nm: var name
* _sz: size
* _al: align bytes
* auxiliary var: _nm ## _tEmP
* NOTE: _al should be power-of-2 and >= sizeof(_tp), before considering to use such macro
*/
//#define ENFORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
//_tp _nm ## _tEmP[(_sz)+(_al)-1]; \
//_tp *_nm = _nm ## _tEmP + ((_al)-1); \
//_nm -= (((int32_t)_nm & ((_al)-1))/sizeof(_tp));
/* Another better solution with reducing extra memory used */
#define ENFORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_sz)+(_al)/sizeof(_tp)-1]; \
_tp *_nm = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm -= (((int32_t)_nm & ((_al)-1))/sizeof(_tp));
/*
* ENFORCE_STACK_ALIGN_2D: force 2 dimension local pData aligned in stack
* _tp: type
* _nm: var name
* _cx, _cy: size in x, y dimension
* _al: align bytes
* auxiliary var: _nm ## _tEmP, _nm ## _tEmP_al
* NOTE: _al should be power-of-2 and >= sizeof(_tp), before considering to use such macro
*/
//#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
//_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)-1]; \
//_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)-1); \
//_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
//_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
/* Another better solution with reducing extra memory used */
#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
/*
* ENFORCE_STACK_ALIGN_3D: force 3 dimension local pData aligned in stack
* _tp: type
* _nm: var name
* _cx, _cy, _cz: size in x, y, z dimension
* _al: align bytes
* auxiliary var: _nm ## _tEmP, _nm ## _tEmP_al
* NOTE: _al should be power-of-2 and >= sizeof(_tp), before considering to use such macro
*/
//#define ENFORCE_STACK_ALIGN_3D(_tp, _nm, _cx, _cy, _cz, _al) \
//_tp _nm ## _tEmP[(_cx)*(_cy)*(_cz)+(_al)-1]; \
//_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)-1); \
//_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
//_tp (*_nm)[(_cy)][(_cz)] = (_tp (*)[(_cy)][(_cz)])_nm ## _tEmP_al;
/* Another better solution with reducing extra memory used */
#define ENFORCE_STACK_ALIGN_3D(_tp, _nm, _cx, _cy, _cz, _al) \
assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
_tp _nm ## _tEmP[(_cx)*(_cy)*(_cz)+(_al)/sizeof(_tp)-1]; \
_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
_tp (*_nm)[(_cy)][(_cz)] = (_tp (*)[(_cy)][(_cz)])_nm ## _tEmP_al;
#endif//ARRAY_STACK_ALIGN_H__

View File

@ -48,14 +48,14 @@ $(TargetPath)
*/
/****************************************************************************
* Options for algorithm, usually change bitrate
* Options for algorithm, usually change bitrate
****************************************************************************/
#define DISABLE_FMO_FEATURE //
/****************************************************************************
* Options for optimization, not change bitrate
* Options for optimization, not change bitrate
****************************************************************************/
//#undef X86_ASM // X86_ASM is included in project preprocessor definitions, undef it when need to disable asm code
//#undef X86_ASM // X86_ASM is included in project preprocessor definitions, undef it when need to disable asm code
#define SINGLE_REF_FRAME // need to disable it when use multi-reference

View File

@ -47,12 +47,12 @@
#include "param_svc.h"
namespace WelsSVCEnc {
/*!
/*!
*************************************************************************************
* \brief to write Sequence Parameter Set (SPS)
*
* \param pSps SWelsSPS to be wrote
* \param bs_aux bitstream writer auxiliary
* \param bs_aux bitstream writer auxiliary
*
* \return 0 - successed
* 1 - failed
@ -61,15 +61,15 @@ namespace WelsSVCEnc {
*************************************************************************************
*/
int32_t WelsWriteSpsNal( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_t* pSpsIdDelta );
int32_t WelsWriteSpsNal (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta);
/*!
/*!
*************************************************************************************
* \brief to write SubSet Sequence Parameter Set
*
* \param sub_sps subset pSps parsed
* \param bs_aux bitstream writer auxiliary
* \param bs_aux bitstream writer auxiliary
*
* \return 0 - successed
* 1 - failed
@ -77,15 +77,15 @@ int32_t WelsWriteSpsNal( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_t*
* \note Call it in case EWelsNalUnitType is SubSet SPS.
*************************************************************************************
*/
int32_t WelsWriteSubsetSpsSyntax( SSubsetSps *pSubsetSps, SBitStringAux *pBitStringAux , int32_t* pSpsIdDelta );
int32_t WelsWriteSubsetSpsSyntax (SSubsetSps* pSubsetSps, SBitStringAux* pBitStringAux , int32_t* pSpsIdDelta);
/*!
/*!
*************************************************************************************
* \brief to write Picture Parameter Set (PPS)
*
* \param pPps pPps
* \param bs_aux bitstream writer auxiliary
* \param bs_aux bitstream writer auxiliary
*
* \return 0 - successed
* 1 - failed
@ -93,7 +93,7 @@ int32_t WelsWriteSubsetSpsSyntax( SSubsetSps *pSubsetSps, SBitStringAux *pBitStr
* \note Call it in case EWelsNalUnitType is PPS.
*************************************************************************************
*/
int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaSetOffset* sPSOVector );
int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaSetOffset* sPSOVector);
/*!
* \brief initialize pSps based on configurable parameters in svc
@ -103,8 +103,9 @@ int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaS
* \return 0 - successful
* 1 - failed
*/
int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
const uint32_t kiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc );
int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
const int32_t kiNumRefFrame,
const uint32_t kiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc);
/*!
* \brief initialize subset pSps based on configurable parameters in svc
@ -114,8 +115,9 @@ int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t k
* \return 0 - successful
* 1 - failed
*/
int32_t WelsInitSubsetSps( SSubsetSps *pSubsetSps, SDLayerParam *pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
const uint32_t kiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc );
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
const int32_t kiNumRefFrame,
const uint32_t kiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc);
/*!
* \brief initialize pPps based on configurable parameters and pSps(subset pSps) in svc
@ -128,12 +130,12 @@ int32_t WelsInitSubsetSps( SSubsetSps *pSubsetSps, SDLayerParam *pLayerParam, co
* \return 0 - successful
* 1 - failed
*/
int32_t WelsInitPps( SWelsPPS *pPps,
SWelsSPS *pSps,
SSubsetSps *pSubsetSps,
const uint32_t kuiPpsId,
const bool_t kbDeblockingFilterPresentFlag,
const bool_t kbUsingSubsetSps );
int32_t WelsInitPps (SWelsPPS* pPps,
SWelsSPS* pSps,
SSubsetSps* pSubsetSps,
const uint32_t kuiPpsId,
const bool_t kbDeblockingFilterPresentFlag,
const bool_t kbUsingSubsetSps);
}
#endif//WELS_ACCESS_UNIT_PARSER_H__

View File

@ -41,13 +41,13 @@
* auxiliary struct for bit-stream reading / writing
*/
typedef struct TagBitStringAux {
uint8_t *pBuf; // pBuffer to start position
uint8_t *pBufEnd; // pBuffer + length
uint8_t *pBufPtr; // current writing position
uint32_t uiCurBits;
int32_t iLeftBits; // count number of available bits left ([1, 8]),
// need pointer to next byte start position in case 0 bit left then 8 instead
}SBitStringAux;
uint8_t* pBuf; // pBuffer to start position
uint8_t* pBufEnd; // pBuffer + length
uint8_t* pBufPtr; // current writing position
uint32_t uiCurBits;
int32_t iLeftBits; // count number of available bits left ([1, 8]),
// need pointer to next byte start position in case 0 bit left then 8 instead
} SBitStringAux;
/*!
* \brief input bits for decoder or initialize bitstream writing in encoder
@ -58,17 +58,16 @@ typedef struct TagBitStringAux {
*
* \return iSize of pBuffer pData in byte; failed in -1 return
*/
static inline int32_t InitBits( SBitStringAux *pBs, const uint8_t *kpBuf, const int32_t kiSize )
{
uint8_t *ptr = (uint8_t *)kpBuf;
static inline int32_t InitBits (SBitStringAux* pBs, const uint8_t* kpBuf, const int32_t kiSize) {
uint8_t* ptr = (uint8_t*)kpBuf;
pBs->pBuf = ptr;
pBs->pBufPtr = ptr;
pBs->pBufEnd = ptr + kiSize;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0;
return kiSize;
pBs->pBuf = ptr;
pBs->pBufPtr = ptr;
pBs->pBufEnd = ptr + kiSize;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0;
return kiSize;
}

View File

@ -40,113 +40,97 @@
#include <coreFoundation/CFBundle.h>
#include <string>
int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
{
if(lpModulePath == NULL || iPathMax <= 0)
{
return -1;
}
memset(lpModulePath, 0, iPathMax);
char cCurrentPath[PATH_MAX];
memset(cCurrentPath, 0, PATH_MAX);
Dl_info dlInfo;
static int sDummy;
dladdr((void*)&sDummy, &dlInfo);
strlcpy(cCurrentPath, dlInfo.dli_fname, PATH_MAX);
// whether is self a framework ?
int locateNumber = 1;
struct FSRef currentPath;
OSStatus iStatus = FSPathMakeRef((unsigned char*)cCurrentPath, &currentPath, NULL);
if(noErr == iStatus)
{
LSItemInfoRecord info;
iStatus = LSCopyItemInfoForRef(&currentPath, kLSRequestExtension, &info);
if(noErr == iStatus && NULL == info.extension)
{
locateNumber = 4;
}
}
std::string strPath(cCurrentPath);
int pos = std::string::npos;
for(int i = 0; i < locateNumber; i++)
{
pos = strPath.rfind('/');
if(std::string::npos == pos)
{
break;
}
strPath.erase(pos);
}
if(std::string::npos == pos)
{
return -2;
}
cCurrentPath[pos] = 0;
strlcpy(lpModulePath, cCurrentPath, iPathMax);
strlcat(lpModulePath, "/", iPathMax);
return 0;
int GetCurrentModulePath (char* lpModulePath, const int iPathMax) {
if (lpModulePath == NULL || iPathMax <= 0) {
return -1;
}
CFBundleRef LoadBundle(const char* lpBundlePath)
{
if(lpBundlePath == NULL)
{
return NULL;
}
memset (lpModulePath, 0, iPathMax);
struct FSRef bundlePath;
OSStatus iStatus = FSPathMakeRef((unsigned char*)lpBundlePath, &bundlePath, NULL);
if(noErr != iStatus)
{
return NULL;
}
char cCurrentPath[PATH_MAX];
memset (cCurrentPath, 0, PATH_MAX);
CFURLRef bundleURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &bundlePath);
if(NULL == bundleURL)
{
return NULL;
}
Dl_info dlInfo;
static int sDummy;
dladdr ((void*)&sDummy, &dlInfo);
// 2.get bundle ref
CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
CFRelease(bundleURL);
strlcpy (cCurrentPath, dlInfo.dli_fname, PATH_MAX);
// Boolean bReturn = FALSE;
if(NULL != bundleRef)
{
// bReturn = CFBundleLoadExecutable(bundleRef);
}
// whether is self a framework ?
int locateNumber = 1;
struct FSRef currentPath;
OSStatus iStatus = FSPathMakeRef ((unsigned char*)cCurrentPath, &currentPath, NULL);
if (noErr == iStatus) {
LSItemInfoRecord info;
iStatus = LSCopyItemInfoForRef (&currentPath, kLSRequestExtension, &info);
if (noErr == iStatus && NULL == info.extension) {
locateNumber = 4;
}
}
std::string strPath (cCurrentPath);
int pos = std::string::npos;
for (int i = 0; i < locateNumber; i++) {
pos = strPath.rfind ('/');
if (std::string::npos == pos) {
break;
}
strPath.erase (pos);
}
if (std::string::npos == pos) {
return -2;
}
cCurrentPath[pos] = 0;
return bundleRef;
strlcpy (lpModulePath, cCurrentPath, iPathMax);
strlcat (lpModulePath, "/", iPathMax);
return 0;
}
Boolean FreeBundle(CFBundleRef bundleRef)
{
if(NULL != bundleRef)
{
// CFBundleUnloadExecutable(bundleRef);
CFRelease(bundleRef);
}
return TRUE;
CFBundleRef LoadBundle (const char* lpBundlePath) {
if (lpBundlePath == NULL) {
return NULL;
}
struct FSRef bundlePath;
OSStatus iStatus = FSPathMakeRef ((unsigned char*)lpBundlePath, &bundlePath, NULL);
if (noErr != iStatus) {
return NULL;
}
CFURLRef bundleURL = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &bundlePath);
if (NULL == bundleURL) {
return NULL;
}
// 2.get bundle ref
CFBundleRef bundleRef = CFBundleCreate (kCFAllocatorSystemDefault, bundleURL);
CFRelease (bundleURL);
// Boolean bReturn = FALSE;
if (NULL != bundleRef) {
// bReturn = CFBundleLoadExecutable(bundleRef);
}
return bundleRef;
}
void* GetProcessAddress(CFBundleRef bundleRef, const char* lpProcName)
{
void *processAddress = NULL;
if(NULL != bundleRef)
{
CFStringRef cfProcName = CFStringCreateWithCString(kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
processAddress = CFBundleGetFunctionPointerForName(bundleRef, cfProcName);
CFRelease(cfProcName);
}
return processAddress;
Boolean FreeBundle (CFBundleRef bundleRef) {
if (NULL != bundleRef) {
// CFBundleUnloadExecutable(bundleRef);
CFRelease (bundleRef);
}
return TRUE;
}
void* GetProcessAddress (CFBundleRef bundleRef, const char* lpProcName) {
void* processAddress = NULL;
if (NULL != bundleRef) {
CFStringRef cfProcName = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
processAddress = CFBundleGetFunctionPointerForName (bundleRef, cfProcName);
CFRelease (cfProcName);
}
return processAddress;
}
#endif

View File

@ -54,19 +54,19 @@ extern "C" {
*/
int32_t WelsCPUIdVerify();
void WelsCPUId( uint32_t uiIndex, uint32_t *pFeatureA, uint32_t *pFeatureB, uint32_t *pFeatureC, uint32_t *pFeatureD );
void WelsCPUId (uint32_t uiIndex, uint32_t* pFeatureA, uint32_t* pFeatureB, uint32_t* pFeatureC, uint32_t* pFeatureD);
int32_t WelsCPUSupportAVX( uint32_t eax, uint32_t ecx );
int32_t WelsCPUSupportFMA( uint32_t eax, uint32_t ecx );
int32_t WelsCPUSupportAVX (uint32_t eax, uint32_t ecx);
int32_t WelsCPUSupportFMA (uint32_t eax, uint32_t ecx);
void WelsEmms();
uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors );
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
/*
* clear FPU registers states for potential float based calculation if support
*/
void WelsCPURestore( const uint32_t kuiCPU );
void WelsCPURestore (const uint32_t kuiCPU);
#endif

View File

@ -42,7 +42,7 @@
/*
* WELS CPU feature flags
*/
*/
#define WELS_CPU_MMX 0x00000001 /* mmx */
#define WELS_CPU_MMXEXT 0x00000002 /* mmx-ext*/
#define WELS_CPU_SSE 0x00000004 /* sse */

View File

@ -55,301 +55,322 @@
#include "typedefs.h"
#endif//WIN32
/*
/*
* Safe Lib specific errno codes. These can be added to the errno.h file
* if desired.
* if desired.
*/
#define ESNULLP ( 400 ) /* null ptr */
#define ESZEROL ( 401 ) /* length is zero */
#define ESLEMIN ( 402 ) /* length is below min */
#define ESLEMAX ( 403 ) /* length exceeds max */
#define ESOVRLP ( 404 ) /* overlap undefined */
#define ESEMPTY ( 405 ) /* empty string */
#define ESNOSPC ( 406 ) /* not enough space for s2 */
#define ESUNTERM ( 407 ) /* unterminated string */
#define ESNODIFF ( 408 ) /* no difference */
#define ESNOTFND ( 409 ) /* not found */
#define ESNULLP ( 400 ) /* null ptr */
#define ESZEROL ( 401 ) /* length is zero */
#define ESLEMIN ( 402 ) /* length is below min */
#define ESLEMAX ( 403 ) /* length exceeds max */
#define ESOVRLP ( 404 ) /* overlap undefined */
#define ESEMPTY ( 405 ) /* empty string */
#define ESNOSPC ( 406 ) /* not enough space for s2 */
#define ESUNTERM ( 407 ) /* unterminated string */
#define ESNODIFF ( 408 ) /* no difference */
#define ESNOTFND ( 409 ) /* not found */
/* EOK may or may not be defined in errno.h */
#ifndef EOK
/* EOK may or may not be defined in errno.h */
#ifndef EOK
#define EOK 0
#endif
#if (defined(WIN32) && defined(_MSC_VER) && (_MSC_VER<1500)) || defined(__GNUC__)
static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int slen )
{
int orig_dmax;
char *orig_dest;
const char *overlap_bumper;
static __inline int wels_strncpy_s (char* dest, int dmax, const char* src, int slen) {
int orig_dmax;
char* orig_dest;
const char* overlap_bumper;
if (dest == NULL) {
// invoke_safe_lib_constraint_handler("strncpy_s: dest is null",
if (dest == NULL) {
// invoke_safe_lib_constraint_handler("strncpy_s: dest is null",
// NULL, ESNULLP);
return (ESNULLP);
}
return (ESNULLP);
}
if (dmax <= 0) {
// invoke_safe_lib_constraint_handler("strncpy_s: dmax is 0",
if (dmax <= 0) {
// invoke_safe_lib_constraint_handler("strncpy_s: dmax is 0",
// NULL, ESZEROL);
return (ESZEROL);
}
return (ESZEROL);
}
// if (dmax > RSIZE_MAX_STR) {
// invoke_safe_lib_constraint_handler("strncpy_s: dmax exceeds max",
// invoke_safe_lib_constraint_handler("strncpy_s: dmax exceeds max",
// NULL, ESLEMAX);
// return (ESLEMAX);
// }
if (src == NULL) {
if (src == NULL) {
// handle_error(orig_dest, orig_dmax, "strncpy_s: src is null", ESNULLP);
return (ESNULLP);
}
return (ESNULLP);
}
if (slen <= 0) {
if (slen <= 0) {
// handle_error(orig_dest, orig_dmax, "strncpy_s: slen is zero", ESZEROL);
return (ESZEROL);
}
return (ESZEROL);
}
// if (slen > RSIZE_MAX_STR) {
// handle_error(orig_dest, orig_dmax, "strncpy_s: slen exceeds max", ESLEMAX);
// return (ESLEMAX);
// }
/* hold base in case src was not copied */
orig_dmax = dmax;
orig_dest = dest;
/* hold base in case src was not copied */
orig_dmax = dmax;
orig_dest = dest;
if (dest < src) {
overlap_bumper = src;
if (dest < src) {
overlap_bumper = src;
while (dmax > 0) {
if (dest == overlap_bumper) {
while (dmax > 0) {
if (dest == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strncpy_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
return (ESOVRLP);
}
if (slen == 0) {
/*
* Copying truncated to slen chars. Note that the TR says to
* copy slen chars plus the null char. We null the slack.
*/
if (slen == 0) {
/*
* Copying truncated to slen chars. Note that the TR says to
* copy slen chars plus the null char. We null the slack.
*/
#ifdef SAFE_LIB_STR_NULL_SLACK
while (dmax) { *dest = '\0'; dmax--; dest++; }
while (dmax) {
*dest = '\0';
dmax--;
dest++;
}
#else
*dest = '\0';
#endif
return (EOK);
}
*dest = '\0';
#endif
return (EOK);
}
*dest = *src;
if (*dest == '\0') {
*dest = *src;
if (*dest == '\0') {
#ifdef SAFE_LIB_STR_NULL_SLACK
/* null slack */
while (dmax) { *dest = '\0'; dmax--; dest++; }
#endif
return (EOK);
}
/* null slack */
while (dmax) {
*dest = '\0';
dmax--;
dest++;
}
#endif
return (EOK);
}
dmax--;
slen--;
dest++;
src++;
}
dmax--;
slen--;
dest++;
src++;
}
} else {
overlap_bumper = dest;
} else {
overlap_bumper = dest;
while (dmax > 0) {
if (src == overlap_bumper) {
while (dmax > 0) {
if (src == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strncpy_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
return (ESOVRLP);
}
if (slen == 0) {
/*
* Copying truncated to slen chars. Note that the TR says to
* copy slen chars plus the null char. We null the slack.
*/
if (slen == 0) {
/*
* Copying truncated to slen chars. Note that the TR says to
* copy slen chars plus the null char. We null the slack.
*/
#ifdef SAFE_LIB_STR_NULL_SLACK
while (dmax) { *dest = '\0'; dmax--; dest++; }
while (dmax) {
*dest = '\0';
dmax--;
dest++;
}
#else
*dest = '\0';
#endif
return (EOK);
}
*dest = '\0';
#endif
return (EOK);
}
*dest = *src;
if (*dest == '\0') {
*dest = *src;
if (*dest == '\0') {
#ifdef SAFE_LIB_STR_NULL_SLACK
/* null slack */
while (dmax) { *dest = '\0'; dmax--; dest++; }
#endif
return (EOK);
}
/* null slack */
while (dmax) {
*dest = '\0';
dmax--;
dest++;
}
#endif
return (EOK);
}
dmax--;
slen--;
dest++;
src++;
}
}
/*
* the entire src was not copied, so zero the string
*/
// handle_error(orig_dest, orig_dmax, "strncpy_s: not enough space for src", ESNOSPC);
return (ESNOSPC);
dmax--;
slen--;
dest++;
src++;
}
}
static __inline int wels_strcat_s(char *dest, int dmax, const char *src)
{
int orig_dmax;
char *orig_dest;
const char *overlap_bumper;
/*
* the entire src was not copied, so zero the string
*/
// handle_error(orig_dest, orig_dmax, "strncpy_s: not enough space for src", ESNOSPC);
return (ESNOSPC);
}
if (dest == NULL) {
// invoke_safe_lib_constraint_handler("strcat_s: dest is null",
static __inline int wels_strcat_s (char* dest, int dmax, const char* src) {
int orig_dmax;
char* orig_dest;
const char* overlap_bumper;
if (dest == NULL) {
// invoke_safe_lib_constraint_handler("strcat_s: dest is null",
// NULL, ESNULLP);
return (ESNULLP);
}
return (ESNULLP);
}
if (src == NULL) {
// invoke_safe_lib_constraint_handler("strcat_s: src is null",
if (src == NULL) {
// invoke_safe_lib_constraint_handler("strcat_s: src is null",
// NULL, ESNULLP);
return (ESNULLP);
}
return (ESNULLP);
}
if (dmax <= 0) {
// invoke_safe_lib_constraint_handler("strcat_s: dmax is 0",
if (dmax <= 0) {
// invoke_safe_lib_constraint_handler("strcat_s: dmax is 0",
// NULL, ESZEROL);
return (ESZEROL);
}
return (ESZEROL);
}
// if (dmax > RSIZE_MAX_STR) {
// invoke_safe_lib_constraint_handler("strcat_s: dmax exceeds max",
// invoke_safe_lib_constraint_handler("strcat_s: dmax exceeds max",
// NULL, ESLEMAX);
// return (ESLEMAX);
// }
/* hold base of dest in case src was not copied */
orig_dmax = dmax;
orig_dest = dest;
/* hold base of dest in case src was not copied */
orig_dmax = dmax;
orig_dest = dest;
if (dest < src) {
overlap_bumper = src;
if (dest < src) {
overlap_bumper = src;
/* Find the end of dest */
while (*dest != '\0') {
if (dest == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strcat_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
/* Find the end of dest */
while (*dest != '\0') {
dest++;
dmax--;
if (dmax == 0) {
// handle_error(orig_dest, orig_dmax, "strcat_s: dest unterminated", ESUNTERM);
return (ESUNTERM);
}
}
if (dest == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strcat_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
while (dmax > 0) {
if (dest == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strcat_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
dest++;
dmax--;
if (dmax == 0) {
// handle_error(orig_dest, orig_dmax, "strcat_s: dest unterminated", ESUNTERM);
return (ESUNTERM);
}
}
*dest = *src;
if (*dest == '\0') {
while (dmax > 0) {
if (dest == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strcat_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
*dest = *src;
if (*dest == '\0') {
#ifdef SAFE_LIB_STR_NULL_SLACK
/* null slack to clear any data */
while (dmax) { *dest = '\0'; dmax--; dest++; }
#endif
return (EOK);
}
dmax--;
dest++;
src++;
/* null slack to clear any data */
while (dmax) {
*dest = '\0';
dmax--;
dest++;
}
#endif
return (EOK);
}
} else {
overlap_bumper = dest;
dmax--;
dest++;
src++;
}
/* Find the end of dest */
while (*dest != '\0') {
} else {
overlap_bumper = dest;
/*
* NOTE: no need to check for overlap here since src comes first
* in memory and we're not incrementing src here.
*/
dest++;
dmax--;
if (dmax == 0) {
// handle_error(orig_dest, orig_dmax, "strcat_s: dest unterminated", ESUNTERM);
return (ESUNTERM);
}
}
/* Find the end of dest */
while (*dest != '\0') {
while (dmax > 0) {
if (src == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strcat_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
/*
* NOTE: no need to check for overlap here since src comes first
* in memory and we're not incrementing src here.
*/
dest++;
dmax--;
if (dmax == 0) {
// handle_error(orig_dest, orig_dmax, "strcat_s: dest unterminated", ESUNTERM);
return (ESUNTERM);
}
}
*dest = *src;
if (*dest == '\0') {
while (dmax > 0) {
if (src == overlap_bumper) {
// handle_error(orig_dest, orig_dmax, "strcat_s: overlapping objects", ESOVRLP);
return (ESOVRLP);
}
*dest = *src;
if (*dest == '\0') {
#ifdef SAFE_LIB_STR_NULL_SLACK
/* null slack to clear any data */
while (dmax) { *dest = '\0'; dmax--; dest++; }
#endif
return (EOK);
}
dmax--;
dest++;
src++;
/* null slack to clear any data */
while (dmax) {
*dest = '\0';
dmax--;
dest++;
}
}
#endif
return (EOK);
}
/*
* the entire src was not copied, so null the string
*/
// handle_error(orig_dest, orig_dmax, "strcat_s: not enough space for src", ESNOSPC);
dmax--;
dest++;
src++;
}
}
return (ESNOSPC);
/*
* the entire src was not copied, so null the string
*/
// handle_error(orig_dest, orig_dmax, "strcat_s: not enough space for src", ESNOSPC);
return (ESNOSPC);
}
static __inline int wels_strnlen_s(const char *dest, int dmax)
{
int count;
static __inline int wels_strnlen_s (const char* dest, int dmax) {
int count;
if (dest == NULL) {
return (0);
}
if (dest == NULL) {
return (0);
}
if (dmax <= 0) {
// invoke_safe_lib_constraint_handler("strnlen_s: dmax is 0",
if (dmax <= 0) {
// invoke_safe_lib_constraint_handler("strnlen_s: dmax is 0",
// NULL, ESZEROL);
return (0);
}
return (0);
}
// if (dmax > RSIZE_MAX_STR) {
// invoke_safe_lib_constraint_handler("strnlen_s: dmax exceeds max",
// invoke_safe_lib_constraint_handler("strnlen_s: dmax exceeds max",
// NULL, ESLEMAX);
// return (0);
// }
count = 0;
while (*dest && dmax) {
count++;
dmax--;
dest++;
}
count = 0;
while (*dest && dmax) {
count++;
dmax--;
dest++;
}
return (count);
return (count);
}
#endif//(WIN32 && _MSC_VER && _MSC_VER<1500) || __GNUC__

View File

@ -50,66 +50,72 @@ namespace WelsSVCEnc {
//struct tagDeblockingFunc;
typedef struct TagDeblockingFilter {
uint8_t *pCsData[3]; // pointer to reconstructed picture pData
int32_t iCsStride[3]; // Cs iStride
int16_t iMbStride;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
uint8_t uiLumaQP;
uint8_t uiChromaQP;
uint8_t uiFilterIdc;
uint8_t uiReserved;
}SDeblockingFilter;
uint8_t* pCsData[3]; // pointer to reconstructed picture pData
int32_t iCsStride[3]; // Cs iStride
int16_t iMbStride;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
uint8_t uiLumaQP;
uint8_t uiChromaQP;
uint8_t uiFilterIdc;
uint8_t uiReserved;
} SDeblockingFilter;
void DeblockLumaLt4_c( uint8_t *pPixY, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockLumaEq4_c( uint8_t *pPixY, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta );
void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta );
void DeblockLumaLt4_c (uint8_t* pPixY, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4_c (uint8_t* pPixY, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
int32_t iBeta, int8_t* pTc);
void DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
int32_t iBeta);
void DeblockLumaLt4V_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockLumaEq4V_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void DeblockLumaLt4V_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4V_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockLumaLt4H_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockLumaEq4H_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void DeblockLumaLt4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockChromaEq4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTc);
void DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockChromaEq4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTc);
void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#ifdef X86_ASM
void DeblockLumaLt4V_sse2( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
void DeblockLumaEq4V_sse2( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta );
void DeblockLumaTransposeH2V_sse2(uint8_t * pPixY, int32_t iStride, uint8_t * pDst);
void DeblockLumaTransposeV2H_sse2(uint8_t * pPixY, int32_t iStride, uint8_t * pSrc);
void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc);
void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaEq4V_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
void DeblockChromaEq4H_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
void DeblockLumaLt4V_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4V_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockLumaTransposeH2V_sse2 (uint8_t* pPixY, int32_t iStride, uint8_t* pDst);
void DeblockLumaTransposeV2H_sse2 (uint8_t* pPixY, int32_t iStride, uint8_t* pSrc);
void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaEq4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
void DeblockChromaEq4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
#endif
#if defined(__cplusplus)
}
#endif//__cplusplus
void DeblockingInit( DeblockingFunc * pFunc, int32_t iCpu );
void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu);
void WelsNonZeroCount_c(int8_t * pNonZeroCount);
void WelsBlockFuncInit(PSetNoneZeroCountZeroFunc *pfSetNZCZero, int32_t iCpu);
void WelsNonZeroCount_c (int8_t* pNonZeroCount);
void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu);
void PerformDeblockingFilter( sWelsEncCtx *pEnc );
void PerformDeblockingFilter (sWelsEncCtx* pEnc);
void DeblockingFilterFrameAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc );
void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc);
void DeblockingFilterSliceAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc, const int32_t kiSliceIdx );
void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx);
}
#endif

View File

@ -38,34 +38,36 @@
#include "wels_func_ptr_def.h"
namespace WelsSVCEnc {
void WelsDequantLumaDc4x4(int16_t *pRes, const int32_t kiQp);
void WelsIHadamard4x4Dc(int16_t* pRes);
void WelsDequantLumaDc4x4 (int16_t* pRes, const int32_t kiQp);
void WelsIHadamard4x4Dc (int16_t* pRes);
void WelsInitReconstructionFuncs( SWelsFuncPtrList *pList, uint32_t iCpuFlags );
void WelsGetEncBlockStrideOffset(int32_t *pBlock, const int32_t kiStrideY, const int32_t kiStrideUV);
void WelsInitReconstructionFuncs (SWelsFuncPtrList* pList, uint32_t iCpuFlags);
void WelsGetEncBlockStrideOffset (int32_t* pBlock, const int32_t kiStrideY, const int32_t kiStrideUV);
void WelsDequantFour4x4_c(int16_t *pRes, const uint16_t* kpQpTable);
void WelsDequant4x4_c(int16_t *pRes, const uint16_t* kpQpTable);
void WelsDequantIHadamard4x4_c(int16_t *pRes, const uint16_t kuiMF);
void WelsDequantIHadamard2x2Dc( int16_t* pDct, const uint16_t kuiMF);
void WelsDequantFour4x4_c (int16_t* pRes, const uint16_t* kpQpTable);
void WelsDequant4x4_c (int16_t* pRes, const uint16_t* kpQpTable);
void WelsDequantIHadamard4x4_c (int16_t* pRes, const uint16_t kuiMF);
void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF);
void WelsIDctT4RecOnMb(uint8_t* pDst, int32_t iDstStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct, PIDctFunc pfIDctFourT4);
void WelsIDctT4Rec_c( uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct );
void WelsIDctFourT4Rec_c( uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct );
void WelsIDctRecI16x16Dc_c(uint8_t *pRec, int32_t iStride, uint8_t *pPred, int32_t iPredStride, int16_t *pDctDc);
void WelsIDctT4RecOnMb (uint8_t* pDst, int32_t iDstStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct,
PIDctFunc pfIDctFourT4);
void WelsIDctT4Rec_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct);
void WelsIDctFourT4Rec_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct);
void WelsIDctRecI16x16Dc_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDctDc);
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#if defined(X86_ASM)
void WelsDequant4x4_sse2(int16_t *pDct, const uint16_t* kpMF);
void WelsDequantFour4x4_sse2(int16_t *pDct, const uint16_t* kpMF);
void WelsDequantIHadamard4x4_sse2(int16_t *pRes, const uint16_t kuiMF);
void WelsDequant4x4_sse2 (int16_t* pDct, const uint16_t* kpMF);
void WelsDequantFour4x4_sse2 (int16_t* pDct, const uint16_t* kpMF);
void WelsDequantIHadamard4x4_sse2 (int16_t* pRes, const uint16_t kuiMF);
void WelsIDctT4Rec_mmx( uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct );
void WelsIDctFourT4Rec_sse2( uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct );
void WelsIDctRecI16x16Dc_sse2(uint8_t *pRec, int32_t iStride, uint8_t *pPrediction, int32_t iPredStride, int16_t *pDctDc);
void WelsIDctT4Rec_mmx (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
void WelsIDctFourT4Rec_sse2 (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
void WelsIDctRecI16x16Dc_sse2 (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride,
int16_t* pDctDc);
#endif//X86_ASM
#if defined(__cplusplus)

View File

@ -46,11 +46,10 @@
* Dependency Quality IDC
*/
typedef struct TagDqIdc
{
uint16_t iPpsId; // pPps id
uint8_t iSpsId; // pSps id
int8_t uiSpatialId; // spatial id
}SDqIdc;
typedef struct TagDqIdc {
uint16_t iPpsId; // pPps id
uint8_t iSpsId; // pSps id
int8_t uiSpatialId; // spatial id
} SDqIdc;
#endif//WELS_ENCODER_DEPENDENCY_QUAILITY_IDC_MAP_H__

View File

@ -37,45 +37,45 @@
#include "wels_func_ptr_def.h"
namespace WelsSVCEnc {
void WelsInitEncodingFuncs( SWelsFuncPtrList *pFuncList, uint32_t uiCpuFlag );
int32_t WelsGetNoneZeroCount_c(int16_t* pLevel);
void WelsInitEncodingFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag);
int32_t WelsGetNoneZeroCount_c (int16_t* pLevel);
/****************************************************************************
* Scan and Score functions
****************************************************************************/
void WelsScan4x4Ac_c( int16_t* pZigValue, int16_t* pDct );
void WelsScan4x4Dc( int16_t* pLevel, int16_t* pDct );
void WelsScan4x4DcAc_c( int16_t* pLevel, int16_t *pDct );
int32_t WelsCalculateSingleCtr4x4_c( int16_t *pDct);
void WelsScan4x4Ac_c (int16_t* pZigValue, int16_t* pDct);
void WelsScan4x4Dc (int16_t* pLevel, int16_t* pDct);
void WelsScan4x4DcAc_c (int16_t* pLevel, int16_t* pDct);
int32_t WelsCalculateSingleCtr4x4_c (int16_t* pDct);
/****************************************************************************
* HDM and Quant functions
* HDM and Quant functions
****************************************************************************/
void WelsHadamardT4Dc_c( int16_t *pLumaDc, int16_t *pDct);
int32_t WelsHadamardQuant2x2_c(int16_t *pRes, const int16_t kiFF, int16_t iMF, int16_t * pDct, int16_t * pBlock);
int32_t WelsHadamardQuant2x2Skip_c(int16_t *pRes, int16_t iFF, int16_t iMF);
void WelsHadamardT4Dc_c (int16_t* pLumaDc, int16_t* pDct);
int32_t WelsHadamardQuant2x2_c (int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct, int16_t* pBlock);
int32_t WelsHadamardQuant2x2Skip_c (int16_t* pRes, int16_t iFF, int16_t iMF);
void WelsQuant4x4_c(int16_t *pDct, int16_t* pFF, int16_t *pMF);
void WelsQuant4x4Dc_c(int16_t *pDct, int16_t iFF, int16_t iMF);
void WelsQuantFour4x4_c(int16_t *pDct, int16_t* pFF, int16_t *pQpTable);
void WelsQuantFour4x4Max_c(int16_t *pDct, int16_t* pF, int16_t *pQpTable, int16_t *pMax);
void WelsQuant4x4_c (int16_t* pDct, int16_t* pFF, int16_t* pMF);
void WelsQuant4x4Dc_c (int16_t* pDct, int16_t iFF, int16_t iMF);
void WelsQuantFour4x4_c (int16_t* pDct, int16_t* pFF, int16_t* pQpTable);
void WelsQuantFour4x4Max_c (int16_t* pDct, int16_t* pF, int16_t* pQpTable, int16_t* pMax);
/****************************************************************************
* DCT functions
****************************************************************************/
void WelsDctT4_c( int16_t *pDct, uint8_t *pPixel1, int32_t iStride1, uint8_t *pPixel2, int32_t iStride2 );
void WelsDctT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
// dct_data is no-use here, just for the same interface with dct_save functions
void WelsDctFourT4_c(int16_t *pDct, uint8_t *pPixel1, int32_t iStride1, uint8_t *pPixel2, int32_t iStride2);
void WelsDctFourT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
/****************************************************************************
* Copy functions
****************************************************************************/
void WelsCopy4x4( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS );
void WelsCopy8x8_c( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS );
void WelsCopy8x16_c( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS ); //
void WelsCopy16x8_c( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS ); //
void WelsCopy16x16_c( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS );
void WelsCopy4x4 (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
void WelsCopy8x8_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
void WelsCopy8x16_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); //
void WelsCopy16x8_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); //
void WelsCopy16x16_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
#if defined(__cplusplus)
extern "C" {
@ -83,43 +83,43 @@ extern "C" {
#ifdef X86_ASM
int32_t WelsGetNoneZeroCount_sse2(int16_t* pLevel);
int32_t WelsGetNoneZeroCount_sse2 (int16_t* pLevel);
/****************************************************************************
* Scan and Score functions
****************************************************************************/
void WelsScan4x4Ac_sse2( int16_t* zig_value, int16_t* pDct );
void WelsScan4x4DcAc_ssse3( int16_t* pLevel, int16_t *pDct );
void WelsScan4x4DcAc_sse2( int16_t* pLevel, int16_t *pDct );
int32_t WelsCalculateSingleCtr4x4_sse2( int16_t *pDct );
void WelsScan4x4Ac_sse2 (int16_t* zig_value, int16_t* pDct);
void WelsScan4x4DcAc_ssse3 (int16_t* pLevel, int16_t* pDct);
void WelsScan4x4DcAc_sse2 (int16_t* pLevel, int16_t* pDct);
int32_t WelsCalculateSingleCtr4x4_sse2 (int16_t* pDct);
/****************************************************************************
* DCT functions
****************************************************************************/
void WelsDctT4_mmx( int16_t *pDct, uint8_t *pPixel1, int32_t iStride1, uint8_t *pPixel2, int32_t iStride2 );
void WelsDctFourT4_sse2(int16_t *pDct, uint8_t *pPixel1, int32_t iStride1, uint8_t *pPixel2, int32_t iStride2);
void WelsDctT4_mmx (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
void WelsDctFourT4_sse2 (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
/****************************************************************************
* HDM and Quant functions
* HDM and Quant functions
****************************************************************************/
int32_t WelsHadamardQuant2x2_mmx(int16_t *pRes, const int16_t kiFF, int16_t iMF, int16_t * pDct, int16_t * pBlock);
void WelsHadamardT4Dc_sse2( int16_t *pLumaDc, int16_t *pDct);
int32_t WelsHadamardQuant2x2Skip_mmx(int16_t *pRes, int16_t iFF, int16_t iMF);
int32_t WelsHadamardQuant2x2_mmx (int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct, int16_t* pBlock);
void WelsHadamardT4Dc_sse2 (int16_t* pLumaDc, int16_t* pDct);
int32_t WelsHadamardQuant2x2Skip_mmx (int16_t* pRes, int16_t iFF, int16_t iMF);
void WelsQuant4x4_sse2(int16_t *pDct, int16_t* pFF, int16_t *pMF);
void WelsQuant4x4Dc_sse2(int16_t *pDct, int16_t iFF, int16_t iMF);
void WelsQuantFour4x4_sse2(int16_t *pDct, int16_t* pFF, int16_t *pMF);
void WelsQuantFour4x4Max_sse2(int16_t *pDct, int16_t* pFF, int16_t *pMF, int16_t *pMax);
void WelsQuant4x4_sse2 (int16_t* pDct, int16_t* pFF, int16_t* pMF);
void WelsQuant4x4Dc_sse2 (int16_t* pDct, int16_t iFF, int16_t iMF);
void WelsQuantFour4x4_sse2 (int16_t* pDct, int16_t* pFF, int16_t* pMF);
void WelsQuantFour4x4Max_sse2 (int16_t* pDct, int16_t* pFF, int16_t* pMF, int16_t* pMax);
/****************************************************************************
* Copy functions for rec
****************************************************************************/
void WelsCopy8x8_mmx( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS );
void WelsCopy8x16_mmx( uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS );
void WelsCopy16x8NotAligned_sse2( uint8_t* Dst, int32_t iStrideD, uint8_t* Src,int32_t iStrideS );
void WelsCopy16x16_sse2( uint8_t* Dst, int32_t iStrideD, uint8_t* Src,int32_t iStrideS );
void WelsCopy16x16NotAligned_sse2( uint8_t* Dst, int32_t iStrideD, uint8_t* Src,int32_t iStrideS );
void WelsCopy8x8_mmx (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
void WelsCopy8x16_mmx (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
void WelsCopy16x8NotAligned_sse2 (uint8_t* Dst, int32_t iStrideD, uint8_t* Src, int32_t iStrideS);
void WelsCopy16x16_sse2 (uint8_t* Dst, int32_t iStrideD, uint8_t* Src, int32_t iStrideS);
void WelsCopy16x16NotAligned_sse2 (uint8_t* Dst, int32_t iStrideD, uint8_t* Src, int32_t iStrideS);
#endif
@ -127,8 +127,8 @@ void WelsCopy16x16NotAligned_sse2( uint8_t* Dst, int32_t iStrideD, uint8_t* Src
}
#endif//__cplusplus
__align16(extern int16_t, g_kiQuantInterFF[58][8] );
__align16 (extern int16_t, g_kiQuantInterFF[58][8]);
#define g_iQuantIntraFF (g_kiQuantInterFF +6 )
__align16(extern int16_t, g_kiQuantMF[52][8]) ;
__align16 (extern int16_t, g_kiQuantMF[52][8]) ;
}
#endif//ENCODE_MB_AUX_H

View File

@ -48,45 +48,45 @@ namespace WelsSVCEnc {
* \param pEncCtx sWelsEncCtx*
* \return successful - 0; otherwise none 0 for failed
*/
int32_t RequestMemorySvc( sWelsEncCtx **ppCtx );
int32_t RequestMemorySvc (sWelsEncCtx** ppCtx);
/*!
* \brief free memory in SVC core encoder
* \param pEncCtx sWelsEncCtx**
* \return none
*/
void FreeMemorySvc( sWelsEncCtx **ppCtx);
void FreeMemorySvc (sWelsEncCtx** ppCtx);
/*!
* \brief initialize function pointers that potentially used in Wels encoding
* \param pEncCtx sWelsEncCtx*
* \return successful - 0; otherwise none 0 for failed
*/
int32_t InitFunctionPointers( SWelsFuncPtrList *pFuncList, SWelsSvcCodingParam *_param, uint32_t uiCpuFlag );
int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* _param, uint32_t uiCpuFlag);
///*!
// * \brief decide frame type (IDR/P frame)
// * \brief decide frame type (IDR/P frame)
// * \param uiFrameType frame type output
// * \param frame_idx frame index elapsed currently
// * \param idr IDR interval
// * \return successful - 0; otherwise none 0 for failed
// */
/*!
* \brief initialize frame coding
* \brief initialize frame coding
*/
void InitFrameCoding( sWelsEncCtx *pEncCtx, const EFrameType keFrameType );
void InitFrameCoding (sWelsEncCtx* pEncCtx, const EFrameType keFrameType);
EFrameType DecideFrameType( sWelsEncCtx *pEncCtx, const int8_t kiSpatialNum );
EFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum);
/*!
* \brief Dump reconstruction for dependency layer
*/
extern "C" void DumpDependencyRec( SPicture *pSrcPic, const str_t *kpFileName, const int8_t kiDid );
extern "C" void DumpDependencyRec (SPicture* pSrcPic, const str_t* kpFileName, const int8_t kiDid);
/*!
* \brief Dump the reconstruction pictures
*/
void DumpRecFrame( SPicture *pSrcPic, const str_t *kpFileName );
void DumpRecFrame (SPicture* pSrcPic, const str_t* kpFileName);
/*!
@ -97,26 +97,26 @@ void DumpRecFrame( SPicture *pSrcPic, const str_t *kpFileName );
* \param nal_idc EWelsNalRefIdc for a frame
* \return successful - 0; otherwise none 0 for failed
*/
int32_t EncodeFrame( sWelsEncCtx *pEncCtx,
const int32_t kiSliceNumCount,
const EWelsNalUnitType keNalType,
const EWelsNalRefIdc keNalIdc );
int32_t EncodeFrame (sWelsEncCtx* pEncCtx,
const int32_t kiSliceNumCount,
const EWelsNalUnitType keNalType,
const EWelsNalRefIdc keNalIdc);
/**********************************************************************************
* memzero Function
* memzero Function
***********************************************************************************/
void WelsSetMemZero_c(void *pDst, int32_t iSize); // confirmed_safe_unsafe_usage
void WelsSetMemZero_c (void* pDst, int32_t iSize); // confirmed_safe_unsafe_usage
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#ifdef X86_ASM
void WelsSetMemZeroAligned64_sse2(void *pDst, int32_t iSize);
void WelsSetMemZeroSize64_mmx(void *pDst, int32_t iSize);
void WelsSetMemZeroSize8_mmx(void *pDst, int32_t iSize);
void WelsPrefetchZero_mmx(int8_t const*kpDst);
void WelsSetMemZeroAligned64_sse2 (void* pDst, int32_t iSize);
void WelsSetMemZeroSize64_mmx (void* pDst, int32_t iSize);
void WelsSetMemZeroSize8_mmx (void* pDst, int32_t iSize);
void WelsPrefetchZero_mmx (int8_t const* kpDst);
#endif
#if defined(__cplusplus)

View File

@ -64,159 +64,167 @@ namespace WelsSVCEnc {
* reference list for each quality layer in SVC
*/
typedef struct TagRefList {
SPicture *pShortRefList[1+MAX_SHORT_REF_COUNT];// reference list 0 - int16_t
SPicture *pLongRefList[1+MAX_LONG_REF_COUNT]; // reference list 1 - int32_t
SPicture *pNextBuffer;
SPicture *pRef[1+MAX_REF_PIC_COUNT]; // plus 1 for swap intend
uint8_t uiShortRefCount;
uint8_t uiLongRefCount; // dependend on pRef pic module
SPicture* pShortRefList[1 + MAX_SHORT_REF_COUNT]; // reference list 0 - int16_t
SPicture* pLongRefList[1 + MAX_LONG_REF_COUNT]; // reference list 1 - int32_t
SPicture* pNextBuffer;
SPicture* pRef[1 + MAX_REF_PIC_COUNT]; // plus 1 for swap intend
uint8_t uiShortRefCount;
uint8_t uiLongRefCount; // dependend on pRef pic module
} SRefList;
typedef struct TagLTRState{
// LTR mark feedback
uint32_t uiLtrMarkState; // LTR mark state, indicate whether there is a LTR mark feedback unsolved
int32_t iLtrMarkFbFrameNum;// the unsolved LTR mark feedback, the marked iFrameNum feedback from decoder
typedef struct TagLTRState {
// LTR mark feedback
uint32_t uiLtrMarkState; // LTR mark state, indicate whether there is a LTR mark feedback unsolved
int32_t iLtrMarkFbFrameNum;// the unsolved LTR mark feedback, the marked iFrameNum feedback from decoder
// LTR used as recovery reference
int32_t iLastRecoverFrameNum; // reserve the last LTR or IDR recover iFrameNum
int32_t iLastCorFrameNumDec; // reserved the last correct position in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
int32_t iCurFrameNumInDec; // current iFrameNum in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
// LTR used as recovery reference
int32_t iLastRecoverFrameNum; // reserve the last LTR or IDR recover iFrameNum
int32_t
iLastCorFrameNumDec; // reserved the last correct position in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
int32_t
iCurFrameNumInDec; // current iFrameNum in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
// LTR mark
int32_t iLTRMarkMode; // direct mark or delay mark
int32_t iLTRMarkSuccessNum; //successful marked num, for mark mode switch
int32_t iCurLtrIdx;// current int32_t term reference index to mark
int32_t iLastLtrIdx;
uint32_t uiLtrMarkInterval;// the interval from the last int32_t term pRef mark
bool_t bLTRMarkingFlag; //decide whether current frame marked as LTR
bool_t bLTRMarkEnable; //when LTR is confirmed and the interval is no smaller than the marking period
bool_t bReceivedT0LostFlag; // indicate whether a t0 lost feedback is recieved, for LTR recovery
}SLTRState;
// LTR mark
int32_t iLTRMarkMode; // direct mark or delay mark
int32_t iLTRMarkSuccessNum; //successful marked num, for mark mode switch
int32_t iCurLtrIdx;// current int32_t term reference index to mark
int32_t iLastLtrIdx;
uint32_t uiLtrMarkInterval;// the interval from the last int32_t term pRef mark
typedef struct TagSpatialPicIndex{
SPicture *pSrc; // I420 based and after color space converted
int32_t iDid; // dependency id
bool_t bLTRMarkingFlag; //decide whether current frame marked as LTR
bool_t bLTRMarkEnable; //when LTR is confirmed and the interval is no smaller than the marking period
bool_t bReceivedT0LostFlag; // indicate whether a t0 lost feedback is recieved, for LTR recovery
} SLTRState;
typedef struct TagSpatialPicIndex {
SPicture* pSrc; // I420 based and after color space converted
int32_t iDid; // dependency id
} SSpatialPicIndex;
typedef struct TagStrideTables {
int32_t *pStrideDecBlockOffset[MAX_DEPENDENCY_LAYER][2]; // [iDid][tid==0][24 x 4]: luma+chroma= 24 x 4
int32_t *pStrideEncBlockOffset[MAX_DEPENDENCY_LAYER]; // [iDid][24 x 4]: luma+chroma= 24 x 4
int16_t *pMbIndexX[MAX_DEPENDENCY_LAYER]; // [iDid][iMbX]: map for iMbX in each spatial layer coding
int16_t *pMbIndexY[MAX_DEPENDENCY_LAYER]; // [iDid][iMbY]: map for iMbY in each spatial layer coding
int32_t* pStrideDecBlockOffset[MAX_DEPENDENCY_LAYER][2]; // [iDid][tid==0][24 x 4]: luma+chroma= 24 x 4
int32_t* pStrideEncBlockOffset[MAX_DEPENDENCY_LAYER]; // [iDid][24 x 4]: luma+chroma= 24 x 4
int16_t* pMbIndexX[MAX_DEPENDENCY_LAYER]; // [iDid][iMbX]: map for iMbX in each spatial layer coding
int16_t* pMbIndexY[MAX_DEPENDENCY_LAYER]; // [iDid][iMbY]: map for iMbY in each spatial layer coding
} SStrideTables;
typedef struct TagWelsEncCtx{
// Input
SWelsSvcCodingParam *pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h
SWelsSliceBs *pSliceBs; // bitstream buffering for various slices, [uiSliceIdx]
typedef struct TagWelsEncCtx {
// Input
SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h
SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx]
int32_t *pSadCostMb;
/* MVD cost tables for Inter MB */
uint16_t *pMvdCostTableInter; //[52]; // adaptive to spatial layers
SMVUnitXY *pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer
int8_t *pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer
int8_t *pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM];
int8_t *pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11)
SMB **ppMbListD; // [MAX_DEPENDENCY_LAYER];
SStrideTables *pStrideTab; // stride tables for internal coding used
SWelsFuncPtrList *pFuncList;
int32_t* pSadCostMb;
/* MVD cost tables for Inter MB */
uint16_t* pMvdCostTableInter; //[52]; // adaptive to spatial layers
SMVUnitXY*
pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer
int8_t*
pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer
int8_t* pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM];
int8_t*
pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11)
SMB** ppMbListD; // [MAX_DEPENDENCY_LAYER];
SStrideTables* pStrideTab; // stride tables for internal coding used
SWelsFuncPtrList* pFuncList;
#if defined(MT_ENABLED)
SSliceThreading *pSliceThreading;
SSliceThreading* pSliceThreading;
#endif//MT_ENABLED
// SSlice context
SSliceCtx *pSliceCtxList;// slice context table for each dependency quality layer
// pointers
SPicture *pEncPic; // pointer to current picture to be encoded
SPicture *pDecPic; // pointer to current picture being reconstructed
SPicture *pRefPic; // pointer to current reference picture
// SSlice context
SSliceCtx* pSliceCtxList;// slice context table for each dependency quality layer
// pointers
SPicture* pEncPic; // pointer to current picture to be encoded
SPicture* pDecPic; // pointer to current picture being reconstructed
SPicture* pRefPic; // pointer to current reference picture
SDqLayer *pCurDqLayer; // DQ layer context used to being encoded currently, for reference base layer to refer: pCurDqLayer->pRefLayer if applicable
SDqLayer **ppDqLayerList; // overall DQ layers encoded for storage
SDqLayer*
pCurDqLayer; // DQ layer context used to being encoded currently, for reference base layer to refer: pCurDqLayer->pRefLayer if applicable
SDqLayer** ppDqLayerList; // overall DQ layers encoded for storage
SRefList **ppRefPicListExt; // reference picture list for SVC
SPicture *pRefList0[16];
SLTRState *pLtr;//[MAX_DEPENDENCY_LAYER];
// Derived
int32_t iCodingIndex;
int32_t iFrameIndex; // count how many frames elapsed during coding context currently
uint32_t uiFrameIdxRc; //only for RC
int32_t iFrameNum; // current frame number coding
int32_t iPOC; // frame iPOC
EWelsSliceType eSliceType; // currently coding slice type
EWelsNalUnitType eNalType; // NAL type
EWelsNalRefIdc eNalPriority; // NAL_Reference_Idc currently
EWelsNalRefIdc eLastNalPriority; // NAL_Reference_Idc in last frame
uint8_t iNumRef0;
SRefList** ppRefPicListExt; // reference picture list for SVC
SPicture* pRefList0[16];
SLTRState* pLtr;//[MAX_DEPENDENCY_LAYER];
uint8_t uiDependencyId; // Idc of dependecy layer to be coded
uint8_t uiTemporalId; // Idc of temporal layer to be coded
bool_t bNeedPrefixNalFlag; // whether add prefix nal
bool_t bEncCurFrmAsIdrFlag;
// Derived
int32_t iCodingIndex;
int32_t iFrameIndex; // count how many frames elapsed during coding context currently
uint32_t uiFrameIdxRc; //only for RC
int32_t iFrameNum; // current frame number coding
int32_t iPOC; // frame iPOC
EWelsSliceType eSliceType; // currently coding slice type
EWelsNalUnitType eNalType; // NAL type
EWelsNalRefIdc eNalPriority; // NAL_Reference_Idc currently
EWelsNalRefIdc eLastNalPriority; // NAL_Reference_Idc in last frame
uint8_t iNumRef0;
// Rate control routine
SWelsSvcRc *pWelsSvcRc;
int32_t iSkipFrameFlag; //_GOM_RC_
int32_t iGlobalQp; // global qp
uint8_t uiDependencyId; // Idc of dependecy layer to be coded
uint8_t uiTemporalId; // Idc of temporal layer to be coded
bool_t bNeedPrefixNalFlag; // whether add prefix nal
bool_t bEncCurFrmAsIdrFlag;
// VAA
SVAAFrameInfo *pVaa; // VAA information of reference
CWelsPreProcess *pVpp;
// Rate control routine
SWelsSvcRc* pWelsSvcRc;
int32_t iSkipFrameFlag; //_GOM_RC_
int32_t iGlobalQp; // global qp
SWelsSPS *pSpsArray; // MAX_SPS_COUNT by standard compatible
SWelsSPS *pSps;
SWelsPPS *pPPSArray; // MAX_PPS_COUNT by standard compatible
SWelsPPS *pPps;
/* SVC only */
SSubsetSps *pSubsetArray; // MAX_SPS_COUNT by standard compatible
SSubsetSps *pSubsetSps;
int32_t iSpsNum; // number of pSps used
int32_t iPpsNum; // number of pPps used
// VAA
SVAAFrameInfo* pVaa; // VAA information of reference
CWelsPreProcess* pVpp;
// Output
SWelsEncoderOutput *pOut; // for NAL raw pData (need allocating memory for sNalList internal)
uint8_t *pFrameBs; // restoring bitstream pBuffer of all NALs in a frame
int32_t iFrameBsSize; // count size of frame bs in bytes allocated
int32_t iPosBsBuffer; // current writing position of frame bs pBuffer
/* For Downsampling & VAA I420 based source pictures */
SPicture *pSpatialPic[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL+1+LONG_TERM_REF_NUM]; // need memory requirement with total number of (log2(uiGopSize)+1+1+long_term_ref_num)
SWelsSPS* pSpsArray; // MAX_SPS_COUNT by standard compatible
SWelsSPS* pSps;
SWelsPPS* pPPSArray; // MAX_PPS_COUNT by standard compatible
SWelsPPS* pPps;
/* SVC only */
SSubsetSps* pSubsetArray; // MAX_SPS_COUNT by standard compatible
SSubsetSps* pSubsetSps;
int32_t iSpsNum; // number of pSps used
int32_t iPpsNum; // number of pPps used
SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER];
uint8_t uiSpatialLayersInTemporal[MAX_DEPENDENCY_LAYER];
// Output
SWelsEncoderOutput* pOut; // for NAL raw pData (need allocating memory for sNalList internal)
uint8_t* pFrameBs; // restoring bitstream pBuffer of all NALs in a frame
int32_t iFrameBsSize; // count size of frame bs in bytes allocated
int32_t iPosBsBuffer; // current writing position of frame bs pBuffer
uint8_t uiSpatialPicNum[MAX_DEPENDENCY_LAYER];
bool_t bLongTermRefFlag[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL+1/*+LONG_TERM_REF_NUM*/];
/* For Downsampling & VAA I420 based source pictures */
SPicture* pSpatialPic[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1 +
LONG_TERM_REF_NUM]; // need memory requirement with total number of (log2(uiGopSize)+1+1+long_term_ref_num)
int16_t iMaxSliceCount;// maximal count number of slices for all layers observation
int16_t iActiveThreadsNum; // number of threads active so far
/*
* DQ layer idc map for svc encoding, might be a better scheme than that of design before,
* can aware idc of referencing layer and that idc of successive layer to be coded
*/
/* SVC only */
SDqIdc *pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData
SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER];
uint8_t uiSpatialLayersInTemporal[MAX_DEPENDENCY_LAYER];
SParaSetOffset sPSOVector;
CMemoryAlign *pMemAlign;
uint8_t uiSpatialPicNum[MAX_DEPENDENCY_LAYER];
bool_t bLongTermRefFlag[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1/*+LONG_TERM_REF_NUM*/];
int16_t iMaxSliceCount;// maximal count number of slices for all layers observation
int16_t iActiveThreadsNum; // number of threads active so far
/*
* DQ layer idc map for svc encoding, might be a better scheme than that of design before,
* can aware idc of referencing layer and that idc of successive layer to be coded
*/
/* SVC only */
SDqIdc*
pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData
SParaSetOffset sPSOVector;
CMemoryAlign* pMemAlign;
#ifdef ENABLE_TRACE_FILE
FILE *pFileLog; // log file for wels encoder
uint32_t uiSizeLog; // size of log have been written in file
FILE* pFileLog; // log file for wels encoder
uint32_t uiSizeLog; // size of log have been written in file
#endif//ENABLE_TRACE_FILE
#if defined(STAT_OUTPUT)
// overall stat pData, refer to SStatData in stat.h, in case avc to use stat[0][0]
SStatData sStatData [ MAX_DEPENDENCY_LAYER ] [ MAX_QUALITY_LEVEL ];
SStatSliceInfo sPerInfo;
#if defined(STAT_OUTPUT)
// overall stat pData, refer to SStatData in stat.h, in case avc to use stat[0][0]
SStatData sStatData [ MAX_DEPENDENCY_LAYER ] [ MAX_QUALITY_LEVEL ];
SStatSliceInfo sPerInfo;
#endif//STAT_OUTPUT
}sWelsEncCtx/*, *PWelsEncCtx*/;
} sWelsEncCtx/*, *PWelsEncCtx*/;
}
#endif//sWelsEncCtx_H__

Some files were not shown because too many files have changed in this diff Show More