astyle all files

This commit is contained in:
huili2 2014-05-05 19:30:21 -07:00
parent 0c246861b7
commit 5ed24f216b
120 changed files with 3913 additions and 3832 deletions

View File

@ -75,7 +75,7 @@ class ISVCEncoder {
/*
* return: 0 - success; otherwise - failed;
*/
virtual int EXTAPI PauseFrame (const SSourcePicture* kpSrcPic,SFrameBSInfo* pBsInfo) = 0;
virtual int EXTAPI PauseFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0;
/*
* return: 0 - success; otherwise - failed;
@ -99,30 +99,30 @@ class ISVCDecoder {
virtual long EXTAPI Uninitialize() = 0;
virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* pSrc,
const int iSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight) = 0;
const int iSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight) = 0;
/*
* return: 0 - success; otherwise -failed;
*/
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* pSrc,
const int iSrcLen,
void** ppDst,
SBufferInfo* pDstInfo) = 0;
const int iSrcLen,
void** ppDst,
SBufferInfo* pDstInfo) = 0;
/*
* this API does not work for now!! This is for future use to support non-I420 color format output.
*/
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* pSrc,
const int iSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& iColorFormat) = 0;
const int iSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& iColorFormat) = 0;
/*************************************************************************
* OutDataFormat, Eos Flag, EC method, ...
@ -141,62 +141,62 @@ typedef struct ISVCEncoderVtbl ISVCEncoderVtbl;
typedef const ISVCEncoderVtbl* ISVCEncoder;
struct ISVCEncoderVtbl {
int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);
int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);
int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam);
int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam);
int (*Uninitialize) (ISVCEncoder*);
int (*Uninitialize) (ISVCEncoder*);
int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo);
int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo);
int (*PauseFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
int (*PauseFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR);
int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR);
int (*SetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
int (*GetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
int (*SetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
int (*GetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
};
typedef struct ISVCDecoderVtbl ISVCDecoderVtbl;
typedef const ISVCDecoderVtbl* ISVCDecoder;
struct ISVCDecoderVtbl {
long (*Initialize) (ISVCDecoder*, const SDecodingParam* pParam);
long (*Uninitialize) (ISVCDecoder*);
long (*Initialize) (ISVCDecoder*, const SDecodingParam* pParam);
long (*Uninitialize) (ISVCDecoder*);
DECODING_STATE (*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc,
DECODING_STATE (*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
unsigned char** ppDst,
int* pStride,
int* iWidth,
int* iHeight);
DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
void** ppDst,
SBufferInfo* pDstInfo);
DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
unsigned char** ppDst,
int* pStride,
unsigned char* pDst,
int iDstStride,
int* iDstLen,
int* iWidth,
int* iHeight);
int* iHeight,
int* iColorFormat);
DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
void** ppDst,
SBufferInfo* pDstInfo);
DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
unsigned char* pDst,
int iDstStride,
int* iDstLen,
int* iWidth,
int* iHeight,
int* iColorFormat);
long (*SetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
long (*GetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
long (*SetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
long (*GetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
};
#endif
int WelsCreateSVCEncoder (ISVCEncoder** ppEncoder);
void WelsDestroySVCEncoder (ISVCEncoder* pEncoder);
int WelsCreateSVCEncoder (ISVCEncoder** ppEncoder);
void WelsDestroySVCEncoder (ISVCEncoder* pEncoder);
long WelsCreateDecoder (ISVCDecoder** ppDecoder);
void WelsDestroyDecoder (ISVCDecoder* pDecoder);
long WelsCreateDecoder (ISVCDecoder** ppDecoder);
void WelsDestroyDecoder (ISVCDecoder* pDecoder);
#ifdef __cplusplus
}

View File

@ -130,11 +130,11 @@ typedef enum {
} LAYER_TYPE;
typedef enum {
SPATIAL_LAYER_0 = 0,
SPATIAL_LAYER_1 = 1,
SPATIAL_LAYER_2 = 2,
SPATIAL_LAYER_3 = 3,
SPATIAL_LAYER_ALL = 4,
SPATIAL_LAYER_0 = 0,
SPATIAL_LAYER_1 = 1,
SPATIAL_LAYER_2 = 2,
SPATIAL_LAYER_3 = 3,
SPATIAL_LAYER_ALL = 4,
} LAYER_NUM;
//enumerate the type of video bitstream which is provided to decoder
@ -167,11 +167,11 @@ typedef struct {
} SLTRMarkingFeedback;
typedef 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
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 enum {
SM_SINGLE_SLICE = 0, // | SliceNum==1
@ -203,7 +203,7 @@ typedef enum {
PRO_SCALABLE_BASELINE = 83,
PRO_SCALABLE_HIGH = 86,
}EProfileIdc;
} EProfileIdc;
typedef enum {
LEVEL_UNKNOWN,
@ -224,7 +224,7 @@ typedef enum {
LEVEL_5_0,
LEVEL_5_1,
LEVEL_5_2
}ELevelIdc;
} ELevelIdc;
typedef struct {
SliceModeEnum uiSliceMode; //by default, uiSliceMode will be SM_SINGLE_SLICE
@ -247,12 +247,13 @@ typedef struct {
typedef enum {
CAMERA_VIDEO_REAL_TIME, //camera video signal
SCREEN_CONTENT_REAL_TIME,//screen content signal
}EUsageType;
} EUsageType;
// TODO: Refine the parameters definition.
// SVC Encoding Parameters
typedef struct TagEncParamBase{
EUsageType iUsageType; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
typedef struct TagEncParamBase {
EUsageType
iUsageType; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
int iInputCsp; // color space of input sequence
int iPicWidth; // width of picture in samples
@ -264,9 +265,9 @@ typedef struct TagEncParamBase{
} SEncParamBase, *PEncParamBase;
typedef struct TagEncParamExt
{
EUsageType iUsageType; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
typedef struct TagEncParamExt {
EUsageType
iUsageType; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
int iInputCsp; // color space of input sequence
int iPicWidth; // width of picture in samples
@ -301,9 +302,10 @@ typedef struct TagEncParamExt
unsigned int iLtrMarkPeriod;
/* multi-thread settings*/
unsigned short iMultipleThreadIdc; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
unsigned short
iMultipleThreadIdc; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
/* Deblocking loop filter */
/* Deblocking loop filter */
int iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
int iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
int iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
@ -313,7 +315,7 @@ typedef struct TagEncParamExt
bool bEnableAdaptiveQuant; // adaptive quantization control
bool bEnableFrameCroppingFlag;// enable frame cropping flag: TRUE always in application
bool bEnableSceneChangeDetect;
}SEncParamExt;
} SEncParamExt;
//Define a new struct to show the property of video bitstream.
typedef struct {
@ -370,13 +372,13 @@ typedef struct Source_Picture_s {
long long uiTimeStamp;
} SSourcePicture;
typedef struct Bitrate_Info_s{
typedef struct Bitrate_Info_s {
LAYER_NUM iLayer;
int iBitrate; //the maximum bitrate
}SBitrateInfo;
} SBitrateInfo;
typedef struct Dump_Layer_s{
int iLayer;
char *pFileName;
}SDumpLayer;
typedef struct Dump_Layer_s {
int iLayer;
char* pFileName;
} SDumpLayer;
#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__

View File

@ -8,11 +8,11 @@ void DeblockLumaLt4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t
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);
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);
int8_t* pTc);
void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
#if defined(__cplusplus)
@ -28,24 +28,26 @@ void DeblockLumaLt4H_ssse3 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int
void DeblockLumaEq4H_ssse3 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaEq4V_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
int8_t* pTC);
void DeblockChromaEq4H_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
int8_t* pTC);
#endif
#if defined(HAVE_NEON)
void DeblockLumaLt4V_neon(uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4V_neon(uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockLumaLt4V_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4V_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockLumaLt4H_neon(uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4H_neon(uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockLumaLt4H_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4H_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_neon(uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTC);
void DeblockChromaEq4V_neon(uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
void DeblockChromaEq4V_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_neon(uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTC);
void DeblockChromaEq4H_neon(uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
void DeblockChromaEq4H_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
#endif
#if defined(__cplusplus)

View File

@ -62,12 +62,13 @@ void ExpandPictureChromaUnalign_sse2 (uint8_t* pDst,
#endif//X86_ASM
#if defined(HAVE_NEON)
void ExpandPictureLuma_neon(uint8_t *pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
void ExpandPictureChroma_neon(uint8_t *pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
void ExpandPictureLuma_neon (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
void ExpandPictureChroma_neon (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
#endif
#if defined(HAVE_NEON_AARCH64)
void ExpandPictureLuma_AArch64_neon(uint8_t *pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
void ExpandPictureChroma_AArch64_neon(uint8_t *pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
void ExpandPictureLuma_AArch64_neon (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH);
void ExpandPictureChroma_AArch64_neon (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW,
const int32_t kiPicH);
#endif
#if defined(__cplusplus)
}

View File

@ -55,12 +55,12 @@ struct tagUnaligned_16 {
#define STRUCTA(size, align) struct tagUnaligned_##size##_##align {\
uint##size##_t l; \
} __attribute__ ((aligned(align)))
STRUCTA(16,2);
STRUCTA(32,2);
STRUCTA(32,4);
STRUCTA(64,2);
STRUCTA(64,4);
STRUCTA(64,8);
STRUCTA (16, 2);
STRUCTA (32, 2);
STRUCTA (32, 4);
STRUCTA (64, 2);
STRUCTA (64, 4);
STRUCTA (64, 8);
//#define _USE_STRUCT_INT_CVT
// #ifdef _USE_STRUCT_INT_CVT
#define ST16(a, b) (((struct tagUnaligned_16 *) (a))->l) = (b)

View File

@ -132,41 +132,41 @@ __declspec(align(alignment)) type name[(sizex)*(sizey)]
}
static inline int32_t CeilLog2 (int32_t i) {
int32_t s = 0;
i--;
while (i > 0) {
s++;
i >>= 1;
}
return s;
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;
int32_t iMin = iX, iMax = iX;
if (iY < iMin)
iMin = iY;
else
iMax = iY;
if (iY < iMin)
iMin = iY;
else
iMax = iY;
if (iZ < iMin)
iMin = iZ;
else if (iZ > iMax)
iMax = iZ;
if (iZ < iMin)
iMin = iZ;
else if (iZ > iMax)
iMax = iZ;
return (iX + iY + iZ) - (iMin + iMax);
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;
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
@ -176,8 +176,8 @@ return iY;
#define NEG_NUM(iX) (1+(~(iX)))
#endif// NEG_NUM
static inline uint8_t WelsClip1(int32_t iX) {
uint8_t uiTmp = (uint8_t)(((iX) & ~255) ? (-(iX) >> 31) : (iX));
static inline uint8_t WelsClip1 (int32_t iX) {
uint8_t uiTmp = (uint8_t) (((iX) & ~255) ? (- (iX) >> 31) : (iX));
return uiTmp;
}
@ -233,11 +233,11 @@ static inline uint8_t WelsClip1(int32_t iX) {
#endif//#if WELS_VERIFY_RETURN_PROC_IF
static inline int32_t WELS_LOG2 (uint32_t v) {
int32_t r = 0;
while (v >>= 1) {
++r;
}
return r;
int32_t r = 0;
while (v >>= 1) {
++r;
}
return r;
}
@ -260,7 +260,7 @@ return r;
#endif//BUTTERFLY4x8
static inline bool WELS_POWER2_IF (uint32_t v) {
return (v && ! (v & (v - 1)));
return (v && ! (v & (v - 1)));
}
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)

View File

@ -175,13 +175,13 @@ WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_n
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
void* arg, WELS_THREAD_ATTR attr) {
#ifdef USE_THREADPOOL
HANDLE h = CreateEvent(NULL, FALSE, FALSE, NULL);
HANDLE h = CreateEvent (NULL, FALSE, FALSE, NULL);
HANDLE h2;
DuplicateHandle(GetCurrentProcess(), h, GetCurrentProcess(), &h2, 0, FALSE, DUPLICATE_SAME_ACCESS);
ThreadPool::RunAsync(ref new WorkItemHandler([=](IAsyncAction^) {
routine(arg);
SetEvent(h2);
CloseHandle(h2);
DuplicateHandle (GetCurrentProcess(), h, GetCurrentProcess(), &h2, 0, FALSE, DUPLICATE_SAME_ACCESS);
ThreadPool::RunAsync (ref new WorkItemHandler ([ = ] (IAsyncAction^) {
routine (arg);
SetEvent (h2);
CloseHandle (h2);
}, CallbackContext::Any), WorkItemPriority::Normal, WorkItemOptions::TimeSliced);
#else
WELS_THREAD_HANDLE h = CreateThread (NULL, 0, routine, arg, 0, NULL);
@ -265,15 +265,15 @@ WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_
return WELS_THREAD_ERROR_OK;
}
#else
WELS_EVENT event = (WELS_EVENT) malloc(sizeof(*event));
WELS_EVENT event = (WELS_EVENT) malloc (sizeof (*event));
if (event == NULL)
return WELS_THREAD_ERROR_GENERAL;
WELS_THREAD_ERROR_CODE err = sem_init(event, 0, 0);
WELS_THREAD_ERROR_CODE err = sem_init (event, 0, 0);
if (!err) {
*p_event = event;
return err;
}
free(event);
free (event);
return err;
#endif
}
@ -285,7 +285,7 @@ WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_n
return err;
#else
WELS_THREAD_ERROR_CODE err = sem_destroy (*event); // match with sem_init
free(*event);
free (*event);
return err;
#endif
}

View File

@ -96,7 +96,7 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uiCPU |= WELS_CPU_CMOV;
}
if ((!strcmp ((const char*)chVendorName, CPU_Vendor_INTEL)) ||
(!strcmp((const char*)chVendorName, CPU_Vendor_AMD)) ) { // confirmed_safe_unsafe_usage
(!strcmp ((const char*)chVendorName, CPU_Vendor_AMD))) { // confirmed_safe_unsafe_usage
if (uiFeatureD & 0x10000000) {
/* Multi-Threading checking: contains of multiple logic processors */
uiCPU |= WELS_CPU_HTT;
@ -136,18 +136,18 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uiCPU |= WELS_CPU_MOVBE;
}
if( pNumberOfLogicProcessors != NULL ){
if( uiCPU & WELS_CPU_HTT){
if (pNumberOfLogicProcessors != NULL) {
if (uiCPU & WELS_CPU_HTT) {
*pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
} else {
*pNumberOfLogicProcessors = 0;
}
if( !strcmp((const char*)chVendorName, CPU_Vendor_INTEL) ){
if( uiMaxCpuidLevel >= 4 ){
if (!strcmp ((const char*)chVendorName, CPU_Vendor_INTEL)) {
if (uiMaxCpuidLevel >= 4) {
uiFeatureC = 0;
WelsCPUId(0x4, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
if( uiFeatureA != 0 ){
*pNumberOfLogicProcessors = ((uiFeatureA&0xfc000000)>>26) + 1;
WelsCPUId (0x4, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
if (uiFeatureA != 0) {
*pNumberOfLogicProcessors = ((uiFeatureA & 0xfc000000) >> 26) + 1;
}
}
}
@ -209,26 +209,25 @@ void WelsCPURestore (const uint32_t kuiCPU) {
#elif defined(HAVE_NEON) //For supporting both android platform and iOS platform
#if defined(ANDROID_NDK)
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
{
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uint32_t uiCPU = 0;
AndroidCpuFamily cpuFamily = ANDROID_CPU_FAMILY_UNKNOWN;
uint64_t uiFeatures = 0;
cpuFamily = android_getCpuFamily();
if (cpuFamily == ANDROID_CPU_FAMILY_ARM) {
uiFeatures = android_getCpuFeatures();
if (uiFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7){
if (uiFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) {
uiCPU |= WELS_CPU_ARMv7;
}
if (uiFeatures & ANDROID_CPU_ARM_FEATURE_VFPv3){
if (uiFeatures & ANDROID_CPU_ARM_FEATURE_VFPv3) {
uiCPU |= WELS_CPU_VFPv3;
}
if (uiFeatures & ANDROID_CPU_ARM_FEATURE_NEON){
if (uiFeatures & ANDROID_CPU_ARM_FEATURE_NEON) {
uiCPU |= WELS_CPU_NEON;
}
}
if( pNumberOfLogicProcessors != NULL ){
if (pNumberOfLogicProcessors != NULL) {
*pNumberOfLogicProcessors = android_getCpuCount();
}
@ -236,38 +235,37 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
}
#elif defined(__APPLE__)
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
{
uint32_t uiCPU = 0;
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uint32_t uiCPU = 0;
#if defined(__ARM_NEON__)
uiCPU |= WELS_CPU_ARMv7;
uiCPU |= WELS_CPU_VFPv3;
uiCPU |= WELS_CPU_NEON;
uiCPU |= WELS_CPU_ARMv7;
uiCPU |= WELS_CPU_VFPv3;
uiCPU |= WELS_CPU_NEON;
#endif
return uiCPU;
return uiCPU;
}
#elif defined(__linux__)
/* Generic arm/linux cpu feature detection */
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
FILE *f = fopen("/proc/cpuinfo", "r");
FILE* f = fopen ("/proc/cpuinfo", "r");
if (!f)
return 0;
char buf[200];
int flags = 0;
while (fgets(buf, sizeof(buf), f)) {
if (!strncmp(buf, "Features", strlen("Features"))) {
if (strstr(buf, " neon "))
while (fgets (buf, sizeof (buf), f)) {
if (!strncmp (buf, "Features", strlen ("Features"))) {
if (strstr (buf, " neon "))
flags |= WELS_CPU_NEON;
if (strstr(buf, " vfpv3 "))
if (strstr (buf, " vfpv3 "))
flags |= WELS_CPU_VFPv3;
break;
}
}
fclose(f);
fclose (f);
return flags;
}

View File

@ -114,7 +114,7 @@ int32_t WelsStrftime (char* pBuffer, int32_t iSize, const char* kpFormat, const
iRc = strftime (pBuffer, iSize, kpFormat, &sTimeNow);
if (iRc == 0)
pBuffer[0] = '\0';
pBuffer[0] = '\0';
return iRc;
}
@ -175,7 +175,7 @@ int32_t WelsStrftime (char* pBuffer, int32_t iSize, const char* kpFormat, const
iRc = strftime (pBuffer, iSize, kpFormat, pTnow);
if (iRc == 0)
pBuffer[0] = '\0';
pBuffer[0] = '\0';
return iRc;
}
@ -236,7 +236,7 @@ int32_t WelsStrftime (char* pBuffer, int32_t iSize, const char* kpFormat, const
iRc = strftime (pBuffer, iSize, kpFormat, pTnow);
if (iRc == 0)
pBuffer[0] = '\0';
pBuffer[0] = '\0';
return iRc;
}
@ -244,8 +244,8 @@ int32_t WelsStrftime (char* pBuffer, int32_t iSize, const char* kpFormat, const
char* WelsStrcat (char* pDest, int32_t iSizeInBytes, const char* kpSrc) {
int32_t iCurLen = strlen(pDest);
return WelsStrncpy(pDest + iCurLen, iSizeInBytes - iCurLen, kpSrc);
int32_t iCurLen = strlen (pDest);
return WelsStrncpy (pDest + iCurLen, iSizeInBytes - iCurLen, kpSrc);
}
int32_t WelsFwrite (const void* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
@ -257,7 +257,7 @@ uint16_t WelsGetMillisecond (const SWelsTime* kpTp) {
}
int32_t WelsFseek (WelsFileHandle* fp, int32_t offset, int32_t origin) {
return fseek(fp, offset, origin);
return fseek (fp, offset, origin);
}
int32_t WelsFflush (WelsFileHandle* pFp) {

View File

@ -2,7 +2,7 @@
#include "macros.h"
// C code only
void DeblockLumaLt4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta,
int8_t* pTc) {
int8_t* pTc) {
for (int32_t i = 0; i < 16; i++) {
int32_t iTc0 = pTc[i >> 2];
if (iTc0 >= 0) {
@ -90,7 +90,7 @@ void DeblockLumaEq4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t
DeblockLumaEq4_c (pPix, 1, iStride, iAlpha, 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) {
int32_t iBeta, int8_t* pTc) {
int32_t p0, p1, q0, q1, iDeta;
bool bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
@ -132,7 +132,7 @@ void DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int
}
}
void DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
int32_t iBeta) {
int32_t iBeta) {
int32_t p0, p1, q0, q1;
bool bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
for (int32_t i = 0; i < 8; i++) {
@ -166,11 +166,11 @@ void DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int
}
}
void DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* tc) {
int8_t* tc) {
DeblockChromaLt4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, tc);
}
void DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* tc) {
int8_t* tc) {
DeblockChromaLt4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, tc);
}
void DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {

View File

@ -107,33 +107,33 @@ int32_t WelsSampleSad16x16_c (uint8_t* pSample1, int32_t iStride1, uint8_t* pSam
void WelsSampleSadFour16x16_c (uint8_t* iSample1, int32_t iStride1, uint8_t* iSample2, int32_t iStride2,
int32_t* pSad) {
* (pSad) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 + 1), iStride2);
* (pSad) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad16x16_c (iSample1, iStride1, (iSample2 + 1), iStride2);
}
void WelsSampleSadFour16x8_c (uint8_t* iSample1, int32_t iStride1, uint8_t* iSample2, int32_t iStride2, int32_t* pSad) {
* (pSad) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 + 1), iStride2);
* (pSad) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad16x8_c (iSample1, iStride1, (iSample2 + 1), iStride2);
}
void WelsSampleSadFour8x16_c (uint8_t* iSample1, int32_t iStride1, uint8_t* iSample2, int32_t iStride2, int32_t* pSad) {
* (pSad) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 + 1), iStride2);
* (pSad) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad8x16_c (iSample1, iStride1, (iSample2 + 1), iStride2);
}
void WelsSampleSadFour8x8_c (uint8_t* iSample1, int32_t iStride1, uint8_t* iSample2, int32_t iStride2, int32_t* pSad) {
* (pSad) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 + 1), iStride2);
* (pSad) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad8x8_c (iSample1, iStride1, (iSample2 + 1), iStride2);
}
void WelsSampleSadFour4x4_c (uint8_t* iSample1, int32_t iStride1, uint8_t* iSample2, int32_t iStride2, int32_t* pSad) {
* (pSad) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 + 1), iStride2);
* (pSad) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 - iStride2), iStride2);
* (pSad + 1) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 + iStride2), iStride2);
* (pSad + 2) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 - 1), iStride2);
* (pSad + 3) = WelsSampleSad4x4_c (iSample1, iStride1, (iSample2 + 1), iStride2);
}

View File

@ -147,10 +147,10 @@ HRESULT CD3D9Utils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
HRESULT CD3D9Utils::Render (void* pDst[3], SBufferInfo* pInfo) {
HRESULT hResult = E_FAIL;
hResult = InitResource (NULL, pInfo);
if (SUCCEEDED (hResult))
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
hResult = InitResource (NULL, pInfo);
if (SUCCEEDED (hResult))
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
if (SUCCEEDED (hResult)) {
IDirect3DSurface9* pBackBuffer = NULL;
@ -218,10 +218,10 @@ HRESULT CD3D9Utils::InitResource (void* pSharedHandle, SBufferInfo* pInfo) {
m_d3dpp.hDeviceWindow = m_hWnd;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
hResult = m_lpD3D9->CreateDevice (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, &m_lpD3D9Device);
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
D3Dformat = (D3DFORMAT)NV12_FORMAT;
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
D3Dformat = (D3DFORMAT)NV12_FORMAT;
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface (iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool,
&m_lpD3D9RawSurfaceShare, NULL);
@ -316,10 +316,10 @@ HRESULT CD3D9ExUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
HRESULT CD3D9ExUtils::Render (void* pDst[3], SBufferInfo* pInfo) {
HRESULT hResult = E_FAIL;
hResult = InitResource (NULL, pInfo);
if (SUCCEEDED (hResult))
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
hResult = InitResource (NULL, pInfo);
if (SUCCEEDED (hResult))
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
if (SUCCEEDED (hResult)) {
IDirect3DSurface9* pBackBuffer = NULL;
@ -337,10 +337,10 @@ HRESULT CD3D9ExUtils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
int iWidth;
int iHeight;
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1];
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1];
if (pDst[0] && pDst[1] && pDst[2])
Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight);
@ -386,10 +386,10 @@ HRESULT CD3D9ExUtils::InitResource (void* pSharedHandle, SBufferInfo* pInfo) {
m_d3dpp.hDeviceWindow = m_hWnd;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
hResult = m_lpD3D9->CreateDeviceEx (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, NULL, &m_lpD3D9Device);
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
D3Dformat = (D3DFORMAT)NV12_FORMAT;
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
D3Dformat = (D3DFORMAT)NV12_FORMAT;
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface (iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool,
&m_lpD3D9RawSurfaceShare, &pSharedHandle);
}

View File

@ -104,15 +104,14 @@ static void SigIntHandler (int a) {
}
static int g_LevelSetting = 0;
int ParseLayerConfig( CReadConfig & cRdLayerCfg, const int iLayer, SEncParamExt& pSvcParam,SFilesSet& sFileSet)
{
int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt& pSvcParam, SFilesSet& sFileSet) {
if (!cRdLayerCfg.ExistFile()) {
fprintf (stderr, "Unabled to open layer #%d configuration file: %s.\n", iLayer, cRdLayerCfg.GetFileName().c_str());
return 1;
}
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
int iLeftTargetBitrate = (pSvcParam.iRCMode!=RC_OFF_MODE)?pSvcParam.iTargetBitrate:0;
int iLeftTargetBitrate = (pSvcParam.iRCMode != RC_OFF_MODE) ? pSvcParam.iTargetBitrate : 0;
SLayerPEncCtx sLayerCtx;
memset (&sLayerCtx, 0, sizeof (SLayerPEncCtx));
@ -131,9 +130,9 @@ int ParseLayerConfig( CReadConfig & cRdLayerCfg, const int iLayer, SEncParamExt&
pDLayer->iVideoHeight = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("FrameRateOut") == 0) {
pDLayer->fFrameRate = (float)atof (strTag[1].c_str());
}else if (strTag[0].compare ("ReconFile") == 0) {
} else if (strTag[0].compare ("ReconFile") == 0) {
const unsigned int kiLen = strTag[1].length();
if (kiLen >= sizeof(sFileSet.sRecFileName[iLayer]))
if (kiLen >= sizeof (sFileSet.sRecFileName[iLayer]))
return -1;
sFileSet.sRecFileName[iLayer][kiLen] = '\0';
strncpy (sFileSet.sRecFileName[iLayer], strTag[1].c_str(), kiLen); // confirmed_safe_unsafe_usage
@ -143,14 +142,14 @@ int ParseLayerConfig( CReadConfig & cRdLayerCfg, const int iLayer, SEncParamExt&
// pDLayer->frext_mode = (bool)atoi(strTag[1].c_str());
} else if (strTag[0].compare ("SpatialBitrate") == 0) {
pDLayer->iSpatialBitrate = 1000 * atoi (strTag[1].c_str());
if (pSvcParam.iRCMode!=RC_OFF_MODE) {
if (pSvcParam.iRCMode != RC_OFF_MODE) {
if (pDLayer->iSpatialBitrate <= 0) {
fprintf (stderr, "Invalid spatial bitrate(%d) in dependency layer #%d.\n", pDLayer->iSpatialBitrate, iLayer);
return -1;
}
if (pDLayer->iSpatialBitrate > iLeftTargetBitrate) {
fprintf (stderr, "Invalid spatial(#%d) bitrate(%d) setting due to unavailable left(%d)!\n", iLayer,
pDLayer->iSpatialBitrate, iLeftTargetBitrate);
pDLayer->iSpatialBitrate, iLeftTargetBitrate);
return -1;
}
iLeftTargetBitrate -= pDLayer->iSpatialBitrate;
@ -177,7 +176,7 @@ int ParseLayerConfig( CReadConfig & cRdLayerCfg, const int iLayer, SEncParamExt&
memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage
memcpy (&pDLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[0],
sizeof (sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
sizeof (sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
return 0;
}
@ -194,14 +193,14 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
if (strTag[0].empty())
continue;
if(strTag[0].compare ("UsageType") == 0){
if (strTag[0].compare ("UsageType") == 0) {
pSvcParam.iUsageType = (EUsageType)atoi (strTag[1].c_str());
}else if (strTag[0].compare ("SourceWidth") == 0) {
} else if (strTag[0].compare ("SourceWidth") == 0) {
pSrcPic->iPicWidth = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("SourceHeight") == 0) {
pSrcPic->iPicHeight = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("InputFile") == 0) {
if (strTag[1].length() > 0)
if (strTag[1].length() > 0)
sFileSet.strSeqFile = strTag[1];
} else if (strTag[0].compare ("OutputFile") == 0) {
sFileSet.strBsFile = strTag[1];
@ -249,7 +248,7 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
pSvcParam.iRCMode = (RC_MODES) atoi (strTag[1].c_str());
} else if (strTag[0].compare ("TargetBitrate") == 0) {
pSvcParam.iTargetBitrate = 1000 * atoi (strTag[1].c_str());
if ((pSvcParam.iRCMode!=RC_OFF_MODE) && pSvcParam.iTargetBitrate <= 0) {
if ((pSvcParam.iRCMode != RC_OFF_MODE) && pSvcParam.iTargetBitrate <= 0) {
fprintf (stderr, "Invalid target bitrate setting due to RC enabled. Check TargetBitrate field please!\n");
return 1;
}
@ -302,8 +301,7 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
for (int8_t iLayer = 0; iLayer < kiActualLayerNum; ++ iLayer) {
CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]);
if (-1==ParseLayerConfig( cRdLayerCfg, iLayer, pSvcParam,sFileSet ))
{
if (-1 == ParseLayerConfig (cRdLayerCfg, iLayer, pSvcParam, sFileSet)) {
iRet = 1;
break;
}
@ -346,7 +344,7 @@ int ParseCommandLine (int argc, char** argv, SEncParamExt& sParam) {
else if (!strcmp (pCmd, "-ltr") && (i < argc))
sParam.bEnableLongTermReference = atoi (argv[i++]) ? true : false;
else if (!strcmp (pCmd, "-ltrnum") && (i< argc))
else if (!strcmp (pCmd, "-ltrnum") && (i < argc))
sParam.iLTRRefNum = atoi (argv[i++]);
else if (!strcmp (pCmd, "-ltrper") && (i < argc))
@ -472,7 +470,7 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
pSvcParam.iLtrMarkPeriod = atoi (argv[n++]);
else if (!strcmp (pCommand, "-rc") && (n < argc))
pSvcParam.iRCMode = static_cast<RC_MODES>(atoi(argv[n++]));
pSvcParam.iRCMode = static_cast<RC_MODES> (atoi (argv[n++]));
else if (!strcmp (pCommand, "-trace") && (n < argc))
g_LevelSetting = atoi (argv[n++]);
@ -489,21 +487,18 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
for (int8_t iLayer = 0; iLayer < pSvcParam.iSpatialLayerNum; ++ iLayer) {
CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]);
if (-1==ParseLayerConfig( cRdLayerCfg, iLayer, pSvcParam,sFileSet ))
{
if (-1 == ParseLayerConfig (cRdLayerCfg, iLayer, pSvcParam, sFileSet)) {
return 1;
}
}
}
else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) {
} else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) {
unsigned int iLayer = atoi (argv[n++]);
const unsigned int iLen = strlen (argv[n]);
if (iLen >= sizeof(sFileSet.sRecFileName[iLayer]))
if (iLen >= sizeof (sFileSet.sRecFileName[iLayer]))
return 1;
sFileSet.sRecFileName[iLayer][iLen] = '\0';
strncpy (sFileSet.sRecFileName[iLayer], argv[n++], iLen); // confirmed_safe_unsafe_usage
}
else if (!strcmp (pCommand, "-dw") && (n + 1 < argc)) {
} else if (!strcmp (pCommand, "-dw") && (n + 1 < argc)) {
unsigned int iLayer = atoi (argv[n++]);
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
pDLayer->iVideoWidth = atoi (argv[n++]);
@ -515,10 +510,10 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
pDLayer->iVideoHeight = atoi (argv[n++]);
}
else if (!strcmp (pCommand, "-frout") && (n + 1 < argc)) {
else if (!strcmp (pCommand, "-frout") && (n + 1 < argc)) {
unsigned int iLayer = atoi (argv[n++]);
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
pDLayer->fFrameRate = (float)atof (argv[n++]);
pDLayer->fFrameRate = (float)atof (argv[n++]);
}
else if (!strcmp (pCommand, "-lqp") && (n + 1 < argc)) {
@ -687,12 +682,12 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
ret = 1;
goto ERROR_RET;
}
pPtrEnc->SetOption(ENCODER_OPTION_TRACE_LEVEL,&g_LevelSetting);
pPtrEnc->SetOption (ENCODER_OPTION_TRACE_LEVEL, &g_LevelSetting);
if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) {
fprintf (stderr, "Encoder Initialization failed!\n");
ret = 1;
ret = 1;
goto ERROR_RET;
}
}
iPicLumaSize = sSvcParam.iPicWidth * sSvcParam.iPicHeight;
switch (sSvcParam.iInputCsp) {
int iStride;
@ -731,19 +726,19 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
pSrcPic = new SSourcePicture;
if (pSrcPic == NULL) {
ret = 1;
goto ERROR_RET;
}
ret = 1;
goto ERROR_RET;
}
pSrcPic->iColorFormat = sSvcParam.iInputCsp;
pSrcPic->iPicHeight = sSvcParam.iPicHeight;
pSrcPic->iPicWidth = sSvcParam.iPicWidth;
pSrcPic->iStride[0] = sSvcParam.iPicWidth;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = sSvcParam.iPicWidth>>1;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = sSvcParam.iPicWidth >> 1;
pSrcPic->pData[0] = pPlanes[0];
pSrcPic->pData[1] = pSrcPic->pData[0] + (sSvcParam.iPicWidth*sSvcParam.iPicHeight);
pSrcPic->pData[2] = pSrcPic->pData[1] + (sSvcParam.iPicWidth*sSvcParam.iPicHeight>>2);
pSrcPic->pData[1] = pSrcPic->pData[0] + (sSvcParam.iPicWidth * sSvcParam.iPicHeight);
pSrcPic->pData[2] = pSrcPic->pData[1] + (sSvcParam.iPicWidth * sSvcParam.iPicHeight >> 2);
while (true) {
if (feof (pFpSrc))
@ -801,9 +796,9 @@ ERROR_RET:
fclose (pFpSrc);
pFpSrc = NULL;
}
if(pSrcPic){
delete pSrcPic;
pSrcPic = NULL;
if (pSrcPic) {
delete pSrcPic;
pSrcPic = NULL;
}
return ret;
}
@ -824,7 +819,7 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
int32_t iActualFrameEncodedCount = 0;
int32_t iFrameIdx = 0;
int32_t iTotalFrameMax = -1;
uint8_t* pYUV= NULL;
uint8_t* pYUV = NULL;
SSourcePicture* pSrcPic = NULL;
uint32_t iSourceWidth, iSourceHeight, kiPicResSize;
// Inactive with sink with output file handler
@ -843,7 +838,7 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
memset (&sFbi, 0, sizeof (SFrameBSInfo));
memset (&sSvcParam, 0, sizeof (SEncParamExt));
memset (&fs.sRecFileName[0][0],0,sizeof(fs.sRecFileName));
memset (&fs.sRecFileName[0][0], 0, sizeof (fs.sRecFileName));
sSvcParam.iInputCsp = videoFormatI420; // I420 in default
sSvcParam.sSpatialLayers[0].uiProfileIdc = PRO_BASELINE;
// svc_cfg->sDependencyLayers[0].frext_mode = 0;
@ -859,9 +854,9 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
pSrcPic = new SSourcePicture;
if (pSrcPic == NULL) {
iRet = 1;
goto INSIDE_MEM_FREE;
}
iRet = 1;
goto INSIDE_MEM_FREE;
}
//fill default pSrcPic
pSrcPic->iColorFormat = videoFormatI420;
pSrcPic->uiTimeStamp = 0;
@ -881,31 +876,31 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
//finish reading the configurations
iSourceWidth = pSrcPic->iPicWidth;
iSourceHeight = pSrcPic->iPicHeight;
kiPicResSize = iSourceWidth * iSourceHeight*3>>1;
kiPicResSize = iSourceWidth * iSourceHeight * 3 >> 1;
pYUV = new uint8_t [kiPicResSize];
if (pYUV == NULL) {
iRet = 1;
goto INSIDE_MEM_FREE;
}
iRet = 1;
goto INSIDE_MEM_FREE;
}
//update pSrcPic
pSrcPic->iStride[0] = iSourceWidth;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = pSrcPic->iStride[0]>>1;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = pSrcPic->iStride[0] >> 1;
pSrcPic->pData[0] = pYUV;
pSrcPic->pData[1] = pSrcPic->pData[0] + (iSourceWidth*iSourceHeight);
pSrcPic->pData[2] = pSrcPic->pData[1] + (iSourceWidth*iSourceHeight>>2);
pSrcPic->pData[1] = pSrcPic->pData[0] + (iSourceWidth * iSourceHeight);
pSrcPic->pData[2] = pSrcPic->pData[1] + (iSourceWidth * iSourceHeight >> 2);
//update sSvcParam
for (int iLayer=0; iLayer<sSvcParam.iSpatialLayerNum; iLayer++) {
for (int iLayer = 0; iLayer < sSvcParam.iSpatialLayerNum; iLayer++) {
SSpatialLayerConfig* pDLayer = &sSvcParam.sSpatialLayers[iLayer];
sSvcParam.iPicWidth = WELS_MAX(sSvcParam.iPicWidth, pDLayer->iVideoWidth);
sSvcParam.iPicHeight = WELS_MAX(sSvcParam.iPicHeight, pDLayer->iVideoHeight);
sSvcParam.iPicWidth = WELS_MAX (sSvcParam.iPicWidth, pDLayer->iVideoWidth);
sSvcParam.iPicHeight = WELS_MAX (sSvcParam.iPicHeight, pDLayer->iVideoHeight);
}
//if target output resolution is not set, use the source size
sSvcParam.iPicWidth = (!sSvcParam.iPicWidth)?iSourceWidth:sSvcParam.iPicWidth;
sSvcParam.iPicHeight = (!sSvcParam.iPicHeight)?iSourceHeight:sSvcParam.iPicHeight;
sSvcParam.iPicWidth = (!sSvcParam.iPicWidth) ? iSourceWidth : sSvcParam.iPicWidth;
sSvcParam.iPicHeight = (!sSvcParam.iPicHeight) ? iSourceHeight : sSvcParam.iPicHeight;
iTotalFrameMax = (int32_t)sSvcParam.uiFrameToBeCoded;
@ -914,12 +909,12 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
iRet = 1;
goto INSIDE_MEM_FREE;
}
for(int iLayer = 0;iLayer<MAX_DEPENDENCY_LAYER;iLayer++){
if(fs.sRecFileName[iLayer][0]!=0){
for (int iLayer = 0; iLayer < MAX_DEPENDENCY_LAYER; iLayer++) {
if (fs.sRecFileName[iLayer][0] != 0) {
SDumpLayer sDumpLayer;
sDumpLayer.iLayer = iLayer;
sDumpLayer.pFileName = fs.sRecFileName[iLayer];
if(cmResultSuccess!=pPtrEnc->SetOption(ENCODER_OPTION_DUMP_FILE,&sDumpLayer)){
if (cmResultSuccess != pPtrEnc->SetOption (ENCODER_OPTION_DUMP_FILE, &sDumpLayer)) {
fprintf (stderr, "SetOption ENCODER_OPTION_DUMP_FILE failed!\n");
iRet = 1;
goto INSIDE_MEM_FREE;
@ -946,18 +941,18 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
#endif
pFileYUV = fopen (fs.strSeqFile.c_str(), "rb");
if (pFileYUV != NULL) {
if (!fseek (pFileYUV, 0, SEEK_END)) {
int64_t i_size = ftell (pFileYUV);
fseek (pFileYUV, 0, SEEK_SET);
iTotalFrameMax = WELS_MAX ((int32_t) (i_size / kiPicResSize), iTotalFrameMax);
}
} else {
fprintf (stderr, "Unable to open source sequence file (%s), check corresponding path!\n",
fs.strSeqFile.c_str());
iRet = 1;
goto INSIDE_MEM_FREE;
if (pFileYUV != NULL) {
if (!fseek (pFileYUV, 0, SEEK_END)) {
int64_t i_size = ftell (pFileYUV);
fseek (pFileYUV, 0, SEEK_SET);
iTotalFrameMax = WELS_MAX ((int32_t) (i_size / kiPicResSize), iTotalFrameMax);
}
} else {
fprintf (stderr, "Unable to open source sequence file (%s), check corresponding path!\n",
fs.strSeqFile.c_str());
iRet = 1;
goto INSIDE_MEM_FREE;
}
iFrameIdx = 0;
while (iFrameIdx < iTotalFrameMax && (((int32_t)sSvcParam.uiFrameToBeCoded <= 0)
@ -969,12 +964,12 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
break;
}
#endif//ONLY_ENC_FRAMES_NUM
bool bCanBeRead = false;
bCanBeRead = (fread (pYUV, 1, kiPicResSize, pFileYUV) == kiPicResSize);
bool bCanBeRead = false;
bCanBeRead = (fread (pYUV, 1, kiPicResSize, pFileYUV) == kiPicResSize);
if (!bCanBeRead)
break;
// To encoder this frame
if (!bCanBeRead)
break;
// To encoder this frame
iStart = WelsTime();
int iEncFrames = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
iTotal += WelsTime() - iStart;
@ -1036,39 +1031,39 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
if (iActualFrameEncodedCount > 0) {
double dElapsed = iTotal / 1e6;
printf ("Width: %d\nHeight: %d\nFrames: %d\nencode time: %f sec\nFPS: %f fps\n",
sSvcParam.iPicWidth, sSvcParam.iPicHeight,
sSvcParam.iPicWidth, sSvcParam.iPicHeight,
iActualFrameEncodedCount, dElapsed, (iActualFrameEncodedCount * 1.0) / dElapsed);
}
INSIDE_MEM_FREE:
if (pFpBs) {
fclose (pFpBs);
pFpBs = NULL;
}
if (pFpBs) {
fclose (pFpBs);
pFpBs = NULL;
}
#if defined (STICK_STREAM_SIZE)
if (fTrackStream) {
fclose (fTrackStream);
fTrackStream = NULL;
}
if (fTrackStream) {
fclose (fTrackStream);
fTrackStream = NULL;
}
#endif
#if defined (COMPARE_DATA)
if (fpGolden) {
fclose (fpGolden);
fpGolden = NULL;
}
if (fpGolden) {
fclose (fpGolden);
fpGolden = NULL;
}
#endif
// Destruction memory introduced in this routine
if (pFileYUV!= NULL) {
fclose (pFileYUV);
pFileYUV = NULL;
}
if (pYUV) {
delete pYUV;
pYUV = NULL;
}
if(pSrcPic){
delete pSrcPic;
pSrcPic = NULL;
}
// Destruction memory introduced in this routine
if (pFileYUV != NULL) {
fclose (pFileYUV);
pFileYUV = NULL;
}
if (pYUV) {
delete pYUV;
pYUV = NULL;
}
if (pSrcPic) {
delete pSrcPic;
pSrcPic = NULL;
}
return iRet;
}
@ -1114,7 +1109,7 @@ void DestroySVCEncHandle (ISVCEncoder* pEncoder) {
* main:
****************************************************************************/
#if defined(ANDROID_NDK) || defined(APPLE_IOS)
extern "C" int EncMain(int argc, char **argv)
extern "C" int EncMain (int argc, char** argv)
#else
int main (int argc, char** argv)
#endif

View File

@ -92,7 +92,8 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi
int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs);
bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps);
bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PNalUnit kpLastNal,
const PSps kpSps);
bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader);
/*!

View File

@ -42,14 +42,14 @@ 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]),
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;

View File

@ -51,7 +51,7 @@ void IdctResAddPred_mmx (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
#endif//X86_ASM
#if defined(HAVE_NEON)
void IdctResAddPred_neon(uint8_t *pred, const int32_t stride, int16_t *rs);
void IdctResAddPred_neon (uint8_t* pred, const int32_t stride, int16_t* rs);
#endif
#if defined(__cplusplus)

View File

@ -64,7 +64,7 @@ extern "C" {
#endif//__cplusplus
#if defined(HAVE_NEON)
void SetNonZeroCount_neon(int16_t* pBlock, int8_t* pNonZeroCount);
void SetNonZeroCount_neon (int16_t* pBlock, int8_t* pNonZeroCount);
#endif
#ifdef __cplusplus

View File

@ -78,7 +78,7 @@ typedef struct TagDataBuffer {
typedef void (*PGetIntraPredFunc) (uint8_t* pPred, const int32_t kiLumaStride);
typedef void (*PIdctResAddPredFunc) (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
const int32_t kiPicHeight);
const int32_t kiPicHeight);
/**/
typedef struct TagRefPic {
@ -92,7 +92,7 @@ typedef struct TagRefPic {
} SRefPic, *PRefPic;
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
typedef struct TagMcFunc {
PWelsMcFunc pMcLumaFunc;
PWelsMcFunc pMcChromaFunc;
@ -120,7 +120,7 @@ typedef struct tagDeblockingFilter {
typedef void (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag);
typedef void (*PLumaDeblockingLT4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* iTc);
int8_t* iTc);
typedef void (*PLumaDeblockingEQ4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
typedef void (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
int32_t iBeta, int8_t* iTc);
@ -330,8 +330,8 @@ typedef struct TagWelsDecoderContext {
} SWelsDecoderContext, *PWelsDecoderContext;
static inline void ResetActiveSPSForEachLayer(PWelsDecoderContext pCtx) {
for(int i = 0; i < MAX_LAYER_NUM; i++) {
static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
pCtx->pActiveLayerSps[i] = NULL;
}
}

View File

@ -48,7 +48,7 @@
namespace WelsDec {
void ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpandPictureLuma,
PExpandPictureFunc pExpandPictureChroma[2]);
PExpandPictureFunc pExpandPictureChroma[2]);
void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCpuFlags);

View File

@ -54,12 +54,12 @@ namespace WelsDec {
* \brief Wels Flexible Macroblock Ordering (FMO)
*/
typedef struct TagFmo {
uint8_t* pMbAllocMap;
int32_t iCountMbNum;
int32_t iSliceGroupCount;
int32_t iSliceGroupType;
bool bActiveFlag;
uint8_t uiReserved[3]; // reserved padding bytes
uint8_t* pMbAllocMap;
int32_t iCountMbNum;
int32_t iSliceGroupCount;
int32_t iSliceGroupType;
bool bActiveFlag;
uint8_t uiReserved[3]; // reserved padding bytes
} SFmo, *PFmo;

View File

@ -98,7 +98,7 @@ void WelsDecoderIChromaPredDcNA_mmx (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredH_sse2(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredH_sse2 (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredDDR_mmx (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredHD_mmx (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredHU_mmx (uint8_t* pPred, const int32_t kiStride);
@ -108,24 +108,24 @@ void WelsDecoderI4x4LumaPredVL_mmx (uint8_t* pPred, const int32_t kiStride);
#endif//X86_ASM
#if defined(HAVE_NEON)
void WelsDecoderI16x16LumaPredV_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredH_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredDc_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredPlane_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredV_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredH_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredDc_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI16x16LumaPredPlane_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredV_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredH_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredDDL_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredDDR_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredVL_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredVR_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredHU_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredHD_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredV_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredH_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredDDL_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredDDR_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredVL_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredVR_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredHU_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderI4x4LumaPredHD_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderIChromaPredV_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderIChromaPredH_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderIChromaPredDc_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderIChromaPredPlane_neon(uint8_t *pPred, const int32_t kiStride);
void WelsDecoderIChromaPredV_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderIChromaPredH_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderIChromaPredDc_neon (uint8_t* pPred, const int32_t kiStride);
void WelsDecoderIChromaPredPlane_neon (uint8_t* pPred, const int32_t kiStride);
#endif//HAVE_NEON
#if defined(__cplusplus)

View File

@ -65,15 +65,15 @@ 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
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;
int32_t iLeftType;
int32_t iTopType;
int32_t iLeftTopType;
int32_t iRightTopType;
} SNeighAvail, *PNeighAvail;
} // namespace WelsDec

View File

@ -41,7 +41,7 @@
namespace WelsDec {
typedef void (*PMcChromaWidthExtFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
const uint8_t* kpABCD, int32_t iHeight);
const uint8_t* kpABCD, int32_t iHeight);
void InitMcFunc (SMcFunc* pMcFunc, int32_t iCpu);

View File

@ -58,8 +58,8 @@ void UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2])
* \param
*/
void 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]);
int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
/*!
@ -68,8 +68,8 @@ void UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][
* \param
*/
void 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]);
int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
/*!
* \brief get the motion predictor for skip mode
@ -84,7 +84,7 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]);
* \param output iMvp[]
*/
void 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]);
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]);
/*!
* \brief get the motion predictor for inter16x8 MB
@ -92,7 +92,7 @@ void PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][3
* \param output mvp_x and mvp_y
*/
void 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]);
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]);
/*!
* \brief get the motion predictor for inter8x16 MB
@ -100,7 +100,7 @@ void PredInter16x8Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[
* \param output mvp_x and mvp_y
*/
void 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]);
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]);
} // namespace WelsDec

View File

@ -45,18 +45,18 @@ namespace WelsDec {
/* NAL Unit Structure */
typedef struct TagNalUnit {
SNalUnitHeaderExt sNalHeaderExt;
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 bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
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 bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
} SNalUnit, *PNalUnit;
@ -64,14 +64,14 @@ union {
/* 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
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 bCompletedAuFlag; // Indicate whether it is a completed AU
uint32_t uiCountUnitsNum; // Count size number of malloced NAL Units in each AU list
uint32_t uiStartPos;
uint32_t uiEndPos;
bool bCompletedAuFlag; // Indicate whether it is a completed AU
} SAccessUnit, *PAccessUnit;
} // namespace WelsDec

View File

@ -53,53 +53,53 @@ typedef struct TagLevelLimits {
/* 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()
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;
uint32_t uiLog2MaxFrameNum;
uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
int32_t iOffsetForNonRefPic;
int32_t iOffsetForTopToBottomField;
int32_t iNumRefFramesInPocCycle;
int8_t iOffsetForRefFrame[256];
int32_t iNumRefFrames;
int32_t iOffsetForTopToBottomField;
int32_t iNumRefFramesInPocCycle;
int8_t iOffsetForRefFrame[256];
int32_t iNumRefFrames;
SPosOffset sFrameCrop;
SPosOffset sFrameCrop;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
uint8_t uiChromaFormatIdc;
uint8_t uiChromaArrayType;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
uint8_t uiChromaFormatIdc;
uint8_t uiChromaArrayType;
uint8_t uiBitDepthLuma;
uint8_t uiBitDepthChroma;
/* TO BE CONTINUE: POC type 1 */
bool bDeltaPicOrderAlwaysZeroFlag;
bool bGapsInFrameNumValueAllowedFlag;
uint8_t uiBitDepthLuma;
uint8_t uiBitDepthChroma;
/* TO BE CONTINUE: POC type 1 */
bool bDeltaPicOrderAlwaysZeroFlag;
bool bGapsInFrameNumValueAllowedFlag;
bool bFrameMbsOnlyFlag;
bool bMbaffFlag; // MB Adapative Frame Field
bool bDirect8x8InferenceFlag;
bool bFrameCroppingFlag;
bool bFrameMbsOnlyFlag;
bool bMbaffFlag; // MB Adapative Frame Field
bool bDirect8x8InferenceFlag;
bool bFrameCroppingFlag;
bool bVuiParamPresentFlag;
bool bVuiParamPresentFlag;
// bool bTimingInfoPresentFlag;
// bool bFixedFrameRateFlag;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
bool bSeparateColorPlaneFlag;
bool bQpPrimeYZeroTransfBypassFlag;
bool bSeqScalingMatrixPresentFlag;
bool bSeqScalingListPresentFlag[12];
const SLevelLimits *pSLevelLimits;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
bool bSeparateColorPlaneFlag;
bool bQpPrimeYZeroTransfBypassFlag;
bool bSeqScalingMatrixPresentFlag;
bool bSeqScalingListPresentFlag[12];
const SLevelLimits* pSLevelLimits;
} SSps, *PSps;
@ -117,63 +117,63 @@ const SLevelLimits *pSLevelLimits;
/* Sequence Parameter Set extension syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSpsSvcExt {
SPosOffset sSeqScaledRefLayer;
SPosOffset sSeqScaledRefLayer;
uint8_t uiExtendedSpatialScalability; // ESS
uint8_t uiChromaPhaseXPlus1Flag;
uint8_t uiChromaPhaseYPlus1;
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
bool bInterLayerDeblockingFilterCtrlPresentFlag;
bool bSeqTCoeffLevelPredFlag;
bool bAdaptiveTCoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
uint8_t uiExtendedSpatialScalability; // ESS
uint8_t uiChromaPhaseXPlus1Flag;
uint8_t uiChromaPhaseYPlus1;
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
bool bInterLayerDeblockingFilterCtrlPresentFlag;
bool bSeqTCoeffLevelPredFlag;
bool bAdaptiveTCoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
} SSpsSvcExt, *PSpsSvcExt;
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSubsetSps {
SSps sSps;
SSpsSvcExt sSpsSvcExt;
bool bSvcVuiParamPresentFlag;
bool bAdditionalExtension2Flag;
bool bAdditionalExtension2DataFlag;
SSps sSps;
SSpsSvcExt sSpsSvcExt;
bool bSvcVuiParamPresentFlag;
bool bAdditionalExtension2Flag;
bool bAdditionalExtension2DataFlag;
} SSubsetSps, *PSubsetSps;
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
typedef struct TagPps {
int32_t iSpsId;
int32_t iPpsId;
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 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;
uint32_t uiNumRefIdxL0Active;
uint32_t uiNumRefIdxL1Active;
int32_t iPicInitQp;
int32_t iPicInitQs;
int32_t iChromaQpIndexOffset;
int32_t iPicInitQp;
int32_t iPicInitQs;
int32_t iChromaQpIndexOffset;
bool bEntropyCodingModeFlag;
bool bPicOrderPresentFlag;
/* slice_group_map_type = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
bool bDeblockingFilterControlPresentFlag;
bool bEntropyCodingModeFlag;
bool bPicOrderPresentFlag;
/* slice_group_map_type = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
bool bDeblockingFilterControlPresentFlag;
bool bConstainedIntraPredFlag;
bool bRedundantPicCntPresentFlag;
bool bWeightedPredFlag;
uint8_t uiWeightedBipredIdc;
bool bConstainedIntraPredFlag;
bool bRedundantPicCntPresentFlag;
bool bWeightedPredFlag;
uint8_t uiWeightedBipredIdc;
} SPps, *PPps;

View File

@ -137,11 +137,11 @@ static const SPartMbInfo g_ksInterSubMbTypeInfo[4] = {
void GetNeighborAvailMbType (PNeighAvail pNeighAvail, PDqLayer pCurLayer);
void WelsFillCacheNonZeroCount (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer);
void WelsFillCacheConstrain0Intra4x4 (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
PDqLayer pCurLayer);
PDqLayer pCurLayer);
void WelsFillCacheConstrain1Intra4x4 (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
PDqLayer pCurLayer);
PDqLayer pCurLayer);
void WelsFillCacheInter (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
/*!

View File

@ -43,9 +43,9 @@ namespace WelsDec {
typedef struct TagPicBuff {
PPicture* ppPic;
int32_t iCapacity; // capacity size of queue
int32_t iCurrentIdx;
PPicture* ppPic;
int32_t iCapacity; // capacity size of queue
int32_t iCurrentIdx;
} SPicBuff, *PPicBuff;
/*

View File

@ -43,36 +43,36 @@ namespace WelsDec {
* 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?
/************************************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
/*******************************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
/*******************************sef_definition for misc use****************************/
bool bUsedAsRef; //for ref pic management
bool bIsLongRef; // long term reference frame flag //for ref pic management
uint8_t uiRefCount;
bool bAvailableFlag; // indicate whether it is available in this picture memory block.
/*******************************sef_definition for misc use****************************/
bool bUsedAsRef; //for ref pic management
bool bIsLongRef; // long term reference frame flag //for ref pic management
uint8_t uiRefCount;
bool bAvailableFlag; // indicate whether it is available in this picture memory block.
/*******************************for future use****************************/
uint8_t uiTemporalId;
uint8_t uiSpatialId;
uint8_t uiQualityId;
/*******************************for future use****************************/
uint8_t uiTemporalId;
uint8_t uiSpatialId;
uint8_t uiQualityId;
int32_t iFrameNum; // frame number //for ref pic management
int32_t iLongTermFrameIdx; //id for long term ref pic
int32_t iFrameNum; // frame number //for ref pic management
int32_t iLongTermFrameIdx; //id for long term ref pic
int32_t iSpsId; //against mosaic caused by cross-IDR interval reference.
int32_t iPpsId;
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

@ -64,7 +64,7 @@ int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLeve
void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx);
void 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 iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight);
} // namespace WelsDec

View File

@ -39,10 +39,10 @@
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];
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
@ -117,58 +117,58 @@ extern const uint8_t g_kuiZeroLeftBitNumMap[16];
#endif
static inline void InitVlcTable (SVlcTable* pVlcTable) {
pVlcTable->kpChromaCoeffTokenVlcTable = g_kuiVlcChromaTable;
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[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[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[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->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->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;
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

@ -51,55 +51,55 @@ 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_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,
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
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,10 +109,10 @@ static const uint8_t g_kuiEmulationPreventionThreeByte = 0x03;
*/
typedef uint8_t NalRefIdc;
enum {
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
};
/*
@ -120,9 +120,9 @@ NRI_PRI_HIGHEST = 3
*/
typedef uint8_t VclType;
enum {
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
};
/*
@ -147,58 +147,58 @@ extern const VclType g_kuiVclTypeMap[32][2];
* 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
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
} ESliceType;
/* List Index */
typedef uint8_t ListIndex;
enum {
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
};
/* Picture Size */
typedef struct TagPictureSize {
int32_t iWidth;
int32_t iHeight;
int32_t iWidth;
int32_t iHeight;
} SPictureSize;
/* Motion Vector components */
typedef uint8_t MvComp;
enum {
MV_X = 0,
MV_Y = 1,
MV_A = 2
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
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;
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,
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;
@ -237,13 +237,13 @@ 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
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

View File

@ -399,7 +399,8 @@ bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeade
}
bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps) {
bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PNalUnit kpLastNal,
const PSps kpSps) {
const PNalUnitHeaderExt kpLastNalHeaderExt = &kpLastNal->sNalHeaderExt;
const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
const SSliceHeader* kpLastSliceHeader = &kpLastNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
@ -411,7 +412,8 @@ bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal,
}
if (kpLastSliceHeader->iFrameNum != kpCurSliceHeader->iFrameNum)
return true;
if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
&& pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
pCtx->bNextNewSeqBegin = true;
return true; // the active sps changed, new sequence begins, so the current au is ready
}
@ -423,7 +425,8 @@ bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal,
if (kpLastNalHeaderExt->uiDependencyId > kpCurNalHeaderExt->uiDependencyId)
return true;
// Subclause 7.4.1.2.4
if (kpLastNalHeaderExt->uiDependencyId == kpCurNalHeaderExt->uiDependencyId && kpLastSliceHeader->iPpsId != kpCurSliceHeader->iPpsId)
if (kpLastNalHeaderExt->uiDependencyId == kpCurNalHeaderExt->uiDependencyId
&& kpLastSliceHeader->iPpsId != kpCurSliceHeader->iPpsId)
return true;
if (kpLastSliceHeader->bFieldPicFlag != kpCurSliceHeader->bFieldPicFlag)
return true;

View File

@ -185,25 +185,25 @@ void static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS
uiNnz32b3 = * (uint32_t*) (pNnzTab + 12);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0);
nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1);
nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4);
nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5);
nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8);
nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9);
nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12);
nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13);
nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14);
@ -233,8 +233,8 @@ uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int
uint32_t uiBSx4;
//uint8_t* bS = static_cast<uint8_t*>(&uiBSx4);
uint8_t* pBS = (uint8_t*) (&uiBSx4);
const uint8_t *pBIdx = &g_kuiTableBIdx[iEdge][0];
const uint8_t *pBnIdx = &g_kuiTableBIdx[iEdge][4];
const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0];
const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4];
for (i = 0; i < 4; i++) {
if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) {
@ -327,7 +327,7 @@ void FilteringEdgeLumaIntraV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t
return;
}
void FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
uint8_t* pBS) {
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@ -343,7 +343,7 @@ void FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t*
return;
}
void FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
uint8_t* pBS) {
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@ -360,7 +360,7 @@ void FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t*
}
void FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
uint8_t* pBS) {
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@ -375,7 +375,7 @@ void FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uin
}
void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
uint8_t* pBS) {
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@ -391,7 +391,7 @@ void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uin
void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4],
int32_t iBoundryFlag) {
int32_t iBoundryFlag) {
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
int32_t iMbX = pCurDqLayer->iMbX;
int32_t iMbY = pCurDqLayer->iMbY;
@ -631,7 +631,7 @@ void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFun
int32_t iTotalMbCount = pSliceHeaderExt->sSliceHeader.pSps->uiTotalMbCount;
SDeblockingFilter pFilter;
memset (&pFilter, 0, sizeof(pFilter));
memset (&pFilter, 0, sizeof (pFilter));
PFmo pFmo = pCtx->pFmo;
int32_t iNextMbXyIndex = 0;
int32_t iTotalNumMb = pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice;
@ -720,18 +720,17 @@ void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) {
#endif
#if defined(HAVE_NEON)
if ( iCpu & WELS_CPU_NEON )
{
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_neon;
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_neon;
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_neon;
pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_neon;
if (iCpu & WELS_CPU_NEON) {
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_neon;
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_neon;
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_neon;
pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_neon;
pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_neon;
pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_neon;
pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_neon;
pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_neon;
}
pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_neon;
pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_neon;
pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_neon;
pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_neon;
}
#endif
}

