Merge pull request #1983 from mstorsjo/remove-tabs

Remove tabs from the source code
This commit is contained in:
sijchen 2015-06-10 15:51:09 +08:00
commit 6ff4ef3b38
141 changed files with 4869 additions and 4885 deletions

View File

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

View File

@ -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 <stdlib.h>
#include <unistd.h>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
uiCPU |= WELS_CPU_CMOV;
}
if ((!strcmp ((const char*)chVendorName, CPU_Vendor_INTEL)) ||
(!strcmp ((const char*)chVendorName, CPU_Vendor_AMD))) { // confirmed_safe_unsafe_usage
(!strcmp ((const char*)chVendorName, CPU_Vendor_AMD))) { // confirmed_safe_unsafe_usage
if (uiFeatureD & 0x10000000) {
/* Multi-Threading checking: contains of multiple logic processors */
uiCPU |= WELS_CPU_HTT;
@ -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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@
#include <stdarg.h>
#include <string.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 "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) {

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <morais at dee.ufcg.edu.br> */

View File

@ -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
/*!
*************************************************************************************

View File

@ -30,7 +30,7 @@
*
*/
//bit_stream.h - bit-stream reading and / writing auxiliary data
//bit_stream.h - bit-stream reading and / writing auxiliary data
#ifndef WELS_BIT_STREAM_H__
#define WELS_BIT_STREAM_H__

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<EWelsNalUnitType> (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<EWelsNalUnitType> (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 <EWelsSliceType> (uiSliceType);
pSliceHead->eSliceType = static_cast <EWelsSliceType> (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<double> (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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<uint8_t*> (WelsMallocz (iLumaSize /* luma */
pPic->pBuffer[0] = static_cast<uint8_t*> (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;

View File

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

View File

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

View File

@ -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 <time.h>
#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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 (&param, 0, sizeof (param));
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used
param.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;

View File

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

View File

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

View File

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

View File

@ -53,134 +53,134 @@ namespace WelsEnc {
*/
typedef struct TagRefPicListReorderSyntax {
struct {
uint32_t uiAbsDiffPicNumMinus1; //uiAbsDiffPicNumMinus1 SHOULD be in the range of [4, (1<<pSps->uiLog2MaxFrameNum)-1], {p104, JVT-X201wcm1}
uint32_t uiAbsDiffPicNumMinus1; //uiAbsDiffPicNumMinus1 SHOULD be in the range of [4, (1<<pSps->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;
}

View File

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

View File

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

View File

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

View File

@ -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;
/*!

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

@ -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<SPicture*> (pMa->WelsMallocz (sizeof (SPicture), "pPic"));
pPic = static_cast<SPicture*> (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<SMVUnitXY*> (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");

View File

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

View File

@ -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<int64_t> (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<int64_t> (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<SVAAFrameInfo*> (pEncCtx->pVaa);
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (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<int32_t> (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);

View File

@ -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<SVAAFrameInfoExt*> (pCtx->pVaa);
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (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<SVAAFrameInfoExt*> (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) {

View File

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

View File

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

View File

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

View File

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

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