diff --git a/codec/build/iOS/dec/demo/demo/DEMOViewController.m b/codec/build/iOS/dec/demo/demo/DEMOViewController.m index f9fbcb06..cc66534a 100644 --- a/codec/build/iOS/dec/demo/demo/DEMOViewController.m +++ b/codec/build/iOS/dec/demo/demo/DEMOViewController.m @@ -47,7 +47,7 @@ extern int DecMain(int argc, char * argv[]); - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + // Do any additional setup after loading the view, typically from a nib. //Add the testing codes self.resFileArray = [[NSMutableArray alloc] init]; self.selectedRow = 0; diff --git a/codec/common/inc/WelsThreadLib.h b/codec/common/inc/WelsThreadLib.h index d81540d9..98d9aeb5 100644 --- a/codec/common/inc/WelsThreadLib.h +++ b/codec/common/inc/WelsThreadLib.h @@ -60,7 +60,7 @@ typedef HANDLE WELS_EVENT; #define WELS_THREAD_ROUTINE_TYPE DWORD WINAPI #define WELS_THREAD_ROUTINE_RETURN(rc) return (DWORD)rc; -#else // NON-WINDOWS +#else // NON-WINDOWS #include #include diff --git a/codec/common/inc/copy_mb.h b/codec/common/inc/copy_mb.h index 24ee1924..a4ea465b 100644 --- a/codec/common/inc/copy_mb.h +++ b/codec/common/inc/copy_mb.h @@ -42,8 +42,8 @@ void WelsCopy4x4_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStr void WelsCopy8x4_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); void WelsCopy4x8_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); void WelsCopy8x8_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); -void WelsCopy8x16_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); // -void WelsCopy16x8_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); // +void WelsCopy8x16_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); // +void WelsCopy16x8_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); // void WelsCopy16x16_c (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); #if defined(__cplusplus) diff --git a/codec/common/inc/expand_pic.h b/codec/common/inc/expand_pic.h index 37e16110..7b782cfb 100644 --- a/codec/common/inc/expand_pic.h +++ b/codec/common/inc/expand_pic.h @@ -46,7 +46,7 @@ extern "C" { #endif//__cplusplus -#define PADDING_LENGTH 32 // reference extension +#define PADDING_LENGTH 32 // reference extension #if defined(X86_ASM) void ExpandPictureLuma_sse2 (uint8_t* pDst, diff --git a/codec/common/inc/golomb_common.h b/codec/common/inc/golomb_common.h index 0ade34af..04f87b00 100644 --- a/codec/common/inc/golomb_common.h +++ b/codec/common/inc/golomb_common.h @@ -67,11 +67,11 @@ namespace WelsCommon { static inline int32_t InitBits (SBitStringAux* pBs, const uint8_t* kpBuf, const int32_t kiSize) { uint8_t* ptr = (uint8_t*)kpBuf; - pBs->pStartBuf = ptr; - pBs->pCurBuf = ptr; - pBs->pEndBuf = ptr + kiSize; - pBs->iLeftBits = 32; - pBs->uiCurBits = 0; + pBs->pStartBuf = ptr; + pBs->pCurBuf = ptr; + pBs->pEndBuf = ptr + kiSize; + pBs->iLeftBits = 32; + pBs->uiCurBits = 0; return kiSize; } diff --git a/codec/common/inc/ls_defines.h b/codec/common/inc/ls_defines.h index becf17b9..7b2914ea 100644 --- a/codec/common/inc/ls_defines.h +++ b/codec/common/inc/ls_defines.h @@ -62,7 +62,7 @@ STRUCTA (64, 2); STRUCTA (64, 4); STRUCTA (64, 8); //#define _USE_STRUCT_INT_CVT -// #ifdef _USE_STRUCT_INT_CVT +//#ifdef _USE_STRUCT_INT_CVT #define ST16(a, b) (((struct tagUnaligned_16 *) (a))->l) = (b) #define ST32(a, b) (((struct tagUnaligned_32 *) (a))->l) = (b) #define ST64(a, b) (((struct tagUnaligned_64 *) (a))->l) = (b) @@ -81,11 +81,11 @@ STRUCTA (64, 8); #define ST64A2(a, b) STA(a, b, 64, 2) #define ST64A4(a, b) STA(a, b, 64, 4) #define ST64A8(a, b) STA(a, b, 64, 8) -// #else -// inline void __ST16(void *dst, uint16_t v) { memcpy(dst, &v, 2); } -// inline void __ST32(void *dst, uint32_t v) { memcpy(dst, &v, 4); } +//#else +//inline void __ST16(void *dst, uint16_t v) { memcpy(dst, &v, 2); } +//inline void __ST32(void *dst, uint32_t v) { memcpy(dst, &v, 4); } //inline void __ST64(void *dst, uint64_t v) { memcpy(dst, &v, 8); } -// #endif +//#endif #else @@ -116,15 +116,15 @@ STRUCTA (64, 8); #endif /* !__GNUC__ */ #ifndef INTD16 -#define INTD16 LD16 +#define INTD16 LD16 #endif//INTD16 #ifndef INTD32 -#define INTD32 LD32 +#define INTD32 LD32 #endif//INTD32 #ifndef INTD64 -#define INTD64 LD64 +#define INTD64 LD64 #endif//INTD64 #endif//___LD_ST_MACROS___ diff --git a/codec/common/inc/macros.h b/codec/common/inc/macros.h index a6a5a45c..4fd49544 100644 --- a/codec/common/inc/macros.h +++ b/codec/common/inc/macros.h @@ -70,7 +70,7 @@ #if defined(_MSC_VER) #if(_MSC_VER < 1700) -#define inline __inline +#define inline __inline #endif #define ALIGNED_DECLARE( type, var, n ) __declspec(align(n)) type var @@ -82,51 +82,51 @@ #ifndef WELS_ALIGN -#define WELS_ALIGN(x, n) (((x)+(n)-1)&~((n)-1)) +#define WELS_ALIGN(x, n) (((x)+(n)-1)&~((n)-1)) #endif//WELS_ALIGN #if 1 // Alternative implementation of WELS_MAX and WELS_MIN #ifndef WELS_MAX -#define WELS_MAX(x, y) ((x) > (y) ? (x) : (y)) +#define WELS_MAX(x, y) ((x) > (y) ? (x) : (y)) #endif//WELS_MAX #ifndef WELS_MIN -#define WELS_MIN(x, y) ((x) < (y) ? (x) : (y)) +#define WELS_MIN(x, y) ((x) < (y) ? (x) : (y)) #endif//WELS_MIN #else // Alternative implementation of WELS_MAX and WELS_MIN #ifndef WELS_MAX -#define WELS_MAX(x, y) ((x) - (((x)-(y))&(((x)-(y))>>31))) +#define WELS_MAX(x, y) ((x) - (((x)-(y))&(((x)-(y))>>31))) #endif//WELS_MAX #ifndef WELS_MIN -#define WELS_MIN(x, y) ((y) + (((x)-(y))&(((x)-(y))>>31))) +#define WELS_MIN(x, y) ((y) + (((x)-(y))&(((x)-(y))>>31))) #endif//WELS_MIN #endif // Alternative implementation of WELS_MAX and WELS_MIN #ifndef WELS_CEIL -#define WELS_CEIL(x) ceil(x) // FIXME: low complexity instead of math library used +#define WELS_CEIL(x) ceil(x) // FIXME: low complexity instead of math library used #endif//WELS_CEIL #ifndef WELS_FLOOR -#define WELS_FLOOR(x) floor(x) // FIXME: low complexity instead of math library used +#define WELS_FLOOR(x) floor(x) // FIXME: low complexity instead of math library used #endif//WELS_FLOOR #ifndef WELS_ROUND -#define WELS_ROUND(x) ((int32_t)(0.5+(x))) +#define WELS_ROUND(x) ((int32_t)(0.5+(x))) #endif//WELS_ROUND #ifndef WELS_ROUND64 -#define WELS_ROUND64(x) ((int64_t)(0.5+(x))) +#define WELS_ROUND64(x) ((int64_t)(0.5+(x))) #endif//WELS_ROUND #ifndef WELS_DIV_ROUND -#define WELS_DIV_ROUND(x,y) ((int32_t)((y)==0?((x)/((y)+1)):(((y)/2+(x))/(y)))) +#define WELS_DIV_ROUND(x,y) ((int32_t)((y)==0?((x)/((y)+1)):(((y)/2+(x))/(y)))) #endif//WELS_DIV_ROUND #ifndef WELS_DIV_ROUND64 -#define WELS_DIV_ROUND64(x,y) ((int64_t)((y)==0?((x)/((y)+1)):(((y)/2+(x))/(y)))) +#define WELS_DIV_ROUND64(x,y) ((int64_t)((y)==0?((x)/((y)+1)):(((y)/2+(x))/(y)))) #endif//WELS_DIV_ROUND64 #define WELS_NON_ZERO_COUNT_AVERAGE(nC,nA,nB) { \ @@ -152,14 +152,14 @@ static inline int32_t WelsMedian (int32_t iX, int32_t iY, int32_t iZ) { int32_t iMin = iX, iMax = iX; if (iY < iMin) - iMin = iY; + iMin = iY; else iMax = iY; if (iZ < iMin) - iMin = iZ; + iMin = iZ; else if (iZ > iMax) - iMax = iZ; + iMax = iZ; return (iX + iY + iZ) - (iMin + iMax); } @@ -253,7 +253,7 @@ static inline int32_t WELS_LOG2 (uint32_t v) { } -#define CLIP3_QP_0_51(q) WELS_CLIP3(q, 0, 51) // ((q) < (0) ? (0) : ((q) > (51) ? (51) : (q))) +#define CLIP3_QP_0_51(q) WELS_CLIP3(q, 0, 51) // ((q) < (0) ? (0) : ((q) > (51) ? (51) : (q))) #define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) diff --git a/codec/common/inc/memory_align.h b/codec/common/inc/memory_align.h index 04cdcfad..b15de9b4 100644 --- a/codec/common/inc/memory_align.h +++ b/codec/common/inc/memory_align.h @@ -68,10 +68,10 @@ 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 }; diff --git a/codec/common/inc/typedefs.h b/codec/common/inc/typedefs.h index 1a68f378..50024110 100644 --- a/codec/common/inc/typedefs.h +++ b/codec/common/inc/typedefs.h @@ -80,7 +80,7 @@ typedef int32_t intX_t; #ifdef EPSN #undef EPSN #endif//EPSN -#define EPSN (0.000001f) // (1e-6) // desired float precision +#define EPSN (0.000001f) // (1e-6) // desired float precision #endif //WELS_TYPE_DEFINES_H__ diff --git a/codec/common/inc/welsCodecTrace.h b/codec/common/inc/welsCodecTrace.h index 4cd13911..b6c323f9 100644 --- a/codec/common/inc/welsCodecTrace.h +++ b/codec/common/inc/welsCodecTrace.h @@ -53,7 +53,7 @@ class welsCodecTrace { static void StaticCodecTrace (void* pCtx, const int32_t kiLevel, const char* kpStrFormat, va_list vl); void CodecTrace (const int32_t kiLevel, const char* kpStrFormat, va_list vl); - int32_t m_iTraceLevel; + int32_t m_iTraceLevel; WelsTraceCallback m_fpTrace; void* m_pTraceCtx; public: diff --git a/codec/common/inc/wels_common_defs.h b/codec/common/inc/wels_common_defs.h index 612c9274..cb2aa809 100644 --- a/codec/common/inc/wels_common_defs.h +++ b/codec/common/inc/wels_common_defs.h @@ -218,14 +218,14 @@ enum EMmcoCode { * Bit-stream auxiliary reading / writing */ typedef struct TagBitStringAux { - uint8_t* pStartBuf; // buffer to start position - uint8_t* pEndBuf; // buffer + length + uint8_t* pStartBuf; // buffer to start position + uint8_t* pEndBuf; // buffer + length int32_t iBits; // count bits of overall bitstreaming input intX_t iIndex; //only for cavlc usage - uint8_t* pCurBuf; // current reading position + uint8_t* pCurBuf; // current reading position uint32_t uiCurBits; - int32_t iLeftBits; // count number of available bits left ([1, 8]), + 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; @@ -234,17 +234,17 @@ typedef struct TagNalUnitHeader { uint8_t uiForbiddenZeroBit; uint8_t uiNalRefIdc; EWelsNalUnitType eNalUnitType; - uint8_t uiReservedOneByte; // only padding usage + uint8_t uiReservedOneByte; // only padding usage } SNalUnitHeader, *PNalUnitHeader; /* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */ typedef struct TagNalUnitHeaderExt { - SNalUnitHeader sNalUnitHeader; + SNalUnitHeader sNalUnitHeader; - // uint8_t reserved_one_bit; + // uint8_t reserved_one_bit; bool bIdrFlag; uint8_t uiPriorityId; - int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder + int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder uint8_t uiDependencyId; uint8_t uiQualityId; diff --git a/codec/common/src/WelsThreadLib.cpp b/codec/common/src/WelsThreadLib.cpp index f686bff8..3a92e845 100644 --- a/codec/common/src/WelsThreadLib.cpp +++ b/codec/common/src/WelsThreadLib.cpp @@ -299,12 +299,12 @@ WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_ } WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name) { #ifdef __APPLE__ - WELS_THREAD_ERROR_CODE err = sem_close (*event); // match with sem_open + WELS_THREAD_ERROR_CODE err = sem_close (*event); // match with sem_open if (event_name) sem_unlink (event_name); return err; #else - WELS_THREAD_ERROR_CODE err = sem_destroy (*event); // match with sem_init + WELS_THREAD_ERROR_CODE err = sem_destroy (*event); // match with sem_init free (*event); return err; #endif @@ -312,17 +312,17 @@ WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_n WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event) { WELS_THREAD_ERROR_CODE err = 0; -// int32_t val = 0; -// sem_getvalue(event, &val); -// fprintf( stderr, "before signal it, val= %d..\n",val ); +// int32_t val = 0; +// sem_getvalue(event, &val); +// fprintf( stderr, "before signal it, val= %d..\n",val ); err = sem_post (*event); -// sem_getvalue(event, &val); -// fprintf( stderr, "after signal it, val= %d..\n",val ); +// sem_getvalue(event, &val); +// fprintf( stderr, "after signal it, val= %d..\n",val ); return err; } WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) { - return sem_wait (*event); // blocking until signaled + return sem_wait (*event); // blocking until signaled } WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) { @@ -360,7 +360,7 @@ WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT* event_list, WELS_EVENT* master_event) { uint32_t nIdx = 0; - uint32_t uiAccessTime = 2; // 2 us once + uint32_t uiAccessTime = 2; // 2 us once if (nCount == 0) return WELS_THREAD_ERROR_WAIT_FAILED; @@ -378,7 +378,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, } while (1) { - nIdx = 0; // access each event by order + nIdx = 0; // access each event by order while (nIdx < nCount) { int32_t err = 0; int32_t wait_count = 0; @@ -399,7 +399,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, // we do need access next event next time ++ nIdx; } - usleep (1); // switch to working threads + usleep (1); // switch to working threads if (master_event != NULL) { // A master event was used and was signalled, but none of the events in the // list was found to be signalled, thus wait a little more when rechecking @@ -417,19 +417,19 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT* event_list, WELS_EVENT* master_event) { uint32_t nIdx = 0; uint32_t uiCountSignals = 0; - uint32_t uiSignalFlag = 0; // UGLY: suppose maximal event number up to 32 + uint32_t uiSignalFlag = 0; // UGLY: suppose maximal event number up to 32 if (nCount == 0 || nCount > (sizeof (uint32_t) << 3)) return WELS_THREAD_ERROR_WAIT_FAILED; while (1) { - nIdx = 0; // access each event by order + nIdx = 0; // access each event by order while (nIdx < nCount) { const uint32_t kuiBitwiseFlag = (1 << nIdx); if ((uiSignalFlag & kuiBitwiseFlag) != kuiBitwiseFlag) { // non-blocking mode int32_t err = 0; -// fprintf( stderr, "sem_wait(): start to wait event %d..\n", nIdx ); +// fprintf( stderr, "sem_wait(): start to wait event %d..\n", nIdx ); if (master_event == NULL) { err = sem_wait (event_list[nIdx]); } else { @@ -445,11 +445,11 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, } } } -// fprintf( stderr, "sem_wait(): wait event %d result %d errno %d..\n", nIdx, err, errno ); +// fprintf( stderr, "sem_wait(): wait event %d result %d errno %d..\n", nIdx, err, errno ); if (WELS_THREAD_ERROR_OK == err) { -// int32_t val = 0; -// sem_getvalue(&event_list[nIdx], &val); -// fprintf( stderr, "after sem_timedwait(), event_list[%d] semaphore value= %d..\n", nIdx, val); +// int32_t val = 0; +// sem_getvalue(&event_list[nIdx], &val); +// fprintf( stderr, "after sem_timedwait(), event_list[%d] semaphore value= %d..\n", nIdx, val); uiSignalFlag |= kuiBitwiseFlag; ++ uiCountSignals; diff --git a/codec/common/src/cpu.cpp b/codec/common/src/cpu.cpp index 635d8c00..2dd81ccf 100644 --- a/codec/common/src/cpu.cpp +++ b/codec/common/src/cpu.cpp @@ -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; @@ -165,7 +165,7 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD); if ((!strcmp ((const char*)chVendorName, CPU_Vendor_AMD)) - && (uiFeatureA >= 0x80000001)) { // confirmed_safe_unsafe_usage + && (uiFeatureA >= 0x80000001)) { // confirmed_safe_unsafe_usage WelsCPUId (0x80000001, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD); if (uiFeatureD & 0x00400000) { uiCPU |= WELS_CPU_MMXEXT; @@ -175,7 +175,7 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { } } - if (!strcmp ((const char*)chVendorName, CPU_Vendor_INTEL)) { // confirmed_safe_unsafe_usage + if (!strcmp ((const char*)chVendorName, CPU_Vendor_INTEL)) { // confirmed_safe_unsafe_usage int32_t family, model; WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD); @@ -189,11 +189,11 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) { // get cache line size if ((!strcmp ((const char*)chVendorName, CPU_Vendor_INTEL)) - || ! (strcmp ((const char*)chVendorName, CPU_Vendor_CYRIX))) { // confirmed_safe_unsafe_usage + || ! (strcmp ((const char*)chVendorName, CPU_Vendor_CYRIX))) { // confirmed_safe_unsafe_usage WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD); CacheLineSize = (uiFeatureB & 0xff00) >> - 5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte + 5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte if (CacheLineSize == 128) { uiCPU |= WELS_CPU_CACHELINE_128; diff --git a/codec/common/src/crt_util_safe_x.cpp b/codec/common/src/crt_util_safe_x.cpp index c8853ee6..e8426118 100644 --- a/codec/common/src/crt_util_safe_x.cpp +++ b/codec/common/src/crt_util_safe_x.cpp @@ -54,7 +54,7 @@ #endif //_WIN32 #include "macros.h" -#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms +#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms #if defined(_WIN32) && defined(_MSC_VER) diff --git a/codec/common/src/deblocking_common.cpp b/codec/common/src/deblocking_common.cpp index 81f41ef4..9733091e 100644 --- a/codec/common/src/deblocking_common.cpp +++ b/codec/common/src/deblocking_common.cpp @@ -56,23 +56,23 @@ void DeblockLumaEq4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_ bool bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta; if (bDetaP2P0) { const int32_t p3 = pPix[-4 * iStrideX]; - pPix[-iStrideX] = (p2 + (p1 << 1) + (p0 << 1) + (q0 << 1) + q1 + 4) >> 3; //p0 - pPix[-2 * iStrideX] = (p2 + p1 + p0 + q0 + 2) >> 2; //p1 - pPix[-3 * iStrideX] = ((p3 << 1) + p2 + (p2 << 1) + p1 + p0 + q0 + 4) >> 3;//p2 + pPix[-iStrideX] = (p2 + (p1 << 1) + (p0 << 1) + (q0 << 1) + q1 + 4) >> 3; //p0 + pPix[-2 * iStrideX] = (p2 + p1 + p0 + q0 + 2) >> 2; //p1 + pPix[-3 * iStrideX] = ((p3 << 1) + p2 + (p2 << 1) + p1 + p0 + q0 + 4) >> 3; //p2 } else { - pPix[-1 * iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0 + pPix[-1 * iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0 } if (bDetaQ2Q0) { const int32_t q3 = pPix[3 * iStrideX]; - pPix[0] = (p1 + (p0 << 1) + (q0 << 1) + (q1 << 1) + q2 + 4) >> 3; //q0 - pPix[iStrideX] = (p0 + q0 + q1 + q2 + 2) >> 2; //q1 - pPix[2 * iStrideX] = ((q3 << 1) + q2 + (q2 << 1) + q1 + q0 + p0 + 4) >> 3;//q2 + pPix[0] = (p1 + (p0 << 1) + (q0 << 1) + (q1 << 1) + q2 + 4) >> 3; //q0 + pPix[iStrideX] = (p0 + q0 + q1 + q2 + 2) >> 2; //q1 + pPix[2 * iStrideX] = ((q3 << 1) + q2 + (q2 << 1) + q1 + q0 + p0 + 4) >> 3; //q2 } else { - pPix[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0 + pPix[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0 } } else { pPix[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0 - pPix[ 0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0 + pPix[ 0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0 } } pPix += iStrideY; diff --git a/codec/common/src/expand_pic.cpp b/codec/common/src/expand_pic.cpp index 1eda20d5..d2e4a504 100644 --- a/codec/common/src/expand_pic.cpp +++ b/codec/common/src/expand_pic.cpp @@ -36,23 +36,23 @@ // rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009 static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH) { - uint8_t* pTmp = pDst; - uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride; - const int32_t kiPaddingLen = PADDING_LENGTH; - const uint8_t kuiTL = pTmp[0]; - const uint8_t kuiTR = pTmp[kiPicW - 1]; - const uint8_t kuiBL = pDstLastLine[0]; - const uint8_t kuiBR = pDstLastLine[kiPicW - 1]; - int32_t i = 0; + uint8_t* pTmp = pDst; + uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride; + const int32_t kiPaddingLen = PADDING_LENGTH; + const uint8_t kuiTL = pTmp[0]; + const uint8_t kuiTR = pTmp[kiPicW - 1]; + const uint8_t kuiBL = pDstLastLine[0]; + const uint8_t kuiBR = pDstLastLine[kiPicW - 1]; + int32_t i = 0; do { - const int32_t kiStrides = (1 + i) * kiStride; - uint8_t* pTop = pTmp - kiStrides; - uint8_t* pBottom = pDstLastLine + kiStrides; + const int32_t kiStrides = (1 + i) * kiStride; + uint8_t* pTop = pTmp - kiStrides; + uint8_t* pBottom = pDstLastLine + kiStrides; // pad pTop and pBottom - memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage - memcpy (pBottom, pDstLastLine, kiPicW); // confirmed_safe_unsafe_usage + memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage + memcpy (pBottom, pDstLastLine, kiPicW); // confirmed_safe_unsafe_usage // pad corners memset (pTop - kiPaddingLen, kuiTL, kiPaddingLen); //pTop left @@ -76,23 +76,23 @@ static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, c static inline void ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH) { - uint8_t* pTmp = pDst; - uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride; - const int32_t kiPaddingLen = (PADDING_LENGTH >> 1); - const uint8_t kuiTL = pTmp[0]; - const uint8_t kuiTR = pTmp[kiPicW - 1]; - const uint8_t kuiBL = pDstLastLine[0]; - const uint8_t kuiBR = pDstLastLine[kiPicW - 1]; - int32_t i = 0; + uint8_t* pTmp = pDst; + uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride; + const int32_t kiPaddingLen = (PADDING_LENGTH >> 1); + const uint8_t kuiTL = pTmp[0]; + const uint8_t kuiTR = pTmp[kiPicW - 1]; + const uint8_t kuiBL = pDstLastLine[0]; + const uint8_t kuiBR = pDstLastLine[kiPicW - 1]; + int32_t i = 0; do { - const int32_t kiStrides = (1 + i) * kiStride; - uint8_t* pTop = pTmp - kiStrides; - uint8_t* pBottom = pDstLastLine + kiStrides; + const int32_t kiStrides = (1 + i) * kiStride; + uint8_t* pTop = pTmp - kiStrides; + uint8_t* pBottom = pDstLastLine + kiStrides; // pad pTop and pBottom - memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage - memcpy (pBottom, pDstLastLine, kiPicW); // confirmed_safe_unsafe_usage + memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage + memcpy (pBottom, pDstLastLine, kiPicW); // confirmed_safe_unsafe_usage // pad corners memset (pTop - kiPaddingLen, kuiTL, kiPaddingLen); //pTop left @@ -147,20 +147,20 @@ void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCP void ExpandReferencingPicture (uint8_t* pData[3], int32_t iWidth, int32_t iHeight, int32_t iStride[3], PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]) { /*local variable*/ - uint8_t* pPicY = pData[0]; + uint8_t* pPicY = pData[0]; uint8_t* pPicCb = pData[1]; uint8_t* pPicCr = pData[2]; - const int32_t kiWidthY = iWidth; - const int32_t kiHeightY = iHeight; - const int32_t kiWidthUV = kiWidthY >> 1; - const int32_t kiHeightUV = kiHeightY >> 1; + const int32_t kiWidthY = iWidth; + const int32_t kiHeightY = iHeight; + const int32_t kiWidthUV = kiWidthY >> 1; + const int32_t kiHeightUV = kiHeightY >> 1; pExpLuma (pPicY, iStride[0], kiWidthY, kiHeightY); if (kiWidthUV >= 16) { // fix coding picture size as 16x16 - const bool kbChrAligned = /*(iWidthUV >= 16) && */ ((kiWidthUV & 0x0F) == 0); // chroma planes: (16+iWidthUV) & 15 + const bool kbChrAligned = /*(iWidthUV >= 16) && */ ((kiWidthUV & 0x0F) == 0); // chroma planes: (16+iWidthUV) & 15 pExpChrom[kbChrAligned] (pPicCb, iStride[1], kiWidthUV, kiHeightUV); pExpChrom[kbChrAligned] (pPicCr, iStride[2], kiWidthUV, kiHeightUV); } else { diff --git a/codec/common/src/intra_pred_common.cpp b/codec/common/src/intra_pred_common.cpp index 38343177..f35ceccb 100644 --- a/codec/common/src/intra_pred_common.cpp +++ b/codec/common/src/intra_pred_common.cpp @@ -61,12 +61,12 @@ void WelsI16x16LumaPredV_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStrid void WelsI16x16LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { int32_t iStridex15 = (kiStride << 4) - kiStride; int32_t iPredStride = 16; - int32_t iPredStridex15 = 240; //(iPredStride<<4)-iPredStride; + int32_t iPredStridex15 = 240; //(iPredStride<<4)-iPredStride; uint8_t i = 15; do { - const uint8_t kuiSrc8 = pRef[iStridex15 - 1]; - const uint64_t kuiV64 = (uint64_t) (0x0101010101010101ULL * kuiSrc8); + const uint8_t kuiSrc8 = pRef[iStridex15 - 1]; + const uint64_t kuiV64 = (uint64_t) (0x0101010101010101ULL * kuiSrc8); ST64 (&pPred[iPredStridex15], kuiV64); ST64 (&pPred[iPredStridex15 + 8], kuiV64); diff --git a/codec/common/src/mc.cpp b/codec/common/src/mc.cpp index 38583a00..75711914 100644 --- a/codec/common/src/mc.cpp +++ b/codec/common/src/mc.cpp @@ -58,7 +58,7 @@ namespace WelsCommon { //iB = dx * (8 - dy); //iC = (8 - dx) * dy; //iD = dx * dy -static const uint8_t g_kuiABCD[8][8][4] = { //g_kA[dy][dx], g_kB[dy][dx], g_kC[dy][dx], g_kD[dy][dx] +static const uint8_t g_kuiABCD[8][8][4] = { //g_kA[dy][dx], g_kB[dy][dx], g_kC[dy][dx], g_kD[dy][dx] { {64, 0, 0, 0}, {56, 8, 0, 0}, {48, 16, 0, 0}, {40, 24, 0, 0}, {32, 32, 0, 0}, {24, 40, 0, 0}, {16, 48, 0, 0}, {8, 56, 0, 0} @@ -965,7 +965,7 @@ void McLuma_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_ {McHorVer20_neon, McHorVer21_neon, McHorVer22_neon, McHorVer23_neon}, {McHorVer30_neon, McHorVer31_neon, McHorVer32_neon, McHorVer33_neon}, }; - // pSrc += (iMvY >> 2) * iSrcStride + (iMvX >> 2); + // pSrc += (iMvY >> 2) * iSrcStride + (iMvX >> 2); pWelsMcFunc[iMvX & 0x03][iMvY & 0x03] (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight); } void McChroma_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, @@ -1248,7 +1248,7 @@ void McLuma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst {McHorVer20_AArch64_neon, McHorVer21_AArch64_neon, McHorVer22_AArch64_neon, McHorVer23_AArch64_neon}, {McHorVer30_AArch64_neon, McHorVer31_AArch64_neon, McHorVer32_AArch64_neon, McHorVer33_AArch64_neon}, }; - // pSrc += (iMvY >> 2) * iSrcStride + (iMvX >> 2); + // pSrc += (iMvY >> 2) * iSrcStride + (iMvX >> 2); pWelsMcFunc[iMvX & 0x03][iMvY & 0x03] (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight); } void McChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, diff --git a/codec/common/src/memory_align.cpp b/codec/common/src/memory_align.cpp index 96bd45d9..78d59a6a 100644 --- a/codec/common/src/memory_align.cpp +++ b/codec/common/src/memory_align.cpp @@ -49,9 +49,9 @@ CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize) #endif//MEMORY_MONITOR { if ((kuiCacheLineSize == 0) || (kuiCacheLineSize & 0x0f)) - m_nCacheLineSize = 0x10; + m_nCacheLineSize = 0x10; else - m_nCacheLineSize = kuiCacheLineSize; + m_nCacheLineSize = kuiCacheLineSize; } CMemoryAlign::~CMemoryAlign() { @@ -61,14 +61,14 @@ CMemoryAlign::~CMemoryAlign() { } void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAlign) { - const int32_t kiSizeOfVoidPointer = sizeof (void**); - const int32_t kiSizeOfInt = sizeof (int32_t); - const int32_t kiAlignedBytes = kiAlign - 1; - const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt; - const int32_t kiActualRequestedSize = kiTrialRequestedSize; - const uint32_t kiPayloadSize = kuiSize; + const int32_t kiSizeOfVoidPointer = sizeof (void**); + const int32_t kiSizeOfInt = sizeof (int32_t); + const int32_t kiAlignedBytes = kiAlign - 1; + const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt; + const int32_t kiActualRequestedSize = kiTrialRequestedSize; + const uint32_t kiPayloadSize = kuiSize; - uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize); + uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize); #ifdef MEMORY_CHECK if (fpMemChkPoint == NULL) { m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+"); diff --git a/codec/common/src/utils.cpp b/codec/common/src/utils.cpp index 086d5938..363cc698 100644 --- a/codec/common/src/utils.cpp +++ b/codec/common/src/utils.cpp @@ -38,7 +38,7 @@ ************************************************************************************* */ #include "utils.h" -#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms +#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms #include "codec_app_def.h" float WelsCalcPsnr (const void* kpTarPic, const int32_t kiTarStride, @@ -112,10 +112,10 @@ float WelsCalcPsnr (const void* kpTarPic, if (NULL == pTar || NULL == pRef) return (-1.0f); - for (y = 0; y < kiHeight; ++ y) { // OPTable !! + for (y = 0; y < kiHeight; ++ y) { // OPTable !! for (x = 0; x < kiWidth; ++ x) { const int32_t kiT = pTar[y * kiTarStride + x] - pRef[y * kiRefStride + x]; - iSqe += kiT * kiT; + iSqe += kiT * kiT; } } if (0 == iSqe) { diff --git a/codec/common/src/welsCodecTrace.cpp b/codec/common/src/welsCodecTrace.cpp index baac560c..b19e0a53 100644 --- a/codec/common/src/welsCodecTrace.cpp +++ b/codec/common/src/welsCodecTrace.cpp @@ -39,7 +39,7 @@ #include #include -#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms +#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms #include "welsCodecTrace.h" #include "utils.h" @@ -78,7 +78,7 @@ void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, v } char pBuf[MAX_LOG_SIZE] = {0}; - WelsVsnprintf (pBuf, MAX_LOG_SIZE, Str_Format, vl); // confirmed_safe_unsafe_usage + WelsVsnprintf (pBuf, MAX_LOG_SIZE, Str_Format, vl); // confirmed_safe_unsafe_usage if (m_fpTrace) { m_fpTrace (m_pTraceCtx, iLevel, pBuf); } @@ -90,7 +90,7 @@ void welsCodecTrace::SetCodecInstance (void* pCodecInstance) { void welsCodecTrace::SetTraceLevel (const int32_t iLevel) { if (iLevel >= 0) - m_iTraceLevel = iLevel; + m_iTraceLevel = iLevel; } void welsCodecTrace::SetTraceCallback (WelsTraceCallback func) { diff --git a/codec/console/common/inc/read_config.h b/codec/console/common/inc/read_config.h index e9fe6e0c..6ad529d5 100644 --- a/codec/console/common/inc/read_config.h +++ b/codec/console/common/inc/read_config.h @@ -59,10 +59,10 @@ class CReadConfig { const std::string& GetFileName(); private: - FILE* m_pCfgFile; - std::string m_strCfgFileName; - unsigned int m_iLines; + FILE* m_pCfgFile; + std::string m_strCfgFileName; + unsigned int m_iLines; }; -#endif // READ_CONFIG_H__ +#endif // READ_CONFIG_H__ diff --git a/codec/console/common/src/read_config.cpp b/codec/console/common/src/read_config.cpp index 3832cc97..2057bcc1 100644 --- a/codec/console/common/src/read_config.cpp +++ b/codec/console/common/src/read_config.cpp @@ -53,7 +53,7 @@ CReadConfig::CReadConfig (const char* kpConfigFileName) : m_pCfgFile (0) , m_strCfgFileName (kpConfigFileName) , m_iLines (0) { - if (strlen (kpConfigFileName) > 0) { // confirmed_safe_unsafe_usage + if (strlen (kpConfigFileName) > 0) { // confirmed_safe_unsafe_usage m_pCfgFile = fopen (kpConfigFileName, "r"); } } @@ -75,7 +75,7 @@ CReadConfig::~CReadConfig() { } void CReadConfig::Openf (const char* kpStrFile) { - if (kpStrFile != NULL && strlen (kpStrFile) > 0) { // confirmed_safe_unsafe_usage + if (kpStrFile != NULL && strlen (kpStrFile) > 0) { // confirmed_safe_unsafe_usage m_strCfgFileName = kpStrFile; m_pCfgFile = fopen (kpStrFile, "r"); } @@ -90,7 +90,7 @@ long CReadConfig::ReadLine (std::string* pVal, const int kiValSize/* = 4*/) { bool bCommentFlag = false; while (n < kiValSize) { - pVal[n] = ""; + pVal[n] = ""; ++ n; } @@ -109,7 +109,7 @@ long CReadConfig::ReadLine (std::string* pVal, const int kiValSize/* = 4*/) { break; if (! (*strTags).empty()) { ++ nTagNum; - strTags = &pVal[nTagNum]; + strTags = &pVal[nTagNum]; } } else *strTags += kCh; diff --git a/codec/console/dec/src/d3d9_utils.cpp b/codec/console/dec/src/d3d9_utils.cpp index 690273b5..43f59fed 100644 --- a/codec/console/dec/src/d3d9_utils.cpp +++ b/codec/console/dec/src/d3d9_utils.cpp @@ -465,18 +465,18 @@ HRESULT InitWindow (HWND* hWnd) { const TCHAR kszWindowClass[] = TEXT ("Wels Decoder Class"); WNDCLASSEX sWndClassEx = {0}; - sWndClassEx.cbSize = sizeof (WNDCLASSEX); - sWndClassEx.style = CS_HREDRAW | CS_VREDRAW; - sWndClassEx.lpfnWndProc = (WNDPROC)WndProc; - sWndClassEx.cbClsExtra = 0; - sWndClassEx.cbWndExtra = 0; - sWndClassEx.hInstance = GetModuleHandle (NULL); - sWndClassEx.hIcon = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_TESTSHARESURFACE); - sWndClassEx.hCursor = LoadCursor (NULL, IDC_ARROW); - sWndClassEx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); - sWndClassEx.lpszMenuName = (LPCSTR)IDC_TESTSHARESURFACE; - sWndClassEx.lpszClassName = kszWindowClass; - sWndClassEx.hIconSm = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_SMALL); + sWndClassEx.cbSize = sizeof (WNDCLASSEX); + sWndClassEx.style = CS_HREDRAW | CS_VREDRAW; + sWndClassEx.lpfnWndProc = (WNDPROC)WndProc; + sWndClassEx.cbClsExtra = 0; + sWndClassEx.cbWndExtra = 0; + sWndClassEx.hInstance = GetModuleHandle (NULL); + sWndClassEx.hIcon = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_TESTSHARESURFACE); + sWndClassEx.hCursor = LoadCursor (NULL, IDC_ARROW); + sWndClassEx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); + sWndClassEx.lpszMenuName = (LPCSTR)IDC_TESTSHARESURFACE; + sWndClassEx.lpszClassName = kszWindowClass; + sWndClassEx.hIconSm = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_SMALL); if (!RegisterClassEx (&sWndClassEx)) return E_FAIL; diff --git a/codec/console/dec/src/h264dec.cpp b/codec/console/dec/src/h264dec.cpp index 917b5673..267575ba 100644 --- a/codec/console/dec/src/h264dec.cpp +++ b/codec/console/dec/src/h264dec.cpp @@ -69,12 +69,12 @@ int g_iDecodedFrameNum = 0; #endif //using namespace WelsDec; -//#define NO_DELAY_DECODING // For Demo interfaces test with no delay decoding +//#define NO_DELAY_DECODING // For Demo interfaces test with no delay decoding void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName, int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName, const char* pLengthFileName) { - FILE* pH264File = NULL; - FILE* pYuvFile = NULL; + FILE* pH264File = NULL; + FILE* pYuvFile = NULL; FILE* pOptionFile = NULL; // Lenght input mode support FILE* fpTrack = NULL; @@ -129,7 +129,7 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons if (pYuvFile == NULL) { fprintf (stderr, "Can not open yuv file to output result of decoding..\n"); // any options - //return; // can let decoder work in quiet mode, no writing any output + //return; // can let decoder work in quiet mode, no writing any output } else fprintf (stderr, "Sequence output file name: %s..\n", kpOuputFileName); } else { @@ -237,8 +237,8 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons pDst[1] = pData[1]; pDst[2] = pData[2]; } - iEnd = WelsTime(); - iTotal += iEnd - iStart; + iEnd = WelsTime(); + iTotal += iEnd - iStart; if (sDstBufInfo.iBufferStatus == 1) { cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile); iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; @@ -269,8 +269,8 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons pDst[1] = pData[1]; pDst[2] = pData[2]; } - iEnd = WelsTime(); - iTotal += iEnd - iStart; + iEnd = WelsTime(); + iTotal += iEnd - iStart; if (sDstBufInfo.iBufferStatus == 1) { cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile); iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; @@ -362,26 +362,26 @@ int32_t main (int32_t iArgC, char* pArgV[]) { long nRd = cReadCfg.ReadLine (&strTag[0]); if (nRd > 0) { if (strTag[0].compare ("InputFile") == 0) { - strInputFile = strTag[1]; + strInputFile = strTag[1]; } else if (strTag[0].compare ("OutputFile") == 0) { - strOutputFile = strTag[1]; + strOutputFile = strTag[1]; } else if (strTag[0].compare ("RestructionFile") == 0) { - strReconFile = strTag[1]; + strReconFile = strTag[1]; int32_t iLen = (int32_t)strReconFile.length(); - sDecParam.pFileNameRestructed = new char[iLen + 1]; + sDecParam.pFileNameRestructed = new char[iLen + 1]; if (sDecParam.pFileNameRestructed != NULL) { sDecParam.pFileNameRestructed[iLen] = 0; } strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage } else if (strTag[0].compare ("TargetDQID") == 0) { - sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str()); + sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("OutColorFormat") == 0) { sDecParam.eOutputColorFormat = (EVideoFormatType) atoi (strTag[1].c_str()); } else if (strTag[0].compare ("ErrorConcealmentIdc") == 0) { sDecParam.eEcActiveIdc = (ERROR_CON_IDC)atol (strTag[1].c_str()); } else if (strTag[0].compare ("CPULoad") == 0) { - sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str()); + sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("VideoBitstreamType") == 0) { sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str()); } @@ -393,17 +393,17 @@ int32_t main (int32_t iArgC, char* pArgV[]) { } } else if (strstr (pArgV[1], ".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage - strInputFile = pArgV[1]; - sDecParam.eOutputColorFormat = videoFormatI420; - sDecParam.uiTargetDqLayer = (uint8_t) - 1; + strInputFile = pArgV[1]; + sDecParam.eOutputColorFormat = videoFormatI420; + sDecParam.uiTargetDqLayer = (uint8_t) - 1; sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; } } else { //iArgC > 2 - strInputFile = pArgV[1]; - strOutputFile = pArgV[2]; - sDecParam.eOutputColorFormat = videoFormatI420; - sDecParam.uiTargetDqLayer = (uint8_t) - 1; + strInputFile = pArgV[1]; + strOutputFile = pArgV[2]; + sDecParam.eOutputColorFormat = videoFormatI420; + sDecParam.uiTargetDqLayer = (uint8_t) - 1; sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; if (iArgC > 3) { diff --git a/codec/console/enc/src/welsenc.cpp b/codec/console/enc/src/welsenc.cpp index 345fd262..2ac8688c 100644 --- a/codec/console/enc/src/welsenc.cpp +++ b/codec/console/enc/src/welsenc.cpp @@ -42,7 +42,7 @@ #ifdef ONLY_ENC_FRAMES_NUM #undef ONLY_ENC_FRAMES_NUM #endif//ONLY_ENC_FRAMES_NUM -#define ONLY_ENC_FRAMES_NUM INT_MAX // 2, INT_MAX // type the num you try to encode here, 2, 10, etc +#define ONLY_ENC_FRAMES_NUM INT_MAX // 2, INT_MAX // type the num you try to encode here, 2, 10, etc #if defined (WINDOWS_PHONE) float g_fFPS = 0.0; @@ -96,8 +96,8 @@ using namespace WelsEnc; * Layer Context */ typedef struct LayerpEncCtx_s { - int32_t iDLayerQp; - SSliceConfig sSliceCfg; + int32_t iDLayerQp; + SSliceConfig sSliceCfg; } SLayerPEncCtx; typedef struct tagFilesSet { @@ -138,9 +138,9 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt& if (strTag[0].empty()) continue; if (strTag[0].compare ("FrameWidth") == 0) { - pDLayer->iVideoWidth = atoi (strTag[1].c_str()); + pDLayer->iVideoWidth = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("FrameHeight") == 0) { - pDLayer->iVideoHeight = atoi (strTag[1].c_str()); + 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) { @@ -148,13 +148,13 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt& 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 + strncpy (sFileSet.sRecFileName[iLayer], strTag[1].c_str(), kiLen); // confirmed_safe_unsafe_usage } else if (strTag[0].compare ("ProfileIdc") == 0) { - pDLayer->uiProfileIdc = (EProfileIdc)atoi (strTag[1].c_str()); + pDLayer->uiProfileIdc = (EProfileIdc)atoi (strTag[1].c_str()); } else if (strTag[0].compare ("FRExt") == 0) { - // pDLayer->frext_mode = (bool)atoi(strTag[1].c_str()); +// pDLayer->frext_mode = (bool)atoi(strTag[1].c_str()); } else if (strTag[0].compare ("SpatialBitrate") == 0) { - pDLayer->iSpatialBitrate = 1000 * atoi (strTag[1].c_str()); + pDLayer->iSpatialBitrate = 1000 * atoi (strTag[1].c_str()); if (pSvcParam.iRCMode != RC_OFF_MODE) { if (pDLayer->iSpatialBitrate <= 0) { fprintf (stderr, "Invalid spatial bitrate(%d) in dependency layer #%d.\n", pDLayer->iSpatialBitrate, iLayer); @@ -181,11 +181,11 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt& } } } else if (strTag[0].compare ("InitialQP") == 0) { - sLayerCtx.iDLayerQp = atoi (strTag[1].c_str()); + sLayerCtx.iDLayerQp = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("SliceMode") == 0) { - sLayerCtx.sSliceCfg.uiSliceMode = (SliceModeEnum)atoi (strTag[1].c_str()); + sLayerCtx.sSliceCfg.uiSliceMode = (SliceModeEnum)atoi (strTag[1].c_str()); } else if (strTag[0].compare ("SliceSize") == 0) { //SM_DYN_SLICE - sLayerCtx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (strTag[1].c_str()); + sLayerCtx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (strTag[1].c_str()); continue; } else if (strTag[0].compare ("SliceNum") == 0) { sLayerCtx.sSliceCfg.sSliceArgument.uiSliceNum = atoi (strTag[1].c_str()); @@ -197,12 +197,12 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt& } } } - pDLayer->iDLayerQp = sLayerCtx.iDLayerQp; - pDLayer->sSliceCfg.uiSliceMode = sLayerCtx.sSliceCfg.uiSliceMode; + pDLayer->iDLayerQp = sLayerCtx.iDLayerQp; + pDLayer->sSliceCfg.uiSliceMode = sLayerCtx.sSliceCfg.uiSliceMode; - memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage + memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage memcpy (&pDLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[0], - sizeof (sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage + sizeof (sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage return 0; } @@ -225,21 +225,21 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv pSrcPic->iPicHeight = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("InputFile") == 0) { if (strTag[1].length() > 0) - sFileSet.strSeqFile = strTag[1]; + sFileSet.strSeqFile = strTag[1]; } else if (strTag[0].compare ("OutputFile") == 0) { - sFileSet.strBsFile = strTag[1]; + sFileSet.strBsFile = strTag[1]; } else if (strTag[0].compare ("MaxFrameRate") == 0) { - pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str()); + pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str()); } else if (strTag[0].compare ("FramesToBeEncoded") == 0) { - sFileSet.uiFrameToBeCoded = atoi (strTag[1].c_str()); + sFileSet.uiFrameToBeCoded = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("TemporalLayerNum") == 0) { - pSvcParam.iTemporalLayerNum = atoi (strTag[1].c_str()); + pSvcParam.iTemporalLayerNum = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("IntraPeriod") == 0) { - pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str()); + pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("MaxNalSize") == 0) { pSvcParam.uiMaxNalSize = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("SpsPpsIDStrategy") == 0) { - int32_t iValue = atoi (strTag[1].c_str()); + int32_t iValue = atoi (strTag[1].c_str()); switch (iValue) { case 0: pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID; @@ -261,71 +261,71 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv break; } } else if (strTag[0].compare ("EnableScalableSEI") == 0) { - pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("EnableFrameCropping") == 0) { pSvcParam.bEnableFrameCroppingFlag = (atoi (strTag[1].c_str()) != 0); } else if (strTag[0].compare ("EntropyCodingModeFlag") == 0) { pSvcParam.iEntropyCodingModeFlag = (atoi (strTag[1].c_str()) != 0); } else if (strTag[0].compare ("LoopFilterDisableIDC") == 0) { - pSvcParam.iLoopFilterDisableIdc = (int8_t)atoi (strTag[1].c_str()); + pSvcParam.iLoopFilterDisableIdc = (int8_t)atoi (strTag[1].c_str()); if (pSvcParam.iLoopFilterDisableIdc > 6 || pSvcParam.iLoopFilterDisableIdc < 0) { fprintf (stderr, "Invalid parameter in iLoopFilterDisableIdc: %d.\n", pSvcParam.iLoopFilterDisableIdc); iRet = 1; break; } } else if (strTag[0].compare ("LoopFilterAlphaC0Offset") == 0) { - pSvcParam.iLoopFilterAlphaC0Offset = (int8_t)atoi (strTag[1].c_str()); + pSvcParam.iLoopFilterAlphaC0Offset = (int8_t)atoi (strTag[1].c_str()); if (pSvcParam.iLoopFilterAlphaC0Offset < -6) - pSvcParam.iLoopFilterAlphaC0Offset = -6; + pSvcParam.iLoopFilterAlphaC0Offset = -6; else if (pSvcParam.iLoopFilterAlphaC0Offset > 6) - pSvcParam.iLoopFilterAlphaC0Offset = 6; + pSvcParam.iLoopFilterAlphaC0Offset = 6; } else if (strTag[0].compare ("LoopFilterBetaOffset") == 0) { - pSvcParam.iLoopFilterBetaOffset = (int8_t)atoi (strTag[1].c_str()); + pSvcParam.iLoopFilterBetaOffset = (int8_t)atoi (strTag[1].c_str()); if (pSvcParam.iLoopFilterBetaOffset < -6) - pSvcParam.iLoopFilterBetaOffset = -6; + pSvcParam.iLoopFilterBetaOffset = -6; else if (pSvcParam.iLoopFilterBetaOffset > 6) - pSvcParam.iLoopFilterBetaOffset = 6; + pSvcParam.iLoopFilterBetaOffset = 6; } else if (strTag[0].compare ("MultipleThreadIdc") == 0) { // # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads; - pSvcParam.iMultipleThreadIdc = atoi (strTag[1].c_str()); + pSvcParam.iMultipleThreadIdc = atoi (strTag[1].c_str()); if (pSvcParam.iMultipleThreadIdc < 0) pSvcParam.iMultipleThreadIdc = 0; else if (pSvcParam.iMultipleThreadIdc > MAX_THREADS_NUM) pSvcParam.iMultipleThreadIdc = MAX_THREADS_NUM; } else if (strTag[0].compare ("RCMode") == 0) { - pSvcParam.iRCMode = (RC_MODES) atoi (strTag[1].c_str()); + pSvcParam.iRCMode = (RC_MODES) atoi (strTag[1].c_str()); } else if (strTag[0].compare ("TargetBitrate") == 0) { - pSvcParam.iTargetBitrate = 1000 * atoi (strTag[1].c_str()); + pSvcParam.iTargetBitrate = 1000 * atoi (strTag[1].c_str()); 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; } } else if (strTag[0].compare ("MaxOverallBitrate") == 0) { - pSvcParam.iMaxBitrate = 1000 * atoi (strTag[1].c_str()); + pSvcParam.iMaxBitrate = 1000 * atoi (strTag[1].c_str()); if ((pSvcParam.iRCMode != RC_OFF_MODE) && pSvcParam.iMaxBitrate < 0) { fprintf (stderr, "Invalid max overall bitrate setting due to RC enabled. Check MaxOverallBitrate field please!\n"); return 1; } } else if (strTag[0].compare ("EnableDenoise") == 0) { - pSvcParam.bEnableDenoise = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableDenoise = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("EnableSceneChangeDetection") == 0) { - pSvcParam.bEnableSceneChangeDetect = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableSceneChangeDetect = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("EnableBackgroundDetection") == 0) { - pSvcParam.bEnableBackgroundDetection = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableBackgroundDetection = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("EnableAdaptiveQuantization") == 0) { - pSvcParam.bEnableAdaptiveQuant = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableAdaptiveQuant = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("EnableFrameSkip") == 0) { - pSvcParam.bEnableFrameSkip = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableFrameSkip = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("EnableLongTermReference") == 0) { - pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("LongTermReferenceNumber") == 0) { pSvcParam.iLTRRefNum = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("LtrMarkPeriod") == 0) { - pSvcParam.iLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str()); + pSvcParam.iLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str()); } else if (strTag[0].compare ("LosslessLink") == 0) { - pSvcParam.bIsLosslessLink = atoi (strTag[1].c_str()) ? true : false; + pSvcParam.bIsLosslessLink = atoi (strTag[1].c_str()) ? true : false; } else if (strTag[0].compare ("NumLayers") == 0) { - pSvcParam.iSpatialLayerNum = (int8_t)atoi (strTag[1].c_str()); + pSvcParam.iSpatialLayerNum = (int8_t)atoi (strTag[1].c_str()); if (pSvcParam.iSpatialLayerNum > MAX_DEPENDENCY_LAYER || pSvcParam.iSpatialLayerNum <= 0) { fprintf (stderr, "Invalid parameter in iSpatialLayerNum: %d.\n", pSvcParam.iSpatialLayerNum); iRet = 1; @@ -333,24 +333,24 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv } } else if (strTag[0].compare ("LayerCfg") == 0) { if (strTag[1].length() > 0) - sFileSet.strLayerCfgFile[iLayerCount] = strTag[1]; -// pSvcParam.sDependencyLayers[iLayerCount].uiDependencyId = iLayerCount; + sFileSet.strLayerCfgFile[iLayerCount] = strTag[1]; +// pSvcParam.sDependencyLayers[iLayerCount].uiDependencyId = iLayerCount; ++ iLayerCount; } else if (strTag[0].compare ("PrefixNALAddingCtrl") == 0) { int ctrl_flag = atoi (strTag[1].c_str()); if (ctrl_flag > 1) - ctrl_flag = 1; + ctrl_flag = 1; else if (ctrl_flag < 0) - ctrl_flag = 0; - pSvcParam.bPrefixNalAddingCtrl = ctrl_flag ? true : false; + ctrl_flag = 0; + pSvcParam.bPrefixNalAddingCtrl = ctrl_flag ? true : false; } } } const int8_t kiActualLayerNum = WELS_MIN (pSvcParam.iSpatialLayerNum, iLayerCount); if (pSvcParam.iSpatialLayerNum > - kiActualLayerNum) { // fixed number of dependency layer due to parameter error in settings - pSvcParam.iSpatialLayerNum = kiActualLayerNum; + kiActualLayerNum) { // fixed number of dependency layer due to parameter error in settings + pSvcParam.iSpatialLayerNum = kiActualLayerNum; } assert (kiActualLayerNum <= MAX_DEPENDENCY_LAYER); @@ -527,58 +527,58 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE else if (!strcmp (pCommand, "-numl") && (n < argc)) { pSvcParam.iSpatialLayerNum = atoi (argv[n++]); } else if (!strcmp (pCommand, "-lconfig") && (n < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); sFileSet.strLayerCfgFile[iLayer].assign (argv[n++]); CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]); if (-1 == ParseLayerConfig (cRdLayerCfg, iLayer, pSvcParam, sFileSet)) { return 1; } } else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); const unsigned int iLen = (int) strlen (argv[n]); if (iLen >= sizeof (sFileSet.sRecFileName[iLayer])) return 1; sFileSet.sRecFileName[iLayer][iLen] = '\0'; - strncpy (sFileSet.sRecFileName[iLayer], argv[n++], iLen); // confirmed_safe_unsafe_usage + strncpy (sFileSet.sRecFileName[iLayer], argv[n++], iLen); // confirmed_safe_unsafe_usage } else if (!strcmp (pCommand, "-dw") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; - pDLayer->iVideoWidth = atoi (argv[n++]); + pDLayer->iVideoWidth = atoi (argv[n++]); } else if (!strcmp (pCommand, "-dh") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; - pDLayer->iVideoHeight = atoi (argv[n++]); + pDLayer->iVideoHeight = atoi (argv[n++]); } else if (!strcmp (pCommand, "-frout") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; pDLayer->fFrameRate = (float)atof (argv[n++]); } else if (!strcmp (pCommand, "-lqp") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; pDLayer->iDLayerQp = sLayerCtx[iLayer].iDLayerQp = atoi (argv[n++]); } //sLayerCtx[iLayer].num_quality_layers = pDLayer->num_quality_layers = 1; else if (!strcmp (pCommand, "-ltarb") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; - pDLayer->iSpatialBitrate = 1000 * atoi (argv[n++]); + pDLayer->iSpatialBitrate = 1000 * atoi (argv[n++]); } else if (!strcmp (pCommand, "-lmaxb") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; - pDLayer->iMaxSpatialBitrate = 1000 * atoi (argv[n++]); + pDLayer->iMaxSpatialBitrate = 1000 * atoi (argv[n++]); } else if (!strcmp (pCommand, "-slcmd") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; switch (atoi (argv[n++])) { @@ -607,13 +607,13 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE } else if (!strcmp (pCommand, "-slcsize") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; pDLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (argv[n++]); } else if (!strcmp (pCommand, "-slcnum") && (n + 1 < argc)) { - unsigned int iLayer = atoi (argv[n++]); + unsigned int iLayer = atoi (argv[n++]); SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer]; pDLayer->sSliceCfg.sSliceArgument.uiSliceNum = atoi (argv[n++]); } @@ -626,59 +626,59 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE int FillSpecificParameters (SEncParamExt& sParam) { /* Test for temporal, spatial, SNR scalability */ sParam.iUsageType = CAMERA_VIDEO_REAL_TIME; - sParam.fMaxFrameRate = 60.0f; // input frame rate - sParam.iPicWidth = 1280; // width of picture in samples - sParam.iPicHeight = 720; // height of picture in samples - sParam.iTargetBitrate = 2500000; // target bitrate desired + sParam.fMaxFrameRate = 60.0f; // input frame rate + sParam.iPicWidth = 1280; // width of picture in samples + sParam.iPicHeight = 720; // height of picture in samples + sParam.iTargetBitrate = 2500000; // target bitrate desired sParam.iMaxBitrate = UNSPECIFIED_BIT_RATE; - sParam.iRCMode = RC_QUALITY_MODE; // rc mode control - sParam.iTemporalLayerNum = 3; // layer number at temporal level - sParam.iSpatialLayerNum = 4; // layer number at spatial level + sParam.iRCMode = RC_QUALITY_MODE; // rc mode control + sParam.iTemporalLayerNum = 3; // layer number at temporal level + sParam.iSpatialLayerNum = 4; // layer number at spatial level sParam.bEnableDenoise = 0; // denoise control sParam.bEnableBackgroundDetection = 1; // background detection control sParam.bEnableAdaptiveQuant = 1; // adaptive quantization control sParam.bEnableFrameSkip = 1; // frame skipping - sParam.bEnableLongTermReference = 0; // long term reference control + sParam.bEnableLongTermReference = 0; // long term reference control sParam.iLtrMarkPeriod = 30; - sParam.uiIntraPeriod = 320; // period of Intra frame + sParam.uiIntraPeriod = 320; // period of Intra frame sParam.eSpsPpsIdStrategy = INCREASING_ID; sParam.bPrefixNalAddingCtrl = 0; sParam.iComplexityMode = MEDIUM_COMPLEXITY; int iIndexLayer = 0; - sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_BASELINE; - sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 160; - sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 90; - sParam.sSpatialLayers[iIndexLayer].fFrameRate = 7.5f; - sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 64000; - sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; + sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_BASELINE; + sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 160; + sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 90; + sParam.sSpatialLayers[iIndexLayer].fFrameRate = 7.5f; + sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 64000; + sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; ++ iIndexLayer; - sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; - sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 320; - sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 180; - sParam.sSpatialLayers[iIndexLayer].fFrameRate = 15.0f; - sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 160000; - sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; + sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; + sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 320; + sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 180; + sParam.sSpatialLayers[iIndexLayer].fFrameRate = 15.0f; + sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 160000; + sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; ++ iIndexLayer; - sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; - sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 640; - sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 360; - sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f; - sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 512000; - sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; + sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; + sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 640; + sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 360; + sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f; + sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 512000; + sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1; ++ iIndexLayer; - sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; - sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 1280; - sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 720; - sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f; - sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 1500000; - sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; + sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; + sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 1280; + sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 720; + sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f; + sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 1500000; + sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1; @@ -693,7 +693,7 @@ int FillSpecificParameters (SEncParamExt& sParam) { } int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFile) { - int iRet = 0; + int iRet = 0; if (pPtrEnc == NULL) return 1; @@ -794,7 +794,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi iTotalFrameMax = (int32_t)fs.uiFrameToBeCoded; - if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) { // SVC encoder initialization + if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) { // SVC encoder initialization fprintf (stderr, "SVC encoder Initialize failed\n"); iRet = 1; goto INSIDE_MEM_FREE; @@ -860,7 +860,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi if (!bCanBeRead) break; // To encoder this frame - iStart = WelsTime(); + iStart = WelsTime(); pSrcPic->uiTimeStamp = WELS_ROUND (iFrameIdx * (1000 / sSvcParam.fMaxFrameRate)); int iEncFrames = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); iTotal += WelsTime() - iStart; @@ -900,7 +900,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi delete [] pUCArry; } #endif - fwrite (pLayerBsInfo->pBsBuf, 1, iLayerSize, pFpBs); // write pure bit stream into file + fwrite (pLayerBsInfo->pBsBuf, 1, iLayerSize, pFpBs); // write pure bit stream into file iFrameSize += iLayerSize; } ++ iLayer; @@ -910,7 +910,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi fwrite (&iFrameSize, 1, sizeof (int), fTrackStream); } #endif//STICK_STREAM_SIZE - ++ iActualFrameEncodedCount; // excluding skipped frame time + ++ iActualFrameEncodedCount; // excluding skipped frame time } else { fprintf (stderr, "EncodeFrame(), ret: %d, frame index: %d.\n", iEncFrames, iFrameIdx); } @@ -1008,8 +1008,8 @@ extern "C" int EncMain (int argc, char** argv) int main (int argc, char** argv) #endif { - ISVCEncoder* pSVCEncoder = NULL; - int iRet = 0; + ISVCEncoder* pSVCEncoder = NULL; + int iRet = 0; #ifdef _MSC_VER _setmode (_fileno (stdin), _O_BINARY); /* thanks to Marcoss Morais */ diff --git a/codec/decoder/core/inc/au_parser.h b/codec/decoder/core/inc/au_parser.h index 51a83b0a..726c129b 100644 --- a/codec/decoder/core/inc/au_parser.h +++ b/codec/decoder/core/inc/au_parser.h @@ -159,7 +159,7 @@ int32_t ParseScalingList(PSps pSps,PBitStringAux pBs,bool bPPS,bool *bScalingLis * \note Call it in case eNalUnitType is NAL_UNIT_SEI. ************************************************************************************* */ -int32_t ParseSei (void* pSei, PBitStringAux pBsAux); // reserved Sei_Msg type +int32_t ParseSei (void* pSei, PBitStringAux pBsAux); // reserved Sei_Msg type /*! ************************************************************************************* diff --git a/codec/decoder/core/inc/bit_stream.h b/codec/decoder/core/inc/bit_stream.h index 9b188063..8490a645 100644 --- a/codec/decoder/core/inc/bit_stream.h +++ b/codec/decoder/core/inc/bit_stream.h @@ -30,7 +30,7 @@ * */ -//bit_stream.h - bit-stream reading and / writing auxiliary data +//bit_stream.h - bit-stream reading and / writing auxiliary data #ifndef WELS_BIT_STREAM_H__ #define WELS_BIT_STREAM_H__ diff --git a/codec/decoder/core/inc/dec_frame.h b/codec/decoder/core/inc/dec_frame.h index 713d9427..5edbe295 100644 --- a/codec/decoder/core/inc/dec_frame.h +++ b/codec/decoder/core/inc/dec_frame.h @@ -47,31 +47,31 @@ namespace WelsDec { ///////////////////////////////////DQ Layer level/////////////////////////////////// -typedef struct TagDqLayer SDqLayer; -typedef SDqLayer* PDqLayer; +typedef struct TagDqLayer SDqLayer; +typedef SDqLayer* PDqLayer; typedef struct TagLayerInfo { - SNalUnitHeaderExt sNalHeaderExt; - SSlice sSliceInLayer; // Here Slice identify to Frame on concept - PSubsetSps pSubsetSps; // current pSubsetSps used, memory alloc in external - PSps pSps; // current sps based avc used, memory alloc in external - PPps pPps; // current pps used + SNalUnitHeaderExt sNalHeaderExt; + SSlice sSliceInLayer; // Here Slice identify to Frame on concept + PSubsetSps pSubsetSps; // current pSubsetSps used, memory alloc in external + PSps pSps; // current sps based avc used, memory alloc in external + PPps pPps; // current pps used } SLayerInfo, *PLayerInfo; /* Layer Representation */ struct TagDqLayer { - SLayerInfo sLayerInfo; + SLayerInfo sLayerInfo; - PBitStringAux pBitStringAux; // pointer to SBitStringAux - PFmo pFmo; // Current fmo context pointer used - int16_t* pMbType; - int32_t* pSliceIdc; // using int32_t for slice_idc - int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; - int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; - int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM]; + PBitStringAux pBitStringAux; // pointer to SBitStringAux + PFmo pFmo; // Current fmo context pointer used + int16_t* pMbType; + int32_t* pSliceIdc; // using int32_t for slice_idc + int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; + int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; + int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM]; bool* pNoSubMbPartSizeLessThan8x8Flag; bool* pTransformSize8x8Flag; int8_t* pLumaQp; - int8_t (*pChromaQp)[2]; + int8_t (*pChromaQp)[2]; int8_t* pCbp; uint16_t *pCbfDc; int8_t (*pNzc)[24]; @@ -93,53 +93,53 @@ struct TagDqLayer { int32_t iMbX; int32_t iMbY; int32_t iMbXyIndex; - int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth - int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight; + int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth + int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight; /* Common syntax elements across all slices of a DQLayer */ - int32_t iSliceIdcBackup; - uint32_t uiSpsId; - uint32_t uiPpsId; - uint32_t uiDisableInterLayerDeblockingFilterIdc; - int32_t iInterLayerSliceAlphaC0Offset; - int32_t iInterLayerSliceBetaOffset; - //SPosOffset sScaledRefLayer; - int32_t iSliceGroupChangeCycle; + int32_t iSliceIdcBackup; + uint32_t uiSpsId; + uint32_t uiPpsId; + uint32_t uiDisableInterLayerDeblockingFilterIdc; + int32_t iInterLayerSliceAlphaC0Offset; + int32_t iInterLayerSliceBetaOffset; + //SPosOffset sScaledRefLayer; + int32_t iSliceGroupChangeCycle; - PRefPicListReorderSyn pRefPicListReordering; - PPredWeightTabSyn pPredWeightTable; - PRefPicMarking pRefPicMarking; // Decoded reference picture marking syntaxs - PRefBasePicMarking pRefPicBaseMarking; + PRefPicListReorderSyn pRefPicListReordering; + PPredWeightTabSyn pPredWeightTable; + PRefPicMarking pRefPicMarking; // Decoded reference picture marking syntaxs + PRefBasePicMarking pRefPicBaseMarking; - PPicture pRef; // reference picture pointer - PPicture pDec; // reconstruction picture pointer for layer + PPicture pRef; // reference picture pointer + PPicture pDec; // reconstruction picture pointer for layer - bool bUseWeightPredictionFlag; - bool bStoreRefBasePicFlag; // iCurTid == 0 && iCurQid = 0 && bEncodeKeyPic = 1 - bool bTCoeffLevelPredFlag; - bool bConstrainedIntraResamplingFlag; - uint8_t uiRefLayerDqId; - uint8_t uiRefLayerChromaPhaseXPlus1Flag; - uint8_t uiRefLayerChromaPhaseYPlus1; - uint8_t uiLayerDqId; // dq_id of current layer - bool bUseRefBasePicFlag; // whether reference pic or reference base pic is referred? + bool bUseWeightPredictionFlag; + bool bStoreRefBasePicFlag; // iCurTid == 0 && iCurQid = 0 && bEncodeKeyPic = 1 + bool bTCoeffLevelPredFlag; + bool bConstrainedIntraResamplingFlag; + uint8_t uiRefLayerDqId; + uint8_t uiRefLayerChromaPhaseXPlus1Flag; + uint8_t uiRefLayerChromaPhaseYPlus1; + uint8_t uiLayerDqId; // dq_id of current layer + bool bUseRefBasePicFlag; // whether reference pic or reference base pic is referred? }; typedef struct TagGpuAvcLayer { - SLayerInfo sLayerInfo; - PBitStringAux pBitStringAux; // pointer to SBitStringAux + SLayerInfo sLayerInfo; + PBitStringAux pBitStringAux; // pointer to SBitStringAux - int16_t* pMbType; - int32_t* pSliceIdc; // using int32_t for slice_idc - int8_t* pLumaQp; - int8_t* pCbp; - int8_t (*pNzc)[24]; - int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 - int32_t iMbX; - int32_t iMbY; - int32_t iMbXyIndex; - int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth - int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight; + int16_t* pMbType; + int32_t* pSliceIdc; // using int32_t for slice_idc + int8_t* pLumaQp; + int8_t* pCbp; + int8_t (*pNzc)[24]; + int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 + int32_t iMbX; + int32_t iMbY; + int32_t iMbXyIndex; + int32_t iMbWidth; // MB width of this picture, equal to sSps.iMbWidth + int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight; } SGpuAvcDqLayer, *PGpuAvcDqLayer; diff --git a/codec/decoder/core/inc/decoder_context.h b/codec/decoder/core/inc/decoder_context.h index c777b5d0..b00da1c5 100644 --- a/codec/decoder/core/inc/decoder_context.h +++ b/codec/decoder/core/inc/decoder_context.h @@ -142,13 +142,13 @@ typedef void (*PGetIntraPred8x8Func) (uint8_t* pPred, const int32_t kiLumaStride /**/ typedef struct TagRefPic { - PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme - PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT]; - PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT]; - uint8_t uiRefCount[LIST_A]; - uint8_t uiShortRefCount[LIST_A]; - uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module - int32_t iMaxLongTermFrameIdx; + PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme + PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT]; + PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT]; + uint8_t uiRefCount[LIST_A]; + uint8_t uiShortRefCount[LIST_A]; + uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module + int32_t iMaxLongTermFrameIdx; } SRefPic, *PRefPic; typedef void (*PCopyFunc) (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS); @@ -161,11 +161,11 @@ typedef struct TagCopyFunc { struct TagDeblockingFunc; typedef struct tagDeblockingFilter { - uint8_t* pCsData[3]; // pointer to reconstructed picture data - int32_t iCsStride[2]; // Cs stride + uint8_t* pCsData[3]; // pointer to reconstructed picture data + int32_t iCsStride[2]; // Cs stride EWelsSliceType eSliceType; - int8_t iSliceAlphaC0Offset; - int8_t iSliceBetaOffset; + int8_t iSliceAlphaC0Offset; + int8_t iSliceBetaOffset; int8_t iChromaQP[2]; int8_t iLumaQP; struct TagDeblockingFunc* pLoopf; @@ -205,9 +205,9 @@ typedef struct TagDeblockingFunc { typedef void (*PWelsNonZeroCountFunc) (int8_t* pNonZeroCount); typedef void (*PWelsBlockZeroFunc) (int16_t* block, int32_t stride); typedef struct TagBlockFunc { - PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc; - PWelsBlockZeroFunc pWelsBlockZero16x16Func; - PWelsBlockZeroFunc pWelsBlockZero8x8Func; + PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc; + PWelsBlockZeroFunc pWelsBlockZero16x16Func; + PWelsBlockZeroFunc pWelsBlockZero8x8Func; } SBlockFunc; typedef void (*PWelsFillNeighborMbInfoIntra4x4Func) (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, @@ -232,62 +232,62 @@ enum { typedef struct TagWelsDecoderContext { SLogContext sLogCtx; // Input - void* pArgDec; // structured arguments for decoder, reserved here for extension in the future + void* pArgDec; // structured arguments for decoder, reserved here for extension in the future - SDataBuffer sRawData; - SDataBuffer sSavedData; //for parse only purpose + SDataBuffer sRawData; + SDataBuffer sSavedData; //for parse only purpose // Configuration - SDecodingParam* pParam; - uint32_t uiCpuFlag; // CPU compatibility detected + SDecodingParam* pParam; + uint32_t uiCpuFlag; // CPU compatibility detected - EVideoFormatType eOutputColorFormat; // color space format to be outputed + EVideoFormatType eOutputColorFormat; // color space format to be outputed VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection. - bool bHaveGotMemory; // global memory for decoder context related ever requested? + bool bHaveGotMemory; // global memory for decoder context related ever requested? - int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output - int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output - int32_t iLastImgWidthInPixel; // width of image in last successful pixel reconstruction picture to be output - int32_t iLastImgHeightInPixel;// height of image in last successful pixel reconstruction picture to be output + int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output + int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output + int32_t iLastImgWidthInPixel; // width of image in last successful pixel reconstruction picture to be output + int32_t iLastImgHeightInPixel;// height of image in last successful pixel reconstruction picture to be output bool bFreezeOutput; // indicating current frame freezing. Default: true // Derived common elements - SNalUnitHeader sCurNalHead; - EWelsSliceType eSliceType; // Slice type - int32_t iFrameNum; - int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet - bool bLastHasMmco5; // - int32_t iErrorCode; // error code return while decoding in case packets lost - SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage - PFmo pFmo; // current fmo context after parsed slice_header - int32_t iActiveFmoNum; // active count number of fmo context in list + SNalUnitHeader sCurNalHead; + EWelsSliceType eSliceType; // Slice type + int32_t iFrameNum; + int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet + bool bLastHasMmco5; // + int32_t iErrorCode; // error code return while decoding in case packets lost + SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage + PFmo pFmo; // current fmo context after parsed slice_header + int32_t iActiveFmoNum; // active count number of fmo context in list /*needed info by decode slice level and mb level*/ int32_t - iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time. + iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time. struct { int16_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */ - int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] - int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM]; + int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] + int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM]; bool* pNoSubMbPartSizeLessThan8x8Flag[LAYER_NUM_EXCHANGEABLE]; bool* pTransformSize8x8Flag[LAYER_NUM_EXCHANGEABLE]; - int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/ - int8_t (*pChromaQp[LAYER_NUM_EXCHANGEABLE])[2]; /*mb chroma_qp*/ - int16_t (*pMvd[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] + int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/ + int8_t (*pChromaQp[LAYER_NUM_EXCHANGEABLE])[2]; /*mb chroma_qp*/ + int16_t (*pMvd[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] uint16_t* pCbfDc[LAYER_NUM_EXCHANGEABLE]; - int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24]; - int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24]; + int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24]; + int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24]; int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/ - int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 + int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM]; - uint8_t* pIntraNxNAvailFlag[LAYER_NUM_EXCHANGEABLE]; + uint8_t* pIntraNxNAvailFlag[LAYER_NUM_EXCHANGEABLE]; int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE]; int8_t* pCbp[LAYER_NUM_EXCHANGEABLE]; uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8 int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE]; - int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc + int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc int8_t* pResidualPredFlag[LAYER_NUM_EXCHANGEABLE]; int8_t* pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE]; bool* pMbCorrectlyDecodedFlag[LAYER_NUM_EXCHANGEABLE]; @@ -297,78 +297,77 @@ typedef struct TagWelsDecoderContext { } sMb; // reconstruction picture - PPicture pDec; //pointer to current picture being reconstructed + PPicture pDec; //pointer to current picture being reconstructed // reference pictures - SRefPic sRefPic; + SRefPic sRefPic; - SVlcTable sVlcTable; // vlc table + SVlcTable sVlcTable; // vlc table - SBitStringAux sBs; + SBitStringAux sBs; int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer /* Global memory external */ - SPosOffset sFrameCrop; + SPosOffset sFrameCrop; - SSps sSpsBuffer[MAX_SPS_COUNT + 1]; - SPps sPpsBuffer[MAX_PPS_COUNT + 1]; - PSliceHeader pSliceHeader; + SSps sSpsBuffer[MAX_SPS_COUNT + 1]; + SPps sPpsBuffer[MAX_PPS_COUNT + 1]; + PSliceHeader pSliceHeader; - PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding. - int32_t iPicQueueNumber; + PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding. + int32_t iPicQueueNumber; - SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1]; - SNalUnit sPrefixNal; + SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1]; + SNalUnit sPrefixNal; - PAccessUnit pAccessUnitList; // current access unit list to be performed - PSps pActiveLayerSps[MAX_LAYER_NUM]; - PSps pSps; // used by current AU - PPps pPps; // used by current AU + PAccessUnit pAccessUnitList; // current access unit list to be performed + PSps pActiveLayerSps[MAX_LAYER_NUM]; + PSps pSps; // used by current AU + PPps pPps; // used by current AU // Memory for pAccessUnitList is dynamically held till decoder destruction. - PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable - PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated + PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable + PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated - int32_t iPicWidthReq; // picture width have requested the memory - int32_t iPicHeightReq; // picture height have requested the memory + int32_t iPicWidthReq; // picture width have requested the memory + int32_t iPicHeightReq; // picture height have requested the memory - uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID - bool bAvcBasedFlag; // For decoding bitstream: - bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer + uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID + bool bAvcBasedFlag; // For decoding bitstream: + bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer bool bInstantDecFlag; // Flag for no-delay decoding - bool bInitialDqLayersMem; // dq layers related memory is available? + bool bInitialDqLayersMem; // dq layers related memory is available? - bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1 + bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1 // for EC parameter sets - bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence? - bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence? - bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence? + bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence? + bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence? + bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence? - int32_t iSpsErrorIgnored; - int32_t iSubSpsErrorIgnored; - int32_t iPpsErrorIgnored; + int32_t iSpsErrorIgnored; + int32_t iSubSpsErrorIgnored; + int32_t iPpsErrorIgnored; - bool bSpsAvailFlags[MAX_SPS_COUNT]; - bool bSubspsAvailFlags[MAX_SPS_COUNT]; - bool bPpsAvailFlags[MAX_PPS_COUNT]; - int32_t iPPSLastInvalidId; - int32_t iPPSInvalidNum; - int32_t iSPSLastInvalidId; - int32_t iSPSInvalidNum; - int32_t iSubSPSLastInvalidId; - int32_t iSubSPSInvalidNum; + bool bSpsAvailFlags[MAX_SPS_COUNT]; + bool bSubspsAvailFlags[MAX_SPS_COUNT]; + bool bPpsAvailFlags[MAX_PPS_COUNT]; + int32_t iPPSLastInvalidId; + int32_t iPPSInvalidNum; + int32_t iSPSLastInvalidId; + int32_t iSPSInvalidNum; + int32_t iSubSPSLastInvalidId; + int32_t iSubSPSInvalidNum; - bool bReferenceLostAtT0Flag; - int32_t iTotalNumMbRec; //record current number of decoded MB + bool bReferenceLostAtT0Flag; + int32_t iTotalNumMbRec; //record current number of decoded MB #ifdef LONG_TERM_REF - bool bParamSetsLostFlag; //sps or pps do not exist or not correct + bool bParamSetsLostFlag; //sps or pps do not exist or not correct - bool - bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self - int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable + bool bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self + int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable - uint16_t uiCurIdrPicId; + uint16_t uiCurIdrPicId; #endif bool bNewSeqBegin; bool bNextNewSeqBegin; @@ -387,20 +386,20 @@ typedef struct TagWelsDecoderContext { SParserBsInfo* pParserBsInfo; PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment - PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16; - PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t - PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t - PIdctResAddPredFunc pIdctResAddPredFunc; - SMcFunc sMcFunc; + PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16; + PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t + PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t + PIdctResAddPredFunc pIdctResAddPredFunc; + SMcFunc sMcFunc; //Transform8x8 PGetIntraPred8x8Func pGetI8x8LumaPredFunc[14]; - PIdctResAddPredFunc pIdctResAddPredFunc8x8; + PIdctResAddPredFunc pIdctResAddPredFunc8x8; //For error concealment SCopyFunc sCopyFunc; /* For Deblocking */ SDeblockingFunc sDeblockingFunc; - SExpandPicFunc sExpandPicFunc; + SExpandPicFunc sExpandPicFunc; /* For Block */ SBlockFunc sBlockFunc; diff --git a/codec/decoder/core/inc/error_code.h b/codec/decoder/core/inc/error_code.h index 0ac2c90f..16f85f90 100644 --- a/codec/decoder/core/inc/error_code.h +++ b/codec/decoder/core/inc/error_code.h @@ -56,7 +56,7 @@ ERR_BOUND = 31 * ERR_NO = (ERR_LEVEL_FROM (HIGH WORD) << 16) | (ERR_INFO_FROM (LOW WORD)) * */ -#define GENERATE_ERROR_NO(iErrLevel, iErrInfo) ((iErrLevel << 16) | (iErrInfo & 0xFFFF)) +#define GENERATE_ERROR_NO(iErrLevel, iErrInfo) ((iErrLevel << 16) | (iErrInfo & 0xFFFF)) #define ERR_INVALID_INTRA4X4_MODE -1 /* ERR_LEVEL */ diff --git a/codec/decoder/core/inc/fmo.h b/codec/decoder/core/inc/fmo.h index 45975961..be668254 100644 --- a/codec/decoder/core/inc/fmo.h +++ b/codec/decoder/core/inc/fmo.h @@ -47,19 +47,19 @@ namespace WelsDec { #ifndef MB_XY_T -#define MB_XY_T int16_t +#define MB_XY_T int16_t #endif//MB_XY_T /*! * \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; diff --git a/codec/decoder/core/inc/nal_prefix.h b/codec/decoder/core/inc/nal_prefix.h index da3c6964..30fd4b70 100644 --- a/codec/decoder/core/inc/nal_prefix.h +++ b/codec/decoder/core/inc/nal_prefix.h @@ -30,7 +30,7 @@ * */ -//nal_prefix.h - definitions for NAL Unit Header(/Ext) and PrefixNALUnit +//nal_prefix.h - definitions for NAL Unit Header(/Ext) and PrefixNALUnit #ifndef WELS_NAL_UNIT_PREFIX_H__ #define WELS_NAL_UNIT_PREFIX_H__ @@ -44,11 +44,11 @@ namespace WelsDec { /* Prefix NAL Unix syntax, refer to Page 392 in JVT X201wcm */ typedef struct TagPrefixNalUnit { -SRefBasePicMarking sRefPicBaseMarking; -bool bStoreRefBasePicFlag; -bool bPrefixNalUnitAdditionalExtFlag; -bool bPrefixNalUnitExtFlag; -bool bPrefixNalCorrectFlag; +SRefBasePicMarking sRefPicBaseMarking; +bool bStoreRefBasePicFlag; +bool bPrefixNalUnitAdditionalExtFlag; +bool bPrefixNalUnitExtFlag; +bool bPrefixNalCorrectFlag; } SPrefixNalUnit, *PPrefixNalUnit; } // namespace WelsDec diff --git a/codec/decoder/core/inc/nalu.h b/codec/decoder/core/inc/nalu.h index f95b67b4..c77bab87 100644 --- a/codec/decoder/core/inc/nalu.h +++ b/codec/decoder/core/inc/nalu.h @@ -30,7 +30,7 @@ * */ -//nalu.h: NAL Unit definition +//nalu.h: NAL Unit definition #ifndef WELS_NAL_UNIT_H__ #define WELS_NAL_UNIT_H__ @@ -45,17 +45,17 @@ namespace WelsDec { /* NAL Unit Structure */ typedef struct TagNalUnit { -SNalUnitHeaderExt sNalHeaderExt; +SNalUnitHeaderExt sNalHeaderExt; union { struct SVclNal { - SSliceHeaderExt sSliceHeaderExt; - SBitStringAux sSliceBitsRead; - uint8_t* pNalPos; // save the address of slice nal for GPU function - int32_t iNalLength; // save the nal length for GPU function - bool bSliceHeaderExtFlag; + SSliceHeaderExt sSliceHeaderExt; + SBitStringAux sSliceBitsRead; + uint8_t* pNalPos; // save the address of slice nal for GPU function + int32_t iNalLength; // save the nal length for GPU function + bool bSliceHeaderExtFlag; } sVclNal; - SPrefixNalUnit sPrefixNal; + SPrefixNalUnit sPrefixNal; } sNalData; unsigned long long uiTimeStamp; } SNalUnit, *PNalUnit; @@ -64,14 +64,14 @@ unsigned long long uiTimeStamp; /* 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 diff --git a/codec/decoder/core/inc/parameter_sets.h b/codec/decoder/core/inc/parameter_sets.h index 10d1d00e..01d566b2 100644 --- a/codec/decoder/core/inc/parameter_sets.h +++ b/codec/decoder/core/inc/parameter_sets.h @@ -42,52 +42,52 @@ namespace WelsDec { /* 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; + uint32_t uiLog2MaxFrameNum; + uint32_t uiPocType; /* POC type 0 */ - int32_t iLog2MaxPocLsb; + int32_t iLog2MaxPocLsb; /* POC type 1 */ - int32_t iOffsetForNonRefPic; + 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; + uint8_t uiBitDepthLuma; + uint8_t uiBitDepthChroma; /* TO BE CONTINUE: POC type 1 */ - bool bDeltaPicOrderAlwaysZeroFlag; - bool bGapsInFrameNumValueAllowedFlag; + 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 bTimingInfoPresentFlag; -// bool bFixedFrameRateFlag; - bool bConstraintSet0Flag; - bool bConstraintSet1Flag; - bool bConstraintSet2Flag; - bool bConstraintSet3Flag; - bool bSeparateColorPlaneFlag; - bool bQpPrimeYZeroTransfBypassFlag; - bool bSeqScalingMatrixPresentFlag; - bool bSeqScalingListPresentFlag[12]; + bool bVuiParamPresentFlag; +// bool bTimingInfoPresentFlag; +// bool bFixedFrameRateFlag; + bool bConstraintSet0Flag; + bool bConstraintSet1Flag; + bool bConstraintSet2Flag; + bool bConstraintSet3Flag; + bool bSeparateColorPlaneFlag; + bool bQpPrimeYZeroTransfBypassFlag; + bool bSeqScalingMatrixPresentFlag; + bool bSeqScalingListPresentFlag[12]; //Add scaling list supporting uint8_t iScalingList4x4[6][16]; uint8_t iScalingList8x8[6][64]; @@ -98,75 +98,75 @@ const SLevelLimits* pSLevelLimits; /* Sequence Parameter Set extension syntax, refer to Page 58 in JVT X201wcm */ //typedef struct TagSpsExt{ -// uint32_t iSpsId; -// uint32_t uiAuxFormatIdc; -// int32_t iAlphaOpaqueValue; -// int32_t iAlphaTransparentValue; +// uint32_t iSpsId; +// uint32_t uiAuxFormatIdc; +// int32_t iAlphaOpaqueValue; +// int32_t iAlphaTransparentValue; -// uint8_t uiBitDepthAux; -// bool bAlphaIncrFlag; -// bool bAdditionalExtFlag; +// uint8_t uiBitDepthAux; +// bool bAlphaIncrFlag; +// bool bAdditionalExtFlag; //}SSpsExt, *PSpsExt; /* 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; + uint32_t uiNumSliceGroups; + uint32_t uiSliceGroupMapType; /* slice_group_map_type = 0 */ - uint32_t uiRunLength[MAX_SLICEGROUP_IDS]; + uint32_t uiRunLength[MAX_SLICEGROUP_IDS]; /* slice_group_map_type = 2 */ - uint32_t uiTopLeft[MAX_SLICEGROUP_IDS]; - uint32_t uiBottomRight[MAX_SLICEGROUP_IDS]; + uint32_t uiTopLeft[MAX_SLICEGROUP_IDS]; + uint32_t uiBottomRight[MAX_SLICEGROUP_IDS]; /* slice_group_map_type = 3, 4 or 5 */ - uint32_t uiSliceGroupChangeRate; + uint32_t uiSliceGroupChangeRate; /* slice_group_map_type = 6 */ - uint32_t uiPicSizeInMapUnits; - uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS]; + 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[2];//cb,cr + int32_t iPicInitQp; + int32_t iPicInitQs; + int32_t iChromaQpIndexOffset[2];//cb,cr - bool bEntropyCodingModeFlag; - bool bPicOrderPresentFlag; + bool bEntropyCodingModeFlag; + bool bPicOrderPresentFlag; /* slice_group_map_type = 3, 4 or 5 */ - bool bSliceGroupChangeDirectionFlag; - bool bDeblockingFilterControlPresentFlag; + bool bSliceGroupChangeDirectionFlag; + bool bDeblockingFilterControlPresentFlag; - bool bConstainedIntraPredFlag; - bool bRedundantPicCntPresentFlag; - bool bWeightedPredFlag; - uint8_t uiWeightedBipredIdc; + bool bConstainedIntraPredFlag; + bool bRedundantPicCntPresentFlag; + bool bWeightedPredFlag; + uint8_t uiWeightedBipredIdc; bool bTransform8x8ModeFlag; //Add for scalinglist support diff --git a/codec/decoder/core/inc/picture.h b/codec/decoder/core/inc/picture.h index cb1ddb53..1424851c 100644 --- a/codec/decoder/core/inc/picture.h +++ b/codec/decoder/core/inc/picture.h @@ -30,7 +30,7 @@ * */ -//picture.h - reconstruction picture/ reference picture/ residual picture are declared here +//picture.h - reconstruction picture/ reference picture/ residual picture are declared here #ifndef WELS_PICTURE_H__ #define WELS_PICTURE_H__ @@ -44,10 +44,10 @@ namespace WelsDec { */ 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? +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 EC mv copy****************************/ @@ -55,25 +55,25 @@ bool bIdrFlag; /*******************************from other standard syntax****************************/ /*from sps*/ -int32_t iWidthInPixel; // picture width in pixel -int32_t iHeightInPixel;// picture height in pixel +int32_t iWidthInPixel; // picture width in pixel +int32_t iHeightInPixel;// picture height in pixel /*from slice header*/ -int32_t iFramePoc; // frame POC +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. +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. -bool bIsComplete; // indicate whether current picture is complete, not from EC +bool bIsComplete; // indicate whether current picture is complete, not from EC /*******************************for future use****************************/ -uint8_t uiTemporalId; -uint8_t uiSpatialId; -uint8_t uiQualityId; +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; @@ -82,7 +82,7 @@ bool bNewSeqBegin; int32_t iMbEcedNum; int32_t iMbEcedPropNum; int32_t iMbNum; -} SPicture, *PPicture; // "Picture" declaration is comflict with Mac system +} SPicture, *PPicture; // "Picture" declaration is comflict with Mac system } // namespace WelsDec diff --git a/codec/decoder/core/inc/slice.h b/codec/decoder/core/inc/slice.h index d3621f7d..8088e20d 100644 --- a/codec/decoder/core/inc/slice.h +++ b/codec/decoder/core/inc/slice.h @@ -51,22 +51,22 @@ struct { uint16_t uiLongTermPicNum; uint16_t uiReorderingOfPicNumsIdc; } sReorderingSyn[LIST_A][MAX_REF_PIC_COUNT]; -bool bRefPicListReorderingFlag[LIST_A]; +bool bRefPicListReorderingFlag[LIST_A]; } SRefPicListReorderSyn, *PRefPicListReorderSyn; /* * Prediction weight table syntax, refer to page 65 in JVT X201wcm */ typedef struct TagPredWeightTabSyntax { -uint32_t uiLumaLog2WeightDenom; -uint32_t uiChromaLog2WeightDenom; +uint32_t uiLumaLog2WeightDenom; +uint32_t uiChromaLog2WeightDenom; struct { - int32_t iLumaWeight[MAX_REF_PIC_COUNT]; + int32_t iLumaWeight[MAX_REF_PIC_COUNT]; int32_t iLumaOffset[MAX_REF_PIC_COUNT]; - int32_t iChromaWeight[MAX_REF_PIC_COUNT][2]; + int32_t iChromaWeight[MAX_REF_PIC_COUNT][2]; int32_t iChromaOffset[MAX_REF_PIC_COUNT][2]; - bool bLumaWeightFlag; - bool bChromaWeightFlag; + bool bLumaWeightFlag; + bool bChromaWeightFlag; } sPredList[LIST_A]; } SPredWeightTabSyn,*PPredWeightTabSyn; @@ -75,129 +75,129 @@ typedef struct TagRefPicMarking { struct { uint32_t uiMmcoType; int32_t iShortFrameNum; - int32_t iDiffOfPicNum; + int32_t iDiffOfPicNum; uint32_t uiLongTermPicNum; - int32_t iLongTermFrameIdx; - int32_t iMaxLongTermFrameIdx; + int32_t iLongTermFrameIdx; + int32_t iMaxLongTermFrameIdx; } sMmcoRef[MAX_MMCO_COUNT]; -bool bNoOutputOfPriorPicsFlag; -bool bLongTermRefFlag; -bool bAdaptiveRefPicMarkingModeFlag; +bool bNoOutputOfPriorPicsFlag; +bool bLongTermRefFlag; +bool bAdaptiveRefPicMarkingModeFlag; } SRefPicMarking, *PRefPicMarking; /* Decode reference base picture marking syntax in Page 396 of JVT X201wcm */ typedef struct TagRefBasePicMarkingSyn { struct { - uint32_t uiMmcoType; - int32_t iShortFrameNum; - uint32_t uiDiffOfPicNums; - uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum. -} mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame + uint32_t uiMmcoType; + int32_t iShortFrameNum; + uint32_t uiDiffOfPicNums; + uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum. +} mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame -bool bAdaptiveRefBasePicMarkingModeFlag; +bool bAdaptiveRefBasePicMarkingModeFlag; } SRefBasePicMarking, *PRefBasePicMarking; /* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */ typedef struct TagSliceHeaders { /*****************************slice header syntax and generated****************************/ -int32_t iFirstMbInSlice; -int32_t iFrameNum; -int32_t iPicOrderCntLsb; -int32_t iDeltaPicOrderCntBottom; -int32_t iDeltaPicOrderCnt[2]; -int32_t iRedundantPicCnt; -int32_t uiRefCount[LIST_A]; -int32_t iSliceQpDelta; //no use for iSliceQp is used directly -int32_t iSliceQp; -int32_t iSliceQsDelta; // For SP/SI slices -uint32_t uiDisableDeblockingFilterIdc; -int32_t iSliceAlphaC0Offset; -int32_t iSliceBetaOffset; -int32_t iSliceGroupChangeCycle; +int32_t iFirstMbInSlice; +int32_t iFrameNum; +int32_t iPicOrderCntLsb; +int32_t iDeltaPicOrderCntBottom; +int32_t iDeltaPicOrderCnt[2]; +int32_t iRedundantPicCnt; +int32_t uiRefCount[LIST_A]; +int32_t iSliceQpDelta; //no use for iSliceQp is used directly +int32_t iSliceQp; +int32_t iSliceQsDelta; // For SP/SI slices +uint32_t uiDisableDeblockingFilterIdc; +int32_t iSliceAlphaC0Offset; +int32_t iSliceBetaOffset; +int32_t iSliceGroupChangeCycle; -PSps pSps; -PPps pPps; -int32_t iSpsId; -int32_t iPpsId; +PSps pSps; +PPps pPps; +int32_t iSpsId; +int32_t iPpsId; bool bIdrFlag; /*********************got from other layer for efficency if possible*********************/ -SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs -SPredWeightTabSyn sPredWeightTable; -int32_t iCabacInitIdc; -int32_t iMbWidth; //from? -int32_t iMbHeight; //from? -SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs +SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs +SPredWeightTabSyn sPredWeightTable; +int32_t iCabacInitIdc; +int32_t iMbWidth; //from? +int32_t iMbHeight; //from? +SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs uint16_t uiIdrPicId; -EWelsSliceType eSliceType; -bool bNumRefIdxActiveOverrideFlag; -bool bFieldPicFlag; //not supported in base profile -bool bBottomFiledFlag; //not supported in base profile -uint8_t uiPadding1Byte; -bool bSpForSwitchFlag; // For SP/SI slices -int16_t iPadding2Bytes; +EWelsSliceType eSliceType; +bool bNumRefIdxActiveOverrideFlag; +bool bFieldPicFlag; //not supported in base profile +bool bBottomFiledFlag; //not supported in base profile +uint8_t uiPadding1Byte; +bool bSpForSwitchFlag; // For SP/SI slices +int16_t iPadding2Bytes; } SSliceHeader, *PSliceHeader; /* Slice header in scalable extension syntax, refer to Page 394 in JVT X201wcm */ typedef struct TagSliceHeaderExt { -SSliceHeader sSliceHeader; -PSubsetSps pSubsetSps; +SSliceHeader sSliceHeader; +PSubsetSps pSubsetSps; -uint32_t uiDisableInterLayerDeblockingFilterIdc; -int32_t iInterLayerSliceAlphaC0Offset; -int32_t iInterLayerSliceBetaOffset; +uint32_t uiDisableInterLayerDeblockingFilterIdc; +int32_t iInterLayerSliceAlphaC0Offset; +int32_t iInterLayerSliceBetaOffset; //SPosOffset sScaledRefLayer; -int32_t iScaledRefLayerPicWidthInSampleLuma; -int32_t iScaledRefLayerPicHeightInSampleLuma; +int32_t iScaledRefLayerPicWidthInSampleLuma; +int32_t iScaledRefLayerPicHeightInSampleLuma; -SRefBasePicMarking sRefBasePicMarking; -bool bBasePredWeightTableFlag; -bool bStoreRefBasePicFlag; -bool bConstrainedIntraResamplingFlag; -bool bSliceSkipFlag; +SRefBasePicMarking sRefBasePicMarking; +bool bBasePredWeightTableFlag; +bool bStoreRefBasePicFlag; +bool bConstrainedIntraResamplingFlag; +bool bSliceSkipFlag; -bool bAdaptiveBaseModeFlag; -bool bDefaultBaseModeFlag; -bool bAdaptiveMotionPredFlag; -bool bDefaultMotionPredFlag; -bool bAdaptiveResidualPredFlag; -bool bDefaultResidualPredFlag; -bool bTCoeffLevelPredFlag; -uint8_t uiRefLayerChromaPhaseXPlus1Flag; +bool bAdaptiveBaseModeFlag; +bool bDefaultBaseModeFlag; +bool bAdaptiveMotionPredFlag; +bool bDefaultMotionPredFlag; +bool bAdaptiveResidualPredFlag; +bool bDefaultResidualPredFlag; +bool bTCoeffLevelPredFlag; +uint8_t uiRefLayerChromaPhaseXPlus1Flag; -uint8_t uiRefLayerChromaPhaseYPlus1; -uint8_t uiRefLayerDqId; -uint8_t uiScanIdxStart; -uint8_t uiScanIdxEnd; +uint8_t uiRefLayerChromaPhaseYPlus1; +uint8_t uiRefLayerDqId; +uint8_t uiScanIdxStart; +uint8_t uiScanIdxEnd; } SSliceHeaderExt, *PSliceHeaderExt; typedef struct TagSlice { /*******************************slice_header****************************/ -SSliceHeaderExt sSliceHeaderExt; +SSliceHeaderExt sSliceHeaderExt; /*******************************use for future****************************/ // for Macroblock coding within slice -int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc. +int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc. /*******************************slice_data****************************/ /*slice_data_ext()*/ -int32_t iMbSkipRun; -int32_t iTotalMbInCurSlice; //record the total number of MB in current slice. +int32_t iMbSkipRun; +int32_t iTotalMbInCurSlice; //record the total number of MB in current slice. /*slice_data_ext() generate*/ /*******************************misc use****************************/ -bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext? +bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext? /*************got from other layer for effiency if possible***************/ /*from lower layer: slice header*/ -uint8_t eSliceType; -uint8_t uiPadding[2]; -int32_t iLastDeltaQp; +uint8_t eSliceType; +uint8_t uiPadding[2]; +int32_t iLastDeltaQp; } SSlice, *PSlice; } // namespace WelsDec diff --git a/codec/decoder/core/inc/wels_common_basis.h b/codec/decoder/core/inc/wels_common_basis.h index c8b860d2..276653db 100644 --- a/codec/decoder/core/inc/wels_common_basis.h +++ b/codec/decoder/core/inc/wels_common_basis.h @@ -53,14 +53,14 @@ extern const uint8_t g_kCache26ScanIdx[16]; extern const uint8_t g_kCache30ScanIdx[16]; extern const uint8_t g_kNonZeroScanIdxC[4]; /* Profile IDC */ -typedef uint8_t ProfileIdc; +typedef uint8_t ProfileIdc; /* 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; /* MB Type & Sub-MB Type */ @@ -86,8 +86,8 @@ typedef int32_t SubMbType; #define LUMA_DC_AC_INTRA_8 17 #define LUMA_DC_AC_INTER_8 18 -#define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); } -#define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; } +#define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); } +#define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; } static const uint8_t g_kuiZigzagScan[16] = { //4*4block residual zig-zag scan order 0, 1, 4, 8, @@ -129,67 +129,65 @@ static const uint8_t g_kuiIdx2CtxLastSignificantCoeffFlag8x8[64] = { // Table 9- 7, 7, 7, 7, 8, 8, 8, 8, }; -static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProperty,bool bCavlc) -{ - switch(*pResidualProperty) - { +static inline void GetMbResProperty (int32_t* pMBproperty, int32_t* pResidualProperty, bool bCavlc) { + switch (*pResidualProperty) { case CHROMA_AC_U: - *pMBproperty = 1; - *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U; - break; + *pMBproperty = 1; + *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U; + break; case CHROMA_AC_V: - *pMBproperty = 2; - *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V; - break; + *pMBproperty = 2; + *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V; + break; case LUMA_DC_AC_INTRA: - *pMBproperty = 0; - *pResidualProperty = LUMA_DC_AC; - break; + *pMBproperty = 0; + *pResidualProperty = LUMA_DC_AC; + break; case CHROMA_DC_U: - *pMBproperty = 1; - *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U; - break; - case CHROMA_DC_V: - *pMBproperty = 2; - *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V; - break; + *pMBproperty = 1; + *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U; + break; + case CHROMA_DC_V: + *pMBproperty = 2; + *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V; + break; case I16_LUMA_AC: - *pMBproperty = 0; - break; + *pMBproperty = 0; + break; case I16_LUMA_DC: - *pMBproperty = 0; - break; + *pMBproperty = 0; + break; case LUMA_DC_AC_INTER: - *pMBproperty = 3; - *pResidualProperty = LUMA_DC_AC; - break; + *pMBproperty = 3; + *pResidualProperty = LUMA_DC_AC; + break; case CHROMA_DC_U_INTER: - *pMBproperty = 4; - *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U; - break; + *pMBproperty = 4; + *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U; + break; case CHROMA_DC_V_INTER: - *pMBproperty = 5; - *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V; - break; - case CHROMA_AC_U_INTER: - *pMBproperty = 4; - *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U; - break; - case CHROMA_AC_V_INTER: - *pMBproperty = 5; - *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V; - break; - // Reference to Table 7-2 - case LUMA_DC_AC_INTRA_8: + *pMBproperty = 5; + *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V; + break; + case CHROMA_AC_U_INTER: + *pMBproperty = 4; + *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U; + break; + case CHROMA_AC_V_INTER: + *pMBproperty = 5; + *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V; + break; + // Reference to Table 7-2 + case LUMA_DC_AC_INTRA_8: *pMBproperty = 6; *pResidualProperty = LUMA_DC_AC_8; break; - case LUMA_DC_AC_INTER_8: + case LUMA_DC_AC_INTER_8: *pMBproperty = 7; *pResidualProperty = LUMA_DC_AC_8; break; - } } +} typedef struct TagI16PredInfo { int8_t iPredMode; @@ -217,7 +215,7 @@ typedef struct TagI4PredInfo { int8_t iLeftAvail; int8_t iTopAvail; int8_t iLeftTopAvail; - // int8_t right_top_avail; //when right_top unavailable but top avail, we can pad the right-top with the rightmost pixel of top + // int8_t right_top_avail; //when right_top unavailable but top avail, we can pad the right-top with the rightmost pixel of top } SI4PredInfo; static const SI4PredInfo g_ksI4PredInfo[9] = { { I4_PRED_V, 0, 1, 0}, diff --git a/codec/decoder/core/src/au_parser.cpp b/codec/decoder/core/src/au_parser.cpp index 5f0f627a..dcaad0f1 100644 --- a/codec/decoder/core/src/au_parser.cpp +++ b/codec/decoder/core/src/au_parser.cpp @@ -110,7 +110,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade int32_t iNalSize = iSrcRbspLen; PBitStringAux pBs = NULL; bool bExtensionFlag = false; - int32_t iErr = ERR_NONE; + int32_t iErr = ERR_NONE; int32_t iBitSize = 0; SDataBuffer* pSavedData = &pCtx->sSavedData; SLogContext* pLogCtx = & (pCtx->sLogCtx); @@ -132,14 +132,14 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade } } - pNalUnitHeader->uiForbiddenZeroBit = (uint8_t) (pNal[0] >> 7); // uiForbiddenZeroBit + pNalUnitHeader->uiForbiddenZeroBit = (uint8_t) (pNal[0] >> 7); // uiForbiddenZeroBit if (pNalUnitHeader->uiForbiddenZeroBit) { //2010.4.14 pCtx->iErrorCode |= dsBitstreamError; return NULL; //uiForbiddenZeroBit should always equal to 0 } - pNalUnitHeader->uiNalRefIdc = (uint8_t) (pNal[0] >> 5); // uiNalRefIdc - pNalUnitHeader->eNalUnitType = (EWelsNalUnitType) (pNal[0] & 0x1f); // eNalUnitType + pNalUnitHeader->uiNalRefIdc = (uint8_t) (pNal[0] >> 5); // uiNalRefIdc + pNalUnitHeader->eNalUnitType = (EWelsNalUnitType) (pNal[0] & 0x1f); // eNalUnitType ++pNal; --iNalSize; @@ -155,7 +155,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade pCtx->iSpsErrorIgnored++; } pCtx->sDecoderStatistics.iSpsNoExistNalNum++; - pCtx->iErrorCode = dsNoParamSets; + pCtx->iErrorCode = dsNoParamSets; return NULL; } pCtx->iSpsErrorIgnored = 0; @@ -169,7 +169,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade pCtx->iPpsErrorIgnored++; } pCtx->sDecoderStatistics.iPpsNoExistNalNum++; - pCtx->iErrorCode = dsNoParamSets; + pCtx->iErrorCode = dsNoParamSets; return NULL; } pCtx->iPpsErrorIgnored = 0; @@ -184,7 +184,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade pCtx->iSubSpsErrorIgnored++; } pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++; - pCtx->iErrorCode |= dsNoParamSets; + pCtx->iErrorCode |= dsNoParamSets; return NULL; } pCtx->iSubSpsErrorIgnored = 0; @@ -203,7 +203,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade pCurNal->uiTimeStamp = pCtx->uiTimeStamp; if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) { - PAccessUnit pCurAu = pCtx->pAccessUnitList; + PAccessUnit pCurAu = pCtx->pAccessUnitList; uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum; if (uiAvailNalNum > 0) { @@ -222,7 +222,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseNalHeader() in Prefix Nal Unit:uiQualityId (%d) != 0, bUseRefBasePicFlag (%d) != 0, not supported!", pCurNal->sNalHeaderExt.uiQualityId, pCurNal->sNalHeaderExt.bUseRefBasePicFlag); - PAccessUnit pCurAu = pCtx->pAccessUnitList; + PAccessUnit pCurAu = pCtx->pAccessUnitList; uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum; if (uiAvailNalNum > 0) { @@ -241,8 +241,8 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade *pConsumedBytes += NAL_UNIT_HEADER_EXT_SIZE; pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit; - pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc; - pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType; + pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc; + pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType; if (pNalUnitHeader->uiNalRefIdc != 0) { pBs = &pCtx->sBs; iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit @@ -250,7 +250,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade iErr = DecInitBits (pBs, pNal, iBitSize); if (iErr) { WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_PREFIX: DecInitBits() fail due invalid access."); - pCtx->iErrorCode |= dsBitstreamError; + pCtx->iErrorCode |= dsBitstreamError; return NULL; } ParsePrefixNalUnit (pCtx, pBs); @@ -262,19 +262,19 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade bExtensionFlag = true; case NAL_UNIT_CODED_SLICE: case NAL_UNIT_CODED_SLICE_IDR: { - PAccessUnit pCurAu = NULL; + PAccessUnit pCurAu = NULL; uint32_t uiAvailNalNum; pCurNal = MemGetNextNal (&pCtx->pAccessUnitList); if (NULL == pCurNal) { WelsLog (pLogCtx, WELS_LOG_ERROR, "MemGetNextNal() fail due out of memory."); - pCtx->iErrorCode |= dsOutOfMemory; + pCtx->iErrorCode |= dsOutOfMemory; return NULL; } pCurNal->uiTimeStamp = pCtx->uiTimeStamp; pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit; - pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc; - pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType; - pCurAu = pCtx->pAccessUnitList; + pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc; + pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType; + pCurAu = pCtx->pAccessUnitList; uiAvailNalNum = pCurAu->uiAvailUnitsNum; @@ -386,7 +386,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade } } WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_CODED_SLICE: DecInitBits() fail due invalid access."); - pCtx->iErrorCode |= dsBitstreamError; + pCtx->iErrorCode |= dsBitstreamError; return NULL; } iErr = ParseSliceHeaderSyntaxs (pCtx, pBs, bExtensionFlag); @@ -576,16 +576,16 @@ bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const */ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen, uint8_t* pSrcNal, const int32_t kSrcNalLen) { - PBitStringAux pBs = NULL; - EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; // make initial value as unspecified - int32_t iPicWidth = 0; - int32_t iPicHeight = 0; - int32_t iBitSize = 0; - int32_t iErr = ERR_NONE; + PBitStringAux pBs = NULL; + EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; // make initial value as unspecified + int32_t iPicWidth = 0; + int32_t iPicHeight = 0; + int32_t iBitSize = 0; + int32_t iErr = ERR_NONE; if (kiSrcLen <= 0) return iErr; - pBs = &pCtx->sBs; // SBitStringAux instance for non VCL NALs decoding + pBs = &pCtx->sBs; // SBitStringAux instance for non VCL NALs decoding iBitSize = (kiSrcLen << 3) - BsGetTrailingBits (pRbsp + kiSrcLen - 1); // convert into bit eNalType = pCtx->sCurNalHead.eNalUnitType; @@ -603,7 +603,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t } } iErr = ParseSps (pCtx, pBs, &iPicWidth, &iPicHeight, pSrcNal, kSrcNalLen); - if (ERR_NONE != iErr) { // modified for pSps/pSubsetSps invalid, 12/1/2009 + if (ERR_NONE != iErr) { // modified for pSps/pSubsetSps invalid, 12/1/2009 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) pCtx->iErrorCode |= dsNoParamSets; else @@ -625,7 +625,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t } } iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen); - if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009 + if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) pCtx->iErrorCode |= dsNoParamSets; else @@ -633,7 +633,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t return iErr; } - pCtx->bPpsExistAheadFlag = true; + pCtx->bPpsExistAheadFlag = true; break; @@ -667,18 +667,18 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //MMCO_base const uint32_t kuiMmco = uiCode; - pRefBasePicMarking->mmco_base[iIdx].uiMmcoType = kuiMmco; + pRefBasePicMarking->mmco_base[iIdx].uiMmcoType = kuiMmco; if (kuiMmco == MMCO_END) break; if (kuiMmco == MMCO_SHORT2UNUSED) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_base_pic_nums_minus1 - pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + uiCode; - pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0; + pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + uiCode; + pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0; } else if (kuiMmco == MMCO_LONG2UNUSED) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_base_pic_num - pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode; + pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode; } ++ iIdx; } while (iIdx < MAX_MMCO_COUNT); @@ -694,7 +694,7 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) { PNalUnitHeaderExt head_ext = &pCurNal->sNalHeaderExt; PPrefixNalUnit sPrefixNal = &pCurNal->sNalData.sPrefixNal; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //store_ref_base_pic_flag - sPrefixNal->bStoreRefBasePicFlag = !!uiCode; + sPrefixNal->bStoreRefBasePicFlag = !!uiCode; if ((head_ext->bUseRefBasePicFlag || sPrefixNal->bStoreRefBasePicFlag) && !head_ext->bIdrFlag) { WELS_READ_VERIFY (ParseRefBasePicMarking (pBs, &sPrefixNal->sRefPicBaseMarking)); } @@ -702,7 +702,7 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) { sPrefixNal->bPrefixNalUnitAdditionalExtFlag = !!uiCode; if (sPrefixNal->bPrefixNalUnitAdditionalExtFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //additional_prefix_nal_unit_extension_data_flag - sPrefixNal->bPrefixNalUnitExtFlag = !!uiCode; + sPrefixNal->bPrefixNalUnitExtFlag = !!uiCode; } } return ERR_NONE; @@ -721,16 +721,16 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) { int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs) { - PSpsSvcExt pExt = NULL; + PSpsSvcExt pExt = NULL; uint32_t uiCode; int32_t iCode; - pExt = &pSpsExt->sSpsSvcExt; + pExt = &pSpsExt->sSpsSvcExt; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //inter_layer_deblocking_filter_control_present_flag - pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!uiCode; + pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!uiCode; WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //extended_spatial_scalability_idc - pExt->uiExtendedSpatialScalability = uiCode; + pExt->uiExtendedSpatialScalability = uiCode; if (pExt->uiExtendedSpatialScalability > 2) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "DecodeSpsSvcExt():extended_spatial_scalability (%d) != 0, ESS not supported!", @@ -738,36 +738,36 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_ESS); } - pExt->uiChromaPhaseXPlus1Flag = - 0; // FIXME: Incoherent with JVT X201 standard (= 1), but conformance to JSVM (= 0) implementation. - pExt->uiChromaPhaseYPlus1 = 1; + pExt->uiChromaPhaseXPlus1Flag = + 0; // FIXME: Incoherent with JVT X201 standard (= 1), but conformance to JSVM (= 0) implementation. + pExt->uiChromaPhaseYPlus1 = 1; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //chroma_phase_x_plus1_flag - pExt->uiChromaPhaseXPlus1Flag = uiCode; + pExt->uiChromaPhaseXPlus1Flag = uiCode; WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //chroma_phase_y_plus1 - pExt->uiChromaPhaseYPlus1 = uiCode; + pExt->uiChromaPhaseYPlus1 = uiCode; - pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag; - pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1; + pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag; + pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1; memset (&pExt->sSeqScaledRefLayer, 0, sizeof (SPosOffset)); if (pExt->uiExtendedSpatialScalability == 1) { SPosOffset* const kpPos = &pExt->sSeqScaledRefLayer; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_ref_layer_chroma_phase_x_plus1_flag - pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = uiCode; + pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = uiCode; WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //seq_ref_layer_chroma_phase_y_plus1 - pExt->uiSeqRefLayerChromaPhaseYPlus1 = uiCode; + pExt->uiSeqRefLayerChromaPhaseYPlus1 = uiCode; WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_left_offset - kpPos->iLeftOffset = iCode; + kpPos->iLeftOffset = iCode; WELS_CHECK_SE_BOTH_WARNING (kpPos->iLeftOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MIN, SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MAX, "seq_scaled_ref_layer_left_offset"); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_top_offset - kpPos->iTopOffset = iCode; + kpPos->iTopOffset = iCode; WELS_CHECK_SE_BOTH_WARNING (kpPos->iTopOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MIN, SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MAX, "seq_scaled_ref_layer_top_offset"); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_right_offset - kpPos->iRightOffset = iCode; + kpPos->iRightOffset = iCode; WELS_CHECK_SE_BOTH_WARNING (kpPos->iRightOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MIN, SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MAX, "seq_scaled_ref_layer_right_offset"); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_bottom_offset @@ -777,14 +777,14 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin } WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_tcoeff_level_prediction_flag - pExt->bSeqTCoeffLevelPredFlag = !!uiCode; - pExt->bAdaptiveTCoeffLevelPredFlag = false; + pExt->bSeqTCoeffLevelPredFlag = !!uiCode; + pExt->bAdaptiveTCoeffLevelPredFlag = false; if (pExt->bSeqTCoeffLevelPredFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_tcoeff_level_prediction_flag - pExt->bAdaptiveTCoeffLevelPredFlag = !!uiCode; + pExt->bAdaptiveTCoeffLevelPredFlag = !!uiCode; } WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_header_restriction_flag - pExt->bSliceHeaderRestrictionFlag = !!uiCode; + pExt->bSliceHeaderRestrictionFlag = !!uiCode; @@ -903,10 +903,10 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicWidth, int32_t* pPicHeight, uint8_t* pSrcNal, const int32_t kSrcNalLen) { - PBitStringAux pBs = pBsAux; + PBitStringAux pBs = pBsAux; SSubsetSps sTempSubsetSps; - PSps pSps = NULL; - PSubsetSps pSubsetSps = NULL; + PSps pSps = NULL; + PSubsetSps pSubsetSps = NULL; SNalUnitHeader* pNalHead = &pCtx->sCurNalHead; ProfileIdc uiProfileIdc; uint8_t uiLevelIdc; @@ -917,28 +917,28 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW const bool kbUseSubsetFlag = IS_SUBSET_SPS_NAL (pNalHead->eNalUnitType); WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); //profile_idc - uiProfileIdc = uiCode; + uiProfileIdc = uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set0_flag - bConstraintSetFlags[0] = !!uiCode; + bConstraintSetFlags[0] = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set1_flag - bConstraintSetFlags[1] = !!uiCode; + bConstraintSetFlags[1] = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set2_flag - bConstraintSetFlags[2] = !!uiCode; + bConstraintSetFlags[2] = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set3_flag - bConstraintSetFlags[3] = !!uiCode; + bConstraintSetFlags[3] = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set4_flag - bConstraintSetFlags[4] = !!uiCode; + bConstraintSetFlags[4] = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set5_flag - bConstraintSetFlags[5] = !!uiCode; + bConstraintSetFlags[5] = !!uiCode; WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); // reserved_zero_2bits, equal to 0 WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); // level_idc - uiLevelIdc = uiCode; + uiLevelIdc = uiCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //seq_parameter_set_id - if (uiCode >= MAX_SPS_COUNT) { // Modified to check invalid negative iSpsId, 12/1/2009 + if (uiCode >= MAX_SPS_COUNT) { // Modified to check invalid negative iSpsId, 12/1/2009 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " iSpsId is out of range! \n"); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW); } - iSpsId = uiCode; + iSpsId = uiCode; pSubsetSps = &sTempSubsetSps; pSps = &sTempSubsetSps.sSps; memset (pSubsetSps, 0, sizeof (SSubsetSps)); @@ -948,11 +948,11 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE); } else pSps->pSLevelLimits = pSLevelLimits; // syntax elements in default - pSps->uiChromaFormatIdc = 1; + pSps->uiChromaFormatIdc = 1; - pSps->uiProfileIdc = uiProfileIdc; - pSps->uiLevelIdc = uiLevelIdc; - pSps->iSpsId = iSpsId; + pSps->uiProfileIdc = uiProfileIdc; + pSps->uiLevelIdc = uiLevelIdc; + pSps->iSpsId = iSpsId; if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc || PRO_HIGH == uiProfileIdc || PRO_HIGH10 == uiProfileIdc || @@ -978,19 +978,19 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): bit_depth_luma (%d) Only 8 bit supported.", 8 + uiCode); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE); } - pSps->uiBitDepthLuma = 8; + pSps->uiBitDepthLuma = 8; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //bit_depth_chroma_minus8 if (uiCode != 0) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): bit_depth_chroma (%d). Only 8 bit supported.", 8 + uiCode); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE); } - pSps->uiBitDepthChroma = 8; + pSps->uiBitDepthChroma = 8; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //qpprime_y_zero_transform_bypass_flag - pSps->bQpPrimeYZeroTransfBypassFlag = !!uiCode; + pSps->bQpPrimeYZeroTransfBypassFlag = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag - pSps->bSeqScalingMatrixPresentFlag = !!uiCode; + pSps->bSeqScalingMatrixPresentFlag = !!uiCode; if (pSps->bSeqScalingMatrixPresentFlag) { WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4, @@ -1000,33 +1000,33 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_FRAME_NUM_MINUS4)); - pSps->uiLog2MaxFrameNum = LOG2_MAX_FRAME_NUM_OFFSET + uiCode; + pSps->uiLog2MaxFrameNum = LOG2_MAX_FRAME_NUM_OFFSET + uiCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_order_cnt_type - pSps->uiPocType = uiCode; + pSps->uiPocType = uiCode; if (0 == pSps->uiPocType) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_pic_order_cnt_lsb_minus4 // log2_max_pic_order_cnt_lsb_minus4 should be in range 0 to 12, inclusive. (sec. 7.4.3) WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX, "log2_max_pic_order_cnt_lsb_minus4", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4)); - pSps->iLog2MaxPocLsb = LOG2_MAX_PIC_ORDER_CNT_LSB_OFFSET + uiCode; // log2_max_pic_order_cnt_lsb_minus4 + pSps->iLog2MaxPocLsb = LOG2_MAX_PIC_ORDER_CNT_LSB_OFFSET + uiCode; // log2_max_pic_order_cnt_lsb_minus4 } else if (1 == pSps->uiPocType) { int32_t i; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //delta_pic_order_always_zero_flag - pSps->bDeltaPicOrderAlwaysZeroFlag = !!uiCode; + pSps->bDeltaPicOrderAlwaysZeroFlag = !!uiCode; WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_non_ref_pic - pSps->iOffsetForNonRefPic = iCode; + pSps->iOffsetForNonRefPic = iCode; WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_top_to_bottom_field - pSps->iOffsetForTopToBottomField = iCode; + pSps->iOffsetForTopToBottomField = iCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_ref_frames_in_pic_order_cnt_cycle WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE_MAX, "num_ref_frames_in_pic_order_cnt_cycle", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE)); - pSps->iNumRefFramesInPocCycle = uiCode; + pSps->iNumRefFramesInPocCycle = uiCode; for (i = 0; i < pSps->iNumRefFramesInPocCycle; i++) { WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_ref_frame[ i ] - pSps->iOffsetForRefFrame[ i ] = iCode; + pSps->iOffsetForRefFrame[ i ] = iCode; } } if (pSps->uiPocType > 2) { @@ -1035,11 +1035,11 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW } WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_num_ref_frames - pSps->iNumRefFrames = uiCode; + pSps->iNumRefFrames = uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //gaps_in_frame_num_value_allowed_flag - pSps->bGapsInFrameNumValueAllowedFlag = !!uiCode; + pSps->bGapsInFrameNumValueAllowedFlag = !!uiCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_width_in_mbs_minus1 - pSps->iMbWidth = PIC_WIDTH_IN_MBS_OFFSET + uiCode; + pSps->iMbWidth = PIC_WIDTH_IN_MBS_OFFSET + uiCode; if (pSps->iMbWidth > MAX_MB_SIZE) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_width_in_mbs(%d) exceeds the maximum allowed!", pSps->iMbWidth); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE); @@ -1048,7 +1048,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!"); } WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_height_in_map_units_minus1 - pSps->iMbHeight = PIC_HEIGHT_IN_MAP_UNITS_OFFSET + uiCode; + pSps->iMbHeight = PIC_HEIGHT_IN_MAP_UNITS_OFFSET + uiCode; if (pSps->iMbHeight > MAX_MB_SIZE) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_height_in_mbs(%d) exceeds the maximum allowed!", pSps->iMbHeight); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE); @@ -1060,7 +1060,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW if (uiTmp32 > (uint32_t)pSLevelLimits->uiMaxFS) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the total count of mb exceeds the level limits!"); } - pSps->uiTotalMbCount = uiTmp32; + pSps->uiTotalMbCount = uiTmp32; WELS_CHECK_SE_UPPER_ERROR (pSps->iNumRefFrames, SPS_MAX_NUM_REF_FRAMES_MAX, "max_num_ref_frames", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_NUM_REF_FRAMES)); // here we check max_num_ref_frames @@ -1072,41 +1072,41 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " max_num_ref_frames exceeds level limits!"); } WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //frame_mbs_only_flag - pSps->bFrameMbsOnlyFlag = !!uiCode; + pSps->bFrameMbsOnlyFlag = !!uiCode; if (!pSps->bFrameMbsOnlyFlag) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): frame_mbs_only_flag (%d) not supported.", pSps->bFrameMbsOnlyFlag); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_MBAFF); } WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //direct_8x8_inference_flag - pSps->bDirect8x8InferenceFlag = !!uiCode; + pSps->bDirect8x8InferenceFlag = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //frame_cropping_flag - pSps->bFrameCroppingFlag = !!uiCode; + pSps->bFrameCroppingFlag = !!uiCode; if (pSps->bFrameCroppingFlag) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_left_offset - pSps->sFrameCrop.iLeftOffset = uiCode; + pSps->sFrameCrop.iLeftOffset = uiCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_right_offset - pSps->sFrameCrop.iRightOffset = uiCode; + pSps->sFrameCrop.iRightOffset = uiCode; if ((pSps->sFrameCrop.iLeftOffset + pSps->sFrameCrop.iRightOffset) > ((int32_t)pSps->iMbWidth * 16 / 2)) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "frame_crop_left_offset + frame_crop_right_offset exceeds limits!"); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA); } WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_top_offset - pSps->sFrameCrop.iTopOffset = uiCode; + pSps->sFrameCrop.iTopOffset = uiCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_bottom_offset - pSps->sFrameCrop.iBottomOffset = uiCode; + pSps->sFrameCrop.iBottomOffset = uiCode; if ((pSps->sFrameCrop.iTopOffset + pSps->sFrameCrop.iBottomOffset) > ((int32_t)pSps->iMbHeight * 16 / 2)) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "frame_crop_top_offset + frame_crop_right_offset exceeds limits!"); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA); } } else { - pSps->sFrameCrop.iLeftOffset = 0; // frame_crop_left_offset - pSps->sFrameCrop.iRightOffset = 0; // frame_crop_right_offset - pSps->sFrameCrop.iTopOffset = 0; // frame_crop_top_offset - pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset + pSps->sFrameCrop.iLeftOffset = 0; // frame_crop_left_offset + pSps->sFrameCrop.iRightOffset = 0; // frame_crop_right_offset + pSps->sFrameCrop.iTopOffset = 0; // frame_crop_top_offset + pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset } WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag - pSps->bVuiParamPresentFlag = !!uiCode; + pSps->bVuiParamPresentFlag = !!uiCode; if (pCtx->bParseOnly) { if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //sps bs exceeds! @@ -1206,10 +1206,10 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc) - pCtx->bAvcBasedFlag = false; + pCtx->bAvcBasedFlag = false; - *pPicWidth = pSps->iMbWidth << 4; - *pPicHeight = pSps->iMbHeight << 4; + *pPicWidth = pSps->iMbWidth << 4; + *pPicHeight = pSps->iMbHeight << 4; PSps pTmpSps = NULL; if (kbUseSubsetFlag) { pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps; @@ -1251,12 +1251,12 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW // Not overwrite active sps, just copy to final place else if (kbUseSubsetFlag) { memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)); - pCtx->bSubspsAvailFlags[iSpsId] = true; - pCtx->bSubspsExistAheadFlag = true; + pCtx->bSubspsAvailFlags[iSpsId] = true; + pCtx->bSubspsExistAheadFlag = true; } else { memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)); pCtx->bSpsAvailFlags[iSpsId] = true; - pCtx->bSpsExistAheadFlag = true; + pCtx->bSpsExistAheadFlag = true; } return 0; } @@ -1451,7 +1451,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, * \note Call it in case eNalUnitType is NAL_UNIT_SEI. ************************************************************************************* */ -int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type +int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type return ERR_NONE; @@ -1470,7 +1470,7 @@ int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type ************************************************************************************* */ int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* bUseDefaultScalingMatrixFlag, - PBitStringAux pBsAux) { // reserved Sei_Msg type + PBitStringAux pBsAux) { // reserved Sei_Msg type int iLastScale = 8; int iNextScale = 8; int iDeltaScale; @@ -1573,8 +1573,8 @@ int32_t ResetFmoList (PWelsDecoderContext pCtx) { if (NULL != pCtx) { // Fixed memory leak due to PPS_ID might not be continuous sometimes, 1/5/2010 UninitFmoList (&pCtx->sFmoList[0], MAX_PPS_COUNT, pCtx->iActiveFmoNum); - iCountNum = pCtx->iActiveFmoNum; - pCtx->iActiveFmoNum = 0; + iCountNum = pCtx->iActiveFmoNum; + pCtx->iActiveFmoNum = 0; } return iCountNum; } diff --git a/codec/decoder/core/src/bit_stream.cpp b/codec/decoder/core/src/bit_stream.cpp index c36efb58..c7526042 100644 --- a/codec/decoder/core/src/bit_stream.cpp +++ b/codec/decoder/core/src/bit_stream.cpp @@ -74,9 +74,9 @@ int32_t DecInitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32 if (NULL == pTmp) return ERR_INFO_INVALID_ACCESS; - pBitString->pStartBuf = pTmp; // buffer to start position - pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length - pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex; + pBitString->pStartBuf = pTmp; // buffer to start position + pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length + pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex; pBitString->pCurBuf = pBitString->pStartBuf; int32_t iErr = InitReadBits (pBitString, 0); if (iErr) { diff --git a/codec/decoder/core/src/deblocking.cpp b/codec/decoder/core/src/deblocking.cpp index 28b2dddf..8137acf4 100644 --- a/codec/decoder/core/src/deblocking.cpp +++ b/codec/decoder/core/src/deblocking.cpp @@ -815,7 +815,7 @@ void DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { uint8_t nBS[2][4][4] = {{{ 0 }}}; - int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; + int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex]; int32_t iMbNb; @@ -921,7 +921,7 @@ void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFun } else { ++iNextMbXyIndex; } - if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbCount) { // slice group boundary or end of a frame + if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbCount) { // slice group boundary or end of a frame break; } diff --git a/codec/decoder/core/src/decode_mb_aux.cpp b/codec/decoder/core/src/decode_mb_aux.cpp index d2ce3a31..8d4ef3c9 100644 --- a/codec/decoder/core/src/decode_mb_aux.cpp +++ b/codec/decoder/core/src/decode_mb_aux.cpp @@ -42,9 +42,9 @@ namespace WelsDec { void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { int16_t iSrc[16]; - uint8_t* pDst = pPred; - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* pDst = pPred; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; int32_t i; for (i = 0; i < 4; i++) { @@ -61,16 +61,16 @@ void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { } for (i = 0; i < 4; i++) { - int32_t kT1 = iSrc[i] + iSrc[i + 8]; - int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1); - int32_t kT3 = (32 + kT1 + kT2) >> 6; - int32_t kT4 = (32 + kT1 - kT2) >> 6; + int32_t kT1 = iSrc[i] + iSrc[i + 8]; + int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1); + int32_t kT3 = (32 + kT1 + kT2) >> 6; + int32_t kT4 = (32 + kT1 - kT2) >> 6; pDst[i] = 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]; + 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]); } @@ -157,7 +157,7 @@ void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) iRes[ (7 << 3) + i] = b[0] - b[7]; } - uint8_t* pDst = pPred; + uint8_t* pDst = pPred; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { pDst[i * kiStride + j] = WelsClip1 (((32 + iRes[ (i << 3) + j]) >> 6) + pDst[i * kiStride + j]); @@ -167,7 +167,7 @@ void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) } void GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) { - int32_t* pOffset = pBlockOffset; + int32_t* pOffset = pBlockOffset; int32_t i; const uint8_t kuiScan0 = g_kuiScan8[0]; diff --git a/codec/decoder/core/src/decode_slice.cpp b/codec/decoder/core/src/decode_slice.cpp index a5c6b981..3c875711 100644 --- a/codec/decoder/core/src/decode_slice.cpp +++ b/codec/decoder/core/src/decode_slice.cpp @@ -120,7 +120,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { } else { ++iNextMbXyIndex; } - if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbTargetLayer) { // slice group boundary or end of a frame + if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbTargetLayer) { // slice group boundary or end of a frame break; } pCurLayer->iMbX = iNextMbXyIndex % pCurLayer->iMbWidth; @@ -155,8 +155,8 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa int32_t iMbXy = pCurLayer->iMbXyIndex; int32_t i, iIndex, iOffset; - WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16 - WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4 + WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16 + WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4 if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { for (i = 0; i < 4; i++) { @@ -227,7 +227,7 @@ void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pC const int32_t kiX1 = kiOffset + kiXOffset[2]; const int32_t kiX2 = STRIDE + kiOffset; const int32_t kiX3 = kiOffset + kiXOffset[3]; - const int32_t kiI4 = i << 2; // 4*i + const int32_t kiI4 = i << 2; // 4*i const int32_t kiZ0 = pBlk[kiOffset] + pBlk[kiX1]; const int32_t kiZ1 = pBlk[kiOffset] - pBlk[kiX1]; const int32_t kiZ2 = pBlk[kiX2] - pBlk[kiX3]; @@ -601,10 +601,10 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva } int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBsAux = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PDqLayer pCurLayer = pCtx->pCurDqLayer; + PBitStringAux pBsAux = pCurLayer->pBitStringAux; + PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; SWelsNeighAvail sNeighAvail; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; @@ -812,10 +812,10 @@ int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin } int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBsAux = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PDqLayer pCurLayer = pCtx->pCurDqLayer; + PBitStringAux pBsAux = pCurLayer->pBitStringAux; + PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; @@ -1048,9 +1048,9 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv } int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PDqLayer pCurLayer = pCtx->pCurDqLayer; + PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; uint32_t uiCode; int32_t iMbXy = pCurLayer->iMbXyIndex; @@ -1227,7 +1227,7 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal pCurLayer->iMbXyIndex = iNextMbXyIndex; do { - if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame + if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame break; } @@ -1260,10 +1260,10 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { SVlcTable* pVlcTable = &pCtx->sVlcTable; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PDqLayer pCurLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurLayer->pBitStringAux; + PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; SWelsNeighAvail sNeighAvail; int32_t iMbResProperty; @@ -1564,7 +1564,7 @@ int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin // check whether there is left bits to read next time in case multiple slices iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits); // sub 1, for stop bit - if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary + if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary uiEosFlag = 1; } if (iUsedBits > (pBs->iBits - @@ -1579,10 +1579,10 @@ int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { SVlcTable* pVlcTable = &pCtx->sVlcTable; - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PDqLayer pCurLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurLayer->pBitStringAux; + PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; @@ -1909,10 +1909,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { } int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { - PDqLayer pCurLayer = pCtx->pCurDqLayer; - PBitStringAux pBs = pCurLayer->pBitStringAux; - PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PDqLayer pCurLayer = pCtx->pCurDqLayer; + PBitStringAux pBs = pCurLayer->pBitStringAux; + PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; intX_t iUsedBits; const int32_t iMbXy = pCurLayer->iMbXyIndex; @@ -1987,7 +1987,7 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin // check whether there is left bits to read next time in case multiple slices iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits); // sub 1, for stop bit - if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary + if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary uiEosFlag = 1; } if (iUsedBits > (pBs->iBits - diff --git a/codec/decoder/core/src/decoder.cpp b/codec/decoder/core/src/decoder.cpp index 39aeb1eb..25d72fd7 100644 --- a/codec/decoder/core/src/decoder.cpp +++ b/codec/decoder/core/src/decoder.cpp @@ -67,7 +67,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons return 1; } - pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); + pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); if (NULL == pPicBuf) { return 1; @@ -93,9 +93,9 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons } // initialize context in queue - pPicBuf->iCapacity = kiSize; + pPicBuf->iCapacity = kiSize; pPicBuf->iCurrentIdx = 0; - * ppPicBuf = pPicBuf; + * ppPicBuf = pPicBuf; return 0; } @@ -109,7 +109,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co return 1; } - pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); + pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); if (NULL == pPicNewBuf) { return 1; @@ -139,9 +139,9 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof (PPicture)); // initialize context in queue - pPicNewBuf->iCapacity = kiNewSize; + pPicNewBuf->iCapacity = kiNewSize; pPicNewBuf->iCurrentIdx = pPicOldBuf->iCurrentIdx; - * ppPicBuf = pPicNewBuf; + * ppPicBuf = pPicNewBuf; for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { pPicNewBuf->ppPic[i]->bUsedAsRef = false; @@ -153,9 +153,9 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co // remove old PicBuf if (pPicOldBuf->ppPic != NULL) { WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); - pPicOldBuf->ppPic = NULL; + pPicOldBuf->ppPic = NULL; } - pPicOldBuf->iCapacity = 0; + pPicOldBuf->iCapacity = 0; pPicOldBuf->iCurrentIdx = 0; WelsFree (pPicOldBuf, "pPicOldBuf"); pPicOldBuf = NULL; @@ -171,7 +171,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co return 1; } - pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); + pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); if (NULL == pPicNewBuf) { return 1; @@ -180,7 +180,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); if (NULL == pPicNewBuf->ppPic) { - pPicNewBuf->iCapacity = 0; + pPicNewBuf->iCapacity = 0; DestroyPicBuff (&pPicNewBuf); return 1; } @@ -214,8 +214,8 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co } // initialize context in queue - pPicNewBuf->iCapacity = kiNewSize; - *ppPicBuf = pPicNewBuf; + pPicNewBuf->iCapacity = kiNewSize; + *ppPicBuf = pPicNewBuf; for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { pPicNewBuf->ppPic[i]->bUsedAsRef = false; @@ -227,9 +227,9 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co // remove old PicBuf if (pPicOldBuf->ppPic != NULL) { WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); - pPicOldBuf->ppPic = NULL; + pPicOldBuf->ppPic = NULL; } - pPicOldBuf->iCapacity = 0; + pPicOldBuf->iCapacity = 0; pPicOldBuf->iCurrentIdx = 0; WelsFree (pPicOldBuf, "pPicOldBuf"); pPicOldBuf = NULL; @@ -257,9 +257,9 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { WelsFree (pPicBuf->ppPic, "pPicBuf->queue"); - pPicBuf->ppPic = NULL; + pPicBuf->ppPic = NULL; } - pPicBuf->iCapacity = 0; + pPicBuf->iCapacity = 0; pPicBuf->iCurrentIdx = 0; WelsFree (pPicBuf, "pPicBuf"); @@ -272,40 +272,40 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { */ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { int32_t iCpuCores = 1; - memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first + memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first pCtx->sLogCtx = *pLogCtx; pCtx->pArgDec = NULL; - pCtx->eOutputColorFormat = videoFormatI420; // yuv in default - pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related - pCtx->uiCpuFlag = 0; + pCtx->eOutputColorFormat = videoFormatI420; // yuv in default + pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related + pCtx->uiCpuFlag = 0; - pCtx->bAuReadyFlag = 0; // au data is not ready + pCtx->bAuReadyFlag = 0; // au data is not ready pCtx->bCabacInited = false; pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); - pCtx->iImgWidthInPixel = 0; - pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available - pCtx->iLastImgWidthInPixel = 0; - pCtx->iLastImgHeightInPixel = 0; + pCtx->iImgWidthInPixel = 0; + pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available + pCtx->iLastImgWidthInPixel = 0; + pCtx->iLastImgHeightInPixel = 0; pCtx->bFreezeOutput = true; - pCtx->iFrameNum = -1; - pCtx->iPrevFrameNum = -1; - pCtx->iErrorCode = ERR_NONE; + pCtx->iFrameNum = -1; + pCtx->iPrevFrameNum = -1; + pCtx->iErrorCode = ERR_NONE; - pCtx->pDec = NULL; + pCtx->pDec = NULL; WelsResetRefPic (pCtx); - pCtx->iActiveFmoNum = 0; + pCtx->iActiveFmoNum = 0; - pCtx->pPicBuff[LIST_0] = NULL; - pCtx->pPicBuff[LIST_1] = NULL; + pCtx->pPicBuff[LIST_0] = NULL; + pCtx->pPicBuff[LIST_1] = NULL; - pCtx->bAvcBasedFlag = true; + pCtx->bAvcBasedFlag = true; pCtx->eErrorConMethod = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE; pCtx->pPreviousDecodedPictureInDpb = NULL; pCtx->sDecoderStatistics.iAvgLumaQp = -1; @@ -331,7 +331,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { * get size of reference picture list in target layer incoming, = (iNumRefFrames */ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { - int32_t iNumRefFrames = 0; + int32_t iNumRefFrames = 0; // +2 for EC MV Copy buffer exchange if ((pCtx == NULL) || (pCtx->pSps == NULL)) { iNumRefFrames = MAX_REF_PIC_COUNT + 2; @@ -353,30 +353,30 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { * request memory blocks for decoder avc part */ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { - const int32_t kiPicWidth = kiMbWidth << 4; - const int32_t kiPicHeight = kiMbHeight << 4; + const int32_t kiPicWidth = kiMbWidth << 4; + const int32_t kiPicHeight = kiMbHeight << 4; int32_t iErr = ERR_NONE; - int32_t iListIdx = 0; //, mb_blocks = 0; - int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) - bool bNeedChangePicQueue = true; + int32_t iListIdx = 0; //, mb_blocks = 0; + int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) + bool bNeedChangePicQueue = true; WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) // Fixed the issue about different gop size over last, 5/17/2010 // get picture queue size currently - iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) + iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) pCtx->iPicQueueNumber = iPicQueueSize; if (pCtx->pPicBuff[LIST_0] != NULL && pCtx->pPicBuff[LIST_0]->iCapacity == - iPicQueueSize) // comparing current picture queue size requested and previous allocation picture queue - bNeedChangePicQueue = false; + iPicQueueSize) // comparing current picture queue size requested and previous allocation picture queue + bNeedChangePicQueue = false; // HD based pic buffer need consider memory size consumed when switch from 720p to other lower size WELS_VERIFY_RETURN_IF (ERR_NONE, pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel - && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer + && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer // sync update pRefList - WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free + WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel) && pCtx->pPicBuff[LIST_0] != NULL && pCtx->pPicBuff[LIST_0]->iCapacity != iPicQueueSize) { @@ -418,11 +418,11 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const return iErr; - pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding - pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding + pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding + pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding - pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested - pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed + pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested + pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed if (pCtx->pCabacDecEngine == NULL) pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); @@ -450,12 +450,12 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { } // added for safe memory - pCtx->iImgWidthInPixel = 0; + pCtx->iImgWidthInPixel = 0; pCtx->iImgHeightInPixel = 0; - pCtx->iLastImgWidthInPixel = 0; + pCtx->iLastImgWidthInPixel = 0; pCtx->iLastImgHeightInPixel = 0; pCtx->bFreezeOutput = true; - pCtx->bHaveGotMemory = false; + pCtx->bHaveGotMemory = false; WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); } @@ -482,7 +482,7 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { #ifdef LONG_TERM_REF pCtx->bParamSetsLostFlag = true; #else - pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010 + pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010 #endif //LONG_TERM_REF pCtx->bNewSeqBegin = true; pCtx->bPrintFrameErrorTraceFlag = true; @@ -517,13 +517,13 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa if (NULL == pCtx || NULL == kpParam) return 1; - pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); + pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); if (NULL == pCtx->pParam) return 1; memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); - pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; + pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; if (!pCtx->bParseOnly) { int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); if (iRet) @@ -621,7 +621,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs int32_t iSrcConsumed = 0; // consumed bit count of source bs int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal - int32_t iSrcLength = 0; //the total size of current AU or NAL + int32_t iSrcLength = 0; //the total size of current AU or NAL int32_t iRet = 0; int32_t iConsumedBytes = 0; int32_t iOffset = 0; @@ -660,15 +660,15 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) { if (pSrcNal[2 + iSrcIdx] == 0x03) { ST16 (pDstNal + iDstIdx, 0); - iDstIdx += 2; - iSrcIdx += 3; + iDstIdx += 2; + iSrcIdx += 3; iSrcConsumed += 3; } else { iConsumedBytes = 0; pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = 0; // set 4 reserved bytes to zero - pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); + pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); if (pNalPayload) { //parse correct if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) { iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3); @@ -758,8 +758,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in return pCtx->iErrorCode; } } else { /* no supplementary picture payload input, but stored a picture */ - PAccessUnit pCurAu = - pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization + PAccessUnit pCurAu = + pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization if (pCurAu->uiAvailUnitsNum == 0) { return pCtx->iErrorCode; @@ -789,9 +789,9 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)); - pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat; + pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat; if (pCtx->pParam != NULL) { - pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat; + pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat; } //For now, support only videoFormatI420! @@ -817,10 +817,10 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { */ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { int32_t iErr = ERR_NONE; - const int32_t kiPicWidth = kiMbWidth << 4; + const int32_t kiPicWidth = kiMbWidth << 4; const int32_t kiPicHeight = kiMbHeight << 4; - iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used + iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used if (ERR_NONE != iErr) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure."); diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp index 83b3c5ba..8ed07c7d 100644 --- a/codec/decoder/core/src/decoder_core.cpp +++ b/codec/decoder/core/src/decoder_core.cpp @@ -60,7 +60,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t #ifdef LONG_TERM_REF pCtx->bParamSetsLostFlag = false; #else - pCtx->bReferenceLostAtT0Flag = false; // need initialize it due new seq, 6/4/2010 + pCtx->bReferenceLostAtT0Flag = false; // need initialize it due new seq, 6/4/2010 #endif //LONG_TERM_REF if (pCtx->iTotalNumMbRec == kiTotalNumMbInCurLayer) { pCtx->bPrintFrameErrorTraceFlag = true; @@ -329,7 +329,7 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) { // Common syntaxs for P or B slices: list0, list1 followed if B slices used. do { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //ref_pic_list_modification_flag_l0 - pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!uiCode; + pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!uiCode; if (pRefPicListReordering->bRefPicListReorderingFlag[iList]) { int32_t iIdx = 0; @@ -341,7 +341,7 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) { if ((iIdx >= MAX_REF_PIC_COUNT) || (kuiIdc > 3)) { return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING); } - pRefPicListReordering->sReorderingSyn[iList][iIdx].uiReorderingOfPicNumsIdc = kuiIdc; + pRefPicListReordering->sReorderingSyn[iList][iIdx].uiReorderingOfPicNumsIdc = kuiIdc; if (kuiIdc == 3) break; @@ -354,7 +354,7 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //abs_diff_pic_num_minus1 WELS_CHECK_SE_UPPER_ERROR_NOLOG (uiCode, (uint32_t) (1 << pSps->uiLog2MaxFrameNum), "abs_diff_pic_num_minus1", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING)); - pRefPicListReordering->sReorderingSyn[iList][iIdx].uiAbsDiffPicNumMinus1 = uiCode; // uiAbsDiffPicNumMinus1 + pRefPicListReordering->sReorderingSyn[iList][iIdx].uiAbsDiffPicNumMinus1 = uiCode; // uiAbsDiffPicNumMinus1 } else if (kuiIdc == 2) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num pRefPicListReordering->sReorderingSyn[iList][iIdx].uiLongTermPicNum = uiCode; @@ -377,12 +377,12 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli uint32_t uiCode; if (kbIdrFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //no_output_of_prior_pics_flag - kpRefMarking->bNoOutputOfPriorPicsFlag = !!uiCode; + kpRefMarking->bNoOutputOfPriorPicsFlag = !!uiCode; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //long_term_reference_flag - kpRefMarking->bLongTermRefFlag = !!uiCode; + kpRefMarking->bLongTermRefFlag = !!uiCode; } else { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_ref_pic_marking_mode_flag - kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!uiCode; + kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!uiCode; if (kpRefMarking->bAdaptiveRefPicMarkingModeFlag) { int32_t iIdx = 0; do { @@ -423,31 +423,31 @@ bool FillDefaultSliceHeaderExt (PSliceHeaderExt pShExt, PNalUnitHeaderExt pNalEx return false; if (pNalExt->iNoInterLayerPredFlag || pNalExt->uiQualityId > 0) - pShExt->bBasePredWeightTableFlag = false; + pShExt->bBasePredWeightTableFlag = false; else - pShExt->bBasePredWeightTableFlag = true; + pShExt->bBasePredWeightTableFlag = true; pShExt->uiRefLayerDqId = (uint8_t) - 1; - pShExt->uiDisableInterLayerDeblockingFilterIdc = 0; - pShExt->iInterLayerSliceAlphaC0Offset = 0; - pShExt->iInterLayerSliceBetaOffset = 0; - pShExt->bConstrainedIntraResamplingFlag = false; - pShExt->uiRefLayerChromaPhaseXPlus1Flag = 0; - pShExt->uiRefLayerChromaPhaseYPlus1 = 1; + pShExt->uiDisableInterLayerDeblockingFilterIdc = 0; + pShExt->iInterLayerSliceAlphaC0Offset = 0; + pShExt->iInterLayerSliceBetaOffset = 0; + pShExt->bConstrainedIntraResamplingFlag = false; + pShExt->uiRefLayerChromaPhaseXPlus1Flag = 0; + pShExt->uiRefLayerChromaPhaseYPlus1 = 1; //memset(&pShExt->sScaledRefLayer, 0, sizeof(SPosOffset)); - pShExt->iScaledRefLayerPicWidthInSampleLuma = pShExt->sSliceHeader.iMbWidth << 4; - pShExt->iScaledRefLayerPicHeightInSampleLuma = pShExt->sSliceHeader.iMbHeight << 4; + pShExt->iScaledRefLayerPicWidthInSampleLuma = pShExt->sSliceHeader.iMbWidth << 4; + pShExt->iScaledRefLayerPicHeightInSampleLuma = pShExt->sSliceHeader.iMbHeight << 4; - pShExt->bSliceSkipFlag = false; - pShExt->bAdaptiveBaseModeFlag = false; - pShExt->bDefaultBaseModeFlag = false; - pShExt->bAdaptiveMotionPredFlag = false; - pShExt->bDefaultMotionPredFlag = false; - pShExt->bAdaptiveResidualPredFlag = false; - pShExt->bDefaultResidualPredFlag = false; - pShExt->bTCoeffLevelPredFlag = false; - pShExt->uiScanIdxStart = 0; - pShExt->uiScanIdxEnd = 15; + pShExt->bSliceSkipFlag = false; + pShExt->bAdaptiveBaseModeFlag = false; + pShExt->bDefaultBaseModeFlag = false; + pShExt->bAdaptiveMotionPredFlag = false; + pShExt->bDefaultMotionPredFlag = false; + pShExt->bAdaptiveResidualPredFlag = false; + pShExt->bDefaultResidualPredFlag = false; + pShExt->bTCoeffLevelPredFlag = false; + pShExt->uiScanIdxStart = 0; + pShExt->uiScanIdxEnd = 15; return true; } @@ -551,8 +551,8 @@ int32_t WelsInitMemory (PWelsDecoderContext pCtx) { if (InitBsBuffer (pCtx) != 0) return ERR_INFO_OUT_OF_MEMORY; - pCtx->uiTargetDqId = (uint8_t) - 1; - pCtx->bEndOfStreamFlag = false; + pCtx->uiTargetDqId = (uint8_t) - 1; + pCtx->bEndOfStreamFlag = false; return ERR_NONE; } @@ -579,15 +579,15 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { } pCtx->sRawData.pHead = NULL; pCtx->sRawData.pEnd = NULL; - pCtx->sRawData.pStartPos = NULL; - pCtx->sRawData.pCurPos = NULL; + pCtx->sRawData.pStartPos = NULL; + pCtx->sRawData.pCurPos = NULL; if (pCtx->bParseOnly) { if (pCtx->sSavedData.pHead) { WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); } pCtx->sSavedData.pHead = NULL; pCtx->sSavedData.pEnd = NULL; - pCtx->sSavedData.pStartPos = NULL; + pCtx->sSavedData.pStartPos = NULL; pCtx->sSavedData.pCurPos = NULL; if (pCtx->pParserBsInfo) { if (pCtx->pParserBsInfo->pDstBuff) { @@ -610,20 +610,20 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) { PNalUnitHeaderExt pHeaderExt = &pNal->sNalHeaderExt; uint8_t uiCurByte = *pSrc; - pHeaderExt->bIdrFlag = !! (uiCurByte & 0x40); - pHeaderExt->uiPriorityId = uiCurByte & 0x3F; + pHeaderExt->bIdrFlag = !! (uiCurByte & 0x40); + pHeaderExt->uiPriorityId = uiCurByte & 0x3F; uiCurByte = * (++pSrc); pHeaderExt->iNoInterLayerPredFlag = uiCurByte >> 7; - pHeaderExt->uiDependencyId = (uiCurByte & 0x70) >> 4; - pHeaderExt->uiQualityId = uiCurByte & 0x0F; + pHeaderExt->uiDependencyId = (uiCurByte & 0x70) >> 4; + pHeaderExt->uiQualityId = uiCurByte & 0x0F; uiCurByte = * (++pSrc); - pHeaderExt->uiTemporalId = uiCurByte >> 5; - pHeaderExt->bUseRefBasePicFlag = !! (uiCurByte & 0x10); - pHeaderExt->bDiscardableFlag = !! (uiCurByte & 0x08); - pHeaderExt->bOutputFlag = !! (uiCurByte & 0x04); - pHeaderExt->uiReservedThree2Bits = uiCurByte & 0x03; - pHeaderExt->uiLayerDqId = (pHeaderExt->uiDependencyId << 4) | pHeaderExt->uiQualityId; + pHeaderExt->uiTemporalId = uiCurByte >> 5; + pHeaderExt->bUseRefBasePicFlag = !! (uiCurByte & 0x10); + pHeaderExt->bDiscardableFlag = !! (uiCurByte & 0x08); + pHeaderExt->bOutputFlag = !! (uiCurByte & 0x04); + pHeaderExt->uiReservedThree2Bits = uiCurByte & 0x03; + pHeaderExt->uiLayerDqId = (pHeaderExt->uiDependencyId << 4) | pHeaderExt->uiQualityId; } @@ -640,21 +640,21 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) { * Parse slice header of bitstream in avc for storing data structure */ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) { - PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1]; + PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1]; - PNalUnitHeaderExt pNalHeaderExt = NULL; - PSliceHeader pSliceHead = NULL; - PSliceHeaderExt pSliceHeadExt = NULL; - PSubsetSps pSubsetSps = NULL; - PSps pSps = NULL; - PPps pPps = NULL; - EWelsNalUnitType eNalType = static_cast (0); - int32_t iPpsId = 0; - int32_t iRet = ERR_NONE; - uint8_t uiSliceType = 0; - uint8_t uiQualityId = BASE_QUALITY_ID; - bool bIdrFlag = false; - bool bSgChangeCycleInvolved = false; // involved slice group change cycle ? + PNalUnitHeaderExt pNalHeaderExt = NULL; + PSliceHeader pSliceHead = NULL; + PSliceHeaderExt pSliceHeadExt = NULL; + PSubsetSps pSubsetSps = NULL; + PSps pSps = NULL; + PPps pPps = NULL; + EWelsNalUnitType eNalType = static_cast (0); + int32_t iPpsId = 0; + int32_t iRet = ERR_NONE; + uint8_t uiSliceType = 0; + uint8_t uiQualityId = BASE_QUALITY_ID; + bool bIdrFlag = false; + bool bSgChangeCycleInvolved = false; // involved slice group change cycle ? uint32_t uiCode; int32_t iCode; SLogContext* pLogCtx = & (pCtx->sLogCtx); @@ -663,26 +663,26 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co return ERR_INFO_OUT_OF_MEMORY; } - pNalHeaderExt = &kpCurNal->sNalHeaderExt; - pSliceHead = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; - eNalType = pNalHeaderExt->sNalUnitHeader.eNalUnitType; + pNalHeaderExt = &kpCurNal->sNalHeaderExt; + pSliceHead = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; + eNalType = pNalHeaderExt->sNalUnitHeader.eNalUnitType; - pSliceHeadExt = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt; + pSliceHeadExt = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt; if (pSliceHeadExt) { SRefBasePicMarking sBaseMarking; const bool kbStoreRefBaseFlag = pSliceHeadExt->bStoreRefBasePicFlag; memcpy (&sBaseMarking, &pSliceHeadExt->sRefBasePicMarking, sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage memset (pSliceHeadExt, 0, sizeof (SSliceHeaderExt)); - pSliceHeadExt->bStoreRefBasePicFlag = kbStoreRefBaseFlag; + pSliceHeadExt->bStoreRefBasePicFlag = kbStoreRefBaseFlag; memcpy (&pSliceHeadExt->sRefBasePicMarking, &sBaseMarking, sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage } - kpCurNal->sNalData.sVclNal.bSliceHeaderExtFlag = kbExtensionFlag; + kpCurNal->sNalData.sVclNal.bSliceHeaderExtFlag = kbExtensionFlag; // first_mb_in_slice WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //first_mb_in_slice - pSliceHead->iFirstMbInSlice = uiCode; + pSliceHead->iFirstMbInSlice = uiCode; WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //slice_type uiSliceType = uiCode; @@ -710,7 +710,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } } - pSliceHead->eSliceType = static_cast (uiSliceType); + pSliceHead->eSliceType = static_cast (uiSliceType); WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id iPpsId = uiCode; @@ -746,7 +746,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co if (kbExtensionFlag) { pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; - pSps = &pSubsetSps->sSps; + pSps = &pSubsetSps->sSps; if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) { pCtx->sDecoderStatistics.iSubSpsReportErrorNum++; if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) { @@ -776,7 +776,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); } pCtx->iSPSLastInvalidId = -1; - pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; + pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; } pSliceHead->iPpsId = iPpsId; pSliceHead->iSpsId = pPps->iSpsId; @@ -798,15 +798,15 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co WELS_READ_VERIFY (BsGetBits (pBs, pSps->uiLog2MaxFrameNum, &uiCode)); //frame_num pSliceHead->iFrameNum = uiCode; - pSliceHead->bFieldPicFlag = false; - pSliceHead->bBottomFiledFlag = false; + pSliceHead->bFieldPicFlag = false; + pSliceHead->bBottomFiledFlag = false; if (!pSps->bFrameMbsOnlyFlag) { WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseSliceHeaderSyntaxs(): frame_mbs_only_flag = %d not supported. ", pSps->bFrameMbsOnlyFlag); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MBAFF); } - pSliceHead->iMbWidth = pSps->iMbWidth; - pSliceHead->iMbHeight = pSps->iMbHeight / (1 + pSliceHead->bFieldPicFlag); + pSliceHead->iMbWidth = pSps->iMbWidth; + pSliceHead->iMbHeight = pSps->iMbHeight / (1 + pSliceHead->bFieldPicFlag); if (bIdrFlag) { if (pSliceHead->iFrameNum != 0) { @@ -819,32 +819,32 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co // standard 7.4.3 idr_pic_id should be in range 0 to 65535, inclusive. WELS_CHECK_SE_UPPER_ERROR (uiCode, SLICE_HEADER_IDR_PIC_ID_MAX, "idr_pic_id", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_IDR_PIC_ID)); - pSliceHead->uiIdrPicId = uiCode; /* uiIdrPicId */ + pSliceHead->uiIdrPicId = uiCode; /* uiIdrPicId */ #ifdef LONG_TERM_REF - pCtx->uiCurIdrPicId = pSliceHead->uiIdrPicId; + pCtx->uiCurIdrPicId = pSliceHead->uiIdrPicId; #endif } - pSliceHead->iDeltaPicOrderCntBottom = 0; - pSliceHead->iDeltaPicOrderCnt[0] = - pSliceHead->iDeltaPicOrderCnt[1] = 0; + pSliceHead->iDeltaPicOrderCntBottom = 0; + pSliceHead->iDeltaPicOrderCnt[0] = + pSliceHead->iDeltaPicOrderCnt[1] = 0; if (pSps->uiPocType == 0) { WELS_READ_VERIFY (BsGetBits (pBs, pSps->iLog2MaxPocLsb, &uiCode)); //pic_order_cnt_lsb - pSliceHead->iPicOrderCntLsb = uiCode; + pSliceHead->iPicOrderCntLsb = uiCode; if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) { WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt_bottom - pSliceHead->iDeltaPicOrderCntBottom = iCode; + pSliceHead->iDeltaPicOrderCntBottom = iCode; } } else if (pSps->uiPocType == 1 && !pSps->bDeltaPicOrderAlwaysZeroFlag) { WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt[ 0 ] - pSliceHead->iDeltaPicOrderCnt[0] = iCode; + pSliceHead->iDeltaPicOrderCnt[0] = iCode; if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) { WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt[ 1 ] pSliceHead->iDeltaPicOrderCnt[1] = iCode; } } - pSliceHead->iRedundantPicCnt = 0; + pSliceHead->iRedundantPicCnt = 0; if (pPps->bRedundantPicCntPresentFlag) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //redundant_pic_cnt // standard section 7.4.3, redundant_pic_cnt should be in range 0 to 127, inclusive. @@ -854,8 +854,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } //set defaults, might be overriden a few line later - pSliceHead->uiRefCount[0] = pPps->uiNumRefIdxL0Active; - pSliceHead->uiRefCount[1] = pPps->uiNumRefIdxL1Active; + pSliceHead->uiRefCount[0] = pPps->uiNumRefIdxL0Active; + pSliceHead->uiRefCount[1] = pPps->uiNumRefIdxL1Active; bool bReadNumRefFlag = (P_SLICE == uiSliceType); if (kbExtensionFlag) { @@ -863,12 +863,12 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } if (bReadNumRefFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //num_ref_idx_active_override_flag - pSliceHead->bNumRefIdxActiveOverrideFlag = !!uiCode; + pSliceHead->bNumRefIdxActiveOverrideFlag = !!uiCode; if (pSliceHead->bNumRefIdxActiveOverrideFlag) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_ref_idx_l0_active_minus1 WELS_CHECK_SE_UPPER_ERROR (uiCode, MAX_NUM_REF_IDX_L0_ACTIVE_MINUS1, "num_ref_idx_l0_active_minus1", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_NUM_REF_IDX_L0_ACTIVE_MINUS1)); - pSliceHead->uiRefCount[0] = 1 + uiCode; + pSliceHead->uiRefCount[0] = 1 + uiCode; } } @@ -894,9 +894,9 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co if (kbExtensionFlag) { if (pNalHeaderExt->iNoInterLayerPredFlag || pNalHeaderExt->uiQualityId > 0) - pSliceHeadExt->bBasePredWeightTableFlag = false; + pSliceHeadExt->bBasePredWeightTableFlag = false; else - pSliceHeadExt->bBasePredWeightTableFlag = true; + pSliceHeadExt->bBasePredWeightTableFlag = true; } if (kpCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) { @@ -907,7 +907,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co if (kbExtensionFlag && !pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //store_ref_base_pic_flag - pSliceHeadExt->bStoreRefBasePicFlag = !!uiCode; + pSliceHeadExt->bStoreRefBasePicFlag = !!uiCode; if ((pNalHeaderExt->bUseRefBasePicFlag || pSliceHeadExt->bStoreRefBasePicFlag) && !bIdrFlag) { WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseSliceHeaderSyntaxs(): bUseRefBasePicFlag or bStoreRefBasePicFlag = 1 not supported."); @@ -928,8 +928,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_qp_delta - pSliceHead->iSliceQpDelta = iCode; - pSliceHead->iSliceQp = pPps->iPicInitQp + pSliceHead->iSliceQpDelta; + pSliceHead->iSliceQpDelta = iCode; + pSliceHead->iSliceQp = pPps->iPicInitQp + pSliceHead->iSliceQpDelta; if (pSliceHead->iSliceQp < 0 || pSliceHead->iSliceQp > 51) { WelsLog (pLogCtx, WELS_LOG_WARNING, "QP %d out of range", pSliceHead->iSliceQp); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_QP); @@ -943,12 +943,12 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } } - pSliceHead->uiDisableDeblockingFilterIdc = 0; - pSliceHead->iSliceAlphaC0Offset = 0; - pSliceHead->iSliceBetaOffset = 0; + pSliceHead->uiDisableDeblockingFilterIdc = 0; + pSliceHead->iSliceAlphaC0Offset = 0; + pSliceHead->iSliceBetaOffset = 0; if (pPps->bDeblockingFilterControlPresentFlag) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_deblocking_filter_idc - pSliceHead->uiDisableDeblockingFilterIdc = uiCode; + pSliceHead->uiDisableDeblockingFilterIdc = uiCode; //refer to JVT-X201wcm1.doc G.7.4.3.4--2010.4.20 if (pSliceHead->uiDisableDeblockingFilterIdc > 6) { WelsLog (pLogCtx, WELS_LOG_WARNING, "disable_deblock_filter_idc (%d) out of range [0, 6]", @@ -957,19 +957,19 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } if (pSliceHead->uiDisableDeblockingFilterIdc != 1) { WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_alpha_c0_offset_div2 - pSliceHead->iSliceAlphaC0Offset = iCode * 2; + pSliceHead->iSliceAlphaC0Offset = iCode * 2; WELS_CHECK_SE_BOTH_ERROR (pSliceHead->iSliceAlphaC0Offset, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MAX, "slice_alpha_c0_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2)); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_beta_offset_div2 - pSliceHead->iSliceBetaOffset = iCode * 2; + pSliceHead->iSliceBetaOffset = iCode * 2; WELS_CHECK_SE_BOTH_ERROR (pSliceHead->iSliceBetaOffset, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MAX, "slice_beta_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2)); } } - bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3 + bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3 && pPps->uiSliceGroupMapType <= 5); if (kbExtensionFlag && bSgChangeCycleInvolved) bSgChangeCycleInvolved = (bSgChangeCycleInvolved && (uiQualityId == BASE_QUALITY_ID)); @@ -978,24 +978,24 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co const int32_t kiNumBits = (int32_t)WELS_CEIL (log (static_cast (1 + pPps->uiPicSizeInMapUnits / pPps->uiSliceGroupChangeRate))); WELS_READ_VERIFY (BsGetBits (pBs, kiNumBits, &uiCode)); //lice_group_change_cycle - pSliceHead->iSliceGroupChangeCycle = uiCode; + pSliceHead->iSliceGroupChangeCycle = uiCode; } else - pSliceHead->iSliceGroupChangeCycle = 0; + pSliceHead->iSliceGroupChangeCycle = 0; } if (!kbExtensionFlag) { FillDefaultSliceHeaderExt (pSliceHeadExt, pNalHeaderExt); } else { /* Extra syntax elements newly introduced */ - pSliceHeadExt->pSubsetSps = pSubsetSps; + pSliceHeadExt->pSubsetSps = pSubsetSps; if (!pNalHeaderExt->iNoInterLayerPredFlag && BASE_QUALITY_ID == uiQualityId) { //the following should be deleted for CODE_CLEAN WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //ref_layer_dq_id - pSliceHeadExt->uiRefLayerDqId = uiCode; + pSliceHeadExt->uiRefLayerDqId = uiCode; if (pSubsetSps->sSpsSvcExt.bInterLayerDeblockingFilterCtrlPresentFlag) { WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_inter_layer_deblocking_filter_idc - pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc = uiCode; + pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc = uiCode; //refer to JVT-X201wcm1.doc G.7.4.3.4--2010.4.20 if (pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc > 6) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "disable_inter_layer_deblock_filter_idc (%d) out of range [0, 6]", @@ -1004,79 +1004,79 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } if (pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc != 1) { WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //inter_layer_slice_alpha_c0_offset_div2 - pSliceHeadExt->iInterLayerSliceAlphaC0Offset = iCode * 2; + pSliceHeadExt->iInterLayerSliceAlphaC0Offset = iCode * 2; WELS_CHECK_SE_BOTH_ERROR (pSliceHeadExt->iInterLayerSliceAlphaC0Offset, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MIN, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MAX, "inter_layer_alpha_c0_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2)); WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //inter_layer_slice_beta_offset_div2 - pSliceHeadExt->iInterLayerSliceBetaOffset = iCode * 2; + pSliceHeadExt->iInterLayerSliceBetaOffset = iCode * 2; WELS_CHECK_SE_BOTH_ERROR (pSliceHeadExt->iInterLayerSliceBetaOffset, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MIN, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MAX, "inter_layer_slice_beta_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2)); } } - pSliceHeadExt->uiRefLayerChromaPhaseXPlus1Flag = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseXPlus1Flag; - pSliceHeadExt->uiRefLayerChromaPhaseYPlus1 = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseYPlus1; + pSliceHeadExt->uiRefLayerChromaPhaseXPlus1Flag = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseXPlus1Flag; + pSliceHeadExt->uiRefLayerChromaPhaseYPlus1 = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseYPlus1; WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constrained_intra_resampling_flag - pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode; + pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode; { SPosOffset pos; - pos.iLeftOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iLeftOffset; - pos.iTopOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iTopOffset * (2 - pSps->bFrameMbsOnlyFlag); - pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset; + pos.iLeftOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iLeftOffset; + pos.iTopOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iTopOffset * (2 - pSps->bFrameMbsOnlyFlag); + pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset; pos.iBottomOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iBottomOffset * (2 - pSps->bFrameMbsOnlyFlag); //memcpy(&pSliceHeadExt->sScaledRefLayer, &pos, sizeof(SPosOffset));//confirmed_safe_unsafe_usage - pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - (pos.iLeftOffset + pos.iRightOffset); - pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) - + pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - (pos.iLeftOffset + pos.iRightOffset); + pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) - (pos.iTopOffset + pos.iBottomOffset) / (1 + pSliceHead->bFieldPicFlag); } } else if (uiQualityId > BASE_QUALITY_ID) { WelsLog (pLogCtx, WELS_LOG_WARNING, "MGS not supported."); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MGS); } else { - pSliceHeadExt->uiRefLayerDqId = (uint8_t) - 1; + pSliceHeadExt->uiRefLayerDqId = (uint8_t) - 1; } - pSliceHeadExt->bSliceSkipFlag = false; - pSliceHeadExt->bAdaptiveBaseModeFlag = false; - pSliceHeadExt->bDefaultBaseModeFlag = false; - pSliceHeadExt->bAdaptiveMotionPredFlag = false; - pSliceHeadExt->bDefaultMotionPredFlag = false; - pSliceHeadExt->bAdaptiveResidualPredFlag = false; - pSliceHeadExt->bDefaultResidualPredFlag = false; + pSliceHeadExt->bSliceSkipFlag = false; + pSliceHeadExt->bAdaptiveBaseModeFlag = false; + pSliceHeadExt->bDefaultBaseModeFlag = false; + pSliceHeadExt->bAdaptiveMotionPredFlag = false; + pSliceHeadExt->bDefaultMotionPredFlag = false; + pSliceHeadExt->bAdaptiveResidualPredFlag = false; + pSliceHeadExt->bDefaultResidualPredFlag = false; if (pNalHeaderExt->iNoInterLayerPredFlag) - pSliceHeadExt->bTCoeffLevelPredFlag = false; + pSliceHeadExt->bTCoeffLevelPredFlag = false; else - pSliceHeadExt->bTCoeffLevelPredFlag = pSubsetSps->sSpsSvcExt.bSeqTCoeffLevelPredFlag; + pSliceHeadExt->bTCoeffLevelPredFlag = pSubsetSps->sSpsSvcExt.bSeqTCoeffLevelPredFlag; if (!pNalHeaderExt->iNoInterLayerPredFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_skip_flag - pSliceHeadExt->bSliceSkipFlag = !!uiCode; + pSliceHeadExt->bSliceSkipFlag = !!uiCode; if (pSliceHeadExt->bSliceSkipFlag) { WelsLog (pLogCtx, WELS_LOG_WARNING, "bSliceSkipFlag == 1 not supported."); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_SLICESKIP); } else { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_base_mode_flag - pSliceHeadExt->bAdaptiveBaseModeFlag = !!uiCode; + pSliceHeadExt->bAdaptiveBaseModeFlag = !!uiCode; if (!pSliceHeadExt->bAdaptiveBaseModeFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_base_mode_flag - pSliceHeadExt->bDefaultBaseModeFlag = !!uiCode; + pSliceHeadExt->bDefaultBaseModeFlag = !!uiCode; } if (!pSliceHeadExt->bDefaultBaseModeFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_motion_prediction_flag - pSliceHeadExt->bAdaptiveMotionPredFlag = !!uiCode; + pSliceHeadExt->bAdaptiveMotionPredFlag = !!uiCode; if (!pSliceHeadExt->bAdaptiveMotionPredFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_motion_prediction_flag - pSliceHeadExt->bDefaultMotionPredFlag = !!uiCode; + pSliceHeadExt->bDefaultMotionPredFlag = !!uiCode; } } WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_residual_prediction_flag - pSliceHeadExt->bAdaptiveResidualPredFlag = !!uiCode; + pSliceHeadExt->bAdaptiveResidualPredFlag = !!uiCode; if (!pSliceHeadExt->bAdaptiveResidualPredFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_residual_prediction_flag pSliceHeadExt->bDefaultResidualPredFlag = !!uiCode; @@ -1084,23 +1084,23 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } if (pSubsetSps->sSpsSvcExt.bAdaptiveTCoeffLevelPredFlag) { WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //tcoeff_level_prediction_flag - pSliceHeadExt->bTCoeffLevelPredFlag = !!uiCode; + pSliceHeadExt->bTCoeffLevelPredFlag = !!uiCode; } } if (!pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) { WELS_READ_VERIFY (BsGetBits (pBs, 4, &uiCode)); //scan_idx_start - pSliceHeadExt->uiScanIdxStart = uiCode; + pSliceHeadExt->uiScanIdxStart = uiCode; WELS_READ_VERIFY (BsGetBits (pBs, 4, &uiCode)); //scan_idx_end - pSliceHeadExt->uiScanIdxEnd = uiCode; + pSliceHeadExt->uiScanIdxEnd = uiCode; if (pSliceHeadExt->uiScanIdxStart != 0 || pSliceHeadExt->uiScanIdxEnd != 15) { WelsLog (pLogCtx, WELS_LOG_WARNING, "uiScanIdxStart (%d) != 0 and uiScanIdxEnd (%d) !=15 not supported here", pSliceHeadExt->uiScanIdxStart, pSliceHeadExt->uiScanIdxEnd); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MGS); } } else { - pSliceHeadExt->uiScanIdxStart = 0; - pSliceHeadExt->uiScanIdxEnd = 15; + pSliceHeadExt->uiScanIdxStart = 0; + pSliceHeadExt->uiScanIdxEnd = 15; } } @@ -1113,7 +1113,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co * ppDst: succeeded VCL NAL based AVC (I/P Slice) */ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst, PNalUnit const kpSrc) { - PNalUnitHeaderExt pNalHdrExtD = NULL, pNalHdrExtS = NULL; + PNalUnitHeaderExt pNalHdrExtD = NULL, pNalHdrExtS = NULL; PSliceHeaderExt pShExtD = NULL; PPrefixNalUnit pPrefixS = NULL; PSps pSps = NULL; @@ -1122,24 +1122,24 @@ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst if (kppDst == NULL || kpSrc == NULL) return false; - pNalHdrExtD = &kppDst->sNalHeaderExt; - pNalHdrExtS = &kpSrc->sNalHeaderExt; - pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt; - pPrefixS = &kpSrc->sNalData.sPrefixNal; - pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId]; + pNalHdrExtD = &kppDst->sNalHeaderExt; + pNalHdrExtS = &kpSrc->sNalHeaderExt; + pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt; + pPrefixS = &kpSrc->sNalData.sPrefixNal; + pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId]; - pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId; - pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId; - pNalHdrExtD->uiTemporalId = pNalHdrExtS->uiTemporalId; - pNalHdrExtD->uiPriorityId = pNalHdrExtS->uiPriorityId; - pNalHdrExtD->bIdrFlag = pNalHdrExtS->bIdrFlag; - pNalHdrExtD->iNoInterLayerPredFlag = pNalHdrExtS->iNoInterLayerPredFlag; - pNalHdrExtD->bDiscardableFlag = pNalHdrExtS->bDiscardableFlag; - pNalHdrExtD->bOutputFlag = pNalHdrExtS->bOutputFlag; - pNalHdrExtD->bUseRefBasePicFlag = pNalHdrExtS->bUseRefBasePicFlag; - pNalHdrExtD->uiLayerDqId = pNalHdrExtS->uiLayerDqId; + pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId; + pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId; + pNalHdrExtD->uiTemporalId = pNalHdrExtS->uiTemporalId; + pNalHdrExtD->uiPriorityId = pNalHdrExtS->uiPriorityId; + pNalHdrExtD->bIdrFlag = pNalHdrExtS->bIdrFlag; + pNalHdrExtD->iNoInterLayerPredFlag = pNalHdrExtS->iNoInterLayerPredFlag; + pNalHdrExtD->bDiscardableFlag = pNalHdrExtS->bDiscardableFlag; + pNalHdrExtD->bOutputFlag = pNalHdrExtS->bOutputFlag; + pNalHdrExtD->bUseRefBasePicFlag = pNalHdrExtS->bUseRefBasePicFlag; + pNalHdrExtD->uiLayerDqId = pNalHdrExtS->uiLayerDqId; - pShExtD->bStoreRefBasePicFlag = pPrefixS->bStoreRefBasePicFlag; + pShExtD->bStoreRefBasePicFlag = pPrefixS->bStoreRefBasePicFlag; memcpy (&pShExtD->sRefBasePicMarking, &pPrefixS->sRefPicBaseMarking, sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage if (pShExtD->sRefBasePicMarking.bAdaptiveRefBasePicMarkingModeFlag) { @@ -1161,7 +1161,7 @@ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) { - PAccessUnit pCurAu = pCtx->pAccessUnitList; + PAccessUnit pCurAu = pCtx->pAccessUnitList; int32_t iIdx = pCurAu->uiEndPos; // Conversed iterator @@ -1186,7 +1186,7 @@ int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) { ++ uiActualIdx; } if (uiActualIdx == - pCurAu->uiActualUnitsNum) { // no found IDR nal within incoming AU, need exit to avoid mosaic issue, 11/19/2009 + pCurAu->uiActualUnitsNum) { // no found IDR nal within incoming AU, need exit to avoid mosaic issue, 11/19/2009 pCtx->sDecoderStatistics.uiIDRLostNum++; WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, @@ -1211,11 +1211,11 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid int32_t i = 0; WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiMaxWidth <= 0 || kiMaxHeight <= 0)) - pCtx->sMb.iMbWidth = (kiMaxWidth + 15) >> 4; - pCtx->sMb.iMbHeight = (kiMaxHeight + 15) >> 4; + pCtx->sMb.iMbWidth = (kiMaxWidth + 15) >> 4; + pCtx->sMb.iMbHeight = (kiMaxHeight + 15) >> 4; if (pCtx->bInitialDqLayersMem && kiMaxWidth <= pCtx->iPicWidthReq - && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped + && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped return ERR_NONE; @@ -1270,7 +1270,7 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid sizeof ( int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), - "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 + "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), "pCtx->sMb.pResidualPredFlag[]"); //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); @@ -1313,9 +1313,9 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid ++ i; } while (i < LAYER_NUM_EXCHANGEABLE); - pCtx->bInitialDqLayersMem = true; - pCtx->iPicWidthReq = kiMaxWidth; - pCtx->iPicHeightReq = kiMaxHeight; + pCtx->bInitialDqLayersMem = true; + pCtx->iPicWidthReq = kiMaxWidth; + pCtx->iPicHeightReq = kiMaxHeight; return ERR_NONE; } @@ -1432,9 +1432,9 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { // if (pCtx->sMb.pMotionPredFlag[i]) //{ - // WelsFree( pCtx->sMb.pMotionPredFlag[i], "pCtx->sMb.pMotionPredFlag[]" ); + // WelsFree( pCtx->sMb.pMotionPredFlag[i], "pCtx->sMb.pMotionPredFlag[]" ); - // pCtx->sMb.pMotionPredFlag[i] = NULL; + // pCtx->sMb.pMotionPredFlag[i] = NULL; //} if (pCtx->sMb.pSubMbType[i]) { @@ -1478,22 +1478,22 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { ++ i; } while (i < LAYER_NUM_EXCHANGEABLE); - pCtx->iPicWidthReq = 0; - pCtx->iPicHeightReq = 0; - pCtx->bInitialDqLayersMem = false; + pCtx->iPicWidthReq = 0; + pCtx->iPicHeightReq = 0; + pCtx->bInitialDqLayersMem = false; } void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) { PAccessUnit pCurAu = pCtx->pAccessUnitList; pCurAu->uiStartPos = 0; - pCurAu->uiEndPos = 0; - pCurAu->bCompletedAuFlag = false; + pCurAu->uiEndPos = 0; + pCurAu->bCompletedAuFlag = false; if (pCurAu->uiActualUnitsNum > 0) { uint32_t iIdx = 0; const uint32_t kuiActualNum = pCurAu->uiActualUnitsNum; // a more simpler method to do nal units list management prefered here - const uint32_t kuiAvailNum = pCurAu->uiAvailUnitsNum; - const uint32_t kuiLeftNum = kuiAvailNum - kuiActualNum; + const uint32_t kuiAvailNum = pCurAu->uiAvailUnitsNum; + const uint32_t kuiLeftNum = kuiAvailNum - kuiActualNum; // Swapping active nal unit nodes of succeeding AU with leading of list while (iIdx < kuiLeftNum) { @@ -1502,7 +1502,7 @@ void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) { pCurAu->pNalUnitsList[iIdx] = t; ++ iIdx; } - pCurAu->uiActualUnitsNum = pCurAu->uiAvailUnitsNum = kuiLeftNum; + pCurAu->uiActualUnitsNum = pCurAu->uiAvailUnitsNum = kuiLeftNum; } } @@ -1512,27 +1512,27 @@ void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) { * \history 11/16/2009 */ void ForceResetCurrentAccessUnit (PAccessUnit pAu) { - uint32_t uiSucAuIdx = pAu->uiEndPos + 1; - uint32_t uiCurAuIdx = 0; + uint32_t uiSucAuIdx = pAu->uiEndPos + 1; + uint32_t uiCurAuIdx = 0; // swap the succeeding AU's nal units to the front while (uiSucAuIdx < pAu->uiAvailUnitsNum) { PNalUnit t = pAu->pNalUnitsList[uiSucAuIdx]; - pAu->pNalUnitsList[uiSucAuIdx] = pAu->pNalUnitsList[uiCurAuIdx]; - pAu->pNalUnitsList[uiCurAuIdx] = t; + pAu->pNalUnitsList[uiSucAuIdx] = pAu->pNalUnitsList[uiCurAuIdx]; + pAu->pNalUnitsList[uiCurAuIdx] = t; ++ uiSucAuIdx; ++ uiCurAuIdx; } // Update avail/actual units num accordingly for next AU parsing if (pAu->uiAvailUnitsNum > pAu->uiEndPos) - pAu->uiAvailUnitsNum -= (pAu->uiEndPos + 1); + pAu->uiAvailUnitsNum -= (pAu->uiEndPos + 1); else - pAu->uiAvailUnitsNum = 0; - pAu->uiActualUnitsNum = 0; + pAu->uiAvailUnitsNum = 0; + pAu->uiActualUnitsNum = 0; pAu->uiStartPos = 0; - pAu->uiEndPos = 0; - pAu->bCompletedAuFlag = false; + pAu->uiEndPos = 0; + pAu->bCompletedAuFlag = false; } //clear current corrupted NAL from pNalUnitsList @@ -1547,11 +1547,11 @@ void ForceResetParaSetStatusAndAUList (PWelsDecoderContext pCtx) { pCtx->bPpsExistAheadFlag = false; // Force clear the AU list - pCtx->pAccessUnitList->uiAvailUnitsNum = 0; - pCtx->pAccessUnitList->uiActualUnitsNum = 0; - pCtx->pAccessUnitList->uiStartPos = 0; - pCtx->pAccessUnitList->uiEndPos = 0; - pCtx->pAccessUnitList->bCompletedAuFlag = false; + pCtx->pAccessUnitList->uiAvailUnitsNum = 0; + pCtx->pAccessUnitList->uiActualUnitsNum = 0; + pCtx->pAccessUnitList->uiStartPos = 0; + pCtx->pAccessUnitList->uiEndPos = 0; + pCtx->pAccessUnitList->bCompletedAuFlag = false; } void CheckAvailNalUnitsListContinuity (PWelsDecoderContext pCtx, int32_t iStartIdx, int32_t iEndIdx) { @@ -1985,35 +1985,35 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PNalUnit pNalUnit, PPicture pPicDec) { PNalUnitHeaderExt pNalHdrExt = &pNalUnit->sNalHeaderExt; - PSliceHeaderExt pShExt = &pNalUnit->sNalData.sVclNal.sSliceHeaderExt; - PSliceHeader pSh = &pShExt->sSliceHeader; - const uint8_t kuiQualityId = pNalHdrExt->uiQualityId; + PSliceHeaderExt pShExt = &pNalUnit->sNalData.sVclNal.sSliceHeaderExt; + PSliceHeader pSh = &pShExt->sSliceHeader; + const uint8_t kuiQualityId = pNalHdrExt->uiQualityId; memcpy (&pDqLayer->sLayerInfo, pLayerInfo, sizeof (SLayerInfo)); //confirmed_safe_unsafe_usage - pDqLayer->pDec = pPicDec; - pDqLayer->iMbWidth = pSh->iMbWidth; // MB width of this picture - pDqLayer->iMbHeight = pSh->iMbHeight;// MB height of this picture + pDqLayer->pDec = pPicDec; + pDqLayer->iMbWidth = pSh->iMbWidth; // MB width of this picture + pDqLayer->iMbHeight = pSh->iMbHeight;// MB height of this picture pDqLayer->iSliceIdcBackup = (pSh->iFirstMbInSlice << 7) | (pNalHdrExt->uiDependencyId << 4) | (pNalHdrExt->uiQualityId); /* Common syntax elements across all slices of a DQLayer */ - pDqLayer->uiPpsId = pLayerInfo->pPps->iPpsId; - pDqLayer->uiDisableInterLayerDeblockingFilterIdc = pShExt->uiDisableInterLayerDeblockingFilterIdc; - pDqLayer->iInterLayerSliceAlphaC0Offset = pShExt->iInterLayerSliceAlphaC0Offset; - pDqLayer->iInterLayerSliceBetaOffset = pShExt->iInterLayerSliceBetaOffset; - pDqLayer->iSliceGroupChangeCycle = pSh->iSliceGroupChangeCycle; - pDqLayer->bStoreRefBasePicFlag = pShExt->bStoreRefBasePicFlag; - pDqLayer->bTCoeffLevelPredFlag = pShExt->bTCoeffLevelPredFlag; - pDqLayer->bConstrainedIntraResamplingFlag = pShExt->bConstrainedIntraResamplingFlag; - pDqLayer->uiRefLayerDqId = pShExt->uiRefLayerDqId; - pDqLayer->uiRefLayerChromaPhaseXPlus1Flag = pShExt->uiRefLayerChromaPhaseXPlus1Flag; - pDqLayer->uiRefLayerChromaPhaseYPlus1 = pShExt->uiRefLayerChromaPhaseYPlus1; + pDqLayer->uiPpsId = pLayerInfo->pPps->iPpsId; + pDqLayer->uiDisableInterLayerDeblockingFilterIdc = pShExt->uiDisableInterLayerDeblockingFilterIdc; + pDqLayer->iInterLayerSliceAlphaC0Offset = pShExt->iInterLayerSliceAlphaC0Offset; + pDqLayer->iInterLayerSliceBetaOffset = pShExt->iInterLayerSliceBetaOffset; + pDqLayer->iSliceGroupChangeCycle = pSh->iSliceGroupChangeCycle; + pDqLayer->bStoreRefBasePicFlag = pShExt->bStoreRefBasePicFlag; + pDqLayer->bTCoeffLevelPredFlag = pShExt->bTCoeffLevelPredFlag; + pDqLayer->bConstrainedIntraResamplingFlag = pShExt->bConstrainedIntraResamplingFlag; + pDqLayer->uiRefLayerDqId = pShExt->uiRefLayerDqId; + pDqLayer->uiRefLayerChromaPhaseXPlus1Flag = pShExt->uiRefLayerChromaPhaseXPlus1Flag; + pDqLayer->uiRefLayerChromaPhaseYPlus1 = pShExt->uiRefLayerChromaPhaseYPlus1; //memcpy(&pDqLayer->sScaledRefLayer, &pShExt->sScaledRefLayer, sizeof(SPosOffset));//confirmed_safe_unsafe_usage if (kuiQualityId == BASE_QUALITY_ID) { - pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering; - pDqLayer->pRefPicMarking = &pSh->sRefMarking; + pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering; + pDqLayer->pRefPicMarking = &pSh->sRefMarking; if (pSh->pPps->bWeightedPredFlag) { pDqLayer->bUseWeightPredictionFlag = true; @@ -2022,20 +2022,20 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN } else pDqLayer->bUseWeightPredictionFlag = false; - pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking; + pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking; } - pDqLayer->uiLayerDqId = pNalHdrExt->uiLayerDqId; // dq_id of current layer - pDqLayer->bUseRefBasePicFlag = pNalHdrExt->bUseRefBasePicFlag; + pDqLayer->uiLayerDqId = pNalHdrExt->uiLayerDqId; // dq_id of current layer + pDqLayer->bUseRefBasePicFlag = pNalHdrExt->bUseRefBasePicFlag; } void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pSps, PPps pPps) { PSliceHeader pSh = &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; - pCtx->eSliceType = pSh->eSliceType; - pCtx->pSliceHeader = pSh; + pCtx->eSliceType = pSh->eSliceType; + pCtx->pSliceHeader = pSh; - pCtx->iFrameNum = pSh->iFrameNum; + pCtx->iFrameNum = pSh->iFrameNum; } int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) { @@ -2050,18 +2050,18 @@ int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { if (NULL != pCtx && NULL != pCurDq) { - pCurDq->pMbType = pCtx->sMb.pMbType[0]; - pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0]; - pCurDq->pMv[0] = pCtx->sMb.pMv[0][0]; + pCurDq->pMbType = pCtx->sMb.pMbType[0]; + pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0]; + pCurDq->pMv[0] = pCtx->sMb.pMv[0][0]; pCurDq->pRefIndex[0] = pCtx->sMb.pRefIndex[0][0]; pCurDq->pNoSubMbPartSizeLessThan8x8Flag = pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[0]; pCurDq->pTransformSize8x8Flag = pCtx->sMb.pTransformSize8x8Flag[0]; pCurDq->pLumaQp = pCtx->sMb.pLumaQp[0]; pCurDq->pChromaQp = pCtx->sMb.pChromaQp[0]; - pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0]; - pCurDq->pCbfDc = pCtx->sMb.pCbfDc[0]; - pCurDq->pNzc = pCtx->sMb.pNzc[0]; - pCurDq->pNzcRs = pCtx->sMb.pNzcRs[0]; + pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0]; + pCurDq->pCbfDc = pCtx->sMb.pCbfDc[0]; + pCurDq->pNzc = pCtx->sMb.pNzc[0]; + pCurDq->pNzcRs = pCtx->sMb.pNzcRs[0]; pCurDq->pScaledTCoeff = pCtx->sMb.pScaledTCoeff[0]; pCurDq->pIntraPredMode = pCtx->sMb.pIntraPredMode[0]; pCurDq->pIntra4x4FinalMode = pCtx->sMb.pIntra4x4FinalMode[0]; @@ -2098,22 +2098,22 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf int16_t iLastIdD = -1, iLastIdQ = -1; int16_t iCurrIdD = 0, iCurrIdQ = 0; uint8_t uiNalRefIdc = 0; - bool bFreshSliceAvailable = - true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008 + bool bFreshSliceAvailable = + true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008 //update pCurDqLayer at the starting of AU decoding if (pCtx->bInitialDqLayersMem) { - pCtx->pCurDqLayer = pCtx->pDqLayersList[0]; + pCtx->pCurDqLayer = pCtx->pDqLayersList[0]; } InitCurDqLayerData (pCtx, pCtx->pCurDqLayer); pNalCur = pCurAu->pNalUnitsList[iIdx]; while (iIdx <= iEndIdx) { - PDqLayer dq_cur = pCtx->pCurDqLayer; + PDqLayer dq_cur = pCtx->pCurDqLayer; SLayerInfo pLayerInfo; - PSliceHeaderExt pShExt = NULL; - PSliceHeader pSh = NULL; + PSliceHeaderExt pShExt = NULL; + PSliceHeader pSh = NULL; if (pCtx->pDec == NULL) { pCtx->pDec = PrefetchPic (pCtx->pPicBuff[0]); @@ -2146,7 +2146,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf GetI4LumaIChromaAddrTable (pCtx->iDecBlockOffsetArray, pCtx->pDec->iLinesize[0], pCtx->pDec->iLinesize[1]); if (pNalCur->sNalHeaderExt.uiLayerDqId > kuiTargetLayerDqId) { // confirmed pNalCur will never be NULL - break; // Per formance it need not to decode the remaining bits any more due to given uiLayerDqId required, 9/2/2009 + break; // Per formance it need not to decode the remaining bits any more due to given uiLayerDqId required, 9/2/2009 } memset (&pLayerInfo, 0, sizeof (SLayerInfo)); @@ -2156,10 +2156,10 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf */ while (iIdx <= iEndIdx) { bool bReconstructSlice; - iCurrIdQ = pNalCur->sNalHeaderExt.uiQualityId; - iCurrIdD = pNalCur->sNalHeaderExt.uiDependencyId; - pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; - pShExt = &pNalCur->sNalData.sVclNal.sSliceHeaderExt; + iCurrIdQ = pNalCur->sNalHeaderExt.uiQualityId; + iCurrIdD = pNalCur->sNalHeaderExt.uiDependencyId; + pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; + pShExt = &pNalCur->sNalData.sVclNal.sSliceHeaderExt; pCtx->bRPLRError = false; bReconstructSlice = CheckSliceNeedReconstruct (pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId); @@ -2170,14 +2170,14 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf pCtx->pDec->bIdrFlag = pNalCur->sNalHeaderExt.bIdrFlag; memcpy (&pLayerInfo.sSliceInLayer.sSliceHeaderExt, pShExt, sizeof (SSliceHeaderExt)); //confirmed_safe_unsafe_usage - pLayerInfo.sSliceInLayer.bSliceHeaderExtFlag = pNalCur->sNalData.sVclNal.bSliceHeaderExtFlag; - pLayerInfo.sSliceInLayer.eSliceType = pSh->eSliceType; - pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp; - dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead; + pLayerInfo.sSliceInLayer.bSliceHeaderExtFlag = pNalCur->sNalData.sVclNal.bSliceHeaderExtFlag; + pLayerInfo.sSliceInLayer.eSliceType = pSh->eSliceType; + pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp; + dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead; - uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc; + uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc; - iPpsId = pSh->iPpsId; + iPpsId = pSh->iPpsId; pLayerInfo.pPps = pSh->pPps; pLayerInfo.pSps = pSh->pSps; @@ -2191,8 +2191,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_FMO_INIT_FAIL); } - bFreshSliceAvailable = (iCurrIdD != iLastIdD - || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder + bFreshSliceAvailable = (iCurrIdD != iLastIdD + || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder WelsDqLayerDecodeStart (pCtx, pNalCur, pLayerInfo.pSps, pLayerInfo.pPps); @@ -2279,15 +2279,15 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf fprintf (stderr, "cur_frame : %d\tiCurrIdD : %d\n ", dq_cur->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iFrameNum, iCurrIdD); #endif//#if !CODEC_FOR_TESTBED - iLastIdD = iCurrIdD; - iLastIdQ = iCurrIdQ; + iLastIdD = iCurrIdD; + iLastIdQ = iCurrIdQ; //pNalUnitsList overflow. ++ iIdx; if (iIdx <= iEndIdx) { - pNalCur = pCurAu->pNalUnitsList[iIdx]; + pNalCur = pCurAu->pNalUnitsList[iIdx]; } else { - pNalCur = NULL; + pNalCur = NULL; } if (pNalCur == NULL || @@ -2346,7 +2346,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf // need update frame_num due current frame is well decoded if (pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0) - pCtx->iPrevFrameNum = pSh->iFrameNum; + pCtx->iPrevFrameNum = pSh->iFrameNum; if (pCtx->bLastHasMmco5) pCtx->iPrevFrameNum = 0; } diff --git a/codec/decoder/core/src/fmo.cpp b/codec/decoder/core/src/fmo.cpp index c3724a92..95795c7e 100644 --- a/codec/decoder/core/src/fmo.cpp +++ b/codec/decoder/core/src/fmo.cpp @@ -93,7 +93,7 @@ static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const in int32_t i = 0; WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == pPps)) uiNumSliceGroups = pPps->uiNumSliceGroups; - iMbNum = pFmo->iCountMbNum; + iMbNum = pFmo->iCountMbNum; WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap || iMbNum <= 0 || kiMbWidth == 0 || uiNumSliceGroups >= MAX_SLICEGROUP_IDS)) @@ -117,14 +117,14 @@ static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const in */ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth, const int32_t kiMbHeight) { - int32_t iNumMb = 0; - int32_t iErr = 0; - bool bResolutionChanged = false; + int32_t iNumMb = 0; + int32_t iErr = 0; + bool bResolutionChanged = false; // the cases we would not like WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == kpPps)) - iNumMb = pFmo->iCountMbNum; + iNumMb = pFmo->iCountMbNum; iNumMb = kiMbWidth * kiMbHeight; @@ -133,15 +133,15 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap"); - pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap"); - WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory + pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap"); + WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory - pFmo->iCountMbNum = iNumMb; + pFmo->iCountMbNum = iNumMb; if (kpPps->uiNumSliceGroups < 2 && iNumMb > 0) { // only one slice group, exactly it is single slice based - memset (pFmo->pMbAllocMap, 0, iNumMb * sizeof (int8_t)); // for safe + memset (pFmo->pMbAllocMap, 0, iNumMb * sizeof (int8_t)); // for safe - pFmo->iSliceGroupCount = 1; + pFmo->iSliceGroupCount = 1; return 0; } @@ -150,7 +150,7 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const || ((int32_t)kpPps->uiNumSliceGroups != pFmo->iSliceGroupCount)) { switch (kpPps->uiSliceGroupMapType) { case 0: - iErr = FmoGenerateMbAllocMapType0 (pFmo, kpPps); + iErr = FmoGenerateMbAllocMapType0 (pFmo, kpPps); break; case 1: iErr = FmoGenerateMbAllocMapType1 (pFmo, kpPps, kiMbWidth); @@ -161,16 +161,16 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const case 5: case 6: // Reserve for others slice group type - iErr = 1; + iErr = 1; break; default: return 1; } } - if (0 == iErr) { // well now - pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups; - pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType; + if (0 == iErr) { // well now + pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups; + pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType; } return iErr; @@ -213,12 +213,12 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) { if (NULL != pIter->pMbAllocMap) { WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap"); - pIter->pMbAllocMap = NULL; + pIter->pMbAllocMap = NULL; } - pIter->iSliceGroupCount = 0; - pIter->iSliceGroupType = -1; - pIter->iCountMbNum = 0; - pIter->bActiveFlag = false; + pIter->iSliceGroupCount = 0; + pIter->iSliceGroupType = -1; + pIter->iCountMbNum = 0; + pIter->bActiveFlag = false; ++ iFreeNodes; if (iFreeNodes >= kiAvail) break; @@ -272,7 +272,7 @@ bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) { } else { if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) { ++ (*pActiveFmoNum); - pFmo->bActiveFlag = true; + pFmo->bActiveFlag = true; } } } @@ -289,8 +289,8 @@ bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) { * \return slice group idc - successful; -1 - failed; */ int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) { - const int32_t kiMbNum = pFmo->iCountMbNum; - const uint8_t* kpMbMap = pFmo->pMbAllocMap; + const int32_t kiMbNum = pFmo->iCountMbNum; + const uint8_t* kpMbMap = pFmo->pMbAllocMap; if (kiMbXy < 0 || kiMbXy >= kiMbNum || kpMbMap == NULL) return -1; @@ -307,10 +307,10 @@ int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) { * \return iNextMb - successful; -1 - failed; */ MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy) { - const int32_t kiTotalMb = pFmo->iCountMbNum; - const uint8_t* kpMbMap = pFmo->pMbAllocMap; - MB_XY_T iNextMb = kiMbXy; - const uint8_t kuiSliceGroupIdc = (uint8_t)FmoMbToSliceGroup (pFmo, kiMbXy); + const int32_t kiTotalMb = pFmo->iCountMbNum; + const uint8_t* kpMbMap = pFmo->pMbAllocMap; + MB_XY_T iNextMb = kiMbXy; + const uint8_t kuiSliceGroupIdc = (uint8_t)FmoMbToSliceGroup (pFmo, kiMbXy); if (kuiSliceGroupIdc == (uint8_t) (-1)) return -1; @@ -318,7 +318,7 @@ MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy) { do { ++ iNextMb; if (iNextMb >= kiTotalMb) { - iNextMb = -1; + iNextMb = -1; break; } if (kpMbMap[iNextMb] == kuiSliceGroupIdc) { diff --git a/codec/decoder/core/src/get_intra_predictor.cpp b/codec/decoder/core/src/get_intra_predictor.cpp index 1c73c508..11898316 100644 --- a/codec/decoder/core/src/get_intra_predictor.cpp +++ b/codec/decoder/core/src/get_intra_predictor.cpp @@ -75,10 +75,10 @@ void WelsI4x4LumaPredH_c (uint8_t* pPred, const int32_t kiStride) { } void WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride2 + kiStride; - const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + - pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 4) >> 3; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride2 + kiStride; + const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + + pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 4) >> 3; const uint32_t kuiMean32 = 0x01010101U * kuiMean; ST32A4 (pPred , kuiMean32); @@ -88,9 +88,9 @@ void WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride) { } void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride2 + kiStride; - const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + 2) >> 2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride2 + kiStride; + const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + 2) >> 2; const uint32_t kuiMean32 = 0x01010101U * kuiMean; ST32A4 (pPred , kuiMean32); @@ -100,10 +100,9 @@ void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { } void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride2 + kiStride; - const uint8_t kuiMean = (pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 2) >> - 2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride2 + kiStride; + const uint8_t kuiMean = (pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 2) >> 2; const uint32_t kuiMean32 = 0x01010101U * kuiMean; ST32A4 (pPred , kuiMean32); @@ -113,7 +112,7 @@ void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) { } void WelsI4x4LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) { - const uint32_t kuiDC32 = 0x80808080U; + const uint32_t kuiDC32 = 0x80808080U; ST32A4 (pPred , kuiDC32); ST32A4 (pPred + kiStride , kuiDC32); @@ -123,25 +122,25 @@ void WelsI4x4LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) { /*down pLeft*/ void WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; /*get pTop*/ - uint8_t* ptop = &pPred[-kiStride]; - const uint8_t kuiT0 = *ptop; - const uint8_t kuiT1 = * (ptop + 1); - const uint8_t kuiT2 = * (ptop + 2); - const uint8_t kuiT3 = * (ptop + 3); - const uint8_t kuiT4 = * (ptop + 4); - const uint8_t kuiT5 = * (ptop + 5); - const uint8_t kuiT6 = * (ptop + 6); - const uint8_t kuiT7 = * (ptop + 7); - const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0 - const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1 - const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2 - const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3 - const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4 - const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5 - const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6 + uint8_t* ptop = &pPred[-kiStride]; + const uint8_t kuiT0 = *ptop; + const uint8_t kuiT1 = * (ptop + 1); + const uint8_t kuiT2 = * (ptop + 2); + const uint8_t kuiT3 = * (ptop + 3); + const uint8_t kuiT4 = * (ptop + 4); + const uint8_t kuiT5 = * (ptop + 5); + const uint8_t kuiT6 = * (ptop + 6); + const uint8_t kuiT7 = * (ptop + 7); + const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0 + const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1 + const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2 + const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3 + const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4 + const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5 + const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6 const uint8_t kuiList[8] = { kuiDDL0, kuiDDL1, kuiDDL2, kuiDDL3, kuiDDL4, kuiDDL5, kuiDDL6, 0 }; ST32A4 (pPred , LD32 (kuiList)); @@ -152,22 +151,22 @@ void WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride) { /*down pLeft*/ void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; /*get pTop*/ - uint8_t* ptop = &pPred[-kiStride]; - const uint8_t kuiT0 = *ptop; - const uint8_t kuiT1 = * (ptop + 1); - const uint8_t kuiT2 = * (ptop + 2); - const uint8_t kuiT3 = * (ptop + 3); - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiT33 = 1 + (kuiT3 << 1); - const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0 - const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1 - const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2 - const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3 + uint8_t* ptop = &pPred[-kiStride]; + const uint8_t kuiT0 = *ptop; + const uint8_t kuiT1 = * (ptop + 1); + const uint8_t kuiT2 = * (ptop + 2); + const uint8_t kuiT3 = * (ptop + 3); + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiT33 = 1 + (kuiT3 << 1); + const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0 + const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1 + const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2 + const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3 const uint8_t kuiList[8] = { kuiDLT0, kuiDLT1, kuiDLT2, kuiDLT3, kuiDLT3, kuiDLT3, kuiDLT3 , kuiDLT3 }; ST32A4 (pPred, LD32 (kuiList)); @@ -179,36 +178,36 @@ void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride) { /*down right*/ void WelsI4x4LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - uint8_t* ptopleft = &pPred[- (kiStride + 1)]; - uint8_t* pleft = &pPred[-1]; - const uint8_t kuiLT = *ptopleft; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* ptopleft = &pPred[- (kiStride + 1)]; + uint8_t* pleft = &pPred[-1]; + const uint8_t kuiLT = *ptopleft; /*get pLeft and pTop*/ - const uint8_t kuiL0 = *pleft; - const uint8_t kuiL1 = * (pleft + kiStride); - const uint8_t kuiL2 = * (pleft + kiStride2); - const uint8_t kuiL3 = * (pleft + kiStride3); - const uint8_t kuiT0 = * (ptopleft + 1); - const uint8_t kuiT1 = * (ptopleft + 2); - const uint8_t kuiT2 = * (ptopleft + 3); - const uint8_t kuiT3 = * (ptopleft + 4); - const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; - const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0 - const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1 - const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2 - const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3 - const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4 - const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5 - const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6 - const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 }; + const uint8_t kuiL0 = *pleft; + const uint8_t kuiL1 = * (pleft + kiStride); + const uint8_t kuiL2 = * (pleft + kiStride2); + const uint8_t kuiL3 = * (pleft + kiStride3); + const uint8_t kuiT0 = * (ptopleft + 1); + const uint8_t kuiT1 = * (ptopleft + 2); + const uint8_t kuiT2 = * (ptopleft + 3); + const uint8_t kuiT3 = * (ptopleft + 4); + const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; + const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0 + const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1 + const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2 + const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3 + const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4 + const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5 + const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6 + const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 }; ST32A4 (pPred , LD32 (kuiList + 3)); ST32A4 (pPred + kiStride , LD32 (kuiList + 2)); @@ -219,34 +218,34 @@ void WelsI4x4LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride) { /*vertical pLeft*/ void WelsI4x4LumaPredVL_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - uint8_t* ptopleft = &pPred[- (kiStride + 1)]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* ptopleft = &pPred[- (kiStride + 1)]; /*get pTop*/ - const uint8_t kuiT0 = * (ptopleft + 1); - const uint8_t kuiT1 = * (ptopleft + 2); - const uint8_t kuiT2 = * (ptopleft + 3); - const uint8_t kuiT3 = * (ptopleft + 4); - const uint8_t kuiT4 = * (ptopleft + 5); - const uint8_t kuiT5 = * (ptopleft + 6); - const uint8_t kuiT6 = * (ptopleft + 7); - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiT34 = 1 + kuiT3 + kuiT4; - const uint16_t kuiT45 = 1 + kuiT4 + kuiT5; - const uint16_t kuiT56 = 1 + kuiT5 + kuiT6; - const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0 - const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1 - const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2 - const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3 - const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4 - const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5 - const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6 - const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7 - const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8 - const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9 - const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 }; + const uint8_t kuiT0 = * (ptopleft + 1); + const uint8_t kuiT1 = * (ptopleft + 2); + const uint8_t kuiT2 = * (ptopleft + 3); + const uint8_t kuiT3 = * (ptopleft + 4); + const uint8_t kuiT4 = * (ptopleft + 5); + const uint8_t kuiT5 = * (ptopleft + 6); + const uint8_t kuiT6 = * (ptopleft + 7); + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiT34 = 1 + kuiT3 + kuiT4; + const uint16_t kuiT45 = 1 + kuiT4 + kuiT5; + const uint16_t kuiT56 = 1 + kuiT5 + kuiT6; + const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0 + const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1 + const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2 + const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3 + const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4 + const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5 + const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6 + const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7 + const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8 + const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9 + const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 }; ST32A4 (pPred, LD32 (kuiList)); ST32A4 (pPred + kiStride, LD32 (kuiList + 5)); @@ -256,27 +255,27 @@ void WelsI4x4LumaPredVL_c (uint8_t* pPred, const int32_t kiStride) { /*vertical pLeft*/ void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - uint8_t* ptopleft = &pPred[- (kiStride + 1)]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* ptopleft = &pPred[- (kiStride + 1)]; /*get pTop*/ - const uint8_t kuiT0 = * (ptopleft + 1); - const uint8_t kuiT1 = * (ptopleft + 2); - const uint8_t kuiT2 = * (ptopleft + 3); - const uint8_t kuiT3 = * (ptopleft + 4); - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiT33 = 1 + (kuiT3 << 1); - const uint8_t kuiVL0 = kuiT01 >> 1; - const uint8_t kuiVL1 = kuiT12 >> 1; - const uint8_t kuiVL2 = kuiT23 >> 1; - const uint8_t kuiVL3 = kuiT33 >> 1; - const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2; - const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2; - const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2; - const uint8_t kuiVL7 = kuiVL3; - const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 }; + const uint8_t kuiT0 = * (ptopleft + 1); + const uint8_t kuiT1 = * (ptopleft + 2); + const uint8_t kuiT2 = * (ptopleft + 3); + const uint8_t kuiT3 = * (ptopleft + 4); + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiT33 = 1 + (kuiT3 << 1); + const uint8_t kuiVL0 = kuiT01 >> 1; + const uint8_t kuiVL1 = kuiT12 >> 1; + const uint8_t kuiVL2 = kuiT23 >> 1; + const uint8_t kuiVL3 = kuiT33 >> 1; + const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2; + const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2; + const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2; + const uint8_t kuiVL7 = kuiVL3; + const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 }; ST32A4 (pPred , LD32 (kuiList)); ST32A4 (pPred + kiStride , LD32 (kuiList + 5)); @@ -287,28 +286,28 @@ void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride) { /*vertical right*/ void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - const uint8_t kuiLT = pPred[-kiStride - 1]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + const uint8_t kuiLT = pPred[-kiStride - 1]; /*get pLeft and pTop*/ - const uint8_t kuiL0 = pPred[ -1]; - const uint8_t kuiL1 = pPred[kiStride - 1]; - const uint8_t kuiL2 = pPred[kiStride2 - 1]; - const uint8_t kuiT0 = pPred[ -kiStride]; - const uint8_t kuiT1 = pPred[1 - kiStride]; - const uint8_t kuiT2 = pPred[2 - kiStride]; - const uint8_t kuiT3 = pPred[3 - kiStride]; - const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0 - const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1 - const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2 - const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3 - const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4 - const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5 - const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6 - const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7 - const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8 - const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9 - const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 }; + const uint8_t kuiL0 = pPred[ - 1]; + const uint8_t kuiL1 = pPred[kiStride - 1]; + const uint8_t kuiL2 = pPred[kiStride2 - 1]; + const uint8_t kuiT0 = pPred[ -kiStride]; + const uint8_t kuiT1 = pPred[1 - kiStride]; + const uint8_t kuiT2 = pPred[2 - kiStride]; + const uint8_t kuiT3 = pPred[3 - kiStride]; + const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0 + const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1 + const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2 + const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3 + const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4 + const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5 + const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6 + const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7 + const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8 + const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9 + const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 }; ST32A4 (pPred , LD32 (kuiList + 1)); ST32A4 (pPred + kiStride , LD32 (kuiList + 6)); @@ -318,23 +317,23 @@ void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride) { /*horizontal up*/ void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; /*get pLeft*/ - const uint8_t kuiL0 = pPred[ -1]; - const uint8_t kuiL1 = pPred[kiStride - 1]; - const uint8_t kuiL2 = pPred[kiStride2 - 1]; - const uint8_t kuiL3 = pPred[kiStride3 - 1]; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiHU0 = kuiL01 >> 1; - const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; - const uint8_t kuiHU2 = kuiL12 >> 1; - const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; - const uint8_t kuiHU4 = kuiL23 >> 1; - const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; - const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 }; + const uint8_t kuiL0 = pPred[ - 1]; + const uint8_t kuiL1 = pPred[kiStride - 1]; + const uint8_t kuiL2 = pPred[kiStride2 - 1]; + const uint8_t kuiL3 = pPred[kiStride3 - 1]; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiHU0 = kuiL01 >> 1; + const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; + const uint8_t kuiHU2 = kuiL12 >> 1; + const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; + const uint8_t kuiHU4 = kuiL23 >> 1; + const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; + const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 }; ST32A4 (pPred , LD32 (kuiList)); ST32A4 (pPred + kiStride , LD32 (kuiList + 2)); @@ -344,35 +343,35 @@ void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride) { /*horizontal down*/ void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - const uint8_t kuiLT = pPred[- (kiStride + 1)]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + const uint8_t kuiLT = pPred[- (kiStride + 1)]; /*get pLeft and pTop*/ - const uint8_t kuiL0 = pPred[-1 ]; - const uint8_t kuiL1 = pPred[-1 + kiStride ]; - const uint8_t kuiL2 = pPred[-1 + kiStride2]; - const uint8_t kuiL3 = pPred[-1 + kiStride3]; - const uint8_t kuiT0 = pPred[-kiStride ]; - const uint8_t kuiT1 = pPred[-kiStride + 1 ]; - const uint8_t kuiT2 = pPred[-kiStride + 2 ]; - const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; - const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiHD0 = kuiTL0 >> 1; - const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2; - const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2; - const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2; - const uint8_t kuiHD4 = kuiL01 >> 1; - const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2; - const uint8_t kuiHD6 = kuiL12 >> 1; - const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2; - const uint8_t kuiHD8 = kuiL23 >> 1; - const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2; - const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 }; + const uint8_t kuiL0 = pPred[-1 ]; + const uint8_t kuiL1 = pPred[-1 + kiStride ]; + const uint8_t kuiL2 = pPred[-1 + kiStride2]; + const uint8_t kuiL3 = pPred[-1 + kiStride3]; + const uint8_t kuiT0 = pPred[-kiStride ]; + const uint8_t kuiT1 = pPred[-kiStride + 1 ]; + const uint8_t kuiT2 = pPred[-kiStride + 2 ]; + const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; + const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiHD0 = kuiTL0 >> 1; + const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2; + const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2; + const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2; + const uint8_t kuiHD4 = kuiL01 >> 1; + const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2; + const uint8_t kuiHD6 = kuiL12 >> 1; + const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2; + const uint8_t kuiHD8 = kuiL23 >> 1; + const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2; + const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 }; ST32A4 (pPred , LD32 (kuiList + 6)); ST32A4 (pPred + kiStride , LD32 (kuiList + 4)); @@ -535,7 +534,7 @@ void WelsI8x8LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAv void WelsI8x8LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) { // for normal 8 bit depth, 8-94 - const uint64_t kuiDC64 = 0x8080808080808080ULL; + const uint64_t kuiDC64 = 0x8080808080808080ULL; int32_t iStride[8]; int32_t i; @@ -882,8 +881,8 @@ void WelsI8x8LumaPredHD_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) { - const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]); - const int32_t kiStride2 = kiStride << 1; + const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]); + const int32_t kiStride2 = kiStride << 1; const int32_t kiStride4 = kiStride2 << 1; ST64A8 (pPred , kuiVal64); @@ -901,8 +900,8 @@ void WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride) { uint8_t i = 7; do { - const uint8_t kuiVal8 = pPred[iTmp - 1]; - const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8; + const uint8_t kuiVal8 = pPred[iTmp - 1]; + const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8; ST64A8 (pPred + iTmp, kuiVal64); @@ -938,25 +937,25 @@ void WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDc_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiL1 = kiStride - 1; - const int32_t kiL2 = kiL1 + kiStride; - const int32_t kiL3 = kiL2 + kiStride; - const int32_t kiL4 = kiL3 + kiStride; - const int32_t kiL5 = kiL4 + kiStride; - const int32_t kiL6 = kiL5 + kiStride; - const int32_t kiL7 = kiL6 + kiStride; + const int32_t kiL1 = kiStride - 1; + const int32_t kiL2 = kiL1 + kiStride; + const int32_t kiL3 = kiL2 + kiStride; + const int32_t kiL4 = kiL3 + kiStride; + const int32_t kiL5 = kiL4 + kiStride; + const int32_t kiL6 = kiL5 + kiStride; + const int32_t kiL7 = kiL6 + kiStride; /*caculate the kMean value*/ - const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + - pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ; - const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride]; - const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7]; - const uint8_t kuiM2 = (kuiSum2 + 2) >> 2; - const uint8_t kuiM3 = (kuiSum3 + 2) >> 2; - const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3; - const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; - const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4}; - const uint64_t kuiUP64 = LD64 (kuiMUP); - const uint64_t kuiDN64 = LD64 (kuiMDown); + const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + + pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ; + const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride]; + const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7]; + const uint8_t kuiM2 = (kuiSum2 + 2) >> 2; + const uint8_t kuiM3 = (kuiSum3 + 2) >> 2; + const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3; + const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; + const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4}; + const uint64_t kuiUP64 = LD64 (kuiMUP); + const uint64_t kuiDN64 = LD64 (kuiMDown); ST64A8 (pPred , kuiUP64); ST64A8 (pPred + kiL1 + 1, kuiUP64); @@ -969,13 +968,13 @@ void WelsIChromaPredDc_c (uint8_t* pPred, const int32_t kiStride) { } void WelsIChromaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiL1 = -1 + kiStride; - const int32_t kiL2 = kiL1 + kiStride; - const int32_t kiL3 = kiL2 + kiStride; - const int32_t kiL4 = kiL3 + kiStride; - const int32_t kiL5 = kiL4 + kiStride; - const int32_t kiL6 = kiL5 + kiStride; - const int32_t kiL7 = kiL6 + kiStride; + const int32_t kiL1 = -1 + kiStride; + const int32_t kiL2 = kiL1 + kiStride; + const int32_t kiL3 = kiL2 + kiStride; + const int32_t kiL4 = kiL3 + kiStride; + const int32_t kiL5 = kiL4 + kiStride; + const int32_t kiL6 = kiL5 + kiStride; + const int32_t kiL7 = kiL6 + kiStride; /*caculate the kMean value*/ const uint8_t kuiMUP = (pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 2) >> 2 ; const uint8_t kuiMDown = (pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7] + 2) >> 2; @@ -993,12 +992,11 @@ void WelsIChromaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { } void WelsIChromaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) { - int32_t iTmp = (kiStride << 3) - kiStride; + int32_t iTmp = (kiStride << 3) - kiStride; /*caculate the kMean value*/ - const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2; - const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> - 2; - const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; + const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2; + const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> 2; + const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; uint8_t i = 7; @@ -1022,13 +1020,13 @@ void WelsIChromaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) { } void WelsI16x16LumaPredV_c (uint8_t* pPred, const int32_t kiStride) { - int32_t iTmp = (kiStride << 4) - kiStride; - const uint64_t kuiTop1 = LD64A8 (pPred - kiStride); + int32_t iTmp = (kiStride << 4) - kiStride; + const uint64_t kuiTop1 = LD64A8 (pPred - kiStride); const uint64_t kuiTop2 = LD64A8 (pPred - kiStride + 8); uint8_t i = 15; do { - ST64A8 (pPred + iTmp , kuiTop1); + ST64A8 (pPred + iTmp , kuiTop1); ST64A8 (pPred + iTmp + 8, kuiTop2); iTmp -= kiStride; @@ -1040,10 +1038,10 @@ void WelsI16x16LumaPredH_c (uint8_t* pPred, const int32_t kiStride) { uint8_t i = 15; do { - const uint8_t kuiVal8 = pPred[iTmp - 1]; - const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8; + const uint8_t kuiVal8 = pPred[iTmp - 1]; + const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8; - ST64A8 (pPred + iTmp , kuiVal64); + ST64A8 (pPred + iTmp , kuiVal64); ST64A8 (pPred + iTmp + 8, kuiVal64); iTmp -= kiStride; @@ -1128,8 +1126,8 @@ void WelsI16x16LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { iSum += pPred[-1 + iTmp]; iTmp -= kiStride; } while (i-- > 0); - uiMean = (8 + iSum) >> 4; - uiMean64 = 0x0101010101010101ULL * uiMean; + uiMean = (8 + iSum) >> 4; + uiMean64 = 0x0101010101010101ULL * uiMean; iTmp = (kiStride << 4) - kiStride; i = 15; diff --git a/codec/decoder/core/src/manage_dec_ref.cpp b/codec/decoder/core/src/manage_dec_ref.cpp index b15ddd87..39e8c300 100644 --- a/codec/decoder/core/src/manage_dec_ref.cpp +++ b/codec/decoder/core/src/manage_dec_ref.cpp @@ -87,7 +87,7 @@ void WelsResetRefPic (PWelsDecoderContext pCtx) { PRefPic pRefPic = &pCtx->sRefPic; pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0; - pRefPic->uiRefCount[LIST_0] = 0; + pRefPic->uiRefCount[LIST_0] = 0; for (i = 0; i < MAX_SHORT_REF_COUNT; i++) { if (pRefPic->pShortRefList[LIST_0][i] != NULL) { @@ -213,7 +213,7 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) { && (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check; WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d", pSliceHeader->iSpsId, ppRefList[i]->iSpsId); - pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.-- + pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.-- return ERR_INFO_REFERENCE_PIC_LOST; } else { break; @@ -230,7 +230,7 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) { && (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check; WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d", pSliceHeader->iSpsId, ppRefList[i]->iSpsId); - pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.-- + pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.-- return ERR_INFO_REFERENCE_PIC_LOST; } else { break; diff --git a/codec/decoder/core/src/memmgr_nal_unit.cpp b/codec/decoder/core/src/memmgr_nal_unit.cpp index 33739291..607e2cb0 100644 --- a/codec/decoder/core/src/memmgr_nal_unit.cpp +++ b/codec/decoder/core/src/memmgr_nal_unit.cpp @@ -64,7 +64,7 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { pPtr = pBase; *ppAu = (PAccessUnit)pPtr; pPtr += kuiSizeAu; - (*ppAu)->pNalUnitsList = (PNalUnit*)pPtr; + (*ppAu)->pNalUnitsList = (PNalUnit*)pPtr; pPtr += kuiSizeNalUnitPtr; do { (*ppAu)->pNalUnitsList[uiIdx] = (PNalUnit)pPtr; @@ -72,12 +72,12 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { ++ uiIdx; } while (uiIdx < kuiSize); - (*ppAu)->uiCountUnitsNum = kuiSize; - (*ppAu)->uiAvailUnitsNum = 0; - (*ppAu)->uiActualUnitsNum = 0; + (*ppAu)->uiCountUnitsNum = kuiSize; + (*ppAu)->uiAvailUnitsNum = 0; + (*ppAu)->uiActualUnitsNum = 0; (*ppAu)->uiStartPos = 0; - (*ppAu)->uiEndPos = 0; - (*ppAu)->bCompletedAuFlag = false; + (*ppAu)->uiEndPos = 0; + (*ppAu)->bCompletedAuFlag = false; return 0; } @@ -101,7 +101,7 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int PAccessUnit pTmp = NULL; int32_t iIdx = 0; - if (MemInitNalList (&pTmp, kiExpSize)) // request new list with expanding + if (MemInitNalList (&pTmp, kiExpSize)) // request new list with expanding return 1; do { @@ -109,13 +109,13 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int ++ iIdx; } while (iIdx < kiOrgSize); - pTmp->uiCountUnitsNum = kiExpSize; - pTmp->uiAvailUnitsNum = (*ppAu)->uiAvailUnitsNum; - pTmp->uiActualUnitsNum = (*ppAu)->uiActualUnitsNum; - pTmp->uiEndPos = (*ppAu)->uiEndPos; - pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag; + pTmp->uiCountUnitsNum = kiExpSize; + pTmp->uiAvailUnitsNum = (*ppAu)->uiAvailUnitsNum; + pTmp->uiActualUnitsNum = (*ppAu)->uiActualUnitsNum; + pTmp->uiEndPos = (*ppAu)->uiEndPos; + pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag; - MemFreeNalList (ppAu); // free old list + MemFreeNalList (ppAu); // free old list *ppAu = pTmp; return 0; } @@ -130,16 +130,16 @@ PNalUnit MemGetNextNal (PAccessUnit* ppAu) { PAccessUnit pAu = *ppAu; PNalUnit pNu = NULL; - if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list + if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU >> 1); if (ExpandNalUnitList (ppAu, pAu->uiCountUnitsNum, kuiExpandingSize)) - return NULL; // out of memory + return NULL; // out of memory pAu = *ppAu; } - pNu = pAu->pNalUnitsList[pAu->uiAvailUnitsNum++]; // ready for next nal position + pNu = pAu->pNalUnitsList[pAu->uiAvailUnitsNum++]; // ready for next nal position - memset (pNu, 0, sizeof (SNalUnit)); // Please do not remove this for cache intend!! + memset (pNu, 0, sizeof (SNalUnit)); // Please do not remove this for cache intend!! return pNu; } diff --git a/codec/decoder/core/src/mv_pred.cpp b/codec/decoder/core/src/mv_pred.cpp index 471f850a..7ab88b19 100644 --- a/codec/decoder/core/src/mv_pred.cpp +++ b/codec/decoder/core/src/mv_pred.cpp @@ -196,15 +196,15 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) { //basic iMVs prediction unit for iMVs partition width (4, 2, 1) void PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30], int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]) { - const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1; - const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6; - const uint8_t kuiRightTopIdx = kuiTopIdx + iPartWidth; - const uint8_t kuiLeftTopIdx = kuiTopIdx - 1; + const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1; + const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6; + const uint8_t kuiRightTopIdx = kuiTopIdx + iPartWidth; + const uint8_t kuiLeftTopIdx = kuiTopIdx - 1; const int8_t kiLeftRef = iRefIndex[0][kuiLeftIdx]; const int8_t kiTopRef = iRefIndex[0][ kuiTopIdx]; - const int8_t kiRightTopRef = iRefIndex[0][kuiRightTopIdx]; - const int8_t kiLeftTopRef = iRefIndex[0][ kuiLeftTopIdx]; + const int8_t kiRightTopRef = iRefIndex[0][kuiRightTopIdx]; + const int8_t kiLeftTopRef = iRefIndex[0][ kuiLeftTopIdx]; int8_t iDiagonalRef = kiRightTopRef; int8_t iMatchRef = 0; @@ -286,8 +286,8 @@ void PredInter16x8Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[ //update iMVs and iRefIndex cache for current MB, only for P_16*16 (SKIP inclusive) /* can be further optimized */ void UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]) { - const int16_t kiRef2 = (iRef << 8) | iRef; - const int32_t kiMV32 = LD32 (iMVs); + const int16_t kiRef2 = (iRef << 8) | iRef; + const int32_t kiMV32 = LD32 (iMVs); int32_t i; int32_t iMbXy = pCurDqLayer->iMbXyIndex; diff --git a/codec/decoder/core/src/parse_mb_syn_cabac.cpp b/codec/decoder/core/src/parse_mb_syn_cabac.cpp index ea44e812..d7a7d8d8 100644 --- a/codec/decoder/core/src/parse_mb_syn_cabac.cpp +++ b/codec/decoder/core/src/parse_mb_syn_cabac.cpp @@ -374,8 +374,8 @@ int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeigh int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A], int8_t pRefIndex[LIST_A][30]) { - PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PDqLayer pCurDqLayer = pCtx->pCurDqLayer; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; int32_t pRefCount[2]; diff --git a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp index a7b7dd64..b1caeb2c 100644 --- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp +++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp @@ -990,8 +990,8 @@ int32_t WelsResidualBlockCavlc8x8 (SVlcTable* pVlcTable, uint8_t* pNonZeroCountC int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PBitStringAux pBs) { - PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; - PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; + PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; int32_t iRefCount[2]; PDqLayer pCurDqLayer = pCtx->pCurDqLayer; @@ -1133,8 +1133,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M uint32_t uiSubMbType; if (MB_TYPE_8x8_REF0 == pCurDqLayer->pMbType[iMbXy]) { - iRefCount[0] = - iRefCount[1] = 1; + iRefCount[0] = + iRefCount[1] = 1; } //uiSubMbType, partition diff --git a/codec/decoder/core/src/pic_queue.cpp b/codec/decoder/core/src/pic_queue.cpp index 0cd7519c..90a933e7 100644 --- a/codec/decoder/core/src/pic_queue.cpp +++ b/codec/decoder/core/src/pic_queue.cpp @@ -64,23 +64,23 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t iPicWidth = 0; int32_t iPicHeight = 0; - int32_t iPicChromaWidth = 0; - int32_t iPicChromaHeight = 0; - int32_t iLumaSize = 0; - int32_t iChromaSize = 0; + int32_t iPicChromaWidth = 0; + int32_t iPicChromaHeight = 0; + int32_t iLumaSize = 0; + int32_t iChromaSize = 0; - pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture"); + pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture"); WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); memset (pPic, 0, sizeof (SPicture)); iPicWidth = WELS_ALIGN (kiPicWidth + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT); iPicHeight = WELS_ALIGN (kiPicHeight + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT); - iPicChromaWidth = iPicWidth >> 1; - iPicChromaHeight = iPicHeight >> 1; + iPicChromaWidth = iPicWidth >> 1; + iPicChromaHeight = iPicHeight >> 1; - iLumaSize = iPicWidth * iPicHeight; - iChromaSize = iPicChromaWidth * iPicChromaHeight; + iLumaSize = iPicWidth * iPicHeight; + iChromaSize = iPicChromaWidth * iPicChromaHeight; if (pCtx->bParseOnly) { pPic->pBuffer[0] = pPic->pBuffer[1] = pPic->pBuffer[2] = NULL; @@ -88,23 +88,23 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const pPic->iLinesize[0] = iPicWidth; pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; } else { - pPic->pBuffer[0] = static_cast (WelsMallocz (iLumaSize /* luma */ + pPic->pBuffer[0] = static_cast (WelsMallocz (iLumaSize /* luma */ + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]")); WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic)); memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1))); pPic->iLinesize[0] = iPicWidth; pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; - pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize; - pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize; - pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH; - pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1); - pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1); + pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize; + pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize; + pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH; + pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1); + pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1); } - pPic->iPlanes = 3; // yv12 in default - pPic->iWidthInPixel = kiPicWidth; + pPic->iPlanes = 3; // yv12 in default + pPic->iWidthInPixel = kiPicWidth; pPic->iHeightInPixel = kiPicHeight; - pPic->iFrameNum = -1; + pPic->iFrameNum = -1; pPic->bAvailableFlag = true; return pPic; diff --git a/codec/decoder/core/src/rec_mb.cpp b/codec/decoder/core/src/rec_mb.cpp index 1d7e33e4..348c659b 100644 --- a/codec/decoder/core/src/rec_mb.cpp +++ b/codec/decoder/core/src/rec_mb.cpp @@ -79,7 +79,7 @@ int32_t RecI8x8Luma (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLe int8_t* pIntra8x8PredMode = pDqLayer->pIntra4x4FinalMode[iMbXy]; // I_NxN int16_t* pRS = pScoeffLevel; /*itransform info*/ - PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8; + PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8; /*************local variable********************/ uint8_t i = 0; @@ -133,7 +133,7 @@ int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLe int8_t* pIntra4x4PredMode = pDqLayer->pIntra4x4FinalMode[iMBXY]; int16_t* pRS = pScoeffLevel; /*itransform info*/ - PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc; + PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc; /*************local variable********************/ @@ -547,8 +547,8 @@ int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLeve uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4; if (1 == uiCbpC || 2 == uiCbpC) { - WelsChromaDcIdct (pScoeffLevel + 256); // 256 = 16*16 - WelsChromaDcIdct (pScoeffLevel + 320); // 256 = 16*16 + WelsChromaDcIdct (pScoeffLevel + 256); // 256 = 16*16 + WelsChromaDcIdct (pScoeffLevel + 320); // 256 = 16*16 for (i = 0; i < 2; i++) { int16_t* pRS = pScoeffLevel + 256 + (i << 6); uint8_t* pPred = pDqLayer->pPred[i + 1]; diff --git a/codec/decoder/plus/inc/welsDecoderExt.h b/codec/decoder/plus/inc/welsDecoderExt.h index 4e2ee826..b40a6655 100644 --- a/codec/decoder/plus/inc/welsDecoderExt.h +++ b/codec/decoder/plus/inc/welsDecoderExt.h @@ -106,8 +106,8 @@ virtual long EXTAPI SetOption (DECODER_OPTION eOptID, void* pOption); virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption); private: -PWelsDecoderContext m_pDecContext; -welsCodecTrace* m_pWelsTrace; +PWelsDecoderContext m_pDecContext; +welsCodecTrace* m_pWelsTrace; int32_t InitDecoder (const bool); void UninitDecoder (void); diff --git a/codec/decoder/plus/src/welsDecoderExt.cpp b/codec/decoder/plus/src/welsDecoderExt.cpp index 15dd8f3d..337a0e70 100644 --- a/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/codec/decoder/plus/src/welsDecoderExt.cpp @@ -59,7 +59,7 @@ extern "C" { #include "manage_dec_ref.h" } #include "error_code.h" -#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms +#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms #include #if defined(_WIN32) /*&& defined(_DEBUG)*/ @@ -102,7 +102,7 @@ CWelsDecoder::CWelsDecoder (void) #endif//OUTPUT_BIT_STREAM - m_pWelsTrace = new welsCodecTrace(); + m_pWelsTrace = new welsCodecTrace(); if (m_pWelsTrace != NULL) { m_pWelsTrace->SetCodecInstance (this); m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); @@ -227,7 +227,7 @@ void CWelsDecoder::UninitDecoder (void) { if (NULL != m_pDecContext) { WelsFree (m_pDecContext, "m_pDecContext"); - m_pDecContext = NULL; + m_pDecContext = NULL; } } @@ -240,7 +240,7 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) { if (m_pDecContext) //free UninitDecoder(); - m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); + m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); if (NULL == m_pDecContext) return cmMallocMemeError; @@ -266,23 +266,23 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { if (pOption == NULL) return cmInitParaError; - iVal = * ((int*)pOption); // is_rgb + iVal = * ((int*)pOption); // is_rgb return DecoderSetCsp (m_pDecContext, iVal); } else if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded if (pOption == NULL) return cmInitParaError; - iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag + iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag - m_pDecContext->bEndOfStreamFlag = iVal ? true : false; + m_pDecContext->bEndOfStreamFlag = iVal ? true : false; return cmResultSuccess; } else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status if (pOption == NULL) return cmInitParaError; - iVal = * ((int*)pOption); // int value for error concealment idc + iVal = * ((int*)pOption); // int value for error concealment idc iVal = WELS_CLIP3 (iVal, (int32_t) ERROR_CON_DISABLE, (int32_t) ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE); m_pDecContext->eErrorConMethod = (ERROR_CON_IDC) iVal; if ((m_pDecContext->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) { @@ -340,11 +340,11 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) { if (DECODER_OPTION_DATAFORMAT == eOptID) { iVal = (int32_t) m_pDecContext->eOutputColorFormat; - * ((int*)pOption) = iVal; + * ((int*)pOption) = iVal; return cmResultSuccess; } else if (DECODER_OPTION_END_OF_STREAM == eOptID) { - iVal = m_pDecContext->bEndOfStreamFlag; - * ((int*)pOption) = iVal; + iVal = m_pDecContext->bEndOfStreamFlag; + * ((int*)pOption) = iVal; return cmResultSuccess; } #ifdef LONG_TERM_REF @@ -471,9 +471,9 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, m_pDecContext->bInstantDecFlag = false; //reset no-delay flag if (m_pDecContext->iErrorCode) { EWelsNalUnitType eNalType = - NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently + NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently - eNalType = m_pDecContext->sCurNalHead.eNalUnitType; + eNalType = m_pDecContext->sCurNalHead.eNalUnitType; if (m_pDecContext->iErrorCode & dsOutOfMemory) { ForceResetParaSetStatusAndAUList (m_pDecContext); @@ -638,7 +638,7 @@ DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc, int& iWidth, int& iHeight, int& iColorFormat) { - DECODING_STATE state = dsErrorFree; + DECODING_STATE state = dsErrorFree; return state; } @@ -678,7 +678,7 @@ long WelsCreateDecoder (ISVCDecoder** ppDecoder) { return ERR_INVALID_PARAMETERS; } - *ppDecoder = new CWelsDecoder(); + *ppDecoder = new CWelsDecoder(); if (NULL == *ppDecoder) { return ERR_MALLOC_FAILED; diff --git a/codec/encoder/core/inc/as264_common.h b/codec/encoder/core/inc/as264_common.h index cd8abff6..30b21a3d 100644 --- a/codec/encoder/core/inc/as264_common.h +++ b/codec/encoder/core/inc/as264_common.h @@ -50,16 +50,16 @@ $(TargetPath) /**************************************************************************** * Options for algorithm, usually change bitrate ****************************************************************************/ -#define DISABLE_FMO_FEATURE // +#define DISABLE_FMO_FEATURE // /**************************************************************************** * Options for optimization, not change bitrate ****************************************************************************/ -//#undef X86_ASM // X86_ASM is included in project preprocessor definitions, undef it when need to disable asm code -#define SINGLE_REF_FRAME // need to disable it when use multi-reference +//#undef X86_ASM // X86_ASM is included in project preprocessor definitions, undef it when need to disable asm code +#define SINGLE_REF_FRAME // need to disable it when use multi-reference -#if defined(WELS_TESTBED) // for SGE testing +#if defined(WELS_TESTBED) // for SGE testing #define ENABLE_FRAME_DUMP #ifdef FRAME_INFO_OUTPUT @@ -68,7 +68,7 @@ $(TargetPath) #endif//WELS_TESTBED -#if defined(__UNITTEST__) // for unittest +#if defined(__UNITTEST__) // for unittest #ifndef ENABLE_FRAME_DUMP #define ENABLE_FRAME_DUMP #endif//ENABLE_FRAME_DUMP @@ -80,7 +80,7 @@ $(TargetPath) // //#define FRAME_INFO_OUTPUT //#define LAYER_INFO_OUTPUT -//#define SLICE_INFO_OUTPUT // useful in multiple slice coding track +//#define SLICE_INFO_OUTPUT // useful in multiple slice coding track //#define MB_TYPES_INFO_OUTPUT diff --git a/codec/encoder/core/inc/deblocking.h b/codec/encoder/core/inc/deblocking.h index 90e059ff..19ba5d19 100644 --- a/codec/encoder/core/inc/deblocking.h +++ b/codec/encoder/core/inc/deblocking.h @@ -50,11 +50,11 @@ namespace WelsEnc { //struct tagDeblockingFunc; typedef struct TagDeblockingFilter { - uint8_t* pCsData[3]; // pointer to reconstructed picture pData - int32_t iCsStride[3]; // Cs iStride + uint8_t* pCsData[3]; // pointer to reconstructed picture pData + int32_t iCsStride[3]; // Cs iStride int16_t iMbStride; - int8_t iSliceAlphaC0Offset; - int8_t iSliceBetaOffset; + int8_t iSliceAlphaC0Offset; + int8_t iSliceBetaOffset; uint8_t uiLumaQP; uint8_t uiChromaQP; uint8_t uiFilterIdc; diff --git a/codec/encoder/core/inc/dq_map.h b/codec/encoder/core/inc/dq_map.h index b26d0b5d..ba83fab2 100644 --- a/codec/encoder/core/inc/dq_map.h +++ b/codec/encoder/core/inc/dq_map.h @@ -48,9 +48,9 @@ namespace WelsEnc { */ typedef struct TagDqIdc { -uint16_t iPpsId; // pPps id -uint8_t iSpsId; // pSps id -int8_t uiSpatialId; // spatial id +uint16_t iPpsId; // pPps id +uint8_t iSpsId; // pSps id +int8_t uiSpatialId; // spatial id } SDqIdc; } diff --git a/codec/encoder/core/inc/encode_mb_aux.h b/codec/encoder/core/inc/encode_mb_aux.h index 11a4b4cb..cd2e620c 100644 --- a/codec/encoder/core/inc/encode_mb_aux.h +++ b/codec/encoder/core/inc/encode_mb_aux.h @@ -44,10 +44,10 @@ int32_t WelsGetNoneZeroCount_c (int16_t* pLevel); /**************************************************************************** * Scan and Score functions ****************************************************************************/ -void WelsScan4x4Ac_c (int16_t* pZigValue, int16_t* pDct); -void WelsScan4x4Dc (int16_t* pLevel, int16_t* pDct); -void WelsScan4x4DcAc_c (int16_t* pLevel, int16_t* pDct); -int32_t WelsCalculateSingleCtr4x4_c (int16_t* pDct); +void WelsScan4x4Ac_c (int16_t* pZigValue, int16_t* pDct); +void WelsScan4x4Dc (int16_t* pLevel, int16_t* pDct); +void WelsScan4x4DcAc_c (int16_t* pLevel, int16_t* pDct); +int32_t WelsCalculateSingleCtr4x4_c (int16_t* pDct); /**************************************************************************** * HDM and Quant functions diff --git a/codec/encoder/core/inc/encoder.h b/codec/encoder/core/inc/encoder.h index b1588ef9..2afe57f7 100644 --- a/codec/encoder/core/inc/encoder.h +++ b/codec/encoder/core/inc/encoder.h @@ -116,7 +116,7 @@ int32_t EncodeFrame (sWelsEncCtx* pEncCtx, /********************************************************************************** * memzero Function ***********************************************************************************/ -void WelsSetMemZero_c (void* pDst, int32_t iSize); // confirmed_safe_unsafe_usage +void WelsSetMemZero_c (void* pDst, int32_t iSize); // confirmed_safe_unsafe_usage #if defined(__cplusplus) extern "C" { diff --git a/codec/encoder/core/inc/encoder_context.h b/codec/encoder/core/inc/encoder_context.h index e54d4b78..1e7a0f7c 100644 --- a/codec/encoder/core/inc/encoder_context.h +++ b/codec/encoder/core/inc/encoder_context.h @@ -55,7 +55,7 @@ #include "crt_util_safe_x.h" #include "utils.h" -#include "mt_defs.h" // for multiple threadin, +#include "mt_defs.h" // for multiple threadin, #include "WelsThreadLib.h" namespace WelsEnc { @@ -64,166 +64,162 @@ namespace WelsEnc { * reference list for each quality layer in SVC */ typedef struct TagRefList { - SPicture* pShortRefList[1 + MAX_SHORT_REF_COUNT]; // reference list 0 - int16_t - SPicture* pLongRefList[1 + MAX_REF_PIC_COUNT]; // reference list 1 - int32_t - SPicture* pNextBuffer; - SPicture* pRef[1 + MAX_REF_PIC_COUNT]; // plus 1 for swap intend - uint8_t uiShortRefCount; - uint8_t uiLongRefCount; // dependend on pRef pic module + SPicture* pShortRefList[1 + MAX_SHORT_REF_COUNT]; // reference list 0 - int16_t + SPicture* pLongRefList[1 + MAX_REF_PIC_COUNT]; // reference list 1 - int32_t + SPicture* pNextBuffer; + SPicture* pRef[1 + MAX_REF_PIC_COUNT]; // plus 1 for swap intend + uint8_t uiShortRefCount; + uint8_t uiLongRefCount; // dependend on pRef pic module } SRefList; typedef struct TagLTRState { // LTR mark feedback - uint32_t uiLtrMarkState; // LTR mark state, indicate whether there is a LTR mark feedback unsolved - int32_t iLtrMarkFbFrameNum;// the unsolved LTR mark feedback, the marked iFrameNum feedback from decoder + uint32_t uiLtrMarkState; // LTR mark state, indicate whether there is a LTR mark feedback unsolved + int32_t iLtrMarkFbFrameNum;// the unsolved LTR mark feedback, the marked iFrameNum feedback from decoder // LTR used as recovery reference - int32_t iLastRecoverFrameNum; // reserve the last LTR or IDR recover iFrameNum - int32_t - iLastCorFrameNumDec; // reserved the last correct position in decoder side, use to select valid LTR to recover or to decide the LTR mark validation - int32_t - iCurFrameNumInDec; // current iFrameNum in decoder side, use to select valid LTR to recover or to decide the LTR mark validation + int32_t iLastRecoverFrameNum; // reserve the last LTR or IDR recover iFrameNum + int32_t iLastCorFrameNumDec; // reserved the last correct position in decoder side, use to select valid LTR to recover or to decide the LTR mark validation + int32_t iCurFrameNumInDec; // current iFrameNum in decoder side, use to select valid LTR to recover or to decide the LTR mark validation // LTR mark - int32_t iLTRMarkMode; // direct mark or delay mark - int32_t iLTRMarkSuccessNum; //successful marked num, for mark mode switch - int32_t iCurLtrIdx;// current int32_t term reference index to mark - int32_t iLastLtrIdx[MAX_TEMPORAL_LAYER_NUM]; - int32_t iSceneLtrIdx;// related to Scene LTR, used by screen content + int32_t iLTRMarkMode; // direct mark or delay mark + int32_t iLTRMarkSuccessNum; //successful marked num, for mark mode switch + int32_t iCurLtrIdx;// current int32_t term reference index to mark + int32_t iLastLtrIdx[MAX_TEMPORAL_LAYER_NUM]; + int32_t iSceneLtrIdx;// related to Scene LTR, used by screen content - uint32_t uiLtrMarkInterval;// the interval from the last int32_t term pRef mark + uint32_t uiLtrMarkInterval;// the interval from the last int32_t term pRef mark - bool bLTRMarkingFlag; //decide whether current frame marked as LTR - bool bLTRMarkEnable; //when LTR is confirmed and the interval is no smaller than the marking period - bool bReceivedT0LostFlag; // indicate whether a t0 lost feedback is recieved, for LTR recovery + bool bLTRMarkingFlag; //decide whether current frame marked as LTR + bool bLTRMarkEnable; //when LTR is confirmed and the interval is no smaller than the marking period + bool bReceivedT0LostFlag; // indicate whether a t0 lost feedback is recieved, for LTR recovery } SLTRState; typedef struct TagSpatialPicIndex { - SPicture* pSrc; // I420 based and after color space converted - int32_t iDid; // dependency id + SPicture* pSrc; // I420 based and after color space converted + int32_t iDid; // dependency id } SSpatialPicIndex; typedef struct TagStrideTables { - int32_t* pStrideDecBlockOffset[MAX_DEPENDENCY_LAYER][2]; // [iDid][tid==0][24 x 4]: luma+chroma= 24 x 4 - int32_t* pStrideEncBlockOffset[MAX_DEPENDENCY_LAYER]; // [iDid][24 x 4]: luma+chroma= 24 x 4 - int16_t* pMbIndexX[MAX_DEPENDENCY_LAYER]; // [iDid][iMbX]: map for iMbX in each spatial layer coding - int16_t* pMbIndexY[MAX_DEPENDENCY_LAYER]; // [iDid][iMbY]: map for iMbY in each spatial layer coding + int32_t* pStrideDecBlockOffset[MAX_DEPENDENCY_LAYER][2]; // [iDid][tid==0][24 x 4]: luma+chroma= 24 x 4 + int32_t* pStrideEncBlockOffset[MAX_DEPENDENCY_LAYER]; // [iDid][24 x 4]: luma+chroma= 24 x 4 + int16_t* pMbIndexX[MAX_DEPENDENCY_LAYER]; // [iDid][iMbX]: map for iMbX in each spatial layer coding + int16_t* pMbIndexY[MAX_DEPENDENCY_LAYER]; // [iDid][iMbY]: map for iMbY in each spatial layer coding } SStrideTables; typedef struct TagWelsEncCtx { SLogContext sLogCtx; // Input - SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h - SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx] + SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h + SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx] - int32_t* pSadCostMb; + int32_t* pSadCostMb; /* MVD cost tables for Inter MB */ - int32_t iMvRange; - uint16_t* pMvdCostTable; //[52]; // adaptive to spatial layers - int32_t iMvdCostTableSize; //the size of above table - int32_t iMvdCostTableStride; //the stride of above table + int32_t iMvRange; + uint16_t* pMvdCostTable; //[52]; // adaptive to spatial layers + int32_t iMvdCostTableSize; //the size of above table + int32_t iMvdCostTableStride; //the stride of above table SMVUnitXY* - pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer + pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer int8_t* - pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer - int8_t* pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM]; + pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer + int8_t* pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM]; int8_t* - pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11) + pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11) - SMB** ppMbListD; // [MAX_DEPENDENCY_LAYER]; - SStrideTables* pStrideTab; // stride tables for internal coding used - SWelsFuncPtrList* pFuncList; + SMB** ppMbListD; // [MAX_DEPENDENCY_LAYER]; + SStrideTables* pStrideTab; // stride tables for internal coding used + SWelsFuncPtrList* pFuncList; - SSliceThreading* pSliceThreading; + SSliceThreading* pSliceThreading; // SSlice context - SSliceCtx* pSliceCtxList;// slice context table for each dependency quality layer + SSliceCtx* pSliceCtxList;// slice context table for each dependency quality layer // pointers - SPicture* pEncPic; // pointer to current picture to be encoded - SPicture* pDecPic; // pointer to current picture being reconstructed - SPicture* pRefPic; // pointer to current reference picture + SPicture* pEncPic; // pointer to current picture to be encoded + SPicture* pDecPic; // pointer to current picture being reconstructed + SPicture* pRefPic; // pointer to current reference picture - SDqLayer* - pCurDqLayer; // DQ layer context used to being encoded currently, for reference base layer to refer: pCurDqLayer->pRefLayer if applicable - SDqLayer** ppDqLayerList; // overall DQ layers encoded for storage + SDqLayer* pCurDqLayer; // DQ layer context used to being encoded currently, for reference base layer to refer: pCurDqLayer->pRefLayer if applicable + SDqLayer** ppDqLayerList; // overall DQ layers encoded for storage - SRefList** ppRefPicListExt; // reference picture list for SVC - SPicture* pRefList0[16]; - SLTRState* pLtr;//[MAX_DEPENDENCY_LAYER]; - bool bCurFrameMarkedAsSceneLtr; + SRefList** ppRefPicListExt; // reference picture list for SVC + SPicture* pRefList0[16]; + SLTRState* pLtr;//[MAX_DEPENDENCY_LAYER]; + bool bCurFrameMarkedAsSceneLtr; // Derived - int32_t iCodingIndex; - int32_t iFrameIndex; // count how many frames elapsed during coding context currently - int32_t iFrameNum; // current frame number coding - int32_t iPOC; // frame iPOC - EWelsSliceType eSliceType; // currently coding slice type - EWelsNalUnitType eNalType; // NAL type - EWelsNalRefIdc eNalPriority; // NAL_Reference_Idc currently - EWelsNalRefIdc eLastNalPriority; // NAL_Reference_Idc in last frame - uint8_t iNumRef0; + int32_t iCodingIndex; + int32_t iFrameIndex; // count how many frames elapsed during coding context currently + int32_t iFrameNum; // current frame number coding + int32_t iPOC; // frame iPOC + EWelsSliceType eSliceType; // currently coding slice type + EWelsNalUnitType eNalType; // NAL type + EWelsNalRefIdc eNalPriority; // NAL_Reference_Idc currently + EWelsNalRefIdc eLastNalPriority; // NAL_Reference_Idc in last frame + uint8_t iNumRef0; - uint8_t uiDependencyId; // Idc of dependecy layer to be coded - uint8_t uiTemporalId; // Idc of temporal layer to be coded - bool bNeedPrefixNalFlag; // whether add prefix nal - bool bEncCurFrmAsIdrFlag; + uint8_t uiDependencyId; // Idc of dependecy layer to be coded + uint8_t uiTemporalId; // Idc of temporal layer to be coded + bool bNeedPrefixNalFlag; // whether add prefix nal + bool bEncCurFrmAsIdrFlag; // Rate control routine - SWelsSvcRc* pWelsSvcRc; + SWelsSvcRc* pWelsSvcRc; bool bCheckWindowStatusRefreshFlag; int64_t iCheckWindowStartTs; int64_t iCheckWindowCurrentTs; int32_t iCheckWindowInterval; int32_t iCheckWindowIntervalShift; bool bCheckWindowShiftResetFlag; - int32_t iSkipFrameFlag; //_GOM_RC_ + int32_t iSkipFrameFlag; //_GOM_RC_ int32_t iContinualSkipFrames; - int32_t iGlobalQp; // global qp + int32_t iGlobalQp; // global qp // VAA - SVAAFrameInfo* pVaa; // VAA information of reference - CWelsPreProcess* pVpp; + SVAAFrameInfo* pVaa; // VAA information of reference + CWelsPreProcess* pVpp; - SWelsSPS* pSpsArray; // MAX_SPS_COUNT by standard compatible - SWelsSPS* pSps; - SWelsPPS* pPPSArray; // MAX_PPS_COUNT by standard compatible - SWelsPPS* pPps; + SWelsSPS* pSpsArray; // MAX_SPS_COUNT by standard compatible + SWelsSPS* pSps; + SWelsPPS* pPPSArray; // MAX_PPS_COUNT by standard compatible + SWelsPPS* pPps; /* SVC only */ - SSubsetSps* pSubsetArray; // MAX_SPS_COUNT by standard compatible - SSubsetSps* pSubsetSps; - int32_t iSpsNum; // number of pSps used - int32_t iSubsetSpsNum; // number of pSps used - int32_t iPpsNum; // number of pPps used + SSubsetSps* pSubsetArray; // MAX_SPS_COUNT by standard compatible + SSubsetSps* pSubsetSps; + int32_t iSpsNum; // number of pSps used + int32_t iSubsetSpsNum; // number of pSps used + int32_t iPpsNum; // number of pPps used // Output - SWelsEncoderOutput* pOut; // for NAL raw pData (need allocating memory for sNalList internal) - uint8_t* pFrameBs; // restoring bitstream pBuffer of all NALs in a frame - int32_t iFrameBsSize; // count size of frame bs in bytes allocated - int32_t iPosBsBuffer; // current writing position of frame bs pBuffer + SWelsEncoderOutput* pOut; // for NAL raw pData (need allocating memory for sNalList internal) + uint8_t* pFrameBs; // restoring bitstream pBuffer of all NALs in a frame + int32_t iFrameBsSize; // count size of frame bs in bytes allocated + int32_t iPosBsBuffer; // current writing position of frame bs pBuffer - SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER]; + SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER]; - bool bRefOfCurTidIsLtr[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL]; - uint16_t uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR + bool bRefOfCurTidIsLtr[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL]; + uint16_t uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR - int32_t iMaxSliceCount;// maximal count number of slices for all layers observation - int16_t iActiveThreadsNum; // number of threads active so far + int32_t iMaxSliceCount;// maximal count number of slices for all layers observation + int16_t iActiveThreadsNum; // number of threads active so far /* * DQ layer idc map for svc encoding, might be a better scheme than that of design before, * can aware idc of referencing layer and that idc of successive layer to be coded */ /* SVC only */ - SDqIdc* - pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData + SDqIdc* pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData - SParaSetOffset sPSOVector; - SParaSetOffset* pPSOVector; - CMemoryAlign* pMemAlign; + SParaSetOffset sPSOVector; + SParaSetOffset* pPSOVector; + CMemoryAlign* pMemAlign; #if defined(STAT_OUTPUT) // overall stat pData, refer to SStatData in stat.h, in case avc to use stat[0][0] - SStatData sStatData [ MAX_DEPENDENCY_LAYER ] [ MAX_QUALITY_LEVEL ]; - SStatSliceInfo sPerInfo; + SStatData sStatData [ MAX_DEPENDENCY_LAYER ] [ MAX_QUALITY_LEVEL ]; + SStatSliceInfo sPerInfo; #endif//STAT_OUTPUT //related to Statistics @@ -236,7 +232,7 @@ typedef struct TagWelsEncCtx { int64_t iLastStatisticsFrameCount; int32_t iEncoderError; - WELS_MUTEX mutexEncoderError; + WELS_MUTEX mutexEncoderError; bool bDeliveryFlag; SStateCtx sWelsCabacContexts[4][WELS_QP_MAX + 1][WELS_CONTEXT_COUNT]; #ifdef ENABLE_FRAME_DUMP diff --git a/codec/encoder/core/inc/mb_cache.h b/codec/encoder/core/inc/mb_cache.h index 8423229c..d7c0494f 100644 --- a/codec/encoder/core/inc/mb_cache.h +++ b/codec/encoder/core/inc/mb_cache.h @@ -73,16 +73,16 @@ typedef struct TagMbCache { //the followed pData now is promised aligned to 16 bytes ALIGNED_DECLARE (SMVComponentUnit, sMvComponents, 16); -ALIGNED_DECLARE (int8_t, iNonZeroCoeffCount[48], 16); // Cache line size -// int8_t iNonZeroCoeffCount[6 * 8]; // Right luma, Chroma(Left Top Cb, Left btm Cr); must follow by iIntraPredMode! +ALIGNED_DECLARE (int8_t, iNonZeroCoeffCount[48], 16); // Cache line size +// int8_t iNonZeroCoeffCount[6 * 8]; // Right luma, Chroma(Left Top Cb, Left btm Cr); must follow by iIntraPredMode! ALIGNED_DECLARE (int8_t, iIntraPredMode[48], 16); -// must follow with iNonZeroCoeffCount! +// must follow with iNonZeroCoeffCount! -int32_t iSadCost[4]; //avail 1; unavail 0 +int32_t iSadCost[4]; //avail 1; unavail 0 SMVUnitXY sMbMvp[MB_BLOCK4x4_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; @@ -108,7 +108,7 @@ bool* pPrevIntra4x4PredModeFlag; //pRemIntra4x4PredModeFlag or added by 1 is the best pred_mode int8_t* pRemIntra4x4PredModeFlag; -int32_t iSadCostSkip[4]; //avail 1; unavail 0 +int32_t iSadCostSkip[4]; //avail 1; unavail 0 bool bMbTypeSkip[4]; //1: skip; 0: non-skip int32_t* pEncSad; @@ -119,8 +119,8 @@ uint8_t uiNeighborIntra; // LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPLEFT_MB_P uint8_t uiLumaI16x16Mode; uint8_t uiChmaI8x8Mode; -bool bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0). -uint32_t uiRefMbType; +bool bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0). +uint32_t uiRefMbType; struct { /* pointer of current mb location in original frame */ @@ -130,8 +130,8 @@ struct { /* pointer of co-located mb location in reference frame */ uint8_t* pRefMb[3]; //for SVC - uint8_t* pCsMb[3];//locating current mb's CS in whole frame -// int16_t *p_rs[3];//locating current mb's RS in whole frame + 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; } SMbCache; diff --git a/codec/encoder/core/inc/md.h b/codec/encoder/core/inc/md.h index eca89d12..7e277106 100644 --- a/codec/encoder/core/inc/md.h +++ b/codec/encoder/core/inc/md.h @@ -84,35 +84,35 @@ extern const int8_t g_kiMapModeIntraChroma[7]; // if we want keep total sizeof(SWelsMD) <= 256, we maybe need to seperate three member of SWelsME. typedef struct TagWelsMD { -int32_t iLambda; -uint16_t* pMvdCost; +int32_t iLambda; +uint16_t* pMvdCost; -int32_t iCostLuma; -int32_t iCostChroma;//satd+lambda(best_pred_mode) //i_sad_chroma; -int32_t iSadPredMb; +int32_t iCostLuma; +int32_t iCostChroma;//satd+lambda(best_pred_mode) //i_sad_chroma; +int32_t iSadPredMb; -uint8_t uiRef; //uiRefIndex appointed by Encoder, used for MC -bool bMdUsingSad; -uint16_t uiReserved; +uint8_t uiRef; //uiRefIndex appointed by Encoder, used for MC +bool bMdUsingSad; +uint16_t uiReserved; -int32_t iCostSkipMb; -int32_t iSadPredSkip; +int32_t iCostSkipMb; +int32_t iSadPredSkip; -int32_t iMbPixX; // pixel position of MB in horizontal axis -int32_t iMbPixY; // pixel position of MB in vertical axis -int32_t iBlock8x8StaticIdc[4]; +int32_t iMbPixX; // pixel position of MB in horizontal axis +int32_t iMbPixY; // pixel position of MB in vertical axis +int32_t iBlock8x8StaticIdc[4]; //NO B frame in our Wels, we can ignore list1 struct { - SWelsME sMe16x16; //adjust each SWelsME for 8 D-word! - SWelsME sMe8x8[4]; - SWelsME sMe16x8[2]; - SWelsME sMe8x16[2]; - SWelsME sMe4x4[4][4]; - SWelsME sMe8x4[4][2]; - SWelsME sMe4x8[4][2]; -// SMVUnitXY i_mvbs[MB_BLOCK8x8_NUM]; //scaled MVB + SWelsME sMe16x16; //adjust each SWelsME for 8 D-word! + SWelsME sMe8x8[4]; + SWelsME sMe16x8[2]; + SWelsME sMe8x16[2]; + SWelsME sMe4x4[4][4]; + SWelsME sMe8x4[4][2]; + SWelsME sMe4x8[4][2]; +// SMVUnitXY i_mvbs[MB_BLOCK8x8_NUM]; //scaled MVB } sMe; } SWelsMD; diff --git a/codec/encoder/core/inc/mt_defs.h b/codec/encoder/core/inc/mt_defs.h index 4fdb3637..08fc1bcc 100644 --- a/codec/encoder/core/inc/mt_defs.h +++ b/codec/encoder/core/inc/mt_defs.h @@ -59,36 +59,35 @@ #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] +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_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] -int32_t* pSliceComplexRatio[MAX_DEPENDENCY_LAYER]; // *INT_MULTIPLY +uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx] +int32_t* pSliceComplexRatio[MAX_DEPENDENCY_LAYER]; // *INT_MULTIPLY #ifdef MT_DEBUG -FILE* pFSliceDiff; // file handle for debug +FILE* pFSliceDiff; // file handle for debug #endif//MT_DEBUG } SSliceThreading; diff --git a/codec/encoder/core/inc/nal_encap.h b/codec/encoder/core/inc/nal_encap.h index b1f5ca19..a17043bd 100644 --- a/codec/encoder/core/inc/nal_encap.h +++ b/codec/encoder/core/inc/nal_encap.h @@ -54,10 +54,10 @@ namespace WelsEnc { * 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 } SWelsNalRaw; @@ -66,39 +66,39 @@ int32_t iStartPos; //NAL start position in buffer * 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* pNalLen; -int32_t iCountNals; // count number of NAL in list +// 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* pNalLen; +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 +// bool bAnnexBFlag; // annexeb flag, to figure it pOut the packetization mode whether need 4 bytes (0 0 0 1) of start code prefix } SWelsEncoderOutput; -//#define MT_DEBUG_BS_WR 0 // for MT debugging if needed +//#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 -// int32_t iCountNals; // count number of NAL in list -int32_t iNalLen[2]; -int32_t iNalIndex; // coding NAL currently, 0 based +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 -// bool bAnnexBFlag; // annexeb flag, to figure it pOut the packetization mode whether need 4 bytes (0 0 0 1) of start code prefix +// 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; diff --git a/codec/encoder/core/inc/param_svc.h b/codec/encoder/core/inc/param_svc.h index 44879047..06749d94 100644 --- a/codec/encoder/core/inc/param_svc.h +++ b/codec/encoder/core/inc/param_svc.h @@ -63,9 +63,9 @@ extern const uint8_t g_kuiTemporalIdListTable[MAX_TEMPORAL_LEVEL][MAX_GOP_SIZE * \return 2 based scaling factor */ static inline uint32_t GetLogFactor (float base, float upper) { - const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0); - const double dEpsilon = 0.0001; - const double dRound = floor (dLog2factor + 0.5); + const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0); + const double dEpsilon = 0.0001; + const double dRound = floor (dLog2factor + 0.5); if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) { return (uint32_t) (dRound); @@ -77,18 +77,18 @@ static inline uint32_t GetLogFactor (float base, float upper) { * Dependency Layer Parameter */ typedef struct TagDLayerParam { - int32_t iActualWidth; // input source picture actual width - int32_t iActualHeight; // input source picture actual height - int32_t iTemporalResolution; - int32_t iDecompositionStages; - uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1]; + int32_t iActualWidth; // input source picture actual width + int32_t iActualHeight; // input source picture actual height + int32_t iTemporalResolution; + int32_t iDecompositionStages; + uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1]; - int8_t iHighestTemporalId; - float fInputFrameRate; // input frame rate - float fOutputFrameRate; // output frame rate + int8_t iHighestTemporalId; + 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 } SSpatialLayerInternal; @@ -96,25 +96,25 @@ typedef struct TagDLayerParam { * Cisco OpenH264 Encoder Parameter Configuration */ typedef struct TagWelsSvcCodingParam: SEncParamExt { - SSpatialLayerInternal sDependencyLayers[MAX_DEPENDENCY_LAYER]; + SSpatialLayerInternal sDependencyLayers[MAX_DEPENDENCY_LAYER]; /* General */ - uint32_t uiGopSize; // GOP size (at maximal frame rate: 16) + 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/ - bool bDeblockingParallelFlag; // deblocking filter parallelization control flag + bool bDeblockingParallelFlag; // deblocking filter parallelization control flag int32_t iBitsVaryPercentage; short iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means; - int8_t iDecompStages; // GOP size dependency + int8_t iDecompStages; // GOP size dependency int32_t iMaxNumRefFrame; public: @@ -125,46 +125,46 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { static void FillDefault (SEncParamExt& param) { memset (¶m, 0, sizeof (param)); - param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired) - param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used + param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired) + param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used - param.iPicWidth = 0; // actual input picture width - param.iPicHeight = 0; // actual input picture height + param.iPicWidth = 0; // actual input picture width + param.iPicHeight = 0; // actual input picture height - param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps] + param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps] - param.iComplexityMode = MEDIUM_COMPLEXITY; - param.iTargetBitrate = UNSPECIFIED_BIT_RATE; // overall target bitrate introduced in RC module - param.iMaxBitrate = UNSPECIFIED_BIT_RATE; - param.iMultipleThreadIdc = 1; + param.iComplexityMode = MEDIUM_COMPLEXITY; + param.iTargetBitrate = UNSPECIFIED_BIT_RATE; // overall target bitrate introduced in RC module + param.iMaxBitrate = UNSPECIFIED_BIT_RATE; + param.iMultipleThreadIdc = 1; - param.iLTRRefNum = 0; - param.iLtrMarkPeriod = 30; //the min distance of two int32_t references + param.iLTRRefNum = 0; + param.iLtrMarkPeriod = 30; //the min distance of two int32_t references - param.bEnableSSEI = false; - param.bSimulcastAVC = false; - param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application + param.bEnableSSEI = false; + param.bSimulcastAVC = false; + param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application // false: Streaming Video Sharing; true: Video Conferencing Meeting; /* Deblocking loop filter */ - param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries - param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0 - param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0 + param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries + param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0 + param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0 /* Rate Control */ - param.iRCMode = RC_QUALITY_MODE; - param.iPaddingFlag = 0; - param.iEntropyCodingModeFlag = 0; - param.bEnableDenoise = false; // denoise control - param.bEnableSceneChangeDetect = true; // scene change detection control - param.bEnableBackgroundDetection = true; // background detection control - param.bEnableAdaptiveQuant = true; // adaptive quantization control - param.bEnableFrameSkip = true; // frame skipping - param.bEnableLongTermReference = false; // long term reference control - param.eSpsPpsIdStrategy = INCREASING_ID; // pSps pPps id addition control - param.bPrefixNalAddingCtrl = false; // prefix NAL adding control - param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded - param.iTemporalLayerNum = 1; // number of temporal layer specified + param.iRCMode = RC_QUALITY_MODE; + param.iPaddingFlag = 0; + param.iEntropyCodingModeFlag = 0; + param.bEnableDenoise = false; // denoise control + param.bEnableSceneChangeDetect = true; // scene change detection control + param.bEnableBackgroundDetection = true; // background detection control + param.bEnableAdaptiveQuant = true; // adaptive quantization control + param.bEnableFrameSkip = true; // frame skipping + param.bEnableLongTermReference = false; // long term reference control + param.eSpsPpsIdStrategy = INCREASING_ID;// pSps pPps id addition control + param.bPrefixNalAddingCtrl = false; // prefix NAL adding control + param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded + param.iTemporalLayerNum = 1; // number of temporal layer specified param.iMaxQp = 51; param.iMinQp = 0; @@ -188,28 +188,28 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { void FillDefault() { FillDefault (*this); - uiGopSize = 1; // GOP size (at maximal frame rate: 16) + uiGopSize = 1; // GOP size (at maximal frame rate: 16) iMaxNumRefFrame = AUTO_REF_PIC_COUNT; - SUsedPicRect.iLeft = - SUsedPicRect.iTop = - SUsedPicRect.iWidth = - SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used + SUsedPicRect.iLeft = + SUsedPicRect.iTop = + SUsedPicRect.iWidth = + SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used - pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/ + pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/ - bDeblockingParallelFlag = false; // deblocking filter parallelization control flag + bDeblockingParallelFlag = false;// deblocking filter parallelization control flag - iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means; + iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means; - iDecompStages = 0; // GOP size dependency, unknown here and be revised later + iDecompStages = 0; // GOP size dependency, unknown here and be revised later iBitsVaryPercentage = 0; } int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) { - fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); - iTargetBitrate = pCodingParam.iTargetBitrate; - iUsageType = pCodingParam.iUsageType; + fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); + iTargetBitrate = pCodingParam.iTargetBitrate; + iUsageType = pCodingParam.iUsageType; iPicWidth = pCodingParam.iPicWidth; iPicHeight = pCodingParam.iPicHeight; @@ -220,34 +220,34 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { iRCMode = pCodingParam.iRCMode; // rc mode - int8_t iIdxSpatial = 0; - EProfileIdc uiProfileIdc = PRO_BASELINE; + int8_t iIdxSpatial = 0; + EProfileIdc uiProfileIdc = PRO_BASELINE; if (iEntropyCodingModeFlag) uiProfileIdc = PRO_MAIN; - SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; + SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; while (iIdxSpatial < iSpatialLayerNum) { - sSpatialLayers->uiProfileIdc = uiProfileIdc; - sSpatialLayers->uiLevelIdc = LEVEL_UNKNOWN; - sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, + sSpatialLayers->uiProfileIdc = uiProfileIdc; + sSpatialLayers->uiLevelIdc = LEVEL_UNKNOWN; + sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); - pDlp->fInputFrameRate = - pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE, + pDlp->fInputFrameRate = + pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); #ifdef ENABLE_FRAME_DUMP - pDlp->sRecFileName[0] = '\0'; // file to be constructed + pDlp->sRecFileName[0] = '\0'; // file to be constructed #endif//ENABLE_FRAME_DUMP pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth; pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight; - sSpatialLayers->iSpatialBitrate = - sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer + sSpatialLayers->iSpatialBitrate = + sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer - sSpatialLayers->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; + sSpatialLayers->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP; - uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE; + uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE; ++ pDlp; ++ iIdxSpatial; } @@ -264,7 +264,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { pCodingParam->fMaxFrameRate = fMaxFrameRate; } int32_t ParamTranscode (const SEncParamExt& pCodingParam) { - float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); + float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); iUsageType = pCodingParam.iUsageType; iPicWidth = pCodingParam.iPicWidth; @@ -280,18 +280,18 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc; /* Deblocking loop filter */ - iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries, - iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0 - iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 - iEntropyCodingModeFlag = pCodingParam.iEntropyCodingModeFlag; - bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag; + iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries, + iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0 + iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 + iEntropyCodingModeFlag = pCodingParam.iEntropyCodingModeFlag; + bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag; /* Rate Control */ iRCMode = pCodingParam.iRCMode; // rc mode bSimulcastAVC = pCodingParam.bSimulcastAVC; iPaddingFlag = pCodingParam.iPaddingFlag; - iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate + iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate iMaxBitrate = pCodingParam.iMaxBitrate; if (iMaxBitrate < iTargetBitrate) { iMaxBitrate = iTargetBitrate; @@ -302,19 +302,19 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now /* Scene change detection control */ - bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect; + bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect; /* Background detection Control */ bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false; /* Adaptive quantization control */ - bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false; + bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false; /* Frame skipping */ - bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false; + bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false; /* Enable int32_t term reference */ - bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false; + bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false; iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod; bIsLosslessLink = pCodingParam.bIsLosslessLink; if (iUsageType == SCREEN_CONTENT_REAL_TIME && !bIsLosslessLink && bEnableLongTermReference) { @@ -322,21 +322,21 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { } /* For ssei information */ - bEnableSSEI = pCodingParam.bEnableSSEI; - bSimulcastAVC = pCodingParam.bSimulcastAVC; + bEnableSSEI = pCodingParam.bEnableSSEI; + bSimulcastAVC = pCodingParam.bSimulcastAVC; /* Layer definition */ - iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1, + 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, + 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) + 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 (((pCodingParam.iNumRefFrame != AUTO_REF_PIC_COUNT) @@ -350,7 +350,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { iLTRRefNum = (pCodingParam.bEnableLongTermReference ? pCodingParam.iLTRRefNum : 0); iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod; - bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl; + bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl; if ( (CONSTANT_ID == pCodingParam.eSpsPpsIdStrategy) || (INCREASING_ID == pCodingParam.eSpsPpsIdStrategy) @@ -364,32 +364,32 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { // keep the default value } - SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; + SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0]; - EProfileIdc uiProfileIdc = PRO_BASELINE; - int8_t iIdxSpatial = 0; + EProfileIdc uiProfileIdc = PRO_BASELINE; + int8_t iIdxSpatial = 0; while (iIdxSpatial < iSpatialLayerNum) { - pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc : + pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc : pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc; pSpatialLayer->uiLevelIdc = pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc; - float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, + float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE, fParamMaxFrameRate); - pDlp->fInputFrameRate = fParamMaxFrameRate; + pDlp->fInputFrameRate = fParamMaxFrameRate; pSpatialLayer->fFrameRate = - pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, fParamMaxFrameRate); + pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, fParamMaxFrameRate); #ifdef ENABLE_FRAME_DUMP - pDlp->sRecFileName[0] = '\0'; // file to be constructed + pDlp->sRecFileName[0] = '\0'; // file to be constructed #endif//ENABLE_FRAME_DUMP pSpatialLayer->iVideoWidth = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth, 0, - iPicWidth); // frame width + iPicWidth); // frame width pSpatialLayer->iVideoHeight = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight, 0, iPicHeight);// frame height - pSpatialLayer->iSpatialBitrate = - pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer - pSpatialLayer->iMaxSpatialBitrate = + pSpatialLayer->iSpatialBitrate = + pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer + pSpatialLayer->iMaxSpatialBitrate = pCodingParam.sSpatialLayers[iIdxSpatial].iMaxSpatialBitrate; //multi slice @@ -400,12 +400,12 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum; const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP); memcpy (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum, - pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage + pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage kiLesserSliceNum * sizeof (uint32_t)) ; pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp; - uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE; + uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE; ++ pDlp; ++ pSpatialLayer; ++ iIdxSpatial; @@ -419,9 +419,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { // assuming that the width/height ratio of all spatial layers are the same void SetActualPicResolution() { - int32_t iSpatialIdx = iSpatialLayerNum - 1; + int32_t iSpatialIdx = iSpatialLayerNum - 1; for (; iSpatialIdx >= 0; iSpatialIdx --) { - SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx]; + SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx]; SSpatialLayerConfig* pDlayer = &sSpatialLayers[iSpatialIdx]; pDlayerInternal->iActualWidth = pDlayer->iVideoWidth; @@ -437,17 +437,16 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { * \return NONE (should ensure valid parameter before this procedure) */ int32_t 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]; - SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; + 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]; + SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0]; EProfileIdc uiProfileIdc = iEntropyCodingModeFlag ? PRO_MAIN : PRO_BASELINE; - int8_t i = 0; + int8_t i = 0; while (i < iSpatialLayerNum) { - const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate); - const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate); + const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate); + const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate); if (UINT_MAX == kuiLogFactorInOutRate || UINT_MAX == kuiLogFactorMaxInRate) { return ENC_RETURN_INVALIDINPUT; } @@ -455,9 +454,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { int8_t iMaxTemporalId = 0; memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId)); - pSpatialLayer->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE; + pSpatialLayer->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE; - iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1; + iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1; for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) { if (0 == (uiFrameIdx & iNotCodedMask)) { const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx]; @@ -468,14 +467,14 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt { } } - pDlp->iHighestTemporalId = iMaxTemporalId; - pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate; - pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate; + pDlp->iHighestTemporalId = iMaxTemporalId; + pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate; + pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate; if (pDlp->iDecompositionStages < 0) { return ENC_RETURN_INVALIDINPUT; } - uiProfileIdc = bSimulcastAVC ? (iEntropyCodingModeFlag ? PRO_HIGH : PRO_BASELINE) : + uiProfileIdc = bSimulcastAVC ? (iEntropyCodingModeFlag ? PRO_HIGH : PRO_BASELINE) : (iEntropyCodingModeFlag ? PRO_SCALABLE_HIGH : PRO_SCALABLE_BASELINE); ++ pDlp; ++ pSpatialLayer; @@ -493,9 +492,9 @@ typedef struct TagExistingParasetList { SSubsetSps sSubsetSps[MAX_SPS_COUNT]; SWelsPPS sPps[MAX_PPS_COUNT]; - uint32_t uiInUseSpsNum; - uint32_t uiInUseSubsetSpsNum; - uint32_t uiInUsePpsNum; + uint32_t uiInUseSpsNum; + uint32_t uiInUseSubsetSpsNum; + uint32_t uiInUsePpsNum; } SExistingParasetList; diff --git a/codec/encoder/core/inc/parameter_sets.h b/codec/encoder/core/inc/parameter_sets.h index 800eee5b..90f2b37f 100644 --- a/codec/encoder/core/inc/parameter_sets.h +++ b/codec/encoder/core/inc/parameter_sets.h @@ -41,119 +41,119 @@ namespace WelsEnc { /* 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 uiPocType; +uint32_t uiSpsId; +int16_t iMbWidth; +int16_t iMbHeight; +uint32_t uiLog2MaxFrameNum; +// uint32_t uiPocType; /* POC type 0 */ -int32_t iLog2MaxPocLsb; +int32_t iLog2MaxPocLsb; /* POC type 1 */ -// int32_t iOffsetForNonRefPic; +// int32_t iOffsetForNonRefPic; -// int32_t iOffsetForTopToBottomField; -// int32_t iNumRefFramesInPocCycle; -// int8_t iOffsetForRefFrame[256]; -SCropOffset sFrameCrop; -int16_t iNumRefFrames; -// uint32_t uiNumUnitsInTick; -// uint32_t uiTimeScale; +// int32_t iOffsetForTopToBottomField; +// int32_t iNumRefFramesInPocCycle; +// int8_t iOffsetForRefFrame[256]; +SCropOffset sFrameCrop; +int16_t iNumRefFrames; +// uint32_t uiNumUnitsInTick; +// uint32_t uiTimeScale; -uint8_t uiProfileIdc; -uint8_t iLevelIdc; -// uint8_t uiChromaFormatIdc; -// uint8_t uiChromaArrayType; //support =1 +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 +// 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 */ -// bool bDeltaPicOrderAlwaysZeroFlag; -bool bGapsInFrameNumValueAllowedFlag; +// 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 bTimingInfoPresentFlag; -// bool bFixedFrameRateFlag; +bool bVuiParamPresentFlag; +// bool bTimingInfoPresentFlag; +// bool bFixedFrameRateFlag; -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 +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; /* Sequence Parameter Set SVC extension syntax, refer to Page 391 in JVT X201wcm */ typedef struct TagSpsSvcExt { -// SCropOffset sSeqScaledRefLayer; +// SCropOffset sSeqScaledRefLayer; -uint8_t iExtendedSpatialScalability; // ESS -// uint8_t uiChromaPhaseXPlus1Flag; -// uint8_t uiChromaPhaseYPlus1; -// uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag; -// uint8_t uiSeqRefLayerChromaPhaseYPlus1; -// bool bInterLayerDeblockingFilterCtrlPresentFlag; -bool bSeqTcoeffLevelPredFlag; -bool bAdaptiveTcoeffLevelPredFlag; -bool bSliceHeaderRestrictionFlag; +uint8_t iExtendedSpatialScalability; // 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 { -SWelsSPS pSps; -SSpsSvcExt sSpsSvcExt; +SWelsSPS pSps; +SSpsSvcExt sSpsSvcExt; -// bool bSvcVuiParamPresentFlag; -// bool bAdditionalExtension2Flag; -// bool bAdditionalExtension2DataFlag; +// bool bSvcVuiParamPresentFlag; +// bool bAdditionalExtension2Flag; +// bool bAdditionalExtension2DataFlag; } SSubsetSps, *PSubsetSps; /* 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; +uint32_t uiNumSliceGroups; +uint32_t uiSliceGroupMapType; /* uiSliceGroupMapType = 0 */ -uint32_t uiRunLength[MAX_SLICEGROUP_IDS]; +uint32_t uiRunLength[MAX_SLICEGROUP_IDS]; /* uiSliceGroupMapType = 2 */ -uint32_t uiTopLeft[MAX_SLICEGROUP_IDS]; -uint32_t uiBottomRight[MAX_SLICEGROUP_IDS]; +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; +bool bSliceGroupChangeDirectionFlag; +uint32_t uiSliceGroupChangeRate; /* uiSliceGroupMapType = 6 */ -uint32_t uiPicSizeInMapUnits; -uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS]; +uint32_t uiPicSizeInMapUnits; +uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS]; #endif//!DISABLE_FMO_FEATURE -// uint32_t uiNumRefIdxL0Active; -// uint32_t uiNumRefIdxL1Active; +// 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 */ -// int32_t iSecondChromaQpIndexOffset; -// /* potential application for High profile */ +// int32_t iSecondChromaQpIndexOffset; +// /* potential application for High profile */ -// bool bPicOrderPresentFlag; +// bool bPicOrderPresentFlag; bool bEntropyCodingModeFlag; -bool bDeblockingFilterControlPresentFlag; +bool bDeblockingFilterControlPresentFlag; -// bool bConstainedIntraPredFlag; -// bool bRedundantPicCntPresentFlag; -// bool bWeightedPredFlag; -// uint8_t uiWeightedBiPredIdc; +// bool bConstainedIntraPredFlag; +// bool bRedundantPicCntPresentFlag; +// bool bWeightedPredFlag; +// uint8_t uiWeightedBiPredIdc; } SWelsPPS, *PWelsPPPS; diff --git a/codec/encoder/core/inc/picture.h b/codec/encoder/core/inc/picture.h index 3afd82c6..fdd4a904 100644 --- a/codec/encoder/core/inc/picture.h +++ b/codec/encoder/core/inc/picture.h @@ -104,18 +104,18 @@ SScreenBlockFeatureStorage* pScreenBlockFeatureStorage; * set picture as unreferenced */ void SetUnref () { - iFramePoc = -1; - iFrameNum = -1; - uiTemporalId = - uiSpatialId = - iLongTermPicNum = -1; - bIsLongRef = false; + iFramePoc = -1; + iFrameNum = -1; + uiTemporalId = + uiSpatialId = + iLongTermPicNum = -1; + bIsLongRef = false; uiRecieveConfirmed = RECIEVE_FAILED; - iMarkFrameNum = -1; - bUsedAsRef = false; + iMarkFrameNum = -1; + bUsedAsRef = false; if (NULL != pScreenBlockFeatureStorage) - pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false; + pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false; } } SPicture; diff --git a/codec/encoder/core/inc/rc.h b/codec/encoder/core/inc/rc.h index 3d9d1bbf..dd4e46f5 100644 --- a/codec/encoder/core/inc/rc.h +++ b/codec/encoder/core/inc/rc.h @@ -203,7 +203,7 @@ int32_t iMinFrameQp; int32_t iMaxFrameQp; int32_t iNumberMbFrame; int32_t iNumberMbGom; -int32_t iSliceNum; +int32_t iSliceNum; int32_t iGomSize; int32_t iSkipFrameNum; @@ -237,7 +237,7 @@ int32_t iPaddingSize; int32_t iPaddingBitrateStat; bool bSkipFlag; -SRCSlicing* pSlicingOverRc; +SRCSlicing* pSlicingOverRc; SRCTemporal* pTemporalOverRc; //for scc @@ -262,11 +262,11 @@ typedef void (*PWelsUpdateBufferWhenFrameSkippedFunc)(sWelsEncCtx* pCtx, int32_ typedef void (*PWelsUpdateMaxBrCheckWindowStatusFunc)(sWelsEncCtx* pCtx, int32_t iSpatialNum, const long long uiTimeStamp); typedef struct WelsRcFunc_s { -PWelsRCPictureInitFunc pfWelsRcPictureInit; -PWelsRCPictureDelayJudgeFunc pfWelsRcPicDelayJudge; -PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate; -PWelsRCMBInitFunc pfWelsRcMbInit; -PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate; +PWelsRCPictureInitFunc pfWelsRcPictureInit; +PWelsRCPictureDelayJudgeFunc pfWelsRcPicDelayJudge; +PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate; +PWelsRCMBInitFunc pfWelsRcMbInit; +PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate; PWelsCheckFrameSkipBasedMaxbrFunc pfWelsCheckSkipBasedMaxbr; PWelsUpdateBufferWhenFrameSkippedFunc pfWelsUpdateBufferWhenSkip; PWelsUpdateMaxBrCheckWindowStatusFunc pfWelsUpdateMaxBrWindowStatus; diff --git a/codec/encoder/core/inc/slice.h b/codec/encoder/core/inc/slice.h index 92af01c6..fe0b8ab3 100644 --- a/codec/encoder/core/inc/slice.h +++ b/codec/encoder/core/inc/slice.h @@ -53,134 +53,134 @@ namespace WelsEnc { */ typedef struct TagRefPicListReorderSyntax { struct { - uint32_t uiAbsDiffPicNumMinus1; //uiAbsDiffPicNumMinus1 SHOULD be in the range of [4, (1<uiLog2MaxFrameNum)-1], {p104, JVT-X201wcm1} + uint32_t uiAbsDiffPicNumMinus1; //uiAbsDiffPicNumMinus1 SHOULD be in the range of [4, (1<uiLog2MaxFrameNum)-1], {p104, JVT-X201wcm1} //but int8_t can't cover the range, SHOULD modify it. - uint16_t iLongTermPicNum; - uint16_t uiReorderingOfPicNumsIdc; //in order to pack 2-uint16_t into 1-(u)int32_t, so modify the type into uint16_t. -} SReorderingSyntax[MAX_REFERENCE_REORDER_COUNT_NUM]; // MAX_REF_PIC_COUNT + uint16_t iLongTermPicNum; + uint16_t uiReorderingOfPicNumsIdc; //in order to pack 2-uint16_t into 1-(u)int32_t, so modify the type into uint16_t. +} SReorderingSyntax[MAX_REFERENCE_REORDER_COUNT_NUM]; // MAX_REF_PIC_COUNT } SRefPicListReorderSyntax; /* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */ typedef struct TagRefPicMarking { struct { - int32_t iMmcoType; - int32_t iShortFrameNum; - int32_t iDiffOfPicNum; - int32_t iLongTermPicNum; - int32_t iLongTermFrameIdx; - int32_t iMaxLongTermFrameIdx; -} SMmcoRef[MAX_REFERENCE_MMCO_COUNT_NUM]; // MAX_MMCO_COUNT + int32_t iMmcoType; + int32_t iShortFrameNum; + int32_t iDiffOfPicNum; + int32_t iLongTermPicNum; + int32_t iLongTermFrameIdx; + int32_t iMaxLongTermFrameIdx; +} SMmcoRef[MAX_REFERENCE_MMCO_COUNT_NUM]; // MAX_MMCO_COUNT -// int32_t mmco_index; -uint8_t uiMmcoCount; -bool bNoOutputOfPriorPicsFlag; -bool bLongTermRefFlag; -bool bAdaptiveRefPicMarkingModeFlag; +// int32_t mmco_index; +uint8_t uiMmcoCount; +bool bNoOutputOfPriorPicsFlag; +bool bLongTermRefFlag; +bool bAdaptiveRefPicMarkingModeFlag; } SRefPicMarking; /* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */ typedef struct TagSliceHeader { /*****************************slice header syntax and generated****************************/ -int32_t iFirstMbInSlice; -// uint32_t pic_parameter_set_id; -int32_t iFrameNum; -int32_t iPicOrderCntLsb; +int32_t iFirstMbInSlice; +// uint32_t pic_parameter_set_id; +int32_t iFrameNum; +int32_t iPicOrderCntLsb; -// int32_t delta_pic_order_cnt_bottom; -// int32_t delta_pic_order_cnt[2]; -// int32_t redundant_pic_cnt; +// int32_t delta_pic_order_cnt_bottom; +// int32_t delta_pic_order_cnt[2]; +// int32_t redundant_pic_cnt; -EWelsSliceType eSliceType; -uint8_t uiNumRefIdxL0Active; // -//int32_t num_ref_idx_l1_active_minus1 //B frame is not supported -uint8_t uiRefCount; -//Ref_Pic *ref_pic; -uint8_t uiRefIndex; // exact reference picture index for slice +EWelsSliceType eSliceType; +uint8_t uiNumRefIdxL0Active; // +//int32_t num_ref_idx_l1_active_minus1 //B frame is not supported +uint8_t uiRefCount; +//Ref_Pic *ref_pic; +uint8_t uiRefIndex; // exact reference picture index for slice -int8_t iSliceQpDelta; -// int32_t slice_qp; -// int32_t slice_qs_delta; // For SP/SI slices -uint8_t uiDisableDeblockingFilterIdc; -int8_t iSliceAlphaC0Offset; -int8_t iSliceBetaOffset; +int8_t iSliceQpDelta; +// int32_t slice_qp; +// int32_t slice_qs_delta; // For SP/SI slices +uint8_t uiDisableDeblockingFilterIdc; +int8_t iSliceAlphaC0Offset; +int8_t iSliceBetaOffset; #if !defined(DISABLE_FMO_FEATURE) -int32_t iSliceGroupChangeCycle; +int32_t iSliceGroupChangeCycle; #endif//!DISABLE_FMO_FEATURE -SWelsSPS* pSps; -SWelsPPS* pPps; -int32_t iSpsId; -int32_t iPpsId; +SWelsSPS* pSps; +SWelsPPS* pPps; +int32_t iSpsId; +int32_t iPpsId; -uint16_t uiIdrPicId; -// uint8_t color_plane_id;//from? +uint16_t uiIdrPicId; +// uint8_t color_plane_id;//from? -bool bNumRefIdxActiveOverrideFlag; -// bool field_pic_flag; //not supported in base profile -// bool bottom_field_flag; //not supported in base profile -uint8_t uiPadding1Bytes; +bool bNumRefIdxActiveOverrideFlag; +// bool field_pic_flag; //not supported in base profile +// bool bottom_field_flag; //not supported in base profile +uint8_t uiPadding1Bytes; -SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs +SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs -SRefPicListReorderSyntax sRefReordering; // Reference picture list reordering syntaxs +SRefPicListReorderSyntax sRefReordering; // Reference picture list reordering syntaxs } SSliceHeader, *PSliceHeader; /* SSlice header in scalable extension syntax, refer to Page 394 in JVT X201wcm */ typedef struct TagSliceHeaderExt { -SSliceHeader sSliceHeader; +SSliceHeader sSliceHeader; -SSubsetSps* pSubsetSps; +SSubsetSps* pSubsetSps; -uint32_t uiNumMbsInSlice; +uint32_t uiNumMbsInSlice; -bool bStoreRefBasePicFlag; -bool bConstrainedIntraResamplingFlag; -bool bSliceSkipFlag; +bool bStoreRefBasePicFlag; +bool bConstrainedIntraResamplingFlag; +bool bSliceSkipFlag; -bool bAdaptiveBaseModeFlag; -bool bDefaultBaseModeFlag; -bool bAdaptiveMotionPredFlag; -bool bDefaultMotionPredFlag; +bool bAdaptiveBaseModeFlag; +bool bDefaultBaseModeFlag; +bool bAdaptiveMotionPredFlag; +bool bDefaultMotionPredFlag; -bool bAdaptiveResidualPredFlag; -bool bDefaultResidualPredFlag; -bool bTcoeffLevelPredFlag; -uint8_t uiDisableInterLayerDeblockingFilterIdc; +bool bAdaptiveResidualPredFlag; +bool bDefaultResidualPredFlag; +bool bTcoeffLevelPredFlag; +uint8_t uiDisableInterLayerDeblockingFilterIdc; } SSliceHeaderExt, *PSliceHeaderExt; typedef struct TagSlice { // mainly for multiple threads imp. -SMbCache sMbCacheInfo; // MBCache is introduced within slice dependency -SBitStringAux* pSliceBsa; +SMbCache sMbCacheInfo; // MBCache is introduced within slice dependency +SBitStringAux* pSliceBsa; /*******************************sSliceHeader****************************/ -SSliceHeaderExt sSliceHeaderExt; +SSliceHeaderExt sSliceHeaderExt; -SMVUnitXY sMvStartMin; -SMVUnitXY sMvStartMax; -SMVUnitXY sMvc[5]; -uint8_t uiMvcNum; -uint8_t sScaleShift; +SMVUnitXY sMvStartMin; +SMVUnitXY sMvStartMax; +SMVUnitXY sMvc[5]; +uint8_t uiMvcNum; +uint8_t sScaleShift; -uint32_t uiSliceIdx; -bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext? -uint8_t uiLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc. +uint32_t uiSliceIdx; +bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext? +uint8_t uiLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc. -bool bDynamicSlicingSliceSizeCtrlFlag; -uint8_t uiAssumeLog2BytePerMb; +bool bDynamicSlicingSliceSizeCtrlFlag; +uint8_t uiAssumeLog2BytePerMb; -uint32_t uiSliceFMECostDown;//TODO: for FME switch under MT, to opt after ME final? +uint32_t uiSliceFMECostDown;//TODO: for FME switch under MT, to opt after ME final? -uint8_t uiReservedFillByte; // reserved to meet 4 bytes alignment +uint8_t uiReservedFillByte; // reserved to meet 4 bytes alignment -SCabacCtx sCabacCtx; -int32_t iCabacInitIdc; -int32_t iMbSkipRun; +SCabacCtx sCabacCtx; +int32_t iCabacInitIdc; +int32_t iMbSkipRun; } SSlice, *PSlice; } diff --git a/codec/encoder/core/inc/stat.h b/codec/encoder/core/inc/stat.h index e0c086b8..6b70026d 100644 --- a/codec/encoder/core/inc/stat.h +++ b/codec/encoder/core/inc/stat.h @@ -47,9 +47,9 @@ namespace WelsEnc { */ typedef struct TagStatQuality { -float rYPsnr[5]; -float rUPsnr[5]; -float rVPsnr[5]; +float rYPsnr[5]; +float rUPsnr[5]; +float rVPsnr[5]; } SStatQuality; @@ -59,10 +59,10 @@ float rVPsnr[5]; typedef struct TagComplexityStat { #ifdef FME_TEST -int32_t cost_time; -int32_t me_time; -int32_t mvp_time; -int32_t mvb_time; +int32_t cost_time; +int32_t me_time; +int32_t mvp_time; +int32_t mvb_time; #endif // any else? @@ -75,9 +75,9 @@ int32_t mvb_time; typedef struct TagStatSliceInfo { /* per slice info */ -int32_t iSliceCount[5]; -int32_t iSliceSize [5]; -int32_t iMbCount [5][18]; +int32_t iSliceCount[5]; +int32_t iSliceSize [5]; +int32_t iMbCount [5][18]; } SStatSliceInfo; @@ -87,13 +87,13 @@ int32_t iMbCount [5][18]; typedef struct TagStatData { // Quality -SStatQuality sQualityStat; +SStatQuality sQualityStat; // Complexity -SComplexityStat sComplexityStat; +SComplexityStat sComplexityStat; // SSlice information output -SStatSliceInfo sSliceData; +SStatSliceInfo sSliceData; } SStatData; diff --git a/codec/encoder/core/inc/svc_enc_frame.h b/codec/encoder/core/inc/svc_enc_frame.h index caf96fea..8749dc92 100644 --- a/codec/encoder/core/inc/svc_enc_frame.h +++ b/codec/encoder/core/inc/svc_enc_frame.h @@ -53,14 +53,14 @@ namespace WelsEnc { ///////////////////////////////////DQ Layer level/////////////////////////////////// -typedef struct TagDqLayer SDqLayer; -typedef SDqLayer* pDqLayer; +typedef struct TagDqLayer SDqLayer; +typedef SDqLayer* pDqLayer; typedef struct TagFeatureSearchPreparation { -SScreenBlockFeatureStorage* pRefBlockFeature;//point the the ref frame storage +SScreenBlockFeatureStorage* pRefBlockFeature;//point the the ref frame storage -uint16_t* pFeatureOfBlock; // Feature of every block (8x8), begin with the point -uint8_t uiFeatureStrategyIndex;// index of hash strategy +uint16_t* pFeatureOfBlock; // Feature of every block (8x8), begin with the point +uint8_t uiFeatureStrategyIndex;// index of hash strategy /* for FME frame-level switch */ bool bFMESwitchFlag; @@ -69,51 +69,51 @@ int32_t iHighFreMbCount; } SFeatureSearchPreparation; //maintain only one typedef struct TagLayerInfo { -SNalUnitHeaderExt sNalHeaderExt; +SNalUnitHeaderExt sNalHeaderExt; SSlice* -pSliceInLayer;// Here SSlice identify to Frame on concept, [iSliceIndex], need memory block external side for MT -SSubsetSps* pSubsetSpsP; // current pSubsetSps used, memory alloc in external -SWelsSPS* pSpsP; // current pSps based avc used, memory alloc in external -SWelsPPS* pPpsP; // current pPps used +pSliceInLayer;// Here SSlice identify to Frame on concept, [iSliceIndex], need memory block external side for MT +SSubsetSps* pSubsetSpsP; // current pSubsetSps used, memory alloc in external +SWelsSPS* pSpsP; // current pSps based avc used, memory alloc in external +SWelsPPS* pPpsP; // current pPps used } SLayerInfo; /* Layer Representation */ struct TagDqLayer { -SLayerInfo sLayerInfo; +SLayerInfo sLayerInfo; -uint8_t* pCsData[3]; // pointer to reconstructed picture pData -int32_t iCsStride[3]; // Cs stride +uint8_t* pCsData[3]; // pointer to reconstructed picture pData +int32_t iCsStride[3]; // Cs stride -uint8_t* pEncData[3]; // pData picture to be encoded in current layer -int32_t iEncStride[3]; // pData picture stride +uint8_t* pEncData[3]; // pData picture to be encoded in current layer +int32_t iEncStride[3]; // pData picture stride -SMB* sMbDataP; // pointer to mb of mbAddr equal to 0 in slice, mb_data_ptr = mb_base_ptr + (1+iMbStride). -int16_t iMbWidth; // MB width of this picture, equal to pSps.iMbWidth -int16_t iMbHeight; // MB height of this picture, equal to pSps.iMbHeight; +SMB* sMbDataP; // pointer to mb of mbAddr equal to 0 in slice, mb_data_ptr = mb_base_ptr + (1+iMbStride). +int16_t iMbWidth; // MB width of this picture, equal to pSps.iMbWidth +int16_t iMbHeight; // MB height of this picture, equal to pSps.iMbHeight; -bool bBaseLayerAvailableFlag; // whether base layer is available for prediction? -bool bSatdInMdFlag; // whether SATD is calculated in ME and integer-pel MD +bool bBaseLayerAvailableFlag; // whether base layer is available for prediction? +bool bSatdInMdFlag; // whether SATD is calculated in ME and integer-pel MD -uint8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries -int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0 -int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 -uint8_t uiDisableInterLayerDeblockingFilterIdc; -int8_t iInterLayerSliceAlphaC0Offset; -int8_t iInterLayerSliceBetaOffset; -bool bDeblockingParallelFlag; //parallel_deblocking_flag +uint8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries +int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0 +int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 +uint8_t uiDisableInterLayerDeblockingFilterIdc; +int8_t iInterLayerSliceAlphaC0Offset; +int8_t iInterLayerSliceBetaOffset; +bool bDeblockingParallelFlag; //parallel_deblocking_flag -SPicture* pRefPic; // reference picture pointer -SPicture* pDecPic; // reconstruction picture pointer for layer -SPicture* pRefOri[MAX_REF_PIC_COUNT]; +SPicture* pRefPic; // reference picture pointer +SPicture* pDecPic; // reconstruction picture pointer for layer +SPicture* pRefOri[MAX_REF_PIC_COUNT]; -SSliceCtx* pSliceEncCtx; // current slice context +SSliceCtx* pSliceEncCtx; // current slice context -int32_t* pNumSliceCodedOfPartition; // for dynamic slicing mode -int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode -int32_t* pLastMbIdxOfPartition; // for dynamic slicing mode +int32_t* pNumSliceCodedOfPartition; // for dynamic slicing mode +int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode +int32_t* pLastMbIdxOfPartition; // for dynamic slicing mode SFeatureSearchPreparation* pFeatureSearchPreparation; -SDqLayer* pRefLayer; // pointer to referencing dq_layer of current layer to be decoded +SDqLayer* pRefLayer; // pointer to referencing dq_layer of current layer to be decoded }; diff --git a/codec/encoder/core/inc/svc_enc_macroblock.h b/codec/encoder/core/inc/svc_enc_macroblock.h index 280baeab..fd7544fe 100644 --- a/codec/encoder/core/inc/svc_enc_macroblock.h +++ b/codec/encoder/core/inc/svc_enc_macroblock.h @@ -49,31 +49,31 @@ namespace WelsEnc { typedef struct TagMB { /*************************mb_layer() syntax and generated********************************/ /*mb_layer():*/ -Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list -int32_t iMbXY; // offset position of MB top left point based -int16_t iMbX; // position of MB in horizontal axis [0..32767] -int16_t iMbY; // position of MB in vertical axis [0..32767] +Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list +int32_t iMbXY; // offset position of MB top left point based +int16_t iMbX; // position of MB in horizontal axis [0..32767] +int16_t iMbY; // position of MB in vertical axis [0..32767] -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; -uint16_t uiSliceIdc; // 2^16=65536 > MaxFS(36864) of level 5.1; AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId); -uint32_t uiChromPredMode; -int32_t iLumaDQp; -SMVUnitXY sMvd[4]; -int32_t iCbpDc; -//uint8_t reserved_filling_bytes[1]; // not deleting this line for further changes of this structure. 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; +uint16_t uiSliceIdc; // 2^16=65536 > MaxFS(36864) of level 5.1; AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId); +uint32_t uiChromPredMode; +int32_t iLumaDQp; +SMVUnitXY sMvd[4]; +int32_t iCbpDc; +//uint8_t reserved_filling_bytes[1]; // not deleting this line for further changes of this structure. 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; } diff --git a/codec/encoder/core/inc/svc_enc_slice_segment.h b/codec/encoder/core/inc/svc_enc_slice_segment.h index 61e0e026..bf90e8ba 100644 --- a/codec/encoder/core/inc/svc_enc_slice_segment.h +++ b/codec/encoder/core/inc/svc_enc_slice_segment.h @@ -77,30 +77,30 @@ namespace WelsEnc { */ /* 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 */ -int32_t iSliceNumInFrame; /* count number of slices in frame; */ -int32_t iMbNumInFrame; /* count number of MBs in frame */ -uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */ -int32_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 */ +int32_t iSliceNumInFrame; /* count number of slices in frame; */ +int32_t iMbNumInFrame; /* count number of MBs in frame */ +uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */ +int32_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; -SCabacCtx sStoredCabac; -int32_t iMbSkipRunStack; -uint8_t uiLastMbQp; +SCabacCtx sStoredCabac; +int32_t iMbSkipRunStack; +uint8_t uiLastMbQp; } SDynamicSlicingStack; /*! diff --git a/codec/encoder/core/inc/svc_encode_mb.h b/codec/encoder/core/inc/svc_encode_mb.h index 86a196dd..6408e637 100644 --- a/codec/encoder/core/inc/svc_encode_mb.h +++ b/codec/encoder/core/inc/svc_encode_mb.h @@ -48,16 +48,16 @@ #include "wels_func_ptr_def.h" namespace WelsEnc { -void WelsDctMb (int16_t* pRs, uint8_t* pEncMb, int32_t iEncStride, uint8_t* pBestPred, PDctFunc pfDctFourT4); +void WelsDctMb (int16_t* pRs, uint8_t* pEncMb, int32_t iEncStride, uint8_t* pBestPred, PDctFunc pfDctFourT4); -void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache); -void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uint8_t uiI4x4Idx); -void WelsEncInterY (SWelsFuncPtrList* func, SMB* pCurMb, SMbCache* pMbCache); -void WelsEncRecUV (SWelsFuncPtrList* func, SMB* pCurMb, SMbCache* pMbCache, int16_t* pRs, int32_t iUV); -void WelsRecPskip (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, SMB* pCurMb, SMbCache* pMbCache); +void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache); +void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uint8_t uiI4x4Idx); +void WelsEncInterY (SWelsFuncPtrList* func, SMB* pCurMb, SMbCache* pMbCache); +void WelsEncRecUV (SWelsFuncPtrList* func, SMB* pCurMb, SMbCache* pMbCache, int16_t* pRs, int32_t iUV); +void WelsRecPskip (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, SMB* pCurMb, SMbCache* pMbCache); -bool WelsTryPYskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache); -bool WelsTryPUVskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, int32_t iUV); +bool WelsTryPYskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache); +bool WelsTryPUVskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, int32_t iUV); } #endif diff --git a/codec/encoder/core/inc/svc_encode_slice.h b/codec/encoder/core/inc/svc_encode_slice.h index 246748df..70bcbeac 100644 --- a/codec/encoder/core/inc/svc_encode_slice.h +++ b/codec/encoder/core/inc/svc_encode_slice.h @@ -76,8 +76,8 @@ int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsH int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag); //encapsulation func: store base rec, highest Dependency Layer(only one quality) rec, single layer rec -int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice); // for intra non-dynamic slice -int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice); // for intra dynamic slice +int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice); // for intra non-dynamic slice +int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice); // for intra dynamic slice int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice); int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice); @@ -94,9 +94,9 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, int32_t iNextSliceFirstMbIdx, const int32_t kiLastMbIdxInPartition); int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pMd, - const int32_t kiSliceFirstMbXY); // for inter non-dynamic slice + const int32_t kiSliceFirstMbXY); // for inter non-dynamic slice int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pMd, - const int32_t kiSliceFirstMbXY); // for inter dynamic slice + const int32_t kiSliceFirstMbXY); // for inter dynamic slice bool DynSlcJudgeSliceBoundaryStepBack (void* pEncCtx, void* pSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, diff --git a/codec/encoder/core/inc/vlc_encoder.h b/codec/encoder/core/inc/vlc_encoder.h index 62e8838c..6b1a97b2 100644 --- a/codec/encoder/core/inc/vlc_encoder.h +++ b/codec/encoder/core/inc/vlc_encoder.h @@ -57,14 +57,14 @@ 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]; +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]; +const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0]; return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]); } @@ -75,7 +75,7 @@ return 0; } static inline int32_t WriteTotalZeros (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) { -const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0]; +const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0]; return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]); } diff --git a/codec/encoder/core/inc/wels_common_basis.h b/codec/encoder/core/inc/wels_common_basis.h index d2a50cdc..16d618b5 100644 --- a/codec/encoder/core/inc/wels_common_basis.h +++ b/codec/encoder/core/inc/wels_common_basis.h @@ -46,9 +46,9 @@ using namespace WelsCommon; namespace WelsEnc { -struct SMVUnitXY { // each 4 Bytes - int16_t iMvX; - int16_t iMvY; +struct SMVUnitXY { // each 4 Bytes + int16_t iMvX; + int16_t iMvY; public: SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) { iMvX = _v0.iMvX - _v1.iMvX; @@ -62,17 +62,17 @@ struct SMVUnitXY { // each 4 Bytes }; }; -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 +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 } 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 { @@ -81,7 +81,7 @@ typedef struct TagParaSetOffset { 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 + bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far int32_t iPpsIdList[MAX_DQ_LAYER_NUM][MAX_PPS_COUNT]; //index0: max pps types; index1: for differnt IDRs, if only index0=1, index1 can reach MAX_PPS_COUNT @@ -102,10 +102,10 @@ typedef struct TagParaSetOffset { /* 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; diff --git a/codec/encoder/core/inc/wels_const.h b/codec/encoder/core/inc/wels_const.h index 57d7b212..1279be44 100644 --- a/codec/encoder/core/inc/wels_const.h +++ b/codec/encoder/core/inc/wels_const.h @@ -34,7 +34,7 @@ #ifndef WELS_CONST_H__ #define WELS_CONST_H__ -#include "as264_common.h" // to communicate with specific macros there, 3/18/2010 +#include "as264_common.h" // to communicate with specific macros there, 3/18/2010 #include "codec_app_def.h" #include "wels_const_common.h" diff --git a/codec/encoder/core/inc/wels_func_ptr_def.h b/codec/encoder/core/inc/wels_func_ptr_def.h index 2238fd56..f2b28058 100644 --- a/codec/encoder/core/inc/wels_func_ptr_def.h +++ b/codec/encoder/core/inc/wels_func_ptr_def.h @@ -215,7 +215,7 @@ struct TagWelsFuncPointerList { PGetIntraPredFunc pfGetLumaI4x4Pred[I4_PRED_A]; PGetIntraPredFunc pfGetChromaPred[C_PRED_A]; - PSampleSadHor8Func pfSampleSadHor8[2]; // 1: for 16x16 square; 0: for 8x8 square + PSampleSadHor8Func pfSampleSadHor8[2]; // 1: for 16x16 square; 0: for 8x8 square PMotionSearchFunc pfMotionSearch[BLOCK_STATIC_IDC_ALL]; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c PSearchMethodFunc pfSearchMethod[BLOCK_SIZE_ALL]; diff --git a/codec/encoder/core/inc/wels_preprocess.h b/codec/encoder/core/inc/wels_preprocess.h index c4b90c2a..40160347 100644 --- a/codec/encoder/core/inc/wels_preprocess.h +++ b/codec/encoder/core/inc/wels_preprocess.h @@ -55,9 +55,9 @@ namespace WelsEnc { typedef struct TagWelsEncCtx sWelsEncCtx; typedef struct { - SPicture* pScaledInputPicture; - int32_t iScaledWidth[MAX_DEPENDENCY_LAYER]; - int32_t iScaledHeight[MAX_DEPENDENCY_LAYER]; + SPicture* pScaledInputPicture; + int32_t iScaledWidth[MAX_DEPENDENCY_LAYER]; + int32_t iScaledHeight[MAX_DEPENDENCY_LAYER]; } Scaled_Picture; @@ -74,29 +74,29 @@ typedef struct { SPicture* pRefPicture; int32_t iSrcListIdx; //idx in h->spatial_pic[base_did]; bool bSceneLtrFlag; - unsigned char* pBestBlockStaticIdc; + unsigned char* pBestBlockStaticIdc; } SRefInfoParam; typedef struct TagVAAFrameInfo { - SVAACalcResult sVaaCalcInfo; + SVAACalcResult sVaaCalcInfo; SAdaptiveQuantizationParam sAdaptiveQuantParam; SComplexityAnalysisParam sComplexityAnalysisParam; - int32_t iPicWidth; // maximal iWidth of picture in samples for svc coding - int32_t iPicHeight; // maximal iHeight of picture in samples for svc coding - int32_t iPicStride; //luma - int32_t iPicStrideUV; + int32_t iPicWidth; // maximal iWidth of picture in samples for svc coding + int32_t iPicHeight; // maximal iHeight of picture in samples for svc coding + int32_t iPicStride; //luma + int32_t iPicStrideUV; - uint8_t* pRefY; //pRef - uint8_t* pCurY; //cur - uint8_t* pRefU; //pRef - uint8_t* pCurU; //cur - uint8_t* pRefV; //pRef - uint8_t* pCurV; //cur + uint8_t* pRefY; //pRef + uint8_t* pCurY; //cur + uint8_t* pRefU; //pRef + uint8_t* pCurU; //cur + uint8_t* pRefV; //pRef + uint8_t* pCurV; //cur - int8_t* pVaaBackgroundMbFlag; - uint8_t uiValidLongTermPicIdx; - uint8_t uiMarkLongTermPicIdx; + int8_t* pVaaBackgroundMbFlag; + uint8_t uiValidLongTermPicIdx; + uint8_t uiMarkLongTermPicIdx; ESceneChangeIdc eSceneChangeIdc; bool bSceneChangeFlag; @@ -150,7 +150,7 @@ class CWelsPreProcess { private: int32_t SingleLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrc, Scaled_Picture* m_sScaledPicture); - void BilateralDenoising (SPicture* pSrc, const int32_t iWidth, const int32_t iHeight); + void BilateralDenoising (SPicture* pSrc, const int32_t iWidth, const int32_t iHeight); bool DetectSceneChange (SPicture* pCurPicture, SPicture* pRefPicture); int32_t DownsamplePadding (SPicture* pSrc, SPicture* pDstPic, int32_t iSrcWidth, int32_t iSrcHeight, int32_t iShrinkWidth, int32_t iShrinkHeight, int32_t iTargetWidth, int32_t iTargetHeight, @@ -194,7 +194,7 @@ class CWelsPreProcess { private: Scaled_Picture m_sScaledPicture; - SPicture* m_pLastSpatialPicture[MAX_DEPENDENCY_LAYER][2]; + SPicture* m_pLastSpatialPicture[MAX_DEPENDENCY_LAYER][2]; IWelsVP* m_pInterfaceVp; sWelsEncCtx* m_pEncCtx; bool m_bInitDone; diff --git a/codec/encoder/core/src/au_set.cpp b/codec/encoder/core/src/au_set.cpp index 5959b581..5fd0aa5b 100644 --- a/codec/encoder/core/src/au_set.cpp +++ b/codec/encoder/core/src/au_set.cpp @@ -107,7 +107,7 @@ static int32_t WelsCheckNumRefSetting (SLogContext* pLogCtx, SWelsSvcCodingParam : (WELS_MAX (1, (pParam->uiGopSize >> 1)))); int32_t iNeededRefNum = (pParam->uiIntraPeriod != 1) ? (iCurrentStrNum + pParam->iLTRRefNum) : 0; - iNeededRefNum = WELS_CLIP3 (iNeededRefNum, + iNeededRefNum = WELS_CLIP3 (iNeededRefNum, MIN_REF_PIC_COUNT, (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN); @@ -243,13 +243,13 @@ int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_ BsWriteBits (pLocalBitStringAux, 8, pSps->uiProfileIdc); - BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet0Flag); // bConstraintSet0Flag - BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet1Flag); // bConstraintSet1Flag - BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet2Flag); // bConstraintSet2Flag - BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet3Flag); // bConstraintSet3Flag - BsWriteBits (pLocalBitStringAux, 4, 0); // reserved_zero_4bits, equal to 0 - BsWriteBits (pLocalBitStringAux, 8, pSps->iLevelIdc); // iLevelIdc - BsWriteUE (pLocalBitStringAux, pSps->uiSpsId + pSpsIdDelta[pSps->uiSpsId]); // seq_parameter_set_id + BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet0Flag); // bConstraintSet0Flag + BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet1Flag); // bConstraintSet1Flag + BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet2Flag); // bConstraintSet2Flag + BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet3Flag); // bConstraintSet3Flag + BsWriteBits (pLocalBitStringAux, 4, 0); // reserved_zero_4bits, equal to 0 + BsWriteBits (pLocalBitStringAux, 8, pSps->iLevelIdc); // iLevelIdc + BsWriteUE (pLocalBitStringAux, pSps->uiSpsId + pSpsIdDelta[pSps->uiSpsId]); // seq_parameter_set_id if (PRO_SCALABLE_BASELINE == pSps->uiProfileIdc || PRO_SCALABLE_HIGH == pSps->uiProfileIdc || PRO_HIGH == pSps->uiProfileIdc || PRO_HIGH10 == pSps->uiProfileIdc || @@ -262,26 +262,26 @@ int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_ BsWriteOneBit (pLocalBitStringAux, 0); //seq_scaling_matrix_present_flag } - BsWriteUE (pLocalBitStringAux, pSps->uiLog2MaxFrameNum - 4); // log2_max_frame_num_minus4 - BsWriteUE (pLocalBitStringAux, 0/*pSps->uiPocType*/); // pic_order_cnt_type - BsWriteUE (pLocalBitStringAux, pSps->iLog2MaxPocLsb - 4); // log2_max_pic_order_cnt_lsb_minus4 + BsWriteUE (pLocalBitStringAux, pSps->uiLog2MaxFrameNum - 4); // log2_max_frame_num_minus4 + BsWriteUE (pLocalBitStringAux, 0/*pSps->uiPocType*/); // pic_order_cnt_type + BsWriteUE (pLocalBitStringAux, pSps->iLog2MaxPocLsb - 4); // log2_max_pic_order_cnt_lsb_minus4 - BsWriteUE (pLocalBitStringAux, pSps->iNumRefFrames); // max_num_ref_frames + BsWriteUE (pLocalBitStringAux, pSps->iNumRefFrames); // max_num_ref_frames BsWriteOneBit (pLocalBitStringAux, pSps->bGapsInFrameNumValueAllowedFlag); //gaps_in_frame_numvalue_allowed_flag - BsWriteUE (pLocalBitStringAux, pSps->iMbWidth - 1); // pic_width_in_mbs_minus1 - BsWriteUE (pLocalBitStringAux, pSps->iMbHeight - 1); // pic_height_in_map_units_minus1 - BsWriteOneBit (pLocalBitStringAux, true/*pSps->bFrameMbsOnlyFlag*/); // bFrameMbsOnlyFlag + BsWriteUE (pLocalBitStringAux, pSps->iMbWidth - 1); // pic_width_in_mbs_minus1 + BsWriteUE (pLocalBitStringAux, pSps->iMbHeight - 1); // pic_height_in_map_units_minus1 + BsWriteOneBit (pLocalBitStringAux, true/*pSps->bFrameMbsOnlyFlag*/); // bFrameMbsOnlyFlag - BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bDirect8x8InferenceFlag*/); // direct_8x8_inference_flag - BsWriteOneBit (pLocalBitStringAux, pSps->bFrameCroppingFlag); // bFrameCroppingFlag + BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bDirect8x8InferenceFlag*/); // direct_8x8_inference_flag + BsWriteOneBit (pLocalBitStringAux, pSps->bFrameCroppingFlag); // bFrameCroppingFlag if (pSps->bFrameCroppingFlag) { - BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropLeft); // frame_crop_left_offset - BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropRight); // frame_crop_right_offset - BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropTop); // frame_crop_top_offset - BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropBottom); // frame_crop_bottom_offset + BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropLeft); // frame_crop_left_offset + BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropRight); // frame_crop_right_offset + BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropTop); // frame_crop_top_offset + BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropBottom); // frame_crop_bottom_offset } if (bBaseLayer) { - BsWriteOneBit (pLocalBitStringAux, true); // vui_parameters_present_flag + BsWriteOneBit (pLocalBitStringAux, true); // vui_parameters_present_flag WelsWriteVUI (pSps, pBitStringAux); } else { BsWriteOneBit (pLocalBitStringAux, false); @@ -468,24 +468,24 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc, const int32_t kiDlayerCount, bool bSVCBaselayer) { memset (pSps, 0, sizeof (SWelsSPS)); - pSps->uiSpsId = kuiSpsId; - pSps->iMbWidth = (pLayerParam->iVideoWidth + 15) >> 4; - pSps->iMbHeight = (pLayerParam->iVideoHeight + 15) >> 4; + pSps->uiSpsId = kuiSpsId; + pSps->iMbWidth = (pLayerParam->iVideoWidth + 15) >> 4; + pSps->iMbHeight = (pLayerParam->iVideoHeight + 15) >> 4; //max value of both iFrameNum and POC are 2^16-1, in our encoder, iPOC=2*iFrameNum, so max of iFrameNum should be 2^15-1.-- pSps->uiLog2MaxFrameNum = 15;//16; - pSps->iLog2MaxPocLsb = 1 + pSps->uiLog2MaxFrameNum; + pSps->iLog2MaxPocLsb = 1 + pSps->uiLog2MaxFrameNum; - pSps->iNumRefFrames = kiNumRefFrame; /* min pRef size when fifo pRef operation*/ + pSps->iNumRefFrames = kiNumRefFrame; /* min pRef size when fifo pRef operation*/ if (kbEnableFrameCropping) { // TODO: get frame_crop_left_offset, frame_crop_right_offset, frame_crop_top_offset, frame_crop_bottom_offset pSps->bFrameCroppingFlag = WelsGetPaddingOffset (pLayerParamInternal->iActualWidth, pLayerParamInternal->iActualHeight, pLayerParam->iVideoWidth, pLayerParam->iVideoHeight, pSps->sFrameCrop); } else { - pSps->bFrameCroppingFlag = false; + pSps->bFrameCroppingFlag = false; } - pSps->uiProfileIdc = pLayerParam->uiProfileIdc ? pLayerParam->uiProfileIdc : PRO_BASELINE; + pSps->uiProfileIdc = pLayerParam->uiProfileIdc ? pLayerParam->uiProfileIdc : PRO_BASELINE; if (pLayerParam->uiProfileIdc == PRO_BASELINE) { pSps->bConstraintSet0Flag = true; } @@ -496,7 +496,7 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL pSps->bConstraintSet2Flag = true; } - ELevelIdc uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate); + ELevelIdc uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate); //update level //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. @@ -533,12 +533,12 @@ int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerPa WelsInitSps (pSps, pLayerParam, pLayerParamInternal, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping, bEnableRc, kiDlayerCount, false); - pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc : + pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc : PRO_SCALABLE_BASELINE; - pSubsetSps->sSpsSvcExt.iExtendedSpatialScalability = 0; /* ESS is 0 in default */ - pSubsetSps->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag = false; - pSubsetSps->sSpsSvcExt.bSeqTcoeffLevelPredFlag = false; + pSubsetSps->sSpsSvcExt.iExtendedSpatialScalability = 0; /* ESS is 0 in default */ + pSubsetSps->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag = false; + pSubsetSps->sSpsSvcExt.bSeqTcoeffLevelPredFlag = false; pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag = true; return 0; @@ -558,26 +558,26 @@ int32_t WelsInitPps (SWelsPPS* pPps, assert (pSps != NULL); if (NULL == pSps) return 1; - pUsedSps = pSps; + pUsedSps = pSps; } else { assert (pSubsetSps != NULL); if (NULL == pSubsetSps) return 1; - pUsedSps = &pSubsetSps->pSps; + pUsedSps = &pSubsetSps->pSps; } /* fill picture parameter set syntax */ - pPps->iPpsId = kuiPpsId; - pPps->iSpsId = pUsedSps->uiSpsId; + pPps->iPpsId = kuiPpsId; + pPps->iSpsId = pUsedSps->uiSpsId; pPps->bEntropyCodingModeFlag = kbEntropyCodingModeFlag; #if !defined(DISABLE_FMO_FEATURE) - pPps->uiNumSliceGroups = 1; //param->qos_param.sliceGroupCount; + pPps->uiNumSliceGroups = 1; //param->qos_param.sliceGroupCount; if (pPps->uiNumSliceGroups > 1) { - pPps->uiSliceGroupMapType = 0; //param->qos_param.sliceGroupType; + pPps->uiSliceGroupMapType = 0; //param->qos_param.sliceGroupType; if (pPps->uiSliceGroupMapType == 0) { uint32_t uiGroup = 0; while (uiGroup < pPps->uiNumSliceGroups) { - pPps->uiRunLength[uiGroup] = 25; + pPps->uiRunLength[uiGroup] = 25; ++ uiGroup; } } else if (pPps->uiSliceGroupMapType == 2) { @@ -594,11 +594,11 @@ int32_t WelsInitPps (SWelsPPS* pPps, } #endif//!DISABLE_FMO_FEATURE - pPps->iPicInitQp = 26; - pPps->iPicInitQs = 26; + pPps->iPicInitQp = 26; + pPps->iPicInitQs = 26; - pPps->uiChromaQpIndexOffset = 0; - pPps->bDeblockingFilterControlPresentFlag = kbDeblockingFilterPresentFlag; + pPps->uiChromaQpIndexOffset = 0; + pPps->bDeblockingFilterControlPresentFlag = kbDeblockingFilterPresentFlag; return 0; } diff --git a/codec/encoder/core/src/deblocking.cpp b/codec/encoder/core/src/deblocking.cpp index 6a59072a..9fc71d09 100644 --- a/codec/encoder/core/src/deblocking.cpp +++ b/codec/encoder/core/src/deblocking.cpp @@ -655,9 +655,9 @@ void DeblockingMbAvcbase (SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilte void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) { int32_t i, j; - const int32_t kiMbWidth = pCurDq->iMbWidth; - const int32_t kiMbHeight = pCurDq->iMbHeight; - SMB* pCurrentMbBlock = pCurDq->sMbDataP; + const int32_t kiMbWidth = pCurDq->iMbWidth; + const int32_t kiMbHeight = pCurDq->iMbHeight; + SMB* pCurrentMbBlock = pCurDq->sMbDataP; SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[0].sSliceHeaderExt; SDeblockingFilter pFilter; @@ -691,14 +691,14 @@ void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) { } void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx) { - SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; - SMB* pMbList = pCurDq->sMbDataP; - SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt; + SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; + SMB* pMbList = pCurDq->sMbDataP; + SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt; SMB* pCurrentMbBlock; - const int32_t kiMbWidth = pCurDq->iMbWidth; - const int32_t kiMbHeight = pCurDq->iMbHeight; - const int32_t kiTotalNumMb = kiMbWidth * kiMbHeight; + const int32_t kiMbWidth = pCurDq->iMbWidth; + const int32_t kiMbHeight = pCurDq->iMbHeight; + const int32_t kiTotalNumMb = kiMbWidth * kiMbHeight; int32_t iCurMbIdx = 0, iNextMbIdx = 0, iNumMbFiltered = 0; /* Step1: parameters set */ @@ -712,13 +712,13 @@ void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, co pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1]; pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2]; pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; - pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; - pFilter.iMbStride = kiMbWidth; + pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; + pFilter.iMbStride = kiMbWidth; iNextMbIdx = sSliceHeaderExt->sSliceHeader.iFirstMbInSlice; for (; ;) { - iCurMbIdx = iNextMbIdx; + iCurMbIdx = iNextMbIdx; pCurrentMbBlock = &pMbList[ iCurMbIdx ]; pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0]) @@ -740,30 +740,30 @@ void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, co } void PerformDeblockingFilter (sWelsEncCtx* pEnc) { - const int32_t kiCurDid = pEnc->uiDependencyId; - SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam; - SSpatialLayerConfig* pSpatialLayer = &pSvcParam->sSpatialLayers[kiCurDid]; - SDqLayer* pCurLayer = pEnc->pCurDqLayer; + const int32_t kiCurDid = pEnc->uiDependencyId; + SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam; + SSpatialLayerConfig* pSpatialLayer = &pSvcParam->sSpatialLayers[kiCurDid]; + SDqLayer* pCurLayer = pEnc->pCurDqLayer; if (pCurLayer->iLoopFilterDisableIdc == 0) { DeblockingFilterFrameAvcbase (pCurLayer, pEnc->pFuncList); } else if (pCurLayer->iLoopFilterDisableIdc == 2) { - int32_t iSliceCount = 0; - int32_t iSliceIdx = 0; + int32_t iSliceCount = 0; + int32_t iSliceIdx = 0; if (SM_DYN_SLICE != pSpatialLayer->sSliceCfg.uiSliceMode) { - iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx); + iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx); do { DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx); ++ iSliceIdx; } while (iSliceIdx < iSliceCount); - } else { // for dynamic slicing mode - const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; - int32_t iPartitionIdx = 0; + } else { // for dynamic slicing mode + const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; + int32_t iPartitionIdx = 0; while (iPartitionIdx < kiNumPicPartition) { - iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx]; - iSliceIdx = iPartitionIdx; + iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx]; + iSliceIdx = iPartitionIdx; do { DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx); iSliceIdx += kiNumPicPartition; diff --git a/codec/encoder/core/src/decode_mb_aux.cpp b/codec/encoder/core/src/decode_mb_aux.cpp index a03f2a6c..6531597e 100644 --- a/codec/encoder/core/src/decode_mb_aux.cpp +++ b/codec/encoder/core/src/decode_mb_aux.cpp @@ -39,13 +39,13 @@ namespace WelsEnc { ****************************************************************************/ void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4 int16_t iTemp[4]; - int32_t i = 4; + int32_t i = 4; while (--i >= 0) { - const int32_t kiIdx = i << 2; - const int32_t kiIdx1 = 1 + kiIdx; - const int32_t kiIdx2 = 1 + kiIdx1; - const int32_t kiIdx3 = 1 + kiIdx2; + const int32_t kiIdx = i << 2; + const int32_t kiIdx1 = 1 + kiIdx; + const int32_t kiIdx2 = 1 + kiIdx1; + const int32_t kiIdx3 = 1 + kiIdx2; iTemp[0] = pRes[kiIdx ] + pRes[kiIdx2]; iTemp[1] = pRes[kiIdx ] - pRes[kiIdx2]; @@ -60,9 +60,9 @@ void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4 i = 4; while (--i >= 0) { - const int32_t kiI4 = 4 + i; - const int32_t kiI8 = 4 + kiI4; - const int32_t kiI12 = 4 + kiI8; + const int32_t kiI4 = 4 + i; + const int32_t kiI8 = 4 + kiI4; + const int32_t kiI12 = 4 + kiI8; iTemp[0] = pRes[i ] + pRes[kiI8 ]; iTemp[1] = pRes[i ] - pRes[kiI8 ]; @@ -78,14 +78,14 @@ void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4 /* for qp < 12 */ void WelsDequantLumaDc4x4 (int16_t* pRes, const int32_t kiQp) { - int32_t i = 15; - const uint16_t kuiDequantValue = g_kuiDequantCoeff[kiQp % 6][0]; - const int16_t kiQF0 = kiQp / 6; - const int16_t kiQF1 = 2 - kiQF0; - const int16_t kiQF0S = 1 << (1 - kiQF0); + int32_t i = 15; + const uint16_t kuiDequantValue = g_kuiDequantCoeff[kiQp % 6][0]; + const int16_t kiQF0 = kiQp / 6; + const int16_t kiQF1 = 2 - kiQF0; + const int16_t kiQF0S = 1 << (1 - kiQF0); while (i >= 0) { - pRes[i ] = (pRes[i ] * kuiDequantValue + kiQF0S) >> kiQF1; + pRes[i ] = (pRes[i ] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i - 1] = (pRes[i - 1] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i - 2] = (pRes[i - 2] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i - 3] = (pRes[i - 3] * kuiDequantValue + kiQF0S) >> kiQF1; @@ -100,24 +100,24 @@ void WelsDequantIHadamard4x4_c (int16_t* pRes, const uint16_t kuiMF) { int32_t i; for (i = 0; i < 16; i += 4) { - iTemp[0] = pRes[i ] + pRes[i + 2]; - iTemp[1] = pRes[i ] - pRes[i + 2]; + iTemp[0] = pRes[i ] + pRes[i + 2]; + iTemp[1] = pRes[i ] - pRes[i + 2]; iTemp[2] = pRes[i + 1] - pRes[i + 3]; iTemp[3] = pRes[i + 1] + pRes[i + 3]; - pRes[i ] = iTemp[0] + iTemp[3]; + pRes[i ] = iTemp[0] + iTemp[3]; pRes[i + 1] = iTemp[1] + iTemp[2]; pRes[i + 2] = iTemp[1] - iTemp[2]; pRes[i + 3] = iTemp[0] - iTemp[3]; } for (i = 0; i < 4; i++) { - iTemp[0] = pRes[i ] + pRes[i + 8 ]; - iTemp[1] = pRes[i ] - pRes[i + 8 ]; + iTemp[0] = pRes[i ] + pRes[i + 8 ]; + iTemp[1] = pRes[i ] - pRes[i + 8 ]; iTemp[2] = pRes[i + 4 ] - pRes[i + 12]; iTemp[3] = pRes[i + 4 ] + pRes[i + 12]; - pRes[i ] = (iTemp[0] + iTemp[3]) * kuiMF; + pRes[i ] = (iTemp[0] + iTemp[3]) * kuiMF; pRes[i + 4 ] = (iTemp[1] + iTemp[2]) * kuiMF; pRes[i + 8 ] = (iTemp[1] - iTemp[2]) * kuiMF; pRes[i + 12] = (iTemp[0] - iTemp[3]) * kuiMF; @@ -126,9 +126,9 @@ void WelsDequantIHadamard4x4_c (int16_t* pRes, const uint16_t kuiMF) { void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF) { const int16_t kiSumU = pDct[0] + pDct[2]; - const int16_t kiDelU = pDct[0] - pDct[2]; + const int16_t kiDelU = pDct[0] - pDct[2]; const int16_t kiSumD = pDct[1] + pDct[3]; - const int16_t kiDelD = pDct[1] - pDct[3]; + const int16_t kiDelD = pDct[1] - pDct[3]; pDct[0] = ((kiSumU + kiSumD) * kuiMF) >> 1; pDct[1] = ((kiSumU - kiSumD) * kuiMF) >> 1; @@ -139,22 +139,22 @@ void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF) { void WelsDequant4x4_c (int16_t* pRes, const uint16_t* kpMF) { int32_t i; for (i = 0; i < 8; i++) { - pRes[i] *= kpMF[i]; - pRes[i + 8] *= kpMF[i]; + pRes[i] *= kpMF[i]; + pRes[i + 8] *= kpMF[i]; } } void WelsDequantFour4x4_c (int16_t* pRes, const uint16_t* kpMF) { int32_t i; for (i = 0; i < 8; i++) { - pRes[i] *= kpMF[i]; - pRes[i + 8] *= kpMF[i]; - pRes[i + 16] *= kpMF[i]; - pRes[i + 24] *= kpMF[i]; - pRes[i + 32] *= kpMF[i]; - pRes[i + 40] *= kpMF[i]; - pRes[i + 48] *= kpMF[i]; - pRes[i + 56] *= kpMF[i]; + pRes[i] *= kpMF[i]; + pRes[i + 8] *= kpMF[i]; + pRes[i + 16] *= kpMF[i]; + pRes[i + 24] *= kpMF[i]; + pRes[i + 32] *= kpMF[i]; + pRes[i + 40] *= kpMF[i]; + pRes[i + 48] *= kpMF[i]; + pRes[i + 56] *= kpMF[i]; } } @@ -172,8 +172,8 @@ void WelsIDctT4Rec_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iP for (i = 0; i < 4; i ++) { //horizon int32_t iIdx = i << 2; - const int32_t kiHorSumU = pDct[iIdx] + pDct[iIdx + 2]; // add 0-2 - const int32_t kiHorDelU = pDct[iIdx] - pDct[iIdx + 2]; // sub 0-2 + const int32_t kiHorSumU = pDct[iIdx] + pDct[iIdx + 2]; // add 0-2 + const int32_t kiHorDelU = pDct[iIdx] - pDct[iIdx + 2]; // sub 0-2 const int32_t kiHorSumD = pDct[iIdx + 1] + (pDct[iIdx + 3] >> 1); const int32_t kiHorDelD = (pDct[iIdx + 1] >> 1) - pDct[iIdx + 3]; @@ -238,13 +238,13 @@ void WelsGetEncBlockStrideOffset (int32_t* pBlock, const int32_t kiStrideY, cons i = j << 2; k = (j & 0x01) << 1; r = j & 0x02; - pBlock[i] = (0 + k + (0 + r) * kiStrideY) << 2; - pBlock[i + 1] = (1 + k + (0 + r) * kiStrideY) << 2; - pBlock[i + 2] = (0 + k + (1 + r) * kiStrideY) << 2; - pBlock[i + 3] = (1 + k + (1 + r) * kiStrideY) << 2; + pBlock[i] = (0 + k + (0 + r) * kiStrideY) << 2; + pBlock[i + 1] = (1 + k + (0 + r) * kiStrideY) << 2; + pBlock[i + 2] = (0 + k + (1 + r) * kiStrideY) << 2; + pBlock[i + 3] = (1 + k + (1 + r) * kiStrideY) << 2; - pBlock[16 + j] = - pBlock[20 + j] = ((j & 0x01) + r * kiStrideUV) << 2; + pBlock[16 + j] = + pBlock[20 + j] = ((j & 0x01) + r * kiStrideUV) << 2; } } diff --git a/codec/encoder/core/src/encode_mb_aux.cpp b/codec/encoder/core/src/encode_mb_aux.cpp index d448fe8a..1a0f711c 100644 --- a/codec/encoder/core/src/encode_mb_aux.cpp +++ b/codec/encoder/core/src/encode_mb_aux.cpp @@ -160,7 +160,7 @@ ALIGNED_DECLARE (const int16_t, g_kiQuantMF[52][8], 16) = { ****************************************************************************/ #define WELS_ABS_LC(a) ((iSign ^ (int32_t)(a)) - iSign) #define NEW_QUANT(pDct, iFF, iMF) (((iFF)+ WELS_ABS_LC(pDct))*(iMF)) >>16 -#define WELS_NEW_QUANT(pDct,iFF,iMF) WELS_ABS_LC(NEW_QUANT(pDct, iFF, iMF)) +#define WELS_NEW_QUANT(pDct,iFF,iMF) WELS_ABS_LC(NEW_QUANT(pDct, iFF, iMF)) void WelsQuant4x4_c (int16_t* pDct, const int16_t* pFF, const int16_t* pMF) { int32_t i, j, iSign; for (i = 0; i < 16; i += 4) { @@ -283,24 +283,24 @@ void WelsHadamardT4Dc_c (int16_t* pLumaDc, int16_t* pDct) { for (i = 0 ; i < 16 ; i += 4) { iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3); - s[0] = pDct[iIdx ] + pDct[iIdx + 80]; - s[3] = pDct[iIdx ] - pDct[iIdx + 80]; - s[1] = pDct[iIdx + 16] + pDct[iIdx + 64]; - s[2] = pDct[iIdx + 16] - pDct[iIdx + 64]; + s[0] = pDct[iIdx ] + pDct[iIdx + 80]; + s[3] = pDct[iIdx ] - pDct[iIdx + 80]; + s[1] = pDct[iIdx + 16] + pDct[iIdx + 64]; + s[2] = pDct[iIdx + 16] - pDct[iIdx + 64]; - p[i ] = s[0] + s[1]; + p[i ] = s[0] + s[1]; p[i + 2] = s[0] - s[1]; p[i + 1] = s[3] + s[2]; p[i + 3] = s[3] - s[2]; } for (i = 0 ; i < 4 ; i ++) { - s[0] = p[i ] + p[i + 12]; - s[3] = p[i ] - p[i + 12]; - s[1] = p[i + 4] + p[i + 8]; - s[2] = p[i + 4] - p[i + 8]; + s[0] = p[i ] + p[i + 12]; + s[3] = p[i ] - p[i + 12]; + s[1] = p[i + 4] + p[i + 8]; + s[2] = p[i + 4] - p[i + 8]; - pLumaDc[i ] = WELS_CLIP3 ((s[0] + s[1] + 1) >> 1, -32768, 32767); + pLumaDc[i ] = WELS_CLIP3 ((s[0] + s[1] + 1) >> 1, -32768, 32767); pLumaDc[i + 8 ] = WELS_CLIP3 ((s[0] - s[1] + 1) >> 1, -32768, 32767); pLumaDc[i + 4 ] = WELS_CLIP3 ((s[3] + s[2] + 1) >> 1, -32768, 32767); pLumaDc[i + 12] = WELS_CLIP3 ((s[3] - s[2] + 1) >> 1, -32768, 32767); @@ -331,7 +331,7 @@ void WelsDctT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pP s[1] = pData[kiI1] + pData[kiI2]; s[2] = pData[kiI1] - pData[kiI2]; - pDct[i ] = s[0] + s[1]; + pDct[i ] = s[0] + s[1]; pDct[kiI2] = s[0] - s[1]; pDct[kiI1] = (s[3] << 1) + s[2]; pDct[kiI3] = s[3] - (s[2] << 1); @@ -339,16 +339,16 @@ void WelsDctT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pP /* vertical transform */ for (i = 0 ; i < 4 ; i ++) { - const int32_t kiI4 = 4 + i; - const int32_t kiI8 = 8 + i; - const int32_t kiI12 = 12 + i; + const int32_t kiI4 = 4 + i; + const int32_t kiI8 = 8 + i; + const int32_t kiI12 = 12 + i; s[0] = pDct[i ] + pDct[kiI12]; s[3] = pDct[i ] - pDct[kiI12]; s[1] = pDct[kiI4] + pDct[kiI8 ]; s[2] = pDct[kiI4] - pDct[kiI8 ]; - pDct[i ] = s[0] + s[1]; + pDct[i ] = s[0] + s[1]; pDct[kiI8 ] = s[0] - s[1]; pDct[kiI4 ] = (s[3] << 1) + s[2]; pDct[kiI12] = s[3] - (s[2] << 1); @@ -359,9 +359,9 @@ void WelsDctFourT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t int32_t stride_1 = iStride1 << 2; int32_t stride_2 = iStride2 << 2; - WelsDctT4_c (pDct, &pPixel1[0], iStride1, &pPixel2[0], iStride2); - WelsDctT4_c (pDct + 16, &pPixel1[4], iStride1, &pPixel2[4], iStride2); - WelsDctT4_c (pDct + 32, &pPixel1[stride_1 ], iStride1, &pPixel2[stride_2 ], iStride2); + WelsDctT4_c (pDct, &pPixel1[0], iStride1, &pPixel2[0], iStride2); + WelsDctT4_c (pDct + 16, &pPixel1[4], iStride1, &pPixel2[4], iStride2); + WelsDctT4_c (pDct + 32, &pPixel1[stride_1 ], iStride1, &pPixel2[stride_2 ], iStride2); WelsDctT4_c (pDct + 48, &pPixel1[stride_1 + 4], iStride1, &pPixel2[stride_2 + 4], iStride2); } diff --git a/codec/encoder/core/src/encoder.cpp b/codec/encoder/core/src/encoder.cpp index 24fecc49..480fd482 100644 --- a/codec/encoder/core/src/encoder.cpp +++ b/codec/encoder/core/src/encoder.cpp @@ -52,7 +52,7 @@ #include "svc_base_layer_md.h" #include "svc_mode_decision.h" #include "set_mb_syn_cavlc.h" -#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross_platforms +#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross_platforms #include "slice_multi_threading.h" // global function pointers definition @@ -74,9 +74,9 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki if (NULL == pSrcPic || kiWidth == 0 || kiHeight == 0) return 1; - pSrcPic->iColorFormat = kiColorspace; - pSrcPic->iPicWidth = kiWidth; - pSrcPic->iPicHeight = kiHeight; + pSrcPic->iColorFormat = kiColorspace; + pSrcPic->iPicWidth = kiWidth; + pSrcPic->iPicHeight = kiHeight; //currently encoder only supports videoFormatI420. if ((kiColorspace & (~videoFormatVFlip)) != videoFormatI420) @@ -84,32 +84,32 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki switch (kiColorspace & (~videoFormatVFlip)) { case videoFormatI420: case videoFormatYV12: - pSrcPic->pData[0] = NULL; - pSrcPic->pData[1] = NULL; - pSrcPic->pData[2] = NULL; - pSrcPic->pData[3] = NULL; - pSrcPic->iStride[0] = kiWidth; - pSrcPic->iStride[2] = pSrcPic->iStride[1] = kiWidth >> 1; - pSrcPic->iStride[3] = 0; + pSrcPic->pData[0] = NULL; + pSrcPic->pData[1] = NULL; + pSrcPic->pData[2] = NULL; + pSrcPic->pData[3] = NULL; + pSrcPic->iStride[0] = kiWidth; + pSrcPic->iStride[2] = pSrcPic->iStride[1] = kiWidth >> 1; + pSrcPic->iStride[3] = 0; break; case videoFormatYUY2: case videoFormatYVYU: case videoFormatUYVY: - pSrcPic->pData[0] = NULL; - pSrcPic->pData[1] = NULL; - pSrcPic->pData[2] = NULL; - pSrcPic->pData[3] = NULL; - pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 16); - pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; + pSrcPic->pData[0] = NULL; + pSrcPic->pData[1] = NULL; + pSrcPic->pData[2] = NULL; + pSrcPic->pData[3] = NULL; + pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 16); + pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; break; case videoFormatRGB: case videoFormatBGR: - pSrcPic->pData[0] = NULL; - pSrcPic->pData[1] = NULL; - pSrcPic->pData[2] = NULL; - pSrcPic->pData[3] = NULL; - pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 24); - pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; + pSrcPic->pData[0] = NULL; + pSrcPic->pData[1] = NULL; + pSrcPic->pData[2] = NULL; + pSrcPic->pData[3] = NULL; + pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 24); + pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; if (kiColorspace & videoFormatVFlip) pSrcPic->iColorFormat = kiColorspace & (~videoFormatVFlip); else @@ -119,19 +119,19 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki case videoFormatRGBA: case videoFormatARGB: case videoFormatABGR: - pSrcPic->pData[0] = NULL; - pSrcPic->pData[1] = NULL; - pSrcPic->pData[2] = NULL; - pSrcPic->pData[3] = NULL; - pSrcPic->iStride[0] = kiWidth << 2; - pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; + pSrcPic->pData[0] = NULL; + pSrcPic->pData[1] = NULL; + pSrcPic->pData[2] = NULL; + pSrcPic->pData[3] = NULL; + pSrcPic->iStride[0] = kiWidth << 2; + pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; if (kiColorspace & videoFormatVFlip) pSrcPic->iColorFormat = kiColorspace & (~videoFormatVFlip); else pSrcPic->iColorFormat = kiColorspace | videoFormatVFlip; break; default: - return 2; // any else? + return 2; // any else? } return 0; @@ -231,8 +231,8 @@ int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, */ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { // for bitstream writing - pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position - pEncCtx->pOut->iNalIndex = 0; // reset NAL index + pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position + pEncCtx->pOut->iNalIndex = 0; // reset NAL index InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize); @@ -240,7 +240,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { ++pEncCtx->iFrameIndex; if (pEncCtx->iPOC < (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2) // if iPOC type is no 0, this need be modification - pEncCtx->iPOC += 2; // for POC type 0 + pEncCtx->iPOC += 2; // for POC type 0 else pEncCtx->iPOC = 0; @@ -248,29 +248,29 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1) ++ pEncCtx->iFrameNum; else - pEncCtx->iFrameNum = 0; // if iFrameNum overflow + pEncCtx->iFrameNum = 0; // if iFrameNum overflow } - pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; - pEncCtx->eSliceType = P_SLICE; - pEncCtx->eNalPriority = NRI_PRI_HIGH; + pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; + pEncCtx->eSliceType = P_SLICE; + pEncCtx->eNalPriority = NRI_PRI_HIGH; } else if (keFrameType == videoFrameTypeIDR) { - pEncCtx->iFrameNum = 0; - pEncCtx->iPOC = 0; + pEncCtx->iFrameNum = 0; + pEncCtx->iPOC = 0; pEncCtx->bEncCurFrmAsIdrFlag = false; pEncCtx->iFrameIndex = 0; - pEncCtx->eNalType = NAL_UNIT_CODED_SLICE_IDR; - pEncCtx->eSliceType = I_SLICE; - pEncCtx->eNalPriority = NRI_PRI_HIGHEST; + pEncCtx->eNalType = NAL_UNIT_CODED_SLICE_IDR; + pEncCtx->eSliceType = I_SLICE; + pEncCtx->eNalPriority = NRI_PRI_HIGHEST; - pEncCtx->iCodingIndex = 0; + pEncCtx->iCodingIndex = 0; // reset_ref_list // rc_init_gop } else if (keFrameType == videoFrameTypeI) { if (pEncCtx->iPOC < (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2) // if iPOC type is no 0, this need be modification - pEncCtx->iPOC += 2; // for POC type 0 + pEncCtx->iPOC += 2; // for POC type 0 else pEncCtx->iPOC = 0; @@ -278,15 +278,15 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1) ++ pEncCtx->iFrameNum; else - pEncCtx->iFrameNum = 0; // if iFrameNum overflow + pEncCtx->iFrameNum = 0; // if iFrameNum overflow } - pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; - pEncCtx->eSliceType = I_SLICE; - pEncCtx->eNalPriority = NRI_PRI_HIGHEST; + pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; + pEncCtx->eSliceType = I_SLICE; + pEncCtx->eNalPriority = NRI_PRI_HIGHEST; // rc_init_gop - } else { // B pictures are not supported now, any else? + } else { // B pictures are not supported now, any else? assert (0); } @@ -296,7 +296,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { } EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum) { - SWelsSvcCodingParam* pSvcParam = pEncCtx->pSvcParam; + SWelsSvcCodingParam* pSvcParam = pEncCtx->pSvcParam; EVideoFrameType iFrameType = videoFrameTypeInvalid; bool bSceneChangeFlag = false; @@ -370,7 +370,7 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) { WelsFileHandle* pDumpRecFile = NULL; - int32_t iWrittenSize = 0; + int32_t iWrittenSize = 0; const char* openMode = bAppend ? "ab" : "wb"; SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP; @@ -380,12 +380,12 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER) return; - if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage + if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage pDumpRecFile = WelsFopen (kpFileName, openMode); else { char sDependencyRecFileName[16] = {0}; - WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage - pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode); + WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage + pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode); } if (NULL != pDumpRecFile && bAppend) WelsFseek (pDumpRecFile, 0, SEEK_END); @@ -393,13 +393,13 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName if (NULL != pDumpRecFile) { int32_t i = 0; int32_t j = 0; - const int32_t kiStrideY = pCurPicture->iLineSize[0]; - const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + - pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; - const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + - pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; - const int32_t kiChromaWidth = kiLumaWidth >> 1; - const int32_t kiChromaHeight = kiLumaHeight >> 1; + const int32_t kiStrideY = pCurPicture->iLineSize[0]; + const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + + pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; + const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + + pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; + const int32_t kiChromaWidth = kiLumaWidth >> 1; + const int32_t kiChromaHeight = kiLumaHeight >> 1; uint8_t* pSrc = NULL; pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; @@ -407,7 +407,7 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); assert (iWrittenSize == kiLumaWidth); if (iWrittenSize < kiLumaWidth) { - assert (0); // make no sense for us if writing failed + assert (0); // make no sense for us if writing failed WelsFclose (pDumpRecFile); return; } @@ -420,7 +420,7 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); assert (iWrittenSize == kiChromaWidth); if (iWrittenSize < kiChromaWidth) { - assert (0); // make no sense for us if writing failed + assert (0); // make no sense for us if writing failed WelsFclose (pDumpRecFile); return; } @@ -437,22 +437,22 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) { - WelsFileHandle* pDumpRecFile = NULL; + WelsFileHandle* pDumpRecFile = NULL; SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP; bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; - int32_t iWrittenSize = 0; + int32_t iWrittenSize = 0; const char* openMode = bAppend ? "ab" : "wb"; if (NULL == pCurPicture || NULL == kpFileName) return; - if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage - pDumpRecFile = WelsFopen (kpFileName, openMode); + if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage + pDumpRecFile = WelsFopen (kpFileName, openMode); } else { - pDumpRecFile = WelsFopen ("rec.yuv", openMode); + pDumpRecFile = WelsFopen ("rec.yuv", openMode); } if (NULL != pDumpRecFile && bAppend) WelsFseek (pDumpRecFile, 0, SEEK_END); @@ -460,13 +460,13 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k if (NULL != pDumpRecFile) { int32_t i = 0; int32_t j = 0; - const int32_t kiStrideY = pCurPicture->iLineSize[0]; - const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + - pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; - const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + - pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; - const int32_t kiChromaWidth = kiLumaWidth >> 1; - const int32_t kiChromaHeight = kiLumaHeight >> 1; + const int32_t kiStrideY = pCurPicture->iLineSize[0]; + const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + + pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; + const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + + pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; + const int32_t kiChromaWidth = kiLumaWidth >> 1; + const int32_t kiChromaHeight = kiLumaHeight >> 1; uint8_t* pSrc = NULL; pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; @@ -474,7 +474,7 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); assert (iWrittenSize == kiLumaWidth); if (iWrittenSize < kiLumaWidth) { - assert (0); // make no sense for us if writing failed + assert (0); // make no sense for us if writing failed WelsFclose (pDumpRecFile); return; } @@ -487,7 +487,7 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); assert (iWrittenSize == kiChromaWidth); if (iWrittenSize < kiChromaWidth) { - assert (0); // make no sense for us if writing failed + assert (0); // make no sense for us if writing failed WelsFclose (pDumpRecFile); return; } @@ -501,7 +501,7 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k /***********************************************************************************/ -void WelsSetMemZero_c (void* pDst, int32_t iSize) { // confirmed_safe_unsafe_usage +void WelsSetMemZero_c (void* pDst, int32_t iSize) { // confirmed_safe_unsafe_usage memset (pDst, 0, iSize); } } diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index e7f9c011..75020c09 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -51,7 +51,7 @@ #include "deblocking.h" #include "ref_list_mgr_svc.h" #include "ls_defines.h" -#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms +#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms #include "slice_multi_threading.h" #include "measure_time.h" #include "svc_set_mb_syn.h" @@ -64,8 +64,8 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, SLayerBSInfo* pLayerBsInfo, int32_t* pNalIdxInLayer, int32_t* pLayerSize, - int32_t iFirstMbInPartition, // first mb inclusive in partition - int32_t iEndMbInPartition, // end mb exclusive in partition + int32_t iFirstMbInPartition, // first mb inclusive in partition + int32_t iEndMbInPartition, // end mb exclusive in partition int32_t iStartSliceIdx ); @@ -348,8 +348,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa //about iMultipleThreadIdc, bDeblockingParallelFlag, iLoopFilterDisableIdc, & uiSliceMode // (1) Single Thread - // if (THREAD==1)//single thread - // no parallel_deblocking: bDeblockingParallelFlag = 0; + // if (THREAD==1)//single thread + // no parallel_deblocking: bDeblockingParallelFlag = 0; // (2) Multi Thread: see uiSliceMode decision if (pCodingParam->iMultipleThreadIdc == 1) { //now is single thread. no parallel deblocking, set flag=0 @@ -391,10 +391,10 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa SSpatialLayerConfig* pSpatialLayer = &pCodingParam->sSpatialLayers[i]; const int32_t kiPicWidth = pSpatialLayer->iVideoWidth; const int32_t kiPicHeight = pSpatialLayer->iVideoHeight; - uint32_t iMbWidth = 0; - uint32_t iMbHeight = 0; - int32_t iMbNumInFrame = 0; - uint32_t iMaxSliceNum = MAX_SLICES_NUM; + uint32_t iMbWidth = 0; + uint32_t iMbHeight = 0; + int32_t iMbNumInFrame = 0; + uint32_t iMaxSliceNum = MAX_SLICES_NUM; if ((kiPicWidth <= 0) || (kiPicHeight <= 0) || (kiPicWidth > MAX_WIDTH) || (kiPicHeight > MAX_HEIGHT)) { WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(),width(1-%d),height(1-%d)invalid %d x %d in dependency layer settings!", MAX_WIDTH, MAX_HEIGHT, @@ -436,8 +436,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa case SM_FIXEDSLCNUM_SLICE: { pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0; - iMbWidth = (kiPicWidth + 15) >> 4; - iMbHeight = (kiPicHeight + 15) >> 4; + iMbWidth = (kiPicWidth + 15) >> 4; + iMbHeight = (kiPicHeight + 15) >> 4; iMbNumInFrame = iMbWidth * iMbHeight; iMaxSliceNum = MAX_SLICES_NUM; if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0 @@ -450,10 +450,10 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa WelsLog (pLogCtx, WELS_LOG_DEBUG, "ParamValidationExt(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!", pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum); - pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; break; } - if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom + if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom //check uiSliceNum and set uiSliceMbNum with current uiSliceNum if (!GomValidCheckSliceNum (iMbWidth, iMbHeight, &pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum)) { WelsLog (pLogCtx, WELS_LOG_WARNING, @@ -469,7 +469,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa } assert (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > 1); } else if (!CheckFixedSliceNumMultiSliceSetting (iMbNumInFrame, - &pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings + &pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings //check uiSliceMbNum with current uiSliceNum WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!", pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); @@ -477,8 +477,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa } // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { - pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; - pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; + pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; break; } } @@ -490,8 +490,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa case SM_RASTER_SLICE: { pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0; - iMbWidth = (kiPicWidth + 15) >> 4; - iMbHeight = (kiPicHeight + 15) >> 4; + iMbWidth = (kiPicWidth + 15) >> 4; + iMbHeight = (kiPicHeight + 15) >> 4; iMbNumInFrame = iMbWidth * iMbHeight; iMaxSliceNum = MAX_SLICES_NUM; if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0] <= 0) { @@ -501,13 +501,13 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa } if (!CheckRasterMultiSliceSetting (iMbNumInFrame, - &pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings + &pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!", pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); return ENC_RETURN_UNSUPPORTED_PARA; } if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0 - || pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { // verify interleave mode settings + || pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { // verify interleave mode settings WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) in SM_RASTER_SLICE settings!", pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum); return ENC_RETURN_UNSUPPORTED_PARA; @@ -515,7 +515,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum == 1) { WelsLog (pLogCtx, WELS_LOG_WARNING, "ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!"); - pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; break; } if ((pCodingParam->iRCMode != RC_OFF_MODE) && pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > 1) { @@ -523,8 +523,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa } // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { - pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; - pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; + pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; break; } } @@ -532,15 +532,15 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa case SM_ROWMB_SLICE: { pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0; - iMbWidth = (kiPicWidth + 15) >> 4; - iMbHeight = (kiPicHeight + 15) >> 4; + iMbWidth = (kiPicWidth + 15) >> 4; + iMbHeight = (kiPicHeight + 15) >> 4; iMaxSliceNum = MAX_SLICES_NUM; if (iMbHeight > iMaxSliceNum) { WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings more than MAX(%d)!", iMbHeight, MAX_SLICES_NUM); return ENC_RETURN_UNSUPPORTED_PARA; } - pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight; + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight; if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0) { WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!", @@ -548,7 +548,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa return ENC_RETURN_UNSUPPORTED_PARA; } if (!CheckRowMbMultiSliceSetting (iMbWidth, - &pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings + &pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!", pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); return ENC_RETURN_UNSUPPORTED_PARA; @@ -556,8 +556,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa } break; case SM_DYN_SLICE: { - iMbWidth = (kiPicWidth + 15) >> 4; - iMbHeight = (kiPicHeight + 15) >> 4; + iMbWidth = (kiPicWidth + 15) >> 4; + iMbHeight = (kiPicHeight + 15) >> 4; if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint <= 0) { WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid iSliceSize (%d) settings!", pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint); @@ -674,19 +674,19 @@ int32_t WelsEncoderApplyBitVaryRang (SLogContext* pLogCtx, SWelsSvcCodingParam* */ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pParam, int32_t* pCountLayers, int32_t* pCountNals) { - int32_t iCountNumLayers = 0; - int32_t iCountNumNals = 0; - int32_t iNumDependencyLayers = 0; - int32_t iDIndex = 0; + int32_t iCountNumLayers = 0; + int32_t iCountNumNals = 0; + int32_t iNumDependencyLayers = 0; + int32_t iDIndex = 0; if (NULL == pParam || NULL == ppCtx || NULL == *ppCtx) return 1; - iNumDependencyLayers = pParam->iSpatialLayerNum; + iNumDependencyLayers = pParam->iSpatialLayerNum; do { SSpatialLayerConfig* pDLayer = &pParam->sSpatialLayers[iDIndex]; -// pDLayer->ptr_cfg = pParam; +// pDLayer->ptr_cfg = pParam; int32_t iOrgNumNals = iCountNumNals; //Note: Sep. 2010 @@ -748,22 +748,22 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara if (NULL != pCountLayers) *pCountLayers = iCountNumLayers; if (NULL != pCountNals) - *pCountNals = iCountNumNals; + *pCountNals = iCountNumNals; return 0; } static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, const int32_t kiDlayerId, const int32_t kiMaxMbNum) { - int32_t iMbWidth = pLayer->iMbWidth; - int32_t iMbHeight = pLayer->iMbHeight; + int32_t iMbWidth = pLayer->iMbWidth; + int32_t iMbHeight = pLayer->iMbHeight; int32_t iIdx; - int32_t iMbNum = iMbWidth * iMbHeight; + int32_t iMbNum = iMbWidth * iMbHeight; SSliceCtx* pSliceCtx = pLayer->pSliceEncCtx; uint32_t uiNeighborAvail; - const int32_t kiOffset = (kiDlayerId & 0x01) * kiMaxMbNum; - SMVUnitXY (*pLayerMvUnitBlock4x4)[MB_BLOCK4x4_NUM] = (SMVUnitXY (*)[MB_BLOCK4x4_NUM]) ( + const int32_t kiOffset = (kiDlayerId & 0x01) * kiMaxMbNum; + SMVUnitXY (*pLayerMvUnitBlock4x4)[MB_BLOCK4x4_NUM] = (SMVUnitXY (*)[MB_BLOCK4x4_NUM]) ( &pEnc->pMvUnitBlock4x4[MB_BLOCK4x4_NUM * kiOffset]); - int8_t (*pLayerRefIndexBlock8x8)[MB_BLOCK8x8_NUM] = (int8_t (*)[MB_BLOCK8x8_NUM]) ( + int8_t (*pLayerRefIndexBlock8x8)[MB_BLOCK8x8_NUM] = (int8_t (*)[MB_BLOCK8x8_NUM]) ( &pEnc->pRefIndexBlock4x4[MB_BLOCK8x8_NUM * kiOffset]); for (iIdx = 0; iIdx < iMbNum; iIdx++) { @@ -804,8 +804,8 @@ static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, con if (bRightTop) { uiNeighborAvail |= TOPRIGHT_MB_POS; } - pList[iIdx].uiSliceIdc = uiSliceIdc; // merge from svc_hd_opt_b for multiple slices coding - pList[iIdx].uiNeighborAvail = uiNeighborAvail; + pList[iIdx].uiSliceIdc = uiSliceIdc; // merge from svc_hd_opt_b for multiple slices coding + pList[iIdx].uiNeighborAvail = uiNeighborAvail; uiNeighborAvail = 0; if (pList[iIdx].iMbX >= BASE_MV_MB_NMB) uiNeighborAvail |= LEFT_MB_POS; @@ -816,22 +816,22 @@ static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, con if (pList[iIdx].iMbY <= (iMbHeight - 1 - BASE_MV_MB_NMB)) uiNeighborAvail |= BOTTOM_MB_POS; - pList[iIdx].sMv = pLayerMvUnitBlock4x4[iIdx]; - pList[iIdx].pRefIndex = pLayerRefIndexBlock8x8[iIdx]; - pList[iIdx].pSadCost = &pEnc->pSadCostMb[iIdx]; - pList[iIdx].pIntra4x4PredMode = &pEnc->pIntra4x4PredModeBlocks[iIdx * INTRA_4x4_MODE_NUM]; - pList[iIdx].pNonZeroCount = &pEnc->pNonZeroCountBlocks[iIdx * MB_LUMA_CHROMA_BLOCK4x4_NUM]; + pList[iIdx].sMv = pLayerMvUnitBlock4x4[iIdx]; + pList[iIdx].pRefIndex = pLayerRefIndexBlock8x8[iIdx]; + pList[iIdx].pSadCost = &pEnc->pSadCostMb[iIdx]; + pList[iIdx].pIntra4x4PredMode = &pEnc->pIntra4x4PredModeBlocks[iIdx * INTRA_4x4_MODE_NUM]; + pList[iIdx].pNonZeroCount = &pEnc->pNonZeroCountBlocks[iIdx * MB_LUMA_CHROMA_BLOCK4x4_NUM]; } } int32_t InitMbListD (sWelsEncCtx** ppCtx) { - int32_t iNumDlayer = (*ppCtx)->pSvcParam->iSpatialLayerNum; - int32_t iMbSize[MAX_DEPENDENCY_LAYER] = { 0 }; - int32_t iOverallMbNum = 0; - int32_t iMbWidth = 0; - int32_t iMbHeight = 0; - int32_t i; + int32_t iNumDlayer = (*ppCtx)->pSvcParam->iSpatialLayerNum; + int32_t iMbSize[MAX_DEPENDENCY_LAYER] = { 0 }; + int32_t iOverallMbNum = 0; + int32_t iMbWidth = 0; + int32_t iMbHeight = 0; + int32_t i; if (iNumDlayer > MAX_DEPENDENCY_LAYER) return 1; @@ -874,7 +874,7 @@ int32_t AllocMbCacheAligned (SMbCache* pMbCache, CMemoryAlign* pMa) { pMbCache->pPrevIntra4x4PredModeFlag = (bool*)pMa->WelsMalloc (16 * sizeof (bool), "pMbCache->pPrevIntra4x4PredModeFlag"); WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pPrevIntra4x4PredModeFlag)); - pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMalloc (16 * sizeof (int8_t), + pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMalloc (16 * sizeof (int8_t), "pMbCache->pRemIntra4x4PredModeFlag"); WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pRemIntra4x4PredModeFlag)); pMbCache->pDct = (SDCTCoeff*)pMa->WelsMalloc (sizeof (SDCTCoeff), "pMbCache->pDct"); @@ -923,14 +923,14 @@ static int32_t WelsGenerateNewSps (sWelsEncCtx* pCtx, const bool kbUseSubsetSps, int32_t iRet = 0; if (!kbUseSubsetSps) { - pSps = & (pCtx->pSpsArray[kiSpsId]); + pSps = & (pCtx->pSpsArray[kiSpsId]); } else { - pSubsetSps = & (pCtx->pSubsetArray[kiSpsId]); - pSps = &pSubsetSps->pSps; + pSubsetSps = & (pCtx->pSubsetArray[kiSpsId]); + pSps = &pSubsetSps->pSps; } - SWelsSvcCodingParam* pParam = pCtx->pSvcParam; - SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; + SWelsSvcCodingParam* pParam = pCtx->pSvcParam; + SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; // Need port pSps/pPps initialization due to spatial scalability changed if (!kbUseSubsetSps) { iRet = WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, @@ -1001,7 +1001,7 @@ int32_t FindExistingSps (SWelsSvcCodingParam* pParam, const bool kbUseSubsetSps, const int32_t iDlayerCount, const int32_t iSpsNumInUse, SWelsSPS* pSpsArray, SSubsetSps* pSubsetArray, bool bSVCBaseLayer) { - SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; + SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; assert (iSpsNumInUse <= MAX_SPS_COUNT); if (!kbUseSubsetSps) { @@ -1070,25 +1070,25 @@ int32_t FindExistingPps (SWelsSPS* pSps, SSubsetSps* pSubsetSps, const bool kbUs * \return 0 - successful; otherwise failed */ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingParasetList) { - SWelsSvcCodingParam* pParam = NULL; - SWelsSPS* pSps = NULL; - SSubsetSps* pSubsetSps = NULL; - SWelsPPS* pPps = NULL; - CMemoryAlign* pMa = NULL; - int32_t iDlayerCount = 0; - int32_t iDlayerIndex = 0; - uint32_t iSpsId = 0; - uint32_t iPpsId = 0; - uint32_t iNumRef = 0; - int32_t iResult = 0; + SWelsSvcCodingParam* pParam = NULL; + SWelsSPS* pSps = NULL; + SSubsetSps* pSubsetSps = NULL; + SWelsPPS* pPps = NULL; + CMemoryAlign* pMa = NULL; + int32_t iDlayerCount = 0; + int32_t iDlayerIndex = 0; + uint32_t iSpsId = 0; + uint32_t iPpsId = 0; + uint32_t iNumRef = 0; + int32_t iResult = 0; if (NULL == ppCtx || NULL == *ppCtx) return 1; - pMa = (*ppCtx)->pMemAlign; - pParam = (*ppCtx)->pSvcParam; - iDlayerCount = pParam->iSpatialLayerNum; - iNumRef = pParam->iMaxNumRefFrame; + pMa = (*ppCtx)->pMemAlign; + pParam = (*ppCtx)->pSvcParam; + iDlayerCount = pParam->iSpatialLayerNum; + iNumRef = pParam->iMaxNumRefFrame; const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX; const int32_t kiMe16x16 = ME_DIA_CROSS; @@ -1096,43 +1096,42 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME) ? 0 : ((kiFeatureStrategyIndex << 16) + ((kiMe16x16 & 0x00FF) << 8) + (kiMe8x8 & 0x00FF)); - iDlayerIndex = 0; + iDlayerIndex = 0; while (iDlayerIndex < iDlayerCount) { - SRefList* pRefList = NULL; - uint32_t i = 0; - const int32_t kiWidth = pParam->sSpatialLayers[iDlayerIndex].iVideoWidth; - const int32_t kiHeight = pParam->sSpatialLayers[iDlayerIndex].iVideoHeight; - int32_t iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with iWidth of horizon - int32_t iPicChromaWidth = iPicWidth >> 1; + SRefList* pRefList = NULL; + uint32_t i = 0; + const int32_t kiWidth = pParam->sSpatialLayers[iDlayerIndex].iVideoWidth; + const int32_t kiHeight = pParam->sSpatialLayers[iDlayerIndex].iVideoHeight; + int32_t iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with iWidth of horizon + int32_t iPicChromaWidth = iPicWidth >> 1; - iPicWidth = WELS_ALIGN (iPicWidth, - 32); // 32(or 16 for chroma below) to match original imp. here instead of iCacheLineSize - iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); + iPicWidth = WELS_ALIGN (iPicWidth, 32); // 32(or 16 for chroma below) to match original imp. here instead of iCacheLineSize + iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); WelsGetEncBlockStrideOffset ((*ppCtx)->pStrideTab->pStrideEncBlockOffset[iDlayerIndex], iPicWidth, iPicChromaWidth); // pRef list - pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList"); + 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); pRefList->pNextBuffer = pRefList->pRef[0]; - (*ppCtx)->ppRefPicListExt[iDlayerIndex] = pRefList; + (*ppCtx)->ppRefPicListExt[iDlayerIndex] = pRefList; ++ iDlayerIndex; } - iDlayerIndex = 0; + iDlayerIndex = 0; while (iDlayerIndex < iDlayerCount) { - SDqLayer* pDqLayer = NULL; - SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex]; - const int32_t kiMbW = (pDlayer->iVideoWidth + 0x0f) >> 4; - const int32_t kiMbH = (pDlayer->iVideoHeight + 0x0f) >> 4; - int32_t iMaxSliceNum = 1; + SDqLayer* pDqLayer = NULL; + SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex]; + const int32_t kiMbW = (pDlayer->iVideoWidth + 0x0f) >> 4; + const int32_t kiMbH = (pDlayer->iVideoHeight + 0x0f) >> 4; + int32_t iMaxSliceNum = 1; const int32_t kiSliceNum = GetInitialSliceNum (kiMbW, kiMbH, &pDlayer->sSliceCfg); if (iMaxSliceNum < kiSliceNum) iMaxSliceNum = kiSliceNum; @@ -1143,11 +1142,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p // for dynamic slicing mode if (SM_DYN_SLICE == pDlayer->sSliceCfg.uiSliceMode) { - const int32_t iSize = pParam->iCountThreadsNum * sizeof (int32_t); + const int32_t iSize = pParam->iCountThreadsNum * sizeof (int32_t); - pDqLayer->pNumSliceCodedOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pNumSliceCodedOfPartition"); - pDqLayer->pLastCodedMbIdxOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pLastCodedMbIdxOfPartition"); - pDqLayer->pLastMbIdxOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pLastMbIdxOfPartition"); + pDqLayer->pNumSliceCodedOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pNumSliceCodedOfPartition"); + pDqLayer->pLastCodedMbIdxOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pLastCodedMbIdxOfPartition"); + pDqLayer->pLastMbIdxOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pLastMbIdxOfPartition"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->pNumSliceCodedOfPartition || @@ -1156,11 +1155,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p FreeMemorySvc (ppCtx)) } - pDqLayer->iMbWidth = kiMbW; - pDqLayer->iMbHeight = kiMbH; + pDqLayer->iMbWidth = kiMbW; + pDqLayer->iMbHeight = kiMbH; { - int32_t iSliceIdx = 0; - pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); + int32_t iSliceIdx = 0; + pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx)) if (iMaxSliceNum > 1) { @@ -1179,10 +1178,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p } } // fix issue in case single pSlice coding might be inclusive exist in variant spatial layer setting, also introducing multi-pSlice modes - else { // only one pSlice + else { // only one pSlice SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[0]; - pSlice->uiSliceIdx = 0; - pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; + pSlice->uiSliceIdx = 0; + pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) { FreeMemorySvc (ppCtx); return 1; @@ -1192,30 +1191,30 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p //deblocking parameters initialization //target-layer deblocking - pDqLayer->iLoopFilterDisableIdc = pParam->iLoopFilterDisableIdc; - pDqLayer->iLoopFilterAlphaC0Offset = (pParam->iLoopFilterAlphaC0Offset) << 1; - pDqLayer->iLoopFilterBetaOffset = (pParam->iLoopFilterBetaOffset) << 1; + pDqLayer->iLoopFilterDisableIdc = pParam->iLoopFilterDisableIdc; + pDqLayer->iLoopFilterAlphaC0Offset = (pParam->iLoopFilterAlphaC0Offset) << 1; + pDqLayer->iLoopFilterBetaOffset = (pParam->iLoopFilterBetaOffset) << 1; //parallel deblocking - pDqLayer->bDeblockingParallelFlag = pParam->bDeblockingParallelFlag; + pDqLayer->bDeblockingParallelFlag = pParam->bDeblockingParallelFlag; //deblocking parameter adjustment if (SM_SINGLE_SLICE == pDlayer->sSliceCfg.uiSliceMode) { //iLoopFilterDisableIdc: will be 0 or 1 under single_slice if (2 == pParam->iLoopFilterDisableIdc) { - pDqLayer->iLoopFilterDisableIdc = 0; + pDqLayer->iLoopFilterDisableIdc = 0; } //bDeblockingParallelFlag pDqLayer->bDeblockingParallelFlag = false; } else { //multi-pSlice if (0 == pDqLayer->iLoopFilterDisableIdc) { - pDqLayer->bDeblockingParallelFlag = false; + pDqLayer->bDeblockingParallelFlag = false; } } // if (kiNeedFeatureStorage && iDlayerIndex == iDlayerCount - 1) { - pDqLayer->pFeatureSearchPreparation = static_cast (pMa->WelsMallocz (sizeof ( + pDqLayer->pFeatureSearchPreparation = static_cast (pMa->WelsMallocz (sizeof ( SFeatureSearchPreparation), "pFeatureSearchPreparation")); WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx)); int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iVideoWidth, pDlayer->iVideoHeight, @@ -1226,7 +1225,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p pDqLayer->pFeatureSearchPreparation = NULL; } - (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; + (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; ++ iDlayerIndex; } @@ -1234,10 +1233,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010 const int32_t kiNeededSpsNum = (*ppCtx)->GetNeededSpsNum(); const int32_t kiNeededSubsetSpsNum = (*ppCtx)->GetNeededSubsetSpsNum(); - (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray"); + (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx)) if (kiNeededSubsetSpsNum > 0) { - (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray"); + (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx)) } else { (*ppCtx)->pSubsetArray = NULL; @@ -1257,7 +1256,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p // PPS const int32_t kiNeededPpsNum = (*ppCtx)->GetNeededPpsNum(); - (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray"); + (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx)) // copy from existing if the pointer exists @@ -1273,17 +1272,17 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p (*ppCtx)->pPSOVector = NULL; } - (*ppCtx)->pDqIdcMap = (SDqIdc*)pMa->WelsMallocz (iDlayerCount * sizeof (SDqIdc), "pDqIdcMap"); + (*ppCtx)->pDqIdcMap = (SDqIdc*)pMa->WelsMallocz (iDlayerCount * sizeof (SDqIdc), "pDqIdcMap"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pDqIdcMap), FreeMemorySvc (ppCtx)) - iDlayerIndex = 0; + iDlayerIndex = 0; while (iDlayerIndex < iDlayerCount) { - SDqIdc* pDqIdc = & (*ppCtx)->pDqIdcMap[iDlayerIndex]; - const bool bUseSubsetSps = (!pParam->bSimulcastAVC) && (iDlayerIndex > BASE_DEPENDENCY_ID); - SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; + SDqIdc* pDqIdc = & (*ppCtx)->pDqIdcMap[iDlayerIndex]; + const bool bUseSubsetSps = (!pParam->bSimulcastAVC) && (iDlayerIndex > BASE_DEPENDENCY_ID); + SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; bool bSvcBaselayer = (!pParam->bSimulcastAVC) && (iDlayerCount > BASE_DEPENDENCY_ID) && (iDlayerIndex == BASE_DEPENDENCY_ID); - pDqIdc->uiSpatialId = iDlayerIndex; + pDqIdc->uiSpatialId = iDlayerIndex; if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) { WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex, @@ -1338,7 +1337,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p } if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) { - pPps = & (*ppCtx)->pPPSArray[iPpsId]; + pPps = & (*ppCtx)->pPPSArray[iPpsId]; // initialize pPps WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); } else { @@ -1354,7 +1353,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p pPps = & ((*ppCtx)->pPPSArray[kiFoundPpsId]); } else { iPpsId = ((*ppCtx)->sPSOVector.uiInUsePpsNum++); - pPps = & (*ppCtx)->pPPSArray[iPpsId]; + pPps = & (*ppCtx)->pPPSArray[iPpsId]; WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); } } @@ -1373,10 +1372,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p FreeMemorySvc (ppCtx); return iResult; } - (*ppCtx)->ppDqLayerList[iDlayerIndex]->pSliceEncCtx = & (*ppCtx)->pSliceCtxList[iDlayerIndex]; + (*ppCtx)->ppDqLayerList[iDlayerIndex]->pSliceEncCtx = & (*ppCtx)->pSliceCtxList[iDlayerIndex]; } - pDqIdc->iSpsId = iSpsId; - pDqIdc->iPpsId = iPpsId; + pDqIdc->iSpsId = iSpsId; + pDqIdc->iPpsId = iPpsId; (*ppCtx)->sPSOVector.bPpsIdMappingIntoSubsetsps[iPpsId] = bUseSubsetSps; @@ -1403,33 +1402,33 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p } int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers) { - CMemoryAlign* pMa = (*ppCtx)->pMemAlign; - SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam; - SStrideTables* pPtr = NULL; - int16_t* pTmpRow = NULL, *pRowX = NULL, *pRowY = NULL, *p = NULL; - uint8_t* pBase = NULL; + CMemoryAlign* pMa = (*ppCtx)->pMemAlign; + SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam; + SStrideTables* pPtr = NULL; + int16_t* pTmpRow = NULL, *pRowX = NULL, *pRowY = NULL, *p = NULL; + uint8_t* pBase = NULL; uint8_t* pBaseDec = NULL, *pBaseEnc = NULL, *pBaseMbX = NULL, *pBaseMbY = NULL; struct { int32_t iMbWidth; - int32_t iCountMbNum; // count number of SMB in each spatial - int32_t iSizeAllMbAlignCache; // cache line size aligned in each spatial + int32_t iCountMbNum; // count number of SMB in each spatial + int32_t iSizeAllMbAlignCache; // cache line size aligned in each spatial } sMbSizeMap[MAX_DEPENDENCY_LAYER] = {{ 0 }}; int32_t iLineSizeY[MAX_DEPENDENCY_LAYER][2] = {{ 0 }}; int32_t iLineSizeUV[MAX_DEPENDENCY_LAYER][2] = {{ 0 }}; int32_t iMapSpatialIdx[MAX_DEPENDENCY_LAYER][2] = {{ 0 }}; - int32_t iSizeDec = 0; - int32_t iSizeEnc = 0; - int32_t iCountLayersNeedCs[2] = {0}; + int32_t iSizeDec = 0; + int32_t iSizeEnc = 0; + int32_t iCountLayersNeedCs[2] = {0}; const int32_t kiUnit1Size = 24 * sizeof (int32_t); - int32_t iUnit2Size = 0; - int32_t iNeedAllocSize = 0; - int32_t iRowSize = 0; - int16_t iMaxMbWidth = 0; - int16_t iMaxMbHeight = 0; - int32_t i = 0; - int32_t iSpatialIdx = 0; - int32_t iTemporalIdx = 0; - int32_t iCntTid = 0; + int32_t iUnit2Size = 0; + int32_t iNeedAllocSize = 0; + int32_t iRowSize = 0; + int16_t iMaxMbWidth = 0; + int16_t iMaxMbHeight = 0; + int32_t i = 0; + int32_t iSpatialIdx = 0; + int32_t iTemporalIdx = 0; + int32_t iCntTid = 0; if (kiNumSpatialLayers <= 0 || kiNumSpatialLayers > MAX_DEPENDENCY_LAYER) return 1; @@ -1439,7 +1438,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers return 1; (*ppCtx)->pStrideTab = pPtr; - iCntTid = pParam->iTemporalLayerNum > 1 ? 2 : 1; + iCntTid = pParam->iTemporalLayerNum > 1 ? 2 : 1; iSpatialIdx = 0; while (iSpatialIdx < kiNumSpatialLayers) { @@ -1447,8 +1446,8 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers const int32_t kiTmpHeight = (pParam->sSpatialLayers[iSpatialIdx].iVideoHeight + 15) >> 4; int32_t iNumMb = kiTmpWidth * kiTmpHeight; - sMbSizeMap[iSpatialIdx].iMbWidth = kiTmpWidth; - sMbSizeMap[iSpatialIdx].iCountMbNum = iNumMb; + sMbSizeMap[iSpatialIdx].iMbWidth = kiTmpWidth; + sMbSizeMap[iSpatialIdx].iCountMbNum = iNumMb; iNumMb *= sizeof (int16_t); sMbSizeMap[iSpatialIdx].iSizeAllMbAlignCache = iNumMb; @@ -1460,14 +1459,14 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers // Adaptive size_cs, size_fdec by implementation dependency iTemporalIdx = 0; while (iTemporalIdx < iCntTid) { - const bool kbBaseTemporalFlag = (iTemporalIdx == 0); + const bool kbBaseTemporalFlag = (iTemporalIdx == 0); iSpatialIdx = 0; while (iSpatialIdx < kiNumSpatialLayers) { - SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iSpatialIdx]; + SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iSpatialIdx]; const int32_t kiWidthPad = WELS_ALIGN (fDlp->iVideoWidth, 16) + (PADDING_LENGTH << 1); - iLineSizeY[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN (kiWidthPad, 32); + iLineSizeY[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN (kiWidthPad, 32); iLineSizeUV[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN ((kiWidthPad >> 1), 16); iMapSpatialIdx[iCountLayersNeedCs[kbBaseTemporalFlag]][kbBaseTemporalFlag] = iSpatialIdx; @@ -1486,24 +1485,24 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers return 1; } - pBaseDec = pBase; // iCountLayersNeedCs - pBaseEnc = pBaseDec + iSizeDec; // iNumSpatialLayers - pBaseMbX = pBaseEnc + iSizeEnc; // iNumSpatialLayers - pBaseMbY = pBaseMbX + iUnit2Size; // iNumSpatialLayers + pBaseDec = pBase; // iCountLayersNeedCs + pBaseEnc = pBaseDec + iSizeDec; // iNumSpatialLayers + pBaseMbX = pBaseEnc + iSizeEnc; // iNumSpatialLayers + pBaseMbY = pBaseMbX + iUnit2Size; // iNumSpatialLayers iTemporalIdx = 0; while (iTemporalIdx < iCntTid) { - const bool kbBaseTemporalFlag = (iTemporalIdx == 0); + const bool kbBaseTemporalFlag = (iTemporalIdx == 0); iSpatialIdx = 0; while (iSpatialIdx < iCountLayersNeedCs[kbBaseTemporalFlag]) { const int32_t kiActualSpatialIdx = iMapSpatialIdx[iSpatialIdx][kbBaseTemporalFlag]; - const int32_t kiLumaWidth = iLineSizeY[kiActualSpatialIdx][kbBaseTemporalFlag]; - const int32_t kiChromaWidth = iLineSizeUV[kiActualSpatialIdx][kbBaseTemporalFlag]; + const int32_t kiLumaWidth = iLineSizeY[kiActualSpatialIdx][kbBaseTemporalFlag]; + const int32_t kiChromaWidth = iLineSizeUV[kiActualSpatialIdx][kbBaseTemporalFlag]; WelsGetEncBlockStrideOffset ((int32_t*)pBaseDec, kiLumaWidth, kiChromaWidth); - pPtr->pStrideDecBlockOffset[kiActualSpatialIdx][kbBaseTemporalFlag] = (int32_t*)pBaseDec; + pPtr->pStrideDecBlockOffset[kiActualSpatialIdx][kbBaseTemporalFlag] = (int32_t*)pBaseDec; pBaseDec += kiUnit1Size; ++ iSpatialIdx; @@ -1512,7 +1511,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers } iTemporalIdx = 0; while (iTemporalIdx < iCntTid) { - const bool kbBaseTemporalFlag = (iTemporalIdx == 0); + const bool kbBaseTemporalFlag = (iTemporalIdx == 0); iSpatialIdx = 0; while (iSpatialIdx < kiNumSpatialLayers) { @@ -1524,12 +1523,12 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers while (i < iCountLayersNeedCs[kbBaseTemporalFlag]) { const int32_t kiActualIdx = iMapSpatialIdx[i][kbBaseTemporalFlag]; if (kiActualIdx == iSpatialIdx) { - bInMap = true; + bInMap = true; break; } if (!bMatchFlag) { - iMatchIndex = kiActualIdx; - bMatchFlag = true; + iMatchIndex = kiActualIdx; + bMatchFlag = true; } ++ i; } @@ -1540,7 +1539,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers } // not in spatial map and assign match one to it - pPtr->pStrideDecBlockOffset[iSpatialIdx][kbBaseTemporalFlag] = + pPtr->pStrideDecBlockOffset[iSpatialIdx][kbBaseTemporalFlag] = pPtr->pStrideDecBlockOffset[iMatchIndex][kbBaseTemporalFlag]; ++ iSpatialIdx; @@ -1552,10 +1551,10 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers while (iSpatialIdx < kiNumSpatialLayers) { const int32_t kiAllocMbSize = sMbSizeMap[iSpatialIdx].iSizeAllMbAlignCache; - pPtr->pStrideEncBlockOffset[iSpatialIdx] = (int32_t*)pBaseEnc; + pPtr->pStrideEncBlockOffset[iSpatialIdx] = (int32_t*)pBaseEnc; - pPtr->pMbIndexX[iSpatialIdx] = (int16_t*)pBaseMbX; - pPtr->pMbIndexY[iSpatialIdx] = (int16_t*)pBaseMbY; + pPtr->pMbIndexX[iSpatialIdx] = (int16_t*)pBaseMbX; + pPtr->pMbIndexY[iSpatialIdx] = (int16_t*)pBaseMbY; pBaseEnc += kiUnit1Size; pBaseMbX += kiAllocMbSize; @@ -1565,20 +1564,20 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers } while (iSpatialIdx < MAX_DEPENDENCY_LAYER) { - pPtr->pStrideDecBlockOffset[iSpatialIdx][0] = NULL; - pPtr->pStrideDecBlockOffset[iSpatialIdx][1] = NULL; - pPtr->pStrideEncBlockOffset[iSpatialIdx] = NULL; - pPtr->pMbIndexX[iSpatialIdx] = NULL; - pPtr->pMbIndexY[iSpatialIdx] = NULL; + pPtr->pStrideDecBlockOffset[iSpatialIdx][0] = NULL; + pPtr->pStrideDecBlockOffset[iSpatialIdx][1] = NULL; + pPtr->pStrideEncBlockOffset[iSpatialIdx] = NULL; + pPtr->pMbIndexX[iSpatialIdx] = NULL; + pPtr->pMbIndexY[iSpatialIdx] = NULL; ++ iSpatialIdx; } // initialize pMbIndexX and pMbIndexY tables as below - iMaxMbWidth = sMbSizeMap[kiNumSpatialLayers - 1].iMbWidth; - iMaxMbWidth = WELS_ALIGN (iMaxMbWidth, 4); // 4 loops for int16_t required introduced as below - iRowSize = iMaxMbWidth * sizeof (int16_t); + iMaxMbWidth = sMbSizeMap[kiNumSpatialLayers - 1].iMbWidth; + iMaxMbWidth = WELS_ALIGN (iMaxMbWidth, 4); // 4 loops for int16_t required introduced as below + iRowSize = iMaxMbWidth * sizeof (int16_t); pTmpRow = (int16_t*)pMa->WelsMalloc (iRowSize, "pTmpRow"); if (NULL == pTmpRow) { @@ -1590,10 +1589,10 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers i = 0; p = pRowX; while (i < iMaxMbWidth) { - *p = i; - * (p + 1) = 1 + i; - * (p + 2) = 2 + i; - * (p + 3) = 3 + i; + *p = i; + * (p + 1) = 1 + i; + * (p + 2) = 2 + i; + * (p + 3) = 3 + i; p += 4; i += 4; @@ -1602,13 +1601,13 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers iSpatialIdx = kiNumSpatialLayers; while (--iSpatialIdx >= 0) { int16_t* pMbIndexX = pPtr->pMbIndexX[iSpatialIdx]; - const int32_t kiMbWidth = sMbSizeMap[iSpatialIdx].iMbWidth; - const int32_t kiMbHeight = sMbSizeMap[iSpatialIdx].iCountMbNum / kiMbWidth; - const int32_t kiLineSize = kiMbWidth * sizeof (int16_t); + const int32_t kiMbWidth = sMbSizeMap[iSpatialIdx].iMbWidth; + const int32_t kiMbHeight = sMbSizeMap[iSpatialIdx].iCountMbNum / kiMbWidth; + const int32_t kiLineSize = kiMbWidth * sizeof (int16_t); i = 0; while (i < kiMbHeight) { - memcpy (pMbIndexX, pRowX, kiLineSize); // confirmed_safe_unsafe_usage + memcpy (pMbIndexX, pRowX, kiLineSize); // confirmed_safe_unsafe_usage pMbIndexX += kiMbWidth; ++ i; @@ -1616,7 +1615,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers } memset (pRowY, 0, iRowSize); - iMaxMbHeight = sMbSizeMap[kiNumSpatialLayers - 1].iCountMbNum / sMbSizeMap[kiNumSpatialLayers - 1].iMbWidth; + iMaxMbHeight = sMbSizeMap[kiNumSpatialLayers - 1].iCountMbNum / sMbSizeMap[kiNumSpatialLayers - 1].iMbWidth; i = 0; for (;;) { ENFORCE_STACK_ALIGN_1D (int16_t, t, 4, 16) @@ -1625,13 +1624,13 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers int16_t j = 0; for (iSpatialIdx = kiNumSpatialLayers - 1; iSpatialIdx >= 0; -- iSpatialIdx) { - const int32_t kiMbWidth = sMbSizeMap[iSpatialIdx].iMbWidth; + const int32_t kiMbWidth = sMbSizeMap[iSpatialIdx].iMbWidth; const int32_t kiMbHeight = sMbSizeMap[iSpatialIdx].iCountMbNum / kiMbWidth; - const int32_t kiLineSize = kiMbWidth * sizeof (int16_t); + const int32_t kiLineSize = kiMbWidth * sizeof (int16_t); int16_t* pMbIndexY = pPtr->pMbIndexY[iSpatialIdx] + i * kiMbWidth; if (i < kiMbHeight) { - memcpy (pMbIndexY, pRowY, kiLineSize); // confirmed_safe_unsafe_usage + memcpy (pMbIndexY, pRowY, kiLineSize); // confirmed_safe_unsafe_usage } } ++ i; @@ -1709,22 +1708,22 @@ void GetMvMvdRange (SWelsSvcCodingParam* pParam, int32_t& iMvRange, int32_t& iMv iMvdRange = WELS_MIN (iMvdRange, iFixMvdRange); } int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingParasetList) { - SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam; - CMemoryAlign* pMa = (*ppCtx)->pMemAlign; - SSpatialLayerConfig* pFinalSpatial = NULL; - int32_t iCountBsLen = 0; - int32_t iCountNals = 0; - int32_t iMaxPicWidth = 0; - int32_t iMaxPicHeight = 0; - int32_t iCountMaxMbNum = 0; - int32_t iIndex = 0; - int32_t iCountLayers = 0; - int32_t iResult = 0; - float fCompressRatioThr = .5f; - const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum; - int32_t iVclLayersBsSizeCount = 0; - int32_t iNonVclLayersBsSizeCount = 0; - int32_t iTargetSpatialBsSize = 0; + SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam; + CMemoryAlign* pMa = (*ppCtx)->pMemAlign; + SSpatialLayerConfig* pFinalSpatial = NULL; + int32_t iCountBsLen = 0; + int32_t iCountNals = 0; + int32_t iMaxPicWidth = 0; + int32_t iMaxPicHeight = 0; + int32_t iCountMaxMbNum = 0; + int32_t iIndex = 0; + int32_t iCountLayers = 0; + int32_t iResult = 0; + float fCompressRatioThr = .5f; + const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum; + int32_t iVclLayersBsSizeCount = 0; + int32_t iNonVclLayersBsSizeCount = 0; + int32_t iTargetSpatialBsSize = 0; if (kiNumDependencyLayers < 1 || kiNumDependencyLayers > MAX_DEPENDENCY_LAYER) { WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_WARNING, "RequestMemorySvc() failed due to invalid iNumDependencyLayers(%d)!", @@ -1741,9 +1740,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa return 1; } - pFinalSpatial = &pParam->sSpatialLayers[kiNumDependencyLayers - 1]; - iMaxPicWidth = pFinalSpatial->iVideoWidth; - iMaxPicHeight = pFinalSpatial->iVideoHeight; + pFinalSpatial = &pParam->sSpatialLayers[kiNumDependencyLayers - 1]; + iMaxPicWidth = pFinalSpatial->iVideoWidth; + iMaxPicHeight = pFinalSpatial->iVideoHeight; iCountMaxMbNum = ((15 + iMaxPicWidth) >> 4) * ((15 + iMaxPicHeight) >> 4); iResult = AcquireLayersNals (ppCtx, pParam, &iCountLayers, &iCountNals); @@ -1762,45 +1761,45 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa while (iIndex < pParam->iSpatialLayerNum) { SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iIndex]; - fCompressRatioThr = COMPRESS_RATIO_THR; + fCompressRatioThr = COMPRESS_RATIO_THR; iLayerBsSize = WELS_ROUND (((3 * fDlp->iVideoWidth * fDlp->iVideoHeight) >> 1) * fCompressRatioThr) + MAX_MACROBLOCK_SIZE_IN_BYTE_x2; - iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged + iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged iVclLayersBsSizeCount += iLayerBsSize; ++ iIndex; } iTargetSpatialBsSize = iLayerBsSize; iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; - pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, + pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); // Output (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut), FreeMemorySvc (ppCtx)) - (*ppCtx)->pOut->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pOut->pBsBuffer"); + (*ppCtx)->pOut->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pOut->pBsBuffer"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pBsBuffer), FreeMemorySvc (ppCtx)) - (*ppCtx)->pOut->uiSize = iCountBsLen; - (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); + (*ppCtx)->pOut->uiSize = iCountBsLen; + (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) - (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen"); + (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc (ppCtx)) - (*ppCtx)->pOut->iCountNals = iCountNals; - (*ppCtx)->pOut->iNalIndex = 0; + (*ppCtx)->pOut->iCountNals = iCountNals; + (*ppCtx)->pOut->iNalIndex = 0; if (pParam->iMultipleThreadIdc > 1) { const int32_t iTotalLength = iCountBsLen + (iTargetSpatialBsSize * ((*ppCtx)->iMaxSliceCount - 1)); - (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); + (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) (*ppCtx)->iFrameBsSize = iTotalLength; } else { - (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); + (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) - (*ppCtx)->iFrameBsSize = iCountBsLen; + (*ppCtx)->iFrameBsSize = iCountBsLen; } - (*ppCtx)->iPosBsBuffer = 0; + (*ppCtx)->iPosBsBuffer = 0; // for pSlice bs buffers if (pParam->iMultipleThreadIdc > 1 && RequestMtResource (ppCtx, pParam, iCountBsLen, iTargetSpatialBsSize)) { @@ -1825,12 +1824,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa (pMa->WelsMallocz (iCountMaxMbNum * 2 * MB_BLOCK8x8_NUM * sizeof (int8_t), "pRefIndexBlock4x4")); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pRefIndexBlock4x4), FreeMemorySvc (ppCtx)) - (*ppCtx)->pSadCostMb = static_cast + (*ppCtx)->pSadCostMb = static_cast (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSadCostMb), FreeMemorySvc (ppCtx)) (*ppCtx)->bEncCurFrmAsIdrFlag = true; // make sure first frame is IDR - (*ppCtx)->iGlobalQp = 26; // global qp in default + (*ppCtx)->iGlobalQp = 26; // global qp in default (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pLtr), FreeMemorySvc (ppCtx)) @@ -1839,14 +1838,14 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa ResetLtrState (& (*ppCtx)->pLtr[i]); } - (*ppCtx)->ppRefPicListExt = (SRefList**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SRefList*), "ppRefPicListExt"); + (*ppCtx)->ppRefPicListExt = (SRefList**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SRefList*), "ppRefPicListExt"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->ppRefPicListExt), FreeMemorySvc (ppCtx)) // pSlice context list - (*ppCtx)->pSliceCtxList = (SSliceCtx*)pMa->WelsMallocz (kiNumDependencyLayers * sizeof (SSliceCtx), "pSliceCtxList"); + (*ppCtx)->pSliceCtxList = (SSliceCtx*)pMa->WelsMallocz (kiNumDependencyLayers * sizeof (SSliceCtx), "pSliceCtxList"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceCtxList), FreeMemorySvc (ppCtx)) - (*ppCtx)->ppDqLayerList = (SDqLayer**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SDqLayer*), "ppDqLayerList"); + (*ppCtx)->ppDqLayerList = (SDqLayer**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SDqLayer*), "ppDqLayerList"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->ppDqLayerList), FreeMemorySvc (ppCtx)) // stride tables @@ -1864,7 +1863,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa //pVaa memory allocation if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { - (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); + (*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->iMaxNumRefFrame, iCountMaxMbNum << 2)) { WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!"); @@ -1872,7 +1871,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa return 1; } } else { - (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa"); + (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) } @@ -1929,9 +1928,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa int32_t iMvdRange = 0; GetMvMvdRange (pParam, (*ppCtx)->iMvRange, iMvdRange); - const uint32_t kuiMvdInterTableSize = (iMvdRange << 2); //intepel*4=qpel - const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); - const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t); + const uint32_t kuiMvdInterTableSize = (iMvdRange << 2); //intepel*4=qpel + const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); + const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t); (*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize; (*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride; @@ -1940,12 +1939,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place? if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL) - (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0]; + (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0]; else - (*ppCtx)->pDecPic = NULL; // error here + (*ppCtx)->pDecPic = NULL; // error here - (*ppCtx)->pSps = & (*ppCtx)->pSpsArray[0]; - (*ppCtx)->pPps = & (*ppCtx)->pPPSArray[0]; + (*ppCtx)->pSps = & (*ppCtx)->pSpsArray[0]; + (*ppCtx)->pPps = & (*ppCtx)->pPPSArray[0]; return 0; } @@ -1958,10 +1957,10 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa */ void FreeMemorySvc (sWelsEncCtx** ppCtx) { if (NULL != *ppCtx) { - sWelsEncCtx* pCtx = *ppCtx; - CMemoryAlign* pMa = pCtx->pMemAlign; + sWelsEncCtx* pCtx = *ppCtx; + CMemoryAlign* pMa = pCtx->pMemAlign; SWelsSvcCodingParam* pParam = pCtx->pSvcParam; - int32_t ilayer = 0; + int32_t ilayer = 0; // SStrideTables if (NULL != pCtx->pStrideTab) { @@ -2035,12 +2034,12 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { if (NULL != pCtx->pMvUnitBlock4x4) { pMa->WelsFree (pCtx->pMvUnitBlock4x4, "pMvUnitBlock4x4"); - pCtx->pMvUnitBlock4x4 = NULL; + pCtx->pMvUnitBlock4x4 = NULL; } if (NULL != pCtx->pRefIndexBlock4x4) { pMa->WelsFree (pCtx->pRefIndexBlock4x4, "pRefIndexBlock4x4"); - pCtx->pRefIndexBlock4x4 = NULL; + pCtx->pRefIndexBlock4x4 = NULL; } if (NULL != pCtx->ppMbListD) { @@ -2067,7 +2066,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { ilayer = 0; if (NULL != pCtx->ppDqLayerList && pParam != NULL) { while (ilayer < pParam->iSpatialLayerNum) { - SDqLayer* pDq = pCtx->ppDqLayerList[ilayer]; + SDqLayer* pDq = pCtx->ppDqLayerList[ilayer]; SSpatialLayerConfig* pDlp = &pCtx->pSvcParam->sSpatialLayers[ilayer]; const bool kbIsDynamicSlicing = (SM_DYN_SLICE == pDlp->sSliceCfg.uiSliceMode); @@ -2094,9 +2093,9 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { } if (kbIsDynamicSlicing) { pMa->WelsFree (pDq->pNumSliceCodedOfPartition, "pNumSliceCodedOfPartition"); - pDq->pNumSliceCodedOfPartition = NULL; + pDq->pNumSliceCodedOfPartition = NULL; pMa->WelsFree (pDq->pLastCodedMbIdxOfPartition, "pLastCodedMbIdxOfPartition"); - pDq->pLastCodedMbIdxOfPartition = NULL; + pDq->pLastCodedMbIdxOfPartition = NULL; pMa->WelsFree (pDq->pLastMbIdxOfPartition, "pLastMbIdxOfPartition"); pDq->pLastMbIdxOfPartition = NULL; } @@ -2120,7 +2119,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { if (NULL != pCtx->ppRefPicListExt && pParam != NULL) { ilayer = 0; while (ilayer < pParam->iSpatialLayerNum) { - SRefList* pRefList = pCtx->ppRefPicListExt[ilayer]; + SRefList* pRefList = pCtx->ppRefPicListExt[ilayer]; if (NULL != pRefList) { int32_t iRef = 0; do { @@ -2144,7 +2143,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { if (NULL != pCtx->pSliceCtxList && pParam != NULL) { ilayer = 0; while (ilayer < pParam->iSpatialLayerNum) { - SSliceCtx* pSliceCtx = &pCtx->pSliceCtxList[ilayer]; + SSliceCtx* pSliceCtx = &pCtx->pSliceCtxList[ilayer]; if (NULL != pSliceCtx) UninitSlicePEncCtx (pSliceCtx, pMa); ++ ilayer; @@ -2164,21 +2163,21 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { } pMa->WelsFree (pCtx->pVaa->pVaaBackgroundMbFlag, "pVaa->pVaaBackgroundMbFlag"); - pCtx->pVaa->pVaaBackgroundMbFlag = NULL; + pCtx->pVaa->pVaaBackgroundMbFlag = NULL; pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSad8x8, "pVaa->sVaaCalcInfo.sad8x8"); - pCtx->pVaa->sVaaCalcInfo.pSad8x8 = NULL; + pCtx->pVaa->sVaaCalcInfo.pSad8x8 = NULL; pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSsd16x16, "pVaa->sVaaCalcInfo.pSsd16x16"); - pCtx->pVaa->sVaaCalcInfo.pSsd16x16 = NULL; + pCtx->pVaa->sVaaCalcInfo.pSsd16x16 = NULL; pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSum16x16, "pVaa->sVaaCalcInfo.pSum16x16"); - pCtx->pVaa->sVaaCalcInfo.pSum16x16 = NULL; + pCtx->pVaa->sVaaCalcInfo.pSum16x16 = NULL; pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16, "pVaa->sVaaCalcInfo.pSumOfSquare16x16"); - pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16 = NULL; + pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16 = NULL; if (pCtx->pSvcParam->bEnableBackgroundDetection) { //BGD control pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8, "pVaa->sVaaCalcInfo.pSumOfDiff8x8"); - pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8 = NULL; + pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8 = NULL; pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8"); - pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; + pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; } if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iMaxNumRefFrame); @@ -2206,7 +2205,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { } #if defined(MEMORY_MONITOR) - assert (pMa->WelsGetMemoryUsage() == 0); // ensure all memory free well + assert (pMa->WelsGetMemoryUsage() == 0); // ensure all memory free well #endif//MEMORY_MONITOR if ((*ppCtx)->pMemAlign != NULL) { @@ -2227,22 +2226,22 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar uint16_t iMaxSliceCount = 0; do { - SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[iSpatialIdx]; - SSliceConfig* pMso = &pDlp->sSliceCfg; - SSliceArgument* pSlcArg = &pMso->sSliceArgument; - const int32_t kiMbWidth = (pDlp->iVideoWidth + 15) >> 4; - const int32_t kiMbHeight = (pDlp->iVideoHeight + 15) >> 4; - const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; - int32_t iSliceNum = (SM_AUTO_SLICE == pMso->uiSliceMode) ? kiCpuCores : pSlcArg->uiSliceNum; + SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[iSpatialIdx]; + SSliceConfig* pMso = &pDlp->sSliceCfg; + SSliceArgument* pSlcArg = &pMso->sSliceArgument; + const int32_t kiMbWidth = (pDlp->iVideoWidth + 15) >> 4; + const int32_t kiMbHeight = (pDlp->iVideoHeight + 15) >> 4; + const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; + int32_t iSliceNum = (SM_AUTO_SLICE == pMso->uiSliceMode) ? kiCpuCores : pSlcArg->uiSliceNum; // NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode, // uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_DYN_SLICE mode, // uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future - pSlcArg->uiSliceNum = iSliceNum; // used fixed one + pSlcArg->uiSliceNum = iSliceNum; // used fixed one switch (pMso->uiSliceMode) { case SM_DYN_SLICE: - iMaxSliceCount = AVERSLICENUM_CONSTRAINT; - break; // go through for SM_DYN_SLICE? + iMaxSliceCount = AVERSLICENUM_CONSTRAINT; + break; // go through for SM_DYN_SLICE? case SM_FIXEDSLCNUM_SLICE: if (iSliceNum > iMaxSliceCount) iMaxSliceCount = iSliceNum; @@ -2275,10 +2274,10 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar WelsLog (pLogCtx, WELS_LOG_DEBUG, "InitSliceSettings(), uiSliceNum(%d) you set for SM_AUTO_SLICE, now turn to SM_SINGLE_SLICE type!", pDlp->sSliceCfg.sSliceArgument.uiSliceNum); - pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; break; } - if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom + if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom //check uiSliceNum and set uiSliceMbNum with current uiSliceNum if (!GomValidCheckSliceNum (kiMbWidth, kiMbHeight, &pDlp->sSliceCfg.sSliceArgument.uiSliceNum)) { WelsLog (pLogCtx, WELS_LOG_WARNING, @@ -2293,18 +2292,18 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar return ENC_RETURN_INVALIDINPUT; } } else if (!CheckFixedSliceNumMultiSliceSetting (kiMbNumInFrame, - &pDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings + &pDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings //check uiSliceMbNum with current uiSliceNum WelsLog (pLogCtx, WELS_LOG_ERROR, "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type", pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); - pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; - pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; + pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; } // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting if (kiMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { - pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; - pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; + pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; + pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; break; } break; @@ -2315,13 +2314,13 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar ++ iSpatialIdx; } while (iSpatialIdx < iSpatialNum); - pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); - pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; + pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); + pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; if (pCodingParam->iLoopFilterDisableIdc == 0 && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled pCodingParam->iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading - *pMaxSliceCount = iMaxSliceCount; + *pMaxSliceCount = iMaxSliceCount; return ENC_RETURN_SUCCESS; } @@ -2379,9 +2378,8 @@ void OutputCpuFeaturesLog (SLogContext* pLogCtx, uint32_t uiCpuFeatureFlags, uin int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum, int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) { // for cpu features detection, Only detect once?? - int32_t uiCpuCores = - 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported - uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features + int32_t uiCpuCores = 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported + uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features #ifdef X86_ASM if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128) @@ -2389,12 +2387,12 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64) iCacheLineSize = 64; else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_32) - iCacheLineSize = 32; + iCacheLineSize = 32; else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_16) - iCacheLineSize = 16; + iCacheLineSize = 16; OutputCpuFeaturesLog (pLogCtx, uiCpuFeatureFlags, uiCpuCores, iCacheLineSize); #else - iCacheLineSize = 16; // 16 bytes aligned in default + iCacheLineSize = 16; // 16 bytes aligned in default #endif//X86_ASM #if defined(DYNAMIC_DETECT_CPU_CORES) @@ -2402,18 +2400,18 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding uiCpuCores = pCodingParam->iMultipleThreadIdc; else { if (uiCpuCores == - 0) // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor + 0) // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor uiCpuCores = DynamicDetectCpuCores(); // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, // for client application here it is constrained by maximal to MAX_THREADS_NUM - if (uiCpuCores > MAX_THREADS_NUM) // MAX_THREADS_NUM - uiCpuCores = MAX_THREADS_NUM; // MAX_THREADS_NUM - else if (uiCpuCores < 1) // just for safe - uiCpuCores = 1; + if (uiCpuCores > MAX_THREADS_NUM) // MAX_THREADS_NUM + uiCpuCores = MAX_THREADS_NUM; // MAX_THREADS_NUM + else if (uiCpuCores < 1) // just for safe + uiCpuCores = 1; } #endif//DYNAMIC_DETECT_CPU_CORES - uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); + uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); @@ -2430,10 +2428,10 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding */ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, SLogContext* pLogCtx, SExistingParasetList* pExistingParasetList) { - sWelsEncCtx* pCtx = NULL; - int32_t iRet = 0; - int16_t iSliceNum = 1; // number of slices used - int32_t iCacheLineSize = 16; // on chip cache line size in byte + sWelsEncCtx* pCtx = NULL; + int32_t iRet = 0; + int16_t iSliceNum = 1; // number of slices used + int32_t iCacheLineSize = 16; // on chip cache line size in byte uint32_t uiCpuFeatureFlags = 0; if (NULL == ppCtx || NULL == pCodingParam) { WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), NULL == ppCtx(0x%p) or NULL == pCodingParam(0x%p).", @@ -2441,12 +2439,12 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar return 1; } - iRet = ParamValidationExt (pLogCtx, pCodingParam); + iRet = ParamValidationExt (pLogCtx, pCodingParam); if (iRet != 0) { WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet); return iRet; } - iRet = pCodingParam->DetermineTemporalSettings(); + iRet = pCodingParam->DetermineTemporalSettings(); if (iRet != ENC_RETURN_SUCCESS) { WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting! -- in/out = 2^x, x <= temppral_layer_num)", @@ -2460,9 +2458,9 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar } - *ppCtx = NULL; + *ppCtx = NULL; - pCtx = static_cast (malloc (sizeof (sWelsEncCtx))); + pCtx = static_cast (malloc (sizeof (sWelsEncCtx))); WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)) memset (pCtx, 0, sizeof (sWelsEncCtx)); @@ -2477,7 +2475,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar FreeMemorySvc (&pCtx); return iRet; } - memcpy (pCtx->pSvcParam, pCodingParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage + memcpy (pCtx->pSvcParam, pCodingParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage pCtx->pFuncList = (SWelsFuncPtrList*)pCtx->pMemAlign->WelsMalloc (sizeof (SWelsFuncPtrList), "SWelsFuncPtrList"); if (NULL == pCtx->pFuncList) { @@ -2486,8 +2484,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar } InitFunctionPointers (pCtx, pCtx->pSvcParam, uiCpuFeatureFlags); - pCtx->iActiveThreadsNum = pCodingParam->iCountThreadsNum; - pCtx->iMaxSliceCount = iSliceNum; + pCtx->iActiveThreadsNum = pCodingParam->iCountThreadsNum; + pCtx->iMaxSliceCount = iSliceNum; iRet = RequestMemorySvc (&pCtx, pExistingParasetList); if (iRet != 0) { WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), RequestMemorySvc failed return %d.", iRet); @@ -2529,7 +2527,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar pCtx->iStatisticsLogInterval = STATISTICS_LOG_INTERVAL_MS; - *ppCtx = pCtx; + *ppCtx = pCtx; WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsInitEncoderExt(), pCtx= 0x%p.", (void*)pCtx); @@ -2554,7 +2552,7 @@ void StatOverallEncodingExt (sWelsEncCtx* pCtx) { if (iCount > 0) { int32_t iCountNumIMb = pCtx->sStatData[i][j].sSliceData.iMbCount[I_SLICE][Intra4x4] + pCtx->sStatData[i][j].sSliceData.iMbCount[I_SLICE][Intra16x16] + pCtx->sStatData[i][j].sSliceData.iMbCount[I_SLICE][7]; - int32_t iCountNumPMb = pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Intra4x4] + + int32_t iCountNumPMb = pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Intra4x4] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Intra16x16] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][7] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter16x16] + @@ -2563,7 +2561,7 @@ void StatOverallEncodingExt (sWelsEncCtx* pCtx) { pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter8x8] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][10] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][PSkip]; - int32_t count_p_mbL0 = pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter16x16] + + int32_t count_p_mbL0 = pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter16x16] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter16x8] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter8x16] + pCtx->sStatData[i][j].sSliceData.iMbCount[P_SLICE][Inter8x8] + @@ -2641,7 +2639,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) { WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]); WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]); - res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit + res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..", iThreadIdx, res); @@ -2664,22 +2662,22 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { * \brief get temporal level due to configuration and coding context */ int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize) { - const int32_t kiCodingIdx = kiFrameNum & (kiGopSize - 1); + const int32_t kiCodingIdx = kiFrameNum & (kiGopSize - 1); return fDlp->uiCodingIdx2TemporalId[kiCodingIdx]; } void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMbList) { - const int32_t kiMbWidth = pSliceCtx->iMbWidth; - const int32_t kiEndMbInSlice = pSliceCtx->iMbNumInFrame - 1; - int32_t iIdx = 0; + const int32_t kiMbWidth = pSliceCtx->iMbWidth; + const int32_t kiEndMbInSlice = pSliceCtx->iMbNumInFrame - 1; + int32_t iIdx = 0; do { SMB* pMb = &pMbList[iIdx]; - uint32_t uiNeighborAvailFlag = 0; - const int32_t kiMbXY = pMb->iMbXY; - const int32_t kiMbX = pMb->iMbX; - const int32_t kiMbY = pMb->iMbY; + uint32_t uiNeighborAvailFlag = 0; + const int32_t kiMbXY = pMb->iMbXY; + const int32_t kiMbX = pMb->iMbX; + const int32_t kiMbY = pMb->iMbY; bool bLeft; bool bTop; bool bLeftTop; @@ -2688,7 +2686,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; uiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); - pMb->uiSliceIdc = uiSliceIdc; + pMb->uiSliceIdc = uiSliceIdc; iLeftXY = kiMbXY - 1; iTopXY = kiMbXY - kiMbWidth; iLeftTopXY = iTopXY - 1; @@ -2711,7 +2709,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb if (bRightTop) { uiNeighborAvailFlag |= TOPRIGHT_MB_POS; } - pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; + pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; ++ iIdx; } while (iIdx <= kiEndMbInSlice); @@ -2721,64 +2719,64 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb * TUNE back if number of picture partition decision algorithm based on past if available */ int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { - int32_t iPartitionNum = 1; + int32_t iPartitionNum = 1; if (pCtx->pSvcParam->iMultipleThreadIdc > 1) { - iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; + iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; } return iPartitionNum; } void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { //pData init - SDqLayer* pCurDq = pCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = (pCurDq->pSliceEncCtx); + SDqLayer* pCurDq = pCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = (pCurDq->pSliceEncCtx); //mb_neighbor DynslcUpdateMbNeighbourInfoListForAllSlices (pSliceCtx, pCurDq->sMbDataP); } void UpdateSlicepEncCtxWithPartition (SSliceCtx* pSliceCtx, int32_t iPartitionNum) { - const int32_t kiMbNumInFrame = pSliceCtx->iMbNumInFrame; - int32_t iCountMbNumPerPartition = kiMbNumInFrame; - int32_t iAssignableMbLeft = kiMbNumInFrame; - int32_t iFirstMbIdx = 0; + const int32_t kiMbNumInFrame = pSliceCtx->iMbNumInFrame; + int32_t iCountMbNumPerPartition = kiMbNumInFrame; + int32_t iAssignableMbLeft = kiMbNumInFrame; + int32_t iFirstMbIdx = 0; int32_t i/*, j*/; if (iPartitionNum <= 0) - iPartitionNum = 1; + iPartitionNum = 1; else if (iPartitionNum > AVERSLICENUM_CONSTRAINT) - iPartitionNum = AVERSLICENUM_CONSTRAINT; // AVERSLICENUM_CONSTRAINT might be variable, however not fixed by MACRO - iCountMbNumPerPartition /= iPartitionNum; - pSliceCtx->iSliceNumInFrame = iPartitionNum; + iPartitionNum = AVERSLICENUM_CONSTRAINT; // AVERSLICENUM_CONSTRAINT might be variable, however not fixed by MACRO + iCountMbNumPerPartition /= iPartitionNum; + pSliceCtx->iSliceNumInFrame = iPartitionNum; i = 0; while (i < iPartitionNum) { if (i + 1 == iPartitionNum) { - pSliceCtx->pCountMbNumInSlice[i] = iAssignableMbLeft; + pSliceCtx->pCountMbNumInSlice[i] = iAssignableMbLeft; } else { - pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; + pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; } - pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; + pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i, pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t)); // for next partition(or pSlice) - iFirstMbIdx += pSliceCtx->pCountMbNumInSlice[i]; + iFirstMbIdx += pSliceCtx->pCountMbNumInSlice[i]; iAssignableMbLeft -= pSliceCtx->pCountMbNumInSlice[i]; ++ i; } } void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) { - SDqLayer* pCurDq = pCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; + SDqLayer* pCurDq = pCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; UpdateSlicepEncCtxWithPartition (pSliceCtx, iPartitionNum); if (I_SLICE == pCtx->eSliceType) { //check if uiSliceSizeConstraint too small #define byte_complexIMBat26 (60) - uint8_t iCurDid = pCtx->uiDependencyId; - uint32_t uiFrmByte = 0; + uint8_t iCurDid = pCtx->uiDependencyId; + uint32_t uiFrmByte = 0; if (pCtx->pSvcParam->iRCMode != RC_OFF_MODE) { //RC case @@ -2826,27 +2824,27 @@ void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) { void WelsInitCurrentLayer (sWelsEncCtx* pCtx, const int32_t kiWidth, const int32_t kiHeight) { - SWelsSvcCodingParam* pParam = pCtx->pSvcParam; - SPicture* pEncPic = pCtx->pEncPic; - SPicture* pDecPic = pCtx->pDecPic; - SDqLayer* pCurDq = pCtx->pCurDqLayer; - SSlice* pBaseSlice = &pCurDq->sLayerInfo.pSliceInLayer[0]; - SSlice* pSlice = NULL; - const uint8_t kiCurDid = pCtx->uiDependencyId; + SWelsSvcCodingParam* pParam = pCtx->pSvcParam; + SPicture* pEncPic = pCtx->pEncPic; + SPicture* pDecPic = pCtx->pDecPic; + SDqLayer* pCurDq = pCtx->pCurDqLayer; + SSlice* pBaseSlice = &pCurDq->sLayerInfo.pSliceInLayer[0]; + SSlice* pSlice = NULL; + const uint8_t kiCurDid = pCtx->uiDependencyId; const bool kbUseSubsetSpsFlag = (!pParam->bSimulcastAVC) && (kiCurDid > BASE_DEPENDENCY_ID); - SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[kiCurDid]; - SNalUnitHeaderExt* pNalHdExt = &pCurDq->sLayerInfo.sNalHeaderExt; - SNalUnitHeader* pNalHd = &pNalHdExt->sNalUnitHeader; - SDqIdc* pDqIdc = &pCtx->pDqIdcMap[kiCurDid]; - int32_t iIdx = 0; - int32_t iSliceCount = 0; + SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[kiCurDid]; + SNalUnitHeaderExt* pNalHdExt = &pCurDq->sLayerInfo.sNalHeaderExt; + SNalUnitHeader* pNalHd = &pNalHdExt->sNalUnitHeader; + SDqIdc* pDqIdc = &pCtx->pDqIdcMap[kiCurDid]; + int32_t iIdx = 0; + int32_t iSliceCount = 0; if (NULL == pCurDq) return; - pCurDq->pDecPic = pDecPic; + pCurDq->pDecPic = pDecPic; - if (fDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE) // need get extra slices for update + if (fDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE) // need get extra slices for update iSliceCount = GetInitialSliceNum (pCurDq->iMbWidth, pCurDq->iMbHeight, &fDlp->sSliceCfg); else iSliceCount = GetCurrentSliceNum (pCurDq->pSliceEncCtx); @@ -2859,71 +2857,71 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, iCurPpsId = pCtx->sPSOVector.iPpsIdList[pDqIdc->iPpsId][WELS_ABS (pCtx->uiIdrPicId - 1) % MAX_PPS_COUNT]; } - pBaseSlice->sSliceHeaderExt.sSliceHeader.iPpsId = iCurPpsId; - pCurDq->sLayerInfo.pPpsP = - pBaseSlice->sSliceHeaderExt.sSliceHeader.pPps = &pCtx->pPPSArray[iCurPpsId]; + pBaseSlice->sSliceHeaderExt.sSliceHeader.iPpsId = iCurPpsId; + pCurDq->sLayerInfo.pPpsP = + pBaseSlice->sSliceHeaderExt.sSliceHeader.pPps = &pCtx->pPPSArray[iCurPpsId]; - pBaseSlice->sSliceHeaderExt.sSliceHeader.iSpsId = iCurSpsId; + pBaseSlice->sSliceHeaderExt.sSliceHeader.iSpsId = iCurSpsId; if (kbUseSubsetSpsFlag) { - pCurDq->sLayerInfo.pSubsetSpsP = &pCtx->pSubsetArray[iCurSpsId]; - pCurDq->sLayerInfo.pSpsP = - pBaseSlice->sSliceHeaderExt.sSliceHeader.pSps = &pCurDq->sLayerInfo.pSubsetSpsP->pSps; + pCurDq->sLayerInfo.pSubsetSpsP = &pCtx->pSubsetArray[iCurSpsId]; + pCurDq->sLayerInfo.pSpsP = + pBaseSlice->sSliceHeaderExt.sSliceHeader.pSps = &pCurDq->sLayerInfo.pSubsetSpsP->pSps; } else { - pCurDq->sLayerInfo.pSubsetSpsP = NULL; - pCurDq->sLayerInfo.pSpsP = - pBaseSlice->sSliceHeaderExt.sSliceHeader.pSps = &pCtx->pSpsArray[iCurSpsId]; + pCurDq->sLayerInfo.pSubsetSpsP = NULL; + pCurDq->sLayerInfo.pSpsP = + pBaseSlice->sSliceHeaderExt.sSliceHeader.pSps = &pCtx->pSpsArray[iCurSpsId]; } pSlice = pBaseSlice; iIdx = 1; while (iIdx < iSliceCount) { ++ pSlice; - pSlice->sSliceHeaderExt.sSliceHeader.iPpsId = pBaseSlice->sSliceHeaderExt.sSliceHeader.iPpsId; - pSlice->sSliceHeaderExt.sSliceHeader.pPps = pBaseSlice->sSliceHeaderExt.sSliceHeader.pPps; - pSlice->sSliceHeaderExt.sSliceHeader.iSpsId = pBaseSlice->sSliceHeaderExt.sSliceHeader.iSpsId; - pSlice->sSliceHeaderExt.sSliceHeader.pSps = pBaseSlice->sSliceHeaderExt.sSliceHeader.pSps; + pSlice->sSliceHeaderExt.sSliceHeader.iPpsId = pBaseSlice->sSliceHeaderExt.sSliceHeader.iPpsId; + pSlice->sSliceHeaderExt.sSliceHeader.pPps = pBaseSlice->sSliceHeaderExt.sSliceHeader.pPps; + pSlice->sSliceHeaderExt.sSliceHeader.iSpsId = pBaseSlice->sSliceHeaderExt.sSliceHeader.iSpsId; + pSlice->sSliceHeaderExt.sSliceHeader.pSps = pBaseSlice->sSliceHeaderExt.sSliceHeader.pSps; ++ iIdx; } memset (pNalHdExt, 0, sizeof (SNalUnitHeaderExt)); - pNalHd->uiNalRefIdc = pCtx->eNalPriority; - pNalHd->eNalUnitType = pCtx->eNalType; + pNalHd->uiNalRefIdc = pCtx->eNalPriority; + pNalHd->eNalUnitType = pCtx->eNalType; - pNalHdExt->uiDependencyId = kiCurDid; - pNalHdExt->bDiscardableFlag = (pCtx->bNeedPrefixNalFlag) ? (pNalHd->uiNalRefIdc == NRI_PRI_LOWEST) : false; - pNalHdExt->bIdrFlag = (pCtx->iFrameNum == 0) && ((pCtx->eNalType == NAL_UNIT_CODED_SLICE_IDR) - || (pCtx->eSliceType == I_SLICE)); - pNalHdExt->uiTemporalId = pCtx->uiTemporalId; + pNalHdExt->uiDependencyId = kiCurDid; + pNalHdExt->bDiscardableFlag = (pCtx->bNeedPrefixNalFlag) ? (pNalHd->uiNalRefIdc == NRI_PRI_LOWEST) : false; + pNalHdExt->bIdrFlag = (pCtx->iFrameNum == 0) && ((pCtx->eNalType == NAL_UNIT_CODED_SLICE_IDR) + || (pCtx->eSliceType == I_SLICE)); + pNalHdExt->uiTemporalId = pCtx->uiTemporalId; - pBaseSlice->bSliceHeaderExtFlag = (NAL_UNIT_CODED_SLICE_EXT == pNalHd->eNalUnitType); + pBaseSlice->bSliceHeaderExtFlag = (NAL_UNIT_CODED_SLICE_EXT == pNalHd->eNalUnitType); pSlice = pBaseSlice; iIdx = 1; while (iIdx < iSliceCount) { ++ pSlice; - pSlice->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; + pSlice->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; ++ iIdx; } // pEncPic pData - pCurDq->pEncData[0] = pEncPic->pData[0]; - pCurDq->pEncData[1] = pEncPic->pData[1]; - pCurDq->pEncData[2] = pEncPic->pData[2]; - pCurDq->iEncStride[0] = pEncPic->iLineSize[0]; - pCurDq->iEncStride[1] = pEncPic->iLineSize[1]; - pCurDq->iEncStride[2] = pEncPic->iLineSize[2]; + pCurDq->pEncData[0] = pEncPic->pData[0]; + pCurDq->pEncData[1] = pEncPic->pData[1]; + pCurDq->pEncData[2] = pEncPic->pData[2]; + pCurDq->iEncStride[0] = pEncPic->iLineSize[0]; + pCurDq->iEncStride[1] = pEncPic->iLineSize[1]; + pCurDq->iEncStride[2] = pEncPic->iLineSize[2]; // cs pData - pCurDq->pCsData[0] = pDecPic->pData[0]; - pCurDq->pCsData[1] = pDecPic->pData[1]; - pCurDq->pCsData[2] = pDecPic->pData[2]; - pCurDq->iCsStride[0] = pDecPic->iLineSize[0]; - pCurDq->iCsStride[1] = pDecPic->iLineSize[1]; - pCurDq->iCsStride[2] = pDecPic->iLineSize[2]; + pCurDq->pCsData[0] = pDecPic->pData[0]; + pCurDq->pCsData[1] = pDecPic->pData[1]; + pCurDq->pCsData[2] = pDecPic->pData[2]; + pCurDq->iCsStride[0] = pDecPic->iLineSize[0]; + pCurDq->iCsStride[1] = pDecPic->iLineSize[1]; + pCurDq->iCsStride[2] = pDecPic->iLineSize[2]; if (pCurDq->pRefLayer != NULL) { - pCurDq->bBaseLayerAvailableFlag = true; + pCurDq->bBaseLayerAvailableFlag = true; } else { - pCurDq->bBaseLayerAvailableFlag = false; + pCurDq->bBaseLayerAvailableFlag = false; } } @@ -2970,9 +2968,9 @@ bool SetMeMethod (const uint8_t uiMethod, PSearchMethodFunc& pSearchMethodFunc) void PreprocessSliceCoding (sWelsEncCtx* pCtx) { - SDqLayer* pCurLayer = pCtx->pCurDqLayer; - //const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; - const bool kbHighestSpatialLayer = + SDqLayer* pCurLayer = pCtx->pCurDqLayer; + //const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; + const bool kbHighestSpatialLayer = (pCtx->pSvcParam->iSpatialLayerNum == (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1)); SWelsFuncPtrList* pFuncList = pCtx->pFuncList; SLogContext* pLogCtx = & (pCtx->sLogCtx); @@ -3019,7 +3017,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { pFuncList->pfInterFineMd = WelsMdInterFinePartitionVaaOnScreen; //ME related func pointers - SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); if (pVaaExt->sScrollDetectInfo.bScrollDetectFlag && (pVaaExt->sScrollDetectInfo.iScrollMvX | pVaaExt->sScrollDetectInfo.iScrollMvY)) { pFuncList->pfSetScrollingMv = SetScrollingMvToMd; @@ -3040,7 +3038,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { pFeatureSearchPreparation->iHighFreMbCount = 0; //calculate bFMESwitchFlag - SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); const int32_t kiMbSize = pCurLayer->iMbHeight * pCurLayer->iMbWidth; pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag (pFeatureSearchPreparation->uiFMEGoodFrameCount, pFeatureSearchPreparation->iHighFreMbCount * 100 / kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad / kiMbSize, @@ -3090,13 +3088,13 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { static inline void WelsSwapDqLayers (sWelsEncCtx* pCtx) { // swap and assign reference - const int32_t kiDid = pCtx->uiDependencyId; - const int32_t kiNextDqIdx = 1 + kiDid; + const int32_t kiDid = pCtx->uiDependencyId; + const int32_t kiNextDqIdx = 1 + kiDid; - SDqLayer* pTmpLayer = pCtx->ppDqLayerList[kiNextDqIdx]; - SDqLayer* pRefLayer = pCtx->pCurDqLayer; - pCtx->pCurDqLayer = pTmpLayer; - pCtx->pCurDqLayer->pRefLayer = pRefLayer; + SDqLayer* pTmpLayer = pCtx->ppDqLayerList[kiNextDqIdx]; + SDqLayer* pRefLayer = pCtx->pCurDqLayer; + pCtx->pCurDqLayer = pTmpLayer; + pCtx->pCurDqLayer->pRefLayer = pRefLayer; } /*! @@ -3111,17 +3109,17 @@ static inline void PrefetchReferencePicture (sWelsEncCtx* pCtx, const EVideoFram assert (kiSliceCount > 0); if (keFrameType != videoFrameTypeIDR) { assert (pCtx->iNumRef0 > 0); - pCtx->pRefPic = pCtx->pRefList0[0]; // always get item 0 due to reordering done - pCtx->pCurDqLayer->pRefPic = pCtx->pRefPic; - uiRefIdx = 0; // reordered reference iIndex - } else { // safe for IDR coding - pCtx->pRefPic = NULL; - pCtx->pCurDqLayer->pRefPic = NULL; + pCtx->pRefPic = pCtx->pRefList0[0]; // always get item 0 due to reordering done + pCtx->pCurDqLayer->pRefPic = pCtx->pRefPic; + uiRefIdx = 0; // reordered reference iIndex + } else { // safe for IDR coding + pCtx->pRefPic = NULL; + pCtx->pCurDqLayer->pRefPic = NULL; } iIdx = 0; while (iIdx < kiSliceCount) { - pSliceBase->sSliceHeaderExt.sSliceHeader.uiRefIndex = uiRefIdx; + pSliceBase->sSliceHeaderExt.sSliceHeader.uiRefIndex = uiRefIdx; ++ pSliceBase; ++ iIdx; } @@ -3132,23 +3130,23 @@ void ParasetIdAdditionIdAdjust (SParaSetOffsetVariable* sParaSetOffsetVariable, const uint32_t kuiMaxIdInBs) { //paraset_type = 0: SPS; =1: PPS //SPS_ID in avc_sps and pSubsetSps will be different using this //SPS_ID case example: - //1st enter: next_spsid_in_bs == 0; spsid == 0; delta==0; //actual spsid_in_bs == 0 - //1st finish: next_spsid_in_bs == 1; - //2nd enter: next_spsid_in_bs == 1; spsid == 0; delta==1; //actual spsid_in_bs == 1 - //2nd finish: next_spsid_in_bs == 2; - //31st enter: next_spsid_in_bs == 31; spsid == 0~2; delta==31~29; //actual spsid_in_bs == 31 - //31st finish: next_spsid_in_bs == 0; - //31st enter: next_spsid_in_bs == 0; spsid == 0~2; delta==-2~0; //actual spsid_in_bs == 0 - //31st finish: next_spsid_in_bs == 1; + //1st enter: next_spsid_in_bs == 0; spsid == 0; delta==0; //actual spsid_in_bs == 0 + //1st finish: next_spsid_in_bs == 1; + //2nd enter: next_spsid_in_bs == 1; spsid == 0; delta==1; //actual spsid_in_bs == 1 + //2nd finish: next_spsid_in_bs == 2; + //31st enter: next_spsid_in_bs == 31; spsid == 0~2; delta==31~29; //actual spsid_in_bs == 31 + //31st finish:next_spsid_in_bs == 0; + //31st enter: next_spsid_in_bs == 0; spsid == 0~2; delta==-2~0; //actual spsid_in_bs == 0 + //31st finish:next_spsid_in_bs == 1; - const int32_t kiEncId = kiCurEncoderParaSetId; - uint32_t uiNextIdInBs = sParaSetOffsetVariable->uiNextParaSetIdToUseInBs; + const int32_t kiEncId = kiCurEncoderParaSetId; + uint32_t uiNextIdInBs = sParaSetOffsetVariable->uiNextParaSetIdToUseInBs; //update current layer's pCodingParam - sParaSetOffsetVariable->iParaSetIdDelta[kiEncId] = uiNextIdInBs - + sParaSetOffsetVariable->iParaSetIdDelta[kiEncId] = uiNextIdInBs - kiEncId; //for current parameter set, change its id_delta //write pso pData for next update: - sParaSetOffsetVariable->bUsedParaSetIdInBs[uiNextIdInBs] = true; // update current used_id + sParaSetOffsetVariable->bUsedParaSetIdInBs[uiNextIdInBs] = true; // update current used_id //prepare for next update: // find the next avaibable iId @@ -3161,7 +3159,7 @@ void ParasetIdAdditionIdAdjust (SParaSetOffsetVariable* sParaSetOffsetVariable, } int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNalSize) { - int iNal = pCtx->pOut->iNalIndex; + int iNal = pCtx->pOut->iNalIndex; WelsLoadNal (pCtx->pOut, NAL_UNIT_SPS, NRI_PRI_HIGHEST); WelsWriteSpsNal (&pCtx->pSpsArray[kiSpsIdx], &pCtx->pOut->sBsWrite, @@ -3174,13 +3172,13 @@ int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNa &iNalSize); WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) - pCtx->iPosBsBuffer += iNalSize; + pCtx->iPosBsBuffer += iNalSize; return ENC_RETURN_SUCCESS; } int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNalSize) { //TODO - int32_t iNal = pCtx->pOut->iNalIndex; + int32_t iNal = pCtx->pOut->iNalIndex; /* generate picture parameter set */ WelsLoadNal (pCtx->pOut, NAL_UNIT_PPS, NRI_PRI_HIGHEST); WelsWritePpsSyntax (&pCtx->pPPSArray[kiPpsIdx], &pCtx->pOut->sBsWrite, @@ -3193,7 +3191,7 @@ int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNa &iNalSize); WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) - pCtx->iPosBsBuffer += iNalSize; + pCtx->iPosBsBuffer += iNalSize; return ENC_RETURN_SUCCESS; } @@ -3225,12 +3223,12 @@ void UpdatePpsList (sWelsEncCtx* pCtx) { * \return writing results, success or error */ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pNumNal, int32_t* pTotalLength) { - int32_t iSize = 0; - int32_t iNal = 0; - int32_t iIdx = 0; - int32_t iId = 0; - int32_t iCountNal = 0; - int32_t iNalLength = 0; + int32_t iSize = 0; + int32_t iNal = 0; + int32_t iIdx = 0; + int32_t iId = 0; + int32_t iCountNal = 0; + int32_t iNalLength = 0; int32_t iReturn = ENC_RETURN_SUCCESS; if (NULL == pCtx || NULL == pNalLen || NULL == pNumNal) @@ -3255,12 +3253,12 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN } /* generate sequence parameters set */ - iId = (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy) ? iIdx : 0; + iId = (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy) ? iIdx : 0; WelsWriteOneSPS (pCtx, iId, iNalLength); pNalLen[iCountNal] = iNalLength; - iSize += iNalLength; + iSize += iNalLength; ++ iIdx; ++ iCountNal; @@ -3269,7 +3267,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN /* write all Subset SPS */ iIdx = 0; while (iIdx < pCtx->iSubsetSpsNum) { - iNal = pCtx->pOut->iNalIndex; + iNal = pCtx->pOut->iNalIndex; if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) { #if _DEBUG @@ -3282,7 +3280,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN MAX_SPS_COUNT); } - iId = iIdx; + iId = iIdx; /* generate Subset SPS */ WelsLoadNal (pCtx->pOut, NAL_UNIT_SUBSET_SPS, NRI_PRI_HIGHEST); @@ -3298,8 +3296,8 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) pNalLen[iCountNal] = iNalLength; - pCtx->iPosBsBuffer += iNalLength; - iSize += iNalLength; + pCtx->iPosBsBuffer += iNalLength; + iSize += iNalLength; ++ iIdx; ++ iCountNal; @@ -3321,7 +3319,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN WelsWriteOnePPS (pCtx, iIdx, iNalLength); pNalLen[iCountNal] = iNalLength; - iSize += iNalLength; + iSize += iNalLength; ++ iIdx; ++ iCountNal; @@ -3358,7 +3356,7 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) iPayloadSize = pNalLen[*pNalIdxInLayer]; - pCtx->iPosBsBuffer += iPayloadSize; + pCtx->iPosBsBuffer += iPayloadSize; (*pNalIdxInLayer) ++; } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension @@ -3374,7 +3372,7 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) iPayloadSize = pNalLen[*pNalIdxInLayer]; - pCtx->iPosBsBuffer += iPayloadSize; + pCtx->iPosBsBuffer += iPayloadSize; (*pNalIdxInLayer) ++; } @@ -3384,13 +3382,13 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { int32_t i = 0; - int32_t iNal = 0; - SBitStringAux* pBs = NULL; + int32_t iNal = 0; + SBitStringAux* pBs = NULL; int32_t iNalLen; iSize = 0; - iNal = pCtx->pOut->iNalIndex; - pBs = &pCtx->pOut->sBsWrite; // SBitStringAux instance for non VCL NALs decoding + iNal = pCtx->pOut->iNalIndex; + pBs = &pCtx->pOut->sBsWrite; // SBitStringAux instance for non VCL NALs decoding if ((pBs->pEndBuf - pBs->pCurBuf) < iLen || iNal >= pCtx->pOut->iCountNals) { #if GOM_TRACE_FLAG @@ -3416,8 +3414,8 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { &iNalLen); WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) - pCtx->iPosBsBuffer += iNalLen; - iSize += iNalLen; + pCtx->iPosBsBuffer += iNalLen; + iSize += iNalLen; return ENC_RETURN_SUCCESS; } @@ -3430,7 +3428,7 @@ int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { return 1; pCtx->bEncCurFrmAsIdrFlag = true; - pCtx->iCodingIndex = 0; + pCtx->iCodingIndex = 0; pCtx->bCheckWindowStatusRefreshFlag = false; return 0; } @@ -3487,15 +3485,15 @@ int32_t WriteSsvcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal, &iNonVclSize); WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) - pLayerBsInfo->uiSpatialId = 0; - pLayerBsInfo->uiTemporalId = 0; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; - pLayerBsInfo->iNalCount = iCountNal; + pLayerBsInfo->uiSpatialId = 0; + pLayerBsInfo->uiTemporalId = 0; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; + pLayerBsInfo->iNalCount = iCountNal; //point to next pLayerBsInfo ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; //update for external countings ++ iLayerNum; @@ -3524,15 +3522,15 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, iCountNal = 1; //finish writing one NAL - pLayerBsInfo->uiSpatialId = iIdx; - pLayerBsInfo->uiTemporalId = 0; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; - pLayerBsInfo->iNalCount = iCountNal; + pLayerBsInfo->uiSpatialId = iIdx; + pLayerBsInfo->uiTemporalId = 0; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; + pLayerBsInfo->iNalCount = iCountNal; //point to next pLayerBsInfo ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; //update for external countings iCountNal = 0; @@ -3555,15 +3553,15 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, iCountNal = 1; //finish writing one NAL - pLayerBsInfo->uiSpatialId = iIdx; - pLayerBsInfo->uiTemporalId = 0; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; - pLayerBsInfo->iNalCount = iCountNal; + pLayerBsInfo->uiSpatialId = iIdx; + pLayerBsInfo->uiTemporalId = 0; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; + pLayerBsInfo->iNalCount = iCountNal; //point to next pLayerBsInfo ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; //update for external countings iCountNal = 0; @@ -3603,15 +3601,15 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, //finish writing one NAL } - pLayerBsInfo->uiSpatialId = iSpatialId; - pLayerBsInfo->uiTemporalId = 0; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; - pLayerBsInfo->iNalCount = iCountNal; + pLayerBsInfo->uiSpatialId = iSpatialId; + pLayerBsInfo->uiTemporalId = 0; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; + pLayerBsInfo->iNalCount = iCountNal; //point to next pLayerBsInfo ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; //update for external countings iCountNal = 0; @@ -3638,15 +3636,15 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, //finish writing one NAL } - pLayerBsInfo->uiSpatialId = iSpatialId; - pLayerBsInfo->uiTemporalId = 0; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; - pLayerBsInfo->iNalCount = iCountNal; + pLayerBsInfo->uiSpatialId = iSpatialId; + pLayerBsInfo->uiTemporalId = 0; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; + pLayerBsInfo->iNalCount = iCountNal; //point to next pLayerBsInfo ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; //update for external countings iCountNal = 0; @@ -3676,29 +3674,29 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour if (pCtx == NULL) { return ENC_RETURN_MEMALLOCERR; } - SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; - SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; + SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; + SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0]; #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) - SPicture* fsnr = NULL; + SPicture* fsnr = NULL; #endif//ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC - SPicture* pEncPic = NULL; // to be decided later - int32_t iDidList[MAX_DEPENDENCY_LAYER] = {0}; - int32_t iLayerNum = 0; - int32_t iLayerSize = 0; - int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame - int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame - int32_t iFrameSize = 0; - int32_t iNalIdxInLayer = 0; - int32_t iCountNal = 0; - EVideoFrameType eFrameType = videoFrameTypeInvalid; - int32_t iCurWidth = 0; - int32_t iCurHeight = 0; - EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; - EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; - int8_t iCurDid = 0; - int8_t iCurTid = 0; - bool bAvcBased = false; + SPicture* pEncPic = NULL; // to be decided later + int32_t iDidList[MAX_DEPENDENCY_LAYER] = {0}; + int32_t iLayerNum = 0; + int32_t iLayerSize = 0; + int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame + int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame + int32_t iFrameSize = 0; + int32_t iNalIdxInLayer = 0; + int32_t iCountNal = 0; + EVideoFrameType eFrameType = videoFrameTypeInvalid; + int32_t iCurWidth = 0; + int32_t iCurHeight = 0; + EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; + EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; + int8_t iCurDid = 0; + int8_t iCurTid = 0; + bool bAvcBased = false; SLogContext* pLogCtx = & (pCtx->sLogCtx); #if defined(ENABLE_PSNR_CALC) float fSnrY = .0f, fSnrU = .0f, fSnrV = .0f; @@ -3708,9 +3706,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour int32_t i = 0, j = 0, k = 0; #endif//_DEBUG - pCtx->iEncoderError = ENC_RETURN_SUCCESS; - pCtx->bCurFrameMarkedAsSceneLtr = false; - pFbi->iLayerNum = 0; // for initialization + pCtx->iEncoderError = ENC_RETURN_SUCCESS; + pCtx->bCurFrameMarkedAsSceneLtr = false; + pFbi->iLayerNum = 0; // for initialization pFbi->uiTimeStamp = pSrcPic->uiTimeStamp; // perform csc/denoise/downsample/padding, generate spatial layers iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic); @@ -3718,7 +3716,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pSrcPic->uiTimeStamp); } - if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate) + if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate) ++ pCtx->iCodingIndex; pFbi->eFrameType = videoFrameTypeSkip; WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, @@ -3754,11 +3752,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour pCtx->iContinualSkipFrames = 0; InitFrameCoding (pCtx, eFrameType); - iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex, + iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex, pSvcParam->uiGopSize); - pCtx->uiTemporalId = iCurTid; + pCtx->uiTemporalId = iCurTid; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; if (eFrameType == videoFrameTypeIDR) { @@ -3775,24 +3773,24 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) } - pCtx->pCurDqLayer = pCtx->ppDqLayerList[pSpatialIndexMap->iDid]; - pCtx->pCurDqLayer->pRefLayer = NULL; + pCtx->pCurDqLayer = pCtx->ppDqLayerList[pSpatialIndexMap->iDid]; + pCtx->pCurDqLayer->pRefLayer = NULL; while (iSpatialIdx < iSpatialNum) { - const int32_t iDidIdx = (pSpatialIndexMap + iSpatialIdx)->iDid; // get iDid - SSpatialLayerConfig* pParam = &pSvcParam->sSpatialLayers[iDidIdx]; + const int32_t iDidIdx = (pSpatialIndexMap + iSpatialIdx)->iDid; // get iDid + SSpatialLayerConfig* pParam = &pSvcParam->sSpatialLayers[iDidIdx]; - pCtx->uiDependencyId = iCurDid = (int8_t)iDidIdx; + pCtx->uiDependencyId = iCurDid = (int8_t)iDidIdx; pCtx->pVpp->AnalyzeSpatialPic (pCtx, iDidIdx); - pCtx->pEncPic = pEncPic = (pSpatialIndexMap + iSpatialIdx)->pSrc; - pCtx->pEncPic->iPictureType = pCtx->eSliceType; - pCtx->pEncPic->iFramePoc = pCtx->iPOC; + pCtx->pEncPic = pEncPic = (pSpatialIndexMap + iSpatialIdx)->pSrc; + pCtx->pEncPic->iPictureType = pCtx->eSliceType; + pCtx->pEncPic->iFramePoc = pCtx->iPOC; - iCurWidth = pParam->iVideoWidth; - iCurHeight = pParam->iVideoHeight; + iCurWidth = pParam->iVideoWidth; + iCurHeight = pParam->iVideoHeight; - iDidList[iSpatialIdx] = iCurDid; + iDidList[iSpatialIdx] = iCurDid; // Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed switch (pParam->sSliceCfg.uiSliceMode) { @@ -3808,8 +3806,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour case SM_DYN_SLICE: { int32_t iPicIPartitionNum = PicPartitionNumDecision (pCtx); // MT compatibility - pCtx->iActiveThreadsNum = - iPicIPartitionNum; // we try to active number of threads, equal to number of picture partitions + pCtx->iActiveThreadsNum = + iPicIPartitionNum; // we try to active number of threads, equal to number of picture partitions WelsInitCurrentDlayerMltslc (pCtx, iPicIPartitionNum); break; } @@ -3819,41 +3817,41 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour } /* coding each spatial layer, only one sQualityStat layer within spatial support */ - int32_t iSliceCount = 1; - if (iLayerNum >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info writing as follows + int32_t iSliceCount = 1; + if (iLayerNum >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info writing as follows WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d)!", iLayerNum, MAX_LAYER_NUM_OF_FRAME); return ENC_RETURN_UNSUPPORTED_PARA; } - iNalIdxInLayer = 0; - bAvcBased = ((pSvcParam->bSimulcastAVC) || (iCurDid == BASE_DEPENDENCY_ID)); - pCtx->bNeedPrefixNalFlag = ((!pSvcParam->bSimulcastAVC) && (bAvcBased && + iNalIdxInLayer = 0; + bAvcBased = ((pSvcParam->bSimulcastAVC) || (iCurDid == BASE_DEPENDENCY_ID)); + pCtx->bNeedPrefixNalFlag = ((!pSvcParam->bSimulcastAVC) && (bAvcBased && (pSvcParam->bPrefixNalAddingCtrl || (pSvcParam->iSpatialLayerNum > 1)))); if (eFrameType == videoFrameTypeP) { - eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT; + eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT; } else if (eFrameType == videoFrameTypeIDR) { - eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE_IDR : NAL_UNIT_CODED_SLICE_EXT; + eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE_IDR : NAL_UNIT_CODED_SLICE_EXT; } if (iCurTid == 0 || pCtx->eSliceType == I_SLICE) - eNalRefIdc = NRI_PRI_HIGHEST; + eNalRefIdc = NRI_PRI_HIGHEST; else if (iCurTid == pSvcParam->iDecompStages) - eNalRefIdc = NRI_PRI_LOWEST; + eNalRefIdc = NRI_PRI_LOWEST; else if (1 + iCurTid == pSvcParam->iDecompStages) - eNalRefIdc = NRI_PRI_LOW; - else // more details for other temporal layers? - eNalRefIdc = NRI_PRI_HIGHEST; - pCtx->eNalType = eNalType; - pCtx->eNalPriority = eNalRefIdc; + eNalRefIdc = NRI_PRI_LOW; + else // more details for other temporal layers? + eNalRefIdc = NRI_PRI_HIGHEST; + pCtx->eNalType = eNalType; + pCtx->eNalPriority = eNalRefIdc; - pCtx->pDecPic = pCtx->ppRefPicListExt[iCurDid]->pNextBuffer; + pCtx->pDecPic = pCtx->ppRefPicListExt[iCurDid]->pNextBuffer; #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) - fsnr = pCtx->pDecPic; + fsnr = pCtx->pDecPic; #endif//#if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) - pCtx->pDecPic->iPictureType = pCtx->eSliceType; - pCtx->pDecPic->iFramePoc = pCtx->iPOC; + pCtx->pDecPic->iPictureType = pCtx->eSliceType; + pCtx->pDecPic->iFramePoc = pCtx->iPOC; WelsInitCurrentLayer (pCtx, iCurWidth, iCurHeight); @@ -3881,18 +3879,18 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL, iCurDid, (pCtx->eSliceType == P_SLICE) && pSvcParam->bEnableBackgroundDetection); WelsUpdateRefSyntax (pCtx, pCtx->iPOC, - eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. - PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer + eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. + PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer pCtx->pFuncList->pfRc.pfWelsRcPictureInit (pCtx, pSrcPic->uiTimeStamp); - PreprocessSliceCoding (pCtx); // MUST be called after pfWelsRcPictureInit() and WelsInitCurrentLayer() + PreprocessSliceCoding (pCtx); // MUST be called after pfWelsRcPictureInit() and WelsInitCurrentLayer() //TODO Complexity Calculation here for screen content - iLayerSize = 0; + iLayerSize = 0; - if (SM_SINGLE_SLICE == pParam->sSliceCfg.uiSliceMode) { // only one slice within a sQualityStat layer + if (SM_SINGLE_SLICE == pParam->sSliceCfg.uiSliceMode) { // only one slice within a sQualityStat layer int32_t iSliceSize = 0; - int32_t iPayloadSize = 0; + int32_t iPayloadSize = 0; if (pCtx->bNeedPrefixNalFlag) { pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, @@ -3918,12 +3916,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]; iLayerSize += iSliceSize; - pCtx->iPosBsBuffer += iSliceSize; - pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER; - pLayerBsInfo->uiSpatialId = iCurDid; - pLayerBsInfo->uiTemporalId = iCurTid; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; + pCtx->iPosBsBuffer += iSliceSize; + pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER; + pLayerBsInfo->uiSpatialId = iCurDid; + pLayerBsInfo->uiTemporalId = iCurTid; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; } // for dynamic slicing single threading.. else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) { @@ -3936,8 +3934,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour int32_t iRet = 0; // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE if ((SM_DYN_SLICE != pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { - iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); - if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed + iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); + if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!", iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, pParam->sSliceCfg.uiSliceMode, iSliceCount); @@ -3950,12 +3948,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour return ENC_RETURN_UNEXPECTED; } - if (pSvcParam->iCountThreadsNum >= iSliceCount) { //THREAD_FULLY_FIRE_MODE + if (pSvcParam->iCountThreadsNum >= iSliceCount) { //THREAD_FULLY_FIRE_MODE #if defined(MT_DEBUG) int64_t t_bs_append = 0; #endif - pCtx->iActiveThreadsNum = iSliceCount; + pCtx->iActiveThreadsNum = iSliceCount; // to fire slice coding threads iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0], @@ -3988,14 +3986,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour t_bs_append, pCtx->iCodingIndex, iCurDid, 0); } #endif//MT_DEBUG - } else { //THREAD_PICK_UP_MODE + } else { //THREAD_PICK_UP_MODE int32_t iNumThreadsRunning = 0; int32_t iNumThreadsScheduled = 0; int32_t iIndexOfSliceToBeCoded = 0; - pCtx->iActiveThreadsNum = pSvcParam->iCountThreadsNum; - iNumThreadsScheduled = pCtx->iActiveThreadsNum; - iNumThreadsRunning = iNumThreadsScheduled; + pCtx->iActiveThreadsNum = pSvcParam->iCountThreadsNum; + iNumThreadsScheduled = pCtx->iActiveThreadsNum; + iNumThreadsRunning = iNumThreadsScheduled; // to fire slice coding threads iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0], @@ -4012,8 +4010,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour while (1) { if (iIndexOfSliceToBeCoded >= iSliceCount && iNumThreadsRunning <= 0) break; - WELS_THREAD_ERROR_CODE lwait = 0; - int32_t iEventId = -1; + WELS_THREAD_ERROR_CODE lwait = 0; + int32_t iEventId = -1; lwait = WelsMultipleEventsWaitSingleBlocking (iNumThreadsScheduled, &pCtx->pSliceThreading->pSliceCodedEvent[0], @@ -4023,12 +4021,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour if (iIndexOfSliceToBeCoded < iSliceCount) { // pick up succeeding slice for threading // thread_id equal to iEventId per implementation here - pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded; + pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded; WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]); WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iEventId]); ++ iIndexOfSliceToBeCoded; - } else { // no other slices left for coding + } else { // no other slices left for coding -- iNumThreadsRunning; } } @@ -4041,7 +4039,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour } // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { - const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; + const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; // to fire slice coding threads iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], @@ -4060,14 +4058,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); - } else { // for non-dynamic-slicing mode single threading branch.. - const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; - int32_t iSliceIdx = 0; + } else { // for non-dynamic-slicing mode single threading branch.. + const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; + int32_t iSliceIdx = 0; - iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); + iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); while (iSliceIdx < iSliceCount) { - int32_t iSliceSize = 0; - int32_t iPayloadSize = 0; + int32_t iSliceSize = 0; + int32_t iPayloadSize = 0; if (bNeedPrefix) { pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc, @@ -4089,8 +4087,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]; - pCtx->iPosBsBuffer += iSliceSize; - iLayerSize += iSliceSize; + pCtx->iPosBsBuffer += iSliceSize; + iLayerSize += iSliceSize; #if defined(SLICE_INFO_OUTPUT) fprintf (stderr, @@ -4104,11 +4102,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour ++ iSliceIdx; } - pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER; - pLayerBsInfo->uiSpatialId = iCurDid; - pLayerBsInfo->uiTemporalId = iCurTid; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->iNalCount = iNalIdxInLayer; + pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER; + pLayerBsInfo->uiSpatialId = iCurDid; + pLayerBsInfo->uiTemporalId = iCurTid; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->iNalCount = iNalIdxInLayer; } } @@ -4162,19 +4160,19 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour #endif//ENABLE_FRAME_DUMP #if defined(ENABLE_PSNR_CALC) - fSnrY = WelsCalcPsnr (fsnr->pData[0], + fSnrY = WelsCalcPsnr (fsnr->pData[0], fsnr->iLineSize[0], pEncPic->pData[0], pEncPic->iLineSize[0], iCurWidth, iCurHeight); - fSnrU = WelsCalcPsnr (fsnr->pData[1], + fSnrU = WelsCalcPsnr (fsnr->pData[1], fsnr->iLineSize[1], pEncPic->pData[1], pEncPic->iLineSize[1], (iCurWidth >> 1), (iCurHeight >> 1)); - fSnrV = WelsCalcPsnr (fsnr->pData[2], + fSnrV = WelsCalcPsnr (fsnr->pData[2], fsnr->iLineSize[2], pEncPic->pData[2], pEncPic->iLineSize[2], @@ -4202,9 +4200,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour #if defined(ENABLE_PSNR_CALC) { - pCtx->sStatData[iCurDid][0].sQualityStat.rYPsnr[pCtx->eSliceType] += fSnrY; - pCtx->sStatData[iCurDid][0].sQualityStat.rUPsnr[pCtx->eSliceType] += fSnrU; - pCtx->sStatData[iCurDid][0].sQualityStat.rVPsnr[pCtx->eSliceType] += fSnrV; + pCtx->sStatData[iCurDid][0].sQualityStat.rYPsnr[pCtx->eSliceType] += fSnrY; + pCtx->sStatData[iCurDid][0].sQualityStat.rUPsnr[pCtx->eSliceType] += fSnrU; + pCtx->sStatData[iCurDid][0].sQualityStat.rVPsnr[pCtx->eSliceType] += fSnrV; } #endif//ENABLE_PSNR_CALC @@ -4232,8 +4230,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour #endif//MB_TYPES_CHECK { - ++ pCtx->sStatData[iCurDid][0].sSliceData.iSliceCount[pCtx->eSliceType]; // for multiple slices coding - pCtx->sStatData[iCurDid][0].sSliceData.iSliceSize[pCtx->eSliceType] += (iLayerSize << 3); // bits + ++ pCtx->sStatData[iCurDid][0].sSliceData.iSliceCount[pCtx->eSliceType]; // for multiple slices coding + pCtx->sStatData[iCurDid][0].sSliceData.iSliceSize[pCtx->eSliceType] += (iLayerSize << 3); // bits } #endif//STAT_OUTPUT @@ -4241,7 +4239,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour ++ iLayerNum; ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) { @@ -4261,14 +4259,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize = 0; - pLayerBsInfo->uiSpatialId = 0; - pLayerBsInfo->uiTemporalId = 0; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; - pLayerBsInfo->iNalCount = 1; + pLayerBsInfo->uiSpatialId = 0; + pLayerBsInfo->uiTemporalId = 0; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; + pLayerBsInfo->iNalCount = 1; pLayerBsInfo->pNalLengthInByte[0] = iPaddingNalSize; ++ pLayerBsInfo; - pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; + pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + 1; ++ iLayerNum; @@ -4322,7 +4320,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour #ifdef ENABLE_FRAME_DUMP DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0], - pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output + pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output pCtx->bRecFlag = true; #endif//ENABLE_FRAME_DUMP @@ -4335,8 +4333,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour } ++ pCtx->iCodingIndex; - pCtx->eLastNalPriority = eNalRefIdc; - pFbi->iLayerNum = iLayerNum; + pCtx->eLastNalPriority = eNalRefIdc; + pFbi->iLayerNum = iLayerNum; pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType); WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iSubSeqId = %d,iFrameSize = %d", @@ -4384,19 +4382,19 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour * SVC adjustment results in new requirement in memory blocks adjustment */ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewParam) { - SWelsSvcCodingParam* pOldParam = NULL; + SWelsSvcCodingParam* pOldParam = NULL; int32_t iReturn = ENC_RETURN_SUCCESS; int8_t iIndexD = 0; bool bNeedReset = false; - int16_t iSliceNum = 1; // number of slices used - int32_t iCacheLineSize = 16; // on chip cache line size in byte + int16_t iSliceNum = 1; // number of slices used + int32_t iCacheLineSize = 16; // on chip cache line size in byte uint32_t uiCpuFeatureFlags = 0; - if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; + if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; /* Check validation in new parameters */ - iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam); - if (iReturn != ENC_RETURN_SUCCESS) return iReturn; + iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam); + if (iReturn != ENC_RETURN_SUCCESS) return iReturn; iReturn = GetMultipleThreadIdc (& (*ppCtx)->sLogCtx, pNewParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); if (iReturn != ENC_RETURN_SUCCESS) { @@ -4405,7 +4403,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa return iReturn; } - pOldParam = (*ppCtx)->pSvcParam; + pOldParam = (*ppCtx)->pSvcParam; if (pOldParam->iUsageType != pNewParam->iUsageType) { WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR, @@ -4416,7 +4414,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa /* Decide whether need reset for IDR frame based on adjusting prarameters changed */ /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */ - bNeedReset = (pOldParam == NULL) || + bNeedReset = (pOldParam == NULL) || (pOldParam->bSimulcastAVC != pNewParam->bSimulcastAVC) || (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) || (pOldParam->iPicWidth != pNewParam->iPicWidth @@ -4433,12 +4431,12 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa bNeedReset = true; } - if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer + if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer iIndexD = 0; assert (pOldParam->iSpatialLayerNum == pNewParam->iSpatialLayerNum); do { - const SSpatialLayerInternal* kpOldDlp = &pOldParam->sDependencyLayers[iIndexD]; - const SSpatialLayerInternal* kpNewDlp = &pNewParam->sDependencyLayers[iIndexD]; + const SSpatialLayerInternal* kpOldDlp = &pOldParam->sDependencyLayers[iIndexD]; + const SSpatialLayerInternal* kpNewDlp = &pNewParam->sDependencyLayers[iIndexD]; float fT1 = .0f; float fT2 = .0f; @@ -4447,7 +4445,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa pOldParam->sSpatialLayers[iIndexD].iVideoHeight != pNewParam->sSpatialLayers[iIndexD].iVideoHeight || kpOldDlp->iActualWidth != kpNewDlp->iActualWidth || kpOldDlp->iActualHeight != kpNewDlp->iActualHeight) { - bNeedReset = true; + bNeedReset = true; break; } @@ -4455,7 +4453,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa || pOldParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum != pNewParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum) { - bNeedReset = true; + bNeedReset = true; break; } @@ -4555,21 +4553,21 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa } } else { /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */ - pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT, + pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT, (pNewParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); - pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6); - pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6); - pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6); - pNewParam->fMaxFrameRate = WELS_CLIP3 (pNewParam->fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); + pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6); + pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6); + pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6); + pNewParam->fMaxFrameRate = WELS_CLIP3 (pNewParam->fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); // we can not use direct struct based memcpy due some fields need keep unchanged as before - pOldParam->fMaxFrameRate = pNewParam->fMaxFrameRate; // maximal frame rate [Hz / fps] - pOldParam->iComplexityMode = pNewParam->iComplexityMode; // color space of input sequence - pOldParam->uiIntraPeriod = pNewParam->uiIntraPeriod; // intra period (multiple of GOP size as desired) + pOldParam->fMaxFrameRate = pNewParam->fMaxFrameRate; // maximal frame rate [Hz / fps] + pOldParam->iComplexityMode = pNewParam->iComplexityMode; // color space of input sequence + pOldParam->uiIntraPeriod = pNewParam->uiIntraPeriod; // intra period (multiple of GOP size as desired) pOldParam->eSpsPpsIdStrategy = pNewParam->eSpsPpsIdStrategy; pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl; - pOldParam->iNumRefFrame = pNewParam->iNumRefFrame; // number of reference frame used + pOldParam->iNumRefFrame = pNewParam->iNumRefFrame; // number of reference frame used pOldParam->uiGopSize = pNewParam->uiGopSize; if (pOldParam->iTemporalLayerNum != pNewParam->iTemporalLayerNum) { pOldParam->iTemporalLayerNum = pNewParam->iTemporalLayerNum; @@ -4577,60 +4575,60 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa } pOldParam->iDecompStages = pNewParam->iDecompStages; /* denoise control */ - pOldParam->bEnableDenoise = pNewParam->bEnableDenoise; + pOldParam->bEnableDenoise = pNewParam->bEnableDenoise; /* background detection control */ - pOldParam->bEnableBackgroundDetection = pNewParam->bEnableBackgroundDetection; + pOldParam->bEnableBackgroundDetection = pNewParam->bEnableBackgroundDetection; /* adaptive quantization control */ - pOldParam->bEnableAdaptiveQuant = pNewParam->bEnableAdaptiveQuant; + pOldParam->bEnableAdaptiveQuant = pNewParam->bEnableAdaptiveQuant; /* int32_t term reference control */ - pOldParam->bEnableLongTermReference = pNewParam->bEnableLongTermReference; - pOldParam->iLtrMarkPeriod = pNewParam->iLtrMarkPeriod; + pOldParam->bEnableLongTermReference = pNewParam->bEnableLongTermReference; + pOldParam->iLtrMarkPeriod = pNewParam->iLtrMarkPeriod; // keep below values unchanged as before - pOldParam->bEnableSSEI = pNewParam->bEnableSSEI; - pOldParam->bSimulcastAVC = pNewParam->bSimulcastAVC; - pOldParam->bEnableFrameCroppingFlag = pNewParam->bEnableFrameCroppingFlag; // enable frame cropping flag + pOldParam->bEnableSSEI = pNewParam->bEnableSSEI; + pOldParam->bSimulcastAVC = pNewParam->bSimulcastAVC; + pOldParam->bEnableFrameCroppingFlag = pNewParam->bEnableFrameCroppingFlag; // enable frame cropping flag /* Motion search */ /* Deblocking loop filter */ - pOldParam->iLoopFilterDisableIdc = pNewParam->iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries - pOldParam->iLoopFilterAlphaC0Offset = pNewParam->iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0 - pOldParam->iLoopFilterBetaOffset = pNewParam->iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 + pOldParam->iLoopFilterDisableIdc = pNewParam->iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries + pOldParam->iLoopFilterAlphaC0Offset = pNewParam->iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0 + pOldParam->iLoopFilterBetaOffset = pNewParam->iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 /* Rate Control */ - pOldParam->iRCMode = pNewParam->iRCMode; - pOldParam->iTargetBitrate = pNewParam->iTargetBitrate; // overall target bitrate introduced in RC module - pOldParam->iPaddingFlag = pNewParam->iPaddingFlag; + pOldParam->iRCMode = pNewParam->iRCMode; + pOldParam->iTargetBitrate = pNewParam->iTargetBitrate; // overall target bitrate introduced in RC module + pOldParam->iPaddingFlag = pNewParam->iPaddingFlag; /* Layer definition */ - pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl; + pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl; // d iIndexD = 0; do { - SSpatialLayerInternal* pOldDlpInternal = &pOldParam->sDependencyLayers[iIndexD]; - SSpatialLayerInternal* pNewDlpInternal = &pNewParam->sDependencyLayers[iIndexD]; + SSpatialLayerInternal* pOldDlpInternal = &pOldParam->sDependencyLayers[iIndexD]; + SSpatialLayerInternal* pNewDlpInternal = &pNewParam->sDependencyLayers[iIndexD]; - SSpatialLayerConfig* pOldDlp = &pOldParam->sSpatialLayers[iIndexD]; - SSpatialLayerConfig* pNewDlp = &pNewParam->sSpatialLayers[iIndexD]; + SSpatialLayerConfig* pOldDlp = &pOldParam->sSpatialLayers[iIndexD]; + SSpatialLayerConfig* pNewDlp = &pNewParam->sSpatialLayers[iIndexD]; - pOldDlpInternal->fInputFrameRate = pNewDlpInternal->fInputFrameRate; // input frame rate - pOldDlpInternal->fOutputFrameRate = pNewDlpInternal->fOutputFrameRate; // output frame rate - pOldDlp->iSpatialBitrate = pNewDlp->iSpatialBitrate; + pOldDlpInternal->fInputFrameRate = pNewDlpInternal->fInputFrameRate; // input frame rate + pOldDlpInternal->fOutputFrameRate = pNewDlpInternal->fOutputFrameRate; // output frame rate + pOldDlp->iSpatialBitrate = pNewDlp->iSpatialBitrate; - pOldDlp->uiProfileIdc = pNewDlp->uiProfileIdc; // value of profile IDC (0 for auto-detection) - pOldDlp->iDLayerQp = pNewDlp->iDLayerQp; + pOldDlp->uiProfileIdc = pNewDlp->uiProfileIdc; // value of profile IDC (0 for auto-detection) + pOldDlp->iDLayerQp = pNewDlp->iDLayerQp; /* Derived variants below */ - pOldDlpInternal->iTemporalResolution = pNewDlpInternal->iTemporalResolution; - pOldDlpInternal->iDecompositionStages = pNewDlpInternal->iDecompositionStages; + pOldDlpInternal->iTemporalResolution = pNewDlpInternal->iTemporalResolution; + pOldDlpInternal->iDecompositionStages = pNewDlpInternal->iDecompositionStages; memcpy (pOldDlpInternal->uiCodingIdx2TemporalId, pNewDlpInternal->uiCodingIdx2TemporalId, - sizeof (pOldDlpInternal->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage + sizeof (pOldDlpInternal->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage ++ iIndexD; } while (iIndexD < pOldParam->iSpatialLayerNum); @@ -4642,13 +4640,13 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa } int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConfig* pLTRValue) { - SWelsSvcCodingParam sConfig; + SWelsSvcCodingParam sConfig; int32_t iNumRefFrame = 1; int32_t iRet = 0; memcpy (&sConfig, (*ppCtx)->pSvcParam, sizeof (SWelsSvcCodingParam)); sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference; sConfig.iLTRRefNum = pLTRValue->iLTRRefNum; - int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1); + int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1); if (sConfig.iUsageType == SCREEN_CONTENT_REAL_TIME) { if (sConfig.bEnableLongTermReference) { sConfig.iLTRRefNum = LONG_TERM_REF_NUM_SCREEN;//WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN); @@ -4663,9 +4661,9 @@ int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConf } else { sConfig.iLTRRefNum = 0; } - iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT + + iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT + sConfig.iLTRRefNum); - iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); + iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); } if (iNumRefFrame > sConfig.iMaxNumRefFrame) { @@ -4804,17 +4802,17 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, memcpy (pSlcingOverRc, pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); uiSliceIdx = iMaxSliceNumOld; SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; - const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, + const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); while (uiSliceIdx < iMaxSliceNum) { pSORC->iComplexityIndexSlice = 0; pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; - pSORC->iTotalQpSlice = 0; - pSORC->iTotalMbSlice = 0; + pSORC->iTotalQpSlice = 0; + pSORC->iTotalMbSlice = 0; pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurLayer->pSliceEncCtx->pCountMbNumInSlice[uiSliceIdx], INT_MULTIPLY); - pSORC->iFrameBitsSlice = 0; - pSORC->iGomBitsSlice = 0; + pSORC->iFrameBitsSlice = 0; + pSORC->iGomBitsSlice = 0; pSORC ++; uiSliceIdx ++; } @@ -4831,38 +4829,38 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, SLayerBSInfo* pLayerBsInfo, int32_t* pNalIdxInLayer, int32_t* pLayerSize, - int32_t iFirstMbInPartition, // first mb inclusive in partition - int32_t iEndMbInPartition, // end mb exclusive in partition + int32_t iFirstMbInPartition, // first mb inclusive in partition + int32_t iEndMbInPartition, // end mb exclusive in partition int32_t iStartSliceIdx ) { - SDqLayer* pCurLayer = pCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; - int32_t iNalIdxInLayer = *pNalIdxInLayer; - int32_t iSliceIdx = iStartSliceIdx; - const int32_t kiSliceStep = pCtx->iActiveThreadsNum; - const int32_t kiPartitionId = iStartSliceIdx % kiSliceStep; - int32_t iPartitionBsSize = 0; - int32_t iAnyMbLeftInPartition = iEndMbInPartition - iFirstMbInPartition; - const EWelsNalUnitType keNalType = pCtx->eNalType; - const EWelsNalRefIdc keNalRefIdc = pCtx->eNalPriority; - const bool kbNeedPrefix = pCtx->bNeedPrefixNalFlag; - const int32_t kiSliceIdxStep = pCtx->iActiveThreadsNum; + SDqLayer* pCurLayer = pCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; + int32_t iNalIdxInLayer = *pNalIdxInLayer; + int32_t iSliceIdx = iStartSliceIdx; + const int32_t kiSliceStep = pCtx->iActiveThreadsNum; + const int32_t kiPartitionId = iStartSliceIdx % kiSliceStep; + int32_t iPartitionBsSize = 0; + int32_t iAnyMbLeftInPartition = iEndMbInPartition - iFirstMbInPartition; + const EWelsNalUnitType keNalType = pCtx->eNalType; + const EWelsNalRefIdc keNalRefIdc = pCtx->eNalPriority; + const bool kbNeedPrefix = pCtx->bNeedPrefixNalFlag; + const int32_t kiSliceIdxStep = pCtx->iActiveThreadsNum; int32_t iReturn = ENC_RETURN_SUCCESS; //init { - pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbInPartition; - pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside - pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1; + pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbInPartition; + pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside + pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1; } pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; while (iAnyMbLeftInPartition > 0) { - int32_t iSliceSize = 0; - int32_t iPayloadSize = 0; + int32_t iSliceSize = 0; + int32_t iPayloadSize = 0; - if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[] + if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[] if (pCtx->iActiveThreadsNum == 1) { //only single thread support re-alloc now if (DynSliceRealloc (pCtx, pFrameBSInfo, pLayerBsInfo)) { @@ -4898,8 +4896,8 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]; - pCtx->iPosBsBuffer += iSliceSize; - iPartitionBsSize += iSliceSize; + pCtx->iPosBsBuffer += iSliceSize; + iPartitionBsSize += iSliceSize; #if defined(SLICE_INFO_OUTPUT) fprintf (stderr, @@ -4911,19 +4909,19 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, #endif//SLICE_INFO_OUTPUT ++ iNalIdxInLayer; - iSliceIdx += kiSliceStep; //if uiSliceIdx is not continuous + iSliceIdx += kiSliceStep; //if uiSliceIdx is not continuous iAnyMbLeftInPartition = iEndMbInPartition - (1 + pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId]); } - *pLayerSize = iPartitionBsSize; - *pNalIdxInLayer = iNalIdxInLayer; + *pLayerSize = iPartitionBsSize; + *pNalIdxInLayer = iNalIdxInLayer; // slice based packing??? - pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER; - pLayerBsInfo->uiSpatialId = pCtx->uiDependencyId; - pLayerBsInfo->uiTemporalId = pCtx->uiTemporalId; - pLayerBsInfo->uiQualityId = 0; - pLayerBsInfo->iNalCount = iNalIdxInLayer; + pLayerBsInfo->uiLayerType = VIDEO_CODING_LAYER; + pLayerBsInfo->uiSpatialId = pCtx->uiDependencyId; + pLayerBsInfo->uiTemporalId = pCtx->uiTemporalId; + pLayerBsInfo->uiQualityId = 0; + pLayerBsInfo->iNalCount = iNalIdxInLayer; return ENC_RETURN_SUCCESS; } diff --git a/codec/encoder/core/src/get_intra_predictor.cpp b/codec/encoder/core/src/get_intra_predictor.cpp index ecd69f99..f3ff9d89 100644 --- a/codec/encoder/core/src/get_intra_predictor.cpp +++ b/codec/encoder/core/src/get_intra_predictor.cpp @@ -95,7 +95,7 @@ void WelsI4x4LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) const uint8_t kuiVec2[4] = {kuiHor2, kuiHor2, kuiHor2, kuiHor2}; const uint8_t kuiVec3[4] = {kuiHor3, kuiHor3, kuiHor3, kuiHor3}; const uint8_t kuiVec4[4] = {kuiHor4, kuiHor4, kuiHor4, kuiHor4}; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ST32 (&uiSrc[0], LD32 (kuiVec1)); ST32 (&uiSrc[4], LD32 (kuiVec2)); ST32 (&uiSrc[8], LD32 (kuiVec3)); @@ -104,22 +104,21 @@ void WelsI4x4LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) WelsFillingPred8x2to16 (pPred, uiSrc); } void WelsI4x4LumaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + - kiStride - 1] + + const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + kiStride - 1] + pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 4) >> 3; WelsFillingPred1to16 (pPred, kuiDcValue); } void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + + const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + kiStride - 1] + 2) >> 2; WelsFillingPred1to16 (pPred, kuiDcValue); } void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const uint8_t kuiDcValue = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 2) >> 2; + const uint8_t kuiDcValue = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 2) >> 2; WelsFillingPred1to16 (pPred, kuiDcValue); } @@ -133,22 +132,22 @@ void WelsI4x4LumaPredDcNA_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri /*down pLeft*/ void WelsI4x4LumaPredDDL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { /*get pTop*/ - const uint8_t kuiT0 = pRef[-kiStride]; - const uint8_t kuiT1 = pRef[1 - kiStride]; - const uint8_t kuiT2 = pRef[2 - kiStride]; - const uint8_t kuiT3 = pRef[3 - kiStride]; - const uint8_t kuiT4 = pRef[4 - kiStride]; - const uint8_t kuiT5 = pRef[5 - kiStride]; - const uint8_t kuiT6 = pRef[6 - kiStride]; - const uint8_t kuiT7 = pRef[7 - kiStride]; - const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDDL0 - const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDDL1 - const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // uiDDL2 - const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // uiDDL3 - const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // uiDDL4 - const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // uiDDL5 - const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // uiDDL6 - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiT0 = pRef[-kiStride]; + const uint8_t kuiT1 = pRef[1 - kiStride]; + const uint8_t kuiT2 = pRef[2 - kiStride]; + const uint8_t kuiT3 = pRef[3 - kiStride]; + const uint8_t kuiT4 = pRef[4 - kiStride]; + const uint8_t kuiT5 = pRef[5 - kiStride]; + const uint8_t kuiT6 = pRef[6 - kiStride]; + const uint8_t kuiT7 = pRef[7 - kiStride]; + const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDDL0 + const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDDL1 + const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // uiDDL2 + const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // uiDDL3 + const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // uiDDL4 + const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // uiDDL5 + const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // uiDDL6 + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = kuiDDL0; uiSrc[1] = uiSrc[4] = kuiDDL1; uiSrc[2] = uiSrc[5] = uiSrc[8] = kuiDDL2; @@ -163,15 +162,15 @@ void WelsI4x4LumaPredDDL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStrid /*down pLeft*/ void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { /*get pTop*/ - const uint8_t kuiT0 = pRef[-kiStride]; - const uint8_t kuiT1 = pRef[1 - kiStride]; - const uint8_t kuiT2 = pRef[2 - kiStride]; - const uint8_t kuiT3 = pRef[3 - kiStride]; - const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDLT0 - const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDLT1 - const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3 << 1)) >> 2; // uiDLT2 - const uint8_t kuiDLT3 = (2 + (kuiT3 << 2)) >> 2; // uiDLT3 - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiT0 = pRef[-kiStride]; + const uint8_t kuiT1 = pRef[1 - kiStride]; + const uint8_t kuiT2 = pRef[2 - kiStride]; + const uint8_t kuiT3 = pRef[3 - kiStride]; + const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDLT0 + const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDLT1 + const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3 << 1)) >> 2; // uiDLT2 + const uint8_t kuiDLT3 = (2 + (kuiT3 << 2)) >> 2; // uiDLT3 + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows memset (&uiSrc[6], kuiDLT3, 10 * sizeof (uint8_t)); uiSrc[0] = kuiDLT0; uiSrc[1] = uiSrc[4] = kuiDLT1; @@ -184,34 +183,34 @@ void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiSt /*down right*/ void WelsI4x4LumaPredDDR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const int32_t kiStridex2 = kiStride << 1; - const int32_t kiStridex3 = kiStride + kiStridex2; - const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft + const int32_t kiStridex2 = kiStride << 1; + const int32_t kiStridex3 = kiStride + kiStridex2; + const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft /*get pLeft and pTop*/ - const uint8_t kuiL0 = pRef[-1]; - const uint8_t kuiL1 = pRef[kiStride - 1]; - const uint8_t kuiL2 = pRef[kiStridex2 - 1]; - const uint8_t kuiL3 = pRef[kiStridex3 - 1]; - const uint8_t kuiT0 = pRef[-kiStride]; - const uint8_t kuiT1 = pRef[1 - kiStride]; - const uint8_t kuiT2 = pRef[2 - kiStride]; - const uint8_t kuiT3 = pRef[3 - kiStride]; - const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; - const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; - const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; - const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; - const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; - const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; - const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; - const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiL0 = pRef[-1]; + const uint8_t kuiL1 = pRef[kiStride - 1]; + const uint8_t kuiL2 = pRef[kiStridex2 - 1]; + const uint8_t kuiL3 = pRef[kiStridex3 - 1]; + const uint8_t kuiT0 = pRef[-kiStride]; + const uint8_t kuiT1 = pRef[1 - kiStride]; + const uint8_t kuiT2 = pRef[2 - kiStride]; + const uint8_t kuiT3 = pRef[3 - kiStride]; + const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; + const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; + const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; + const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; + const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; + const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; + const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; + const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = uiSrc[5] = uiSrc[10] = uiSrc[15] = kuiDDR0; uiSrc[1] = uiSrc[6] = uiSrc[11] = kuiDDR1; uiSrc[2] = uiSrc[7] = kuiDDR2; @@ -227,24 +226,24 @@ void WelsI4x4LumaPredDDR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStrid /*vertical pLeft*/ void WelsI4x4LumaPredVL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { /*get pTop*/ - const uint8_t kuiT0 = pRef[-kiStride]; - const uint8_t kuiT1 = pRef[1 - kiStride]; - const uint8_t kuiT2 = pRef[2 - kiStride]; - const uint8_t kuiT3 = pRef[3 - kiStride]; - const uint8_t kuiT4 = pRef[4 - kiStride]; - const uint8_t kuiT5 = pRef[5 - kiStride]; - const uint8_t kuiT6 = pRef[6 - kiStride]; - const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1) >> 1; // uiVL0 - const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2) >> 1; // uiVL1 - const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3) >> 1; // uiVL2 - const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4) >> 1; // uiVL3 - const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5) >> 1; // uiVL4 - const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVL5 - const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVL6 - const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3 << 1) + kuiT4) >> 2; // uiVL7 - const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4 << 1) + kuiT5) >> 2; // uiVL8 - const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5 << 1) + kuiT6) >> 2; // uiVL9 - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiT0 = pRef[-kiStride]; + const uint8_t kuiT1 = pRef[1 - kiStride]; + const uint8_t kuiT2 = pRef[2 - kiStride]; + const uint8_t kuiT3 = pRef[3 - kiStride]; + const uint8_t kuiT4 = pRef[4 - kiStride]; + const uint8_t kuiT5 = pRef[5 - kiStride]; + const uint8_t kuiT6 = pRef[6 - kiStride]; + const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1) >> 1; // uiVL0 + const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2) >> 1; // uiVL1 + const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3) >> 1; // uiVL2 + const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4) >> 1; // uiVL3 + const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5) >> 1; // uiVL4 + const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVL5 + const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVL6 + const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3 << 1) + kuiT4) >> 2; // uiVL7 + const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4 << 1) + kuiT5) >> 2; // uiVL8 + const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5 << 1) + kuiT6) >> 2; // uiVL9 + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = kuiVL0; uiSrc[1] = uiSrc[8] = kuiVL1; uiSrc[2] = uiSrc[9] = kuiVL2; @@ -263,21 +262,21 @@ void WelsI4x4LumaPredVL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride /*vertical pLeft*/ void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - uint8_t* pTopLeft = &pRef[-kiStride - 1]; // pTop-pLeft + uint8_t* pTopLeft = &pRef[-kiStride - 1]; // pTop-pLeft /*get pTop*/ - const uint8_t kuiT0 = * (pTopLeft + 1); - const uint8_t kuiT1 = * (pTopLeft + 2); - const uint8_t kuiT2 = * (pTopLeft + 3); - const uint8_t kuiT3 = * (pTopLeft + 4); - const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1) >> 1; // uiVLT0 - const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2) >> 1; // uiVLT1 - const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3) >> 1; // uiVLT2 - const uint8_t kuiVLT3 = (1 + (kuiT3 << 1)) >> 1; // uiVLT3 - const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVLT4 - const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVLT5 - const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3 << 1) + kuiT3) >> 2; // uiVLT6 - const uint8_t kuiVLT7 = (2 + (kuiT3 << 2)) >> 2; // uiVLT7 - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiT0 = * (pTopLeft + 1); + const uint8_t kuiT1 = * (pTopLeft + 2); + const uint8_t kuiT2 = * (pTopLeft + 3); + const uint8_t kuiT3 = * (pTopLeft + 4); + const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1) >> 1; // uiVLT0 + const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2) >> 1; // uiVLT1 + const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3) >> 1; // uiVLT2 + const uint8_t kuiVLT3 = (1 + (kuiT3 << 1)) >> 1; // uiVLT3 + const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVLT4 + const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVLT5 + const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3 << 1) + kuiT3) >> 2; // uiVLT6 + const uint8_t kuiVLT7 = (2 + (kuiT3 << 2)) >> 2; // uiVLT7 + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = kuiVLT0; uiSrc[1] = uiSrc[8] = kuiVLT1; uiSrc[2] = uiSrc[9] = kuiVLT2; @@ -292,27 +291,27 @@ void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStr /*vertical right*/ void WelsI4x4LumaPredVR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const int32_t kiStridex2 = kiStride << 1; - const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft + const int32_t kiStridex2 = kiStride << 1; + const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft /*get pLeft and pTop*/ - const uint8_t kuiL0 = pRef[-1]; - const uint8_t kuiL1 = pRef[kiStride - 1]; - const uint8_t kuiL2 = pRef[kiStridex2 - 1]; - const uint8_t kuiT0 = pRef[-kiStride]; - const uint8_t kuiT1 = pRef[1 - kiStride]; - const uint8_t kuiT2 = pRef[2 - kiStride]; - const uint8_t kuiT3 = pRef[3 - kiStride]; - const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; - const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; - const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; - const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; - const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; - const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; - const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; - const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; - const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; - const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiL0 = pRef[-1]; + const uint8_t kuiL1 = pRef[kiStride - 1]; + const uint8_t kuiL2 = pRef[kiStridex2 - 1]; + const uint8_t kuiT0 = pRef[-kiStride]; + const uint8_t kuiT1 = pRef[1 - kiStride]; + const uint8_t kuiT2 = pRef[2 - kiStride]; + const uint8_t kuiT3 = pRef[3 - kiStride]; + const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; + const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; + const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; + const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; + const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; + const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; + const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; + const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; + const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; + const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = uiSrc[9] = kuiVR0; uiSrc[1] = uiSrc[10] = kuiVR1; uiSrc[2] = uiSrc[11] = kuiVR2; @@ -330,23 +329,23 @@ void WelsI4x4LumaPredVR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride /*horizontal up*/ void WelsI4x4LumaPredHU_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const int32_t kiStridex2 = kiStride << 1; - const int32_t kiStridex3 = kiStride + kiStridex2; + const int32_t kiStridex2 = kiStride << 1; + const int32_t kiStridex3 = kiStride + kiStridex2; /*get pLeft*/ - const uint8_t kuiL0 = pRef[-1]; - const uint8_t kuiL1 = pRef[kiStride - 1]; - const uint8_t kuiL2 = pRef[kiStridex2 - 1]; - const uint8_t kuiL3 = pRef[kiStridex3 - 1]; - const uint16_t kuiL01 = (1 + kuiL0 + kuiL1); - const uint16_t kuiL12 = (1 + kuiL1 + kuiL2); - const uint16_t kuiL23 = (1 + kuiL2 + kuiL3); - const uint8_t kuiHU0 = kuiL01 >> 1; - const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; - const uint8_t kuiHU2 = kuiL12 >> 1; - const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; - const uint8_t kuiHU4 = kuiL23 >> 1; - const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiL0 = pRef[-1]; + const uint8_t kuiL1 = pRef[kiStride - 1]; + const uint8_t kuiL2 = pRef[kiStridex2 - 1]; + const uint8_t kuiL3 = pRef[kiStridex3 - 1]; + const uint16_t kuiL01 = (1 + kuiL0 + kuiL1); + const uint16_t kuiL12 = (1 + kuiL1 + kuiL2); + const uint16_t kuiL23 = (1 + kuiL2 + kuiL3); + const uint8_t kuiHU0 = kuiL01 >> 1; + const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; + const uint8_t kuiHU2 = kuiL12 >> 1; + const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; + const uint8_t kuiHU4 = kuiL23 >> 1; + const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = kuiHU0; uiSrc[1] = kuiHU1; uiSrc[2] = uiSrc[4] = kuiHU2; @@ -361,28 +360,28 @@ void WelsI4x4LumaPredHU_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride /*horizontal down*/ void WelsI4x4LumaPredHD_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const int32_t kiStridex2 = kiStride << 1; - const int32_t kiStridex3 = kiStride + kiStridex2; - const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft + const int32_t kiStridex2 = kiStride << 1; + const int32_t kiStridex3 = kiStride + kiStridex2; + const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft /*get pLeft and pTop*/ - const uint8_t kuiL0 = pRef[-1]; - const uint8_t kuiL1 = pRef[kiStride - 1]; - const uint8_t kuiL2 = pRef[kiStridex2 - 1]; - const uint8_t kuiL3 = pRef[kiStridex3 - 1]; - const uint8_t kuiT0 = pRef[-kiStride]; - const uint8_t kuiT1 = pRef[1 - kiStride]; - const uint8_t kuiT2 = pRef[2 - kiStride]; - const uint8_t kuiHD0 = (1 + kuiLT + kuiL0) >> 1; // uiHD0 - const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // uiHD1 - const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // uiHD2 - const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiHD3 - const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1) >> 1; // uiHD4 - const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // uiHD5 - const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2) >> 1; // uiHD6 - const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // uiHD7 - const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1; // uiHD8 - const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2; // uiHD9 - ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows + const uint8_t kuiL0 = pRef[-1]; + const uint8_t kuiL1 = pRef[kiStride - 1]; + const uint8_t kuiL2 = pRef[kiStridex2 - 1]; + const uint8_t kuiL3 = pRef[kiStridex3 - 1]; + const uint8_t kuiT0 = pRef[-kiStride]; + const uint8_t kuiT1 = pRef[1 - kiStride]; + const uint8_t kuiT2 = pRef[2 - kiStride]; + const uint8_t kuiHD0 = (1 + kuiLT + kuiL0) >> 1; // uiHD0 + const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // uiHD1 + const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // uiHD2 + const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiHD3 + const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1) >> 1; // uiHD4 + const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // uiHD5 + const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2) >> 1; // uiHD6 + const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // uiHD7 + const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1; // uiHD8 + const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2; // uiHD9 + ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows uiSrc[0] = uiSrc[6] = kuiHD0; uiSrc[1] = uiSrc[7] = kuiHD1; uiSrc[2] = kuiHD2; @@ -404,7 +403,7 @@ void WelsI4x4LumaPredHD_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride void WelsIChromaPredV_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { const uint64_t kuiSrc64 = LD64 (&pRef[-kiStride]); - ST64 (pPred , kuiSrc64); + ST64 (pPred , kuiSrc64); ST64 (pPred + 8 , kuiSrc64); ST64 (pPred + 16, kuiSrc64); ST64 (pPred + 24, kuiSrc64); @@ -420,7 +419,7 @@ void WelsIChromaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) uint8_t i = 7; do { - const uint8_t kuiLeft = pRef[iStridex7 - 1]; // pLeft value + const uint8_t kuiLeft = pRef[iStridex7 - 1]; // pLeft value uint64_t kuiSrc64 = (uint64_t) (0x0101010101010101ULL * kuiLeft); ST64 (pPred + iI8x8Stridex7, kuiSrc64); @@ -463,8 +462,8 @@ void WelsIChromaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) const int32_t kuiL6 = kuiL5 + kiStride; const int32_t kuiL7 = kuiL6 + kiStride; /*caculate the iMean value*/ - const uint8_t kuiMean1 = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + - pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 4) >> 3; + const uint8_t kuiMean1 = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + + pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 4) >> 3; const uint32_t kuiSum2 = pRef[4 - kiStride] + pRef[5 - kiStride] + pRef[6 - kiStride] + pRef[7 - kiStride]; const uint32_t kuiSum3 = pRef[kuiL4] + pRef[kuiL5] + pRef[kuiL6] + pRef[kuiL7]; const uint8_t kuiMean2 = (kuiSum2 + 2) >> 2; @@ -476,7 +475,7 @@ void WelsIChromaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) const uint64_t kuiTopMean64 = LD64 (kuiTopMean); const uint64_t kuiBottomMean64 = LD64 (kuiBottomMean); - ST64 (pPred , kuiTopMean64); + ST64 (pPred , kuiTopMean64); ST64 (pPred + 8 , kuiTopMean64); ST64 (pPred + 16, kuiTopMean64); ST64 (pPred + 24, kuiTopMean64); @@ -487,19 +486,19 @@ void WelsIChromaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) } void WelsIChromaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { - const int32_t kuiL1 = kiStride - 1; - const int32_t kuiL2 = kuiL1 + kiStride; - const int32_t kuiL3 = kuiL2 + kiStride; - const int32_t kuiL4 = kuiL3 + kiStride; - const int32_t kuiL5 = kuiL4 + kiStride; - const int32_t kuiL6 = kuiL5 + kiStride; - const int32_t kuiL7 = kuiL6 + kiStride; + const int32_t kuiL1 = kiStride - 1; + const int32_t kuiL2 = kuiL1 + kiStride; + const int32_t kuiL3 = kuiL2 + kiStride; + const int32_t kuiL4 = kuiL3 + kiStride; + const int32_t kuiL5 = kuiL4 + kiStride; + const int32_t kuiL6 = kuiL5 + kiStride; + const int32_t kuiL7 = kuiL6 + kiStride; /*caculate the iMean value*/ - const uint8_t kuiTopMean = (pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 2) >> 2 ; - const uint8_t kuiBottomMean = (pRef[kuiL4] + pRef[kuiL5] + pRef[kuiL6] + pRef[kuiL7] + 2) >> 2; - const uint64_t kuiTopMean64 = (uint64_t) (0x0101010101010101ULL * kuiTopMean); - const uint64_t kuiBottomMean64 = (uint64_t) (0x0101010101010101ULL * kuiBottomMean); - ST64 (pPred , kuiTopMean64); + const uint8_t kuiTopMean = (pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 2) >> 2 ; + const uint8_t kuiBottomMean = (pRef[kuiL4] + pRef[kuiL5] + pRef[kuiL6] + pRef[kuiL7] + 2) >> 2; + const uint64_t kuiTopMean64 = (uint64_t) (0x0101010101010101ULL * kuiTopMean); + const uint64_t kuiBottomMean64 = (uint64_t) (0x0101010101010101ULL * kuiBottomMean); + ST64 (pPred , kuiTopMean64); ST64 (pPred + 8 , kuiTopMean64); ST64 (pPred + 16, kuiTopMean64); ST64 (pPred + 24, kuiTopMean64); @@ -516,7 +515,7 @@ void WelsIChromaPredDcTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri const uint8_t kuiMean[8] = {kuiMean1, kuiMean1, kuiMean1, kuiMean1, kuiMean2, kuiMean2, kuiMean2, kuiMean2}; const uint64_t kuiMean64 = LD64 (kuiMean); - ST64 (pPred , kuiMean64); + ST64 (pPred , kuiMean64); ST64 (pPred + 8 , kuiMean64); ST64 (pPred + 16, kuiMean64); ST64 (pPred + 24, kuiMean64); @@ -528,7 +527,7 @@ void WelsIChromaPredDcTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri void WelsIChromaPredDcNA_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { const uint64_t kuiDcValue64 = (uint64_t)0x8080808080808080ULL; - ST64 (pPred , kuiDcValue64); + ST64 (pPred , kuiDcValue64); ST64 (pPred + 8 , kuiDcValue64); ST64 (pPred + 16, kuiDcValue64); ST64 (pPred + 24, kuiDcValue64); diff --git a/codec/encoder/core/src/md.cpp b/codec/encoder/core/src/md.cpp index 88a06f87..43d9c82d 100644 --- a/codec/encoder/core/src/md.cpp +++ b/codec/encoder/core/src/md.cpp @@ -435,14 +435,14 @@ uint8_t MdInterAnalysisVaaInfo_c (int32_t* pSad8x8) { int32_t AnalysisVaaInfoIntra_c (uint8_t* pDataY, const int32_t kiLineSize) { ENFORCE_STACK_ALIGN_1D (uint16_t, uiAvgBlock, 16, 16) uint16_t* pBlock = &uiAvgBlock[0]; - uint8_t* pEncData = pDataY; - const int32_t kiLineSize2 = kiLineSize << 1; - const int32_t kiLineSize3 = kiLineSize + kiLineSize2; - const int32_t kiLineSize4 = kiLineSize << 2; + uint8_t* pEncData = pDataY; + const int32_t kiLineSize2 = kiLineSize << 1; + const int32_t kiLineSize3 = kiLineSize + kiLineSize2; + const int32_t kiLineSize4 = kiLineSize << 2; int32_t i = 0, j = 0, num = 0; int32_t iSumAvg = 0, iSumSqr = 0; -// analysis_vaa_info_intra_core_c( pDataY, iLineSize, pBlock ); +// analysis_vaa_info_intra_core_c( pDataY, iLineSize, pBlock ); for (; j < 16; j += 4) { num = 0; for (i = 0; i < 16; i += 4, num ++) { @@ -492,9 +492,9 @@ void InitIntraAnalysisVaaInfo (SWelsFuncPtrList* pFuncList, const uint32_t kuiCp bool MdIntraAnalysisVaaInfo (sWelsEncCtx* pEncCtx, uint8_t* pEncMb) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; const int32_t kiLineSize = pCurDqLayer->iEncStride[0]; - const int32_t kiVariance = pEncCtx->pFuncList->pfGetVarianceFromIntraVaa (pEncMb, kiLineSize); + const int32_t kiVariance = pEncCtx->pFuncList->pfGetVarianceFromIntraVaa (pEncMb, kiLineSize); return (kiVariance >= INTRA_VARIANCE_SAD_THRESHOLD); } @@ -527,18 +527,18 @@ typedef struct TagQuarParams { inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefinePointer* pMeRefine, const int32_t kiWidth, const int32_t kiHeight, SQuarRefineParams* pParams, int32_t iStrideEnc) { - PWelsSampleAveragingFunc pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging; + PWelsSampleAveragingFunc pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging; int32_t iCurCost; - uint8_t* pEncMb = pMe->pEncMb; - uint8_t* pTmp = NULL; - const uint8_t kuiPixel = pMe->uiBlockSize; + uint8_t* pEncMb = pMe->pEncMb; + uint8_t* pTmp = NULL; + const uint8_t kuiPixel = pMe->uiBlockSize; pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[0], ME_REFINE_BUF_STRIDE, pParams->pSrcB[0], pParams->iStrideA, kiWidth, kiHeight); iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[0]); if (iCurCost < pParams->iBestCost) { - pParams->iBestQuarPix = ME_QUAR_PIXEL_TOP; + pParams->iBestQuarPix = ME_QUAR_PIXEL_TOP; SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp); } //=========================(0, 1)=======================// @@ -791,9 +791,9 @@ void InitBlkStrideWithRef (int32_t* pBlkStride, const int32_t kiStrideRef) { * iMvdSz = (648*2+1) or (972*2+1); */ void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) { - const int32_t kiSz = kiMvdSz >> 1; - uint16_t* pNegMvd = pMvdCostInter; - uint16_t* pPosMvd = pMvdCostInter + kiSz + 1; + const int32_t kiSz = kiMvdSz >> 1; + uint16_t* pNegMvd = pMvdCostInter; + uint16_t* pPosMvd = pMvdCostInter + kiSz + 1; const int32_t* kpQpLambda = &g_kiQpCostTable[0]; int32_t i, j; @@ -803,15 +803,15 @@ void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) { int32_t iPosSe = 1; for (j = 0; j < kiSz; j += 4) { - *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); - *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); - *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); - *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); + *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); + *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); + *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); + *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); - *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); - *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); - *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); - *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); + *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); + *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); + *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); + *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); } *pNegMvd = kiLambda; pNegMvd += kiSz + 1; @@ -820,12 +820,12 @@ void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) { } void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef, int32_t* pSadPred) { - const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4 - int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2 - const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1 - const int32_t kiSadB = pSadCostCache[1]; - int32_t iSadC = pSadCostCache[2]; - const int32_t kiSadA = pSadCostCache[3]; + const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4 + int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2 + const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1 + const int32_t kiSadB = pSadCostCache[1]; + int32_t iSadC = pSadCostCache[2]; + const int32_t kiSadA = pSadCostCache[3]; int32_t iCount; @@ -865,13 +865,13 @@ void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef, void PredictSadSkip (int8_t* pRefIndexCache, bool* pMbSkipCache, int32_t* pSadCostCache, int32_t uiRef, int32_t* iSadPredSkip) { - const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4 - int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2 - const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1 - const int32_t kiSadB = (pMbSkipCache[1] == 1 ? pSadCostCache[1] : 0); - int32_t iSadC = (pMbSkipCache[2] == 1 ? pSadCostCache[2] : 0); - const int32_t kiSadA = (pMbSkipCache[3] == 1 ? pSadCostCache[3] : 0); - int32_t iRefSkip = pMbSkipCache[2]; + const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4 + int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2 + const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1 + const int32_t kiSadB = (pMbSkipCache[1] == 1 ? pSadCostCache[1] : 0); + int32_t iSadC = (pMbSkipCache[2] == 1 ? pSadCostCache[2] : 0); + const int32_t kiSadA = (pMbSkipCache[3] == 1 ? pSadCostCache[3] : 0); + int32_t iRefSkip = pMbSkipCache[2]; int32_t iCount = 0; diff --git a/codec/encoder/core/src/mv_pred.cpp b/codec/encoder/core/src/mv_pred.cpp index a05d2b2b..d3bad4de 100644 --- a/codec/encoder/core/src/mv_pred.cpp +++ b/codec/encoder/core/src/mv_pred.cpp @@ -43,8 +43,8 @@ namespace WelsEnc { //basic pMv prediction unit for pMv width (4, 2, 1) void PredMv (const SMVComponentUnit* kpMvComp, int8_t iPartIdx, int8_t iPartW, int32_t iRef, SMVUnitXY* sMvp) { - const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1; - const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6; + const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1; + const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6; int32_t iMatchRef; int32_t iLeftRef = kpMvComp->iRefIndexCache[kuiLeftIdx]; @@ -69,8 +69,8 @@ void PredMv (const SMVComponentUnit* kpMvComp, int8_t iPartIdx, int8_t iPartW, i } // b2[diag] b1[top] b0[left] is available! - iMatchRef = (iRef == iLeftRef) << MB_LEFT_BIT; - iMatchRef |= (iRef == iTopRef) << MB_TOP_BIT; + iMatchRef = (iRef == iLeftRef) << MB_LEFT_BIT; + iMatchRef |= (iRef == iTopRef) << MB_TOP_BIT; iMatchRef |= (iRef == iDiagonalRef) << MB_TOPRIGHT_BIT; switch (iMatchRef) { case LEFT_MB_POS:// A @@ -147,37 +147,37 @@ void PredSkipMv (SMbCache* pMbCache, SMVUnitXY* sMvp) { //update pMv and uiRefIndex cache for current MB, only for P_16*16 (SKIP inclusive) void UpdateP16x16MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef, SMVUnitXY* pMv) { // optimized 11/25/2011 - SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; - const uint32_t kuiMv32 = LD32 (pMv); - const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); - uint64_t uiMvBuf[8] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64 }; - const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); - const uint32_t kuiRef32 = BUTTERFLY2x4 (kuiRef16); + SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; + const uint32_t kuiMv32 = LD32 (pMv); + const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); + uint64_t uiMvBuf[8] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64 }; + const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); + const uint32_t kuiRef32 = BUTTERFLY2x4 (kuiRef16); ST32 (pCurMb->pRefIndex, kuiRef32); // update pMv range from 0~15 - memcpy (pCurMb->sMv, uiMvBuf, sizeof (uiMvBuf)); // confirmed_safe_unsafe_usage + memcpy (pCurMb->sMv, uiMvBuf, sizeof (uiMvBuf)); // confirmed_safe_unsafe_usage /* * blocks 0: 7~10, 1: 13~16, 2: 19~22, 3: 25~28 */ - pMvComp->iRefIndexCache[7] = kiRef; + pMvComp->iRefIndexCache[7] = kiRef; ST16 (&pMvComp->iRefIndexCache[8], kuiRef16); - pMvComp->iRefIndexCache[10] = kiRef; - pMvComp->iRefIndexCache[13] = kiRef; + pMvComp->iRefIndexCache[10] = kiRef; + pMvComp->iRefIndexCache[13] = kiRef; ST16 (&pMvComp->iRefIndexCache[14], kuiRef16); - pMvComp->iRefIndexCache[16] = kiRef; - pMvComp->iRefIndexCache[19] = kiRef; + pMvComp->iRefIndexCache[16] = kiRef; + pMvComp->iRefIndexCache[19] = kiRef; ST16 (&pMvComp->iRefIndexCache[20], kuiRef16); - pMvComp->iRefIndexCache[22] = kiRef; - pMvComp->iRefIndexCache[25] = kiRef; + pMvComp->iRefIndexCache[22] = kiRef; + pMvComp->iRefIndexCache[25] = kiRef; ST16 (&pMvComp->iRefIndexCache[26], kuiRef16); - pMvComp->iRefIndexCache[28] = kiRef; + pMvComp->iRefIndexCache[28] = kiRef; /* * blocks 0: 7~10, 1: 13~16, 2: 19~22, 3: 25~28 */ - pMvComp->sMotionVectorCache[7] = *pMv; + pMvComp->sMotionVectorCache[7] = *pMv; ST64 (&pMvComp->sMotionVectorCache[8], kuiMv64); pMvComp->sMotionVectorCache[10] = *pMv; pMvComp->sMotionVectorCache[13] = *pMv; @@ -195,36 +195,36 @@ void UpdateP16x16MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, SMVUnitXY* pMv) { // optimized 11/25/2011 - SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; - const uint32_t kuiMv32 = LD32 (pMv); - const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); - uint64_t uiMvBuf[4] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64 }; - const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; - const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; - const int16_t kiCacheIdx1 = 1 + kiCacheIdx; - const int16_t kiCacheIdx3 = 3 + kiCacheIdx; - const int16_t kiCacheIdx6 = 6 + kiCacheIdx; - const int16_t kiCacheIdx7 = 7 + kiCacheIdx; - const int16_t kiCacheIdx9 = 9 + kiCacheIdx; - const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); + SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; + const uint32_t kuiMv32 = LD32 (pMv); + const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); + uint64_t uiMvBuf[4] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64 }; + const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; + const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; + const int16_t kiCacheIdx1 = 1 + kiCacheIdx; + const int16_t kiCacheIdx3 = 3 + kiCacheIdx; + const int16_t kiCacheIdx6 = 6 + kiCacheIdx; + const int16_t kiCacheIdx7 = 7 + kiCacheIdx; + const int16_t kiCacheIdx9 = 9 + kiCacheIdx; + const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); ST16 (&pCurMb->pRefIndex[ (kiPartIdx >> 2)], kuiRef16); - memcpy (&pCurMb->sMv[kiScan4Idx], uiMvBuf, sizeof (uiMvBuf)); // confirmed_safe_unsafe_usage + memcpy (&pCurMb->sMv[kiScan4Idx], uiMvBuf, sizeof (uiMvBuf)); // confirmed_safe_unsafe_usage /* * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 */ - pMvComp->iRefIndexCache[kiCacheIdx] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx] = kiRef; ST16 (&pMvComp->iRefIndexCache[kiCacheIdx1], kuiRef16); - pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef; - pMvComp->iRefIndexCache[kiCacheIdx6] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx6] = kiRef; ST16 (&pMvComp->iRefIndexCache[kiCacheIdx7], kuiRef16); - pMvComp->iRefIndexCache[kiCacheIdx9] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx9] = kiRef; /* * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 */ - pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv; + pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv; ST64 (&pMvComp->sMotionVectorCache[kiCacheIdx1], kuiMv64); pMvComp->sMotionVectorCache[kiCacheIdx3] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx6] = *pMv; @@ -235,20 +235,20 @@ void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPar void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, SMVUnitXY* pMv) { // optimized 11/25/2011 - SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; - const uint32_t kuiMv32 = LD32 (pMv); - const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); - const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; - const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; - const int16_t kiCacheIdx1 = 1 + kiCacheIdx; - const int16_t kiCacheIdx3 = 3 + kiCacheIdx; - const int16_t kiCacheIdx12 = 12 + kiCacheIdx; - const int16_t kiCacheIdx13 = 13 + kiCacheIdx; - const int16_t kiCacheIdx15 = 15 + kiCacheIdx; - const int16_t kiBlkIdx = kiPartIdx >> 2; - const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); + SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; + const uint32_t kuiMv32 = LD32 (pMv); + const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); + const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; + const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; + const int16_t kiCacheIdx1 = 1 + kiCacheIdx; + const int16_t kiCacheIdx3 = 3 + kiCacheIdx; + const int16_t kiCacheIdx12 = 12 + kiCacheIdx; + const int16_t kiCacheIdx13 = 13 + kiCacheIdx; + const int16_t kiCacheIdx15 = 15 + kiCacheIdx; + const int16_t kiBlkIdx = kiPartIdx >> 2; + const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); - pCurMb->pRefIndex[kiBlkIdx] = kiRef; + pCurMb->pRefIndex[kiBlkIdx] = kiRef; pCurMb->pRefIndex[2 + kiBlkIdx] = kiRef; ST64 (&pCurMb->sMv[kiScan4Idx], kuiMv64); ST64 (&pCurMb->sMv[4 + kiScan4Idx], kuiMv64); @@ -258,17 +258,17 @@ void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t ki /* * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 */ - pMvComp->iRefIndexCache[kiCacheIdx] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx] = kiRef; ST16 (&pMvComp->iRefIndexCache[kiCacheIdx1], kuiRef16); - pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef; - pMvComp->iRefIndexCache[kiCacheIdx12] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx12] = kiRef; ST16 (&pMvComp->iRefIndexCache[kiCacheIdx13], kuiRef16); - pMvComp->iRefIndexCache[kiCacheIdx15] = kiRef; + pMvComp->iRefIndexCache[kiCacheIdx15] = kiRef; /* * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 */ - pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv; + pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv; ST64 (&pMvComp->sMotionVectorCache[kiCacheIdx1], kuiMv64); pMvComp->sMotionVectorCache[kiCacheIdx3] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx12] = *pMv; @@ -279,13 +279,13 @@ void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t ki void UpdateP8x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, SMVUnitXY* pMv) { SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; - const uint32_t kuiMv32 = LD32 (pMv); - const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); - const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; - const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; - const int16_t kiCacheIdx1 = 1 + kiCacheIdx; - const int16_t kiCacheIdx6 = 6 + kiCacheIdx; - const int16_t kiCacheIdx7 = 7 + kiCacheIdx; + const uint32_t kuiMv32 = LD32 (pMv); + const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); + const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; + const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; + const int16_t kiCacheIdx1 = 1 + kiCacheIdx; + const int16_t kiCacheIdx6 = 6 + kiCacheIdx; + const int16_t kiCacheIdx7 = 7 + kiCacheIdx; //mb ST64 (&pCurMb->sMv[ kiScan4Idx], kuiMv64); diff --git a/codec/encoder/core/src/nal_encap.cpp b/codec/encoder/core/src/nal_encap.cpp index b3d36ad5..03c4c057 100644 --- a/codec/encoder/core/src/nal_encap.cpp +++ b/codec/encoder/core/src/nal_encap.cpp @@ -45,31 +45,31 @@ namespace WelsEnc { */ void WelsLoadNal (SWelsEncoderOutput* pEncoderOuput, const int32_t/*EWelsNalUnitType*/ kiType, const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) { - SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput; - SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ pWelsEncoderOuput->iNalIndex ]; - SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader; - const int32_t kiStartPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3); + SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput; + SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ pWelsEncoderOuput->iNalIndex ]; + SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader; + const int32_t kiStartPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3); - sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType; - sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc; - sNalUnitHeader->uiForbiddenZeroBit = 0; + sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType; + sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc; + sNalUnitHeader->uiForbiddenZeroBit = 0; - pRawNal->pRawData = &pWelsEncoderOuput->pBsBuffer[kiStartPos]; - pRawNal->iStartPos = kiStartPos; - pRawNal->iPayloadSize = 0; + pRawNal->pRawData = &pWelsEncoderOuput->pBsBuffer[kiStartPos]; + pRawNal->iStartPos = kiStartPos; + pRawNal->iPayloadSize = 0; } /*! * \brief unload pRawNal NAL */ void WelsUnloadNal (SWelsEncoderOutput* pEncoderOuput) { - SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput; - int32_t* pIdx = &pWelsEncoderOuput->iNalIndex; - SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ *pIdx ]; - const int32_t kiEndPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3); + SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput; + int32_t* pIdx = &pWelsEncoderOuput->iNalIndex; + SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ *pIdx ]; + const int32_t kiEndPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3); /* count payload size of pRawNal NAL */ - pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos; + pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos; ++ (*pIdx); } @@ -79,33 +79,33 @@ void WelsUnloadNal (SWelsEncoderOutput* pEncoderOuput) { */ void WelsLoadNalForSlice (SWelsSliceBs* pSliceBsIn, const int32_t/*EWelsNalUnitType*/ kiType, const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) { - SWelsSliceBs* pSliceBs = pSliceBsIn; - SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ pSliceBs->iNalIndex ]; - SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader; - SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite; - const int32_t kiStartPos = (BsGetBitsPos (pBitStringAux) >> 3); + SWelsSliceBs* pSliceBs = pSliceBsIn; + SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ pSliceBs->iNalIndex ]; + SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader; + SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite; + const int32_t kiStartPos = (BsGetBitsPos (pBitStringAux) >> 3); - sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType; - sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc; - sNalUnitHeader->uiForbiddenZeroBit = 0; + sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType; + sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc; + sNalUnitHeader->uiForbiddenZeroBit = 0; - pRawNal->pRawData = &pSliceBs->pBsBuffer[kiStartPos]; - pRawNal->iStartPos = kiStartPos; - pRawNal->iPayloadSize = 0; + pRawNal->pRawData = &pSliceBs->pBsBuffer[kiStartPos]; + pRawNal->iStartPos = kiStartPos; + pRawNal->iPayloadSize = 0; } /*! * \brief unload pRawNal NAL */ void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBsIn) { - SWelsSliceBs* pSliceBs = pSliceBsIn; - int32_t* pIdx = &pSliceBs->iNalIndex; - SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ *pIdx ]; - SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite; - const int32_t kiEndPos = (BsGetBitsPos (pBitStringAux) >> 3); + SWelsSliceBs* pSliceBs = pSliceBsIn; + int32_t* pIdx = &pSliceBs->iNalIndex; + SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ *pIdx ]; + SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite; + const int32_t kiEndPos = (BsGetBitsPos (pBitStringAux) >> 3); /* count payload size of pRawNal NAL */ - pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos; + pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos; ++ (*pIdx); } @@ -124,7 +124,7 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t int32_t* pDstLen) { const bool kbNALExt = pRawNal->sNalExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_PREFIX || pRawNal->sNalExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_EXT; - int32_t iAssumedNeededLength = NAL_HEADER_SIZE + (kbNALExt ? 3 : 0) + pRawNal->iPayloadSize + 1; + 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 @@ -132,12 +132,12 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t return ENC_RETURN_MEMALLOCERR; //TODO: call the realloc© instead } - uint8_t* pDstStart = (uint8_t*)pDst; - uint8_t* pDstPointer = pDstStart; - uint8_t* pSrcPointer = pRawNal->pRawData; - uint8_t* pSrcEnd = pRawNal->pRawData + pRawNal->iPayloadSize; - int32_t iZeroCount = 0; - int32_t iNalLength = 0; + uint8_t* pDstStart = (uint8_t*)pDst; + uint8_t* pDstPointer = pDstStart; + uint8_t* pSrcPointer = pRawNal->pRawData; + uint8_t* pSrcEnd = pRawNal->pRawData + pRawNal->iPayloadSize; + int32_t iZeroCount = 0; + int32_t iNalLength = 0; *pDstLen = 0; static const uint8_t kuiStartCodePrefix[NAL_HEADER_SIZE] = { 0, 0, 0, 1 }; @@ -145,20 +145,20 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t pDstPointer += 4; /* NAL Unit Header */ - *pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType & + *pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType & 0x1f); if (kbNALExt) { - SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt; + SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt; /* NAL UNIT Extension Header */ - *pDstPointer++ = (0x80) | + *pDstPointer++ = (0x80) | (sNalExt->bIdrFlag << 6); - *pDstPointer++ = (0x80) | + *pDstPointer++ = (0x80) | (sNalExt->uiDependencyId << 4); - *pDstPointer++ = (sNalExt->uiTemporalId << 5) | + *pDstPointer++ = (sNalExt->uiTemporalId << 5) | (sNalExt->bDiscardableFlag << 3) | (0x07); } @@ -166,21 +166,21 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t while (pSrcPointer < pSrcEnd) { if (iZeroCount == 2 && *pSrcPointer <= 3) { //add the code 03 - *pDstPointer++ = 3; - iZeroCount = 0; + *pDstPointer++ = 3; + iZeroCount = 0; } if (*pSrcPointer == 0) { ++ iZeroCount; } else { - iZeroCount = 0; + iZeroCount = 0; } *pDstPointer++ = *pSrcPointer++; } /* count length of NAL Unit */ - iNalLength = (int32_t) (pDstPointer - pDstStart); + iNalLength = (int32_t) (pDstPointer - pDstStart); if (NULL != pDstLen) - *pDstLen = iNalLength; + *pDstLen = iNalLength; return ENC_RETURN_SUCCESS; } diff --git a/codec/encoder/core/src/picture_handle.cpp b/codec/encoder/core/src/picture_handle.cpp index e4017078..adce50f9 100644 --- a/codec/encoder/core/src/picture_handle.cpp +++ b/codec/encoder/core/src/picture_handle.cpp @@ -54,51 +54,51 @@ SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth , const int32_t int32_t iPicWidth = 0; int32_t iPicHeight = 0; - int32_t iPicChromaWidth = 0; - int32_t iPicChromaHeight = 0; - int32_t iLumaSize = 0; - int32_t iChromaSize = 0; + int32_t iPicChromaWidth = 0; + int32_t iPicChromaHeight = 0; + int32_t iLumaSize = 0; + int32_t iChromaSize = 0; - pPic = static_cast (pMa->WelsMallocz (sizeof (SPicture), "pPic")); + pPic = static_cast (pMa->WelsMallocz (sizeof (SPicture), "pPic")); WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); - iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon - iPicHeight = WELS_ALIGN (kiHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical - iPicChromaWidth = iPicWidth >> 1; - iPicChromaHeight = iPicHeight >> 1; - iPicWidth = WELS_ALIGN (iPicWidth, - 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size - iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); - iLumaSize = iPicWidth * iPicHeight; - iChromaSize = iPicChromaWidth * iPicChromaHeight; + iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon + iPicHeight = WELS_ALIGN (kiHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical + iPicChromaWidth = iPicWidth >> 1; + iPicChromaHeight = iPicHeight >> 1; + iPicWidth = WELS_ALIGN (iPicWidth, + 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size + iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); + iLumaSize = iPicWidth * iPicHeight; + iChromaSize = iPicChromaWidth * iPicChromaHeight; - pPic->pBuffer = (uint8_t*)pMa->WelsMalloc (iLumaSize /* luma */ + pPic->pBuffer = (uint8_t*)pMa->WelsMalloc (iLumaSize /* luma */ + (iChromaSize << 1) /* Cb,Cr */ , "pPic->pBuffer"); WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer, FreePicture (pMa, &pPic)); - pPic->iLineSize[0] = iPicWidth; - pPic->iLineSize[1] = pPic->iLineSize[2] = iPicChromaWidth; - pPic->pData[0] = pPic->pBuffer + (1 + pPic->iLineSize[0]) * PADDING_LENGTH; - pPic->pData[1] = pPic->pBuffer + iLumaSize + (((1 + pPic->iLineSize[1]) * PADDING_LENGTH) >> 1); - pPic->pData[2] = pPic->pBuffer + iLumaSize + iChromaSize + (((1 + pPic->iLineSize[2]) * PADDING_LENGTH) >> 1); + pPic->iLineSize[0] = iPicWidth; + pPic->iLineSize[1] = pPic->iLineSize[2] = iPicChromaWidth; + pPic->pData[0] = pPic->pBuffer + (1 + pPic->iLineSize[0]) * PADDING_LENGTH; + pPic->pData[1] = pPic->pBuffer + iLumaSize + (((1 + pPic->iLineSize[1]) * PADDING_LENGTH) >> 1); + pPic->pData[2] = pPic->pBuffer + iLumaSize + iChromaSize + (((1 + pPic->iLineSize[2]) * PADDING_LENGTH) >> 1); - pPic->iWidthInPixel = kiWidth; - pPic->iHeightInPixel = kiHeight; - pPic->iFrameNum = -1; + pPic->iWidthInPixel = kiWidth; + pPic->iHeightInPixel = kiHeight; + pPic->iFrameNum = -1; - pPic->bIsLongRef = false; + pPic->bIsLongRef = false; pPic->iLongTermPicNum = -1; pPic->uiRecieveConfirmed = 0; - pPic->iMarkFrameNum = -1; + pPic->iMarkFrameNum = -1; if (bNeedMbInfo) { const uint32_t kuiCountMbNum = ((15 + kiWidth) >> 4) * ((15 + kiHeight) >> 4); - pPic->uiRefMbType = (uint32_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint32_t), "pPic->uiRefMbType"); + pPic->uiRefMbType = (uint32_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint32_t), "pPic->uiRefMbType"); WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->uiRefMbType, FreePicture (pMa, &pPic)); - pPic->pRefMbQp = (uint8_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint8_t), "pPic->pRefMbQp"); + pPic->pRefMbQp = (uint8_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint8_t), "pPic->pRefMbQp"); WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pRefMbQp, FreePicture (pMa, &pPic)); pPic->sMvList = static_cast (pMa->WelsMallocz (kuiCountMbNum * sizeof (SMVUnitXY), @@ -134,22 +134,22 @@ void FreePicture (CMemoryAlign* pMa, SPicture** ppPic) { pMa->WelsFree (pPic->pBuffer, "pPic->pBuffer"); pPic->pBuffer = NULL; } - pPic->pBuffer = NULL; - pPic->pData[0] = - pPic->pData[1] = - pPic->pData[2] = NULL; - pPic->iLineSize[0] = - pPic->iLineSize[1] = + pPic->pBuffer = NULL; + pPic->pData[0] = + pPic->pData[1] = + pPic->pData[2] = NULL; + pPic->iLineSize[0] = + pPic->iLineSize[1] = pPic->iLineSize[2] = 0; - pPic->iWidthInPixel = 0; - pPic->iHeightInPixel = 0; - pPic->iFrameNum = -1; + pPic->iWidthInPixel = 0; + pPic->iHeightInPixel = 0; + pPic->iFrameNum = -1; - pPic->bIsLongRef = false; - pPic->uiRecieveConfirmed = 0; - pPic->iLongTermPicNum = -1; - pPic->iMarkFrameNum = -1; + pPic->bIsLongRef = false; + pPic->uiRecieveConfirmed = 0; + pPic->iLongTermPicNum = -1; + pPic->iMarkFrameNum = -1; if (pPic->uiRefMbType) { pMa->WelsFree (pPic->uiRefMbType, "pPic->uiRefMbType"); diff --git a/codec/encoder/core/src/property.cpp b/codec/encoder/core/src/property.cpp index e9b97903..85c76ddc 100644 --- a/codec/encoder/core/src/property.cpp +++ b/codec/encoder/core/src/property.cpp @@ -38,7 +38,7 @@ ************************************************************************************* */ #include "property.h" -#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross_platforms +#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross_platforms namespace WelsEnc { #define WELS_CODE_NAME "Wels" #define WELS_LIB_NAME "Encoder" @@ -64,11 +64,11 @@ int32_t GetCodeName (char* pBuf, int32_t iSize) { if (NULL == pBuf) return 0; - iLen = (int32_t)strlen (WELS_CODE_NAME); // confirmed_safe_unsafe_usage + iLen = (int32_t)strlen (WELS_CODE_NAME); // confirmed_safe_unsafe_usage if (iSize <= iLen) return 0; - WelsStrncpy (pBuf, iSize, WELS_CODE_NAME); // confirmed_safe_unsafe_usage + WelsStrncpy (pBuf, iSize, WELS_CODE_NAME); // confirmed_safe_unsafe_usage return iLen; } @@ -85,11 +85,11 @@ int32_t GetLibName (char* pBuf, int32_t iSize) { if (NULL == pBuf) return 0; - iLen = (int32_t)strlen (WELS_LIB_NAME); // confirmed_safe_unsafe_usage + iLen = (int32_t)strlen (WELS_LIB_NAME); // confirmed_safe_unsafe_usage if (iSize <= iLen) return 0; - WelsStrncpy (pBuf, iSize, WELS_LIB_NAME); // confirmed_safe_unsafe_usage + WelsStrncpy (pBuf, iSize, WELS_LIB_NAME); // confirmed_safe_unsafe_usage return iLen; } @@ -106,11 +106,11 @@ int32_t GetVerNum (char* pBuf, int32_t iSize) { if (NULL == pBuf) return 0; - iLen = (int32_t)strlen (WELS_VERSION_STR); // confirmed_safe_unsafe_usage + iLen = (int32_t)strlen (WELS_VERSION_STR); // confirmed_safe_unsafe_usage if (iSize <= iLen) return 0; - WelsStrncpy (pBuf, iSize, WELS_VERSION_STR); // confirmed_safe_unsafe_usage + WelsStrncpy (pBuf, iSize, WELS_VERSION_STR); // confirmed_safe_unsafe_usage return iLen; } @@ -127,11 +127,11 @@ int32_t GetIdentInfo (char* pBuf, int32_t iSize) { if (NULL == pBuf) return 0; - iLen = (int32_t)strlen (WELS_IDENT); // confirmed_safe_unsafe_usage + iLen = (int32_t)strlen (WELS_IDENT); // confirmed_safe_unsafe_usage if (iSize <= iLen) return 0; - WelsStrncpy (pBuf, iSize, WELS_IDENT); // confirmed_safe_unsafe_usage + WelsStrncpy (pBuf, iSize, WELS_IDENT); // confirmed_safe_unsafe_usage return iLen; } diff --git a/codec/encoder/core/src/ratectl.cpp b/codec/encoder/core/src/ratectl.cpp index d38f7a45..61e1b1e5 100644 --- a/codec/encoder/core/src/ratectl.cpp +++ b/codec/encoder/core/src/ratectl.cpp @@ -59,27 +59,27 @@ const int32_t g_kiQpToQstepTable[52] = { }; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0)) void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) { - const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; - const int32_t kiGomSize = pWelsSvcRc->iGomSize; - const int32_t kiGomSizeD = kiGomSize * sizeof (double); - const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t); - const int32_t kiLayerRcSize = kiGomSizeD + (kiGomSizeI * 3) + sizeof (SRCTemporal) * kiMaxTl; - uint8_t* pBaseMem = (uint8_t*)pMA->WelsMalloc (kiLayerRcSize, "pWelsSvcRc->pTemporalOverRc"); + const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; + const int32_t kiGomSize = pWelsSvcRc->iGomSize; + const int32_t kiGomSizeD = kiGomSize * sizeof (double); + const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t); + const int32_t kiLayerRcSize = kiGomSizeD + (kiGomSizeI * 3) + sizeof (SRCTemporal) * kiMaxTl; + uint8_t* pBaseMem = (uint8_t*)pMA->WelsMalloc (kiLayerRcSize, "pWelsSvcRc->pTemporalOverRc"); if (NULL == pBaseMem) return; - pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem; + pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem; pBaseMem += sizeof (SRCTemporal) * kiMaxTl; - pWelsSvcRc->pGomComplexity = (double*)pBaseMem; + pWelsSvcRc->pGomComplexity = (double*)pBaseMem; pBaseMem += kiGomSizeD; - pWelsSvcRc->pGomForegroundBlockNum = (int32_t*)pBaseMem; + pWelsSvcRc->pGomForegroundBlockNum = (int32_t*)pBaseMem; pBaseMem += kiGomSizeI; - pWelsSvcRc->pCurrentFrameGomSad = (int32_t*)pBaseMem; + pWelsSvcRc->pCurrentFrameGomSad = (int32_t*)pBaseMem; pBaseMem += kiGomSizeI; - pWelsSvcRc->pGomCost = (int32_t*)pBaseMem; + pWelsSvcRc->pGomCost = (int32_t*)pBaseMem; - pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC"); + pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC"); } void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) { @@ -90,10 +90,10 @@ void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) { if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) { pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc"); pWelsSvcRc->pTemporalOverRc = NULL; - pWelsSvcRc->pGomComplexity = NULL; - pWelsSvcRc->pGomForegroundBlockNum = NULL; - pWelsSvcRc->pCurrentFrameGomSad = NULL; - pWelsSvcRc->pGomCost = NULL; + pWelsSvcRc->pGomComplexity = NULL; + pWelsSvcRc->pGomForegroundBlockNum = NULL; + pWelsSvcRc->pCurrentFrameGomSad = NULL; + pWelsSvcRc->pGomCost = NULL; } } @@ -121,7 +121,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) { pWelsSvcRc->iNumberMbFrame = iMbWidth * (pDLayerParam->iVideoHeight >> 4); pWelsSvcRc->iSliceNum = pSliceCtx->iSliceNumInFrame; - pWelsSvcRc->iRcVaryPercentage = pEncCtx->pSvcParam->iBitsVaryPercentage; // % -- for temp + pWelsSvcRc->iRcVaryPercentage = pEncCtx->pSvcParam->iBitsVaryPercentage; // % -- for temp pWelsSvcRc->iRcVaryRatio = pWelsSvcRc->iRcVaryPercentage; pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO; @@ -169,9 +169,9 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) { RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pEncCtx->pSvcParam->sDependencyLayers[j].iHighestTemporalId); - bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) || - (SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) || - (SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode)); + bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) || + (SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) || + (SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode)); if (bMultiSliceMode) pWelsSvcRc->iNumberMbGom = pWelsSvcRc->iNumberMbFrame; } @@ -180,7 +180,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) { void RcInitTlWeight (sWelsEncCtx* pEncCtx) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; + SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; const int32_t kiDecompositionStages = pDLayerParam->iDecompositionStages; const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId; @@ -193,7 +193,7 @@ void RcInitTlWeight (sWelsEncCtx* pEncCtx) { n = 0; while (n <= kiHighestTid) { - pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n]; + pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n]; ++ n; } //Calculate the frame index for the current frame and its reference frame @@ -210,16 +210,16 @@ void RcInitTlWeight (sWelsEncCtx* pEncCtx) { } void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; - const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); + const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId; const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate, pDLayerParamInternal->fOutputFrameRate); - const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize; + const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize; int32_t i; pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate; @@ -252,9 +252,9 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { void RcInitVGop (sWelsEncCtx* pEncCtx) { - const int32_t kiDid = pEncCtx->uiDependencyId; + const int32_t kiDid = pEncCtx->uiDependencyId; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; - SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; + SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId; pWelsSvcRc->iRemainingBits = VGOP_SIZE * pWelsSvcRc->iBitsPerFrame; @@ -269,11 +269,11 @@ void RcInitVGop (sWelsEncCtx* pEncCtx) { } void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) { - const int32_t kiDid = pEncCtx->uiDependencyId; - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; - SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; - SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid]; - SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid]; + const int32_t kiDid = pEncCtx->uiDependencyId; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; + SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; + SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid]; + SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid]; const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId; int32_t i; @@ -296,7 +296,7 @@ void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) { pWelsSvcRc->iGopIndexInVGop = 0; pWelsSvcRc->iRemainingBits = 0; - pWelsSvcRc->iBitsPerFrame = 0; + pWelsSvcRc->iBitsPerFrame = 0; //Backup the initial bitrate and fps pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate; @@ -327,14 +327,14 @@ bool RcJudgeBitrateFpsUpdate (sWelsEncCtx* pEncCtx) { #if GOM_TRACE_FLAG void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) { - const int32_t kiDid = pEncCtx->uiDependencyId; - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; + const int32_t kiDid = pEncCtx->uiDependencyId; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; if (pWelsSvcRc->iFrameCodedInVGop) { - const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId; - SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; + const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId; + SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; int32_t iVGopBitrate = 0; - int32_t iTotalBits = pWelsSvcRc->iPaddingBitrateStat; + int32_t iTotalBits = pWelsSvcRc->iPaddingBitrateStat; int32_t iTid = 0; while (iTid <= kiHighestTid) { iTotalBits += pTOverRc[iTid].iGopBitsDq; @@ -356,10 +356,10 @@ void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) { #endif void RcUpdateTemporalZero (sWelsEncCtx* pEncCtx) { - const int32_t kiDid = pEncCtx->uiDependencyId; - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; - SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid]; - const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages); + const int32_t kiDid = pEncCtx->uiDependencyId; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; + SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid]; + const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages); if (pWelsSvcRc->iPreviousGopSize != kiGopSize) { #if GOM_TRACE_FLAG @@ -389,8 +389,8 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) { int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}}; int32_t iBppIndex = 0; - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; if (pDLayerParamInternal->fOutputFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight) dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParamInternal->fOutputFrameRate * @@ -422,7 +422,7 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) { } void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; //obtain the idr qp using previous idr complexity if (pWelsSvcRc->iNumberMbFrame != pWelsSvcRc->iIntraMbCount) { pWelsSvcRc->iIntraComplexity = pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame / @@ -438,9 +438,9 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - int32_t iTl = pEncCtx->uiTemporalId; - SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + int32_t iTl = pEncCtx->uiTemporalId; + SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; int32_t iLumaQp = 0; if (0 == pTOverRc->iPFrameNum) { @@ -515,29 +515,29 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { } void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { - SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx; - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; - const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; - const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast (pWelsSvcRc->iTargetBits) * INT_MULTIPLY, - pWelsSvcRc->iNumberMbFrame); + SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; + const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; + const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast (pWelsSvcRc->iTargetBits) * INT_MULTIPLY, + pWelsSvcRc->iNumberMbFrame); for (int32_t i = 0; i < kiSliceNum; i++) { - pSOverRc->iStartMbSlice = - pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i]; - pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); - pSOverRc->iTotalQpSlice = 0; - pSOverRc->iTotalMbSlice = 0; - pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY); - pSOverRc->iFrameBitsSlice = 0; - pSOverRc->iGomBitsSlice = 0; + pSOverRc->iStartMbSlice = + pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i]; + pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); + pSOverRc->iTotalQpSlice = 0; + pSOverRc->iTotalMbSlice = 0; + pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY); + pSOverRc->iFrameBitsSlice = 0; + pSOverRc->iGomBitsSlice = 0; ++ pSOverRc; } } void RcDecideTargetBits (sWelsEncCtx* pEncCtx) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId]; pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL; //allocate bits @@ -560,17 +560,17 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) { void RcInitGomParameters (sWelsEncCtx* pEncCtx) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; - const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; - const int32_t kiGlobalQp = pEncCtx->iGlobalQp; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; + const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; + const int32_t kiGlobalQp = pEncCtx->iGlobalQp; pWelsSvcRc->iAverageFrameQp = 0; pWelsSvcRc->iMinFrameQp = 51; pWelsSvcRc->iMaxFrameQp = 0; for (int32_t i = 0; i < kiSliceNum; ++i) { - pSOverRc->iComplexityIndexSlice = 0; - pSOverRc->iCalculatedQpSlice = kiGlobalQp; + pSOverRc->iComplexityIndexSlice = 0; + pSOverRc->iCalculatedQpSlice = kiGlobalQp; ++ pSOverRc; } memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double)); @@ -579,16 +579,16 @@ void RcInitGomParameters (sWelsEncCtx* pEncCtx) { void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; - int32_t iLumaQp = pSOverRc->iCalculatedQpSlice; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; + int32_t iLumaQp = pSOverRc->iCalculatedQpSlice; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) { iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp + pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51); } - pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)]; - pCurMb->uiLumaQp = iLumaQp; + pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)]; + pCurMb->uiLumaQp = iLumaQp; } SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) { @@ -615,15 +615,15 @@ SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) { } void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SWelsSvcRc* pWelsSvcRc_Base = NULL; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SWelsSvcRc* pWelsSvcRc_Base = NULL; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; int32_t iAllocateBits = 0; int32_t iSumSad = 0; int32_t iLastGomIndex = 0; int32_t iLeftBits = 0; - const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; + const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; int32_t i; iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom; @@ -653,8 +653,8 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; int64_t iBitsRatio = 1; int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice; @@ -665,13 +665,13 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { } else { //globe decision iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits + 1); - if (iBitsRatio < 8409) //2^(-1.5/6)*10000 + if (iBitsRatio < 8409) //2^(-1.5/6)*10000 pSOverRc->iCalculatedQpSlice += 2; - else if (iBitsRatio < 9439) //2^(-0.5/6)*10000 + else if (iBitsRatio < 9439) //2^(-0.5/6)*10000 pSOverRc->iCalculatedQpSlice += 1; - else if (iBitsRatio > 10600) //2^(0.5/6)*10000 + else if (iBitsRatio > 10600) //2^(0.5/6)*10000 pSOverRc->iCalculatedQpSlice -= 1; - else if (iBitsRatio > 11900) //2^(1.5/6)*10000 + else if (iBitsRatio > 11900) //2^(1.5/6)*10000 pSOverRc->iCalculatedQpSlice -= 2; } @@ -687,7 +687,7 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; + SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame; const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame; //condition 1: whole pBuffer fullness @@ -803,7 +803,7 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iSpatialNum) { SSpatialPicIndex* pSpatialIndexMap = &pEncCtx->sSpatialIndexMap[0]; for (int32_t i = 0; i < iSpatialNum; i++) { - int32_t iCurDid = (pSpatialIndexMap + i)->iDid; + int32_t iCurDid = (pSpatialIndexMap + i)->iDid; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iCurDid]; const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame; const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame; @@ -831,7 +831,7 @@ void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, co pEncCtx->iCheckWindowCurrentTs = pEncCtx->iCheckWindowStartTs = uiTimeStamp; pEncCtx->bCheckWindowStatusRefreshFlag = true; for (int32_t i = 0; i < iSpatialNum; i++) { - int32_t iCurDid = (pSpatialIndexMap + i)->iDid; + int32_t iCurDid = (pSpatialIndexMap + i)->iDid; pEncCtx->pWelsSvcRc[iCurDid].iBufferFullnessSkip = 0; pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] = 0; pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[EVEN_TIME_WINDOW] = 0; @@ -844,7 +844,7 @@ void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, co if (pEncCtx->iCheckWindowInterval >= (TIME_CHECK_WINDOW >> 1) && !pEncCtx->bCheckWindowShiftResetFlag) { pEncCtx->bCheckWindowShiftResetFlag = true; for (int32_t i = 0; i < iSpatialNum; i++) { - int32_t iCurDid = (pSpatialIndexMap + i)->iDid; + int32_t iCurDid = (pSpatialIndexMap + i)->iDid; if (pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] > 0 && pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] != pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[0]) { @@ -863,7 +863,7 @@ void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, co pEncCtx->iCheckWindowInterval = 0; pEncCtx->bCheckWindowShiftResetFlag = false; for (int32_t i = 0; i < iSpatialNum; i++) { - int32_t iCurDid = (pSpatialIndexMap + i)->iDid; + int32_t iCurDid = (pSpatialIndexMap + i)->iDid; if (pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[EVEN_TIME_WINDOW] > 0) { pEncCtx->pWelsSvcRc[iCurDid].bNeedShiftWindowCheck[ODD_TIME_WINDOW] = true; } else { @@ -884,7 +884,7 @@ void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) { if (pWelsSvcRc->iBufferFullnessPadding < kiBufferThreshold) { pWelsSvcRc->iPaddingSize = -pWelsSvcRc->iBufferFullnessPadding; - pWelsSvcRc->iPaddingSize >>= 3; // /8 + pWelsSvcRc->iPaddingSize >>= 3; // /8 pWelsSvcRc->iBufferFullnessPadding = 0; } else pWelsSvcRc->iPaddingSize = 0; @@ -912,7 +912,7 @@ void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx; int32_t iTotalQp = 0, iTotalMb = 0; int32_t i; @@ -953,9 +953,9 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { } void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - const int32_t kiTl = pEncCtx->uiTemporalId; - SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl]; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + const int32_t kiTl = pEncCtx->uiTemporalId; + SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl]; if (0 == pTOverRc->iPFrameNum) { pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep; @@ -996,7 +996,7 @@ void WelsRcPictureInitGom (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; if (pEncCtx->eSliceType == I_SLICE) { - if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed + if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed RcInitRefreshParameter (pEncCtx); } } @@ -1046,11 +1046,11 @@ void WelsRcPictureInfoUpdateGom (sWelsEncCtx* pEncCtx, int32_t iLayerSize) { } void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - const int32_t kiSliceId = pSlice->uiSliceIdx; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; - SBitStringAux* bs = pSlice->pSliceBsa; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + const int32_t kiSliceId = pSlice->uiSliceIdx; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; + SBitStringAux* bs = pSlice->pSliceBsa; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; pSOverRc->iBsPosSlice = BsGetBitsPos (bs); @@ -1073,11 +1073,11 @@ void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) { } void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) { - SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SBitStringAux* bs = pSlice->pSliceBsa; - int32_t iSliceId = pSlice->uiSliceIdx; - SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; - const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; + SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; + SBitStringAux* bs = pSlice->pSliceBsa; + int32_t iSliceId = pSlice->uiSliceIdx; + SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; + const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice; pSOverRc->iFrameBitsSlice += iCurMbBits; @@ -1095,10 +1095,10 @@ void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma void WelsRcPictureInitDisable (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; + SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; const int32_t kiQp = pDLayerParam->iDLayerQp; - pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp); + pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp); if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) { pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY - @@ -1114,9 +1114,9 @@ void WelsRcPictureInfoUpdateDisable (sWelsEncCtx* pEncCtx, int32_t iLayerSize) } void WelsRcMbInitDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) { - int32_t iLumaQp = pEncCtx->iGlobalQp; + int32_t iLumaQp = pEncCtx->iGlobalQp; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; @@ -1134,7 +1134,7 @@ void WelsRcMbInfoUpdateDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCos } void WelRcPictureInitBufferBasedQp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { - SVAAFrameInfo* pVaa = static_cast (pEncCtx->pVaa); + SVAAFrameInfo* pVaa = static_cast (pEncCtx->pVaa); int32_t iMinQp = MIN_SCREEN_QP; if (pVaa->eSceneChangeIdc == LARGE_CHANGED_SCENE) @@ -1292,11 +1292,11 @@ void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFram } void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; - SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; + SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; int32_t iLumaQp = pWelsSvcRc->iLastCalculatedQScale; //decide one frame bits allocated if (pEncCtx->eSliceType == I_SLICE) { - if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed + if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed RcInitRefreshParameter (pEncCtx); double dBpp = 0.05; if ((pDLayerParam->fFrameRate > EPSN) && (pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)) @@ -1344,15 +1344,15 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp } } else { - int32_t iTl = pEncCtx->uiTemporalId; - SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; + int32_t iTl = pEncCtx->uiTemporalId; + SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; int32_t iMaxTh = static_cast (pWelsSvcRc->iBufferSizeSkip - pWelsSvcRc->iBufferFullnessSkip); int32_t iMinTh = iMaxTh / (iTl + 2); - SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; - const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); + SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; + const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); int32_t iAverageFrameSize = (int32_t) ((double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate)); - const int32_t kiGopBits = iAverageFrameSize * kiGopSize; + const int32_t kiGopBits = iAverageFrameSize * kiGopSize; int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY, pTOverRc->iFrameCmplxMean); iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE); diff --git a/codec/encoder/core/src/ref_list_mgr_svc.cpp b/codec/encoder/core/src/ref_list_mgr_svc.cpp index 8a774cde..cfee8c88 100644 --- a/codec/encoder/core/src/ref_list_mgr_svc.cpp +++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp @@ -40,7 +40,7 @@ namespace WelsEnc { * reset LTR marking , recovery ,feedback state to default */ void ResetLtrState (SLTRState* pLtr) { - pLtr->bReceivedT0LostFlag = false; + pLtr->bReceivedT0LostFlag = false; pLtr->iLastRecoverFrameNum = 0; pLtr->iLastCorFrameNumDec = -1; pLtr->iCurFrameNumInDec = -1; @@ -48,7 +48,7 @@ void ResetLtrState (SLTRState* pLtr) { // LTR mark pLtr->iLTRMarkMode = LTR_DIRECT_MARK; pLtr->iLTRMarkSuccessNum = 0; //successful marked num - pLtr->bLTRMarkingFlag = false; //decide whether current frame marked as LTR + pLtr->bLTRMarkingFlag = false; //decide whether current frame marked as LTR pLtr->bLTRMarkEnable = false; //when LTR is confirmed and the interval is no smaller than the marking period pLtr->iCurLtrIdx = 0; memset (&pLtr->iLastLtrIdx , 0 , sizeof (pLtr->iLastLtrIdx)) ; @@ -149,7 +149,7 @@ static inline int32_t CompareFrameNum (int32_t iFrameNumA, int32_t iFrameNumB, i * delete failed mark according LTR recovery pRequest */ static inline void DeleteInvalidLTR (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SPicture** pLongRefList = pRefList->pLongRefList; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; int32_t iMaxFrameNumPlus1 = (1 << pCtx->pSps->uiLog2MaxFrameNum); @@ -191,8 +191,8 @@ static inline void DeleteInvalidLTR (sWelsEncCtx* pCtx) { * handle LTR Mark feedback message */ static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; - SPicture** pLongRefList = pRefList->pLongRefList; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SPicture** pLongRefList = pRefList->pLongRefList; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; int32_t i, j; @@ -246,7 +246,7 @@ static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) { * LTR mark process */ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SPicture** pLongRefList = pRefList->pLongRefList; SPicture** pShortRefList = pRefList->pShortRefList; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; @@ -295,9 +295,9 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) { if (pRefList->uiLongRefCount > 0) { memmove (&pRefList->pLongRefList[1], &pRefList->pLongRefList[0], - pRefList->uiLongRefCount * sizeof (SPicture*)); // confirmed_safe_unsafe_usage + pRefList->uiLongRefCount * sizeof (SPicture*)); // confirmed_safe_unsafe_usage } - pLongRefList[0] = pShortRefList[i]; + pLongRefList[0] = pShortRefList[i]; pRefList->uiLongRefCount++; if (pRefList->uiLongRefCount > pCtx->pSvcParam->iLTRRefNum) { pRefList->pLongRefList[pRefList->uiLongRefCount - 1]->SetUnref(); @@ -308,7 +308,7 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) { } static inline void LTRMarkProcessScreen (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SPicture** pLongRefList = pRefList->pLongRefList; int32_t iLtrIdx = pCtx->pDecPic->iLongTermPicNum; pCtx->pVaa->uiMarkLongTermPicIdx = pCtx->pDecPic->iLongTermPicNum; @@ -323,8 +323,8 @@ static inline void LTRMarkProcessScreen (sWelsEncCtx* pCtx) { } static void PrefetchNextBuffer (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; - const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; int32_t i; pRefList->pNextBuffer = NULL; @@ -347,14 +347,14 @@ static void PrefetchNextBuffer (sWelsEncCtx* pCtx) { * update reference picture list */ bool WelsUpdateRefList (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; - SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; + SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; - int32_t iRefIdx = 0; - const uint8_t kuiTid = pCtx->uiTemporalId; - const uint8_t kuiDid = pCtx->uiDependencyId; - const EWelsSliceType keSliceType = pCtx->eSliceType; + int32_t iRefIdx = 0; + const uint8_t kuiTid = pCtx->uiTemporalId; + const uint8_t kuiDid = pCtx->uiDependencyId; + const EWelsSliceType keSliceType = pCtx->eSliceType; uint32_t i = 0; // Need update pRef list in case store base layer or target dependency layer construction if (NULL == pCtx->pCurDqLayer) @@ -364,7 +364,7 @@ bool WelsUpdateRefList (sWelsEncCtx* pCtx) { return false; if (NULL != pCtx->pDecPic) { -#if !defined(ENABLE_FRAME_DUMP) // to save complexity, 1/6/2009 +#if !defined(ENABLE_FRAME_DUMP) // to save complexity, 1/6/2009 if ((pParamD->iHighestTemporalId == 0) || (kuiTid < pParamD->iHighestTemporalId)) #endif// !ENABLE_FRAME_DUMP // Expanding picture for future reference @@ -374,11 +374,11 @@ bool WelsUpdateRefList (sWelsEncCtx* pCtx) { // move picture in list pCtx->pDecPic->uiTemporalId = kuiTid; - pCtx->pDecPic->uiSpatialId = kuiDid; - pCtx->pDecPic->iFrameNum = pCtx->iFrameNum; - pCtx->pDecPic->iFramePoc = pCtx->iPOC; + pCtx->pDecPic->uiSpatialId = kuiDid; + pCtx->pDecPic->iFrameNum = pCtx->iFrameNum; + pCtx->pDecPic->iFramePoc = pCtx->iPOC; pCtx->pDecPic->uiRecieveConfirmed = RECIEVE_UNKOWN; - pCtx->pDecPic->bUsedAsRef = true; + pCtx->pDecPic->bUsedAsRef = true; for (iRefIdx = pRefList->uiShortRefCount - 1; iRefIdx >= 0; --iRefIdx) { pRefList->pShortRefList[iRefIdx + 1] = pRefList->pShortRefList[iRefIdx]; @@ -409,7 +409,7 @@ bool WelsUpdateRefList (sWelsEncCtx* pCtx) { DeleteSTRFromShortList (pCtx, 0); } } - } else { // in case IDR currently coding + } else { // in case IDR currently coding if (pCtx->pSvcParam->bEnableLongTermReference) { LTRMarkProcess (pCtx); @@ -428,7 +428,7 @@ bool WelsUpdateRefList (sWelsEncCtx* pCtx) { bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) { SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SPicture** pLongRefList = pRefList->pLongRefList; int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1); int32_t iMaxFrameNumPlus1 = (1 << pCtx->pSps->uiLog2MaxFrameNum); @@ -446,7 +446,7 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) { } void WelsMarkPic (sWelsEncCtx* pCtx) { SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); + const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1); int32_t iSliceIdx = 0; @@ -467,9 +467,9 @@ void WelsMarkPic (sWelsEncCtx* pCtx) { } for (iSliceIdx = 0; iSliceIdx < kiCountSliceNum; iSliceIdx++) { - SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; - SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; - SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; + SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; + SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; + SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; memset (pRefPicMark, 0, sizeof (SRefPicMarking)); @@ -555,11 +555,11 @@ void FilterLTRMarkingFeedback (sWelsEncCtx* pCtx, SLTRMarkingFeedback* pLTRMarki * build reference picture list */ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; - SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; - const uint8_t kuiTid = pCtx->uiTemporalId; - uint32_t i = 0; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; + const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; + const uint8_t kuiTid = pCtx->uiTemporalId; + uint32_t i = 0; // to support any type of cur_dq->mgs_control // [ 0: using current layer to do ME/MC; @@ -568,7 +568,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe // build reference list 0/1 if applicable - pCtx->iNumRef0 = 0; + pCtx->iNumRef0 = 0; if (pCtx->eSliceType != I_SLICE) { if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bReceivedT0LostFlag && pCtx->uiTemporalId == 0) { @@ -586,7 +586,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe for (i = 0; i < pRefList->uiShortRefCount; ++ i) { SPicture* pRef = pRefList->pShortRefList[i]; if (pRef != NULL && pRef->bUsedAsRef && pRef->iFramePoc >= 0 && pRef->uiTemporalId <= kuiTid) { - pCtx->pRefList0[pCtx->iNumRef0++] = pRef; + pCtx->pRefList0[pCtx->iNumRef0++] = pRef; WelsLog (& (pCtx->sLogCtx), WELS_LOG_DETAIL, "WelsBuildRefList pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d", pCtx->uiTemporalId, pRef->iFrameNum, pRef->uiTemporalId); @@ -594,13 +594,13 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe } } } - } else { // safe for IDR + } else { // safe for IDR WelsResetRefList (pCtx); //for IDR, SHOULD reset pRef list. ResetLtrState (&pCtx->pLtr[pCtx->uiDependencyId]); //SHOULD update it when IDR. for (int32_t k = 0; k < MAX_TEMPORAL_LEVEL; k++) { pCtx->bRefOfCurTidIsLtr[pCtx->uiDependencyId][k] = false; } - pCtx->pRefList0[0] = NULL; + pCtx->pRefList0[0] = NULL; } if (pCtx->iNumRef0 > kiNumRef) @@ -609,7 +609,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe } static void UpdateBlockStatic (sWelsEncCtx* pCtx) { - SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); assert (pCtx->iNumRef0 == 1); //multi-ref is not support yet? for (int32_t idx = 0; idx < pCtx->iNumRef0; idx++) { //TODO: we need to re-factor the source picture storage first, @@ -627,9 +627,9 @@ static void UpdateBlockStatic (sWelsEncCtx* pCtx) { */ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) { SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - int32_t iIdx = 0; - const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); - int32_t iAbsDiffPicNumMinus1 = -1; + int32_t iIdx = 0; + const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); + int32_t iAbsDiffPicNumMinus1 = -1; assert (kiCountSliceNum > 0); @@ -638,10 +638,10 @@ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t u iAbsDiffPicNumMinus1 = pCtx->iFrameNum - (pCtx->pRefList0[0]->iFrameNum) - 1; for (iIdx = 0; iIdx < kiCountSliceNum; iIdx++) { - SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt; - SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; - SRefPicListReorderSyntax* pRefReorder = &pSliceHdr->sRefReordering; - SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; + SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt; + SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; + SRefPicListReorderSyntax* pRefReorder = &pSliceHdr->sRefReordering; + SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; /*syntax for num_ref_idx_l0_active_minus1*/ pSliceHdr->uiRefCount = pCtx->iNumRef0; @@ -713,10 +713,10 @@ static void UpdateSrcPicList (sWelsEncCtx* pCtx) { } bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; - SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; - SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; - const uint8_t kuiTid = pCtx->uiTemporalId; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; + SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; + const uint8_t kuiTid = pCtx->uiTemporalId; // Need update ref list in case store base layer or target dependency layer construction if (NULL == pCtx->pCurDqLayer) return false; @@ -725,7 +725,7 @@ bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) { return false; if (NULL != pCtx->pDecPic) { -#if !defined(ENABLE_FRAME_DUMP) // to save complexity, 1/6/2009 +#if !defined(ENABLE_FRAME_DUMP) // to save complexity, 1/6/2009 if ((pParamD->iHighestTemporalId == 0) || (kuiTid < pParamD->iHighestTemporalId)) #endif// !ENABLE_FRAME_DUMP // Expanding picture for future reference @@ -734,13 +734,13 @@ bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) { pCtx->pFuncList->sExpandPicFunc.pfExpandLumaPicture, pCtx->pFuncList->sExpandPicFunc.pfExpandChromaPicture); // move picture in list - pCtx->pDecPic->uiTemporalId = pCtx->uiTemporalId; - pCtx->pDecPic->uiSpatialId = pCtx->uiDependencyId; - pCtx->pDecPic->iFrameNum = pCtx->iFrameNum; - pCtx->pDecPic->iFramePoc = pCtx->iPOC; - pCtx->pDecPic->bUsedAsRef = true; - pCtx->pDecPic->bIsLongRef = true; - pCtx->pDecPic->bIsSceneLTR = pLtr->bLTRMarkingFlag || (pCtx->pSvcParam->bEnableLongTermReference + pCtx->pDecPic->uiTemporalId = pCtx->uiTemporalId; + pCtx->pDecPic->uiSpatialId = pCtx->uiDependencyId; + pCtx->pDecPic->iFrameNum = pCtx->iFrameNum; + pCtx->pDecPic->iFramePoc = pCtx->iPOC; + pCtx->pDecPic->bUsedAsRef = true; + pCtx->pDecPic->bIsLongRef = true; + pCtx->pDecPic->bIsSceneLTR = pLtr->bLTRMarkingFlag || (pCtx->pSvcParam->bEnableLongTermReference && pCtx->eSliceType == I_SLICE); pCtx->pDecPic->iLongTermPicNum = pLtr->iCurLtrIdx; } @@ -749,7 +749,7 @@ bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) { LTRMarkProcessScreen (pCtx); pLtr->bLTRMarkingFlag = false; ++pLtr->uiLtrMarkInterval; - } else { // in case IDR currently coding + } else { // in case IDR currently coding LTRMarkProcessScreen (pCtx); pLtr->iCurLtrIdx = 1; pLtr->iSceneLtrIdx = 1; @@ -761,10 +761,10 @@ bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) { return true; } bool WelsBuildRefListScreen (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) { - SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; + SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SWelsSvcCodingParam* pParam = pCtx->pSvcParam; SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); - const int32_t iNumRef = pParam->iNumRefFrame; + const int32_t iNumRef = pParam->iNumRefFrame; pCtx->iNumRef0 = 0; if (pCtx->eSliceType != I_SLICE) { @@ -805,7 +805,7 @@ bool WelsBuildRefListScreen (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBes WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "WelsBuildRefListScreen(), CurrentFramePoc=%d, isLTR=%d", iPOC, pCtx->bCurFrameMarkedAsSceneLtr); for (int j = 0; j < iNumRef; j++) { - SPicture* pARefPicture = pRefList->pLongRefList[j]; + SPicture* pARefPicture = pRefList->pLongRefList[j]; if (pARefPicture != NULL) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "WelsBuildRefListScreen()\tRefLot[%d]: iPoc=%d, iPictureType=%d, bUsedAsRef=%d, bIsLongRef=%d, bIsSceneLTR=%d, uiTemporalId=%d, iFrameNum=%d, iMarkFrameNum=%d, iLongTermPicNum=%d, uiRecieveConfirmed=%d", @@ -828,7 +828,7 @@ bool WelsBuildRefListScreen (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBes // dealing with IDR WelsResetRefList (pCtx); //for IDR, SHOULD reset pRef list. ResetLtrState (&pCtx->pLtr[pCtx->uiDependencyId]); //SHOULD update it when IDR. - pCtx->pRefList0[0] = NULL; + pCtx->pRefList0[0] = NULL; } if (pCtx->iNumRef0 > iNumRef) { pCtx->iNumRef0 = iNumRef; @@ -850,8 +850,8 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) { iMaxActualLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1 - WELS_MAX (iMaxTid , 1); SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; - SPicture** ppLongRefList = pRefList->pLongRefList; - const int32_t iNumRef = pCtx->pSvcParam->iNumRefFrame; + SPicture** ppLongRefList = pRefList->pLongRefList; + const int32_t iNumRef = pCtx->pSvcParam->iNumRefFrame; int32_t i; const int32_t iLongRefNum = iNumRef - STR_ROOM; const bool bIsRefListNotFull = pRefList->uiLongRefCount < iLongRefNum; @@ -876,7 +876,7 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) { } } } else { - int32_t iRefNum_t[MAX_TEMPORAL_LAYER_NUM] = {0}; + int32_t iRefNum_t[MAX_TEMPORAL_LAYER_NUM] = {0}; for (i = 0 ; i < pRefList->uiLongRefCount ; ++i) { if (ppLongRefList[i]->bUsedAsRef && ppLongRefList[i]->bIsLongRef && (!ppLongRefList[i]->bIsSceneLTR)) { ++iRefNum_t[ ppLongRefList[i]->uiTemporalId ]; @@ -919,9 +919,9 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) { const int32_t iMaxLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1; const int32_t iSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); for (int32_t iSliceIdx = 0; iSliceIdx < iSliceNum; iSliceIdx++) { - SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; - SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; - SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; + SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; + SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; + SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; memset (pRefPicMark, 0, sizeof (SRefPicMarking)); if (pCtx->pSvcParam->bEnableLongTermReference) { diff --git a/codec/encoder/core/src/sample.cpp b/codec/encoder/core/src/sample.cpp index 80c6c6e2..6906dac1 100644 --- a/codec/encoder/core/src/sample.cpp +++ b/codec/encoder/core/src/sample.cpp @@ -179,7 +179,7 @@ int32_t WelsSampleSatdIntra4x4Combined3_c (uint8_t* pDec, int32_t iDecStride, ui iBestCost = iCurCost; } - memcpy (pDst, uiLocalBuffer[iBestMode], 16 * sizeof (uint8_t)); // confirmed_safe_unsafe_usage + memcpy (pDst, uiLocalBuffer[iBestMode], 16 * sizeof (uint8_t)); // confirmed_safe_unsafe_usage *pBestMode = iBestMode; return iBestCost; @@ -220,7 +220,7 @@ int32_t WelsSampleSatdIntra8x8Combined3_c (uint8_t* pDecCb, int32_t iDecStride, iBestCost = iCurCost; } - *pBestMode = iBestMode; + *pBestMode = iBestMode; return iBestCost; diff --git a/codec/encoder/core/src/set_mb_syn_cavlc.cpp b/codec/encoder/core/src/set_mb_syn_cavlc.cpp index c8971b31..2a6ee2b4 100644 --- a/codec/encoder/core/src/set_mb_syn_cavlc.cpp +++ b/codec/encoder/core/src/set_mb_syn_cavlc.cpp @@ -233,18 +233,18 @@ int32_t WriteBlockResidualCavlc (SWelsFuncPtrList* pFuncList, int16_t* pCoffLev void StashMBStatusCavlc (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun) { SBitStringAux* pBs = pSlice->pSliceBsa; - pDss->pBsStackBufPtr = pBs->pCurBuf; - pDss->uiBsStackCurBits = pBs->uiCurBits; - pDss->iBsStackLeftBits = pBs->iLeftBits; - pDss->uiLastMbQp = pSlice->uiLastMbQp; + pDss->pBsStackBufPtr = pBs->pCurBuf; + pDss->uiBsStackCurBits = pBs->uiCurBits; + pDss->iBsStackLeftBits = pBs->iLeftBits; + pDss->uiLastMbQp = pSlice->uiLastMbQp; pDss->iMbSkipRunStack = iMbSkipRun; } int32_t StashPopMBStatusCavlc (SDynamicSlicingStack* pDss, SSlice* pSlice) { SBitStringAux* pBs = pSlice->pSliceBsa; - pBs->pCurBuf = pDss->pBsStackBufPtr; - pBs->uiCurBits = pDss->uiBsStackCurBits; - pBs->iLeftBits = pDss->iBsStackLeftBits; - pSlice->uiLastMbQp = pDss->uiLastMbQp; + pBs->pCurBuf = pDss->pBsStackBufPtr; + pBs->uiCurBits = pDss->uiBsStackCurBits; + pBs->iLeftBits = pDss->iBsStackLeftBits; + pSlice->uiLastMbQp = pDss->uiLastMbQp; return pDss->iMbSkipRunStack; } void StashMBStatusCabac (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun) { diff --git a/codec/encoder/core/src/slice_multi_threading.cpp b/codec/encoder/core/src/slice_multi_threading.cpp index d40cf52d..95bf79c4 100644 --- a/codec/encoder/core/src/slice_multi_threading.cpp +++ b/codec/encoder/core/src/slice_multi_threading.cpp @@ -56,7 +56,7 @@ #include "svc_encode_slice.h" #include "deblocking.h" #include "svc_enc_golomb.h" -#include "crt_util_safe_x.h" // for safe crt like calls +#include "crt_util_safe_x.h" // for safe crt like calls #include "rc.h" #include "cpu.h" @@ -73,17 +73,17 @@ namespace WelsEnc { void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, SMB* pMbList, const int32_t uiSliceIdc) { - const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; - const int32_t kiMbWidth = pSliceCtx->iMbWidth; - int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; - const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; + const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; + const int32_t kiMbWidth = pSliceCtx->iMbWidth; + int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; + const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; do { - SMB* pMb = &pMbList[iIdx]; - uint32_t uiNeighborAvailFlag = 0; - const int32_t kiMbXY = pMb->iMbXY; - const int32_t kiMbX = pMb->iMbX; - const int32_t kiMbY = pMb->iMbY; + SMB* pMb = &pMbList[iIdx]; + uint32_t uiNeighborAvailFlag = 0; + const int32_t kiMbXY = pMb->iMbXY; + const int32_t kiMbX = pMb->iMbX; + const int32_t kiMbY = pMb->iMbY; bool bLeft; bool bTop; bool bLeftTop; @@ -112,26 +112,26 @@ void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, if (bRightTop) { uiNeighborAvailFlag |= TOPRIGHT_MB_POS; } - pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; - pMb->uiSliceIdc = uiSliceIdc; + pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; + pMb->uiSliceIdc = uiSliceIdc; ++ iIdx; } while (iIdx <= kiEndMbInSlice); } void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) { - int32_t* pRatioList = (int32_t*)pRatio; + int32_t* pRatioList = (int32_t*)pRatio; int32_t iAvI[MAX_SLICES_NUM]; - int32_t iSumAv = 0; - uint32_t* pSliceTime = (uint32_t*)pSliceConsume; - int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice; - const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; - int32_t iSliceIdx = 0; + int32_t iSumAv = 0; + uint32_t* pSliceTime = (uint32_t*)pSliceConsume; + int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice; + const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; + int32_t iSliceIdx = 0; WelsEmms(); while (iSliceIdx < kiSliceCount) { - iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pCountMbInSlice[iSliceIdx], pSliceTime[iSliceIdx]); + iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pCountMbInSlice[iSliceIdx], pSliceTime[iSliceIdx]); MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), pSliceConsumeTime[%d]= %d us, slice_run= %d", iSliceIdx, pSliceTime[iSliceIdx], pCountMbInSlice[iSliceIdx]); @@ -145,10 +145,10 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice } int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { - uint32_t* pSliceConsume = (uint32_t*)pConsumeTime; - uint32_t uiTotalConsume = 0; - int32_t iSliceIdx = 0; - int32_t iNeedAdj = false; + uint32_t* pSliceConsume = (uint32_t*)pConsumeTime; + uint32_t uiTotalConsume = 0; + int32_t iSliceIdx = 0; + int32_t iNeedAdj = false; WelsEmms(); @@ -164,9 +164,9 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { } iSliceIdx = 0; - float fThr = EPSN; // threshold for various cores cases - float fRmse = .0f; // root mean square error of pSlice consume ratios - const float kfMeanRatio = 1.0f / iSliceNum; + float fThr = EPSN; // threshold for various cores cases + float fRmse = .0f; // root mean square error of pSlice consume ratios + const float kfMeanRatio = 1.0f / iSliceNum; do { const float fRatio = 1.0f * pSliceConsume[iSliceIdx] / uiTotalConsume; const float fDiffRatio = fRatio - kfMeanRatio; @@ -183,7 +183,7 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { } else fThr = 1.0f; if (fRmse > fThr) - iNeedAdj = true; + iNeedAdj = true; MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] NeedDynamicAdjust(), herein adjustment decision is made (iNeedAdj= %d) by: fRmse of pSlice complexity ratios %.6f, the corresponding threshold %.6f, iCountSliceNum %d", iNeedAdj, fRmse, fThr, iSliceNum); @@ -195,15 +195,15 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, SDqLayer* pCurDqLayer, void* pComplexRatio, int32_t iCurDid) { - SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx; - const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; - const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; - int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required - int32_t iMaximalMbNum = 0; // dynamically assign later - int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio; - int32_t iMbNumLeft = kiCountNumMb; - int32_t iRunLen[MAX_THREADS_NUM] = {0}; - int32_t iSliceIdx = 0; + SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx; + const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; + const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; + int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required + int32_t iMaximalMbNum = 0; // dynamically assign later + int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio; + int32_t iMbNumLeft = kiCountNumMb; + int32_t iRunLen[MAX_THREADS_NUM] = {0}; + int32_t iSliceIdx = 0; int32_t iNumMbInEachGom = 0; SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[iCurDid]; @@ -222,19 +222,19 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, if (iNumMbInEachGom * kiCountSliceNum >= kiCountNumMb) { return; } - iMinimalMbNum = iNumMbInEachGom; + iMinimalMbNum = iNumMbInEachGom; } - if (kiCountSliceNum < 2 || (kiCountSliceNum & 0x01)) // we need suppose uiSliceNum is even for multiple threading + if (kiCountSliceNum < 2 || (kiCountSliceNum & 0x01)) // we need suppose uiSliceNum is even for multiple threading return; - iMaximalMbNum = kiCountNumMb - (kiCountSliceNum - 1) * iMinimalMbNum; + iMaximalMbNum = kiCountNumMb - (kiCountSliceNum - 1) * iMinimalMbNum; WelsEmms(); MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, "[MT] DynamicAdjustSlicing(), iDid= %d, iCountNumMb= %d", iCurDid, kiCountNumMb); - iSliceIdx = 0; + iSliceIdx = 0; while (iSliceIdx + 1 < kiCountSliceNum) { int32_t iNumMbAssigning = WELS_DIV_ROUND (kiCountNumMb * pSliceComplexRatio[iSliceIdx], INT_MULTIPLY); @@ -245,24 +245,24 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, // make sure one GOM at least in each pSlice for safe if (iNumMbAssigning < iMinimalMbNum) - iNumMbAssigning = iMinimalMbNum; + iNumMbAssigning = iMinimalMbNum; else if (iNumMbAssigning > iMaximalMbNum) - iNumMbAssigning = iMaximalMbNum; + iNumMbAssigning = iMaximalMbNum; assert (iNumMbAssigning > 0); iMbNumLeft -= iNumMbAssigning; - if (iMbNumLeft <= 0) { // error due to we can not support slice_skip now yet, do not adjust this time + if (iMbNumLeft <= 0) { // error due to we can not support slice_skip now yet, do not adjust this time assert (0); return; } - iRunLen[iSliceIdx] = iNumMbAssigning; + iRunLen[iSliceIdx] = iNumMbAssigning; MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx], iNumMbAssigning); ++ iSliceIdx; - iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts + iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts } iRunLen[iSliceIdx] = iMbNumLeft; MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, @@ -271,8 +271,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) { - const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; - int32_t iThreadIdx = 0; + const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; + int32_t iThreadIdx = 0; do { WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]); WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]); @@ -286,31 +286,31 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen, const int32_t iTargetSpatialBsSize) { - CMemoryAlign* pMa = NULL; + CMemoryAlign* pMa = NULL; SWelsSvcCodingParam* pPara = NULL; - SSliceThreading* pSmt = NULL; - SWelsSliceBs* pSliceB = NULL; - uint8_t* pBsBase = NULL; - int32_t iNumSpatialLayers = 0; - int32_t iThreadNum = 0; - int32_t iIdx = 0; + SSliceThreading* pSmt = NULL; + SWelsSliceBs* pSliceB = NULL; + uint8_t* pBsBase = NULL; + int32_t iNumSpatialLayers = 0; + int32_t iThreadNum = 0; + int32_t iIdx = 0; int32_t iSliceBsBufferSize = 0; - int16_t iMaxSliceNum = 1; + int16_t iMaxSliceNum = 1; int32_t iReturn = ENC_RETURN_SUCCESS; if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) return 1; - pMa = (*ppCtx)->pMemAlign; + pMa = (*ppCtx)->pMemAlign; pPara = pCodingParam; - iNumSpatialLayers = pPara->iSpatialLayerNum; - iThreadNum = pPara->iCountThreadsNum; + iNumSpatialLayers = pPara->iSpatialLayerNum; + iThreadNum = pPara->iCountThreadsNum; iMaxSliceNum = (*ppCtx)->iMaxSliceCount; - pSmt = (SSliceThreading*)pMa->WelsMalloc (sizeof (SSliceThreading), "SSliceThreading"); + pSmt = (SSliceThreading*)pMa->WelsMalloc (sizeof (SSliceThreading), "SSliceThreading"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt), FreeMemorySvc (ppCtx)) - (*ppCtx)->pSliceThreading = pSmt; - pSmt->pThreadPEncCtx = (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum, + (*ppCtx)->pSliceThreading = pSmt; + pSmt->pThreadPEncCtx = (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum, "pThreadPEncCtx"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadPEncCtx), FreeMemorySvc (ppCtx)) @@ -323,18 +323,18 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara iIdx = 0; while (iIdx < iNumSpatialLayers) { - SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg; + SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg; const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum; 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[]"); + pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx)) - pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); + pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx)) } else { - pSmt->pSliceConsumeTime[iIdx] = NULL; - pSmt->pSliceComplexRatio[iIdx] = NULL; + pSmt->pSliceConsumeTime[iIdx] = NULL; + pSmt->pSliceComplexRatio[iIdx] = NULL; } ++ iIdx; } @@ -348,7 +348,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara fclose (pSmt->pFSliceDiff); pSmt->pFSliceDiff = NULL; } - pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+"); + pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+"); #endif//MT_DEBUG MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "encpEncCtx= 0x%p", (void*) *ppCtx); @@ -358,10 +358,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara iIdx = 0; while (iIdx < iThreadNum) { - pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx; - pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; - pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; - pSmt->pThreadHandles[iIdx] = 0; + pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx; + pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; + pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; + pSmt->pThreadHandles[iIdx] = 0; WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name); @@ -392,26 +392,26 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name); MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno); - (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); + (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx)) - pBsBase = (*ppCtx)->pFrameBs + iCountBsLen; - pSliceB = (*ppCtx)->pSliceBs; - iSliceBsBufferSize = iTargetSpatialBsSize; + pBsBase = (*ppCtx)->pFrameBs + iCountBsLen; + pSliceB = (*ppCtx)->pSliceBs; + iSliceBsBufferSize = iTargetSpatialBsSize; iIdx = 0; while (iIdx < iMaxSliceNum) { pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer"); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSliceB->pBsBuffer), FreeMemorySvc (ppCtx)) - pSliceB->uiSize = iSliceBsBufferSize; + pSliceB->uiSize = iSliceBsBufferSize; if (iIdx > 0) { - pSliceB->pBs = pBsBase; - pSliceB->uiBsPos = 0; - pBsBase += iSliceBsBufferSize; + pSliceB->pBs = pBsBase; + pSliceB->uiBsPos = 0; + pBsBase += iSliceBsBufferSize; } else { - pSliceB->pBs = NULL; - pSliceB->uiBsPos = 0; + pSliceB->pBs = NULL; + pSliceB->uiBsPos = 0; } ++ pSliceB; ++ iIdx; @@ -431,22 +431,22 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara } void ReleaseMtResource (sWelsEncCtx** ppCtx) { - SWelsSliceBs* pSliceB = NULL; - SWelsSvcCodingParam* pCodingParam = NULL; - SSliceThreading* pSmt = NULL; - CMemoryAlign* pMa = NULL; - int32_t iIdx = 0; - int32_t iThreadNum = 0; - int16_t uiSliceNum = 0; + SWelsSliceBs* pSliceB = NULL; + SWelsSvcCodingParam* pCodingParam = NULL; + SSliceThreading* pSmt = NULL; + CMemoryAlign* pMa = NULL; + int32_t iIdx = 0; + int32_t iThreadNum = 0; + int16_t uiSliceNum = 0; if (NULL == ppCtx || NULL == *ppCtx) return; - pMa = (*ppCtx)->pMemAlign; - pCodingParam = (*ppCtx)->pSvcParam; - uiSliceNum = (*ppCtx)->iMaxSliceCount; - iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum; - pSmt = (*ppCtx)->pSliceThreading; + pMa = (*ppCtx)->pMemAlign; + pCodingParam = (*ppCtx)->pSvcParam; + uiSliceNum = (*ppCtx)->iMaxSliceCount; + iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum; + pSmt = (*ppCtx)->pSliceThreading; if (NULL == pSmt) return; @@ -520,46 +520,46 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { } int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) { - SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; - SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; - SWelsSliceBs* pSliceBs = NULL; - const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE); + SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; + SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; + SWelsSliceBs* pSliceBs = NULL; + const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE); - int32_t iLayerSize = 0; - int32_t iNalIdxBase = pLbi->iNalCount; - int32_t iSliceIdx = 0; + int32_t iLayerSize = 0; + int32_t iNalIdxBase = pLbi->iNalCount; + int32_t iSliceIdx = 0; if (!kbIsDynamicSlicingMode) { - pSliceBs = &pCtx->pSliceBs[0]; - iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first - iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1 + pSliceBs = &pCtx->pSliceBs[0]; + iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first + iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1 while (iSliceIdx < iSliceCount) { ++ pSliceBs; if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { int32_t iNalIdx = 0; - const int32_t iCountNal = pSliceBs->iNalIndex; + const int32_t iCountNal = pSliceBs->iNalIndex; #if MT_DEBUG_BS_WR assert (pSliceBs->bSliceCodedFlag); #endif//MT_DEBUG_BS_WR - memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage + memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage pCtx->iPosBsBuffer += pSliceBs->uiBsPos; iLayerSize += pSliceBs->uiBsPos; while (iNalIdx < iCountNal) { - pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; + pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; ++ iNalIdx; } - pLbi->iNalCount += iCountNal; - iNalIdxBase += iCountNal; + pLbi->iNalCount += iCountNal; + iNalIdxBase += iCountNal; } ++ iSliceIdx; } - } else { // for SM_DYN_SLICE - const int32_t kiPartitionCnt = iSliceCount; - int32_t iPartitionIdx = 0; + } else { // for SM_DYN_SLICE + const int32_t kiPartitionCnt = iSliceCount; + int32_t iPartitionIdx = 0; // due partition_0 has been written to pFrameBsBuffer // so iLayerSize need add it @@ -567,27 +567,27 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 const int32_t kiCountSlicesCoded = pCtx->pCurDqLayer->pNumSliceCodedOfPartition[iPartitionIdx]; int32_t iIdx = 0; - iSliceIdx = iPartitionIdx; + iSliceIdx = iPartitionIdx; while (iIdx < kiCountSlicesCoded) { - pSliceBs = &pCtx->pSliceBs[iSliceIdx]; + pSliceBs = &pCtx->pSliceBs[iSliceIdx]; if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { if (iPartitionIdx > 0) { int32_t iNalIdx = 0; - const int32_t iCountNal = pSliceBs->iNalIndex; + const int32_t iCountNal = pSliceBs->iNalIndex; - memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage + memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage pCtx->iPosBsBuffer += pSliceBs->uiBsPos; iLayerSize += pSliceBs->uiBsPos; while (iNalIdx < iCountNal) { - pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; + pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; ++ iNalIdx; } - pLbi->iNalCount += iCountNal; - iNalIdxBase += iCountNal; + pLbi->iNalCount += iCountNal; + iNalIdxBase += iCountNal; } else { - iLayerSize += pSliceBs->uiBsPos; + iLayerSize += pSliceBs->uiBsPos; } } @@ -603,17 +603,17 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, int32_t& iSliceSize) { - SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; + SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; - uint8_t* pDst = pFrameBsBuffer; - const int32_t kiNalCnt = pSliceBs->iNalIndex; - int32_t iNalIdx = 0; + uint8_t* pDst = pFrameBsBuffer; + const int32_t kiNalCnt = pSliceBs->iNalIndex; + int32_t iNalIdx = 0; int32_t iNalSize = 0; - const int32_t iFirstSlice = (iSliceIdx == 0); - int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; + const int32_t iFirstSlice = (iSliceIdx == 0); + int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; int32_t iReturn = ENC_RETURN_SUCCESS; const int32_t kiWrittenLength = pCtx->iPosBsBuffer; - iSliceSize = 0; + iSliceSize = 0; while (iNalIdx < kiNalCnt) { iNalSize = 0; @@ -622,38 +622,38 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) iSliceSize += iNalSize; pDst += iNalSize; - pLbi->pNalLengthInByte[iNalBase + iNalIdx] = iNalSize; + pLbi->pNalLengthInByte[iNalBase + iNalIdx] = iNalSize; ++ iNalIdx; } - pSliceBs->uiBsPos = iSliceSize; + pSliceBs->uiBsPos = iSliceSize; if (iFirstSlice) { // pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread() - pLbi->uiLayerType = VIDEO_CODING_LAYER; - pLbi->uiSpatialId = pNalHdrExt->uiDependencyId; - pLbi->uiTemporalId = pNalHdrExt->uiTemporalId; - pLbi->uiQualityId = 0; - pLbi->iNalCount = kiNalCnt; + pLbi->uiLayerType = VIDEO_CODING_LAYER; + pLbi->uiSpatialId = pNalHdrExt->uiDependencyId; + pLbi->uiTemporalId = pNalHdrExt->uiTemporalId; + pLbi->uiQualityId = 0; + pLbi->iNalCount = kiNalCnt; } else { - pLbi->iNalCount += kiNalCnt; + pLbi->iNalCount += kiNalCnt; } return ENC_RETURN_SUCCESS; } int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) { - SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; + SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; - uint8_t* pDst = pSliceBsBuf; - int32_t* pNalLen = &pSliceBs->iNalLen[0]; - const int32_t kiNalCnt = pSliceBs->iNalIndex; - int32_t iNalIdx = 0; - int32_t iNalSize = 0; + uint8_t* pDst = pSliceBsBuf; + int32_t* pNalLen = &pSliceBs->iNalLen[0]; + const int32_t kiNalCnt = pSliceBs->iNalIndex; + int32_t iNalIdx = 0; + int32_t iNalSize = 0; int32_t iReturn = ENC_RETURN_SUCCESS; const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf); - iSliceSize = 0; + iSliceSize = 0; assert (kiNalCnt <= 2); if (kiNalCnt > 2) return 0; @@ -668,41 +668,41 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl pDst += iNalSize; ++ iNalIdx; } - pSliceBs->uiBsPos = iSliceSize; + pSliceBs->uiBsPos = iSliceSize; return iReturn; } // thread process for coding one pSlice WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { - SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg; - sWelsEncCtx* pEncPEncCtx = NULL; - SDqLayer* pCurDq = NULL; - SSlice* pSlice = NULL; - SWelsSliceBs* pSliceBs = NULL; + SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg; + sWelsEncCtx* pEncPEncCtx = NULL; + SDqLayer* pCurDq = NULL; + SSlice* pSlice = NULL; + SWelsSliceBs* pSliceBs = NULL; WELS_EVENT pEventsList[3]; - int32_t iEventCount = 0; - WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL; - uint32_t uiThrdRet = 0; - int32_t iSliceSize = 0; - int32_t iSliceIdx = -1; - int32_t iThreadIdx = -1; - int32_t iEventIdx = -1; - bool bNeedPrefix = false; - EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; - EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; + int32_t iEventCount = 0; + WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL; + uint32_t uiThrdRet = 0; + int32_t iSliceSize = 0; + int32_t iSliceIdx = -1; + int32_t iThreadIdx = -1; + int32_t iEventIdx = -1; + bool bNeedPrefix = false; + EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; + EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; int32_t iReturn = ENC_RETURN_SUCCESS; if (NULL == pPrivateData) WELS_THREAD_ROUTINE_RETURN (1); - pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx; + pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx; - iThreadIdx = pPrivateData->iThreadIndex; - iEventIdx = iThreadIdx; + iThreadIdx = pPrivateData->iThreadIndex; + iEventIdx = iThreadIdx; - pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]; - pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx]; + pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]; + pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx]; pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]; WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc"); @@ -714,39 +714,39 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount, &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 + if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited SLayerBSInfo* pLbi = pPrivateData->pLayerBs; - const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; - const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; - SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam; - SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid]; + const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; + const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; + SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam; + SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid]; - pCurDq = pEncPEncCtx->pCurDqLayer; - eNalType = pEncPEncCtx->eNalType; - eNalRefIdc = pEncPEncCtx->eNalPriority; - bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; + pCurDq = pEncPEncCtx->pCurDqLayer; + eNalType = pEncPEncCtx->eNalType; + eNalRefIdc = pEncPEncCtx->eNalPriority; + bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) { - int64_t iSliceStart = 0; + int64_t iSliceStart = 0; bool bDsaFlag = false; - iSliceIdx = pPrivateData->iSliceIndex; - pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; - pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; + iSliceIdx = pPrivateData->iSliceIndex; + pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; + pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; - bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_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) iSliceStart = WelsTime(); - pSliceBs->uiBsPos = 0; - pSliceBs->iNalIndex = 0; + pSliceBs->uiBsPos = 0; + pSliceBs->iNalIndex = 0; assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa); InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); #if MT_DEBUG_BS_WR - pSliceBs->bSliceCodedFlag = false; + pSliceBs->bSliceCodedFlag = false; #endif//MT_DEBUG_BS_WR if (bNeedPrefix) { @@ -772,7 +772,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { WelsUnloadNalForSlice (pSliceBs); if (0 == iSliceIdx) { - pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; + pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize); if (ENC_RETURN_SUCCESS != iReturn) { uiThrdRet = iReturn; @@ -818,42 +818,42 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { #endif//SLICE_INFO_OUTPUT #if MT_DEBUG_BS_WR - pSliceBs->bSliceCodedFlag = true; + pSliceBs->bSliceCodedFlag = true; #endif//MT_DEBUG_BS_WR WelsEventSignal ( - &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice + &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice WelsEventSignal ( &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); - } else { // for SM_DYN_SLICE parallelization - SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; - const int32_t kiPartitionId = iThreadIdx; - const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; - const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive - const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive - int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; + } else { // for SM_DYN_SLICE parallelization + SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; + const int32_t kiPartitionId = iThreadIdx; + const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; + const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive + const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive + int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; - iSliceIdx = pPrivateData->iSliceIndex; + iSliceIdx = pPrivateData->iSliceIndex; - pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; - pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside - pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; + pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; + pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside + pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; - pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; while (iAnyMbLeftInPartition > 0) { if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure - uiThrdRet = 1; + uiThrdRet = 1; break; } - pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; - pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; + pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; + pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; - pSliceBs->uiBsPos = 0; - pSliceBs->iNalIndex = 0; + pSliceBs->uiBsPos = 0; + pSliceBs->iNalIndex = 0; InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); if (bNeedPrefix) { @@ -880,7 +880,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { if (0 == kiPartitionId) { if (0 == iSliceIdx) - pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; + pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer; iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer, iSliceIdx, iSliceSize); if (ENC_RETURN_SUCCESS != iReturn) { @@ -925,27 +925,27 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { iSliceIdx += kiSliceIdxStep; } - if (uiThrdRet) // any exception?? + if (uiThrdRet) // any exception?? break; - WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice + 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 - uiThrdRet = 0; + } 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 - iSliceIdx = - iEventIdx; // pPrivateData->iSliceIndex; old threads can not be terminated, pPrivateData is not correct for applicable - pCurDq = pEncPEncCtx->pCurDqLayer; + } 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 + &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice } else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED WelsLog (& (pEncPEncCtx->sLogCtx), WELS_LOG_WARNING, "[MT] CodingSliceThreadProc(), waiting pReadySliceCodingEvent[%d] failed(%d) and thread%d terminated!", iEventIdx, iWaitRet, iThreadIdx); - uiThrdRet = 1; + uiThrdRet = 1; break; } } while (1); @@ -978,8 +978,8 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { int32_t FiredSliceThreads (sWelsEncCtx* pCtx, 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; + int32_t iEndMbIdx = 0; + int32_t iIdx = 0; const int32_t kiEventCnt = uiNumThreads; if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { @@ -991,19 +991,19 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, //////////////////////////////////////// if (bIsDynamicSlicingMode) { - iEndMbIdx = pSliceCtx->iMbNumInFrame; + iEndMbIdx = pSliceCtx->iMbNumInFrame; for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { - const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx]; - pPriData[iIdx].iStartMbIndex = iFirstMbIdx; - pPriData[iIdx].iEndMbIndex = iEndMbIdx; - iEndMbIdx = iFirstMbIdx; + const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx]; + pPriData[iIdx].iStartMbIndex = iFirstMbIdx; + pPriData[iIdx].iEndMbIndex = iEndMbIdx; + iEndMbIdx = iFirstMbIdx; } } iIdx = 0; while (iIdx < kiEventCnt) { pPriData[iIdx].pLayerBs = pLbi; - pPriData[iIdx].iSliceIndex = iIdx; + pPriData[iIdx].iSliceIndex = iIdx; if (pEventsList[iIdx]) WelsEventSignal (&pEventsList[iIdx]); if (pMasterEventsList[iIdx]) @@ -1021,16 +1021,16 @@ int32_t DynamicDetectCpuCores() { } int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { - SDqLayer* pCurDq = pCtx->ppDqLayerList[0]; - int32_t iNeedAdj = 1; + SDqLayer* pCurDq = pCtx->ppDqLayerList[0]; + int32_t iNeedAdj = 1; #ifdef MT_DEBUG int64_t iT0 = WelsTime(); #endif//MT_DEBUG - pCtx->pCurDqLayer = pCurDq; + pCtx->pCurDqLayer = pCurDq; // do not need adjust due to not different at both slices of consumed time - iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame); + iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame); if (iNeedAdj) DynamicAdjustSlicing (pCtx, pCurDq, @@ -1056,12 +1056,12 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { // uiSliceMode of referencing spatial should be SM_FIXEDSLCNUM_SLICE // if using spatial base layer for complexity estimation - const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0) + const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0) && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceCfg.sSliceArgument.uiSliceNum); - if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation + if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation // do not need adjust due to not different at both slices of consumed time iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid - 1], pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); @@ -1071,7 +1071,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { pCtx->pSliceThreading->pSliceComplexRatio[iCurDid - 1], iCurDid ); - } else { // use temporal layer for complexity estimation + } else { // use temporal layer for complexity estimation // do not need adjust due to not different at both slices of consumed time iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); @@ -1119,12 +1119,12 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t if (iSpatialNum > MAX_DEPENDENCY_LAYER) return; - pPara = pCtx->pSvcParam; + pPara = pCtx->pSvcParam; while (iSpatialIdx < iSpatialNum) { - const int32_t kiDid = pDidList[iSpatialIdx]; - SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; - SSliceConfig* pMso = &pDlp->sSliceCfg; - SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; + const int32_t kiDid = pDidList[iSpatialIdx]; + SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; + SSliceConfig* pMso = &pDlp->sSliceCfg; + SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; if (pCtx->pSliceThreading) { diff --git a/codec/encoder/core/src/svc_base_layer_md.cpp b/codec/encoder/core/src/svc_base_layer_md.cpp index 03bb810b..4fe1db5c 100644 --- a/codec/encoder/core/src/svc_base_layer_md.cpp +++ b/codec/encoder/core/src/svc_base_layer_md.cpp @@ -269,45 +269,45 @@ void WelsMdIntraInit (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, con int32_t iStrideY, iStrideUV; int32_t iOffsetY, iOffsetUV; - iStrideY = pCurLayer->iEncStride[0]; - iStrideUV = pCurLayer->iEncStride[1]; - iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; - iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; - pMbCache->SPicData.pEncMb[0] = pCurLayer->pEncData[0] + iOffsetY; - pMbCache->SPicData.pEncMb[1] = pCurLayer->pEncData[1] + iOffsetUV; - pMbCache->SPicData.pEncMb[2] = pCurLayer->pEncData[2] + iOffsetUV; + iStrideY = pCurLayer->iEncStride[0]; + iStrideUV = pCurLayer->iEncStride[1]; + iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; + iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; + pMbCache->SPicData.pEncMb[0] = pCurLayer->pEncData[0] + iOffsetY; + pMbCache->SPicData.pEncMb[1] = pCurLayer->pEncData[1] + iOffsetUV; + pMbCache->SPicData.pEncMb[2] = pCurLayer->pEncData[2] + iOffsetUV; - iStrideY = pCurLayer->iCsStride[0]; - iStrideUV = pCurLayer->iCsStride[1]; - iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; - iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; - pMbCache->SPicData.pCsMb[0] = pCurLayer->pCsData[0] + iOffsetY; - pMbCache->SPicData.pCsMb[1] = pCurLayer->pCsData[1] + iOffsetUV; - pMbCache->SPicData.pCsMb[2] = pCurLayer->pCsData[2] + iOffsetUV; + iStrideY = pCurLayer->iCsStride[0]; + iStrideUV = pCurLayer->iCsStride[1]; + iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; + iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; + pMbCache->SPicData.pCsMb[0] = pCurLayer->pCsData[0] + iOffsetY; + pMbCache->SPicData.pCsMb[1] = pCurLayer->pCsData[1] + iOffsetUV; + pMbCache->SPicData.pCsMb[2] = pCurLayer->pCsData[2] + iOffsetUV; - iStrideY = pCurLayer->pDecPic->iLineSize[0]; - iStrideUV = pCurLayer->pDecPic->iLineSize[1]; - iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; - iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; - pMbCache->SPicData.pDecMb[0] = pCurLayer->pDecPic->pData[0] + iOffsetY; - pMbCache->SPicData.pDecMb[1] = pCurLayer->pDecPic->pData[1] + iOffsetUV; - pMbCache->SPicData.pDecMb[2] = pCurLayer->pDecPic->pData[2] + iOffsetUV; + iStrideY = pCurLayer->pDecPic->iLineSize[0]; + iStrideUV = pCurLayer->pDecPic->iLineSize[1]; + iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; + iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; + pMbCache->SPicData.pDecMb[0] = pCurLayer->pDecPic->pData[0] + iOffsetY; + pMbCache->SPicData.pDecMb[1] = pCurLayer->pDecPic->pData[1] + iOffsetUV; + pMbCache->SPicData.pDecMb[2] = pCurLayer->pDecPic->pData[2] + iOffsetUV; } else { - pMbCache->SPicData.pEncMb[0] += MB_WIDTH_LUMA; - pMbCache->SPicData.pEncMb[1] += MB_WIDTH_CHROMA; - pMbCache->SPicData.pEncMb[2] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pEncMb[0] += MB_WIDTH_LUMA; + pMbCache->SPicData.pEncMb[1] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pEncMb[2] += MB_WIDTH_CHROMA; - pMbCache->SPicData.pDecMb[0] += MB_WIDTH_LUMA; - pMbCache->SPicData.pDecMb[1] += MB_WIDTH_CHROMA; - pMbCache->SPicData.pDecMb[2] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pDecMb[0] += MB_WIDTH_LUMA; + pMbCache->SPicData.pDecMb[1] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pDecMb[2] += MB_WIDTH_CHROMA; - pMbCache->SPicData.pCsMb[0] += MB_WIDTH_LUMA; - pMbCache->SPicData.pCsMb[1] += MB_WIDTH_CHROMA; - pMbCache->SPicData.pCsMb[2] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pCsMb[0] += MB_WIDTH_LUMA; + pMbCache->SPicData.pCsMb[1] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pCsMb[2] += MB_WIDTH_CHROMA; } //step 2. initial pWelsMd - pCurMb->uiCbp = 0; + pCurMb->uiCbp = 0; //step 4: locating scaled_tcoeff @@ -320,14 +320,14 @@ void WelsMdIntraInit (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, con void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const int32_t iSliceFirstMbXY) { SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; const int32_t kiMbX = pCurMb->iMbX; const int32_t kiMbY = pCurMb->iMbY; - const int32_t kiMbXY = pCurMb->iMbXY; + const int32_t kiMbXY = pCurMb->iMbXY; const int32_t kiMbWidth = pCurLayer->iMbWidth; const int32_t kiMbHeight = pCurLayer->iMbHeight; - pMbCache->pEncSad = &pCurLayer->pDecPic->pMbSkipSad[kiMbXY]; + pMbCache->pEncSad = &pCurLayer->pDecPic->pMbSkipSad[kiMbXY]; //step 1. load neighbor cache pEncCtx->pFuncList->pfFillInterNeighborCache (pMbCache, pCurMb, kiMbWidth, @@ -338,20 +338,20 @@ void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const i //step 4. locating current p_ref // merge loops if (0 == kiMbX || iSliceFirstMbXY == kiMbXY) { - const int32_t kiRefStrideY = pCurLayer->pRefPic->iLineSize[0]; - const int32_t kiRefStrideUV = pCurLayer->pRefPic->iLineSize[1]; - const int32_t kiCurStrideY = (kiMbX + kiMbY * kiRefStrideY) << 4; - const int32_t kiCurStrideUV = (kiMbX + kiMbY * kiRefStrideUV) << 3; - pMbCache->SPicData.pRefMb[0] = pCurLayer->pRefPic->pData[0] + kiCurStrideY; - pMbCache->SPicData.pRefMb[1] = pCurLayer->pRefPic->pData[1] + kiCurStrideUV; - pMbCache->SPicData.pRefMb[2] = pCurLayer->pRefPic->pData[2] + kiCurStrideUV; + const int32_t kiRefStrideY = pCurLayer->pRefPic->iLineSize[0]; + const int32_t kiRefStrideUV = pCurLayer->pRefPic->iLineSize[1]; + const int32_t kiCurStrideY = (kiMbX + kiMbY * kiRefStrideY) << 4; + const int32_t kiCurStrideUV = (kiMbX + kiMbY * kiRefStrideUV) << 3; + pMbCache->SPicData.pRefMb[0] = pCurLayer->pRefPic->pData[0] + kiCurStrideY; + pMbCache->SPicData.pRefMb[1] = pCurLayer->pRefPic->pData[1] + kiCurStrideUV; + pMbCache->SPicData.pRefMb[2] = pCurLayer->pRefPic->pData[2] + kiCurStrideUV; } else { - pMbCache->SPicData.pRefMb[0] += MB_WIDTH_LUMA; - pMbCache->SPicData.pRefMb[1] += MB_WIDTH_CHROMA; - pMbCache->SPicData.pRefMb[2] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pRefMb[0] += MB_WIDTH_LUMA; + pMbCache->SPicData.pRefMb[1] += MB_WIDTH_CHROMA; + pMbCache->SPicData.pRefMb[2] += MB_WIDTH_CHROMA; } - pMbCache->uiRefMbType = pCurLayer->pRefPic->uiRefMbType[kiMbXY]; + pMbCache->uiRefMbType = pCurLayer->pRefPic->uiRefMbType[kiMbXY]; pMbCache->bCollocatedPredFlag = false; //comment: sometimes, mode decision process may skip the md_p16x16 and md_pskip function, @@ -367,7 +367,7 @@ int32_t WelsMdI16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache* int32_t iAvailCount; int32_t iIdx = 0; uint8_t* pPredI16x16[2] = {pMbCache->pMemPredMb, pMbCache->pMemPredMb + 256}; - uint8_t* pDst = pPredI16x16[0]; + uint8_t* pDst = pPredI16x16[0]; uint8_t* pDec = pMbCache->SPicData.pCsMb[0]; uint8_t* pEnc = pMbCache->SPicData.pEncMb[0]; int32_t iLineSizeDec = pCurDqLayer->iCsStride[0]; @@ -416,14 +416,14 @@ int32_t WelsMdI16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache* return iBestCost; } int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - int32_t iLambda = pWelsMd->iLambda; - int32_t iBestCostLuma = pWelsMd->iCostLuma; - uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; - uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0]; - const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0]; - const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0]; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + int32_t iLambda = pWelsMd->iLambda; + int32_t iBestCostLuma = pWelsMd->iCostLuma; + uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; + uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0]; + const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0]; + const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0]; uint8_t* pCurEnc, *pCurDec, *pDst; @@ -432,16 +432,16 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach int32_t iAvailCount; const uint8_t* kpAvailMode; int32_t i, j, iCoordinateX, iCoordinateY, iIdxStrideEnc, iIdxStrideDec; - int32_t lambda[2] = {iLambda << 2, iLambda}; - bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag; - int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag; - const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0]; - const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0]; - const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra]; - const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0]; - const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0]; - int32_t iBestPredBufferNum = 0; - int32_t iCosti4x4 = 0; + int32_t lambda[2] = {iLambda << 2, iLambda}; + bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag; + int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag; + const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0]; + const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0]; + const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra]; + const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0]; + const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0]; + int32_t iBestPredBufferNum = 0; + int32_t iCosti4x4 = 0; #if defined(X86_ASM) WelsPrefetchZero_mmx (g_kiMapModeI4x4); @@ -449,7 +449,7 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach #endif//X86_ASM for (i = 0; i < 16; i++) { - const int32_t kiOffset = kpNeighborIntraToI4x4[i]; + const int32_t kiOffset = kpNeighborIntraToI4x4[i]; //step 1: locating current 4x4 block position in pEnc and pDecMb iCoordinateX = kpCoordinateIdxX[i]; @@ -531,7 +531,7 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach *pRemIntra4x4PredModeFlag = (iFinalMode < iPredMode ? iFinalMode : (iFinalMode - 1)); } pRemIntra4x4PredModeFlag++; - // pCurMb->pIntra4x4PredMode[g_kuiMbCountScan4Idx[i]] = iFinalMode; + // pCurMb->pIntra4x4PredMode[g_kuiMbCountScan4Idx[i]] = iFinalMode; pMbCache->iIntraPredMode[kpCache48CountScan4[i]] = iFinalMode; //step 6: encoding I_4x4 @@ -539,21 +539,21 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach } ST32 (pCurMb->pIntra4x4PredMode, LD32 (&pMbCache->iIntraPredMode[33])); pCurMb->pIntra4x4PredMode[4] = pMbCache->iIntraPredMode[12]; - pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20]; + pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20]; pCurMb->pIntra4x4PredMode[6] = pMbCache->iIntraPredMode[28]; iCosti4x4 += (iLambda << 4) + (iLambda << 3); //4*6*lambda from JVT SATD0 return iCosti4x4; } int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - int32_t iLambda = pWelsMd->iLambda; - int32_t iBestCostLuma = pWelsMd->iCostLuma; - uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; - uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0]; - const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0]; - const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0]; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + int32_t iLambda = pWelsMd->iLambda; + int32_t iBestCostLuma = pWelsMd->iCostLuma; + uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; + uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0]; + const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0]; + const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0]; uint8_t* pCurEnc, *pCurDec, *pDst; int8_t iPredMode, iCurMode, iBestMode, iFinalMode; @@ -562,25 +562,25 @@ int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMb const uint8_t* kpAvailMode; int32_t i, j, iCoordinateX, iCoordinateY, iIdxStrideEnc, iIdxStrideDec; int32_t iCostH, iCostV, iCostVR, iCostHD, iCostVL, iCostHU, iBestModeFake; - int32_t lambda[2] = {iLambda << 2, iLambda}; - bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag; - int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag; - const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0]; - const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0]; - const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra]; - const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0]; - const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0]; - int32_t iBestPredBufferNum = 0; - int32_t iCosti4x4 = 0; + int32_t lambda[2] = {iLambda << 2, iLambda}; + bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag; + int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag; + const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0]; + const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0]; + const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra]; + const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0]; + const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0]; + int32_t iBestPredBufferNum = 0; + int32_t iCosti4x4 = 0; #if defined(X86_ASM) WelsPrefetchZero_mmx (g_kiMapModeI4x4); WelsPrefetchZero_mmx ((int8_t*)&pFunc->pfGetLumaI4x4Pred); #endif//X86_ASM for (i = 0; i < 16; i++) { - const int32_t kiOffset = kpNeighborIntraToI4x4[i]; -// const int32_t i_next = (1+i) & 15; // next loop -// const uint8_t dummy_byte= pIntra4x4AvailCount[pNeighborIntraToI4x4[i_next]]; // prefetch pIntra4x4AvailCount of next loop to avoid cache missed + const int32_t kiOffset = kpNeighborIntraToI4x4[i]; +// const int32_t i_next = (1+i) & 15; // next loop +// const uint8_t dummy_byte= pIntra4x4AvailCount[pNeighborIntraToI4x4[i_next]]; // prefetch pIntra4x4AvailCount of next loop to avoid cache missed //step 1: locating current 4x4 block position in pEnc and pDecMb iCoordinateX = kpCoordinateIdxX[i]; @@ -851,14 +851,14 @@ int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMb *pRemIntra4x4PredModeFlag = (iFinalMode < iPredMode ? iFinalMode : (iFinalMode - 1)); } pRemIntra4x4PredModeFlag++; - // pCurMb->pIntra4x4PredMode[scan4[i]] = iFinalMode; + // pCurMb->pIntra4x4PredMode[scan4[i]] = iFinalMode; pMbCache->iIntraPredMode[kpCache48CountScan4[i]] = iFinalMode; //step 6: encoding I_4x4 WelsEncRecI4x4Y (pEncCtx, pCurMb, pMbCache, i); } ST32 (pCurMb->pIntra4x4PredMode, LD32 (&pMbCache->iIntraPredMode[33])); pCurMb->pIntra4x4PredMode[4] = pMbCache->iIntraPredMode[12]; - pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20]; + pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20]; pCurMb->pIntra4x4PredMode[6] = pMbCache->iIntraPredMode[28]; iCosti4x4 += (iLambda << 4) + (iLambda << 3); //4*6*lambda from JVT SATD0 return iCosti4x4; @@ -866,16 +866,16 @@ int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMb int32_t WelsMdIntraChroma (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache* pMbCache, int32_t iLambda) { const int8_t* kpAvailMode; - int32_t iAvailCount = 0; + int32_t iAvailCount = 0; int32_t iChmaIdx = 0; - uint8_t* pPredIntraChma[2] = {pMbCache->pMemPredChroma, pMbCache->pMemPredChroma + 128}; - uint8_t* pDstChma = pPredIntraChma[0]; - uint8_t* pEncCb = pMbCache->SPicData.pEncMb[1]; - uint8_t* pEncCr = pMbCache->SPicData.pEncMb[2]; - uint8_t* pDecCb = pMbCache->SPicData.pCsMb[1];//pMbCache->SPicData.pDecMb[1]; - uint8_t* pDecCr = pMbCache->SPicData.pCsMb[2];//pMbCache->SPicData.pDecMb[2]; - const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[1]; - const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[1];//pMbCache->SPicData.i_stride_dec[1]; + uint8_t* pPredIntraChma[2] = {pMbCache->pMemPredChroma, pMbCache->pMemPredChroma + 128}; + uint8_t* pDstChma = pPredIntraChma[0]; + uint8_t* pEncCb = pMbCache->SPicData.pEncMb[1]; + uint8_t* pEncCr = pMbCache->SPicData.pEncMb[2]; + uint8_t* pDecCb = pMbCache->SPicData.pCsMb[1];//pMbCache->SPicData.pDecMb[1]; + uint8_t* pDecCr = pMbCache->SPicData.pCsMb[2];//pMbCache->SPicData.pDecMb[2]; + const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[1]; + const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[1];//pMbCache->SPicData.i_stride_dec[1]; int32_t i, iCurMode, iCurCost, iBestMode, iBestCost = INT_MAX; @@ -908,8 +908,8 @@ int32_t WelsMdIntraChroma (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCa assert (iCurMode >= 0 && iCurMode < 7); - // pDstCb = &pMbCache->mem_pred_intra_cb[iCurMode<<6]; - // pDstCr = &pMbCache->mem_pred_intra_cr[iCurMode<<6]; + // pDstCb = &pMbCache->mem_pred_intra_cb[iCurMode<<6]; + // pDstCr = &pMbCache->mem_pred_intra_cr[iCurMode<<6]; pFunc->pfGetChromaPred[iCurMode] (pDstChma, pDecCb, kiLineSizeDec); //Cb iCurCost = pFunc->sSampleDealingFuncs.pfMdCost[BLOCK_8x8] (pDstChma, 8, pEncCb, kiLineSizeEnc); @@ -920,12 +920,12 @@ int32_t WelsMdIntraChroma (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCa iBestMode = iCurMode; iBestCost = iCurCost; iChmaIdx = iChmaIdx ^ 0x01; - pDstChma = pPredIntraChma[iChmaIdx]; + pDstChma = pPredIntraChma[iChmaIdx]; } } } - pMbCache->pBestPredIntraChroma = pPredIntraChma[iChmaIdx ^ 0x01]; + pMbCache->pBestPredIntraChroma = pPredIntraChma[iChmaIdx ^ 0x01]; pMbCache->uiChmaI8x8Mode = iBestMode; return iBestCost; } @@ -979,8 +979,8 @@ int32_t WelsMdP16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWe SMbCache* pMbCache = &pSlice->sMbCacheInfo; SWelsME* pMe16x16 = &pWelsMd->sMe.sMe16x16; uint32_t uiNeighborAvail = pCurMb->uiNeighborAvail; - const int32_t kiMbWidth = pCurLayer->iMbWidth; // for assign once - const int32_t kiMbHeight = pCurLayer->iMbHeight; + 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], pCurLayer->pRefPic->pScreenBlockFeatureStorage, *pMe16x16); @@ -1039,7 +1039,7 @@ int32_t WelsMdP16x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pW sMe16x8->iCurMeBlockPixY = pWelsMd->iMbPixY + iPixelY; sMe16x8->uSadPredISatd.uiSadPred = pWelsMd->iSadPredMb >> 1; - pSlice->sMvc[0] = sMe16x8->sMvBase; + pSlice->sMvc[0] = sMe16x8->sMvBase; pSlice->uiMvcNum = 1; PredInter16x8Mv (pMbCache, i << 3, 0, & (sMe16x8->sMvp)); @@ -1112,17 +1112,17 @@ int32_t WelsMdP8x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pWe pFunc->pfMotionSearch[pWelsMd->iBlock8x8StaticIdc[i]] (pFunc, pCurDqLayer, sMe8x8, pSlice); UpdateP8x8Motion2Cache (pMbCache, i << 2, pWelsMd->uiRef, & (sMe8x8->sMv)); iCostP8x8 += sMe8x8->uiSatdCost; -// sMe8x8++; +// sMe8x8++; } return iCostP8x8; } void WelsMdInterFinePartition (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, int32_t iBestCost) { SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; -// SMbCache *pMbCache = &pSlice->sMbCacheInfo; +// SMbCache *pMbCache = &pSlice->sMbCacheInfo; int32_t iCost = 0; -// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP8x8, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); +// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP8x8, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); iCost = WelsMdP8x8 (pEncCtx->pFuncList, pCurDqLayer, pWelsMd, pSlice); @@ -1130,7 +1130,7 @@ void WelsMdInterFinePartition (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p int32_t iCostPart; pCurMb->uiMbType = MB_TYPE_8x8; -// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP16x8, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); +// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP16x8, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); iCostPart = WelsMdP16x8 (pEncCtx->pFuncList, pCurDqLayer, pWelsMd, pSlice); if (iCostPart <= iCost) { iCost = iCostPart; @@ -1138,7 +1138,7 @@ void WelsMdInterFinePartition (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p //pCurMb->mb_partition = 2; } -// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP8x16, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); +// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP8x16, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); iCostPart = WelsMdP8x16 (pEncCtx->pFuncList, pCurDqLayer, pWelsMd, pSlice); if (iCostPart <= iCost) { iCost = iCostPart; @@ -1151,7 +1151,7 @@ void WelsMdInterFinePartition (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, int32_t iBestCost) { SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; -// SMbCache *pMbCache = &pSlice->sMbCacheInfo; +// SMbCache *pMbCache = &pSlice->sMbCacheInfo; int32_t iCostP8x16, iCostP16x8, iCostP8x8; uint8_t uiMbSign = pEncCtx->pFuncList->pfGetMbSignFromInterVaa (&pEncCtx->pVaa->sVaaCalcInfo.pSad8x8[pCurMb->iMbXY][0]); @@ -1159,12 +1159,12 @@ void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice return; } -// iCost = pWelsMd->sMe16x16.uiSatdCost; +// iCost = pWelsMd->sMe16x16.uiSatdCost; switch (uiMbSign) { case 3: case 12: -// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP16x8, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); +// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP16x8, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); iCostP16x8 = WelsMdP16x8 (pEncCtx->pFuncList, pCurDqLayer, pWelsMd, pSlice); if (iCostP16x8 < iBestCost) { iBestCost = iCostP16x8; @@ -1175,7 +1175,7 @@ void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice case 5: case 10: -// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP8x16, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); +// WelsLog( pEncCtx, WELS_LOG_INFO, "WelsMdP8x16, p_ref[0]= 0x%p", pMbCache->SPicData.pRefMb[0]); iCostP8x16 = WelsMdP8x16 (pEncCtx->pFuncList, pCurDqLayer, pWelsMd, pSlice); if (iCostP8x16 < iBestCost) { iBestCost = iCostP8x16; @@ -1218,10 +1218,10 @@ void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice inline void VaaBackgroundMbDataUpdate (SWelsFuncPtrList* pFunc, SVAAFrameInfo* pVaaInfo, SMB* pCurMb) { - const int32_t kiPicStride = pVaaInfo->iPicStride; - const int32_t kiPicStrideUV = pVaaInfo->iPicStrideUV; - const int32_t kiOffsetY = (pCurMb->iMbY * kiPicStride + pCurMb->iMbX) << 4; - const int32_t kiOffsetUV = (pCurMb->iMbY * kiPicStrideUV + pCurMb->iMbX) << 3; + const int32_t kiPicStride = pVaaInfo->iPicStride; + const int32_t kiPicStrideUV = pVaaInfo->iPicStrideUV; + const int32_t kiOffsetY = (pCurMb->iMbY * kiPicStride + pCurMb->iMbX) << 4; + const int32_t kiOffsetUV = (pCurMb->iMbY * kiPicStrideUV + pCurMb->iMbX) << 3; pFunc->pfCopy16x16Aligned (pVaaInfo->pCurY + kiOffsetY, kiPicStride, pVaaInfo->pRefY + kiOffsetY, kiPicStride); pFunc->pfCopy8x8Aligned (pVaaInfo->pCurU + kiOffsetUV, kiPicStrideUV, pVaaInfo->pRefU + kiOffsetUV, kiPicStrideUV); @@ -1230,22 +1230,22 @@ inline void VaaBackgroundMbDataUpdate (SWelsFuncPtrList* pFunc, SVAAFrameInfo* p void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache, SSlice* pSlice, bool bSkipMbFlag) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SMVUnitXY sMvp = { 0 }; - uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; - uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; - uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2]; - int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0]; - int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1]; - uint8_t* pDstLuma = pMbCache->pSkipMb; - uint8_t* pDstCb = pMbCache->pSkipMb + 256; - uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SMVUnitXY sMvp = { 0 }; + uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; + uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; + uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2]; + int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0]; + int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1]; + uint8_t* pDstLuma = pMbCache->pSkipMb; + uint8_t* pDstCb = pMbCache->pSkipMb + 256; + uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64; if (!bSkipMbFlag) { - pDstLuma = pMbCache->pMemPredLuma; - pDstCb = pMbCache->pMemPredChroma; - pDstCr = pMbCache->pMemPredChroma + 64; + pDstLuma = pMbCache->pMemPredLuma; + pDstCb = pMbCache->pMemPredChroma; + pDstCr = pMbCache->pMemPredChroma + 64; } //MC pFunc->sMcFuncs.pMcLumaFunc (pRefLuma, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16); @@ -1300,8 +1300,8 @@ void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, } bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; @@ -1316,8 +1316,8 @@ bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCac SMVUnitXY sMvp = { 0 }; int32_t n; - int32_t iEncStride = pCurLayer->iEncStride[0]; - uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; + int32_t iEncStride = pCurLayer->iEncStride[0]; + uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; int32_t* pStrideEncBlockOffset = pEncCtx->pStrideTab->pStrideEncBlockOffset[pEncCtx->uiDependencyId]; int32_t* pEncBlockOffset; @@ -1583,7 +1583,7 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM } bool WelsMdFirstIntraMode (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; int32_t iCostI16x16 = WelsMdI16x16 (pFunc, pEncCtx->pCurDqLayer, pMbCache, pWelsMd->iLambda); @@ -1612,14 +1612,14 @@ bool WelsMdFirstIntraMode (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, } void WelsMdInterMb (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pUnused) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail; - const int32_t kiMbWidth = pCurDqLayer->iMbWidth; - const SMB* top_mb = pCurMb - kiMbWidth; - const bool bMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false); - const bool bMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (top_mb->uiMbType) : false); - const bool bMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((top_mb - 1)->uiMbType) : false); + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail; + const int32_t kiMbWidth = pCurDqLayer->iMbWidth; + const SMB* top_mb = pCurMb - kiMbWidth; + const bool bMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false); + const bool bMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (top_mb->uiMbType) : false); + const bool bMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((top_mb - 1)->uiMbType) : false); const bool bMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP ((top_mb + 1)->uiMbType) : false); bool bTrySkip = bMbLeftAvailPskip || bMbTopAvailPskip || bMbTopLeftAvailPskip || bMbTopRightAvailPskip; bool bKeepSkip = bMbLeftAvailPskip && bMbTopAvailPskip && bMbTopRightAvailPskip; @@ -1719,7 +1719,7 @@ void WelsMdInterDecidedPskip (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, ////// void WelsMdInterEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache) { SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; //add pEnc&rec to MD--2010.3.15 const int32_t kiCsStrideY = pCurDqLayer->iCsStride[0]; @@ -1779,7 +1779,7 @@ void WelsMdInterSecondaryModesEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlic void WelsMdIntraSecondaryModesEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; //initial prediction memory for I_4x4 - pFunc->pfIntraFineMd (pEncCtx, pWelsMd, pCurMb, pMbCache); //WelsMdIntraFinePartitionVaa + pFunc->pfIntraFineMd (pEncCtx, pWelsMd, pCurMb, pMbCache); //WelsMdIntraFinePartitionVaa //add pEnc&rec to MD--2010.3.15 if (IS_INTRA16x16 (pCurMb->uiMbType)) { diff --git a/codec/encoder/core/src/svc_enc_slice_segment.cpp b/codec/encoder/core/src/svc_enc_slice_segment.cpp index 2f64ae18..ae90269a 100644 --- a/codec/encoder/core/src/svc_enc_slice_segment.cpp +++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp @@ -71,13 +71,13 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM return 1; if (SM_ROWMB_SLICE == pSliceSeg->uiSliceMode) { - const int32_t kiMbWidth = pSliceSeg->iMbWidth; + const int32_t kiMbWidth = pSliceSeg->iMbWidth; int32_t iSliceNum = pSliceSeg->iSliceNumInFrame, uiSliceIdx = 0; while (uiSliceIdx < iSliceNum) { const int32_t kiFirstMb = uiSliceIdx * kiMbWidth; - pSliceSeg->pCountMbNumInSlice[uiSliceIdx] = kiMbWidth; - pSliceSeg->pFirstMbInSlice[uiSliceIdx] = kiFirstMb; + pSliceSeg->pCountMbNumInSlice[uiSliceIdx] = kiMbWidth; + pSliceSeg->pFirstMbInSlice[uiSliceIdx] = kiFirstMb; WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, uiSliceIdx, kiMbWidth, sizeof(uint16_t)); ++ uiSliceIdx; @@ -87,22 +87,22 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM } else if (SM_RASTER_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; - const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame; - uint16_t iSliceIdx = 0; - int32_t iMbIdx = 0; + const int32_t* kpSlicesAssignList = (int32_t*) & (kpMso->sSliceArgument.uiSliceMbNum[0]); + const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame; + const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame; + uint16_t iSliceIdx = 0; + int32_t iMbIdx = 0; do { - const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; - int32_t iRunIdx = 0; + const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; + int32_t iRunIdx = 0; - pSliceSeg->pFirstMbInSlice[iSliceIdx] = iMbIdx; - pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; + pSliceSeg->pFirstMbInSlice[iSliceIdx] = iMbIdx; + pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; // due here need check validate mb_assign_map for input pData, can not use memset do { - pSliceSeg->pOverallMbMap[iMbIdx + iRunIdx] = iSliceIdx; + pSliceSeg->pOverallMbMap[iMbIdx + iRunIdx] = iSliceIdx; ++ iRunIdx; } while (iRunIdx < kiCurRunLength && iMbIdx + iRunIdx < kiCountNumMbInFrame); @@ -118,7 +118,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCountNumMbInFrame; iSliceIdx++; } while (iSliceIdx < kiMaxSliceNum); - } else { // any else uiSliceMode? + } else { // any else uiSliceMode? assert (0); } @@ -132,18 +132,18 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM //slice parameter check for SM_FIXEDSLCNUM_SLICE bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) { - int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); - const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; - uint32_t uiSliceIdx = 0; - const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum; - int32_t iNumMbLeft = kiMbNumInFrame; + int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); + const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; + uint32_t uiSliceIdx = 0; + const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum; + int32_t iNumMbLeft = kiMbNumInFrame; if (NULL == pSlicesAssignList) return false; for (; uiSliceIdx + 1 < kuiSliceNum; ++ uiSliceIdx) { pSlicesAssignList[uiSliceIdx] = kiMbNumPerSlice; - iNumMbLeft -= kiMbNumPerSlice; + iNumMbLeft -= kiMbNumPerSlice; } pSlicesAssignList[uiSliceIdx] = iNumMbLeft; @@ -153,14 +153,14 @@ bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceAr //slice parameter check for SM_ROWMB_SLICE bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSliceArg) { int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); - const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; - uint32_t uiSliceIdx = 0; + const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; + uint32_t uiSliceIdx = 0; if (NULL == pSlicesAssignList) return false; while (uiSliceIdx < kuiSliceNum) { - pSlicesAssignList[uiSliceIdx] = kiMbWidth; + pSlicesAssignList[uiSliceIdx] = kiMbWidth; ++ uiSliceIdx; } return true; @@ -168,19 +168,19 @@ bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSlic //slice parameter check for SM_RASTER_SLICE bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) { - int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); - int32_t iActualSliceCount = 0; + int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); + int32_t iActualSliceCount = 0; //check mb_num setting - uint32_t uiSliceIdx = 0; - int32_t iCountMb = 0; + uint32_t uiSliceIdx = 0; + int32_t iCountMb = 0; if (NULL == pSlicesAssignList) return false; while ((uiSliceIdx < MAX_SLICES_NUM) && (0 < pSlicesAssignList[uiSliceIdx])) { - iCountMb += pSlicesAssignList[uiSliceIdx]; - iActualSliceCount = uiSliceIdx + 1; + iCountMb += pSlicesAssignList[uiSliceIdx]; + iActualSliceCount = uiSliceIdx + 1; if (iCountMb >= kiMbNumInFrame) { break; @@ -198,12 +198,12 @@ bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* //need correction: //setting is more than iMbNumInFrame, //cut the last uiSliceMbNum; adjust iCountMb - pSlicesAssignList[iActualSliceCount - 1] -= (iCountMb - kiMbNumInFrame); - iCountMb = kiMbNumInFrame; + pSlicesAssignList[iActualSliceCount - 1] -= (iCountMb - kiMbNumInFrame); + iCountMb = kiMbNumInFrame; } else if (iActualSliceCount < MAX_SLICES_NUM) { //where ( iCountMb < iMbNumInFrame ) //can do correction: - // make the last uiSliceMbNum the left num + // make the last uiSliceMbNum the left num pSlicesAssignList[iActualSliceCount] = kiMbNumInFrame - iCountMb; iActualSliceCount += 1; } else { @@ -220,8 +220,8 @@ bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* // GOM based RC related for uiSliceNum decision, only used at SM_FIXEDSLCNUM_SLICE bool GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, uint32_t* pSliceNum) { - const int32_t kiCountNumMb = kiMbWidth * kiMbHeight; - uint32_t iSliceNum = *pSliceNum; + const int32_t kiCountNumMb = kiMbWidth * kiMbHeight; + uint32_t iSliceNum = *pSliceNum; int32_t iGomSize; //The default RC is Bit-rate mode[Yi], but need consider as below: @@ -239,8 +239,8 @@ bool GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, u while (true) { if (kiCountNumMb < iGomSize * (int32_t) iSliceNum) { -- iSliceNum; - iSliceNum = iSliceNum - (iSliceNum & 0x01); // verfiy even num for multiple slices case - if (iSliceNum < 2) // for safe + iSliceNum = iSliceNum - (iSliceNum & 0x01); // verfiy even num for multiple slices case + if (iSliceNum < 2) // for safe break; continue; } @@ -257,17 +257,17 @@ bool GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, u // GOM based RC related for uiSliceMbNum decision, only used at SM_FIXEDSLCNUM_SLICE bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceArgument* pSliceArg) { - uint32_t* pSlicesAssignList = & (pSliceArg->uiSliceMbNum[0]); - const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; - const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; - const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum; - int32_t iNumMbLeft = kiMbNumInFrame; + uint32_t* pSlicesAssignList = & (pSliceArg->uiSliceMbNum[0]); + const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; + const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; + const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum; + int32_t iNumMbLeft = kiMbNumInFrame; - int32_t iMinimalMbNum = kiMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required - int32_t iMaximalMbNum = 0; // dynamically assign later + int32_t iMinimalMbNum = kiMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required + int32_t iMaximalMbNum = 0; // dynamically assign later int32_t iGomSize; - uint32_t uiSliceIdx = 0; // for test + uint32_t uiSliceIdx = 0; // for test // The default RC is Bit-rate mode [Yi], but need consider as below: // Tuned to use max of mode0 and mode1 due can not refresh on this from rc mode changed outside, 8/16/2011 @@ -284,15 +284,15 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, int32_t iNumMbAssigning = WELS_DIV_ROUND (INT_MULTIPLY * kiMbNumPerSlice, iGomSize * INT_MULTIPLY) * iGomSize; int32_t iCurNumMbAssigning = 0; - iMinimalMbNum = iGomSize; + iMinimalMbNum = iGomSize; while (uiSliceIdx + 1 < kuiSliceNum) { - iMaximalMbNum = iNumMbLeft - (kuiSliceNum - uiSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts + iMaximalMbNum = iNumMbLeft - (kuiSliceNum - uiSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts // make sure one GOM at least in each slice for safe if (iNumMbAssigning < iMinimalMbNum) - iCurNumMbAssigning = iMinimalMbNum; + iCurNumMbAssigning = iMinimalMbNum; else if (iNumMbAssigning > iMaximalMbNum) - iCurNumMbAssigning = ( iMaximalMbNum / iGomSize ) * iGomSize; + iCurNumMbAssigning = ( iMaximalMbNum / iGomSize ) * iGomSize; else iCurNumMbAssigning = iNumMbAssigning; @@ -305,7 +305,7 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, return false; } - pSlicesAssignList[uiSliceIdx] = iCurNumMbAssigning; + pSlicesAssignList[uiSliceIdx] = iCurNumMbAssigning; ++ uiSliceIdx; } pSlicesAssignList[uiSliceIdx] = iNumMbLeft; @@ -382,23 +382,23 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg, if (NULL != pSliceSeg->pCountMbNumInSlice) { pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); - pSliceSeg->pCountMbNumInSlice = NULL; + pSliceSeg->pCountMbNumInSlice = NULL; } // just for safe - pSliceSeg->iSliceNumInFrame = 0; - pSliceSeg->iMbNumInFrame = 0; - pSliceSeg->iMbWidth = 0; - pSliceSeg->iMbHeight = 0; - pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // sigle in default + pSliceSeg->iSliceNumInFrame = 0; + pSliceSeg->iMbNumInFrame = 0; + pSliceSeg->iMbWidth = 0; + pSliceSeg->iMbHeight = 0; + pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // sigle in default } if (SM_SINGLE_SLICE == uiSliceMode) { - pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); + pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) - pSliceSeg->iSliceNumInFrame = 1; + pSliceSeg->iSliceNumInFrame = 1; - pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), + pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), "pSliceSeg->pFirstMbInSlice"); WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice) @@ -407,12 +407,12 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg, "pSliceSeg->pCountMbNumInSlice"); WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice) - pSliceSeg->uiSliceMode = uiSliceMode; - pSliceSeg->iMbWidth = kiMbWidth; - pSliceSeg->iMbHeight = kiMbHeight; - pSliceSeg->iMbNumInFrame = kiCountMbNum; - pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum; - pSliceSeg->pFirstMbInSlice[0] = 0; + pSliceSeg->uiSliceMode = uiSliceMode; + pSliceSeg->iMbWidth = kiMbWidth; + pSliceSeg->iMbHeight = kiMbHeight; + pSliceSeg->iMbNumInFrame = kiCountMbNum; + pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum; + pSliceSeg->pFirstMbInSlice[0] = 0; return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0])); } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode ) @@ -420,31 +420,31 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg, && uiSliceMode != SM_DYN_SLICE && uiSliceMode != SM_AUTO_SLICE) return 1; - pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); + pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof(uint16_t)); - //SM_DYN_SLICE: init, set pSliceSeg->iSliceNumInFrame = 1; + //SM_DYN_SLICE: init, set pSliceSeg->iSliceNumInFrame = 1; pSliceSeg->iSliceNumInFrame = GetInitialSliceNum (kiMbWidth, kiMbHeight, pMso); if (-1 == pSliceSeg->iSliceNumInFrame) return 1; - pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), + pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), "pSliceSeg->pCountMbNumInSlice"); WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice) - pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), + pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), "pSliceSeg->pFirstMbInSlice"); WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice) - pSliceSeg->uiSliceMode = pMso->uiSliceMode; - pSliceSeg->iMbWidth = kiMbWidth; - pSliceSeg->iMbHeight = kiMbHeight; - pSliceSeg->iMbNumInFrame = kiCountMbNum; + pSliceSeg->uiSliceMode = pMso->uiSliceMode; + pSliceSeg->iMbWidth = kiMbWidth; + pSliceSeg->iMbHeight = kiMbHeight; + pSliceSeg->iMbNumInFrame = kiCountMbNum; if (SM_DYN_SLICE == pMso->uiSliceMode) { if (0 < pMso->sSliceArgument.uiSliceSizeConstraint) { pSliceSeg->uiSliceSizeConstraint = pMso->sSliceArgument.uiSliceSizeConstraint; @@ -491,11 +491,11 @@ void UninitSliceSegment (SSliceCtx* pSliceSeg, CMemoryAlign* pMa) { pSliceSeg->pCountMbNumInSlice = NULL; } - pSliceSeg->iMbNumInFrame = 0; - pSliceSeg->iMbWidth = 0; - pSliceSeg->iMbHeight = 0; - pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // single in default - pSliceSeg->iSliceNumInFrame = 0; + pSliceSeg->iMbNumInFrame = 0; + pSliceSeg->iMbWidth = 0; + pSliceSeg->iMbHeight = 0; + pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // single in default + pSliceSeg->iSliceNumInFrame = 0; } } @@ -587,7 +587,7 @@ int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY) { int32_t iNextMbIdx = kiMbXY; ++ iNextMbIdx; if (iNextMbIdx >= pSliceSeg->iMbNumInFrame) - iNextMbIdx = -1; + iNextMbIdx = -1; return iNextMbIdx; } else { /*if ( SM_MULTIPLE_SLICE == pSliceSeg->uiSliceMode )*/ if (SM_RESERVED != pSliceSeg->uiSliceMode) { @@ -598,7 +598,7 @@ int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY) { return iNextMbIdx; return -1; } else - return -1; // reserved here for other multiple slice type + return -1; // reserved here for other multiple slice type } } else return -1; @@ -664,11 +664,11 @@ int32_t GetCurrentSliceNum (const SSliceCtx* kpSliceCtx) { } int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx, int32_t* pRunLength) { - const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame; - const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame; - int32_t iSameRunLenFlag = 1; - int32_t iFirstMbIdx = 0; - int32_t iSliceIdx = 0; + const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame; + const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame; + int32_t iSameRunLenFlag = 1; + int32_t iFirstMbIdx = 0; + int32_t iSliceIdx = 0; assert (iCountSliceNumInFrame <= MAX_THREADS_NUM); @@ -680,15 +680,15 @@ int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx, ++ iSliceIdx; } if (iSameRunLenFlag) { - return 1; // do not need adjust it due to same running length as before to save complexity + return 1; // do not need adjust it due to same running length as before to save complexity } iSliceIdx = 0; do { - const int32_t kiSliceRun = pRunLength[iSliceIdx]; + const int32_t kiSliceRun = pRunLength[iSliceIdx]; - pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx; - pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; + pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx; + pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, kiSliceRun, sizeof(uint16_t)); diff --git a/codec/encoder/core/src/svc_encode_mb.cpp b/codec/encoder/core/src/svc_encode_mb.cpp index 0743a0e9..040c74ed 100644 --- a/codec/encoder/core/src/svc_encode_mb.cpp +++ b/codec/encoder/core/src/svc_encode_mb.cpp @@ -53,17 +53,17 @@ void WelsDctMb (int16_t* pRes, uint8_t* pEncMb, int32_t iEncStride, uint8_t* pBe void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { ENFORCE_STACK_ALIGN_1D (int16_t, aDctT4Dc, 16, 16) - SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList; - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - const int32_t kiEncStride = pCurDqLayer->iEncStride[0]; - int16_t* pRes = pMbCache->pCoeffLevel; - uint8_t* pPred = pMbCache->SPicData.pCsMb[0]; - const int32_t kiRecStride = pCurDqLayer->iCsStride[0]; - int16_t* pBlock = pMbCache->pDct->iLumaBlock[0]; - uint8_t* pBestPred = pMbCache->pMemPredLuma; - const uint8_t* kpNoneZeroCountIdx = &g_kuiMbCountScan4Idx[0]; - uint8_t i, uiQp = pCurMb->uiLumaQp; - uint32_t uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiCountI16x16Dc; + SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + const int32_t kiEncStride = pCurDqLayer->iEncStride[0]; + int16_t* pRes = pMbCache->pCoeffLevel; + uint8_t* pPred = pMbCache->SPicData.pCsMb[0]; + const int32_t kiRecStride = pCurDqLayer->iCsStride[0]; + int16_t* pBlock = pMbCache->pDct->iLumaBlock[0]; + uint8_t* pBestPred = pMbCache->pMemPredLuma; + const uint8_t* kpNoneZeroCountIdx = &g_kuiMbCountScan4Idx[0]; + uint8_t i, uiQp = pCurMb->uiLumaQp; + uint32_t uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiCountI16x16Dc; const int16_t* pMF = g_kiQuantMF[uiQp]; const int16_t* pFF = g_iQuantIntraFF[uiQp]; @@ -137,10 +137,10 @@ void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { } } void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uint8_t uiI4x4Idx) { - SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList; - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - int32_t iEncStride = pCurDqLayer->iEncStride[0]; - uint8_t uiQp = pCurMb->uiLumaQp; + SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + int32_t iEncStride = pCurDqLayer->iEncStride[0]; + uint8_t uiQp = pCurMb->uiLumaQp; int16_t* pResI4x4 = pMbCache->pCoeffLevel; uint8_t* pPredI4x4; @@ -178,21 +178,21 @@ void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uin } void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache) { - PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max; - PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8; - PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64; - PScanFunc pfScan4x4 = pFuncList->pfScan4x4; - PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4; - PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount; - PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4; - int16_t* pRes = pMbCache->pCoeffLevel; - int32_t iSingleCtrMb = 0, iSingleCtr8x8[4]; - int16_t* pBlock = pMbCache->pDct->iLumaBlock[0]; - uint8_t uiQp = pCurMb->uiLumaQp; + PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max; + PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8; + PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64; + PScanFunc pfScan4x4 = pFuncList->pfScan4x4; + PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4; + PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount; + PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4; + int16_t* pRes = pMbCache->pCoeffLevel; + int32_t iSingleCtrMb = 0, iSingleCtr8x8[4]; + int16_t* pBlock = pMbCache->pDct->iLumaBlock[0]; + uint8_t uiQp = pCurMb->uiLumaQp; const int16_t* pMF = g_kiQuantMF[uiQp]; const int16_t* pFF = g_kiQuantInterFF[uiQp]; int16_t aMax[16]; - int32_t i, j, iNoneZeroCountMbDcAc = 0, iNoneZeroCount = 0; + int32_t i, j, iNoneZeroCountMbDcAc = 0, iNoneZeroCount = 0; for (i = 0; i < 4; i++) { pfQuantizationFour4x4Max (pRes, pFF, pMF, aMax + (i << 2)); @@ -220,7 +220,7 @@ void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache if (iSingleCtrMb < 6) { //from JVT-O079 iNoneZeroCountMbDcAc = 0; - pfSetMemZeroSize64 (pRes, 768); // confirmed_safe_unsafe_usage + pfSetMemZeroSize64 (pRes, 768); // confirmed_safe_unsafe_usage } else { const uint8_t* kpNoneZeroCountIdx = g_kuiMbCountScan4Idx; for (i = 0; i < 4; i++) { @@ -233,8 +233,8 @@ void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache } pfDequantizationFour4x4 (pRes, g_kuiDequantCoeff[uiQp]); pCurMb->uiCbp |= 1 << i; - } else { // set zero for an 8x8 pBlock - pfSetMemZeroSize64 (pRes, 128); // confirmed_safe_unsafe_usage + } else { // set zero for an 8x8 pBlock + pfSetMemZeroSize64 (pRes, 128); // confirmed_safe_unsafe_usage kpNoneZeroCountIdx += 4; pBlock += 64; } @@ -244,22 +244,22 @@ void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache } void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache, int16_t* pRes, int32_t iUV) { - PQuantizationHadamardFunc pfQuantizationHadamard2x2 = pFuncList->pfQuantizationHadamard2x2; - PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max; - PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8; - PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64; - PScanFunc pfScan4x4Ac = pFuncList->pfScan4x4Ac; - PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4; - PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount; - PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4; - const int32_t kiInterFlag = !IS_INTRA (pCurMb->uiMbType); - const uint8_t kiQp = pCurMb->uiChromaQp; - uint8_t i, uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiNoneZeroCountMbDc = 0; - uint8_t uiNoneZeroCountOffset = (iUV - 1) << 1; //UV==1 or 2 - uint8_t uiSubMbIdx = 16 + ((iUV - 1) << 2); //uiSubMbIdx == 16 or 20 - int16_t* iChromaDc = pMbCache->pDct->iChromaDc[iUV - 1], *pBlock = pMbCache->pDct->iChromaBlock[ (iUV - 1) << 2]; + PQuantizationHadamardFunc pfQuantizationHadamard2x2 = pFuncList->pfQuantizationHadamard2x2; + PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max; + PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8; + PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64; + PScanFunc pfScan4x4Ac = pFuncList->pfScan4x4Ac; + PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4; + PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount; + PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4; + const int32_t kiInterFlag = !IS_INTRA (pCurMb->uiMbType); + const uint8_t kiQp = pCurMb->uiChromaQp; + uint8_t i, uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiNoneZeroCountMbDc = 0; + uint8_t uiNoneZeroCountOffset = (iUV - 1) << 1; //UV==1 or 2 + uint8_t uiSubMbIdx = 16 + ((iUV - 1) << 2); //uiSubMbIdx == 16 or 20 + int16_t* iChromaDc = pMbCache->pDct->iChromaDc[iUV - 1], *pBlock = pMbCache->pDct->iChromaBlock[ (iUV - 1) << 2]; int16_t aDct2x2[4], j, aMax[4]; - int32_t iSingleCtr8x8 = 0; + int32_t iSingleCtr8x8 = 0; const int16_t* pMF = g_kiQuantMF[kiQp]; const int16_t* pFF = g_kiQuantInterFF[ (!kiInterFlag) * 6 + kiQp]; @@ -285,8 +285,8 @@ void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCac } pRes -= 64; - if (iSingleCtr8x8 < 7) { //from JVT-O079 - pfSetMemZeroSize64 (pRes, 128); // confirmed_safe_unsafe_usage + if (iSingleCtr8x8 < 7) { //from JVT-O079 + pfSetMemZeroSize64 (pRes, 128); // confirmed_safe_unsafe_usage ST16 (&pCurMb->pNonZeroCount[16 + uiNoneZeroCountOffset], 0); ST16 (&pCurMb->pNonZeroCount[20 + uiNoneZeroCountOffset], 0); } else { @@ -307,17 +307,17 @@ void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCac WelsDequantIHadamard2x2Dc (aDct2x2, g_kuiDequantCoeff[kiQp][0]); if (2 != (pCurMb->uiCbp >> 4)) pCurMb->uiCbp |= (0x01 << 4) ; - pRes[0] = aDct2x2[0]; - pRes[16] = aDct2x2[1]; - pRes[32] = aDct2x2[2]; - pRes[48] = aDct2x2[3]; + pRes[0] = aDct2x2[0]; + pRes[16] = aDct2x2[1]; + pRes[32] = aDct2x2[2]; + pRes[48] = aDct2x2[3]; } } void WelsRecPskip (SDqLayer* pCurLayer, SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache) { - int32_t* iRecStride = pCurLayer->iCsStride; - uint8_t** pCsMb = &pMbCache->SPicData.pCsMb[0]; + int32_t* iRecStride = pCurLayer->iCsStride; + uint8_t** pCsMb = &pMbCache->SPicData.pCsMb[0]; pFuncList->pfCopy16x16Aligned (pCsMb[0], *iRecStride++, pMbCache->pSkipMb, 16); pFuncList->pfCopy8x8Aligned (pCsMb[1], *iRecStride++, pMbCache->pSkipMb + 256, 8); @@ -326,7 +326,7 @@ void WelsRecPskip (SDqLayer* pCurLayer, SWelsFuncPtrList* pFuncList, SMB* pCu } bool WelsTryPYskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { - int32_t iSingleCtrMb = 0; + int32_t iSingleCtrMb = 0; int16_t* pRes = pMbCache->pCoeffLevel; const uint8_t kuiQp = pCurMb->uiLumaQp; @@ -339,7 +339,7 @@ bool WelsTryPYskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { pEncCtx->pFuncList->pfQuantizationFour4x4Max (pRes, pFF, pMF, (int16_t*)aMax); for (j = 0; j < 4; j++) { - if (aMax[j] > 1) return false; // iSingleCtrMb += 9, can't be P_SKIP + if (aMax[j] > 1) return false; // iSingleCtrMb += 9, can't be P_SKIP else if (aMax[j] == 1) { pEncCtx->pFuncList->pfScan4x4 (pBlock, pRes); // iSingleCtrMb += pEncCtx->pFuncList->pfCalculateSingleCtr4x4 (pBlock); diff --git a/codec/encoder/core/src/svc_encode_slice.cpp b/codec/encoder/core/src/svc_encode_slice.cpp index 3e734979..e1bb6ff7 100644 --- a/codec/encoder/core/src/svc_encode_slice.cpp +++ b/codec/encoder/core/src/svc_encode_slice.cpp @@ -67,10 +67,10 @@ void UpdateNonZeroCountCache (SMB* pMb, SMbCache* pMbCache) { } void WelsSliceHeaderScalExtInit (SDqLayer* pCurLayer, SSlice* pSlice) { - SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; + SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; - uint8_t uiDependencyId = pNalHeadExt->uiDependencyId; + uint8_t uiDependencyId = pNalHeadExt->uiDependencyId; pSliceHeadExt->bSliceSkipFlag = false; @@ -90,7 +90,7 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* SSliceHeaderExt* pCurSliceExt = &pSlice->sSliceHeaderExt; SSliceHeader* pCurSliceHeader = &pCurSliceExt->sSliceHeader; - pCurSliceHeader->eSliceType = pEncCtx->eSliceType; + pCurSliceHeader->eSliceType = pEncCtx->eSliceType; pCurSliceExt->bStoreRefBasePicFlag = false; @@ -99,14 +99,14 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum; pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId; - pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0 + pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0 if (P_SLICE == pEncCtx->eSliceType) { - pCurSliceHeader->uiNumRefIdxL0Active = 1; + pCurSliceHeader->uiNumRefIdxL0Active = 1; if (pCurSliceHeader->uiRefCount > 0 && pCurSliceHeader->uiRefCount < pCurLayer->sLayerInfo.pSpsP->iNumRefFrames) { pCurSliceHeader->bNumRefIdxActiveOverrideFlag = true; - pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount; + pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount; } //to solve mismatch between debug&release else { @@ -117,23 +117,23 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* pCurSliceHeader->iSliceQpDelta = pEncCtx->iGlobalQp - pCurLayer->sLayerInfo.pPpsP->iPicInitQp; //for deblocking initial - pCurSliceHeader->uiDisableDeblockingFilterIdc = pCurLayer->iLoopFilterDisableIdc; - pCurSliceHeader->iSliceAlphaC0Offset = - pCurLayer->iLoopFilterAlphaC0Offset; // need update iSliceAlphaC0Offset & iSliceBetaOffset for pSlice-header if loop_filter_idc != 1 - pCurSliceHeader->iSliceBetaOffset = pCurLayer->iLoopFilterBetaOffset; + pCurSliceHeader->uiDisableDeblockingFilterIdc = pCurLayer->iLoopFilterDisableIdc; + pCurSliceHeader->iSliceAlphaC0Offset = + pCurLayer->iLoopFilterAlphaC0Offset; // need update iSliceAlphaC0Offset & iSliceBetaOffset for pSlice-header if loop_filter_idc != 1 + pCurSliceHeader->iSliceBetaOffset = pCurLayer->iLoopFilterBetaOffset; pCurSliceExt->uiDisableInterLayerDeblockingFilterIdc = pCurLayer->uiDisableInterLayerDeblockingFilterIdc; if (pSlice->bSliceHeaderExtFlag) { WelsSliceHeaderScalExtInit (pCurLayer, pSlice); } else { //both adaptive and default flags should equal to 0. - pCurSliceExt->bAdaptiveBaseModeFlag = - pCurSliceExt->bAdaptiveMotionPredFlag = - pCurSliceExt->bAdaptiveResidualPredFlag = false; + pCurSliceExt->bAdaptiveBaseModeFlag = + pCurSliceExt->bAdaptiveMotionPredFlag = + pCurSliceExt->bAdaptiveResidualPredFlag = false; - pCurSliceExt->bDefaultBaseModeFlag = - pCurSliceExt->bDefaultMotionPredFlag = - pCurSliceExt->bDefaultResidualPredFlag = false; + pCurSliceExt->bDefaultBaseModeFlag = + pCurSliceExt->bDefaultMotionPredFlag = + pCurSliceExt->bDefaultResidualPredFlag = false; } } @@ -178,13 +178,13 @@ void WelsCountMbType (int32_t (*iMbCount)[18], const EWelsSliceType keSt, const * \brief write reference picture list on reordering syntax in Slice header */ void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) { - SRefPicListReorderSyntax* pRefOrdering = &sSliceHeader->sRefReordering; - uint8_t eSliceType = sSliceHeader->eSliceType % 5; + SRefPicListReorderSyntax* pRefOrdering = &sSliceHeader->sRefReordering; + uint8_t eSliceType = sSliceHeader->eSliceType % 5; int16_t n = 0; - if (I_SLICE != eSliceType && SI_SLICE != eSliceType) { // !I && !SI + if (I_SLICE != eSliceType && SI_SLICE != eSliceType) { // !I && !SI BsWriteOneBit (pBs, true); -// { +// { uint16_t uiReorderingOfPicNumsIdc; do { uiReorderingOfPicNumsIdc = pRefOrdering->SReorderingSyntax[n].uiReorderingOfPicNumsIdc; @@ -196,7 +196,7 @@ void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) { n ++; } while (3 != uiReorderingOfPicNumsIdc); -// } +// } } } @@ -204,7 +204,7 @@ void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) { * \brief write reference picture marking syntax in pSlice header */ void WriteRefPicMarking (SBitStringAux* pBs, SSliceHeader* pSliceHeader, SNalUnitHeaderExt* pNalHdrExt) { - SRefPicMarking* sRefMarking = &pSliceHeader->sRefMarking; + SRefPicMarking* sRefMarking = &pSliceHeader->sRefMarking; int16_t n = 0; if (pNalHdrExt->bIdrFlag) { @@ -324,7 +324,7 @@ void WelsSliceHeaderExtWrite (sWelsEncCtx* pCtx, SBitStringAux* pBs, SDqLayer* p } BsWriteBits (pBs, pSps->iLog2MaxPocLsb, pSliceHeader->iPicOrderCntLsb); -// { +// { if (P_SLICE == pSliceHeader->eSliceType) { BsWriteOneBit (pBs, pSliceHeader->bNumRefIdxActiveOverrideFlag); if (pSliceHeader->bNumRefIdxActiveOverrideFlag) { @@ -342,7 +342,7 @@ void WelsSliceHeaderExtWrite (sWelsEncCtx* pCtx, SBitStringAux* pBs, SDqLayer* p BsWriteOneBit (pBs, pSliceHeadExt->bStoreRefBasePicFlag); } } -// } +// } if (pPps->bEntropyCodingModeFlag && pSliceHeader->eSliceType != I_SLICE) { @@ -417,14 +417,14 @@ void WelsInterMbEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { //only BaseLayer inter MB and SpatialLayer (uiQualityId = 0) inter MB calling this pFunc. //only for I SSlice void WelsIMbChromaEncode (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - const int32_t kiEncStride = pCurLayer->iEncStride[1]; - const int32_t kiCsStride = pCurLayer->iCsStride[1]; - int16_t* pCurRS = pMbCache->pCoeffLevel; - uint8_t* pBestPred = pMbCache->pBestPredIntraChroma; - uint8_t* pCsCb = pMbCache->SPicData.pCsMb[1]; - uint8_t* pCsCr = pMbCache->SPicData.pCsMb[2]; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + const int32_t kiEncStride = pCurLayer->iEncStride[1]; + const int32_t kiCsStride = pCurLayer->iCsStride[1]; + int16_t* pCurRS = pMbCache->pCoeffLevel; + uint8_t* pBestPred = pMbCache->pBestPredIntraChroma; + uint8_t* pCsCb = pMbCache->SPicData.pCsMb[1]; + uint8_t* pCsCr = pMbCache->SPicData.pCsMb[2]; //cb pFunc->pfDctFourT4 (pCurRS, pMbCache->SPicData.pEncMb[1], kiEncStride, pBestPred, 8); @@ -441,12 +441,12 @@ void WelsIMbChromaEncode (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) //only BaseLayer inter MB and SpatialLayer (uiQualityId = 0) inter MB calling this pFunc. //for P SSlice (intra part + inter part) void WelsPMbChromaEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - const int32_t kiEncStride = pCurLayer->iEncStride[1]; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - int16_t* pCurRS = pMbCache->pCoeffLevel + 256; - uint8_t* pBestPred = pMbCache->pMemPredChroma; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + const int32_t kiEncStride = pCurLayer->iEncStride[1]; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + int16_t* pCurRS = pMbCache->pCoeffLevel + 256; + uint8_t* pBestPred = pMbCache->pMemPredChroma; pFunc->pfDctFourT4 (pCurRS, pMbCache->SPicData.pEncMb[1], kiEncStride, pBestPred, 8); pFunc->pfDctFourT4 (pCurRS + 64, pMbCache->SPicData.pEncMb[2], kiEncStride, pBestPred + 64, 8); @@ -457,15 +457,15 @@ void WelsPMbChromaEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { void OutputPMbWithoutConstructCsRsNoCopy (sWelsEncCtx* pCtx, SDqLayer* pDq, SSlice* pSlice, SMB* pMb) { if ((IS_INTER (pMb->uiMbType) && !IS_SKIP (pMb->uiMbType)) - || IS_I_BL (pMb->uiMbType)) { //intra have been reconstructed, NO COPY from CS to pDecPic-- - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - uint8_t* pDecY = pMbCache->SPicData.pDecMb[0]; - uint8_t* pDecU = pMbCache->SPicData.pDecMb[1]; - uint8_t* pDecV = pMbCache->SPicData.pDecMb[2]; - int16_t* pScaledTcoeff = pMbCache->pCoeffLevel; - const int32_t kiDecStrideLuma = pDq->pDecPic->iLineSize[0]; - const int32_t kiDecStrideChroma = pDq->pDecPic->iLineSize[1]; - PIDctFunc pfIdctFour4x4 = pCtx->pFuncList->pfIDctFourT4; + || IS_I_BL (pMb->uiMbType)) { //intra have been reconstructed, NO COPY from CS to pDecPic-- + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + uint8_t* pDecY = pMbCache->SPicData.pDecMb[0]; + uint8_t* pDecU = pMbCache->SPicData.pDecMb[1]; + uint8_t* pDecV = pMbCache->SPicData.pDecMb[2]; + int16_t* pScaledTcoeff = pMbCache->pCoeffLevel; + const int32_t kiDecStrideLuma = pDq->pDecPic->iLineSize[0]; + const int32_t kiDecStrideChroma = pDq->pDecPic->iLineSize[1]; + PIDctFunc pfIdctFour4x4 = pCtx->pFuncList->pfIDctFourT4; WelsIDctT4RecOnMb (pDecY, kiDecStrideLuma, pDecY, kiDecStrideLuma, pScaledTcoeff, pfIdctFour4x4); pfIdctFour4x4 (pDecU, kiDecStrideChroma, pDecU, kiDecStrideChroma, pScaledTcoeff + 256); @@ -482,17 +482,17 @@ void UpdateQpForOverflow (SMB* pCurMb, uint8_t kuiChromaQpIndexOffset) { //first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction) //second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer) int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt; - SMB* pMbList = pCurLayer->sMbDataP; - SMB* pCurMb = NULL; - const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice; - int32_t iNextMbIdx = kiSliceFirstMbXY; - const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; - int32_t iCurMbIdx = 0, iNumMbCoded = 0; - const int32_t kiSliceIdx = pSlice->uiSliceIdx; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt; + SMB* pMbList = pCurLayer->sMbDataP; + SMB* pCurMb = NULL; + const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice; + int32_t iNextMbIdx = kiSliceFirstMbXY; + const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; + int32_t iCurMbIdx = 0, iNumMbCoded = 0; + const int32_t kiSliceIdx = pSlice->uiSliceIdx; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; SWelsMD sMd; @@ -503,7 +503,7 @@ int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encodin } for (; ;) { pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0); - iCurMbIdx = iNextMbIdx; + iCurMbIdx = iNextMbIdx; pCurMb = &pMbList[ iCurMbIdx ]; pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice); @@ -544,19 +544,19 @@ TRY_REENCODING: // Only for intra dynamic slicing int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding - SBitStringAux* pBs = pSlice->pSliceBsa; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt; - SMB* pMbList = pCurLayer->sMbDataP; - SMB* pCurMb = NULL; - const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice; - int32_t iNextMbIdx = kiSliceFirstMbXY; - const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; - int32_t iCurMbIdx = 0, iNumMbCoded = 0; - const int32_t kiSliceIdx = pSlice->uiSliceIdx; - const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); + SBitStringAux* pBs = pSlice->pSliceBsa; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt; + SMB* pMbList = pCurLayer->sMbDataP; + SMB* pCurMb = NULL; + const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice; + int32_t iNextMbIdx = kiSliceFirstMbXY; + const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; + int32_t iCurMbIdx = 0, iNumMbCoded = 0; + const int32_t kiSliceIdx = pSlice->uiSliceIdx; + const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; int32_t iEncReturn = ENC_RETURN_SUCCESS; @@ -567,7 +567,7 @@ int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + WelsInitSliceCabac (pEncCtx, pSlice); } for (; ;) { - iCurMbIdx = iNextMbIdx; + iCurMbIdx = iNextMbIdx; pCurMb = &pMbList[ iCurMbIdx ]; pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0); @@ -598,7 +598,7 @@ TRY_REENCODING: if (DynSlcJudgeSliceBoundaryStepBack (pEncCtx, pSlice, pSliceCtx, pCurMb, &sDss)) { //islice pEncCtx->pFuncList->pfStashPopMBStatus (&sDss, pSlice); pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = iCurMbIdx - - 1; // update pLastCodedMbIdxOfPartition, need to -1 due to stepping back + 1; // update pLastCodedMbIdxOfPartition, need to -1 due to stepping back ++ pCurLayer->pNumSliceCodedOfPartition[kiPartitionId]; break; @@ -618,9 +618,9 @@ TRY_REENCODING: iNextMbIdx = WelsGetNextMbOfSlice (pSliceCtx, iCurMbIdx); //whether all of MB in current pSlice encoded or not if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbCoded >= kiTotalNumMb) { - pSliceCtx->pCountMbNumInSlice[kiSliceIdx] = iCurMbIdx - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId]; + pSliceCtx->pCountMbNumInSlice[kiSliceIdx] = iCurMbIdx - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId]; pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = - iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use iCurMbIdx directly + iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use iCurMbIdx directly break; } } @@ -631,13 +631,13 @@ TRY_REENCODING: // first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction) // second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer) int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { //pMd + encoding - const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt; - const SSliceHeader* kpSh = &kpShExt->sSliceHeader; - const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice; + const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt; + const SSliceHeader* kpSh = &kpShExt->sSliceHeader; + const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice; SWelsMD sMd; - sMd.uiRef = kpSh->uiRefIndex; - sMd.bMdUsingSad = kbIsHighestDlayerFlag; + sMd.uiRef = kpSh->uiRefIndex; + sMd.bMdUsingSad = kbIsHighestDlayerFlag; if (!pEncCtx->pCurDqLayer->bBaseLayerAvailableFlag || !kbIsHighestDlayerFlag) memset (&sMd.sMe, 0, sizeof (sMd.sMe)); @@ -646,13 +646,13 @@ int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsH } int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { - const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt; - const SSliceHeader* kpSh = &kpShExt->sSliceHeader; - const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice; + const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt; + const SSliceHeader* kpSh = &kpShExt->sSliceHeader; + const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice; SWelsMD sMd; - sMd.uiRef = kpSh->uiRefIndex; - sMd.bMdUsingSad = kbIsHighestDlayerFlag; + sMd.uiRef = kpSh->uiRefIndex; + sMd.bMdUsingSad = kbIsHighestDlayerFlag; if (!pEncCtx->pCurDqLayer->bBaseLayerAvailableFlag || !kbIsHighestDlayerFlag) memset (&sMd.sMe, 0, sizeof (sMd.sMe)); @@ -662,38 +662,38 @@ int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pSlice-level init should be outside and before this function - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; + const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum == (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1); //MD switch if (kbBaseAvail && kbHighestSpatial) { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; } else { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; } return WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial); } int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pSlice-level init should be outside and before this function - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; + const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum == (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1); //MD switch if (kbBaseAvail && kbHighestSpatial) { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; } else { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; } return WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial); } @@ -711,11 +711,11 @@ static const PWelsSliceHeaderWriteFunc g_pWelsWriteSliceHeader[2] = { // 0: for int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) { - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; - SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx]; - SBitStringAux* pBs = pCurSlice->pSliceBsa; - const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; + SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx]; + SBitStringAux* pBs = pCurSlice->pSliceBsa; + const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode == SM_DYN_SLICE); @@ -763,27 +763,27 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, SMB* pMbList, const int32_t kiFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { - const int32_t kiMbWidth = pSliceCtx->iMbWidth; - int32_t iIdx = kiFirstMbIdxOfNextSlice; - int32_t iNextSliceFirstMbIdxRowStart = ((kiFirstMbIdxOfNextSlice % kiMbWidth) ? 1 : 0); - int32_t iCountMbUpdate = kiMbWidth + + const int32_t kiMbWidth = pSliceCtx->iMbWidth; + int32_t iIdx = kiFirstMbIdxOfNextSlice; + int32_t iNextSliceFirstMbIdxRowStart = ((kiFirstMbIdxOfNextSlice % kiMbWidth) ? 1 : 0); + int32_t iCountMbUpdate = kiMbWidth + iNextSliceFirstMbIdxRowStart; //need to update MB(iMbXY+1) to MB(iMbXY+1+row) in common case - const int32_t kiEndMbNeedUpdate = kiFirstMbIdxOfNextSlice + iCountMbUpdate; - SMB* pMb = &pMbList[iIdx]; + const int32_t kiEndMbNeedUpdate = kiFirstMbIdxOfNextSlice + iCountMbUpdate; + SMB* pMb = &pMbList[iIdx]; do { - uint32_t uiNeighborAvailFlag = 0; - const int32_t kiMbXY = pMb->iMbXY; - const int32_t kiMbX = pMb->iMbX; - const int32_t kiMbY = pMb->iMbY; + uint32_t uiNeighborAvailFlag = 0; + const int32_t kiMbXY = pMb->iMbXY; + const int32_t kiMbX = pMb->iMbX; + const int32_t kiMbY = pMb->iMbY; bool bLeft; bool bTop; bool bLeftTop; bool bRightTop; int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; - const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); + const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); - pMb->uiSliceIdc = kuiSliceIdc; + pMb->uiSliceIdc = kuiSliceIdc; iLeftXY = kiMbXY - 1; iTopXY = kiMbXY - kiMbWidth; iLeftTopXY = iTopXY - 1; @@ -806,7 +806,7 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, if (bRightTop) { uiNeighborAvailFlag |= TOPRIGHT_MB_POS; } - pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; + pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; ++ pMb; ++ iIdx; @@ -817,17 +817,17 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - int32_t iCurMbIdx = pCurMb->iMbXY; - uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; - const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; - uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; - SSlice* pNextSlice = NULL; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + int32_t iCurMbIdx = pCurMb->iMbXY; + uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; + const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; + uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; + SSlice* pNextSlice = NULL; - SMB* pMbList = pCurLayer->sMbDataP; + SMB* pMbList = pCurLayer->sMbDataP; //update cur pSlice info - pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; + pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; //pNextSlice pointer/initialization pNextSlice = & (pCurLayer->sLayerInfo.pSliceInLayer[ iNextSliceIdc ]); @@ -841,7 +841,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic pNextSlice->bSliceHeaderExtFlag = (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType); memcpy (&pNextSlice->sSliceHeaderExt, &pCurSlice->sSliceHeaderExt, - sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage + sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage pSliceCtx->pFirstMbInSlice[iNextSliceIdc] = iFirstMbIdxOfNextSlice; WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc, @@ -855,12 +855,12 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli SDynamicSlicingStack* pDss) { sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx; SSlice* pCurSlice = (SSlice*)pSlice; - int32_t iCurMbIdx = pCurMb->iMbXY; - uint32_t uiLen = 0; - int32_t iPosBitOffset = 0; + int32_t iCurMbIdx = pCurMb->iMbXY; + uint32_t uiLen = 0; + int32_t iPosBitOffset = 0; const int32_t kiActiveThreadsNum = pEncCtx->iActiveThreadsNum; const int32_t kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum; - const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId]; + const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId]; const bool kbCurMbNotFirstMbOfCurSlice = (pSliceCtx->pOverallMbMap[iCurMbIdx] == pSliceCtx->pOverallMbMap[iCurMbIdx - 1]); @@ -933,26 +933,26 @@ inline void WelsInitInterMDStruc (const SMB* pCurMb, uint16_t* pMvdCostTable, co SWelsMD* pMd) { pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp]; pMd->pMvdCost = &pMvdCostTable[pCurMb->uiLumaQp * kiMvdInterTableStride]; - pMd-> iMbPixX = (pCurMb->iMbX << 4); - pMd-> iMbPixY = (pCurMb->iMbY << 4); + 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) { - SWelsMD* pMd = (SWelsMD*)pWelsMd; - SBitStringAux* pBs = pSlice->pSliceBsa; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - SMB* pMbList = pCurLayer->sMbDataP; - SMB* pCurMb = NULL; - int32_t iNumMbCoded = 0; - int32_t iNextMbIdx = kiSliceFirstMbXY; - int32_t iCurMbIdx = -1; - const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; - const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride; - uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize]; - const int32_t kiSliceIdx = pSlice->uiSliceIdx; + SWelsMD* pMd = (SWelsMD*)pWelsMd; + SBitStringAux* pBs = pSlice->pSliceBsa; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SMB* pMbList = pCurLayer->sMbDataP; + SMB* pCurMb = NULL; + int32_t iNumMbCoded = 0; + int32_t iNextMbIdx = kiSliceFirstMbXY; + int32_t iCurMbIdx = -1; + const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; + const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride; + uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize]; + const int32_t kiSliceIdx = pSlice->uiSliceIdx; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; int32_t iEncReturn = ENC_RETURN_SUCCESS; SDynamicSlicingStack sDss; @@ -963,7 +963,7 @@ int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, for (;;) { pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun); //point to current pMb - iCurMbIdx = iNextMbIdx; + iCurMbIdx = iNextMbIdx; pCurMb = &pMbList[ iCurMbIdx ]; @@ -1030,21 +1030,21 @@ TRY_REENCODING: // Only for inter dynamic slicing int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) { - SWelsMD* pMd = (SWelsMD*)pWelsMd; - SBitStringAux* pBs = pSlice->pSliceBsa; - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - SMB* pMbList = pCurLayer->sMbDataP; - SMB* pCurMb = NULL; - int32_t iNumMbCoded = 0; - const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; - int32_t iNextMbIdx = kiSliceFirstMbXY; - int32_t iCurMbIdx = -1; - const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride; - uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize]; - const int32_t kiSliceIdx = pSlice->uiSliceIdx; - const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); + SWelsMD* pMd = (SWelsMD*)pWelsMd; + SBitStringAux* pBs = pSlice->pSliceBsa; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SMB* pMbList = pCurLayer->sMbDataP; + SMB* pCurMb = NULL; + int32_t iNumMbCoded = 0; + const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; + int32_t iNextMbIdx = kiSliceFirstMbXY; + int32_t iCurMbIdx = -1; + const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride; + uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize]; + const int32_t kiSliceIdx = pSlice->uiSliceIdx; + const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; int32_t iEncReturn = ENC_RETURN_SUCCESS; @@ -1060,7 +1060,7 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun); //point to current pMb - iCurMbIdx = iNextMbIdx; + iCurMbIdx = iNextMbIdx; pCurMb = &pMbList[ iCurMbIdx ]; //step(1): set QP for the current MB @@ -1111,7 +1111,7 @@ TRY_REENCODING: if (DynSlcJudgeSliceBoundaryStepBack (pEncCtx, pSlice, pSliceCtx, pCurMb, &sDss)) { pSlice->iMbSkipRun = pEncCtx->pFuncList->pfStashPopMBStatus (&sDss, pSlice); pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = iCurMbIdx - - 1; // update pLastCodedMbIdxOfPartition, need to -1 due to stepping back + 1; // update pLastCodedMbIdxOfPartition, need to -1 due to stepping back ++ pCurLayer->pNumSliceCodedOfPartition[kiPartitionId]; break; @@ -1134,7 +1134,7 @@ TRY_REENCODING: //whether all of MB in current pSlice encoded or not if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbCoded >= kiTotalNumMb) { pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = - iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use pCurMb_idx directly + iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use pCurMb_idx directly break; } } diff --git a/codec/encoder/core/src/svc_mode_decision.cpp b/codec/encoder/core/src/svc_mode_decision.cpp index 190bbf9d..3b357e7b 100644 --- a/codec/encoder/core/src/svc_mode_decision.cpp +++ b/codec/encoder/core/src/svc_mode_decision.cpp @@ -58,11 +58,10 @@ void WelsMdSpatialelInterMbIlfmdNoilp (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, S const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail; const int32_t kiMbWidth = pCurDqLayer->iMbWidth; const SMB* kpTopMb = pCurMb - kiMbWidth; - const bool kbMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false); - const bool kbMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (kpTopMb->uiMbType) : false); - const bool kbMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((kpTopMb - 1)->uiMbType) : false); - const bool kbMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP (( - kpTopMb + 1)->uiMbType) : false); + const bool kbMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false); + const bool kbMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (kpTopMb->uiMbType) : false); + const bool kbMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((kpTopMb - 1)->uiMbType) : false); + const bool kbMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP ((kpTopMb + 1)->uiMbType) : false); bool bTrySkip = kbMbLeftAvailPskip | kbMbTopAvailPskip | kbMbTopLeftAvailPskip | kbMbTopRightAvailPskip; bool bKeepSkip = kbMbLeftAvailPskip & kbMbTopAvailPskip & kbMbTopRightAvailPskip; @@ -107,10 +106,10 @@ void WelsMdSpatialelInterMbIlfmdNoilp (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, S void WelsMdInterMbEnhancelayer (sWelsEncCtx* pEncCtx, SWelsMD* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache) { - SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; - SWelsMD* pWelsMd = (SWelsMD*)pMd; - const SMB* kpInterLayerRefMb = GetRefMb (pCurLayer, pCurMb); - const Mb_Type kuiInterLayerRefMbType = kpInterLayerRefMb->uiMbType; + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; + SWelsMD* pWelsMd = (SWelsMD*)pMd; + const SMB* kpInterLayerRefMb = GetRefMb (pCurLayer, pCurMb); + const Mb_Type kuiInterLayerRefMbType = kpInterLayerRefMb->uiMbType; SetMvBaseEnhancelayer (pWelsMd, pCurMb, kpInterLayerRefMb); // initial sMvBase here only when pRef mb type is inter, if not sMvBase will be not used! @@ -121,7 +120,7 @@ void WelsMdInterMbEnhancelayer (sWelsEncCtx* pEncCtx, SWelsMD* pMd, SSlice* pSli // do initiation for noILP (needed by ILFMD) SMB* GetRefMb (SDqLayer* pCurLayer, SMB* pCurMb) { - const SDqLayer* kpRefLayer = pCurLayer->pRefLayer; + const SDqLayer* kpRefLayer = pCurLayer->pRefLayer; const int32_t kiRefMbIdx = (pCurMb->iMbY >> 1) * kpRefLayer->iMbWidth + (pCurMb->iMbX >> 1); //because current lower layer is half size on both vertical and horizontal return (&kpRefLayer->sMbDataP[kiRefMbIdx]); @@ -180,12 +179,12 @@ bool CheckChromaCost (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMbCache* pMbCache uint8_t* pCbEnc = pMbCache->SPicData.pEncMb[1]; uint8_t* pCrEnc = pMbCache->SPicData.pEncMb[2]; - uint8_t* pCbRef = pMbCache->SPicData.pRefMb[1]; + uint8_t* pCbRef = pMbCache->SPicData.pRefMb[1]; uint8_t* pCrRef = pMbCache->SPicData.pRefMb[2]; const int32_t iCbEncStride = pCurDqLayer->iEncStride[1]; - const int32_t iCrEncStride = pCurDqLayer->iEncStride[2]; - const int32_t iChromaRefStride = pCurDqLayer->pRefPic->iLineSize[1]; + const int32_t iCrEncStride = pCurDqLayer->iEncStride[2]; + const int32_t iChromaRefStride = pCurDqLayer->pRefPic->iLineSize[1]; const int32_t iCbSad = GetChromaCost (pSad, pCbEnc, iCbEncStride, pCbRef, iChromaRefStride); const int32_t iCrSad = GetChromaCost (pSad, pCrEnc, iCrEncStride, pCrRef, iChromaRefStride); @@ -220,7 +219,7 @@ bool WelsMdInterJudgeBGDPskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p const int32_t kiRefMbQp = pCurDqLayer->pRefPic->pRefMbQp[pCurMb->iMbXY]; const int32_t kiCurMbQp = pCurMb->uiLumaQp;// unsigned -> signed - int8_t* pVaaBgMbFlag = pEncCtx->pVaa->pVaaBackgroundMbFlag + pCurMb->iMbXY; + int8_t* pVaaBgMbFlag = pEncCtx->pVaa->pVaaBackgroundMbFlag + pCurMb->iMbXY; const int32_t kiMbWidth = pCurDqLayer->iMbWidth; @@ -245,7 +244,7 @@ bool WelsMdInterJudgeBGDPskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p //TODO: consider reusing this result of ChromaCheck when SCDSkip needs this as well if (CheckChromaCost (pEncCtx, pWelsMd, pMbCache, pCurMb->iMbXY)) { - SMVUnitXY sVaaPredSkipMv = { 0 }; + SMVUnitXY sVaaPredSkipMv = { 0 }; PredSkipMv (pMbCache, &sVaaPredSkipMv); WelsMdBackgroundMbEnc (pEncCtx, pWelsMd, pCurMb, pMbCache, pSlice, (LD32 (&sVaaPredSkipMv) == 0)); return true; @@ -321,7 +320,7 @@ inline bool CheckBorder (int32_t iMbX, int32_t iMbY, int32_t iScrollMvX, int32_t bool JudgeStaticSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWelsMD* pWelsMd) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; const int32_t kiMbX = pCurMb->iMbX; const int32_t kiMbY = pCurMb->iMbY; @@ -332,8 +331,8 @@ bool JudgeStaticSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SPicture* pRefOri = pCurDqLayer->pRefOri[0]; if (pRefOri != NULL) { - iStrideUV = pCurDqLayer->iEncStride[1]; - iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; + iStrideUV = pCurDqLayer->iEncStride[1]; + iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; int32_t iSadCostCb = CalUVSadCost (pFunc, pMbCache->SPicData.pEncMb[1], iStrideUV, pRefOri->pData[1] + iOffsetUV, pRefOri->iLineSize[1]); @@ -348,12 +347,12 @@ bool JudgeStaticSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe } bool JudgeScrollSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWelsMD* pWelsMd) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; const int32_t kiMbX = pCurMb->iMbX; const int32_t kiMbY = pCurMb->iMbY; const int32_t kiMbWidth = pCurDqLayer->iMbWidth; const int32_t kiMbHeight = pCurDqLayer->iMbHeight; - // const int32_t block_width = mb_width << 1; + // const int32_t block_width = mb_width << 1; SVAAFrameInfoExt_t* pVaaExt = static_cast (pEncCtx->pVaa); bool bTryScrollSkip = false; @@ -372,8 +371,8 @@ bool JudgeScrollSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe if (CheckBorder (kiMbX, kiMbY, iScrollMvX, iScrollMvY, kiMbWidth, kiMbHeight)) { bTryScrollSkip = false; } else { - iStrideUV = pCurDqLayer->iEncStride[1]; - iOffsetUV = (kiMbX << 3) + (iScrollMvX >> 1) + ((kiMbY << 3) + (iScrollMvY >> 1)) * iStrideUV; + iStrideUV = pCurDqLayer->iEncStride[1]; + iOffsetUV = (kiMbX << 3) + (iScrollMvX >> 1) + ((kiMbY << 3) + (iScrollMvY >> 1)) * iStrideUV; int32_t iSadCostCb = CalUVSadCost (pFunc, pMbCache->SPicData.pEncMb[1], iStrideUV, pRefOri->pData[1] + iOffsetUV, pRefOri->iLineSize[1]); @@ -391,27 +390,27 @@ bool JudgeScrollSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe void SvcMdSCDMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache, SSlice* pSlice, bool bQpSimilarFlag, bool bMbSkipFlag, SMVUnitXY sCurMbMv[], ESkipModes eSkipMode) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; - SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; - SMVUnitXY sMvp = { 0}; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; + SMVUnitXY sMvp = { 0}; ST16 (&sMvp.iMvX, sCurMbMv[eSkipMode].iMvX); ST16 (&sMvp.iMvY, sCurMbMv[eSkipMode].iMvY); - uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; - uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; - uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2]; - int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0]; - int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1]; - uint8_t* pDstLuma = pMbCache->pSkipMb; - uint8_t* pDstCb = pMbCache->pSkipMb + 256; - uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64; + uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; + uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; + uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2]; + int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0]; + int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1]; + uint8_t* pDstLuma = pMbCache->pSkipMb; + uint8_t* pDstCb = pMbCache->pSkipMb + 256; + uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64; - const int32_t iOffsetY = (sCurMbMv[eSkipMode].iMvX >> 2) + (sCurMbMv[eSkipMode].iMvY >> 2) * iLineSizeY; + const int32_t iOffsetY = (sCurMbMv[eSkipMode].iMvX >> 2) + (sCurMbMv[eSkipMode].iMvY >> 2) * iLineSizeY; const int32_t iOffsetUV = (sCurMbMv[eSkipMode].iMvX >> 3) + (sCurMbMv[eSkipMode].iMvY >> 3) * iLineSizeUV; if (!bQpSimilarFlag || !bMbSkipFlag) { pDstLuma = pMbCache->pMemPredLuma; - pDstCb = pMbCache->pMemPredChroma; - pDstCr = pMbCache->pMemPredChroma + 64; + pDstCb = pMbCache->pMemPredChroma; + pDstCr = pMbCache->pMemPredChroma + 64; } //MC pFunc->sMcFuncs.pMcLumaFunc (pRefLuma + iOffsetY, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16); @@ -466,8 +465,8 @@ void SvcMdSCDMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach bool MdInterSCDPskipProcess (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache, ESkipModes eSkipMode) { - SVAAFrameInfoExt_t* pVaaExt = static_cast (pEncCtx->pVaa); - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SVAAFrameInfoExt_t* pVaaExt = static_cast (pEncCtx->pVaa); + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; const int32_t kiRefMbQp = pCurDqLayer->pRefPic->pRefMbQp[pCurMb->iMbXY]; const int32_t kiCurMbQp = pCurMb->uiLumaQp;// unsigned -> signed @@ -517,7 +516,7 @@ void SetBlockStaticIdcToMd (void* pVaa, SWelsMD* pWelsMd, SMB* pCurMb, SDqLayer* // Scene Change Detection (SCD) PSkip Decision for screen content //////////////////////// bool WelsMdInterJudgeSCDPskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) { - SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; + SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SetBlockStaticIdcToMd (pEncCtx->pVaa, pWelsMd, pCurMb, pCurDqLayer); @@ -635,7 +634,7 @@ void WelsMdInterFinePartitionVaaOnScreen (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd // SetScrollingMvToMd // void SetScrollingMvToMd (SVAAFrameInfo* pVaa, SWelsMD* pWelsMd) { - SVAAFrameInfoExt* pVaaExt = static_cast (pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (pVaa); SMVUnitXY sTempMv; sTempMv.iMvX = pVaaExt->sScrollDetectInfo.iScrollMvX; diff --git a/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp b/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp index f491d080..37d14ebe 100644 --- a/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp +++ b/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp @@ -372,7 +372,7 @@ SMVUnitXY WelsCabacMbMvd (SCabacCtx* pCabacCtx, SMB* pCurMb, uint32_t iMbWidth, int16_t WelsGetMbCtxCabac (SMbCache* pMbCache, SMB* pCurMb, uint32_t iMbWidth, ECtxBlockCat eCtxBlockCat, int16_t iIdx) { int16_t iNzA = -1, iNzB = -1; - int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount; + int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount; int32_t bIntra = IS_INTRA (pCurMb->uiMbType); int32_t iCtxInc = 0; switch (eCtxBlockCat) { @@ -479,11 +479,11 @@ int32_t WelsWriteMbResidualCabac (SWelsFuncPtrList* pFuncList, SSlice* pSlice, S int16_t iMbWidth, uint32_t uiChromaQpIndexOffset) { const uint16_t uiMbType = pCurMb->uiMbType; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; int16_t i = 0; - int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount; + int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount; SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; - const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice; + const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice; pCurMb->iCbpDc = 0; @@ -560,7 +560,7 @@ int32_t WelsWriteMbResidualCabac (SWelsFuncPtrList* pFuncList, SSlice* pSlice, S } } else { pCurMb->iLumaDQp = 0; - pCurMb->uiLumaQp = pSlice->uiLastMbQp; + pCurMb->uiLumaQp = pSlice->uiLastMbQp; pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + uiChromaQpIndexOffset)]; } return 0; @@ -578,11 +578,11 @@ void WelsInitSliceCabac (sWelsEncCtx* pEncCtx, SSlice* pSlice) { int32_t WelsSpatialWriteMbSynCabac (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { SCabacCtx* pCabacCtx = &pSlice->sCabacCtx; - SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; const uint16_t uiMbType = pCurMb->uiMbType; SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; uint32_t uiNumRefIdxL0Active = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1; - const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice; + const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice; int16_t i = 0; int16_t iMbWidth = pEncCtx->pCurDqLayer->iMbWidth; uint32_t uiChromaQpIndexOffset = pEncCtx->pCurDqLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; @@ -592,7 +592,7 @@ int32_t WelsSpatialWriteMbSynCabac (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* p WelsCabacEncodeTerminate (&pSlice->sCabacCtx, 0); if (IS_SKIP (pCurMb->uiMbType)) { - pCurMb->uiLumaQp = pSlice->uiLastMbQp; + pCurMb->uiLumaQp = pSlice->uiLastMbQp; pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + uiChromaQpIndexOffset)]; WelsMbSkipCabac (&pSlice->sCabacCtx, pCurMb, iMbWidth, pEncCtx->eSliceType, 1); diff --git a/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp b/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp index 9b45cded..f8d838eb 100644 --- a/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp +++ b/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp @@ -57,8 +57,8 @@ const uint32_t g_kuiInterCbpMap[48] = { //============================Enhance Layer CAVLC Writing=========================== void WelsSpatialWriteMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - SBitStringAux* pBs = pSlice->pSliceBsa; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SBitStringAux* pBs = pSlice->pSliceBsa; SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; int32_t iNumRefIdxl0ActiveMinus1 = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1; @@ -169,8 +169,8 @@ void WelsSpatialWriteMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) } void WelsSpatialWriteSubMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { - SMbCache* pMbCache = &pSlice->sMbCacheInfo; - SBitStringAux* pBs = pSlice->pSliceBsa; + SMbCache* pMbCache = &pSlice->sMbCacheInfo; + SBitStringAux* pBs = pSlice->pSliceBsa; SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; int32_t iNumRefIdxl0ActiveMinus1 = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1; @@ -226,7 +226,7 @@ int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb const uint8_t kuiChromaQpIndexOffset = pEncCtx->pCurDqLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; if (IS_SKIP (pCurMb->uiMbType)) { - pCurMb->uiLumaQp = pSlice->uiLastMbQp; + pCurMb->uiLumaQp = pSlice->uiLastMbQp; pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)]; pSlice->iMbSkipRun++; @@ -271,10 +271,10 @@ int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb int32_t WelsWriteMbResidual (SWelsFuncPtrList* pFuncList, SMbCache* sMbCacheInfo, SMB* pCurMb, SBitStringAux* pBs) { int32_t i; - Mb_Type uiMbType = pCurMb->uiMbType; - const int32_t kiCbpChroma = pCurMb->uiCbp >> 4; - const int32_t kiCbpLuma = pCurMb->uiCbp & 0x0F; - int8_t* pNonZeroCoeffCount = sMbCacheInfo->iNonZeroCoeffCount; + Mb_Type uiMbType = pCurMb->uiMbType; + const int32_t kiCbpChroma = pCurMb->uiCbp >> 4; + const int32_t kiCbpLuma = pCurMb->uiCbp & 0x0F; + int8_t* pNonZeroCoeffCount = sMbCacheInfo->iNonZeroCoeffCount; int16_t* pBlock; int8_t iA, iB, iC; diff --git a/codec/encoder/core/src/wels_preprocess.cpp b/codec/encoder/core/src/wels_preprocess.cpp index 08f4140e..c49fa52c 100644 --- a/codec/encoder/core/src/wels_preprocess.cpp +++ b/codec/encoder/core/src/wels_preprocess.cpp @@ -122,9 +122,9 @@ int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx) { } int32_t CWelsPreProcess::AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam) { - CMemoryAlign* pMa = pCtx->pMemAlign; - const int32_t kiDlayerCount = pParam->iSpatialLayerNum; - int32_t iDlayerIndex = 0; + CMemoryAlign* pMa = pCtx->pMemAlign; + const int32_t kiDlayerCount = pParam->iSpatialLayerNum; + int32_t iDlayerIndex = 0; // spatial pictures iDlayerIndex = 0; @@ -155,7 +155,7 @@ int32_t CWelsPreProcess::AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCoding } void CWelsPreProcess::FreeSpatialPictures (sWelsEncCtx* pCtx) { - CMemoryAlign* pMa = pCtx->pMemAlign; + CMemoryAlign* pMa = pCtx->pMemAlign; int32_t j = 0; while (j < pCtx->pSvcParam->iSpatialLayerNum) { uint8_t i = 0; @@ -221,7 +221,7 @@ int32_t CWelsPreProcess::AnalyzeSpatialPic (sWelsEncCtx* pCtx, const int32_t kiD bool bCalculateVar = (pSvcParam->iRCMode >= RC_BITRATE_MODE && pCtx->eSliceType == I_SLICE); if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { - SVAAFrameInfoExt* pVaaExt = static_cast (m_pEncCtx->pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (m_pEncCtx->pVaa); SRefInfoParam* BestRefCandidateParam = (pCtx->bCurFrameMarkedAsSceneLtr) ? (& (pVaaExt->sVaaLtrBestRefCandidate[0])) : (& (pVaaExt->sVaaStrBestRefCandidate[0])); SPicture* pRefPic = m_pSpatialPic[0][BestRefCandidateParam->iSrcListIdx]; @@ -294,21 +294,21 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource int8_t iDependencyId = pSvcParam->iSpatialLayerNum - 1; int32_t iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1; - SPicture* pSrcPic = NULL; // large - SPicture* pDstPic = NULL; // small - SSpatialLayerConfig* pDlayerParam = NULL; - SSpatialLayerInternal* pDlayerParamInternal = NULL; - int32_t iSpatialNum = 0; - int32_t iSrcWidth = 0; - int32_t iSrcHeight = 0; - int32_t iTargetWidth = 0; - int32_t iTargetHeight = 0; + SPicture* pSrcPic = NULL; // large + SPicture* pDstPic = NULL; // small + SSpatialLayerConfig* pDlayerParam = NULL; + SSpatialLayerInternal* pDlayerParamInternal = NULL; + int32_t iSpatialNum = 0; + int32_t iSrcWidth = 0; + int32_t iSrcHeight = 0; + int32_t iTargetWidth = 0; + int32_t iTargetHeight = 0; int32_t iTemporalId = 0; - int32_t iActualSpatialLayerNum = 0; + int32_t iActualSpatialLayerNum = 0; pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId]; pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId]; - iTargetWidth = pDlayerParam->iVideoWidth; + iTargetWidth = pDlayerParam->iVideoWidth; iTargetHeight = pDlayerParam->iVideoHeight; iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)]; iSrcWidth = pSvcParam->SUsedPicRect.iWidth; @@ -328,7 +328,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource pDstPic = pSrcPic; if (pScaledPicture->pScaledInputPicture) { // for highest downsampling - pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; + pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId]; iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId]; } @@ -363,28 +363,28 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource -- iActualSpatialLayerNum; } - m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos]; + m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos]; -- iDependencyId; // generate other spacial layer // pSrc is - // -- padded input pic, if downsample should be applied to generate highest layer, [if] block above - // -- highest layer, if no downsampling, [else] block above + // -- padded input pic, if downsample should be applied to generate highest layer, [if] block above + // -- highest layer, if no downsampling, [else] block above if (pSvcParam->iSpatialLayerNum > 1) { while (iDependencyId >= 0) { pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId]; pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId]; - iTargetWidth = pDlayerParam->iVideoWidth; - iTargetHeight = pDlayerParam->iVideoHeight; + iTargetWidth = pDlayerParam->iVideoWidth; + iTargetHeight = pDlayerParam->iVideoHeight; iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)]; - iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1; + iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1; // NOT work for CGS, FIXME // spatial layer is able to encode indeed if ((iTemporalId != INVALID_TEMPORAL_ID)) { // down sampling performed - pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; // small + pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; // small iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId]; iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId]; DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight, true); @@ -394,7 +394,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource -- iActualSpatialLayerNum; ++ iSpatialNum; - m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos]; + m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos]; } -- iDependencyId; } @@ -408,10 +408,10 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource * \brief Whether input picture need be scaled? */ bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPicture) { - const int32_t kiInputPicWidth = pParam->SUsedPicRect.iWidth; + const int32_t kiInputPicWidth = pParam->SUsedPicRect.iWidth; const int32_t kiInputPicHeight = pParam->SUsedPicRect.iHeight; - const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualWidth; - const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualHeight; + const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualWidth; + const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualHeight; bool bNeedDownsampling = true; int32_t iSpatialIdx = pParam->iSpatialLayerNum - 1; @@ -423,10 +423,10 @@ bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPic for (; iSpatialIdx >= 0; iSpatialIdx --) { SSpatialLayerInternal* pCurLayer = &pParam->sDependencyLayers[iSpatialIdx]; - int32_t iCurDstWidth = pCurLayer->iActualWidth; - int32_t iCurDstHeight = pCurLayer->iActualHeight; - int32_t iInputWidthXDstHeight = kiInputPicWidth * iCurDstHeight; - int32_t iInputHeightXDstWidth = kiInputPicHeight * iCurDstWidth; + int32_t iCurDstWidth = pCurLayer->iActualWidth; + int32_t iCurDstHeight = pCurLayer->iActualHeight; + int32_t iInputWidthXDstHeight = kiInputPicWidth * iCurDstHeight; + int32_t iInputHeightXDstWidth = kiInputPicHeight * iCurDstWidth; if (iInputWidthXDstHeight > iInputHeightXDstWidth) { pScaledPicture->iScaledWidth[iSpatialIdx] = WELS_MAX (iCurDstWidth, 4); @@ -459,21 +459,21 @@ void FreeScaledPic (Scaled_Picture* pScaledPicture, CMemoryAlign* pMemoryAlign } int32_t CWelsPreProcess::InitLastSpatialPictures (sWelsEncCtx* pCtx) { - SWelsSvcCodingParam* pParam = pCtx->pSvcParam; - const int32_t kiDlayerCount = pParam->iSpatialLayerNum; - int32_t iDlayerIndex = 0; + SWelsSvcCodingParam* pParam = pCtx->pSvcParam; + const int32_t kiDlayerCount = pParam->iSpatialLayerNum; + int32_t iDlayerIndex = 0; if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) { - m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL; + m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL; } } else { for (; iDlayerIndex < kiDlayerCount; iDlayerIndex++) { const int32_t kiLayerInTemporal = m_uiSpatialLayersInTemporal[iDlayerIndex]; - m_pLastSpatialPicture[iDlayerIndex][0] = m_pSpatialPic[iDlayerIndex][kiLayerInTemporal - 2]; - m_pLastSpatialPicture[iDlayerIndex][1] = NULL; + m_pLastSpatialPicture[iDlayerIndex][0] = m_pSpatialPic[iDlayerIndex][kiLayerInTemporal - 2]; + m_pLastSpatialPicture[iDlayerIndex][1] = NULL; } for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) { - m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL; + m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL; } } return 0; @@ -575,7 +575,7 @@ int32_t CWelsPreProcess::DownsamplePadding (SPicture* pSrc, SPicture* pDstPic, iSrcWidth, iSrcHeight); } } else { - memcpy (&sDstPicMap, &sSrcPixMap, sizeof (sDstPicMap)); // confirmed_safe_unsafe_usage + memcpy (&sDstPicMap, &sSrcPixMap, sizeof (sDstPicMap)); // confirmed_safe_unsafe_usage } // get rid of odd line @@ -614,9 +614,9 @@ void CWelsPreProcess::VaaCalculation (SVAAFrameInfo* pVaaInfo, SPicture* pCurPic sRefPixMap.iStride[0] = pRefPicture->iLineSize[0]; sRefPixMap.eFormat = VIDEO_FORMAT_I420; - calc_param.iCalcVar = bCalculateVar; - calc_param.iCalcBgd = bCalculateBGD; - calc_param.iCalcSsd = bCalculateSQDiff; + calc_param.iCalcVar = bCalculateVar; + calc_param.iCalcBgd = bCalculateBGD; + calc_param.iCalcSsd = bCalculateSQDiff; calc_param.pCalcResult = &pVaaInfo->sVaaCalcInfo; m_pInterfaceVp->Set (iMethodIdx, &calc_param); @@ -630,14 +630,14 @@ void CWelsPreProcess::BackgroundDetection (SVAAFrameInfo* pVaaInfo, SPicture* pC pVaaInfo->iPicWidth = pCurPicture->iWidthInPixel; pVaaInfo->iPicHeight = pCurPicture->iHeightInPixel; - pVaaInfo->iPicStride = pCurPicture->iLineSize[0]; - pVaaInfo->iPicStrideUV = pCurPicture->iLineSize[1]; - pVaaInfo->pCurY = pCurPicture->pData[0]; - pVaaInfo->pRefY = pRefPicture->pData[0]; - pVaaInfo->pCurU = pCurPicture->pData[1]; - pVaaInfo->pRefU = pRefPicture->pData[1]; - pVaaInfo->pCurV = pCurPicture->pData[2]; - pVaaInfo->pRefV = pRefPicture->pData[2]; + pVaaInfo->iPicStride = pCurPicture->iLineSize[0]; + pVaaInfo->iPicStrideUV = pCurPicture->iLineSize[1]; + pVaaInfo->pCurY = pCurPicture->pData[0]; + pVaaInfo->pRefY = pRefPicture->pData[0]; + pVaaInfo->pCurU = pCurPicture->pData[1]; + pVaaInfo->pRefU = pRefPicture->pData[1]; + pVaaInfo->pCurV = pCurPicture->pData[2]; + pVaaInfo->pRefV = pRefPicture->pData[2]; int32_t iMethodIdx = METHOD_BACKGROUND_DETECTION; SPixMap sSrcPixMap; @@ -673,8 +673,8 @@ void CWelsPreProcess::BackgroundDetection (SVAAFrameInfo* pVaaInfo, SPicture* pC m_pInterfaceVp->Set (iMethodIdx, (void*)&BGDParam); m_pInterfaceVp->Process (iMethodIdx, &sSrcPixMap, &sRefPixMap); } else { - int32_t iPicWidthInMb = (pCurPicture->iWidthInPixel + 15) >> 4; - int32_t iPicHeightInMb = (pCurPicture->iHeightInPixel + 15) >> 4; + int32_t iPicWidthInMb = (pCurPicture->iWidthInPixel + 15) >> 4; + int32_t iPicHeightInMb = (pCurPicture->iHeightInPixel + 15) >> 4; memset (pVaaInfo->pVaaBackgroundMbFlag, 0, iPicWidthInMb * iPicHeightInMb); } } @@ -713,11 +713,11 @@ void CWelsPreProcess::AdaptiveQuantCalculation (SVAAFrameInfo* pVaaInfo, SPictur } void CWelsPreProcess::SetRefMbType (sWelsEncCtx* pCtx, uint32_t** pRefMbTypeArray, int32_t iRefPicType) { - const uint8_t uiTid = pCtx->uiTemporalId; + const uint8_t uiTid = pCtx->uiTemporalId; const uint8_t uiDid = pCtx->uiDependencyId; SRefList* pRefPicLlist = pCtx->ppRefPicListExt[uiDid]; - SLTRState* pLtr = &pCtx->pLtr[uiDid]; - uint8_t i = 0; + SLTRState* pLtr = &pCtx->pLtr[uiDid]; + uint8_t i = 0; if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bReceivedT0LostFlag && uiTid == 0) { for (i = 0; i < pRefPicLlist->uiLongRefCount; i++) { @@ -745,8 +745,8 @@ void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCu int32_t iComplexityAnalysisMode = 0; if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { - SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); - SComplexityAnalysisScreenParam* sComplexityAnalysisParam = &pVaaExt->sComplexityScreenParam; + SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); + SComplexityAnalysisScreenParam* sComplexityAnalysisParam = &pVaaExt->sComplexityScreenParam; SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[kiDependencyId]; if (pCtx->eSliceType == P_SLICE) @@ -797,7 +797,7 @@ void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCu m_pInterfaceVp->Get (iMethodIdx, (void*)sComplexityAnalysisParam); } else { - SVAAFrameInfo* pVaaInfo = pCtx->pVaa; + SVAAFrameInfo* pVaaInfo = pCtx->pVaa; SComplexityAnalysisParam* sComplexityAnalysisParam = & (pVaaInfo->sComplexityAnalysisParam); SWelsSvcRc* SWelsSvcRc = &pCtx->pWelsSvcRc[kiDependencyId]; @@ -990,7 +990,7 @@ void CWelsPreProcess::SaveBestRefToVaa (SRefInfoParam& sRefSaved, SRefInfoParam* ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPicture* pCurPicture) { #define STATIC_SCENE_MOTION_RATIO 0.01f SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; - SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (pCtx->pVaa); if (NULL == pCtx || NULL == pVaaExt || NULL == pCurPicture) { return LARGE_CHANGED_SCENE; } @@ -1140,7 +1140,7 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi int32_t CWelsPreProcess::GetRefFrameInfo (int32_t iRefIdx, bool bCurrentFrameIsSceneLtr, SPicture*& pRefOri) { const int32_t iTargetDid = m_pEncCtx->pSvcParam->iSpatialLayerNum - 1; - SVAAFrameInfoExt* pVaaExt = static_cast (m_pEncCtx->pVaa); + SVAAFrameInfoExt* pVaaExt = static_cast (m_pEncCtx->pVaa); SRefInfoParam* pBestRefCandidateParam = (bCurrentFrameIsSceneLtr) ? (& (pVaaExt->sVaaLtrBestRefCandidate[iRefIdx])) : (& (pVaaExt->sVaaStrBestRefCandidate[iRefIdx])); pRefOri = m_pSpatialPic[iTargetDid][pBestRefCandidateParam->iSrcListIdx]; @@ -1201,7 +1201,7 @@ int32_t CWelsPreProcess::UpdateBlockIdcForScreen (uint8_t* pCurBlockStaticPoint * \return none */ void CWelsPreProcess::WelsExchangeSpatialPictures (SPicture** ppPic1, SPicture** ppPic2) { - SPicture* tmp = *ppPic1; + SPicture* tmp = *ppPic1; assert (*ppPic1 != *ppPic2); @@ -1292,12 +1292,12 @@ void CWelsPreProcess::WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SP int32_t iSrcWidth = kpSrc->iPicWidth; int32_t iSrcHeight = kpSrc->iPicHeight; - if (iSrcHeight > kiTargetHeight) iSrcHeight = kiTargetHeight; - if (iSrcWidth > kiTargetWidth) iSrcWidth = kiTargetWidth; + if (iSrcHeight > kiTargetHeight) iSrcHeight = kiTargetHeight; + if (iSrcWidth > kiTargetWidth) iSrcWidth = kiTargetWidth; // copy from fr26 to fix the odd uiSize failed issue - if (iSrcWidth & 0x1) -- iSrcWidth; - if (iSrcHeight & 0x1) -- iSrcHeight; + if (iSrcWidth & 0x1) -- iSrcWidth; + if (iSrcHeight & 0x1) -- iSrcHeight; const int32_t kiSrcTopOffsetY = pSvcParam->SUsedPicRect.iTop; const int32_t kiSrcTopOffsetUV = (kiSrcTopOffsetY >> 1); diff --git a/codec/encoder/plus/inc/welsEncoderExt.h b/codec/encoder/plus/inc/welsEncoderExt.h index 3b8b7268..a45693b9 100644 --- a/codec/encoder/plus/inc/welsEncoderExt.h +++ b/codec/encoder/plus/inc/welsEncoderExt.h @@ -101,24 +101,24 @@ class CWelsH264SVCEncoder : public ISVCEncoder { void TraceParamInfo(SEncParamExt *pParam); void UpdateStatistics(const int64_t kiCurrentFrameTs, EVideoFrameType eFrameType, const int32_t kiCurrentFrameSize, const int64_t kiCurrentFrameMs); - sWelsEncCtx* m_pEncContext; + sWelsEncCtx* m_pEncContext; - welsCodecTrace* m_pWelsTrace; - int32_t m_iMaxPicWidth; - int32_t m_iMaxPicHeight; + welsCodecTrace* m_pWelsTrace; + int32_t m_iMaxPicWidth; + int32_t m_iMaxPicHeight; - int32_t m_iCspInternal; - bool m_bInitialFlag; + int32_t m_iCspInternal; + bool m_bInitialFlag; #ifdef OUTPUT_BIT_STREAM - FILE* m_pFileBs; - FILE* m_pFileBsSize; - bool m_bSwitch; - int32_t m_iSwitchTimes; + FILE* m_pFileBs; + FILE* m_pFileBsSize; + bool m_bSwitch; + int32_t m_iSwitchTimes; #endif//OUTPUT_BIT_STREAM #ifdef REC_FRAME_COUNT - int32_t m_uiCountFrameNum; + int32_t m_uiCountFrameNum; #endif//REC_FRAME_COUNT void InitEncoder (void); diff --git a/codec/encoder/plus/src/welsEncoderExt.cpp b/codec/encoder/plus/src/welsEncoderExt.cpp index f01d9be6..7204c874 100644 --- a/codec/encoder/plus/src/welsEncoderExt.cpp +++ b/codec/encoder/plus/src/welsEncoderExt.cpp @@ -38,7 +38,7 @@ #include "utils.h" #include "macros.h" #include "version.h" -#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms +#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms #include "ref_list_mgr_svc.h" #include "codec_ver.h" @@ -124,8 +124,8 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() m_pFileBs = WelsFopen (strStreamFileName, "wb"); m_pFileBsSize = WelsFopen (strLenFileName, "wb"); - m_bSwitch = false; - m_iSwitchTimes = 0; + m_bSwitch = false; + m_iSwitchTimes = 0; #endif//OUTPUT_BIT_STREAM InitEncoder(); @@ -149,8 +149,8 @@ CWelsH264SVCEncoder::~CWelsH264SVCEncoder() { WelsFclose (m_pFileBsSize); m_pFileBsSize = NULL; } - m_bSwitch = false; - m_iSwitchTimes = 0; + m_bSwitch = false; + m_iSwitchTimes = 0; #endif//OUTPUT_BIT_STREAM Uninitialize(); @@ -163,7 +163,7 @@ CWelsH264SVCEncoder::~CWelsH264SVCEncoder() { void CWelsH264SVCEncoder::InitEncoder (void) { - m_pWelsTrace = new welsCodecTrace(); + m_pWelsTrace = new welsCodecTrace(); if (m_pWelsTrace == NULL) { return; } @@ -257,7 +257,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { return cmInitParaError; } if (pCfg->iTemporalLayerNum < 1) - pCfg->iTemporalLayerNum = 1; + pCfg->iTemporalLayerNum = 1; if (pCfg->iTemporalLayerNum > MAX_TEMPORAL_LEVEL) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iTemporalLayerNum= %d, valid at range of [1, %d].", @@ -266,7 +266,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { return cmInitParaError; } - // assert( cfg.uiGopSize >= 1 && ( cfg.uiIntraPeriod && (cfg.uiIntraPeriod % cfg.uiGopSize) == 0) ); + // assert( cfg.uiGopSize >= 1 && ( cfg.uiIntraPeriod && (cfg.uiIntraPeriod % cfg.uiGopSize) == 0) ); if (pCfg->uiGopSize < 1 || pCfg->uiGopSize > MAX_GOP_SIZE) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, @@ -312,9 +312,9 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { } else { pCfg->iLTRRefNum = pCfg->bEnableLongTermReference ? LONG_TERM_REF_NUM : 0; if (pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT) { - pCfg->iNumRefFrame = ((pCfg->uiGopSize >> 1) > 1) ? ((pCfg->uiGopSize >> 1) + pCfg->iLTRRefNum) : + 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_CAMERA); + pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); } } @@ -323,13 +323,13 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { } const int32_t kiDecStages = WELS_LOG2 (pCfg->uiGopSize); - pCfg->iTemporalLayerNum = (int8_t) (1 + kiDecStages); - pCfg->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pCfg->iLoopFilterAlphaC0Offset, -6, 6); - pCfg->iLoopFilterBetaOffset = WELS_CLIP3 (pCfg->iLoopFilterBetaOffset, -6, 6); + pCfg->iTemporalLayerNum = (int8_t) (1 + kiDecStages); + pCfg->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pCfg->iLoopFilterAlphaC0Offset, -6, 6); + pCfg->iLoopFilterBetaOffset = WELS_CLIP3 (pCfg->iLoopFilterBetaOffset, -6, 6); // decide property list size between INIT_TYPE_PARAMETER_BASED/INIT_TYPE_CONFIG_BASED - m_iMaxPicWidth = pCfg->iPicWidth; - m_iMaxPicHeight = pCfg->iPicHeight; + m_iMaxPicWidth = pCfg->iPicWidth; + m_iMaxPicHeight = pCfg->iPicHeight; TraceParamInfo (pCfg); if (WelsInitEncoderExt (&m_pEncContext, pCfg, &m_pWelsTrace->m_sLogCtx, NULL)) { @@ -360,7 +360,7 @@ int32_t CWelsH264SVCEncoder::Uninitialize() { if (NULL != m_pEncContext) { WelsUninitEncoderExt (&m_pEncContext); - m_pEncContext = NULL; + m_pEncContext = NULL; } m_bInitialFlag = false; @@ -654,12 +654,12 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } switch (eOptionId) { - case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag + case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ENCODER_OPTION_INTER_SPATIAL_PRED, this feature not supported at present."); } break; - case ENCODER_OPTION_DATAFORMAT: { // Input color space + case ENCODER_OPTION_DATAFORMAT: { // Input color space int32_t iValue = * ((int32_t*)pOption); int32_t iColorspace = iValue; if (iColorspace == 0) { @@ -671,8 +671,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_DATAFORMAT, m_iCspInternal= 0x%x", m_iCspInternal); } break; - case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval - int32_t iValue = * ((int32_t*)pOption); + case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval + int32_t iValue = * ((int32_t*)pOption); WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IDR_INTERVAL iValue= %d", iValue); if (iValue < -1 || iValue == 0) @@ -680,26 +680,26 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { if (iValue == (int32_t)m_pEncContext->pSvcParam->uiIntraPeriod) { return cmResultSuccess; } - m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue; + m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue; } break; - case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter - SEncParamBase sEncodingParam; - SWelsSvcCodingParam sConfig; + case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter + SEncParamBase sEncodingParam; + SWelsSvcCodingParam sConfig; int32_t iTargetWidth = 0; int32_t iTargetHeight = 0; - memcpy (&sEncodingParam, pOption, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage + memcpy (&sEncodingParam, pOption, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage if (sConfig.ParamBaseTranscode (sEncodingParam)) { return cmInitParaError; } /* New configuration available here */ - iTargetWidth = sConfig.iPicWidth; - iTargetHeight = sConfig.iPicHeight; + iTargetWidth = sConfig.iPicWidth; + iTargetHeight = sConfig.iPicHeight; if (m_iMaxPicWidth != iTargetWidth || m_iMaxPicHeight != iTargetHeight) { - m_iMaxPicWidth = iTargetWidth; - m_iMaxPicHeight = iTargetHeight; + m_iMaxPicWidth = iTargetWidth; + m_iMaxPicHeight = iTargetHeight; } WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE iUsageType = %d,iPicWidth= %d;iPicHeight= %d;iTargetBitrate= %d;fMaxFrameRate= %.6ff;iRCMode= %d", @@ -715,13 +715,13 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } break; - case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter - SEncParamExt sEncodingParam; - SWelsSvcCodingParam sConfig; + case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter + SEncParamExt sEncodingParam; + SWelsSvcCodingParam sConfig; int32_t iTargetWidth = 0; int32_t iTargetHeight = 0; - memcpy (&sEncodingParam, pOption, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage + memcpy (&sEncodingParam, pOption, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage TraceParamInfo (&sEncodingParam); #ifdef OUTPUT_BIT_STREAM if (sEncodingParam.sSpatialLayers[sEncodingParam.iSpatialLayerNum - 1].iVideoWidth != @@ -731,7 +731,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } #endif//OUTPUT_BIT_STREAM if (sEncodingParam.iSpatialLayerNum < 1 - || sEncodingParam.iSpatialLayerNum > MAX_SPATIAL_LAYER_NUM) { // verify number of spatial layer + || sEncodingParam.iSpatialLayerNum > MAX_SPATIAL_LAYER_NUM) { // verify number of spatial layer WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, iSpatialLayerNum(%d) failed!", sEncodingParam.iSpatialLayerNum); @@ -756,12 +756,12 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } /* New configuration available here */ - iTargetWidth = sConfig.iPicWidth; - iTargetHeight = sConfig.iPicHeight; + iTargetWidth = sConfig.iPicWidth; + iTargetHeight = sConfig.iPicHeight; if (m_iMaxPicWidth != iTargetWidth || m_iMaxPicHeight != iTargetHeight) { - m_iMaxPicWidth = iTargetWidth; - m_iMaxPicHeight = iTargetHeight; + m_iMaxPicWidth = iTargetWidth; + m_iMaxPicHeight = iTargetHeight; } /* Check every field whether there is new request for memory block changed or else, Oct. 24, 2008 */ if (WelsEncoderParamAdjust (&m_pEncContext, &sConfig)) { @@ -769,8 +769,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } } break; - case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate - float iValue = * ((float*)pOption); + case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate + float iValue = * ((float*)pOption); if (iValue <= 0) { return cmInitParaError; } @@ -782,7 +782,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { m_pEncContext->pSvcParam->fMaxFrameRate); } break; - case ENCODER_OPTION_BITRATE: { // Target bit-rate + case ENCODER_OPTION_BITRATE: { // Target bit-rate SBitrateInfo* pInfo = (static_cast (pOption)); int32_t iBitrate = pInfo->iBitrate; if (iBitrate <= 0) { @@ -791,7 +791,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { iBitrate); return cmInitParaError; } - iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE); + iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE); switch (pInfo->iLayer) { case SPATIAL_LAYER_ALL: m_pEncContext->pSvcParam->iTargetBitrate = iBitrate; @@ -828,7 +828,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } break; - case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate + case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate SBitrateInfo* pInfo = (static_cast (pOption)); int32_t iBitrate = pInfo->iBitrate; if (iBitrate <= 0) { @@ -837,7 +837,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { iBitrate); return cmInitParaError; } - iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE); + iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE); switch (pInfo->iLayer) { case SPATIAL_LAYER_ALL: m_pEncContext->pSvcParam->iMaxBitrate = iBitrate; @@ -873,17 +873,17 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { } } break; - case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode + case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode int32_t iValue = * ((int32_t*)pOption); - m_pEncContext->pSvcParam->iRCMode = (RC_MODES) iValue; + m_pEncContext->pSvcParam->iRCMode = (RC_MODES) iValue; WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_RC_MODE iRCMode= %d ", iValue); } break; - case ENCODER_PADDING_PADDING: { // 0:disable padding;1:padding + case ENCODER_PADDING_PADDING: { // 0:disable padding;1:padding int32_t iValue = * ((int32_t*)pOption); - m_pEncContext->pSvcParam->iPaddingFlag = iValue; + m_pEncContext->pSvcParam->iPaddingFlag = iValue; WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::SetOption():ENCODER_PADDING_PADDING iPaddingFlag= %d ", iValue); @@ -1106,45 +1106,45 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) { } switch (eOptionId) { - case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag + case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ENCODER_OPTION_INTER_SPATIAL_PRED, this feature not supported at present."); } break; - case ENCODER_OPTION_DATAFORMAT: { // Input color space + case ENCODER_OPTION_DATAFORMAT: { // Input color space WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_DATAFORMAT, m_iCspInternal= 0x%x", m_iCspInternal); - * ((int32_t*)pOption) = m_iCspInternal; + * ((int32_t*)pOption) = m_iCspInternal; } break; - case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval + case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_IDR_INTERVAL, uiIntraPeriod= %d", m_pEncContext->pSvcParam->uiIntraPeriod); * ((int32_t*)pOption) = m_pEncContext->pSvcParam->uiIntraPeriod; } break; - case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter + case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT"); - memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage + memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage } break; - case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter + case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE"); m_pEncContext->pSvcParam->GetBaseParams ((SEncParamBase*) pOption); } break; - case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate + case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_FRAME_RATE, fMaxFrameRate = %.6ff", m_pEncContext->pSvcParam->fMaxFrameRate); - * ((float*)pOption) = m_pEncContext->pSvcParam->fMaxFrameRate; + * ((float*)pOption) = m_pEncContext->pSvcParam->fMaxFrameRate; } break; - case ENCODER_OPTION_BITRATE: { // Target bit-rate + case ENCODER_OPTION_BITRATE: { // Target bit-rate SBitrateInfo* pInfo = (static_cast (pOption)); if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1) @@ -1160,7 +1160,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) { pInfo->iLayer, pInfo->iBitrate); } break; - case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate + case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate SBitrateInfo* pInfo = (static_cast (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)) @@ -1196,7 +1196,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) { } break; case ENCODER_OPTION_STATISTICS_LOG_INTERVAL: { - * ((int32_t*)pOption) = m_pEncContext->iStatisticsLogInterval; + * ((int32_t*)pOption) = m_pEncContext->iStatisticsLogInterval; } break; case ENCODER_OPTION_COMPLEXITY: { @@ -1216,22 +1216,22 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { char strFileName[256] = {0}; const int32_t iDataLength = m_iMaxPicWidth * m_iMaxPicHeight; - WelsStrncpy (strFileName, 256, "pic_in_"); // confirmed_safe_unsafe_usage + WelsStrncpy (strFileName, 256, "pic_in_"); // confirmed_safe_unsafe_usage if (m_iMaxPicWidth == 640) { - WelsStrcat (strFileName, 256, "360p."); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "360p."); // confirmed_safe_unsafe_usage } else if (m_iMaxPicWidth == 320) { - WelsStrcat (strFileName, 256, "180p."); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "180p."); // confirmed_safe_unsafe_usage } else if (m_iMaxPicWidth == 160) { - WelsStrcat (strFileName, 256, "90p."); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "90p."); // confirmed_safe_unsafe_usage } switch (m_iCspInternal) { case videoFormatI420: case videoFormatYV12: - WelsStrcat (strFileName, 256, "yuv"); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "yuv"); // confirmed_safe_unsafe_usage pFile = WelsFopen (strFileName, "ab+"); - // WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_I420, m_iCspInternal= 0x%x", m_iCspInternal); + // WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_I420, m_iCspInternal= 0x%x", m_iCspInternal); if (NULL != pFile) { fwrite (pSrc, sizeof (uint8_t), (iDataLength * 3) >> 1, pFile); fflush (pFile); @@ -1239,7 +1239,7 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { } break; case videoFormatRGB: - WelsStrcat (strFileName, 256, "rgb"); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "rgb"); // confirmed_safe_unsafe_usage pFile = WelsFopen (strFileName, "ab+"); if (NULL != pFile) { fwrite (pSrc, sizeof (uint8_t), iDataLength * 3, pFile); @@ -1247,9 +1247,9 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { fclose (pFile); } case videoFormatBGR: - WelsStrcat (strFileName, 256, "bgr"); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "bgr"); // confirmed_safe_unsafe_usage pFile = WelsFopen (strFileName, "ab+"); - // WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_BGR, m_iCspInternal= 0x%x", m_iCspInternal); + // WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_BGR, m_iCspInternal= 0x%x", m_iCspInternal); if (NULL != pFile) { fwrite (pSrc, sizeof (uint8_t), iDataLength * 3, pFile); fflush (pFile); @@ -1257,7 +1257,7 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { } break; case videoFormatYUY2: - WelsStrcat (strFileName, 256, "yuy2"); // confirmed_safe_unsafe_usage + WelsStrcat (strFileName, 256, "yuy2"); // confirmed_safe_unsafe_usage pFile = WelsFopen (strFileName, "ab+"); if (NULL != pFile) { fwrite (pSrc, sizeof (uint8_t), (CALC_BI_STRIDE (m_iMaxPicWidth, 16)) * m_iMaxPicHeight, pFile); diff --git a/codec/processing/interface/IWelsVP.h b/codec/processing/interface/IWelsVP.h index ba995257..8a787941 100644 --- a/codec/processing/interface/IWelsVP.h +++ b/codec/processing/interface/IWelsVP.h @@ -169,15 +169,15 @@ typedef struct { } SSceneChangeResult; typedef struct { - unsigned char* pCurY; // Y data of current frame - unsigned char* pRefY; // Y data of pRef frame for diff calc - int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together - int* pSsd16x16; // sum of square difference of 16x16 - int* pSum16x16; // sum of 16x16 - int* pSumOfSquare16x16; // sum of square of 16x16 - int (*pSumOfDiff8x8)[4]; + unsigned char* pCurY; // Y data of current frame + unsigned char* pRefY; // Y data of pRef frame for diff calc + int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together + int* pSsd16x16; // sum of square difference of 16x16 + int* pSum16x16; // sum of 16x16 + int* pSumOfSquare16x16; // sum of square of 16x16 + int (*pSumOfDiff8x8)[4]; unsigned char (*pMad8x8)[4]; - int iFrameSad; // sad of frame + int iFrameSad; // sad of frame } SVAACalcResult; typedef struct { @@ -185,11 +185,11 @@ typedef struct { int iCalcBgd; int iCalcSsd; int iReserved; - SVAACalcResult* pCalcResult; + SVAACalcResult* pCalcResult; } SVAACalcParam; typedef struct { - signed char* pBackgroundMbFlag; + signed char* pBackgroundMbFlag; SVAACalcResult* pCalcRes; } SBGDInterface; @@ -204,12 +204,12 @@ typedef struct { } SMotionTextureUnit; typedef struct { - int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode - SVAACalcResult* pCalcResult; + int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode + SVAACalcResult* pCalcResult; SMotionTextureUnit* pMotionTextureUnit; - signed char* pMotionTextureIndexToDeltaQp; - int iAverMotionTextureIndexToDeltaQp; // *AQ_STEP_INT_MULTIPLY + signed char* pMotionTextureIndexToDeltaQp; + int iAverMotionTextureIndexToDeltaQp; // *AQ_STEP_INT_MULTIPLY } SAdaptiveQuantizationParam; typedef enum { diff --git a/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp b/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp index cee854b9..7deefa61 100644 --- a/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp +++ b/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp @@ -66,8 +66,8 @@ EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPix SMotionTextureUnit* pMotionTexture = NULL; SVAACalcResult* pVaaCalcResults = NULL; int32_t iMotionTextureIndexToDeltaQp = 0; - int32_t iAverMotionTextureIndexToDeltaQp = 0; // double to uint32 - int64_t iAverageMotionIndex = 0; // double to float + int32_t iAverMotionTextureIndexToDeltaQp = 0; // double to uint32 + int64_t iAverageMotionIndex = 0; // double to float int64_t iAverageTextureIndex = 0; int64_t iQStep = 0; diff --git a/codec/processing/src/adaptivequantization/AdaptiveQuantization.h b/codec/processing/src/adaptivequantization/AdaptiveQuantization.h index b2467994..4d04a09c 100644 --- a/codec/processing/src/adaptivequantization/AdaptiveQuantization.h +++ b/codec/processing/src/adaptivequantization/AdaptiveQuantization.h @@ -87,8 +87,8 @@ class CAdaptiveQuantization : public IStrategy { void WelsInitVarFunc (PVarFunc& pfVar, int32_t iCpuFlag); private: - PVarFunc m_pfVar; - int32_t m_CPUFlag; + PVarFunc m_pfVar; + int32_t m_CPUFlag; SAdaptiveQuantizationParam m_sAdaptiveQuantParam; }; diff --git a/codec/processing/src/backgrounddetection/BackgroundDetection.cpp b/codec/processing/src/backgrounddetection/BackgroundDetection.cpp index 98e93740..408a5f96 100644 --- a/codec/processing/src/backgrounddetection/BackgroundDetection.cpp +++ b/codec/processing/src/backgrounddetection/BackgroundDetection.cpp @@ -107,16 +107,16 @@ EResult CBackgroundDetection::Set (int32_t iType, void* pParam) { } inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight) { - int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE; - int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE; + int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE; + int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE; return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); } void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth, SBackgroundOU* pBgdOU) { - int32_t iSubSD[4]; - uint8_t iSubMAD[4]; - int32_t iSubSAD[4]; + int32_t iSubSD[4]; + uint8_t iSubMAD[4]; + int32_t iSubSAD[4]; uint8_t (*pMad8x8)[4]; int32_t (*pSad8x8)[4]; @@ -141,9 +141,9 @@ void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_ iSubMAD[2] = pMad8x8[iMbIndex][2]; iSubMAD[3] = pMad8x8[iMbIndex][3]; - pBgdOU->iSD = iSubSD[0] + iSubSD[1] + iSubSD[2] + iSubSD[3]; - pBgdOU->iSAD = iSubSAD[0] + iSubSAD[1] + iSubSAD[2] + iSubSAD[3]; - pBgdOU->iSD = WELS_ABS (pBgdOU->iSD); + pBgdOU->iSD = iSubSD[0] + iSubSD[1] + iSubSD[2] + iSubSD[3]; + pBgdOU->iSAD = iSubSAD[0] + iSubSAD[1] + iSubSAD[2] + iSubSAD[3]; + pBgdOU->iSD = WELS_ABS (pBgdOU->iSD); // get the max absolute difference (MAD) of OU and min value of the MAD of sub-blocks of OU pBgdOU->iMAD = WELS_MAX (WELS_MAX (iSubMAD[0], iSubMAD[1]), WELS_MAX (iSubMAD[2], iSubMAD[3])); @@ -155,9 +155,9 @@ void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_ } void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) { - int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; - int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; - int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; + int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; + int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; + int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array; @@ -187,8 +187,8 @@ void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) { } } inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, uint8_t* pOriCur, int32_t iStride) { - int32_t ASD = 0; - int32_t idx; + int32_t ASD = 0; + int32_t idx; for (idx = 0; idx < BGD_OU_SIZE_UV; idx++) { ASD += *pOriCur - *pOriRef; pOriRef += iStride; @@ -199,16 +199,16 @@ inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, u inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[]) { - SBackgroundOU* pOU_L = pOUNeighbours[0]; - SBackgroundOU* pOU_R = pOUNeighbours[1]; - SBackgroundOU* pOU_U = pOUNeighbours[2]; - SBackgroundOU* pOU_D = pOUNeighbours[3]; + SBackgroundOU* pOU_L = pOUNeighbours[0]; + SBackgroundOU* pOU_R = pOUNeighbours[1]; + SBackgroundOU* pOU_U = pOUNeighbours[2]; + SBackgroundOU* pOU_D = pOUNeighbours[3]; if (pBackgroundOU->iMAD > pBackgroundOU->iMinSubMad << 1) { int32_t iMaxNbrForegroundMad; int32_t iMaxNbrBackgroundMad; - int32_t aBackgroundMad[4]; - int32_t aForegroundMad[4]; + int32_t aBackgroundMad[4]; + int32_t aForegroundMad[4]; aForegroundMad[0] = (pOU_L->iBackgroundFlag - 1) & pOU_L->iMAD; aForegroundMad[1] = (pOU_R->iBackgroundFlag - 1) & pOU_R->iMAD; @@ -232,9 +232,9 @@ inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBack inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourForegroundFlags, int32_t iStartSamplePos, int32_t iPicStrideUV, vBGDParam* pBgdParam) { - static const int8_t kaOUPos[4] = {OU_LEFT, OU_RIGHT, OU_TOP, OU_BOTTOM}; - int32_t aEdgeOffset[4] = {0, BGD_OU_SIZE_UV - 1, 0, iPicStrideUV* (BGD_OU_SIZE_UV - 1)}; - int32_t iStride[4] = {iPicStrideUV, iPicStrideUV, 1, 1}; + static const int8_t kaOUPos[4] = {OU_LEFT, OU_RIGHT, OU_TOP, OU_BOTTOM}; + int32_t aEdgeOffset[4] = {0, BGD_OU_SIZE_UV - 1, 0, iPicStrideUV* (BGD_OU_SIZE_UV - 1)}; + int32_t iStride[4] = {iPicStrideUV, iPicStrideUV, 1, 1}; // V component first, high probability because V stands for red color and human skin colors have more weight on this component for (int32_t i = 0; i < 4; i++) { @@ -262,8 +262,8 @@ inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourF inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[], vBGDParam* pBgdParam, int32_t iChromaSampleStartPos) { - int32_t iPicStrideUV = pBgdParam->iStride[1]; - int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + + int32_t iPicStrideUV = pBgdParam->iStride[1]; + int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + pOUNeighbours[2]->iBackgroundFlag + pOUNeighbours[3]->iBackgroundFlag; if (pBackgroundOU->iSAD > BGD_OU_SIZE * Q_FACTOR) { @@ -278,7 +278,7 @@ inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackground // chroma component check if (pBackgroundOU->iBackgroundFlag == 1) { - int8_t iNeighbourForegroundFlags = !pOUNeighbours[0]->iBackgroundFlag | ((!pOUNeighbours[1]->iBackgroundFlag) << 1) + int8_t iNeighbourForegroundFlags = !pOUNeighbours[0]->iBackgroundFlag | ((!pOUNeighbours[1]->iBackgroundFlag) << 1) | ((!pOUNeighbours[2]->iBackgroundFlag) << 2) | ((!pOUNeighbours[3]->iBackgroundFlag) << 3); pBackgroundOU->iBackgroundFlag = !ForegroundDilation23Chroma (iNeighbourForegroundFlags, iChromaSampleStartPos, iPicStrideUV, pBgdParam); @@ -291,9 +291,9 @@ inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackground } inline void CBackgroundDetection::BackgroundErosion (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[]) { if (pBackgroundOU->iMaxDiffSubSd <= (BGD_OU_SIZE * Q_FACTOR)) { //BGD_OU_SIZE*BGD_OU_SIZE>>2 - int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + + int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + pOUNeighbours[2]->iBackgroundFlag + pOUNeighbours[3]->iBackgroundFlag; - int32_t sumNbrBGsad = (pOUNeighbours[0]->iSAD & (-pOUNeighbours[0]->iBackgroundFlag)) + (pOUNeighbours[2]->iSAD & + int32_t sumNbrBGsad = (pOUNeighbours[0]->iSAD & (-pOUNeighbours[0]->iBackgroundFlag)) + (pOUNeighbours[2]->iSAD & (-pOUNeighbours[2]->iBackgroundFlag)) + (pOUNeighbours[1]->iSAD & (-pOUNeighbours[1]->iBackgroundFlag)) + (pOUNeighbours[3]->iSAD & (-pOUNeighbours[3]->iBackgroundFlag)); @@ -318,10 +318,10 @@ inline void CBackgroundDetection::SetBackgroundMbFlag (int8_t* pBackgroundMbFlag inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU, int8_t* pBackgroundMbFlag, int32_t iPicWidthInOU, int32_t iPicWidthInMb) { if (pCurOU->iSAD > BGD_OU_SIZE * Q_FACTOR) { - SBackgroundOU* pOU_L = pCurOU - 1; - SBackgroundOU* pOU_R = pCurOU + 1; - SBackgroundOU* pOU_U = pCurOU - iPicWidthInOU; - SBackgroundOU* pOU_D = pCurOU + iPicWidthInOU; + SBackgroundOU* pOU_L = pCurOU - 1; + SBackgroundOU* pOU_R = pCurOU + 1; + SBackgroundOU* pOU_U = pCurOU - iPicWidthInOU; + SBackgroundOU* pOU_D = pCurOU + iPicWidthInOU; if (pOU_L->iBackgroundFlag + pOU_R->iBackgroundFlag + pOU_U->iBackgroundFlag + pOU_D->iBackgroundFlag <= 1) { SetBackgroundMbFlag (pBackgroundMbFlag, iPicWidthInMb, 0); pCurOU->iBackgroundFlag = 0; @@ -330,21 +330,21 @@ inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU, } void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pBgdParam) { - int32_t iPicStrideUV = pBgdParam->iStride[1]; - int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; - int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; - int32_t iOUStrideUV = iPicStrideUV << (LOG2_BGD_OU_SIZE - 1); - int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; + int32_t iPicStrideUV = pBgdParam->iStride[1]; + int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; + int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; + int32_t iOUStrideUV = iPicStrideUV << (LOG2_BGD_OU_SIZE - 1); + int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array; - int8_t* pVaaBackgroundMbFlag = (int8_t*)pBgdParam->pBackgroundMbFlag; - SBackgroundOU* pOUNeighbours[4];//0: left; 1: right; 2: top; 3: bottom + int8_t* pVaaBackgroundMbFlag = (int8_t*)pBgdParam->pBackgroundMbFlag; + SBackgroundOU* pOUNeighbours[4];//0: left; 1: right; 2: top; 3: bottom - pOUNeighbours[2] = pBackgroundOU;//top OU + pOUNeighbours[2] = pBackgroundOU;//top OU for (int32_t j = 0; j < iPicHeightInOU; j ++) { int8_t* pRowSkipFlag = pVaaBackgroundMbFlag; - pOUNeighbours[0] = pBackgroundOU;//left OU - pOUNeighbours[3] = pBackgroundOU + (iPicWidthInOU & ((j == iPicHeightInOU - 1) - 1)); //bottom OU + pOUNeighbours[0] = pBackgroundOU;//left OU + pOUNeighbours[3] = pBackgroundOU + (iPicWidthInOU & ((j == iPicHeightInOU - 1) - 1)); //bottom OU for (int32_t i = 0; i < iPicWidthInOU; i++) { pOUNeighbours[1] = pBackgroundOU + (i < iPicWidthInOU - 1); //right OU @@ -367,7 +367,7 @@ void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pB pOUNeighbours[3]++; pBackgroundOU++; } - pOUNeighbours[2] = pBackgroundOU - iPicWidthInOU; + pOUNeighbours[2] = pBackgroundOU - iPicWidthInOU; pVaaBackgroundMbFlag += OU_SIZE_IN_MB * iPicWidthInMb; } } diff --git a/codec/processing/src/backgrounddetection/BackgroundDetection.h b/codec/processing/src/backgrounddetection/BackgroundDetection.h index a442a625..80d916dd 100644 --- a/codec/processing/src/backgrounddetection/BackgroundDetection.h +++ b/codec/processing/src/backgrounddetection/BackgroundDetection.h @@ -49,12 +49,12 @@ WELSVP_NAMESPACE_BEGIN typedef struct { - int32_t iBackgroundFlag; - int32_t iSAD; - int32_t iSD; - int32_t iMAD; - int32_t iMinSubMad; - int32_t iMaxDiffSubSd; + int32_t iBackgroundFlag; + int32_t iSAD; + int32_t iSD; + int32_t iMAD; + int32_t iMinSubMad; + int32_t iMaxDiffSubSd; } SBackgroundOU; class CBackgroundDetection : public IStrategy { @@ -69,11 +69,11 @@ class CBackgroundDetection : public IStrategy { struct vBGDParam { uint8_t* pCur[3]; uint8_t* pRef[3]; - int32_t iBgdWidth; - int32_t iBgdHeight; + int32_t iBgdWidth; + int32_t iBgdHeight; int32_t iStride[3]; - SBackgroundOU* pOU_array; - int8_t* pBackgroundMbFlag; + SBackgroundOU* pOU_array; + int8_t* pBackgroundMbFlag; SVAACalcResult* pCalcRes; } m_BgdParam; diff --git a/codec/processing/src/common/memory.cpp b/codec/processing/src/common/memory.cpp index c498687c..65ef5876 100644 --- a/codec/processing/src/common/memory.cpp +++ b/codec/processing/src/common/memory.cpp @@ -36,11 +36,11 @@ WELSVP_NAMESPACE_BEGIN ///////////////////////////////////////////////////////////////////////////////// void* WelsMalloc (const uint32_t kuiSize, char* pTag) { - const int32_t kiSizeVoidPointer = sizeof (void**); - const int32_t kiSizeInt32 = sizeof (int32_t); - const int32_t kiAlignedBytes = ALIGNBYTES - 1; + const int32_t kiSizeVoidPointer = sizeof (void**); + const int32_t kiSizeInt32 = sizeof (int32_t); + const int32_t kiAlignedBytes = ALIGNBYTES - 1; - uint8_t* pBuf = (uint8_t*) ::malloc (kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32); + uint8_t* pBuf = (uint8_t*) ::malloc (kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32); uint8_t* pAlignedBuf = NULL; if (NULL == pBuf) @@ -95,7 +95,7 @@ void* WelsRealloc (void* pPointer, uint32_t* pRealSize, const uint32_t kuiSize, const uint32_t kuiOldSize = *pRealSize; uint32_t kuiNewSize = 0; void* pLocalPointer = NULL; - if (kuiOldSize >= kuiSize) // large enough of original block, so do nothing + if (kuiOldSize >= kuiSize) // large enough of original block, so do nothing return (pPointer); // new request @@ -105,13 +105,13 @@ void* WelsRealloc (void* pPointer, uint32_t* pRealSize, const uint32_t kuiSize, pLocalPointer = InternalReallocate (pPointer, kuiNewSize, pTag); if (NULL != pLocalPointer) { - *pRealSize = kuiNewSize; + *pRealSize = kuiNewSize; return (pLocalPointer); } else { return NULL; } - return NULL; // something wrong + return NULL; // something wrong } WELSVP_NAMESPACE_END diff --git a/codec/processing/src/common/util.h b/codec/processing/src/common/util.h index b81bbc3d..bb135e5d 100644 --- a/codec/processing/src/common/util.h +++ b/codec/processing/src/common/util.h @@ -70,15 +70,15 @@ WELSVP_NAMESPACE_BEGIN #define MB_TYPE_INTRA (MB_TYPE_INTRA4x4 | MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM) #define IS_INTRA(type) ((type)&MB_TYPE_INTRA) -#define WELS_MAX(x, y) ((x) > (y) ? (x) : (y)) -#define WELS_MIN(x, y) ((x) < (y) ? (x) : (y)) +#define WELS_MAX(x, y) ((x) > (y) ? (x) : (y)) +#define WELS_MIN(x, y) ((x) < (y) ? (x) : (y)) #ifndef WELS_SIGN -#define WELS_SIGN(a) ((int32_t)(a) >> 31) +#define WELS_SIGN(a) ((int32_t)(a) >> 31) #endif #ifndef WELS_ABS -#define WELS_ABS(a) ((WELS_SIGN(a) ^ (int32_t)(a)) - WELS_SIGN(a)) +#define WELS_ABS(a) ((WELS_SIGN(a) ^ (int32_t)(a)) - WELS_SIGN(a)) #endif #define WELS_CLAMP(x, minv, maxv) WELS_MIN(WELS_MAX(x, minv), maxv) diff --git a/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp b/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp index 7164986c..428a08ed 100644 --- a/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp +++ b/codec/processing/src/complexityanalysis/ComplexityAnalysis.cpp @@ -350,8 +350,8 @@ EResult CComplexityAnalysisScreen::Get (int32_t nType, void* pParam) { void CComplexityAnalysisScreen::GomComplexityAnalysisIntra (SPixMap* pSrc) { int32_t iWidth = pSrc->sRect.iRectWidth; int32_t iHeight = pSrc->sRect.iRectHeight; - int32_t iBlockWidth = iWidth >> 4; - int32_t iBlockHeight = iHeight >> 4; + int32_t iBlockWidth = iWidth >> 4; + int32_t iBlockHeight = iHeight >> 4; int32_t iBlockSadH, iBlockSadV, iGomSad = 0; int32_t iIdx = 0; @@ -375,7 +375,7 @@ void CComplexityAnalysisScreen::GomComplexityAnalysisIntra (SPixMap* pSrc) { pTmpCur = pPtrY; for (int32_t i = 0; i < iBlockWidth; i++) { - iBlockSadH = iBlockSadV = 0x7fffffff; // INT_MAX + iBlockSadH = iBlockSadV = 0x7fffffff; // INT_MAX if (j > 0) { m_pIntraFunc[0] (iMemPredMb, pTmpCur, iStrideY); iBlockSadH = m_pSadFunc (pTmpCur, iStrideY, iMemPredMb, 16); @@ -406,8 +406,8 @@ void CComplexityAnalysisScreen::GomComplexityAnalysisIntra (SPixMap* pSrc) { void CComplexityAnalysisScreen::GomComplexityAnalysisInter (SPixMap* pSrc, SPixMap* pRef, bool bScrollFlag) { int32_t iWidth = pSrc->sRect.iRectWidth; int32_t iHeight = pSrc->sRect.iRectHeight; - int32_t iBlockWidth = iWidth >> 4; - int32_t iBlockHeight = iHeight >> 4; + int32_t iBlockWidth = iWidth >> 4; + int32_t iBlockHeight = iHeight >> 4; int32_t iInterSad, iScrollSad, iBlockSadH, iBlockSadV, iGomSad = 0; int32_t iIdx = 0; @@ -457,7 +457,7 @@ void CComplexityAnalysisScreen::GomComplexityAnalysisInter (SPixMap* pSrc, SPixM } - iBlockSadH = iBlockSadV = 0x7fffffff; // INT_MAX + iBlockSadH = iBlockSadV = 0x7fffffff; // INT_MAX if (j > 0) { m_pIntraFunc[0] (iMemPredMb, pTmpCur, iStrideY); diff --git a/codec/processing/src/denoise/denoise.cpp b/codec/processing/src/denoise/denoise.cpp index 182098bb..b20da57f 100644 --- a/codec/processing/src/denoise/denoise.cpp +++ b/codec/processing/src/denoise/denoise.cpp @@ -46,7 +46,7 @@ CDenoiser::CDenoiser (int32_t iCpuFlag) { m_uiSpaceRadius = DENOISE_GRAY_RADIUS; m_fSigmaGrey = DENOISE_GRAY_SIGMA; - m_uiType = DENOISE_ALL_COMPONENT; + m_uiType = DENOISE_ALL_COMPONENT; InitDenoiseFunc (m_pfDenoise, m_CPUFlag); } diff --git a/codec/processing/src/denoise/denoise.h b/codec/processing/src/denoise/denoise.h index 4d6624e4..13d28402 100644 --- a/codec/processing/src/denoise/denoise.h +++ b/codec/processing/src/denoise/denoise.h @@ -79,8 +79,8 @@ WELSVP_EXTERN_C_END #endif typedef struct TagDenoiseFuncs { - DenoiseFilterFuncPtr pfBilateralLumaFilter8;//on 8 samples - DenoiseFilterFuncPtr pfWaverageChromaFilter8;//on 8 samples + DenoiseFilterFuncPtr pfBilateralLumaFilter8;//on 8 samples + DenoiseFilterFuncPtr pfWaverageChromaFilter8;//on 8 samples } SDenoiseFuncs; class CDenoiser : public IStrategy { @@ -96,9 +96,9 @@ class CDenoiser : public IStrategy { void WaverageDenoiseChroma (uint8_t* pSrcUV, int32_t width, int32_t height, int32_t stride); private: - float m_fSigmaGrey; //sigma for grey scale similarity, suggestion 2.5-3 - uint16_t m_uiSpaceRadius; //filter windows radius: 1-3x3, 2-5x5,3-7x7. Larger size, slower speed - uint16_t m_uiType; //do denoising on which component 1-Y, 2-U, 4-V; 7-YUV, 3-YU, 5-YV, 6-UV + float m_fSigmaGrey; //sigma for grey scale similarity, suggestion 2.5-3 + uint16_t m_uiSpaceRadius; //filter windows radius: 1-3x3, 2-5x5,3-7x7. Larger size, slower speed + uint16_t m_uiType; //do denoising on which component 1-Y, 2-U, 4-V; 7-YUV, 3-YU, 5-YV, 6-UV SDenoiseFuncs m_pfDenoise; int32_t m_CPUFlag; diff --git a/codec/processing/src/denoise/denoise_filter.cpp b/codec/processing/src/denoise/denoise_filter.cpp index 0d7793fe..533c0402 100644 --- a/codec/processing/src/denoise/denoise_filter.cpp +++ b/codec/processing/src/denoise/denoise_filter.cpp @@ -55,7 +55,7 @@ void BilateralLumaFilter8_c (uint8_t* pSample, int32_t iStride) { pCurLine = pSample - iStride - DENOISE_GRAY_RADIUS; for (y = 0; y < 3; y++) { for (x = 0; x < 3; x++) { - if (x == 1 && y == 1) continue; // except center point + if (x == 1 && y == 1) continue; // except center point iCurSample = pCurLine[x]; iCurWeight = WELS_ABS (iCurSample - iCenterSample); iGreyDiff = 32 - iCurWeight; @@ -83,9 +83,9 @@ void BilateralLumaFilter8_c (uint8_t* pSample, int32_t iStride) { 1 2 4 2 1 1 1 2 1 1 ***************************************************************************/ -#define SUM_LINE1(pSample) (pSample[0] +(pSample[1]) +(pSample[2]<<1) + pSample[3] + pSample[4]) -#define SUM_LINE2(pSample) (pSample[0] +(pSample[1]<<1) +(pSample[2]<<2) +(pSample[3]<<1) +pSample[4]) -#define SUM_LINE3(pSample) ((pSample[0]<<1) +(pSample[1]<<2) +(pSample[2]*20) +(pSample[3]<<2) +(pSample[4]<<1)) +#define SUM_LINE1(pSample) (pSample[0] +(pSample[1]) +(pSample[2]<<1) + pSample[3] + pSample[4]) +#define SUM_LINE2(pSample) (pSample[0] +(pSample[1]<<1) +(pSample[2]<<2) +(pSample[3]<<1) + pSample[4]) +#define SUM_LINE3(pSample) ((pSample[0]<<1) +(pSample[1]<<2) +(pSample[2]*20) +(pSample[3]<<2) +(pSample[4]<<1)) void WaverageChromaFilter8_c (uint8_t* pSample, int32_t iStride) { int32_t sum; uint8_t* pStartPixels = pSample - UV_WINDOWS_RADIUS * iStride - UV_WINDOWS_RADIUS; diff --git a/codec/processing/src/downsample/downsample.cpp b/codec/processing/src/downsample/downsample.cpp index 48691132..8765dfe1 100644 --- a/codec/processing/src/downsample/downsample.cpp +++ b/codec/processing/src/downsample/downsample.cpp @@ -139,14 +139,14 @@ EResult CDownsampling::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pDs int32_t CDownsampling::GetAlignedIndex (const int32_t kiSrcWidth) { int32_t iAlignIndex; - if ((kiSrcWidth & 0x1f) == 0) // x32 - iAlignIndex = 0; - else if ((kiSrcWidth & 0x0f) == 0) // x16 - iAlignIndex = 1; - else if ((kiSrcWidth & 0x07) == 0) // x8 - iAlignIndex = 2; + if ((kiSrcWidth & 0x1f) == 0) // x32 + iAlignIndex = 0; + else if ((kiSrcWidth & 0x0f) == 0) // x16 + iAlignIndex = 1; + else if ((kiSrcWidth & 0x07) == 0) // x8 + iAlignIndex = 2; else - iAlignIndex = 3; + iAlignIndex = 3; return iAlignIndex; } diff --git a/codec/processing/src/downsample/downsample.h b/codec/processing/src/downsample/downsample.h index 11c85dc6..09048f0b 100644 --- a/codec/processing/src/downsample/downsample.h +++ b/codec/processing/src/downsample/downsample.h @@ -58,8 +58,8 @@ typedef void (GeneralDownsampleFunc) (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight); -typedef HalveDownsampleFunc* PHalveDownsampleFunc; -typedef GeneralDownsampleFunc* PGeneralDownsampleFunc; +typedef HalveDownsampleFunc* PHalveDownsampleFunc; +typedef GeneralDownsampleFunc* PGeneralDownsampleFunc; HalveDownsampleFunc DyadicBilinearDownsampler_c; GeneralDownsampleFunc GeneralBilinearFastDownsampler_c; @@ -67,28 +67,28 @@ GeneralDownsampleFunc GeneralBilinearAccurateDownsampler_c; typedef struct { // align_index: 0 = x32; 1 = x16; 2 = x8; 3 = common case left; - PHalveDownsampleFunc pfHalfAverage[4]; - PGeneralDownsampleFunc pfGeneralRatioLuma; - PGeneralDownsampleFunc pfGeneralRatioChroma; + PHalveDownsampleFunc pfHalfAverage[4]; + PGeneralDownsampleFunc pfGeneralRatioLuma; + PGeneralDownsampleFunc pfGeneralRatioChroma; } SDownsampleFuncs; #ifdef X86_ASM WELSVP_EXTERN_C_BEGIN // used for scr width is multipler of 8 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx8_sse; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx8_sse; // iSrcWidth= x16 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx16_sse; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx16_sse; // iSrcWidth= x32 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse; // used for scr width is multipler of 16 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx16_ssse3; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx16_ssse3; // iSrcWidth= x32 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_ssse3; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_ssse3; // iSrcWidth= x16 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx16_sse4; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx16_sse4; // iSrcWidth= x32 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse4; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse4; GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2; GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2; @@ -103,9 +103,9 @@ WELSVP_EXTERN_C_END #ifdef HAVE_NEON WELSVP_EXTERN_C_BEGIN // iSrcWidth no limitation -HalveDownsampleFunc DyadicBilinearDownsampler_neon; +HalveDownsampleFunc DyadicBilinearDownsampler_neon; // iSrcWidth = x32 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_neon; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_neon; GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_neon; @@ -119,9 +119,9 @@ WELSVP_EXTERN_C_END #ifdef HAVE_NEON_AARCH64 WELSVP_EXTERN_C_BEGIN // iSrcWidth no limitation -HalveDownsampleFunc DyadicBilinearDownsampler_AArch64_neon; +HalveDownsampleFunc DyadicBilinearDownsampler_AArch64_neon; // iSrcWidth = x32 pixels -HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_AArch64_neon; +HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_AArch64_neon; GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_AArch64_neon; diff --git a/codec/processing/src/downsample/downsamplefuncs.cpp b/codec/processing/src/downsample/downsamplefuncs.cpp index b90994e0..4c3a0d46 100644 --- a/codec/processing/src/downsample/downsamplefuncs.cpp +++ b/codec/processing/src/downsample/downsamplefuncs.cpp @@ -49,11 +49,11 @@ void DyadicBilinearDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) { - uint8_t* pDstLine = pDst; - uint8_t* pSrcLine = pSrc; - const int32_t kiSrcStridex2 = kiSrcStride << 1; - const int32_t kiDstWidth = kiSrcWidth >> 1; - const int32_t kiDstHeight = kiSrcHeight >> 1; + uint8_t* pDstLine = pDst; + uint8_t* pSrcLine = pSrc; + const int32_t kiSrcStridex2 = kiSrcStride << 1; + const int32_t kiDstWidth = kiSrcWidth >> 1; + const int32_t kiDstHeight = kiSrcHeight >> 1; for (int32_t j = 0; j < kiDstHeight; j ++) { for (int32_t i = 0; i < kiDstWidth; i ++) { @@ -63,8 +63,8 @@ void DyadicBilinearDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1); } - pDstLine += kiDstStride; - pSrcLine += kiSrcStridex2; + pDstLine += kiDstStride; + pSrcLine += kiSrcStridex2; } } @@ -110,7 +110,7 @@ void GeneralBilinearFastDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, x += 1; x >>= 1; //x = (((__int64)(SCALE_BIG - 1 - iFu))*(SCALE_BIG - 1 - fv)*a + ((__int64)iFu)*(SCALE_BIG - 1 -fv)*b + ((__int64)(SCALE_BIG - 1 -iFu))*fv*c + - // ((__int64)iFu)*fv*d + (1 << (2*SCALE_BIT_BIG-1)) ) >> (2*SCALE_BIT_BIG); + // ((__int64)iFu)*fv*d + (1 << (2*SCALE_BIT_BIG-1)) ) >> (2*SCALE_BIT_BIG); x = WELS_CLAMP (x, 0, 255); *pByDst++ = (uint8_t)x; diff --git a/codec/processing/src/imagerotate/imagerotate.h b/codec/processing/src/imagerotate/imagerotate.h index 6e159b99..98619b60 100644 --- a/codec/processing/src/imagerotate/imagerotate.h +++ b/codec/processing/src/imagerotate/imagerotate.h @@ -58,9 +58,9 @@ ImageRotateFunc ImageRotate180D_c; ImageRotateFunc ImageRotate270D_c; typedef struct { - ImageRotateFuncPtr pfImageRotate90D; - ImageRotateFuncPtr pfImageRotate180D; - ImageRotateFuncPtr pfImageRotate270D; + ImageRotateFuncPtr pfImageRotate90D; + ImageRotateFuncPtr pfImageRotate180D; + ImageRotateFuncPtr pfImageRotate270D; } SImageRotateFuncs; class CImageRotating : public IStrategy { diff --git a/codec/processing/src/scenechangedetection/SceneChangeDetection.h b/codec/processing/src/scenechangedetection/SceneChangeDetection.h index 4f97b449..ae146cff 100644 --- a/codec/processing/src/scenechangedetection/SceneChangeDetection.h +++ b/codec/processing/src/scenechangedetection/SceneChangeDetection.h @@ -104,7 +104,7 @@ class CSceneChangeDetectorVideo { iCurRowStride = sLocalParam.iCurStride << 3; for (int32_t j = 0; j < sLocalParam.iBlock8x8Height; j++) { - pRefTmp = pRefY; + pRefTmp = pRefY; pCurTmp = pCurY; for (int32_t i = 0; i < sLocalParam.iBlock8x8Width; i++) { int32_t iSad = m_pfSad (pCurTmp, sLocalParam.iCurStride, pRefTmp, sLocalParam.iRefStride); @@ -154,7 +154,7 @@ class CSceneChangeDetectorScreen : public CSceneChangeDetectorVideo { iCurRowStride = sLocalParam.iCurStride << 3; for (int32_t j = 0; j < sLocalParam.iBlock8x8Height; j++) { - pRefTmp = pRefY; + pRefTmp = pRefY; pCurTmp = pCurY; for (int32_t i = 0; i < sLocalParam.iBlock8x8Width; i++) { int32_t iBlockPointX = i << 3; @@ -216,7 +216,7 @@ class CSceneChangeDetection : public IStrategy { int32_t iBlock8x8Num = m_sLocalParam.iBlock8x8Width * m_sLocalParam.iBlock8x8Height; int32_t iSceneChangeThresholdLarge = WelsStaticCast (int32_t, m_cDetector.GetSceneChangeMotionRatioLarge() * iBlock8x8Num + 0.5f + PESN); - int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t, + int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t, m_cDetector.GetSceneChangeMotionRatioMedium() * iBlock8x8Num + 0.5f + PESN); m_sSceneChangeParam.iMotionBlockNum = 0; diff --git a/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp b/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp index e5a77506..e7c9d2ce 100644 --- a/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp +++ b/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp @@ -69,9 +69,9 @@ 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) { - const int32_t kiHalfHeight = iHeight >> 1; - const int32_t kiMidPos = iOffsetY + kiHalfHeight; - int32_t TestPos = kiMidPos; + const int32_t kiHalfHeight = iHeight >> 1; + const int32_t kiMidPos = iOffsetY + kiHalfHeight; + int32_t TestPos = kiMidPos; int32_t iOffsetAbs; uint8_t* pTmp; diff --git a/codec/processing/src/vaacalc/vaacalculation.cpp b/codec/processing/src/vaacalc/vaacalculation.cpp index 2759a22f..6b780351 100644 --- a/codec/processing/src/vaacalc/vaacalculation.cpp +++ b/codec/processing/src/vaacalc/vaacalculation.cpp @@ -87,11 +87,11 @@ void CVAACalculation::InitVaaFuncs (SVaaFuncs& sVaaFuncs, int32_t iCpuFlag) { } EResult CVAACalculation::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) { - uint8_t* pCurData = (uint8_t*)pSrcPixMap->pPixel[0]; - uint8_t* pRefData = (uint8_t*)pRefPixMap->pPixel[0]; - int32_t iPicWidth = pSrcPixMap->sRect.iRectWidth; - int32_t iPicHeight = pSrcPixMap->sRect.iRectHeight; - int32_t iPicStride = pSrcPixMap->iStride[0]; + uint8_t* pCurData = (uint8_t*)pSrcPixMap->pPixel[0]; + uint8_t* pRefData = (uint8_t*)pRefPixMap->pPixel[0]; + int32_t iPicWidth = pSrcPixMap->sRect.iRectWidth; + int32_t iPicHeight = pSrcPixMap->sRect.iRectHeight; + int32_t iPicStride = pSrcPixMap->iStride[0]; SVAACalcResult* pResult = m_sCalcParam.pCalcResult; diff --git a/codec/processing/src/vaacalc/vaacalculation.h b/codec/processing/src/vaacalc/vaacalculation.h index 0624896b..5badb099 100644 --- a/codec/processing/src/vaacalc/vaacalculation.h +++ b/codec/processing/src/vaacalc/vaacalculation.h @@ -75,55 +75,55 @@ typedef void (VAACalcSadSsdFunc) (const uint8_t* pCurData, const uint8_t* pRefDa int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16, int32_t* pSsd16x16); -typedef VAACalcSadBgdFunc* PVAACalcSadBgdFunc; -typedef VAACalcSadSsdBgdFunc* PVAACalcSadSsdBgdFunc; -typedef VAACalcSadFunc* PVAACalcSadFunc; -typedef VAACalcSadVarFunc* PVAACalcSadVarFunc; -typedef VAACalcSadSsdFunc* PVAACalcSadSsdFunc; +typedef VAACalcSadBgdFunc* PVAACalcSadBgdFunc; +typedef VAACalcSadSsdBgdFunc* PVAACalcSadSsdBgdFunc; +typedef VAACalcSadFunc* PVAACalcSadFunc; +typedef VAACalcSadVarFunc* PVAACalcSadVarFunc; +typedef VAACalcSadSsdFunc* PVAACalcSadSsdFunc; typedef struct TagVaaFuncs { - PVAACalcSadBgdFunc pfVAACalcSadBgd; - PVAACalcSadSsdBgdFunc pfVAACalcSadSsdBgd; - PVAACalcSadFunc pfVAACalcSad; - PVAACalcSadVarFunc pfVAACalcSadVar; - PVAACalcSadSsdFunc pfVAACalcSadSsd; + PVAACalcSadBgdFunc pfVAACalcSadBgd; + PVAACalcSadSsdBgdFunc pfVAACalcSadSsdBgd; + PVAACalcSadFunc pfVAACalcSad; + PVAACalcSadVarFunc pfVAACalcSadVar; + PVAACalcSadSsdFunc pfVAACalcSadSsd; } SVaaFuncs; -VAACalcSadBgdFunc VAACalcSadBgd_c; -VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_c; -VAACalcSadFunc VAACalcSad_c; -VAACalcSadVarFunc VAACalcSadVar_c; -VAACalcSadSsdFunc VAACalcSadSsd_c; +VAACalcSadBgdFunc VAACalcSadBgd_c; +VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_c; +VAACalcSadFunc VAACalcSad_c; +VAACalcSadVarFunc VAACalcSadVar_c; +VAACalcSadSsdFunc VAACalcSadSsd_c; #ifdef X86_ASM WELSVP_EXTERN_C_BEGIN -VAACalcSadBgdFunc VAACalcSadBgd_sse2; -VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_sse2; -VAACalcSadFunc VAACalcSad_sse2; -VAACalcSadVarFunc VAACalcSadVar_sse2; -VAACalcSadSsdFunc VAACalcSadSsd_sse2; +VAACalcSadBgdFunc VAACalcSadBgd_sse2; +VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_sse2; +VAACalcSadFunc VAACalcSad_sse2; +VAACalcSadVarFunc VAACalcSadVar_sse2; +VAACalcSadSsdFunc VAACalcSadSsd_sse2; WELSVP_EXTERN_C_END #endif #ifdef HAVE_NEON WELSVP_EXTERN_C_BEGIN -VAACalcSadBgdFunc VAACalcSadBgd_neon; -VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_neon; -VAACalcSadFunc VAACalcSad_neon; -VAACalcSadVarFunc VAACalcSadVar_neon; -VAACalcSadSsdFunc VAACalcSadSsd_neon; +VAACalcSadBgdFunc VAACalcSadBgd_neon; +VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_neon; +VAACalcSadFunc VAACalcSad_neon; +VAACalcSadVarFunc VAACalcSadVar_neon; +VAACalcSadSsdFunc VAACalcSadSsd_neon; WELSVP_EXTERN_C_END #endif #ifdef HAVE_NEON_AARCH64 WELSVP_EXTERN_C_BEGIN -VAACalcSadBgdFunc VAACalcSadBgd_AArch64_neon; -VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_AArch64_neon; -VAACalcSadFunc VAACalcSad_AArch64_neon; -VAACalcSadVarFunc VAACalcSadVar_AArch64_neon; -VAACalcSadSsdFunc VAACalcSadSsd_AArch64_neon; +VAACalcSadBgdFunc VAACalcSadBgd_AArch64_neon; +VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_AArch64_neon; +VAACalcSadFunc VAACalcSad_AArch64_neon; +VAACalcSadVarFunc VAACalcSadVar_AArch64_neon; +VAACalcSadSsdFunc VAACalcSadSsd_AArch64_neon; WELSVP_EXTERN_C_END #endif diff --git a/test/api/encode_decode_api_test.cpp b/test/api/encode_decode_api_test.cpp index a5ace13a..68780451 100644 --- a/test/api/encode_decode_api_test.cpp +++ b/test/api/encode_decode_api_test.cpp @@ -543,15 +543,15 @@ void EncodeDecodeTestAPIBase::SliceParamValidationForMode2 (int iSpatialIdx) { unsigned int uiSliceIdx = 0; unsigned int uiActualSliceCount = 0; - uiMbWidth = (param_.iPicWidth + 15) >> 4; - uiMbHeight = (param_.iPicHeight + 15) >> 4; + uiMbWidth = (param_.iPicWidth + 15) >> 4; + uiMbHeight = (param_.iPicHeight + 15) >> 4; uiMbNumInFrame = uiMbWidth * uiMbHeight; uiSliceIdx = 0; while (uiSliceIdx < MAX_SLICES_NUM) { param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx] = rand() % uiMbNumInFrame; - uiCountMb += param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx]; - uiActualSliceCount = uiSliceIdx + 1; + uiCountMb += param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx]; + uiActualSliceCount = uiSliceIdx + 1; if (uiCountMb >= uiMbNumInFrame) { break; @@ -575,7 +575,7 @@ void EncodeDecodeTestAPIBase::SliceParamValidationForMode3 (int iSpatialIdx) { unsigned int uiMbHeight = 0; - uiMbHeight = (param_.iPicHeight + 15) >> 4; + uiMbHeight = (param_.iPicHeight + 15) >> 4; //change slice mode to SM_SINGLE_SLICE if (uiMbHeight > MAX_SLICES_NUM) { @@ -819,7 +819,7 @@ void ExtractDidNal (SFrameBSInfo* pBsInfo, int& iSrcLen, std::vector* } else { iPrefix = 0; } - tmpSLostSim.eNalType = (EWelsNalUnitType) ((* (pSrcPtr + iPrefix)) & 0x1f); // eNalUnitType + tmpSLostSim.eNalType = (EWelsNalUnitType) ((* (pSrcPtr + iPrefix)) & 0x1f); // eNalUnitType bLost = (ToRemainDidNal ((pSrcPtr + iPrefix + 2), tmpSLostSim.eNalType, iTarDid)) ? false : true; tmpSLostSim.isLost = bLost; p_SLostSim->push_back (tmpSLostSim); @@ -852,7 +852,7 @@ int SimulateNALLoss (const unsigned char* pSrc, int& iSrcLen, std::vector> 1; - int32_t iPicChromaHeightExt = iPicHeightExt >> 1; - iStride[2] = iStride[1]; - int32_t iLumaSize = iStride[0] * iPicHeightExt; - int32_t iChromaSize = iStride[1] * iPicChromaHeightExt; + iStride[0] = WELS_ALIGN (iPicWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon + int32_t iPicHeightExt = WELS_ALIGN (iPicHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical + iStride[1] = iStride[0] >> 1; + int32_t iPicChromaHeightExt = iPicHeightExt >> 1; + iStride[2] = iStride[1]; + int32_t iLumaSize = iStride[0] * iPicHeightExt; + int32_t iChromaSize = iStride[1] * iPicChromaHeightExt; pPicAnchorBuffer = static_cast (WelsMallocz (iLumaSize + (iChromaSize << 1), "pPicAnchor")); - pPicAnchor[0] = pPicAnchorBuffer + (1 + iStride[0]) * PADDING_LENGTH; - pPicAnchor[1] = pPicAnchorBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1); - pPicAnchor[2] = pPicAnchorBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1); + pPicAnchor[0] = pPicAnchorBuffer + (1 + iStride[0]) * PADDING_LENGTH; + pPicAnchor[1] = pPicAnchorBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1); + pPicAnchor[2] = pPicAnchorBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1); pPicTestBuffer = static_cast (WelsMallocz (iLumaSize + (iChromaSize << 1), "pPicTest")); - pPicTest[0] = pPicTestBuffer + (1 + iStride[0]) * PADDING_LENGTH; - pPicTest[1] = pPicTestBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1); - pPicTest[2] = pPicTestBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1); + pPicTest[0] = pPicTestBuffer + (1 + iStride[0]) * PADDING_LENGTH; + pPicTest[1] = pPicTestBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1); + pPicTest[2] = pPicTestBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1); // Generate Src diff --git a/test/decoder/DecUT_IdctResAddPred.cpp b/test/decoder/DecUT_IdctResAddPred.cpp index 37ce8789..1cedd774 100644 --- a/test/decoder/DecUT_IdctResAddPred.cpp +++ b/test/decoder/DecUT_IdctResAddPred.cpp @@ -7,9 +7,9 @@ using namespace WelsDec; void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { int16_t iSrc[16]; - uint8_t* pDst = pPred; - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* pDst = pPred; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; int32_t i; for (i = 0; i < 4; i++) { @@ -26,16 +26,16 @@ void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { } for (i = 0; i < 4; i++) { - int32_t kT1 = iSrc[i] + iSrc[i + 8]; - int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1); - int32_t kT3 = (32 + kT1 + kT2) >> 6; - int32_t kT4 = (32 + kT1 - kT2) >> 6; + int32_t kT1 = iSrc[i] + iSrc[i + 8]; + int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1); + int32_t kT3 = (32 + kT1 + kT2) >> 6; + int32_t kT4 = (32 + kT1 - kT2) >> 6; pDst[i] = 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]; + 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]); } diff --git a/test/decoder/DecUT_IntraPrediction.cpp b/test/decoder/DecUT_IntraPrediction.cpp index 953f484e..f13f0409 100644 --- a/test/decoder/DecUT_IntraPrediction.cpp +++ b/test/decoder/DecUT_IntraPrediction.cpp @@ -93,25 +93,25 @@ void LumaI##size##x##size##PredDCNone(uint8_t *pPred, const int32_t kiStride) {\ /*down pLeft*/ void WelsI4x4LumaPredDDL_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; /*get pTop*/ - uint8_t* ptop = &pPred[-kiStride]; - const uint8_t kuiT0 = *ptop; - const uint8_t kuiT1 = * (ptop + 1); - const uint8_t kuiT2 = * (ptop + 2); - const uint8_t kuiT3 = * (ptop + 3); - const uint8_t kuiT4 = * (ptop + 4); - const uint8_t kuiT5 = * (ptop + 5); - const uint8_t kuiT6 = * (ptop + 6); - const uint8_t kuiT7 = * (ptop + 7); - const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0 - const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1 - const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2 - const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3 - const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4 - const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5 - const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6 + uint8_t* ptop = &pPred[-kiStride]; + const uint8_t kuiT0 = *ptop; + const uint8_t kuiT1 = * (ptop + 1); + const uint8_t kuiT2 = * (ptop + 2); + const uint8_t kuiT3 = * (ptop + 3); + const uint8_t kuiT4 = * (ptop + 4); + const uint8_t kuiT5 = * (ptop + 5); + const uint8_t kuiT6 = * (ptop + 6); + const uint8_t kuiT7 = * (ptop + 7); + const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0 + const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1 + const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2 + const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3 + const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4 + const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5 + const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6 const uint8_t kuiList[8] = { kuiDDL0, kuiDDL1, kuiDDL2, kuiDDL3, kuiDDL4, kuiDDL5, kuiDDL6, 0 }; ST32 (pPred , LD32 (kuiList)); @@ -122,22 +122,22 @@ void WelsI4x4LumaPredDDL_ref (uint8_t* pPred, const int32_t kiStride) { /*down pLeft*/ void WelsI4x4LumaPredDDLTop_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; /*get pTop*/ - uint8_t* ptop = &pPred[-kiStride]; - const uint8_t kuiT0 = *ptop; - const uint8_t kuiT1 = * (ptop + 1); - const uint8_t kuiT2 = * (ptop + 2); - const uint8_t kuiT3 = * (ptop + 3); - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiT33 = 1 + (kuiT3 << 1); - const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0 - const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1 - const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2 - const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3 + uint8_t* ptop = &pPred[-kiStride]; + const uint8_t kuiT0 = *ptop; + const uint8_t kuiT1 = * (ptop + 1); + const uint8_t kuiT2 = * (ptop + 2); + const uint8_t kuiT3 = * (ptop + 3); + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiT33 = 1 + (kuiT3 << 1); + const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0 + const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1 + const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2 + const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3 const uint8_t kuiList[8] = { kuiDLT0, kuiDLT1, kuiDLT2, kuiDLT3, kuiDLT3, kuiDLT3, kuiDLT3 , kuiDLT3 }; ST32 (pPred, LD32 (kuiList)); @@ -149,36 +149,36 @@ void WelsI4x4LumaPredDDLTop_ref (uint8_t* pPred, const int32_t kiStride) { /*down right*/ void WelsI4x4LumaPredDDR_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - uint8_t* ptopleft = &pPred[- (kiStride + 1)]; - uint8_t* pleft = &pPred[-1]; - const uint8_t kuiLT = *ptopleft; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* ptopleft = &pPred[- (kiStride + 1)]; + uint8_t* pleft = &pPred[-1]; + const uint8_t kuiLT = *ptopleft; /*get pLeft and pTop*/ - const uint8_t kuiL0 = *pleft; - const uint8_t kuiL1 = * (pleft + kiStride); - const uint8_t kuiL2 = * (pleft + kiStride2); - const uint8_t kuiL3 = * (pleft + kiStride3); - const uint8_t kuiT0 = * (ptopleft + 1); - const uint8_t kuiT1 = * (ptopleft + 2); - const uint8_t kuiT2 = * (ptopleft + 3); - const uint8_t kuiT3 = * (ptopleft + 4); - const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; - const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0 - const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1 - const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2 - const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3 - const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4 - const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5 - const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6 - const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 }; + const uint8_t kuiL0 = *pleft; + const uint8_t kuiL1 = * (pleft + kiStride); + const uint8_t kuiL2 = * (pleft + kiStride2); + const uint8_t kuiL3 = * (pleft + kiStride3); + const uint8_t kuiT0 = * (ptopleft + 1); + const uint8_t kuiT1 = * (ptopleft + 2); + const uint8_t kuiT2 = * (ptopleft + 3); + const uint8_t kuiT3 = * (ptopleft + 4); + const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; + const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0 + const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1 + const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2 + const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3 + const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4 + const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5 + const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6 + const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 }; ST32 (pPred , LD32 (kuiList + 3)); ST32 (pPred + kiStride , LD32 (kuiList + 2)); @@ -189,34 +189,34 @@ void WelsI4x4LumaPredDDR_ref (uint8_t* pPred, const int32_t kiStride) { /*vertical pLeft*/ void WelsI4x4LumaPredVL_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - uint8_t* ptopleft = &pPred[- (kiStride + 1)]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* ptopleft = &pPred[- (kiStride + 1)]; /*get pTop*/ - const uint8_t kuiT0 = * (ptopleft + 1); - const uint8_t kuiT1 = * (ptopleft + 2); - const uint8_t kuiT2 = * (ptopleft + 3); - const uint8_t kuiT3 = * (ptopleft + 4); - const uint8_t kuiT4 = * (ptopleft + 5); - const uint8_t kuiT5 = * (ptopleft + 6); - const uint8_t kuiT6 = * (ptopleft + 7); - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiT34 = 1 + kuiT3 + kuiT4; - const uint16_t kuiT45 = 1 + kuiT4 + kuiT5; - const uint16_t kuiT56 = 1 + kuiT5 + kuiT6; - const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0 - const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1 - const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2 - const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3 - const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4 - const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5 - const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6 - const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7 - const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8 - const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9 - const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 }; + const uint8_t kuiT0 = * (ptopleft + 1); + const uint8_t kuiT1 = * (ptopleft + 2); + const uint8_t kuiT2 = * (ptopleft + 3); + const uint8_t kuiT3 = * (ptopleft + 4); + const uint8_t kuiT4 = * (ptopleft + 5); + const uint8_t kuiT5 = * (ptopleft + 6); + const uint8_t kuiT6 = * (ptopleft + 7); + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiT34 = 1 + kuiT3 + kuiT4; + const uint16_t kuiT45 = 1 + kuiT4 + kuiT5; + const uint16_t kuiT56 = 1 + kuiT5 + kuiT6; + const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0 + const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1 + const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2 + const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3 + const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4 + const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5 + const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6 + const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7 + const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8 + const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9 + const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 }; ST32 (pPred, LD32 (kuiList)); ST32 (pPred + kiStride, LD32 (kuiList + 5)); @@ -226,27 +226,27 @@ void WelsI4x4LumaPredVL_ref (uint8_t* pPred, const int32_t kiStride) { /*vertical pLeft*/ void WelsI4x4LumaPredVLTop_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - uint8_t* ptopleft = &pPred[- (kiStride + 1)]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + uint8_t* ptopleft = &pPred[- (kiStride + 1)]; /*get pTop*/ - const uint8_t kuiT0 = * (ptopleft + 1); - const uint8_t kuiT1 = * (ptopleft + 2); - const uint8_t kuiT2 = * (ptopleft + 3); - const uint8_t kuiT3 = * (ptopleft + 4); - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; - const uint16_t kuiT33 = 1 + (kuiT3 << 1); - const uint8_t kuiVL0 = kuiT01 >> 1; - const uint8_t kuiVL1 = kuiT12 >> 1; - const uint8_t kuiVL2 = kuiT23 >> 1; - const uint8_t kuiVL3 = kuiT33 >> 1; - const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2; - const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2; - const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2; - const uint8_t kuiVL7 = kuiVL3; - const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 }; + const uint8_t kuiT0 = * (ptopleft + 1); + const uint8_t kuiT1 = * (ptopleft + 2); + const uint8_t kuiT2 = * (ptopleft + 3); + const uint8_t kuiT3 = * (ptopleft + 4); + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; + const uint16_t kuiT33 = 1 + (kuiT3 << 1); + const uint8_t kuiVL0 = kuiT01 >> 1; + const uint8_t kuiVL1 = kuiT12 >> 1; + const uint8_t kuiVL2 = kuiT23 >> 1; + const uint8_t kuiVL3 = kuiT33 >> 1; + const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2; + const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2; + const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2; + const uint8_t kuiVL7 = kuiVL3; + const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 }; ST32 (pPred , LD32 (kuiList)); ST32 (pPred + kiStride , LD32 (kuiList + 5)); @@ -257,28 +257,28 @@ void WelsI4x4LumaPredVLTop_ref (uint8_t* pPred, const int32_t kiStride) { /*vertical right*/ void WelsI4x4LumaPredVR_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - const uint8_t kuiLT = pPred[-kiStride - 1]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + const uint8_t kuiLT = pPred[-kiStride - 1]; /*get pLeft and pTop*/ - const uint8_t kuiL0 = pPred[ -1]; - const uint8_t kuiL1 = pPred[kiStride - 1]; - const uint8_t kuiL2 = pPred[kiStride2 - 1]; - const uint8_t kuiT0 = pPred[ -kiStride]; - const uint8_t kuiT1 = pPred[1 - kiStride]; - const uint8_t kuiT2 = pPred[2 - kiStride]; - const uint8_t kuiT3 = pPred[3 - kiStride]; - const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0 - const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1 - const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2 - const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3 - const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4 - const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5 - const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6 - const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7 - const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8 - const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9 - const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 }; + const uint8_t kuiL0 = pPred[ - 1]; + const uint8_t kuiL1 = pPred[kiStride - 1]; + const uint8_t kuiL2 = pPred[kiStride2 - 1]; + const uint8_t kuiT0 = pPred[ -kiStride]; + const uint8_t kuiT1 = pPred[1 - kiStride]; + const uint8_t kuiT2 = pPred[2 - kiStride]; + const uint8_t kuiT3 = pPred[3 - kiStride]; + const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0 + const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1 + const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2 + const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3 + const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4 + const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5 + const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6 + const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7 + const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8 + const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9 + const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 }; ST32 (pPred , LD32 (kuiList + 1)); ST32 (pPred + kiStride , LD32 (kuiList + 6)); @@ -288,23 +288,23 @@ void WelsI4x4LumaPredVR_ref (uint8_t* pPred, const int32_t kiStride) { /*horizontal up*/ void WelsI4x4LumaPredHU_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; /*get pLeft*/ - const uint8_t kuiL0 = pPred[ -1]; - const uint8_t kuiL1 = pPred[kiStride - 1]; - const uint8_t kuiL2 = pPred[kiStride2 - 1]; - const uint8_t kuiL3 = pPred[kiStride3 - 1]; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiHU0 = kuiL01 >> 1; - const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; - const uint8_t kuiHU2 = kuiL12 >> 1; - const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; - const uint8_t kuiHU4 = kuiL23 >> 1; - const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; - const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 }; + const uint8_t kuiL0 = pPred[ - 1]; + const uint8_t kuiL1 = pPred[kiStride - 1]; + const uint8_t kuiL2 = pPred[kiStride2 - 1]; + const uint8_t kuiL3 = pPred[kiStride3 - 1]; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiHU0 = kuiL01 >> 1; + const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; + const uint8_t kuiHU2 = kuiL12 >> 1; + const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; + const uint8_t kuiHU4 = kuiL23 >> 1; + const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; + const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 }; ST32 (pPred , LD32 (kuiList)); ST32 (pPred + kiStride , LD32 (kuiList + 2)); @@ -314,35 +314,35 @@ void WelsI4x4LumaPredHU_ref (uint8_t* pPred, const int32_t kiStride) { /*horizontal down*/ void WelsI4x4LumaPredHD_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; - const uint8_t kuiLT = pPred[- (kiStride + 1)]; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; + const uint8_t kuiLT = pPred[- (kiStride + 1)]; /*get pLeft and pTop*/ - const uint8_t kuiL0 = pPred[-1 ]; - const uint8_t kuiL1 = pPred[-1 + kiStride ]; - const uint8_t kuiL2 = pPred[-1 + kiStride2]; - const uint8_t kuiL3 = pPred[-1 + kiStride3]; - const uint8_t kuiT0 = pPred[-kiStride ]; - const uint8_t kuiT1 = pPred[-kiStride + 1 ]; - const uint8_t kuiT2 = pPred[-kiStride + 2 ]; - const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; - const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; - const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; - const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; - const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; - const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; - const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; - const uint8_t kuiHD0 = kuiTL0 >> 1; - const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2; - const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2; - const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2; - const uint8_t kuiHD4 = kuiL01 >> 1; - const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2; - const uint8_t kuiHD6 = kuiL12 >> 1; - const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2; - const uint8_t kuiHD8 = kuiL23 >> 1; - const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2; - const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 }; + const uint8_t kuiL0 = pPred[-1 ]; + const uint8_t kuiL1 = pPred[-1 + kiStride ]; + const uint8_t kuiL2 = pPred[-1 + kiStride2]; + const uint8_t kuiL3 = pPred[-1 + kiStride3]; + const uint8_t kuiT0 = pPred[-kiStride ]; + const uint8_t kuiT1 = pPred[-kiStride + 1 ]; + const uint8_t kuiT2 = pPred[-kiStride + 2 ]; + const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; + const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; + const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; + const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; + const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; + const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; + const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; + const uint8_t kuiHD0 = kuiTL0 >> 1; + const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2; + const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2; + const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2; + const uint8_t kuiHD4 = kuiL01 >> 1; + const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2; + const uint8_t kuiHD6 = kuiL12 >> 1; + const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2; + const uint8_t kuiHD8 = kuiL23 >> 1; + const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2; + const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 }; ST32 (pPred , LD32 (kuiList + 6)); ST32 (pPred + kiStride , LD32 (kuiList + 4)); @@ -433,27 +433,27 @@ void WelsIChromaPredPlane_ref (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDc_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiL1 = kiStride - 1; - const int32_t kiL2 = kiL1 + kiStride; - const int32_t kiL3 = kiL2 + kiStride; - const int32_t kiL4 = kiL3 + kiStride; - const int32_t kiL5 = kiL4 + kiStride; - const int32_t kiL6 = kiL5 + kiStride; - const int32_t kiL7 = kiL6 + kiStride; + const int32_t kiL1 = kiStride - 1; + const int32_t kiL2 = kiL1 + kiStride; + const int32_t kiL3 = kiL2 + kiStride; + const int32_t kiL4 = kiL3 + kiStride; + const int32_t kiL5 = kiL4 + kiStride; + const int32_t kiL6 = kiL5 + kiStride; + const int32_t kiL7 = kiL6 + kiStride; /*caculate the kMean value*/ - const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + + const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ; - const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride]; - const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7]; - const uint8_t kuiM2 = (kuiSum2 + 2) >> 2; - const uint8_t kuiM3 = (kuiSum3 + 2) >> 2; - const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3; - const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; - const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4}; - const uint64_t kuiUP64 = LD64 (kuiMUP); - const uint64_t kuiDN64 = LD64 (kuiMDown); + const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride]; + const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7]; + const uint8_t kuiM2 = (kuiSum2 + 2) >> 2; + const uint8_t kuiM3 = (kuiSum3 + 2) >> 2; + const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3; + const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; + const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4}; + const uint64_t kuiUP64 = LD64 (kuiMUP); + const uint64_t kuiDN64 = LD64 (kuiMDown); - ST64 (pPred , kuiUP64); + ST64 (pPred , kuiUP64); ST64 (pPred + kiL1 + 1, kuiUP64); ST64 (pPred + kiL2 + 1, kuiUP64); ST64 (pPred + kiL3 + 1, kuiUP64); @@ -464,20 +464,20 @@ void WelsIChromaPredDc_ref (uint8_t* pPred, const int32_t kiStride) { } void WelsIChromaPredDcLeft_ref (uint8_t* pPred, const int32_t kiStride) { - const int32_t kiL1 = -1 + kiStride; - const int32_t kiL2 = kiL1 + kiStride; - const int32_t kiL3 = kiL2 + kiStride; - const int32_t kiL4 = kiL3 + kiStride; - const int32_t kiL5 = kiL4 + kiStride; - const int32_t kiL6 = kiL5 + kiStride; - const int32_t kiL7 = kiL6 + kiStride; + const int32_t kiL1 = -1 + kiStride; + const int32_t kiL2 = kiL1 + kiStride; + const int32_t kiL3 = kiL2 + kiStride; + const int32_t kiL4 = kiL3 + kiStride; + const int32_t kiL5 = kiL4 + kiStride; + const int32_t kiL6 = kiL5 + kiStride; + const int32_t kiL7 = kiL6 + kiStride; /*caculate the kMean value*/ const uint8_t kuiMUP = (pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 2) >> 2 ; const uint8_t kuiMDown = (pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7] + 2) >> 2; const uint64_t kuiUP64 = 0x0101010101010101ULL * kuiMUP; const uint64_t kuiDN64 = 0x0101010101010101ULL * kuiMDown; - ST64 (pPred , kuiUP64); + ST64 (pPred , kuiUP64); ST64 (pPred + kiL1 + 1, kuiUP64); ST64 (pPred + kiL2 + 1, kuiUP64); ST64 (pPred + kiL3 + 1, kuiUP64); @@ -488,12 +488,11 @@ void WelsIChromaPredDcLeft_ref (uint8_t* pPred, const int32_t kiStride) { } void WelsIChromaPredDcTop_ref (uint8_t* pPred, const int32_t kiStride) { - int32_t iTmp = (kiStride << 3) - kiStride; + int32_t iTmp = (kiStride << 3) - kiStride; /*caculate the kMean value*/ - const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2; - const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> - 2; - const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; + const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2; + const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> 2; + const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; uint8_t i = 7; diff --git a/test/decoder/DecUT_ParseSyntax.cpp b/test/decoder/DecUT_ParseSyntax.cpp index 3c2b0e51..96b7680a 100644 --- a/test/decoder/DecUT_ParseSyntax.cpp +++ b/test/decoder/DecUT_ParseSyntax.cpp @@ -94,7 +94,7 @@ void UninitDecoder (PWelsDecoderContext pCtx) { WelsEndDecoder (pCtx); if (NULL != pCtx) { free (pCtx); - pCtx = NULL; + pCtx = NULL; } } @@ -135,7 +135,7 @@ class DecoderParseSyntaxTest : public ::testing::Test { unsigned char m_szBuffer[BUF_SIZE]; //for mocking packet int m_iBufLength; //record the valid data in m_szBuffer PWelsDecoderContext m_pCtx; - welsCodecTrace* m_pWelsTrace; + welsCodecTrace* m_pWelsTrace; }; @@ -160,7 +160,7 @@ void DecoderParseSyntaxTest::Init() { // m_pCtx = (PWelsDecoderContext)malloc (sizeof (SWelsDecoderContext)); - m_pWelsTrace = new welsCodecTrace(); + m_pWelsTrace = new welsCodecTrace(); if (m_pWelsTrace != NULL) { m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); } diff --git a/test/encoder/EncUT_EncoderMbAux.cpp b/test/encoder/EncUT_EncoderMbAux.cpp index 4388af70..e9eb897e 100644 --- a/test/encoder/EncUT_EncoderMbAux.cpp +++ b/test/encoder/EncUT_EncoderMbAux.cpp @@ -277,7 +277,7 @@ TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) { #endif #define WELS_ABS_LC(a) ((sign ^ (int32_t)(a)) - sign) #define NEW_QUANT(pDct, ff, mf) (((ff)+ WELS_ABS_LC(pDct))*(mf)) >>16 -#define WELS_NEW_QUANT(pDct,ff,mf) WELS_ABS_LC(NEW_QUANT(pDct, ff, mf)) +#define WELS_NEW_QUANT(pDct,ff,mf) WELS_ABS_LC(NEW_QUANT(pDct, ff, mf)) void WelsQuantFour4x4MaxAnchor (int16_t* pDct, int16_t* ff, int16_t* mf, int16_t* max) { int32_t i, j, k, sign; int16_t max_abs; @@ -421,8 +421,8 @@ void WelsHadamardT4DcAnchor (int16_t* pLumaDc, int16_t* pDct) { int32_t i, iIdx; for (i = 0 ; i < 16 ; i += 4) { iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3); - s[0] = pDct[iIdx ] + pDct[iIdx + 80]; - s[3] = pDct[iIdx ] - pDct[iIdx + 80]; + s[0] = pDct[iIdx ] + pDct[iIdx + 80]; + s[3] = pDct[iIdx ] - pDct[iIdx + 80]; s[1] = pDct[iIdx + 16] + pDct[iIdx + 64]; s[2] = pDct[iIdx + 16] - pDct[iIdx + 64]; p[i ] = s[0] + s[1]; diff --git a/test/encoder/EncUT_GetIntraPredictor.cpp b/test/encoder/EncUT_GetIntraPredictor.cpp index e85c8f62..5b8963a0 100644 --- a/test/encoder/EncUT_GetIntraPredictor.cpp +++ b/test/encoder/EncUT_GetIntraPredictor.cpp @@ -9,7 +9,7 @@ using namespace WelsEnc; TEST (GetIntraPredictorTest, TestGetI4x4LumaPredV) { uint8_t* pPred = new uint8_t[64]; - uint8_t* pRef = new uint8_t[64]; + uint8_t* pRef = new uint8_t[64]; for (int i = 0; i < 64; i++) pRef[i] = rand() % 256; @@ -85,7 +85,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDL) { const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows + ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows uiV[0] = kuiDDL0; uiV[1] = uiV[4] = kuiDDL1; uiV[2] = uiV[5] = uiV[8] = kuiDDL2; @@ -137,8 +137,8 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDLTop) { TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDR) { const int32_t kiStride = rand() % 256 + 16; - const int32_t kiStride2 = kiStride << 1; - const int32_t kiStride3 = kiStride + kiStride2; + const int32_t kiStride2 = kiStride << 1; + const int32_t kiStride3 = kiStride + kiStride2; uint8_t* pPred = new uint8_t[64]; uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1]; @@ -248,7 +248,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVLTop) { pRef++; - uint8_t* pTopLeft = &pRef[-kiStride - 1]; // top-left + uint8_t* pTopLeft = &pRef[-kiStride - 1]; // top-left const uint8_t kuiT0 = * (pTopLeft + 1); const uint8_t kuiT1 = * (pTopLeft + 2); @@ -295,7 +295,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVR) { pRef += kiStride + 1; - const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left + const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left const uint8_t kuiL0 = pRef[-1]; const uint8_t kuiL1 = pRef[kiStride - 1]; const uint8_t kuiL2 = pRef[kiStride2 - 1]; @@ -313,7 +313,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVR) { const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows + ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows uiV[0] = uiV[9] = kuiVR0; uiV[1] = uiV[10] = kuiVR1; uiV[2] = uiV[11] = kuiVR2; @@ -362,7 +362,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHU) { const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiHU4 = kuiL23 >> 1; const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows + ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows uiV[0] = kuiHU0; uiV[1] = kuiHU1; uiV[2] = uiV[4] = kuiHU2; @@ -395,7 +395,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHD) { pRef += kiStride + 1; - const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left + const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left const uint8_t kuiL0 = pRef[-1]; const uint8_t kuiL1 = pRef[kiStride - 1]; const uint8_t kuiL2 = pRef[kiStride2 - 1]; @@ -413,7 +413,7 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHD) { const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1; const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2; - ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows + ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows uiV[0] = uiV[6] = kuiHD0; uiV[1] = uiV[7] = kuiHD1; uiV[2] = kuiHD2; diff --git a/test/encoder/EncUT_MemoryAlloc.cpp b/test/encoder/EncUT_MemoryAlloc.cpp index 81a3761e..10a4de63 100644 --- a/test/encoder/EncUT_MemoryAlloc.cpp +++ b/test/encoder/EncUT_MemoryAlloc.cpp @@ -30,16 +30,16 @@ TEST (MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) { const uint32_t kuiTargetAlignSize[4] = {32, 16, 64, 8}; const uint32_t kuiZero = 0; for (int i = 0; i < 4; i++) { - const uint32_t kuiTestAlignSize = kuiTargetAlignSize[i]; - const uint32_t kuiTestDataSize = abs (rand()); + const uint32_t kuiTestAlignSize = kuiTargetAlignSize[i]; + const uint32_t kuiTestDataSize = abs (rand()); CMemoryAlign cTestMa (kuiTestAlignSize); const uint32_t uiSize = kuiTestDataSize; const char strUnitTestTag[100] = "pUnitTestData"; - const uint32_t kuiUsedCacheLineSize = ((kuiTestAlignSize == 0) + const uint32_t kuiUsedCacheLineSize = ((kuiTestAlignSize == 0) || (kuiTestAlignSize & 0x0F)) ? (16) : (kuiTestAlignSize); - const uint32_t kuiExtraAlignSize = kuiUsedCacheLineSize - 1; - const uint32_t kuiExpectedSize = sizeof (void**) + sizeof (int32_t) + kuiExtraAlignSize + uiSize; + const uint32_t kuiExtraAlignSize = kuiUsedCacheLineSize - 1; + const uint32_t kuiExpectedSize = sizeof (void**) + sizeof (int32_t) + kuiExtraAlignSize + uiSize; uint8_t* pUnitTestData = static_cast (cTestMa.WelsMalloc (uiSize, strUnitTestTag)); if (pUnitTestData != NULL) { ASSERT_TRUE ((((uintptr_t) (pUnitTestData)) & kuiExtraAlignSize) == 0); diff --git a/test/encoder/EncUT_MotionEstimate.cpp b/test/encoder/EncUT_MotionEstimate.cpp index 194587c8..81d334b9 100644 --- a/test/encoder/EncUT_MotionEstimate.cpp +++ b/test/encoder/EncUT_MotionEstimate.cpp @@ -41,7 +41,7 @@ class MotionEstimateTest : public ::testing::Test { m_iWidth = 64;//size of search window m_iHeight = 64;//size of search window m_iMaxSearchBlock = 16; - m_uiMvdTableSize = (1 + (648 << 1)); + m_uiMvdTableSize = (1 + (648 << 1)); pMa = new CMemoryAlign (0); m_pRefData = static_cast @@ -142,9 +142,9 @@ class MotionEstimateRangeTest : public ::testing::Test { m_iMvRange = m_iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE; m_iMvdRange = (m_iUsageType ? EXPANDED_MVD_RANGE : ((m_iNumDependencyLayers == 1) ? CAMERA_MVD_RANGE : CAMERA_HIGHLAYER_MVD_RANGE)); - m_uiMvdInterTableSize = (m_iMvdRange << 2); //intepel*4=qpel - m_uiMvdInterTableStride = 1 + (m_uiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); - m_uiMvdCacheAlignedSize = m_uiMvdInterTableStride * sizeof (uint16_t); + m_uiMvdInterTableSize = (m_iMvdRange << 2); //intepel*4=qpel + m_uiMvdInterTableStride = 1 + (m_uiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); + m_uiMvdCacheAlignedSize = m_uiMvdInterTableStride * sizeof (uint16_t); m_pMa = new CMemoryAlign (16); ASSERT_TRUE (NULL != m_pMa); @@ -338,7 +338,7 @@ void MotionEstimateTest::DoLineTest (PLineFullSearchFunc func, bool vertical) { const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX) << 2); const int32_t iCurMeBlockPixY = sMe.iCurMeBlockPixY; const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY) << 2); - uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here + uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here uint16_t* pMvdCostY = sMe.pMvdCost - iCurMeBlockQpelPixY - sMe.sMvp.iMvY; uint16_t* pMvdCost = vertical ? pMvdCostY : pMvdCostX; int iSize = vertical ? m_iHeight : m_iWidth; @@ -405,7 +405,7 @@ class FeatureMotionEstimateTest : public ::testing::Test { m_iWidth = 64;//size of search window m_iHeight = 64;//size of search window m_iMaxSearchBlock = 8; - m_uiMvdTableSize = (1 + (648 << 1)); + m_uiMvdTableSize = (1 + (648 << 1)); m_pMa = new CMemoryAlign (16); ASSERT_TRUE (NULL != m_pMa); diff --git a/test/encoder/EncUT_ParameterSetStrategy.cpp b/test/encoder/EncUT_ParameterSetStrategy.cpp index 43448f1b..1e2898df 100644 --- a/test/encoder/EncUT_ParameterSetStrategy.cpp +++ b/test/encoder/EncUT_ParameterSetStrategy.cpp @@ -16,9 +16,9 @@ class ParameterSetStrategyTest : public ::testing::Test { m_pSubsetArray = NULL; pMa = new CMemoryAlign (0); - m_pSpsArray = (SWelsSPS*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SWelsSPS), "m_pSpsArray"); + m_pSpsArray = (SWelsSPS*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SWelsSPS), "m_pSpsArray"); ASSERT_TRUE (NULL != m_pSpsArray); - m_pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SSubsetSps), "m_pSubsetArray"); + m_pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SSubsetSps), "m_pSubsetArray"); ASSERT_TRUE (NULL != m_pSubsetArray); m_pSpsArrayPointer = &m_pSpsArray[0]; @@ -33,11 +33,11 @@ class ParameterSetStrategyTest : public ::testing::Test { void GenerateParam (SWelsSvcCodingParam* pParam); public: CMemoryAlign* pMa; - SWelsSPS* m_pSpsArray; - SSubsetSps* m_pSubsetArray; + SWelsSPS* m_pSpsArray; + SSubsetSps* m_pSubsetArray; - SWelsSPS* m_pSpsArrayPointer; - SSubsetSps* m_pSubsetArrayPointer; + SWelsSPS* m_pSpsArrayPointer; + SSubsetSps* m_pSubsetArrayPointer; }; @@ -70,7 +70,7 @@ TEST_F (ParameterSetStrategyTest, FindExistingSps) { int iCurSpsInUse = 1; m_pSpsArrayPointer = &m_pSpsArray[iCurSpsId]; - pDlayerParam = & (sParam1.sSpatialLayers[iDlayerIndex]); + pDlayerParam = & (sParam1.sSpatialLayers[iDlayerIndex]); iRet = WelsInitSps (m_pSpsArrayPointer, pDlayerParam, &sParam1.sDependencyLayers[iDlayerIndex], sParam1.uiIntraPeriod, sParam1.iMaxNumRefFrame, iCurSpsId, sParam1.bEnableFrameCroppingFlag, sParam1.iRCMode != RC_OFF_MODE, iDlayerCount, false); @@ -90,7 +90,7 @@ TEST_F (ParameterSetStrategyTest, FindExistingSps) { // add new sps iCurSpsId = 1; m_pSpsArrayPointer = &m_pSpsArray[iCurSpsId]; - pDlayerParam = & (sParam2.sSpatialLayers[iDlayerIndex]); + pDlayerParam = & (sParam2.sSpatialLayers[iDlayerIndex]); iRet = WelsInitSps (m_pSpsArrayPointer, pDlayerParam, &sParam2.sDependencyLayers[iDlayerIndex], sParam2.uiIntraPeriod, sParam2.iMaxNumRefFrame, iCurSpsId, sParam2.bEnableFrameCroppingFlag, sParam2.iRCMode != RC_OFF_MODE, iDlayerCount, false); diff --git a/test/encoder/EncUT_Sample.cpp b/test/encoder/EncUT_Sample.cpp index a55498a8..492358c7 100644 --- a/test/encoder/EncUT_Sample.cpp +++ b/test/encoder/EncUT_Sample.cpp @@ -42,7 +42,7 @@ TEST (IntraSadSatdFuncTest, func) { \ const int32_t iLineSizeEnc = 32; \ int32_t tmpa, tmpb; \ int32_t iBestMode_c, iBestMode_a, iLambda = 50; \ - int32_t lambda[2] = {iLambda << 2, iLambda}; \ + int32_t lambda[2] = {iLambda << 2, iLambda}; \ int32_t iPredMode = rand() % 3; \ if (ASM) {\ int32_t iCpuCores = 0; \ diff --git a/test/processing/ProcessUT_DownSample.cpp b/test/processing/ProcessUT_DownSample.cpp index 385e79e3..d29b6fbc 100644 --- a/test/processing/ProcessUT_DownSample.cpp +++ b/test/processing/ProcessUT_DownSample.cpp @@ -11,11 +11,11 @@ using namespace WelsVP; void DyadicBilinearDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) { - uint8_t* pDstLine = pDst; - uint8_t* pSrcLine = pSrc; - const int32_t kiSrcStridex2 = kiSrcStride << 1; - const int32_t kiDstWidth = kiSrcWidth >> 1; - const int32_t kiDstHeight = kiSrcHeight >> 1; + uint8_t* pDstLine = pDst; + uint8_t* pSrcLine = pSrc; + const int32_t kiSrcStridex2 = kiSrcStride << 1; + const int32_t kiDstWidth = kiSrcWidth >> 1; + const int32_t kiDstHeight = kiSrcHeight >> 1; for (int32_t j = 0; j < kiDstHeight; j ++) { for (int32_t i = 0; i < kiDstWidth; i ++) { @@ -25,8 +25,8 @@ void DyadicBilinearDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1); } - pDstLine += kiDstStride; - pSrcLine += kiSrcStridex2; + pDstLine += kiDstStride; + pSrcLine += kiSrcStridex2; } } @@ -72,7 +72,7 @@ void GeneralBilinearFastDownsampler_ref (uint8_t* pDst, const int32_t kiDstStrid x += 1; x >>= 1; //x = (((__int64)(SCALE_BIG - 1 - iFu))*(SCALE_BIG - 1 - fv)*a + ((__int64)iFu)*(SCALE_BIG - 1 -fv)*b + ((__int64)(SCALE_BIG - 1 -iFu))*fv*c + - // ((__int64)iFu)*fv*d + (1 << (2*SCALE_BIT_BIG-1)) ) >> (2*SCALE_BIT_BIG); + // ((__int64)iFu)*fv*d + (1 << (2*SCALE_BIT_BIG-1)) ) >> (2*SCALE_BIT_BIG); x = WELS_CLAMP (x, 0, 255); *pByDst++ = (uint8_t)x;