View File

@ -92,13 +92,13 @@ void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
int32_t kT3 = (32 + kT1 + kT2) >> 6;
int32_t kT4 = (32 + kT1 - kT2) >> 6;
pDst[i] = WelsClip1( kT3 + pPred[i] );
pDst[i + kiStride3] = WelsClip1( kT4 + pPred[i + kiStride3] );
pDst[i] = WelsClip1 (kT3 + pPred[i]);
pDst[i + kiStride3] = WelsClip1 (kT4 + pPred[i + kiStride3]);
kT1 = iSrc[i] - iSrc[i + 8];
kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12];
pDst[i + kiStride] = WelsClip1( ((32 + kT1 + kT2) >> 6) + pDst[i + kiStride] );
pDst[i + kiStride2] = WelsClip1( ((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2] );
pDst[i + kiStride] = WelsClip1 (((32 + kT1 + kT2) >> 6) + pDst[i + kiStride]);
pDst[i + kiStride2] = WelsClip1 (((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2]);
}
}

View File

@ -441,7 +441,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
int32_t iMbX = pCurLayer->iMbX;
int32_t iMbY = pCurLayer->iMbY;
const int32_t iMbXy = pCurLayer->iMbXyIndex;
int8_t *pNzc = pCurLayer->pNzc[iMbXy];
int8_t* pNzc = pCurLayer->pNzc[iMbXy];
int32_t i;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
uint32_t uiCode;
@ -844,7 +844,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
}
memset(pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof(int16_t));
memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
ST32A4 (&pNzc[0], 0);
ST32A4 (&pNzc[4], 0);
@ -975,7 +975,7 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur) {
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
const int32_t iMbXy = pCurLayer->iMbXyIndex;
int8_t *pNzc = pCurLayer->pNzc[iMbXy];
int8_t* pNzc = pCurLayer->pNzc[iMbXy];
int32_t iBaseModeFlag, i;
int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
@ -1048,7 +1048,7 @@ void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {
pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_c;
#ifdef HAVE_NEON
if ( iCpu & WELS_CPU_NEON ) {
if (iCpu & WELS_CPU_NEON) {
pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_neon;
}
#endif

View File

@ -970,7 +970,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]");
pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), "pCtx->sMb.pMbCorrectlyDecodedFlag[]");
pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
"pCtx->sMb.pMbCorrectlyDecodedFlag[]");
// check memory block valid due above allocated..
WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY,
@ -1482,60 +1483,63 @@ void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) {
* return:
* true - the AU to be construct is the start of new sequence; false - not
*/
static bool CheckNewSeqBeginAndUpdateActiveLayerSps(PWelsDecoderContext pCtx) {
static bool CheckNewSeqBeginAndUpdateActiveLayerSps (PWelsDecoderContext pCtx) {
bool bNewSeq = false;
PAccessUnit pCurAu = pCtx->pAccessUnitList;
PSps pTmpLayerSps[MAX_LAYER_NUM];
for(int i = 0; i < MAX_LAYER_NUM; i++) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
pTmpLayerSps[i] = NULL;
}
// track the layer sps for the current au
for(unsigned int i = pCurAu->uiStartPos; i <= pCurAu->uiEndPos; i++) {
for (unsigned int i = pCurAu->uiStartPos; i <= pCurAu->uiEndPos; i++) {
uint32_t uiDid = pCurAu->pNalUnitsList[i]->sNalHeaderExt.uiDependencyId;
pTmpLayerSps[uiDid] = pCurAu->pNalUnitsList[i]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
if ((pCurAu->pNalUnitsList[i]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR) || (pCurAu->pNalUnitsList[i]->sNalHeaderExt.bIdrFlag))
if ((pCurAu->pNalUnitsList[i]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR)
|| (pCurAu->pNalUnitsList[i]->sNalHeaderExt.bIdrFlag))
bNewSeq = true;
}
int iMaxActiveLayer = 0, iMaxCurrentLayer = 0;
for(int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
for (int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
if (pCtx->pActiveLayerSps[i] != NULL) {
iMaxActiveLayer = i;
break;
}
}
for(int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
for (int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
if (pTmpLayerSps[i] != NULL) {
iMaxCurrentLayer = i;
break;
}
}
if ((iMaxCurrentLayer != iMaxActiveLayer) || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->pActiveLayerSps[iMaxActiveLayer])) {
if ((iMaxCurrentLayer != iMaxActiveLayer)
|| (pTmpLayerSps[iMaxCurrentLayer] != pCtx->pActiveLayerSps[iMaxActiveLayer])) {
bNewSeq = true;
}
// fill active sps if the current sps is not null while active layer is null
if (!bNewSeq) {
for(int i = 0; i < MAX_LAYER_NUM; i++) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
if (pCtx->pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) {
pCtx->pActiveLayerSps[i] = pTmpLayerSps[i];
}
}
} else {
// UpdateActiveLayerSps if new sequence start
memcpy(&pCtx->pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof(PSps));
memcpy (&pCtx->pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps));
}
return bNewSeq;
}
static void WriteBackActiveParameters(PWelsDecoderContext pCtx) {
static void WriteBackActiveParameters (PWelsDecoderContext pCtx) {
if (pCtx->iOverwriteFlags & OVERWRITE_PPS) {
memcpy(&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof(SPps));
memcpy (&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps));
}
if (pCtx->iOverwriteFlags & OVERWRITE_SPS) {
memcpy(&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof(SSps));
memcpy (&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps));
pCtx->bNewSeqBegin = true;
}
if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) {
memcpy(&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId], &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof(SSubsetSps));
memcpy (&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId],
&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps));
pCtx->bNewSeqBegin = true;
}
pCtx->iOverwriteFlags = OVERWRITE_NONE;
@ -1561,7 +1565,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
pCtx->bAuReadyFlag = false;
pCtx->bLastHasMmco5 = false;
bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps(pCtx);
bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx);
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || bTmpNewSeqBegin;
iErr = WelsDecodeAccessUnitStart (pCtx);
GetVclNalTemporalId (pCtx);
@ -1595,11 +1599,11 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
ImplementErrorCon (pCtx);
pCtx->bNewSeqBegin = false;
WriteBackActiveParameters(pCtx);
WriteBackActiveParameters (pCtx);
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;
pCtx->bNextNewSeqBegin = false; // reset it
if (pCtx->bNewSeqBegin)
ResetActiveSPSForEachLayer(pCtx);
ResetActiveSPSForEachLayer (pCtx);
if (ERR_NONE != iErr) {
WelsLog (pCtx, WELS_LOG_INFO, "returned error from decoding:[0x%x]\n", iErr);
return iErr;
@ -1932,7 +1936,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3
}
}
// need update frame_num due current frame is well decoded
// need update frame_num due current frame is well decoded
pCtx->iPrevFrameNum = pSh->iFrameNum;
if (pCtx->bLastHasMmco5)
pCtx->iPrevFrameNum = 0;

