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;
@ -141,43 +141,43 @@ 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,
DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
void** ppDst,
SBufferInfo* pDstInfo);
DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc,
DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc,
const int iSrcLen,
unsigned char* pDst,
int iDstStride,
@ -186,17 +186,17 @@ struct ISVCDecoderVtbl {
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

@ -171,7 +171,7 @@ typedef struct {
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
} 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,7 +302,8 @@ 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 */
int iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
@ -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{
typedef struct Dump_Layer_s {
int iLayer;
char *pFileName;
}SDumpLayer;
char* pFileName;
} SDumpLayer;
#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__

View File

@ -35,17 +35,19 @@ void DeblockChromaLt4H_ssse3 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
#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) {
int32_t s = 0;
i--;
while (i > 0) {
s++;
i >>= 1;
}
return s;
}
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)
if (iY < iMin)
iMin = iY;
else
else
iMax = iY;
if (iZ < iMin)
if (iZ < iMin)
iMin = iZ;
else if (iZ > iMax)
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) {
int32_t r = 0;
while (v >>= 1) {
++r;
}
return 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,8 +235,7 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
}
#elif defined(__APPLE__)
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
{
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uint32_t uiCPU = 0;
#if defined(__ARM_NEON__)
@ -251,23 +249,23 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
/* 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

@ -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

@ -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,7 +142,7 @@ 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;
@ -194,9 +193,9 @@ 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());
@ -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++]);
@ -687,7 +682,7 @@ 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;
@ -739,11 +734,11 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
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,7 +796,7 @@ ERROR_RET:
fclose (pFpSrc);
pFpSrc = NULL;
}
if(pSrcPic){
if (pSrcPic) {
delete pSrcPic;
pSrcPic = NULL;
}
@ -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;
@ -881,7 +876,7 @@ 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) {
@ -891,21 +886,21 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
//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;
@ -1057,7 +1052,7 @@ INSIDE_MEM_FREE:
}
#endif
// Destruction memory introduced in this routine
if (pFileYUV!= NULL) {
if (pFileYUV != NULL) {
fclose (pFileYUV);
pFileYUV = NULL;
}
@ -1065,7 +1060,7 @@ INSIDE_MEM_FREE:
delete pYUV;
pYUV = NULL;
}
if(pSrcPic){
if (pSrcPic) {
delete pSrcPic;
pSrcPic = NULL;
}
@ -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

@ -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

@ -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

@ -45,9 +45,9 @@ namespace WelsDec {
/* NAL Unit Structure */
typedef struct TagNalUnit {
SNalUnitHeaderExt sNalHeaderExt;
SNalUnitHeaderExt sNalHeaderExt;
union {
union {
struct SVclNal {
SSliceHeaderExt sSliceHeaderExt;
SBitStringAux sSliceBitsRead;
@ -56,7 +56,7 @@ union {
bool bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
} 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

@ -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

@ -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

@ -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]) {
@ -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,8 +720,7 @@ void DeblockingInit (SDeblockingFunc* 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

@ -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;

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

@ -43,14 +43,14 @@ 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 {
enum {
WELS_LOG_QUIET = 0,
WELS_LOG_ERROR = 1 << 0,
WELS_LOG_WARNING = 1 << 1,
@ -61,22 +61,22 @@ enum {
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) {
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, ...) {
static void WelsVTrace (void* pObject, const int32_t kLevel, const char* kpFormat, ...) {
IWelsTrace* pThis = (IWelsTrace*) (pObject);
va_list argptr;
@ -88,67 +88,67 @@ static void WelsVTrace (void* pObject, const int32_t kLevel, const char* kpForma
}
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() {
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,36 +56,36 @@ 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,
/***************************************************************************
* 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,
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,
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
@ -94,19 +94,19 @@ virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc,
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

@ -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,68 +65,68 @@ 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 {
struct {
/* pointer of current mb location in original frame */
uint8_t* pEncMb[3];
/* pointer of current mb location in recovery frame */
@ -137,7 +137,7 @@ struct {
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 {
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,80 +64,81 @@ 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) {
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
return (uint32_t) (dRound);
}
return UINT_MAX;
}
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 {
/* 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
} 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));
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
@ -184,7 +185,7 @@ static void FillDefault (SEncParamExt& param) {
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.uiMaxNalSize = 0;
for(int32_t iLayer = 0;iLayer< MAX_SPATIAL_LAYER_NUM;iLayer++){
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;
@ -197,10 +198,10 @@ static void FillDefault (SEncParamExt& param) {
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
}
}
}
void FillDefault () {
FillDefault(*this);
void FillDefault() {
FillDefault (*this);
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
SUsedPicRect.iLeft =
@ -216,7 +217,7 @@ void FillDefault () {
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
memset(sDependencyLayers,0,sizeof(SDLayerParam)*MAX_DEPENDENCY_LAYER);
memset (sDependencyLayers, 0, sizeof (SDLayerParam)*MAX_DEPENDENCY_LAYER);
@ -226,14 +227,14 @@ void FillDefault () {
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++)
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sDependencyLayers[0].iDLayerQp = SVC_QUALITY_BASE_QP;
}
}
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
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);
@ -283,8 +284,8 @@ int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
SetActualPicResolution();
return 0;
}
void GetBaseParams (SEncParamBase* pCodingParam) {
}
void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iUsageType = iUsageType;
pCodingParam->iInputCsp = iInputCsp;
pCodingParam->iPicWidth = iPicWidth;
@ -292,8 +293,8 @@ void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iTargetBitrate = iTargetBitrate;
pCodingParam->iRCMode = iRCMode;
pCodingParam->fMaxFrameRate = fMaxFrameRate;
}
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
}
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
@ -352,30 +353,31 @@ int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
/* 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
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
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;
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);
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, uiGopSize >> 1);
}
} else {
iLTRRefNum = bEnableLongTermReference ? WELS_CLIP3(pCodingParam.iLTRRefNum,1,LONG_TERM_REF_NUM) : 0;
if( iNumRefFrame == AUTO_REF_PIC_COUNT){
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);
}
@ -393,8 +395,10 @@ int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
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;
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);
@ -434,11 +438,11 @@ int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
SetActualPicResolution();
return 0;
}
}
// assuming that the width/height ratio of all spatial layers are the same
void SetActualPicResolution() {
void SetActualPicResolution() {
int32_t iSpatialIdx = iSpatialLayerNum - 1;
SDLayerParam* pDlayer = &sDependencyLayers[iSpatialIdx];
@ -450,14 +454,14 @@ void SetActualPicResolution() {
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() {
/*!
* \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];
@ -494,16 +498,16 @@ void DetermineTemporalSettings() {
++ i;
}
iDecompStages = (int8_t)iDecStages;
}
}
} SWelsSvcCodingParam;
static inline int32_t FreeCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
if (pParam == NULL || *pParam == NULL || pMa == NULL)
if (pParam == NULL || *pParam == NULL || pMa == NULL)
return 1;
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
*pParam = NULL;
return 0;
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
*pParam = NULL;
return 0;
}
static inline int32_t AllocCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {

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,7 +47,8 @@ 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*,
@ -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

@ -58,7 +58,7 @@ 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
@ -68,7 +68,7 @@ typedef struct TagFeatureSearchPreparation{
bool bFMESwitchFlag;
uint8_t uiFMEGoodFrameCount;
int32_t iHighFreMbCount;
}SFeatureSearchPreparation;//maintain only one
} SFeatureSearchPreparation; //maintain only one
typedef struct TagLayerInfo {
SNalUnitHeaderExt sNalHeaderExt;

View File

@ -93,9 +93,9 @@ 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) {
if (256 > kiValue) {
return g_uiGolombUELength[kiValue];
} else {
} else {
uint32_t n = 0;
uint32_t iTmpValue = kiValue + 1;
@ -112,74 +112,74 @@ if (256 > kiValue) {
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) {
uint32_t iTmpValue;
if (0 == kiValue) {
return 1;
} else if (0 < kiValue) {
} else if (0 < kiValue) {
iTmpValue = (kiValue << 1) - 1;
return BsSizeUE (iTmpValue);
} else {
} 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) {
if (n < pBs->iLeftBits) {
pBs->uiCurBits = (pBs->uiCurBits << n) | kuiValue;
pBs->iLeftBits -= n;
} else {
} else {
n -= pBs->iLeftBits;
pBs->uiCurBits = (pBs->uiCurBits << pBs->iLeftBits) | (kuiValue >> n);
WRITE_BE_32(pBs->pBufPtr, pBs->uiCurBits);
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits);
pBs->pBufPtr += 4;
pBs->uiCurBits = kuiValue & ((1 << n) - 1);
pBs->iLeftBits = 32 - n;
}
return 0;
}
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) {
uint32_t iTmpValue = kuiValue + 1;
if (256 > kuiValue) {
BsWriteBits (pBs, g_uiGolombUELength[kuiValue], kuiValue + 1);
} else {
} else {
uint32_t n = 0;
if (iTmpValue & 0xffff0000) {
@ -195,36 +195,36 @@ if (256 > kuiValue) {
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) {
uint32_t iTmpValue;
if (0 == iValue) {
BsWriteOneBit (pBs, 1);
} else if (0 < iValue) {
} else if (0 < iValue) {
iTmpValue = (iValue << 1) - 1;
BsWriteUE (pBs, iTmpValue);
} else {
} else {
iTmpValue = ((-iValue) << 1);
BsWriteUE (pBs, iTmpValue);
}
return;
}
return;
}
/*
* Write truncated exp golomb codes
*/
static inline void BsWriteTE (SBitStringAux* pBs, const int32_t kiX, const uint32_t kuiValue) {
if (1 == kiX) {
if (1 == kiX) {
BsWriteOneBit (pBs, !kuiValue);
} else {
} 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

@ -61,45 +61,46 @@ 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{
typedef struct TagFeatureSearchIn {
PSampleSadSatdCostFunc pSad;
uint32_t* pTimesOfFeature;
uint16_t** pQpelLocationOfFeature;
uint16_t *pMvdCostX;
uint16_t *pMvdCostY;
uint16_t* pMvdCostX;
uint16_t* pMvdCostY;
uint8_t* pEnc;
uint8_t* pColoRef;
@ -118,20 +119,20 @@ typedef struct TagFeatureSearchIn{
int32_t iMinQpelY;
int32_t iMaxQpelX;
int32_t iMaxQpelY;
}SFeatureSearchIn;
} SFeatureSearchIn;
typedef struct TagFeatureSearchOut{
typedef struct TagFeatureSearchOut {
SMVUnitXY sBestMv;
uint32_t uiBestSadCost;
uint8_t* pBestRef;
}SFeatureSearchOut;
} 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);
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,
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,
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,
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 );
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,
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,
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 );
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,
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,
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,
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,
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 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,
void PerformFMEPreprocess (SWelsFuncPtrList* pFunc, SPicture* pRef, uint16_t* pFeatureOfBlock,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage);
void UpdateFMESwitch(SDqLayer* pCurLayer);
void UpdateFMESwitchNull(SDqLayer* pCurLayer);
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,
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);
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) {
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,
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,
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,
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 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

@ -68,13 +68,13 @@ typedef struct {
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
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,
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);
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

@ -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

@ -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,
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));
WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS != iReturn, FreeMemorySvc (ppCtx));
} else {
pDqLayer->pFeatureSearchPreparation = NULL;
}
@ -1367,7 +1369,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
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)){
if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)) {
WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
FreeMemorySvc (ppCtx);
return 1;
@ -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,10 +2458,10 @@ 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,
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
@ -2468,7 +2470,8 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
if (pFeatureSearchPreparation->bFMESwitchFlag
&& !pScreenBlockFeatureStorage->bRefBlockFeatureCalculated) {
//TODO: use ORIGIN of reference when preprocessing is ready
PerformFMEPreprocess( pFuncList, pCurLayer->pRefPic,pFeatureSearchPreparation->pFeatureOfBlock,pScreenBlockFeatureStorage);
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.

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))
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
}

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;
@ -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,9 +429,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
if (0 == pTOverRc->iPFrameNum) {
iLumaQp = pWelsSvcRc->iInitialQp;
}
else if (pWelsSvcRc->iCurrentBitsLevel==BITS_EXCEEDED)
{
} else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {
iLumaQp = MAX_LOW_BR_QP;
//limit QP
int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
@ -453,14 +451,13 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = (int32_t)(iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp);
iLumaQp = (int32_t) (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp);
}
pEncCtx->iGlobalQp = iLumaQp;
return;
}
else {
} 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,12 +528,9 @@ 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))
{
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))
{
} 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);
@ -661,7 +655,7 @@ 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))
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,7 +662,7 @@ 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
@ -689,9 +689,10 @@ 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]);
@ -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,7 +132,8 @@ 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,
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];
@ -156,7 +157,8 @@ 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",
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG,
"[MT] NeedDynamicAdjust(), herein do no adjust due first picture, iCountSliceNum= %d\n",
iSliceNum);
return false;
}
@ -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;
@ -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,
InitMe (*pWelsMd, BLOCK_16x8,
pMbCache->SPicData.pEncMb[0] + (iPixelY * iStrideEnc),
pMbCache->SPicData.pRefMb[0] + (iPixelY * iStrideRef),
*sMe16x8 );
*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,
InitMe (*pWelsMd, BLOCK_8x16,
pMbCache->SPicData.pEncMb[0] + iPixelX,
pMbCache->SPicData.pRefMb[0] + iPixelX,
*sMe8x16 );
*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,
InitMe (*pWelsMd, BLOCK_8x8,
pMbCache->SPicData.pEncMb[0] + iStrideEnc,
pMbCache->SPicData.pRefMb[0] + iStrideRef,
*sMe8x8 );
*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;

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

@ -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);
@ -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
@ -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

@ -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;
}

View File