View File

@ -38,7 +38,7 @@ namespace WelsDec {
// rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009
static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
const int32_t kiPicHeight) {
const int32_t kiPicHeight) {
uint8_t* pTmp = pDst;
uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride;
const int32_t kiPaddingLen = PADDING_LENGTH;

View File

@ -239,7 +239,7 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) {
* \return true - changed or not initialized yet; false - not change at all
*/
bool FmoParamSetsChanged (PFmo pFmo, const int32_t kiCountNumMb, const int32_t kiSliceGroupType,
const int32_t kiSliceGroupCount) {
const int32_t kiSliceGroupCount) {
WELS_VERIFY_RETURN_IF (false, (NULL == pFmo))
return ((!pFmo->bActiveFlag)

View File

@ -110,7 +110,8 @@ void WelsResetRefPic (PWelsDecoderContext pCtx) {
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) {
int32_t i, iCount = 0;
if ((pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] <= 0) && (pCtx->eSliceType != I_SLICE && pCtx->eSliceType != SI_SLICE)) {
if ((pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] <= 0) && (pCtx->eSliceType != I_SLICE
&& pCtx->eSliceType != SI_SLICE)) {
if (pCtx->iErrorConMethod != ERROR_CON_DISABLE) { //IDR lost!, recover it for future decoding with data all set to 0
PPicture pRef = PrefetchPic (pCtx->pPicBuff[0]);
if (pRef != NULL) {
@ -281,7 +282,7 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) {
}
if (!pCtx->pDec->bIsLongRef) {
if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX(1,pCtx->pSps->iNumRefFrames)) {
if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX (1, pCtx->pSps->iNumRefFrames)) {
if (pCtx->iErrorConMethod != ERROR_CON_DISABLE) {
iRet = RemainOneBufferInDpbForEC (pCtx);
} else {
@ -372,7 +373,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
}
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX(1,pCtx->pSps->iNumRefFrames)) {
if (pRefPic->uiLongRefCount[LIST_0] + pRefPic->uiShortRefCount[LIST_0] >= WELS_MAX (1, pCtx->pSps->iNumRefFrames)) {
return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
}
#ifdef LONG_TERM_REF
@ -561,7 +562,8 @@ static int32_t RemainOneBufferInDpbForEC (PWelsDecoderContext pCtx) {
uiLongTermFrameIdx++;
}
}
if (pRefPic->uiShortRefCount[0] + pRefPic->uiLongRefCount[0] >= pCtx->pSps->iNumRefFrames) { //fail to remain one empty buffer in DPB
if (pRefPic->uiShortRefCount[0] + pRefPic->uiLongRefCount[0] >=
pCtx->pSps->iNumRefFrames) { //fail to remain one empty buffer in DPB
WelsLog (pCtx, WELS_LOG_WARNING, "RemainOneBufferInDpbForEC(): empty one DPB failed for EC!\n");
iRet = ERR_INFO_REF_COUNT_OVERFLOW;
}

View File

@ -195,7 +195,7 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) {
//basic iMVs prediction unit for iMVs partition width (4, 2, 1)
void 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]) {
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;
@ -242,7 +242,7 @@ void PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][3
}
}
void 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]) {
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]) {
if (0 == iPartIdx) {
const int8_t kiLeftRef = iRefIndex[0][6];
if (iRef == kiLeftRef) {
@ -265,7 +265,7 @@ void PredInter8x16Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[
PredMv (iMotionVector, iRefIndex, iPartIdx, 2, iRef, iMVP);
}
void 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]) {
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]) {
if (0 == iPartIdx) {
const int8_t kiTopRef = iRefIndex[0][1];
if (iRef == kiTopRef) {
@ -309,8 +309,8 @@ void UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2])
//update iRefIndex and iMVs of Mb, only for P16x8
/*need further optimization, mb_cache not work */
void 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]) {
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;
@ -339,8 +339,8 @@ void UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][
}
//update iRefIndex and iMVs of both Mb and Mb_cache, only for P8x16
void 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]) {
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;

View File

@ -650,7 +650,7 @@ static int32_t CavlcGetRunBefore (int32_t iRun[16], SReadBitsCache* pBitsCache,
}
} else {
for (int j = i; j < uiTotalCoeff; j++) {
iRun[j] = 0;
iRun[j] = 0;
}
return iUsedBits;
}

View File

@ -81,17 +81,17 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight;
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc (iLumaSize /* luma */
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
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);
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);

View File

@ -184,7 +184,7 @@ typedef struct TagMCRefMember {
} sMCRefMember;
//according to current 8*8 block ref_index to gain reference picture
static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList,
int32_t iIndex) {
int32_t iIndex) {
PPicture pRefPic;
int8_t iRefIdx = pRefIdxList[iIndex];
@ -203,7 +203,7 @@ static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx,
#define MC_FLOW_SIMPLE_JUDGE 1
#endif //MC_FLOW_SIMPLE_JUDGE
static inline void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
int32_t iExpandWidth = PADDING_LENGTH;
int32_t iExpandHeight = PADDING_LENGTH;
@ -465,7 +465,7 @@ int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLeve
}
void 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 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;

View File

@ -43,112 +43,112 @@ typedef int (*CM_WELS_TRACE) (const char* kpFormat, ...);
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,
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 char* kpFormat, va_list pVl) = 0;
virtual int32_t SetTraceLevel (int32_t iLevel) = 0;
virtual int32_t Trace (const int32_t kLevel, const char* kpFormat, va_list pVl) = 0;
static void WelsTrace (void* pObject, const int32_t kLevel, const char* kpFormat, va_list pVl) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
static void WelsTrace (void* pObject, const int32_t kLevel, const char* kpFormat, va_list pVl) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
if (pThis) {
pThis->Trace (kLevel, kpFormat, pVl);
}
}
static void WelsVTrace (void* pObject, const int32_t kLevel, const char* kpFormat, ...) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
va_list argptr;
va_start (argptr, kpFormat);
if (pThis) {
pThis->Trace (kLevel, kpFormat, argptr);
if (pThis) {
pThis->Trace (kLevel, kpFormat, pVl);
}
}
va_end (argptr);
}
static void WelsVTrace (void* pObject, const int32_t kLevel, const char* kpFormat, ...) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
va_list argptr;
va_start (argptr, kpFormat);
if (pThis) {
pThis->Trace (kLevel, kpFormat, 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 char* kpFormat, va_list pVl);
virtual int32_t SetTraceLevel (int32_t iLevel);
virtual int32_t Trace (const int32_t kLevel, const char* kpFormat, va_list pVl);
virtual int32_t WriteString (int32_t iLevel, const char* pStr) = 0;
virtual int32_t WriteString (int32_t iLevel, const char* pStr) = 0;
protected:
CWelsTraceBase() {
m_iLevel = WELS_LOG_DEFAULT;
};
CWelsTraceBase() {
m_iLevel = WELS_LOG_DEFAULT;
};
private:
int32_t m_iLevel;
int32_t m_iLevel;
};
class CWelsTraceFile : public CWelsTraceBase {
public:
CWelsTraceFile (const char* filename = (const char*)"wels_decoder_trace.txt");
virtual ~CWelsTraceFile();
CWelsTraceFile (const char* filename = (const char*)"wels_decoder_trace.txt");
virtual ~CWelsTraceFile();
public:
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
private:
WelsFileHandle* m_pTraceFile;
WelsFileHandle* m_pTraceFile;
};
#ifdef _WIN32
class CWelsTraceWinDgb : public CWelsTraceBase {
public:
CWelsTraceWinDgb() {};
virtual ~CWelsTraceWinDgb() {};
CWelsTraceWinDgb() {};
virtual ~CWelsTraceWinDgb() {};
public:
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
};
#endif
class CWelsCodecTrace : public CWelsTraceBase {
public:
CWelsCodecTrace() ;
virtual ~CWelsCodecTrace();
CWelsCodecTrace() ;
virtual ~CWelsCodecTrace();
public:
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
virtual int32_t WriteString (int32_t iLevel, const char* pStr);
protected:
int32_t LoadWelsTraceModule();
int32_t UnloadWelsTraceModule();
int32_t LoadWelsTraceModule();
int32_t UnloadWelsTraceModule();
private:
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;
};

View File

@ -56,57 +56,57 @@ namespace WelsDec {
class CWelsDecoder : public ISVCDecoder {
public:
CWelsDecoder (void);
virtual ~CWelsDecoder();
CWelsDecoder (void);
virtual ~CWelsDecoder();
virtual long EXTAPI Initialize (const SDecodingParam* pParam);
virtual long EXTAPI Uninitialize();
virtual long EXTAPI Initialize (const SDecodingParam* pParam);
virtual long EXTAPI 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 EXTAPI DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight);
/***************************************************************************
* 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 EXTAPI DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight);
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc,
const int kiSrcLen,
void** ppDst,
SBufferInfo* pDstInfo);
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& color_format);
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc,
const int kiSrcLen,
void** ppDst,
SBufferInfo* pDstInfo);
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& color_format);
virtual long EXTAPI SetOption (DECODER_OPTION eOptID, void* pOption);
virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption);
virtual long EXTAPI SetOption (DECODER_OPTION eOptID, void* pOption);
virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption);
private:
PWelsDecoderContext m_pDecContext;
IWelsTrace* m_pTrace;
PWelsDecoderContext m_pDecContext;
IWelsTrace* m_pTrace;
void InitDecoder (void);
void UninitDecoder (void);
void InitDecoder (void);
void UninitDecoder (void);
#ifdef OUTPUT_BIT_STREAM
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
#endif//OUTPUT_BIT_STREAM
};

View File

@ -325,8 +325,8 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,
if (kiSrcLen > MAX_ACCESS_UNIT_CAPACITY - MAX_MACROBLOCK_CAPACITY) {//prevent from residual reading overflow
m_pDecContext->iErrorCode |= dsOutOfMemory;
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO,
"max AU size exceeded. Allowed size = %d, current size = %d",
MAX_ACCESS_UNIT_CAPACITY, kiSrcLen);
"max AU size exceeded. Allowed size = %d, current size = %d",
MAX_ACCESS_UNIT_CAPACITY, kiSrcLen);
return dsOutOfMemory;
}
if (kiSrcLen > 0 && kpSrc != NULL) {

View File

@ -50,23 +50,24 @@ 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;
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;
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#if defined(HAVE_NEON)
void WelsNonZeroCount_neon(int8_t * pNonZeroCount);
void DeblockingBSCalcEnc_neon(int8_t *pNzc, SMVUnitXY *pMv, int32_t iBoundryFlag, int32_t iMbStride, uint8_t (*pBS)[4][4]);
void WelsNonZeroCount_neon (int8_t* pNonZeroCount);
void DeblockingBSCalcEnc_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBoundryFlag, int32_t iMbStride,
uint8_t (*pBS)[4][4]);
#endif
#if defined(__cplusplus)
}

View File

@ -71,13 +71,14 @@ void WelsIDctRecI16x16Dc_sse2 (uint8_t* pRec, int32_t iStride, uint8_t* pPredict
#endif//X86_ASM
#ifdef HAVE_NEON
void WelsDequantFour4x4_neon(int16_t* pDct, const uint16_t* kpMF);
void WelsDequant4x4_neon(int16_t* pDct, const uint16_t* kpMF);
void WelsDequantIHadamard4x4_neon(int16_t* pRes, const uint16_t kuiMF);
void WelsDequantFour4x4_neon (int16_t* pDct, const uint16_t* kpMF);
void WelsDequant4x4_neon (int16_t* pDct, const uint16_t* kpMF);
void WelsDequantIHadamard4x4_neon (int16_t* pRes, const uint16_t kuiMF);
void WelsIDctT4Rec_neon(uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
void WelsIDctFourT4Rec_neon(uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
void WelsIDctRecI16x16Dc_neon(uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDctDc);
void WelsIDctT4Rec_neon (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
void WelsIDctFourT4Rec_neon (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
void WelsIDctRecI16x16Dc_neon (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride,
int16_t* pDctDc);
#endif
#if defined(__cplusplus)

View File

@ -106,20 +106,20 @@ void WelsQuantFour4x4Max_sse2 (int16_t* pDct, const int16_t* pFF, const int16_t*
#endif
#ifdef HAVE_NEON
void WelsHadamardT4Dc_neon(int16_t* pLumaDc, int16_t* pDct);
int32_t WelsHadamardQuant2x2_neon(int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct, int16_t* pBlock);
int32_t WelsHadamardQuant2x2Skip_neon(int16_t* pRes, int16_t iFF, int16_t iMF);
int32_t WelsHadamardQuant2x2SkipKernel_neon(int16_t *pRes, int16_t iThreshold);// avoid divide operator
void WelsHadamardT4Dc_neon (int16_t* pLumaDc, int16_t* pDct);
int32_t WelsHadamardQuant2x2_neon (int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct, int16_t* pBlock);
int32_t WelsHadamardQuant2x2Skip_neon (int16_t* pRes, int16_t iFF, int16_t iMF);
int32_t WelsHadamardQuant2x2SkipKernel_neon (int16_t* pRes, int16_t iThreshold); // avoid divide operator
void WelsDctT4_neon(int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
void WelsDctFourT4_neon(int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
void WelsDctT4_neon (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
void WelsDctFourT4_neon (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pPixel2, int32_t iStride2);
int32_t WelsGetNoneZeroCount_neon(int16_t* pLevel);
int32_t WelsGetNoneZeroCount_neon (int16_t* pLevel);
void WelsQuant4x4_neon(int16_t* pDct, const int16_t* pFF, const int16_t* pMF);
void WelsQuant4x4Dc_neon(int16_t* pDct, int16_t iFF, int16_t iMF);
void WelsQuantFour4x4_neon(int16_t* pDct, const int16_t* pFF, const int16_t* pMF);
void WelsQuantFour4x4Max_neon(int16_t* pDct, const int16_t* pFF, const int16_t* pMF, int16_t* pMax);
void WelsQuant4x4_neon (int16_t* pDct, const int16_t* pFF, const int16_t* pMF);
void WelsQuant4x4Dc_neon (int16_t* pDct, int16_t iFF, int16_t iMF);
void WelsQuantFour4x4_neon (int16_t* pDct, const int16_t* pFF, const int16_t* pMF);
void WelsQuantFour4x4Max_neon (int16_t* pDct, const int16_t* pFF, const int16_t* pMF, int16_t* pMax);
#endif
#if defined(__cplusplus)

View File

@ -61,7 +61,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx);
* \brief allocate or reallocate the output bs buffer
* \return: successful - 0; otherwise none 0 for failed
*/
int32_t AllocateBsOutputBuffer(CMemoryAlign*pMa, const int32_t iNeededLen, int32_t iOrigLen, const char* kpTag, uint8_t*& pOutputBuffer );
int32_t AllocateBsOutputBuffer (CMemoryAlign* pMa, const int32_t iNeededLen, int32_t iOrigLen, const char* kpTag,
uint8_t*& pOutputBuffer);
//TODO: to finish this function and call it
/*!
@ -127,7 +128,7 @@ void WelsSetMemZeroSize64_mmx (void* pDst, int32_t iSize);
void WelsSetMemZeroSize8_mmx (void* pDst, int32_t iSize);
void WelsPrefetchZero_mmx (int8_t const* kpDst);
#elif defined(HAVE_NEON)
void WelsSetMemZero_neon(void* pDst, int32_t iSize);
void WelsSetMemZero_neon (void* pDst, int32_t iSize);
#endif
#if defined(__cplusplus)

View File

@ -64,7 +64,7 @@ int32_t InitPic (const void* kpSrc, const int32_t kiCsp, const int32_t kiWidth,
* \pParam pParam SWelsSvcCodingParam*
* \return successful - 0; otherwise none 0 for failed
*/
int32_t ParamValidationExt (sWelsEncCtx* pCtx,SWelsSvcCodingParam* pParam);
int32_t ParamValidationExt (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam);
// GOM based RC related for uiSliceNum decision
void GomValidCheck (const int32_t kiMbWidth, const int32_t kiMbHeight, int32_t* pSliceNum);
@ -92,7 +92,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx);
* \param kpSrcPic Source picture
* \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP)
*/
int32_t WelsEncoderEncodeExt (sWelsEncCtx*, SFrameBSInfo * pFbi, const SSourcePicture* kpSrcPic);
int32_t WelsEncoderEncodeExt (sWelsEncCtx*, SFrameBSInfo* pFbi, const SSourcePicture* kpSrcPic);
int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst);
@ -107,7 +107,7 @@ int32_t ForceCodingIDR (sWelsEncCtx* pCtx);
*/
int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNew);
void WelsEncoderApplyFrameRate (SWelsSvcCodingParam* pParam);
void WelsEncoderApplyBitRate(SWelsSvcCodingParam* pParam,int32_t iLayer);
void WelsEncoderApplyBitRate (SWelsSvcCodingParam* pParam, int32_t iLayer);
int32_t FilterLTRRecoveryRequest (sWelsEncCtx* pCtx, SLTRRecoverRequest* pLTRRecoverRequest);

View File

@ -116,24 +116,24 @@ void WelsI4x4LumaPredHU_mmx (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri
#endif//X86_ASM
#if defined(HAVE_NEON)
void WelsI16x16LumaPredV_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredH_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredDc_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredPlane_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredV_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredH_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredDc_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI16x16LumaPredPlane_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredV_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredH_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredDDL_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredDDR_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredVL_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredVR_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredHU_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredHD_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredV_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredH_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredDDL_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredDDR_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredVL_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredVR_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredHU_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsI4x4LumaPredHD_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredV_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredH_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredDc_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredPlane_neon(uint8_t *pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredV_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredH_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredDc_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
void WelsIChromaPredPlane_neon (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
#endif//HAVE_NEON
#if defined(__cplusplus)
}

View File

@ -65,79 +65,79 @@ extern const uint8_t g_kuiCache48CountScan4Idx[24];
typedef struct TagDCTCoeff {
//ALIGNED_DECLARE( int16_t, residual_ac[16], 16 ); //I_16x16
int16_t iLumaBlock[16][16]; //based on block4x4 luma DC/AC
int16_t iLumaBlock[16][16]; //based on block4x4 luma DC/AC
//ALIGNED_DECLARE( int16_t, iLumaI16x16Dc[16], 16 ); //I_16x16 DC
int16_t iLumaI16x16Dc[16];
int16_t iLumaI16x16Dc[16];
//ALIGNED_DECLARE( int16_t, iChromaDc[2][4], 16 ); //chroma DC
int16_t iChromaBlock[8][16]; //based on block4x4 chroma DC/AC
int16_t iChromaDc[2][4];
int16_t iChromaBlock[8][16]; //based on block4x4 chroma DC/AC
int16_t iChromaDc[2][4];
} SDCTCoeff ;
typedef struct TagMbCache {
//the followed pData now is promised aligned to 16 bytes
ALIGNED_DECLARE (SMVComponentUnit, sMvComponents, 16);
ALIGNED_DECLARE (SMVComponentUnit, sMvComponents, 16);
ALIGNED_DECLARE_MATRIX_1D (iNonZeroCoeffCount, 48, int8_t, 16); // Cache line size
ALIGNED_DECLARE_MATRIX_1D (iNonZeroCoeffCount, 48, int8_t, 16); // Cache line size
// int8_t iNonZeroCoeffCount[6 * 8]; // Right luma, Chroma(Left Top Cb, Left btm Cr); must follow by iIntraPredMode!
ALIGNED_DECLARE_MATRIX_1D (iIntraPredMode, 48, int8_t, 16);
ALIGNED_DECLARE_MATRIX_1D (iIntraPredMode, 48, int8_t, 16);
// must follow with iNonZeroCoeffCount!
int32_t iSadCost[4]; //avail 1; unavail 0
SMVUnitXY sMbMvp[MB_BLOCK8x8_NUM];// for write bs
int32_t iSadCost[4]; //avail 1; unavail 0
SMVUnitXY sMbMvp[MB_BLOCK8x8_NUM];// for write bs
//for residual decoding (recovery) at the side of Encoder
int16_t* pCoeffLevel; // tmep
int16_t* pCoeffLevel; // tmep
//malloc memory for prediction
uint8_t* pSkipMb;
uint8_t* pSkipMb;
//ALIGNED_DECLARE(uint8_t, pMemPredMb[2][256], 16);//One: Best I_16x16 Luma and refine frac_pixel pBuffer; another: PingPong I_8x8&&Inter Cb + Cr
uint8_t* pMemPredMb;
uint8_t* pMemPredLuma;// inter && intra share same pointer;
uint8_t* pMemPredMb;
uint8_t* pMemPredLuma;// inter && intra share same pointer;
//ALIGNED_DECLARE(uint8_t, pMemPredChroma[2][64*2], 16); //another PingPong pBuffer: Best Cb + Cr;
uint8_t* pMemPredChroma;// inter && intra share same pointer;
uint8_t* pBestPredIntraChroma; //Cb:0~63; Cr:64~127
uint8_t* pMemPredChroma;// inter && intra share same pointer;
uint8_t* pBestPredIntraChroma; //Cb:0~63; Cr:64~127
//ALIGNED_DECLARE(uint8_t, pMemPredBlk4[2][16], 16); //I_4x4
uint8_t* pMemPredBlk4;
uint8_t* pMemPredBlk4;
uint8_t* pBestPredI4x4Blk4;//I_4x4
uint8_t* pBestPredI4x4Blk4;//I_4x4
//ALIGNED_DECLARE(uint8_t, pBufferInterPredMe[4][400], 16);//inter type pBuffer for ME h & v & hv
uint8_t* pBufferInterPredMe; // [4][400] is enough because only h&v or v&hv or h&hv. but if both h&v&hv is needed when 8 quart pixel, future we have to use [5][400].
uint8_t* pBufferInterPredMe; // [4][400] is enough because only h&v or v&hv or h&hv. but if both h&v&hv is needed when 8 quart pixel, future we have to use [5][400].
//no scan4[] order, just as memory order to store
//ALIGNED_DECLARE(bool, pPrevIntra4x4PredModeFlag[16], 16);//if 1, means no rem_intra4x4_pred_mode; if 0, means rem_intra4x4_pred_mode != 0
bool* pPrevIntra4x4PredModeFlag;
bool* pPrevIntra4x4PredModeFlag;
//ALIGNED_DECLARE(int8_t, pRemIntra4x4PredModeFlag[16], 16);//-1 as default; if pPrevIntra4x4PredModeFlag==0,
//pRemIntra4x4PredModeFlag or added by 1 is the best pred_mode
int8_t* pRemIntra4x4PredModeFlag;
int8_t* pRemIntra4x4PredModeFlag;
int32_t iSadCostSkip[4]; //avail 1; unavail 0
bool bMbTypeSkip[4]; //1: skip; 0: non-skip
int32_t* pEncSad;
int32_t iSadCostSkip[4]; //avail 1; unavail 0
bool bMbTypeSkip[4]; //1: skip; 0: non-skip
int32_t* pEncSad;
//for residual encoding at the side of Encoder
SDCTCoeff* pDct;
SDCTCoeff* pDct;
uint8_t uiNeighborIntra; // LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPLEFT_MB_POS = 0x04 ,TOPRIGHT_MB_POS = 0x08;
uint8_t uiLumaI16x16Mode;
uint8_t uiChmaI8x8Mode;
uint8_t uiNeighborIntra; // LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPLEFT_MB_POS = 0x04 ,TOPRIGHT_MB_POS = 0x08;
uint8_t uiLumaI16x16Mode;
uint8_t uiChmaI8x8Mode;
bool bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0).
uint32_t uiRefMbType;
bool bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0).
uint32_t uiRefMbType;
struct {
/* pointer of current mb location in original frame */
uint8_t* pEncMb[3];
/* pointer of current mb location in recovery frame */
uint8_t* pDecMb[3];
/* pointer of co-located mb location in reference frame */
uint8_t* pRefMb[3];
//for SVC
uint8_t* pCsMb[3];//locating current mb's CS in whole frame
struct {
/* pointer of current mb location in original frame */
uint8_t* pEncMb[3];
/* pointer of current mb location in recovery frame */
uint8_t* pDecMb[3];
/* pointer of co-located mb location in reference frame */
uint8_t* pRefMb[3];
//for SVC
uint8_t* pCsMb[3];//locating current mb's CS in whole frame
// int16_t *p_rs[3];//locating current mb's RS in whole frame
} SPicData;
} SPicData;
} SMbCache;
}//end of namespace

View File

@ -75,43 +75,43 @@ extern const int8_t g_kiMapModeIntraChroma[7];
// if we want keep total sizeof(SWelsMD) <= 256, we maybe need to seperate three member of SWelsME.
typedef struct TagWelsMD {
int32_t iLambda;
uint16_t* pMvdCost;
int32_t iLambda;
uint16_t* pMvdCost;
int32_t iCostLuma;
int32_t iCostChroma;//satd+lambda(best_pred_mode) //i_sad_chroma;
int32_t iSadPredMb;
int32_t iCostLuma;
int32_t iCostChroma;//satd+lambda(best_pred_mode) //i_sad_chroma;
int32_t iSadPredMb;
uint8_t uiRef; //uiRefIndex appointed by Encoder, used for MC
bool bMdUsingSad;
uint16_t uiReserved;
uint8_t uiRef; //uiRefIndex appointed by Encoder, used for MC
bool bMdUsingSad;
uint16_t uiReserved;
int32_t iCostSkipMb;
int32_t iSadPredSkip;
int32_t iCostSkipMb;
int32_t iSadPredSkip;
int32_t iMbPixX; // pixel position of MB in horizontal axis
int32_t iMbPixY; // pixel position of MB in vertical axis
int32_t iBlock8x8StaticIdc[4];
int32_t iMbPixX; // pixel position of MB in horizontal axis
int32_t iMbPixY; // pixel position of MB in vertical axis
int32_t iBlock8x8StaticIdc[4];
//NO B frame in our Wels, we can ignore list1
struct {
SWelsME sMe16x16; //adjust each SWelsME for 8 D-word!
SWelsME sMe8x8[4];
SWelsME sMe16x8[2];
SWelsME sMe8x16[2];
struct {
SWelsME sMe16x16; //adjust each SWelsME for 8 D-word!
SWelsME sMe8x8[4];
SWelsME sMe16x8[2];
SWelsME sMe8x16[2];
// SMVUnitXY i_mvbs[MB_BLOCK8x8_NUM]; //scaled MVB
} sMe;
} sMe;
} SWelsMD;
typedef struct TagMeRefinePointer {
uint8_t* pHalfPixH;
uint8_t* pHalfPixV;
uint8_t* pHalfPixHV;
uint8_t* pHalfPixH;
uint8_t* pHalfPixV;
uint8_t* pHalfPixHV;
uint8_t* pQuarPixBest;
uint8_t* pQuarPixTmp;
uint8_t* pQuarPixBest;
uint8_t* pQuarPixTmp;
} SMeRefinePointer;

View File

@ -43,30 +43,30 @@ namespace WelsSVCEnc {
class CMemoryAlign {
public:
CMemoryAlign (const uint32_t kuiCacheLineSize);
virtual ~CMemoryAlign();
CMemoryAlign (const uint32_t kuiCacheLineSize);
virtual ~CMemoryAlign();
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
void WelsFree (void* pPointer, const char* kpTag);
const uint32_t WelsGetCacheLineSize() const;
const uint32_t WelsGetMemoryUsage() const;
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
void WelsFree (void* pPointer, const char* kpTag);
const uint32_t WelsGetCacheLineSize() const;
const uint32_t WelsGetMemoryUsage() const;
private:
// private copy & assign constructors adding to fix klocwork scan issues
CMemoryAlign (const CMemoryAlign& kcMa);
CMemoryAlign& operator= (const CMemoryAlign& kcMa);
CMemoryAlign (const CMemoryAlign& kcMa);
CMemoryAlign& operator= (const CMemoryAlign& kcMa);
protected:
uint32_t m_nCacheLineSize;
uint32_t m_nCacheLineSize;
#ifdef MEMORY_MONITOR
uint32_t m_nMemoryUsageInBytes;
uint32_t m_nMemoryUsageInBytes;
#endif//MEMORY_MONITOR
#ifdef MEMORY_CHECK
FILE* m_fpMemChkPoint;
uint32_t m_nCountRequestNum;
FILE* m_fpMemChkPoint;
uint32_t m_nCountRequestNum;
#endif//MEMORY_CHECK
};

View File

@ -59,35 +59,36 @@
#define THRESHOLD_RMSE_CORE2 0.0200f // v1.1: 0.0200f; v1.0: 0.04f
typedef struct TagSliceThreadPrivateData {
void* pWelsPEncCtx;
SLayerBSInfo* pLayerBs;
int32_t iSliceIndex; // slice index, zero based
int32_t iThreadIndex; // thread index, zero based
void* pWelsPEncCtx;
SLayerBSInfo* pLayerBs;
int32_t iSliceIndex; // slice index, zero based
int32_t iThreadIndex; // thread index, zero based
// for dynamic slicing mode
int32_t iStartMbIndex; // inclusive
int32_t iEndMbIndex; // exclusive
int32_t iStartMbIndex; // inclusive
int32_t iEndMbIndex; // exclusive
} SSliceThreadPrivateData;
typedef struct TagSliceThreading {
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
char eventNamespace[100];
WELS_THREAD_HANDLE pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx]
WELS_EVENT pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
WELS_EVENT pSliceCodedMasterEvent; // events for signalling that some event in pSliceCodedEvent has been signalled
WELS_EVENT pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
WELS_EVENT pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list neighbor for various slices
WELS_EVENT pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
WELS_EVENT pExitEncodeEvent[MAX_THREADS_NUM]; // event for exit encoding event
WELS_EVENT pThreadMasterEvent[MAX_THREADS_NUM]; // event for indicating that some event has been signalled to the thread
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
char eventNamespace[100];
WELS_THREAD_HANDLE pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx]
WELS_EVENT pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
WELS_EVENT pSliceCodedMasterEvent; // events for signalling that some event in pSliceCodedEvent has been signalled
WELS_EVENT pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
WELS_EVENT pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list neighbor for various slices
WELS_EVENT pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
WELS_EVENT pExitEncodeEvent[MAX_THREADS_NUM]; // event for exit encoding event
WELS_EVENT
pThreadMasterEvent[MAX_THREADS_NUM]; // event for indicating that some event has been signalled to the thread
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT
uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx]
float* pSliceComplexRatio[MAX_DEPENDENCY_LAYER];
uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx]
float* pSliceComplexRatio[MAX_DEPENDENCY_LAYER];
#ifdef MT_DEBUG
FILE* pFSliceDiff; // file handle for debug
FILE* pFSliceDiff; // file handle for debug
#endif//MT_DEBUG
} SSliceThreading;

View File

@ -52,28 +52,28 @@ namespace WelsSVCEnc {
* Raw payload pData for NAL unit, AVC/SVC compatible
*/
typedef struct TagWelsNalRaw {
uint8_t* pRawData; // pRawNal payload for slice pData
int32_t iPayloadSize; // size of pRawNal pData
uint8_t* pRawData; // pRawNal payload for slice pData
int32_t iPayloadSize; // size of pRawNal pData
SNalUnitHeaderExt sNalExt; // NAL header information
SNalUnitHeaderExt sNalExt; // NAL header information
int32_t iStartPos; //NAL start position in buffer
int32_t iStartPos; //NAL start position in buffer
} SWelsNalRaw;
/*
* Encoder majoy output pData
*/
typedef struct TagWelsEncoderOutput {
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded picture, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded picture, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
SBitStringAux sBsWrite;
SBitStringAux sBsWrite;
// SWelsNalRaw raw_nals[MAX_DEPENDENCY_LAYER*2+MAX_DEPENDENCY_LAYER*MAX_QUALITY_LEVEL]; // AVC: max up to SPS+PPS+max_slice_idc (2 + 8) for FMO;
SWelsNalRaw* sNalList; // nal list, adaptive for AVC/SVC in case single slice, multiple slices or fmo
int32_t iCountNals; // count number of NAL in list
SWelsNalRaw* sNalList; // nal list, adaptive for AVC/SVC in case single slice, multiple slices or fmo
int32_t iCountNals; // count number of NAL in list
// SVC: num_sps (MAX_D) + num_pps (MAX_D) + num_vcl (MAX_D * MAX_Q)
int32_t iNalIndex; // coding NAL currently, 0 based
int32_t iNalIndex; // coding NAL currently, 0 based
// bool bAnnexBFlag; // annexeb flag, to figure it pOut the packetization mode whether need 4 bytes (0 0 0 1) of start code prefix
} SWelsEncoderOutput;
@ -81,21 +81,21 @@ int32_t iNalIndex; // coding NAL currently, 0 based
//#define MT_DEBUG_BS_WR 0 // for MT debugging if needed
typedef struct TagWelsSliceBs {
uint8_t* pBs; // output bitstream, pBitStringAux not needed for slice 0 due to no dependency of pFrameBs available
uint32_t uiBsPos; // position of output bitstream
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded slice, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
uint8_t* pBs; // output bitstream, pBitStringAux not needed for slice 0 due to no dependency of pFrameBs available
uint32_t uiBsPos; // position of output bitstream
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded slice, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
SBitStringAux sBsWrite;
SBitStringAux sBsWrite;
SWelsNalRaw sNalList[2]; // nal list, PREFIX NAL(if applicable) + SLICE NAL
SWelsNalRaw sNalList[2]; // nal list, PREFIX NAL(if applicable) + SLICE NAL
// int32_t iCountNals; // count number of NAL in list
int32_t iNalLen[2];
int32_t iNalIndex; // coding NAL currently, 0 based
int32_t iNalLen[2];
int32_t iNalIndex; // coding NAL currently, 0 based
// bool bAnnexBFlag; // annexeb flag, to figure it pOut the packetization mode whether need 4 bytes (0 0 0 1) of start code prefix
#if MT_DEBUG_BS_WR
bool bSliceCodedFlag;
bool bSliceCodedFlag;
#endif//MT_DEBUG_BS_WR
} SWelsSliceBs;
@ -129,7 +129,8 @@ void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBs);
* \param pRawNal pRawNal NAL pData
* \return ERR_CODE
*/
int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t kiDstBufferLen, void* pDst, int32_t* pDstLen);
int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t kiDstBufferLen, void* pDst,
int32_t* pDstLen);
/*!
* \brief write prefix nal

View File

@ -64,446 +64,450 @@ extern const uint8_t g_kuiTemporalIdListTable[MAX_TEMPORAL_LEVEL][MAX_GOP_SIZE
* \return 2 based scaling factor
*/
static inline uint32_t GetLogFactor (float base, float upper) {
const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0);
const double dEpsilon = 0.0001;
const double dRound = floor (dLog2factor + 0.5);
const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0);
const double dEpsilon = 0.0001;
const double dRound = floor (dLog2factor + 0.5);
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
return (uint32_t) (dRound);
}
return UINT_MAX;
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
return (uint32_t) (dRound);
}
return UINT_MAX;
}
/*
* Dependency Layer Parameter
*/
typedef struct TagDLayerParam {
int32_t iActualWidth; // input source picture actual width
int32_t iActualHeight; // input source picture actual height
int32_t iFrameWidth; // frame width
int32_t iFrameHeight; // frame height
int32_t iActualWidth; // input source picture actual width
int32_t iActualHeight; // input source picture actual height
int32_t iFrameWidth; // frame width
int32_t iFrameHeight; // frame height
int32_t iSpatialBitrate;
int32_t iSpatialBitrate;
/* temporal settings related */
int32_t iTemporalResolution;
int32_t iDecompositionStages;
uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1];
/* temporal settings related */
int32_t iTemporalResolution;
int32_t iDecompositionStages;
uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1];
uint8_t uiProfileIdc; // value of profile IDC (0 for auto-detection)
uint8_t uiLevelIdc;
int8_t iHighestTemporalId;
uint8_t uiProfileIdc; // value of profile IDC (0 for auto-detection)
uint8_t uiLevelIdc;
int8_t iHighestTemporalId;
// uint8_t uiDependencyId;
int8_t iDLayerQp;
int8_t iDLayerQp;
SSliceConfig sSliceCfg; // multiple slice options
SSliceConfig sSliceCfg; // multiple slice options
float fInputFrameRate; // input frame rate
float fOutputFrameRate; // output frame rate
float fInputFrameRate; // input frame rate
float fOutputFrameRate; // output frame rate
#ifdef ENABLE_FRAME_DUMP
char sRecFileName[MAX_FNAME_LEN]; // file to be constructed
char sRecFileName[MAX_FNAME_LEN]; // file to be constructed
#endif//ENABLE_FRAME_DUMP
} SDLayerParam;
/*
* Cisco OpenH264 Encoder Parameter Configuration
*/
typedef struct TagWelsSvcCodingParam: SEncParamExt{
SDLayerParam sDependencyLayers[MAX_DEPENDENCY_LAYER];
typedef struct TagWelsSvcCodingParam: SEncParamExt {
SDLayerParam sDependencyLayers[MAX_DEPENDENCY_LAYER];
/* General */
uint32_t uiGopSize; // GOP size (at maximal frame rate: 16)
struct {
int32_t iLeft;
int32_t iTop;
int32_t iWidth;
int32_t iHeight;
} SUsedPicRect; // the rect in input picture that encoder actually used
/* General */
uint32_t uiGopSize; // GOP size (at maximal frame rate: 16)
struct {
int32_t iLeft;
int32_t iTop;
int32_t iWidth;
int32_t iHeight;
} SUsedPicRect; // the rect in input picture that encoder actually used
char* pCurPath; // record current lib path such as:/pData/pData/com.wels.enc/lib/
char* pCurPath; // record current lib path such as:/pData/pData/com.wels.enc/lib/
bool bDeblockingParallelFlag; // deblocking filter parallelization control flag
bool bDeblockingParallelFlag; // deblocking filter parallelization control flag
short iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
short
iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
int8_t iDecompStages; // GOP size dependency
int8_t iDecompStages; // GOP size dependency
public:
TagWelsSvcCodingParam () {
FillDefault ();
}
~TagWelsSvcCodingParam() {}
TagWelsSvcCodingParam() {
FillDefault();
}
~TagWelsSvcCodingParam() {}
static void FillDefault (SEncParamExt& param) {
memset(&param, 0, sizeof(param));
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used
static void FillDefault (SEncParamExt& param) {
memset (&param, 0, sizeof (param));
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used
param.iPicWidth = 0; // actual input picture width
param.iPicHeight = 0; // actual input picture height
param.iPicWidth = 0; // actual input picture width
param.iPicHeight = 0; // actual input picture height
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
param.iInputCsp = videoFormatI420; // input sequence color space in default
param.uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
param.iInputCsp = videoFormatI420; // input sequence color space in default
param.uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
param.iMaxBitrate = MAX_BIT_RATE;
param.iMultipleThreadIdc = 1;
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
param.iMaxBitrate = MAX_BIT_RATE;
param.iMultipleThreadIdc = 1;
param.iLTRRefNum = 0;
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
param.iLTRRefNum = 0;
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
param.bEnableSSEI = true;
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
param.bEnableSSEI = true;
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
/* Deblocking loop filter */
param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries
param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
/* Deblocking loop filter */
param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries
param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
/* Rate Control */
param.iRCMode = RC_QUALITY_MODE;
param.iPaddingFlag = 0;
/* Rate Control */
param.iRCMode = RC_QUALITY_MODE;
param.iPaddingFlag = 0;
param.bEnableDenoise = false; // denoise control
param.bEnableSceneChangeDetect = true; // scene change detection control
param.bEnableBackgroundDetection = true; // background detection control
param.bEnableAdaptiveQuant = true; // adaptive quantization control
param.bEnableFrameSkip = true; // frame skipping
param.bEnableLongTermReference = false; // long term reference control
param.bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
param.iTemporalLayerNum = 1; // number of temporal layer specified
param.bEnableDenoise = false; // denoise control
param.bEnableSceneChangeDetect = true; // scene change detection control
param.bEnableBackgroundDetection = true; // background detection control
param.bEnableAdaptiveQuant = true; // adaptive quantization control
param.bEnableFrameSkip = true; // frame skipping
param.bEnableLongTermReference = false; // long term reference control
param.bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
param.iTemporalLayerNum = 1; // number of temporal layer specified
param.iMaxQp = 51;
param.iMinQp = 0;
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.uiMaxNalSize = 0;
param.iMaxQp = 51;
param.iMinQp = 0;
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.uiMaxNalSize = 0;
for(int32_t iLayer = 0;iLayer< MAX_SPATIAL_LAYER_NUM;iLayer++){
param.sSpatialLayers[iLayer].uiProfileIdc = PRO_BASELINE;
param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_5_0;
param.sSpatialLayers[iLayer].iDLayerQp = SVC_QUALITY_BASE_QP;
param.sSpatialLayers[iLayer].fFrameRate = param.fMaxFrameRate;
param.sSpatialLayers[iLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1;
for (int32_t iLayer = 0; iLayer < MAX_SPATIAL_LAYER_NUM; iLayer++) {
param.sSpatialLayers[iLayer].uiProfileIdc = PRO_BASELINE;
param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_5_0;
param.sSpatialLayers[iLayer].iDLayerQp = SVC_QUALITY_BASE_QP;
param.sSpatialLayers[iLayer].fFrameRate = param.fMaxFrameRate;
param.sSpatialLayers[iLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
}
}
void FillDefault() {
FillDefault (*this);
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
SUsedPicRect.iLeft =
SUsedPicRect.iTop =
SUsedPicRect.iWidth =
SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used
pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
memset (sDependencyLayers, 0, sizeof (SDLayerParam)*MAX_DEPENDENCY_LAYER);
//init multi-slice
sDependencyLayers[0].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
}
}
void FillDefault () {
FillDefault(*this);
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
SUsedPicRect.iLeft =
SUsedPicRect.iTop =
SUsedPicRect.iWidth =
SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used
pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
memset(sDependencyLayers,0,sizeof(SDLayerParam)*MAX_DEPENDENCY_LAYER);
//init multi-slice
sDependencyLayers[0].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for(int32_t idx = 0;idx <kiLesserSliceNum;idx++)
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sDependencyLayers[0].iDLayerQp = SVC_QUALITY_BASE_QP;
}
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iTargetBitrate = pCodingParam.iTargetBitrate;
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
iRCMode = pCodingParam.iRCMode; // rc mode
int8_t iIdxSpatial = 0;
uint8_t uiProfileIdc = PRO_BASELINE;
SDLayerParam* pDlp = &sDependencyLayers[0];
while (iIdxSpatial < iSpatialLayerNum) {
pDlp->uiProfileIdc = uiProfileIdc;
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
MIN_FRAME_RATE, MAX_FRAME_RATE);
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
MAX_FRAME_RATE);
#ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
pDlp->iFrameWidth = pDlp->iActualWidth;
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
pDlp->iFrameHeight = pDlp->iActualHeight;
pDlp->iSpatialBitrate =
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
pDlp->iDLayerQp = SVC_QUALITY_BASE_QP;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ iIdxSpatial;
}
SetActualPicResolution();
return 0;
}
void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iUsageType = iUsageType;
pCodingParam->iInputCsp = iInputCsp;
pCodingParam->iPicWidth = iPicWidth;
pCodingParam->iPicHeight = iPicHeight;
pCodingParam->iTargetBitrate = iTargetBitrate;
pCodingParam->iRCMode = iRCMode;
pCodingParam->fMaxFrameRate = fMaxFrameRate;
}
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
uiFrameToBeCoded = (uint32_t) -
1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iTargetBitrate = pCodingParam.iTargetBitrate;
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
/* Deblocking loop filter */
iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries,
if (iLoopFilterDisableIdc == 0) // Loop filter requested to be enabled
iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0
iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
iRCMode = pCodingParam.iRCMode; // rc mode
bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag;
int8_t iIdxSpatial = 0;
uint8_t uiProfileIdc = PRO_BASELINE;
/* Rate Control */
iRCMode = pCodingParam.iRCMode; // rc mode
iPaddingFlag = pCodingParam.iPaddingFlag;
SDLayerParam* pDlp = &sDependencyLayers[0];
iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate
iMaxBitrate = pCodingParam.iMaxBitrate;
while (iIdxSpatial < iSpatialLayerNum) {
uiMaxNalSize = pCodingParam.uiMaxNalSize;
/* Denoise Control */
bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now
pDlp->uiProfileIdc = uiProfileIdc;
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
MIN_FRAME_RATE, MAX_FRAME_RATE);
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
MAX_FRAME_RATE);
#ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
pDlp->iFrameWidth = pDlp->iActualWidth;
/* Scene change detection control */
bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect;
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
pDlp->iFrameHeight = pDlp->iActualHeight;
/* Background detection Control */
bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false;
pDlp->iSpatialBitrate =
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
/* Adaptive quantization control */
bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false;
pDlp->iDLayerQp = SVC_QUALITY_BASE_QP;
/* Frame skipping */
bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ iIdxSpatial;
}
SetActualPicResolution();
/* Enable int32_t term reference */
bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
return 0;
}
void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iUsageType = iUsageType;
pCodingParam->iInputCsp = iInputCsp;
pCodingParam->iPicWidth = iPicWidth;
pCodingParam->iPicHeight = iPicHeight;
pCodingParam->iTargetBitrate = iTargetBitrate;
pCodingParam->iRCMode = iRCMode;
pCodingParam->fMaxFrameRate = fMaxFrameRate;
}
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc;
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
uiFrameToBeCoded = (uint32_t) -
1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
/* For ssei information */
bEnableSSEI = pCodingParam.bEnableSSEI;
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
/* Layer definition */
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
iTemporalLayerNum = (int8_t)WELS_CLIP3(pCodingParam.iTemporalLayerNum, 1, MAX_TEMPORAL_LEVEL);// number of temporal layer specified
/* Deblocking loop filter */
iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries,
if (iLoopFilterDisableIdc == 0) // Loop filter requested to be enabled
iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0
iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired)
if (uiIntraPeriod == (uint32_t) (-1))
uiIntraPeriod = 0;
else if (uiIntraPeriod & (uiGopSize-1)) // none multiple of GOP size
uiIntraPeriod = ((uiIntraPeriod + uiGopSize - 1) / uiGopSize) * uiGopSize;
bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag;
if (iUsageType == SCREEN_CONTENT_REAL_TIME) {
if (bEnableLongTermReference) {
iLTRRefNum = WELS_CLIP3(pCodingParam.iLTRRefNum,1,LONG_TERM_REF_NUM_SCREEN);
if( iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX(1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
/* Rate Control */
iRCMode = pCodingParam.iRCMode; // rc mode
iPaddingFlag = pCodingParam.iPaddingFlag;
iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate
iMaxBitrate = pCodingParam.iMaxBitrate;
uiMaxNalSize = pCodingParam.uiMaxNalSize;
/* Denoise Control */
bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now
/* Scene change detection control */
bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect;
/* Background detection Control */
bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false;
/* Adaptive quantization control */
bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false;
/* Frame skipping */
bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false;
/* Enable int32_t term reference */
bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc;
/* For ssei information */
bEnableSSEI = pCodingParam.bEnableSSEI;
/* Layer definition */
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
MAX_TEMPORAL_LEVEL); // number of temporal layer specified
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired)
if (uiIntraPeriod == (uint32_t) (-1))
uiIntraPeriod = 0;
else if (uiIntraPeriod & (uiGopSize - 1)) // none multiple of GOP size
uiIntraPeriod = ((uiIntraPeriod + uiGopSize - 1) / uiGopSize) * uiGopSize;
if (iUsageType == SCREEN_CONTENT_REAL_TIME) {
if (bEnableLongTermReference) {
iLTRRefNum = WELS_CLIP3 (pCodingParam.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN);
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
} else {
iLTRRefNum = 0;
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, uiGopSize >> 1);
}
} else {
iLTRRefNum = 0;
if( iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX(1, uiGopSize>>1);
iLTRRefNum = bEnableLongTermReference ? WELS_CLIP3 (pCodingParam.iLTRRefNum, 1, LONG_TERM_REF_NUM) : 0;
if (iNumRefFrame == AUTO_REF_PIC_COUNT) {
iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
}
}
} else {
iLTRRefNum = bEnableLongTermReference ? WELS_CLIP3(pCodingParam.iLTRRefNum,1,LONG_TERM_REF_NUM) : 0;
if( iNumRefFrame == AUTO_REF_PIC_COUNT){
iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
}
}
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
bEnableSpsPpsIdAddition =
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
//SHOULD enable this feature.
bEnableSpsPpsIdAddition =
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
//SHOULD enable this feature.
SDLayerParam* pDlp = &sDependencyLayers[0];
float fMaxFr = .0f;
uint8_t uiProfileIdc = PRO_BASELINE;
int8_t iIdxSpatial = 0;
while (iIdxSpatial < iSpatialLayerNum) {
pDlp->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN)?uiProfileIdc:pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
pDlp->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN)?LEVEL_5_0:pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
SDLayerParam* pDlp = &sDependencyLayers[0];
float fMaxFr = .0f;
uint8_t uiProfileIdc = PRO_BASELINE;
int8_t iIdxSpatial = 0;
while (iIdxSpatial < iSpatialLayerNum) {
pDlp->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
pDlp->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN) ? LEVEL_5_0 :
pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
MIN_FRAME_RATE, fParamMaxFrameRate);
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
if (pDlp->fInputFrameRate > fMaxFr + EPSN)
fMaxFr = pDlp->fInputFrameRate;
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
MIN_FRAME_RATE, fParamMaxFrameRate);
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
if (pDlp->fInputFrameRate > fMaxFr + EPSN)
fMaxFr = pDlp->fInputFrameRate;
#ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pDlp->iFrameWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
pDlp->iFrameHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
pDlp->iSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
pDlp->iFrameWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
pDlp->iFrameHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
pDlp->iSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
//multi slice
pDlp->sSliceCfg.uiSliceMode = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
pDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
= (uint32_t) (pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
pDlp->sSliceCfg.sSliceArgument.uiSliceNum
= pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
memcpy (pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum,
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
kiLesserSliceNum * sizeof (uint32_t)) ;
//multi slice
pDlp->sSliceCfg.uiSliceMode = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
pDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
= (uint32_t) (pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
pDlp->sSliceCfg.sSliceArgument.uiSliceNum
= pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
memcpy (pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum,
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
kiLesserSliceNum * sizeof (uint32_t)) ;
pDlp->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
pDlp->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ iIdxSpatial;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ iIdxSpatial;
}
fMaxFrameRate = fMaxFr;
SetActualPicResolution();
return 0;
}
fMaxFrameRate = fMaxFr;
SetActualPicResolution();
return 0;
}
// assuming that the width/height ratio of all spatial layers are the same
void SetActualPicResolution() {
int32_t iSpatialIdx = iSpatialLayerNum - 1;
SDLayerParam* pDlayer = &sDependencyLayers[iSpatialIdx];
void SetActualPicResolution() {
int32_t iSpatialIdx = iSpatialLayerNum - 1;
SDLayerParam* pDlayer = &sDependencyLayers[iSpatialIdx];
for (; iSpatialIdx >= 0; iSpatialIdx --) {
pDlayer = &sDependencyLayers[iSpatialIdx];
for (; iSpatialIdx >= 0; iSpatialIdx --) {
pDlayer = &sDependencyLayers[iSpatialIdx];
pDlayer->iActualWidth = pDlayer->iFrameWidth;
pDlayer->iActualHeight = pDlayer->iFrameHeight;
pDlayer->iFrameWidth = WELS_ALIGN (pDlayer->iActualWidth, MB_WIDTH_LUMA);
pDlayer->iFrameHeight = WELS_ALIGN (pDlayer->iActualHeight, MB_HEIGHT_LUMA);
pDlayer->iActualWidth = pDlayer->iFrameWidth;
pDlayer->iActualHeight = pDlayer->iFrameHeight;
pDlayer->iFrameWidth = WELS_ALIGN (pDlayer->iActualWidth, MB_WIDTH_LUMA);
pDlayer->iFrameHeight = WELS_ALIGN (pDlayer->iActualHeight, MB_HEIGHT_LUMA);
}
}
}
/*!
* \brief determined key coding tables for temporal scalability, uiProfileIdc etc for each spatial layer settings
* \param SWelsSvcCodingParam, and carried with known GOP size, max, input and output frame rate of each spatial
* \return NONE (should ensure valid parameter before this procedure)
*/
void DetermineTemporalSettings() {
const int32_t iDecStages = WELS_LOG2 (
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
SDLayerParam* pDlp = &sDependencyLayers[0];
uint8_t uiProfileIdc = PRO_BASELINE;
int8_t i = 0;
/*!
* \brief determined key coding tables for temporal scalability, uiProfileIdc etc for each spatial layer settings
* \param SWelsSvcCodingParam, and carried with known GOP size, max, input and output frame rate of each spatial
* \return NONE (should ensure valid parameter before this procedure)
*/
void DetermineTemporalSettings() {
const int32_t iDecStages = WELS_LOG2 (
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
SDLayerParam* pDlp = &sDependencyLayers[0];
uint8_t uiProfileIdc = PRO_BASELINE;
int8_t i = 0;
while (i < iSpatialLayerNum) {
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
int32_t iNotCodedMask = 0;
int8_t iMaxTemporalId = 0;
while (i < iSpatialLayerNum) {
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
int32_t iNotCodedMask = 0;
int8_t iMaxTemporalId = 0;
memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId));
pDlp->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId));
pDlp->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) {
if (0 == (uiFrameIdx & iNotCodedMask)) {
const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx];
pDlp->uiCodingIdx2TemporalId[uiFrameIdx] = kiTemporalId;
if (kiTemporalId > iMaxTemporalId) {
iMaxTemporalId = kiTemporalId;
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) {
if (0 == (uiFrameIdx & iNotCodedMask)) {
const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx];
pDlp->uiCodingIdx2TemporalId[uiFrameIdx] = kiTemporalId;
if (kiTemporalId > iMaxTemporalId) {
iMaxTemporalId = kiTemporalId;
}
}
}
pDlp->iHighestTemporalId = iMaxTemporalId;
pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate;
pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ i;
}
pDlp->iHighestTemporalId = iMaxTemporalId;
pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate;
pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ i;
iDecompStages = (int8_t)iDecStages;
}
iDecompStages = (int8_t)iDecStages;
}
} SWelsSvcCodingParam;
static inline int32_t FreeCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
if (pParam == NULL || *pParam == NULL || pMa == NULL)
return 1;
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
*pParam = NULL;
return 0;
if (pParam == NULL || *pParam == NULL || pMa == NULL)
return 1;
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
*pParam = NULL;
return 0;
}
static inline int32_t AllocCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
@ -513,7 +517,7 @@ static inline int32_t AllocCodingParam (SWelsSvcCodingParam** pParam, CMemoryAli
FreeCodingParam (pParam, pMa);
}
SWelsSvcCodingParam* pCodingParam = (SWelsSvcCodingParam*)pMa->WelsMalloc (sizeof (SWelsSvcCodingParam),
"SWelsSvcCodingParam");
"SWelsSvcCodingParam");
if (NULL == pCodingParam)
return 1;
*pParam = pCodingParam;