@ -57,19 +57,20 @@ const int32_t QStepx16ByQp[52] = { /* save QStep<<4 for int32_t */
2560, 2816, 3328, 3584 /* 48~51 */
};
static inline void UpdateMeResults( const SMVUnitXY ksBestMv, const uint32_t kiBestSadCost, uint8_t* pRef, SWelsME * pMe ) {
static inline void UpdateMeResults (const SMVUnitXY ksBestMv, const uint32_t kiBestSadCost, uint8_t* pRef,
SWelsME* pMe) {
pMe->sMv = ksBestMv;
pMe->pRefMb = pRef;
pMe->uiSadCost = kiBestSadCost;
}
static inline void MeEndIntepelSearch( SWelsME * pMe ) {
static inline void MeEndIntepelSearch (SWelsME* pMe) {
/* -> qpel mv */
pMe->sMv.iMvX <<= 2;
pMe->sMv.iMvY <<= 2;
pMe->uiSatdCost = pMe->uiSadCost;
}
void WelsInitMeFunc( SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScreenContent ) {
void WelsInitMeFunc (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScreenContent) {
if (!bScreenContent) {
pFuncList->pfCheckDirectionalMv = CheckDirectionalMvFalse;
pFuncList->pfCalculateBlockFeatureOfFrame[0] =
@ -84,7 +85,7 @@ void WelsInitMeFunc( SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScre
pFuncList->pfVerticalFullSearch = LineFullSearch_c;
pFuncList->pfHorizontalFullSearch = LineFullSearch_c;
#if defined (X86_ASM)
if ( uiCpuFlag & WELS_CPU_SSE41 ) {
if (uiCpuFlag & WELS_CPU_SSE41) {
pFuncList->pfSampleSadHor8[0] = SampleSad8x8Hor8_sse41;
pFuncList->pfSampleSadHor8[1] = SampleSad16x16Hor8_sse41;
pFuncList->pfVerticalFullSearch = VerticalFullSearchUsingSSE41;
@ -119,12 +120,13 @@ void WelsMotionEstimateSearch (SWelsFuncPtrList* pFuncList, void* pLplayer, void
const int32_t kiStrideRef = pCurDqLayer->pRefPic->iLineSize[0];
// Step 1: Initial point prediction
if ( !WelsMotionEstimateInitialPoint (pFuncList, pMe, pSlice, kiStrideEnc, kiStrideRef) ) {
if (!WelsMotionEstimateInitialPoint (pFuncList, pMe, pSlice, kiStrideEnc, kiStrideRef)) {
pFuncList->pfSearchMethod[pMe->uiBlockSize] (pFuncList, pMe, pSlice, kiStrideEnc, kiStrideRef);
MeEndIntepelSearch(pMe);
MeEndIntepelSearch (pMe);
}
pFuncList->pfCalculateSatd( pFuncList->sSampleDealingFuncs.pfSampleSatd[pMe->uiBlockSize], pMe, kiStrideEnc, kiStrideRef );
pFuncList->pfCalculateSatd (pFuncList->sSampleDealingFuncs.pfSampleSatd[pMe->uiBlockSize], pMe, kiStrideEnc,
kiStrideRef);
}
/*!
@ -185,31 +187,31 @@ bool WelsMotionEstimateInitialPoint (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
}
}
if ( pFuncList->pfCheckDirectionalMv
(pSad, pMe, ksMvStartMin, ksMvStartMax, iStrideEnc, iStrideRef, iSadCost) ) {
if (pFuncList->pfCheckDirectionalMv
(pSad, pMe, ksMvStartMin, ksMvStartMax, iStrideEnc, iStrideRef, iSadCost)) {
sMv = pMe->sDirectionalMv;
pRefMb = &pMe->pColoRefMb[sMv.iMvY * iStrideRef + sMv.iMvX];
iBestSadCost = iSadCost;
}
UpdateMeResults( sMv, iBestSadCost, pRefMb, pMe );
if ( iBestSadCost < static_cast<int32_t>(pMe->uSadPredISatd.uiSadPred) ) {
UpdateMeResults (sMv, iBestSadCost, pRefMb, pMe);
if (iBestSadCost < static_cast<int32_t> (pMe->uSadPredISatd.uiSadPred)) {
//Initial point early Stop
MeEndIntepelSearch(pMe);
MeEndIntepelSearch (pMe);
return true;
}
return false;
}
void CalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe,
const int32_t kiEncStride, const int32_t kiRefStride ) {
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
pMe->uSadPredISatd.uiSatd = pSatd(pMe->pEncMb, kiEncStride, pMe->pRefMb, kiRefStride);
void CalculateSatdCost (PSampleSadSatdCostFunc pSatd, void* vpMe,
const int32_t kiEncStride, const int32_t kiRefStride) {
SWelsME* pMe = static_cast<SWelsME*> (vpMe);
pMe->uSadPredISatd.uiSatd = pSatd (pMe->pEncMb, kiEncStride, pMe->pRefMb, kiRefStride);
pMe->uiSatdCost = pMe->uSadPredISatd.uiSatd + COST_MVD (pMe->pMvdCost, pMe->sMv.iMvX - pMe->sMvp.iMvX,
pMe->sMv.iMvY - pMe->sMvp.iMvY);
}
void NotCalculateSatdCost( 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) {
}
@ -286,8 +288,8 @@ void WelsDiamondSearch (SWelsFuncPtrList* pFuncList, void* pLpme, void* pLpslice
}
/* integer-pel mv */
pMe->sMv.iMvX = (iMvDx + pMe->sMvp.iMvX) >>2;
pMe->sMv.iMvY = (iMvDy + pMe->sMvp.iMvY) >>2;
pMe->sMv.iMvX = (iMvDx + pMe->sMvp.iMvX) >> 2;
pMe->sMv.iMvY = (iMvDy + pMe->sMvp.iMvY) >> 2;
pMe->uiSatdCost = pMe->uiSadCost = (iBestCost);
pMe->pRefMb = pRefMb;
}
@ -295,21 +297,21 @@ void WelsDiamondSearch (SWelsFuncPtrList* pFuncList, void* pLpme, void* pLpslice
/////////////////////////
// DirectionalMv Basics
/////////////////////////
bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
bool CheckDirectionalMv (PSampleSadSatdCostFunc pSad, void* vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost) {
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
SWelsME* pMe = static_cast<SWelsME*> (vpMe);
const int16_t kiMvX = pMe->sDirectionalMv.iMvX;
const int16_t kiMvY = pMe->sDirectionalMv.iMvY;
//Check MV from scrolling detection
if ( (BLOCK_16x16!=pMe->uiBlockSize) //scrolled_MV with P16x16 is checked SKIP checking function
&& ( kiMvX | kiMvY ) //(0,0) checked in ordinary initial point checking
&& CheckMvInRange( pMe->sDirectionalMv, ksMinMv, ksMaxMv ) ) {
if ((BLOCK_16x16 != pMe->uiBlockSize) //scrolled_MV with P16x16 is checked SKIP checking function
&& (kiMvX | kiMvY) //(0,0) checked in ordinary initial point checking
&& CheckMvInRange (pMe->sDirectionalMv, ksMinMv, ksMaxMv)) {
uint8_t* pRef = &pMe->pColoRefMb[kiMvY * kiRefStride + kiMvX];
uint32_t uiCurrentSadCost = pSad( pMe->pEncMb, kiEncStride, pRef, kiRefStride ) +
COST_MVD(pMe->pMvdCost, (kiMvX<<2) - pMe->sMvp.iMvX, (kiMvY<<2) - pMe->sMvp.iMvY );
if( uiCurrentSadCost < pMe->uiSadCost ) {
uint32_t uiCurrentSadCost = pSad (pMe->pEncMb, kiEncStride, pRef, kiRefStride) +
COST_MVD (pMe->pMvdCost, (kiMvX << 2) - pMe->sMvp.iMvX, (kiMvY << 2) - pMe->sMvp.iMvY);
if (uiCurrentSadCost < pMe->uiSadCost) {
iBestSadCost = uiCurrentSadCost;
return true;
}
@ -317,7 +319,7 @@ bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
return false;
}
bool CheckDirectionalMvFalse(PSampleSadSatdCostFunc pSad, void * vpMe,
bool CheckDirectionalMvFalse (PSampleSadSatdCostFunc pSad, void* vpMe,
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
int32_t& iBestSadCost) {
return false;
@ -327,44 +329,45 @@ bool CheckDirectionalMvFalse(PSampleSadSatdCostFunc pSad, void * vpMe,
// Cross Search Basics
/////////////////////////
#if defined (X86_ASM)
void CalcMvdCostx8_c( uint16_t *pMvdCost, const int32_t kiStartMv, uint16_t* pMvdTable, const uint16_t kiFixedCost )
{
uint16_t *pBaseCost = pMvdCost;
const int32_t kiOffset = (kiStartMv<<2);
uint16_t *pMvd = pMvdTable+kiOffset;
void CalcMvdCostx8_c (uint16_t* pMvdCost, const int32_t kiStartMv, uint16_t* pMvdTable, const uint16_t kiFixedCost) {
uint16_t* pBaseCost = pMvdCost;
const int32_t kiOffset = (kiStartMv << 2);
uint16_t* pMvd = pMvdTable + kiOffset;
for (int32_t i = 0; i < 8; ++ i) {
pBaseCost[i] = ((*pMvd) + kiFixedCost);
pMvd += 4;
}
}
void VerticalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
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 ) {
const bool bVerticalSearch) {
uint8_t* kpEncMb = pMe->pEncMb;
const int32_t kiCurMeBlockPix = pMe->iCurMeBlockPixY;
uint8_t* pRef = &pMe->pColoRefMb[(kiMinPos - kiCurMeBlockPix)*kiRefStride];
uint8_t* pRef = &pMe->pColoRefMb[ (kiMinPos - kiCurMeBlockPix) * kiRefStride];
const int32_t kIsBlock16x16 = pMe->uiBlockSize == BLOCK_16x16;
const int32_t kiEdgeBlocks = kIsBlock16x16 ? 16 : 8;
PSampleSadHor8Func pSampleSadHor8 = pFuncList->pfSampleSadHor8[kIsBlock16x16];
PSampleSadSatdCostFunc pSad = pFuncList->sSampleDealingFuncs.pfSampleSad[pMe->uiBlockSize];
PTransposeMatrixBlockFunc TransposeMatrixBlock = kIsBlock16x16 ? TransposeMatrixBlock16x16_sse2 : TransposeMatrixBlock8x8_mmx;
PTransposeMatrixBlocksFunc TransposeMatrixBlocks= kIsBlock16x16 ? TransposeMatrixBlocksx16_sse2 : TransposeMatrixBlocksx8_mmx;
PTransposeMatrixBlockFunc TransposeMatrixBlock = kIsBlock16x16 ? TransposeMatrixBlock16x16_sse2 :
TransposeMatrixBlock8x8_mmx;
PTransposeMatrixBlocksFunc TransposeMatrixBlocks = kIsBlock16x16 ? TransposeMatrixBlocksx16_sse2 :
TransposeMatrixBlocksx8_mmx;
const int32_t kiDiff = kiMaxPos - kiMinPos;
const int32_t kiRowNum = WELS_ALIGN((kiDiff - kiEdgeBlocks + 1), kiEdgeBlocks);
const int32_t kiBlocksNum = kIsBlock16x16 ? (kiRowNum>>4) : (kiRowNum>>3);
int32_t iCountLoop8 = (kiRowNum-kiEdgeBlocks) >> 3;
const int32_t kiRemainingVectors = kiDiff - (iCountLoop8<<3);
const int32_t kiRowNum = WELS_ALIGN ((kiDiff - kiEdgeBlocks + 1), kiEdgeBlocks);
const int32_t kiBlocksNum = kIsBlock16x16 ? (kiRowNum >> 4) : (kiRowNum >> 3);
int32_t iCountLoop8 = (kiRowNum - kiEdgeBlocks) >> 3;
const int32_t kiRemainingVectors = kiDiff - (iCountLoop8 << 3);
const int32_t kiMatrixStride = MAX_VERTICAL_MV_RANGE;
ENFORCE_STACK_ALIGN_2D( uint8_t, uiMatrixRef, 16, kiMatrixStride, 16 ); // transpose matrix result for ref
ENFORCE_STACK_ALIGN_2D( uint8_t, uiMatrixEnc, 16, 16, 16 ); // transpose matrix result for enc
assert(kiRowNum <= kiMatrixStride); // make sure effective memory
ENFORCE_STACK_ALIGN_2D (uint8_t, uiMatrixRef, 16, kiMatrixStride, 16); // transpose matrix result for ref
ENFORCE_STACK_ALIGN_2D (uint8_t, uiMatrixEnc, 16, 16, 16); // transpose matrix result for enc
assert (kiRowNum <= kiMatrixStride); // make sure effective memory
TransposeMatrixBlock( &uiMatrixEnc[0][0], 16, kpEncMb, kiEncStride );
TransposeMatrixBlocks( &uiMatrixRef[0][0], kiMatrixStride, pRef, kiRefStride, kiBlocksNum );
ENFORCE_STACK_ALIGN_1D( uint16_t, uiBaseCost, 8, 16 );
TransposeMatrixBlock (&uiMatrixEnc[0][0], 16, kpEncMb, kiEncStride);
TransposeMatrixBlocks (&uiMatrixRef[0][0], kiMatrixStride, pRef, kiRefStride, kiBlocksNum);
ENFORCE_STACK_ALIGN_1D (uint16_t, uiBaseCost, 8, 16);
int32_t iTargetPos = kiMinPos;
int16_t iBestPos = pMe->sMv.iMvX;
uint32_t uiBestCost = pMe->uiSadCost;
@ -373,12 +376,12 @@ void VerticalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
kpEncMb = &uiMatrixEnc[0][0];
pRef = &uiMatrixRef[0][0];
while(iCountLoop8 > 0) {
CalcMvdCostx8_c(uiBaseCost, iTargetPos, pMvdTable, kiFixedMvd);
uiCostMin = pSampleSadHor8( kpEncMb, 16, pRef, kiMatrixStride, uiBaseCost, &iIndexMinPos );
while (iCountLoop8 > 0) {
CalcMvdCostx8_c (uiBaseCost, iTargetPos, pMvdTable, kiFixedMvd);
uiCostMin = pSampleSadHor8 (kpEncMb, 16, pRef, kiMatrixStride, uiBaseCost, &iIndexMinPos);
if (uiCostMin < uiBestCost) {
uiBestCost = uiCostMin;
iBestPos = iTargetPos+iIndexMinPos;
iBestPos = iTargetPos + iIndexMinPos;
}
iTargetPos += 8;
pRef += 8;
@ -386,10 +389,10 @@ void VerticalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
}
if (kiRemainingVectors > 0) {
kpEncMb = pMe->pEncMb;
pRef = &pMe->pColoRefMb[(iTargetPos - kiCurMeBlockPix)*kiRefStride];
pRef = &pMe->pColoRefMb[ (iTargetPos - kiCurMeBlockPix) * kiRefStride];
while (iTargetPos < kiMaxPos) {
const uint16_t pMvdCost = pMvdTable[iTargetPos<<2];
uint32_t uiSadCost = pSad( kpEncMb, kiEncStride, pRef, kiRefStride ) + (kiFixedMvd + pMvdCost);
const uint16_t pMvdCost = pMvdTable[iTargetPos << 2];
uint32_t uiSadCost = pSad (kpEncMb, kiEncStride, pRef, kiRefStride) + (kiFixedMvd + pMvdCost);
if (uiSadCost < uiBestCost) {
uiBestCost = uiSadCost;
iBestPos = iTargetPos;
@ -402,23 +405,22 @@ void VerticalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
SMVUnitXY sBestMv;
sBestMv.iMvX = 0;
sBestMv.iMvY = iBestPos - kiCurMeBlockPix;
UpdateMeResults( sBestMv, uiBestCost, &pMe->pColoRefMb[sBestMv.iMvY*kiRefStride], pMe );
UpdateMeResults (sBestMv, uiBestCost, &pMe->pColoRefMb[sBestMv.iMvY * kiRefStride], pMe);
}
}
void HorizontalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
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 )
{
uint8_t *kpEncMb = pMe->pEncMb;
const bool bVerticalSearch) {
uint8_t* kpEncMb = pMe->pEncMb;
const int32_t kiCurMeBlockPix = pMe->iCurMeBlockPixX;
uint8_t *pRef = &pMe->pColoRefMb[kiMinPos - kiCurMeBlockPix];
uint8_t* pRef = &pMe->pColoRefMb[kiMinPos - kiCurMeBlockPix];
const int32_t kIsBlock16x16 = pMe->uiBlockSize == BLOCK_16x16;
PSampleSadHor8Func pSampleSadHor8 = pFuncList->pfSampleSadHor8[kIsBlock16x16];
PSampleSadSatdCostFunc pSad = pFuncList->sSampleDealingFuncs.pfSampleSad[pMe->uiBlockSize];
ENFORCE_STACK_ALIGN_1D( uint16_t, uiBaseCost, 8, 16 );
ENFORCE_STACK_ALIGN_1D (uint16_t, uiBaseCost, 8, 16);
const int32_t kiNumVector = kiMaxPos - kiMinPos;
int32_t iCountLoop8 = kiNumVector >> 3;
const int32_t kiRemainingLoop8 = kiNumVector & 7;
@ -428,21 +430,21 @@ void HorizontalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
uint32_t uiCostMin;
int32_t iIndexMinPos;
while(iCountLoop8 > 0) {
CalcMvdCostx8_c(uiBaseCost, iTargetPos, pMvdTable, kiFixedMvd);
uiCostMin = pSampleSadHor8( kpEncMb, kiEncStride, pRef, kiRefStride, uiBaseCost, &iIndexMinPos );
while (iCountLoop8 > 0) {
CalcMvdCostx8_c (uiBaseCost, iTargetPos, pMvdTable, kiFixedMvd);
uiCostMin = pSampleSadHor8 (kpEncMb, kiEncStride, pRef, kiRefStride, uiBaseCost, &iIndexMinPos);
if (uiCostMin < uiBestCost) {
uiBestCost = uiCostMin;
iBestPos = iTargetPos+iIndexMinPos;
iBestPos = iTargetPos + iIndexMinPos;
}
iTargetPos += 8;
pRef += 8;
-- iCountLoop8;
}
if ( kiRemainingLoop8 > 0 ) {
if (kiRemainingLoop8 > 0) {
while (iTargetPos < kiMaxPos) {
const uint16_t pMvdCost = pMvdTable[iTargetPos<<2];
uint32_t uiSadCost = pSad( kpEncMb, kiEncStride, pRef, kiRefStride ) + (kiFixedMvd + pMvdCost);
const uint16_t pMvdCost = pMvdTable[iTargetPos << 2];
uint32_t uiSadCost = pSad (kpEncMb, kiEncStride, pRef, kiRefStride) + (kiFixedMvd + pMvdCost);
if (uiSadCost < uiBestCost) {
uiBestCost = uiSadCost;
iBestPos = iTargetPos;
@ -455,69 +457,69 @@ void HorizontalFullSearchUsingSSE41( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
SMVUnitXY sBestMv;
sBestMv.iMvX = iBestPos - kiCurMeBlockPix;
sBestMv.iMvY = 0;
UpdateMeResults( sBestMv, uiBestCost, &pMe->pColoRefMb[sBestMv.iMvY], pMe );
UpdateMeResults (sBestMv, uiBestCost, &pMe->pColoRefMb[sBestMv.iMvY], pMe);
}
}
#endif
void LineFullSearch_c( SWelsFuncPtrList *pFuncList, SWelsME *pMe,
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 ) {
const bool bVerticalSearch) {
PSampleSadSatdCostFunc pSad = pFuncList->sSampleDealingFuncs.pfSampleSad[pMe->uiBlockSize];
const int32_t kiCurMeBlockPix = bVerticalSearch?pMe->iCurMeBlockPixY:pMe->iCurMeBlockPixX;
const int32_t kiStride = bVerticalSearch?kiRefStride:1;
uint8_t* pRef = &pMe->pColoRefMb[(kiMinPos - kiCurMeBlockPix)*kiStride];
uint16_t* pMvdCost = &(pMvdTable[kiMinPos<<2]);
const int32_t kiCurMeBlockPix = bVerticalSearch ? pMe->iCurMeBlockPixY : pMe->iCurMeBlockPixX;
const int32_t kiStride = bVerticalSearch ? kiRefStride : 1;
uint8_t* pRef = &pMe->pColoRefMb[ (kiMinPos - kiCurMeBlockPix) * kiStride];
uint16_t* pMvdCost = & (pMvdTable[kiMinPos << 2]);
uint32_t uiBestCost = 0xFFFFFFFF;
int32_t iBestPos = 0;
for ( int32_t iTargetPos = kiMinPos; iTargetPos < kiMaxPos; ++ iTargetPos ) {
for (int32_t iTargetPos = kiMinPos; iTargetPos < kiMaxPos; ++ iTargetPos) {
uint8_t* const kpEncMb = pMe->pEncMb;
uint32_t uiSadCost = pSad( kpEncMb, kiEncStride, pRef, kiRefStride ) + (kiFixedMvd + *pMvdCost);
uint32_t uiSadCost = pSad (kpEncMb, kiEncStride, pRef, kiRefStride) + (kiFixedMvd + *pMvdCost);
if (uiSadCost < uiBestCost) {
uiBestCost = uiSadCost;
iBestPos = iTargetPos;
}
pRef += kiStride;
pMvdCost+=4;
pMvdCost += 4;
}
if (uiBestCost < pMe->uiSadCost) {
SMVUnitXY sBestMv;
sBestMv.iMvX = bVerticalSearch?0:(iBestPos - kiCurMeBlockPix);
sBestMv.iMvY = bVerticalSearch?(iBestPos - kiCurMeBlockPix):0;
UpdateMeResults( sBestMv, uiBestCost, &pMe->pColoRefMb[sBestMv.iMvY*kiStride], pMe );
sBestMv.iMvX = bVerticalSearch ? 0 : (iBestPos - kiCurMeBlockPix);
sBestMv.iMvY = bVerticalSearch ? (iBestPos - kiCurMeBlockPix) : 0;
UpdateMeResults (sBestMv, uiBestCost, &pMe->pColoRefMb[sBestMv.iMvY * kiStride], pMe);
}
}
void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SWelsME * pMe,
void WelsMotionCrossSearch (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
const SSlice* pSlice, const int32_t kiEncStride, const int32_t kiRefStride) {
PLineFullSearchFunc pfVerticalFullSearchFunc = pFuncList->pfVerticalFullSearch;
PLineFullSearchFunc pfHorizontalFullSearchFunc = pFuncList->pfHorizontalFullSearch;
const int32_t iCurMeBlockPixX = pMe->iCurMeBlockPixX;
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX) << 2);
const int32_t iCurMeBlockPixY = pMe->iCurMeBlockPixY;
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY)<<2);
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY) << 2);
uint16_t* pMvdCostX = pMe->pMvdCost - iCurMeBlockQpelPixX - pMe->sMvp.iMvX;//do the offset here instead of in the search
uint16_t* pMvdCostY = pMe->pMvdCost - iCurMeBlockQpelPixY - pMe->sMvp.iMvY;//do the offset here instead of in the search
//vertical search
pfVerticalFullSearchFunc( pFuncList, pMe,
pfVerticalFullSearchFunc (pFuncList, pMe,
pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
kiEncStride, kiRefStride,
iCurMeBlockPixY + pSlice->sMvStartMin.iMvY,
iCurMeBlockPixY + pSlice->sMvStartMax.iMvY, true );
iCurMeBlockPixY + pSlice->sMvStartMax.iMvY, true);
//horizontal search
if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
pfHorizontalFullSearchFunc( pFuncList, pMe,
pfHorizontalFullSearchFunc (pFuncList, pMe,
pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
kiEncStride, kiRefStride,
iCurMeBlockPixX + pSlice->sMvStartMin.iMvX,
iCurMeBlockPixX + pSlice->sMvStartMax.iMvX,
false );
false);
}
}
@ -525,23 +527,24 @@ void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SWelsME * pMe,
// Feature Search Basics
/////////////////////////
//memory related
int32_t RequestFeatureSearchPreparation( CMemoryAlign *pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight, const int32_t iNeedFeatureStorage,
int32_t RequestFeatureSearchPreparation (CMemoryAlign* pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight,
const int32_t iNeedFeatureStorage,
SFeatureSearchPreparation* pFeatureSearchPreparation) {
const int32_t kiFeatureStrategyIndex = iNeedFeatureStorage>>16;
const bool bFme8x8 = ((iNeedFeatureStorage & 0x0000FF & ME_FME)==ME_FME);
const int32_t kiMarginSize = bFme8x8?8:16;
const int32_t kiFrameSize = (kiFrameWidth-kiMarginSize) * (kiFrameHeight-kiMarginSize);
const int32_t kiFeatureStrategyIndex = iNeedFeatureStorage >> 16;
const bool bFme8x8 = ((iNeedFeatureStorage & 0x0000FF & ME_FME) == ME_FME);
const int32_t kiMarginSize = bFme8x8 ? 8 : 16;
const int32_t kiFrameSize = (kiFrameWidth - kiMarginSize) * (kiFrameHeight - kiMarginSize);
int32_t iListOfFeatureOfBlock;
if (0==kiFeatureStrategyIndex) {
iListOfFeatureOfBlock =sizeof(uint16_t) * kiFrameSize;
if (0 == kiFeatureStrategyIndex) {
iListOfFeatureOfBlock = sizeof (uint16_t) * kiFrameSize;
} else {
iListOfFeatureOfBlock = sizeof(uint16_t) * kiFrameSize +
(kiFrameWidth-kiMarginSize) * sizeof(uint32_t) + kiFrameWidth * 8 * sizeof(uint8_t);
iListOfFeatureOfBlock = sizeof (uint16_t) * kiFrameSize +
(kiFrameWidth - kiMarginSize) * sizeof (uint32_t) + kiFrameWidth * 8 * sizeof (uint8_t);
}
pFeatureSearchPreparation->pFeatureOfBlock =
(uint16_t *)pMa->WelsMalloc(iListOfFeatureOfBlock, "pFeatureOfBlock");
WELS_VERIFY_RETURN_IF(ENC_RETURN_MEMALLOCERR, NULL == (pFeatureSearchPreparation->pFeatureOfBlock) )
(uint16_t*)pMa->WelsMalloc (iListOfFeatureOfBlock, "pFeatureOfBlock");
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == (pFeatureSearchPreparation->pFeatureOfBlock))
pFeatureSearchPreparation->uiFeatureStrategyIndex = kiFeatureStrategyIndex;
pFeatureSearchPreparation->bFMESwitchFlag = true;
@ -550,64 +553,69 @@ int32_t RequestFeatureSearchPreparation( CMemoryAlign *pMa, const int32_t kiFram
return ENC_RETURN_SUCCESS;
}
int32_t ReleaseFeatureSearchPreparation( CMemoryAlign *pMa, uint16_t*& pFeatureOfBlock) {
if ( pMa && pFeatureOfBlock ) {
pMa->WelsFree( pFeatureOfBlock, "pFeatureOfBlock");
pFeatureOfBlock=NULL;
int32_t ReleaseFeatureSearchPreparation (CMemoryAlign* pMa, uint16_t*& pFeatureOfBlock) {
if (pMa && pFeatureOfBlock) {
pMa->WelsFree (pFeatureOfBlock, "pFeatureOfBlock");
pFeatureOfBlock = NULL;
return ENC_RETURN_SUCCESS;
}
return ENC_RETURN_UNEXPECTED;
}
int32_t RequestScreenBlockFeatureStorage( CMemoryAlign *pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight, const int32_t iNeedFeatureStorage,
int32_t RequestScreenBlockFeatureStorage (CMemoryAlign* pMa, const int32_t kiFrameWidth, const int32_t kiFrameHeight,
const int32_t iNeedFeatureStorage,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage) {
const int32_t kiFeatureStrategyIndex = iNeedFeatureStorage>>16;
const int32_t kiFeatureStrategyIndex = iNeedFeatureStorage >> 16;
const int32_t kiMe8x8FME = iNeedFeatureStorage & 0x0000FF & ME_FME;
const int32_t kiMe16x16FME = ((iNeedFeatureStorage & 0x00FF00)>>8) & ME_FME;
if ((kiMe8x8FME==ME_FME) && (kiMe16x16FME==ME_FME)) {
const int32_t kiMe16x16FME = ((iNeedFeatureStorage & 0x00FF00) >> 8) & ME_FME;
if ((kiMe8x8FME == ME_FME) && (kiMe16x16FME == ME_FME)) {
return ENC_RETURN_UNSUPPORTED_PARA;
//the following memory allocation cannot support when FME at both size
}
const bool bIsBlock8x8 = (kiMe8x8FME==ME_FME);
const int32_t kiMarginSize = bIsBlock8x8?8:16;
const int32_t kiFrameSize = (kiFrameWidth-kiMarginSize) * (kiFrameHeight-kiMarginSize);
const int32_t kiListSize = (0==kiFeatureStrategyIndex)?(bIsBlock8x8 ? LIST_SIZE_SUM_8x8 : LIST_SIZE_SUM_16x16):256;
const bool bIsBlock8x8 = (kiMe8x8FME == ME_FME);
const int32_t kiMarginSize = bIsBlock8x8 ? 8 : 16;
const int32_t kiFrameSize = (kiFrameWidth - kiMarginSize) * (kiFrameHeight - kiMarginSize);
const int32_t kiListSize = (0 == kiFeatureStrategyIndex) ? (bIsBlock8x8 ? LIST_SIZE_SUM_8x8 : LIST_SIZE_SUM_16x16) :
256;
pScreenBlockFeatureStorage->pTimesOfFeatureValue = (uint32_t*)pMa->WelsMalloc(kiListSize*sizeof(uint32_t),"pScreenBlockFeatureStorage->pTimesOfFeatureValue");
WELS_VERIFY_RETURN_IF(ENC_RETURN_MEMALLOCERR, NULL == pScreenBlockFeatureStorage->pTimesOfFeatureValue)
pScreenBlockFeatureStorage->pTimesOfFeatureValue = (uint32_t*)pMa->WelsMalloc (kiListSize * sizeof (uint32_t),
"pScreenBlockFeatureStorage->pTimesOfFeatureValue");
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pScreenBlockFeatureStorage->pTimesOfFeatureValue)
pScreenBlockFeatureStorage->pLocationOfFeature = (uint16_t**)pMa->WelsMalloc(kiListSize*sizeof(uint16_t*),"pScreenBlockFeatureStorage->pLocationOfFeature");
WELS_VERIFY_RETURN_IF(ENC_RETURN_MEMALLOCERR, NULL == pScreenBlockFeatureStorage->pLocationOfFeature)
pScreenBlockFeatureStorage->pLocationOfFeature = (uint16_t**)pMa->WelsMalloc (kiListSize * sizeof (uint16_t*),
"pScreenBlockFeatureStorage->pLocationOfFeature");
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pScreenBlockFeatureStorage->pLocationOfFeature)
pScreenBlockFeatureStorage->pLocationPointer = (uint16_t*)pMa->WelsMalloc(2*kiFrameSize*sizeof(uint16_t), "pScreenBlockFeatureStorage->pLocationPointer");
WELS_VERIFY_RETURN_IF(ENC_RETURN_MEMALLOCERR, NULL == pScreenBlockFeatureStorage->pLocationPointer)
pScreenBlockFeatureStorage->pLocationPointer = (uint16_t*)pMa->WelsMalloc (2 * kiFrameSize * sizeof (uint16_t),
"pScreenBlockFeatureStorage->pLocationPointer");
WELS_VERIFY_RETURN_IF (ENC_RETURN_MEMALLOCERR, NULL == pScreenBlockFeatureStorage->pLocationPointer)
pScreenBlockFeatureStorage->pFeatureOfBlockPointer = NULL;
pScreenBlockFeatureStorage->iIs16x16 = !bIsBlock8x8;
pScreenBlockFeatureStorage->uiFeatureStrategyIndex = kiFeatureStrategyIndex;
pScreenBlockFeatureStorage->iActualListSize = kiListSize;
memset(pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL*sizeof(uint32_t));
memset (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL * sizeof (uint32_t));
pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false;
return ENC_RETURN_SUCCESS;
}
int32_t ReleaseScreenBlockFeatureStorage( CMemoryAlign *pMa, SScreenBlockFeatureStorage* pScreenBlockFeatureStorage ) {
if ( pMa && pScreenBlockFeatureStorage ) {
int32_t ReleaseScreenBlockFeatureStorage (CMemoryAlign* pMa, SScreenBlockFeatureStorage* pScreenBlockFeatureStorage) {
if (pMa && pScreenBlockFeatureStorage) {
if (pScreenBlockFeatureStorage->pTimesOfFeatureValue) {
pMa->WelsFree( pScreenBlockFeatureStorage->pTimesOfFeatureValue, "pScreenBlockFeatureStorage->pTimesOfFeatureValue");
pScreenBlockFeatureStorage->pTimesOfFeatureValue=NULL;
pMa->WelsFree (pScreenBlockFeatureStorage->pTimesOfFeatureValue, "pScreenBlockFeatureStorage->pTimesOfFeatureValue");
pScreenBlockFeatureStorage->pTimesOfFeatureValue = NULL;
}
if (pScreenBlockFeatureStorage->pLocationOfFeature) {
pMa->WelsFree( pScreenBlockFeatureStorage->pLocationOfFeature, "pScreenBlockFeatureStorage->pLocationOfFeature");
pScreenBlockFeatureStorage->pLocationOfFeature=NULL;
pMa->WelsFree (pScreenBlockFeatureStorage->pLocationOfFeature, "pScreenBlockFeatureStorage->pLocationOfFeature");
pScreenBlockFeatureStorage->pLocationOfFeature = NULL;
}
if (pScreenBlockFeatureStorage->pLocationPointer) {
pMa->WelsFree( pScreenBlockFeatureStorage->pLocationPointer, "pScreenBlockFeatureStorage->pLocationPointer");
pScreenBlockFeatureStorage->pLocationPointer=NULL;
pMa->WelsFree (pScreenBlockFeatureStorage->pLocationPointer, "pScreenBlockFeatureStorage->pLocationPointer");
pScreenBlockFeatureStorage->pLocationPointer = NULL;
}
return ENC_RETURN_SUCCESS;
@ -616,18 +624,18 @@ int32_t ReleaseScreenBlockFeatureStorage( CMemoryAlign *pMa, SScreenBlockFeature
}
//preprocess related
int32_t SumOf8x8SingleBlock_c(uint8_t* pRef, const int32_t kiRefStride) {
int32_t SumOf8x8SingleBlock_c (uint8_t* pRef, const int32_t kiRefStride) {
int32_t iSum = 0, i;
for(i = 0; i < 8; i++) {
for (i = 0; i < 8; i++) {
iSum += pRef[0] + pRef[1] + pRef[2] + pRef[3];
iSum += pRef[4] + pRef[5] + pRef[6] + pRef[7];
pRef += kiRefStride;
}
return iSum;
}
int32_t SumOf16x16SingleBlock_c(uint8_t* pRef, const int32_t kiRefStride) {
int32_t SumOf16x16SingleBlock_c (uint8_t* pRef, const int32_t kiRefStride) {
int32_t iSum = 0, i;
for(i = 0; i < 16; i++) {
for (i = 0; i < 16; i++) {
iSum += pRef[0] + pRef[1] + pRef[2] + pRef[3];
iSum += pRef[4] + pRef[5] + pRef[6] + pRef[7];
iSum += pRef[8] + pRef[9] + pRef[10] + pRef[11];
@ -637,18 +645,18 @@ int32_t SumOf16x16SingleBlock_c(uint8_t* pRef, const int32_t kiRefStride) {
return iSum;
}
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 SumOf8x8BlockOfFrame_c (uint8_t* pRefPicture, const int32_t kiWidth, const int32_t kiHeight,
const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]) {
int32_t x, y;
uint8_t *pRef;
uint16_t *pBuffer;
uint8_t* pRef;
uint16_t* pBuffer;
int32_t iSum;
for(y = 0; y < kiHeight; y++) {
for (y = 0; y < kiHeight; y++) {
pRef = pRefPicture + kiRefStride * y;
pBuffer = pFeatureOfBlock + kiWidth * y;
for(x = 0; x < kiWidth; x++) {
iSum = SumOf8x8SingleBlock_c(pRef + x, kiRefStride);
for (x = 0; x < kiWidth; x++) {
iSum = SumOf8x8SingleBlock_c (pRef + x, kiRefStride);
pBuffer[x] = iSum;
pTimesOfFeatureValue[iSum]++;
@ -656,18 +664,19 @@ void SumOf8x8BlockOfFrame_c(uint8_t *pRefPicture, const int32_t kiWidth, const i
}
}
void SumOf16x16BlockOfFrame_c(uint8_t *pRefPicture, const int32_t kiWidth, const int32_t kiHeight, const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[])
{//TODO: this is similar to SumOf8x8BlockOfFrame_c expect the calling of single block func, refactor-able?
void SumOf16x16BlockOfFrame_c (uint8_t* pRefPicture, const int32_t kiWidth, const int32_t kiHeight,
const int32_t kiRefStride,
uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]) {
//TODO: this is similar to SumOf8x8BlockOfFrame_c expect the calling of single block func, refactor-able?
int32_t x, y;
uint8_t *pRef;
uint16_t *pBuffer;
uint8_t* pRef;
uint16_t* pBuffer;
int32_t iSum;
for(y = 0; y < kiHeight; y++) {
for (y = 0; y < kiHeight; y++) {
pRef = pRefPicture + kiRefStride * y;
pBuffer = pFeatureOfBlock + kiWidth * y;
for(x = 0; x < kiWidth; x++) {
iSum = SumOf16x16SingleBlock_c(pRef + x, kiRefStride);
for (x = 0; x < kiWidth; x++) {
iSum = SumOf16x16SingleBlock_c (pRef + x, kiRefStride);
pBuffer[x] = iSum;
pTimesOfFeatureValue[iSum]++;
@ -675,25 +684,25 @@ void SumOf16x16BlockOfFrame_c(uint8_t *pRefPicture, const int32_t kiWidth, const
}
}
void InitializeHashforFeature_c( uint32_t* pTimesOfFeatureValue, uint16_t* pBuf, const int32_t kiListSize,
uint16_t** pLocationOfFeature, uint16_t** pFeatureValuePointerList ) {
void InitializeHashforFeature_c (uint32_t* pTimesOfFeatureValue, uint16_t* pBuf, const int32_t kiListSize,
uint16_t** pLocationOfFeature, uint16_t** pFeatureValuePointerList) {
//assign location pointer
uint16_t *pBufPos = pBuf;
for( int32_t i = 0 ; i < kiListSize; ++i ) {
uint16_t* pBufPos = pBuf;
for (int32_t i = 0 ; i < kiListSize; ++i) {
pLocationOfFeature[i] =
pFeatureValuePointerList[i] = pBufPos;
pBufPos += (pTimesOfFeatureValue[i]<<1);
pBufPos += (pTimesOfFeatureValue[i] << 1);
}
}
void FillQpelLocationByFeatureValue_c( uint16_t* pFeatureOfBlock, const int32_t kiWidth, const int32_t kiHeight,
uint16_t** pFeatureValuePointerList ) {
void FillQpelLocationByFeatureValue_c (uint16_t* pFeatureOfBlock, const int32_t kiWidth, const int32_t kiHeight,
uint16_t** pFeatureValuePointerList) {
//assign each pixel's position
uint16_t* pSrcPointer = pFeatureOfBlock;
int32_t iQpelY = 0;
for(int32_t y = 0; y < kiHeight; y++) {
for(int32_t x = 0; x < kiWidth; x++) {
for (int32_t y = 0; y < kiHeight; y++) {
for (int32_t x = 0; x < kiWidth; x++) {
uint16_t uiFeature = pSrcPointer[x];
ST32( &pFeatureValuePointerList[uiFeature][0], ((iQpelY<<16)|(x<<2)) );
ST32 (&pFeatureValuePointerList[uiFeature][0], ((iQpelY << 16) | (x << 2)));
pFeatureValuePointerList[uiFeature] += 2;
}
iQpelY += 4;
@ -701,7 +710,7 @@ void FillQpelLocationByFeatureValue_c( uint16_t* pFeatureOfBlock, const int32_t
}
}
void CalculateFeatureOfBlock( SWelsFuncPtrList *pFunc, SPicture* pRef,
void CalculateFeatureOfBlock (SWelsFuncPtrList* pFunc, SPicture* pRef,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage) {
uint16_t* pFeatureOfBlock = pScreenBlockFeatureStorage->pFeatureOfBlockPointer;
uint32_t* pTimesOfFeatureValue = pScreenBlockFeatureStorage->pTimesOfFeatureValue;
@ -711,46 +720,47 @@ void CalculateFeatureOfBlock( SWelsFuncPtrList *pFunc, SPicture* pRef,
uint8_t* pRefData = pRef->pData[0];
const int32_t iRefStride = pRef->iLineSize[0];
int32_t iIs16x16 = pScreenBlockFeatureStorage->iIs16x16;
const int32_t iEdgeDiscard = (iIs16x16?16:8);//this is to save complexity of padding on pRef
const int32_t iEdgeDiscard = (iIs16x16 ? 16 : 8); //this is to save complexity of padding on pRef
const int32_t iWidth = pRef->iWidthInPixel - iEdgeDiscard;
const int32_t kiHeight = pRef->iHeightInPixel - iEdgeDiscard;
const int32_t kiActualListSize = pScreenBlockFeatureStorage->iActualListSize;
uint16_t* pFeatureValuePointerList[WELS_MAX(LIST_SIZE_SUM_16x16,LIST_SIZE_MSE_16x16)] = {0};
uint16_t* pFeatureValuePointerList[WELS_MAX (LIST_SIZE_SUM_16x16, LIST_SIZE_MSE_16x16)] = {0};
memset(pTimesOfFeatureValue, 0, sizeof(int32_t)*kiActualListSize);
(pFunc->pfCalculateBlockFeatureOfFrame[iIs16x16])(pRefData,iWidth, kiHeight, iRefStride, pFeatureOfBlock, pTimesOfFeatureValue);
memset (pTimesOfFeatureValue, 0, sizeof (int32_t)*kiActualListSize);
(pFunc->pfCalculateBlockFeatureOfFrame[iIs16x16]) (pRefData, iWidth, kiHeight, iRefStride, pFeatureOfBlock,
pTimesOfFeatureValue);
//assign pLocationOfFeature pointer
InitializeHashforFeature_c( pTimesOfFeatureValue, pBuf, kiActualListSize,
pLocationOfFeature, pFeatureValuePointerList );
InitializeHashforFeature_c (pTimesOfFeatureValue, pBuf, kiActualListSize,
pLocationOfFeature, pFeatureValuePointerList);
//assign each pixel's pLocationOfFeature
FillQpelLocationByFeatureValue_c(pFeatureOfBlock, iWidth, kiHeight, pFeatureValuePointerList);
FillQpelLocationByFeatureValue_c (pFeatureOfBlock, iWidth, kiHeight, pFeatureValuePointerList);
}
void PerformFMEPreprocess( SWelsFuncPtrList *pFunc, SPicture* pRef, uint16_t* pFeatureOfBlock,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage)
{
void PerformFMEPreprocess (SWelsFuncPtrList* pFunc, SPicture* pRef, uint16_t* pFeatureOfBlock,
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage) {
pScreenBlockFeatureStorage->pFeatureOfBlockPointer = pFeatureOfBlock;
CalculateFeatureOfBlock(pFunc, pRef, pScreenBlockFeatureStorage );
CalculateFeatureOfBlock (pFunc, pRef, pScreenBlockFeatureStorage);
pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = true;
uint32_t uiRefPictureAvgQstepx16 = QStepx16ByQp[WelsMedian(0, pRef->iFrameAverageQp, 51)];
uint32_t uiSadCostThreshold16x16 = ((30 * (uiRefPictureAvgQstepx16 + 160))>>3);
uint32_t uiRefPictureAvgQstepx16 = QStepx16ByQp[WelsMedian (0, pRef->iFrameAverageQp, 51)];
uint32_t uiSadCostThreshold16x16 = ((30 * (uiRefPictureAvgQstepx16 + 160)) >> 3);
pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_16x16] = uiSadCostThreshold16x16;
pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_8x8] = (uiSadCostThreshold16x16>>2);
pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_8x8] = (uiSadCostThreshold16x16 >> 2);
pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_16x8]
= pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_8x16]
= pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_4x4] = UINT_MAX;
}
//search related
void SetFeatureSearchIn( SWelsFuncPtrList *pFunc, const SWelsME& sMe,
const SSlice *pSlice, SScreenBlockFeatureStorage* pRefFeatureStorage,
void SetFeatureSearchIn (SWelsFuncPtrList* pFunc, const SWelsME& sMe,
const SSlice* pSlice, SScreenBlockFeatureStorage* pRefFeatureStorage,
const int32_t kiEncStride, const int32_t kiRefStride,
SFeatureSearchIn* pFeatureSearchIn ) {
SFeatureSearchIn* pFeatureSearchIn) {
pFeatureSearchIn->pSad = pFunc->sSampleDealingFuncs.pfSampleSad[sMe.uiBlockSize];
pFeatureSearchIn->iFeatureOfCurrent=pFunc->pfCalculateSingleBlockFeature[BLOCK_16x16==sMe.uiBlockSize](sMe.pEncMb, kiEncStride);
pFeatureSearchIn->iFeatureOfCurrent = pFunc->pfCalculateSingleBlockFeature[BLOCK_16x16 == sMe.uiBlockSize] (sMe.pEncMb,
kiEncStride);
pFeatureSearchIn->pEnc = sMe.pEncMb;
pFeatureSearchIn->pColoRef = sMe.pColoRefMb;
@ -759,36 +769,38 @@ void SetFeatureSearchIn( SWelsFuncPtrList *pFunc, const SWelsME& sMe,
pFeatureSearchIn->uiSadCostThresh = sMe.uiSadCostThreshold;
pFeatureSearchIn->iCurPixX = sMe.iCurMeBlockPixX;
pFeatureSearchIn->iCurPixXQpel = (pFeatureSearchIn->iCurPixX<<2);
pFeatureSearchIn->iCurPixXQpel = (pFeatureSearchIn->iCurPixX << 2);
pFeatureSearchIn->iCurPixY = sMe.iCurMeBlockPixY;
pFeatureSearchIn->iCurPixYQpel = (pFeatureSearchIn->iCurPixY<<2);
pFeatureSearchIn->iCurPixYQpel = (pFeatureSearchIn->iCurPixY << 2);
pFeatureSearchIn->pTimesOfFeature = pRefFeatureStorage->pTimesOfFeatureValue;
pFeatureSearchIn->pQpelLocationOfFeature = pRefFeatureStorage->pLocationOfFeature;
pFeatureSearchIn->pMvdCostX = sMe.pMvdCost - pFeatureSearchIn->iCurPixXQpel - sMe.sMvp.iMvX;
pFeatureSearchIn->pMvdCostY = sMe.pMvdCost - pFeatureSearchIn->iCurPixYQpel - sMe.sMvp.iMvY;
pFeatureSearchIn->iMinQpelX = pFeatureSearchIn->iCurPixXQpel+((pSlice->sMvStartMin.iMvX)<<2);
pFeatureSearchIn->iMinQpelY = pFeatureSearchIn->iCurPixYQpel+((pSlice->sMvStartMin.iMvY)<<2);
pFeatureSearchIn->iMaxQpelX = pFeatureSearchIn->iCurPixXQpel+((pSlice->sMvStartMax.iMvX)<<2);
pFeatureSearchIn->iMaxQpelY = pFeatureSearchIn->iCurPixYQpel+((pSlice->sMvStartMax.iMvY)<<2);
pFeatureSearchIn->iMinQpelX = pFeatureSearchIn->iCurPixXQpel + ((pSlice->sMvStartMin.iMvX) << 2);
pFeatureSearchIn->iMinQpelY = pFeatureSearchIn->iCurPixYQpel + ((pSlice->sMvStartMin.iMvY) << 2);
pFeatureSearchIn->iMaxQpelX = pFeatureSearchIn->iCurPixXQpel + ((pSlice->sMvStartMax.iMvX) << 2);
pFeatureSearchIn->iMaxQpelY = pFeatureSearchIn->iCurPixYQpel + ((pSlice->sMvStartMax.iMvY) << 2);
}
void SaveFeatureSearchOut( const SMVUnitXY sBestMv, const uint32_t uiBestSadCost, uint8_t* pRef, SFeatureSearchOut* pFeatureSearchOut) {
void SaveFeatureSearchOut (const SMVUnitXY sBestMv, const uint32_t uiBestSadCost, uint8_t* pRef,
SFeatureSearchOut* pFeatureSearchOut) {
pFeatureSearchOut->sBestMv = sBestMv;
pFeatureSearchOut->uiBestSadCost = uiBestSadCost;
pFeatureSearchOut->pBestRef = pRef;
}
bool FeatureSearchOne( SFeatureSearchIn &sFeatureSearchIn, const int32_t iFeatureDifference, const uint32_t kuiExpectedSearchTimes,
bool FeatureSearchOne (SFeatureSearchIn& sFeatureSearchIn, const int32_t iFeatureDifference,
const uint32_t kuiExpectedSearchTimes,
SFeatureSearchOut* pFeatureSearchOut) {
const int32_t iFeatureOfRef = (sFeatureSearchIn.iFeatureOfCurrent + iFeatureDifference);
if(iFeatureOfRef < 0 || iFeatureOfRef >= LIST_SIZE)
if (iFeatureOfRef < 0 || iFeatureOfRef >= LIST_SIZE)
return true;
PSampleSadSatdCostFunc pSad = sFeatureSearchIn.pSad;
uint8_t* pEnc = sFeatureSearchIn.pEnc;
uint8_t* pColoRef = sFeatureSearchIn.pColoRef;
const int32_t iEncStride= sFeatureSearchIn.iEncStride;
const int32_t iEncStride = sFeatureSearchIn.iEncStride;
const int32_t iRefStride = sFeatureSearchIn.iRefStride;
const uint16_t uiSadCostThresh = sFeatureSearchIn.uiSadCostThresh;
@ -802,13 +814,13 @@ bool FeatureSearchOne( SFeatureSearchIn &sFeatureSearchIn, const int32_t iFeatur
const int32_t iMaxQpelX = sFeatureSearchIn.iMaxQpelX;
const int32_t iMaxQpelY = sFeatureSearchIn.iMaxQpelY;
const int32_t iSearchTimes = WELS_MIN(sFeatureSearchIn.pTimesOfFeature[iFeatureOfRef], kuiExpectedSearchTimes);
const int32_t iSearchTimesx2 = (iSearchTimes<<1);
const int32_t iSearchTimes = WELS_MIN (sFeatureSearchIn.pTimesOfFeature[iFeatureOfRef], kuiExpectedSearchTimes);
const int32_t iSearchTimesx2 = (iSearchTimes << 1);
const uint16_t* pQpelPosition = sFeatureSearchIn.pQpelLocationOfFeature[iFeatureOfRef];
SMVUnitXY sBestMv;
uint32_t uiBestCost, uiTmpCost;
uint8_t *pBestRef, *pCurRef;
uint8_t* pBestRef, *pCurRef;
int32_t iQpelX, iQpelY;
int32_t iIntepelX, iIntepelY;
int32_t i;
@ -818,39 +830,39 @@ bool FeatureSearchOne( SFeatureSearchIn &sFeatureSearchIn, const int32_t iFeatur
uiBestCost = pFeatureSearchOut->uiBestSadCost;
pBestRef = pFeatureSearchOut->pBestRef;
for( i = 0; i < iSearchTimesx2; i+=2) {
for (i = 0; i < iSearchTimesx2; i += 2) {
iQpelX = pQpelPosition[i];
iQpelY = pQpelPosition[i+1];
iQpelY = pQpelPosition[i + 1];
if((iQpelX > iMaxQpelX) || (iQpelX < iMinQpelX)
if ((iQpelX > iMaxQpelX) || (iQpelX < iMinQpelX)
|| (iQpelY > iMaxQpelY) || (iQpelY < iMinQpelY)
|| (iQpelX == iCurPixXQpel) || (iQpelY == iCurPixYQpel) )
|| (iQpelX == iCurPixXQpel) || (iQpelY == iCurPixYQpel))
continue;
uiTmpCost = sFeatureSearchIn.pMvdCostX[ iQpelX ] + sFeatureSearchIn.pMvdCostY[ iQpelY ];
if(uiTmpCost + iFeatureDifference >= uiBestCost)
if (uiTmpCost + iFeatureDifference >= uiBestCost)
continue;
iIntepelX = (iQpelX>>2) - iCurPixX;
iIntepelY = (iQpelY>>2) - iCurPixY;
iIntepelX = (iQpelX >> 2) - iCurPixX;
iIntepelY = (iQpelY >> 2) - iCurPixY;
pCurRef = &pColoRef[iIntepelX + iIntepelY * iRefStride];
uiTmpCost += pSad( pEnc, iEncStride, pCurRef, iRefStride );
if( uiTmpCost < uiBestCost ) {
uiTmpCost += pSad (pEnc, iEncStride, pCurRef, iRefStride);
if (uiTmpCost < uiBestCost) {
sBestMv.iMvX = iIntepelX;
sBestMv.iMvY = iIntepelY;
uiBestCost = uiTmpCost;
pBestRef = pCurRef;
if(uiBestCost < uiSadCostThresh)
if (uiBestCost < uiSadCostThresh)
break;
}
}
SaveFeatureSearchOut(sBestMv, uiBestCost, pBestRef, pFeatureSearchOut);
SaveFeatureSearchOut (sBestMv, uiBestCost, pBestRef, pFeatureSearchOut);
return (i < iSearchTimesx2);
}
void MotionEstimateFeatureFullSearch( SFeatureSearchIn &sFeatureSearchIn,
void MotionEstimateFeatureFullSearch (SFeatureSearchIn& sFeatureSearchIn,
const uint32_t kuiMaxSearchPoint,
SWelsME* pMe) {
SFeatureSearchOut sFeatureSearchOut = { { 0 } };//TODO: this can be refactored and removed
@ -859,22 +871,22 @@ void MotionEstimateFeatureFullSearch( SFeatureSearchIn &sFeatureSearchIn,
sFeatureSearchOut.pBestRef = pMe->pRefMb;
int32_t iFeatureDifference = 0;//TODO: change it according to computational-complexity setting when needed
FeatureSearchOne( sFeatureSearchIn, iFeatureDifference, kuiMaxSearchPoint, &sFeatureSearchOut );
if ( sFeatureSearchOut.uiBestSadCost < pMe->uiSadCost ) {//TODO: this may be refactored and removed
UpdateMeResults(sFeatureSearchOut.sBestMv,
FeatureSearchOne (sFeatureSearchIn, iFeatureDifference, kuiMaxSearchPoint, &sFeatureSearchOut);
if (sFeatureSearchOut.uiBestSadCost < pMe->uiSadCost) { //TODO: this may be refactored and removed
UpdateMeResults (sFeatureSearchOut.sBestMv,
sFeatureSearchOut.uiBestSadCost, sFeatureSearchOut.pBestRef,
pMe);
}
}
//switch related
static uint32_t CountFMECostDown( const SDqLayer* pCurLayer ) {
static uint32_t CountFMECostDown (const SDqLayer* pCurLayer) {
uint32_t uiCostDownSum = 0;
const int32_t kiSliceCount = GetCurrentSliceNum( pCurLayer->pSliceEncCtx );
if ( kiSliceCount >= 1 ) {
const int32_t kiSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx);
if (kiSliceCount >= 1) {
int32_t iSliceIndex = 0;
SSlice *pSlice = &pCurLayer->sLayerInfo.pSliceInLayer[iSliceIndex];
while( iSliceIndex < kiSliceCount ) {
SSlice* pSlice = &pCurLayer->sLayerInfo.pSliceInLayer[iSliceIndex];
while (iSliceIndex < kiSliceCount) {
uiCostDownSum += pSlice->uiSliceFMECostDown;
++ pSlice;
++ iSliceIndex;
@ -884,47 +896,49 @@ static uint32_t CountFMECostDown( const SDqLayer* pCurLayer ) {
}
#define FMESWITCH_MBAVERCOSTSAVING_THRESHOLD (2) //empirically set.
#define FMESWITCH_GOODFRAMECOUNT_MAX (5) //empirically set.
static void UpdateFMEGoodFrameCount(const uint32_t iAvMBNormalizedRDcostDown, uint8_t& uiFMEGoodFrameCount) {
static void UpdateFMEGoodFrameCount (const uint32_t iAvMBNormalizedRDcostDown, uint8_t& uiFMEGoodFrameCount) {
//this strategy may be changed, here the number is derived from empirical-numbers
// uiFMEGoodFrameCount lies in [0,FMESWITCH_GOODFRAMECOUNT_MAX]
if ( iAvMBNormalizedRDcostDown > FMESWITCH_MBAVERCOSTSAVING_THRESHOLD ) {
if ( uiFMEGoodFrameCount < FMESWITCH_GOODFRAMECOUNT_MAX )
if (iAvMBNormalizedRDcostDown > FMESWITCH_MBAVERCOSTSAVING_THRESHOLD) {
if (uiFMEGoodFrameCount < FMESWITCH_GOODFRAMECOUNT_MAX)
++ uiFMEGoodFrameCount;
} else {
if ( uiFMEGoodFrameCount > 0 )
if (uiFMEGoodFrameCount > 0)
-- uiFMEGoodFrameCount;
}
}
void UpdateFMESwitch(SDqLayer* pCurLayer) {
const uint32_t iFMECost = CountFMECostDown( pCurLayer );
const uint32_t iAvMBNormalizedRDcostDown = iFMECost / (pCurLayer->iMbWidth*pCurLayer->iMbHeight);
UpdateFMEGoodFrameCount( iAvMBNormalizedRDcostDown, pCurLayer->pFeatureSearchPreparation->uiFMEGoodFrameCount );
void UpdateFMESwitch (SDqLayer* pCurLayer) {
const uint32_t iFMECost = CountFMECostDown (pCurLayer);
const uint32_t iAvMBNormalizedRDcostDown = iFMECost / (pCurLayer->iMbWidth * pCurLayer->iMbHeight);
UpdateFMEGoodFrameCount (iAvMBNormalizedRDcostDown, pCurLayer->pFeatureSearchPreparation->uiFMEGoodFrameCount);
}
void UpdateFMESwitchNull(SDqLayer* pCurLayer) {
void UpdateFMESwitchNull (SDqLayer* pCurLayer) {
}
/////////////////////////
// Search function options
/////////////////////////
void WelsDiamondCrossSearch(SWelsFuncPtrList *pFunc, void* vpMe, void* vpSlice, const int32_t kiEncStride, const int32_t kiRefStride) {
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
SSlice* pSlice = static_cast<SSlice *>(vpSlice);
void WelsDiamondCrossSearch (SWelsFuncPtrList* pFunc, void* vpMe, void* vpSlice, const int32_t kiEncStride,
const int32_t kiRefStride) {
SWelsME* pMe = static_cast<SWelsME*> (vpMe);
SSlice* pSlice = static_cast<SSlice*> (vpSlice);
// Step 1: diamond search
WelsDiamondSearch(pFunc, vpMe, vpSlice, kiEncStride, kiRefStride);
WelsDiamondSearch (pFunc, vpMe, vpSlice, kiEncStride, kiRefStride);
// Step 2: CROSS search
SScreenBlockFeatureStorage pRefBlockFeature; //TODO: use this structure from Ref
pMe->uiSadCostThreshold = pRefBlockFeature.uiSadCostThreshold[pMe->uiBlockSize];
if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
WelsMotionCrossSearch(pFunc, pMe, pSlice, kiEncStride, kiRefStride);
WelsMotionCrossSearch (pFunc, pMe, pSlice, kiEncStride, kiRefStride);
}
}
void WelsDiamondCrossFeatureSearch(SWelsFuncPtrList *pFunc, void* vpMe, void* vpSlice, const int32_t kiEncStride, const int32_t kiRefStride) {
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
SSlice* pSlice = static_cast<SSlice *>(vpSlice);
void WelsDiamondCrossFeatureSearch (SWelsFuncPtrList* pFunc, void* vpMe, void* vpSlice, const int32_t kiEncStride,
const int32_t kiRefStride) {
SWelsME* pMe = static_cast<SWelsME*> (vpMe);
SSlice* pSlice = static_cast<SSlice*> (vpSlice);
// Step 1: diamond search + cross
WelsDiamondCrossSearch(pFunc, pMe, pSlice, kiEncStride, kiRefStride);
WelsDiamondCrossSearch (pFunc, pMe, pSlice, kiEncStride, kiRefStride);
// Step 2: FeatureSearch
if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
@ -933,10 +947,10 @@ void WelsDiamondCrossFeatureSearch(SWelsFuncPtrList *pFunc, void* vpMe, void* vp
SScreenBlockFeatureStorage tmpScreenBlockFeatureStorage; //TODO: use this structure from Ref
uint32_t uiMaxSearchPoint = INT_MAX;//TODO: change it according to computational-complexity setting
SFeatureSearchIn sFeatureSearchIn = {0};
SetFeatureSearchIn(pFunc, *pMe, pSlice, &tmpScreenBlockFeatureStorage,
SetFeatureSearchIn (pFunc, *pMe, pSlice, &tmpScreenBlockFeatureStorage,
kiEncStride, kiRefStride,
&sFeatureSearchIn);
MotionEstimateFeatureFullSearch( sFeatureSearchIn, uiMaxSearchPoint, pMe);
MotionEstimateFeatureFullSearch (sFeatureSearchIn, uiMaxSearchPoint, pMe);
pSlice->uiSliceFMECostDown -= pMe->uiSadCost;
}

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;

View File

@ -1047,7 +1047,8 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
iVaaFrameSceneChangeIdc = SIMILAR_SCENE;
}
WelsLog(pCtx,WELS_LOG_INFO,"iVaaFrameSceneChangeIdc = %d,codingIdx = %d\n",iVaaFrameSceneChangeIdc,pCtx->iCodingIndex);
WelsLog (pCtx, WELS_LOG_INFO, "iVaaFrameSceneChangeIdc = %d,codingIdx = %d\n", iVaaFrameSceneChangeIdc,
pCtx->iCodingIndex);
SaveBestRefToVaa (sLtrSaved, & (pVaaExt->sVaaStrBestRefCandidate[0]));

View File

@ -133,7 +133,7 @@ void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char
void welsCodecTrace::SetTraceLevel (const int32_t iLevel) {
if (iLevel >= 0)
m_iTraceLevel = iLevel;
WelsStderrSetTraceLevel(iLevel);
WelsStderrSetTraceLevel (iLevel);
}

View File

@ -84,7 +84,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
#ifdef OUTPUT_BIT_STREAM
SWelsTime tTime;
WelsGetTimeOfDay(&tTime);
WelsGetTimeOfDay (&tTime);
iCurUsed = WelsSnprintf (strStreamFileName, iBufferLeft, "enc_bs_0x%p_", (void*)this);
iCurUsedSize = WelsSnprintf (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this);
@ -108,14 +108,14 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
if (iBufferLeft > 0) {
iCurUsed = WelsSnprintf (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264",
WelsGetMillisecond(&tTime));
WelsGetMillisecond (&tTime));
iBufferUsed += iCurUsed;
iBufferLeft -= iCurUsed;
}
if (iBufferLeftSize > 0) {
iCurUsedSize = WelsSnprintf (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len",
WelsGetMillisecond(&tTime));
WelsGetMillisecond (&tTime));
iBufferUsedSize += iCurUsedSize;
iBufferLeftSize -= iCurUsedSize;
}
@ -186,7 +186,7 @@ void CWelsH264SVCEncoder::InitEncoder (void) {
/* Interfaces override from ISVCEncoder */
int CWelsH264SVCEncoder::GetDefaultParams (SEncParamExt* argv) {
SWelsSvcCodingParam::FillDefault(*argv);
SWelsSvcCodingParam::FillDefault (*argv);
return cmResultSuccess;
}
@ -209,7 +209,7 @@ int CWelsH264SVCEncoder::Initialize (const SEncParamBase* argv) {
return cmInitParaError;
}
return InitializeInternal(&sConfig);
return InitializeInternal (&sConfig);
}
int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) {
@ -228,10 +228,10 @@ int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) {
return cmInitParaError;
}
return InitializeInternal(&sConfig);
return InitializeInternal (&sConfig);
}
int CWelsH264SVCEncoder::InitializeInternal(SWelsSvcCodingParam* pCfg) {
int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
if (NULL == pCfg) {
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p.\n",
pCfg);
@ -245,7 +245,7 @@ int CWelsH264SVCEncoder::InitializeInternal(SWelsSvcCodingParam* pCfg) {
}
#ifdef REC_FRAME_COUNT
SWelsSvcCodingParam &sEncodingParam = *pCfg;
SWelsSvcCodingParam& sEncodingParam = *pCfg;
WelsLog (m_pEncContext, WELS_LOG_INFO, "CWelsH264SVCEncoder::Initialize, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
m_uiCountFrameNum, m_iCspInternal);
WelsLog (m_pEncContext, WELS_LOG_INFO,
@ -346,14 +346,14 @@ int CWelsH264SVCEncoder::InitializeInternal(SWelsSvcCodingParam* pCfg) {
}
if (pCfg->iUsageType == SCREEN_CONTENT_REAL_TIME) {
if (pCfg->bEnableLongTermReference) {
pCfg->iLTRRefNum = WELS_CLIP3(pCfg->iLTRRefNum,1,LONG_TERM_REF_NUM_SCREEN);
pCfg->iNumRefFrame = WELS_MAX(1,WELS_LOG2 (pCfg->uiGopSize)) + pCfg->iLTRRefNum;
pCfg->iLTRRefNum = WELS_CLIP3 (pCfg->iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN);
pCfg->iNumRefFrame = WELS_MAX (1, WELS_LOG2 (pCfg->uiGopSize)) + pCfg->iLTRRefNum;
} else {
pCfg->iLTRRefNum = 0;
pCfg->iNumRefFrame = WELS_MAX(1, pCfg->uiGopSize>>1);
pCfg->iNumRefFrame = WELS_MAX (1, pCfg->uiGopSize >> 1);
}
} else {
pCfg->iLTRRefNum = pCfg->bEnableLongTermReference ? WELS_CLIP3(pCfg->iLTRRefNum,1,LONG_TERM_REF_NUM) : 0;
pCfg->iLTRRefNum = pCfg->bEnableLongTermReference ? WELS_CLIP3 (pCfg->iLTRRefNum, 1, LONG_TERM_REF_NUM) : 0;
pCfg->iNumRefFrame = ((pCfg->uiGopSize >> 1) > 1) ? ((pCfg->uiGopSize >> 1) + pCfg->iLTRRefNum) :
(MIN_REF_PIC_COUNT + pCfg->iLTRRefNum);
pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
@ -419,9 +419,9 @@ int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSIn
return cmInitParaError;
}
const int32_t kiEncoderReturn = EncodeFrameInternal(kpSrcPic, pBsInfo);
const int32_t kiEncoderReturn = EncodeFrameInternal (kpSrcPic, pBsInfo);
if(kiEncoderReturn != cmResultSuccess)
if (kiEncoderReturn != cmResultSuccess)
return kiEncoderReturn;
#ifdef REC_FRAME_COUNT
@ -437,14 +437,13 @@ int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSIn
}
int CWelsH264SVCEncoder::EncodeFrameInternal(const SSourcePicture* pSrcPic, SFrameBSInfo* pBsInfo) {
int CWelsH264SVCEncoder::EncodeFrameInternal (const SSourcePicture* pSrcPic, SFrameBSInfo* pBsInfo) {
const int32_t kiEncoderReturn = WelsEncoderEncodeExt (m_pEncContext, pBsInfo, pSrcPic);
if(kiEncoderReturn == ENC_RETURN_MEMALLOCERR) {
if (kiEncoderReturn == ENC_RETURN_MEMALLOCERR) {
WelsUninitEncoderExt (&m_pEncContext);
return cmMallocMemeError;
}
else if((kiEncoderReturn != ENC_RETURN_SUCCESS)&&(kiEncoderReturn == ENC_RETURN_CORRECTED)){
} else if ((kiEncoderReturn != ENC_RETURN_SUCCESS) && (kiEncoderReturn == ENC_RETURN_CORRECTED)) {
WelsLog (m_pEncContext, WELS_LOG_ERROR, "unexpected return(%d) from EncodeFrameInternal()!\n", kiEncoderReturn);
return cmUnkonwReason;
}
@ -692,7 +691,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_FRAME_RATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x, iValue= %f\n",
m_uiCountFrameNum, m_iCspInternal, iValue);
#endif//REC_FRAME_COUNT
if (iValue<=0) {
if (iValue <= 0) {
return cmInitParaError;
}
//adjust to valid range
@ -701,19 +700,20 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
}
break;
case ENCODER_OPTION_BITRATE: { // Target bit-rate
SBitrateInfo*pInfo = (static_cast<SBitrateInfo *>(pOption));
SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption));
int32_t iBitrate = pInfo->iBitrate;
#ifdef REC_FRAME_COUNT
WelsLog (m_pEncContext, WELS_LOG_INFO,
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x, iValue= %d\n",
m_uiCountFrameNum, m_iCspInternal, iValue);
#endif//REC_FRAME_COUNT
if (iBitrate<=0) {
WelsLog (m_pEncContext, WELS_LOG_ERROR,"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iBitrate = %d\n",iBitrate);
if (iBitrate <= 0) {
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iBitrate = %d\n",
iBitrate);
return cmInitParaError;
}
iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE);
switch(pInfo->iLayer){
switch (pInfo->iLayer) {
case SPATIAL_LAYER_ALL:
m_pEncContext->pSvcParam->iTargetBitrate = iBitrate;
break;
@ -730,16 +730,17 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
m_pEncContext->pSvcParam->sSpatialLayers[3].iSpatialBitrate = iBitrate;
break;
default:
WelsLog (m_pEncContext, WELS_LOG_ERROR,"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iLayer = %d\n",pInfo->iLayer);
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iLayer = %d\n",
pInfo->iLayer);
return cmInitParaError;
break;
}
//adjust to valid range
WelsEncoderApplyBitRate (m_pEncContext->pSvcParam,pInfo->iLayer);
WelsEncoderApplyBitRate (m_pEncContext->pSvcParam, pInfo->iLayer);
}
break;
case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate
SBitrateInfo*pInfo = (static_cast<SBitrateInfo *>(pOption));
SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption));
int32_t iBitrate = pInfo->iBitrate;
#ifdef REC_FRAME_COUNT
@ -747,12 +748,13 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x, iValue= %d\n",
m_uiCountFrameNum, m_iCspInternal, iValue);
#endif//REC_FRAME_COUNT
if (iBitrate<=0) {
WelsLog (m_pEncContext, WELS_LOG_ERROR,"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_MAX_BITRATE,iBitrate = %d\n",iBitrate);
if (iBitrate <= 0) {
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_MAX_BITRATE,iBitrate = %d\n",
iBitrate);
return cmInitParaError;
}
iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE);
switch(pInfo->iLayer){
switch (pInfo->iLayer) {
case SPATIAL_LAYER_ALL:
m_pEncContext->pSvcParam->iMaxBitrate = iBitrate;
break;
@ -769,12 +771,13 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
m_pEncContext->pSvcParam->sSpatialLayers[3].iMaxSpatialBitrate = iBitrate;
break;
default:
WelsLog (m_pEncContext, WELS_LOG_ERROR,"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_MAX_BITRATE,iLayer = %d\n",pInfo->iLayer);
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_MAX_BITRATE,iLayer = %d\n",
pInfo->iLayer);
return cmInitParaError;
break;
}
//adjust to valid range
WelsEncoderApplyBitRate (m_pEncContext->pSvcParam,pInfo->iLayer);
WelsEncoderApplyBitRate (m_pEncContext->pSvcParam, pInfo->iLayer);
}
break;
case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode
@ -838,19 +841,20 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
}
}
break;
case ENCODER_OPTION_DUMP_FILE:{
case ENCODER_OPTION_DUMP_FILE: {
#ifdef ENABLE_FRAME_DUMP
if(m_pEncContext->pSvcParam!=NULL){
SDumpLayer*pDump = (static_cast<SDumpLayer *>(pOption));
WelsStrncpy(m_pEncContext->pSvcParam->sDependencyLayers[pDump->iLayer].sRecFileName, sizeof(m_pEncContext->pSvcParam->sDependencyLayers[pDump->iLayer].sRecFileName),pDump->pFileName);
if (m_pEncContext->pSvcParam != NULL) {
SDumpLayer* pDump = (static_cast<SDumpLayer*> (pOption));
WelsStrncpy (m_pEncContext->pSvcParam->sDependencyLayers[pDump->iLayer].sRecFileName,
sizeof (m_pEncContext->pSvcParam->sDependencyLayers[pDump->iLayer].sRecFileName), pDump->pFileName);
}
#endif
}
break;
case ENCODER_OPTION_TRACE_LEVEL:{
if(m_pWelsTrace){
uint32_t level = *((uint32_t*)pOption);
m_pWelsTrace->SetTraceLevel(level);
case ENCODER_OPTION_TRACE_LEVEL: {
if (m_pWelsTrace) {
uint32_t level = * ((uint32_t*)pOption);
m_pWelsTrace->SetTraceLevel (level);
}
}
break;
@ -908,7 +912,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
m_uiCountFrameNum, m_iCspInternal);
#endif//REC_FRAME_COUNT
m_pEncContext->pSvcParam->GetBaseParams((SEncParamBase*) pOption);
m_pEncContext->pSvcParam->GetBaseParams ((SEncParamBase*) pOption);
}
break;
@ -927,27 +931,30 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
m_uiCountFrameNum, m_iCspInternal);
#endif//REC_FRAME_COUNT
SBitrateInfo*pInfo = (static_cast<SBitrateInfo *>(pOption));
if((pInfo->iLayer!=SPATIAL_LAYER_ALL)&&(pInfo->iLayer!=SPATIAL_LAYER_0)&&(pInfo->iLayer!=SPATIAL_LAYER_1)&&(pInfo->iLayer!=SPATIAL_LAYER_2)&&(pInfo->iLayer!=SPATIAL_LAYER_3))
SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption));
if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1)
&& (pInfo->iLayer != SPATIAL_LAYER_2) && (pInfo->iLayer != SPATIAL_LAYER_3))
return cmInitParaError;
if(pInfo->iLayer == SPATIAL_LAYER_ALL){
if (pInfo->iLayer == SPATIAL_LAYER_ALL) {
pInfo->iBitrate = m_pEncContext->pSvcParam->iTargetBitrate;
}else{
} else {
pInfo->iBitrate = m_pEncContext->pSvcParam->sSpatialLayers[pInfo->iLayer].iSpatialBitrate;
}
}
break;
case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate
#ifdef REC_FRAME_COUNT
WelsLog (m_pEncContext, WELS_LOG_INFO,"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_MAX_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
WelsLog (m_pEncContext, WELS_LOG_INFO,
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_MAX_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
m_uiCountFrameNum, m_iCspInternal);
#endif//REC_FRAME_COUNT
SBitrateInfo*pInfo = (static_cast<SBitrateInfo *>(pOption));
if((pInfo->iLayer!=SPATIAL_LAYER_ALL)&&(pInfo->iLayer!=SPATIAL_LAYER_0)&&(pInfo->iLayer!=SPATIAL_LAYER_1)&&(pInfo->iLayer!=SPATIAL_LAYER_2)&&(pInfo->iLayer!=SPATIAL_LAYER_3))
SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption));
if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1)
&& (pInfo->iLayer != SPATIAL_LAYER_2) && (pInfo->iLayer != SPATIAL_LAYER_3))
return cmInitParaError;
if(pInfo->iLayer == SPATIAL_LAYER_ALL){
if (pInfo->iLayer == SPATIAL_LAYER_ALL) {
pInfo->iBitrate = m_pEncContext->pSvcParam->iMaxBitrate;
}else{
} else {
pInfo->iBitrate = m_pEncContext->pSvcParam->sSpatialLayers[pInfo->iLayer].iMaxSpatialBitrate;
}
}

View File

@ -138,7 +138,7 @@ typedef enum {
//-----------------------------------------------------------------//
// Algorithm parameters define
//-----------------------------------------------------------------//
typedef struct{
typedef struct {
SRect sMaskRect;
bool bMaskInfoAvailable;
int iScrollMvX;
@ -163,7 +163,7 @@ typedef struct {
ESceneChangeIdc eSceneChangeIdc; // SIMILAR_SCENE, MEDIUM_CHANGED_SCENE, LARGE_CHANGED_SCENE
int iMotionBlockNum; // Number of motion blocks
int iFrameComplexity; // frame complexity
unsigned char * pStaticBlockIdc; // static block idc
unsigned char* pStaticBlockIdc; // static block idc
} SSceneChangeResult;
typedef struct {
@ -216,8 +216,7 @@ typedef enum {
GOM_VAR = -2
} EComplexityAnalysisMode;
typedef struct
{
typedef struct {
int iScrollMvX;
int iScrollMvY;
bool bScrollDetectFlag; // 0:false ; 1:ltr; 2: scene change
@ -235,10 +234,9 @@ typedef struct {
SVAACalcResult* pCalcResult;
} SComplexityAnalysisParam;
typedef struct
{
typedef struct {
int iMbRowInGom;
int *pGomComplexity;
int* pGomComplexity;
int iGomNumInFrame;
int iFrameComplexity;
int iIdrFlag;

View File

@ -267,11 +267,11 @@ IStrategy* CVpFrameWork::CreateStrategy (EMethods m_eMethod, int32_t iCpuFlag) {
pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag));
break;
case METHOD_SCROLL_DETECTION:
pStrategy = WelsDynamicCast (IStrategy*, new CScrollDetection(iCpuFlag));
pStrategy = WelsDynamicCast (IStrategy*, new CScrollDetection (iCpuFlag));
break;
case METHOD_SCENE_CHANGE_DETECTION_VIDEO:
case METHOD_SCENE_CHANGE_DETECTION_SCREEN:
pStrategy = BuildSceneChangeDetection(m_eMethod, iCpuFlag);
pStrategy = BuildSceneChangeDetection (m_eMethod, iCpuFlag);
break;
case METHOD_DOWNSAMPLE:
pStrategy = WelsDynamicCast (IStrategy*, new CDownsampling (iCpuFlag));

View File

@ -53,12 +53,12 @@ typedef int32_t (SadFunc) (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY,
typedef SadFunc* SadFuncPtr;
typedef int32_t (Sad16x16Func) ( uint8_t * pSrcY, int32_t iSrcStrideY, uint8_t *pRefY, int32_t iRefStrideY );
typedef Sad16x16Func *PSad16x16Func;
typedef int32_t (Sad16x16Func) (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY);
typedef Sad16x16Func* PSad16x16Func;
typedef void (GetIntraPred)(uint8_t *pPred, uint8_t *pRef, const int32_t kiStride);
typedef void (GetIntraPred) (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
typedef GetIntraPred *GetIntraPredPtr;
typedef GetIntraPred* GetIntraPredPtr;
GetIntraPred WelsI16x16LumaPredV_c;
GetIntraPred WelsI16x16LumaPredH_c;

View File

@ -82,21 +82,20 @@ class CComplexityAnalysis : public IStrategy {
//for screen content
class CComplexityAnalysisScreen : public IStrategy
{
public:
CComplexityAnalysisScreen(int32_t cpu_flag);
class CComplexityAnalysisScreen : public IStrategy {
public:
CComplexityAnalysisScreen (int32_t cpu_flag);
~CComplexityAnalysisScreen();
EResult Process(int32_t nType, SPixMap *src, SPixMap *ref);
EResult Set(int32_t nType, void *pParam);
EResult Get(int32_t nType, void *pParam);
EResult Process (int32_t nType, SPixMap* src, SPixMap* ref);
EResult Set (int32_t nType, void* pParam);
EResult Get (int32_t nType, void* pParam);
private:
void GomComplexityAnalysisIntra( SPixMap *pSrc );
void GomComplexityAnalysisInter( SPixMap *pSrc, SPixMap *pRef,bool bScrollFlag);
private:
void GomComplexityAnalysisIntra (SPixMap* pSrc);
void GomComplexityAnalysisInter (SPixMap* pSrc, SPixMap* pRef, bool bScrollFlag);
private:
private:
PSad16x16Func m_pSadFunc;
GetIntraPredPtr m_pIntraFunc[2];
SComplexityAnalysisScreenParam m_ComplexityAnalysisParam;

View File

@ -112,7 +112,8 @@ HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_neon;
GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_neon;
void GeneralBilinearAccurateDownsampler_neon( uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, const int32_t kiDstHeight,
void GeneralBilinearAccurateDownsampler_neon (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
const int32_t kiDstHeight,
uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY);
WELSVP_EXTERN_C_END

View File

@ -230,13 +230,15 @@ void GeneralBilinearAccurateDownsampler_c (uint8_t* pDst, const int32_t kiDstStr
#endif //X86_ASM
#ifdef HAVE_NEON
void GeneralBilinearAccurateDownsamplerWrap_neon(uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, const int32_t kiDstHeight,
void GeneralBilinearAccurateDownsamplerWrap_neon (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
const int32_t kiDstHeight,
uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
const int32_t kiScaleBit = 15;
const uint32_t kuiScale = (1 << kiScaleBit);
uint32_t uiScalex = (uint32_t)((float)kiSrcWidth / (float)kiDstWidth * kuiScale);
uint32_t uiScaley = (uint32_t)((float)kiSrcHeight / (float)kiDstHeight * kuiScale);
GeneralBilinearAccurateDownsampler_neon(pDst, kiDstStride, kiDstWidth, kiDstHeight, pSrc, kiSrcStride, uiScalex, uiScaley);
uint32_t uiScalex = (uint32_t) ((float)kiSrcWidth / (float)kiDstWidth * kuiScale);
uint32_t uiScaley = (uint32_t) ((float)kiSrcHeight / (float)kiDstHeight * kuiScale);
GeneralBilinearAccurateDownsampler_neon (pDst, kiDstStride, kiDstWidth, kiDstHeight, pSrc, kiSrcStride, uiScalex,
uiScaley);
}
#endif
WELSVP_NAMESPACE_END

View File

@ -35,13 +35,13 @@
WELSVP_NAMESPACE_BEGIN
IStrategy * BuildSceneChangeDetection(EMethods eMethod, int32_t iCpuFlag){
switch(eMethod){
IStrategy* BuildSceneChangeDetection (EMethods eMethod, int32_t iCpuFlag) {
switch (eMethod) {
case METHOD_SCENE_CHANGE_DETECTION_VIDEO:
return new CSceneChangeDetection<CSceneChangeDetectorVideo>(eMethod, iCpuFlag);
return new CSceneChangeDetection<CSceneChangeDetectorVideo> (eMethod, iCpuFlag);
break;
case METHOD_SCENE_CHANGE_DETECTION_SCREEN:
return new CSceneChangeDetection<CSceneChangeDetectorScreen>(eMethod, iCpuFlag);
return new CSceneChangeDetection<CSceneChangeDetectorScreen> (eMethod, iCpuFlag);
break;
default:
// not support yet

View File

@ -56,40 +56,41 @@
WELSVP_NAMESPACE_BEGIN
class CSceneChangeDetectorVideo {
public:
CSceneChangeDetectorVideo(SSceneChangeResult & sParam, int32_t iCpuFlag) : m_sParam(sParam) {
public:
CSceneChangeDetectorVideo (SSceneChangeResult& sParam, int32_t iCpuFlag) : m_sParam (sParam) {
m_pfSad = WelsSampleSad8x8_c;
#ifdef X86_ASM
if (iCpuFlag & WELS_CPU_SSE2){
if (iCpuFlag & WELS_CPU_SSE2) {
m_pfSad = WelsSampleSad8x8_sse21;
}
#endif
#ifdef HAVE_NEON
if (iCpuFlag & WELS_CPU_NEON){
if (iCpuFlag & WELS_CPU_NEON) {
m_pfSad = WelsProcessingSampleSad8x8_neon;
}
#endif
}
virtual ~CSceneChangeDetectorVideo() {
}
void operator () (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t *& pStaticBlockIdc) {
int32_t iSad = m_pfSad(pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t*& pStaticBlockIdc) {
int32_t iSad = m_pfSad (pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
}
protected:
protected:
SadFuncPtr m_pfSad;
SSceneChangeResult &m_sParam;
SSceneChangeResult& m_sParam;
};
class CSceneChangeDetectorScreen : public CSceneChangeDetectorVideo{
public:
CSceneChangeDetectorScreen(SSceneChangeResult & sParam, int32_t iCpuFlag) : CSceneChangeDetectorVideo(sParam, iCpuFlag) {
class CSceneChangeDetectorScreen : public CSceneChangeDetectorVideo {
public:
CSceneChangeDetectorScreen (SSceneChangeResult& sParam, int32_t iCpuFlag) : CSceneChangeDetectorVideo (sParam,
iCpuFlag) {
}
virtual ~CSceneChangeDetectorScreen() {
}
void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t *& pStaticBlockIdc) {
int32_t iSad = m_pfSad(pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
if( iSad == 0 ){
void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t*& pStaticBlockIdc) {
int32_t iSad = m_pfSad (pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
if (iSad == 0) {
*pStaticBlockIdc ++ = COLLOCATED_STATIC;
} else {
m_sParam.iFrameComplexity += iSad;
@ -102,28 +103,30 @@ public:
template<typename T>
class CSceneChangeDetection : public IStrategy {
public:
CSceneChangeDetection (EMethods eMethod, int32_t iCpuFlag): m_cDetector(m_sSceneChangeParam, iCpuFlag) {
CSceneChangeDetection (EMethods eMethod, int32_t iCpuFlag): m_cDetector (m_sSceneChangeParam, iCpuFlag) {
m_eMethod = eMethod;
WelsMemset (&m_sSceneChangeParam, 0, sizeof (m_sSceneChangeParam));
}
~CSceneChangeDetection(){
~CSceneChangeDetection() {
}
EResult Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
EResult Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
EResult eReturn = RET_INVALIDPARAM;
int32_t iWidth = pSrcPixMap->sRect.iRectWidth;
int32_t iHeight = pSrcPixMap->sRect.iRectHeight;
int32_t iBlock8x8Width = iWidth >> 3;
int32_t iBlock8x8Height = iHeight >> 3;
int32_t iBlock8x8Num = iBlock8x8Width * iBlock8x8Height;
int32_t iSceneChangeThresholdLarge = WelsStaticCast (int32_t, SCENE_CHANGE_MOTION_RATIO_LARGE * iBlock8x8Num + 0.5f + PESN);
int32_t iSceneChangeThresholdMedium = WelsStaticCast(int32_t, SCENE_CHANGE_MOTION_RATIO_MEDIUM * iBlock8x8Num + 0.5f + PESN);
int32_t iSceneChangeThresholdLarge = WelsStaticCast (int32_t,
SCENE_CHANGE_MOTION_RATIO_LARGE * iBlock8x8Num + 0.5f + PESN);
int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t,
SCENE_CHANGE_MOTION_RATIO_MEDIUM * iBlock8x8Num + 0.5f + PESN);
uint8_t* pRefY = NULL, *pCurY = NULL;
int32_t iRefStride = 0, iCurStride = 0;
int32_t iRefRowStride = 0, iCurRowStride = 0;
uint8_t* pRefTmp = NULL, *pCurTmp = NULL;
uint8_t * pStaticBlockIdc = m_sSceneChangeParam.pStaticBlockIdc;
uint8_t* pStaticBlockIdc = m_sSceneChangeParam.pStaticBlockIdc;
pRefY = (uint8_t*)pRefPixMap->pPixel[0];
pCurY = (uint8_t*)pSrcPixMap->pPixel[0];
@ -143,7 +146,7 @@ class CSceneChangeDetection : public IStrategy {
pCurTmp = pCurY;
for (int32_t i = 0; i < iBlock8x8Width; i++) {
m_cDetector(pRefTmp, iRefStride, pCurTmp, iCurStride, pStaticBlockIdc);
m_cDetector (pRefTmp, iRefStride, pCurTmp, iCurStride, pStaticBlockIdc);
pRefTmp += 8;
pCurTmp += 8;
}
@ -154,7 +157,7 @@ class CSceneChangeDetection : public IStrategy {
if (m_sSceneChangeParam.iMotionBlockNum >= iSceneChangeThresholdLarge) {
m_sSceneChangeParam.eSceneChangeIdc = LARGE_CHANGED_SCENE;
} else if( m_sSceneChangeParam.iMotionBlockNum >= iSceneChangeThresholdMedium ){
} else if (m_sSceneChangeParam.iMotionBlockNum >= iSceneChangeThresholdMedium) {
m_sSceneChangeParam.eSceneChangeIdc = MEDIUM_CHANGED_SCENE;
}
@ -171,11 +174,11 @@ class CSceneChangeDetection : public IStrategy {
return RET_SUCCESS;
}
EResult Set(int32_t iType, void * pParam) {
if( pParam == NULL ){
EResult Set (int32_t iType, void* pParam) {
if (pParam == NULL) {
return RET_INVALIDPARAM;
}
m_sSceneChangeParam = *(SSceneChangeResult*)pParam;
m_sSceneChangeParam = * (SSceneChangeResult*)pParam;
return RET_SUCCESS;
}
private:
@ -183,7 +186,7 @@ class CSceneChangeDetection : public IStrategy {
T m_cDetector;
};
IStrategy * BuildSceneChangeDetection(EMethods eMethod, int32_t iCpuFlag);
IStrategy* BuildSceneChangeDetection (EMethods eMethod, int32_t iCpuFlag);
WELSVP_NAMESPACE_END

View File

@ -37,37 +37,38 @@
WELSVP_NAMESPACE_BEGIN
EResult CScrollDetection::Process(int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
EResult CScrollDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
if (pRefPixMap->pPixel[0] == NULL || pSrcPixMap->pPixel[0] == NULL ||
pRefPixMap->sRect.iRectWidth != pSrcPixMap->sRect.iRectWidth || pRefPixMap->sRect.iRectHeight != pSrcPixMap->sRect.iRectHeight){
pRefPixMap->sRect.iRectWidth != pSrcPixMap->sRect.iRectWidth
|| pRefPixMap->sRect.iRectHeight != pSrcPixMap->sRect.iRectHeight) {
return RET_INVALIDPARAM;
}
if (!m_sScrollDetectionParam.bMaskInfoAvailable)
ScrollDetectionWithoutMask(pSrcPixMap, pRefPixMap);
ScrollDetectionWithoutMask (pSrcPixMap, pRefPixMap);
else
ScrollDetectionWithMask(pSrcPixMap, pRefPixMap);
ScrollDetectionWithMask (pSrcPixMap, pRefPixMap);
return RET_SUCCESS;
}
EResult CScrollDetection::Set(int32_t iType, void *pParam){
if( pParam == NULL ){
EResult CScrollDetection::Set (int32_t iType, void* pParam) {
if (pParam == NULL) {
return RET_INVALIDPARAM;
}
m_sScrollDetectionParam = *((SScrollDetectionParam*)pParam);
m_sScrollDetectionParam = * ((SScrollDetectionParam*)pParam);
return RET_SUCCESS;
}
EResult CScrollDetection::Get(int32_t iType, void *pParam){
if( pParam == NULL ){
EResult CScrollDetection::Get (int32_t iType, void* pParam) {
if (pParam == NULL) {
return RET_INVALIDPARAM;
}
*((SScrollDetectionParam*)pParam) = m_sScrollDetectionParam;
* ((SScrollDetectionParam*)pParam) = m_sScrollDetectionParam;
return RET_SUCCESS;
}
void CScrollDetection::ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
void CScrollDetection::ScrollDetectionWithMask (SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
int32_t iStartX, iStartY, iWidth, iHeight;
iStartX = m_sScrollDetectionParam.sMaskRect.iRectLeft;
@ -76,39 +77,39 @@ void CScrollDetection::ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRe
iHeight = m_sScrollDetectionParam.sMaskRect.iRectHeight;
iWidth /= 2;
iStartX += iWidth/2;
iStartX += iWidth / 2;
m_sScrollDetectionParam.iScrollMvX = 0;
m_sScrollDetectionParam.iScrollMvY = 0;
m_sScrollDetectionParam.bScrollDetectFlag = false;
if(iStartX >= 0 && iWidth > MINIMUM_DETECT_WIDTH && iHeight > 2 * CHECK_OFFSET){
ScrollDetectionCore(pSrcPixMap, pRefPixMap,iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
if (iStartX >= 0 && iWidth > MINIMUM_DETECT_WIDTH && iHeight > 2 * CHECK_OFFSET) {
ScrollDetectionCore (pSrcPixMap, pRefPixMap, iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
}
}
void CScrollDetection::ScrollDetectionWithoutMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
void CScrollDetection::ScrollDetectionWithoutMask (SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
int32_t iStartX, iStartY, iWidth, iHeight;
const int32_t kiPicBorderWidth= pSrcPixMap->sRect.iRectHeight>>4;
const int32_t kiRegionWidth = (int) (pSrcPixMap->sRect.iRectWidth-(kiPicBorderWidth<<1))/3;
const int32_t kiRegionHeight = (pSrcPixMap->sRect.iRectHeight*7)>>3;
const int32_t kiHieghtStride = (int) pSrcPixMap->sRect.iRectHeight*5/24;
const int32_t kiPicBorderWidth = pSrcPixMap->sRect.iRectHeight >> 4;
const int32_t kiRegionWidth = (int) (pSrcPixMap->sRect.iRectWidth - (kiPicBorderWidth << 1)) / 3;
const int32_t kiRegionHeight = (pSrcPixMap->sRect.iRectHeight * 7) >> 3;
const int32_t kiHieghtStride = (int) pSrcPixMap->sRect.iRectHeight * 5 / 24;
for (int32_t i=0; i< REGION_NUMBER;i++){
iStartX = kiPicBorderWidth+(i%3)*kiRegionWidth;
iStartY = -pSrcPixMap->sRect.iRectHeight*7/48+ (int)(i/3)*(kiHieghtStride);
for (int32_t i = 0; i < REGION_NUMBER; i++) {
iStartX = kiPicBorderWidth + (i % 3) * kiRegionWidth;
iStartY = -pSrcPixMap->sRect.iRectHeight * 7 / 48 + (int) (i / 3) * (kiHieghtStride);
iWidth = kiRegionWidth;
iHeight = kiRegionHeight;
iWidth /= 2;
iStartX += iWidth/2;
iStartX += iWidth / 2;
m_sScrollDetectionParam.iScrollMvX = 0;
m_sScrollDetectionParam.iScrollMvY = 0;
m_sScrollDetectionParam.bScrollDetectFlag = false;
ScrollDetectionCore(pSrcPixMap, pRefPixMap, iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
ScrollDetectionCore (pSrcPixMap, pRefPixMap, iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
if (m_sScrollDetectionParam.bScrollDetectFlag && m_sScrollDetectionParam.iScrollMvY)
break;

View File

@ -51,22 +51,22 @@ WELSVP_EXTERN_C_BEGIN
WELSVP_EXTERN_C_END
#endif
class CScrollDetection : public IStrategy{
public:
CScrollDetection(int32_t iCpuFlag){
class CScrollDetection : public IStrategy {
public:
CScrollDetection (int32_t iCpuFlag) {
m_eMethod = METHOD_SCROLL_DETECTION;
WelsMemset (&m_sScrollDetectionParam, 0, sizeof (m_sScrollDetectionParam));
};
~CScrollDetection(){
~CScrollDetection() {
}
EResult Process(int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
EResult Set(int32_t iType, void *pParam);
EResult Get(int32_t iType, void *pParam);
EResult Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
EResult Set (int32_t iType, void* pParam);
EResult Get (int32_t iType, void* pParam);
private:
void ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
void ScrollDetectionWithoutMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
private:
private:
void ScrollDetectionWithMask (SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
void ScrollDetectionWithoutMask (SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
private:
SScrollDetectionParam m_sScrollDetectionParam;
};

View File

@ -35,23 +35,23 @@
WELSVP_NAMESPACE_BEGIN
int32_t CheckLine(uint8_t* pData, int32_t iWidth){
int32_t CheckLine (uint8_t* pData, int32_t iWidth) {
int32_t iQualified = 0;
int32_t iColorMap[8] = {0};
int32_t iChangedTimes = 0;
int32_t iColorCounts = 0;
RECORD_COLOR(pData[0], iColorMap);
RECORD_COLOR (pData[0], iColorMap);
for (int32_t i=1; i<iWidth; i++){
RECORD_COLOR(pData[i], iColorMap);
iChangedTimes += (pData[i] != pData[i-1]);
for (int32_t i = 1; i < iWidth; i++) {
RECORD_COLOR (pData[i], iColorMap);
iChangedTimes += (pData[i] != pData[i - 1]);
}
for (int32_t i=0; i<8; i++)
for (int32_t j=0; j<32; j++)
iColorCounts += ((iColorMap[i] >> j)&1);
for (int32_t i = 0; i < 8; i++)
for (int32_t j = 0; j < 32; j++)
iColorCounts += ((iColorMap[i] >> j) & 1);
switch(iColorCounts){
switch (iColorCounts) {
case 1:
iQualified = 0;
break;
@ -66,24 +66,24 @@ int32_t CheckLine(uint8_t* pData, int32_t iWidth){
return iQualified;
}
int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
int32_t iStride, int32_t iOffsetX, int32_t iOffsetY){
int32_t SelectTestLine (uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
int32_t iStride, int32_t iOffsetX, int32_t iOffsetY) {
const int32_t kiHalfHeight = iHeight >> 1;
const int32_t kiMidPos = iOffsetY + kiHalfHeight;
int32_t TestPos = kiMidPos;
int32_t iOffsetAbs;
uint8_t* pTmp;
for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++){
for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++) {
TestPos = kiMidPos + iOffsetAbs;
if (TestPos < iPicHeight){
if (TestPos < iPicHeight) {
pTmp = pY + TestPos * iStride + iOffsetX;
if (CheckLine(pTmp, iWidth)) break;
if (CheckLine (pTmp, iWidth)) break;
}
TestPos = kiMidPos - iOffsetAbs;
if(TestPos >=0){
if (TestPos >= 0) {
pTmp = pY + TestPos * iStride + iOffsetX;
if (CheckLine(pTmp, iWidth)) break;
if (CheckLine (pTmp, iWidth)) break;
}
}
if (iOffsetAbs == kiHalfHeight)
@ -95,27 +95,26 @@ int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPi
* compare pixel line between previous and current one
* return: 0 for totally equal, otherwise 1
*/
int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth)
{
int32_t CompareLine (uint8_t* pYSrc, uint8_t* pYRef, const int32_t kiWidth) {
int32_t iCmp = 1;
if ( *((int32_t*)pYSrc) != *((int32_t*)pYRef)) return 1;
if ( *((int32_t*)(pYSrc + 4)) != *((int32_t*)(pYRef + 4))) return 1;
if ( *((int32_t*)(pYSrc + 8)) != *((int32_t*)(pYRef + 8))) return 1;
if ( kiWidth > 12 )
iCmp = WelsMemcmp(pYSrc+12, pYRef+12, kiWidth-12);
if (* ((int32_t*)pYSrc) != * ((int32_t*)pYRef)) return 1;
if (* ((int32_t*) (pYSrc + 4)) != * ((int32_t*) (pYRef + 4))) return 1;
if (* ((int32_t*) (pYSrc + 8)) != * ((int32_t*) (pYRef + 8))) return 1;
if (kiWidth > 12)
iCmp = WelsMemcmp (pYSrc + 12, pYRef + 12, kiWidth - 12);
return iCmp;
}
void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam){
void ScrollDetectionCore (SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam& sScrollDetectionParam) {
bool bScrollDetected = 0;
uint8_t* pYLine;
uint8_t* pYTmp;
int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs;
int32_t iPicHeight = pRefPixMap->sRect.iRectHeight;
int32_t iMinHeight = WELS_MAX(iOffsetY,0);
int32_t iMaxHeight = WELS_MIN(iOffsetY + iHeight - 1, iPicHeight-1) ;//offset_y + height - 1;//
int32_t iMinHeight = WELS_MAX (iOffsetY, 0);
int32_t iMaxHeight = WELS_MIN (iOffsetY + iHeight - 1, iPicHeight - 1) ; //offset_y + height - 1;//
uint8_t* pYRef, *pYSrc;
int32_t iYStride;
@ -123,76 +122,74 @@ void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidt
pYSrc = (uint8_t*)pSrcPixMap->pPixel[0];
iYStride = pRefPixMap->iStride[0];
iTestPos = SelectTestLine(pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY);
iTestPos = SelectTestLine (pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY);
if (iTestPos == -1){
if (iTestPos == -1) {
sScrollDetectionParam.bScrollDetectFlag = 0;
return;
}
pYLine = pYSrc + iYStride * iTestPos + iOffsetX;
iMaxAbs = WELS_MIN(WELS_MAX(iTestPos-iMinHeight-1, iMaxHeight-iTestPos),MAX_SCROLL_MV_Y);
iMaxAbs = WELS_MIN (WELS_MAX (iTestPos - iMinHeight - 1, iMaxHeight - iTestPos), MAX_SCROLL_MV_Y);
iSearchPos = iTestPos;
for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++){
for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++) {
iSearchPos = iTestPos + iOffsetAbs;
if (iSearchPos <= iMaxHeight){
if (iSearchPos <= iMaxHeight) {
pYTmp = pYRef + iSearchPos * iYStride + iOffsetX;
if (!CompareLine(pYLine, pYTmp, iWidth)){
uint8_t *pYUpper, *pYLineUpper;
if (!CompareLine (pYLine, pYTmp, iWidth)) {
uint8_t* pYUpper, *pYLineUpper;
int32_t iCheckedLines;
int32_t iLowOffset = WELS_MIN(iMaxHeight - iSearchPos, CHECK_OFFSET);
int32_t iLowOffset = WELS_MIN (iMaxHeight - iSearchPos, CHECK_OFFSET);
int32_t i;
iCheckedLines = WELS_MIN(iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET);
iCheckedLines = WELS_MIN (iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET);
pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride;
pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride;
for(i = 0; i < iCheckedLines; i ++){
if (CompareLine(pYLineUpper, pYUpper, iWidth)){
for (i = 0; i < iCheckedLines; i ++) {
if (CompareLine (pYLineUpper, pYUpper, iWidth)) {
break;
}
pYUpper += iYStride;
pYLineUpper += iYStride;
}
if (i == iCheckedLines){
bScrollDetected=1;
if (i == iCheckedLines) {
bScrollDetected = 1;
break;
}
}
}
iSearchPos = iTestPos - iOffsetAbs-1;
if (iSearchPos >= iMinHeight){
iSearchPos = iTestPos - iOffsetAbs - 1;
if (iSearchPos >= iMinHeight) {
pYTmp = pYRef + iSearchPos * iYStride + iOffsetX;
if (!CompareLine(pYLine, pYTmp, iWidth))
{
uint8_t *pYUpper, *pYLineUpper;
if (!CompareLine (pYLine, pYTmp, iWidth)) {
uint8_t* pYUpper, *pYLineUpper;
int32_t iCheckedLines;
int32_t iUpOffset = WELS_MIN(iSearchPos - iMinHeight, CHECK_OFFSET);
int32_t iUpOffset = WELS_MIN (iSearchPos - iMinHeight, CHECK_OFFSET);
int32_t i;
pYUpper = pYTmp - iUpOffset * iYStride;
pYLineUpper = pYLine - iUpOffset * iYStride;
iCheckedLines = WELS_MIN(iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET);
iCheckedLines = WELS_MIN (iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET);
for(i = 0; i < iCheckedLines; i ++){
if (CompareLine(pYLineUpper,pYUpper, iWidth)){
for (i = 0; i < iCheckedLines; i ++) {
if (CompareLine (pYLineUpper, pYUpper, iWidth)) {
break;
}
pYUpper += iYStride;
pYLineUpper += iYStride;
}
if (i == iCheckedLines){
bScrollDetected=1;
if (i == iCheckedLines) {
bScrollDetected = 1;
break;
}
}
}
}
if (!bScrollDetected){
if (!bScrollDetected) {
sScrollDetectionParam.bScrollDetectFlag = 0;
}
else{
} else {
sScrollDetectionParam.bScrollDetectFlag = 1;
sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv
sScrollDetectionParam.iScrollMvX = 0;

View File

@ -51,11 +51,11 @@ WELSVP_NAMESPACE_BEGIN
x[_t>>5] |= (1 << (_t&31)); \
}
int32_t CheckLine(uint8_t* pData, int32_t iWidth);
int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
int32_t CheckLine (uint8_t* pData, int32_t iWidth);
int32_t SelectTestLine (uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
int32_t iStride, int32_t iOffsetX, int32_t iOffsetY);
int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth);
void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam);
int32_t CompareLine (uint8_t* pYSrc, uint8_t* pYRef, const int32_t kiWidth);
void ScrollDetectionCore (SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam& sScrollDetectionParam);
WELSVP_NAMESPACE_END

View File

@ -34,7 +34,8 @@
WELSVP_NAMESPACE_BEGIN
void VAACalcSadSsd_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight, int32_t iPicStride,
void VAACalcSadSsd_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* psqsum16x16, int32_t* psqdiff16x16) {
const uint8_t* tmp_ref = pRefData;
const uint8_t* tmp_cur = pCurData;
@ -145,7 +146,8 @@ void VAACalcSadSsd_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t
tmp_cur += step;
}
}
void VAACalcSadVar_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight, int32_t iPicStride,
void VAACalcSadVar_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* psqsum16x16) {
const uint8_t* tmp_ref = pRefData;
const uint8_t* tmp_cur = pCurData;
@ -249,7 +251,8 @@ void VAACalcSadVar_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t
}
void VAACalcSad_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight, int32_t iPicStride,
void VAACalcSad_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8) {
const uint8_t* tmp_ref = pRefData;
const uint8_t* tmp_cur = pCurData;
@ -480,7 +483,8 @@ void VAACalcSadSsdBgd_c (const uint8_t* pCurData, const uint8_t* pRefData, int32
}
}
void VAACalcSadBgd_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight, int32_t iPicStride,
void VAACalcSadBgd_c (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSd8x8, uint8_t* pMad8x8) {
const uint8_t* tmp_ref = pRefData;
const uint8_t* tmp_cur = pCurData;

View File

@ -49,11 +49,13 @@
WELSVP_NAMESPACE_BEGIN
typedef void (VAACalcSadBgdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
typedef void (VAACalcSadBgdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth,
int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSd8x8, uint8_t* pMad8x8);
typedef void (VAACalcSadSsdBgdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
typedef void (VAACalcSadSsdBgdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth,
int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16,
int32_t* pSsd16x16, int32_t* pSd8x8, uint8_t* pMad8x8);
@ -62,11 +64,13 @@ typedef void (VAACalcSadFunc) (const uint8_t* pCurData, const uint8_t* pRefData,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8);
typedef void (VAACalcSadVarFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
typedef void (VAACalcSadVarFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth,
int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16);
typedef void (VAACalcSadSsdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight,
typedef void (VAACalcSadSsdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth,
int32_t iPicHeight,
int32_t iPicStride,
int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16, int32_t* pSsd16x16);