View File

@ -41,48 +41,48 @@ namespace WelsSVCEnc {
/* Sequence Parameter Set, refer to Page 57 in JVT X201wcm */
typedef struct TagWelsSPS {
uint32_t uiSpsId;
int16_t iMbWidth;
int16_t iMbHeight;
uint32_t uiLog2MaxFrameNum;
uint32_t uiSpsId;
int16_t iMbWidth;
int16_t iMbHeight;
uint32_t uiLog2MaxFrameNum;
// uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
// int32_t iOffsetForNonRefPic;
// int32_t iOffsetForTopToBottomField;
// int32_t iNumRefFramesInPocCycle;
// int8_t iOffsetForRefFrame[256];
SCropOffset sFrameCrop;
int16_t iNumRefFrames;
SCropOffset sFrameCrop;
int16_t iNumRefFrames;
// uint32_t uiNumUnitsInTick;
// uint32_t uiTimeScale;
uint8_t uiProfileIdc;
uint8_t iLevelIdc;
uint8_t uiProfileIdc;
uint8_t iLevelIdc;
// uint8_t uiChromaFormatIdc;
// uint8_t uiChromaArrayType; //support =1
// uint8_t uiBitDepthLuma; //=8, only used in decoder, encoder in general_***; it can be removed when removed general up_sample
// uint8_t uiBitDepthChroma; //=8
/* TO BE CONTINUE: POC type 1 */
/* TO BE CONTINUE: POC type 1 */
// bool bDeltaPicOrderAlwaysZeroFlag;
// bool bGapsInFrameNumValueAllowedFlag; //=true
// bool bFrameMbsOnlyFlag;
// bool bMbaffFlag; // MB Adapative Frame Field
// bool bDirect8x8InferenceFlag;
bool bFrameCroppingFlag;
bool bFrameCroppingFlag;
// bool bVuiParamPresentFlag;
// bool bTimingInfoPresentFlag;
// bool bFixedFrameRateFlag;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
// bool bSeparateColorPlaneFlag; // =false,: only used in decoder, encoder in general_***; it can be removed when removed general up_sample
} SWelsSPS, *PWelsSPS;
@ -92,21 +92,21 @@ bool bConstraintSet3Flag;
typedef struct TagSpsSvcExt {
// SCropOffset sSeqScaledRefLayer;
uint8_t iExtendedSpatialScalability; // ESS
uint8_t iExtendedSpatialScalability; // ESS
// uint8_t uiChromaPhaseXPlus1Flag;
// uint8_t uiChromaPhaseYPlus1;
// uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
// uint8_t uiSeqRefLayerChromaPhaseYPlus1;
// bool bInterLayerDeblockingFilterCtrlPresentFlag;
bool bSeqTcoeffLevelPredFlag;
bool bAdaptiveTcoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
bool bSeqTcoeffLevelPredFlag;
bool bAdaptiveTcoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
} SSpsSvcExt, *PSpsSvcExt;
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSubsetSps {
SWelsSPS pSps;
SSpsSvcExt sSpsSvcExt;
SWelsSPS pSps;
SSpsSvcExt sSpsSvcExt;
// bool bSvcVuiParamPresentFlag;
// bool bAdditionalExtension2Flag;
@ -115,40 +115,40 @@ SSpsSvcExt sSpsSvcExt;
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
typedef struct TagWelsPPS {
uint32_t iSpsId;
uint32_t iPpsId;
uint32_t iSpsId;
uint32_t iPpsId;
#if !defined(DISABLE_FMO_FEATURE)
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* uiSliceGroupMapType = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 3, 4 or 5 */
/* uiSliceGroupMapType = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
uint32_t uiSliceGroupChangeRate;
/* uiSliceGroupMapType = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* uiSliceGroupMapType = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 3, 4 or 5 */
/* uiSliceGroupMapType = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
uint32_t uiSliceGroupChangeRate;
/* uiSliceGroupMapType = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
#endif//!DISABLE_FMO_FEATURE
// uint32_t uiNumRefIdxL0Active;
// uint32_t uiNumRefIdxL1Active;
int8_t iPicInitQp;
int8_t iPicInitQs;
uint8_t uiChromaQpIndexOffset;
int8_t iPicInitQp;
int8_t iPicInitQs;
uint8_t uiChromaQpIndexOffset;
/* potential application for High profile */
/* potential application for High profile */
// int32_t iSecondChromaQpIndexOffset;
// /* potential application for High profile */
// bool bPicOrderPresentFlag;
bool bDeblockingFilterControlPresentFlag;
bool bDeblockingFilterControlPresentFlag;
// bool bConstainedIntraPredFlag;
// bool bRedundantPicCntPresentFlag;

View File

@ -40,8 +40,7 @@
namespace WelsSVCEnc {
#define LIST_SIZE 0x10000 //(256*256)
typedef struct TagScreenBlockFeatureStorage
{
typedef struct TagScreenBlockFeatureStorage {
//Input
uint16_t* pFeatureOfBlockPointer; // Pointer to pFeatureOfBlock
int32_t iIs16x16; //Feature block size
@ -49,7 +48,8 @@ typedef struct TagScreenBlockFeatureStorage
//Modify
uint32_t* pTimesOfFeatureValue; // times of every value in Feature
uint16_t** pLocationOfFeature; // uint16_t *pLocationOfFeature[LIST_SIZE], pLocationOfFeature[i] saves all the location(x,y) whose Feature = i;
uint16_t**
pLocationOfFeature; // uint16_t *pLocationOfFeature[LIST_SIZE], pLocationOfFeature[i] saves all the location(x,y) whose Feature = i;
uint16_t* pLocationPointer; // buffer of position array
int32_t iActualListSize; // actual list size
uint32_t uiSadCostThreshold[BLOCK_SIZE_ALL];

View File

@ -52,7 +52,8 @@ namespace WelsSVCEnc {
* \pram iNeedFeatureStorage need storage for FME
* \return successful if effective picture pointer returned, otherwise failed with NULL
*/
SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth, const int32_t kiHeight, bool bNeedMbInfo, int32_t iNeedFeatureStorage);
SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth, const int32_t kiHeight, bool bNeedMbInfo,
int32_t iNeedFeatureStorage);
/*!
* \brief free picture pData planes

View File

@ -55,7 +55,7 @@ namespace WelsSVCEnc {
#define WELS_RC_DISABLE 0
#define WELS_RC_GOM 1
enum{
enum {
BITS_NORMAL,
BITS_LIMITED,
BITS_EXCEEDED,

View File

@ -48,21 +48,21 @@
namespace WelsSVCEnc {
typedef enum {
RECIEVE_UNKOWN = 0,
RECIEVE_SUCCESS = 1,
RECIEVE_FAILED = 2,
RECIEVE_UNKOWN = 0,
RECIEVE_SUCCESS = 1,
RECIEVE_FAILED = 2,
} LTR_MARKING_RECEIVE_STATE;
typedef enum {
LTR_DIRECT_MARK = 0,
LTR_DELAY_MARK = 1,
LTR_DIRECT_MARK = 0,
LTR_DELAY_MARK = 1,
} LTR_MARKING_PROCESS_MODE;
typedef enum {
FRAME_NUM_EQUAL = 0x01,
FRAME_NUM_BIGGER = 0x02,
FRAME_NUM_SMALLER = 0x04,
FRAME_NUM_OVER_MAX = 0x08,
FRAME_NUM_EQUAL = 0x01,
FRAME_NUM_BIGGER = 0x02,
FRAME_NUM_SMALLER = 0x04,
FRAME_NUM_OVER_MAX = 0x08,
} COMPARE_FRAME_NUM;
/*
@ -81,7 +81,7 @@ bool WelsUpdateRefList (void* pCtx);
/*
* build reference picture list
*/
bool WelsBuildRefList (void* pCtx, const int32_t kiPOC,int32_t iBestLtrRefIdx);
bool WelsBuildRefList (void* pCtx, const int32_t kiPOC, int32_t iBestLtrRefIdx);
/*
* update syntax for reference base related
@ -98,7 +98,7 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx);
*/
void WelsMarkPic (void* pCtx);
void InitRefListMgrFunc(SWelsFuncPtrList* pFuncList,EUsageType eUsageType);
void InitRefListMgrFunc (SWelsFuncPtrList* pFuncList, EUsageType eUsageType);
#ifdef LONG_TERM_REF_DUMP
void DumpRef (sWelsEncCtx* ctx);

View File

@ -47,11 +47,12 @@ int32_t WelsSampleSatd8x8_c (uint8_t*, int32_t, uint8_t*, int32_t);
//int32_t WelsSampleSatd4x8( uint8_t *, int32_t, uint8_t *, int32_t );
int32_t WelsSampleSatd4x4_c (uint8_t*, int32_t, uint8_t*, int32_t);
int32_t WelsSampleSatdIntra4x4Combined3_c (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t*, int32_t, int32_t, int32_t);
int32_t WelsSampleSatdIntra4x4Combined3_c (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t*, int32_t, int32_t,
int32_t);
int32_t WelsSampleSatdIntra16x16Combined3_c (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
int32_t WelsSampleSadIntra16x16Combined3_c (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
int32_t WelsSampleSatdIntra8x8Combined3_c (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*,
uint8_t*, uint8_t*);
uint8_t*, uint8_t*);
#if defined(__cplusplus)
extern "C" {
@ -92,9 +93,12 @@ int32_t WelsSampleSatd4x4_neon (uint8_t*, int32_t, uint8_t*, int32_t);
int32_t WelsIntra16x16Combined3Satd_neon (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
int32_t WelsIntra16x16Combined3Sad_neon (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
int32_t WelsIntra8x8Combined3Satd_neon (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*, uint8_t*, uint8_t*);
int32_t WelsIntra8x8Combined3Sad_neon (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*, uint8_t*, uint8_t*);
int32_t WelsIntra4x4Combined3Satd_neon (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t*, int32_t, int32_t, int32_t);
int32_t WelsIntra8x8Combined3Satd_neon (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*, uint8_t*,
uint8_t*);
int32_t WelsIntra8x8Combined3Sad_neon (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*, uint8_t*,
uint8_t*);
int32_t WelsIntra4x4Combined3Satd_neon (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t*, int32_t, int32_t,
int32_t);
#endif

View File

@ -49,11 +49,11 @@ namespace WelsSVCEnc {
enum EResidualProperty {
LUMA_DC = 0,
LUMA_AC = 1,
LUMA_4x4 = 2,
CHROMA_DC = 3,
CHROMA_AC = 4
LUMA_DC = 0,
LUMA_AC = 1,
LUMA_4x4 = 2,
CHROMA_DC = 3,
CHROMA_AC = 4
};
@ -63,16 +63,16 @@ typedef int32_t (*PCavlcParamCalFunc) (int16_t* pCoff, uint8_t* pRun, int16_t*
int32_t iEndIdx);
typedef struct TagCoeffFunc {
PCavlcParamCalFunc pfCavlcParamCal;
PCavlcParamCalFunc pfCavlcParamCal;
} SCoeffFunc;
/* For CAVLC */
extern SCoeffFunc sCoeffFunc;
typedef struct TagCavlcTableItem {
uint16_t uiBits;
uint8_t uiLen;
uint8_t uiSuffixLength;
uint16_t uiBits;
uint8_t uiLen;
uint8_t uiSuffixLength;
} SCavlcTableItem;
void InitCoeffFunc (const uint32_t uiCpuFlag);

View File

@ -70,7 +70,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pParam, con
void ReleaseMtResource (sWelsEncCtx** ppCtx);
int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t kiSliceCount);
int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, int32_t& iSliceSize);
int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx,
int32_t& iSliceSize);
#if !defined(_WIN32)
WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg);
@ -80,7 +81,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg);
int32_t CreateSliceThreads (sWelsEncCtx* pCtx);
int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLayerBsInfo,
int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, WELS_EVENT* pMasterEventsList,
SLayerBSInfo* pLayerBsInfo,
const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx* pSliceCtx, const bool kbIsDynamicSlicingMode);
int32_t DynamicDetectCpuCores();

View File

@ -75,9 +75,9 @@ void WelsMdInterMb (void* pEncCtx, void* pWelsMd, SSlice* pSlice, SMB* pCurMb, S
//void wels_md_inter_init ( SWelsMD* pMd, const uint8_t ref_idx, const bool is_highest_dlayer_flag );
bool WelsMdInterJudgeBGDPskip (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool* bKeepSkip);
bool* bKeepSkip);
bool WelsMdInterJudgeBGDPskipFalse (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool* bKeepSkip);
bool* bKeepSkip);
void WelsMdInterUpdateBGDInfo (SDqLayer* pCurLayer, SMB* pCurMb, const bool kbCollocatedPredFlag,
const int32_t kiRefPictureType);
@ -85,7 +85,7 @@ void WelsMdInterUpdateBGDInfoNULL (SDqLayer* pCurLayer, SMB* pCurMb, const bool
const int32_t kiRefPictureType);
bool WelsMdInterJudgePskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool bTrySkip);
bool bTrySkip);
void WelsMdInterUpdatePskip (SDqLayer* pCurDqLayer, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache);
void WelsMdInterDecidedPskip (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache);

View File

@ -58,17 +58,17 @@ namespace WelsSVCEnc {
typedef struct TagDqLayer SDqLayer;
typedef SDqLayer* pDqLayer;
typedef struct TagFeatureSearchPreparation{
typedef struct TagFeatureSearchPreparation {
SScreenBlockFeatureStorage* pRefBlockFeature;//point the the ref frame storage
uint16_t* pFeatureOfBlock; // Feature of every block (8x8), begin with the point
uint8_t uiFeatureStrategyIndex;// index of hash strategy
uint8_t uiFeatureStrategyIndex;// index of hash strategy
/* for FME frame-level switch */
bool bFMESwitchFlag;
uint8_t uiFMEGoodFrameCount;
int32_t iHighFreMbCount;
}SFeatureSearchPreparation;//maintain only one
/* for FME frame-level switch */
bool bFMESwitchFlag;
uint8_t uiFMEGoodFrameCount;
int32_t iHighFreMbCount;
} SFeatureSearchPreparation; //maintain only one
typedef struct TagLayerInfo {
SNalUnitHeaderExt sNalHeaderExt;

View File

@ -93,138 +93,138 @@ extern const uint32_t g_uiGolombUELength[256];
* Get size of unsigned exp golomb codes
*/
static inline uint32_t BsSizeUE (const uint32_t kiValue) {
if (256 > kiValue) {
return g_uiGolombUELength[kiValue];
} else {
uint32_t n = 0;
uint32_t iTmpValue = kiValue + 1;
if (256 > kiValue) {
return g_uiGolombUELength[kiValue];
} else {
uint32_t n = 0;
uint32_t iTmpValue = kiValue + 1;
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
return ((n << 1) + 1);
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
return ((n << 1) + 1);
}
}
/*
* Get size of signed exp golomb codes
*/
static inline uint32_t BsSizeSE (const int32_t kiValue) {
uint32_t iTmpValue;
if (0 == kiValue) {
return 1;
} else if (0 < kiValue) {
iTmpValue = (kiValue << 1) - 1;
return BsSizeUE (iTmpValue);
} else {
iTmpValue = ((-kiValue) << 1);
return BsSizeUE (iTmpValue);
}
uint32_t iTmpValue;
if (0 == kiValue) {
return 1;
} else if (0 < kiValue) {
iTmpValue = (kiValue << 1) - 1;
return BsSizeUE (iTmpValue);
} else {
iTmpValue = ((-kiValue) << 1);
return BsSizeUE (iTmpValue);
}
}
/*
* Get size of truncated exp golomb codes
*/
static inline int32_t BsSizeTE (const int32_t kiX, const int32_t kiValue) {
return 0;
return 0;
}
static inline int32_t BsWriteBits (SBitStringAux* pBs, int32_t n, const uint32_t kuiValue) {
if (n < pBs->iLeftBits) {
pBs->uiCurBits = (pBs->uiCurBits << n) | kuiValue;
pBs->iLeftBits -= n;
} else {
n -= pBs->iLeftBits;
pBs->uiCurBits = (pBs->uiCurBits << pBs->iLeftBits) | (kuiValue >> n);
WRITE_BE_32(pBs->pBufPtr, pBs->uiCurBits);
pBs->pBufPtr += 4;
pBs->uiCurBits = kuiValue & ((1 << n) - 1);
pBs->iLeftBits = 32 - n;
}
return 0;
if (n < pBs->iLeftBits) {
pBs->uiCurBits = (pBs->uiCurBits << n) | kuiValue;
pBs->iLeftBits -= n;
} else {
n -= pBs->iLeftBits;
pBs->uiCurBits = (pBs->uiCurBits << pBs->iLeftBits) | (kuiValue >> n);
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits);
pBs->pBufPtr += 4;
pBs->uiCurBits = kuiValue & ((1 << n) - 1);
pBs->iLeftBits = 32 - n;
}
return 0;
}
/*
* Write 1 bit
*/
static inline int32_t BsWriteOneBit (SBitStringAux* pBs, const uint32_t kuiValue) {
BsWriteBits (pBs, 1, kuiValue);
BsWriteBits (pBs, 1, kuiValue);
return 0;
return 0;
}
static inline void BsFlush (SBitStringAux* pBs) {
WRITE_BE_32(pBs->pBufPtr, pBs->uiCurBits << pBs->iLeftBits);
pBs->pBufPtr += 4 - pBs->iLeftBits / 8;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0; // for future writing safe, 5/19/2010
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits << pBs->iLeftBits);
pBs->pBufPtr += 4 - pBs->iLeftBits / 8;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0; // for future writing safe, 5/19/2010
}
/*
* Write unsigned exp golomb codes
*/
static inline void BsWriteUE (SBitStringAux* pBs, const uint32_t kuiValue) {
uint32_t iTmpValue = kuiValue + 1;
if (256 > kuiValue) {
BsWriteBits (pBs, g_uiGolombUELength[kuiValue], kuiValue + 1);
} else {
uint32_t n = 0;
uint32_t iTmpValue = kuiValue + 1;
if (256 > kuiValue) {
BsWriteBits (pBs, g_uiGolombUELength[kuiValue], kuiValue + 1);
} else {
uint32_t n = 0;
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
BsWriteBits (pBs, (n << 1) + 1, kuiValue + 1);
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
BsWriteBits (pBs, (n << 1) + 1, kuiValue + 1);
}
return;
return;
}
/*
* Write signed exp golomb codes
*/
static inline void BsWriteSE (SBitStringAux* pBs, int32_t iValue) {
uint32_t iTmpValue;
if (0 == iValue) {
BsWriteOneBit (pBs, 1);
} else if (0 < iValue) {
iTmpValue = (iValue << 1) - 1;
BsWriteUE (pBs, iTmpValue);
} else {
iTmpValue = ((-iValue) << 1);
BsWriteUE (pBs, iTmpValue);
}
return;
uint32_t iTmpValue;
if (0 == iValue) {
BsWriteOneBit (pBs, 1);
} else if (0 < iValue) {
iTmpValue = (iValue << 1) - 1;
BsWriteUE (pBs, iTmpValue);
} else {
iTmpValue = ((-iValue) << 1);
BsWriteUE (pBs, iTmpValue);
}
return;
}
/*
* Write truncated exp golomb codes
*/
static inline void BsWriteTE (SBitStringAux* pBs, const int32_t kiX, const uint32_t kuiValue) {
if (1 == kiX) {
BsWriteOneBit (pBs, !kuiValue);
} else {
BsWriteUE (pBs, kuiValue);
}
if (1 == kiX) {
BsWriteOneBit (pBs, !kuiValue);
} else {
BsWriteUE (pBs, kuiValue);
}
}
@ -232,18 +232,18 @@ if (1 == kiX) {
* Write RBSP trailing bits
*/
static inline void BsRbspTrailingBits (SBitStringAux* pBs) {
BsWriteOneBit (pBs, 1);
BsFlush (pBs);
BsWriteOneBit (pBs, 1);
BsFlush (pBs);
}
static inline bool BsCheckByteAlign (SBitStringAux* pBs) {
return ! (pBs->iLeftBits & 0x7);
return ! (pBs->iLeftBits & 0x7);
}
static inline int32_t BsGetBitsPos (SBitStringAux* pBs) {
return (((pBs->pBufPtr - pBs->pBuf) << 3) + 32 - pBs->iLeftBits);
return (((pBs->pBufPtr - pBs->pBuf) << 3) + 32 - pBs->iLeftBits);
}
}

View File

@ -47,29 +47,29 @@ namespace WelsSVCEnc {
// keep the most essential level pData structure be 64 Bytes, which matches cache line size; if so, the order with structure maybe negligible.
// pls take care when modify MB structure size
typedef struct TagMB {
/*************************mb_layer() syntax and generated********************************/
/*mb_layer():*/
Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list
int16_t iMbXY; // offset position of MB top left point based
int16_t iMbX; // position of MB in horizontal axis
int16_t iMbY; // position of MB in vertical axis
/*************************mb_layer() syntax and generated********************************/
/*mb_layer():*/
Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list
int16_t iMbXY; // offset position of MB top left point based
int16_t iMbX; // position of MB in horizontal axis
int16_t iMbY; // position of MB in vertical axis
uint8_t uiNeighborAvail; // avail && same_slice: LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPRIGHT_MB_POS = 0x04 ,TOPLEFT_MB_POS = 0x08;
uint8_t uiCbp;
uint8_t uiNeighborAvail; // avail && same_slice: LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPRIGHT_MB_POS = 0x04 ,TOPLEFT_MB_POS = 0x08;
uint8_t uiCbp;
SMVUnitXY* sMv;
int8_t* pRefIndex;
SMVUnitXY* sMv;
int8_t* pRefIndex;
int32_t* pSadCost; // mb sad. set to 0 for intra mb
int8_t* pIntra4x4PredMode; // [MB_BLOCK4x4_NUM]
int8_t* pNonZeroCount; // [MB_LUMA_CHROMA_BLOCK4x4_NUM]
int32_t* pSadCost; // mb sad. set to 0 for intra mb
int8_t* pIntra4x4PredMode; // [MB_BLOCK4x4_NUM]
int8_t* pNonZeroCount; // [MB_LUMA_CHROMA_BLOCK4x4_NUM]
SMVUnitXY sP16x16Mv;
SMVUnitXY sP16x16Mv;
uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant.
uint8_t uiChromaQp;
uint8_t uiSliceIdc; // AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId);
uint8_t reserved_filling_bytes[1]; // filling bytes reserved to make structure aligned with 4 bytes, higher cache hit on less structure size by 2 cache lines( 2 * 64 bytes) once hit
uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant.
uint8_t uiChromaQp;
uint8_t uiSliceIdc; // AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId);
uint8_t reserved_filling_bytes[1]; // filling bytes reserved to make structure aligned with 4 bytes, higher cache hit on less structure size by 2 cache lines( 2 * 64 bytes) once hit
} SMB, *PMb;
}

View File

@ -73,28 +73,28 @@ namespace WelsSVCEnc {
*/
/* Single/multiple slices */
typedef struct SlicepEncCtx_s {
SliceModeEnum uiSliceMode; /* 0: single slice in frame; 1: multiple slices in frame; */
int16_t iMbWidth; /* width of picture size in mb */
int16_t iMbHeight; /* height of picture size in mb */
int16_t iSliceNumInFrame; /* count number of slices in frame; */
int32_t iMbNumInFrame; /* count number of MBs in frame */
uint8_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */
int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
uint32_t uiSliceSizeConstraint;/*in byte*/
int32_t iMaxSliceNumConstraint;/*maximal number of slices constraint*/
SliceModeEnum uiSliceMode; /* 0: single slice in frame; 1: multiple slices in frame; */
int16_t iMbWidth; /* width of picture size in mb */
int16_t iMbHeight; /* height of picture size in mb */
int16_t iSliceNumInFrame; /* count number of slices in frame; */
int32_t iMbNumInFrame; /* count number of MBs in frame */
uint8_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */
int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
uint32_t uiSliceSizeConstraint;/*in byte*/
int32_t iMaxSliceNumConstraint;/*maximal number of slices constraint*/
} SSliceCtx;
typedef struct TagDynamicSlicingStack {
int32_t iStartPos;
int32_t iCurrentPos;
int32_t iStartPos;
int32_t iCurrentPos;
uint8_t* pBsStackBufPtr; // current writing position
uint32_t uiBsStackCurBits;
int32_t iBsStackLeftBits;
uint8_t* pBsStackBufPtr; // current writing position
uint32_t uiBsStackCurBits;
int32_t iBsStackLeftBits;
int32_t iMbSkipRunStack;
int32_t iMbSkipRunStack;
} SDynamicSlicingStack;
/*!

View File

@ -83,7 +83,7 @@ int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx,
const int32_t keNalType);
const int32_t keNalType);
void WelsInitSliceEncodingFuncs (uint32_t uiCpuFlag);
@ -94,12 +94,12 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx,
void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
int32_t iNextSliceFirstMbIdx, const int32_t kiLastMbIdxInPartition);
int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pMd,
const int32_t kiSliceFirstMbXY); // for inter non-dynamic slice
const int32_t kiSliceFirstMbXY); // for inter non-dynamic slice
int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pMd,
const int32_t kiSliceFirstMbXY); // for inter dynamic slice
const int32_t kiSliceFirstMbXY); // for inter dynamic slice
bool DynSlcJudgeSliceBoundaryStepBack (void* pEncCtx, void* pSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
SDynamicSlicingStack* pDss);
SDynamicSlicingStack* pDss);
}
#endif //SVC_ENCODE_SLICE_H__

View File

@ -61,77 +61,78 @@ enum {
ME_FULL = 0x10, // FULL
// derived ME methods combination
ME_DIA_CROSS = (ME_DIA|ME_CROSS), // DIA+CROSS
ME_DIA_CROSS_FME = (ME_DIA_CROSS|ME_FME), // DIA+CROSS+FME
ME_DIA_CROSS = (ME_DIA | ME_CROSS), // DIA+CROSS
ME_DIA_CROSS_FME = (ME_DIA_CROSS | ME_FME), // DIA+CROSS+FME
};
union SadPredISatdUnit {
uint32_t uiSadPred;
uint32_t uiSatd; //reuse the sad_pred as a temp satd pData
uint32_t uiSadPred;
uint32_t uiSatd; //reuse the sad_pred as a temp satd pData
};
typedef struct TagWelsME {
/* input */
uint16_t* pMvdCost;
union SadPredISatdUnit uSadPredISatd; //reuse the sad_pred as a temp pData
uint32_t uiSadCost; //used by ME and RC //max SAD should be max_delta*size+lambda*mvdsize = 255*256+91*33*2 = 65280 + 6006 = 71286 > (2^16)-1 = 65535
uint32_t uiSatdCost; /* satd + lm * nbits */
uint32_t uiSadCostThreshold;
int32_t iCurMeBlockPixX;
int32_t iCurMeBlockPixY;
uint8_t uiBlockSize; /* BLOCK_WxH */
uint8_t uiReserved;
/* input */
uint16_t* pMvdCost;
union SadPredISatdUnit uSadPredISatd; //reuse the sad_pred as a temp pData
uint32_t
uiSadCost; //used by ME and RC //max SAD should be max_delta*size+lambda*mvdsize = 255*256+91*33*2 = 65280 + 6006 = 71286 > (2^16)-1 = 65535
uint32_t uiSatdCost; /* satd + lm * nbits */
uint32_t uiSadCostThreshold;
int32_t iCurMeBlockPixX;
int32_t iCurMeBlockPixY;
uint8_t uiBlockSize; /* BLOCK_WxH */
uint8_t uiReserved;
uint8_t* pEncMb;
uint8_t* pRefMb;
uint8_t* pColoRefMb;
uint8_t* pEncMb;
uint8_t* pRefMb;
uint8_t* pColoRefMb;
SMVUnitXY sMvp;
SMVUnitXY sMvBase;
SMVUnitXY sDirectionalMv;
SMVUnitXY sMvp;
SMVUnitXY sMvBase;
SMVUnitXY sDirectionalMv;
/* output */
SMVUnitXY sMv;
/* output */
SMVUnitXY sMv;
} SWelsME;
typedef struct TagFeatureSearchIn{
PSampleSadSatdCostFunc pSad;
typedef struct TagFeatureSearchIn {
PSampleSadSatdCostFunc pSad;
uint32_t* pTimesOfFeature;
uint16_t** pQpelLocationOfFeature;
uint16_t *pMvdCostX;
uint16_t *pMvdCostY;
uint32_t* pTimesOfFeature;
uint16_t** pQpelLocationOfFeature;
uint16_t* pMvdCostX;
uint16_t* pMvdCostY;
uint8_t* pEnc;
uint8_t* pColoRef;
int32_t iEncStride;
int32_t iRefStride;
uint16_t uiSadCostThresh;
uint8_t* pEnc;
uint8_t* pColoRef;
int32_t iEncStride;
int32_t iRefStride;
uint16_t uiSadCostThresh;
int32_t iFeatureOfCurrent;
int32_t iFeatureOfCurrent;
int32_t iCurPixX;
int32_t iCurPixY;
int32_t iCurPixXQpel;
int32_t iCurPixYQpel;
int32_t iCurPixX;
int32_t iCurPixY;
int32_t iCurPixXQpel;
int32_t iCurPixYQpel;
int32_t iMinQpelX;
int32_t iMinQpelY;
int32_t iMaxQpelX;
int32_t iMaxQpelY;
}SFeatureSearchIn;
int32_t iMinQpelX;
int32_t iMinQpelY;
int32_t iMaxQpelX;
int32_t iMaxQpelY;
} SFeatureSearchIn;
typedef struct TagFeatureSearchOut{
SMVUnitXY sBestMv;
uint32_t uiBestSadCost;
uint8_t* pBestRef;
}SFeatureSearchOut;
typedef struct TagFeatureSearchOut {
SMVUnitXY sBestMv;
uint32_t uiBestSadCost;
uint8_t* pBestRef;
} SFeatureSearchOut;
#define COST_MVD(table, mx, my) (table[mx] + table[my])
extern const int32_t QStepx16ByQp[52];
// Function definitions below
void WelsInitMeFunc( SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScreenContent );
void WelsInitMeFunc (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScreenContent);
/*!
* \brief BL mb motion estimate search
@ -179,45 +180,47 @@ bool WelsMotionEstimateInitialPoint (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
*
* \return NONE
*/
void WelsDiamondSearch (SWelsFuncPtrList* pFuncList, void* pLpme, void* pLpslice, const int32_t kiEncStride, const int32_t kiRefStride);
void WelsDiamondSearch (SWelsFuncPtrList* pFuncList, void* pLpme, void* pLpslice, const int32_t kiEncStride,
const int32_t kiRefStride);
bool WelsMeSadCostSelect (int32_t* pSadCost, const uint16_t* kpMvdCost, int32_t* pBestCost, const int32_t kiDx,
const int32_t kiDy, int32_t* pIx, int32_t* pIy);
const int32_t kiDy, int32_t* pIx, int32_t* pIy);
void CalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride );
void NotCalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride );
bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost);
bool CheckDirectionalMvFalse(PSampleSadSatdCostFunc pSad, void * vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost);
void CalculateSatdCost (PSampleSadSatdCostFunc pSatd, void* vpMe, const int32_t kiEncStride, const int32_t kiRefStride);
void NotCalculateSatdCost (PSampleSadSatdCostFunc pSatd, void* vpMe, const int32_t kiEncStride,
const int32_t kiRefStride);
bool CheckDirectionalMv (PSampleSadSatdCostFunc pSad, void* vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost);
bool CheckDirectionalMvFalse (PSampleSadSatdCostFunc pSad, void* vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost);
// Cross Search Basics
void LineFullSearch_c( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch );
void LineFullSearch_c (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch);
#ifdef X86_ASM
extern "C"
{
uint32_t SampleSad8x8Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
uint32_t SampleSad16x16Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
uint32_t SampleSad8x8Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
uint32_t SampleSad16x16Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
}
void VerticalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch );
void HorizontalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch );
void VerticalFullSearchUsingSSE41 (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch);
void HorizontalFullSearchUsingSSE41 (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch);
#endif
void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SWelsME * pMe, const SSlice* pSlice);
void WelsMotionCrossSearch (SWelsFuncPtrList* pFuncList, SDqLayer* pCurLayer, SWelsME* pMe, const SSlice* pSlice);
// Feature Search Basics
#define LIST_SIZE_SUM_16x16 0x0FF01 //(256*255+1)
@ -228,48 +231,53 @@ void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SW
#define FMESWITCH_DEFAULT_GOODFRAME_NUM (2)
#define FMESWITCH_MBSAD_THRESHOLD 30 // empirically set.
int32_t SumOf8x8SingleBlock_c(uint8_t* pRef, const int32_t kiRefStride);
int32_t SumOf16x16SingleBlock_c(uint8_t* pRef, const int32_t kiRefStride);
void SumOf8x8BlockOfFrame_c(uint8_t *pRefPicture, const int32_t kiWidth, const int32_t kiHeight, const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]);
void SumOf16x16BlockOfFrame_c(uint8_t *pRefPicture, const int32_t kiWidth, const int32_t kiHeight, const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]);
int32_t RequestScreenBlockFeatureStorage( CMemoryAlign *pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight, const int32_t iNeedFeatureStorage,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage);
int32_t ReleaseScreenBlockFeatureStorage( CMemoryAlign *pMa, SScreenBlockFeatureStorage* pScreenBlockFeatureStorage );
int32_t RequestFeatureSearchPreparation( CMemoryAlign *pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight, const int32_t iNeedFeatureStorage,
SFeatureSearchPreparation* pFeatureSearchPreparation);
int32_t ReleaseFeatureSearchPreparation( CMemoryAlign *pMa, uint16_t*& pFeatureOfBlock);
int32_t SumOf8x8SingleBlock_c (uint8_t* pRef, const int32_t kiRefStride);
int32_t SumOf16x16SingleBlock_c (uint8_t* pRef, const int32_t kiRefStride);
void SumOf8x8BlockOfFrame_c (uint8_t* pRefPicture, const int32_t kiWidth, const int32_t kiHeight,
const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]);
void SumOf16x16BlockOfFrame_c (uint8_t* pRefPicture, const int32_t kiWidth, const int32_t kiHeight,
const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]);
int32_t RequestScreenBlockFeatureStorage (CMemoryAlign* pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight,
const int32_t iNeedFeatureStorage,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage);
int32_t ReleaseScreenBlockFeatureStorage (CMemoryAlign* pMa, SScreenBlockFeatureStorage* pScreenBlockFeatureStorage);
int32_t RequestFeatureSearchPreparation (CMemoryAlign* pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight,
const int32_t iNeedFeatureStorage,
SFeatureSearchPreparation* pFeatureSearchPreparation);
int32_t ReleaseFeatureSearchPreparation (CMemoryAlign* pMa, uint16_t*& pFeatureOfBlock);
#define FMESWITCH_DEFAULT_GOODFRAME_NUM (2)
#define FME_DEFAULT_FEATURE_INDEX (0)
void PerformFMEPreprocess( SWelsFuncPtrList *pFunc, SPicture* pRef, uint16_t* pFeatureOfBlock,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage);
void UpdateFMESwitch(SDqLayer* pCurLayer);
void UpdateFMESwitchNull(SDqLayer* pCurLayer);
void PerformFMEPreprocess (SWelsFuncPtrList* pFunc, SPicture* pRef, uint16_t* pFeatureOfBlock,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage);
void UpdateFMESwitch (SDqLayer* pCurLayer);
void UpdateFMESwitchNull (SDqLayer* pCurLayer);
//inline functions
inline void SetMvWithinIntegerMvRange( const int32_t kiMbWidth, const int32_t kiMbHeight, const int32_t kiMbX, const int32_t kiMbY,
const int32_t kiMaxMvRange,
SMVUnitXY* pMvMin, SMVUnitXY* pMvMax) {
pMvMin->iMvX = WELS_MAX(-1*((kiMbX + 1)<<4) + INTPEL_NEEDED_MARGIN, -1*kiMaxMvRange);
pMvMin->iMvY = WELS_MAX(-1*((kiMbY + 1)<<4) + INTPEL_NEEDED_MARGIN, -1*kiMaxMvRange);
pMvMax->iMvX = WELS_MIN( ((kiMbWidth - kiMbX)<<4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
pMvMax->iMvY = WELS_MIN( ((kiMbHeight - kiMbY)<<4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
inline void SetMvWithinIntegerMvRange (const int32_t kiMbWidth, const int32_t kiMbHeight, const int32_t kiMbX,
const int32_t kiMbY,
const int32_t kiMaxMvRange,
SMVUnitXY* pMvMin, SMVUnitXY* pMvMax) {
pMvMin->iMvX = WELS_MAX (-1 * ((kiMbX + 1) << 4) + INTPEL_NEEDED_MARGIN, -1 * kiMaxMvRange);
pMvMin->iMvY = WELS_MAX (-1 * ((kiMbY + 1) << 4) + INTPEL_NEEDED_MARGIN, -1 * kiMaxMvRange);
pMvMax->iMvX = WELS_MIN (((kiMbWidth - kiMbX) << 4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
pMvMax->iMvY = WELS_MIN (((kiMbHeight - kiMbY) << 4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
}
inline bool CheckMvInRange( const int16_t kiCurrentMv, const int16_t kiMinMv, const int16_t kiMaxMv ) {
inline bool CheckMvInRange (const int16_t kiCurrentMv, const int16_t kiMinMv, const int16_t kiMaxMv) {
return ((kiCurrentMv >= kiMinMv) && (kiCurrentMv < kiMaxMv));
}
inline bool CheckMvInRange( const SMVUnitXY ksCurrentMv, const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv ) {
return (CheckMvInRange(ksCurrentMv.iMvX, ksMinMv.iMvX, ksMaxMv.iMvX)
&& CheckMvInRange(ksCurrentMv.iMvY, ksMinMv.iMvY, ksMaxMv.iMvY));
inline bool CheckMvInRange (const SMVUnitXY ksCurrentMv, const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv) {
return (CheckMvInRange (ksCurrentMv.iMvX, ksMinMv.iMvX, ksMaxMv.iMvX)
&& CheckMvInRange (ksCurrentMv.iMvY, ksMinMv.iMvY, ksMaxMv.iMvY));
}
//FME switch related
inline bool CalcFMESwitchFlag(const uint8_t uiFMEGoodFrameCount, const int32_t iHighFreMbPrecentage,
const int32_t iAvgMbSAD, const bool bScrollingDetected ) {
return ( bScrollingDetected ||( uiFMEGoodFrameCount>0 && iAvgMbSAD > FMESWITCH_MBSAD_THRESHOLD ) );
inline bool CalcFMESwitchFlag (const uint8_t uiFMEGoodFrameCount, const int32_t iHighFreMbPrecentage,
const int32_t iAvgMbSAD, const bool bScrollingDetected) {
return (bScrollingDetected || (uiFMEGoodFrameCount > 0 && iAvgMbSAD > FMESWITCH_MBSAD_THRESHOLD));
//TODO: add the logic of iHighFreMbPrecentage
//return ( iHighFreMbPrecentage > 2
// && ( bScrollingDetected || iHighFreMbPrecentage >15

View File

@ -51,14 +51,14 @@ namespace WelsSVCEnc {
typedef int32_t iWelsLogLevel;
enum {
WELS_LOG_QUIET = 0x00, // Quiet mode
WELS_LOG_ERROR = 1 << 0, // Error log iLevel
WELS_LOG_WARNING = 1 << 1, // Warning log iLevel
WELS_LOG_INFO = 1 << 2, // Information log iLevel
WELS_LOG_DEBUG = 1 << 3, // Debug log iLevel
WELS_LOG_RESV = 1 << 4, // Resversed log iLevel
WELS_LOG_LEVEL_COUNT = 5,
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG // Default log iLevel in Wels codec
WELS_LOG_QUIET = 0x00, // Quiet mode
WELS_LOG_ERROR = 1 << 0, // Error log iLevel
WELS_LOG_WARNING = 1 << 1, // Warning log iLevel
WELS_LOG_INFO = 1 << 2, // Information log iLevel
WELS_LOG_DEBUG = 1 << 3, // Debug log iLevel
WELS_LOG_RESV = 1 << 4, // Resversed log iLevel
WELS_LOG_LEVEL_COUNT = 5,
WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG // Default log iLevel in Wels codec
};
/*

View File

@ -58,36 +58,36 @@ extern const ALIGNED_DECLARE (uint8_t, g_kuiEncNcMapTable[18], 16);
static inline int32_t WriteTotalCoeffTrailingones (SBitStringAux* pBs, uint8_t uiNc, uint8_t uiTotalCoeff,
uint8_t uiTrailingOnes) {
const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc];
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc];
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
}
static inline int32_t WriteTotalcoeffTrailingonesChroma (SBitStringAux* pBs, uint8_t uiTotalCoeff,
uint8_t uiTrailingOnes) {
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
}
//kuiZeroCount = level_prefix;
static inline int32_t WriteLevelPrefix (SBitStringAux* pBs, const uint32_t kuiZeroCount) {
BsWriteBits (pBs, kuiZeroCount + 1, 1);
return 0;
BsWriteBits (pBs, kuiZeroCount + 1, 1);
return 0;
}
static inline int32_t WriteTotalZeros (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]);
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]);
}
static inline int32_t WriteTotalZerosChromaDc (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
const uint8_t* kpTotalZerosChromaDc = &g_kuiVlcTotalZerosChromaDc[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZerosChromaDc[1], kpTotalZerosChromaDc[0]);
const uint8_t* kpTotalZerosChromaDc = &g_kuiVlcTotalZerosChromaDc[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZerosChromaDc[1], kpTotalZerosChromaDc[0]);
}
static inline int32_t WriteRunBefore (SBitStringAux* pBs, uint8_t uiZeroLeft, uint8_t uiRunBefore) {
const uint8_t* kpRunBefore = &g_kuiVlcRunBefore[uiZeroLeft][uiRunBefore][0];
return BsWriteBits (pBs, kpRunBefore[1], kpRunBefore[0]);
const uint8_t* kpRunBefore = &g_kuiVlcRunBefore[uiZeroLeft][uiRunBefore][0];
return BsWriteBits (pBs, kpRunBefore[1], kpRunBefore[0]);
}
}
#endif

View File

@ -50,38 +50,38 @@ extern const uint8_t g_kuiChromaQpTable[52];
* NAL Unit Type (5 Bits)
*/
enum EWelsNalUnitType {
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
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
};
/*
@ -89,10 +89,10 @@ NAL_UNIT_UNSPEC_31 = 31
*/
enum EWelsNalRefIdc {
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
};
/*
@ -100,9 +100,9 @@ NRI_PRI_HIGHEST = 3
*/
enum EVclType {
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
};
/*
@ -129,64 +129,64 @@ extern const EVclType g_keTypeMap[32][2];
*/
enum EWelsSliceType {
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
};
/* SSlice Types in scalable extension */ ;
enum ESliceTypeExt {
EP_SLICE = 0, // EP_SLICE: 0, 5
EB_SLICE = 1, // EB_SLICE: 1, 6
EI_SLICE = 2 // EI_SLICE: 2, 7
EP_SLICE = 0, // EP_SLICE: 0, 5
EB_SLICE = 1, // EB_SLICE: 1, 6
EI_SLICE = 2 // EI_SLICE: 2, 7
};
/* List Index */
enum EListIndex {
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
};
struct SMVUnitXY { // each 4 Bytes
int16_t iMvX;
int16_t iMvY;
int16_t iMvX;
int16_t iMvY;
public:
SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) {
iMvX = _v0.iMvX - _v1.iMvX;
iMvY = _v0.iMvY - _v1.iMvY;
return (*this);
}
SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) {
iMvX = _v0.iMvX - _v1.iMvX;
iMvY = _v0.iMvY - _v1.iMvY;
return (*this);
}
};
typedef struct TagMVComponentUnit { // each LIST_0/LIST_1
SMVUnitXY sMotionVectorCache[5 * 6 - 1]; // Luma only: 5 x 6 - 1 = 29 D-Words
int8_t iRefIndexCache[5 * 6]; // Luma only: 5 x 6 = 30 bytes
SMVUnitXY sMotionVectorCache[5 * 6 - 1]; // Luma only: 5 x 6 - 1 = 29 D-Words
int8_t iRefIndexCache[5 * 6]; // Luma only: 5 x 6 = 30 bytes
} SMVComponentUnit, *PMVComponentUnit;
typedef struct TagParaSetOffsetVariable {
int32_t iParaSetIdDelta[MAX_DQ_LAYER_NUM/*+1*/]; //mark delta between SPS_ID_in_bs and sps_id_in_encoder, can be minus, for each dq-layer
int32_t iParaSetIdDelta[MAX_DQ_LAYER_NUM/*+1*/]; //mark delta between SPS_ID_in_bs and sps_id_in_encoder, can be minus, for each dq-layer
//need not extra +1 due no MGS and FMO case so far
bool bUsedParaSetIdInBs[MAX_PPS_COUNT]; //mark the used SPS_ID with 1
uint32_t uiNextParaSetIdToUseInBs; //mark the next SPS_ID_in_bs, for all layers
bool bUsedParaSetIdInBs[MAX_PPS_COUNT]; //mark the used SPS_ID with 1
uint32_t uiNextParaSetIdToUseInBs; //mark the next SPS_ID_in_bs, for all layers
} SParaSetOffsetVariable;
typedef struct TagParaSetOffset {
//in PS0 design, "sParaSetOffsetVariable" record the previous paras before current IDR, AND NEED to be stacked and recover across IDR
SParaSetOffsetVariable
sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS
SParaSetOffsetVariable
sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS
//in PSO design, "bPpsIdMappingIntoSubsetsps" uses the current para of current IDR period
bool
bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
uint16_t
uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR!! Can we just NOT put this into the SParaSetOffset structure?!!
bool
bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
uint16_t
uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR!! Can we just NOT put this into the SParaSetOffset structure?!!
#if _DEBUG
bool bEnableSpsPpsIdAddition;
bool bEnableSpsPpsIdAddition;
#endif
} SParaSetOffset;
@ -194,47 +194,47 @@ bool bEnableSpsPpsIdAddition;
/* Motion Vector components */
enum EMvComp {
MV_X = 0,
MV_Y = 1,
MV_A = 2
MV_X = 0,
MV_Y = 1,
MV_A = 2
};
/* Chroma Components */
enum EChromaComp {
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
};
/* Position Offset structure */
typedef struct TagCropOffset {
int16_t iCropLeft;
int16_t iCropRight;
int16_t iCropTop;
int16_t iCropBottom;
int16_t iCropLeft;
int16_t iCropRight;
int16_t iCropTop;
int16_t iCropBottom;
} SCropOffset;
/* Transform Type */
enum ETransType {
T_4x4 = 0,
T_8x8 = 1,
T_16x16 = 2,
T_PCM = 3
T_4x4 = 0,
T_8x8 = 1,
T_16x16 = 2,
T_PCM = 3
};
enum EMbPosition {
LEFT_MB_POS = 0x01, // A
TOP_MB_POS = 0x02, // B
TOPRIGHT_MB_POS = 0x04, // C
TOPLEFT_MB_POS = 0x08, // D,
RIGHT_MB_POS = 0x10, // add followed four case to reuse when intra up-sample
BOTTOM_MB_POS = 0x20, //
BOTTOMRIGHT_MB_POS = 0x40, //
BOTTOMLEFT_MB_POS = 0x80, //
MB_POS_A = 0x100
LEFT_MB_POS = 0x01, // A
TOP_MB_POS = 0x02, // B
TOPRIGHT_MB_POS = 0x04, // C
TOPLEFT_MB_POS = 0x08, // D,
RIGHT_MB_POS = 0x10, // add followed four case to reuse when intra up-sample
BOTTOM_MB_POS = 0x20, //
BOTTOMRIGHT_MB_POS = 0x40, //
BOTTOMLEFT_MB_POS = 0x80, //
MB_POS_A = 0x100
};
#define MB_ON_PIC_BOUNDRY (RIGHT_MB_POS|BOTTOM_MB_POS|LEFT_MB_POS|TOP_MB_POS)
@ -301,13 +301,13 @@ typedef uint32_t Mb_Type;
enum {
Intra4x4 = 0,
Intra16x16 = 1,
Inter16x16 = 2,
Inter16x8 = 3,
Inter8x16 = 4,
Inter8x8 = 5,
PSkip = 6
Intra4x4 = 0,
Intra16x16 = 1,
Inter16x16 = 2,
Inter16x8 = 3,
Inter8x16 = 4,
Inter8x8 = 5,
PSkip = 6
};
@ -315,13 +315,13 @@ PSkip = 6
* Memory Management Control Operation (MMCO) code
*/
enum EMmcoCode {
MMCO_END = 0,
MMCO_SHORT2UNUSED = 1,
MMCO_LONG2UNUSED = 2,
MMCO_SHORT2LONG = 3,
MMCO_SET_MAX_LONG = 4,
MMCO_RESET = 5,
MMCO_LONG = 6
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

View File

@ -96,7 +96,8 @@ typedef void (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr
int32_t iBeta, int8_t* iTc);
typedef void (*PChromaDeblockingEQ4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
int32_t iBeta);
typedef void (*PDeblockingBSCalc) (SWelsFuncPtrList* pFunc, SMB* pCurMb, uint8_t uiBS[2][4][4], Mb_Type uiCurMbType, int32_t iMbStride, int32_t iLeftFlag, int32_t iTopFlag);
typedef void (*PDeblockingBSCalc) (SWelsFuncPtrList* pFunc, SMB* pCurMb, uint8_t uiBS[2][4][4], Mb_Type uiCurMbType,
int32_t iMbStride, int32_t iLeftFlag, int32_t iTopFlag);
typedef struct tagDeblockingFunc {
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
@ -142,23 +143,26 @@ typedef int32_t (*PIntraPred16x16Combined3Func) (uint8_t*, int32_t, uint8_t*, in
typedef int32_t (*PIntraPred8x8Combined3Func) (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*,
uint8_t*, uint8_t*);
typedef uint32_t (*PSampleSadHor8Func)( uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t* );
typedef uint32_t (*PSampleSadHor8Func) (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
typedef void (*PMotionSearchFunc) (SWelsFuncPtrList* pFuncList, void* pCurDqLayer, void* pMe,
void* pSlice);
typedef void (*PSearchMethodFunc) (SWelsFuncPtrList* pFuncList, void* pMe, void* pSlice, const int32_t kiEncStride, const int32_t kiRefStride);
typedef void (*PCalculateSatdFunc) ( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride );
typedef bool (*PCheckDirectionalMv) (PSampleSadSatdCostFunc pSad, void * vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost);
typedef void (*PLineFullSearchFunc) ( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch );
typedef void (*PCalculateBlockFeatureOfFrame)(uint8_t *pRef, const int32_t kiWidth, const int32_t kiHeight, const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]);
typedef int32_t (*PCalculateSingleBlockFeature)(uint8_t *pRef, const int32_t kiRefStride);
typedef void (*PUpdateFMESwitch)(SDqLayer* pCurLayer);
typedef void (*PSearchMethodFunc) (SWelsFuncPtrList* pFuncList, void* pMe, void* pSlice, const int32_t kiEncStride,
const int32_t kiRefStride);
typedef void (*PCalculateSatdFunc) (PSampleSadSatdCostFunc pSatd, void* vpMe, const int32_t kiEncStride,
const int32_t kiRefStride);
typedef bool (*PCheckDirectionalMv) (PSampleSadSatdCostFunc pSad, void* vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost);
typedef void (*PLineFullSearchFunc) (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
uint16_t* pMvdTable, const int32_t kiFixedMvd,
const int32_t kiEncStride, const int32_t kiRefStride,
const int32_t kiMinPos, const int32_t kiMaxPos,
const bool bVerticalSearch);
typedef void (*PCalculateBlockFeatureOfFrame) (uint8_t* pRef, const int32_t kiWidth, const int32_t kiHeight,
const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]);
typedef int32_t (*PCalculateSingleBlockFeature) (uint8_t* pRef, const int32_t kiRefStride);
typedef void (*PUpdateFMESwitch) (SDqLayer* pCurLayer);
#define MAX_BLOCK_TYPE 5 // prev 7
typedef struct TagSampleDealingFunc {
@ -183,8 +187,8 @@ typedef int32_t (*PGetVarianceFromIntraVaaFunc) (uint8_t* pSampelY, const int32_
typedef uint8_t (*PGetMbSignFromInterVaaFunc) (int32_t* pSad8x8);
typedef void (*PUpdateMbMvFunc) (SMVUnitXY* pMvUnit, const SMVUnitXY ksMv);
typedef bool (*PBuildRefListFunc)(void* pCtx, const int32_t iPOC,int32_t iBestLtrRefIdx);
typedef void (*PMarkPicFunc)(void* pCtx);
typedef bool (*PBuildRefListFunc) (void* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx);
typedef void (*PMarkPicFunc) (void* pCtx);
typedef bool (*PUpdateRefListFunc) (void* pCtx);
struct TagWelsFuncPointerList {

View File

@ -62,19 +62,19 @@ typedef struct {
typedef struct {
int32_t iMinFrameComplexity;
int32_t iMinFrameComplexity;
int32_t iMinFrameComplexity08;
int32_t iMinFrameComplexity11;
int32_t iMinFrameNumGap;
int32_t iMinFrameQp;
}SRefJudgement;
} SRefJudgement;
typedef struct {
SPicture *pRefPicture;
SPicture* pRefPicture;
int32_t iSrcListIdx; //idx in h->spatial_pic[base_did];
bool bSceneLtrFlag;
}SRefInfoParam;
} SRefInfoParam;
typedef struct {
SVAACalcResult sVaaCalcInfo;
@ -102,17 +102,16 @@ typedef struct {
bool bIdrPeriodFlag;
} SVAAFrameInfo;
typedef struct SVAAFrameInfoExt_t: public SVAAFrameInfo
{
typedef struct SVAAFrameInfoExt_t: public SVAAFrameInfo {
SComplexityAnalysisScreenParam sComplexityScreenParam;
SScrollDetectionResult sScrollDetectInfo;
//TOP3_BEST_REF_NO_TID
//TOP3_BEST_REF_NO_TID
SRefInfoParam sVaaStrBestRefCandidate[MAX_REF_PIC_COUNT];
int32_t iNumOfAvailableRef;
uint8_t *pVaaBestBlockStaticIdc;//pointer
uint8_t *pVaaBlockStaticIdc[16];//real memory,
}SVAAFrameInfoExt;
uint8_t* pVaaBestBlockStaticIdc;//pointer
uint8_t* pVaaBlockStaticIdc[16];//real memory,
} SVAAFrameInfoExt;
class CWelsPreProcess {
public:
@ -125,8 +124,9 @@ class CWelsPreProcess {
void FreeSpatialPictures (sWelsEncCtx* pCtx);
int32_t BuildSpatialPicList (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrcPic);
int32_t AnalyzeSpatialPic (sWelsEncCtx* pEncCtx, const int32_t kiDIdx);
int32_t UpdateSpatialPictures(sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, const int8_t iCurTid, const int32_t d_idx);
int32_t GetRefCandidateLtrIndex(int32_t iRefIdx);
int32_t UpdateSpatialPictures (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, const int8_t iCurTid,
const int32_t d_idx);
int32_t GetRefCandidateLtrIndex (int32_t iRefIdx);
void AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCurPicture, SPicture* pRefPicture,
const int32_t kiDependencyId, const bool kbCalculateBGD);
@ -156,17 +156,19 @@ class CWelsPreProcess {
void WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SPicture* pDstPic, const SSourcePicture* kpSrc,
const int32_t kiWidth, const int32_t kiHeight);
ESceneChangeIdc DetectSceneChangeScreen(sWelsEncCtx* pCtx,SPicture* pCurPicture);
void InitPixMap( const SPicture *pPicture, SPixMap *pPixMap );
void GetAvailableRefList(SPicture ** pSrcPicList,uint8_t iCurTid, const int32_t iClosestLtrFrameNum,
SRefInfoParam* pAvailableRefList, int32_t& iAvailableRefNum, int32_t& iAvailableSceneRefNum);
void InitRefJudgement( SRefJudgement *pRefJudgement );
bool JudgeBestRef(SPicture* pRefPic,const SRefJudgement& sRefJudgement, const int32_t iFrameComplexity, const bool bIsClosestLtrFrame);
void SaveBestRefToJudgement(const int32_t iRefPictureAvQP, const int32_t iComplexity, SRefJudgement* pRefJudgement);
void SaveBestRefToLocal(SRefInfoParam *pRefPicInfo,const SSceneChangeResult& sSceneChangeResult, SRefInfoParam* pRefSaved);
void SaveBestRefToVaa(SRefInfoParam& sRefSaved,SRefInfoParam* pVaaBestRef);
ESceneChangeIdc DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPicture* pCurPicture);
void InitPixMap (const SPicture* pPicture, SPixMap* pPixMap);
void GetAvailableRefList (SPicture** pSrcPicList, uint8_t iCurTid, const int32_t iClosestLtrFrameNum,
SRefInfoParam* pAvailableRefList, int32_t& iAvailableRefNum, int32_t& iAvailableSceneRefNum);
void InitRefJudgement (SRefJudgement* pRefJudgement);
bool JudgeBestRef (SPicture* pRefPic, const SRefJudgement& sRefJudgement, const int32_t iFrameComplexity,
const bool bIsClosestLtrFrame);
void SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int32_t iComplexity, SRefJudgement* pRefJudgement);
void SaveBestRefToLocal (SRefInfoParam* pRefPicInfo, const SSceneChangeResult& sSceneChangeResult,
SRefInfoParam* pRefSaved);
void SaveBestRefToVaa (SRefInfoParam& sRefSaved, SRefInfoParam* pVaaBestRef);
private:
private:
Scaled_Picture m_sScaledPicture;
SPicture* m_pLastSpatialPicture[MAX_DEPENDENCY_LAYER][2];
IWelsVP* m_pInterfaceVp;
@ -174,7 +176,7 @@ private:
bool m_bInitDone;
uint8_t m_uiSpatialLayersInTemporal[MAX_DEPENDENCY_LAYER];
uint8_t m_uiSpatialPicNum[MAX_DEPENDENCY_LAYER];
public:
public:
/* For Downsampling & VAA I420 based source pictures */
SPicture* m_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)

View File

@ -39,15 +39,19 @@ namespace WelsSVCEnc {
#ifdef X86_ASM
extern "C"
{
void TransposeMatrixBlocksx16_sse2( void *pDst, const int32_t kiDstStride, void *pSrc, const int32_t kiSrcStride, const int32_t kiBlocksNum );
void TransposeMatrixBlock16x16_sse2( void *pDst, const int32_t kiDstStride, void *pSrc, const int32_t kiSrcStride );
void TransposeMatrixBlocksx8_mmx( void *pDst, const int32_t kiDstStride, void *pSrc, const int32_t kiSrcStride, const int32_t kiBlocksNum );
void TransposeMatrixBlock8x8_mmx( void *pDst, const int32_t kiDstStride, void *pSrc, const int32_t kiSrcStride );
void TransposeMatrixBlocksx16_sse2 (void* pDst, const int32_t kiDstStride, void* pSrc, const int32_t kiSrcStride,
const int32_t kiBlocksNum);
void TransposeMatrixBlock16x16_sse2 (void* pDst, const int32_t kiDstStride, void* pSrc, const int32_t kiSrcStride);
void TransposeMatrixBlocksx8_mmx (void* pDst, const int32_t kiDstStride, void* pSrc, const int32_t kiSrcStride,
const int32_t kiBlocksNum);
void TransposeMatrixBlock8x8_mmx (void* pDst, const int32_t kiDstStride, void* pSrc, const int32_t kiSrcStride);
}
#endif
typedef void (*PTransposeMatrixBlockFunc)( void *pDst, const int32_t kiDstStride, void *pSrc, const int32_t kiSrcStride );
typedef void (*PTransposeMatrixBlocksFunc)( void *pDst, const int32_t kiDstStride, void *pSrc, const int32_t kiSrcStride, const int32_t kiBlocksNum );
typedef void (*PTransposeMatrixBlockFunc) (void* pDst, const int32_t kiDstStride, void* pSrc,
const int32_t kiSrcStride);
typedef void (*PTransposeMatrixBlocksFunc) (void* pDst, const int32_t kiDstStride, void* pSrc,
const int32_t kiSrcStride, const int32_t kiBlocksNum);
}// end of namespace declaration

View File

@ -404,8 +404,8 @@ int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t k
//for Scalable Baseline, Scalable High, and Scalable High Intra profiles.If level_idc is equal to 9, the indicated level is level 1b.
//for the Baseline, Constrained Baseline, Main, and Extended profiles,If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
if((pSps->iLevelIdc == 9)&&
((pSps->uiProfileIdc == PRO_BASELINE) ||(pSps->uiProfileIdc == PRO_MAIN)||(pSps->uiProfileIdc == PRO_EXTENDED))) {
if ((pSps->iLevelIdc == 9) &&
((pSps->uiProfileIdc == PRO_BASELINE) || (pSps->uiProfileIdc == PRO_MAIN) || (pSps->uiProfileIdc == PRO_EXTENDED))) {
pSps->iLevelIdc = 11;
pSps->bConstraintSet3Flag = true;
}

View File

@ -193,25 +193,25 @@ void inline DeblockingBSInsideMBNormal (SMB* pCurMb, uint8_t uiBS[2][4][4], int8
uiNnz32b3 = * (uint32_t*) (pNnzTab + 12);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
uiBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 1, 0);
uiBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 2, 1);
uiBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 3, 2);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
uiBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 5, 4);
uiBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 6, 5);
uiBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 7, 6);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
uiBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 9, 8);
uiBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 10, 9);
uiBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 11, 10);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
uiBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 13, 12);
uiBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 14, 13);
uiBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 15, 14);
@ -240,8 +240,8 @@ uint32_t DeblockingBSMarginalMBAvcbase (SMB* pCurMb, SMB* pNeighMb, int32_t iEdg
int32_t i;
uint32_t uiBSx4;
uint8_t* pBS = (uint8_t*) (&uiBSx4);
const uint8_t *pBIdx = &g_kuiTableBIdx[iEdge][0];
const uint8_t *pBnIdx = &g_kuiTableBIdx[iEdge][4];
const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0];
const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4];
for (i = 0; i < 4; i++) {
@ -792,7 +792,7 @@ void WelsNonZeroCount_c (int8_t* pNonZeroCount) {
void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu) {
*pfSetNZCZero = WelsNonZeroCount_c;
#ifdef HAVE_NEON
if( iCpu & WELS_CPU_NEON ) {
if (iCpu & WELS_CPU_NEON) {
*pfSetNZCZero = WelsNonZeroCount_neon;
}
#endif
@ -826,7 +826,7 @@ void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu) {
#endif
#if defined(HAVE_NEON)
if (iCpu & WELS_CPU_NEON ) {
if (iCpu & WELS_CPU_NEON) {
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_neon;
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_neon;
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_neon;

View File

@ -259,15 +259,15 @@ void WelsInitReconstructionFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFl
#if defined(X86_ASM)
if (uiCpuFlag & WELS_CPU_MMXEXT) {
pFuncList->pfIDctT4 = WelsIDctT4Rec_mmx;
pFuncList->pfIDctT4 = WelsIDctT4Rec_mmx;
}
if (uiCpuFlag & WELS_CPU_SSE2) {
pFuncList->pfDequantization4x4 = WelsDequant4x4_sse2;
pFuncList->pfDequantizationFour4x4 = WelsDequantFour4x4_sse2;
pFuncList->pfDequantizationIHadamard4x4 = WelsDequantIHadamard4x4_sse2;
pFuncList->pfDequantization4x4 = WelsDequant4x4_sse2;
pFuncList->pfDequantizationFour4x4 = WelsDequantFour4x4_sse2;
pFuncList->pfDequantizationIHadamard4x4 = WelsDequantIHadamard4x4_sse2;
pFuncList->pfIDctFourT4 = WelsIDctFourT4Rec_sse2;
pFuncList->pfIDctI16x16Dc = WelsIDctRecI16x16Dc_sse2;
pFuncList->pfIDctFourT4 = WelsIDctFourT4Rec_sse2;
pFuncList->pfIDctI16x16Dc = WelsIDctRecI16x16Dc_sse2;
}
#endif//X86_ASM

View File

@ -450,9 +450,9 @@ int32_t WelsGetNoneZeroCount_c (int16_t* pLevel) {
}
#ifdef HAVE_NEON
int32_t WelsHadamardQuant2x2Skip_neon(int16_t* pRes, int16_t iFF, int16_t iMF) {
int16_t iThreshold = ((1<<16)-1)/iMF - iFF;
return WelsHadamardQuant2x2SkipKernel_neon(pRes, iThreshold);
int32_t WelsHadamardQuant2x2Skip_neon (int16_t* pRes, int16_t iFF, int16_t iMF) {
int16_t iThreshold = ((1 << 16) - 1) / iMF - iFF;
return WelsHadamardQuant2x2SkipKernel_neon (pRes, iThreshold);
}
#endif

View File

@ -192,7 +192,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam*
//
WelsInitBGDFunc (pFuncList, pParam->bEnableBackgroundDetection);
WelsInitScrollingSkipFunc (pFuncList, bScreenContent&&(pParam->bEnableSceneChangeDetect));
WelsInitScrollingSkipFunc (pFuncList, bScreenContent && (pParam->bEnableSceneChangeDetect));
// for pfGetVarianceFromIntraVaa function ptr adaptive by CPU features, 6/7/2010
InitIntraAnalysisVaaInfo (pFuncList, uiCpuFlag);

View File

@ -711,8 +711,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX;
const int32_t kiMe16x16 = ME_DIA_CROSS;
const int32_t kiMe8x8 = ME_DIA_CROSS_FME;
const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME)?0:
((kiFeatureStrategyIndex<<16) + ((kiMe16x16 & 0x00FF)<<8) + (kiMe8x8 & 0x00FF));
const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME) ? 0 :
((kiFeatureStrategyIndex << 16) + ((kiMe16x16 & 0x00FF) << 8) + (kiMe8x8 & 0x00FF));
iDlayerIndex = 0;
while (iDlayerIndex < iDlayerCount) {
@ -733,7 +733,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList), FreeMemorySvc (ppCtx))
do {
pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true, (iDlayerIndex == iDlayerCount-1)?kiNeedFeatureStorage:0); // to use actual size of current layer
pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true,
(iDlayerIndex == iDlayerCount - 1) ? kiNeedFeatureStorage : 0); // to use actual size of current layer
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx))
++ i;
} while (i < 1 + iNumRef);
@ -831,13 +832,14 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
}
//
if (kiNeedFeatureStorage && iDlayerIndex==iDlayerCount-1)
{
pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (SFeatureSearchPreparation), "pFeatureSearchPreparation"));
WELS_VERIFY_RETURN_PROC_IF (1, NULL==pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));
int32_t iReturn = RequestFeatureSearchPreparation(pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight, kiNeedFeatureStorage,
pDqLayer->pFeatureSearchPreparation);
WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS!=iReturn, FreeMemorySvc (ppCtx));
if (kiNeedFeatureStorage && iDlayerIndex == iDlayerCount - 1) {
pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (
SFeatureSearchPreparation), "pFeatureSearchPreparation"));
WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));
int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight,
kiNeedFeatureStorage,
pDqLayer->pFeatureSearchPreparation);
WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS != iReturn, FreeMemorySvc (ppCtx));
} else {
pDqLayer->pFeatureSearchPreparation = NULL;
}
@ -1363,19 +1365,19 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pWelsSvcRc), FreeMemorySvc (ppCtx))
//End of Rate control module memory allocation
//pVaa memory allocation
if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
(*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
if(RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)){
WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
FreeMemorySvc (ppCtx);
return 1;
}
} else {
(*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
//pVaa memory allocation
if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
(*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)) {
WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
FreeMemorySvc (ppCtx);
return 1;
}
} else {
(*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
}
if ((*ppCtx)->pSvcParam->bEnableAdaptiveQuant) { //malloc mem
(*ppCtx)->pVaa->sAdaptiveQuantParam.pMotionTextureUnit = static_cast<SMotionTextureUnit*>
@ -1585,7 +1587,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
}
if (pDq->pFeatureSearchPreparation) {
ReleaseFeatureSearchPreparation(pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);
ReleaseFeatureSearchPreparation (pMa, pDq->pFeatureSearchPreparation->pFeatureOfBlock);
pMa->WelsFree (pDq->pFeatureSearchPreparation, "pFeatureSearchPreparation");
pDq->pFeatureSearchPreparation = NULL;
}
@ -1663,8 +1665,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8");
pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL;
}
if(pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
ReleaseMemoryVaaScreen(pCtx->pVaa, pMa,pCtx->pSvcParam->iNumRefFrame);
if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iNumRefFrame);
pMa->WelsFree (pCtx->pVaa, "pVaa");
pCtx->pVaa = NULL;
}
@ -2456,19 +2458,20 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
if (P_SLICE == pCtx->eSliceType) {
//calculate bFMESwitchFlag
SVAAFrameInfoExt *pVaaExt = static_cast<SVAAFrameInfoExt *>(pCtx->pVaa);
const int32_t kiMbSize = pCurLayer->iMbHeight*pCurLayer->iMbWidth;
pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag( pFeatureSearchPreparation->uiFMEGoodFrameCount,
pFeatureSearchPreparation->iHighFreMbCount*100/kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad/kiMbSize,
pVaaExt->sScrollDetectInfo.bScrollDetectFlag);
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
const int32_t kiMbSize = pCurLayer->iMbHeight * pCurLayer->iMbWidth;
pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag (pFeatureSearchPreparation->uiFMEGoodFrameCount,
pFeatureSearchPreparation->iHighFreMbCount * 100 / kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad / kiMbSize,
pVaaExt->sScrollDetectInfo.bScrollDetectFlag);
//PerformFMEPreprocess
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage = pCurLayer->pRefPic->pScreenBlockFeatureStorage;
pFeatureSearchPreparation->pRefBlockFeature = pScreenBlockFeatureStorage;
if (pFeatureSearchPreparation->bFMESwitchFlag
&& !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
//TODO: use ORIGIN of reference when preprocessing is ready
PerformFMEPreprocess( pFuncList, pCurLayer->pRefPic,pFeatureSearchPreparation->pFeatureOfBlock,pScreenBlockFeatureStorage);
&& !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
//TODO: use ORIGIN of reference when preprocessing is ready
PerformFMEPreprocess (pFuncList, pCurLayer->pRefPic, pFeatureSearchPreparation->pFeatureOfBlock,
pScreenBlockFeatureStorage);
}
//assign ME pointer
@ -3011,9 +3014,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
#ifdef LONG_TERM_REF_DUMP
DumpRef (pCtx);
#endif
if((pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)&&(pSvcParam->iRCMode != RC_OFF_MODE))
pCtx->pVpp->AnalyzePictureComplexity(pCtx,pCtx->pEncPic,((pCtx->eSliceType == P_SLICE)&&(pCtx->iNumRef0>0))?pCtx->pRefList0[0]:NULL,
iCurDid,pSvcParam->bEnableBackgroundDetection);
if ((pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) && (pSvcParam->iRCMode != RC_OFF_MODE))
pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE)
&& (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL,
iCurDid, pSvcParam->bEnableBackgroundDetection);
WelsUpdateRefSyntax (pCtx, pCtx->iPOC,
eFrameType); //get reordering syntax used for writing slice header and transmit to encoder.
@ -3093,8 +3097,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
pCtx->iActiveThreadsNum = iSliceCount;
// to fire slice coding threads
iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
&pCtx->pSliceThreading->pThreadMasterEvent[0],
pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
&pCtx->pSliceThreading->pThreadMasterEvent[0],
pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false);
if (iRet) {
WelsLog (pCtx, WELS_LOG_ERROR,
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
@ -3132,8 +3136,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
iNumThreadsRunning = iNumThreadsScheduled;
// to fire slice coding threads
iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
&pCtx->pSliceThreading->pThreadMasterEvent[0],
pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
&pCtx->pSliceThreading->pThreadMasterEvent[0],
pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false);
if (iRet) {
WelsLog (pCtx, WELS_LOG_ERROR,
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
@ -3178,8 +3182,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
// to fire slice coding threads
iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
&pCtx->pSliceThreading->pThreadMasterEvent[0],
pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
&pCtx->pSliceThreading->pThreadMasterEvent[0],
pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true);
if (iRet) {
WelsLog (pCtx, WELS_LOG_ERROR,
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",

View File

@ -137,11 +137,11 @@ void InitExpandPictureFunc (void* pL, const uint32_t kuiCPUFlag) {
}
#endif//HAVE_NEON
#if defined(HAVE_NEON_AARCH64)
if (kuiCPUFlag & WELS_CPU_NEON) {
pFuncList->pfExpandLumaPicture = ExpandPictureLuma_AArch64_neon;
pFuncList->pfExpandChromaPicture[0] = ExpandPictureChroma_AArch64_neon;
pFuncList->pfExpandChromaPicture[1] = ExpandPictureChroma_AArch64_neon;
}
if (kuiCPUFlag & WELS_CPU_NEON) {
pFuncList->pfExpandLumaPicture = ExpandPictureLuma_AArch64_neon;
pFuncList->pfExpandChromaPicture[0] = ExpandPictureChroma_AArch64_neon;
pFuncList->pfExpandChromaPicture[1] = ExpandPictureChroma_AArch64_neon;
}
#endif//HAVE_NEON_AARCH64
}

View File

@ -729,7 +729,7 @@ void WelsInitIntraPredFuncs (SWelsFuncPtrList* pFuncList, const uint32_t kuiCpuF
pFuncList->pfGetChromaPred[C_PRED_V] = WelsIChromaPredV_neon;
pFuncList->pfGetChromaPred[C_PRED_P] = WelsIChromaPredPlane_neon;
pFuncList->pfGetChromaPred[C_PRED_H] = WelsIChromaPredH_neon;
}
}
#endif
#ifdef X86_ASM

View File

@ -120,14 +120,15 @@ void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBsIn) {
*/
//TODO 1: refactor the calling of this func in multi-thread
//TODO 2: complete the realloc&copy
int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t kiDstBufferLen, void* pDst, int32_t* pDstLen) {
int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t kiDstBufferLen, void* pDst,
int32_t* pDstLen) {
const bool kbNALExt = pRawNal->sNalExt.sNalHeader.eNalUnitType == NAL_UNIT_PREFIX
|| pRawNal->sNalExt.sNalHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_EXT;
int32_t iAssumedNeededLength = NAL_HEADER_SIZE+(kbNALExt?3:0)+pRawNal->iPayloadSize+1;
WELS_VERIFY_RETURN_IF(ENC_RETURN_UNEXPECTED, (iAssumedNeededLength<=0))
|| pRawNal->sNalExt.sNalHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_EXT;
int32_t iAssumedNeededLength = NAL_HEADER_SIZE + (kbNALExt ? 3 : 0) + pRawNal->iPayloadSize + 1;
WELS_VERIFY_RETURN_IF (ENC_RETURN_UNEXPECTED, (iAssumedNeededLength <= 0))
//since for each 0x000 need a 0x03, so the needed length will not exceed (iAssumeNeedLenth + iAssumeNeedLength/3), here adjust to >>1 to omit division
if (kiDstBufferLen < (iAssumedNeededLength + (iAssumedNeededLength>>1)) ) {
if (kiDstBufferLen < (iAssumedNeededLength + (iAssumedNeededLength >> 1))) {
return ENC_RETURN_MEMALLOCERR;
//TODO: call the realloc&copy instead
}
@ -151,14 +152,14 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t
/* NAL UNIT Extension Header */
*pDstPointer++ = (0x80) |
(sNalExt->bIdrFlag << 6);
(sNalExt->bIdrFlag << 6);
*pDstPointer++ = (0x80) |
(sNalExt->uiDependencyId << 4);
(sNalExt->uiDependencyId << 4);
*pDstPointer++ = (sNalExt->uiTemporalId << 5) |
(sNalExt->bDiscardableFlag << 3) |
(0x07);
(sNalExt->bDiscardableFlag << 3) |
(0x07);
}
while (pSrcPointer < pSrcEnd) {

View File

@ -110,9 +110,10 @@ SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth , const int32_t
}
if (iNeedFeatureStorage) {
pPic->pScreenBlockFeatureStorage = static_cast<SScreenBlockFeatureStorage*> (pMa->WelsMallocz (sizeof (SScreenBlockFeatureStorage), "pScreenBlockFeatureStorage"));
int32_t iReturn = RequestScreenBlockFeatureStorage(pMa, kiWidth, kiHeight, iNeedFeatureStorage,
pPic->pScreenBlockFeatureStorage );
pPic->pScreenBlockFeatureStorage = static_cast<SScreenBlockFeatureStorage*> (pMa->WelsMallocz (sizeof (
SScreenBlockFeatureStorage), "pScreenBlockFeatureStorage"));
int32_t iReturn = RequestScreenBlockFeatureStorage (pMa, kiWidth, kiHeight, iNeedFeatureStorage,
pPic->pScreenBlockFeatureStorage);
WELS_VERIFY_RETURN_PROC_IF (NULL, ENC_RETURN_SUCCESS != iReturn, FreePicture (pMa, &pPic));
} else {
pPic->pScreenBlockFeatureStorage = NULL;
@ -136,10 +137,10 @@ void FreePicture (CMemoryAlign* pMa, SPicture** ppPic) {
pPic->pBuffer = NULL;
pPic->pData[0] =
pPic->pData[1] =
pPic->pData[2] = NULL;
pPic->pData[2] = NULL;
pPic->iLineSize[0] =
pPic->iLineSize[1] =
pPic->iLineSize[2] = 0;
pPic->iLineSize[2] = 0;
pPic->iWidthInPixel = 0;
pPic->iHeightInPixel = 0;
@ -169,7 +170,7 @@ void FreePicture (CMemoryAlign* pMa, SPicture** ppPic) {
}
if (pPic->pScreenBlockFeatureStorage) {
ReleaseScreenBlockFeatureStorage(pMa, pPic->pScreenBlockFeatureStorage);
ReleaseScreenBlockFeatureStorage (pMa, pPic->pScreenBlockFeatureStorage);
pMa->WelsFree (pPic->pScreenBlockFeatureStorage, "pPic->pScreenBlockFeatureStorage");
pPic->pScreenBlockFeatureStorage = NULL;
}

View File

@ -429,38 +429,35 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
if (0 == pTOverRc->iPFrameNum) {
iLumaQp = pWelsSvcRc->iInitialQp;
}
else if (pWelsSvcRc->iCurrentBitsLevel==BITS_EXCEEDED)
{
iLumaQp = MAX_LOW_BR_QP;
//limit QP
int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
if (iLastIdxCodecInVGop < 0)
iLastIdxCodecInVGop += VGOP_SIZE;
int32_t iTlLast = pWelsSvcRc->iTlOfFrames[iLastIdxCodecInVGop];
int32_t iDeltaQpTemporal = iTl - iTlLast;
if (0 == iTlLast && iTl > 0)
iDeltaQpTemporal += 3;
else if (0 == iTl && iTlLast > 0)
iDeltaQpTemporal -= 3;
} else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {
iLumaQp = MAX_LOW_BR_QP;
//limit QP
int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
if (iLastIdxCodecInVGop < 0)
iLastIdxCodecInVGop += VGOP_SIZE;
int32_t iTlLast = pWelsSvcRc->iTlOfFrames[iLastIdxCodecInVGop];
int32_t iDeltaQpTemporal = iTl - iTlLast;
if (0 == iTlLast && iTl > 0)
iDeltaQpTemporal += 3;
else if (0 == iTl && iTlLast > 0)
iDeltaQpTemporal -= 3;
iLumaQp = WELS_CLIP3 (iLumaQp,
pWelsSvcRc->iLastCalculatedQScale - pWelsSvcRc->iFrameDeltaQpLower + iDeltaQpTemporal,
pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
iLumaQp = WELS_CLIP3 (iLumaQp,
pWelsSvcRc->iLastCalculatedQScale - pWelsSvcRc->iFrameDeltaQpLower + iDeltaQpTemporal,
pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
pWelsSvcRc->dQStep = RcConvertQp2QStep (iLumaQp);
pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
pWelsSvcRc->dQStep = RcConvertQp2QStep (iLumaQp);
pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = (int32_t)(iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp);
}
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = (int32_t) (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp);
}
pEncCtx->iGlobalQp = iLumaQp;
pEncCtx->iGlobalQp = iLumaQp;
return;
}
else {
return;
} else {
double dCmplxRatio = (double)pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity / pTOverRc->iFrameCmplxMean;
dCmplxRatio = WELS_CLIP3 (dCmplxRatio, 1.0 - FRAME_CMPLX_RATIO_RANGE, 1.0 + FRAME_CMPLX_RATIO_RANGE);
@ -490,10 +487,10 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
#ifndef _NOT_USE_AQ_FOR_TEST_
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = (int32_t)(iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp);
iLumaQp = (int32_t) (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp);
if (pEncCtx->pSvcParam->iRCMode!=RC_LOW_BW_MODE)
iLumaQp = (int32_t)WELS_CLIP3 (iLumaQp,pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
if (pEncCtx->pSvcParam->iRCMode != RC_LOW_BW_MODE)
iLumaQp = (int32_t)WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
}
#endif
@ -531,14 +528,11 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
} else {
pWelsSvcRc->iTargetBits = (int32_t) (pWelsSvcRc->iRemainingBits * pTOverRc->dTlayerWeight /
pWelsSvcRc->dRemainingWeights);
if ((pWelsSvcRc->iTargetBits <= 0) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE))
{
pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED;
}
else if ((pWelsSvcRc->iTargetBits <= pTOverRc->iMinBitsTl) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE))
{
pWelsSvcRc->iCurrentBitsLevel = BITS_LIMITED;
}
if ((pWelsSvcRc->iTargetBits <= 0) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) {
pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED;
} else if ((pWelsSvcRc->iTargetBits <= pTOverRc->iMinBitsTl) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) {
pWelsSvcRc->iCurrentBitsLevel = BITS_LIMITED;
}
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, pTOverRc->iMinBitsTl, pTOverRc->iMaxBitsTl);
}
pWelsSvcRc->dRemainingWeights -= pTOverRc->dTlayerWeight;
@ -661,8 +655,8 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice,
pEncCtx->iGlobalQp - pWelsSvcRc->iQpRangeLowerInFrame, pEncCtx->iGlobalQp + pWelsSvcRc->iQpRangeUpperInFrame);
if (!(pEncCtx->pSvcParam->iRCMode==RC_LOW_BW_MODE))
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
if (! (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE))
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
pSOverRc->iGomBitsSlice = 0;

View File

@ -600,7 +600,7 @@ bool WelsBuildRefList (void* pEncCtx, const int32_t iPOC, int32_t iBestLtrRefIdx
if (pRef != NULL && pRef->bUsedAsRef && pRef->iFramePoc >= 0 && pRef->uiTemporalId <= kuiTid) {
pCtx->pRefList0[pCtx->iNumRef0++] = pRef;
WelsLog (pCtx, WELS_LOG_INFO, "WelsBuildRefList pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d\n",
pCtx->uiTemporalId,pRef->iFrameNum,pRef->uiTemporalId);
pCtx->uiTemporalId, pRef->iFrameNum, pRef->uiTemporalId);
break;
}
}
@ -640,7 +640,7 @@ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t u
/*syntax for num_ref_idx_l0_active_minus1*/
pSliceHdr->uiRefCount = pCtx->iNumRef0;
if (pCtx->iNumRef0 > 0) {
if ((!pCtx->pRefList0[0]->bIsLongRef)||(!pCtx->pSvcParam->bEnableLongTermReference)) {
if ((!pCtx->pRefList0[0]->bIsLongRef) || (!pCtx->pSvcParam->bEnableLongTermReference)) {
if (iAbsDiffPicNumMinus1 < 0) {
WelsLog (pCtx, WELS_LOG_INFO, "WelsUpdateRefSyntax():::uiAbsDiffPicNumMinus1:%d\n", iAbsDiffPicNumMinus1);
iAbsDiffPicNumMinus1 += (1 << (pCtx->pSps->uiLog2MaxFrameNum));
@ -662,11 +662,11 @@ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t u
pRefPicMark->bNoOutputOfPriorPicsFlag = false;
pRefPicMark->bLongTermRefFlag = pCtx->pSvcParam->bEnableLongTermReference;
} else {
if(pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
pRefPicMark->bAdaptiveRefPicMarkingModeFlag = pCtx->pSvcParam->bEnableLongTermReference;
else
pRefPicMark->bAdaptiveRefPicMarkingModeFlag = (pCtx->pSvcParam->bEnableLongTermReference
&& pLtr->bLTRMarkingFlag) ? (true) : (false);
&& pLtr->bLTRMarkingFlag) ? (true) : (false);
}
}
}
@ -689,17 +689,18 @@ static int32_t UpdateSrcPicList (sWelsEncCtx* pCtx) {
pCtx->pEncPic->bIsSceneLTR = pCtx->pDecPic->bIsSceneLTR;
pCtx->pEncPic->iFrameAverageQp = pCtx->pDecPic->iFrameAverageQp;
}
PrefetchNextBuffer(pCtx);
PrefetchNextBuffer (pCtx);
for (int32_t i = 0; i < MAX_REF_PIC_COUNT; ++i) {
if (NULL == pLongRefSrcList[i + 1] || (NULL != pLongRefList[i] && pLongRefList[i]->bUsedAsRef&& pLongRefList[i]->bIsLongRef)) {
if (NULL == pLongRefSrcList[i + 1] || (NULL != pLongRefList[i] && pLongRefList[i]->bUsedAsRef
&& pLongRefList[i]->bIsLongRef)) {
continue;
} else {
SetUnref (pLongRefSrcList[i + 1]);
}
} else {
SetUnref (pLongRefSrcList[i + 1]);
}
WelsExchangeSpatialPictures (&pCtx->pVpp->m_pSpatialPic[iDIdx][0],
&pCtx->pVpp->m_pSpatialPic[iDIdx][1 + pCtx->pVaa->uiMarkLongTermPicIdx]);
SetUnref (pCtx->pVpp->m_pSpatialPic[iDIdx][0]);
}
WelsExchangeSpatialPictures (&pCtx->pVpp->m_pSpatialPic[iDIdx][0],
&pCtx->pVpp->m_pSpatialPic[iDIdx][1 + pCtx->pVaa->uiMarkLongTermPicIdx]);
SetUnref (pCtx->pVpp->m_pSpatialPic[iDIdx][0]);
return 0;
}
@ -772,8 +773,9 @@ bool WelsBuildRefListScreen (void* pEncCtx, const int32_t iPOC, int32_t iBestLtr
"WelsBuildRefListScreen(), ref !current iFrameNum = %d, ref iFrameNum = %d,LTR number = %d,iNumRef = %d ref is Scene LTR = %d\n",
pCtx->iFrameNum, pCtx->pRefList0[pCtx->iNumRef0 - 1]->iFrameNum, pRefList->uiLongRefCount, iNumRef,
pRefPic->bIsSceneLTR);
WelsLog (pCtx, WELS_LOG_INFO, "WelsBuildRefListScreen pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d\n",
pCtx->uiTemporalId,pRefPic->iFrameNum,pRefPic->uiTemporalId);
WelsLog (pCtx, WELS_LOG_INFO,
"WelsBuildRefListScreen pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d\n",
pCtx->uiTemporalId, pRefPic->iFrameNum, pRefPic->uiTemporalId);
}
}
} else {

View File

@ -132,8 +132,9 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice
while (iSliceIdx < kiSliceCount) {
fAvI[iSliceIdx] = 1.0f * pCountMbInSlice[iSliceIdx] / pSliceTime[iSliceIdx];
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), pSliceConsumeTime[%d]= %d us, slice_run= %d\n", iSliceIdx,
pSliceTime[iSliceIdx], pCountMbInSlice[iSliceIdx]);
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), pSliceConsumeTime[%d]= %d us, slice_run= %d\n",
iSliceIdx,
pSliceTime[iSliceIdx], pCountMbInSlice[iSliceIdx]);
fSumAv += fAvI[iSliceIdx];
++ iSliceIdx;
@ -156,8 +157,9 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
iSliceIdx += 2;
}
if (uiTotalConsume == 0) {
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] NeedDynamicAdjust(), herein do no adjust due first picture, iCountSliceNum= %d\n",
iSliceNum);
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG,
"[MT] NeedDynamicAdjust(), herein do no adjust due first picture, iCountSliceNum= %d\n",
iSliceNum);
return false;
}
@ -183,8 +185,8 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
if (fRmse > fThr)
iNeedAdj = true;
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG,
"[MT] NeedDynamicAdjust(), herein adjustment decision is made (iNeedAdj= %d) by: fRmse of pSlice complexity ratios %.6f, the corresponding threshold %.6f, iCountSliceNum %d\n",
iNeedAdj, fRmse, fThr, iSliceNum);
"[MT] NeedDynamicAdjust(), herein adjustment decision is made (iNeedAdj= %d) by: fRmse of pSlice complexity ratios %.6f, the corresponding threshold %.6f, iCountSliceNum %d\n",
iNeedAdj, fRmse, fThr, iSliceNum);
return iNeedAdj;
}
@ -256,8 +258,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
}
iRunLen[iSliceIdx] = iNumMbAssigning;
MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
"[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d\n",
iSliceIdx, pSliceComplexRatio[iSliceIdx], pSliceCtx->pCountMbNumInSlice[iSliceIdx], iNumMbAssigning);
"[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d\n",
iSliceIdx, pSliceComplexRatio[iSliceIdx], pSliceCtx->pCountMbNumInSlice[iSliceIdx], iNumMbAssigning);
++ iSliceIdx;
iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
}
@ -313,16 +315,17 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
#ifdef _WIN32
// Dummy event namespace, the windows events don't actually use this
WelsSnprintf (pSmt->eventNamespace, sizeof(pSmt->eventNamespace), "%p", (void*) *ppCtx);
WelsSnprintf (pSmt->eventNamespace, sizeof (pSmt->eventNamespace), "%p", (void*) *ppCtx);
#else
WelsSnprintf (pSmt->eventNamespace, sizeof(pSmt->eventNamespace), "%p%x", (void*) *ppCtx, getpid());
WelsSnprintf (pSmt->eventNamespace, sizeof (pSmt->eventNamespace), "%p%x", (void*) *ppCtx, getpid());
#endif//!_WIN32
iIdx = 0;
while (iIdx < iNumSpatialLayers) {
SSliceConfig* pMso = &pPara->sDependencyLayers[iIdx].sSliceCfg;
const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum;
if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pMso->uiSliceMode == SM_AUTO_SLICE)) && pPara->iMultipleThreadIdc > 1
if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE))
&& pPara->iMultipleThreadIdc > 1
&& pPara->iMultipleThreadIdc >= kiSliceNum) {
pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx))
@ -371,7 +374,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno);
WelsSnprintf (name, SEM_NAME_MAX, "fu%d%s", iIdx, pSmt->eventNamespace);
err = WelsEventOpen (&pSmt->pFinUpdateMbListEvent[iIdx], name);
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno);
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err,
errno);
WelsSnprintf (name, SEM_NAME_MAX, "sc%d%s", iIdx, pSmt->eventNamespace);
err = WelsEventOpen (&pSmt->pSliceCodedEvent[iIdx], name);
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno);
@ -415,10 +419,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
iReturn = WelsMutexInit (&pSmt->mutexSliceNumUpdate);
WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
iReturn = WelsMutexInit (&(*ppCtx)->mutexEncoderError);
iReturn = WelsMutexInit (& (*ppCtx)->mutexEncoderError);
WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iCountSliceNum= %d\n", pPara->iCountThreadsNum,
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "RequestMtResource(), iThreadNum=%d, iCountSliceNum= %d\n",
pPara->iCountThreadsNum,
iMaxSliceNum);
return 0;
@ -467,7 +472,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
WelsEventClose (&pSmt->pSliceCodedMasterEvent, ename);
WelsMutexDestroy (&pSmt->mutexSliceNumUpdate);
WelsMutexDestroy (&((*ppCtx)->mutexEncoderError));
WelsMutexDestroy (& ((*ppCtx)->mutexEncoderError));
if (pSmt->pThreadPEncCtx != NULL) {
pMa->WelsFree (pSmt->pThreadPEncCtx, "pThreadPEncCtx");
@ -595,7 +600,8 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
return iLayerSize;
}
int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, int32_t& iSliceSize) {
int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx,
int32_t& iSliceSize) {
SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
uint8_t* pDst = pFrameBsBuffer;
@ -610,8 +616,9 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr
while (iNalIdx < kiNalCnt) {
iNalSize = 0;
iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pCtx->iFrameBsSize-kiWrittenLength-iSliceSize, pDst, &iNalSize);
WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS)
iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pCtx->iFrameBsSize - kiWrittenLength - iSliceSize,
pDst, &iNalSize);
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
iSliceSize += iNalSize;
pDst += iNalSize;
pLbi->iNalLengthInByte[iNalBase + iNalIdx] = iNalSize;
@ -653,8 +660,9 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl
while (iNalIdx < kiNalCnt) {
iNalSize = 0;
iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pSliceBs->uiSize-kiWrittenLength-iSliceSize, pDst, &iNalSize);
WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS)
iReturn = WelsEncodeNal (&pSliceBs->sNalList[iNalIdx], pNalHdrExt, pSliceBs->uiSize - kiWrittenLength - iSliceSize,
pDst, &iNalSize);
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
pNalLen[iNalIdx] = iNalSize;
iSliceSize += iNalSize;
pDst += iNalSize;
@ -702,7 +710,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
"[MT] CodingSliceThreadProc(), try to call WelsMultipleEventsWaitSingleBlocking(pEventsList= %p %p %p), pEncPEncCtx= %p!\n",
pEventsList[0], pEventsList[1], pEventsList[1], (void*)pEncPEncCtx);
iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount,
&pEventsList[0], &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled
&pEventsList[0],
&pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled
if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
SLayerBSInfo* pLbi = pPrivateData->pLayerBs;
const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
@ -722,7 +731,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) &&
bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
|| (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) &&
pCodingParam->iMultipleThreadIdc > 1 &&
pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
if (bDsaFlag)
@ -752,7 +762,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
if (ENC_RETURN_SUCCESS!=iReturn) {
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
break;
}
@ -762,15 +772,14 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
if (0 == iSliceIdx) {
pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize);
if (ENC_RETURN_SUCCESS!=iReturn) {
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
break;
}
pEncPEncCtx->iPosBsBuffer += iSliceSize;
} else
{
} else {
iReturn = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
if (ENC_RETURN_SUCCESS!=iReturn) {
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
break;
}
@ -859,7 +868,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
if (ENC_RETURN_SUCCESS!=iReturn) {
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
break;
}
@ -869,16 +878,16 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
if (0 == kiPartitionId) {
if (0 == iSliceIdx)
pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer, iSliceIdx, iSliceSize);
if (ENC_RETURN_SUCCESS!=iReturn) {
iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer, iSliceIdx,
iSliceSize);
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
break;
}
pEncPEncCtx->iPosBsBuffer += iSliceSize;
} else
{
} else {
iSliceSize = WriteSliceBs (pEncPEncCtx, pSliceBs->pBs, iSliceIdx, iSliceSize);
if (ENC_RETURN_SUCCESS!=iReturn) {
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
break;
}
@ -918,20 +927,17 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
}
}
else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal
} else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal
uiThrdRet = 0;
break;
}
else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 2 == iWaitRet) { // update pMb list singal
} else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 2 == iWaitRet) { // update pMb list singal
iSliceIdx =
iEventIdx; // pPrivateData->iSliceIndex; old threads can not be terminated, pPrivateData is not correct for applicable
pCurDq = pEncPEncCtx->pCurDqLayer;
UpdateMbListNeighborParallel (pCurDq->pSliceEncCtx, pCurDq->sMbDataP, iSliceIdx);
WelsEventSignal (
&pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice
}
else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED
} else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED
WelsLog (pEncPEncCtx, WELS_LOG_WARNING,
"[MT] CodingSliceThreadProc(), waiting pReadySliceCodingEvent[%d] failed(%d) and thread%d terminated!\n", iEventIdx,
iWaitRet, iThreadIdx);
@ -962,9 +968,9 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) {
return 0;
}
int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi,
const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode)
{
int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, WELS_EVENT* pMasterEventsList,
SLayerBSInfo* pLbi,
const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) {
int32_t iEndMbIdx = 0;
int32_t iIdx = 0;
const int32_t kiEventCnt = uiNumThreads;
@ -1044,9 +1050,9 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) {
// if using spatial base layer for complexity estimation
const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
&& (pCtx->pSvcParam->sDependencyLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
&& pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sDependencyLayers[iCurDid -
1].sSliceCfg.sSliceArgument.uiSliceNum);
&& (pCtx->pSvcParam->sDependencyLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
&& pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sDependencyLayers[iCurDid -
1].sSliceCfg.sSliceArgument.uiSliceNum);
if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
// do not need adjust due to not different at both slices of consumed time
@ -1116,7 +1122,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t
const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
if (pCtx->pSliceThreading) {
if (pCtx->pSliceThreading->pFSliceDiff
&& ((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pMso->uiSliceMode == SM_AUTO_SLICE))
&& ((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE))
&& pPara->iMultipleThreadIdc > 1
&& pPara->iMultipleThreadIdc >= kuiCountSliceNum) {
uint32_t i = 0;

View File

@ -358,7 +358,8 @@ void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const i
ST32 (&pCurMb->sP16x16Mv, 0);
ST32 (&pCurLayer->pDecPic->sMvList[kiMbXY], 0);
SetMvWithinIntegerMvRange( kiMbWidth, kiMbHeight, kiMbX, kiMbY, CAMERA_STARTMV_RANGE, &(pSlice->sMvStartMin), &(pSlice->sMvStartMax));
SetMvWithinIntegerMvRange (kiMbWidth, kiMbHeight, kiMbX, kiMbY, CAMERA_STARTMV_RANGE, & (pSlice->sMvStartMin),
& (pSlice->sMvStartMax));
}
int32_t WelsMdI16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache* pMbCache, int32_t iLambda) {
@ -969,9 +970,8 @@ void WelsMdIntraMb (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach
WelsMdIntraSecondaryModesEnc (pEncCtx, pWelsMd, pCurMb, pMbCache);
}
static inline void InitMe(const SWelsMD& sWelsMd, const int32_t iBlockSize, uint8_t* pEnc, uint8_t* pRef,
SWelsME& sWelsMe )
{
static inline void InitMe (const SWelsMD& sWelsMd, const int32_t iBlockSize, uint8_t* pEnc, uint8_t* pRef,
SWelsME& sWelsMe) {
sWelsMe.iCurMeBlockPixX = sWelsMd.iMbPixX;
sWelsMe.iCurMeBlockPixY = sWelsMd.iMbPixY;
sWelsMe.uiBlockSize = iBlockSize;
@ -987,8 +987,8 @@ int32_t WelsMdP16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWe
uint32_t uiNeighborAvail = pCurMb->uiNeighborAvail;
const int32_t kiMbWidth = pCurLayer->iMbWidth; // for assign once
const int32_t kiMbHeight = pCurLayer->iMbHeight;
InitMe(*pWelsMd, BLOCK_16x16, pMbCache->SPicData.pEncMb[0], pMbCache->SPicData.pRefMb[0],
*pMe16x16 );
InitMe (*pWelsMd, BLOCK_16x16, pMbCache->SPicData.pEncMb[0], pMbCache->SPicData.pRefMb[0],
*pMe16x16);
//not putting the line below into InitMe to avoid judging mode in InitMe
pMe16x16->uSadPredISatd.uiSadPred = pWelsMd->iSadPredMb;
@ -1035,10 +1035,10 @@ int32_t WelsMdP16x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pW
do {
sMe16x8 = &pWelsMd->sMe.sMe16x8[i];
iPixelY = (i << 3);
InitMe(*pWelsMd, BLOCK_16x8,
pMbCache->SPicData.pEncMb[0] + (iPixelY * iStrideEnc),
pMbCache->SPicData.pRefMb[0] + (iPixelY * iStrideRef),
*sMe16x8 );
InitMe (*pWelsMd, BLOCK_16x8,
pMbCache->SPicData.pEncMb[0] + (iPixelY * iStrideEnc),
pMbCache->SPicData.pRefMb[0] + (iPixelY * iStrideRef),
*sMe16x8);
//not putting the lines below into InitMe to avoid judging mode in InitMe
sMe16x8->iCurMeBlockPixY = pWelsMd->iMbPixY + iPixelY;
sMe16x8->uSadPredISatd.uiSadPred = pWelsMd->iSadPredMb >> 1;
@ -1062,10 +1062,10 @@ int32_t WelsMdP8x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWel
do {
iPixelX = (i << 3);
sMe8x16 = &pWelsMd->sMe.sMe8x16[i];
InitMe(*pWelsMd, BLOCK_8x16,
pMbCache->SPicData.pEncMb[0] + iPixelX,
pMbCache->SPicData.pRefMb[0] + iPixelX,
*sMe8x16 );
InitMe (*pWelsMd, BLOCK_8x16,
pMbCache->SPicData.pEncMb[0] + iPixelX,
pMbCache->SPicData.pRefMb[0] + iPixelX,
*sMe8x16);
//not putting the lines below into InitMe to avoid judging mode in InitMe
sMe8x16->iCurMeBlockPixX = pWelsMd->iMbPixX + iPixelX;
sMe8x16->uSadPredISatd.uiSadPred = pWelsMd->iSadPredMb >> 1;
@ -1093,14 +1093,14 @@ int32_t WelsMdP8x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pWe
iIdxY = i >> 1;
iPixelX = (iIdxX << 3);
iPixelY = (iIdxY << 3);
iStrideEnc = iPixelX + ( iPixelY * iLineSizeEnc);
iStrideRef = iPixelX + ( iPixelY * iLineSizeRef);
iStrideEnc = iPixelX + (iPixelY * iLineSizeEnc);
iStrideRef = iPixelX + (iPixelY * iLineSizeRef);
sMe8x8 = &pWelsMd->sMe.sMe8x8[i];
InitMe(*pWelsMd, BLOCK_8x8,
pMbCache->SPicData.pEncMb[0] + iStrideEnc,
pMbCache->SPicData.pRefMb[0] + iStrideRef,
*sMe8x8 );
InitMe (*pWelsMd, BLOCK_8x8,
pMbCache->SPicData.pEncMb[0] + iStrideEnc,
pMbCache->SPicData.pRefMb[0] + iStrideRef,
*sMe8x8);
//not putting these three lines below into InitMe to avoid judging mode in InitMe
sMe8x8->iCurMeBlockPixX = pWelsMd->iMbPixX + iPixelX;
sMe8x8->iCurMeBlockPixY = pWelsMd->iMbPixY + iPixelY;
@ -1340,7 +1340,7 @@ bool WelsMdPSkipEnc (void* pEnc, void* pMd, SMB* pCurMb, SMbCache* pMbCache) {
PredSkipMv (pMbCache, &sMvp);
// Special case, need to clip the vector //
SMVUnitXY sQpelMvp = { static_cast<int16_t>(sMvp.iMvX >> 2), static_cast<int16_t>(sMvp.iMvY >> 2) };
SMVUnitXY sQpelMvp = { static_cast<int16_t> (sMvp.iMvX >> 2), static_cast<int16_t> (sMvp.iMvY >> 2) };
n = (pCurMb->iMbX << 4) + sQpelMvp.iMvX;
if (n < -29)
return false;
@ -1669,7 +1669,7 @@ void WelsMdInterMb (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache
// try the ordinary Pskip
//////
bool WelsMdInterJudgePskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool bTrySkip) {
bool bTrySkip) {
bool bRet = true;
if (((pEncCtx->pRefPic->iPictureType == P_SLICE) && (pMbCache->uiRefMbType == MB_TYPE_SKIP
|| pMbCache->uiRefMbType == MB_TYPE_BACKGROUND)) ||
@ -1751,7 +1751,7 @@ void WelsMdInterEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, SMbCa
// try the BGD Pskip
//////
bool WelsMdInterJudgeBGDPskip (void* pCtx, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool* bKeepSkip) {
bool* bKeepSkip) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SWelsMD* pWelsMd = (SWelsMD*)pMd;
@ -1783,7 +1783,7 @@ bool WelsMdInterJudgeBGDPskip (void* pCtx, void* pMd, SSlice* pSlice, SMB* pCurM
}
bool WelsMdInterJudgeBGDPskipFalse (void* pCtx, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool* bKeepSkip) {
bool* bKeepSkip) {
return false;
}

View File

@ -84,7 +84,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
return 0;
} else if (SM_RASTER_SLICE == pSliceSeg->uiSliceMode ||
SM_FIXEDSLCNUM_SLICE == pSliceSeg->uiSliceMode||
SM_FIXEDSLCNUM_SLICE == pSliceSeg->uiSliceMode ||
SM_AUTO_SLICE == pSliceSeg->uiSliceMode) {
const int32_t* kpSlicesAssignList = (int32_t*) & (kpMso->sSliceArgument.uiSliceMbNum[0]);
const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame;
@ -310,7 +310,7 @@ int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, S
case SM_FIXEDSLCNUM_SLICE:
case SM_RASTER_SLICE:
case SM_ROWMB_SLICE:
case SM_AUTO_SLICE:{
case SM_AUTO_SLICE: {
return pMso->sSliceArgument.uiSliceNum;
}
case SM_DYN_SLICE: {
@ -400,7 +400,7 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0]));
} else { //if ( SM_MULTIPLE_SLICE == uiSliceMode )
if (uiSliceMode != SM_FIXEDSLCNUM_SLICE && uiSliceMode != SM_ROWMB_SLICE && uiSliceMode != SM_RASTER_SLICE
&& uiSliceMode != SM_DYN_SLICE&& uiSliceMode != SM_AUTO_SLICE)
&& uiSliceMode != SM_DYN_SLICE && uiSliceMode != SM_AUTO_SLICE)
return 1;
pSliceSeg->pOverallMbMap = (uint8_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint8_t), "pSliceSeg->pOverallMbMap");

View File

@ -644,7 +644,7 @@ int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum ==
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
//MD switch
if (kbBaseAvail && kbHighestSpatial) {
@ -663,7 +663,7 @@ int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum ==
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
//MD switch
if (kbBaseAvail && kbHighestSpatial) {
@ -693,7 +693,8 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx];
SBitStringAux* pBs = pCurSlice->pSliceBsa;
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode ==
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode
==
SM_DYN_SLICE);
assert (kiSliceIdx == pCurSlice->uiSliceIdx);
@ -831,7 +832,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic
}
bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
SDynamicSlicingStack* pDss) {
SDynamicSlicingStack* pDss) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SSlice* pCurSlice = (SSlice*)pSlice;
int32_t iCurMbIdx = pCurMb->iMbXY;
@ -903,13 +904,13 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli
///////////////
// pMb loop
///////////////
inline void WelsInitInterMDStruc(const SMB* pCurMb, uint16_t *pMvdCostTableInter, const int32_t kiMvdInterTableStride, SWelsMD* pMd )
{
inline void WelsInitInterMDStruc (const SMB* pCurMb, uint16_t* pMvdCostTableInter, const int32_t kiMvdInterTableStride,
SWelsMD* pMd) {
pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp];
pMd->pMvdCost = &pMvdCostTableInter[pCurMb->uiLumaQp * kiMvdInterTableStride];
pMd-> iMbPixX = (pCurMb->iMbX<<4);
pMd-> iMbPixY = (pCurMb->iMbY<<4);
memset( &pMd->iBlock8x8StaticIdc[0], 0, sizeof(pMd->iBlock8x8StaticIdc) );
pMd-> iMbPixX = (pCurMb->iMbX << 4);
pMd-> iMbPixY = (pCurMb->iMbY << 4);
memset (&pMd->iBlock8x8StaticIdc[0], 0, sizeof (pMd->iBlock8x8StaticIdc));
}
// for inter non-dynamic pSlice
int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) {
@ -943,7 +944,7 @@ int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
//step (2). save some vale for future use, initial pWelsMd
WelsMdIntraInit (pEncCtx, pCurMb, pMbCache, kiSliceFirstMbXY);
WelsMdInterInit (pEncCtx, pSlice, pCurMb, kiSliceFirstMbXY);
WelsInitInterMDStruc(pCurMb, pMvdCostTableInter, kiMvdInterTableStride, pMd );
WelsInitInterMDStruc (pCurMb, pMvdCostTableInter, kiMvdInterTableStride, pMd);
pEncCtx->pFuncList->pfInterMd (pEncCtx, pMd, pSlice, pCurMb, pMbCache);
//mb_qp
@ -999,7 +1000,7 @@ int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
// Only for inter dynamic slicing
int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
const int32_t kiSliceFirstMbXY) {
const int32_t kiSliceFirstMbXY) {
SWelsMD* pMd = (SWelsMD*)pWelsMd;
SBitStringAux* pBs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
@ -1041,7 +1042,7 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice,
//step (2). save some vale for future use, initial pWelsMd
WelsMdIntraInit (pEncCtx, pCurMb, pMbCache, kiSliceFirstMbXY);
WelsMdInterInit (pEncCtx, pSlice, pCurMb, kiSliceFirstMbXY);
WelsInitInterMDStruc(pCurMb, pMvdCostTableInter, kiMvdInterTableStride, pMd );
WelsInitInterMDStruc (pCurMb, pMvdCostTableInter, kiMvdInterTableStride, pMd);
pEncCtx->pFuncList->pfInterMd (pEncCtx, pMd, pSlice, pCurMb, pMbCache);
//mb_qp

View File

@ -61,7 +61,7 @@ void WelsMdSpatialelInterMbIlfmdNoilp (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, S
const bool kbMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (kpTopMb->uiMbType) : false);
const bool kbMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((kpTopMb - 1)->uiMbType) : false);
const bool kbMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP ((
kpTopMb + 1)->uiMbType) : false);
kpTopMb + 1)->uiMbType) : false);
bool bTrySkip = kbMbLeftAvailPskip | kbMbTopAvailPskip | kbMbTopLeftAvailPskip | kbMbTopRightAvailPskip;
bool bKeepSkip = kbMbLeftAvailPskip & kbMbTopAvailPskip & kbMbTopRightAvailPskip;
@ -162,11 +162,12 @@ void SetMvBaseEnhancelayer (SWelsMD* pMd, SMB* pCurMb, const SMB* kpRefMb) {
///////////////////////
// Scrolling PSkip Decision for screen content
////////////////////////
bool WelsMdInterJudgeScrollingPskip(void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
bool WelsMdInterJudgeScrollingPskip (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
//TBD
return false;
}
bool WelsMdInterJudgeScrollingPskipFalse(void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
bool WelsMdInterJudgeScrollingPskipFalse (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb,
SMbCache* pMbCache) {
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -208,10 +208,9 @@ void WelsSpatialWriteSubMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurM
}
}
int32_t CheckBitstreamBuffer(const uint8_t kuiSliceIdx, sWelsEncCtx* pEncCtx, SBitStringAux* pBs)
{
int32_t CheckBitstreamBuffer (const uint8_t kuiSliceIdx, sWelsEncCtx* pEncCtx, SBitStringAux* pBs) {
const int32_t iLeftLength = pBs->pBufEnd - pBs->pBufPtr - 1;
assert(iLeftLength > 0);
assert (iLeftLength > 0);
if (iLeftLength < MAX_MACROBLOCK_SIZE_IN_BYTE) {
return ENC_RETURN_MEMALLOCERR;
@ -253,7 +252,7 @@ int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb
}
/* Step 4: Check the left buffer */
return CheckBitstreamBuffer(pSlice->uiSliceIdx, pEncCtx, pBs);
return CheckBitstreamBuffer (pSlice->uiSliceIdx, pEncCtx, pBs);
}
void WelsWriteMbResidual (SMbCache* sMbCacheInfo, SMB* pCurMb, SBitStringAux* pBs) {

View File

@ -142,7 +142,7 @@ void WelsLogDefault (void* pCtx, const int32_t kiLevel, const char* kpFmtStr, va
if (pEncCtx) {
SWelsTime tTime;
WelsGetTimeOfDay(&tTime);
WelsGetTimeOfDay (&tTime);
iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage
iBufUsed += iCurUsed;
iBufLeft -= iCurUsed;

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