Merge pull request #21 from ethanhugg/astyle
Pretty printed the C++ code with astyle
This commit is contained in:
commit
fd420e071b
9
build/astyle.cfg
Normal file
9
build/astyle.cfg
Normal file
@ -0,0 +1,9 @@
|
||||
--style=google
|
||||
--indent=spaces=2
|
||||
--max-code-length=120
|
||||
--pad-oper
|
||||
--align-pointer=type
|
||||
--align-reference=type
|
||||
--unpad-paren
|
||||
--pad-first-paren-out
|
||||
--lineend=linux
|
@ -93,8 +93,7 @@ typedef sem_t WELS_EVENT;
|
||||
typedef int32_t WELS_THREAD_ERROR_CODE;
|
||||
typedef int32_t WELS_THREAD_ATTR;
|
||||
|
||||
typedef struct _WelsLogicalProcessorInfo
|
||||
{
|
||||
typedef struct _WelsLogicalProcessorInfo {
|
||||
int32_t ProcessorCount;
|
||||
} WelsLogicalProcessInfo;
|
||||
|
||||
@ -121,10 +120,12 @@ WELS_THREAD_ERROR_CODE WelsEventReset( WELS_EVENT * event );
|
||||
WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event);
|
||||
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds);
|
||||
#ifdef WIN32
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking( uint32_t nCount, WELS_EVENT *event_list, uint32_t dwMilliseconds );
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT* event_list,
|
||||
uint32_t dwMilliseconds);
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT* event_list);
|
||||
#else
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking( uint32_t nCount, WELS_EVENT **event_list, uint32_t dwMilliseconds );
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT** event_list,
|
||||
uint32_t dwMilliseconds);
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT** event_list);
|
||||
#endif//WIN32
|
||||
|
||||
|
@ -44,41 +44,35 @@
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
void WelsSleep( uint32_t dwMilliseconds )
|
||||
{
|
||||
void WelsSleep (uint32_t dwMilliseconds) {
|
||||
Sleep (dwMilliseconds);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexInit( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
|
||||
InitializeCriticalSection (mutex);
|
||||
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexLock( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
|
||||
EnterCriticalSection (mutex);
|
||||
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexUnlock( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
|
||||
LeaveCriticalSection (mutex);
|
||||
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexDestroy( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
|
||||
DeleteCriticalSection (mutex);
|
||||
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventInit( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventInit (WELS_EVENT* event) {
|
||||
WELS_EVENT h = CreateEvent (NULL, FALSE, FALSE, NULL);
|
||||
|
||||
if (h == NULL) {
|
||||
@ -88,45 +82,38 @@ WELS_THREAD_ERROR_CODE WelsEventInit( WELS_EVENT * event )
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventSignal( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event) {
|
||||
if (SetEvent (*event)) {
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
return WELS_THREAD_ERROR_GENERIAL;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventReset( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventReset (WELS_EVENT* event) {
|
||||
if (ResetEvent (*event))
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
return WELS_THREAD_ERROR_GENERIAL;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventWait( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
|
||||
return WaitForSingleObject (*event, INFINITE);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut( WELS_EVENT * event, uint32_t dwMilliseconds )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {
|
||||
return WaitForSingleObject (*event, dwMilliseconds);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount,
|
||||
WELS_EVENT* event_list,
|
||||
uint32_t dwMilliseconds )
|
||||
{
|
||||
uint32_t dwMilliseconds) {
|
||||
return WaitForMultipleObjects (nCount, event_list, FALSE, dwMilliseconds);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking( uint32_t nCount, WELS_EVENT *event_list )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT* event_list) {
|
||||
return WaitForMultipleObjects (nCount, event_list, TRUE, (uint32_t) - 1);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventDestroy( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventDestroy (WELS_EVENT* event) {
|
||||
CloseHandle (*event);
|
||||
|
||||
*event = NULL;
|
||||
@ -135,8 +122,7 @@ WELS_THREAD_ERROR_CODE WelsEventDestroy( WELS_EVENT * event )
|
||||
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
|
||||
void * arg, WELS_THREAD_ATTR attr)
|
||||
{
|
||||
void* arg, WELS_THREAD_ATTR attr) {
|
||||
WELS_THREAD_HANDLE h = CreateThread (NULL, 0, routine, arg, 0, NULL);
|
||||
|
||||
if (h == NULL) {
|
||||
@ -147,42 +133,35 @@ WELS_THREAD_ERROR_CODE WelsThreadCreate( WELS_THREAD_HANDLE * thread, LPWELS
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsSetThreadCancelable()
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsSetThreadCancelable() {
|
||||
// nil implementation for WIN32
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadJoin( WELS_THREAD_HANDLE thread )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread) {
|
||||
WaitForSingleObject (thread, INFINITE);
|
||||
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadCancel( WELS_THREAD_HANDLE thread )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsThreadCancel (WELS_THREAD_HANDLE thread) {
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadDestroy( WELS_THREAD_HANDLE *thread )
|
||||
{
|
||||
if ( thread != NULL )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsThreadDestroy (WELS_THREAD_HANDLE* thread) {
|
||||
if (thread != NULL) {
|
||||
CloseHandle (*thread);
|
||||
*thread = NULL;
|
||||
}
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_HANDLE WelsThreadSelf()
|
||||
{
|
||||
WELS_THREAD_HANDLE WelsThreadSelf() {
|
||||
return GetCurrentThread();
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo(WelsLogicalProcessInfo * pInfo)
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* pInfo) {
|
||||
SYSTEM_INFO si;
|
||||
|
||||
GetSystemInfo (&si);
|
||||
@ -199,8 +178,7 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo(WelsLogicalProcessInfo * p
|
||||
//#include <Gestalt.h>
|
||||
#endif//MACOS
|
||||
|
||||
static int32_t SystemCall(const str_t * pCmd, str_t * pRes, int32_t iSize)
|
||||
{
|
||||
static int32_t SystemCall (const str_t* pCmd, str_t* pRes, int32_t iSize) {
|
||||
int32_t fd[2];
|
||||
int32_t iPid;
|
||||
int32_t iCount;
|
||||
@ -241,14 +219,12 @@ static int32_t SystemCall(const str_t * pCmd, str_t * pRes, int32_t iSize)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WelsSleep( uint32_t dwMilliseconds )
|
||||
{
|
||||
void WelsSleep (uint32_t dwMilliseconds) {
|
||||
usleep (dwMilliseconds * 1000); // microseconds
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
|
||||
void * arg, WELS_THREAD_ATTR attr)
|
||||
{
|
||||
void* arg, WELS_THREAD_ATTR attr) {
|
||||
WELS_THREAD_ERROR_CODE err = 0;
|
||||
|
||||
pthread_attr_t at;
|
||||
@ -270,68 +246,56 @@ WELS_THREAD_ERROR_CODE WelsThreadCreate( WELS_THREAD_HANDLE * thread, LPWELS
|
||||
// return pthread_create(thread, NULL, routine, arg);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsSetThreadCancelable()
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsSetThreadCancelable() {
|
||||
WELS_THREAD_ERROR_CODE err = pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
|
||||
if (0 == err)
|
||||
err = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL);
|
||||
return err;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadJoin( WELS_THREAD_HANDLE thread )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread) {
|
||||
return pthread_join (thread, NULL);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadCancel( WELS_THREAD_HANDLE thread )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsThreadCancel (WELS_THREAD_HANDLE thread) {
|
||||
return pthread_cancel (thread);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsThreadDestroy( WELS_THREAD_HANDLE *thread )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsThreadDestroy (WELS_THREAD_HANDLE* thread) {
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
WELS_THREAD_HANDLE WelsThreadSelf()
|
||||
{
|
||||
WELS_THREAD_HANDLE WelsThreadSelf() {
|
||||
return pthread_self();
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexInit( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
|
||||
return pthread_mutex_init (mutex, NULL);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexLock( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
|
||||
return pthread_mutex_lock (mutex);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexUnlock( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
|
||||
return pthread_mutex_unlock (mutex);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMutexDestroy( WELS_MUTEX * mutex )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
|
||||
return pthread_mutex_destroy (mutex);
|
||||
}
|
||||
|
||||
// unnamed semaphores can not work well for posix threading models under not root users
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventInit( WELS_EVENT *event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventInit (WELS_EVENT* event) {
|
||||
return sem_init (event, 0, 0);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventDestroy( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventDestroy (WELS_EVENT* event) {
|
||||
return sem_destroy (event); // match with sem_init
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventOpen( WELS_EVENT **p_event, str_t *event_name )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT** p_event, str_t* event_name) {
|
||||
if (p_event == NULL || event_name == NULL)
|
||||
return WELS_THREAD_ERROR_GENERIAL;
|
||||
*p_event = sem_open (event_name, O_CREAT, (S_IRUSR | S_IWUSR)/*0600*/, 0);
|
||||
@ -343,16 +307,14 @@ WELS_THREAD_ERROR_CODE WelsEventOpen( WELS_EVENT **p_event, str_t *event_name
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
}
|
||||
WELS_THREAD_ERROR_CODE WelsEventClose( WELS_EVENT *event, str_t *event_name )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, str_t* event_name) {
|
||||
WELS_THREAD_ERROR_CODE err = sem_close (event); // match with sem_open
|
||||
if (event_name)
|
||||
sem_unlink (event_name);
|
||||
return err;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventSignal( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event) {
|
||||
WELS_THREAD_ERROR_CODE err = 0;
|
||||
// int32_t val = 0;
|
||||
// sem_getvalue(event, &val);
|
||||
@ -362,26 +324,20 @@ WELS_THREAD_ERROR_CODE WelsEventSignal( WELS_EVENT * event )
|
||||
// fprintf( stderr, "after signal it, val= %d..\n",val );
|
||||
return err;
|
||||
}
|
||||
WELS_THREAD_ERROR_CODE WelsEventReset( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventReset (WELS_EVENT* event) {
|
||||
// FIXME for posix event reset, seems not be supported for pthread??
|
||||
sem_close (event);
|
||||
return sem_init (event, 0, 0);
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventWait( WELS_EVENT * event )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
|
||||
return sem_wait (event); // blocking until signaled
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut( WELS_EVENT * event, uint32_t dwMilliseconds )
|
||||
{
|
||||
if ( dwMilliseconds != (uint32_t)-1 )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {
|
||||
if (dwMilliseconds != (uint32_t) - 1) {
|
||||
return sem_wait (event);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if defined(MACOS)
|
||||
int32_t err = 0;
|
||||
int32_t wait_count = 0;
|
||||
@ -411,8 +367,7 @@ WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut( WELS_EVENT * event, uint32_t
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount,
|
||||
WELS_EVENT** event_list,
|
||||
uint32_t dwMilliseconds )
|
||||
{
|
||||
uint32_t dwMilliseconds) {
|
||||
// bWaitAll = FALSE && blocking
|
||||
uint32_t nIdx = 0;
|
||||
const uint32_t kuiAccessTime = 2; // 2 us once
|
||||
@ -421,11 +376,9 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking( uint32_t nCount,
|
||||
if (nCount == 0)
|
||||
return WELS_THREAD_ERROR_WAIT_FAILED;
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
nIdx = 0; // access each event by order
|
||||
while ( nIdx < nCount )
|
||||
{
|
||||
while (nIdx < nCount) {
|
||||
int32_t err = 0;
|
||||
//#if defined(MACOS) // clock_gettime(CLOCK_REALTIME) & sem_timedwait not supported on mac, so have below impl
|
||||
int32_t wait_count = 0;
|
||||
@ -485,8 +438,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking( uint32_t nCount,
|
||||
return WELS_THREAD_ERROR_WAIT_FAILED;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking( uint32_t nCount, WELS_EVENT **event_list )
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, WELS_EVENT** event_list) {
|
||||
// bWaitAll = TRUE && blocking
|
||||
uint32_t nIdx = 0;
|
||||
// const uint32_t kuiAccessTime = (uint32_t)-1;// 1 ms once
|
||||
@ -496,29 +448,24 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking( uint32_t nCount, WE
|
||||
if (nCount == 0 || nCount > (sizeof (uint32_t) << 3))
|
||||
return WELS_THREAD_ERROR_WAIT_FAILED;
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
nIdx = 0; // access each event by order
|
||||
while (nIdx < nCount)
|
||||
{
|
||||
while (nIdx < nCount) {
|
||||
const uint32_t kuiBitwiseFlag = (1 << nIdx);
|
||||
|
||||
if ( (uiSignalFlag & kuiBitwiseFlag) != kuiBitwiseFlag ) // non-blocking mode
|
||||
{
|
||||
if ((uiSignalFlag & kuiBitwiseFlag) != kuiBitwiseFlag) { // non-blocking mode
|
||||
int32_t err = 0;
|
||||
// fprintf( stderr, "sem_wait(): start to wait event %d..\n", nIdx );
|
||||
err = sem_wait (event_list[nIdx]);
|
||||
// fprintf( stderr, "sem_wait(): wait event %d result %d errno %d..\n", nIdx, err, errno );
|
||||
if ( WELS_THREAD_ERROR_OK == err )
|
||||
{
|
||||
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);
|
||||
|
||||
uiSignalFlag |= kuiBitwiseFlag;
|
||||
++ uiCountSignals;
|
||||
if ( uiCountSignals >= nCount )
|
||||
{
|
||||
if (uiCountSignals >= nCount) {
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
}
|
||||
@ -531,8 +478,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking( uint32_t nCount, WE
|
||||
return WELS_THREAD_ERROR_WAIT_FAILED;
|
||||
}
|
||||
|
||||
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo(WelsLogicalProcessInfo * pInfo)
|
||||
{
|
||||
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* pInfo) {
|
||||
#ifdef LINUX
|
||||
|
||||
#define CMD_RES_SIZE 2048
|
||||
|
@ -36,8 +36,7 @@
|
||||
#include "codec_app_def.h"
|
||||
#include "codec_def.h"
|
||||
|
||||
class ISVCEncoder
|
||||
{
|
||||
class ISVCEncoder {
|
||||
public:
|
||||
/*
|
||||
* return: CM_RETURN: 0 - success; otherwise - failed;
|
||||
@ -73,8 +72,7 @@ public:
|
||||
virtual int GetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
|
||||
};
|
||||
|
||||
class ISVCDecoder
|
||||
{
|
||||
class ISVCDecoder {
|
||||
public:
|
||||
virtual long Initialize (void* pParam, const INIT_TYPE iInitType) = 0;
|
||||
virtual long Uninitialize() = 0;
|
||||
|
@ -50,8 +50,7 @@
|
||||
#define SAVED_NALUNIT_NUM_TMP ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) //SPS/PPS + SEI/SSEI + PADDING_NAL
|
||||
#define MAX_SLICES_NUM_TMP ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM_TMP ) / 3 )
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
/* Errors derived from bitstream parsing */
|
||||
dsErrorFree = 0x00, /* Bitstream error-free */
|
||||
dsFramePending = 0x01, /* Need more throughput to generate a frame output, */
|
||||
@ -70,8 +69,7 @@ typedef enum
|
||||
} DECODING_STATE;
|
||||
|
||||
/* Option types introduced in SVC encoder application */
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
ENCODER_OPTION_DATAFORMAT = 0,
|
||||
ENCODER_OPTION_IDR_INTERVAL,
|
||||
ENCODER_OPTION_SVC_ENCODE_PARAM,
|
||||
@ -94,8 +92,7 @@ typedef enum
|
||||
} ENCODER_OPTION;
|
||||
|
||||
/* Option types introduced in SVC decoder application */
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
DECODER_OPTION_DATAFORMAT = 0, /* Set color space of decoding output frame */
|
||||
DECODER_OPTION_TRUNCATED_MODE, /* Used in decoding bitstream of non integrated frame, only truncated working mode is supported by tune, so skip it */
|
||||
DECODER_OPTION_END_OF_STREAM, /* Indicate bitstream of the final frame to be decoded */
|
||||
@ -110,14 +107,12 @@ typedef enum
|
||||
DECODER_OPTION_DEVICE_INFO,
|
||||
|
||||
} DECODER_OPTION;
|
||||
typedef enum //feedback that whether or not have VCL NAL in current AU
|
||||
{
|
||||
typedef enum { //feedback that whether or not have VCL NAL in current AU
|
||||
FEEDBACK_NON_VCL_NAL = 0,
|
||||
FEEDBACK_VCL_NAL,
|
||||
FEEDBACK_UNKNOWN_NAL
|
||||
} FEEDBACK_VCL_NAL_IN_AU;
|
||||
typedef enum //feedback the iTemporalId in current AU if have VCL NAL
|
||||
{
|
||||
typedef enum { //feedback the iTemporalId in current AU if have VCL NAL
|
||||
FEEDBACK_TEMPORAL_ID_0 = 0,
|
||||
FEEDBACK_TEMPORAL_ID_1,
|
||||
FEEDBACK_TEMPORAL_ID_2,
|
||||
@ -127,29 +122,25 @@ typedef enum //feedback the iTemporalId in current AU if have VCL NAL
|
||||
} FEEDBACK_TEMPORAL_ID;
|
||||
|
||||
/* Type of layer being encoded */
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
NON_VIDEO_CODING_LAYER = 0,
|
||||
VIDEO_CODING_LAYER = 1
|
||||
} LAYER_TYPE;
|
||||
|
||||
/* SVC Encoder/Decoder Initializing Parameter Types */
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
INIT_TYPE_PARAMETER_BASED = 0, // For SVC DEMO Application
|
||||
INIT_TYPE_CONFIG_BASED, // For SVC CONSOLE Application
|
||||
} INIT_TYPE;
|
||||
|
||||
//enumerate the type of video bitstream which is provided to decoder
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
VIDEO_BITSTREAM_AVC = 0,
|
||||
VIDEO_BITSTREAM_SVC = 1,
|
||||
VIDEO_BITSTREAM_DEFAULT = VIDEO_BITSTREAM_SVC,
|
||||
} VIDEO_BITSTREAM_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
NO_RECOVERY_REQUSET = 0,
|
||||
LTR_RECOVERY_REQUEST = 1,
|
||||
IDR_RECOVERY_REQUEST = 2,
|
||||
@ -158,24 +149,21 @@ typedef enum
|
||||
LTR_MARKING_FAILED = 5,
|
||||
} KEY_FRAME_REQUEST_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
unsigned int uiFeedbackType; //IDR request or LTR recovery request
|
||||
unsigned int uiIDRPicId; // distinguish request from different IDR
|
||||
int iLastCorrectFrameNum;
|
||||
int iCurrentFrameNum; //specify current decoder frame_num.
|
||||
} SLTRRecoverRequest;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
unsigned int uiFeedbackType; //mark failed or successful
|
||||
unsigned int uiIDRPicId; // distinguish request from different IDR
|
||||
int iLTRFrameNum; //specify current decoder frame_num
|
||||
} SLTRMarkingFeedback;
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
//# 0 SM_SINGLE_SLICE | SliceNum==1
|
||||
//# 1 SM_FIXEDSLCNUM_SLICE | according to SliceNum | Enabled dynamic slicing for multi-thread
|
||||
@ -184,7 +172,8 @@ typedef struct
|
||||
//# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
unsigned int uiSliceMode; //by default, uiSliceMode will be 0
|
||||
struct {
|
||||
unsigned int uiSliceMbNum[MAX_SLICES_NUM_TMP]; //here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
|
||||
unsigned int
|
||||
uiSliceMbNum[MAX_SLICES_NUM_TMP]; //here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
|
||||
unsigned int uiSliceNum;
|
||||
unsigned int uiSliceSizeConstraint;
|
||||
} sSliceArgument;//not all the elements in this argument will be used, how it will be used depends on uiSliceMode; see below
|
||||
|
@ -37,8 +37,7 @@
|
||||
#pragma once
|
||||
#endif//WIN32
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
/*rgb color formats*/
|
||||
videoFormatRGB = 1,
|
||||
videoFormatRGBA = 2,
|
||||
@ -62,8 +61,7 @@ typedef enum
|
||||
videoFormatVFlip = 0x80000000
|
||||
} EVideoFormatType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
videoFrameTypeInvalid, /* Encoder not ready or parameters are invalidate */
|
||||
videoFrameTypeIDR, /* This type is only available for H264 if this frame is key frame, then return this type */
|
||||
videoFrameTypeI, /* I frame type */
|
||||
@ -72,8 +70,7 @@ typedef enum
|
||||
videoFrameTypeIPMixed, /* Frame type introduced I and P slices are mixing */
|
||||
} EVideoFrameType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
cmResultSuccess,
|
||||
cmInitParaError, /*Parameters are invalid */
|
||||
cmMachPerfIsBad, /*The performance of machine is not enough to support
|
||||
@ -86,8 +83,7 @@ typedef enum
|
||||
|
||||
|
||||
/* nal unit type */
|
||||
enum ENalUnitType
|
||||
{
|
||||
enum ENalUnitType {
|
||||
NAL_UNKNOWN = 0,
|
||||
NAL_SLICE = 1,
|
||||
NAL_SLICE_DPA = 2,
|
||||
@ -100,8 +96,7 @@ enum ENalUnitType
|
||||
/* ref_idc == 0 for 6,9,10,11,12 */
|
||||
};
|
||||
/* NRI: eNalRefIdc */
|
||||
enum ENalPriority
|
||||
{
|
||||
enum ENalPriority {
|
||||
NAL_PRIORITY_DISPOSABLE = 0,
|
||||
NAL_PRIORITY_LOW = 1,
|
||||
NAL_PRIORITY_HIGH = 2,
|
||||
@ -134,8 +129,7 @@ enum{
|
||||
};
|
||||
|
||||
/* information of coded Slice(=NAL)(s) */
|
||||
typedef struct SliceInformation
|
||||
{
|
||||
typedef struct SliceInformation {
|
||||
unsigned char* pBufferOfSlices; // base buffer of coded slice(s)
|
||||
int iCodedSliceCount; // number of coded slices
|
||||
unsigned int* pLengthOfSlices; // array of slices length accordingly by number of slice
|
||||
@ -145,7 +139,8 @@ typedef struct SliceInformation
|
||||
char iFrameIndex; // index of frame[-1, .., idr_interval-1]
|
||||
unsigned char uiNalRefIdc; // NRI, priority level of slice(NAL)
|
||||
unsigned char uiNalType; // NAL type
|
||||
unsigned char uiContainingFinalNal; // whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
|
||||
unsigned char
|
||||
uiContainingFinalNal; // whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
|
||||
} SliceInfo, *PSliceInfo;
|
||||
|
||||
|
||||
@ -172,8 +167,7 @@ typedef struct {
|
||||
} SRateThresholds, *PRateThresholds;
|
||||
|
||||
/*new interface*/
|
||||
typedef struct WelsDeviceInfo
|
||||
{
|
||||
typedef struct WelsDeviceInfo {
|
||||
int bSupport; /* a logic flag provided by decoder which indicates whether GPU decoder can work based on the following device info. */
|
||||
char Vendor[128]; // vendor name
|
||||
char Device[128]; // device name
|
||||
@ -181,8 +175,7 @@ typedef struct WelsDeviceInfo
|
||||
char DriverDate[128]; // driver release date
|
||||
} Device_Info;
|
||||
|
||||
typedef enum TagBufferProperty
|
||||
{
|
||||
typedef enum TagBufferProperty {
|
||||
BUFFER_HOST = 0, // host memory
|
||||
BUFFER_DEVICE = 1, // device memory including surface and shared handle
|
||||
// for DXVA: shared handle
|
||||
@ -192,24 +185,21 @@ typedef enum TagBufferProperty
|
||||
//SHARED_HANDLE // shared handle
|
||||
} EBufferProperty;
|
||||
|
||||
typedef enum TagDecodeMode
|
||||
{
|
||||
typedef enum TagDecodeMode {
|
||||
AUTO_MODE = 0, // decided by decoder itself, dynamic mode switch, delayed switch
|
||||
SW_MODE = 1, // decoded by CPU, instant switch
|
||||
GPU_MODE = 2, // decoded by GPU, instant switch
|
||||
SWITCH_MODE = 3 // switch to the other mode, forced mode switch, delayed switch
|
||||
} EDecodeMode;
|
||||
|
||||
typedef struct TagSysMemBuffer
|
||||
{
|
||||
typedef struct TagSysMemBuffer {
|
||||
int iWidth; //width of decoded pic for display
|
||||
int iHeight; //height of decoded pic for display
|
||||
int iFormat; // type is "EVideoFormatType"
|
||||
int iStride[2]; //stride of 2 component
|
||||
} SSysMEMBuffer;
|
||||
|
||||
typedef struct TagVideoMemBuffer
|
||||
{
|
||||
typedef struct TagVideoMemBuffer {
|
||||
int iSurfaceWidth; // used for surface create
|
||||
int iSurfaceHeight;
|
||||
int D3Dformat; //type is "D3DFORMAT"
|
||||
@ -220,8 +210,7 @@ typedef struct TagVideoMemBuffer
|
||||
int iRightBottomY;
|
||||
} SVideoMemBuffer;
|
||||
|
||||
typedef struct TagBufferInfo
|
||||
{
|
||||
typedef struct TagBufferInfo {
|
||||
EBufferProperty eBufferProperty; //0: host memory; 1: device memory;
|
||||
int iBufferStatus; // 0: one frame data is not ready; 1: one frame data is ready
|
||||
EDecodeMode eWorkMode; //indicate what the real working mode in decoder
|
||||
|
@ -57,8 +57,7 @@
|
||||
#include <d3d9.h>
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CD3D9Utils
|
||||
{
|
||||
class CD3D9Utils {
|
||||
public:
|
||||
CD3D9Utils();
|
||||
~CD3D9Utils();
|
||||
@ -86,8 +85,7 @@ private:
|
||||
LPDIRECT3DSURFACE9 m_lpD3D9RawSurfaceShare;
|
||||
};
|
||||
|
||||
class CD3D9ExUtils
|
||||
{
|
||||
class CD3D9ExUtils {
|
||||
public:
|
||||
CD3D9ExUtils();
|
||||
~CD3D9ExUtils();
|
||||
@ -116,15 +114,13 @@ private:
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
OS_UNSUPPORTED = 0,
|
||||
OS_XP,
|
||||
OS_VISTA_UPPER
|
||||
};
|
||||
|
||||
class CUtils
|
||||
{
|
||||
class CUtils {
|
||||
public:
|
||||
CUtils();
|
||||
~CUtils();
|
||||
|
@ -44,8 +44,7 @@
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class CReadConfig
|
||||
{
|
||||
class CReadConfig {
|
||||
public:
|
||||
CReadConfig (const char* kpConfigFileName);
|
||||
virtual ~CReadConfig();
|
||||
|
@ -47,8 +47,7 @@ void Write2File(FILE *pFp, unsigned char* pData[3], int iStride[2], int iWidth,
|
||||
|
||||
#define NV12_FORMAT MAKEFOURCC('N','V','1','2')
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT uiWidth;
|
||||
UINT uiHeight;
|
||||
D3DFORMAT D3Dformat;
|
||||
@ -67,8 +66,7 @@ typedef HRESULT (WINAPI *pFnCreateD3D9Ex) (UINT SDKVersion, IDirect3D9Ex** );
|
||||
typedef LPDIRECT3D9 (WINAPI* pFnCreateD3D9) (UINT SDKVersion);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CD3D9Utils::CD3D9Utils()
|
||||
{
|
||||
CD3D9Utils::CD3D9Utils() {
|
||||
m_hDll = NULL;
|
||||
m_hWnd = NULL;
|
||||
m_pDumpYUV = NULL;
|
||||
@ -83,13 +81,11 @@ CD3D9Utils::CD3D9Utils()
|
||||
ZeroMemory (&m_d3dpp, sizeof (m_d3dpp));
|
||||
}
|
||||
|
||||
CD3D9Utils::~CD3D9Utils()
|
||||
{
|
||||
CD3D9Utils::~CD3D9Utils() {
|
||||
Uninit();
|
||||
}
|
||||
|
||||
HRESULT CD3D9Utils::Init(BOOL bWindowed)
|
||||
{
|
||||
HRESULT CD3D9Utils::Init (BOOL bWindowed) {
|
||||
if (m_bInitDone)
|
||||
return S_OK;
|
||||
|
||||
@ -105,15 +101,13 @@ HRESULT CD3D9Utils::Init(BOOL bWindowed)
|
||||
return bWindowed ? InitWindow (&m_hWnd) : S_OK;
|
||||
}
|
||||
|
||||
HRESULT CD3D9Utils::Uninit()
|
||||
{
|
||||
HRESULT CD3D9Utils::Uninit() {
|
||||
SAFE_RELEASE (m_lpD3D9RawSurfaceShare);
|
||||
SAFE_RELEASE (m_lpD3D9Device);
|
||||
SAFE_RELEASE (m_lpD3D9);
|
||||
SAFE_FREE (m_pDumpYUV);
|
||||
|
||||
if(m_hDll)
|
||||
{
|
||||
if (m_hDll) {
|
||||
FreeLibrary (m_hDll);
|
||||
m_hDll = NULL;
|
||||
}
|
||||
@ -121,8 +115,7 @@ HRESULT CD3D9Utils::Uninit()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CD3D9Utils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
{
|
||||
HRESULT CD3D9Utils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
|
||||
if (pDst == NULL || pInfo == NULL)
|
||||
@ -133,22 +126,17 @@ HRESULT CD3D9Utils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
if (!m_bInitDone)
|
||||
m_bInitDone = !bNeedD3D9;
|
||||
|
||||
if (!m_bInitDone)
|
||||
{
|
||||
if (!m_bInitDone) {
|
||||
hResult = Init (bWindowed);
|
||||
if (SUCCEEDED (hResult))
|
||||
m_bInitDone = TRUE;
|
||||
}
|
||||
|
||||
if (m_bInitDone)
|
||||
{
|
||||
if (bWindowed)
|
||||
{
|
||||
if (m_bInitDone) {
|
||||
if (bWindowed) {
|
||||
hResult = Render (pDst, pInfo);
|
||||
Sleep (30);
|
||||
}
|
||||
else if (pFp)
|
||||
{
|
||||
} else if (pFp) {
|
||||
hResult = Dump (pDst, pInfo, pFp);
|
||||
Sleep (0);
|
||||
}
|
||||
@ -157,20 +145,18 @@ HRESULT CD3D9Utils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT CD3D9Utils::Render(void *pDst[3], SBufferInfo *pInfo)
|
||||
{
|
||||
HRESULT CD3D9Utils::Render (void* pDst[3], SBufferInfo* pInfo) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
EBufferProperty eBufferProperty = pInfo->eBufferProperty;
|
||||
|
||||
if (eBufferProperty == BUFFER_HOST)
|
||||
{
|
||||
if (eBufferProperty == BUFFER_HOST) {
|
||||
hResult = InitResource (NULL, pInfo);
|
||||
if (SUCCEEDED (hResult))
|
||||
hResult = Dump2Surface(pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth, pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
|
||||
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
|
||||
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hResult))
|
||||
{
|
||||
if (SUCCEEDED (hResult)) {
|
||||
IDirect3DSurface9* pBackBuffer = NULL;
|
||||
hResult = m_lpD3D9Device->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
|
||||
hResult = m_lpD3D9Device->StretchRect (m_lpD3D9RawSurfaceShare, NULL, pBackBuffer, NULL, D3DTEXF_NONE);
|
||||
@ -180,8 +166,7 @@ HRESULT CD3D9Utils::Render(void *pDst[3], SBufferInfo *pInfo)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT CD3D9Utils::Dump(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
{
|
||||
HRESULT CD3D9Utils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
EBufferProperty eBufferProperty = pInfo->eBufferProperty;
|
||||
int iStride[2];
|
||||
@ -199,8 +184,7 @@ HRESULT CD3D9Utils::Dump(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT CD3D9Utils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
{
|
||||
HRESULT CD3D9Utils::InitResource (void* pSharedHandle, SBufferInfo* pInfo) {
|
||||
HRESULT hResult = S_OK;
|
||||
|
||||
// coverity scan uninitial
|
||||
@ -212,17 +196,14 @@ HRESULT CD3D9Utils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
if (pInfo == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
if (m_lpD3D9Device == NULL && m_lpD3D9RawSurfaceShare == NULL)
|
||||
{
|
||||
if (m_lpD3D9Device == NULL && m_lpD3D9RawSurfaceShare == NULL) {
|
||||
HMONITOR hMonitorWnd = MonitorFromWindow (m_hWnd, MONITOR_DEFAULTTONULL);
|
||||
|
||||
UINT uiAdapter = D3DADAPTER_DEFAULT;
|
||||
UINT uiCnt = m_lpD3D9->GetAdapterCount();
|
||||
for(UINT i=0; i<uiCnt; i++)
|
||||
{
|
||||
for (UINT i = 0; i < uiCnt; i++) {
|
||||
HMONITOR hMonitor = m_lpD3D9->GetAdapterMonitor (i);
|
||||
if(hMonitor == hMonitorWnd)
|
||||
{
|
||||
if (hMonitor == hMonitorWnd) {
|
||||
uiAdapter = i;
|
||||
break;
|
||||
}
|
||||
@ -242,15 +223,15 @@ HRESULT CD3D9Utils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
m_d3dpp.hDeviceWindow = m_hWnd;
|
||||
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
hResult = m_lpD3D9->CreateDevice (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, &m_lpD3D9Device);
|
||||
if (pInfo->eBufferProperty == BUFFER_HOST)
|
||||
{
|
||||
if (pInfo->eBufferProperty == BUFFER_HOST) {
|
||||
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
|
||||
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
|
||||
D3Dformat = (D3DFORMAT)NV12_FORMAT;
|
||||
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
|
||||
}
|
||||
|
||||
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface(iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool, &m_lpD3D9RawSurfaceShare, NULL);
|
||||
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface (iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool,
|
||||
&m_lpD3D9RawSurfaceShare, NULL);
|
||||
|
||||
}
|
||||
|
||||
@ -260,8 +241,7 @@ HRESULT CD3D9Utils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
CD3D9ExUtils::CD3D9ExUtils()
|
||||
{
|
||||
CD3D9ExUtils::CD3D9ExUtils() {
|
||||
m_hDll = NULL;
|
||||
m_hWnd = NULL;
|
||||
m_pDumpYUV = NULL;
|
||||
@ -276,13 +256,11 @@ CD3D9ExUtils::CD3D9ExUtils()
|
||||
ZeroMemory (&m_d3dpp, sizeof (m_d3dpp));
|
||||
}
|
||||
|
||||
CD3D9ExUtils::~CD3D9ExUtils()
|
||||
{
|
||||
CD3D9ExUtils::~CD3D9ExUtils() {
|
||||
Uninit();
|
||||
}
|
||||
|
||||
HRESULT CD3D9ExUtils::Init(BOOL bWindowed)
|
||||
{
|
||||
HRESULT CD3D9ExUtils::Init (BOOL bWindowed) {
|
||||
if (m_bInitDone)
|
||||
return S_OK;
|
||||
|
||||
@ -298,15 +276,13 @@ HRESULT CD3D9ExUtils::Init(BOOL bWindowed)
|
||||
return bWindowed ? InitWindow (&m_hWnd) : S_OK;
|
||||
}
|
||||
|
||||
HRESULT CD3D9ExUtils::Uninit()
|
||||
{
|
||||
HRESULT CD3D9ExUtils::Uninit() {
|
||||
SAFE_RELEASE (m_lpD3D9RawSurfaceShare);
|
||||
SAFE_RELEASE (m_lpD3D9Device);
|
||||
SAFE_RELEASE (m_lpD3D9);
|
||||
SAFE_FREE (m_pDumpYUV);
|
||||
|
||||
if(m_hDll)
|
||||
{
|
||||
if (m_hDll) {
|
||||
FreeLibrary (m_hDll);
|
||||
m_hDll = NULL;
|
||||
}
|
||||
@ -314,8 +290,7 @@ HRESULT CD3D9ExUtils::Uninit()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CD3D9ExUtils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
{
|
||||
HRESULT CD3D9ExUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
|
||||
if (pDst == NULL || pInfo == NULL)
|
||||
@ -326,22 +301,17 @@ HRESULT CD3D9ExUtils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
if (!m_bInitDone)
|
||||
m_bInitDone = !bNeedD3D9;
|
||||
|
||||
if (!m_bInitDone)
|
||||
{
|
||||
if (!m_bInitDone) {
|
||||
hResult = Init (bWindowed);
|
||||
if (SUCCEEDED (hResult))
|
||||
m_bInitDone = TRUE;
|
||||
}
|
||||
|
||||
if (m_bInitDone)
|
||||
{
|
||||
if (bWindowed)
|
||||
{
|
||||
if (m_bInitDone) {
|
||||
if (bWindowed) {
|
||||
hResult = Render (pDst, pInfo);
|
||||
Sleep (30); // set a simple time controlling with default of 30fps
|
||||
}
|
||||
else if (pFp)
|
||||
{
|
||||
} else if (pFp) {
|
||||
hResult = Dump (pDst, pInfo, pFp);
|
||||
Sleep (0);
|
||||
}
|
||||
@ -350,25 +320,21 @@ HRESULT CD3D9ExUtils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT CD3D9ExUtils::Render(void *pDst[3], SBufferInfo *pInfo)
|
||||
{
|
||||
HRESULT CD3D9ExUtils::Render (void* pDst[3], SBufferInfo* pInfo) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
EBufferProperty eBufferProperty = pInfo->eBufferProperty;
|
||||
|
||||
if (eBufferProperty == BUFFER_HOST)
|
||||
{
|
||||
if (eBufferProperty == BUFFER_HOST) {
|
||||
hResult = InitResource (NULL, pInfo);
|
||||
if (SUCCEEDED (hResult))
|
||||
hResult = Dump2Surface(pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth, pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
|
||||
}
|
||||
else if (eBufferProperty == BUFFER_DEVICE)
|
||||
{
|
||||
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
|
||||
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
|
||||
} else if (eBufferProperty == BUFFER_DEVICE) {
|
||||
VOID* pSharedHandle = pDst[0];
|
||||
hResult = InitResource (pSharedHandle, pInfo);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hResult))
|
||||
{
|
||||
if (SUCCEEDED (hResult)) {
|
||||
IDirect3DSurface9* pBackBuffer = NULL;
|
||||
hResult = m_lpD3D9Device->GetBackBuffer (0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
|
||||
hResult = m_lpD3D9Device->StretchRect (m_lpD3D9RawSurfaceShare, NULL, pBackBuffer, NULL, D3DTEXF_NONE);
|
||||
@ -378,37 +344,31 @@ HRESULT CD3D9ExUtils::Render(void *pDst[3], SBufferInfo *pInfo)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT CD3D9ExUtils::Dump(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
{
|
||||
HRESULT CD3D9ExUtils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
EBufferProperty eBufferProperty = pInfo->eBufferProperty;
|
||||
int iStride[2];
|
||||
int iWidth;
|
||||
int iHeight;
|
||||
|
||||
if (eBufferProperty != BUFFER_HOST)
|
||||
{
|
||||
if (eBufferProperty != BUFFER_HOST) {
|
||||
iWidth = pInfo->UsrData.sVideoBuffer.iSurfaceWidth;
|
||||
iHeight = pInfo->UsrData.sVideoBuffer.iSurfaceHeight;
|
||||
iStride[0] = iWidth;
|
||||
iStride[1] = iWidth / 2;
|
||||
|
||||
if (m_pDumpYUV == NULL)
|
||||
{
|
||||
if (m_pDumpYUV == NULL) {
|
||||
m_pDumpYUV = (unsigned char*)malloc (iWidth * iHeight * 3 / 2 * sizeof (unsigned char));
|
||||
}
|
||||
|
||||
if (m_pDumpYUV)
|
||||
{
|
||||
if (m_pDumpYUV) {
|
||||
void* pSurface = pDst[1];
|
||||
pDst[0] = m_pDumpYUV;
|
||||
pDst[1] = m_pDumpYUV + iHeight * iStride[0] * sizeof (unsigned char);
|
||||
pDst[2] = m_pDumpYUV + iHeight * iStride[0] * 5 / 4 * sizeof (unsigned char);
|
||||
hResult = Dump2YUV (pDst, pSurface, iWidth, iHeight, iStride);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
|
||||
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
|
||||
iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
|
||||
@ -421,8 +381,7 @@ HRESULT CD3D9ExUtils::Dump(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT CD3D9ExUtils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
{
|
||||
HRESULT CD3D9ExUtils::InitResource (void* pSharedHandle, SBufferInfo* pInfo) {
|
||||
HRESULT hResult = S_OK;
|
||||
int iWidth;
|
||||
int iHeight;
|
||||
@ -432,17 +391,14 @@ HRESULT CD3D9ExUtils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
if (pInfo == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
if (m_lpD3D9Device == NULL && m_lpD3D9RawSurfaceShare == NULL)
|
||||
{
|
||||
if (m_lpD3D9Device == NULL && m_lpD3D9RawSurfaceShare == NULL) {
|
||||
HMONITOR hMonitorWnd = MonitorFromWindow (m_hWnd, MONITOR_DEFAULTTONULL);
|
||||
|
||||
UINT uiAdapter = D3DADAPTER_DEFAULT;
|
||||
UINT uiCnt = m_lpD3D9->GetAdapterCount();
|
||||
for(UINT i=0; i<uiCnt; i++)
|
||||
{
|
||||
for (UINT i = 0; i < uiCnt; i++) {
|
||||
HMONITOR hMonitor = m_lpD3D9->GetAdapterMonitor (i);
|
||||
if(hMonitor == hMonitorWnd)
|
||||
{
|
||||
if (hMonitor == hMonitorWnd) {
|
||||
uiAdapter = i;
|
||||
break;
|
||||
}
|
||||
@ -463,21 +419,19 @@ HRESULT CD3D9ExUtils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
m_d3dpp.hDeviceWindow = m_hWnd;
|
||||
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
hResult = m_lpD3D9->CreateDeviceEx (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, NULL, &m_lpD3D9Device);
|
||||
if (pInfo->eBufferProperty == BUFFER_HOST)
|
||||
{
|
||||
if (pInfo->eBufferProperty == BUFFER_HOST) {
|
||||
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
|
||||
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
|
||||
D3Dformat = (D3DFORMAT)NV12_FORMAT;
|
||||
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iWidth = pInfo->UsrData.sVideoBuffer.iSurfaceWidth;
|
||||
iHeight = pInfo->UsrData.sVideoBuffer.iSurfaceHeight;
|
||||
D3Dformat = (D3DFORMAT)pInfo->UsrData.sVideoBuffer.D3Dformat;
|
||||
D3Dpool = (D3DPOOL)pInfo->UsrData.sVideoBuffer.D3DPool;
|
||||
}
|
||||
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface(iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool, &m_lpD3D9RawSurfaceShare, &pSharedHandle);
|
||||
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface (iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool,
|
||||
&m_lpD3D9RawSurfaceShare, &pSharedHandle);
|
||||
}
|
||||
|
||||
if (m_lpD3D9Device == NULL || m_lpD3D9RawSurfaceShare == NULL)
|
||||
@ -487,8 +441,7 @@ HRESULT CD3D9ExUtils::InitResource(void *pSharedHandle, SBufferInfo *pInfo)
|
||||
}
|
||||
|
||||
|
||||
HRESULT Dump2YUV(void *pDst[3], void *pSurface, int iWidth, int iHeight, int iStride[2])
|
||||
{
|
||||
HRESULT Dump2YUV (void* pDst[3], void* pSurface, int iWidth, int iHeight, int iStride[2]) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
|
||||
if (!pDst[0] || !pDst[1] || !pDst[2] || !pSurface)
|
||||
@ -510,10 +463,8 @@ HRESULT Dump2YUV(void *pDst[3], void *pSurface, int iWidth, int iHeight, int iSt
|
||||
unsigned char* pOutU = (unsigned char*)pDst[2];
|
||||
unsigned char* pInC = pInY + iInStride * iHeight;
|
||||
iOutStride = iStride[1];
|
||||
for (int i=0; i<iHeight/2; i++)
|
||||
{
|
||||
for (int j=0; j<iWidth; j+=2)
|
||||
{
|
||||
for (int i = 0; i < iHeight / 2; i++) {
|
||||
for (int j = 0; j < iWidth; j += 2) {
|
||||
pOutV[i * iOutStride + j / 2] = pInC[i * iInStride + j ];
|
||||
pOutU[i * iOutStride + j / 2] = pInC[i * iInStride + j + 1];
|
||||
}
|
||||
@ -524,8 +475,7 @@ HRESULT Dump2YUV(void *pDst[3], void *pSurface, int iWidth, int iHeight, int iSt
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT Dump2Surface(void *pDst[3], void *pSurface, int iWidth, int iHeight, int iStride[2])
|
||||
{
|
||||
HRESULT Dump2Surface (void* pDst[3], void* pSurface, int iWidth, int iHeight, int iStride[2]) {
|
||||
HRESULT hResult = E_FAIL;
|
||||
|
||||
if (!pDst[0] || !pDst[1] || !pDst[2] || !pSurface)
|
||||
@ -545,10 +495,8 @@ HRESULT Dump2Surface(void *pDst[3], void *pSurface, int iWidth, int iHeight, int
|
||||
unsigned char* pInV = (unsigned char*)pDst[1];
|
||||
unsigned char* pInU = (unsigned char*)pDst[2];
|
||||
unsigned char* pOutC = pOutY + iOutStride * iHeight;
|
||||
for (int i=0; i<iHeight/2; i++)
|
||||
{
|
||||
for (int j=0; j<iWidth; j+=2)
|
||||
{
|
||||
for (int i = 0; i < iHeight / 2; i++) {
|
||||
for (int j = 0; j < iWidth; j += 2) {
|
||||
pOutC[i * iOutStride + j ] = pInV[i * iStride[1] + j / 2];
|
||||
pOutC[i * iOutStride + j + 1] = pInU[i * iStride[1] + j / 2];
|
||||
}
|
||||
@ -559,8 +507,7 @@ HRESULT Dump2Surface(void *pDst[3], void *pSurface, int iWidth, int iHeight, int
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT InitWindow(HWND *hWnd)
|
||||
{
|
||||
HRESULT InitWindow (HWND* hWnd) {
|
||||
const TCHAR kszWindowTitle[] = TEXT ("Wels Decoder Application");
|
||||
const TCHAR kszWindowClass[] = TEXT ("Wels Decoder Class");
|
||||
|
||||
@ -594,17 +541,14 @@ HRESULT InitWindow(HWND *hWnd)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
INT wmId, wmEvent;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD (wParam);
|
||||
wmEvent = HIWORD (wParam);
|
||||
switch (wmId)
|
||||
{
|
||||
switch (wmId) {
|
||||
case IDM_ABOUT:
|
||||
break;
|
||||
case IDM_EXIT:
|
||||
@ -628,8 +572,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
#endif
|
||||
|
||||
CUtils::CUtils()
|
||||
{
|
||||
CUtils::CUtils() {
|
||||
hHandle = NULL;
|
||||
iOSType = CheckOS();
|
||||
|
||||
@ -645,18 +588,13 @@ CUtils::CUtils()
|
||||
iOSType = OS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
CUtils::~CUtils()
|
||||
{
|
||||
CUtils::~CUtils() {
|
||||
#ifdef ENABLE_DISPLAY_MODULE
|
||||
if (hHandle)
|
||||
{
|
||||
if (iOSType == OS_XP)
|
||||
{
|
||||
if (hHandle) {
|
||||
if (iOSType == OS_XP) {
|
||||
CD3D9Utils* hTmp = (CD3D9Utils*) hHandle;
|
||||
delete hTmp;
|
||||
}
|
||||
else if (iOSType == OS_VISTA_UPPER)
|
||||
{
|
||||
} else if (iOSType == OS_VISTA_UPPER) {
|
||||
CD3D9ExUtils* hTmp = (CD3D9ExUtils*) hHandle;
|
||||
delete hTmp;
|
||||
}
|
||||
@ -665,15 +603,12 @@ CUtils::~CUtils()
|
||||
#endif
|
||||
}
|
||||
|
||||
int CUtils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
{
|
||||
int CUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
|
||||
|
||||
int iRet = 0;
|
||||
|
||||
if (iOSType == OS_UNSUPPORTED)
|
||||
{
|
||||
if (pFp && pDst[0] && pDst[1] && pDst[2] && pInfo)
|
||||
{
|
||||
if (iOSType == OS_UNSUPPORTED) {
|
||||
if (pFp && pDst[0] && pDst[1] && pDst[2] && pInfo) {
|
||||
int iStride[2];
|
||||
int iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
|
||||
int iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
|
||||
@ -685,19 +620,14 @@ int CUtils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DISPLAY_MODULE
|
||||
else
|
||||
{
|
||||
else {
|
||||
MSG msg;
|
||||
ZeroMemory (&msg, sizeof (msg));
|
||||
while( msg.message != WM_QUIT )
|
||||
{
|
||||
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
|
||||
{
|
||||
while (msg.message != WM_QUIT) {
|
||||
if (PeekMessage (&msg, NULL, 0U, 0U, PM_REMOVE)) {
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
HRESULT hResult = S_OK;
|
||||
if (iOSType == OS_XP)
|
||||
hResult = ((CD3D9Utils*)hHandle)->Process (pDst, pInfo, pFp);
|
||||
@ -715,8 +645,7 @@ int CUtils::Process(void *pDst[3], SBufferInfo *pInfo, FILE *pFp)
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int CUtils::CheckOS()
|
||||
{
|
||||
int CUtils::CheckOS() {
|
||||
int iType = OS_UNSUPPORTED;
|
||||
|
||||
#ifdef ENABLE_DISPLAY_MODULE
|
||||
@ -724,15 +653,13 @@ int CUtils::CheckOS()
|
||||
ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
||||
|
||||
if( !GetVersionEx ((OSVERSIONINFO *) &osvi) )
|
||||
{
|
||||
if (!GetVersionEx ((OSVERSIONINFO*) &osvi)) {
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
if (! GetVersionEx ((OSVERSIONINFO*) &osvi))
|
||||
return iType;
|
||||
}
|
||||
|
||||
switch (osvi.dwPlatformId)
|
||||
{
|
||||
switch (osvi.dwPlatformId) {
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
if (osvi.dwMajorVersion >= 6)
|
||||
iType = OS_VISTA_UPPER;
|
||||
@ -748,14 +675,12 @@ int CUtils::CheckOS()
|
||||
return iType;
|
||||
}
|
||||
|
||||
void Write2File(FILE *pFp, unsigned char* pData[3], int iStride[2], int iWidth, int iHeight)
|
||||
{
|
||||
void Write2File (FILE* pFp, unsigned char* pData[3], int iStride[2], int iWidth, int iHeight) {
|
||||
int i;
|
||||
unsigned char* pPtr = NULL;
|
||||
|
||||
pPtr = pData[0];
|
||||
for( i=0; i<iHeight; i++ )
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
fwrite (pPtr, 1, iWidth, pFp);
|
||||
pPtr += iStride[0];
|
||||
}
|
||||
@ -763,15 +688,13 @@ void Write2File(FILE *pFp, unsigned char* pData[3], int iStride[2], int iWidth,
|
||||
iHeight = iHeight / 2;
|
||||
iWidth = iWidth / 2;
|
||||
pPtr = pData[1];
|
||||
for( i=0; i<iHeight; i++ )
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
fwrite (pPtr, 1, iWidth, pFp);
|
||||
pPtr += iStride[1];
|
||||
}
|
||||
|
||||
pPtr = pData[2];
|
||||
for( i=0; i<iHeight; i++ )
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
fwrite (pPtr, 1, iWidth, pFp);
|
||||
pPtr += iStride[1];
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ using namespace std;
|
||||
|
||||
//#define STICK_STREAM_SIZE // For Demo interfaces test with track file of integrated frames
|
||||
|
||||
void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName, int32_t& iWidth, int32_t& iHeight, void_t* pOptionFileName )
|
||||
{
|
||||
void_t H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName,
|
||||
int32_t& iWidth, int32_t& iHeight, void_t* pOptionFileName) {
|
||||
FILE* pH264File = NULL;
|
||||
FILE* pYuvFile = NULL;
|
||||
FILE* pOptionFile = NULL;
|
||||
@ -91,17 +91,14 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
double dElapsed = 0;
|
||||
|
||||
if (pDecoder == NULL) return;
|
||||
if (kpH264FileName)
|
||||
{
|
||||
if (kpH264FileName) {
|
||||
pH264File = fopen (kpH264FileName, "rb");
|
||||
if (pH264File == NULL) {
|
||||
fprintf (stderr, "Can not open h264 source file, check its legal path related please..\n");
|
||||
return;
|
||||
}
|
||||
fprintf (stderr, "H264 source file name: %s..\n", kpH264FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fprintf (stderr, "Can not find any h264 bitstream file to read..\n");
|
||||
fprintf (stderr, "----------------decoder return------------------------\n");
|
||||
return;
|
||||
@ -113,11 +110,9 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
fprintf (stderr, "Can not open yuv file to output result of decoding..\n");
|
||||
// any options
|
||||
//return; // can let decoder work in quiet mode, no writing any output
|
||||
}
|
||||
else
|
||||
} else
|
||||
fprintf (stderr, "Sequence output file name: %s..\n", kpOuputFileName);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
fprintf (stderr, "Can not find any output file to write..\n");
|
||||
// any options
|
||||
}
|
||||
@ -126,8 +121,7 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
pOptionFile = fopen ((char*)pOptionFileName, "wb");
|
||||
if (pOptionFile == NULL) {
|
||||
fprintf (stderr, "Can not open optional file for write..\n");
|
||||
}
|
||||
else
|
||||
} else
|
||||
fprintf (stderr, "Extra optional file: %s..\n", (char*)pOptionFileName);
|
||||
}
|
||||
|
||||
@ -161,8 +155,7 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
}
|
||||
|
||||
// set the output buffer property
|
||||
if(pYuvFile)
|
||||
{
|
||||
if (pYuvFile) {
|
||||
pDecoder->SetOption (DECODER_OPTION_OUTPUT_PROPERTY, &eOutputProperty);
|
||||
}
|
||||
|
||||
@ -225,33 +218,26 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
|
||||
pDecoder->DecodeFrame (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo);
|
||||
|
||||
if(sDstBufInfo.iBufferStatus == 1)
|
||||
{
|
||||
if (sDstBufInfo.iBufferStatus == 1) {
|
||||
pDst[0] = (uint8_t*)pData[0];
|
||||
pDst[1] = (uint8_t*)pData[1];
|
||||
pDst[2] = (uint8_t*)pData[2];
|
||||
}
|
||||
iEnd = WelsTime();
|
||||
iTotal += iEnd - iStart;
|
||||
if ( (sDstBufInfo.iBufferStatus==1) )
|
||||
{
|
||||
if ((sDstBufInfo.iBufferStatus == 1)) {
|
||||
iFrameNum++;
|
||||
cOutputModule.Process ((void_t**)pDst, &sDstBufInfo, pYuvFile);
|
||||
if (sDstBufInfo.eBufferProperty == BUFFER_HOST)
|
||||
{
|
||||
if (sDstBufInfo.eBufferProperty == BUFFER_HOST) {
|
||||
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
|
||||
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
|
||||
iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
|
||||
}
|
||||
|
||||
if ( pOptionFile != NULL )
|
||||
{
|
||||
if ( iWidth != iLastWidth && iHeight != iLastHeight )
|
||||
{
|
||||
if (pOptionFile != NULL) {
|
||||
if (iWidth != iLastWidth && iHeight != iLastHeight) {
|
||||
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
|
||||
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
|
||||
fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile);
|
||||
@ -273,29 +259,23 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
|
||||
|
||||
pDecoder->DecodeFrame (NULL, 0, pData, &sDstBufInfo);
|
||||
if(sDstBufInfo.iBufferStatus == 1)
|
||||
{
|
||||
if (sDstBufInfo.iBufferStatus == 1) {
|
||||
pDst[0] = (uint8_t*)pData[0];
|
||||
pDst[1] = (uint8_t*)pData[1];
|
||||
pDst[2] = (uint8_t*)pData[2];
|
||||
}
|
||||
|
||||
if ((sDstBufInfo.iBufferStatus==1))
|
||||
{
|
||||
if ((sDstBufInfo.iBufferStatus == 1)) {
|
||||
cOutputModule.Process ((void_t**)pDst, &sDstBufInfo, pYuvFile);
|
||||
if (sDstBufInfo.eBufferProperty == BUFFER_HOST)
|
||||
{
|
||||
if (sDstBufInfo.eBufferProperty == BUFFER_HOST) {
|
||||
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
|
||||
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
|
||||
iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
|
||||
}
|
||||
|
||||
if ( pOptionFile != NULL )
|
||||
{
|
||||
if (pOptionFile != NULL) {
|
||||
/* Anyway, we need write in case of final frame decoding */
|
||||
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
|
||||
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
|
||||
@ -322,31 +302,26 @@ void_t H264DecodeInstance( ISVCDecoder* pDecoder, const char* kpH264FileName, co
|
||||
|
||||
// coverity scan uninitial
|
||||
label_exit:
|
||||
if (pBuf)
|
||||
{
|
||||
if (pBuf) {
|
||||
delete[] pBuf;
|
||||
pBuf = NULL;
|
||||
}
|
||||
if ( pH264File )
|
||||
{
|
||||
if (pH264File) {
|
||||
fclose (pH264File);
|
||||
pH264File = NULL;
|
||||
}
|
||||
if ( pYuvFile )
|
||||
{
|
||||
if (pYuvFile) {
|
||||
fclose (pYuvFile);
|
||||
pYuvFile = NULL;
|
||||
}
|
||||
if ( pOptionFile )
|
||||
{
|
||||
if (pOptionFile) {
|
||||
fclose (pOptionFile);
|
||||
pOptionFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t main(int32_t iArgC, char* pArgV[])
|
||||
{
|
||||
int32_t main (int32_t iArgC, char* pArgV[]) {
|
||||
ISVCDecoder* pDecoder = NULL;
|
||||
|
||||
SDecodingParam sDecParam = {0};
|
||||
@ -354,17 +329,13 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
|
||||
sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty);
|
||||
|
||||
if (iArgC < 2)
|
||||
{
|
||||
if (iArgC < 2) {
|
||||
printf ("usage 1: h264dec.exe welsdec.cfg\n");
|
||||
printf ("usage 2: h264dec.exe welsdec.264 out.yuv\n");
|
||||
printf ("usage 3: h264dec.exe welsdec.264\n");
|
||||
return 1;
|
||||
}
|
||||
else if (iArgC == 2)
|
||||
{
|
||||
if (strstr(pArgV[1], ".cfg")) // read config file //confirmed_safe_unsafe_usage
|
||||
{
|
||||
} else if (iArgC == 2) {
|
||||
if (strstr (pArgV[1], ".cfg")) { // read config file //confirmed_safe_unsafe_usage
|
||||
CReadConfig cReadCfg (pArgV[1]);
|
||||
string strTag[4];
|
||||
string strReconFile ("");
|
||||
@ -380,11 +351,9 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
if (nRd > 0) {
|
||||
if (strTag[0].compare ("InputFile") == 0) {
|
||||
strInputFile = strTag[1];
|
||||
}
|
||||
else if (strTag[0].compare("OutputFile") == 0){
|
||||
} else if (strTag[0].compare ("OutputFile") == 0) {
|
||||
strOutputFile = strTag[1];
|
||||
}
|
||||
else if (strTag[0].compare("RestructionFile") == 0){
|
||||
} else if (strTag[0].compare ("RestructionFile") == 0) {
|
||||
strReconFile = strTag[1];
|
||||
int32_t iLen = strReconFile.length();
|
||||
sDecParam.pFileNameRestructed = new char[iLen + 1];
|
||||
@ -393,32 +362,25 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
}
|
||||
|
||||
strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
else if (strTag[0].compare("TargetDQID") == 0){
|
||||
} else if (strTag[0].compare ("TargetDQID") == 0) {
|
||||
sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str());
|
||||
}
|
||||
else if (strTag[0].compare("OutColorFormat") == 0){
|
||||
} else if (strTag[0].compare ("OutColorFormat") == 0) {
|
||||
sDecParam.iOutputColorFormat = atol (strTag[1].c_str());
|
||||
}
|
||||
else if (strTag[0].compare("ErrorConcealmentFlag") == 0){
|
||||
} else if (strTag[0].compare ("ErrorConcealmentFlag") == 0) {
|
||||
sDecParam.uiEcActiveFlag = (uint8_t)atol (strTag[1].c_str());
|
||||
}
|
||||
else if (strTag[0].compare("CPULoad") == 0){
|
||||
} else if (strTag[0].compare ("CPULoad") == 0) {
|
||||
sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str());
|
||||
}
|
||||
else if (strTag[0].compare("VideoBitstreamType") == 0){
|
||||
} else if (strTag[0].compare ("VideoBitstreamType") == 0) {
|
||||
sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strOutputFile.empty())
|
||||
{
|
||||
if (strOutputFile.empty()) {
|
||||
printf ("No output file specified in configuration file.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (strstr(pArgV[1], ".264")) // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
|
||||
{
|
||||
} else if (strstr (pArgV[1],
|
||||
".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
|
||||
strInputFile = pArgV[1];
|
||||
memset (&sDecParam, 0, sizeof (sDecParam));
|
||||
sDecParam.iOutputColorFormat = videoFormatI420;
|
||||
@ -426,9 +388,7 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
sDecParam.uiEcActiveFlag = 1;
|
||||
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
||||
}
|
||||
}
|
||||
else //iArgC > 2
|
||||
{
|
||||
} else { //iArgC > 2
|
||||
strInputFile = pArgV[1];
|
||||
strOutputFile = pArgV[2];
|
||||
memset (&sDecParam, 0, sizeof (sDecParam));
|
||||
@ -455,15 +415,13 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
}
|
||||
}
|
||||
|
||||
if (strOutputFile.empty())
|
||||
{
|
||||
if (strOutputFile.empty()) {
|
||||
printf ("No output file specified in configuration file.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (strInputFile.empty())
|
||||
{
|
||||
if (strInputFile.empty()) {
|
||||
printf ("No input file specified in configuration file.\n");
|
||||
return 1;
|
||||
}
|
||||
@ -482,18 +440,14 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
pCreateDecoderFunc = (PCreateDecoderFunc)::GetProcAddress (hModule, "CreateDecoder");
|
||||
pDestroyDecoderFunc = (PDestroyDecoderFunc)::GetProcAddress (hModule, "DestroyDecoder");
|
||||
|
||||
if ((hModule != NULL) && (pCreateDecoderFunc != NULL) && (pDestroyDecoderFunc != NULL))
|
||||
{
|
||||
if ((hModule != NULL) && (pCreateDecoderFunc != NULL) && (pDestroyDecoderFunc != NULL)) {
|
||||
printf ("load library sw function successfully\n");
|
||||
|
||||
if ( pCreateDecoderFunc( &pDecoder ) || (NULL == pDecoder) )
|
||||
{
|
||||
if (pCreateDecoderFunc (&pDecoder) || (NULL == pDecoder)) {
|
||||
printf ("Create Decoder failed.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf ("load library sw function failed\n");
|
||||
return 1;
|
||||
}
|
||||
@ -502,8 +456,7 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
#else
|
||||
|
||||
|
||||
if ( CreateDecoder( &pDecoder ) || (NULL == pDecoder) )
|
||||
{
|
||||
if (CreateDecoder (&pDecoder) || (NULL == pDecoder)) {
|
||||
printf ("Create Decoder failed.\n");
|
||||
return 1;
|
||||
}
|
||||
@ -511,8 +464,7 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
#endif
|
||||
|
||||
|
||||
if ( pDecoder->Initialize( &sDecParam, INIT_TYPE_PARAMETER_BASED ) )
|
||||
{
|
||||
if (pDecoder->Initialize (&sDecParam, INIT_TYPE_PARAMETER_BASED)) {
|
||||
printf ("Decoder initialization failed.\n");
|
||||
return 1;
|
||||
}
|
||||
@ -522,7 +474,8 @@ int32_t main(int32_t iArgC, char* pArgV[])
|
||||
int32_t iHeight = 0;
|
||||
|
||||
|
||||
H264DecodeInstance( pDecoder, strInputFile.c_str(), strOutputFile.c_str(), iWidth, iHeight, (!strOptionFile.empty() ? (void_t*)(const_cast<char*>(strOptionFile.c_str())) : NULL) );
|
||||
H264DecodeInstance (pDecoder, strInputFile.c_str(), strOutputFile.c_str(), iWidth, iHeight,
|
||||
(!strOptionFile.empty() ? (void_t*) (const_cast<char*> (strOptionFile.c_str())) : NULL));
|
||||
|
||||
if (sDecParam.pFileNameRestructed != NULL) {
|
||||
delete []sDecParam.pFileNameRestructed;
|
||||
|
@ -70,10 +70,8 @@ CFBundleRef g_at264ModuleHWD = nil;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
{
|
||||
if(lpModulePath == NULL || iPathMax <= 0)
|
||||
{
|
||||
int GetCurrentModulePath (char* lpModulePath, const int iPathMax) {
|
||||
if (lpModulePath == NULL || iPathMax <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -93,12 +91,10 @@ int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
int locateNumber = 1;
|
||||
struct FSRef currentPath;
|
||||
OSStatus iStatus = FSPathMakeRef ((unsigned char*)cCurrentPath, ¤tPath, NULL);
|
||||
if(noErr == iStatus)
|
||||
{
|
||||
if (noErr == iStatus) {
|
||||
LSItemInfoRecord info;
|
||||
iStatus = LSCopyItemInfoForRef (¤tPath, kLSRequestExtension, &info);
|
||||
if(noErr == iStatus && NULL == info.extension)
|
||||
{
|
||||
if (noErr == iStatus && NULL == info.extension) {
|
||||
locateNumber = 4;
|
||||
}
|
||||
}
|
||||
@ -108,17 +104,14 @@ int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
|
||||
std::string strPath (cCurrentPath);
|
||||
int pos = std::string::npos;
|
||||
for(int i = 0; i < locateNumber; i++)
|
||||
{
|
||||
for (int i = 0; i < locateNumber; i++) {
|
||||
pos = strPath.rfind ('/');
|
||||
if(std::string::npos == pos)
|
||||
{
|
||||
if (std::string::npos == pos) {
|
||||
break;
|
||||
}
|
||||
strPath.erase (pos);
|
||||
}
|
||||
if(std::string::npos == pos)
|
||||
{
|
||||
if (std::string::npos == pos) {
|
||||
return -2;
|
||||
}
|
||||
cCurrentPath[pos] = 0;
|
||||
@ -129,22 +122,19 @@ int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFBundleRef LoadBundle(const char* lpBundlePath)
|
||||
{
|
||||
if(lpBundlePath == NULL)
|
||||
{
|
||||
CFBundleRef LoadBundle (const char* lpBundlePath) {
|
||||
if (lpBundlePath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFStringRef bundlePath = CFStringCreateWithCString(kCFAllocatorSystemDefault, lpBundlePath, CFStringGetSystemEncoding());
|
||||
if(NULL == bundlePath)
|
||||
{
|
||||
CFStringRef bundlePath = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpBundlePath,
|
||||
CFStringGetSystemEncoding());
|
||||
if (NULL == bundlePath) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFURLRef bundleURL = CFURLCreateWithString (kCFAllocatorSystemDefault, bundlePath, NULL);
|
||||
if(NULL == bundleURL)
|
||||
{
|
||||
if (NULL == bundleURL) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@ -153,18 +143,15 @@ CFBundleRef LoadBundle(const char* lpBundlePath)
|
||||
CFBundleRef bundleRef = CFBundleCreate (kCFAllocatorSystemDefault, bundleURL);
|
||||
CFRelease (bundleURL);
|
||||
|
||||
if(NULL != bundleRef)
|
||||
{
|
||||
if (NULL != bundleRef) {
|
||||
}
|
||||
|
||||
return bundleRef;
|
||||
}
|
||||
|
||||
void* GetProcessAddress(CFBundleRef bundleRef, const char* lpProcName)
|
||||
{
|
||||
void* GetProcessAddress (CFBundleRef bundleRef, const char* lpProcName) {
|
||||
void* processAddress = NULL;
|
||||
if(NULL != bundleRef)
|
||||
{
|
||||
if (NULL != bundleRef) {
|
||||
CFStringRef cfProcName = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
|
||||
processAddress = CFBundleGetFunctionPointerForName (bundleRef, cfProcName);
|
||||
CFRelease (cfProcName);
|
||||
@ -175,8 +162,7 @@ void* GetProcessAddress(CFBundleRef bundleRef, const char* lpProcName)
|
||||
|
||||
////////////////////////
|
||||
|
||||
bool load_bundle_welsdec()
|
||||
{
|
||||
bool load_bundle_welsdec() {
|
||||
|
||||
char achPath[512] = {0};
|
||||
|
||||
@ -192,16 +178,13 @@ bool load_bundle_welsdec()
|
||||
|
||||
}
|
||||
|
||||
void free_bundle_welsdec()
|
||||
{
|
||||
if(g_at264Module != NULL)
|
||||
{
|
||||
void free_bundle_welsdec() {
|
||||
if (g_at264Module != NULL) {
|
||||
CFBundleUnloadExecutable (g_at264Module);
|
||||
}
|
||||
}
|
||||
|
||||
bool get_functions_address_create_decoder(ISVCDecoder** ppDecoder)
|
||||
{
|
||||
bool get_functions_address_create_decoder (ISVCDecoder** ppDecoder) {
|
||||
if (!g_at264Module)
|
||||
return false;
|
||||
|
||||
@ -212,21 +195,15 @@ bool get_functions_address_create_decoder(ISVCDecoder** ppDecoder)
|
||||
(LPCreateVHDController)GetProcessAddress (g_at264Module, "CreateSVCVHDController");
|
||||
|
||||
|
||||
if(pfuncCreateSWDec != NULL)
|
||||
{
|
||||
if (pfuncCreateSWDec != NULL) {
|
||||
pfuncCreateSWDec (ppDecoder);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(pfuncCreateHWDec != NULL)
|
||||
{
|
||||
if (pfuncCreateHWDec != NULL) {
|
||||
pfuncCreateHWDec();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -234,8 +211,7 @@ bool get_functions_address_create_decoder(ISVCDecoder** ppDecoder)
|
||||
|
||||
}
|
||||
|
||||
bool get_functions_address_free_decoder(ISVCDecoder* pDecoder)
|
||||
{
|
||||
bool get_functions_address_free_decoder (ISVCDecoder* pDecoder) {
|
||||
if (!g_at264Module)
|
||||
return false;
|
||||
|
||||
@ -245,21 +221,15 @@ bool get_functions_address_free_decoder(ISVCDecoder* pDecoder)
|
||||
LPDestroyVHDController pfuncDestroyHWDec =
|
||||
(LPDestroyVHDController)GetProcessAddress (g_at264Module, "DestroySVCVHDController");
|
||||
|
||||
if(pfuncDestroySWDec != NULL)
|
||||
{
|
||||
if (pfuncDestroySWDec != NULL) {
|
||||
pfuncDestroySWDec (pDecoder);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(pfuncDestroyHWDec != NULL)
|
||||
{
|
||||
if (pfuncDestroyHWDec != NULL) {
|
||||
pfuncDestroyHWDec();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,23 +49,20 @@
|
||||
CReadConfig::CReadConfig (const char* kpConfigFileName)
|
||||
: m_pCfgFile (0)
|
||||
, m_strCfgFileName (kpConfigFileName)
|
||||
, m_ulLines(0)
|
||||
{
|
||||
, m_ulLines (0) {
|
||||
if (strlen (kpConfigFileName) > 0) { // FIXME: To check validation in configure file name
|
||||
m_pCfgFile = fopen (kpConfigFileName, "r");
|
||||
}
|
||||
}
|
||||
|
||||
CReadConfig::~CReadConfig()
|
||||
{
|
||||
CReadConfig::~CReadConfig() {
|
||||
if (m_pCfgFile) {
|
||||
fclose (m_pCfgFile);
|
||||
m_pCfgFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
long CReadConfig::ReadLine( string* pStr, const int kiValSize/* = 4*/ )
|
||||
{
|
||||
long CReadConfig::ReadLine (string* pStr, const int kiValSize/* = 4*/) {
|
||||
if (m_pCfgFile == NULL || pStr == NULL || kiValSize <= 1)
|
||||
return 0;
|
||||
|
||||
@ -95,8 +92,7 @@ long CReadConfig::ReadLine( string* pStr, const int kiValSize/* = 4*/ )
|
||||
++ iTagNum;
|
||||
strTags = &pStr[iTagNum];
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
*strTags += kChar;
|
||||
}
|
||||
|
||||
@ -105,24 +101,20 @@ long CReadConfig::ReadLine( string* pStr, const int kiValSize/* = 4*/ )
|
||||
return 1 + iTagNum;
|
||||
}
|
||||
|
||||
const bool CReadConfig::EndOfFile()
|
||||
{
|
||||
const bool CReadConfig::EndOfFile() {
|
||||
if (m_pCfgFile == NULL)
|
||||
return true;
|
||||
return feof (m_pCfgFile) ? true : false;
|
||||
}
|
||||
|
||||
const int CReadConfig::GetLines()
|
||||
{
|
||||
const int CReadConfig::GetLines() {
|
||||
return m_ulLines;
|
||||
}
|
||||
|
||||
const bool CReadConfig::ExistFile()
|
||||
{
|
||||
const bool CReadConfig::ExistFile() {
|
||||
return (m_pCfgFile != NULL);
|
||||
}
|
||||
|
||||
const string& CReadConfig::GetFileName()
|
||||
{
|
||||
const string& CReadConfig::GetFileName() {
|
||||
return m_strCfgFileName;
|
||||
}
|
||||
|
@ -45,20 +45,17 @@
|
||||
#include "wels_const.h"
|
||||
using namespace std;
|
||||
|
||||
typedef struct tagFilesSet
|
||||
{
|
||||
typedef struct tagFilesSet {
|
||||
string strBsFile;
|
||||
string strSeqFile; // for cmd lines
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
string strLayerCfgFile;
|
||||
string strSeqFile;
|
||||
} sSpatialLayers[MAX_DEPENDENCY_LAYER];
|
||||
} SFilesSet;
|
||||
|
||||
|
||||
class CReadConfig
|
||||
{
|
||||
class CReadConfig {
|
||||
public:
|
||||
CReadConfig();
|
||||
CReadConfig (const char* pConfigFileName);
|
||||
|
@ -46,10 +46,8 @@ CFBundleRef g_at264Module = nil;
|
||||
|
||||
const char H264EncoderDLL[] = "welsenc.bundle";
|
||||
|
||||
int WelsEncGetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
{
|
||||
if(lpModulePath == NULL || iPathMax <= 0)
|
||||
{
|
||||
int WelsEncGetCurrentModulePath (char* lpModulePath, const int iPathMax) {
|
||||
if (lpModulePath == NULL || iPathMax <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -68,17 +66,14 @@ int WelsEncGetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
|
||||
std::string strPath (cCurrentPath);
|
||||
int pos = std::string::npos;
|
||||
for(int i = 0; i < locateNumber; i++)
|
||||
{
|
||||
for (int i = 0; i < locateNumber; i++) {
|
||||
pos = strPath.rfind ('/');
|
||||
if(std::string::npos == pos)
|
||||
{
|
||||
if (std::string::npos == pos) {
|
||||
break;
|
||||
}
|
||||
strPath.erase (pos);
|
||||
}
|
||||
if(std::string::npos == pos)
|
||||
{
|
||||
if (std::string::npos == pos) {
|
||||
return -2;
|
||||
}
|
||||
cCurrentPath[pos] = 0;
|
||||
@ -90,8 +85,7 @@ int WelsEncGetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
|
||||
}
|
||||
|
||||
int32_t WelsEncBundleLoad()
|
||||
{
|
||||
int32_t WelsEncBundleLoad() {
|
||||
|
||||
char achPath[512] = {0};
|
||||
|
||||
@ -106,32 +100,27 @@ int32_t WelsEncBundleLoad()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WelsEncBundleFree()
|
||||
{
|
||||
if(g_at264Module != NULL)
|
||||
{
|
||||
void WelsEncBundleFree() {
|
||||
if (g_at264Module != NULL) {
|
||||
CFBundleUnloadExecutable (g_at264Module);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t WelsEncBundleCreateEncoder(ISVCEncoder** ppEncoder)
|
||||
{
|
||||
int32_t WelsEncBundleCreateEncoder (ISVCEncoder** ppEncoder) {
|
||||
if (!g_at264Module)
|
||||
return 1;
|
||||
|
||||
LPCreateWelsCSEncoder pfuncCreateCSEnc =
|
||||
(LPCreateWelsCSEncoder)GetProcessAddress (g_at264Module, "CreateSVCEncoder");
|
||||
|
||||
if(pfuncCreateCSEnc != NULL)
|
||||
{
|
||||
if (pfuncCreateCSEnc != NULL) {
|
||||
return (pfuncCreateCSEnc (ppEncoder));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t WelsEncBundleDestroyEncoder(ISVCEncoder* pEncoder)
|
||||
{
|
||||
int32_t WelsEncBundleDestroyEncoder (ISVCEncoder* pEncoder) {
|
||||
if (!g_at264Module)
|
||||
return 1;
|
||||
|
||||
@ -141,8 +130,7 @@ int32_t WelsEncBundleDestroyEncoder(ISVCEncoder* pEncoder)
|
||||
if (pfuncDestroyCSEnc != NULL) {
|
||||
pfuncDestroyCSEnc (pEncoder);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -50,15 +50,13 @@
|
||||
CReadConfig::CReadConfig()
|
||||
: m_pCfgFile (NULL)
|
||||
, m_strCfgFileName ("")
|
||||
, m_iLines( 0 )
|
||||
{
|
||||
, m_iLines (0) {
|
||||
}
|
||||
|
||||
CReadConfig::CReadConfig (const char* kpConfigFileName)
|
||||
: m_pCfgFile (0)
|
||||
, m_strCfgFileName (kpConfigFileName)
|
||||
, m_iLines(0)
|
||||
{
|
||||
, m_iLines (0) {
|
||||
if (strlen (kpConfigFileName) > 0) { // confirmed_safe_unsafe_usage
|
||||
m_pCfgFile = fopen (kpConfigFileName, "r");
|
||||
}
|
||||
@ -67,33 +65,27 @@ CReadConfig::CReadConfig( const char *kpConfigFileName )
|
||||
CReadConfig::CReadConfig (const string& kpConfigFileName)
|
||||
: m_pCfgFile (0)
|
||||
, m_strCfgFileName (kpConfigFileName)
|
||||
, m_iLines(0)
|
||||
{
|
||||
if ( kpConfigFileName.length() > 0 )
|
||||
{
|
||||
, m_iLines (0) {
|
||||
if (kpConfigFileName.length() > 0) {
|
||||
m_pCfgFile = fopen (kpConfigFileName.c_str(), "r");
|
||||
}
|
||||
}
|
||||
|
||||
CReadConfig::~CReadConfig()
|
||||
{
|
||||
CReadConfig::~CReadConfig() {
|
||||
if (m_pCfgFile) {
|
||||
fclose (m_pCfgFile);
|
||||
m_pCfgFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CReadConfig::Openf(const char *kpStrFile)
|
||||
{
|
||||
if ( kpStrFile != NULL && strlen(kpStrFile) > 0 ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
void CReadConfig::Openf (const char* kpStrFile) {
|
||||
if (kpStrFile != NULL && strlen (kpStrFile) > 0) { // confirmed_safe_unsafe_usage
|
||||
m_strCfgFileName = kpStrFile;
|
||||
m_pCfgFile = fopen (kpStrFile, "r");
|
||||
}
|
||||
}
|
||||
|
||||
long CReadConfig::ReadLine( string* pVal, const int kiValSize/* = 4*/ )
|
||||
{
|
||||
long CReadConfig::ReadLine (string* pVal, const int kiValSize/* = 4*/) {
|
||||
if (m_pCfgFile == NULL || pVal == NULL || kiValSize <= 1)
|
||||
return 0;
|
||||
|
||||
@ -123,8 +115,7 @@ long CReadConfig::ReadLine( string* pVal, const int kiValSize/* = 4*/ )
|
||||
++ nTagNum;
|
||||
strTags = &pVal[nTagNum];
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
*strTags += kCh;
|
||||
}
|
||||
|
||||
@ -133,25 +124,21 @@ long CReadConfig::ReadLine( string* pVal, const int kiValSize/* = 4*/ )
|
||||
return 1 + nTagNum;
|
||||
}
|
||||
|
||||
const bool CReadConfig::EndOfFile()
|
||||
{
|
||||
const bool CReadConfig::EndOfFile() {
|
||||
if (m_pCfgFile == NULL)
|
||||
return true;
|
||||
return feof (m_pCfgFile) ? true : false;
|
||||
}
|
||||
|
||||
const int CReadConfig::GetLines()
|
||||
{
|
||||
const int CReadConfig::GetLines() {
|
||||
return m_iLines;
|
||||
}
|
||||
|
||||
const bool CReadConfig::ExistFile()
|
||||
{
|
||||
const bool CReadConfig::ExistFile() {
|
||||
return (m_pCfgFile != NULL);
|
||||
}
|
||||
|
||||
const string& CReadConfig::GetFileName()
|
||||
{
|
||||
const string& CReadConfig::GetFileName() {
|
||||
return m_strCfgFileName;
|
||||
}
|
||||
|
||||
|
@ -99,13 +99,11 @@ typedef struct LayerpEncCtx_s {
|
||||
|
||||
/* Ctrl-C handler */
|
||||
static int g_iCtrlC = 0;
|
||||
static void SigIntHandler( int a )
|
||||
{
|
||||
static void SigIntHandler (int a) {
|
||||
g_iCtrlC = 1;
|
||||
}
|
||||
|
||||
int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet& sFileSet)
|
||||
{
|
||||
int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet& sFileSet) {
|
||||
string strTag[4];
|
||||
int32_t iLeftTargetBitrate = 0;
|
||||
int32_t iLeftSpatialBitrate[MAX_DEPENDENCY_LAYER] = { 0 };
|
||||
@ -124,43 +122,31 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
if (strTag[0].compare ("OutputFile") == 0) {
|
||||
sFileSet.strBsFile = strTag[1];
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("MaxFrameRate") == 0){
|
||||
} else if (strTag[0].compare ("MaxFrameRate") == 0) {
|
||||
pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FramesToBeEncoded") == 0){
|
||||
} else if (strTag[0].compare ("FramesToBeEncoded") == 0) {
|
||||
pSvcParam.uiFrameToBeCoded = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if ( strTag[0].compare("SourceSequenceInRGB24") == 0 ){
|
||||
} else if (strTag[0].compare ("SourceSequenceInRGB24") == 0) {
|
||||
pSvcParam.iInputCsp = atoi (strTag[1].c_str()) == 0 ? videoFormatI420 : videoFormatRGB;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("GOPSize") == 0){
|
||||
} else if (strTag[0].compare ("GOPSize") == 0) {
|
||||
pSvcParam.uiGopSize = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("IntraPeriod") == 0){
|
||||
} else if (strTag[0].compare ("IntraPeriod") == 0) {
|
||||
pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableSpsPpsIDAddition") == 0)
|
||||
{
|
||||
} else if (strTag[0].compare ("EnableSpsPpsIDAddition") == 0) {
|
||||
pSvcParam.bEnableSpsPpsIdAddition = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableScalableSEI") == 0)
|
||||
{
|
||||
} else if (strTag[0].compare ("EnableScalableSEI") == 0) {
|
||||
pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableFrameCropping") == 0)
|
||||
{
|
||||
} else if (strTag[0].compare ("EnableFrameCropping") == 0) {
|
||||
pSvcParam.bEnableFrameCroppingFlag = (atoi (strTag[1].c_str()) != 0);
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("LoopFilterDisableIDC") == 0){
|
||||
} else if (strTag[0].compare ("LoopFilterDisableIDC") == 0) {
|
||||
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);
|
||||
@ -168,50 +154,44 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("LoopFilterAlphaC0Offset") == 0){
|
||||
} else if (strTag[0].compare ("LoopFilterAlphaC0Offset") == 0) {
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iLoopFilterAlphaC0Offset < -6)
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = -6;
|
||||
else if (pSvcParam.iLoopFilterAlphaC0Offset > 6)
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = 6;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("LoopFilterBetaOffset") == 0){
|
||||
} else if (strTag[0].compare ("LoopFilterBetaOffset") == 0) {
|
||||
pSvcParam.iLoopFilterBetaOffset = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iLoopFilterBetaOffset < -6)
|
||||
pSvcParam.iLoopFilterBetaOffset = -6;
|
||||
else if (pSvcParam.iLoopFilterBetaOffset > 6)
|
||||
pSvcParam.iLoopFilterBetaOffset = 6;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("InterLayerLoopFilterDisableIDC") == 0){
|
||||
} else if (strTag[0].compare ("InterLayerLoopFilterDisableIDC") == 0) {
|
||||
pSvcParam.iInterLayerLoopFilterDisableIdc = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iInterLayerLoopFilterDisableIdc > 6 || pSvcParam.iInterLayerLoopFilterDisableIdc < 0) {
|
||||
fprintf(stderr, "Invalid parameter in iInterLayerLoopFilterDisableIdc: %d.\n", pSvcParam.iInterLayerLoopFilterDisableIdc);
|
||||
fprintf (stderr, "Invalid parameter in iInterLayerLoopFilterDisableIdc: %d.\n",
|
||||
pSvcParam.iInterLayerLoopFilterDisableIdc);
|
||||
iRet = 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("InterLayerLoopFilterAlphaC0Offset") == 0){
|
||||
} else if (strTag[0].compare ("InterLayerLoopFilterAlphaC0Offset") == 0) {
|
||||
pSvcParam.iInterLayerLoopFilterAlphaC0Offset = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iInterLayerLoopFilterAlphaC0Offset < -6)
|
||||
pSvcParam.iInterLayerLoopFilterAlphaC0Offset = -6;
|
||||
else if (pSvcParam.iInterLayerLoopFilterAlphaC0Offset > 6)
|
||||
pSvcParam.iInterLayerLoopFilterAlphaC0Offset = 6;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("InterLayerLoopFilterBetaOffset") == 0){
|
||||
} else if (strTag[0].compare ("InterLayerLoopFilterBetaOffset") == 0) {
|
||||
pSvcParam.iInterLayerLoopFilterBetaOffset = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iInterLayerLoopFilterBetaOffset < -6)
|
||||
pSvcParam.iInterLayerLoopFilterBetaOffset = -6;
|
||||
else if (pSvcParam.iInterLayerLoopFilterBetaOffset > 6)
|
||||
pSvcParam.iInterLayerLoopFilterBetaOffset = 6;
|
||||
continue;
|
||||
}
|
||||
else if ( strTag[0].compare("MultipleThreadIdc") == 0 )
|
||||
{
|
||||
} 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());
|
||||
if (pSvcParam.iMultipleThreadIdc < 0)
|
||||
@ -219,16 +199,13 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
else if (pSvcParam.iMultipleThreadIdc > MAX_THREADS_NUM)
|
||||
pSvcParam.iMultipleThreadIdc = MAX_THREADS_NUM;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableRC") == 0){
|
||||
} else if (strTag[0].compare ("EnableRC") == 0) {
|
||||
pSvcParam.bEnableRc = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("RCMode") == 0){
|
||||
} else if (strTag[0].compare ("RCMode") == 0) {
|
||||
pSvcParam.iRCMode = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("TargetBitrate") == 0){
|
||||
} else if (strTag[0].compare ("TargetBitrate") == 0) {
|
||||
pSvcParam.iTargetBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
if (pSvcParam.bEnableRc && pSvcParam.iTargetBitrate <= 0) {
|
||||
fprintf (stderr, "Invalid target bitrate setting due to RC enabled. Check TargetBitrate field please!\n");
|
||||
@ -238,33 +215,25 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
iLeftTargetBitrate = pSvcParam.iTargetBitrate;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableDenoise") == 0){
|
||||
} else if (strTag[0].compare ("EnableDenoise") == 0) {
|
||||
pSvcParam.bEnableDenoise = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableSceneChangeDetection") == 0){
|
||||
} else if (strTag[0].compare ("EnableSceneChangeDetection") == 0) {
|
||||
pSvcParam.bEnableSceneChangeDetect = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableBackgroundDetection") == 0)
|
||||
{
|
||||
} else if (strTag[0].compare ("EnableBackgroundDetection") == 0) {
|
||||
pSvcParam.bEnableBackgroundDetection = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableAdaptiveQuantization") == 0){
|
||||
} else if (strTag[0].compare ("EnableAdaptiveQuantization") == 0) {
|
||||
pSvcParam.bEnableAdaptiveQuant = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("EnableLongTermReference") == 0){
|
||||
} else if (strTag[0].compare ("EnableLongTermReference") == 0) {
|
||||
pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("LtrMarkPeriod") == 0){
|
||||
} else if (strTag[0].compare ("LtrMarkPeriod") == 0) {
|
||||
pSvcParam.uiLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("NumLayers") == 0){
|
||||
} else if (strTag[0].compare ("NumLayers") == 0) {
|
||||
pSvcParam.iNumDependencyLayer = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iNumDependencyLayer > MAX_DEPENDENCY_LAYER || pSvcParam.iNumDependencyLayer <= 0) {
|
||||
fprintf (stderr, "Invalid parameter in iNumDependencyLayer: %d.\n", pSvcParam.iNumDependencyLayer);
|
||||
@ -272,15 +241,13 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("LayerCfg") == 0){
|
||||
} else if (strTag[0].compare ("LayerCfg") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.sSpatialLayers[iLayerCount].strLayerCfgFile = strTag[1];
|
||||
// pSvcParam.sDependencyLayers[iLayerCount].uiDependencyId = iLayerCount;
|
||||
++ iLayerCount;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("PrefixNALAddingCtrl") == 0){
|
||||
} else if (strTag[0].compare ("PrefixNALAddingCtrl") == 0) {
|
||||
int ctrl_flag = atoi (strTag[1].c_str());
|
||||
if (ctrl_flag > 1)
|
||||
ctrl_flag = 1;
|
||||
@ -293,7 +260,8 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
}
|
||||
|
||||
const int8_t kiActualLayerNum = WELS_MIN (pSvcParam.iNumDependencyLayer, iLayerCount);
|
||||
if (pSvcParam.iNumDependencyLayer > kiActualLayerNum){ // fixed number of dependency layer due to parameter error in settings
|
||||
if (pSvcParam.iNumDependencyLayer >
|
||||
kiActualLayerNum) { // fixed number of dependency layer due to parameter error in settings
|
||||
pSvcParam.iNumDependencyLayer = kiActualLayerNum;
|
||||
}
|
||||
|
||||
@ -324,26 +292,21 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
pDLayer->iFrameWidth = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualWidth = pDLayer->iFrameWidth;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("SourceHeight") == 0){
|
||||
} else if (strTag[0].compare ("SourceHeight") == 0) {
|
||||
pDLayer->iFrameHeight = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualHeight = pDLayer->iFrameHeight;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FrameRateIn") == 0){
|
||||
} else if (strTag[0].compare ("FrameRateIn") == 0) {
|
||||
pDLayer->fInputFrameRate = (float)atof (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FrameRateOut") == 0){
|
||||
} else if (strTag[0].compare ("FrameRateOut") == 0) {
|
||||
pDLayer->fOutputFrameRate = (float)atof (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("InputFile") == 0){
|
||||
} else if (strTag[0].compare ("InputFile") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.sSpatialLayers[iLayer].strSeqFile = strTag[1];
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("ReconFile") == 0){
|
||||
} else if (strTag[0].compare ("ReconFile") == 0) {
|
||||
const int kiLen = strTag[1].length();
|
||||
if (kiLen >= MAX_FNAME_LEN)
|
||||
return 1;
|
||||
@ -352,12 +315,10 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
strncpy (pDLayer->sRecFileName, strTag[1].c_str(), kiLen); // confirmed_safe_unsafe_usage
|
||||
#endif//ENABLE_FRAME_DUMP
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("ProfileIdc") == 0){
|
||||
} else if (strTag[0].compare ("ProfileIdc") == 0) {
|
||||
pDLayer->uiProfileIdc = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FRExt") == 0){
|
||||
} else if (strTag[0].compare ("FRExt") == 0) {
|
||||
// pDLayer->frext_mode = (bool_t)atoi(strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
@ -369,7 +330,8 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
return 1;
|
||||
}
|
||||
if (pSvcParam.bEnableRc && pDLayer->iSpatialBitrate > iLeftTargetBitrate) {
|
||||
fprintf(stderr, "Invalid spatial(#%d) bitrate(%d) setting due to unavailable left(%d)!\n", iLayer, pDLayer->iSpatialBitrate, iLeftTargetBitrate);
|
||||
fprintf (stderr, "Invalid spatial(#%d) bitrate(%d) setting due to unavailable left(%d)!\n", iLayer,
|
||||
pDLayer->iSpatialBitrate, iLeftTargetBitrate);
|
||||
return 1;
|
||||
}
|
||||
iLeftSpatialBitrate[iLayer] = pDLayer->iSpatialBitrate;
|
||||
@ -382,17 +344,13 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
if (strTag[0].compare ("SliceMode") == 0) {
|
||||
sLayerCtx.sMso.uiSliceMode = (SliceMode)atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("SliceSize") == 0){//SM_DYN_SLICE
|
||||
} else if (strTag[0].compare ("SliceSize") == 0) { //SM_DYN_SLICE
|
||||
sLayerCtx.sMso.sSliceArgument.uiSliceSizeConstraint = (SliceMode)atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("SliceNum") == 0){
|
||||
} else if (strTag[0].compare ("SliceNum") == 0) {
|
||||
sLayerCtx.sMso.sSliceArgument.iSliceNum = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if ( strTag[0].compare(0, kiSize, str_ ) == 0 )
|
||||
{
|
||||
} else if (strTag[0].compare (0, kiSize, str_) == 0) {
|
||||
const char* kpString = strTag[0].c_str();
|
||||
int uiSliceIdx = atoi (&kpString[kiSize]);
|
||||
assert (uiSliceIdx < MAX_SLICES_NUM);
|
||||
@ -405,22 +363,21 @@ int ParseConfig(CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
pDLayer->sMso.uiSliceMode = sLayerCtx.sMso.uiSliceMode;
|
||||
|
||||
memcpy (&pDLayer->sMso, &sLayerCtx.sMso, sizeof (SMulSliceOption)); // confirmed_safe_unsafe_usage
|
||||
memcpy( &pDLayer->sMso.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[0], sizeof(sLayerCtx.sMso.sSliceArgument.uiSliceMbNum) ); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sMso.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[0],
|
||||
sizeof (sLayerCtx.sMso.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int ParseCommandLine( int argc, char ** argv, SVCEncodingParam & sParam)
|
||||
{
|
||||
int ParseCommandLine (int argc, char** argv, SVCEncodingParam& sParam) {
|
||||
char* pCmd;
|
||||
int i = 0;
|
||||
|
||||
if (argc <= 0) // no additional pCmd parameters
|
||||
return 0;
|
||||
|
||||
while ( i < argc )
|
||||
{
|
||||
while (i < argc) {
|
||||
pCmd = argv[i];
|
||||
|
||||
if (!strcmp (pCmd, "-numl")) { // confirmed_safe_unsafe_usage
|
||||
@ -435,13 +392,11 @@ int ParseCommandLine( int argc, char ** argv, SVCEncodingParam & sParam)
|
||||
int iPeriod = atoi (argv[i + 1]);
|
||||
sParam.iIntraPeriod = iPeriod;
|
||||
i += 2;
|
||||
}
|
||||
else if( !strcmp(pCmd,"-spsid") ) { // confirmed_safe_unsafe_usage
|
||||
} else if (!strcmp (pCmd, "-spsid")) { // confirmed_safe_unsafe_usage
|
||||
int iSpsPpsId = atoi (argv[i + 1]);
|
||||
sParam.bEnableSpsPpsIdAddition = iSpsPpsId ? true : false;
|
||||
i += 2;
|
||||
}
|
||||
else if( !strcmp(pCmd,"-denois") ) { // confirmed_safe_unsafe_usage
|
||||
} else if (!strcmp (pCmd, "-denois")) { // confirmed_safe_unsafe_usage
|
||||
int iDenois = atoi (argv[i + 1]);
|
||||
sParam.bEnableDenoise = iDenois ? true : false;
|
||||
i += 2;
|
||||
@ -469,8 +424,7 @@ int ParseCommandLine( int argc, char ** argv, SVCEncodingParam & sParam)
|
||||
int iTarB = atoi (argv[i + 1]);
|
||||
sParam.iTargetBitrate = iTarB;
|
||||
i += 2;
|
||||
} else if( !strcmp(pCmd,"-ltarb") ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
} else if (!strcmp (pCmd, "-ltarb")) { // confirmed_safe_unsafe_usage
|
||||
int iLayer = atoi (argv[i + 1]);
|
||||
int iSpatialBitrate = atoi (argv[i + 2]);
|
||||
sParam.sSpatialLayers[iLayer].iSpatialBitrate = iSpatialBitrate;
|
||||
@ -479,18 +433,15 @@ int ParseCommandLine( int argc, char ** argv, SVCEncodingParam & sParam)
|
||||
int32_t iLog = atoi (argv[i + 1]);
|
||||
WelsStderrSetTraceLevel (iLog);
|
||||
i += 2;
|
||||
} else if( !strcmp(pCmd,"-sw") )
|
||||
{
|
||||
} else if (!strcmp (pCmd, "-sw")) {
|
||||
int iWidth = atoi (argv[i + 1]);
|
||||
sParam.iPicWidth = iWidth;
|
||||
i += 2;
|
||||
} else if( !strcmp(pCmd,"-sh") )
|
||||
{
|
||||
} else if (!strcmp (pCmd, "-sh")) {
|
||||
int iHeight = atoi (argv[i + 1]);
|
||||
sParam.iPicHeight = iHeight;
|
||||
i += 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
@ -498,8 +449,7 @@ int ParseCommandLine( int argc, char ** argv, SVCEncodingParam & sParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PrintHelp()
|
||||
{
|
||||
void PrintHelp() {
|
||||
printf ("\n Wels SVC Encoder Usage:\n\n");
|
||||
printf (" Syntax: welsenc.exe welsenc.cfg\n");
|
||||
printf (" Syntax: welsenc.exe welsenc.cfg [options]\n");
|
||||
@ -532,8 +482,7 @@ void PrintHelp()
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFilesSet& sFileSet)
|
||||
{
|
||||
int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFilesSet& sFileSet) {
|
||||
char* pCommand = NULL;
|
||||
char* pTemp = NULL;
|
||||
unsigned int uiQpChangeFlag[4] = {0};
|
||||
@ -546,98 +495,81 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
if (argc <= 0) // no additional pCmd parameters
|
||||
return 0;
|
||||
|
||||
while(n < argc)
|
||||
{
|
||||
while (n < argc) {
|
||||
pCommand = argv[n++];
|
||||
if (!(strcmp(pCommand,"-h"))) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-h"))) { // confirmed_safe_unsafe_usage
|
||||
PrintHelp();
|
||||
continue;
|
||||
}
|
||||
if (!(strcmp(pCommand,"-bf"))) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-bf"))) { // confirmed_safe_unsafe_usage
|
||||
sFileSet.strBsFile.assign (argv[n]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-frms")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-frms"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.uiFrameToBeCoded = atoi (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-gop")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-gop"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.uiGopSize = atoi (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-iper")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-iper"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.uiIntraPeriod = atoi (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-spsid")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-spsid"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableSpsPpsIdAddition = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-denois")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-denois"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableDenoise = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-scene")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-scene"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableSceneChangeDetect = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if ( !(strcmp(pCommand,"-bgd")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-bgd"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableBackgroundDetection = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-aq")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-aq"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableAdaptiveQuant = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-ltr")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-ltr"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableLongTermReference = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-ltrper")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-ltrper"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.uiLtrMarkPeriod = atoi (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-rc")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-rc"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.bEnableRc = atoi (argv[n ]) ? true : false;
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-tarb")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-tarb"))) { // confirmed_safe_unsafe_usage
|
||||
pSvcParam.iTargetBitrate = atoi (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-numl")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-numl"))) { // confirmed_safe_unsafe_usage
|
||||
bool_t bFound = false;
|
||||
pSvcParam.iNumDependencyLayer = atoi (argv[n++]);
|
||||
for (int ln = 0 ; ln < pSvcParam.iNumDependencyLayer ; ln++)
|
||||
{
|
||||
for (int ln = 0 ; ln < pSvcParam.iNumDependencyLayer ; ln++) {
|
||||
// pSvcParam.sDependencyLayers[ln].uiDependencyId = ln;
|
||||
sFileSet.sSpatialLayers[ln].strLayerCfgFile.assign (argv[n]);
|
||||
++ n;
|
||||
@ -669,26 +601,21 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
pDLayer->iFrameWidth = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualWidth = pDLayer->iFrameWidth;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("SourceHeight") == 0){
|
||||
} else if (strTag[0].compare ("SourceHeight") == 0) {
|
||||
pDLayer->iFrameHeight = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualHeight = pDLayer->iFrameHeight;
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FrameRateIn") == 0){
|
||||
} else if (strTag[0].compare ("FrameRateIn") == 0) {
|
||||
pDLayer->fInputFrameRate = (float)atof (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FrameRateOut") == 0){
|
||||
} else if (strTag[0].compare ("FrameRateOut") == 0) {
|
||||
pDLayer->fOutputFrameRate = (float)atof (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("InputFile") == 0){
|
||||
} else if (strTag[0].compare ("InputFile") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.sSpatialLayers[iLayer].strSeqFile = strTag[1];
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("ReconFile") == 0){
|
||||
} else if (strTag[0].compare ("ReconFile") == 0) {
|
||||
#ifdef ENABLE_FRAME_DUMP
|
||||
const int kiLen = strTag[1].length();
|
||||
if (kiLen >= MAX_FNAME_LEN)
|
||||
@ -697,12 +624,10 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
strncpy (pDLayer->sRecFileName, strTag[1].c_str(), kiLen); // confirmed_safe_unsafe_usage
|
||||
#endif//ENABLE_FRAME_DUMP
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("ProfileIdc") == 0){
|
||||
} else if (strTag[0].compare ("ProfileIdc") == 0) {
|
||||
pDLayer->uiProfileIdc = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("FRExt") == 0){
|
||||
} else if (strTag[0].compare ("FRExt") == 0) {
|
||||
// pDLayer->frext_mode = (bool_t)atoi(strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
@ -719,17 +644,13 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
if (strTag[0].compare ("SliceMode") == 0) {
|
||||
sLayerCtx.sMso.uiSliceMode = (SliceMode)atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("SliceSize") == 0){//SM_DYN_SLICE
|
||||
} else if (strTag[0].compare ("SliceSize") == 0) { //SM_DYN_SLICE
|
||||
sLayerCtx.sMso.sSliceArgument.uiSliceSizeConstraint = (SliceMode)atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if (strTag[0].compare("SliceNum") == 0){
|
||||
} else if (strTag[0].compare ("SliceNum") == 0) {
|
||||
sLayerCtx.sMso.sSliceArgument.iSliceNum = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
}
|
||||
else if ( strTag[0].compare(0, kiSize, str_ ) == 0 )
|
||||
{
|
||||
} else if (strTag[0].compare (0, kiSize, str_) == 0) {
|
||||
const char* kpString = strTag[0].c_str();
|
||||
int uiSliceIdx = atoi (&kpString[kiSize]);
|
||||
assert (uiSliceIdx < MAX_SLICES_NUM);
|
||||
@ -741,21 +662,20 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
pDLayer->iDLayerQp = sLayerCtx.iDLayerQp;
|
||||
pDLayer->sMso.uiSliceMode = sLayerCtx.sMso.uiSliceMode;
|
||||
memcpy (&pDLayer->sMso, &sLayerCtx.sMso, sizeof (SMulSliceOption)); // confirmed_safe_unsafe_usage
|
||||
memcpy( &pDLayer->sMso.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[0], sizeof(sLayerCtx.sMso.sSliceArgument.uiSliceMbNum) ); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sMso.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[0],
|
||||
sizeof (sLayerCtx.sMso.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
|
||||
|
||||
}
|
||||
//n += 1;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-org")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-org"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
sFileSet.sSpatialLayers[iLayer].strSeqFile.assign (argv[n]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-drec")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-drec"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
const int iLen = strlen (argv[n]); // confirmed_safe_unsafe_usage
|
||||
#ifdef ENABLE_FRAME_DUMP
|
||||
@ -766,8 +686,7 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-sw")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-sw"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->iFrameWidth = atoi (argv[n ]);
|
||||
@ -775,8 +694,7 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-sh")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-sh"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->iFrameHeight = atoi (argv[n ]);
|
||||
@ -784,16 +702,14 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-frin")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-frin"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->fInputFrameRate = (float)atof (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-frout")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-frout"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->fOutputFrameRate = (float)atof (argv[n ]);
|
||||
@ -801,8 +717,7 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !(strcmp(pCommand,"-lqp")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-lqp"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
uiQpChangeFlag[iLayer] = 1;
|
||||
@ -812,8 +727,7 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
}
|
||||
//sLayerCtx[iLayer].num_quality_layers = pDLayer->num_quality_layers = 1;
|
||||
|
||||
if( !(strcmp(pCommand,"-ltarb")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-ltarb"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->iSpatialBitrate = 1000 * atoi (argv[n ]);
|
||||
@ -821,13 +735,11 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !(strcmp(pCommand,"-slcmd")) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-slcmd"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
|
||||
switch ( atoi(argv[n] ) )
|
||||
{
|
||||
switch (atoi (argv[n])) {
|
||||
case 0:
|
||||
pDLayer->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
break;
|
||||
@ -850,16 +762,14 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-slcsize")) )//confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-slcsize"))) { //confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->sMso.sSliceArgument.uiSliceSizeConstraint = atoi (argv[n ]);
|
||||
++ n;
|
||||
continue;
|
||||
}
|
||||
if( !(strcmp(pCommand,"-slcnum")) )// confirmed_safe_unsafe_usage
|
||||
{
|
||||
if (! (strcmp (pCommand, "-slcnum"))) { // confirmed_safe_unsafe_usage
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->sMso.sSliceArgument.iSliceNum = atoi (argv[n ]);
|
||||
@ -872,8 +782,7 @@ int ParseCommandLine(int argc, char** argv, SWelsSvcCodingParam & pSvcParam, SFi
|
||||
|
||||
|
||||
|
||||
int FillSpecificParameters( SVCEncodingParam &sParam )
|
||||
{
|
||||
int FillSpecificParameters (SVCEncodingParam& sParam) {
|
||||
/* Test for temporal, spatial, SNR scalability */
|
||||
sParam.fFrameRate = 30.0f; // input frame rate
|
||||
sParam.iPicWidth = 1280; // width of picture in samples
|
||||
@ -956,8 +865,7 @@ int FillSpecificParameters( SVCEncodingParam &sParam )
|
||||
#endif
|
||||
|
||||
float fMaxFr = sParam.sSpatialLayers[sParam.iSpatialLayerNum - 1].fFrameRate;
|
||||
for (int32_t i = sParam.iSpatialLayerNum-2; i >= 0; -- i)
|
||||
{
|
||||
for (int32_t i = sParam.iSpatialLayerNum - 2; i >= 0; -- i) {
|
||||
if (sParam.sSpatialLayers[i].fFrameRate > fMaxFr + EPSN)
|
||||
fMaxFr = sParam.sSpatialLayers[i].fFrameRate;
|
||||
}
|
||||
@ -967,8 +875,7 @@ int FillSpecificParameters( SVCEncodingParam &sParam )
|
||||
}
|
||||
|
||||
/* For SVC Demo test */
|
||||
int ProcessEncodingSvcWithParam ( ISVCEncoder *pPtrEnc, int argc, char ** argv )
|
||||
{
|
||||
int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
const char* kpSrcFile = argv[1];
|
||||
const char* kpStrBsFile = argv[2];
|
||||
|
||||
@ -1000,14 +907,12 @@ int ProcessEncodingSvcWithParam ( ISVCEncoder *pPtrEnc, int argc, char ** argv )
|
||||
FillSpecificParameters (sSvcParam);
|
||||
|
||||
int iParsedNum = 3;
|
||||
if( ParseCommandLine(argc-iParsedNum, argv+iParsedNum, sSvcParam) != 0 )
|
||||
{
|
||||
if (ParseCommandLine (argc - iParsedNum, argv + iParsedNum, sSvcParam) != 0) {
|
||||
printf ("parse pCommand line failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( cmResultSuccess != pPtrEnc->Initialize( &sSvcParam, INIT_TYPE_PARAMETER_BASED ) )
|
||||
{
|
||||
if (cmResultSuccess != pPtrEnc->Initialize (&sSvcParam, INIT_TYPE_PARAMETER_BASED)) {
|
||||
fprintf (stderr, "Encoder Initialization failed!\n");
|
||||
return 1;
|
||||
}
|
||||
@ -1051,8 +956,7 @@ int ProcessEncodingSvcWithParam ( ISVCEncoder *pPtrEnc, int argc, char ** argv )
|
||||
}
|
||||
|
||||
int32_t iFrame = 0;
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
if (feof (pFpSrc))
|
||||
break;
|
||||
#ifdef ONLY_ENC_FRAMES_NUM
|
||||
@ -1095,8 +999,7 @@ int ProcessEncodingSvcWithParam ( ISVCEncoder *pPtrEnc, int argc, char ** argv )
|
||||
printf ("Frames: %d\nencode time: %f sec\nFPS: %f fps\n", iFrame, dElapsed, (iFrame * 1.0) / dElapsed);
|
||||
}
|
||||
|
||||
if ( NULL != pPlanes[0] )
|
||||
{
|
||||
if (NULL != pPlanes[0]) {
|
||||
delete [] pPlanes[0];
|
||||
pPlanes[0] = NULL;
|
||||
}
|
||||
@ -1114,8 +1017,7 @@ int ProcessEncodingSvcWithParam ( ISVCEncoder *pPtrEnc, int argc, char ** argv )
|
||||
}
|
||||
|
||||
|
||||
int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
{
|
||||
int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
int iRet = 0;
|
||||
|
||||
if (pPtrEnc == NULL)
|
||||
@ -1159,7 +1061,8 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
// for configuration file
|
||||
cRdCfg.Openf (argv[1]);
|
||||
if (!cRdCfg.ExistFile()) {
|
||||
fprintf(stderr, "Specified file: %s not exist, maybe invalid path or parameter settting.\n", cRdCfg.GetFileName().c_str());
|
||||
fprintf (stderr, "Specified file: %s not exist, maybe invalid path or parameter settting.\n",
|
||||
cRdCfg.GetFileName().c_str());
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
}
|
||||
@ -1171,8 +1074,7 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
goto INSIDE_MEM_FREE;
|
||||
}
|
||||
|
||||
if ( ParseCommandLine(argc-iParsedNum, argv+iParsedNum, sSvcParam, fs) != 0 )
|
||||
{
|
||||
if (ParseCommandLine (argc - iParsedNum, argv + iParsedNum, sSvcParam, fs) != 0) {
|
||||
printf ("parse pCommand line failed\n");
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
@ -1188,8 +1090,7 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
sSvcParam.iActualPicHeight =
|
||||
sSvcParam.SUsedPicRect.iHeight = sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameHeight;
|
||||
|
||||
if ( cmResultSuccess != pPtrEnc->Initialize((void *)&sSvcParam, INIT_TYPE_CONFIG_BASED) ) // SVC encoder initialization
|
||||
{
|
||||
if (cmResultSuccess != pPtrEnc->Initialize ((void*)&sSvcParam, INIT_TYPE_CONFIG_BASED)) { // SVC encoder initialization
|
||||
fprintf (stderr, "SVC encoder Initialize failed\n");
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
@ -1208,8 +1109,7 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
|
||||
#if defined(COMPARE_DATA)
|
||||
//For getting the golden file handle
|
||||
if((fpGolden = fopen(argv[3], "rb")) == NULL)
|
||||
{
|
||||
if ((fpGolden = fopen (argv[3], "rb")) == NULL) {
|
||||
fprintf (stderr, "Unable to open golden sequence file, check corresponding path!\n");
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
@ -1228,8 +1128,7 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
memset (pSrcPic, 0, sizeof (SSourcePicture));
|
||||
|
||||
pYUV[iDlayerIdx] = new uint8_t [ (3 * kiPicResSize) >> 1];
|
||||
if (pYUV[iDlayerIdx] == NULL)
|
||||
{
|
||||
if (pYUV[iDlayerIdx] == NULL) {
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
}
|
||||
@ -1244,15 +1143,14 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
|
||||
pFileYUV[iDlayerIdx] = fopen (fs.sSpatialLayers[iDlayerIdx].strSeqFile.c_str(), "rb");
|
||||
if (pFileYUV[iDlayerIdx] != NULL) {
|
||||
if( !fseek( pFileYUV[iDlayerIdx], 0, SEEK_END ) )
|
||||
{
|
||||
if (!fseek (pFileYUV[iDlayerIdx], 0, SEEK_END)) {
|
||||
int64_t i_size = ftell (pFileYUV[iDlayerIdx]);
|
||||
fseek (pFileYUV[iDlayerIdx], 0, SEEK_SET);
|
||||
iTotalFrameMax = WELS_MAX ((int32_t) (i_size / ((3 * kiPicResSize) >> 1)), iTotalFrameMax);
|
||||
}
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "Unable to open source sequence file (%s), check corresponding path!\n", fs.sSpatialLayers[iDlayerIdx].strSeqFile.c_str());
|
||||
} else {
|
||||
fprintf (stderr, "Unable to open source sequence file (%s), check corresponding path!\n",
|
||||
fs.sSpatialLayers[iDlayerIdx].strSeqFile.c_str());
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
}
|
||||
@ -1261,14 +1159,14 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
}
|
||||
|
||||
iFrameIdx = 0;
|
||||
while (iFrameIdx < iTotalFrameMax && (((int32_t)sSvcParam.uiFrameToBeCoded <= 0) || (iFrameIdx < (int32_t)sSvcParam.uiFrameToBeCoded)) ) {
|
||||
while (iFrameIdx < iTotalFrameMax && (((int32_t)sSvcParam.uiFrameToBeCoded <= 0)
|
||||
|| (iFrameIdx < (int32_t)sSvcParam.uiFrameToBeCoded))) {
|
||||
bool_t bOnePicAvailableAtLeast = false;
|
||||
bool_t bSomeSpatialUnavailable = false;
|
||||
|
||||
#ifdef ONLY_ENC_FRAMES_NUM
|
||||
// Only encoded some limited frames here
|
||||
if ( iActualFrameEncodedCount >= ONLY_ENC_FRAMES_NUM )
|
||||
{
|
||||
if (iActualFrameEncodedCount >= ONLY_ENC_FRAMES_NUM) {
|
||||
break;
|
||||
}
|
||||
#endif//ONLY_ENC_FRAMES_NUM
|
||||
@ -1282,12 +1180,10 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
|
||||
bool_t bCanBeRead = false;
|
||||
|
||||
if ( iFrameIdx % uiSkipIdx == 0 ) // such layer is enabled to encode indeed
|
||||
{
|
||||
if (iFrameIdx % uiSkipIdx == 0) { // such layer is enabled to encode indeed
|
||||
bCanBeRead = (fread (pYUV[iDlayerIdx], 1, kiPicResSize, pFileYUV[iDlayerIdx]) == kiPicResSize);
|
||||
|
||||
if ( bCanBeRead )
|
||||
{
|
||||
if (bCanBeRead) {
|
||||
bOnePicAvailableAtLeast = true;
|
||||
|
||||
pSrcPicList[nSpatialLayerNum]->pData[0] = pYUV[iDlayerIdx];
|
||||
@ -1303,15 +1199,11 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
= pDLayer->iFrameWidth >> 1;
|
||||
|
||||
++ nSpatialLayerNum;
|
||||
}
|
||||
else // file end while reading
|
||||
{
|
||||
} else { // file end while reading
|
||||
bSomeSpatialUnavailable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
@ -1332,13 +1224,11 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
iTotal += WelsTime() - iStart;
|
||||
|
||||
// fixed issue in case dismatch source picture introduced by frame skipped, 1/12/2010
|
||||
if ( videoFrameTypeSkip == iEncFrames )
|
||||
{
|
||||
if (videoFrameTypeSkip == iEncFrames) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( iEncFrames != videoFrameTypeInvalid && iEncFrames != videoFrameTypeSkip )
|
||||
{
|
||||
if (iEncFrames != videoFrameTypeInvalid && iEncFrames != videoFrameTypeSkip) {
|
||||
int iLayer = 0;
|
||||
int iFrameSize = 0;
|
||||
while (iLayer < sFbi.iLayerNum) {
|
||||
@ -1382,8 +1272,7 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
}
|
||||
#endif//STICK_STREAM_SIZE
|
||||
++ iActualFrameEncodedCount; // excluding skipped frame time
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
fprintf (stderr, "EncodeFrame(), ret: %d, frame index: %d.\n", iEncFrames, iFrameIdx);
|
||||
}
|
||||
|
||||
@ -1397,11 +1286,9 @@ int ProcessEncodingSvcWithConfig ( ISVCEncoder *pPtrEnc, int argc, char **argv )
|
||||
iActualFrameEncodedCount, dElapsed, (iActualFrameEncodedCount * 1.0) / dElapsed);
|
||||
}
|
||||
|
||||
INSIDE_MEM_FREE:
|
||||
{
|
||||
INSIDE_MEM_FREE: {
|
||||
#if (defined(RUN_SIMULATOR) || defined(WIN32)||defined(_MACH_PLATFORM) || (defined(__GNUC__)))
|
||||
if (pFpBs)
|
||||
{
|
||||
if (pFpBs) {
|
||||
fclose (pFpBs);
|
||||
pFpBs = NULL;
|
||||
}
|
||||
@ -1420,8 +1307,7 @@ INSIDE_MEM_FREE:
|
||||
#endif
|
||||
// Destruction memory introduced in this routine
|
||||
iDlayerIdx = 0;
|
||||
while (iDlayerIdx < sSvcParam.iNumDependencyLayer)
|
||||
{
|
||||
while (iDlayerIdx < sSvcParam.iNumDependencyLayer) {
|
||||
if (pFileYUV[iDlayerIdx] != NULL) {
|
||||
fclose (pFileYUV[iDlayerIdx]);
|
||||
pFileYUV[iDlayerIdx] = NULL;
|
||||
@ -1430,8 +1316,7 @@ INSIDE_MEM_FREE:
|
||||
}
|
||||
|
||||
if (pSrcPicList) {
|
||||
for( int32_t i=0;i<sSvcParam.iNumDependencyLayer;i++ )
|
||||
{
|
||||
for (int32_t i = 0; i < sSvcParam.iNumDependencyLayer; i++) {
|
||||
if (pSrcPicList[i]) {
|
||||
delete pSrcPicList[i];
|
||||
pSrcPicList[i] = NULL;
|
||||
@ -1453,23 +1338,18 @@ INSIDE_MEM_FREE:
|
||||
}
|
||||
|
||||
// Merge from Heifei's Wonder. Lock process to a single core
|
||||
void LockToSingleCore()
|
||||
{
|
||||
void LockToSingleCore() {
|
||||
#ifdef _MSC_VER
|
||||
//for 2005 compiler, change "DWORD" to "DWORD_PTR"
|
||||
DWORD ProcessAffMask = 0, SystemAffMask = 0;
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
GetProcessAffinityMask (hProcess, &ProcessAffMask, &SystemAffMask);
|
||||
if (ProcessAffMask > 1)
|
||||
{
|
||||
if (ProcessAffMask > 1) {
|
||||
// more than one CPU core available. Fix to only one:
|
||||
if (ProcessAffMask & 2)
|
||||
{
|
||||
if (ProcessAffMask & 2) {
|
||||
ProcessAffMask = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ProcessAffMask = 1;
|
||||
}
|
||||
// Lock process to a single CPU core
|
||||
@ -1482,8 +1362,7 @@ void LockToSingleCore()
|
||||
return ;
|
||||
}
|
||||
|
||||
long CreateSVCEncHandle(ISVCEncoder** ppEncoder)
|
||||
{
|
||||
long CreateSVCEncHandle (ISVCEncoder** ppEncoder) {
|
||||
long ret = 0;
|
||||
#if defined(MACOS)
|
||||
ret = WelsEncBundleLoad();
|
||||
@ -1494,10 +1373,8 @@ long CreateSVCEncHandle(ISVCEncoder** ppEncoder)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DestroySVCEncHanlde(ISVCEncoder* pEncoder)
|
||||
{
|
||||
if (pEncoder)
|
||||
{
|
||||
void DestroySVCEncHanlde (ISVCEncoder* pEncoder) {
|
||||
if (pEncoder) {
|
||||
#if defined(MACOS)
|
||||
WelsEncBundleDestroyEncoder (pEncoder);
|
||||
#else
|
||||
@ -1533,38 +1410,28 @@ int main( int argc, char **argv )
|
||||
signal (SIGINT, SigIntHandler);
|
||||
|
||||
iRet = CreateSVCEncHandle (&pSVCEncoder);
|
||||
if ( iRet )
|
||||
{
|
||||
if (iRet) {
|
||||
cout << "CreateSVCEncoder() failed!!" << endl;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
if (argc < 2) {
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
string strCfgFileName = argv[1];
|
||||
basic_string <char>::size_type index;
|
||||
static const basic_string <char>::size_type npos = size_t (-1);
|
||||
index = strCfgFileName.rfind (".cfg"); // check configuration type (like .cfg?)
|
||||
if ( index == npos )
|
||||
{
|
||||
if (argc > 2)
|
||||
{
|
||||
if (index == npos) {
|
||||
if (argc > 2) {
|
||||
iRet = ProcessEncodingSvcWithParam (pSVCEncoder, argc, argv);
|
||||
if (iRet != 0)
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cout << "You specified pCommand is invalid!!" << endl;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iRet = ProcessEncodingSvcWithConfig (pSVCEncoder, argc, argv);
|
||||
if (iRet > 0)
|
||||
goto exit;
|
||||
|
@ -83,7 +83,8 @@ uint8_t* DetectStartCodePrefix( const uint8_t *kpBuf, int32_t *pOffset, int32_t
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeader, uint8_t *pSrcRbsp, int32_t iSrcRbspLen, uint8_t *pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes );
|
||||
uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeader, uint8_t* pSrcRbsp,
|
||||
int32_t iSrcRbspLen, uint8_t* pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes);
|
||||
|
||||
int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen);
|
||||
|
||||
@ -92,7 +93,8 @@ void_t ParseRefBasePicMarking ( PBitStringAux pBs, PRefBasePicMarking pRefBasePi
|
||||
void_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs);
|
||||
|
||||
bool_t CheckAccessUnitBoundary (const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps);
|
||||
bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt, PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader );
|
||||
bool_t CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
|
||||
PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader);
|
||||
/*!
|
||||
*************************************************************************************
|
||||
* \brief to parse Sequence Parameter Set (SPS)
|
||||
|
@ -94,10 +94,12 @@ void_t DeblockLumaEq4V_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32
|
||||
void_t DeblockLumaLt4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
|
||||
void_t DeblockLumaEq4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void_t DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
|
||||
void_t DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc);
|
||||
void_t DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void_t DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
|
||||
void_t DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc);
|
||||
void_t DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@ -112,9 +114,11 @@ void DeblockLumaTransposeV2H_sse2(uint8_t * pPixY, int32_t iStride, uint8_t * pS
|
||||
void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
|
||||
void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaEq4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaLt4V_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
|
||||
void DeblockChromaLt4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
void DeblockChromaEq4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaLt4H_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
|
||||
void DeblockChromaLt4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -65,16 +65,13 @@ namespace WelsDec {
|
||||
NEED_BITS(iCurBits, pBufPtr, iLeftBits); \
|
||||
}
|
||||
|
||||
static inline int32_t ShowBits( PBitStringAux pBs, int32_t iNumBits )
|
||||
{
|
||||
static inline int32_t ShowBits (PBitStringAux pBs, int32_t iNumBits) {
|
||||
return UBITS (pBs->uiCurBits, iNumBits);
|
||||
}
|
||||
static inline void_t FlushBits( PBitStringAux pBs, int32_t iNumBits )
|
||||
{
|
||||
static inline void_t FlushBits (PBitStringAux pBs, int32_t iNumBits) {
|
||||
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iNumBits);
|
||||
}
|
||||
static inline int32_t BsGetBits( PBitStringAux pBs, int32_t iNumBits )
|
||||
{
|
||||
static inline int32_t BsGetBits (PBitStringAux pBs, int32_t iNumBits) {
|
||||
int32_t iRc = UBITS (pBs->uiCurBits, iNumBits);
|
||||
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iNumBits);
|
||||
return iRc;
|
||||
@ -90,29 +87,24 @@ extern const uint8_t g_kuiInterCbpTable[48];
|
||||
|
||||
extern const uint8_t g_kuiLeadingZeroTable[256];
|
||||
|
||||
static const uint32_t g_kuiPrefix8BitsTable[16] =
|
||||
{
|
||||
static const uint32_t g_kuiPrefix8BitsTable[16] = {
|
||||
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
|
||||
};
|
||||
|
||||
|
||||
static inline uint32_t GetPrefixBits(uint32_t uiValue)
|
||||
{
|
||||
static inline uint32_t GetPrefixBits (uint32_t uiValue) {
|
||||
uint32_t iNumBit = 0;
|
||||
|
||||
if (uiValue & 0xffff0000)
|
||||
{
|
||||
if (uiValue & 0xffff0000) {
|
||||
uiValue >>= 16;
|
||||
iNumBit += 16;
|
||||
}
|
||||
if (uiValue & 0xff00)
|
||||
{
|
||||
if (uiValue & 0xff00) {
|
||||
uiValue >>= 8;
|
||||
iNumBit += 8;
|
||||
}
|
||||
|
||||
if (uiValue & 0xf0)
|
||||
{
|
||||
if (uiValue & 0xf0) {
|
||||
uiValue >>= 4;
|
||||
iNumBit += 4;
|
||||
}
|
||||
@ -124,24 +116,20 @@ static inline uint32_t GetPrefixBits(uint32_t uiValue)
|
||||
/*
|
||||
* Read one bit from bit stream followed
|
||||
*/
|
||||
static inline uint32_t BsGetOneBit(PBitStringAux pBs)
|
||||
{
|
||||
static inline uint32_t BsGetOneBit (PBitStringAux pBs) {
|
||||
return (BsGetBits (pBs, 1));
|
||||
}
|
||||
|
||||
static inline int32_t GetLeadingZeroBits( uint32_t iCurBits ) //<=16 bits
|
||||
{
|
||||
static inline int32_t GetLeadingZeroBits (uint32_t iCurBits) { //<=16 bits
|
||||
int32_t iValue;
|
||||
|
||||
iValue = UBITS (iCurBits, 8); //ShowBits( bs, 8 );
|
||||
if( iValue )
|
||||
{
|
||||
if (iValue) {
|
||||
return g_kuiLeadingZeroTable[iValue];
|
||||
}
|
||||
|
||||
iValue = UBITS (iCurBits, 16); //ShowBits( bs, 16 );
|
||||
if( iValue )
|
||||
{
|
||||
if (iValue) {
|
||||
return (g_kuiLeadingZeroTable[iValue] + 8);
|
||||
}
|
||||
|
||||
@ -149,20 +137,17 @@ static inline int32_t GetLeadingZeroBits( uint32_t iCurBits ) //<=16 bits
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline uint32_t BsGetUe( PBitStringAux pBs )
|
||||
{
|
||||
static inline uint32_t BsGetUe (PBitStringAux pBs) {
|
||||
uint32_t iValue = 0;
|
||||
int32_t iLeadingZeroBits = GetLeadingZeroBits (pBs->uiCurBits);
|
||||
|
||||
if ( iLeadingZeroBits == -1 ) //bistream error
|
||||
{
|
||||
if (iLeadingZeroBits == -1) { //bistream error
|
||||
return 0xffffffff;//-1
|
||||
}
|
||||
|
||||
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits + 1);
|
||||
|
||||
if( iLeadingZeroBits )
|
||||
{
|
||||
if (iLeadingZeroBits) {
|
||||
iValue = UBITS (pBs->uiCurBits, iLeadingZeroBits);
|
||||
DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits);
|
||||
}
|
||||
@ -174,18 +159,14 @@ static inline uint32_t BsGetUe( PBitStringAux pBs )
|
||||
/*
|
||||
* Read signed exp golomb codes
|
||||
*/
|
||||
static inline int32_t BsGetSe(PBitStringAux pBs)
|
||||
{
|
||||
static inline int32_t BsGetSe (PBitStringAux pBs) {
|
||||
uint32_t uiCodeNum;
|
||||
|
||||
uiCodeNum = BsGetUe (pBs);
|
||||
|
||||
if(uiCodeNum&0x01)
|
||||
{
|
||||
if (uiCodeNum & 0x01) {
|
||||
return (int32_t) ((uiCodeNum + 1) >> 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NEG_NUM ((int32_t) (uiCodeNum >> 1));
|
||||
}
|
||||
}
|
||||
@ -193,14 +174,10 @@ static inline int32_t BsGetSe(PBitStringAux pBs)
|
||||
/*
|
||||
* Read truncated exp golomb codes
|
||||
*/
|
||||
static inline uint32_t BsGetTe(PBitStringAux pBs, uint8_t uiRange)
|
||||
{
|
||||
if ( 1 == uiRange )
|
||||
{
|
||||
static inline uint32_t BsGetTe (PBitStringAux pBs, uint8_t uiRange) {
|
||||
if (1 == uiRange) {
|
||||
return BsGetOneBit (pBs) ^ 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return BsGetUe (pBs);
|
||||
}
|
||||
}
|
||||
@ -208,8 +185,7 @@ static inline uint32_t BsGetTe(PBitStringAux pBs, uint8_t uiRange)
|
||||
/*
|
||||
* Get unsigned truncated exp golomb code.
|
||||
*/
|
||||
static inline int32_t BsGetTe0(PBitStringAux pBs, int32_t iRange)
|
||||
{
|
||||
static inline int32_t BsGetTe0 (PBitStringAux pBs, int32_t iRange) {
|
||||
if (iRange == 1)
|
||||
return 0;
|
||||
else if (iRange == 2)
|
||||
@ -221,14 +197,12 @@ static inline int32_t BsGetTe0(PBitStringAux pBs, int32_t iRange)
|
||||
/*
|
||||
* Get number of trailing bits
|
||||
*/
|
||||
static inline int32_t BsGetTrailingBits( uint8_t *pBuf )
|
||||
{
|
||||
static inline int32_t BsGetTrailingBits (uint8_t* pBuf) {
|
||||
// TODO
|
||||
uint32_t uiValue = *pBuf;
|
||||
int32_t iRetNum = 1;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
if (uiValue & 1)
|
||||
return iRetNum;
|
||||
uiValue >>= 1;
|
||||
|
@ -60,8 +60,7 @@ namespace WelsDec {
|
||||
//#define MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
|
||||
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
|
||||
|
||||
typedef struct TagDataBuffer
|
||||
{
|
||||
typedef struct TagDataBuffer {
|
||||
uint8_t* pHead;
|
||||
uint8_t* pEnd;
|
||||
|
||||
@ -84,7 +83,8 @@ typedef struct TagDataBuffer
|
||||
/*typedef for get intra predictor func pointer*/
|
||||
typedef void_t (*PGetIntraPredFunc) (uint8_t* pPred, const int32_t kiLumaStride);
|
||||
typedef void_t (*PIdctResAddPredFunc) (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
|
||||
typedef void_t (*PExpandPictureFunc)( uint8_t *pDst, const int32_t kiStride, const int32_t kiPicWidth, const int32_t kiPicHeight );
|
||||
typedef void_t (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
|
||||
const int32_t kiPicHeight);
|
||||
|
||||
/**/
|
||||
typedef struct TagRefPic {
|
||||
@ -119,10 +119,13 @@ typedef struct tagDeblockingFilter {
|
||||
} SDeblockingFilter, *PDeblockingFilter;
|
||||
|
||||
typedef void_t (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag);
|
||||
typedef void_t (*PLumaDeblockingLT4Func)( uint8_t *iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc );
|
||||
typedef void_t (*PLumaDeblockingLT4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* iTc);
|
||||
typedef void_t (*PLumaDeblockingEQ4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
typedef void_t (*PChromaDeblockingLT4Func)( uint8_t *iSampleCb, uint8_t *iSampleCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc );
|
||||
typedef void_t (*PChromaDeblockingEQ4Func)( uint8_t *iSampleCb, uint8_t *iSampleCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
|
||||
typedef void_t (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* iTc);
|
||||
typedef void_t (*PChromaDeblockingEQ4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta);
|
||||
|
||||
typedef struct TagDeblockingFunc {
|
||||
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
|
||||
@ -136,7 +139,8 @@ typedef struct TagDeblockingFunc {
|
||||
PChromaDeblockingEQ4Func pfChromaDeblockinEQ4Hor;
|
||||
} SDeblockingFunc, *PDeblockingFunc;
|
||||
|
||||
typedef void_t (*PWelsBlockAddStrideFunc)(uint8_t *pDest, uint8_t *pPred, int16_t *pRes, int32_t iPredStride, int32_t iResStride);
|
||||
typedef void_t (*PWelsBlockAddStrideFunc) (uint8_t* pDest, uint8_t* pPred, int16_t* pRes, int32_t iPredStride,
|
||||
int32_t iResStride);
|
||||
typedef void_t (*PWelsBlockZeroFunc) (int16_t* pBlock, int32_t iStride);
|
||||
typedef void_t (*PWelsNonZeroCountFunc) (int16_t* pBlock, int8_t* pNonZeroCount);
|
||||
typedef void_t (*PWelsSimpleIdct4x4AddFunc) (int16_t* pDest, int16_t* pSrc, int32_t iStride);
|
||||
@ -147,8 +151,10 @@ typedef struct TagBlockFunc {
|
||||
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
|
||||
} SBlockFunc;
|
||||
|
||||
typedef void_t ( *PWelsFillNeighborMbInfoIntra4x4Func )( PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, PDqLayer pCurLayer );
|
||||
typedef int32_t (*PWelsParseIntra4x4ModeFunc) ( PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
typedef void_t (*PWelsFillNeighborMbInfoIntra4x4Func) (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
|
||||
int8_t* pIntraPredMode, PDqLayer pCurLayer);
|
||||
typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
|
||||
PDqLayer pCurDqLayer);
|
||||
typedef int32_t (*PWelsParseIntra16x16ModeFunc) (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
|
||||
typedef struct TagExpandPicFunc {
|
||||
@ -196,10 +202,10 @@ typedef struct TagWelsDecoderContext {
|
||||
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.
|
||||
int32_t
|
||||
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
|
||||
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
|
||||
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
|
||||
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
|
||||
@ -286,7 +292,8 @@ typedef struct TagWelsDecoderContext {
|
||||
#ifdef LONG_TERM_REF
|
||||
bool_t bParamSetsLostFlag; //sps or pps do not exist or not correct
|
||||
|
||||
bool_t bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
|
||||
bool_t
|
||||
bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
|
||||
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
|
||||
|
||||
uint16_t uiCurIdrPicId;
|
||||
|
@ -117,7 +117,8 @@ int32_t ConstructAccessUnit( PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
|
||||
* DecodeCurrentAccessUnit
|
||||
* Decode current access unit when current AU is completed.
|
||||
*/
|
||||
int32_t DecodeCurrentAccessUnit( PWelsDecoderContext pCtx, uint8_t **ppDst, int32_t *iDstLen, int32_t *pWidth, int32_t *pHeight, SBufferInfo *pDstInfo );
|
||||
int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* iDstLen, int32_t* pWidth,
|
||||
int32_t* pHeight, SBufferInfo* pDstInfo);
|
||||
|
||||
/*
|
||||
* Prepare current dq layer context initialization.
|
||||
|
@ -42,8 +42,7 @@
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
typedef enum TagWelsErr
|
||||
{
|
||||
typedef enum TagWelsErr {
|
||||
ERR_NONE = 0,
|
||||
ERR_INVALID_PARAMETERS = 1,
|
||||
ERR_MALLOC_FAILED = 2,
|
||||
|
@ -45,7 +45,8 @@
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
void_t ExpandReferencingPicture(PPicture pPic, PExpandPictureFunc pExpandPictureLuma, PExpandPictureFunc pExpandPictureChroma[2]);
|
||||
void_t ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpandPictureLuma,
|
||||
PExpandPictureFunc pExpandPictureChroma[2]);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -37,9 +37,15 @@
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
struct tagUnaligned_64 { uint64_t l; } __attribute__((packed));
|
||||
struct tagUnaligned_32 { uint32_t l; } __attribute__((packed));
|
||||
struct tagUnaligned_16 { uint16_t l; } __attribute__((packed));
|
||||
struct tagUnaligned_64 {
|
||||
uint64_t l;
|
||||
} __attribute__ ((packed));
|
||||
struct tagUnaligned_32 {
|
||||
uint32_t l;
|
||||
} __attribute__ ((packed));
|
||||
struct tagUnaligned_16 {
|
||||
uint16_t l;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define LD16(a) (((struct tagUnaligned_16 *) (a))->l)
|
||||
#define LD32(a) (((struct tagUnaligned_32 *) (a))->l)
|
||||
|
@ -143,11 +143,10 @@ namespace WelsDec {
|
||||
nC += (uint8_t)(nA == -1 && nB == -1); \
|
||||
}
|
||||
|
||||
static __inline int32_t CeilLog2( int32_t i )
|
||||
{
|
||||
int32_t s = 0; i--;
|
||||
while( i > 0 )
|
||||
{
|
||||
static __inline int32_t CeilLog2 (int32_t i) {
|
||||
int32_t s = 0;
|
||||
i--;
|
||||
while (i > 0) {
|
||||
s++;
|
||||
i >>= 1;
|
||||
}
|
||||
@ -157,8 +156,7 @@ static __inline int32_t CeilLog2( int32_t i )
|
||||
the second path will degrades the performance
|
||||
*/
|
||||
#if 1
|
||||
static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
|
||||
{
|
||||
static inline int32_t WelsMedian (int32_t iX, int32_t iY, int32_t iZ) {
|
||||
int32_t iMin = iX, iMax = iX;
|
||||
|
||||
if (iY < iMin)
|
||||
@ -174,8 +172,7 @@ static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
|
||||
return (iX + iY + iZ) - (iMin + iMax);
|
||||
}
|
||||
#else
|
||||
static inline int32_t WelsMedian(int32_t iX, int32_t iY, int32_t iZ)
|
||||
{
|
||||
static inline int32_t WelsMedian (int32_t iX, int32_t iY, int32_t iZ) {
|
||||
int32_t iTmp = (iX - iY) & ((iX - iY) >> 31);
|
||||
iX -= iTmp;
|
||||
iY += iTmp;
|
||||
|
@ -66,8 +66,7 @@ extern const uint8_t g_kuiCacheNzcScanIdx[24];
|
||||
|
||||
extern const uint8_t g_kuiScan4[16];
|
||||
|
||||
typedef struct TagNeighborAvail
|
||||
{
|
||||
typedef struct TagNeighborAvail {
|
||||
int32_t iTopAvail;
|
||||
int32_t iLeftAvail;
|
||||
int32_t iRightTopAvail;
|
||||
|
@ -49,24 +49,39 @@ extern "C" {
|
||||
// MMXEXT definition //
|
||||
//***************************************************************************//
|
||||
#if defined(X86_ASM)
|
||||
typedef void_t (*PMcChromaWidthExtFunc)( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD, int32_t iHeight );
|
||||
extern void_t McHorVer20WidthEq4_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McChromaWidthEq4_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD, int32_t iHeight );
|
||||
extern void_t McCopyWidthEq4_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McCopyWidthEq8_mmx (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t PixelAvgWidthEq4_mmx (uint8_t *pDst, int32_t iDstStride, uint8_t *pSrcA, int32_t iSrcAStride, uint8_t *pSrcB, int32_t iSrcBStride, int32_t iHeight);
|
||||
extern void_t PixelAvgWidthEq8_mmx (uint8_t *pDst, int32_t iDstStride, uint8_t *pSrcA, int32_t iSrcAStride, uint8_t *pSrcB, int32_t iSrcBStride, int32_t iHeight);
|
||||
typedef void_t (*PMcChromaWidthExtFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* kpABCD, int32_t iHeight);
|
||||
extern void_t McHorVer20WidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McChromaWidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* kpABCD, int32_t iHeight);
|
||||
extern void_t McCopyWidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McCopyWidthEq8_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t PixelAvgWidthEq4_mmx (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight);
|
||||
extern void_t PixelAvgWidthEq8_mmx (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight);
|
||||
//***************************************************************************//
|
||||
// SSE2 definition //
|
||||
//***************************************************************************//
|
||||
extern void_t McChromaWidthEq8_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t* kpABCD, int32_t iHeight );
|
||||
extern void_t McCopyWidthEq16_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McHorVer20WidthEq8_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McHorVer20WidthEq16_sse2(uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McHorVer02WidthEq8_sse2 (uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McHorVer22Width8HorFirst_sse2(uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight);
|
||||
extern void_t McHorVer22VerLast_sse2(uint8_t * pTap, int32_t iTapStride, uint8_t * pDst,int32_t iDstStride,int32_t iWidth,int32_t iHeight);
|
||||
extern void_t PixelAvgWidthEq16_sse2 (uint8_t *pDst, int32_t iDstStride, uint8_t *pSrcA, int32_t iSrcAStride, uint8_t *pSrcB, int32_t iSrcBStride, int32_t iHeight);
|
||||
extern void_t McChromaWidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* kpABCD, int32_t iHeight);
|
||||
extern void_t McCopyWidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McHorVer20WidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McHorVer20WidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McHorVer02WidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McHorVer22Width8HorFirst_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
extern void_t McHorVer22VerLast_sse2 (uint8_t* pTap, int32_t iTapStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
extern void_t PixelAvgWidthEq16_sse2 (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iHeight);
|
||||
|
||||
#endif //X86_ASM
|
||||
|
||||
|
@ -64,8 +64,7 @@ extern "C" {
|
||||
* \return time elapsed since run (unit: microsecond)
|
||||
*/
|
||||
|
||||
int64_t WelsTime( void_t )
|
||||
{
|
||||
int64_t WelsTime (void_t) {
|
||||
#if !(defined(_MSC_VER) || defined(__MINGW32__))
|
||||
struct timeval tv_date;
|
||||
|
||||
|
@ -57,7 +57,8 @@ void_t UpdateP16x16MotionInfo(PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]
|
||||
* \param
|
||||
* \param
|
||||
*/
|
||||
void_t UpdateP16x8MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
void_t UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
|
||||
int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
|
||||
|
||||
|
||||
@ -66,7 +67,8 @@ void_t UpdateP16x8MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A]
|
||||
* \param
|
||||
* \param
|
||||
*/
|
||||
void_t UpdateP8x16MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
void_t UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
|
||||
int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]);
|
||||
|
||||
/*!
|
||||
|
@ -55,8 +55,7 @@ namespace WelsDec {
|
||||
#define CHROMA_DC 4
|
||||
#define CHROMA_AC 5
|
||||
|
||||
typedef struct TagReadBitsCache
|
||||
{
|
||||
typedef struct TagReadBitsCache {
|
||||
uint32_t uiCache32Bit;
|
||||
uint8_t uiRemainBits;
|
||||
uint8_t* pBuf;
|
||||
@ -137,8 +136,10 @@ static const SPartMbInfo g_ksInterSubMbTypeInfo[4]={
|
||||
|
||||
void_t GetNeighborAvailMbType (PNeighAvail pNeighAvail, PDqLayer pCurLayer);
|
||||
void_t WelsFillCacheNonZeroCount (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer);
|
||||
void_t WelsFillCacheConstrain0Intra4x4(PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, PDqLayer pCurLayer);
|
||||
void_t WelsFillCacheConstrain1Intra4x4(PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, PDqLayer pCurLayer);
|
||||
void_t WelsFillCacheConstrain0Intra4x4 (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
|
||||
PDqLayer pCurLayer);
|
||||
void_t WelsFillCacheConstrain1Intra4x4 (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
|
||||
PDqLayer pCurLayer);
|
||||
void_t WelsFillCacheInter (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
|
||||
int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
|
||||
|
||||
@ -195,8 +196,10 @@ int32_t WelsResidualBlockCavlc( SVlcTable* pVlcTable,
|
||||
* \param input : current mb, bit-stream
|
||||
* \param output: 0 indicating decoding correctly; -1 means error
|
||||
*/
|
||||
int32_t ParseIntra4x4ModeConstrain0 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
int32_t ParseIntra4x4ModeConstrain1 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
int32_t ParseIntra4x4ModeConstrain0 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
|
||||
PDqLayer pCurDqLayer);
|
||||
int32_t ParseIntra4x4ModeConstrain1 (PNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
|
||||
PDqLayer pCurDqLayer);
|
||||
int32_t ParseIntra16x16ModeConstrain0 (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
int32_t ParseIntra16x16ModeConstrain1 (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
|
||||
|
||||
@ -205,7 +208,8 @@ int32_t ParseIntra16x16ModeConstrain1(PNeighAvail pNeighAvail, PBitStringAux pBs
|
||||
* \param input : decoding context, current mb, bit-stream
|
||||
* \param output: 0 indicating decoding correctly; -1 means error
|
||||
*/
|
||||
int32_t ParseInterInfo(PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PBitStringAux pBs);
|
||||
int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
|
||||
PBitStringAux pBs);
|
||||
|
||||
//#pragma pack()
|
||||
|
||||
|
@ -64,7 +64,8 @@ typedef void_t (*PWelsLogCallbackFunc)(void_t *pPtr, const int32_t kiLevel, cons
|
||||
extern PWelsLogCallbackFunc g_pLog;
|
||||
|
||||
#ifdef __GNUC__
|
||||
extern void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...) __attribute__ ((__format__ (__printf__, 3,
|
||||
4)));
|
||||
#else
|
||||
extern void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...);
|
||||
#endif
|
||||
|
@ -38,8 +38,7 @@
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
typedef struct TagVlcTable
|
||||
{
|
||||
typedef struct TagVlcTable {
|
||||
const uint8_t (*kpCoeffTokenVlcTable[4][8])[2];
|
||||
const uint8_t (*kpChromaCoeffTokenVlcTable)[2];
|
||||
const uint8_t (*kpZeroTable[7])[2];
|
||||
@ -114,8 +113,7 @@ extern const uint8_t g_kuiZeroLeftBitNumMap[16];
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void_t InitVlcTable(SVlcTable * pVlcTable)
|
||||
{
|
||||
static inline void_t InitVlcTable (SVlcTable* pVlcTable) {
|
||||
pVlcTable->kpChromaCoeffTokenVlcTable = g_kuiVlcChromaTable;
|
||||
|
||||
pVlcTable->kpCoeffTokenVlcTable[0][0] = g_kuiVlcTable_0;
|
||||
|
@ -67,8 +67,7 @@ enum{
|
||||
/*
|
||||
* NAL Unit Type (5 Bits)
|
||||
*/
|
||||
typedef enum TagNalUnitType
|
||||
{
|
||||
typedef enum TagNalUnitType {
|
||||
NAL_UNIT_UNSPEC_0 = 0,
|
||||
NAL_UNIT_CODED_SLICE = 1,
|
||||
NAL_UNIT_CODED_SLICE_DPA = 2,
|
||||
@ -202,8 +201,7 @@ typedef struct TagPosOffset{
|
||||
int32_t iBottomOffset;
|
||||
} SPosOffset;
|
||||
|
||||
enum EMbPosition //
|
||||
{
|
||||
enum EMbPosition { //
|
||||
MB_LEFT = 0x01, // A
|
||||
MB_TOP = 0x02, // B
|
||||
MB_TOPRIGHT = 0x04, // C
|
||||
|
@ -71,8 +71,7 @@ namespace WelsDec {
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
uint8_t* DetectStartCodePrefix( const uint8_t *kpBuf, int32_t *pOffset, int32_t iBufSize )
|
||||
{
|
||||
uint8_t* DetectStartCodePrefix (const uint8_t* kpBuf, int32_t* pOffset, int32_t iBufSize) {
|
||||
uint8_t* pBits = (uint8_t*)kpBuf;
|
||||
|
||||
do {
|
||||
@ -114,8 +113,8 @@ uint8_t* DetectStartCodePrefix( const uint8_t *kpBuf, int32_t *pOffset, int32_t
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeader, uint8_t *pSrcRbsp, int32_t iSrcRbspLen, uint8_t *pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes )
|
||||
{
|
||||
uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeader, uint8_t* pSrcRbsp,
|
||||
int32_t iSrcRbspLen, uint8_t* pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes) {
|
||||
PNalUnit pCurNal = NULL;
|
||||
uint8_t* pNal = pSrcRbsp;
|
||||
int32_t iNalSize = iSrcRbspLen;
|
||||
@ -130,24 +129,19 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
{
|
||||
int32_t iIndex = iSrcRbspLen - 1;
|
||||
uint8_t uiBsZero = 0;
|
||||
while ( iIndex >= 0 )
|
||||
{
|
||||
while (iIndex >= 0) {
|
||||
uiBsZero = pSrcRbsp[iIndex];
|
||||
if ( 0 == uiBsZero )
|
||||
{
|
||||
if (0 == uiBsZero) {
|
||||
--iNalSize;
|
||||
--iIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pNalUnitHeader->uiForbiddenZeroBit = (uint8_t) (pNal[0] >> 7); // uiForbiddenZeroBit
|
||||
if ( pNalUnitHeader->uiForbiddenZeroBit )//2010.4.14
|
||||
{
|
||||
if (pNalUnitHeader->uiForbiddenZeroBit) { //2010.4.14
|
||||
return NULL; //uiForbiddenZeroBit should always equal to 0
|
||||
}
|
||||
|
||||
@ -162,22 +156,28 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
WelsLog (pCtx, WELS_LOG_INFO, "nal type: %d \n", pNalUnitHeader->eNalUnitType);
|
||||
#endif
|
||||
|
||||
if ( !(IS_SEI_NAL(pNalUnitHeader->eNalUnitType) || IS_SPS_NAL(pNalUnitHeader->eNalUnitType) || pCtx->bSpsExistAheadFlag) )
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).\n", pNalUnitHeader->eNalUnitType);
|
||||
if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType)
|
||||
|| pCtx->bSpsExistAheadFlag)) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING,
|
||||
"parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).\n",
|
||||
pNalUnitHeader->eNalUnitType);
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
if ( !(IS_SEI_NAL(pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS(pNalUnitHeader->eNalUnitType) || pCtx->bPpsExistAheadFlag) )
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).\n", pNalUnitHeader->eNalUnitType);
|
||||
if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType)
|
||||
|| pCtx->bPpsExistAheadFlag)) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING,
|
||||
"parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).\n",
|
||||
pNalUnitHeader->eNalUnitType);
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bPpsExistAheadFlag)) ||
|
||||
(IS_NEW_INTRODUCED_NAL(pNalUnitHeader->eNalUnitType) && !(pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag || pCtx->bPpsExistAheadFlag) ) )
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).\n", pNalUnitHeader->eNalUnitType);
|
||||
(IS_NEW_INTRODUCED_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag
|
||||
|| pCtx->bPpsExistAheadFlag))) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING,
|
||||
"ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).\n",
|
||||
pNalUnitHeader->eNalUnitType);
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
@ -186,8 +186,7 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
switch (pNalUnitHeader->eNalUnitType) {
|
||||
case NAL_UNIT_SEI:
|
||||
|
||||
if ( pCtx->pAccessUnitList->uiAvailUnitsNum > 0 )
|
||||
{
|
||||
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
|
||||
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
|
||||
pCtx->bAuReadyFlag = true;
|
||||
}
|
||||
@ -196,8 +195,7 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
|
||||
case NAL_UNIT_SPS:
|
||||
|
||||
if ( pCtx->pAccessUnitList->uiAvailUnitsNum > 0 )
|
||||
{
|
||||
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
|
||||
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
|
||||
pCtx->bAuReadyFlag = true;
|
||||
}
|
||||
@ -207,8 +205,7 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
case NAL_UNIT_PREFIX:
|
||||
pCurNal = &pCtx->sPrefixNal;
|
||||
|
||||
if ( iNalSize < NAL_UNIT_HEADER_EXT_SIZE )
|
||||
{
|
||||
if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -234,13 +231,11 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
case NAL_UNIT_CODED_SLICE_EXT:
|
||||
bExtensionFlag = true;
|
||||
case NAL_UNIT_CODED_SLICE:
|
||||
case NAL_UNIT_CODED_SLICE_IDR:
|
||||
{
|
||||
case NAL_UNIT_CODED_SLICE_IDR: {
|
||||
PAccessUnit pCurAu = NULL;
|
||||
uint32_t uiAvailNalNum;
|
||||
pCurNal = MemGetNextNal (&pCtx->pAccessUnitList);
|
||||
if( NULL == pCurNal )
|
||||
{
|
||||
if (NULL == pCurNal) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "MemGetNextNal() fail due out of memory.\n");
|
||||
pCtx->iErrorCode |= dsOutOfMemory;
|
||||
return NULL;
|
||||
@ -253,27 +248,25 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
uiAvailNalNum = pCurAu->uiAvailUnitsNum;
|
||||
|
||||
|
||||
if( pNalUnitHeader->eNalUnitType == NAL_UNIT_CODED_SLICE_EXT )
|
||||
{
|
||||
if ( iNalSize < NAL_UNIT_HEADER_EXT_SIZE )
|
||||
{
|
||||
if (pNalUnitHeader->eNalUnitType == NAL_UNIT_CODED_SLICE_EXT) {
|
||||
if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DecodeNalHeaderExt (pCurNal, pNal);
|
||||
if (pCurNal->sNalHeaderExt.uiQualityId != 0 ||
|
||||
pCurNal->sNalHeaderExt.bUseRefBasePicFlag )
|
||||
{
|
||||
pCurNal->sNalHeaderExt.bUseRefBasePicFlag) {
|
||||
if (pCurNal->sNalHeaderExt.uiQualityId != 0)
|
||||
WelsLog(pCtx, WELS_LOG_WARNING, "ParseNalHeader():uiQualityId (%d) != 0, MGS not supported!\n", pCurNal->sNalHeaderExt.uiQualityId);
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseNalHeader():uiQualityId (%d) != 0, MGS not supported!\n",
|
||||
pCurNal->sNalHeaderExt.uiQualityId);
|
||||
if (pCurNal->sNalHeaderExt.bUseRefBasePicFlag != 0)
|
||||
WelsLog(pCtx, WELS_LOG_WARNING, "ParseNalHeader():bUseRefBasePicFlag (%d) != 0, MGS not supported!\n", pCurNal->sNalHeaderExt.bUseRefBasePicFlag);
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseNalHeader():bUseRefBasePicFlag (%d) != 0, MGS not supported!\n",
|
||||
pCurNal->sNalHeaderExt.bUseRefBasePicFlag);
|
||||
|
||||
pCtx->iErrorCode |= dsInvalidArgument;
|
||||
ForceClearCurrentNal (pCurAu);
|
||||
|
||||
if ( uiAvailNalNum > 1 )
|
||||
{
|
||||
if (uiAvailNalNum > 1) {
|
||||
pCurAu->uiEndPos = uiAvailNalNum - 2;
|
||||
pCtx->bAuReadyFlag = true;
|
||||
}
|
||||
@ -283,17 +276,15 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
iNalSize -= NAL_UNIT_HEADER_EXT_SIZE;
|
||||
*pConsumedBytes += NAL_UNIT_HEADER_EXT_SIZE;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
|
||||
|
||||
if ( NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType )
|
||||
{
|
||||
if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
|
||||
PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sPrefixNal);
|
||||
}
|
||||
|
||||
pCurNal->sNalHeaderExt.bIdrFlag = ( NAL_UNIT_CODED_SLICE_IDR == pNalUnitHeader->eNalUnitType ) ? true : false; //SHOULD update this flag for AVC if no prefix NAL
|
||||
pCurNal->sNalHeaderExt.bIdrFlag = (NAL_UNIT_CODED_SLICE_IDR == pNalUnitHeader->eNalUnitType) ? true :
|
||||
false; //SHOULD update this flag for AVC if no prefix NAL
|
||||
pCurNal->sNalHeaderExt.iNoInterLayerPredFlag = 1;
|
||||
}
|
||||
|
||||
@ -301,24 +292,20 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit
|
||||
InitBits (pBs, pNal, iBitSize);
|
||||
iErr = ParseSliceHeaderSyntaxs (pCtx, pBs, bExtensionFlag);
|
||||
if ( iErr != ERR_NONE )
|
||||
{
|
||||
if (iErr != ERR_NONE) {
|
||||
//if current NAL occur error when parsing, should clean it from pNalUnitsList
|
||||
//otherwise, when Next good NAL decoding, this corrupt NAL is considered as normal NAL and lead to decoder crash
|
||||
ForceClearCurrentNal (pCurAu);
|
||||
|
||||
if ( uiAvailNalNum > 1 )
|
||||
{
|
||||
if (uiAvailNalNum > 1) {
|
||||
pCurAu->uiEndPos = uiAvailNalNum - 2;
|
||||
pCtx->bAuReadyFlag = true;
|
||||
|
||||
|
||||
}
|
||||
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
|
||||
if ( dsNoParamSets & pCtx->iErrorCode )
|
||||
{
|
||||
if ( uiAvailNalNum <= 1 ) //no any data to decode and SPS/PPS ID mismatch, SHOULD request IDR
|
||||
{
|
||||
if (dsNoParamSets & pCtx->iErrorCode) {
|
||||
if (uiAvailNalNum <= 1) { //no any data to decode and SPS/PPS ID mismatch, SHOULD request IDR
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -327,9 +314,7 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
ResetParameterSetsState (pCtx);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
@ -339,8 +324,7 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
|
||||
if ((uiAvailNalNum > 1) &&
|
||||
CheckAccessUnitBoundary (pCurAu->pNalUnitsList[uiAvailNalNum - 1], pCurAu->pNalUnitsList[uiAvailNalNum - 2],
|
||||
pCurAu->pNalUnitsList[uiAvailNalNum-1]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps) )
|
||||
{
|
||||
pCurAu->pNalUnitsList[uiAvailNalNum - 1]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps)) {
|
||||
pCurAu->uiEndPos = uiAvailNalNum - 2;
|
||||
pCtx->bAuReadyFlag = true;
|
||||
|
||||
@ -356,8 +340,8 @@ uint8_t* ParseNalHeader( PWelsDecoderContext pCtx, SNalUnitHeader *pNalUnitHeade
|
||||
}
|
||||
|
||||
|
||||
bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt, PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader )
|
||||
{
|
||||
bool_t CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
|
||||
PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader) {
|
||||
const PSps kpSps = pCurSliceHeader->pSps;
|
||||
|
||||
//Sub-clause 7.1.4.1.1 temporal_id
|
||||
@ -390,7 +374,8 @@ bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHea
|
||||
return TRUE;
|
||||
if (pLastSliceHeader->bBottomFiledFlag != pCurSliceHeader->bBottomFiledFlag)
|
||||
return TRUE;
|
||||
if ( (pLastNalHdrExt->sNalUnitHeader.uiNalRefIdc != NRI_PRI_LOWEST) != (pCurNalHeaderExt->sNalUnitHeader.uiNalRefIdc != NRI_PRI_LOWEST) )
|
||||
if ((pLastNalHdrExt->sNalUnitHeader.uiNalRefIdc != NRI_PRI_LOWEST) != (pCurNalHeaderExt->sNalUnitHeader.uiNalRefIdc !=
|
||||
NRI_PRI_LOWEST))
|
||||
return TRUE;
|
||||
if (pLastNalHdrExt->bIdrFlag != pCurNalHeaderExt->bIdrFlag)
|
||||
return TRUE;
|
||||
@ -403,8 +388,7 @@ bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHea
|
||||
return TRUE;
|
||||
if (pLastSliceHeader->iDeltaPicOrderCntBottom != pCurSliceHeader->iDeltaPicOrderCntBottom)
|
||||
return TRUE;
|
||||
}
|
||||
else if ( kpSps->uiPocType == 1 ){
|
||||
} else if (kpSps->uiPocType == 1) {
|
||||
if (pLastSliceHeader->iDeltaPicOrderCnt[0] != pCurSliceHeader->iDeltaPicOrderCnt[0])
|
||||
return TRUE;
|
||||
if (pLastSliceHeader->iDeltaPicOrderCnt[1] != pCurSliceHeader->iDeltaPicOrderCnt[1])
|
||||
@ -415,8 +399,7 @@ bool_t CheckAccessUnitBoundaryExt( PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHea
|
||||
}
|
||||
|
||||
|
||||
bool_t CheckAccessUnitBoundary( const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps )
|
||||
{
|
||||
bool_t CheckAccessUnitBoundary (const PNalUnit kpCurNal, const PNalUnit kpLastNal, const PSps kpSps) {
|
||||
const PNalUnitHeaderExt kpLastNalHeaderExt = &kpLastNal->sNalHeaderExt;
|
||||
const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
|
||||
const SSliceHeader* kpLastSliceHeader = &kpLastNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
|
||||
@ -452,7 +435,8 @@ bool_t CheckAccessUnitBoundary( const PNalUnit kpCurNal, const PNalUnit kpLastNa
|
||||
return TRUE;
|
||||
if (kpLastSliceHeader->bBottomFiledFlag != kpCurSliceHeader->bBottomFiledFlag)
|
||||
return TRUE;
|
||||
if ( (kpLastNalHeaderExt->sNalUnitHeader.uiNalRefIdc != NRI_PRI_LOWEST) != (kpCurNalHeaderExt->sNalUnitHeader.uiNalRefIdc != NRI_PRI_LOWEST) )
|
||||
if ((kpLastNalHeaderExt->sNalUnitHeader.uiNalRefIdc != NRI_PRI_LOWEST) != (kpCurNalHeaderExt->sNalUnitHeader.uiNalRefIdc
|
||||
!= NRI_PRI_LOWEST))
|
||||
return TRUE;
|
||||
if (kpLastNalHeaderExt->bIdrFlag != kpCurNalHeaderExt->bIdrFlag)
|
||||
return TRUE;
|
||||
@ -465,8 +449,7 @@ bool_t CheckAccessUnitBoundary( const PNalUnit kpCurNal, const PNalUnit kpLastNa
|
||||
return TRUE;
|
||||
if (kpLastSliceHeader->iDeltaPicOrderCntBottom != kpCurSliceHeader->iDeltaPicOrderCntBottom)
|
||||
return TRUE;
|
||||
}
|
||||
else if ( kpSps->uiPocType == 1 ){
|
||||
} else if (kpSps->uiPocType == 1) {
|
||||
if (kpLastSliceHeader->iDeltaPicOrderCnt[0] != kpCurSliceHeader->iDeltaPicOrderCnt[0])
|
||||
return TRUE;
|
||||
if (kpLastSliceHeader->iDeltaPicOrderCnt[1] != kpCurSliceHeader->iDeltaPicOrderCnt[1])
|
||||
@ -489,8 +472,7 @@ bool_t CheckAccessUnitBoundary( const PNalUnit kpCurNal, const PNalUnit kpLastNa
|
||||
*
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t ParseNonVclNal( PWelsDecoderContext pCtx, uint8_t *pRbsp, const int32_t kiSrcLen )
|
||||
{
|
||||
int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen) {
|
||||
PBitStringAux pBs = NULL;
|
||||
ENalUnitType eNalType = NAL_UNIT_UNSPEC_0; // make initial value as unspecified
|
||||
int32_t iPicWidth = 0;
|
||||
@ -511,8 +493,7 @@ int32_t ParseNonVclNal( PWelsDecoderContext pCtx, uint8_t *pRbsp, const int32_t
|
||||
WelsLog (pCtx, WELS_LOG_INFO, "parsing nal: %d \n", eNalType);
|
||||
#endif
|
||||
iErr = ParseSps (pCtx, pBs, &iPicWidth, &iPicHeight);
|
||||
if ( ERR_NONE != iErr ) // modified for pSps/pSubsetSps invalid, 12/1/2009
|
||||
{
|
||||
if (ERR_NONE != iErr) { // modified for pSps/pSubsetSps invalid, 12/1/2009
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return iErr;
|
||||
}
|
||||
@ -529,8 +510,7 @@ int32_t ParseNonVclNal( PWelsDecoderContext pCtx, uint8_t *pRbsp, const int32_t
|
||||
WelsLog (pCtx, WELS_LOG_INFO, "parsing nal: %d \n", eNalType);
|
||||
#endif
|
||||
iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs);
|
||||
if ( ERR_NONE != iErr ) // modified for pps invalid, 12/1/2009
|
||||
{
|
||||
if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return iErr;
|
||||
}
|
||||
@ -558,8 +538,7 @@ int32_t ParseNonVclNal( PWelsDecoderContext pCtx, uint8_t *pRbsp, const int32_t
|
||||
return iErr;
|
||||
}
|
||||
|
||||
void_t ParseRefBasePicMarking ( PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking )
|
||||
{
|
||||
void_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking) {
|
||||
const bool_t kbAdaptiveMarkingModeFlag = !!BsGetOneBit (pBs);
|
||||
pRefBasePicMarking->bAdaptiveRefBasePicMarkingModeFlag = kbAdaptiveMarkingModeFlag;
|
||||
if (kbAdaptiveMarkingModeFlag) {
|
||||
@ -575,8 +554,7 @@ void_t ParseRefBasePicMarking ( PBitStringAux pBs, PRefBasePicMarking pRefBasePi
|
||||
if (kuiMmco == MMCO_SHORT2UNUSED) {
|
||||
pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + BsGetUe (pBs);
|
||||
pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0;
|
||||
}
|
||||
else if (kuiMmco == MMCO_LONG2UNUSED){
|
||||
} else if (kuiMmco == MMCO_LONG2UNUSED) {
|
||||
pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = BsGetUe (pBs);
|
||||
}
|
||||
++ iIdx;
|
||||
@ -584,16 +562,14 @@ void_t ParseRefBasePicMarking ( PBitStringAux pBs, PRefBasePicMarking pRefBasePi
|
||||
}
|
||||
}
|
||||
|
||||
void_t ParsePrefixNalUnit ( PWelsDecoderContext pCtx, PBitStringAux pBs )
|
||||
{
|
||||
void_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
|
||||
PNalUnit pCurNal = &pCtx->sPrefixNal;
|
||||
|
||||
if (pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
|
||||
PNalUnitHeaderExt head_ext = &pCurNal->sNalHeaderExt;
|
||||
PPrefixNalUnit sPrefixNal = &pCurNal->sNalData.sPrefixNal;
|
||||
sPrefixNal->bStoreRefBasePicFlag = !!BsGetOneBit (pBs);
|
||||
if ( (head_ext->bUseRefBasePicFlag || sPrefixNal->bStoreRefBasePicFlag) && !head_ext->bIdrFlag )
|
||||
{
|
||||
if ((head_ext->bUseRefBasePicFlag || sPrefixNal->bStoreRefBasePicFlag) && !head_ext->bIdrFlag) {
|
||||
ParseRefBasePicMarking (pBs, &sPrefixNal->sRefPicBaseMarking);
|
||||
}
|
||||
sPrefixNal->bPrefixNalUnitAdditionalExtFlag = !!BsGetOneBit (pBs);
|
||||
@ -604,8 +580,7 @@ void_t ParsePrefixNalUnit ( PWelsDecoderContext pCtx, PBitStringAux pBs )
|
||||
}
|
||||
|
||||
|
||||
int32_t DecodeSpsSvcExt( PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs )
|
||||
{
|
||||
int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs) {
|
||||
PSpsSvcExt pExt = NULL;
|
||||
uint8_t uiChromaArrayType = 1;
|
||||
|
||||
@ -613,13 +588,14 @@ int32_t DecodeSpsSvcExt( PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
|
||||
|
||||
pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!BsGetOneBit (pBs);
|
||||
pExt->uiExtendedSpatialScalability = BsGetBits (pBs, 2);
|
||||
if ( pExt->uiExtendedSpatialScalability > 2 )
|
||||
{
|
||||
WelsLog(pCtx, WELS_LOG_WARNING, "DecodeSpsSvcExt():extended_spatial_scalability (%d) != 0, ESS not supported!\n", pExt->uiExtendedSpatialScalability);
|
||||
if (pExt->uiExtendedSpatialScalability > 2) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "DecodeSpsSvcExt():extended_spatial_scalability (%d) != 0, ESS not supported!\n",
|
||||
pExt->uiExtendedSpatialScalability);
|
||||
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->uiChromaPhaseXPlus1Flag =
|
||||
0; // FIXME: Incoherent with JVT X201 standard (= 1), but conformance to JSVM (= 0) implementation.
|
||||
pExt->uiChromaPhaseYPlus1 = 1;
|
||||
uiChromaArrayType = pSpsExt->sSps.uiChromaArrayType;
|
||||
|
||||
@ -669,8 +645,7 @@ int32_t DecodeSpsSvcExt( PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
|
||||
*/
|
||||
|
||||
|
||||
int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicWidth, int32_t *pPicHeight )
|
||||
{
|
||||
int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicWidth, int32_t* pPicHeight) {
|
||||
PBitStringAux pBs = pBsAux;
|
||||
PSps pSps = NULL;
|
||||
PSubsetSps pSubsetSps = NULL;
|
||||
@ -682,12 +657,9 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
const bool_t kbUseSubsetFlag = IS_SUBSET_SPS_NAL (pNalHead->eNalUnitType);
|
||||
|
||||
|
||||
if ( kbUseSubsetFlag ) // SubsetSps
|
||||
{
|
||||
if (kbUseSubsetFlag) { // SubsetSps
|
||||
pCtx->bSubspsExistAheadFlag = true;
|
||||
}
|
||||
else // Sps
|
||||
{
|
||||
} else { // Sps
|
||||
pCtx->bSpsExistAheadFlag = true;
|
||||
|
||||
// added for EC, 10/28/2009
|
||||
@ -716,14 +688,12 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
iSpsId = BsGetUe (pBs); // seq_parameter_set_id
|
||||
|
||||
|
||||
if ( iSpsId >= MAX_SPS_COUNT || iSpsId < 0 ) // Modified to check invalid negative iSpsId, 12/1/2009
|
||||
{
|
||||
if (iSpsId >= MAX_SPS_COUNT || iSpsId < 0) { // Modified to check invalid negative iSpsId, 12/1/2009
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, " iSpsId is out of range! \n");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW);
|
||||
}
|
||||
|
||||
if ( kbUseSubsetFlag )
|
||||
{
|
||||
if (kbUseSubsetFlag) {
|
||||
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
|
||||
pSubsetSps = &pCtx->sSubsetSpsBuffer[pCtx->iSubspsTotalNum];
|
||||
pCtx->bSubspsAvailFlags[pCtx->iSubspsTotalNum] = true;
|
||||
@ -736,9 +706,7 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
pSps = &pSubsetSps->sSps;
|
||||
pCtx->bSubspsAvailFlags[iSpsId] = true; // added for EC, 10/28/2009
|
||||
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
|
||||
pSps = &pCtx->sSpsBuffer[pCtx->iSpsTotalNum];
|
||||
pCtx->bSpsAvailFlags[pCtx->iSpsTotalNum] = true;
|
||||
@ -766,22 +734,19 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
PRO_CAVLC444 == uiProfileIdc || 44 == uiProfileIdc) {
|
||||
|
||||
pSps->uiChromaFormatIdc = BsGetUe (pBs);
|
||||
if( pSps->uiChromaFormatIdc != 1 )
|
||||
{
|
||||
if (pSps->uiChromaFormatIdc != 1) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): chroma_format_idc (%d) = 1 supported.\n", pSps->uiChromaFormatIdc);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
pSps->uiChromaArrayType = pSps->uiChromaFormatIdc;
|
||||
pSps->uiBitDepthLuma = 8 + BsGetUe (pBs);
|
||||
if( pSps->uiBitDepthLuma != 8 )
|
||||
{
|
||||
if (pSps->uiBitDepthLuma != 8) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): bit_depth_luma (%d) Only 8 bit supported.\n", pSps->uiBitDepthLuma);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
|
||||
pSps->uiBitDepthChroma = 8 + BsGetUe (pBs);
|
||||
if( pSps->uiBitDepthChroma != 8 )
|
||||
{
|
||||
if (pSps->uiBitDepthChroma != 8) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): bit_depth_chroma (%d). Only 8 bit supported.\n", pSps->uiBitDepthChroma);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
@ -789,7 +754,8 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
pSps->bSeqScalingMatrixPresentFlag = !!BsGetOneBit (pBs);
|
||||
|
||||
if (pSps->bSeqScalingMatrixPresentFlag) { // For high profile, it is not used in current application. FIXME
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.\n", pSps->bSeqScalingMatrixPresentFlag);
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.\n",
|
||||
pSps->bSeqScalingMatrixPresentFlag);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
}
|
||||
@ -797,13 +763,10 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
pSps->uiLog2MaxFrameNum = 4 + BsGetUe (pBs); // log2_max_frame_num_minus4
|
||||
pSps->uiPocType = BsGetUe (pBs); // pic_order_cnt_type
|
||||
|
||||
if ( 0 == pSps->uiPocType )
|
||||
{
|
||||
if (0 == pSps->uiPocType) {
|
||||
pSps->iLog2MaxPocLsb = 4 + BsGetUe (pBs); // log2_max_pic_order_cnt_lsb_minus4
|
||||
|
||||
}
|
||||
else if ( 1 == pSps->uiPocType )
|
||||
{
|
||||
} else if (1 == pSps->uiPocType) {
|
||||
int32_t i;
|
||||
pSps->bDeltaPicOrderAlwaysZeroFlag = !!BsGetOneBit (pBs); // bDeltaPicOrderAlwaysZeroFlag
|
||||
pSps->iOffsetForNonRefPic = BsGetSe (pBs); // iOffsetForNonRefPic
|
||||
@ -812,8 +775,7 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
for (i = 0; i < pSps->iNumRefFramesInPocCycle; i++)
|
||||
pSps->iOffsetForRefFrame[ i ] = BsGetSe (pBs); // iOffsetForRefFrame[ i ]
|
||||
}
|
||||
if ( pSps->uiPocType > 2 )
|
||||
{
|
||||
if (pSps->uiPocType > 2) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, " illegal pic_order_cnt_type: %d ! \n", pSps->uiPocType);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_POC_TYPE);
|
||||
}
|
||||
@ -825,22 +787,18 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
pSps->uiTotalMbCount = pSps->iMbWidth * pSps->iMbHeight;
|
||||
pSps->bFrameMbsOnlyFlag = !!BsGetOneBit (pBs); // frame_mbs_only_flag
|
||||
|
||||
if ( !pSps->bFrameMbsOnlyFlag )
|
||||
{
|
||||
if (!pSps->bFrameMbsOnlyFlag) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): frame_mbs_only_flag (%d) not supported.\n", pSps->bFrameMbsOnlyFlag);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_MBAFF);
|
||||
}
|
||||
pSps->bDirect8x8InferenceFlag = !!BsGetOneBit (pBs); // direct_8x8_inference_flag
|
||||
pSps->bFrameCroppingFlag = !!BsGetOneBit (pBs); // frame_cropping_flag
|
||||
if ( pSps->bFrameCroppingFlag )
|
||||
{
|
||||
if (pSps->bFrameCroppingFlag) {
|
||||
pSps->sFrameCrop.iLeftOffset = BsGetUe (pBs); // frame_crop_left_offset
|
||||
pSps->sFrameCrop.iRightOffset = BsGetUe (pBs); // frame_crop_right_offset
|
||||
pSps->sFrameCrop.iTopOffset = BsGetUe (pBs); // frame_crop_top_offset
|
||||
pSps->sFrameCrop.iBottomOffset = BsGetUe (pBs); // frame_crop_bottom_offset
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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
|
||||
@ -849,8 +807,7 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
pSps->bVuiParamPresentFlag = !!BsGetOneBit (pBs); // vui_parameters_present_flag
|
||||
|
||||
// Check if SPS SVC extension applicated
|
||||
if ( kbUseSubsetFlag && ( PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc ) )
|
||||
{
|
||||
if (kbUseSubsetFlag && (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)) {
|
||||
if (DecodeSpsSvcExt (pCtx, pSubsetSps, pBs) != ERR_NONE) {
|
||||
return -1;
|
||||
}
|
||||
@ -886,16 +843,14 @@ int32_t ParseSps( PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t *pPicW
|
||||
* \note Call it in case eNalUnitType is PPS.
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux )
|
||||
{
|
||||
int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) {
|
||||
|
||||
PPps pPps = NULL;
|
||||
uint32_t uiPpsId = 0;
|
||||
uint32_t iTmp;
|
||||
|
||||
uiPpsId = BsGetUe (pBsAux);
|
||||
if ( uiPpsId >= MAX_PPS_COUNT )
|
||||
{
|
||||
if (uiPpsId >= MAX_PPS_COUNT) {
|
||||
return ERR_INFO_PPS_ID_OVERFLOW;
|
||||
}
|
||||
|
||||
@ -909,8 +864,7 @@ int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux
|
||||
pPps->iPpsId = uiPpsId;
|
||||
pPps->iSpsId = BsGetUe (pBsAux);
|
||||
|
||||
if (pPps->iSpsId >= MAX_SPS_COUNT)
|
||||
{
|
||||
if (pPps->iSpsId >= MAX_SPS_COUNT) {
|
||||
return ERR_INFO_SPS_ID_OVERFLOW;
|
||||
}
|
||||
|
||||
@ -919,25 +873,21 @@ int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux
|
||||
|
||||
pPps->uiNumSliceGroups = 1 + BsGetUe (pBsAux);
|
||||
|
||||
if (pPps->uiNumSliceGroups > MAX_SLICEGROUP_IDS)
|
||||
{
|
||||
if (pPps->uiNumSliceGroups > MAX_SLICEGROUP_IDS) {
|
||||
return ERR_INFO_INVALID_SLICEGROUP;
|
||||
}
|
||||
|
||||
if (pPps->uiNumSliceGroups > 1)
|
||||
{
|
||||
if (pPps->uiNumSliceGroups > 1) {
|
||||
pPps->uiSliceGroupMapType = BsGetUe (pBsAux);
|
||||
if( pPps->uiSliceGroupMapType > 1)
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "ParsePps(): slice_group_map_type (%d): support only 0,1.\n", pPps->uiSliceGroupMapType);
|
||||
if (pPps->uiSliceGroupMapType > 1) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParsePps(): slice_group_map_type (%d): support only 0,1.\n",
|
||||
pPps->uiSliceGroupMapType);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_FMOTYPE);
|
||||
}
|
||||
|
||||
switch(pPps->uiSliceGroupMapType)
|
||||
{
|
||||
switch (pPps->uiSliceGroupMapType) {
|
||||
case 0:
|
||||
for (iTmp = 0; iTmp < pPps->uiNumSliceGroups; iTmp++)
|
||||
{
|
||||
for (iTmp = 0; iTmp < pPps->uiNumSliceGroups; iTmp++) {
|
||||
pPps->uiRunLength[iTmp] = 1 + BsGetUe (pBsAux);
|
||||
}
|
||||
break;
|
||||
@ -950,16 +900,15 @@ int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux
|
||||
pPps->uiNumRefIdxL1Active = 1 + BsGetUe (pBsAux);
|
||||
|
||||
if (pPps->uiNumRefIdxL0Active > MAX_REF_PIC_COUNT ||
|
||||
pPps->uiNumRefIdxL1Active > MAX_REF_PIC_COUNT)
|
||||
{
|
||||
pPps->uiNumRefIdxL1Active > MAX_REF_PIC_COUNT) {
|
||||
return ERR_INFO_REF_COUNT_OVERFLOW;
|
||||
}
|
||||
|
||||
pPps->bWeightedPredFlag = !!BsGetOneBit (pBsAux);
|
||||
pPps->uiWeightedBipredIdc = BsGetBits (pBsAux, 2);
|
||||
if( pPps->bWeightedPredFlag || pPps->uiWeightedBipredIdc != 0 )
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "ParsePps(): weighted_pred_flag (%d) weighted_bipred_idc (%d) neither supported.\n", pPps->bWeightedPredFlag, pPps->uiWeightedBipredIdc);
|
||||
if (pPps->bWeightedPredFlag || pPps->uiWeightedBipredIdc != 0) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "ParsePps(): weighted_pred_flag (%d) weighted_bipred_idc (%d) neither supported.\n",
|
||||
pPps->bWeightedPredFlag, pPps->uiWeightedBipredIdc);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_WP);
|
||||
}
|
||||
|
||||
@ -995,8 +944,7 @@ int32_t ParsePps( PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux
|
||||
* \note Call it in case eNalUnitType is NAL_UNIT_SEI.
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t ParseSei( void_t *pSei, PBitStringAux pBsAux ) // reserved Sei_Msg type
|
||||
{
|
||||
int32_t ParseSei (void_t* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type
|
||||
|
||||
|
||||
return ERR_NONE;
|
||||
@ -1011,11 +959,9 @@ int32_t ParseSei( void_t *pSei, PBitStringAux pBsAux ) // reserved Sei_Msg type
|
||||
* \return count number of fmo context units are reset
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t ResetFmoList( PWelsDecoderContext pCtx )
|
||||
{
|
||||
int32_t ResetFmoList (PWelsDecoderContext pCtx) {
|
||||
int32_t iCountNum = 0;
|
||||
if ( NULL != 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;
|
||||
|
@ -43,17 +43,14 @@
|
||||
namespace WelsDec {
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
inline uint32_t EndianFix(uint32_t uiX)
|
||||
{
|
||||
inline uint32_t EndianFix (uint32_t uiX) {
|
||||
return uiX;
|
||||
}
|
||||
#else //WORDS_BIGENDIAN
|
||||
|
||||
#ifdef _MSC_VER
|
||||
inline uint32_t EndianFix(uint32_t uiX)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
inline uint32_t EndianFix (uint32_t uiX) {
|
||||
__asm {
|
||||
mov eax, uiX
|
||||
bswap eax
|
||||
mov uiX, eax
|
||||
@ -62,8 +59,7 @@ inline uint32_t EndianFix(uint32_t uiX)
|
||||
}
|
||||
#else //_MSC_VER
|
||||
|
||||
inline uint32_t EndianFix(uint32_t uiX)
|
||||
{
|
||||
inline uint32_t EndianFix (uint32_t uiX) {
|
||||
#ifdef ARM_ARCHv7
|
||||
__asm__ __volatile__ ("rev %0, %0":"+r" (uiX)); //Just for the ARMv7
|
||||
#elif defined (X86_ARCH)
|
||||
@ -78,15 +74,13 @@ inline uint32_t EndianFix(uint32_t uiX)
|
||||
|
||||
#endif //WORDS_BIGENDIAN
|
||||
|
||||
inline uint32_t GetValue4Bytes( uint8_t* pDstNal )
|
||||
{
|
||||
inline uint32_t GetValue4Bytes (uint8_t* pDstNal) {
|
||||
uint32_t uiValue = 0;
|
||||
uiValue = (pDstNal[0] << 24) | (pDstNal[1] << 16) | (pDstNal[2] << 8) | (pDstNal[3]);
|
||||
return uiValue;
|
||||
}
|
||||
|
||||
void_t InitReadBits( PBitStringAux pBitString )
|
||||
{
|
||||
void_t InitReadBits (PBitStringAux pBitString) {
|
||||
pBitString->uiCurBits = GetValue4Bytes (pBitString->pCurBuf);
|
||||
pBitString->pCurBuf += 4;
|
||||
pBitString->iLeftBits = -16;
|
||||
@ -101,8 +95,7 @@ void_t InitReadBits( PBitStringAux pBitString )
|
||||
*
|
||||
* \return size of buffer data in byte; failed in -1 return
|
||||
*/
|
||||
int32_t InitBits( PBitStringAux pBitString, const uint8_t *kpBuf, const int32_t kiSize )
|
||||
{
|
||||
int32_t InitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32_t kiSize) {
|
||||
const int32_t kiSizeBuf = (kiSize + 7) >> 3;
|
||||
uint8_t* pTmp = (uint8_t*)kpBuf;
|
||||
|
||||
|
@ -50,58 +50,48 @@ namespace WelsDec {
|
||||
|
||||
#if defined(X86_ASM)
|
||||
|
||||
uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
{
|
||||
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||
uint32_t uiCPU = 0;
|
||||
uint32_t uiFeatureA = 0, uiFeatureB = 0, uiFeatureC = 0, uiFeatureD = 0;
|
||||
int32_t CacheLineSize = 0;
|
||||
int8_t chVenderName[16] = { 0 };
|
||||
|
||||
if( !WelsCPUIdVerify() )
|
||||
{
|
||||
if (!WelsCPUIdVerify()) {
|
||||
/* cpuid is not supported in cpu */
|
||||
return 0;
|
||||
}
|
||||
|
||||
WelsCPUId (0, &uiFeatureA, (uint32_t*)&chVenderName[0], (uint32_t*)&chVenderName[8], (uint32_t*)&chVenderName[4]);
|
||||
if( uiFeatureA == 0 )
|
||||
{
|
||||
if (uiFeatureA == 0) {
|
||||
/* maximum input value for basic cpuid information */
|
||||
return 0;
|
||||
}
|
||||
|
||||
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
if( (uiFeatureD & 0x00800000) == 0 )
|
||||
{
|
||||
if ((uiFeatureD & 0x00800000) == 0) {
|
||||
/* Basic MMX technology is not support in cpu, mean nothing for us so return here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
uiCPU = WELS_CPU_MMX;
|
||||
if( uiFeatureD & 0x02000000 )
|
||||
{
|
||||
if (uiFeatureD & 0x02000000) {
|
||||
/* SSE technology is identical to AMD MMX extensions */
|
||||
uiCPU |= WELS_CPU_MMXEXT | WELS_CPU_SSE;
|
||||
}
|
||||
if( uiFeatureD & 0x04000000 )
|
||||
{
|
||||
if (uiFeatureD & 0x04000000) {
|
||||
/* SSE2 support here */
|
||||
uiCPU |= WELS_CPU_SSE2;
|
||||
}
|
||||
if ( uiFeatureD & 0x00000001 )
|
||||
{
|
||||
if (uiFeatureD & 0x00000001) {
|
||||
/* x87 FPU on-chip checking */
|
||||
uiCPU |= WELS_CPU_FPU;
|
||||
}
|
||||
if ( uiFeatureD & 0x00008000 )
|
||||
{
|
||||
if (uiFeatureD & 0x00008000) {
|
||||
/* CMOV instruction checking */
|
||||
uiCPU |= WELS_CPU_CMOV;
|
||||
}
|
||||
if ( !strcmp((const str_t*)chVenderName,CPU_Vender_INTEL) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if ( uiFeatureD & 0x10000000 )
|
||||
{
|
||||
if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
|
||||
if (uiFeatureD & 0x10000000) {
|
||||
/* Multi-Threading checking: contains of multiple logic processors */
|
||||
uiCPU |= WELS_CPU_HTT;
|
||||
}
|
||||
@ -123,36 +113,32 @@ uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
/* SSE4.2 support here, next generation Nehalem processor */
|
||||
uiCPU |= WELS_CPU_SSE42;
|
||||
}
|
||||
if ( WelsCPUSupportAVX( uiFeatureA, uiFeatureC ) )
|
||||
{
|
||||
if (WelsCPUSupportAVX (uiFeatureA, uiFeatureC)) {
|
||||
/* AVX supported */
|
||||
uiCPU |= WELS_CPU_AVX;
|
||||
}
|
||||
if ( WelsCPUSupportFMA( uiFeatureA, uiFeatureC ) )
|
||||
{
|
||||
if (WelsCPUSupportFMA (uiFeatureA, uiFeatureC)) {
|
||||
/* AVX FMA supported */
|
||||
uiCPU |= WELS_CPU_FMA;
|
||||
}
|
||||
if ( uiFeatureC & 0x02000000 )
|
||||
{
|
||||
if (uiFeatureC & 0x02000000) {
|
||||
/* AES checking */
|
||||
uiCPU |= WELS_CPU_AES;
|
||||
}
|
||||
if ( uiFeatureC & 0x00400000 )
|
||||
{
|
||||
if (uiFeatureC & 0x00400000) {
|
||||
/* MOVBE checking */
|
||||
uiCPU |= WELS_CPU_MOVBE;
|
||||
}
|
||||
|
||||
if ( pNumberOfLogicProcessors != NULL )
|
||||
{
|
||||
if (pNumberOfLogicProcessors != NULL) {
|
||||
// HTT enabled on chip
|
||||
*pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
|
||||
}
|
||||
|
||||
WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
|
||||
if( (!strcmp((const str_t*)chVenderName,CPU_Vender_AMD)) && (uiFeatureA>=0x80000001) ){ // confirmed_safe_unsafe_usage
|
||||
if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_AMD))
|
||||
&& (uiFeatureA >= 0x80000001)) { // confirmed_safe_unsafe_usage
|
||||
WelsCPUId (0x80000001, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
if (uiFeatureD & 0x00400000) {
|
||||
uiCPU |= WELS_CPU_MMXEXT;
|
||||
@ -175,21 +161,20 @@ uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
}
|
||||
|
||||
// get cache line size
|
||||
if( (!strcmp((const str_t*)chVenderName,CPU_Vender_INTEL)) || !(strcmp((const str_t*)chVenderName,CPU_Vender_CYRIX)) ){ // confirmed_safe_unsafe_usage
|
||||
if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL))
|
||||
|| ! (strcmp ((const str_t*)chVenderName, CPU_Vender_CYRIX))) { // confirmed_safe_unsafe_usage
|
||||
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
|
||||
CacheLineSize = (uiFeatureB&0xff00)>>5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
|
||||
CacheLineSize = (uiFeatureB & 0xff00) >>
|
||||
5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
|
||||
|
||||
if (CacheLineSize == 128) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_128;
|
||||
}
|
||||
else if( CacheLineSize == 64 ){
|
||||
} else if (CacheLineSize == 64) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_64;
|
||||
}
|
||||
else if( CacheLineSize == 32 ){
|
||||
} else if (CacheLineSize == 32) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_32;
|
||||
}
|
||||
else if( CacheLineSize == 16 ){
|
||||
} else if (CacheLineSize == 16) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_16;
|
||||
}
|
||||
}
|
||||
@ -198,10 +183,8 @@ uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
}
|
||||
|
||||
|
||||
void WelsCPURestore( const uint32_t kuiCPU )
|
||||
{
|
||||
if( kuiCPU & (WELS_CPU_MMX|WELS_CPU_MMXEXT|WELS_CPU_3DNOW|WELS_CPU_3DNOWEXT) )
|
||||
{
|
||||
void WelsCPURestore (const uint32_t kuiCPU) {
|
||||
if (kuiCPU & (WELS_CPU_MMX | WELS_CPU_MMXEXT | WELS_CPU_3DNOW | WELS_CPU_3DNOWEXT)) {
|
||||
WelsEmms();
|
||||
}
|
||||
}
|
||||
|
@ -124,13 +124,16 @@ static const int8_t g_kiTc0Table[52+24][4] = { //this table refers Table 8-17 in
|
||||
, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }
|
||||
};
|
||||
|
||||
static const uint8_t g_kuiTableBIdx[2][8] =
|
||||
static const uint8_t g_kuiTableBIdx[2][8] = {
|
||||
{
|
||||
{0, 4, 8, 12,
|
||||
3, 7, 11, 15},
|
||||
0, 4, 8, 12,
|
||||
3, 7, 11, 15
|
||||
},
|
||||
|
||||
{0, 1, 2, 3 ,
|
||||
12, 13, 14, 15},
|
||||
{
|
||||
0, 1, 2, 3 ,
|
||||
12, 13, 14, 15
|
||||
},
|
||||
};
|
||||
|
||||
#define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \
|
||||
@ -141,8 +144,7 @@ static const uint8_t g_kuiTableBIdx[2][8] =
|
||||
tc[3] = g_kiTc0Table(iIndexA)[pBS[3]] + bChroma;\
|
||||
}
|
||||
|
||||
void_t inline DeblockingBSInsideMBAvsbase( int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor )
|
||||
{
|
||||
void_t inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) {
|
||||
uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, uiBsx3, 4, 4);
|
||||
|
||||
@ -176,8 +178,8 @@ void_t inline DeblockingBSInsideMBAvsbase( int8_t* pNnzTab, uint8_t nBS[2][4][4]
|
||||
|
||||
}
|
||||
|
||||
void_t static inline DeblockingBSInsideMBNormal( PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, int32_t iMbXy )
|
||||
{
|
||||
void_t static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab,
|
||||
int32_t iMbXy) {
|
||||
uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
|
||||
int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy];
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4);
|
||||
@ -227,8 +229,7 @@ void_t static inline DeblockingBSInsideMBNormal( PDqLayer pCurDqLayer, uint8_t n
|
||||
nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11);
|
||||
}
|
||||
|
||||
uint32_t DeblockingBsMarginalMBAvcbase( PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy)
|
||||
{
|
||||
uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) {
|
||||
int32_t i;
|
||||
uint32_t uiBSx4;
|
||||
//uint8_t* bS = static_cast<uint8_t*>(&uiBSx4);
|
||||
@ -236,53 +237,45 @@ uint32_t DeblockingBsMarginalMBAvcbase( PDqLayer pCurDqLayer, int32_t iEdge, int
|
||||
uint32_t uiBIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][0]);
|
||||
uint32_t uiBnIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][4]);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
if( pCurDqLayer->pNzc[iMbXy][uiBIdx&0xff] | pCurDqLayer->pNzc[iNeighMb][uiBnIdx&0xff] )
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (pCurDqLayer->pNzc[iMbXy][uiBIdx & 0xff] | pCurDqLayer->pNzc[iNeighMb][uiBnIdx & 0xff]) {
|
||||
pBS[i] = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pBS[i] = MB_BS_MV(pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, (uiBIdx&0xff), (uiBnIdx&0xff));
|
||||
} else {
|
||||
pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, (uiBIdx & 0xff),
|
||||
(uiBnIdx & 0xff));
|
||||
}
|
||||
uiBIdx = uiBIdx >> 8;
|
||||
uiBnIdx = uiBnIdx >> 8;
|
||||
}
|
||||
return uiBSx4;
|
||||
}
|
||||
int32_t DeblockingAvailableNoInterlayer( PDqLayer pCurDqLayer, int32_t iFilterIdc )
|
||||
{
|
||||
int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) {
|
||||
int32_t iMbY = pCurDqLayer->iMbY;
|
||||
int32_t iMbX = pCurDqLayer->iMbX;
|
||||
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
|
||||
BOOL_T bLeftFlag = FALSE;
|
||||
BOOL_T bTopFlag = FALSE;
|
||||
|
||||
if ( 2 == iFilterIdc )
|
||||
{
|
||||
if (2 == iFilterIdc) {
|
||||
bLeftFlag = (iMbX > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - 1]);
|
||||
bTopFlag = (iMbY > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - pCurDqLayer->iMbWidth]);
|
||||
}
|
||||
else //if ( 0 == iFilterIdc )
|
||||
{
|
||||
} else { //if ( 0 == iFilterIdc )
|
||||
bLeftFlag = (iMbX > 0);
|
||||
bTopFlag = (iMbY > 0);
|
||||
}
|
||||
return (bLeftFlag << LEFT_FLAG_BIT) | (bTopFlag << TOP_FLAG_BIT);
|
||||
}
|
||||
|
||||
void_t FilteringEdgeLumaH(SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeLumaH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0);
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Ver (pPix, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
@ -290,17 +283,16 @@ void_t FilteringEdgeLumaH(SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iSt
|
||||
}
|
||||
|
||||
|
||||
void_t FilteringEdgeLumaV(SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeLumaV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0);
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Hor (pPix, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
@ -308,101 +300,99 @@ void_t FilteringEdgeLumaV(SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iSt
|
||||
}
|
||||
|
||||
|
||||
void_t FilteringEdgeLumaIntraH( SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeLumaIntraH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfLumaDeblockingEQ4Ver (pPix, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void_t FilteringEdgeLumaIntraV( SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeLumaIntraV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfLumaDeblockingEQ4Hor (pPix, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void_t FilteringEdgeChromaH( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void_t FilteringEdgeChromaV( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void_t FilteringEdgeChromaIntraH( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void_t FilteringEdgeChromaIntraV( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void_t FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIndexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockinEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void_t DeblockingInterMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], int32_t iBoundryFlag )
|
||||
{
|
||||
void_t DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4],
|
||||
int32_t iBoundryFlag) {
|
||||
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
|
||||
int32_t iMbX = pCurDqLayer->iMbX;
|
||||
int32_t iMbY = pCurDqLayer->iMbY;
|
||||
@ -417,21 +407,16 @@ void_t DeblockingInterMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint
|
||||
pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSizeUV + iMbX) << 3);
|
||||
pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSizeUV + iMbX) << 3);
|
||||
|
||||
if( iBoundryFlag & LEFT_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & LEFT_FLAG_MASK) {
|
||||
int32_t iLeftXyIndex = iMbXyIndex - 1;
|
||||
pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iLeftXyIndex] + 1) >> 1;
|
||||
pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iLeftXyIndex] + 1) >> 1;
|
||||
|
||||
if( nBS[0][0][0] == 0x04 )
|
||||
{
|
||||
if (nBS[0][0][0] == 0x04) {
|
||||
FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL);
|
||||
FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*(uint32_t *)nBS[0][0] != 0)
|
||||
{
|
||||
} else {
|
||||
if (* (uint32_t*)nBS[0][0] != 0) {
|
||||
FilteringEdgeLumaV (pFilter, pDestY, iLineSize, nBS[0][0]);
|
||||
FilteringEdgeChromaV (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[0][0]);
|
||||
}
|
||||
@ -441,37 +426,29 @@ void_t DeblockingInterMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint
|
||||
pFilter->iLumaQP = iCurLumaQp;
|
||||
pFilter->iChromaQP = iCurChromaQp;
|
||||
|
||||
if(*(uint32_t *)nBS[0][1] != 0)
|
||||
{
|
||||
if (* (uint32_t*)nBS[0][1] != 0) {
|
||||
FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)nBS[0][2] != 0)
|
||||
{
|
||||
if (* (uint32_t*)nBS[0][2] != 0) {
|
||||
FilteringEdgeLumaV (pFilter, &pDestY[2 << 2], iLineSize, nBS[0][2]);
|
||||
FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)nBS[0][3] != 0)
|
||||
{
|
||||
if (* (uint32_t*)nBS[0][3] != 0) {
|
||||
FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]);
|
||||
}
|
||||
|
||||
if( iBoundryFlag & TOP_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & TOP_FLAG_MASK) {
|
||||
int32_t iTopXyIndex = iMbXyIndex - pCurDqLayer->iMbWidth;
|
||||
pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iTopXyIndex] + 1) >> 1;
|
||||
pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iTopXyIndex] + 1) >> 1;
|
||||
|
||||
if( nBS[1][0][0] == 0x04)
|
||||
{
|
||||
if (nBS[1][0][0] == 0x04) {
|
||||
FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL);
|
||||
FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*(uint32_t *)nBS[1][0] != 0)
|
||||
{
|
||||
} else {
|
||||
if (* (uint32_t*)nBS[1][0] != 0) {
|
||||
FilteringEdgeLumaH (pFilter, pDestY, iLineSize, nBS[1][0]);
|
||||
FilteringEdgeChromaH (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[1][0]);
|
||||
}
|
||||
@ -481,25 +458,22 @@ void_t DeblockingInterMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint
|
||||
pFilter->iLumaQP = iCurLumaQp;
|
||||
pFilter->iChromaQP = iCurChromaQp;
|
||||
|
||||
if(*(uint32_t *)nBS[1][1] != 0)
|
||||
{
|
||||
if (* (uint32_t*)nBS[1][1] != 0) {
|
||||
FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)nBS[1][2] != 0)
|
||||
{
|
||||
if (* (uint32_t*)nBS[1][2] != 0) {
|
||||
FilteringEdgeLumaH (pFilter, &pDestY[ (2 << 2)*iLineSize], iLineSize, nBS[1][2]);
|
||||
FilteringEdgeChromaH( pFilter, &pDestCb[(2<<1)*iLineSizeUV], &pDestCr[(2<<1)*iLineSizeUV], iLineSizeUV, nBS[1][2] );
|
||||
FilteringEdgeChromaH (pFilter, &pDestCb[ (2 << 1)*iLineSizeUV], &pDestCr[ (2 << 1)*iLineSizeUV], iLineSizeUV,
|
||||
nBS[1][2]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)nBS[1][3] != 0)
|
||||
{
|
||||
if (* (uint32_t*)nBS[1][3] != 0) {
|
||||
FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]);
|
||||
}
|
||||
}
|
||||
|
||||
void_t /*__FASTCALL*/ FilteringEdgeLumaHV( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )
|
||||
{
|
||||
void_t /*__FASTCALL*/ FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
|
||||
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
|
||||
int32_t iMbX = pCurDqLayer->iMbX;
|
||||
int32_t iMbY = pCurDqLayer->iMbY;
|
||||
@ -519,16 +493,15 @@ void_t /*__FASTCALL*/ FilteringEdgeLumaHV( PDqLayer pCurDqLayer, PDeblockingFilt
|
||||
* (uint32_t*)uiBSx4 = 0x03030303;
|
||||
|
||||
// luma v
|
||||
if( iBoundryFlag & LEFT_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & LEFT_FLAG_MASK) {
|
||||
pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - 1] + 1) >> 1;
|
||||
FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->iLumaQP = iCurQp;
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 0);
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc);
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc);
|
||||
@ -536,22 +509,19 @@ void_t /*__FASTCALL*/ FilteringEdgeLumaHV( PDqLayer pCurDqLayer, PDeblockingFilt
|
||||
}
|
||||
|
||||
// luma h
|
||||
if( iBoundryFlag & TOP_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & TOP_FLAG_MASK) {
|
||||
pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - iMbWidth] + 1) >> 1;
|
||||
FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->iLumaQP = iCurQp;
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
|
||||
pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
|
||||
}
|
||||
}
|
||||
void_t /*__FASTCALL*/ FilteringEdgeChromaHV( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )
|
||||
{
|
||||
void_t /*__FASTCALL*/ FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
|
||||
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
|
||||
int32_t iMbX = pCurDqLayer->iMbX;
|
||||
int32_t iMbY = pCurDqLayer->iMbY;
|
||||
@ -571,51 +541,46 @@ void_t /*__FASTCALL*/ FilteringEdgeChromaHV( PDqLayer pCurDqLayer, PDeblockingFi
|
||||
* (uint32_t*)uiBSx4 = 0x03030303;
|
||||
|
||||
// chroma v
|
||||
if( iBoundryFlag & LEFT_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & LEFT_FLAG_MASK) {
|
||||
pFilter->iChromaQP = (iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex - 1] + 1) >> 1;
|
||||
FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->iChromaQP = iCurQp;
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1);
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc);
|
||||
}
|
||||
|
||||
// chroma h
|
||||
if( iBoundryFlag & TOP_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & TOP_FLAG_MASK) {
|
||||
pFilter->iChromaQP = (iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex - iMbWidth] + 1) >> 1;
|
||||
FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->iChromaQP = iCurQp;
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver( &pDestCb[(2<<1)*iLineSize],&pDestCr[(2<<1)*iLineSize],iLineSize,iAlpha,iBeta,iTc );
|
||||
if (iAlpha | iBeta) {
|
||||
pFilter->pLoopf->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize,
|
||||
iAlpha, iBeta, iTc);
|
||||
}
|
||||
}
|
||||
|
||||
// merge h&v lookup table operation to save performance
|
||||
void_t DeblockingIntraMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )
|
||||
{
|
||||
void_t DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
|
||||
FilteringEdgeLumaHV (pCurDqLayer, pFilter, iBoundryFlag);
|
||||
FilteringEdgeChromaHV (pCurDqLayer, pFilter, iBoundryFlag);
|
||||
}
|
||||
|
||||
void_t WelsDeblockingMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )
|
||||
{
|
||||
void_t WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
|
||||
uint8_t nBS[2][4][4] = { 0 };
|
||||
|
||||
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
|
||||
int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex];
|
||||
int32_t iMbNb;
|
||||
|
||||
switch( iCurMbType )
|
||||
{
|
||||
switch (iCurMbType) {
|
||||
case MB_TYPE_INTRA4x4:
|
||||
case MB_TYPE_INTRA16x16:
|
||||
case MB_TYPE_INTRA_PCM:
|
||||
@ -623,38 +588,28 @@ void_t WelsDeblockingMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32
|
||||
break;
|
||||
default:
|
||||
|
||||
if(iBoundryFlag & LEFT_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & LEFT_FLAG_MASK) {
|
||||
iMbNb = iMbXyIndex - 1;
|
||||
*(uint32_t*)nBS[0][0] = IS_INTRA(pCurDqLayer->pMbType[iMbNb])?0x04040404:DeblockingBsMarginalMBAvcbase( pCurDqLayer, 0, iMbNb, iMbXyIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
* (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
|
||||
pCurDqLayer, 0, iMbNb, iMbXyIndex);
|
||||
} else {
|
||||
* (uint32_t*)nBS[0][0] = 0;
|
||||
}
|
||||
if(iBoundryFlag & TOP_FLAG_MASK)
|
||||
{
|
||||
if (iBoundryFlag & TOP_FLAG_MASK) {
|
||||
iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth;
|
||||
*(uint32_t*)nBS[1][0] = IS_INTRA(pCurDqLayer->pMbType[iMbNb])?0x04040404:DeblockingBsMarginalMBAvcbase( pCurDqLayer, 1, iMbNb, iMbXyIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
* (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
|
||||
pCurDqLayer, 1, iMbNb, iMbXyIndex);
|
||||
} else {
|
||||
* (uint32_t*)nBS[1][0] = 0;
|
||||
}
|
||||
//SKIP MB_16x16 or others
|
||||
if( iCurMbType != MB_TYPE_SKIP )
|
||||
{
|
||||
if( iCurMbType == MB_TYPE_16x16 )
|
||||
{
|
||||
if (iCurMbType != MB_TYPE_SKIP) {
|
||||
if (iCurMbType == MB_TYPE_16x16) {
|
||||
DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
* (uint32_t*)nBS[0][1] = * (uint32_t*)nBS[0][2] = * (uint32_t*)nBS[0][3] =
|
||||
* (uint32_t*)nBS[1][1] = * (uint32_t*)nBS[1][2] = * (uint32_t*)nBS[1][3] = 0;
|
||||
}
|
||||
@ -664,13 +619,11 @@ void_t WelsDeblockingMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32
|
||||
}
|
||||
|
||||
// C code only
|
||||
void_t DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc )
|
||||
{
|
||||
for( int32_t i = 0;i<16;i++)
|
||||
{
|
||||
void_t DeblockLumaLt4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc) {
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
int32_t iTc0 = pTc[i >> 2];
|
||||
if(iTc0>=0)
|
||||
{
|
||||
if (iTc0 >= 0) {
|
||||
int32_t p0 = pPix[-iStrideX];
|
||||
int32_t p1 = pPix[-2 * iStrideX];
|
||||
int32_t p2 = pPix[-3 * iStrideX];
|
||||
@ -681,17 +634,14 @@ void_t DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32
|
||||
bool_t bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bool_t bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
int32_t iTc = iTc0;
|
||||
if ( bDetaP0Q0&& bDetaP1P0 && bDetaQ1Q0 )
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta;
|
||||
bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta;
|
||||
if ( bDetaP2P0)
|
||||
{
|
||||
if (bDetaP2P0) {
|
||||
pPix[-2 * iStrideX] = p1 + WELS_CLIP3 ((p2 + ((p0 + q0 + 1) >> 1) - (p1 << 1)) >> 1, -iTc0, iTc0);
|
||||
iTc++;
|
||||
}
|
||||
if (bDetaQ2Q0)
|
||||
{
|
||||
if (bDetaQ2Q0) {
|
||||
pPix[iStrideX] = q1 + WELS_CLIP3 ((q2 + ((p0 + q0 + 1) >> 1) - (q1 << 1)) >> 1, -iTc0, iTc0);
|
||||
iTc++;
|
||||
}
|
||||
@ -703,13 +653,11 @@ void_t DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32
|
||||
pPix += iStrideY;
|
||||
}
|
||||
}
|
||||
void_t DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void_t DeblockLumaEq4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta) {
|
||||
int32_t p0, p1, p2, q0, q1, q2;
|
||||
int32_t iDetaP0Q0;
|
||||
bool_t bDetaP1P0, bDetaQ1Q0;
|
||||
for (int32_t i = 0;i<16;i++)
|
||||
{
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
p0 = pPix[-iStrideX];
|
||||
p1 = pPix[-2 * iStrideX];
|
||||
p2 = pPix[-3 * iStrideX];
|
||||
@ -719,37 +667,27 @@ void_t DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int3
|
||||
iDetaP0Q0 = WELS_ABS (p0 - q0);
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if ((iDetaP0Q0<iAlpha) && bDetaP1P0 &&bDetaQ1Q0)
|
||||
{
|
||||
if (iDetaP0Q0< (( iAlpha >> 2 ) + 2 ) )
|
||||
{
|
||||
if ((iDetaP0Q0 < iAlpha) && bDetaP1P0 && bDetaQ1Q0) {
|
||||
if (iDetaP0Q0 < ((iAlpha >> 2) + 2)) {
|
||||
bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta;
|
||||
bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta;
|
||||
if(bDetaP2P0)
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pPix[-1 * iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0
|
||||
}
|
||||
if (bDetaQ2Q0)
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pPix[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pPix[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0
|
||||
pPix[ 0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0
|
||||
}
|
||||
@ -757,32 +695,26 @@ void_t DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int3
|
||||
pPix += iStrideY;
|
||||
}
|
||||
}
|
||||
void_t DeblockLumaLt4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
|
||||
{
|
||||
void_t DeblockLumaLt4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* tc) {
|
||||
DeblockLumaLt4_c (pPix, iStride, 1, iAlpha, iBeta, tc);
|
||||
}
|
||||
void_t DeblockLumaLt4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
|
||||
{
|
||||
void_t DeblockLumaLt4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* tc) {
|
||||
DeblockLumaLt4_c (pPix, 1, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
void_t DeblockLumaEq4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void_t DeblockLumaEq4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockLumaEq4_c (pPix, iStride, 1, iAlpha, iBeta);
|
||||
}
|
||||
void_t DeblockLumaEq4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void_t DeblockLumaEq4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockLumaEq4_c (pPix, 1, iStride, iAlpha, iBeta);
|
||||
}
|
||||
void_t DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc )
|
||||
{
|
||||
void_t DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* pTc) {
|
||||
int32_t p0, p1, q0, q1, iDeta;
|
||||
bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
|
||||
|
||||
for(int32_t i = 0;i<8;i++)
|
||||
{
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
int32_t iTc0 = pTc[i >> 1];
|
||||
if(iTc0 >0)
|
||||
{
|
||||
if (iTc0 > 0) {
|
||||
p0 = pPixCb[-iStrideX];
|
||||
p1 = pPixCb[-2 * iStrideX];
|
||||
q0 = pPixCb[0];
|
||||
@ -791,8 +723,7 @@ void_t DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, i
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
|
||||
pPixCb[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
|
||||
pPixCb[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
|
||||
@ -808,8 +739,7 @@ void_t DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, i
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
|
||||
if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
|
||||
pPixCr[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
|
||||
pPixCr[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
|
||||
@ -819,13 +749,12 @@ void_t DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, i
|
||||
pPixCr += iStrideY;
|
||||
}
|
||||
}
|
||||
void_t DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void_t DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta) {
|
||||
int32_t i = 0, d = 0;
|
||||
int32_t p0, p1, q0, q1;
|
||||
bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
|
||||
for(int32_t i =0;i<8;i++)
|
||||
{
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
//cb
|
||||
p0 = pPixCb[-iStrideX];
|
||||
p1 = pPixCb[-2 * iStrideX];
|
||||
@ -834,8 +763,7 @@ void_t DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, i
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
pPixCb[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
|
||||
pPixCb[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
|
||||
}
|
||||
@ -848,8 +776,7 @@ void_t DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, i
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
pPixCr[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
|
||||
pPixCr[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
|
||||
}
|
||||
@ -857,27 +784,24 @@ void_t DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, i
|
||||
pPixCb += iStrideY;
|
||||
}
|
||||
}
|
||||
void_t DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
|
||||
{
|
||||
void_t DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* tc) {
|
||||
DeblockChromaLt4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, tc);
|
||||
}
|
||||
void_t DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
|
||||
{
|
||||
void_t DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* tc) {
|
||||
DeblockChromaLt4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, tc);
|
||||
}
|
||||
void_t DeblockChromaEq4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void_t DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockChromaEq4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta);
|
||||
}
|
||||
void_t DeblockChromaEq4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void_t DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockChromaEq4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta);
|
||||
}
|
||||
|
||||
#ifdef X86_ASM
|
||||
extern "C" {
|
||||
void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc)
|
||||
{
|
||||
void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16);
|
||||
|
||||
DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]);
|
||||
@ -885,8 +809,7 @@ void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32
|
||||
DeblockLumaTransposeV2H_sse2 (pPixY - 4, iStride, &uiBuf[0]);
|
||||
}
|
||||
|
||||
void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta)
|
||||
{
|
||||
void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16);
|
||||
|
||||
DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]);
|
||||
@ -904,8 +827,7 @@ void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32
|
||||
*
|
||||
* \return NONE
|
||||
*/
|
||||
void_t WelsDeblockingFilterSlice( PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb )
|
||||
{
|
||||
void_t WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb) {
|
||||
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
|
||||
PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;
|
||||
int32_t iMbWidth = pCurDqLayer->iMbWidth;
|
||||
@ -936,35 +858,28 @@ void_t WelsDeblockingFilterSlice( PWelsDecoderContext pCtx, PDeblockingFilterMbF
|
||||
pFilter.pLoopf = &pCtx->sDeblockingFunc;
|
||||
|
||||
/* Step2: macroblock deblocking */
|
||||
if( 0 == iFilterIdc || 2 == iFilterIdc )
|
||||
{
|
||||
if (0 == iFilterIdc || 2 == iFilterIdc) {
|
||||
iNextMbXyIndex = pSliceHeaderExt->sSliceHeader.iFirstMbInSlice;
|
||||
pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth;
|
||||
pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth;
|
||||
pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, iFilterIdc);
|
||||
|
||||
pDeblockMb (pCurDqLayer, &pFilter, iBoundryFlag);
|
||||
|
||||
++iCountNumMb;
|
||||
if ( iCountNumMb >= iTotalNumMb )
|
||||
{
|
||||
if (iCountNumMb >= iTotalNumMb) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pSliceHeaderExt->sSliceHeader.pPps->uiNumSliceGroups > 1 )
|
||||
{
|
||||
if (pSliceHeaderExt->sSliceHeader.pPps->uiNumSliceGroups > 1) {
|
||||
iNextMbXyIndex = FmoNextMb (pFmo, iNextMbXyIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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;
|
||||
}
|
||||
|
||||
@ -983,8 +898,7 @@ void_t WelsDeblockingFilterSlice( PWelsDecoderContext pCtx, PDeblockingFilterMbF
|
||||
* \return NONE
|
||||
*/
|
||||
|
||||
void_t DeblockingInit( SDeblockingFunc *pFunc, int32_t iCpu )
|
||||
{
|
||||
void_t DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) {
|
||||
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c;
|
||||
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c;
|
||||
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c;
|
||||
|
@ -38,18 +38,17 @@
|
||||
namespace WelsDec {
|
||||
|
||||
#define MAX_NEG_CROP 1024
|
||||
uint8_t g_ClipTable[256 + 2 * MAX_NEG_CROP]; //the front 1024 is 0, the back 1024 is 255, the middle 256 elements is 0-255
|
||||
uint8_t g_ClipTable[256 + 2 *
|
||||
MAX_NEG_CROP]; //the front 1024 is 0, the back 1024 is 255, the middle 256 elements is 0-255
|
||||
|
||||
|
||||
/* init pClip table to pClip the final dct data */
|
||||
void_t InitDctClipTable(void_t)
|
||||
{
|
||||
void_t InitDctClipTable (void_t) {
|
||||
uint8_t* p = &g_ClipTable[0];
|
||||
const int32_t kiLength = MAX_NEG_CROP * sizeof (uint8_t);
|
||||
int32_t i = 0;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
const int32_t kiIdx = MAX_NEG_CROP + i;
|
||||
|
||||
p[kiIdx] = i;
|
||||
@ -66,8 +65,7 @@ void_t InitDctClipTable(void_t)
|
||||
|
||||
//NOTE::: p_RS should NOT be modified and it will lead to mismatch with JSVM.
|
||||
// so should allocate kA array to store the temporary value (idct).
|
||||
void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs)
|
||||
{
|
||||
void_t IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
|
||||
int16_t iSrc[16];
|
||||
|
||||
uint8_t* pDst = pPred;
|
||||
@ -76,8 +74,7 @@ void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs)
|
||||
uint8_t* pClip = &g_ClipTable[MAX_NEG_CROP];
|
||||
int32_t i;
|
||||
|
||||
for(i=0; i<4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
const int32_t kiY = i << 2;
|
||||
const int32_t kiT0 = pRs[kiY] + pRs[kiY + 2];
|
||||
const int32_t kiT1 = pRs[kiY] - pRs[kiY + 2];
|
||||
@ -90,8 +87,7 @@ void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs)
|
||||
iSrc[kiY + 3] = kiT0 - kiT3;
|
||||
}
|
||||
|
||||
for(i=0; i<4; i++)
|
||||
{
|
||||
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;
|
||||
@ -107,14 +103,12 @@ void_t IdctResAddPred_c(uint8_t *pPred, const int32_t kiStride, int16_t *pRs)
|
||||
}
|
||||
}
|
||||
|
||||
void_t GetI4LumaIChromaAddrTable(int32_t *pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride)
|
||||
{
|
||||
void_t GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) {
|
||||
int32_t* pOffset = pBlockOffset;
|
||||
int32_t i;
|
||||
const uint8_t kuiScan0 = g_kuiScan8[0];
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
for (i = 0; i < 16; i++) {
|
||||
const uint32_t kuiA = g_kuiScan8[i] - kuiScan0;
|
||||
const uint32_t kuiX = kuiA & 0x07;
|
||||
const uint32_t kuiY = kuiA >> 3;
|
||||
@ -122,8 +116,7 @@ void_t GetI4LumaIChromaAddrTable(int32_t *pBlockOffset, const int32_t kiYStride,
|
||||
pOffset[i] = (kuiX + kiYStride * kuiY) << 2;
|
||||
}
|
||||
|
||||
for(i=0; i<4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
const uint32_t kuiA = g_kuiScan8[i] - kuiScan0;
|
||||
|
||||
pOffset[16 + i] =
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -70,16 +70,14 @@ extern PPicture AllocPicture( PWelsDecoderContext pCtx,const int32_t kiPicWidth,
|
||||
extern void_t FreePicture (PPicture pPic);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
inline void_t GetValueOf4Bytes( uint8_t* pDstNal, int32_t iDdstIdx )
|
||||
{
|
||||
inline void_t GetValueOf4Bytes (uint8_t* pDstNal, int32_t iDdstIdx) {
|
||||
pDstNal[0] = (iDdstIdx & 0xff000000) >> 24;
|
||||
pDstNal[1] = (iDdstIdx & 0xff0000) >> 16;
|
||||
pDstNal[2] = (iDdstIdx & 0xff00) >> 8;
|
||||
pDstNal[3] = (iDdstIdx & 0xff);
|
||||
}
|
||||
#else //WORDS_BIGENDIAN
|
||||
inline void_t GetValueOf4Bytes( uint8_t* pDstNal, int32_t iDdstIdx )
|
||||
{
|
||||
inline void_t GetValueOf4Bytes (uint8_t* pDstNal, int32_t iDdstIdx) {
|
||||
pDstNal[0] = (iDdstIdx & 0xff);
|
||||
pDstNal[1] = (iDdstIdx & 0xff00) >> 8;
|
||||
pDstNal[2] = (iDdstIdx & 0xff0000) >> 16;
|
||||
@ -87,33 +85,28 @@ inline void_t GetValueOf4Bytes( uint8_t* pDstNal, int32_t iDdstIdx )
|
||||
}
|
||||
#endif //WORDS_BIGENDIAN
|
||||
|
||||
static int32_t CreatePicBuff(PWelsDecoderContext pCtx, PPicBuff *ppPicBuf, const int32_t kiSize, const int32_t kiPicWidth, const int32_t kiPicHeight)
|
||||
{
|
||||
static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize,
|
||||
const int32_t kiPicWidth, const int32_t kiPicHeight) {
|
||||
PPicBuff pPicBuf = NULL;
|
||||
int32_t iPicIdx = 0;
|
||||
if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0)
|
||||
{
|
||||
if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicBuf = (PPicBuff)WelsMalloc (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if ( NULL == pPicBuf )
|
||||
{
|
||||
if (NULL == pPicBuf) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicBuf->ppPic = (PPicture*)WelsMalloc (kiSize * sizeof (PPicture), "PPicture*");
|
||||
|
||||
if ( NULL == pPicBuf->ppPic )
|
||||
{
|
||||
if (NULL == pPicBuf->ppPic) {
|
||||
return 1;
|
||||
}
|
||||
for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx)
|
||||
{
|
||||
for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx) {
|
||||
PPicture pPic = AllocPicture (pCtx, kiPicWidth, kiPicHeight);
|
||||
if ( NULL == pPic )
|
||||
{
|
||||
if (NULL == pPic) {
|
||||
return 1;
|
||||
}
|
||||
pPicBuf->ppPic[iPicIdx] = pPic;
|
||||
@ -127,22 +120,18 @@ static int32_t CreatePicBuff(PWelsDecoderContext pCtx, PPicBuff *ppPicBuf, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void_t DestroyPicBuff( PPicBuff *ppPicBuf )
|
||||
{
|
||||
static void_t DestroyPicBuff (PPicBuff* ppPicBuf) {
|
||||
PPicBuff pPicBuf = NULL;
|
||||
|
||||
if (NULL == ppPicBuf || NULL == *ppPicBuf)
|
||||
return;
|
||||
|
||||
pPicBuf = *ppPicBuf;
|
||||
while(pPicBuf->ppPic != NULL)
|
||||
{
|
||||
while (pPicBuf->ppPic != NULL) {
|
||||
int32_t iPicIdx = 0;
|
||||
while (iPicIdx < pPicBuf->iCapacity)
|
||||
{
|
||||
while (iPicIdx < pPicBuf->iCapacity) {
|
||||
PPicture pPic = pPicBuf->ppPic[iPicIdx];
|
||||
if(pPic != NULL)
|
||||
{
|
||||
if (pPic != NULL) {
|
||||
FreePicture (pPic);
|
||||
}
|
||||
pPic = NULL;
|
||||
@ -164,8 +153,7 @@ static void_t DestroyPicBuff( PPicBuff *ppPicBuf )
|
||||
/*
|
||||
* fill data fields in default for decoder context
|
||||
*/
|
||||
void_t WelsDecoderDefaults( PWelsDecoderContext pCtx )
|
||||
{
|
||||
void_t WelsDecoderDefaults (PWelsDecoderContext pCtx) {
|
||||
int32_t iCpuCores = 1;
|
||||
memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first
|
||||
|
||||
@ -182,12 +170,9 @@ void_t WelsDecoderDefaults( PWelsDecoderContext pCtx )
|
||||
#if defined(X86_ASM)
|
||||
pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
|
||||
#ifdef HAVE_CACHE_LINE_ALIGN
|
||||
if ( pCtx->uiCpuFlag & WELS_CPU_CACHELINE_64 )
|
||||
{
|
||||
if (pCtx->uiCpuFlag & WELS_CPU_CACHELINE_64) {
|
||||
g_uiCacheLineSize = 64;
|
||||
}
|
||||
else if ( pCtx->uiCpuFlag & WELS_CPU_CACHELINE_32 )
|
||||
{
|
||||
} else if (pCtx->uiCpuFlag & WELS_CPU_CACHELINE_32) {
|
||||
g_uiCacheLineSize = 32;
|
||||
}
|
||||
#endif//HAVE_CACHE_LINE_ALIGN
|
||||
@ -221,8 +206,7 @@ void_t WelsDecoderDefaults( PWelsDecoderContext pCtx )
|
||||
/*
|
||||
* get size of reference picture list in target layer incoming, = (iNumRefFrames x 2)
|
||||
*/
|
||||
static inline int32_t GetTargetRefListSize( PWelsDecoderContext pCtx )
|
||||
{
|
||||
static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) {
|
||||
bool_t* pSubsetSpsAvail = &pCtx->bSubspsAvailFlags[0];
|
||||
bool_t* pSpsAvail = &pCtx->bSpsAvailFlags[0];
|
||||
int32_t iSubsetIdx = -1;
|
||||
@ -232,10 +216,8 @@ static inline int32_t GetTargetRefListSize( PWelsDecoderContext pCtx )
|
||||
int32_t iPos = MAX_SPS_COUNT - 1;
|
||||
int32_t iNumRefFrames = 0;
|
||||
|
||||
while (iPos >= 0)
|
||||
{
|
||||
if ( pSubsetSpsAvail[iPos] )
|
||||
{
|
||||
while (iPos >= 0) {
|
||||
if (pSubsetSpsAvail[iPos]) {
|
||||
bExistSubsetSps = true;
|
||||
iSubsetIdx = iPos;
|
||||
break;
|
||||
@ -243,13 +225,10 @@ static inline int32_t GetTargetRefListSize( PWelsDecoderContext pCtx )
|
||||
-- iPos;
|
||||
}
|
||||
|
||||
if ( !bExistSubsetSps )
|
||||
{
|
||||
if (!bExistSubsetSps) {
|
||||
iPos = MAX_SPS_COUNT - 1;
|
||||
while (iPos >= 0)
|
||||
{
|
||||
if ( pSpsAvail[iPos] )
|
||||
{
|
||||
while (iPos >= 0) {
|
||||
if (pSpsAvail[iPos]) {
|
||||
bExistSps = true;
|
||||
iSpsIdx = iPos;
|
||||
break;
|
||||
@ -258,12 +237,9 @@ static inline int32_t GetTargetRefListSize( PWelsDecoderContext pCtx )
|
||||
}
|
||||
}
|
||||
|
||||
if ( !(bExistSubsetSps || bExistSps) )
|
||||
{
|
||||
if (! (bExistSubsetSps || bExistSps)) {
|
||||
iNumRefFrames = MAX_REF_PIC_COUNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
PSps pSps = bExistSubsetSps ? (&pCtx->sSubsetSpsBuffer[iSubsetIdx].sSps) : (&pCtx->sSpsBuffer[iSpsIdx]);
|
||||
|
||||
iNumRefFrames = (pSps->iNumRefFrames) + 1;
|
||||
@ -274,8 +250,7 @@ static inline int32_t GetTargetRefListSize( PWelsDecoderContext pCtx )
|
||||
|
||||
#ifdef LONG_TERM_REF
|
||||
//pic_queue size minimum set 2
|
||||
if (iNumRefFrames <2)
|
||||
{
|
||||
if (iNumRefFrames < 2) {
|
||||
iNumRefFrames = 2;
|
||||
}
|
||||
#endif
|
||||
@ -286,8 +261,7 @@ 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 )
|
||||
{
|
||||
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;
|
||||
int32_t iErr = ERR_NONE;
|
||||
@ -302,20 +276,21 @@ int32_t WelsRequestMem( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const
|
||||
// get picture queue size currently
|
||||
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
|
||||
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;
|
||||
// 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
|
||||
WELS_VERIFY_RETURN_IF (ERR_NONE, pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel
|
||||
&& kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer
|
||||
|
||||
// sync update pRefList
|
||||
WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free
|
||||
|
||||
// for Recycled_Pic_Queue
|
||||
for ( iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx )
|
||||
{
|
||||
for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
|
||||
PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx];
|
||||
if ( NULL != ppPic && NULL != *ppPic )
|
||||
{
|
||||
if (NULL != ppPic && NULL != *ppPic) {
|
||||
DestroyPicBuff (ppPic);
|
||||
}
|
||||
}
|
||||
@ -337,8 +312,7 @@ int32_t WelsRequestMem( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const
|
||||
/*
|
||||
* free memory blocks in avc
|
||||
*/
|
||||
void_t WelsFreeMem( PWelsDecoderContext pCtx )
|
||||
{
|
||||
void_t WelsFreeMem (PWelsDecoderContext pCtx) {
|
||||
int32_t iListIdx = 0;
|
||||
|
||||
/* TODO: free memory blocks introduced in avc */
|
||||
@ -347,11 +321,9 @@ void_t WelsFreeMem( PWelsDecoderContext pCtx )
|
||||
WelsResetRefPic (pCtx);
|
||||
|
||||
// for sPicBuff
|
||||
for ( iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx )
|
||||
{
|
||||
for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
|
||||
PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx];
|
||||
if ( NULL != pPicBuff && NULL != *pPicBuff )
|
||||
{
|
||||
if (NULL != pPicBuff && NULL != *pPicBuff) {
|
||||
DestroyPicBuff (pPicBuff);
|
||||
}
|
||||
}
|
||||
@ -366,8 +338,7 @@ void_t WelsFreeMem( PWelsDecoderContext pCtx )
|
||||
/*!
|
||||
* \brief Open decoder
|
||||
*/
|
||||
void_t WelsOpenDecoder( PWelsDecoderContext pCtx )
|
||||
{
|
||||
void_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
|
||||
// function pointers
|
||||
//initial MC function pointer--
|
||||
InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);
|
||||
@ -394,8 +365,7 @@ void_t WelsOpenDecoder( PWelsDecoderContext pCtx )
|
||||
/*!
|
||||
* \brief Close decoder
|
||||
*/
|
||||
void_t WelsCloseDecoder( PWelsDecoderContext pCtx )
|
||||
{
|
||||
void_t WelsCloseDecoder (PWelsDecoderContext pCtx) {
|
||||
WelsFreeMem (pCtx);
|
||||
|
||||
WelsFreeMemory (pCtx);
|
||||
@ -412,8 +382,7 @@ void_t WelsCloseDecoder( PWelsDecoderContext pCtx )
|
||||
/*!
|
||||
* \brief configure decoder parameters
|
||||
*/
|
||||
int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam )
|
||||
{
|
||||
int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const void_t* kpParam) {
|
||||
if (NULL == pCtx || NULL == kpParam)
|
||||
return 1;
|
||||
|
||||
@ -427,12 +396,9 @@ int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam )
|
||||
pCtx->bErrorResilienceFlag = pCtx->pParam->uiEcActiveFlag ? true : false;
|
||||
|
||||
if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType ||
|
||||
VIDEO_BITSTREAM_AVC == pCtx->pParam->sVideoProperty.eVideoBsType )
|
||||
{
|
||||
VIDEO_BITSTREAM_AVC == pCtx->pParam->sVideoProperty.eVideoBsType) {
|
||||
pCtx->eVideoType = pCtx->pParam->sVideoProperty.eVideoBsType;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pCtx->eVideoType = VIDEO_BITSTREAM_DEFAULT;
|
||||
}
|
||||
|
||||
@ -453,8 +419,7 @@ int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam )
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t WelsInitDecoder( PWelsDecoderContext pCtx, void_t * pTraceHandle, PWelsLogCallbackFunc pLog )
|
||||
{
|
||||
int32_t WelsInitDecoder (PWelsDecoderContext pCtx, void_t* pTraceHandle, PWelsLogCallbackFunc pLog) {
|
||||
if (pCtx == NULL) {
|
||||
return ERR_INFO_INVALID_PTR;
|
||||
}
|
||||
@ -490,14 +455,12 @@ int32_t WelsInitDecoder( PWelsDecoderContext pCtx, void_t * pTraceHandle, PWelsL
|
||||
* \note N/A
|
||||
*************************************************************************************
|
||||
*/
|
||||
void_t WelsEndDecoder( PWelsDecoderContext pCtx )
|
||||
{
|
||||
void_t WelsEndDecoder (PWelsDecoderContext pCtx) {
|
||||
// close decoder
|
||||
WelsCloseDecoder (pCtx);
|
||||
}
|
||||
|
||||
void_t GetVclNalTemporalId( PWelsDecoderContext pCtx )
|
||||
{
|
||||
void_t GetVclNalTemporalId (PWelsDecoderContext pCtx) {
|
||||
PAccessUnit pAccessUnit = pCtx->pAccessUnitList;
|
||||
int32_t idx = pAccessUnit->uiStartPos;
|
||||
|
||||
@ -522,10 +485,8 @@ void_t GetVclNalTemporalId( PWelsDecoderContext pCtx )
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen,
|
||||
uint8_t **ppDst, SBufferInfo* pDstBufInfo)
|
||||
{
|
||||
if ( !pCtx->bEndOfStreamFlag)
|
||||
{
|
||||
uint8_t** ppDst, SBufferInfo* pDstBufInfo) {
|
||||
if (!pCtx->bEndOfStreamFlag) {
|
||||
SDataBuffer* pRawData = &pCtx->sRawData;
|
||||
|
||||
int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs
|
||||
@ -541,16 +502,15 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
uint8_t* pNalPayload = NULL;
|
||||
|
||||
|
||||
if ( NULL == DetectStartCodePrefix( kpBsBuf, &iOffset, kiBsLen ) ) //CAN'T find the 00 00 01 start prefix from the source buffer
|
||||
{
|
||||
if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset,
|
||||
kiBsLen)) { //CAN'T find the 00 00 01 start prefix from the source buffer
|
||||
return dsBitstreamError;
|
||||
}
|
||||
|
||||
pSrcNal = const_cast<uint8_t*> (kpBsBuf) + iOffset;
|
||||
iSrcLength = kiBsLen - iOffset;
|
||||
|
||||
if ( (kiBsLen + 4) > ( pRawData->pEnd - pRawData->pCurPos ) )
|
||||
{
|
||||
if ((kiBsLen + 4) > (pRawData->pEnd - pRawData->pCurPos)) {
|
||||
pRawData->pCurPos = pRawData->pHead;
|
||||
}
|
||||
|
||||
@ -559,32 +519,25 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
//0x03 removal and extract all of NAL Unit from current raw data
|
||||
pDstNal = pRawData->pCurPos + 4; //4-bytes used to write the length of current NAL rbsp
|
||||
|
||||
while ( iSrcConsumed < iSrcLength )
|
||||
{
|
||||
while (iSrcConsumed < iSrcLength) {
|
||||
if ((2 + iSrcConsumed < iSrcLength) &&
|
||||
(0 == LD16 (pSrcNal + iSrcIdx)) &&
|
||||
( (pSrcNal[2+iSrcIdx]==0x03) || (pSrcNal[2+iSrcIdx]==0x01) ) )
|
||||
{
|
||||
if ( pSrcNal[2+iSrcIdx] == 0x03 )
|
||||
{
|
||||
((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) {
|
||||
if (pSrcNal[2 + iSrcIdx] == 0x03) {
|
||||
ST16 (pDstNal + iDstIdx, 0);
|
||||
iDstIdx += 2;
|
||||
iSrcIdx += 3;
|
||||
iSrcConsumed += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GetValueOf4Bytes (pDstNal - 4, iDstIdx); //pDstNal-4 (non-aligned by 4) in Solaris10(SPARC). Given value by byte.
|
||||
|
||||
iConsumedBytes = 0;
|
||||
pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
|
||||
|
||||
if (pCtx->bAuReadyFlag)
|
||||
{
|
||||
if (pCtx->bAuReadyFlag) {
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
|
||||
|
||||
if ( (dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode)
|
||||
{
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -599,12 +552,9 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
}
|
||||
|
||||
if ((IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL (pCtx->sCurNalHead.eNalUnitType)) &&
|
||||
pNalPayload )
|
||||
{
|
||||
if ( ParseNonVclNal( pCtx, pNalPayload, iDstIdx-iConsumedBytes ) )
|
||||
{
|
||||
if ( dsNoParamSets & pCtx->iErrorCode )
|
||||
{
|
||||
pNalPayload) {
|
||||
if (ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes)) {
|
||||
if (dsNoParamSets & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -617,12 +567,9 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
}
|
||||
|
||||
pDstNal += iDstIdx; //update current position
|
||||
if ( (iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal) )
|
||||
{
|
||||
if ((iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal)) {
|
||||
pRawData->pCurPos = pRawData->pHead;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pRawData->pCurPos = pDstNal;
|
||||
}
|
||||
pDstNal = pRawData->pCurPos + 4; //init, 4 bytes used to store the next NAL
|
||||
@ -644,12 +591,10 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
iConsumedBytes = 0;
|
||||
pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
|
||||
|
||||
if (pCtx->bAuReadyFlag)
|
||||
{
|
||||
if (pCtx->bAuReadyFlag) {
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
|
||||
|
||||
if ( (dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode)
|
||||
{
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -660,12 +605,10 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
}
|
||||
}
|
||||
|
||||
if( (IS_PARAM_SETS_NALS(pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL(pCtx->sCurNalHead.eNalUnitType)) && pNalPayload )
|
||||
{
|
||||
if ( ParseNonVclNal( pCtx, pNalPayload, iDstIdx-iConsumedBytes ) )
|
||||
{
|
||||
if ( dsNoParamSets & pCtx->iErrorCode )
|
||||
{
|
||||
if ((IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL (pCtx->sCurNalHead.eNalUnitType))
|
||||
&& pNalPayload) {
|
||||
if (ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes)) {
|
||||
if (dsNoParamSets & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -679,23 +622,18 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
|
||||
pDstNal += iDstIdx;
|
||||
pRawData->pCurPos = pDstNal; //init the pCurPos for next NAL(s) storage
|
||||
}
|
||||
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
|
||||
} 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
|
||||
|
||||
if ( pCurAu->uiAvailUnitsNum == 0 )
|
||||
{
|
||||
if (pCurAu->uiAvailUnitsNum == 0) {
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
|
||||
|
||||
ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
|
||||
|
||||
if ( (dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode)
|
||||
{
|
||||
if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -714,13 +652,11 @@ int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const in
|
||||
/*
|
||||
* set colorspace format in decoder
|
||||
*/
|
||||
int32_t DecoderSetCsp(PWelsDecoderContext pCtx, const int32_t kiColorFormat)
|
||||
{
|
||||
int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) {
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pCtx));
|
||||
|
||||
pCtx->iOutputColorFormat = kiColorFormat;
|
||||
if ( pCtx->pParam != NULL )
|
||||
{
|
||||
if (pCtx->pParam != NULL) {
|
||||
pCtx->pParam->iOutputColorFormat = kiColorFormat;
|
||||
}
|
||||
|
||||
@ -736,23 +672,20 @@ int32_t DecoderSetCsp(PWelsDecoderContext pCtx, const int32_t kiColorFormat)
|
||||
* \pram iMbHeight MB height
|
||||
* \return 0 - successful; none 0 - something wrong
|
||||
*/
|
||||
int32_t SyncPictureResolutionExt( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight )
|
||||
{
|
||||
int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) {
|
||||
int32_t iErr = ERR_NONE;
|
||||
const int32_t kiPicWidth = kiMbWidth << 4;
|
||||
const int32_t kiPicHeight = kiMbHeight << 4;
|
||||
|
||||
iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used
|
||||
if ( ERR_NONE != iErr )
|
||||
{
|
||||
if (ERR_NONE != iErr) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure.\n");
|
||||
pCtx->iErrorCode = dsOutOfMemory;
|
||||
return iErr;
|
||||
}
|
||||
|
||||
iErr = InitialDqLayersContext (pCtx, kiPicWidth, kiPicHeight);
|
||||
if ( ERR_NONE != iErr )
|
||||
{
|
||||
if (ERR_NONE != iErr) {
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "SyncPictureResolutionExt()::InitialDqLayersContext--buffer allocated failure.\n");
|
||||
pCtx->iErrorCode = dsOutOfMemory;
|
||||
}
|
||||
@ -763,11 +696,9 @@ int32_t SyncPictureResolutionExt( PWelsDecoderContext pCtx, const int32_t kiMbWi
|
||||
/*!
|
||||
* \brief update maximal picture width and height if applicable when receiving a SPS NAL
|
||||
*/
|
||||
void_t UpdateMaxPictureResolution( PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight )
|
||||
{
|
||||
void_t UpdateMaxPictureResolution (PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight) {
|
||||
//any dimension larger than that of current dimension, should modify the max-dimension
|
||||
if ( kiCurWidth > pCtx->iMaxWidthInSps || kiCurHeight > pCtx->iMaxHeightInSps)
|
||||
{
|
||||
if (kiCurWidth > pCtx->iMaxWidthInSps || kiCurHeight > pCtx->iMaxHeightInSps) {
|
||||
pCtx->iMaxWidthInSps = kiCurWidth;
|
||||
pCtx->iMaxHeightInSps = kiCurHeight;
|
||||
}
|
||||
@ -775,8 +706,7 @@ void_t UpdateMaxPictureResolution( PWelsDecoderContext pCtx, const int32_t kiCur
|
||||
return;
|
||||
}
|
||||
|
||||
void_t AssignFuncPointerForRec(PWelsDecoderContext pCtx)
|
||||
{
|
||||
void_t AssignFuncPointerForRec (PWelsDecoderContext pCtx) {
|
||||
pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c;
|
||||
pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c;
|
||||
pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c;
|
||||
@ -812,8 +742,7 @@ void_t AssignFuncPointerForRec(PWelsDecoderContext pCtx)
|
||||
pCtx->pIdctResAddPredFunc = IdctResAddPred_c;
|
||||
|
||||
#if defined(X86_ASM)
|
||||
if ( pCtx->uiCpuFlag & WELS_CPU_MMXEXT )
|
||||
{
|
||||
if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) {
|
||||
pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx;
|
||||
|
||||
/////////mmx code opt---
|
||||
@ -828,8 +757,7 @@ void_t AssignFuncPointerForRec(PWelsDecoderContext pCtx)
|
||||
pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsI4x4LumaPredDDL_mmx;
|
||||
pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsI4x4LumaPredVL_mmx;
|
||||
}
|
||||
if ( pCtx->uiCpuFlag & WELS_CPU_SSE2 )
|
||||
{
|
||||
if (pCtx->uiCpuFlag & WELS_CPU_SSE2) {
|
||||
/////////sse2 code opt---
|
||||
pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsI16x16LumaPredDc_sse2;
|
||||
pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsI16x16LumaPredPlane_sse2;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,8 +43,8 @@ namespace WelsDec {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////non_zero_count[16+8] mapping scan index
|
||||
const uint8_t g_kuiMbNonZeroCountIdx[24] =
|
||||
{ // 0 1 | 4 5 luma 8*8 block non_zero_count[16+8]
|
||||
const uint8_t g_kuiMbNonZeroCountIdx[24] = {
|
||||
// 0 1 | 4 5 luma 8*8 block non_zero_count[16+8]
|
||||
0, 1, 4, 5, // 2 3 | 6 7 0 | 1 0 1 2 3
|
||||
2, 3, 6, 7, //--------------- --------- 4 5 6 7
|
||||
8, 9, 12, 13, // 8 9 | 12 13 2 | 3 8 9 10 11
|
||||
@ -54,8 +54,7 @@ const uint8_t g_kuiMbNonZeroCountIdx[24] =
|
||||
};
|
||||
//cache element equal to 26
|
||||
|
||||
const uint8_t g_kuiCacheNzcScanIdx[24] =
|
||||
{
|
||||
const uint8_t g_kuiCacheNzcScanIdx[24] = {
|
||||
/* Luma */
|
||||
9, 10, 17, 18, // 1+1*8, 2+1*8, 1+2*8, 2+2*8,
|
||||
11, 12, 19, 20, // 3+1*8, 4+1*8, 3+2*8, 4+2*8,
|
||||
@ -71,16 +70,15 @@ const uint8_t g_kuiCacheNzcScanIdx[24] =
|
||||
};
|
||||
|
||||
//cache element equal to 30
|
||||
const uint8_t g_kuiCache30ScanIdx[16] = //mv or ref_index cache scan index, 4*4 block as basic unit
|
||||
{
|
||||
const uint8_t g_kuiCache30ScanIdx[16] = { //mv or ref_index cache scan index, 4*4 block as basic unit
|
||||
7, 8, 13, 14,
|
||||
9, 10, 15, 16,
|
||||
19, 20, 25, 26,
|
||||
21, 22, 27, 28
|
||||
};
|
||||
|
||||
const uint8_t g_kuiScan4[16] = //for mb cache in sMb (only current element, without neighbor)
|
||||
{ // 4*4block scan mb cache order
|
||||
const uint8_t g_kuiScan4[16] = { //for mb cache in sMb (only current element, without neighbor)
|
||||
// 4*4block scan mb cache order
|
||||
0, 1, 4, 5, // 0 1 | 4 5 0 1 | 2 3
|
||||
2, 3, 6, 7, // 2 3 | 6 7 4 5 | 6 7
|
||||
8, 9, 12, 13, //----------------->-----------
|
||||
@ -101,8 +99,7 @@ const uint8_t g_kuiChromaQp[52]={
|
||||
/*
|
||||
* vcl type map for given NAL unit type and corresponding H264 type
|
||||
*/
|
||||
const VclType g_kuiVclTypeMap[32][2] =
|
||||
{
|
||||
const VclType g_kuiVclTypeMap[32][2] = {
|
||||
{ NON_VCL, NON_VCL }, // 0: NAL_UNIT_UNSPEC_0
|
||||
{ VCL, VCL, }, // 1: NAL_UNIT_CODED_SLICE
|
||||
{ VCL, NOT_APP }, // 2: NAL_UNIT_CODED_SLICE_DPA
|
||||
@ -191,22 +188,19 @@ __align16( const uint16_t, g_kuiDequantCoeff[52][8]) = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const uint8_t g_kuiIntra4x4CbpTable[48] =
|
||||
{
|
||||
const uint8_t g_kuiIntra4x4CbpTable[48] = {
|
||||
47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, //15
|
||||
16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, //31
|
||||
8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41 //47
|
||||
};
|
||||
|
||||
const uint8_t g_kuiInterCbpTable[48] =
|
||||
{
|
||||
const uint8_t g_kuiInterCbpTable[48] = {
|
||||
0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, //15
|
||||
14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, //31
|
||||
17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 //47
|
||||
};
|
||||
|
||||
const uint8_t g_kuiLeadingZeroTable[256] =
|
||||
{
|
||||
const uint8_t g_kuiLeadingZeroTable[256] = {
|
||||
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
@ -229,8 +223,7 @@ const uint8_t g_kuiLeadingZeroTable[256] =
|
||||
|
||||
// extern at vlc_decoder.h
|
||||
|
||||
const uint8_t g_kuiVlcChromaTable[256][2] =
|
||||
{
|
||||
const uint8_t g_kuiVlcChromaTable[256][2] = {
|
||||
{13, 7}, {13, 7}, {12, 8}, {11, 8}, {8, 7}, {8, 7}, {7, 7}, {7, 7}, {10, 6}, {10, 6}, {10, 6}, {10, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, //15
|
||||
{ 3, 6}, { 3, 6}, { 3, 6}, { 3, 6}, {9, 6}, {9, 6}, {9, 6}, {9, 6}, { 4, 6}, { 4, 6}, { 4, 6}, { 4, 6}, {1, 6}, {1, 6}, {1, 6}, {1, 6}, //31
|
||||
{ 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, {5, 3}, {5, 3}, {5, 3}, {5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, {5, 3}, {5, 3}, {5, 3}, {5, 3}, //47
|
||||
@ -249,8 +242,8 @@ const uint8_t g_kuiVlcChromaTable[256][2] =
|
||||
{ 2, 1}, { 2, 1}, { 2, 1}, { 2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, { 2, 1}, { 2, 1}, { 2, 1}, { 2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1} //255
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_0[256][2] = //[0] means the index of vlc table, [1] means the length of vlc code [256] value means the value of 8bits
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_0[256][2]
|
||||
= { //[0] means the index of vlc table, [1] means the length of vlc code [256] value means the value of 8bits
|
||||
{ 0, 0}, { 0, 0}, { 0, 0}, {0, 0}, {21, 8}, {12, 8}, {7, 8}, {3, 8}, {17, 7}, {17, 7}, {8, 7}, {8, 7}, {13, 6}, {13, 6}, {13, 6}, {13, 6}, //15
|
||||
{ 4, 6}, { 4, 6}, { 4, 6}, {4, 6}, { 1, 6}, { 1, 6}, {1, 6}, {1, 6}, { 9, 5}, { 9, 5}, {9, 5}, {9, 5}, { 9, 5}, { 9, 5}, { 9, 5}, { 9, 5}, //31
|
||||
{ 5, 3}, { 5, 3}, { 5, 3}, {5, 3}, { 5, 3}, { 5, 3}, {5, 3}, {5, 3}, { 5, 3}, { 5, 3}, {5, 3}, {5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, //47
|
||||
@ -269,8 +262,7 @@ const uint8_t g_kuiVlcTable_0[256][2] = //[0] means the index of vlc table, [1]
|
||||
{ 0, 1}, { 0, 1}, { 0, 1}, {0, 1}, { 0, 1}, { 0, 1}, {0, 1}, {0, 1}, { 0, 1}, { 0, 1}, {0, 1}, {0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1} //255
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_0_0[256][2] = // read 8 bits // for g_kuiVlcTable_0[0] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_0_0[256][2] = { // read 8 bits // for g_kuiVlcTable_0[0] //checked no error--
|
||||
{ 0, 0}, { 0, 0}, {47, 7}, {47, 7}, {58, 8}, {60, 8}, {59, 8}, {54, 8}, {61, 8}, {56, 8}, {55, 8}, {50, 8}, {57, 8}, {52, 8}, {51, 8}, {46, 8}, //15
|
||||
{53, 7}, {53, 7}, {48, 7}, {48, 7}, {43, 7}, {43, 7}, {42, 7}, {42, 7}, {49, 7}, {49, 7}, {44, 7}, {44, 7}, {39, 7}, {39, 7}, {38, 7}, {38, 7}, //31
|
||||
{45, 6}, {45, 6}, {45, 6}, {45, 6}, {40, 6}, {40, 6}, {40, 6}, {40, 6}, {35, 6}, {35, 6}, {35, 6}, {35, 6}, {34, 6}, {34, 6}, {34, 6}, {34, 6}, //47
|
||||
@ -289,23 +281,19 @@ const uint8_t g_kuiVlcTable_0_0[256][2] = // read 8 bits // for g_kuiVlcTable_0
|
||||
{14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3}, {14, 3} //255
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_0_1[4][2] = // read 2 bits // for g_kuiVlcTable_0[1] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_0_1[4][2] = { // read 2 bits // for g_kuiVlcTable_0[1] //checked no error--
|
||||
{29, 2}, {20, 2}, {15, 2}, {10, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_0_2[2][2] = // read 1 bit // for g_kuiVlcTable_0[2] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_0_2[2][2] = { // read 1 bit // for g_kuiVlcTable_0[2] //checked no error--
|
||||
{25, 1}, {16, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_0_3[2][2] = // read 1 bit // for g_kuiVlcTable_0[3] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_0_3[2][2] = { // read 1 bit // for g_kuiVlcTable_0[3] //checked no error--
|
||||
{11, 1}, {6, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_1[256][2] = //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_1[256][2] = { //checked no error--
|
||||
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {14, 8}, {20, 8}, {19, 8}, {10, 8}, {29, 7}, {29, 7}, {16, 7}, {16, 7}, {15, 7}, {15, 7}, { 6, 7}, { 6, 7}, //15
|
||||
{25, 6}, {25, 6}, {25, 6}, {25, 6}, {12, 6}, {12, 6}, {12, 6}, {12, 6}, {11, 6}, {11, 6}, {11, 6}, {11, 6}, { 3, 6}, { 3, 6}, { 3, 6}, { 3, 6}, //31
|
||||
{21, 6}, {21, 6}, {21, 6}, {21, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 7, 6}, { 7, 6}, { 7, 6}, { 7, 6}, { 1, 6}, { 1, 6}, { 1, 6}, { 1, 6}, //47
|
||||
@ -325,31 +313,26 @@ const uint8_t g_kuiVlcTable_1[256][2] = //checked no error--
|
||||
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_1_0[64][2] = // read 6 bits // for g_kuiVlcTable_1[0] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_1_0[64][2] = { // read 6 bits // for g_kuiVlcTable_1[0] //checked no error--
|
||||
{ 0, 0}, { 0, 0}, {57, 5}, {57, 5}, {61, 6}, {60, 6}, {59, 6}, {58, 6}, {55, 6}, {54, 6}, {56, 6}, {51, 6}, {52, 5}, {52, 5}, {50, 5}, {50, 5}, //15
|
||||
{53, 5}, {53, 5}, {48, 5}, {48, 5}, {47, 5}, {47, 5}, {46, 5}, {46, 5}, {49, 5}, {49, 5}, {44, 5}, {44, 5}, {43, 5}, {43, 5}, {42, 5}, {42, 5}, //31
|
||||
{38, 4}, {38, 4}, {38, 4}, {38, 4}, {40, 4}, {40, 4}, {40, 4}, {40, 4}, {39, 4}, {39, 4}, {39, 4}, {39, 4}, {34, 4}, {34, 4}, {34, 4}, {34, 4}, //47
|
||||
{45, 4}, {45, 4}, {45, 4}, {45, 4}, {36, 4}, {36, 4}, {36, 4}, {36, 4}, {35, 4}, {35, 4}, {35, 4}, {35, 4}, {30, 4}, {30, 4}, {30, 4}, {30, 4} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_1_1[8][2] = // read 3 bits // for g_kuiVlcTable_1[1] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_1_1[8][2] = { // read 3 bits // for g_kuiVlcTable_1[1] //checked no error--
|
||||
{41, 3}, {32, 3}, {31, 3}, {26, 3}, {37, 3}, {28, 3}, {27, 3}, {22, 3}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_1_2[2][2] = // read 1 bit // for g_kuiVlcTable_1[2] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_1_2[2][2] = { // read 1 bit // for g_kuiVlcTable_1[2] //checked no error--
|
||||
{33, 1}, {24, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_1_3[2][2] = // read 1 bit // for g_kuiVlcTable_1[3] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_1_3[2][2] = { // read 1 bit // for g_kuiVlcTable_1[3] //checked no error--
|
||||
{23, 1}, {18, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2[256][2] = //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2[256][2] = { //checked no error--
|
||||
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {45, 8}, {40, 8}, {35, 8}, {30, 8}, {41, 8}, {36, 8}, {31, 8}, {26, 8}, //15
|
||||
{22, 7}, {22, 7}, {18, 7}, {18, 7}, {32, 7}, {32, 7}, {14, 7}, {14, 7}, {37, 7}, {37, 7}, {28, 7}, {28, 7}, {27, 7}, {27, 7}, {10, 7}, {10, 7}, //31
|
||||
{ 6, 6}, { 6, 6}, { 6, 6}, { 6, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {23, 6}, {23, 6}, {23, 6}, {23, 6}, { 3, 6}, { 3, 6}, { 3, 6}, { 3, 6}, //47
|
||||
@ -368,49 +351,40 @@ const uint8_t g_kuiVlcTable_2[256][2] = //checked no error--
|
||||
{ 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4}, { 0, 4} //255
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_0[4][2] = // read 2 bits // for g_kuiVlcTable_2[0] //checked
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_0[4][2] = { // read 2 bits // for g_kuiVlcTable_2[0] //checked
|
||||
{0, 0}, {58, 2}, {61, 2}, {60, 2}
|
||||
};
|
||||
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_1[4][2] = // read 2 bits // for g_kuiVlcTable_2[1] //checked
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_1[4][2] = { // read 2 bits // for g_kuiVlcTable_2[1] //checked
|
||||
{59, 2}, {54, 2}, {57, 2}, {56, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_2[4][2] = // read 2 bits // for g_kuiVlcTable_2[2] //checked
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_2[4][2] = { // read 2 bits // for g_kuiVlcTable_2[2] //checked
|
||||
{55, 2}, {50, 2}, {53, 2}, {52, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_3[4][2] = // read 2 bits // for g_kuiVlcTable_2[3] //checked
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_3[4][2] = { // read 2 bits // for g_kuiVlcTable_2[3] //checked
|
||||
{51, 2}, {46, 2}, {47, 1}, {47, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_4[2][2] = // read 1 bit // for g_kuiVlcTable_2[4] //checked
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_4[2][2] = { // read 1 bit // for g_kuiVlcTable_2[4] //checked
|
||||
{42, 1}, {48, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_5[2][2] = // read 1 bit // for g_kuiVlcTable_2[5] //checked
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_5[2][2] = { // read 1 bit // for g_kuiVlcTable_2[5] //checked
|
||||
{43, 1}, {38, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_6[2][2] = // read 1 bit // for g_kuiVlcTable_2[6] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_6[2][2] = { // read 1 bit // for g_kuiVlcTable_2[6] //checked no error--
|
||||
{49, 1}, {44, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_2_7[2][2] = // read 1 bit // for g_kuiVlcTable_2[7] //checked no error--
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_2_7[2][2] = { // read 1 bit // for g_kuiVlcTable_2[7] //checked no error--
|
||||
{39, 1}, {34, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTable_3[64][2] = // read 6 bits //corrected
|
||||
{
|
||||
const uint8_t g_kuiVlcTable_3[64][2] = { // read 6 bits //corrected
|
||||
{ 1, 6}, { 2, 6}, { 0, 0}, { 0, 6}, { 3, 6}, { 4, 6}, { 5, 6}, { 0, 0}, { 6, 6}, { 7, 6}, { 8, 6}, { 9, 6}, {10, 6}, {11, 6}, {12, 6}, {13, 6}, //15
|
||||
{14, 6}, {15, 6}, {16, 6}, {17, 6}, {18, 6}, {19, 6}, {20, 6}, {21, 6}, {22, 6}, {23, 6}, {24, 6}, {25, 6}, {26, 6}, {27, 6}, {28, 6}, {29, 6}, //31
|
||||
{30, 6}, {31, 6}, {32, 6}, {33, 6}, {34, 6}, {35, 6}, {36, 6}, {37, 6}, {38, 6}, {39, 6}, {40, 6}, {41, 6}, {42, 6}, {43, 6}, {44, 6}, {45, 6}, //47
|
||||
@ -418,34 +392,28 @@ const uint8_t g_kuiVlcTable_3[64][2] = // read 6 bits //corrected
|
||||
};
|
||||
|
||||
|
||||
const uint8_t g_kuiVlcTableNeedMoreBitsThread[3] =
|
||||
{
|
||||
const uint8_t g_kuiVlcTableNeedMoreBitsThread[3] = {
|
||||
4, 4, 8
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTableMoreBitsCount0[4] =
|
||||
{
|
||||
const uint8_t g_kuiVlcTableMoreBitsCount0[4] = {
|
||||
8, 2, 1, 1
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTableMoreBitsCount1[4] =
|
||||
{
|
||||
const uint8_t g_kuiVlcTableMoreBitsCount1[4] = {
|
||||
6, 3, 1, 1
|
||||
};
|
||||
|
||||
const uint8_t g_kuiVlcTableMoreBitsCount2[8] =
|
||||
{
|
||||
const uint8_t g_kuiVlcTableMoreBitsCount2[8] = {
|
||||
2, 2, 2, 2, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
const uint8_t g_kuiNcMapTable[17] =
|
||||
{
|
||||
const uint8_t g_kuiNcMapTable[17] = {
|
||||
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3
|
||||
};
|
||||
|
||||
|
||||
const uint8_t g_kuiVlcTrailingOneTotalCoeffTable[62][2] =
|
||||
{
|
||||
const uint8_t g_kuiVlcTrailingOneTotalCoeffTable[62][2] = {
|
||||
{0, 0},
|
||||
{0, 1}, {1, 1},
|
||||
{0, 2}, {1, 2}, {2, 2},
|
||||
@ -465,8 +433,8 @@ const uint8_t g_kuiVlcTrailingOneTotalCoeffTable[62][2] =
|
||||
{0, 16}, {1, 16}, {2, 16}, {3, 16}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable0[512][2] = //read 9 bits, generated by tzVlcIndex=1 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable0[512][2]
|
||||
= { //read 9 bits, generated by tzVlcIndex=1 in Table 9-7 in H.264/AVC standard
|
||||
{0, 0}, {15, 9}, {14, 9}, {13, 9}, {12, 8}, {12, 8}, {11, 8}, {11, 8}, {10, 7}, {10, 7}, {10, 7}, {10, 7}, {9, 7}, {9, 7}, {9, 7}, {9, 7}, //15
|
||||
{8, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 8, 6}, { 7, 6}, { 7, 6}, { 7, 6}, { 7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, //31
|
||||
{6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, { 6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, //47
|
||||
@ -501,160 +469,150 @@ const uint8_t g_kuiTotalZerosTable0[512][2] = //read 9 bits, generated by tzVlcI
|
||||
{0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1} //511
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable1[64][2] = //read 6 bits, generated by tzVlcIndex=2 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable1[64][2]
|
||||
= { //read 6 bits, generated by tzVlcIndex=2 in Table 9-7 in H.264/AVC standard
|
||||
{14, 6}, {13, 6}, {12, 6}, {11, 6}, {10, 5}, {10, 5}, {9, 5}, {9, 5}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {7, 4}, {7, 4}, {7, 4}, {7, 4}, //15
|
||||
{ 6, 4}, { 6, 4}, { 6, 4}, { 6, 4}, { 5, 4}, { 5, 4}, {5, 4}, {5, 4}, {4, 3}, {4, 3}, {4, 3}, {4, 3}, {4, 3}, {4, 3}, {4, 3}, {4, 3}, //31
|
||||
{ 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, {3, 3}, {3, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, //47
|
||||
{ 1, 3}, { 1, 3}, { 1, 3}, { 1, 3}, { 1, 3}, { 1, 3}, {1, 3}, {1, 3}, {0, 3}, {0, 3}, {0, 3}, {0, 3}, {0, 3}, {0, 3}, {0, 3}, {0, 3} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable2[64][2] = //read 6 bits, generated by tzVlcIndex=3 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable2[64][2]
|
||||
= { //read 6 bits, generated by tzVlcIndex=3 in Table 9-7 in H.264/AVC standard
|
||||
{13, 6}, {11, 6}, {12, 5}, {12, 5}, {10, 5}, {10, 5}, {9, 5}, {9, 5}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {5, 4}, {5, 4}, {5, 4}, {5, 4}, //15
|
||||
{ 4, 4}, { 4, 4}, { 4, 4}, { 4, 4}, { 0, 4}, { 0, 4}, {0, 4}, {0, 4}, {7, 3}, {7, 3}, {7, 3}, {7, 3}, {7, 3}, {7, 3}, {7, 3}, {7, 3}, //31
|
||||
{ 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, {6, 3}, {6, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, //47
|
||||
{ 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable3[32][2] = //read 5 bits, generated by tzVlcIndex=4 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable3[32][2]
|
||||
= { //read 5 bits, generated by tzVlcIndex=4 in Table 9-7 in H.264/AVC standard
|
||||
{12, 5}, {11, 5}, {10, 5}, {0, 5}, {9, 4}, {9, 4}, {7, 4}, {7, 4}, {3, 4}, {3, 4}, {2, 4}, {2, 4}, {8, 3}, {8, 3}, {8, 3}, {8, 3}, //15
|
||||
{ 6, 3}, { 6, 3}, { 6, 3}, {6, 3}, {5, 3}, {5, 3}, {5, 3}, {5, 3}, {4, 3}, {4, 3}, {4, 3}, {4, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, //31
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable4[32][2] = //read 5 bits, generated by tzVlcIndex=5 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable4[32][2]
|
||||
= { //read 5 bits, generated by tzVlcIndex=5 in Table 9-7 in H.264/AVC standard
|
||||
{11, 5}, { 9, 5}, {10, 4}, {10, 4}, { 8, 4}, { 8, 4}, { 2, 4}, { 2, 4}, { 1, 4}, { 1, 4}, { 0, 4}, { 0, 4}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, //15
|
||||
{ 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3} //31
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable5[64][2] = //read 6 bits, generated by tzVlcIndex=6 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable5[64][2]
|
||||
= { //read 6 bits, generated by tzVlcIndex=6 in Table 9-7 in H.264/AVC standard
|
||||
{10, 6}, { 0, 6}, { 1, 5}, { 1, 5}, { 8, 4}, { 8, 4}, { 8, 4}, { 8, 4}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, //15
|
||||
{ 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, //31
|
||||
{ 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, //47
|
||||
{ 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable6[64][2] = //read 6 bits, generated by tzVlcIndex=7 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable6[64][2]
|
||||
= { //read 6 bits, generated by tzVlcIndex=7 in Table 9-7 in H.264/AVC standard
|
||||
{ 9, 6}, { 0, 6}, { 1, 5}, { 1, 5}, { 7, 4}, { 7, 4}, { 7, 4}, { 7, 4}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, //15
|
||||
{ 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, { 4, 3}, //31
|
||||
{ 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, //47
|
||||
{ 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable7[64][2] = //read 6 bits, generated by tzVlcIndex=8 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable7[64][2]
|
||||
= { //read 6 bits, generated by tzVlcIndex=8 in Table 9-7 in H.264/AVC standard
|
||||
{ 8, 6}, { 0, 6}, { 2, 5}, { 2, 5}, { 1, 4}, { 1, 4}, { 1, 4}, { 1, 4}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, { 7, 3}, //15
|
||||
{ 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 6, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, { 3, 3}, //31
|
||||
{ 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, //47
|
||||
{ 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable8[64][2] = //read 6 bits, generated by tzVlcIndex=9 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable8[64][2]
|
||||
= { //read 6 bits, generated by tzVlcIndex=9 in Table 9-7 in H.264/AVC standard
|
||||
{ 1, 6}, { 0, 6}, { 7, 5}, { 7, 5}, { 2, 4}, { 2, 4}, { 2, 4}, { 2, 4}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, { 5, 3}, //15
|
||||
{ 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, //31
|
||||
{ 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, //47
|
||||
{ 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2} //63
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable9[32][2] = //read 5 bits, generated by tzVlcIndex=10 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable9[32][2]
|
||||
= { //read 5 bits, generated by tzVlcIndex=10 in Table 9-7 in H.264/AVC standard
|
||||
{ 1, 5}, { 0, 5}, { 6, 4}, { 6, 4}, { 2, 3}, { 2, 3}, { 2, 3}, { 2, 3}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, { 5, 2}, //15
|
||||
{ 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 4, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2}, { 3, 2} //31
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable10[16][2] = //read 4 bits, generated by tzVlcIndex=11 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable10[16][2]
|
||||
= { //read 4 bits, generated by tzVlcIndex=11 in Table 9-7 in H.264/AVC standard
|
||||
{ 0, 4}, { 1, 4}, { 2, 3}, { 2, 3}, { 3, 3}, { 3, 3}, { 5, 3}, { 5, 3}, { 4, 1}, { 4, 1}, { 4, 1}, { 4, 1}, { 4, 1}, { 4, 1}, { 4, 1}, { 4, 1} //15
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable11[16][2] = //read 4 bits, generated by tzVlcIndex=12 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable11[16][2]
|
||||
= { //read 4 bits, generated by tzVlcIndex=12 in Table 9-7 in H.264/AVC standard
|
||||
{ 0, 4}, { 1, 4}, { 4, 3}, { 4, 3}, { 2, 2}, { 2, 2}, { 2, 2}, { 2, 2}, { 3, 1}, { 3, 1}, { 3, 1}, { 3, 1}, { 3, 1}, { 3, 1}, { 3, 1}, { 3, 1} //15
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable12[8][2] = //read 3 bits, generated by tzVlcIndex=13 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable12[8][2]
|
||||
= { //read 3 bits, generated by tzVlcIndex=13 in Table 9-7 in H.264/AVC standard
|
||||
{ 0, 3}, { 1, 3}, { 3, 2}, { 3, 2}, { 2, 1}, { 2, 1}, { 2, 1}, { 2, 1} //8
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable13[4][2] = //read 2 bits, generated by tzVlcIndex=14 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable13[4][2]
|
||||
= { //read 2 bits, generated by tzVlcIndex=14 in Table 9-7 in H.264/AVC standard
|
||||
{ 0, 2}, { 1, 2}, { 2, 1}, { 2, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosTable14[2][2] = //read 1 bits generated by tzVlcIndex=15 in Table 9-7 in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosTable14[2][2]
|
||||
= { //read 1 bits generated by tzVlcIndex=15 in Table 9-7 in H.264/AVC standard
|
||||
{ 0, 1}, { 1, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosBitNumMap[15] =
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosBitNumMap[15] = {
|
||||
9, 6, 6, 5, 5, 6, 6, 6, 6, 5, 4, 4, 3, 2, 1
|
||||
};
|
||||
|
||||
|
||||
const uint8_t g_kuiTotalZerosChromaTable0[8][2] = //read 3 bits, generated by tzVlcIndex=1 in Table 9-9(a) in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosChromaTable0[8][2]
|
||||
= { //read 3 bits, generated by tzVlcIndex=1 in Table 9-9(a) in H.264/AVC standard
|
||||
{ 3, 3}, { 2, 3}, { 1, 2}, { 1, 2}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosChromaTable1[4][2] = //read 2 bits, generated by tzVlcIndex=2 in Table 9-9(a) in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosChromaTable1[4][2]
|
||||
= { //read 2 bits, generated by tzVlcIndex=2 in Table 9-9(a) in H.264/AVC standard
|
||||
{ 2, 2}, { 1, 2}, { 0, 1}, { 0, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosChromaTable2[2][2] = //read 1 bits, generated by tzVlcIndex=3 in Table 9-9(a) in H.264/AVC standard
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosChromaTable2[2][2]
|
||||
= { //read 1 bits, generated by tzVlcIndex=3 in Table 9-9(a) in H.264/AVC standard
|
||||
{ 1, 1}, { 0, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiTotalZerosBitNumChromaMap[3] =
|
||||
{
|
||||
const uint8_t g_kuiTotalZerosBitNumChromaMap[3] = {
|
||||
3, 2, 1
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable0[2][2] = //read 1 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable0[2][2] = { //read 1 bits
|
||||
{1, 1}, {0, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable1[4][2] = //read 2 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable1[4][2] = { //read 2 bits
|
||||
{2, 2}, {1, 2}, {0, 1}, {0, 1}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable2[4][2] = //read 2 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable2[4][2] = { //read 2 bits
|
||||
{3, 2}, {2, 2}, {1, 2}, {0, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable3[8][2] = //read 3 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable3[8][2] = { //read 3 bits
|
||||
{4, 3}, {3, 3}, {2, 2}, {2, 2}, {1, 2}, {1, 2}, {0, 2}, {0, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable4[8][2] = //read 3 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable4[8][2] = { //read 3 bits
|
||||
{5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 2}, {1, 2}, {0, 2}, {0, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable5[8][2] = //read 3 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable5[8][2] = { //read 3 bits
|
||||
{1, 3}, {2, 3}, {4, 3}, {3, 3}, {6, 3}, {5, 3}, {0, 2}, {0, 2}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftTable6[8][2] = //read 3 bits
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftTable6[8][2] = { //read 3 bits
|
||||
{7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 3}, {0, 3}
|
||||
};
|
||||
|
||||
const uint8_t g_kuiZeroLeftBitNumMap[16] =
|
||||
{
|
||||
const uint8_t g_kuiZeroLeftBitNumMap[16] = {
|
||||
0, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
|
||||
};
|
||||
|
||||
|
@ -39,8 +39,8 @@
|
||||
namespace WelsDec {
|
||||
|
||||
// rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009
|
||||
static inline void_t ExpandPictureLuma_c( uint8_t *pDst, const int32_t kiStride, const int32_t kiPicWidth, const int32_t kiPicHeight )
|
||||
{
|
||||
static inline void_t ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
|
||||
const int32_t kiPicHeight) {
|
||||
uint8_t* pTmp = pDst;
|
||||
uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride;
|
||||
const int32_t kiPaddingLen = PADDING_LENGTH;
|
||||
@ -79,8 +79,8 @@ static inline void_t ExpandPictureLuma_c( uint8_t *pDst, const int32_t kiStride,
|
||||
} while (i < kiPicHeight);
|
||||
}
|
||||
|
||||
static inline void_t ExpandPictureChroma_c( uint8_t *pDst, const int32_t kiStride, const int32_t kiPicWidth, const int32_t kiPicHeight )
|
||||
{
|
||||
static inline void_t ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
|
||||
const int32_t kiPicHeight) {
|
||||
uint8_t* pTmp = pDst;
|
||||
uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride;
|
||||
const int32_t kiPaddingLen = (PADDING_LENGTH >> 1);
|
||||
@ -119,15 +119,13 @@ static inline void_t ExpandPictureChroma_c( uint8_t *pDst, const int32_t kiStrid
|
||||
} while (i < kiPicHeight);
|
||||
}
|
||||
|
||||
void_t InitExpandPictureFunc( SExpandPicFunc *pExpandPicFunc, const uint32_t kuiCpuFlags )
|
||||
{
|
||||
void_t InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCpuFlags) {
|
||||
pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_c;
|
||||
pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChroma_c;
|
||||
pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChroma_c;
|
||||
|
||||
#if defined(X86_ASM)
|
||||
if ( (kuiCpuFlags & WELS_CPU_SSE2) == WELS_CPU_SSE2 )
|
||||
{
|
||||
if ((kuiCpuFlags & WELS_CPU_SSE2) == WELS_CPU_SSE2) {
|
||||
pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_sse2;
|
||||
pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChromaUnalign_sse2;
|
||||
pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChromaAlign_sse2;
|
||||
@ -135,8 +133,7 @@ void_t InitExpandPictureFunc( SExpandPicFunc *pExpandPicFunc, const uint32_t kui
|
||||
#endif//X86_ASM
|
||||
}
|
||||
|
||||
void_t ExpandReferencingPicture(PPicture pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChroma[2])
|
||||
{
|
||||
void_t ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChroma[2]) {
|
||||
/*local variable*/
|
||||
uint8_t* pPicY = pPic->pData[0];
|
||||
uint8_t* pPicCb = pPic->pData[1];
|
||||
@ -147,15 +144,12 @@ void_t ExpandReferencingPicture(PPicture pPic, PExpandPictureFunc pExpLuma, PExp
|
||||
const int32_t kiHeightUV = kiHeightY >> 1;
|
||||
|
||||
pExpLuma (pPicY, pPic->iLinesize[0], kiWidthY, kiHeightY);
|
||||
if ( kiWidthUV >= 16 )
|
||||
{
|
||||
if (kiWidthUV >= 16) {
|
||||
// fix coding picture size as 16x16 issues 7/27/2010
|
||||
const bool_t kbChrAligned = /*(kiWidthUV >= 16) && */ ((kiWidthUV & 0x0F) == 0); // chroma planes: (16+kiWidthUV) & 15
|
||||
pExpChroma[kbChrAligned] (pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV);
|
||||
pExpChroma[kbChrAligned] (pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// fix coding picture size as 16x16 issues 7/27/2010
|
||||
ExpandPictureChroma_c (pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV);
|
||||
ExpandPictureChroma_c (pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV);
|
||||
|
@ -54,8 +54,7 @@ namespace WelsDec {
|
||||
*
|
||||
* \return 0 - successful; none 0 - failed
|
||||
*/
|
||||
static inline int32_t FmoGenerateMbAllocMapType0( PFmo pFmo, PPps pPps )
|
||||
{
|
||||
static inline int32_t FmoGenerateMbAllocMapType0 (PFmo pFmo, PPps pPps) {
|
||||
uint32_t uiNumSliceGroups = 0;
|
||||
int32_t iMbNum = 0;
|
||||
int32_t i = 0;
|
||||
@ -65,8 +64,7 @@ static inline int32_t FmoGenerateMbAllocMapType0( PFmo pFmo, PPps pPps )
|
||||
iMbNum = pFmo->iCountMbNum;
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap || iMbNum <= 0 || uiNumSliceGroups >= MAX_SLICEGROUP_IDS))
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
uint8_t uiGroup = 0;
|
||||
do {
|
||||
const int32_t kiRunIdx = pPps->uiRunLength[uiGroup];
|
||||
@ -92,18 +90,17 @@ static inline int32_t FmoGenerateMbAllocMapType0( PFmo pFmo, PPps pPps )
|
||||
*
|
||||
* \return 0 - successful; none 0 - failed
|
||||
*/
|
||||
static inline int32_t FmoGenerateMbAllocMapType1( PFmo pFmo, PPps pPps, const int32_t kiMbWidth )
|
||||
{
|
||||
static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const int32_t kiMbWidth) {
|
||||
uint32_t uiNumSliceGroups = 0;
|
||||
int32_t iMbNum = 0;
|
||||
int16_t i = 0;
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == pPps))
|
||||
uiNumSliceGroups = pPps->uiNumSliceGroups;
|
||||
iMbNum = pFmo->iCountMbNum;
|
||||
WELS_VERIFY_RETURN_IF( 1, ( NULL == pFmo->pMbAllocMap || iMbNum <= 0 || kiMbWidth == 0 || uiNumSliceGroups >= MAX_SLICEGROUP_IDS ) )
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap || iMbNum <= 0 || kiMbWidth == 0
|
||||
|| uiNumSliceGroups >= MAX_SLICEGROUP_IDS))
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
pFmo->pMbAllocMap[i] = (uint8_t) (((i % kiMbWidth) + (((i / kiMbWidth) * uiNumSliceGroups) >> 1)) % uiNumSliceGroups);
|
||||
++ i;
|
||||
} while (i < iMbNum);
|
||||
@ -121,8 +118,8 @@ static inline int32_t FmoGenerateMbAllocMapType1( PFmo pFmo, PPps pPps, const in
|
||||
*
|
||||
* \return 0 - successful; none 0 - failed
|
||||
*/
|
||||
static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth, const int32_t kiMbHeight )
|
||||
{
|
||||
static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth,
|
||||
const int32_t kiMbHeight) {
|
||||
int32_t iNumMb = 0;
|
||||
int32_t iErr = 0;
|
||||
bool_t bResolutionChanged = false;
|
||||
@ -144,8 +141,7 @@ static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const
|
||||
|
||||
pFmo->iCountMbNum = iNumMb;
|
||||
|
||||
if ( kpPps->uiNumSliceGroups < 2 && iNumMb > 0) // only one slice group, exactly it is single slice based
|
||||
{
|
||||
if (kpPps->uiNumSliceGroups < 2 && iNumMb > 0) { // only one slice group, exactly it is single slice based
|
||||
memset (pFmo->pMbAllocMap, 0, iNumMb * sizeof (int8_t)); // for safe
|
||||
|
||||
pFmo->iSliceGroupCount = 1;
|
||||
@ -154,10 +150,8 @@ static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const
|
||||
}
|
||||
|
||||
if (bResolutionChanged || ((int32_t)kpPps->uiSliceGroupMapType != pFmo->iSliceGroupType)
|
||||
|| ((int32_t)kpPps->uiNumSliceGroups != pFmo->iSliceGroupCount) )
|
||||
{
|
||||
switch ( kpPps->uiSliceGroupMapType )
|
||||
{
|
||||
|| ((int32_t)kpPps->uiNumSliceGroups != pFmo->iSliceGroupCount)) {
|
||||
switch (kpPps->uiSliceGroupMapType) {
|
||||
case 0:
|
||||
iErr = FmoGenerateMbAllocMapType0 (pFmo, kpPps);
|
||||
break;
|
||||
@ -177,8 +171,7 @@ static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const
|
||||
}
|
||||
}
|
||||
|
||||
if ( 0 == iErr ) // well now
|
||||
{
|
||||
if (0 == iErr) { // well now
|
||||
pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups;
|
||||
pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType;
|
||||
}
|
||||
@ -196,8 +189,7 @@ static inline int32_t FmoGenerateSliceGroup( PFmo pFmo, const PPps kpPps, const
|
||||
*
|
||||
* \return 0 - successful; none 0 - failed;
|
||||
*/
|
||||
int32_t InitFmo( PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight )
|
||||
{
|
||||
int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight) {
|
||||
return FmoGenerateSliceGroup (pFmo, pPps, kiMbWidth, kiMbHeight);
|
||||
}
|
||||
|
||||
@ -211,8 +203,7 @@ int32_t InitFmo( PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki
|
||||
*
|
||||
* \return NONE
|
||||
*/
|
||||
void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail )
|
||||
{
|
||||
void_t UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) {
|
||||
PFmo pIter = pFmo;
|
||||
int32_t i = 0;
|
||||
int32_t iFreeNodes = 0;
|
||||
@ -221,10 +212,8 @@ void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail )
|
||||
return;
|
||||
|
||||
while (i < kiCnt) {
|
||||
if ( pIter != NULL && pIter->bActiveFlag )
|
||||
{
|
||||
if ( NULL != pIter->pMbAllocMap )
|
||||
{
|
||||
if (pIter != NULL && pIter->bActiveFlag) {
|
||||
if (NULL != pIter->pMbAllocMap) {
|
||||
WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap");
|
||||
|
||||
pIter->pMbAllocMap = NULL;
|
||||
@ -252,8 +241,8 @@ void_t UninitFmoList( PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail )
|
||||
*
|
||||
* \return true - changed or not initialized yet; false - not change at all
|
||||
*/
|
||||
bool_t FmoParamSetsChanged( PFmo pFmo, const int32_t kiCountNumMb, const int32_t kiSliceGroupType, const int32_t kiSliceGroupCount )
|
||||
{
|
||||
bool_t FmoParamSetsChanged (PFmo pFmo, const int32_t kiCountNumMb, const int32_t kiSliceGroupType,
|
||||
const int32_t kiSliceGroupCount) {
|
||||
WELS_VERIFY_RETURN_IF (false, (NULL == pFmo))
|
||||
|
||||
return ((!pFmo->bActiveFlag)
|
||||
@ -272,25 +261,19 @@ bool_t FmoParamSetsChanged( PFmo pFmo, const int32_t kiCountNumMb, const int32_t
|
||||
*
|
||||
* \return true - update/insert successfully; false - failed;
|
||||
*/
|
||||
bool_t FmoParamUpdate( PFmo pFmo, PSps pSps, PPps pPps, int32_t *pActiveFmoNum )
|
||||
{
|
||||
bool_t FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) {
|
||||
const uint32_t kuiMbWidth = pSps->iMbWidth;
|
||||
const uint32_t kuiMbHeight = pSps->iMbHeight;
|
||||
|
||||
if (FmoParamSetsChanged (pFmo,
|
||||
kuiMbWidth * kuiMbHeight,
|
||||
pPps->uiSliceGroupMapType,
|
||||
pPps->uiNumSliceGroups ) )
|
||||
{
|
||||
pPps->uiNumSliceGroups)) {
|
||||
|
||||
if ( InitFmo( pFmo, pPps, kuiMbWidth, kuiMbHeight ) )
|
||||
{
|
||||
if (InitFmo (pFmo, pPps, kuiMbWidth, kuiMbHeight)) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT )
|
||||
{
|
||||
} else {
|
||||
if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) {
|
||||
++ (*pActiveFmoNum);
|
||||
pFmo->bActiveFlag = true;
|
||||
}
|
||||
@ -308,8 +291,7 @@ bool_t 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 )
|
||||
{
|
||||
int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) {
|
||||
const int32_t kiMbNum = pFmo->iCountMbNum;
|
||||
const uint8_t* kpMbMap = pFmo->pMbAllocMap;
|
||||
|
||||
@ -327,8 +309,7 @@ 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 )
|
||||
{
|
||||
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;
|
||||
|
@ -51,8 +51,7 @@ namespace WelsDec {
|
||||
#define I8x8_COUNT 8
|
||||
#define I16x16_COUNT 16
|
||||
|
||||
void_t WelsI4x4LumaPredV_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI4x4LumaPredV_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const uint32_t kuiVal = LD32 (pPred - kiStride);
|
||||
|
||||
ST32 (pPred , kuiVal);
|
||||
@ -61,8 +60,7 @@ void_t WelsI4x4LumaPredV_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST32 (pPred + (kiStride << 1) + kiStride , kuiVal);
|
||||
}
|
||||
|
||||
void_t WelsI4x4LumaPredH_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI4x4LumaPredH_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const int32_t kiStride2 = kiStride << 1;
|
||||
const int32_t kiStride3 = kiStride2 + kiStride;
|
||||
const uint32_t kuiL0 = 0x01010101U * pPred[-1 ];
|
||||
@ -76,8 +74,7 @@ void_t WelsI4x4LumaPredH_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST32 (pPred + kiStride3, kuiL3);
|
||||
}
|
||||
|
||||
void_t WelsI4x4LumaPredDc_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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] +
|
||||
@ -90,8 +87,7 @@ void_t WelsI4x4LumaPredDc_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST32 (pPred + kiStride3, kuiMean32);
|
||||
}
|
||||
|
||||
void_t WelsI4x4LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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;
|
||||
@ -103,11 +99,11 @@ void_t WelsI4x4LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST32 (pPred + kiStride3, kuiMean32);
|
||||
}
|
||||
|
||||
void_t WelsI4x4LumaPredDcTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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 uint8_t kuiMean = (pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 2) >>
|
||||
2;
|
||||
const uint32_t kuiMean32 = 0x01010101U * kuiMean;
|
||||
|
||||
ST32 (pPred , kuiMean32);
|
||||
@ -116,8 +112,7 @@ void_t WelsI4x4LumaPredDcTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST32 (pPred + kiStride3, kuiMean32);
|
||||
}
|
||||
|
||||
void_t WelsI4x4LumaPredDcNA_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI4x4LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const uint32_t kuiDC32 = 0x80808080U;
|
||||
|
||||
ST32 (pPred , kuiDC32);
|
||||
@ -127,8 +122,7 @@ void_t WelsI4x4LumaPredDcNA_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
/*down pLeft*/
|
||||
void_t WelsI4x4LumaPredDDL_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const int32_t kiStride2 = kiStride << 1;
|
||||
const int32_t kiStride3 = kiStride + kiStride2;
|
||||
/*get pTop*/
|
||||
@ -157,8 +151,7 @@ void_t WelsI4x4LumaPredDDL_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
/*down pLeft*/
|
||||
void_t WelsI4x4LumaPredDDLTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const int32_t kiStride2 = kiStride << 1;
|
||||
const int32_t kiStride3 = kiStride + kiStride2;
|
||||
/*get pTop*/
|
||||
@ -185,8 +178,7 @@ void_t WelsI4x4LumaPredDDLTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
|
||||
|
||||
/*down right*/
|
||||
void_t WelsI4x4LumaPredDDR_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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)];
|
||||
@ -226,8 +218,7 @@ void_t WelsI4x4LumaPredDDR_c(uint8_t *pPred, const int32_t kiStride)
|
||||
|
||||
|
||||
/*vertical pLeft*/
|
||||
void_t WelsI4x4LumaPredVL_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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)];
|
||||
@ -264,8 +255,7 @@ void_t WelsI4x4LumaPredVL_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
/*vertical pLeft*/
|
||||
void_t WelsI4x4LumaPredVLTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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)];
|
||||
@ -296,8 +286,7 @@ void_t WelsI4x4LumaPredVLTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
|
||||
|
||||
/*vertical right*/
|
||||
void_t WelsI4x4LumaPredVR_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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];
|
||||
@ -328,8 +317,7 @@ void_t WelsI4x4LumaPredVR_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
/*horizontal up*/
|
||||
void_t WelsI4x4LumaPredHU_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const int32_t kiStride2 = kiStride << 1;
|
||||
const int32_t kiStride3 = kiStride + kiStride2;
|
||||
/*get pLeft*/
|
||||
@ -355,8 +343,7 @@ void_t WelsI4x4LumaPredHU_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
/*horizontal down*/
|
||||
void_t WelsI4x4LumaPredHD_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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)];
|
||||
@ -393,8 +380,7 @@ void_t WelsI4x4LumaPredHD_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST32 (pPred + kiStride3, LD32 (kuiList));
|
||||
}
|
||||
|
||||
void_t WelsIChromaPredV_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const uint64_t kuiVal64 = LD64 (&pPred[-kiStride]);
|
||||
const int32_t kiStride2 = kiStride << 1;
|
||||
const int32_t kiStride4 = kiStride2 << 1;
|
||||
@ -409,13 +395,11 @@ void_t WelsIChromaPredV_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST64 (pPred + (kiStride << 3) - kiStride , kuiVal64);
|
||||
}
|
||||
|
||||
void_t WelsIChromaPredH_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 3) - kiStride;
|
||||
uint8_t i = 7;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
const uint8_t kuiVal8 = pPred[iTmp - 1];
|
||||
const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8;
|
||||
|
||||
@ -426,15 +410,13 @@ void_t WelsIChromaPredH_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
|
||||
void_t WelsIChromaPredPlane_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t a = 0, b = 0, c = 0, H = 0, V = 0;
|
||||
int32_t i, j;
|
||||
uint8_t* pTop = &pPred[-kiStride];
|
||||
uint8_t* pLeft = &pPred[-1];
|
||||
|
||||
for(i = 0 ; i < 4 ; i ++)
|
||||
{
|
||||
for (i = 0 ; i < 4 ; i ++) {
|
||||
H += (i + 1) * (pTop[4 + i] - pTop[2 - i]);
|
||||
V += (i + 1) * (pLeft[ (4 + i) * kiStride] - pLeft[ (2 - i) * kiStride]);
|
||||
}
|
||||
@ -443,10 +425,8 @@ void_t WelsIChromaPredPlane_c(uint8_t *pPred, const int32_t kiStride)
|
||||
b = (17 * H + 16) >> 5;
|
||||
c = (17 * V + 16) >> 5;
|
||||
|
||||
for(i = 0 ; i < 8 ; i ++)
|
||||
{
|
||||
for(j = 0 ; j < 8 ; j ++)
|
||||
{
|
||||
for (i = 0 ; i < 8 ; i ++) {
|
||||
for (j = 0 ; j < 8 ; j ++) {
|
||||
int32_t iTmp = (a + b * (j - 3) + c * (i - 3) + 16) >> 5;
|
||||
iTmp = WELS_CLIP1 (iTmp);
|
||||
pPred[j] = iTmp;
|
||||
@ -456,8 +436,7 @@ void_t WelsIChromaPredPlane_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
|
||||
|
||||
void_t WelsIChromaPredDc_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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;
|
||||
@ -488,8 +467,7 @@ void_t WelsIChromaPredDc_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST64 (pPred + kiL7 + 1, kuiDN64);
|
||||
}
|
||||
|
||||
void_t WelsIChromaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t 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;
|
||||
@ -513,47 +491,42 @@ void_t WelsIChromaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
ST64 (pPred + kiL7 + 1, kuiDN64);
|
||||
}
|
||||
|
||||
void_t WelsIChromaPredDcTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsIChromaPredDcTop_c (uint8_t* pPred, const int32_t 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 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;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
ST64 (pPred + iTmp, LD64 (kuiM));
|
||||
|
||||
iTmp -= kiStride;
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
void_t WelsIChromaPredDcNA_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsIChromaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 3) - kiStride;
|
||||
const uint64_t kuiDC64 = 0x8080808080808080ULL;
|
||||
uint8_t i = 7;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
ST64 (pPred + iTmp, kuiDC64);
|
||||
|
||||
iTmp -= kiStride;
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
void_t WelsI16x16LumaPredV_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredV_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 4) - kiStride;
|
||||
const uint64_t kuiTop1 = LD64 (pPred - kiStride);
|
||||
const uint64_t kuiTop2 = LD64 (pPred - kiStride + 8);
|
||||
uint8_t i = 15;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
ST64 (pPred + iTmp , kuiTop1);
|
||||
ST64 (pPred + iTmp + 8, kuiTop2);
|
||||
|
||||
@ -561,13 +534,11 @@ void_t WelsI16x16LumaPredV_c(uint8_t *pPred, const int32_t kiStride)
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
void_t WelsI16x16LumaPredH_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredH_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 4) - kiStride;
|
||||
uint8_t i = 15;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
const uint8_t kuiVal8 = pPred[iTmp - 1];
|
||||
const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8;
|
||||
|
||||
@ -578,15 +549,13 @@ void_t WelsI16x16LumaPredH_c(uint8_t *pPred, const int32_t kiStride)
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
void_t WelsI16x16LumaPredPlane_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredPlane_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t a = 0, b = 0, c = 0, H = 0, V = 0;
|
||||
int32_t i, j;
|
||||
uint8_t* pTop = &pPred[-kiStride];
|
||||
uint8_t* pLeft = &pPred[-1];
|
||||
|
||||
for(i = 0 ; i < 8 ; i ++)
|
||||
{
|
||||
for (i = 0 ; i < 8 ; i ++) {
|
||||
H += (i + 1) * (pTop[8 + i] - pTop[6 - i]);
|
||||
V += (i + 1) * (pLeft[ (8 + i) * kiStride] - pLeft[ (6 - i) * kiStride]);
|
||||
}
|
||||
@ -595,10 +564,8 @@ void_t WelsI16x16LumaPredPlane_c(uint8_t *pPred, const int32_t kiStride)
|
||||
b = (5 * H + 32) >> 6;
|
||||
c = (5 * V + 32) >> 6;
|
||||
|
||||
for(i = 0 ; i < 16 ; i ++)
|
||||
{
|
||||
for(j = 0 ; j < 16 ; j ++)
|
||||
{
|
||||
for (i = 0 ; i < 16 ; i ++) {
|
||||
for (j = 0 ; j < 16 ; j ++) {
|
||||
int32_t iTmp = (a + b * (j - 7) + c * (i - 7) + 16) >> 5;
|
||||
iTmp = WELS_CLIP1 (iTmp);
|
||||
pPred[j] = iTmp;
|
||||
@ -607,16 +574,14 @@ void_t WelsI16x16LumaPredPlane_c(uint8_t *pPred, const int32_t kiStride)
|
||||
}
|
||||
}
|
||||
|
||||
void_t WelsI16x16LumaPredDc_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredDc_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 4) - kiStride;
|
||||
int32_t iSum = 0;
|
||||
uint8_t i = 15;
|
||||
uint8_t uiMean = 0;
|
||||
|
||||
/*caculate the kMean value*/
|
||||
do
|
||||
{
|
||||
do {
|
||||
iSum += pPred[-1 + iTmp] + pPred[-kiStride + i];
|
||||
iTmp -= kiStride;
|
||||
} while (i-- > 0);
|
||||
@ -624,38 +589,33 @@ void_t WelsI16x16LumaPredDc_c(uint8_t *pPred, const int32_t kiStride)
|
||||
|
||||
iTmp = (kiStride << 4) - kiStride;
|
||||
i = 15;
|
||||
do
|
||||
{
|
||||
do {
|
||||
memset (&pPred[iTmp], uiMean, I16x16_COUNT);
|
||||
iTmp -= kiStride;
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
|
||||
void_t WelsI16x16LumaPredDcTop_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 4) - kiStride;
|
||||
int32_t iSum = 0;
|
||||
uint8_t i = 15;
|
||||
uint8_t uiMean = 0;
|
||||
|
||||
/*caculate the kMean value*/
|
||||
do
|
||||
{
|
||||
do {
|
||||
iSum += pPred[-kiStride + i];
|
||||
} while (i-- > 0);
|
||||
uiMean = (8 + iSum) >> 4;
|
||||
|
||||
i = 15;
|
||||
do
|
||||
{
|
||||
do {
|
||||
memset (&pPred[iTmp], uiMean, I16x16_COUNT);
|
||||
iTmp -= kiStride;
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
void_t WelsI16x16LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 4) - kiStride;
|
||||
int32_t iSum = 0;
|
||||
uint64_t uiMean64 = 0;
|
||||
@ -663,8 +623,7 @@ void_t WelsI16x16LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
uint8_t i = 15;
|
||||
|
||||
/*caculate the kMean value*/
|
||||
do
|
||||
{
|
||||
do {
|
||||
iSum += pPred[-1 + iTmp];
|
||||
iTmp -= kiStride;
|
||||
} while (i-- > 0);
|
||||
@ -673,8 +632,7 @@ void_t WelsI16x16LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
|
||||
iTmp = (kiStride << 4) - kiStride;
|
||||
i = 15;
|
||||
do
|
||||
{
|
||||
do {
|
||||
ST64 (pPred + iTmp , uiMean64);
|
||||
ST64 (pPred + iTmp + 8, uiMean64);
|
||||
|
||||
@ -682,14 +640,12 @@ void_t WelsI16x16LumaPredDcLeft_c(uint8_t *pPred, const int32_t kiStride)
|
||||
} while (i-- > 0);
|
||||
}
|
||||
|
||||
void_t WelsI16x16LumaPredDcNA_c(uint8_t *pPred, const int32_t kiStride)
|
||||
{
|
||||
void_t WelsI16x16LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const uint64_t kuiDC64 = 0x8080808080808080ULL;
|
||||
int32_t iTmp = (kiStride << 4) - kiStride;
|
||||
uint8_t i = 15;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
ST64 (pPred + iTmp, kuiDC64);
|
||||
ST64 (pPred + iTmp + 8, kuiDC64);
|
||||
|
||||
|
@ -47,10 +47,8 @@
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
static void_t SetUnRef(PPicture pRef)
|
||||
{
|
||||
if( NULL != pRef)
|
||||
{
|
||||
static void_t SetUnRef (PPicture pRef) {
|
||||
if (NULL != pRef) {
|
||||
pRef->bUsedAsRef = false;
|
||||
pRef->bIsLongRef = false;
|
||||
pRef->iFrameNum = -1;
|
||||
@ -68,8 +66,7 @@ static void_t SetUnRef(PPicture pRef)
|
||||
// 1.sps arrived that is new sequence starting
|
||||
// 2.IDR NAL i.e. 1st layer in IDR AU
|
||||
|
||||
void_t WelsResetRefPic(PWelsDecoderContext pCtx)
|
||||
{
|
||||
void_t WelsResetRefPic (PWelsDecoderContext pCtx) {
|
||||
int32_t i = 0;
|
||||
PRefPic pRefPic = &pCtx->sRefPic;
|
||||
pCtx->sRefPic.uiLongRefCount[0] = pCtx->sRefPic.uiShortRefCount[0] = 0;
|
||||
@ -96,8 +93,7 @@ void_t WelsResetRefPic(PWelsDecoderContext pCtx)
|
||||
/**
|
||||
* fills the pRefPic.pRefList.
|
||||
*/
|
||||
int32_t WelsInitRefList(PWelsDecoderContext pCtx, int32_t iPoc)
|
||||
{
|
||||
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) {
|
||||
int32_t i, j, iCount = 0;
|
||||
const bool_t kbUseRefBasePicFlag = pCtx->pCurDqLayer->bUseRefBasePicFlag;
|
||||
PPicture* ppShoreRefList = pCtx->sRefPic.pShortRefList[LIST_0];
|
||||
@ -108,15 +104,13 @@ int32_t WelsInitRefList(PWelsDecoderContext pCtx, int32_t iPoc)
|
||||
if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) {
|
||||
pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
|
||||
} else {
|
||||
for ( j = 0;j<pCtx->sRefPic.uiShortRefCount[LIST_0];++j)
|
||||
{
|
||||
if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum && ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag)
|
||||
{
|
||||
for (j = 0; j < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++j) {
|
||||
if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum
|
||||
&& ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == pCtx->sRefPic.uiShortRefCount[LIST_0])
|
||||
{
|
||||
if (j == pCtx->sRefPic.uiShortRefCount[LIST_0]) {
|
||||
pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i];
|
||||
}
|
||||
}
|
||||
@ -128,15 +122,13 @@ int32_t WelsInitRefList(PWelsDecoderContext pCtx, int32_t iPoc)
|
||||
if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) {
|
||||
pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i];
|
||||
} else {
|
||||
for ( j = 0;j<pCtx->sRefPic.uiLongRefCount[LIST_0];++j)
|
||||
{
|
||||
if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx && ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag)
|
||||
{
|
||||
for (j = 0; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) {
|
||||
if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx
|
||||
&& ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == pCtx->sRefPic.uiLongRefCount[LIST_0])
|
||||
{
|
||||
if (j == pCtx->sRefPic.uiLongRefCount[LIST_0]) {
|
||||
pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i];
|
||||
}
|
||||
}
|
||||
@ -146,8 +138,7 @@ int32_t WelsInitRefList(PWelsDecoderContext pCtx, int32_t iPoc)
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
|
||||
{
|
||||
int32_t WelsReorderRefList (PWelsDecoderContext pCtx) {
|
||||
PRefPicListReorderSyn pRefPicListReorderSyn = pCtx->pCurDqLayer->pRefPicListReordering;
|
||||
PNalUnitHeaderExt pNalHeaderExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
|
||||
PSliceHeader pSliceHeader = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader;
|
||||
@ -164,16 +155,15 @@ int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
if ( iRefCount <= 0 )
|
||||
{
|
||||
if (iRefCount <= 0) {
|
||||
pCtx->iErrorCode = dsNoParamSets; //No any reference for decoding, SHOULD request IDR
|
||||
return ERR_INFO_REFERENCE_PIC_LOST;
|
||||
}
|
||||
|
||||
if (pRefPicListReorderSyn->bRefPicListReorderingFlag[LIST_0]) {
|
||||
while (pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc != 3)
|
||||
{
|
||||
uint16_t uiReorderingOfPicNumsIdc = pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc;
|
||||
while (pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc != 3) {
|
||||
uint16_t uiReorderingOfPicNumsIdc =
|
||||
pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiReorderingOfPicNumsIdc;
|
||||
if (uiReorderingOfPicNumsIdc < 2) {
|
||||
iAbsDiffPicNum = pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiAbsDiffPicNumMinus1 + 1;
|
||||
|
||||
@ -185,11 +175,11 @@ int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
|
||||
iPredFrameNum &= iMaxPicNum - 1;
|
||||
|
||||
for (i = iRefCount - 1; i >= iReorderingIndex; i--) {
|
||||
if (ppRefList[i]->iFrameNum == iPredFrameNum && !ppRefList[i]->bIsLongRef)
|
||||
{
|
||||
if( ( pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId ) && ( pSliceHeader->iSpsId != ppRefList[i]->iSpsId ) )//check;
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",pSliceHeader->iSpsId, ppRefList[i]->iSpsId );
|
||||
if (ppRefList[i]->iFrameNum == iPredFrameNum && !ppRefList[i]->bIsLongRef) {
|
||||
if ((pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId)
|
||||
&& (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check;
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",
|
||||
pSliceHeader->iSpsId, ppRefList[i]->iSpsId);
|
||||
pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
|
||||
return ERR_INFO_REFERENCE_PIC_LOST;
|
||||
} else {
|
||||
@ -200,11 +190,13 @@ int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
|
||||
|
||||
} else if (uiReorderingOfPicNumsIdc == 2) {
|
||||
for (i = iRefCount - 1; i >= iReorderingIndex; i--) {
|
||||
if( ppRefList[i]->bIsLongRef && ppRefList[i]->iLongTermFrameIdx == pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiLongTermPicNum )
|
||||
{
|
||||
if ( ( pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId ) && ( pSliceHeader->iSpsId != ppRefList[i]->iSpsId ) )//check;
|
||||
{
|
||||
WelsLog( pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",pSliceHeader->iSpsId, ppRefList[i]->iSpsId );
|
||||
if (ppRefList[i]->bIsLongRef
|
||||
&& ppRefList[i]->iLongTermFrameIdx ==
|
||||
pRefPicListReorderSyn->sReorderingSyn[LIST_0][iReorderingIndex].uiLongTermPicNum) {
|
||||
if ((pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId)
|
||||
&& (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check;
|
||||
WelsLog (pCtx, WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d\n",
|
||||
pSliceHeader->iSpsId, ppRefList[i]->iSpsId);
|
||||
pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
|
||||
return ERR_INFO_REFERENCE_PIC_LOST;
|
||||
} else {
|
||||
@ -217,7 +209,8 @@ int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
|
||||
return ERR_INFO_REFERENCE_PIC_LOST;
|
||||
}
|
||||
pPic = ppRefList[i];
|
||||
memmove(&ppRefList[1+iReorderingIndex], &ppRefList[iReorderingIndex], (i-iReorderingIndex)*sizeof(PPicture));//confirmed_safe_unsafe_usage
|
||||
memmove (&ppRefList[1 + iReorderingIndex], &ppRefList[iReorderingIndex],
|
||||
(i - iReorderingIndex)*sizeof (PPicture)); //confirmed_safe_unsafe_usage
|
||||
ppRefList[iReorderingIndex] = pPic;
|
||||
iReorderingIndex++;
|
||||
}
|
||||
@ -225,8 +218,7 @@ int32_t WelsReorderRefList(PWelsDecoderContext pCtx)
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t WelsMarkAsRef(PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag)
|
||||
{
|
||||
int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFlag) {
|
||||
PRefPic pRefPic = &pCtx->sRefPic;
|
||||
PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;
|
||||
PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking;
|
||||
@ -245,7 +237,8 @@ int32_t WelsMarkAsRef(PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFla
|
||||
pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag;
|
||||
|
||||
for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) {
|
||||
if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType== NAL_UNIT_CODED_SLICE_IDR|| pCurAU->pNalUnitsList[j]->sNalHeaderExt.bIdrFlag) {
|
||||
if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR
|
||||
|| pCurAU->pNalUnitsList[j]->sNalHeaderExt.bIdrFlag) {
|
||||
bIsIDRAU = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -268,8 +261,7 @@ int32_t WelsMarkAsRef(PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFla
|
||||
|
||||
if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {
|
||||
iRet = MMCO (pCtx, pRefPicMarking);
|
||||
if( pCtx->bLastHasMmco5 )
|
||||
{
|
||||
if (pCtx->bLastHasMmco5) {
|
||||
pCtx->pDec->iFrameNum = 0;
|
||||
pCtx->pDec->iFramePoc = 0;
|
||||
}
|
||||
@ -288,15 +280,15 @@ int32_t WelsMarkAsRef(PWelsDecoderContext pCtx, const bool_t kbRefBaseMarkingFla
|
||||
return iRet;
|
||||
}
|
||||
|
||||
static int32_t MMCOBase(PWelsDecoderContext pCtx,PRefBasePicMarking pRefPicBaseMarking)
|
||||
{
|
||||
static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking) {
|
||||
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
|
||||
int32_t i = 0;
|
||||
int32_t iRet = ERR_NONE;
|
||||
|
||||
for (i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++) {
|
||||
uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType;
|
||||
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) &((1<<pSps->uiLog2MaxFrameNum)-1);
|
||||
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) & ((
|
||||
1 << pSps->uiLog2MaxFrameNum) - 1);
|
||||
uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum;
|
||||
if (uiMmcoType > MMCO_LONG2UNUSED) {
|
||||
return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
|
||||
@ -311,14 +303,14 @@ static int32_t MMCOBase(PWelsDecoderContext pCtx,PRefBasePicMarking pRefPicBaseM
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
static int32_t MMCO(PWelsDecoderContext pCtx,PRefPicMarking pRefPicMarking)
|
||||
{
|
||||
static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) {
|
||||
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
|
||||
int32_t i = 0;
|
||||
int32_t iRet = ERR_NONE;
|
||||
for (i = 0; pRefPicMarking->sMmcoRef[i].uiMmcoType != MMCO_END; i++) {
|
||||
uint32_t uiMmcoType = pRefPicMarking->sMmcoRef[i].uiMmcoType;
|
||||
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicMarking->sMmcoRef[i].iDiffOfPicNum) & ((1<<pSps->uiLog2MaxFrameNum)-1);
|
||||
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicMarking->sMmcoRef[i].iDiffOfPicNum) & ((
|
||||
1 << pSps->uiLog2MaxFrameNum) - 1);
|
||||
uint32_t uiLongTermPicNum = pRefPicMarking->sMmcoRef[i].uiLongTermPicNum;
|
||||
int32_t iLongTermFrameIdx = pRefPicMarking->sMmcoRef[i].iLongTermFrameIdx;
|
||||
int32_t iMaxLongTermFrameIdx = pRefPicMarking->sMmcoRef[i].iMaxLongTermFrameIdx;
|
||||
@ -334,15 +326,13 @@ static int32_t MMCO(PWelsDecoderContext pCtx,PRefPicMarking pRefPicMarking)
|
||||
return ERR_NONE;
|
||||
}
|
||||
static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool_t bRefBasePic,
|
||||
int32_t iShortFrameNum,uint32_t uiLongTermPicNum ,int32_t iLongTermFrameIdx,int32_t iMaxLongTermFrameIdx )
|
||||
{
|
||||
int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {
|
||||
PRefPic pRefPic = &pCtx->sRefPic;
|
||||
PPicture pPic = NULL;
|
||||
int32_t i = 0;
|
||||
int32_t iRet = ERR_NONE;
|
||||
|
||||
switch (uiMmcoType)
|
||||
{
|
||||
switch (uiMmcoType) {
|
||||
case MMCO_SHORT2UNUSED:
|
||||
pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic);
|
||||
break;
|
||||
@ -361,7 +351,8 @@ static int32_t MMCOProcess( PWelsDecoderContext pCtx,uint32_t uiMmcoType,bool_t
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bCurAuContainLtrMarkSeFlag = true;
|
||||
pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum;
|
||||
WelsLog( pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_SHORT2LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNumOfAuMarkedLtr );
|
||||
WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_SHORT2LONG:::LTR marking....iFrameNum: %d\n",
|
||||
pCtx->iFrameNumOfAuMarkedLtr);
|
||||
#endif
|
||||
|
||||
MarkAsLongTerm (pRefPic, iShortFrameNum, iLongTermFrameIdx);
|
||||
@ -398,8 +389,7 @@ static int32_t MMCOProcess( PWelsDecoderContext pCtx,uint32_t uiMmcoType,bool_t
|
||||
return iRet;
|
||||
}
|
||||
|
||||
static int32_t SlidingWindow( PWelsDecoderContext pCtx )
|
||||
{
|
||||
static int32_t SlidingWindow (PWelsDecoderContext pCtx) {
|
||||
PRefPic pRefPic = &pCtx->sRefPic;
|
||||
PPicture pPic = NULL;
|
||||
int32_t i = 0;
|
||||
@ -418,25 +408,23 @@ static int32_t SlidingWindow( PWelsDecoderContext pCtx )
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
static PPicture WelsDelShortFromList(PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag)
|
||||
{
|
||||
static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
|
||||
int32_t i = 0;
|
||||
int32_t iMoveSize = 0;
|
||||
PPicture pPic = NULL;
|
||||
|
||||
for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {
|
||||
if( pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum)
|
||||
{
|
||||
if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) {
|
||||
if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
|
||||
|| (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
|
||||
||(eRemoveFlag == REMOVE_BASE_FIRST ) )
|
||||
{
|
||||
|| (eRemoveFlag == REMOVE_BASE_FIRST)) {
|
||||
iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
|
||||
pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
|
||||
pPic = pRefPic->pShortRefList[LIST_0][i];
|
||||
pRefPic->pShortRefList[LIST_0][i] = NULL;
|
||||
if (iMoveSize > 0) {
|
||||
memmove(&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i+1], iMoveSize * sizeof(PPicture));//confirmed_safe_unsafe_usage
|
||||
memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
|
||||
iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
pRefPic->uiShortRefCount[LIST_0]--;
|
||||
pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
|
||||
@ -448,8 +436,7 @@ static PPicture WelsDelShortFromList(PRefPic pRefPic, int32_t iFrameNum, ERemove
|
||||
return pPic;
|
||||
}
|
||||
|
||||
static PPicture WelsDelShortFromListSetUnref(PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag)
|
||||
{
|
||||
static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
|
||||
PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag);
|
||||
if (pPic) {
|
||||
SetUnRef (pPic);
|
||||
@ -457,22 +444,20 @@ static PPicture WelsDelShortFromListSetUnref(PRefPic pRefPic, int32_t iFrameNum,
|
||||
return pPic;
|
||||
}
|
||||
|
||||
static PPicture WelsDelLongFromList(PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag)
|
||||
{
|
||||
static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
|
||||
PPicture pPic = NULL;
|
||||
int32_t i = 0;
|
||||
for ( i = 0;i<pRefPic->uiLongRefCount[LIST_0];i++)
|
||||
{
|
||||
for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
|
||||
pPic = pRefPic->pLongRefList[LIST_0][i];
|
||||
if ( pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx)
|
||||
{
|
||||
if( ((eRemoveFlag == REMOVE_TARGET) && !(pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE) && pPic->bRefBaseFlag) )
|
||||
{
|
||||
if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {
|
||||
if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE)
|
||||
&& pPic->bRefBaseFlag)) {
|
||||
int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
|
||||
pPic->bUsedAsRef = FALSE;
|
||||
pPic->bIsLongRef = FALSE;
|
||||
if (iMoveSize > 0) {
|
||||
memmove(&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i+1], iMoveSize * sizeof(PPicture));//confirmed_safe_unsafe_usage
|
||||
memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
|
||||
iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
pRefPic->uiLongRefCount[LIST_0]--;
|
||||
pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
|
||||
@ -483,8 +468,7 @@ static PPicture WelsDelLongFromList(PRefPic pRefPic, uint32_t uiLongTermFrameIdx
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PPicture WelsDelLongFromListSetUnref(PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag)
|
||||
{
|
||||
static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
|
||||
PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag);
|
||||
if (pPic) {
|
||||
SetUnRef (pPic);
|
||||
@ -492,21 +476,20 @@ static PPicture WelsDelLongFromListSetUnref(PRefPic pRefPic, uint32_t uiLongTerm
|
||||
return pPic;
|
||||
}
|
||||
|
||||
static int32_t AddShortTermToList(PRefPic pRefPic,PPicture pPic)
|
||||
{
|
||||
static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic) {
|
||||
pPic->bUsedAsRef = TRUE;
|
||||
pPic->bIsLongRef = FALSE;
|
||||
pPic->iLongTermFrameIdx = -1;
|
||||
if (pRefPic->uiShortRefCount[LIST_0] > 0) {
|
||||
memmove(&pRefPic->pShortRefList[LIST_0][1],&pRefPic->pShortRefList[LIST_0][0],pRefPic->uiShortRefCount[LIST_0]*sizeof(PPicture));//confirmed_safe_unsafe_usage
|
||||
memmove (&pRefPic->pShortRefList[LIST_0][1], &pRefPic->pShortRefList[LIST_0][0],
|
||||
pRefPic->uiShortRefCount[LIST_0]*sizeof (PPicture));//confirmed_safe_unsafe_usage
|
||||
}
|
||||
pRefPic->pShortRefList[LIST_0][0] = pPic;
|
||||
pRefPic->uiShortRefCount[LIST_0]++;
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
static int32_t AddLongTermToList(PRefPic pRefPic,PPicture pPic, int32_t iLongTermFrameIdx)
|
||||
{
|
||||
static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx) {
|
||||
int32_t i = 0;
|
||||
|
||||
pPic->bUsedAsRef = TRUE;
|
||||
@ -520,7 +503,8 @@ static int32_t AddLongTermToList(PRefPic pRefPic,PPicture pPic, int32_t iLongTer
|
||||
break;
|
||||
}
|
||||
}
|
||||
memmove(&pRefPic->pLongRefList[LIST_0][i+1],&pRefPic->pLongRefList[LIST_0][i],(pRefPic->uiLongRefCount[LIST_0]-i)*sizeof(PPicture));//confirmed_safe_unsafe_usage
|
||||
memmove (&pRefPic->pLongRefList[LIST_0][i + 1], &pRefPic->pLongRefList[LIST_0][i],
|
||||
(pRefPic->uiLongRefCount[LIST_0] - i)*sizeof (PPicture)); //confirmed_safe_unsafe_usage
|
||||
pRefPic->pLongRefList[LIST_0][i] = pPic;
|
||||
} else {
|
||||
return ERR_INFO_REF_COUNT_OVERFLOW;
|
||||
@ -531,8 +515,7 @@ static int32_t AddLongTermToList(PRefPic pRefPic,PPicture pPic, int32_t iLongTer
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
static int32_t AssignLongTermIdx(PRefPic pRefPic,int32_t iFrameNum,int32_t iLongTermFrameIdx )
|
||||
{
|
||||
static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
|
||||
PPicture pPic = NULL;
|
||||
int32_t iRet = ERR_NONE;
|
||||
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
|
||||
@ -554,8 +537,7 @@ static int32_t AssignLongTermIdx(PRefPic pRefPic,int32_t iFrameNum,int32_t iLong
|
||||
return iRet;
|
||||
}
|
||||
|
||||
static int32_t MarkAsLongTerm( PRefPic pRefPic,int32_t iFrameNum, int32_t iLongTermFrameIdx )
|
||||
{
|
||||
static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
|
||||
PPicture pPic = NULL;
|
||||
int32_t i = 0;
|
||||
int32_t iRet = ERR_NONE;
|
||||
|
@ -50,8 +50,7 @@ namespace WelsDec {
|
||||
//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}
|
||||
@ -86,49 +85,46 @@ static const uint8_t g_kuiABCD[8][8][4] = //g_kA[dy][dx], g_kB[dy][dx], g_kC[dy]
|
||||
}
|
||||
};
|
||||
|
||||
typedef void_t (*PWelsMcWidthHeightFunc)(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight);
|
||||
typedef void_t (*PWelsMcWidthHeightFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
|
||||
//***************************************************************************//
|
||||
// C code implementation //
|
||||
//***************************************************************************//
|
||||
static inline void_t McCopyWidthEq2_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McCopyWidthEq2_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++)// iWidth == 2 only for chroma
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) { // iWidth == 2 only for chroma
|
||||
ST16 (pDst, LD16 (pSrc));
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void_t McCopyWidthEq4_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McCopyWidthEq4_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
ST32 (pDst, LD32 (pSrc));
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void_t McCopyWidthEq8_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McCopyWidthEq8_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
ST64 (pDst, LD64 (pSrc));
|
||||
pDst += iDstStride;
|
||||
pSrc += iSrcStride;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void_t McCopyWidthEq16_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McCopyWidthEq16_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
int32_t i;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
ST64 (pDst , LD64 (pSrc));
|
||||
ST64 (pDst + 8, LD64 (pSrc + 8));
|
||||
pDst += iDstStride;
|
||||
@ -138,8 +134,7 @@ static inline void_t McCopyWidthEq16_c(uint8_t* pSrc, int32_t iSrcStride, uint8_
|
||||
|
||||
//--------------------Luma sample MC------------------//
|
||||
|
||||
static inline int32_t HorFilterInput16bit_c(int16_t* pSrc)
|
||||
{
|
||||
static inline int32_t HorFilterInput16bit_c (int16_t* pSrc) {
|
||||
int32_t iPix05 = pSrc[-2] + pSrc[3];
|
||||
int32_t iPix14 = pSrc[-1] + pSrc[2];
|
||||
int32_t iPix23 = pSrc[ 0] + pSrc[1];
|
||||
@ -147,8 +142,7 @@ static inline int32_t HorFilterInput16bit_c(int16_t* pSrc)
|
||||
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
||||
}
|
||||
// h: iOffset=1 / v: iOffset=iSrcStride
|
||||
static inline int32_t FilterInput8bitWithStride_c(uint8_t* pSrc, const int32_t kiOffset)
|
||||
{
|
||||
static inline int32_t FilterInput8bitWithStride_c (uint8_t* pSrc, const int32_t kiOffset) {
|
||||
const int32_t kiOffset1 = kiOffset;
|
||||
const int32_t kiOffset2 = (kiOffset << 1);
|
||||
const int32_t kiOffset3 = kiOffset + kiOffset2;
|
||||
@ -160,13 +154,10 @@ static inline int32_t FilterInput8bitWithStride_c(uint8_t* pSrc, const int32_t k
|
||||
}
|
||||
|
||||
static inline void_t PixelAvg_c (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride,
|
||||
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
uint8_t* pSrcB, int32_t iSrcBStride, int32_t iWidth, int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (j = 0; j < iWidth; j++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = (pSrcA[j] + pSrcB[j] + 1) >> 1;
|
||||
}
|
||||
pDst += iDstStride;
|
||||
@ -174,8 +165,8 @@ static inline void_t PixelAvg_c(uint8_t* pDst, int32_t iDstStride, uint8_t* pSrc
|
||||
pSrcB += iSrcBStride;
|
||||
}
|
||||
}
|
||||
static inline void_t McCopy_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McCopy_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McCopyWidthEq16_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
@ -186,13 +177,11 @@ static inline void_t McCopy_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst,
|
||||
McCopyWidthEq2_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer20_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer20_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (j = 0; j < iWidth; j++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = WELS_CLIP1 ((FilterInput8bitWithStride_c (pSrc + j, 1) + 16) >> 5);
|
||||
}
|
||||
pDst += iDstStride;
|
||||
@ -200,13 +189,11 @@ static inline void_t McHorVer20_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pD
|
||||
}
|
||||
}
|
||||
|
||||
static inline void_t McHorVer02_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer02_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (j = 0; j < iWidth; j++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = WELS_CLIP1 ((FilterInput8bitWithStride_c (pSrc + j, iSrcStride) + 16) >> 5);
|
||||
}
|
||||
pDst += iDstStride;
|
||||
@ -214,19 +201,16 @@ static inline void_t McHorVer02_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pD
|
||||
}
|
||||
}
|
||||
|
||||
static inline void_t McHorVer22_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer22_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
int16_t iTmp[16 + 5] = {0}; //16
|
||||
int32_t i, j, k;
|
||||
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (j = 0; j < iWidth + 5; j++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth + 5; j++) {
|
||||
iTmp[j] = FilterInput8bitWithStride_c (pSrc - 2 + j, iSrcStride);
|
||||
}
|
||||
for (k = 0; k < iWidth; k++)
|
||||
{
|
||||
for (k = 0; k < iWidth; k++) {
|
||||
pDst[k] = WELS_CLIP1 ((HorFilterInput16bit_c (&iTmp[2 + k]) + 512) >> 10);
|
||||
}
|
||||
pSrc += iSrcStride;
|
||||
@ -235,88 +219,88 @@ static inline void_t McHorVer22_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pD
|
||||
}
|
||||
|
||||
/////////////////////luma MC//////////////////////////
|
||||
static inline void_t McHorVer01_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer01_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiTmp[256] = { 0 };
|
||||
McHorVer02_c (pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer03_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer03_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiTmp[256] = { 0 };
|
||||
McHorVer02_c (pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, pSrc + iSrcStride, iSrcStride, uiTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer10_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer10_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer11_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer11_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
uint8_t uiVerTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
McHorVer02_c (pSrc, iSrcStride, uiVerTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer12_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer12_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiVerTmp[256] = { 0 };
|
||||
uint8_t uiCtrTmp[256] = { 0 };
|
||||
McHorVer02_c (pSrc, iSrcStride, uiVerTmp, 16, iWidth, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiVerTmp, 16, uiCtrTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer13_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer13_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
uint8_t uiVerTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc + iSrcStride, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
McHorVer02_c (pSrc, iSrcStride, uiVerTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer21_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer21_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
uint8_t uiCtrTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiHorTmp, 16, uiCtrTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer23_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer23_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
uint8_t uiCtrTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc + iSrcStride, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiHorTmp, 16, uiCtrTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer30_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer30_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, pSrc + 1, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer31_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer31_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
uint8_t uiVerTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
McHorVer02_c (pSrc + 1, iSrcStride, uiVerTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer32_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer32_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiVerTmp[256] = { 0 };
|
||||
uint8_t uiCtrTmp[256] = { 0 };
|
||||
McHorVer02_c (pSrc + 1, iSrcStride, uiVerTmp, 16, iWidth, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight);
|
||||
PixelAvg_c (pDst, iDstStride, uiVerTmp, 16, uiCtrTmp, 16, iWidth, iHeight);
|
||||
}
|
||||
static inline void_t McHorVer33_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer33_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
uint8_t uiHorTmp[256] = { 0 };
|
||||
uint8_t uiVerTmp[256] = { 0 };
|
||||
McHorVer20_c (pSrc + iSrcStride, iSrcStride, uiHorTmp, 16, iWidth, iHeight);
|
||||
@ -328,8 +312,7 @@ void_t McLuma_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstSt
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight)
|
||||
//pSrc has been added the offset of mv
|
||||
{
|
||||
PWelsMcWidthHeightFunc pWelsMcFunc[4][4] = //[x][y]
|
||||
{
|
||||
PWelsMcWidthHeightFunc pWelsMcFunc[4][4] = { //[x][y]
|
||||
{McCopy_c, McHorVer01_c, McHorVer02_c, McHorVer03_c},
|
||||
{McHorVer10_c, McHorVer11_c, McHorVer12_c, McHorVer13_c},
|
||||
{McHorVer20_c, McHorVer21_c, McHorVer22_c, McHorVer23_c},
|
||||
@ -339,8 +322,8 @@ void_t McLuma_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstSt
|
||||
pWelsMcFunc[iMvX & 0x03][iMvY & 0x03] (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McChromaWithFragMv_c( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight )
|
||||
{
|
||||
static inline void_t McChromaWithFragMv_c (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||
int32_t i, j;
|
||||
int32_t iA, iB, iC, iD;
|
||||
uint8_t* pSrcNext = pSrc + iSrcStride;
|
||||
@ -349,10 +332,8 @@ static inline void_t McChromaWithFragMv_c( uint8_t *pSrc, int32_t iSrcStride, ui
|
||||
iB = (kuiABCD >> 8) & 0xff;
|
||||
iC = (kuiABCD >> 16) & 0xff;
|
||||
iD = (kuiABCD >> 24) & 0xff;
|
||||
for (i = 0; i < iHeight; i++)
|
||||
{
|
||||
for (j = 0; j < iWidth; j++)
|
||||
{
|
||||
for (i = 0; i < iHeight; i++) {
|
||||
for (j = 0; j < iWidth; j++) {
|
||||
pDst[j] = (iA * pSrc[j] + iB * pSrc[j + 1] + iC * pSrcNext[j] + iD * pSrcNext[j + 1] + 32) >> 6;
|
||||
}
|
||||
pDst += iDstStride;
|
||||
@ -377,27 +358,27 @@ void_t McChroma_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDst
|
||||
//***************************************************************************//
|
||||
// SSE2 implement //
|
||||
//***************************************************************************//
|
||||
static inline void_t McHorVer22WidthEq8_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight )
|
||||
{
|
||||
static inline void_t McHorVer22WidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
ENFORCE_STACK_ALIGN_2D (int16_t, iTap, 21, 8, 16)
|
||||
McHorVer22Width8HorFirst_sse2 (pSrc - 2, iSrcStride, (uint8_t*)iTap, 16, iHeight + 5);
|
||||
McHorVer22VerLast_sse2 ((uint8_t*)iTap, 16, pDst, iDstStride, 8, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer02WidthEq16_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight )
|
||||
{
|
||||
static inline void_t McHorVer02WidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
McHorVer02WidthEq8_sse2 (&pSrc[8], iSrcStride, &pDst[8], iDstStride, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer22WidthEq16_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight )
|
||||
{
|
||||
static inline void_t McHorVer22WidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight) {
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (&pSrc[8], iSrcStride, &pDst[8], iDstStride, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McCopy_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McCopy_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McCopyWidthEq16_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
@ -408,8 +389,8 @@ static inline void_t McCopy_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDs
|
||||
McCopyWidthEq2_c (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer20_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer20_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
@ -418,8 +399,8 @@ static inline void_t McHorVer20_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t*
|
||||
McHorVer20WidthEq4_mmx (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer02_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer02_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
@ -428,8 +409,8 @@ static inline void_t McHorVer02_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t*
|
||||
McHorVer02_c (pSrc, iSrcStride, pDst, iDstStride, 4, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer22_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer22_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
if (iWidth == 16)
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||
else if (iWidth == 8)
|
||||
@ -438,261 +419,201 @@ static inline void_t McHorVer22_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t*
|
||||
McHorVer22_c (pSrc, iSrcStride, pDst, iDstStride, 4, iHeight);
|
||||
}
|
||||
|
||||
static inline void_t McHorVer01_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer01_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer02_c (pSrc, iSrcStride, pTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer03_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer03_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer02_c (pSrc, iSrcStride, pTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pSrc + iSrcStride, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer10_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer10_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer11_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer11_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pVerTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02_c (pSrc, iSrcStride, pVerTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer12_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer12_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pVerTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pCtrTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pVerTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, pVerTmp, 16, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer02_c (pSrc, iSrcStride, pVerTmp, 16, 4, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer13_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer13_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pVerTmp, 256, 16);
|
||||
if (iWidth ==16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq8_sse2 (pSrc, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02_c (pSrc, iSrcStride, pVerTmp, 16, 4 , iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer21_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer21_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pCtrTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer23_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer23_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pCtrTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer30_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer30_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pSrc + 1, iSrcStride, pHorTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pSrc + 1, iSrcStride, pHorTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pSrc + 1, iSrcStride, pHorTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer31_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer31_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pVerTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc + 1, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq8_sse2 (pSrc + 1, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02_c (pSrc + 1, iSrcStride, pVerTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer32_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer32_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pVerTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pCtrTmp, 256, 16);
|
||||
if (iWidth ==16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer02WidthEq16_sse2 (pSrc + 1, iSrcStride, pVerTmp, 16, iHeight);
|
||||
McHorVer22WidthEq16_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer02WidthEq8_sse2 (pSrc + 1, iSrcStride, pVerTmp, 16, iHeight);
|
||||
McHorVer22WidthEq8_sse2 (pSrc, iSrcStride, pCtrTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer02_c (pSrc + 1, iSrcStride, pVerTmp, 16, 4, iHeight);
|
||||
McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight);
|
||||
}
|
||||
}
|
||||
static inline void_t McHorVer33_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight)
|
||||
{
|
||||
static inline void_t McHorVer33_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight) {
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pHorTmp, 256, 16);
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, pVerTmp, 256, 16);
|
||||
if (iWidth == 16)
|
||||
{
|
||||
if (iWidth == 16) {
|
||||
McHorVer20WidthEq16_sse2 (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq16_sse2 (pSrc + 1, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else if(iWidth == 8)
|
||||
{
|
||||
} else if (iWidth == 8) {
|
||||
McHorVer20WidthEq8_sse2 (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02WidthEq8_sse2 (pSrc + 1, iSrcStride, pVerTmp, 16, iHeight);
|
||||
PixelAvgWidthEq8_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
McHorVer20WidthEq4_mmx (pSrc + iSrcStride, iSrcStride, pHorTmp, 16, iHeight);
|
||||
McHorVer02_c (pSrc + 1, iSrcStride, pVerTmp, 16, 4, iHeight);
|
||||
PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight);
|
||||
@ -703,8 +624,7 @@ void_t McLuma_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDs
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight)
|
||||
//pSrc has been added the offset of mv
|
||||
{
|
||||
PWelsMcWidthHeightFunc pWelsMcFunc[4][4] = //[x][y]
|
||||
{
|
||||
PWelsMcWidthHeightFunc pWelsMcFunc[4][4] = { //[x][y]
|
||||
{McCopy_sse2, McHorVer01_sse2, McHorVer02_sse2, McHorVer03_sse2},
|
||||
{McHorVer10_sse2, McHorVer11_sse2, McHorVer12_sse2, McHorVer13_sse2},
|
||||
{McHorVer20_sse2, McHorVer21_sse2, McHorVer22_sse2, McHorVer23_sse2},
|
||||
@ -715,39 +635,32 @@ void_t McLuma_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDs
|
||||
}
|
||||
|
||||
void_t McChroma_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight )
|
||||
{
|
||||
static const PMcChromaWidthExtFunc kpMcChromaWidthFuncs[2] =
|
||||
{
|
||||
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||
static const PMcChromaWidthExtFunc kpMcChromaWidthFuncs[2] = {
|
||||
McChromaWidthEq4_mmx,
|
||||
McChromaWidthEq8_sse2
|
||||
};
|
||||
const int32_t kiD8x = iMvX & 0x07;
|
||||
const int32_t kiD8y = iMvY & 0x07;
|
||||
if (kiD8x ==0 && kiD8y ==0)
|
||||
{
|
||||
if (kiD8x == 0 && kiD8y == 0) {
|
||||
McCopy_sse2 (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||
return;
|
||||
}
|
||||
if (iWidth != 2)
|
||||
{
|
||||
if (iWidth != 2) {
|
||||
kpMcChromaWidthFuncs[iWidth >> 3] (pSrc, iSrcStride, pDst, iDstStride, g_kuiABCD[kiD8y][kiD8x], iHeight);
|
||||
}
|
||||
else
|
||||
} else
|
||||
McChromaWithFragMv_c (pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight);
|
||||
}
|
||||
|
||||
|
||||
#endif //X86_ASM
|
||||
|
||||
void_t InitMcFunc(SMcFunc *pMcFunc, int32_t iCpu)
|
||||
{
|
||||
void_t InitMcFunc (SMcFunc* pMcFunc, int32_t iCpu) {
|
||||
pMcFunc->pMcLumaFunc = McLuma_c;
|
||||
pMcFunc->pMcChromaFunc = McChroma_c;
|
||||
|
||||
#if defined (X86_ASM)
|
||||
if ( iCpu & WELS_CPU_SSE2 )
|
||||
{
|
||||
if (iCpu & WELS_CPU_SSE2) {
|
||||
pMcFunc->pMcLumaFunc = McLuma_sse2;
|
||||
pMcFunc->pMcChromaFunc = McChroma_sse2;
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ int32_t iCountMalloc = 0;
|
||||
#define ALIGNBYTES (16)
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void_t * WelsMalloc( const uint32_t kuiSize, const str_t *kpTag )
|
||||
{
|
||||
void_t* WelsMalloc (const uint32_t kuiSize, const str_t* kpTag) {
|
||||
const int32_t kiSizeVoidPtr = sizeof (void_t**);
|
||||
const int32_t kiSizeInt = sizeof (int32_t);
|
||||
#ifdef HAVE_CACHE_LINE_ALIGN
|
||||
@ -67,14 +66,12 @@ void_t * WelsMalloc( const uint32_t kuiSize, const str_t *kpTag )
|
||||
pMemCheckFree = WelsFopen (".\\mem_check_free.txt", "at+");
|
||||
}
|
||||
|
||||
if ( kpTag != NULL )
|
||||
{
|
||||
if ( pMemCheckMalloc != NULL )
|
||||
{
|
||||
fprintf( pMemCheckMalloc, "0x%x, size: %d , malloc %s\n", (void_t *)pBuf, (kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt), kpTag );
|
||||
if (kpTag != NULL) {
|
||||
if (pMemCheckMalloc != NULL) {
|
||||
fprintf (pMemCheckMalloc, "0x%x, size: %d , malloc %s\n", (void_t*)pBuf,
|
||||
(kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt), kpTag);
|
||||
}
|
||||
if ( pMemCheckMalloc != NULL )
|
||||
{
|
||||
if (pMemCheckMalloc != NULL) {
|
||||
fflush (pMemCheckMalloc);
|
||||
}
|
||||
}
|
||||
@ -96,13 +93,10 @@ void_t * WelsMalloc( const uint32_t kuiSize, const str_t *kpTag )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void_t WelsFree( void_t* pPtr, const str_t *kpTag )
|
||||
{
|
||||
if( pPtr )
|
||||
{
|
||||
void_t WelsFree (void_t* pPtr, const str_t* kpTag) {
|
||||
if (pPtr) {
|
||||
#ifdef MEMORY_CHECK
|
||||
if ( NULL != pMemCheckFree && kpTag != NULL )
|
||||
{
|
||||
if (NULL != pMemCheckFree && kpTag != NULL) {
|
||||
fprintf (pMemCheckFree, "0x%x, free %s\n", (void_t*) (* (((void_t**) pPtr) - 1)), kpTag);
|
||||
fflush (pMemCheckFree);
|
||||
}
|
||||
|
@ -82,12 +82,10 @@ int32_t MemInitNalList(PAccessUnit *ppAu, const uint32_t kuiSize){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t MemFreeNalList(PAccessUnit *ppAu)
|
||||
{
|
||||
int32_t MemFreeNalList (PAccessUnit* ppAu) {
|
||||
if (ppAu != NULL) {
|
||||
PAccessUnit pAu = *ppAu;
|
||||
if (pAu != NULL)
|
||||
{
|
||||
if (pAu != NULL) {
|
||||
WelsFree (pAu, "Access Unit");
|
||||
*ppAu = NULL;
|
||||
}
|
||||
@ -96,20 +94,17 @@ int32_t MemFreeNalList(PAccessUnit *ppAu)
|
||||
}
|
||||
|
||||
|
||||
int32_t ExpandNalUnitList(PAccessUnit *ppAu, const int32_t kiOrgSize, const int32_t kiExpSize)
|
||||
{
|
||||
int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int32_t kiExpSize) {
|
||||
if (kiExpSize <= kiOrgSize)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
else {
|
||||
PAccessUnit pTmp = NULL;
|
||||
int32_t iIdx = 0;
|
||||
|
||||
if (MemInitNalList (&pTmp, kiExpSize)) // request new list with expanding
|
||||
return 1;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
memcpy (pTmp->pNalUnitsList[iIdx], (*ppAu)->pNalUnitsList[iIdx], sizeof (SNalUnit)); //confirmed_safe_unsafe_usage
|
||||
++ iIdx;
|
||||
} while (iIdx < kiOrgSize);
|
||||
@ -135,8 +130,7 @@ 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
|
||||
|
@ -46,8 +46,7 @@ namespace WelsDec {
|
||||
|
||||
//basic iMVs prediction unit for iMVs partition width (4, 2, 1)
|
||||
void_t PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2])
|
||||
{
|
||||
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;
|
||||
@ -68,64 +67,47 @@ void_t PredMv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][
|
||||
* (int32_t*)iBMV = INTD32 (iMotionVector[0][ kuiTopIdx]);
|
||||
* (int32_t*)iCMV = INTD32 (iMotionVector[0][kuiRightTopIdx]);
|
||||
|
||||
if (REF_NOT_AVAIL == iDiagonalRef)
|
||||
{
|
||||
if (REF_NOT_AVAIL == iDiagonalRef) {
|
||||
iDiagonalRef = kiLeftTopRef;
|
||||
* (int32_t*)iCMV = INTD32 (iMotionVector[0][kuiLeftTopIdx]);
|
||||
}
|
||||
|
||||
iMatchRef = (iRef == kiLeftRef) + (iRef == kiTopRef) + (iRef == iDiagonalRef);
|
||||
|
||||
if (REF_NOT_AVAIL == kiTopRef && REF_NOT_AVAIL == iDiagonalRef && kiLeftRef >= REF_NOT_IN_LIST)
|
||||
{
|
||||
if (REF_NOT_AVAIL == kiTopRef && REF_NOT_AVAIL == iDiagonalRef && kiLeftRef >= REF_NOT_IN_LIST) {
|
||||
ST32 (iMVP, LD32 (iAMV));
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 == iMatchRef)
|
||||
{
|
||||
if (iRef == kiLeftRef)
|
||||
{
|
||||
if (1 == iMatchRef) {
|
||||
if (iRef == kiLeftRef) {
|
||||
ST32 (iMVP, LD32 (iAMV));
|
||||
}
|
||||
else if (iRef == kiTopRef)
|
||||
{
|
||||
} else if (iRef == kiTopRef) {
|
||||
ST32 (iMVP, LD32 (iBMV));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ST32 (iMVP, LD32 (iCMV));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iMVP[0] = WelsMedian (iAMV[0], iBMV[0], iCMV[0]);
|
||||
iMVP[1] = WelsMedian (iAMV[1], iBMV[1], iCMV[1]);
|
||||
}
|
||||
}
|
||||
void_t PredInter8x16Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2])
|
||||
{
|
||||
if (0 == iPartIdx)
|
||||
{
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]) {
|
||||
if (0 == iPartIdx) {
|
||||
const int8_t kiLeftRef = iRefIndex[0][6];
|
||||
if (iRef == kiLeftRef)
|
||||
{
|
||||
if (iRef == kiLeftRef) {
|
||||
ST32 (iMVP, LD32 (&iMotionVector[0][6][0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // 1 == iPartIdx
|
||||
{
|
||||
} else { // 1 == iPartIdx
|
||||
int8_t iDiagonalRef = iRefIndex[0][5]; //top-right
|
||||
int8_t index = 5;
|
||||
if (REF_NOT_AVAIL == iDiagonalRef)
|
||||
{
|
||||
if (REF_NOT_AVAIL == iDiagonalRef) {
|
||||
iDiagonalRef = iRefIndex[0][2]; //top-left for 8*8 block(index 1)
|
||||
index = 2;
|
||||
}
|
||||
if (iRef == iDiagonalRef)
|
||||
{
|
||||
if (iRef == iDiagonalRef) {
|
||||
ST32 (iMVP, LD32 (&iMotionVector[0][index][0]));
|
||||
return;
|
||||
}
|
||||
@ -134,22 +116,16 @@ void_t PredInter8x16Mv(int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex
|
||||
PredMv (iMotionVector, iRefIndex, iPartIdx, 2, iRef, iMVP);
|
||||
}
|
||||
void_t PredInter16x8Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2])
|
||||
{
|
||||
if (0 == iPartIdx)
|
||||
{
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVP[2]) {
|
||||
if (0 == iPartIdx) {
|
||||
const int8_t kiTopRef = iRefIndex[0][1];
|
||||
if (iRef == kiTopRef)
|
||||
{
|
||||
if (iRef == kiTopRef) {
|
||||
ST32 (iMVP, LD32 (&iMotionVector[0][1][0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // 8 == iPartIdx
|
||||
{
|
||||
} else { // 8 == iPartIdx
|
||||
const int8_t kiLeftRef = iRefIndex[0][18];
|
||||
if (iRef == kiLeftRef)
|
||||
{
|
||||
if (iRef == kiLeftRef) {
|
||||
ST32 (iMVP, LD32 (&iMotionVector[0][18][0]));
|
||||
return;
|
||||
}
|
||||
@ -160,15 +136,13 @@ void_t 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_t UpdateP16x16MotionInfo( PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2])
|
||||
{
|
||||
void_t UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]) {
|
||||
const int16_t kiRef2 = (iRef << 8) | iRef;
|
||||
const int32_t kiMV32 = LD32 (iMVs);
|
||||
int32_t i;
|
||||
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
|
||||
|
||||
for (i = 0; i < 16; i+=4)
|
||||
{
|
||||
for (i = 0; i < 16; i += 4) {
|
||||
//mb
|
||||
const uint8_t kuiScan4Idx = g_kuiScan4[i];
|
||||
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
|
||||
@ -185,15 +159,14 @@ void_t UpdateP16x16MotionInfo( PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2
|
||||
|
||||
//update iRefIndex and iMVs of Mb, only for P16x8
|
||||
/*need further optimization, mb_cache not work */
|
||||
void_t UpdateP16x8MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2])
|
||||
{
|
||||
void_t UpdateP16x8MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
|
||||
int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]) {
|
||||
const int16_t kiRef2 = (iRef << 8) | iRef;
|
||||
const int32_t kiMV32 = LD32 (iMVs);
|
||||
int32_t i;
|
||||
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
|
||||
for (i = 0; i < 2; i++, iPartIdx+=4)
|
||||
{
|
||||
for (i = 0; i < 2; i++, iPartIdx += 4) {
|
||||
const uint8_t kuiScan4Idx = g_kuiScan4[iPartIdx];
|
||||
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
|
||||
const uint8_t kuiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
|
||||
@ -216,16 +189,15 @@ void_t UpdateP16x8MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A]
|
||||
}
|
||||
}
|
||||
//update iRefIndex and iMVs of both Mb and Mb_cache, only for P8x16
|
||||
void_t UpdateP8x16MotionInfo(PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2])
|
||||
{
|
||||
void_t UpdateP8x16MotionInfo (PDqLayer pCurDqLayer, int16_t iMotionVector[LIST_A][30][MV_A],
|
||||
int8_t iRefIndex[LIST_A][30],
|
||||
int32_t iPartIdx, int8_t iRef, int16_t iMVs[2]) {
|
||||
const int16_t kiRef2 = (iRef << 8) | iRef;
|
||||
const int32_t kiMV32 = LD32 (iMVs);
|
||||
int32_t i;
|
||||
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
|
||||
|
||||
for (i = 0; i < 2; i++, iPartIdx+=8)
|
||||
{
|
||||
for (i = 0; i < 2; i++, iPartIdx += 8) {
|
||||
const uint8_t kuiScan4Idx = g_kuiScan4[iPartIdx];
|
||||
const uint8_t kuiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
|
||||
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -63,8 +63,7 @@ void_t FreePicture( PPicture pPic );
|
||||
|
||||
|
||||
|
||||
PPicture AllocPicture( PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight )
|
||||
{
|
||||
PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight) {
|
||||
PPicture pPic = NULL;
|
||||
int32_t iPicWidth = 0;
|
||||
int32_t iPicHeight = 0;
|
||||
@ -86,8 +85,7 @@ PPicture AllocPicture( PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
|
||||
|
||||
iLumaSize = iPicWidth * iPicHeight;
|
||||
iChromaSize = iPicChromaWidth * iPicChromaHeight;
|
||||
if(pCtx->iDecoderMode == SW_MODE)
|
||||
{
|
||||
if (pCtx->iDecoderMode == SW_MODE) {
|
||||
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc (iLumaSize /* luma */
|
||||
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
|
||||
|
||||
@ -112,13 +110,10 @@ PPicture AllocPicture( PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
|
||||
return pPic;
|
||||
}
|
||||
|
||||
void_t FreePicture( PPicture pPic )
|
||||
{
|
||||
if ( NULL != pPic )
|
||||
{
|
||||
void_t FreePicture (PPicture pPic) {
|
||||
if (NULL != pPic) {
|
||||
|
||||
if ( pPic->pBuffer[0] )
|
||||
{
|
||||
if (pPic->pBuffer[0]) {
|
||||
WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]");
|
||||
}
|
||||
|
||||
@ -127,33 +122,28 @@ void_t FreePicture( PPicture pPic )
|
||||
pPic = NULL;
|
||||
}
|
||||
}
|
||||
PPicture PrefetchPic( PPicBuff pPicBuf )
|
||||
{
|
||||
PPicture PrefetchPic (PPicBuff pPicBuf) {
|
||||
int32_t iPicIdx = 0;
|
||||
PPicture pPic = NULL;
|
||||
|
||||
if (pPicBuf->iCapacity == 0)
|
||||
{
|
||||
if (pPicBuf->iCapacity == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for ( iPicIdx = pPicBuf->iCurrentIdx+1; iPicIdx<pPicBuf->iCapacity ;++iPicIdx)
|
||||
{
|
||||
if (pPicBuf->ppPic[iPicIdx] !=NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef)
|
||||
{
|
||||
for (iPicIdx = pPicBuf->iCurrentIdx + 1; iPicIdx < pPicBuf->iCapacity ; ++iPicIdx) {
|
||||
if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag
|
||||
&& !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) {
|
||||
pPic = pPicBuf->ppPic[iPicIdx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pPic !=NULL)
|
||||
{
|
||||
if (pPic != NULL) {
|
||||
pPicBuf->iCurrentIdx = iPicIdx;
|
||||
return pPic;
|
||||
}
|
||||
for ( iPicIdx = 0 ; iPicIdx<pPicBuf->iCurrentIdx ;++iPicIdx)
|
||||
{
|
||||
if (pPicBuf->ppPic[iPicIdx] !=NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef)
|
||||
{
|
||||
for (iPicIdx = 0 ; iPicIdx < pPicBuf->iCurrentIdx ; ++iPicIdx) {
|
||||
if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag
|
||||
&& !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) {
|
||||
pPic = pPicBuf->ppPic[iPicIdx];
|
||||
break;
|
||||
}
|
||||
|
@ -49,8 +49,7 @@
|
||||
|
||||
namespace WelsDec {
|
||||
|
||||
void_t WelsFillRecNeededMbInfo(PWelsDecoderContext pCtx, bool_t bOutput, PDqLayer pCurLayer)
|
||||
{
|
||||
void_t WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool_t bOutput, PDqLayer pCurLayer) {
|
||||
PPicture pCurPic = pCtx->pDec;
|
||||
int32_t iLumaStride = pCurPic->iLinesize[0];
|
||||
int32_t iChromaStride = pCurPic->iLinesize[1];
|
||||
@ -60,23 +59,20 @@ void_t WelsFillRecNeededMbInfo(PWelsDecoderContext pCtx, bool_t bOutput, PDqLaye
|
||||
pCurLayer->iLumaStride = iLumaStride;
|
||||
pCurLayer->iChromaStride = iChromaStride;
|
||||
|
||||
if(bOutput)
|
||||
{
|
||||
if (bOutput) {
|
||||
pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
|
||||
pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
|
||||
pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t RecI4x4Mb(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
|
||||
{
|
||||
int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
|
||||
RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
|
||||
RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t RecI4x4Luma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
|
||||
{
|
||||
int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
|
||||
/*****get local variable from outer variable********/
|
||||
/*prediction info*/
|
||||
uint8_t* pPred = pDqLayer->pPred[0];
|
||||
@ -95,16 +91,14 @@ int32_t RecI4x4Luma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLev
|
||||
uint8_t i = 0;
|
||||
|
||||
/*************real process*********************/
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
for (i = 0; i < 16; i++) {
|
||||
|
||||
uint8_t* pPredI4x4 = pPred + pBlockOffset[i];
|
||||
uint8_t uiMode = pIntra4x4PredMode[g_kuiScan4[i]];
|
||||
|
||||
pGetI4x4LumaPredFunc[uiMode] (pPredI4x4, iLumaStride);
|
||||
|
||||
if ( pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]] )
|
||||
{
|
||||
if (pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]]) {
|
||||
int16_t* pRSI4x4 = &pRS[i << 4];
|
||||
pIdctResAddPredFunc (pPredI4x4, iLumaStride, pRSI4x4);
|
||||
}
|
||||
@ -114,8 +108,7 @@ int32_t RecI4x4Luma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLev
|
||||
}
|
||||
|
||||
|
||||
int32_t RecI4x4Chroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
|
||||
{
|
||||
int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
|
||||
int32_t iChromaStride = pCtx->pCurDqLayer->iCsStride[1];
|
||||
|
||||
int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
|
||||
@ -134,8 +127,7 @@ int32_t RecI4x4Chroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffL
|
||||
}
|
||||
|
||||
|
||||
int32_t RecI16x16Mb(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
|
||||
{
|
||||
int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
|
||||
/*decoder use, encoder no use*/
|
||||
int8_t iI16x16PredMode = pDqLayer->pIntraPredMode[iMBXY][7];
|
||||
int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
|
||||
@ -158,13 +150,11 @@ int32_t RecI16x16Mb(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLev
|
||||
pGetI16x16LumaPredFunc[iI16x16PredMode] (pPred, iYStride);
|
||||
|
||||
/*1 mb is divided 16 4x4_block to idct*/
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
for (i = 0; i < 16; i++) {
|
||||
int16_t* pRSI4x4 = pRS + (i << 4);
|
||||
uint8_t* pPredI4x4 = pPred + pBlockOffset[i];
|
||||
|
||||
if ( pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]] || pRSI4x4[0] )
|
||||
{
|
||||
if (pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[i]] || pRSI4x4[0]) {
|
||||
pIdctResAddPredFunc (pPredI4x4, iYStride, pRSI4x4);
|
||||
}
|
||||
}
|
||||
@ -198,8 +188,8 @@ typedef struct TagMCRefMember {
|
||||
int32_t iPicHeight;
|
||||
} sMCRefMember;
|
||||
//according to current 8*8 block ref_index to gain reference picture
|
||||
static inline void_t GetRefPic(sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList, int32_t iIndex)
|
||||
{
|
||||
static inline void_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList,
|
||||
int32_t iIndex) {
|
||||
PPicture pRefPic;
|
||||
|
||||
int8_t iRefIdx = pRefIdxList[iIndex];
|
||||
@ -218,8 +208,7 @@ static inline void_t GetRefPic(sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx
|
||||
#define MC_FLOW_SIMPLE_JUDGE 1
|
||||
#endif //MC_FLOW_SIMPLE_JUDGE
|
||||
static inline void_t BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
|
||||
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2])
|
||||
{
|
||||
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
|
||||
int32_t iExpandWidth = PADDING_LENGTH;
|
||||
int32_t iExpandHeight = PADDING_LENGTH;
|
||||
|
||||
@ -255,12 +244,10 @@ static inline void_t BaseMC(sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t i
|
||||
|
||||
FORCE_STACK_ALIGN_1D (uint8_t, uiExpandBuf, (PADDING_LENGTH + 6) * (PADDING_LENGTH + 6), 16);
|
||||
|
||||
if (iFullMVx & 0x07)
|
||||
{
|
||||
if (iFullMVx & 0x07) {
|
||||
iExpandWidth -= 3;
|
||||
}
|
||||
if (iFullMVy & 0x07)
|
||||
{
|
||||
if (iFullMVy & 0x07) {
|
||||
iExpandHeight -= 3;
|
||||
}
|
||||
|
||||
@ -278,34 +265,36 @@ static inline void_t BaseMC(sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t i
|
||||
{
|
||||
FillBufForMc (uiExpandBuf, 21, pSrcY, pMCRefMem->iSrcLineLuma, iMVOffsetLuma - iPadOffset,
|
||||
iBlkWidth + 5, iBlkHeight + 5, iIntMVx - 2, iIntMVy - 2, pMCRefMem->iPicWidth, pMCRefMem->iPicHeight);
|
||||
pMCFunc->pMcLumaFunc(uiExpandBuf+44, 21, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth, iBlkHeight);//44=2+2*21
|
||||
pMCFunc->pMcLumaFunc (uiExpandBuf + 44, 21, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth,
|
||||
iBlkHeight); //44=2+2*21
|
||||
bExpand = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pSrcY += iMVOffsetLuma;
|
||||
pMCFunc->pMcLumaFunc(pSrcY, pMCRefMem->iSrcLineLuma, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth, iBlkHeight);
|
||||
pMCFunc->pMcLumaFunc (pSrcY, pMCRefMem->iSrcLineLuma, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth,
|
||||
iBlkHeight);
|
||||
}
|
||||
|
||||
if (bExpand)
|
||||
{
|
||||
FillBufForMc(uiExpandBuf, 21, pSrcU, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma+1, iBlkHeightChroma+1, iFullMVx>>3, iFullMVy>>3, iPicWidthChroma, iPicHeightChroma);
|
||||
pMCFunc->pMcChromaFunc(uiExpandBuf, 21, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
|
||||
if (bExpand) {
|
||||
FillBufForMc (uiExpandBuf, 21, pSrcU, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma + 1,
|
||||
iBlkHeightChroma + 1, iFullMVx >> 3, iFullMVy >> 3, iPicWidthChroma, iPicHeightChroma);
|
||||
pMCFunc->pMcChromaFunc (uiExpandBuf, 21, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma,
|
||||
iBlkHeightChroma);
|
||||
|
||||
FillBufForMc(uiExpandBuf, 21, pSrcV, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma+1, iBlkHeightChroma+1, iFullMVx>>3, iFullMVy>>3, iPicWidthChroma, iPicHeightChroma);
|
||||
pMCFunc->pMcChromaFunc(uiExpandBuf, 21, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
|
||||
}
|
||||
else
|
||||
{
|
||||
FillBufForMc (uiExpandBuf, 21, pSrcV, pMCRefMem->iSrcLineChroma, iMVOffsetChroma, iBlkWidthChroma + 1,
|
||||
iBlkHeightChroma + 1, iFullMVx >> 3, iFullMVy >> 3, iPicWidthChroma, iPicHeightChroma);
|
||||
pMCFunc->pMcChromaFunc (uiExpandBuf, 21, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma,
|
||||
iBlkHeightChroma);
|
||||
} else {
|
||||
pSrcU += iMVOffsetChroma;
|
||||
pSrcV += iMVOffsetChroma;
|
||||
pMCFunc->pMcChromaFunc(pSrcU, pMCRefMem->iSrcLineChroma, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
|
||||
pMCFunc->pMcChromaFunc(pSrcV, pMCRefMem->iSrcLineChroma, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy, iBlkWidthChroma, iBlkHeightChroma);
|
||||
pMCFunc->pMcChromaFunc (pSrcU, pMCRefMem->iSrcLineChroma, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,
|
||||
iBlkWidthChroma, iBlkHeightChroma);
|
||||
pMCFunc->pMcChromaFunc (pSrcV, pMCRefMem->iSrcLineChroma, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,
|
||||
iBlkWidthChroma, iBlkHeightChroma);
|
||||
}
|
||||
}
|
||||
|
||||
void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDecoderContext pCtx)
|
||||
{
|
||||
void_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {
|
||||
sMCRefMember pMCRefMem;
|
||||
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
|
||||
SMcFunc* pMCFunc = &pCtx->sMcFunc;
|
||||
@ -333,8 +322,7 @@ void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDe
|
||||
|
||||
pMCRefMem.iDstLineLuma = iDstLineLuma;
|
||||
pMCRefMem.iDstLineChroma = iDstLineChroma;
|
||||
switch(iMBType)
|
||||
{
|
||||
switch (iMBType) {
|
||||
case MB_TYPE_SKIP:
|
||||
case MB_TYPE_16x16:
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
|
||||
@ -371,13 +359,11 @@ void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDe
|
||||
BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);
|
||||
break;
|
||||
case MB_TYPE_8x8:
|
||||
case MB_TYPE_8x8_REF0:
|
||||
{
|
||||
case MB_TYPE_8x8_REF0: {
|
||||
uint32_t iSubMBType;
|
||||
int32_t iXOffset, iYOffset;
|
||||
uint8_t* pDstY, *pDstU, *pDstV;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];
|
||||
iBlk8X = (i & 1) << 3;
|
||||
iBlk8Y = (i >> 1) << 3;
|
||||
@ -393,8 +379,7 @@ void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDe
|
||||
pMCRefMem.pDstY = pDstY;
|
||||
pMCRefMem.pDstU = pDstU;
|
||||
pMCRefMem.pDstV = pDstV;
|
||||
switch(iSubMBType)
|
||||
{
|
||||
switch (iSubMBType) {
|
||||
case SUB_MB_TYPE_8x8:
|
||||
iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
|
||||
iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
|
||||
@ -424,10 +409,8 @@ void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDe
|
||||
pMCRefMem.pDstV += 2;
|
||||
BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
|
||||
break;
|
||||
case SUB_MB_TYPE_4x4:
|
||||
{
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
case SUB_MB_TYPE_4x4: {
|
||||
for (j = 0; j < 4; j++) {
|
||||
int32_t iUVLineStride;
|
||||
iJIdx = ((j >> 1) << 2) + (j & 1);
|
||||
|
||||
@ -456,32 +439,27 @@ void_t GetInterPred(uint8_t *pPredY, uint8_t *pPredCb, uint8_t *pPredCr, PWelsDe
|
||||
}
|
||||
}
|
||||
|
||||
int32_t RecChroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel, PDqLayer pDqLayer)
|
||||
{
|
||||
int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
|
||||
int32_t iChromaStride = pCtx->pCurDqLayer->iCsStride[1];
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
|
||||
|
||||
uint8_t i = 0, j = 0;
|
||||
uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4;
|
||||
|
||||
if ( 1 == uiCbpC || 2 == uiCbpC )
|
||||
{
|
||||
if (1 == uiCbpC || 2 == uiCbpC) {
|
||||
WelsChromaDcIdct (pScoeffLevel + 256); // 256 = 16*16
|
||||
WelsChromaDcIdct (pScoeffLevel + 320); // 256 = 16*16
|
||||
for(i=0; i<2; i++)
|
||||
{
|
||||
for (i = 0; i < 2; i++) {
|
||||
int16_t* pRS = pScoeffLevel + 256 + (i << 6);
|
||||
uint8_t* pPred = pDqLayer->pPred[i + 1];
|
||||
int32_t* pBlockOffset = i == 0 ? &pCtx->iDecBlockOffsetArray[16] : &pCtx->iDecBlockOffsetArray[20];
|
||||
|
||||
/*1 chroma is divided 4 4x4_block to idct*/
|
||||
for(j=0; j<4; j++)
|
||||
{
|
||||
for (j = 0; j < 4; j++) {
|
||||
int16_t* pRSI4x4 = &pRS[j << 4];
|
||||
uint8_t* pPredI4x4 = pPred + pBlockOffset[j];
|
||||
|
||||
if ( pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[16+(i<<2)+j]] || pRSI4x4[0] )
|
||||
{
|
||||
if (pDqLayer->pNzc[iMBXY][g_kuiMbNonZeroCountIdx[16 + (i << 2) + j]] || pRSI4x4[0]) {
|
||||
pIdctResAddPredFunc (pPredI4x4, iChromaStride, pRSI4x4);
|
||||
}
|
||||
}
|
||||
@ -492,8 +470,7 @@ int32_t RecChroma(int32_t iMBXY, PWelsDecoderContext pCtx, int16_t *pScoeffLevel
|
||||
}
|
||||
|
||||
void_t FillBufForMc (uint8_t* pBuf, int32_t iBufStride, uint8_t* pSrc, int32_t iSrcStride, int32_t iSrcOffset,
|
||||
int32_t iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight)
|
||||
{
|
||||
int32_t iBlockWidth, int32_t iBlockHeight, int32_t iSrcX, int32_t iSrcY, int32_t iPicWidth, int32_t iPicHeight) {
|
||||
int32_t iY;
|
||||
int32_t iStartY, iStartX, iEndY, iEndX;
|
||||
int32_t iOffsetAdj = 0;
|
||||
@ -502,23 +479,17 @@ void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iS
|
||||
uint8_t* pBufSrc, *pBufDst;
|
||||
uint8_t* pBufSrc1, *pBufDst1;
|
||||
|
||||
if( iSrcY >= iPicHeight )
|
||||
{
|
||||
if (iSrcY >= iPicHeight) {
|
||||
iOffsetAdj += (iPicHeight - 1 - iSrcY) * iSrcStride;
|
||||
iSrcY = iPicHeight - 1;
|
||||
}
|
||||
else if( iSrcY <= -iBlockHeight )
|
||||
{
|
||||
} else if (iSrcY <= -iBlockHeight) {
|
||||
iOffsetAdj += (1 - iBlockHeight - iSrcY) * iSrcStride;
|
||||
iSrcY = 1 - iBlockHeight;
|
||||
}
|
||||
if( iSrcX >= iPicWidth )
|
||||
{
|
||||
if (iSrcX >= iPicWidth) {
|
||||
iOffsetAdj += (iPicWidth - 1 - iSrcX);
|
||||
iSrcX = iPicWidth - 1;
|
||||
}
|
||||
else if( iSrcX <= -iBlockWidth )
|
||||
{
|
||||
} else if (iSrcX <= -iBlockWidth) {
|
||||
iOffsetAdj += (1 - iBlockWidth - iSrcX);
|
||||
iSrcX = 1 - iBlockWidth;
|
||||
}
|
||||
@ -537,8 +508,7 @@ void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iS
|
||||
iAddrSrc = iStartX + iStartY * iSrcStride;
|
||||
iAddrBuf = iStartX + iStartY * iBufStride;
|
||||
iNum = iEndX - iStartX;
|
||||
for( iY = iStartY; iY < iEndY; iY++ )
|
||||
{
|
||||
for (iY = iStartY; iY < iEndY; iY++) {
|
||||
memcpy (pBuf + iAddrBuf, pSrc + iOffsetAdj + iAddrSrc, iNum);
|
||||
iAddrSrc += iSrcStride;
|
||||
iAddrBuf += iBufStride;
|
||||
@ -548,8 +518,7 @@ void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iS
|
||||
pBufSrc = pBuf + iStartX + iStartY * iBufStride;
|
||||
pBufDst = pBuf + iStartX;
|
||||
iNum = iEndX - iStartX;
|
||||
for( iY = 0; iY < iStartY; iY++ )
|
||||
{
|
||||
for (iY = 0; iY < iStartY; iY++) {
|
||||
memcpy (pBufDst, pBufSrc, iNum);
|
||||
pBufDst += iBufStride;
|
||||
}
|
||||
@ -558,8 +527,7 @@ void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iS
|
||||
pBufSrc = pBuf + iStartX + (iEndY - 1) * iBufStride;
|
||||
pBufDst = pBuf + iStartX + iEndY * iBufStride;
|
||||
iNum = iEndX - iStartX;
|
||||
for( iY = iEndY; iY < iBlockHeight; iY++ )
|
||||
{
|
||||
for (iY = iEndY; iY < iBlockHeight; iY++) {
|
||||
memcpy (pBufDst, pBufSrc, iNum);
|
||||
pBufDst += iBufStride;
|
||||
}
|
||||
@ -572,8 +540,7 @@ void_t FillBufForMc(uint8_t *pBuf, int32_t iBufStride, uint8_t *pSrc, int32_t iS
|
||||
pBufSrc1 = pBuf + iEndX - 1;
|
||||
pBufDst1 = pBuf + iEndX;
|
||||
iNum1 = iBlockWidth - iEndX;
|
||||
for( iY=0; iY<iBlockHeight; iY++ )
|
||||
{
|
||||
for (iY = 0; iY < iBlockHeight; iY++) {
|
||||
//left
|
||||
memset (pBufDst, pBufSrc[0], iNum);
|
||||
pBufDst += iBufStride;
|
||||
|
@ -68,8 +68,7 @@ PWelsLogCallbackFunc g_pLog = NULL;
|
||||
|
||||
|
||||
|
||||
void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...)
|
||||
{
|
||||
void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...) {
|
||||
va_list pVl;
|
||||
|
||||
PWelsDecoderContext pCtx = (PWelsDecoderContext)pPtr;
|
||||
@ -84,8 +83,7 @@ void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...)
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER>=1500)
|
||||
|
||||
int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
|
||||
{
|
||||
int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
|
||||
va_list pArgPtr;
|
||||
int32_t iRc;
|
||||
|
||||
@ -98,25 +96,21 @@ int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFo
|
||||
return iRc;
|
||||
}
|
||||
|
||||
str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
|
||||
{
|
||||
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
|
||||
strncpy_s (pDest, iSizeInBytes, kpSrc, iCount);
|
||||
|
||||
return pDest;
|
||||
}
|
||||
|
||||
int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
|
||||
{
|
||||
int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
|
||||
return strnlen_s (kpStr, iMaxlen);
|
||||
}
|
||||
|
||||
int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
|
||||
{
|
||||
int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
|
||||
return vsprintf_s (pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
|
||||
}
|
||||
|
||||
WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
|
||||
{
|
||||
WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
|
||||
WelsFileHandle* pFp = NULL;
|
||||
if (fopen_s (&pFp, kpFilename, kpMode) != 0) {
|
||||
return NULL;
|
||||
@ -125,18 +119,15 @@ WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
|
||||
return pFp;
|
||||
}
|
||||
|
||||
int32_t WelsFclose(WelsFileHandle* pFp)
|
||||
{
|
||||
int32_t WelsFclose (WelsFileHandle* pFp) {
|
||||
return fclose (pFp);
|
||||
}
|
||||
|
||||
int32_t WelsGetTimeOfDay(SWelsTime * pTp)
|
||||
{
|
||||
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
|
||||
return _ftime_s (pTp);
|
||||
}
|
||||
|
||||
int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
|
||||
{
|
||||
int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
|
||||
struct tm sTimeNow;
|
||||
|
||||
localtime_s (&sTimeNow, &kpTp->time);
|
||||
@ -146,8 +137,7 @@ int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, con
|
||||
|
||||
#else
|
||||
|
||||
int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
|
||||
{
|
||||
int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
|
||||
va_list pArgPtr;
|
||||
int32_t iRc;
|
||||
|
||||
@ -160,41 +150,34 @@ int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFo
|
||||
return iRc;
|
||||
}
|
||||
|
||||
str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
|
||||
{
|
||||
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
|
||||
strncpy (pDest, kpSrc, iCount); //confirmed_safe_unsafe_usage
|
||||
|
||||
return pDest;
|
||||
}
|
||||
|
||||
int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
|
||||
{
|
||||
int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
|
||||
return strlen (kpStr); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
|
||||
{
|
||||
int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
|
||||
return vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
|
||||
WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
|
||||
{
|
||||
WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
|
||||
return fopen (kpFilename, kpMode);
|
||||
}
|
||||
|
||||
int32_t WelsFclose(WelsFileHandle* pFp)
|
||||
{
|
||||
int32_t WelsFclose (WelsFileHandle* pFp) {
|
||||
return fclose (pFp);
|
||||
}
|
||||
|
||||
int32_t WelsGetTimeOfDay(SWelsTime * pTp)
|
||||
{
|
||||
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
|
||||
return _ftime (pTp);
|
||||
}
|
||||
|
||||
int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
|
||||
{
|
||||
int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
|
||||
struct tm* pTnow;
|
||||
|
||||
pTnow = localtime (&kpTp->time);
|
||||
@ -207,8 +190,7 @@ int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, con
|
||||
|
||||
#else //GCC
|
||||
|
||||
int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
|
||||
{
|
||||
int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
|
||||
va_list pArgPtr;
|
||||
int32_t iRc;
|
||||
|
||||
@ -221,19 +203,16 @@ int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFo
|
||||
return iRc;
|
||||
}
|
||||
|
||||
str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
|
||||
{
|
||||
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
|
||||
return strncpy (pDest, kpSrc, iCount); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
#if !defined(MACOS) && !defined(UNIX) && !defined(APPLE_IOS)
|
||||
int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
|
||||
{
|
||||
int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
|
||||
return strnlen (kpStr, iMaxlen); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
#else
|
||||
int32_t WelsStrnlen(const str_t *kpString, int32_t iMaxlen)
|
||||
{
|
||||
int32_t WelsStrnlen (const str_t* kpString, int32_t iMaxlen) {
|
||||
// In mac os, there is no strnlen in string.h, we can only use strlen instead of strnlen or
|
||||
// implement strnlen by ourself
|
||||
|
||||
@ -248,23 +227,19 @@ int32_t WelsStrnlen(const str_t *kpString, int32_t iMaxlen)
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
|
||||
{
|
||||
int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
|
||||
return vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
|
||||
{
|
||||
WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
|
||||
return fopen (kpFilename, kpMode);
|
||||
}
|
||||
|
||||
int32_t WelsFclose(WelsFileHandle * pFp)
|
||||
{
|
||||
int32_t WelsFclose (WelsFileHandle* pFp) {
|
||||
return fclose (pFp);
|
||||
}
|
||||
|
||||
int32_t WelsGetTimeOfDay(SWelsTime * pTp)
|
||||
{
|
||||
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
|
||||
struct timeval sTv;
|
||||
|
||||
if (gettimeofday (&sTv, NULL)) {
|
||||
@ -277,8 +252,7 @@ int32_t WelsGetTimeOfDay(SWelsTime * pTp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
|
||||
{
|
||||
int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
|
||||
struct tm* pTnow;
|
||||
|
||||
pTnow = localtime (&kpTp->time);
|
||||
@ -289,18 +263,15 @@ int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, con
|
||||
#endif
|
||||
|
||||
|
||||
int32_t WelsFwrite(const void_t * kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp)
|
||||
{
|
||||
int32_t WelsFwrite (const void_t* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
|
||||
return fwrite (kpBuffer, iSize, iCount, pFp);
|
||||
}
|
||||
|
||||
uint16_t WelsGetMillsecond(const SWelsTime * kpTp)
|
||||
{
|
||||
uint16_t WelsGetMillsecond (const SWelsTime* kpTp) {
|
||||
return kpTp->millitm;
|
||||
}
|
||||
|
||||
int32_t WelsFflush(WelsFileHandle* pFp)
|
||||
{
|
||||
int32_t WelsFflush (WelsFileHandle* pFp) {
|
||||
return fflush (pFp);
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,7 @@ typedef enum {
|
||||
Wels_Trace_Type_WinDgb = 2,
|
||||
} EWelsTraceType;
|
||||
|
||||
class IWelsTrace
|
||||
{
|
||||
class IWelsTrace {
|
||||
public:
|
||||
enum {
|
||||
WELS_LOG_QUIET = 0,
|
||||
@ -73,8 +72,7 @@ public:
|
||||
virtual int32_t SetTraceLevel (int32_t iLevel) = 0;
|
||||
virtual int32_t Trace (const int32_t kLevel, const str_t* kpFormat, va_list pVl) = 0;
|
||||
|
||||
static void_t WelsTrace(void_t* pObject, const int32_t kLevel, const str_t * kpFormat, va_list pVl)
|
||||
{
|
||||
static void_t WelsTrace (void_t* pObject, const int32_t kLevel, const str_t* kpFormat, va_list pVl) {
|
||||
IWelsTrace* pThis = (IWelsTrace*) (pObject);
|
||||
|
||||
if (pThis) {
|
||||
@ -82,8 +80,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void_t WelsVTrace(void_t *pObject, const int32_t kLevel, const str_t *kpFormat, ...)
|
||||
{
|
||||
static void_t WelsVTrace (void_t* pObject, const int32_t kLevel, const str_t* kpFormat, ...) {
|
||||
IWelsTrace* pThis = (IWelsTrace*) (pObject);
|
||||
|
||||
va_list argptr;
|
||||
@ -100,16 +97,14 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class CWelsTraceBase : public IWelsTrace
|
||||
{
|
||||
class CWelsTraceBase : public IWelsTrace {
|
||||
public:
|
||||
virtual int32_t SetTraceLevel (int32_t iLevel);
|
||||
virtual int32_t Trace (const int32_t kLevel, const str_t* kpFormat, va_list pVl);
|
||||
|
||||
virtual int32_t WriteString (int32_t iLevel, const str_t* pStr) = 0;
|
||||
protected:
|
||||
CWelsTraceBase()
|
||||
{
|
||||
CWelsTraceBase() {
|
||||
m_iLevel = WELS_LOG_DEFAULT;
|
||||
};
|
||||
|
||||
@ -117,8 +112,7 @@ private:
|
||||
int32_t m_iLevel;
|
||||
};
|
||||
|
||||
class CWelsTraceFile : public CWelsTraceBase
|
||||
{
|
||||
class CWelsTraceFile : public CWelsTraceBase {
|
||||
public:
|
||||
CWelsTraceFile (const str_t* filename = (const str_t*)"wels_decoder_trace.txt");
|
||||
virtual ~CWelsTraceFile();
|
||||
@ -131,8 +125,7 @@ private:
|
||||
};
|
||||
|
||||
#ifdef WIN32
|
||||
class CWelsTraceWinDgb : public CWelsTraceBase
|
||||
{
|
||||
class CWelsTraceWinDgb : public CWelsTraceBase {
|
||||
public:
|
||||
CWelsTraceWinDgb() {};
|
||||
virtual ~CWelsTraceWinDgb() {};
|
||||
@ -142,8 +135,7 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
class CWelsCodecTrace : public CWelsTraceBase
|
||||
{
|
||||
class CWelsCodecTrace : public CWelsTraceBase {
|
||||
public:
|
||||
CWelsCodecTrace() ;
|
||||
virtual ~CWelsCodecTrace();
|
||||
|
@ -58,8 +58,7 @@ namespace WelsDec {
|
||||
|
||||
//#define OUTPUT_BIT_STREAM ////for test to output bitstream
|
||||
|
||||
class CWelsDecoder : public ISVCDecoder
|
||||
{
|
||||
class CWelsDecoder : public ISVCDecoder {
|
||||
public:
|
||||
CWelsDecoder (void_t);
|
||||
virtual ~CWelsDecoder();
|
||||
|
@ -59,8 +59,7 @@
|
||||
namespace WelsDec {
|
||||
|
||||
#ifdef MACOS
|
||||
static CFBundleRef LoadLibrary(const char* lpszbundle)
|
||||
{
|
||||
static CFBundleRef LoadLibrary (const char* lpszbundle) {
|
||||
// 1.get bundle path
|
||||
char cBundlePath[PATH_MAX];
|
||||
memset (cBundlePath, 0, PATH_MAX);
|
||||
@ -72,24 +71,17 @@ static CFBundleRef LoadLibrary(const char* lpszbundle)
|
||||
strlcpy (cBundlePath, dlInfo.dli_fname, PATH_MAX);
|
||||
|
||||
char* pPath = NULL;
|
||||
for(int i = 4; i > 0; i--)
|
||||
{
|
||||
for (int i = 4; i > 0; i--) {
|
||||
pPath = strrchr (cBundlePath, '/'); //confirmed_safe_unsafe_usage
|
||||
if(pPath)
|
||||
{
|
||||
if (pPath) {
|
||||
*pPath = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(pPath)
|
||||
{
|
||||
if (pPath) {
|
||||
strlcat (cBundlePath, "/", PATH_MAX);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -109,18 +101,15 @@ static CFBundleRef LoadLibrary(const char* lpszbundle)
|
||||
CFRelease (bundleURL);
|
||||
|
||||
// Boolean bReturn = FALSE;
|
||||
if(NULL != bundleRef)
|
||||
{
|
||||
if (NULL != bundleRef) {
|
||||
// bReturn = CFBundleLoadExecutable(bundleRef);
|
||||
}
|
||||
|
||||
return bundleRef;
|
||||
}
|
||||
|
||||
static Boolean FreeLibrary(CFBundleRef bundle)
|
||||
{
|
||||
if(NULL != bundle)
|
||||
{
|
||||
static Boolean FreeLibrary (CFBundleRef bundle) {
|
||||
if (NULL != bundle) {
|
||||
// CFBundleUnloadExecutable(bundle);
|
||||
CFRelease (bundle);
|
||||
}
|
||||
@ -128,8 +117,7 @@ static Boolean FreeLibrary(CFBundleRef bundle)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void_t* GetProcessAddress(CFBundleRef bundle, const char* lpszprocname)
|
||||
{
|
||||
static void_t* GetProcessAddress (CFBundleRef bundle, const char* lpszprocname) {
|
||||
if (NULL == bundle)
|
||||
return NULL;
|
||||
|
||||
@ -143,15 +131,13 @@ static void_t* GetProcessAddress(CFBundleRef bundle, const char* lpszprocname)
|
||||
|
||||
|
||||
|
||||
int32_t CWelsTraceBase::SetTraceLevel(int iLevel)
|
||||
{
|
||||
int32_t CWelsTraceBase::SetTraceLevel (int iLevel) {
|
||||
m_iLevel = iLevel;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CWelsTraceBase::Trace(const int kLevel, const str_t *kpFormat, va_list pVl)
|
||||
{
|
||||
int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) {
|
||||
if (kLevel & m_iLevel) {
|
||||
str_t chWStrFormat[MAX_LOG_SIZE] = {0};
|
||||
str_t chBuf[MAX_LOG_SIZE] = {0};
|
||||
@ -171,21 +157,18 @@ int32_t CWelsTraceBase::Trace(const int kLevel, const str_t *kpFormat, va_list
|
||||
return 0;
|
||||
}
|
||||
|
||||
CWelsTraceFile::CWelsTraceFile(const str_t * pFileName)
|
||||
{
|
||||
CWelsTraceFile::CWelsTraceFile (const str_t* pFileName) {
|
||||
m_pTraceFile = WelsFopen (pFileName, (const str_t*)"wt");
|
||||
}
|
||||
|
||||
CWelsTraceFile::~CWelsTraceFile()
|
||||
{
|
||||
CWelsTraceFile::~CWelsTraceFile() {
|
||||
if (m_pTraceFile) {
|
||||
WelsFclose (m_pTraceFile);
|
||||
m_pTraceFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CWelsTraceFile::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
{
|
||||
int32_t CWelsTraceFile::WriteString (int32_t iLevel, const str_t* pStr) {
|
||||
int iRC = 0;
|
||||
const static str_t chEnter[16] = "\n";
|
||||
if (m_pTraceFile) {
|
||||
@ -199,8 +182,7 @@ int32_t CWelsTraceFile::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
int32_t CWelsTraceWinDgb::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
{
|
||||
int32_t CWelsTraceWinDgb::WriteString (int32_t iLevel, const str_t* pStr) {
|
||||
OutputDebugStringA (pStr);
|
||||
|
||||
return WelsStrnlen (pStr, MAX_LOG_SIZE); //strnlen(pStr, MAX_LOG_SIZE);
|
||||
@ -208,8 +190,7 @@ int32_t CWelsTraceWinDgb::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
|
||||
#endif
|
||||
|
||||
CWelsCodecTrace::CWelsCodecTrace()
|
||||
{
|
||||
CWelsCodecTrace::CWelsCodecTrace() {
|
||||
m_hTraceHandle = NULL;
|
||||
m_fpDebugTrace = NULL;
|
||||
m_fpInfoTrace = NULL;
|
||||
@ -219,13 +200,11 @@ CWelsCodecTrace::CWelsCodecTrace()
|
||||
LoadWelsTraceModule();
|
||||
}
|
||||
|
||||
CWelsCodecTrace::~CWelsCodecTrace()
|
||||
{
|
||||
CWelsCodecTrace::~CWelsCodecTrace() {
|
||||
UnloadWelsTraceModule();
|
||||
}
|
||||
|
||||
int32_t CWelsCodecTrace::LoadWelsTraceModule()
|
||||
{
|
||||
int32_t CWelsCodecTrace::LoadWelsTraceModule() {
|
||||
#ifdef NO_DYNAMIC_VP
|
||||
m_fpDebugTrace = welsStderrTrace<WELS_LOG_DEBUG>;
|
||||
m_fpInfoTrace = welsStderrTrace<WELS_LOG_INFO>;
|
||||
@ -252,8 +231,7 @@ int32_t CWelsCodecTrace::LoadWelsTraceModule()
|
||||
}
|
||||
|
||||
// coverity scan uninitial
|
||||
if (hHandle != NULL)
|
||||
{
|
||||
if (hHandle != NULL) {
|
||||
::FreeLibrary (hHandle);
|
||||
hHandle = NULL;
|
||||
}
|
||||
@ -287,11 +265,9 @@ int32_t CWelsCodecTrace::LoadWelsTraceModule()
|
||||
return -1;
|
||||
|
||||
m_hTraceHandle = dlopen (chPath, RTLD_LAZY);
|
||||
if (m_hTraceHandle == NULL)
|
||||
{
|
||||
if (m_hTraceHandle == NULL) {
|
||||
WelsFileHandle* fp = WelsFopen ((const str_t*)"/tmp/trace.txt", (const str_t*)"a");
|
||||
if(fp)
|
||||
{
|
||||
if (fp) {
|
||||
fprintf (fp, "welsCodecTrace::welsCodecTrace ===> dlopen %s fail, %s\n", chPath, dlerror());
|
||||
WelsFclose (fp);
|
||||
}
|
||||
@ -302,11 +278,9 @@ int32_t CWelsCodecTrace::LoadWelsTraceModule()
|
||||
m_fpInfoTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSINFO2");
|
||||
m_fpWarnTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSWARN2");
|
||||
m_fpErrorTrace = (CM_WELS_TRACE)dlsym (m_hTraceHandle, "WELSERROR2");
|
||||
if(m_fpDebugTrace == NULL)
|
||||
{
|
||||
if (m_fpDebugTrace == NULL) {
|
||||
WelsFileHandle* fp = WelsFopen ((const str_t*)"/tmp/trace.txt", (const str_t*)"a");
|
||||
if(fp)
|
||||
{
|
||||
if (fp) {
|
||||
printf ("welsCodecTrace::welsCodecTrace ===> dlsym failed (WELSDEBUG2) , dlerror = %s\n", dlerror());
|
||||
WelsFclose (fp);
|
||||
}
|
||||
@ -318,8 +292,7 @@ int32_t CWelsCodecTrace::LoadWelsTraceModule()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CWelsCodecTrace::UnloadWelsTraceModule()
|
||||
{
|
||||
int32_t CWelsCodecTrace::UnloadWelsTraceModule() {
|
||||
#if defined WIN32
|
||||
if (m_hTraceHandle) {
|
||||
::FreeLibrary ((HMODULE)m_hTraceHandle);
|
||||
@ -342,15 +315,13 @@ int32_t CWelsCodecTrace::UnloadWelsTraceModule()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CWelsCodecTrace::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
{
|
||||
int32_t CWelsCodecTrace::WriteString (int32_t iLevel, const str_t* pStr) {
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
if (m_hTraceHandle)
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
switch(iLevel)
|
||||
{
|
||||
switch (iLevel) {
|
||||
case WELS_LOG_ERROR:
|
||||
if (m_fpErrorTrace)
|
||||
m_fpErrorTrace ("%s", pStr);
|
||||
@ -373,8 +344,7 @@ int32_t CWelsCodecTrace::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch(iLevel)
|
||||
{
|
||||
switch (iLevel) {
|
||||
case WELS_LOG_ERROR:
|
||||
if (m_fpErrorTrace)
|
||||
m_fpErrorTrace ("CODEC", "%s", pStr);
|
||||
@ -403,11 +373,9 @@ int32_t CWelsCodecTrace::WriteString(int32_t iLevel, const str_t * pStr)
|
||||
}
|
||||
|
||||
|
||||
IWelsTrace * CreateWelsTrace(EWelsTraceType eType, void_t * pParam)
|
||||
{
|
||||
IWelsTrace* CreateWelsTrace (EWelsTraceType eType, void_t* pParam) {
|
||||
IWelsTrace* pTrace = NULL;
|
||||
switch(eType)
|
||||
{
|
||||
switch (eType) {
|
||||
case Wels_Trace_Type:
|
||||
pTrace = new CWelsCodecTrace();
|
||||
break;
|
||||
|
@ -85,8 +85,7 @@ namespace WelsDec {
|
||||
/***************************************************************************/
|
||||
CWelsDecoder::CWelsDecoder (void_t)
|
||||
: m_pDecContext (NULL),
|
||||
m_pTrace( NULL )
|
||||
{
|
||||
m_pTrace (NULL) {
|
||||
#ifdef OUTPUT_BIT_STREAM
|
||||
str_t chFileName[1024] = { 0 }; //for .264
|
||||
int iBufUsed = 0;
|
||||
@ -111,28 +110,25 @@ CWelsDecoder::CWelsDecoder(void_t)
|
||||
iBufUsedSize += WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
|
||||
|
||||
iBufLeft -= iBufUsed;
|
||||
if ( iBufLeft > iBufUsed )
|
||||
{
|
||||
if (iBufLeft > iBufUsed) {
|
||||
iBufUsed += WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
|
||||
iBufLeft -= iBufUsed;
|
||||
}
|
||||
|
||||
iBufLeftSize -= iBufUsedSize;
|
||||
if ( iBufLeftSize> iBufUsedSize )
|
||||
{
|
||||
if (iBufLeftSize > iBufUsedSize) {
|
||||
iBufUsedSize += WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
|
||||
iBufLeftSize -= iBufUsedSize;
|
||||
}
|
||||
|
||||
if ( iBufLeft > iBufUsed )
|
||||
{
|
||||
if (iBufLeft > iBufUsed) {
|
||||
iBufUsed += WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime));
|
||||
iBufLeft -= iBufUsed;
|
||||
}
|
||||
|
||||
if ( iBufLeftSize > iBufUsedSize )
|
||||
{
|
||||
iBufUsedSize += WelsSnprintf(&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", WelsGetMillsecond(&sCurTime));
|
||||
if (iBufLeftSize > iBufUsedSize) {
|
||||
iBufUsedSize += WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",
|
||||
WelsGetMillsecond (&sCurTime));
|
||||
iBufLeftSize -= iBufUsedSize;
|
||||
}
|
||||
|
||||
@ -151,20 +147,17 @@ CWelsDecoder::CWelsDecoder(void_t)
|
||||
*
|
||||
* return: none
|
||||
/***************************************************************************/
|
||||
CWelsDecoder::~CWelsDecoder()
|
||||
{
|
||||
CWelsDecoder::~CWelsDecoder() {
|
||||
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
|
||||
|
||||
UninitDecoder();
|
||||
|
||||
#ifdef OUTPUT_BIT_STREAM
|
||||
if ( m_pFBS )
|
||||
{
|
||||
if (m_pFBS) {
|
||||
WelsFclose (m_pFBS);
|
||||
m_pFBS = NULL;
|
||||
}
|
||||
if ( m_pFBSSize )
|
||||
{
|
||||
if (m_pFBSSize) {
|
||||
WelsFclose (m_pFBSSize);
|
||||
m_pFBSSize = NULL;
|
||||
}
|
||||
@ -176,8 +169,7 @@ CWelsDecoder::~CWelsDecoder()
|
||||
}
|
||||
}
|
||||
|
||||
long CWelsDecoder::Initialize(void_t* pParam, const INIT_TYPE keInitType)
|
||||
{
|
||||
long CWelsDecoder::Initialize (void_t* pParam, const INIT_TYPE keInitType) {
|
||||
if (pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED) {
|
||||
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
|
||||
return cmInitParaError;
|
||||
@ -191,15 +183,13 @@ long CWelsDecoder::Initialize(void_t* pParam, const INIT_TYPE keInitType)
|
||||
return cmResultSuccess;
|
||||
}
|
||||
|
||||
long CWelsDecoder::Uninitialize()
|
||||
{
|
||||
long CWelsDecoder::Uninitialize() {
|
||||
UninitDecoder();
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
void_t CWelsDecoder::UninitDecoder( void_t )
|
||||
{
|
||||
void_t CWelsDecoder::UninitDecoder (void_t) {
|
||||
if (NULL == m_pDecContext)
|
||||
return;
|
||||
|
||||
@ -207,8 +197,7 @@ void_t CWelsDecoder::UninitDecoder( void_t )
|
||||
|
||||
WelsEndDecoder (m_pDecContext);
|
||||
|
||||
if ( NULL != m_pDecContext )
|
||||
{
|
||||
if (NULL != m_pDecContext) {
|
||||
WelsFree (m_pDecContext, "m_pDecContext");
|
||||
|
||||
m_pDecContext = NULL;
|
||||
@ -218,8 +207,7 @@ void_t CWelsDecoder::UninitDecoder( void_t )
|
||||
}
|
||||
|
||||
// the return value of this function is not suitable, it need report failure info to upper layer.
|
||||
void_t CWelsDecoder::InitDecoder( void_t )
|
||||
{
|
||||
void_t CWelsDecoder::InitDecoder (void_t) {
|
||||
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder()..");
|
||||
|
||||
m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
|
||||
@ -232,24 +220,20 @@ void_t CWelsDecoder::InitDecoder( void_t )
|
||||
/*
|
||||
* Set Option
|
||||
*/
|
||||
long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
{
|
||||
long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void_t* pOption) {
|
||||
int iVal = 0;
|
||||
|
||||
if (m_pDecContext == NULL)
|
||||
return dsInitialOptExpected;
|
||||
|
||||
if ( eOptID == DECODER_OPTION_DATAFORMAT ) // Set color space of decoding output frame
|
||||
{
|
||||
if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
iVal = * ((int*)pOption); // is_rgb
|
||||
|
||||
return DecoderSetCsp (m_pDecContext, iVal);
|
||||
}
|
||||
else if ( eOptID == DECODER_OPTION_END_OF_STREAM ) // Indicate bit-stream of the final frame to be decoded
|
||||
{
|
||||
} else if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
@ -258,21 +242,16 @@ long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
|
||||
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( eOptID == DECODER_OPTION_MODE)
|
||||
{
|
||||
} else if (eOptID == DECODER_OPTION_MODE) {
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
iVal = * ((int*)pOption);
|
||||
|
||||
m_pDecContext->iSetMode = iVal;
|
||||
if(iVal == SW_MODE)
|
||||
{
|
||||
if (iVal == SW_MODE) {
|
||||
m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if !defined(__APPLE__)
|
||||
m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
|
||||
#else
|
||||
@ -282,9 +261,7 @@ long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
}
|
||||
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( eOptID == DECODER_OPTION_OUTPUT_PROPERTY)
|
||||
{
|
||||
} else if (eOptID == DECODER_OPTION_OUTPUT_PROPERTY) {
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
@ -300,8 +277,7 @@ long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
/*
|
||||
* Get Option
|
||||
*/
|
||||
long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
{
|
||||
long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void_t* pOption) {
|
||||
int iVal = 0;
|
||||
|
||||
if (m_pDecContext == NULL)
|
||||
@ -314,8 +290,7 @@ long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
iVal = m_pDecContext->iOutputColorFormat;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_END_OF_STREAM == eOptID ){
|
||||
} else if (DECODER_OPTION_END_OF_STREAM == eOptID) {
|
||||
iVal = m_pDecContext->bEndOfStreamFlag;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
@ -325,40 +300,29 @@ long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
iVal = m_pDecContext->uiCurIdrPicId;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_FRAME_NUM == eOptID)
|
||||
{
|
||||
} else if (DECODER_OPTION_FRAME_NUM == eOptID) {
|
||||
iVal = m_pDecContext->iFrameNum;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_LTR_MARKING_FLAG == eOptID )
|
||||
{
|
||||
} else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) {
|
||||
iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID )
|
||||
{
|
||||
} else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) {
|
||||
iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
#endif
|
||||
else if ( DECODER_OPTION_VCL_NAL == eOptID ) //feedback whether or not have VCL NAL in current AU
|
||||
{
|
||||
else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU
|
||||
iVal = m_pDecContext->iFeedbackVclNalInAu;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_TEMPORAL_ID == eOptID ) //if have VCL NAL in current AU, then feedback the temporal ID
|
||||
{
|
||||
} else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID
|
||||
iVal = m_pDecContext->iFeedbackTidInAu;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_MODE == eOptID )
|
||||
{
|
||||
} else if (DECODER_OPTION_MODE == eOptID) {
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
@ -366,9 +330,7 @@ long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
else if ( DECODER_OPTION_DEVICE_INFO == eOptID )
|
||||
{
|
||||
} else if (DECODER_OPTION_DEVICE_INFO == eOptID) {
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
@ -381,26 +343,21 @@ long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
|
||||
DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
|
||||
const int kiSrcLen,
|
||||
void_t** ppDst,
|
||||
SBufferInfo* pDstInfo)
|
||||
{
|
||||
if ( kiSrcLen > 0 && kpSrc != NULL )
|
||||
{
|
||||
SBufferInfo* pDstInfo) {
|
||||
if (kiSrcLen > 0 && kpSrc != NULL) {
|
||||
#ifdef OUTPUT_BIT_STREAM
|
||||
if ( m_pFBS )
|
||||
{
|
||||
if (m_pFBS) {
|
||||
WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);
|
||||
WelsFflush (m_pFBS);
|
||||
}
|
||||
if ( m_pFBSSize )
|
||||
{
|
||||
if (m_pFBSSize) {
|
||||
WelsFwrite (&kiSrcLen, sizeof (int), 1, m_pFBSSize);
|
||||
WelsFflush (m_pFBSSize);
|
||||
}
|
||||
#endif//OUTPUT_BIT_STREAM
|
||||
m_pDecContext->bEndOfStreamFlag = false;
|
||||
}
|
||||
else
|
||||
{ //For application MODE, the error detection should be added for safe.
|
||||
} else {
|
||||
//For application MODE, the error detection should be added for safe.
|
||||
//But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
|
||||
m_pDecContext->bEndOfStreamFlag = true;
|
||||
}
|
||||
@ -420,20 +377,20 @@ DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
|
||||
|
||||
m_pDecContext->iFeedbackTidInAu = -1; //initialize
|
||||
|
||||
WelsDecodeBs( m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst, pDstInfo); //iErrorCode has been modified in this function
|
||||
WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst,
|
||||
pDstInfo); //iErrorCode has been modified in this function
|
||||
|
||||
pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
|
||||
|
||||
if ( m_pDecContext->iErrorCode )
|
||||
{
|
||||
ENalUnitType eNalType = NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
|
||||
if (m_pDecContext->iErrorCode) {
|
||||
ENalUnitType eNalType =
|
||||
NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
|
||||
|
||||
eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
|
||||
|
||||
//for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
|
||||
if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
|
||||
(VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType) )
|
||||
{
|
||||
(VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) {
|
||||
#ifdef LONG_TERM_REF
|
||||
m_pDecContext->bParamSetsLostFlag = true;
|
||||
#else
|
||||
@ -442,7 +399,8 @@ DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
|
||||
ResetParameterSetsState (m_pDecContext); //initial SPS&PPS ready flag
|
||||
}
|
||||
|
||||
IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode);
|
||||
IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n",
|
||||
m_pDecContext->iErrorCode);
|
||||
return (DECODING_STATE)m_pDecContext->iErrorCode;
|
||||
}
|
||||
|
||||
@ -454,8 +412,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
|
||||
unsigned char** ppDst,
|
||||
int* pStride,
|
||||
int& iWidth,
|
||||
int& iHeight )
|
||||
{
|
||||
int& iHeight) {
|
||||
DECODING_STATE eDecState = dsErrorFree;
|
||||
SBufferInfo DstInfo;
|
||||
|
||||
@ -467,8 +424,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
|
||||
DstInfo.eBufferProperty = BUFFER_HOST;
|
||||
|
||||
eDecState = DecodeFrame (kpSrc, kiSrcLen, (void_t**)ppDst, &DstInfo);
|
||||
if (eDecState == dsErrorFree)
|
||||
{
|
||||
if (eDecState == dsErrorFree) {
|
||||
pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
|
||||
pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
|
||||
iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
|
||||
@ -485,8 +441,7 @@ DECODING_STATE CWelsDecoder::DecodeFrameEx(const unsigned char * kpSrc,
|
||||
int& iDstLen,
|
||||
int& iWidth,
|
||||
int& iHeight,
|
||||
int & iColorFormat )
|
||||
{
|
||||
int& iColorFormat) {
|
||||
DECODING_STATE state = dsErrorFree;
|
||||
|
||||
return state;
|
||||
@ -504,8 +459,7 @@ using namespace WelsDec;
|
||||
* CreateDecoder
|
||||
* @return: success in return 0, otherwise failed.
|
||||
*/
|
||||
long CreateDecoder( ISVCDecoder** ppDecoder )
|
||||
{
|
||||
long CreateDecoder (ISVCDecoder** ppDecoder) {
|
||||
|
||||
if (NULL == ppDecoder) {
|
||||
return ERR_INVALID_PARAMETERS;
|
||||
@ -523,8 +477,7 @@ long CreateDecoder( ISVCDecoder** ppDecoder )
|
||||
/*
|
||||
* DestroyDecoder
|
||||
*/
|
||||
void_t DestroyDecoder( ISVCDecoder* pDecoder )
|
||||
{
|
||||
void_t DestroyDecoder (ISVCDecoder* pDecoder) {
|
||||
if (NULL != pDecoder) {
|
||||
delete (CWelsDecoder*)pDecoder;
|
||||
pDecoder = NULL;
|
||||
|
@ -57,8 +57,7 @@
|
||||
#define WELSVP_MINOR_VERSION 1
|
||||
#define WELSVP_VERSION ((WELSVP_MAJOR_VERSION << 8) + WELSVP_MINOR_VERSION)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
RET_SUCCESS = 0,
|
||||
RET_FAILED = -1,
|
||||
RET_INVALIDPARAM = -2,
|
||||
@ -68,8 +67,7 @@ typedef enum
|
||||
RET_NEEDREINIT = -6
|
||||
} EResult;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
VIDEO_FORMAT_NULL = 0, /* invalid format */
|
||||
/*rgb color formats*/
|
||||
VIDEO_FORMAT_RGB = 1, /* rgb 24bits */
|
||||
@ -107,22 +105,19 @@ typedef enum
|
||||
VIDEO_FORMAT_VFlip = 0x80000000
|
||||
} EVideoFormat;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
BUFFER_HOSTMEM = 0,
|
||||
BUFFER_SURFACE
|
||||
} EPixMapBufferProperty;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int iRectTop;
|
||||
int iRectLeft;
|
||||
int iRectWidth;
|
||||
int iRectHeight;
|
||||
} SRect;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
void* pPixel[3];
|
||||
int iSizeInBits;
|
||||
int iStride[3];
|
||||
@ -131,8 +126,7 @@ typedef struct
|
||||
EPixMapBufferProperty eProperty;//not use? to remove? but how about the size of SPixMap?
|
||||
} SPixMap;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
METHOD_NULL = 0,
|
||||
METHOD_COLORSPACE_CONVERT ,//not support yet
|
||||
METHOD_DENOISE ,
|
||||
@ -150,20 +144,17 @@ typedef enum
|
||||
// Algorithm parameters define
|
||||
//-----------------------------------------------------------------//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int bSceneChangeFlag; // 0:false ; 1:true
|
||||
} SSceneChangeResult;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
SIMILAR_SCENE, //similar scene
|
||||
MEDIUM_CHANGED_SCENE, //medium changed scene
|
||||
LARGE_CHANGED_SCENE, //large changed scene
|
||||
} ESceneChangeIdc;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
unsigned char* pCurY; // Y data of current frame
|
||||
unsigned char* pRefY; // Y data of pRef frame for diff calc
|
||||
int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together
|
||||
@ -175,8 +166,7 @@ typedef struct
|
||||
int iFrameSad; // sad of frame
|
||||
} SVAACalcResult;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int iCalcVar;
|
||||
int iCalcBgd;
|
||||
int iCalcSsd;
|
||||
@ -184,26 +174,22 @@ typedef struct
|
||||
SVAACalcResult* pCalcResult;
|
||||
} SVAACalcParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
signed char* pBackgroundMbFlag;
|
||||
SVAACalcResult* pCalcRes;
|
||||
} SBGDInterface;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
AQ_QUALITY_MODE, //Quality mode
|
||||
AQ_BITRATE_MODE, //Bitrate mode
|
||||
} EAQModes;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
unsigned short uiMotionIndex;
|
||||
unsigned short uiTextureIndex;
|
||||
} SMotionTextureUnit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode
|
||||
SVAACalcResult* pCalcResult;
|
||||
SMotionTextureUnit* pMotionTextureUnit;
|
||||
@ -212,15 +198,13 @@ typedef struct
|
||||
double dAverMotionTextureIndexToDeltaQp;
|
||||
} SAdaptiveQuantizationParam;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FRAME_SAD = 0,
|
||||
GOM_SAD = -1,
|
||||
GOM_VAR = -2
|
||||
} EComplexityAnalysisMode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int iComplexityAnalysisMode;
|
||||
int iCalcBgd;
|
||||
int iMbNumInGom;
|
||||
@ -234,8 +218,7 @@ typedef struct
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
void* pCtx;
|
||||
EResult (*Init) (void* pCtx, int iType, void* pCfg);
|
||||
EResult (*Uninit) (void* pCtx, int iType);
|
||||
@ -248,8 +231,7 @@ typedef struct
|
||||
|
||||
#if defined(__cplusplus) && !defined(CINTERFACE) /* C++ style interface */
|
||||
|
||||
class IWelsVP
|
||||
{
|
||||
class IWelsVP {
|
||||
public:
|
||||
virtual ~IWelsVP() {}
|
||||
|
||||
|
@ -103,7 +103,8 @@ int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaS
|
||||
* \return 0 - successful
|
||||
* 1 - failed
|
||||
*/
|
||||
int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
|
||||
const int32_t kiNumRefFrame,
|
||||
const uint32_t kiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc);
|
||||
|
||||
/*!
|
||||
@ -114,7 +115,8 @@ int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t k
|
||||
* \return 0 - successful
|
||||
* 1 - failed
|
||||
*/
|
||||
int32_t WelsInitSubsetSps( SSubsetSps *pSubsetSps, SDLayerParam *pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
|
||||
const int32_t kiNumRefFrame,
|
||||
const uint32_t kiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc);
|
||||
|
||||
/*!
|
||||
|
@ -58,8 +58,7 @@ typedef struct TagBitStringAux {
|
||||
*
|
||||
* \return iSize of pBuffer pData in byte; failed in -1 return
|
||||
*/
|
||||
static inline int32_t InitBits( SBitStringAux *pBs, const uint8_t *kpBuf, const int32_t kiSize )
|
||||
{
|
||||
static inline int32_t InitBits (SBitStringAux* pBs, const uint8_t* kpBuf, const int32_t kiSize) {
|
||||
uint8_t* ptr = (uint8_t*)kpBuf;
|
||||
|
||||
pBs->pBuf = ptr;
|
||||
|
@ -40,10 +40,8 @@
|
||||
#include <coreFoundation/CFBundle.h>
|
||||
#include <string>
|
||||
|
||||
int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
{
|
||||
if(lpModulePath == NULL || iPathMax <= 0)
|
||||
{
|
||||
int GetCurrentModulePath (char* lpModulePath, const int iPathMax) {
|
||||
if (lpModulePath == NULL || iPathMax <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -62,28 +60,23 @@ int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
int locateNumber = 1;
|
||||
struct FSRef currentPath;
|
||||
OSStatus iStatus = FSPathMakeRef ((unsigned char*)cCurrentPath, ¤tPath, NULL);
|
||||
if(noErr == iStatus)
|
||||
{
|
||||
if (noErr == iStatus) {
|
||||
LSItemInfoRecord info;
|
||||
iStatus = LSCopyItemInfoForRef (¤tPath, kLSRequestExtension, &info);
|
||||
if(noErr == iStatus && NULL == info.extension)
|
||||
{
|
||||
if (noErr == iStatus && NULL == info.extension) {
|
||||
locateNumber = 4;
|
||||
}
|
||||
}
|
||||
std::string strPath (cCurrentPath);
|
||||
int pos = std::string::npos;
|
||||
for(int i = 0; i < locateNumber; i++)
|
||||
{
|
||||
for (int i = 0; i < locateNumber; i++) {
|
||||
pos = strPath.rfind ('/');
|
||||
if(std::string::npos == pos)
|
||||
{
|
||||
if (std::string::npos == pos) {
|
||||
break;
|
||||
}
|
||||
strPath.erase (pos);
|
||||
}
|
||||
if(std::string::npos == pos)
|
||||
{
|
||||
if (std::string::npos == pos) {
|
||||
return -2;
|
||||
}
|
||||
cCurrentPath[pos] = 0;
|
||||
@ -94,23 +87,19 @@ int GetCurrentModulePath(char* lpModulePath, const int iPathMax)
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFBundleRef LoadBundle(const char* lpBundlePath)
|
||||
{
|
||||
if(lpBundlePath == NULL)
|
||||
{
|
||||
CFBundleRef LoadBundle (const char* lpBundlePath) {
|
||||
if (lpBundlePath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct FSRef bundlePath;
|
||||
OSStatus iStatus = FSPathMakeRef ((unsigned char*)lpBundlePath, &bundlePath, NULL);
|
||||
if(noErr != iStatus)
|
||||
{
|
||||
if (noErr != iStatus) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFURLRef bundleURL = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &bundlePath);
|
||||
if(NULL == bundleURL)
|
||||
{
|
||||
if (NULL == bundleURL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -119,29 +108,24 @@ CFBundleRef LoadBundle(const char* lpBundlePath)
|
||||
CFRelease (bundleURL);
|
||||
|
||||
// Boolean bReturn = FALSE;
|
||||
if(NULL != bundleRef)
|
||||
{
|
||||
if (NULL != bundleRef) {
|
||||
// bReturn = CFBundleLoadExecutable(bundleRef);
|
||||
}
|
||||
|
||||
return bundleRef;
|
||||
}
|
||||
|
||||
Boolean FreeBundle(CFBundleRef bundleRef)
|
||||
{
|
||||
if(NULL != bundleRef)
|
||||
{
|
||||
Boolean FreeBundle (CFBundleRef bundleRef) {
|
||||
if (NULL != bundleRef) {
|
||||
// CFBundleUnloadExecutable(bundleRef);
|
||||
CFRelease (bundleRef);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void* GetProcessAddress(CFBundleRef bundleRef, const char* lpProcName)
|
||||
{
|
||||
void* GetProcessAddress (CFBundleRef bundleRef, const char* lpProcName) {
|
||||
void* processAddress = NULL;
|
||||
if(NULL != bundleRef)
|
||||
{
|
||||
if (NULL != bundleRef) {
|
||||
CFStringRef cfProcName = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
|
||||
processAddress = CFBundleGetFunctionPointerForName (bundleRef, cfProcName);
|
||||
CFRelease (cfProcName);
|
||||
|
@ -77,8 +77,7 @@
|
||||
|
||||
#if (defined(WIN32) && defined(_MSC_VER) && (_MSC_VER<1500)) || defined(__GNUC__)
|
||||
|
||||
static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int slen )
|
||||
{
|
||||
static __inline int wels_strncpy_s (char* dest, int dmax, const char* src, int slen) {
|
||||
int orig_dmax;
|
||||
char* orig_dest;
|
||||
const char* overlap_bumper;
|
||||
@ -135,7 +134,11 @@ static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int s
|
||||
* copy slen chars plus the null char. We null the slack.
|
||||
*/
|
||||
#ifdef SAFE_LIB_STR_NULL_SLACK
|
||||
while (dmax) { *dest = '\0'; dmax--; dest++; }
|
||||
while (dmax) {
|
||||
*dest = '\0';
|
||||
dmax--;
|
||||
dest++;
|
||||
}
|
||||
#else
|
||||
*dest = '\0';
|
||||
#endif
|
||||
@ -146,7 +149,11 @@ static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int s
|
||||
if (*dest == '\0') {
|
||||
#ifdef SAFE_LIB_STR_NULL_SLACK
|
||||
/* null slack */
|
||||
while (dmax) { *dest = '\0'; dmax--; dest++; }
|
||||
while (dmax) {
|
||||
*dest = '\0';
|
||||
dmax--;
|
||||
dest++;
|
||||
}
|
||||
#endif
|
||||
return (EOK);
|
||||
}
|
||||
@ -172,7 +179,11 @@ static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int s
|
||||
* copy slen chars plus the null char. We null the slack.
|
||||
*/
|
||||
#ifdef SAFE_LIB_STR_NULL_SLACK
|
||||
while (dmax) { *dest = '\0'; dmax--; dest++; }
|
||||
while (dmax) {
|
||||
*dest = '\0';
|
||||
dmax--;
|
||||
dest++;
|
||||
}
|
||||
#else
|
||||
*dest = '\0';
|
||||
#endif
|
||||
@ -183,7 +194,11 @@ static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int s
|
||||
if (*dest == '\0') {
|
||||
#ifdef SAFE_LIB_STR_NULL_SLACK
|
||||
/* null slack */
|
||||
while (dmax) { *dest = '\0'; dmax--; dest++; }
|
||||
while (dmax) {
|
||||
*dest = '\0';
|
||||
dmax--;
|
||||
dest++;
|
||||
}
|
||||
#endif
|
||||
return (EOK);
|
||||
}
|
||||
@ -202,8 +217,7 @@ static __inline int wels_strncpy_s( char *dest, int dmax, const char *src, int s
|
||||
return (ESNOSPC);
|
||||
}
|
||||
|
||||
static __inline int wels_strcat_s(char *dest, int dmax, const char *src)
|
||||
{
|
||||
static __inline int wels_strcat_s (char* dest, int dmax, const char* src) {
|
||||
int orig_dmax;
|
||||
char* orig_dest;
|
||||
const char* overlap_bumper;
|
||||
@ -265,7 +279,11 @@ static __inline int wels_strcat_s(char *dest, int dmax, const char *src)
|
||||
if (*dest == '\0') {
|
||||
#ifdef SAFE_LIB_STR_NULL_SLACK
|
||||
/* null slack to clear any data */
|
||||
while (dmax) { *dest = '\0'; dmax--; dest++; }
|
||||
while (dmax) {
|
||||
*dest = '\0';
|
||||
dmax--;
|
||||
dest++;
|
||||
}
|
||||
#endif
|
||||
return (EOK);
|
||||
}
|
||||
@ -303,7 +321,11 @@ static __inline int wels_strcat_s(char *dest, int dmax, const char *src)
|
||||
if (*dest == '\0') {
|
||||
#ifdef SAFE_LIB_STR_NULL_SLACK
|
||||
/* null slack to clear any data */
|
||||
while (dmax) { *dest = '\0'; dmax--; dest++; }
|
||||
while (dmax) {
|
||||
*dest = '\0';
|
||||
dmax--;
|
||||
dest++;
|
||||
}
|
||||
#endif
|
||||
return (EOK);
|
||||
}
|
||||
@ -322,8 +344,7 @@ static __inline int wels_strcat_s(char *dest, int dmax, const char *src)
|
||||
return (ESNOSPC);
|
||||
}
|
||||
|
||||
static __inline int wels_strnlen_s(const char *dest, int dmax)
|
||||
{
|
||||
static __inline int wels_strnlen_s (const char* dest, int dmax) {
|
||||
int count;
|
||||
|
||||
if (dest == NULL) {
|
||||
|
@ -63,8 +63,10 @@ typedef struct TagDeblockingFilter {
|
||||
|
||||
void DeblockLumaLt4_c (uint8_t* pPixY, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
|
||||
void DeblockLumaEq4_c (uint8_t* pPixY, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
|
||||
void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta );
|
||||
void DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* pTc);
|
||||
void DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta);
|
||||
|
||||
|
||||
void DeblockLumaLt4V_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
|
||||
@ -73,10 +75,12 @@ void DeblockLumaEq4V_c( uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t
|
||||
void DeblockLumaLt4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
|
||||
void DeblockLumaEq4H_c (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
|
||||
void DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc);
|
||||
void DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
void DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc );
|
||||
void DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTc);
|
||||
void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@ -91,9 +95,11 @@ void DeblockLumaTransposeV2H_sse2(uint8_t * pPixY, int32_t iStride, uint8_t * pS
|
||||
void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
|
||||
void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaEq4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaLt4V_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
|
||||
void DeblockChromaLt4V_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
void DeblockChromaEq4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
void DeblockChromaLt4H_sse2(uint8_t * pPixCb, uint8_t * pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t * pTC);
|
||||
void DeblockChromaLt4H_sse2 (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* pTC);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -49,7 +49,8 @@ void WelsDequant4x4_c(int16_t *pRes, const uint16_t* kpQpTable);
|
||||
void WelsDequantIHadamard4x4_c (int16_t* pRes, const uint16_t kuiMF);
|
||||
void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF);
|
||||
|
||||
void WelsIDctT4RecOnMb(uint8_t* pDst, int32_t iDstStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct, PIDctFunc pfIDctFourT4);
|
||||
void WelsIDctT4RecOnMb (uint8_t* pDst, int32_t iDstStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct,
|
||||
PIDctFunc pfIDctFourT4);
|
||||
void WelsIDctT4Rec_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct);
|
||||
void WelsIDctFourT4Rec_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDct);
|
||||
void WelsIDctRecI16x16Dc_c (uint8_t* pRec, int32_t iStride, uint8_t* pPred, int32_t iPredStride, int16_t* pDctDc);
|
||||
@ -65,7 +66,8 @@ void WelsDequantIHadamard4x4_sse2(int16_t *pRes, const uint16_t kuiMF);
|
||||
|
||||
void WelsIDctT4Rec_mmx (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
|
||||
void WelsIDctFourT4Rec_sse2 (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride, int16_t* pDct);
|
||||
void WelsIDctRecI16x16Dc_sse2(uint8_t *pRec, int32_t iStride, uint8_t *pPrediction, int32_t iPredStride, int16_t *pDctDc);
|
||||
void WelsIDctRecI16x16Dc_sse2 (uint8_t* pRec, int32_t iStride, uint8_t* pPrediction, int32_t iPredStride,
|
||||
int16_t* pDctDc);
|
||||
#endif//X86_ASM
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -46,8 +46,7 @@
|
||||
* Dependency Quality IDC
|
||||
*/
|
||||
|
||||
typedef struct TagDqIdc
|
||||
{
|
||||
typedef struct TagDqIdc {
|
||||
uint16_t iPpsId; // pPps id
|
||||
uint8_t iSpsId; // pSps id
|
||||
int8_t uiSpatialId; // spatial id
|
||||
|
@ -79,8 +79,10 @@ typedef struct TagLTRState{
|
||||
|
||||
// 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
|
||||
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
|
||||
@ -114,10 +116,13 @@ typedef struct TagWelsEncCtx{
|
||||
int32_t* pSadCostMb;
|
||||
/* MVD cost tables for Inter MB */
|
||||
uint16_t* pMvdCostTableInter; //[52]; // adaptive to spatial layers
|
||||
SMVUnitXY *pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer
|
||||
int8_t *pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer
|
||||
SMVUnitXY*
|
||||
pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer
|
||||
int8_t*
|
||||
pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer
|
||||
int8_t* pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM];
|
||||
int8_t *pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11)
|
||||
int8_t*
|
||||
pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11)
|
||||
|
||||
SMB** ppMbListD; // [MAX_DEPENDENCY_LAYER];
|
||||
SStrideTables* pStrideTab; // stride tables for internal coding used
|
||||
@ -134,7 +139,8 @@ typedef struct TagWelsEncCtx{
|
||||
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*
|
||||
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
|
||||
@ -184,7 +190,8 @@ typedef struct TagWelsEncCtx{
|
||||
int32_t iPosBsBuffer; // current writing position of frame bs pBuffer
|
||||
|
||||
/* For Downsampling & VAA I420 based source pictures */
|
||||
SPicture *pSpatialPic[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL+1+LONG_TERM_REF_NUM]; // need memory requirement with total number of (log2(uiGopSize)+1+1+long_term_ref_num)
|
||||
SPicture* pSpatialPic[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1 +
|
||||
LONG_TERM_REF_NUM]; // need memory requirement with total number of (log2(uiGopSize)+1+1+long_term_ref_num)
|
||||
|
||||
SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER];
|
||||
uint8_t uiSpatialLayersInTemporal[MAX_DEPENDENCY_LAYER];
|
||||
@ -200,7 +207,8 @@ typedef struct TagWelsEncCtx{
|
||||
* 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;
|
||||
CMemoryAlign* pMemAlign;
|
||||
|
@ -97,7 +97,8 @@ void WelsUninitEncoderExt( sWelsEncCtx **ppCtx );
|
||||
* [NO in picture list case, YES in console aplication based]
|
||||
* \return EFrameType (WELS_FRAME_TYPE_IDR/WELS_FRAME_TYPE_I/WELS_FRAME_TYPE_P)
|
||||
*/
|
||||
int32_t WelsEncoderEncodeExt( sWelsEncCtx *, void *pDst, const SSourcePicture **kppSrcList, const int32_t kiConfiguredLayerNum );
|
||||
int32_t WelsEncoderEncodeExt (sWelsEncCtx*, void* pDst, const SSourcePicture** kppSrcList,
|
||||
const int32_t kiConfiguredLayerNum);
|
||||
|
||||
/*
|
||||
* Force coding IDR as follows
|
||||
|
@ -38,15 +38,20 @@
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
struct tagUnaligned_64 { uint64_t l; } __attribute__((packed));
|
||||
struct tagUnaligned_32 { uint32_t l; } __attribute__((packed));
|
||||
struct tagUnaligned_16 { uint16_t l; } __attribute__((packed));
|
||||
struct tagUnaligned_64 {
|
||||
uint64_t l;
|
||||
} __attribute__ ((packed));
|
||||
struct tagUnaligned_32 {
|
||||
uint32_t l;
|
||||
} __attribute__ ((packed));
|
||||
struct tagUnaligned_16 {
|
||||
uint16_t l;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define LD16(a) (((struct tagUnaligned_16 *) (a))->l)
|
||||
#define LD32(a) (((struct tagUnaligned_32 *) (a))->l)
|
||||
//#define LD64(a) (((struct tagUnaligned_64 *) (a))->l)
|
||||
inline uint64_t LD64(const void * a)
|
||||
{
|
||||
inline uint64_t LD64 (const void* a) {
|
||||
uint64_t v;
|
||||
memcpy (&v, a, sizeof (v)); // confirmed_safe_unsafe_usage
|
||||
return v;
|
||||
@ -56,8 +61,7 @@
|
||||
#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)
|
||||
inline void ST64(void * a, uint64_t b)
|
||||
{
|
||||
inline void ST64 (void* a, uint64_t b) {
|
||||
memcpy (a, &b, sizeof (b)); // confirmed_safe_unsafe_usage
|
||||
}
|
||||
// #else
|
||||
|
@ -136,14 +136,12 @@ __declspec(align(alignment)) type name[(sizex)*(sizey)]
|
||||
#define WELS_ROUND(x) ((int32_t)((x)+0.5f+EPSN))
|
||||
#endif//WELS_ROUND
|
||||
|
||||
static inline int32_t WELS_CEIL(float v)
|
||||
{
|
||||
static inline int32_t WELS_CEIL (float v) {
|
||||
const int32_t n = (int32_t)v; // floor value
|
||||
return ((v > EPSN + n) ? (1 + n) : n); // (int32_t)ceil(v);
|
||||
}
|
||||
|
||||
static inline int32_t WELS_FLOOR(float v)
|
||||
{
|
||||
static inline int32_t WELS_FLOOR (float v) {
|
||||
return (int32_t)v;
|
||||
}
|
||||
|
||||
@ -158,47 +156,39 @@ static inline int32_t WELS_FLOOR(float v)
|
||||
* log base 2 of v and ceil/floor extension
|
||||
*/
|
||||
|
||||
static inline int32_t WELS_CEILLOG2( uint32_t v )
|
||||
{
|
||||
static inline int32_t WELS_CEILLOG2 (uint32_t v) {
|
||||
int32_t r = 0;
|
||||
--v;
|
||||
while( v > 0 )
|
||||
{
|
||||
while (v > 0) {
|
||||
++r;
|
||||
v >>= 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int32_t WELS_FLOORLOG2( uint32_t v )
|
||||
{
|
||||
static inline int32_t WELS_FLOORLOG2 (uint32_t v) {
|
||||
int32_t r = 0;
|
||||
while( v > 1 )
|
||||
{
|
||||
while (v > 1) {
|
||||
++r;
|
||||
v >>= 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int32_t WELS_LOG2( uint32_t v )
|
||||
{
|
||||
static inline int32_t WELS_LOG2 (uint32_t v) {
|
||||
int32_t r = 0;
|
||||
while (v >>= 1)
|
||||
{
|
||||
while (v >>= 1) {
|
||||
++r;
|
||||
}
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
static inline BOOL_T WELS_POWER2_IF( uint32_t v )
|
||||
{
|
||||
static inline BOOL_T WELS_POWER2_IF (uint32_t v) {
|
||||
return (v && ! (v & (v - 1)));
|
||||
}
|
||||
|
||||
static inline int32_t WELS_MEDIAN(int32_t x, int32_t y, int32_t z)
|
||||
{
|
||||
static inline int32_t WELS_MEDIAN (int32_t x, int32_t y, int32_t z) {
|
||||
int32_t t = (x - y) & ((x - y) >> 31);
|
||||
x -= t;
|
||||
y += t;
|
||||
@ -236,8 +226,7 @@ static inline int32_t WELS_MEDIAN(int32_t x, int32_t y, int32_t z)
|
||||
#define WELS_SIGN(a) ((int32_t)(a) >> 31) // General: (a)>>(sizeof(int)*CHAR_BIT-1), CHAR_BIT= the number of bits per byte (normally 8)
|
||||
#endif //WELS_SIGN
|
||||
|
||||
static inline int32_t WELS_ABS(int32_t a)
|
||||
{
|
||||
static inline int32_t WELS_ABS (int32_t a) {
|
||||
const int32_t sign = WELS_SIGN (a);
|
||||
return ((a + sign) ^ sign);
|
||||
}
|
||||
@ -257,8 +246,7 @@ static inline int32_t WELS_ABS(int32_t a)
|
||||
// Bitwise routines
|
||||
// n: ulong
|
||||
// b: bit order
|
||||
static inline bool_t BITWISE_ENABLED(const uint32_t n, const uint8_t b)
|
||||
{
|
||||
static inline bool_t BITWISE_ENABLED (const uint32_t n, const uint8_t b) {
|
||||
const uint8_t bit = (b & 0x1f); // maximal bit position 31 for uint32_t 4 bytes
|
||||
#if defined(WORDS_BIGENDIAN)
|
||||
/*
|
||||
@ -278,8 +266,7 @@ static inline bool_t BITWISE_ENABLED(const uint32_t n, const uint8_t b)
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
|
||||
static inline uint32_t ENDIAN_FIX(uint32_t x)
|
||||
{
|
||||
static inline uint32_t ENDIAN_FIX (uint32_t x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -287,10 +274,8 @@ static inline uint32_t ENDIAN_FIX(uint32_t x)
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
static inline uint32_t ENDIAN_FIX(uint32_t x)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
static inline uint32_t ENDIAN_FIX (uint32_t x) {
|
||||
__asm {
|
||||
mov eax, x
|
||||
bswap eax
|
||||
mov x, eax
|
||||
@ -298,8 +283,7 @@ static inline uint32_t ENDIAN_FIX(uint32_t x)
|
||||
return x;
|
||||
}
|
||||
#else // GCC
|
||||
static inline uint32_t ENDIAN_FIX(uint32_t x)
|
||||
{
|
||||
static inline uint32_t ENDIAN_FIX (uint32_t x) {
|
||||
#ifdef X86_ARCH
|
||||
__asm__ __volatile__ ("bswap %0":"+r" (x));
|
||||
#else
|
||||
|
@ -64,8 +64,7 @@ extern const uint8_t g_kuiCache30ScanIdx[16];
|
||||
extern const uint8_t g_kuiCache12_8x8RefIdx[4];
|
||||
extern const uint8_t g_kuiCache48CountScan4Idx[24];
|
||||
|
||||
typedef struct TagDCTCoeff
|
||||
{
|
||||
typedef struct TagDCTCoeff {
|
||||
//ALIGNED_DECLARE( int16_t, residual_ac[16], 16 ); //I_16x16
|
||||
int16_t iLumaBlock[16][16]; //based on block4x4 luma DC/AC
|
||||
//ALIGNED_DECLARE( int16_t, iLumaI16x16Dc[16], 16 ); //I_16x16 DC
|
||||
@ -128,8 +127,7 @@ typedef struct TagMbCache{
|
||||
bool_t bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0).
|
||||
uint32_t uiRefMbType;
|
||||
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
/* pointer of current mb location in original frame */
|
||||
uint8_t* pEncMb[3];
|
||||
/* pointer of current mb location in recovery frame */
|
||||
|
@ -55,26 +55,35 @@ extern "C" {
|
||||
// MMXEXT and SSE2 definition //
|
||||
//***************************************************************************//
|
||||
#if defined(X86_ASM)
|
||||
void McChromaWidthEq4_mmx( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD,int32_t iHeigh );
|
||||
void McChromaWidthEq4_mmx (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, const uint8_t* kpABCD,
|
||||
int32_t iHeigh);
|
||||
void McCopyWidthEq4_mmx (uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
void McCopyWidthEq8_mmx (uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
void PixelAvgWidthEq8_mmx (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
|
||||
void McHorVer20_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride,int32_t iWidth, int32_t iHeight);
|
||||
void McHorVer02_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride,int32_t iWidth, int32_t iHeight);
|
||||
void McHorVer22HorFirst_sse2(uint8_t * pSrc,int32_t iSrcStride,uint8_t * pTap,int32_t iTapStride,int32_t iWidth,int32_t iHeight);
|
||||
void McHorVer22VerLastAlign_sse2(uint8_t * pTap, int32_t iTapStride, uint8_t * pDst,int32_t iDstStride,int32_t iWidth,int32_t iHeight);
|
||||
void McHorVer22VerLastUnAlign_sse2(uint8_t * pTap, int32_t iTapStride, uint8_t * pDst,int32_t iDstStride,int32_t iWidth,int32_t iHeight);
|
||||
void McChromaWidthEq8_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD, int32_t iHeigh );
|
||||
void McHorVer20_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight);
|
||||
void McHorVer02_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight);
|
||||
void McHorVer22HorFirst_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pTap, int32_t iTapStride, int32_t iWidth,
|
||||
int32_t iHeight);
|
||||
void McHorVer22VerLastAlign_sse2 (uint8_t* pTap, int32_t iTapStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||
int32_t iHeight);
|
||||
void McHorVer22VerLastUnAlign_sse2 (uint8_t* pTap, int32_t iTapStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
void McChromaWidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, const uint8_t* kpABCD,
|
||||
int32_t iHeigh);
|
||||
void McCopyWidthEq16_sse2 (uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
void McHorVer20WidthEq16_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight);
|
||||
void McHorVer02WidthEq8_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight);
|
||||
void McHorVer22Width8HorFirst_sse2( uint8_t*pSrc, int32_t iSrcStride, uint8_t* pTap, int32_t iTapStride,int32_t iHeight);
|
||||
void McHorVer22Width8HorFirst_sse2 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pTap, int32_t iTapStride,
|
||||
int32_t iHeight);
|
||||
void PixelAvgWidthEq16_sse2 (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
|
||||
|
||||
void PixelAvgWidthEq16_ssse3 (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
void McChromaWidthEq8_ssse3( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, const uint8_t *kpABCD, int32_t iHeigh );
|
||||
void McChromaWidthEq8_ssse3 (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
const uint8_t* kpABCD, int32_t iHeigh);
|
||||
|
||||
|
||||
#endif //X86_ASM
|
||||
|
@ -74,8 +74,7 @@ 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
|
||||
{
|
||||
typedef struct TagWelsMD {
|
||||
int32_t iLambda;
|
||||
uint16_t* pMvdCost;
|
||||
|
||||
@ -92,8 +91,7 @@ typedef struct TagWelsMD
|
||||
|
||||
//NO B frame in our Wels, we can ignore list1
|
||||
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
SWelsME sMe16x16; //adjust each SWelsME for 8 D-word!
|
||||
SWelsME sMe8x8[4];
|
||||
SWelsME sMe16x8[2];
|
||||
@ -103,8 +101,7 @@ typedef struct TagWelsMD
|
||||
|
||||
} SWelsMD;
|
||||
|
||||
typedef struct TagMeRefinePointer
|
||||
{
|
||||
typedef struct TagMeRefinePointer {
|
||||
uint8_t* pHalfPixH;
|
||||
uint8_t* pHalfPixV;
|
||||
uint8_t* pHalfPixHV;
|
||||
@ -118,7 +115,8 @@ static void md_intra_init(sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb);
|
||||
static void md_inter_init (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb);
|
||||
|
||||
void FillNeighborCacheIntra (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth/*, bool_t constrained_intra_pred_flag*/);
|
||||
void FillNeighborCacheInterWithoutBGD(SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth, int8_t *pVaaBgMbFlag); //BGD spatial func
|
||||
void FillNeighborCacheInterWithoutBGD (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth,
|
||||
int8_t* pVaaBgMbFlag); //BGD spatial func
|
||||
void FillNeighborCacheInterWithBGD (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth, int8_t* pVaaBgMbFlag);
|
||||
void InitFillNeighborCacheInterFunc (SWelsFuncPtrList* pFuncList, const int32_t kiFlag);
|
||||
|
||||
@ -127,7 +125,8 @@ void MvdCostInit( uint16_t* pMvdCostInter, const int32_t kiMvdSz );
|
||||
void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef, int32_t* pSadPred);
|
||||
|
||||
|
||||
void PredictSadSkip( int8_t* pRefIndexCache, bool_t* pMbSkipCache, int32_t* pSadCostCache, int32_t uiRef, int32_t * iSadPredSkip );
|
||||
void PredictSadSkip (int8_t* pRefIndexCache, bool_t* pMbSkipCache, int32_t* pSadCostCache, int32_t uiRef,
|
||||
int32_t* iSadPredSkip);
|
||||
|
||||
// for pfGetVarianceFromIntraVaa function ptr adaptive by CPU features, 6/7/2010
|
||||
void InitIntraAnalysisVaaInfo (SWelsFuncPtrList* pFuncList, const uint32_t kuiCpuFlag);
|
||||
|
@ -61,8 +61,7 @@
|
||||
* \return time elapsed since run (unit: microsecond)
|
||||
*/
|
||||
|
||||
static inline int64_t WelsTime()
|
||||
{
|
||||
static inline int64_t WelsTime() {
|
||||
#if !(defined(_MSC_VER) || defined(__MINGW32__))
|
||||
struct timeval tv_date;
|
||||
|
||||
|
@ -43,8 +43,7 @@ namespace WelsSVCEnc {
|
||||
|
||||
#define MEMORY_REQUEST_ALIGN_BYTES 0 // or (1^n), i.e, 0x04
|
||||
|
||||
class CMemoryAlign
|
||||
{
|
||||
class CMemoryAlign {
|
||||
public:
|
||||
CMemoryAlign (const uint32_t kuiCacheLineSize);
|
||||
virtual ~CMemoryAlign();
|
||||
|
@ -179,8 +179,7 @@ typedef struct TagSliceThreadPrivateData {
|
||||
int32_t iEndMbIndex; // exclusive
|
||||
} SSliceThreadPrivateData;
|
||||
|
||||
typedef struct TagSliceThreading
|
||||
{
|
||||
typedef struct TagSliceThreading {
|
||||
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
|
||||
WELS_THREAD_HANDLE* pThreadHandles;// thread handles, [iThreadIdx]
|
||||
#ifdef WIN32
|
||||
|
@ -64,21 +64,24 @@ void UpdateP16x16MotionInfo(SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef,
|
||||
* \param
|
||||
* \param
|
||||
*/
|
||||
void UpdateP16x8MotionInfo(SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, SMVUnitXY* pMv);
|
||||
void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef,
|
||||
SMVUnitXY* pMv);
|
||||
|
||||
/*!
|
||||
* \brief update pMv and uiRefIndex cache for current MB and pMbCache, only for P_8x16
|
||||
* \param
|
||||
* \param
|
||||
*/
|
||||
void update_P8x16_motion_info(SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, SMVUnitXY* pMv);
|
||||
void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef,
|
||||
SMVUnitXY* pMv);
|
||||
|
||||
/*!
|
||||
* \brief update pMv and uiRefIndex cache for current MB and pMbCache, only for P_8x8
|
||||
* \param
|
||||
* \param
|
||||
*/
|
||||
void UpdateP8x8MotionInfo(SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, SMVUnitXY* pMv);
|
||||
void UpdateP8x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef,
|
||||
SMVUnitXY* pMv);
|
||||
|
||||
/*!
|
||||
* \brief get the motion predictor for 4*4 or 8*8 or 16*16 block
|
||||
|
@ -100,7 +100,8 @@ typedef struct TagWelsSliceBs {
|
||||
/*!
|
||||
* \brief load an initialize NAL pRawNal pData
|
||||
*/
|
||||
void WelsLoadNal( SWelsEncoderOutput *pEncoderOuput, const int32_t/*EWelsNalUnitType*/ kiType, const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc );
|
||||
void WelsLoadNal (SWelsEncoderOutput* pEncoderOuput, const int32_t/*EWelsNalUnitType*/ kiType,
|
||||
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc);
|
||||
|
||||
/*!
|
||||
* \brief unload pRawNal NAL
|
||||
@ -110,7 +111,8 @@ void WelsUnloadNal( SWelsEncoderOutput *pEncoderOuput );
|
||||
/*!
|
||||
* \brief load an initialize NAL pRawNal pData
|
||||
*/
|
||||
void WelsLoadNalForSlice( SWelsSliceBs *pSliceBs, const int32_t/*EWelsNalUnitType*/ kiType, const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc );
|
||||
void WelsLoadNalForSlice (SWelsSliceBs* pSliceBs, const int32_t/*EWelsNalUnitType*/ kiType,
|
||||
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc);
|
||||
|
||||
/*!
|
||||
* \brief unload pRawNal NAL
|
||||
|
@ -63,14 +63,12 @@ extern const uint8_t g_kuiTemporalIdListTable[MAX_TEMPORAL_LEVEL][MAX_GOP_SIZE
|
||||
* \param upper input upper value
|
||||
* \return 2 based scaling factor
|
||||
*/
|
||||
static __inline uint32_t GetLogFactor( real32_t base, real32_t upper )
|
||||
{
|
||||
static __inline uint32_t GetLogFactor (real32_t base, real32_t upper) {
|
||||
const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0);
|
||||
const double dEpsilon = 0.0001;
|
||||
const double dRound = floor (dLog2factor + 0.5);
|
||||
|
||||
if( dLog2factor < dRound+dEpsilon && dRound < dLog2factor+dEpsilon )
|
||||
{
|
||||
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
|
||||
return (uint32_t) (dRound);
|
||||
}
|
||||
return UINT_MAX;
|
||||
@ -190,14 +188,12 @@ typedef struct TagWelsSvcCodingParam {
|
||||
|
||||
|
||||
public:
|
||||
TagWelsSvcCodingParam(const bool_t kbEnableRc = true)
|
||||
{
|
||||
TagWelsSvcCodingParam (const bool_t kbEnableRc = true) {
|
||||
FillDefault (kbEnableRc);
|
||||
}
|
||||
~TagWelsSvcCodingParam() {}
|
||||
|
||||
void FillDefault( const bool_t kbEnableRc )
|
||||
{
|
||||
void FillDefault (const bool_t kbEnableRc) {
|
||||
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
|
||||
uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
|
||||
iNumRefFrame = MIN_REF_PIC_COUNT; // number of reference frame used
|
||||
@ -220,14 +216,16 @@ public:
|
||||
#ifdef MT_ENABLED
|
||||
iMultipleThreadIdc = 0; // auto to detect cpu cores inside
|
||||
#else
|
||||
iMultipleThreadIdc = 1; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||
iMultipleThreadIdc =
|
||||
1; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||
#endif//MT_ENABLED
|
||||
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
||||
|
||||
iLTRRefNum = 0;
|
||||
uiLtrMarkPeriod = 30; //the min distance of two int32_t references
|
||||
|
||||
bMgsT0OnlyStrategy = true; // Strategy of have MGS only at T0 frames (0: do not use this strategy; 1: use this strategy)
|
||||
bMgsT0OnlyStrategy =
|
||||
true; // Strategy of have MGS only at T0 frames (0: do not use this strategy; 1: use this strategy)
|
||||
bEnableSSEI = true;
|
||||
bEnableFrameCroppingFlag = true; // enable frame cropping flag: TRUE alwayse in application
|
||||
bEnableCropPic = true; // enable cropping source picture. , 8/25/2010
|
||||
@ -258,11 +256,11 @@ public:
|
||||
iNumTemporalLayer = 0; // number of temporal layer specified
|
||||
}
|
||||
|
||||
int32_t ParamTranscode( SVCEncodingParam& pCodingParam, const bool_t kbEnableRc = true )
|
||||
{
|
||||
int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool_t kbEnableRc = true) {
|
||||
pCodingParam.fFrameRate = WELS_CLIP3 (pCodingParam.fFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
|
||||
uiFrameToBeCoded = (uint32_t)-1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
|
||||
uiFrameToBeCoded = (uint32_t) -
|
||||
1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
|
||||
|
||||
iActualPicWidth = pCodingParam.iPicWidth;
|
||||
iActualPicHeight = pCodingParam.iPicHeight;
|
||||
@ -319,9 +317,12 @@ public:
|
||||
bEnableSSEI = true;
|
||||
|
||||
/* Layer definition */
|
||||
iNumDependencyLayer = (int8_t)WELS_CLIP3(pCodingParam.iSpatialLayerNum, 1, MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
pCodingParam.iTemporalLayerNum = (int8_t)WELS_CLIP3(pCodingParam.iTemporalLayerNum, 1, MAX_TEMPORAL_LEVEL); // safe valid iTemporalLayerNum
|
||||
iNumTemporalLayer = (int8_t)pCodingParam.iTemporalLayerNum;//(int8_t)WELS_CLIP3(pCodingParam.iTemporalLayerNum, 1, MAX_TEMPORAL_LEVEL);// number of temporal layer specified
|
||||
iNumDependencyLayer = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
|
||||
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
pCodingParam.iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
|
||||
MAX_TEMPORAL_LEVEL); // safe valid iTemporalLayerNum
|
||||
iNumTemporalLayer = (int8_t)
|
||||
pCodingParam.iTemporalLayerNum;//(int8_t)WELS_CLIP3(pCodingParam.iTemporalLayerNum, 1, MAX_TEMPORAL_LEVEL);// number of temporal layer specified
|
||||
|
||||
uiGopSize = 1 << (iNumTemporalLayer - 1); // Override GOP size based temporal layer
|
||||
iDecompStages = iNumTemporalLayer - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
|
||||
@ -339,20 +340,22 @@ public:
|
||||
|
||||
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
|
||||
|
||||
bEnableSpsPpsIdAddition = pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
|
||||
bEnableSpsPpsIdAddition =
|
||||
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
|
||||
//SHOULD enable this feature.
|
||||
|
||||
SDLayerParam* pDlp = &sDependencyLayers[0];
|
||||
float fMaxFr = .0f;
|
||||
uint8_t uiProfileIdc = PRO_BASELINE;
|
||||
int8_t iIdxSpatial = 0;
|
||||
while(iIdxSpatial < iNumDependencyLayer)
|
||||
{
|
||||
while (iIdxSpatial < iNumDependencyLayer) {
|
||||
pDlp->uiProfileIdc = uiProfileIdc;
|
||||
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3(pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE, pCodingParam.fFrameRate);
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
|
||||
MIN_FRAME_RATE, pCodingParam.fFrameRate);
|
||||
pDlp->fInputFrameRate =
|
||||
pDlp->fOutputFrameRate = WELS_CLIP3(pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
pDlp->fOutputFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
|
||||
MAX_FRAME_RATE);
|
||||
if (pDlp->fInputFrameRate > fMaxFr + EPSN)
|
||||
fMaxFr = pDlp->fInputFrameRate;
|
||||
|
||||
@ -361,7 +364,8 @@ public:
|
||||
#endif//ENABLE_FRAME_DUMP
|
||||
pDlp->iFrameWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
|
||||
pDlp->iFrameHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
|
||||
pDlp->iSpatialBitrate = pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
|
||||
pDlp->iSpatialBitrate =
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
|
||||
|
||||
|
||||
//multi slice
|
||||
@ -371,7 +375,8 @@ public:
|
||||
pDlp->sMso.sSliceArgument.iSliceNum
|
||||
= pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum;
|
||||
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
|
||||
memcpy(pDlp->sMso.sSliceArgument.uiSliceMbNum, pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
|
||||
memcpy (pDlp->sMso.sSliceArgument.uiSliceMbNum,
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
|
||||
kiLesserSliceNum * sizeof (uint32_t)) ;
|
||||
|
||||
pDlp->iDLayerQp = SVC_QUALITY_BASE_QP;
|
||||
@ -390,13 +395,11 @@ public:
|
||||
|
||||
// assuming that the width/height ratio of all spatial layers are the same
|
||||
|
||||
void SetActualPicResolution()
|
||||
{
|
||||
void SetActualPicResolution() {
|
||||
int32_t iSpatialIdx = iNumDependencyLayer - 1;
|
||||
SDLayerParam* pDlayer = &sDependencyLayers[iSpatialIdx];
|
||||
|
||||
for (; iSpatialIdx >= 0; iSpatialIdx -- )
|
||||
{
|
||||
for (; iSpatialIdx >= 0; iSpatialIdx --) {
|
||||
pDlayer = &sDependencyLayers[iSpatialIdx];
|
||||
|
||||
pDlayer->iActualWidth = pDlayer->iFrameWidth;
|
||||
@ -411,16 +414,15 @@ public:
|
||||
* \param SWelsSvcCodingParam, and carried with known GOP size, max, input and output frame rate of each spatial
|
||||
* \return NONE (should ensure valid parameter before this procedure)
|
||||
*/
|
||||
void DetermineTemporalSettings()
|
||||
{
|
||||
const int32_t iDecStages = WELS_LOG2( uiGopSize ); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
|
||||
void DetermineTemporalSettings() {
|
||||
const int32_t iDecStages = WELS_LOG2 (
|
||||
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
|
||||
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
|
||||
SDLayerParam* pDlp = &sDependencyLayers[0];
|
||||
uint8_t uiProfileIdc = PRO_BASELINE;
|
||||
int8_t i = 0;
|
||||
|
||||
while (i < iNumDependencyLayer )
|
||||
{
|
||||
while (i < iNumDependencyLayer) {
|
||||
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
|
||||
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
|
||||
int32_t iNotCodedMask = 0;
|
||||
@ -434,8 +436,7 @@ public:
|
||||
if (0 == (uiFrameIdx & iNotCodedMask)) {
|
||||
const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx];
|
||||
pDlp->uiCodingIdx2TemporalId[uiFrameIdx] = kiTemporalId;
|
||||
if ( kiTemporalId > iMaxTemporalId )
|
||||
{
|
||||
if (kiTemporalId > iMaxTemporalId) {
|
||||
iMaxTemporalId = kiTemporalId;
|
||||
}
|
||||
}
|
||||
@ -454,8 +455,7 @@ public:
|
||||
|
||||
} SWelsSvcCodingParam;
|
||||
|
||||
static inline int32_t FreeCodingParam( SWelsSvcCodingParam **pParam, CMemoryAlign *pMa )
|
||||
{
|
||||
static inline int32_t FreeCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
|
||||
if (pParam == NULL || *pParam == NULL || pMa == NULL)
|
||||
return 1;
|
||||
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
|
||||
@ -463,15 +463,15 @@ static inline int32_t FreeCodingParam( SWelsSvcCodingParam **pParam, CMemoryAlig
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int32_t AllocCodingParam( SWelsSvcCodingParam **pParam, CMemoryAlign *pMa, const int32_t kiRequestNumSpatial )
|
||||
{
|
||||
static inline int32_t AllocCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa,
|
||||
const int32_t kiRequestNumSpatial) {
|
||||
if (pParam == NULL || pMa == NULL || kiRequestNumSpatial < 1 || kiRequestNumSpatial > MAX_SPATIAL_LAYER_NUM)
|
||||
return 1;
|
||||
if (*pParam != NULL)
|
||||
{
|
||||
if (*pParam != NULL) {
|
||||
FreeCodingParam (pParam, pMa);
|
||||
}
|
||||
SWelsSvcCodingParam *pCodingParam = (SWelsSvcCodingParam *)pMa->WelsMalloc(sizeof(SWelsSvcCodingParam), "SWelsSvcCodingParam");
|
||||
SWelsSvcCodingParam* pCodingParam = (SWelsSvcCodingParam*)pMa->WelsMalloc (sizeof (SWelsSvcCodingParam),
|
||||
"SWelsSvcCodingParam");
|
||||
if (NULL == pCodingParam)
|
||||
return 1;
|
||||
*pParam = pCodingParam;
|
||||
|
@ -57,8 +57,7 @@ namespace WelsSVCEnc {
|
||||
#define WELS_RC_DISABLE 0
|
||||
#define WELS_RC_GOM 1
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
RC_MODE0, //Quality mode
|
||||
RC_MODE1, //Bitrate mode
|
||||
} RC_MODES;
|
||||
@ -121,8 +120,7 @@ enum {
|
||||
#define PADDING_BUFFER_RATIO 0.5
|
||||
#define PADDING_THRESHOLD 0.05
|
||||
|
||||
typedef struct TagRCSlicing
|
||||
{
|
||||
typedef struct TagRCSlicing {
|
||||
int32_t iComplexityIndexSlice;
|
||||
int32_t iCalculatedQpSlice;
|
||||
int32_t iStartMbSlice;
|
||||
@ -137,8 +135,7 @@ typedef struct TagRCSlicing
|
||||
//int32_t gom_coded_mb;
|
||||
} SRCSlicing;
|
||||
|
||||
typedef struct TagRCTemporal
|
||||
{
|
||||
typedef struct TagRCTemporal {
|
||||
int32_t iMinBitsTl;
|
||||
int32_t iMaxBitsTl;
|
||||
double dTlayerWeight;
|
||||
@ -221,8 +218,7 @@ typedef void (*PWelsRCPictureInfoUpdateFunc) (void *pCtx, int32_t iLayerSize);
|
||||
typedef void (*PWelsRCMBInfoUpdateFunc) (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice);
|
||||
typedef void (*PWelsRCMBInitFunc) (void* pCtx, SMB* pCurMb, SSlice* pSlice);
|
||||
|
||||
typedef struct WelsRcFunc_s
|
||||
{
|
||||
typedef struct WelsRcFunc_s {
|
||||
PWelsRCPictureInitFunc pfWelsRcPictureInit;
|
||||
PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate;
|
||||
PWelsRCMBInitFunc pfWelsRcMbInit;
|
||||
|
@ -47,21 +47,18 @@
|
||||
#include "codec_app_def.h"
|
||||
|
||||
namespace WelsSVCEnc {
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
RECIEVE_UNKOWN = 0,
|
||||
RECIEVE_SUCCESS = 1,
|
||||
RECIEVE_FAILED = 2,
|
||||
} LTR_MARKING_RECEIVE_STATE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
LTR_DIRECT_MARK = 0,
|
||||
LTR_DELAY_MARK = 1,
|
||||
} LTR_MARKING_PROCESS_MODE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
FRAME_NUM_EQUAL = 0x01,
|
||||
FRAME_NUM_BIGGER = 0x02,
|
||||
FRAME_NUM_SMALLER = 0x04,
|
||||
|
@ -37,8 +37,7 @@
|
||||
#include "wels_func_ptr_def.h"
|
||||
|
||||
namespace WelsSVCEnc {
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BLOCK_16x16 = 0,
|
||||
BLOCK_16x8 = 1,
|
||||
BLOCK_8x16 = 2,
|
||||
@ -95,7 +94,8 @@ int32_t WelsSampleSatd16x8_sse2( uint8_t *, int32_t, uint8_t *, int32_t );
|
||||
int32_t WelsSampleSatd8x16_sse2 (uint8_t*, int32_t, uint8_t*, int32_t);
|
||||
int32_t WelsSampleSatd16x16_sse2 (uint8_t*, int32_t, uint8_t*, int32_t);
|
||||
int32_t WelsSampleSatd4x4_sse2 (uint8_t*, int32_t, uint8_t*, int32_t);
|
||||
int32_t WelsSmpleSatdThree4x4_sse2( uint8_t *, int32_t, uint8_t *, int32_t, uint8_t*, int32_t*, int32_t, int32_t, int32_t );
|
||||
int32_t WelsSmpleSatdThree4x4_sse2 (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t*, int32_t, int32_t,
|
||||
int32_t);
|
||||
|
||||
int32_t WelsSampleSatd8x8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t);
|
||||
int32_t WelsSampleSatd8x16_sse41 (uint8_t*, int32_t, uint8_t*, int32_t);
|
||||
@ -105,8 +105,10 @@ int32_t WelsSampleSatd4x4_sse41( uint8_t *, int32_t, uint8_t *, int32_t );
|
||||
|
||||
int32_t WelsIntra16x16Combined3Satd_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
|
||||
int32_t WelsIntra16x16Combined3Sad_ssse3 (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
|
||||
int32_t WelsIntraChroma8x8Combined3Satd_sse41( uint8_t *, int32_t, uint8_t *, int32_t, int32_t*, int32_t, uint8_t*,uint8_t*,uint8_t*);
|
||||
int32_t WelsIntraChroma8x8Combined3Sad_ssse3( uint8_t *, int32_t, uint8_t *, int32_t, int32_t*, int32_t, uint8_t*,uint8_t*,uint8_t*);
|
||||
int32_t WelsIntraChroma8x8Combined3Satd_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*,
|
||||
uint8_t*, uint8_t*);
|
||||
int32_t WelsIntraChroma8x8Combined3Sad_ssse3 (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*,
|
||||
uint8_t*, uint8_t*);
|
||||
|
||||
|
||||
#endif//X86_ASM
|
||||
|
@ -60,18 +60,17 @@ enum EResidualProperty{
|
||||
|
||||
#define LUMA_DC_AC 0x04
|
||||
|
||||
typedef int32_t (*PCavlcParamCalFunc) ( int16_t * pCoff, uint8_t * pRun, int16_t * pLevel, int32_t * pTotalCoeffs, int32_t iEndIdx);
|
||||
typedef int32_t (*PCavlcParamCalFunc) (int16_t* pCoff, uint8_t* pRun, int16_t* pLevel, int32_t* pTotalCoeffs,
|
||||
int32_t iEndIdx);
|
||||
|
||||
typedef struct TagCoeffFunc
|
||||
{
|
||||
typedef struct TagCoeffFunc {
|
||||
PCavlcParamCalFunc pfCavlcParamCal;
|
||||
} SCoeffFunc;
|
||||
|
||||
/* For CAVLC */
|
||||
extern SCoeffFunc sCoeffFunc;
|
||||
|
||||
typedef struct TagCavlcTableItem
|
||||
{
|
||||
typedef struct TagCavlcTableItem {
|
||||
uint16_t uiBits;
|
||||
uint8_t uiLen;
|
||||
uint8_t uiSuffixLength;
|
||||
@ -81,14 +80,16 @@ void InitCoeffFunc( const uint32_t uiCpuFlag );
|
||||
|
||||
void InitCavlcTable();
|
||||
|
||||
void WriteBlockResidualCavlc( int16_t *pCoffLevel, int32_t iEndIdx, int32_t iCalRunLevelFlag, int32_t iResidualProperty, int8_t iNC, SBitStringAux *pBs );
|
||||
void WriteBlockResidualCavlc (int16_t* pCoffLevel, int32_t iEndIdx, int32_t iCalRunLevelFlag,
|
||||
int32_t iResidualProperty, int8_t iNC, SBitStringAux* pBs);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif//__cplusplus
|
||||
|
||||
#ifdef X86_ASM
|
||||
int32_t CavlcParamCal_sse2(int16_t*pCoffLevel, uint8_t* pRun, int16_t *pLevel, int32_t * pTotalCoeffs , int32_t iEndIdx);
|
||||
int32_t CavlcParamCal_sse2 (int16_t* pCoffLevel, uint8_t* pRun, int16_t* pLevel, int32_t* pTotalCoeffs ,
|
||||
int32_t iEndIdx);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -53,8 +53,7 @@ namespace WelsSVCEnc {
|
||||
* Reference picture list reordering syntax, refer to page 64 in JVT X201wcm
|
||||
*/
|
||||
typedef struct TagRefPicListReorderSyntax {
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
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;
|
||||
@ -65,8 +64,7 @@ typedef struct TagRefPicListReorderSyntax {
|
||||
|
||||
/* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */
|
||||
typedef struct TagRefPicMarking {
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
int32_t iMmcoType;
|
||||
int32_t iShortFrameNum;
|
||||
int32_t iDiffOfPicNum;
|
||||
|
@ -74,7 +74,8 @@ void reset_env_mt( sWelsEncCtx *pCtx );
|
||||
#endif//PACKING_ONE_SLICE_PER_LAYER
|
||||
|
||||
|
||||
int32_t RequestMtResource( sWelsEncCtx **ppCtx, SWelsSvcCodingParam *pParam, const int32_t kiCountBsLen, const int32_t kiTargetSpatialBsSize );
|
||||
int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pParam, const int32_t kiCountBsLen,
|
||||
const int32_t kiTargetSpatialBsSize);
|
||||
|
||||
void ReleaseMtResource (sWelsEncCtx** ppCtx);
|
||||
|
||||
@ -96,9 +97,11 @@ void ResetCountBsSizeInPartitions( uint32_t *pCountBsSizeList, const int32_t kiP
|
||||
#endif//PACKING_ONE_SLICE_PER_LAYER
|
||||
|
||||
#ifdef WIN32
|
||||
int32_t FiredSliceThreads( SSliceThreadPrivateData *pPriData, WELS_EVENT *pEventsList, SLayerBSInfo *pLayerBsInfo, const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx *pSliceCtx, const BOOL_T kbIsDynamicSlicingMode );
|
||||
int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, SLayerBSInfo* pLayerBsInfo,
|
||||
const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx* pSliceCtx, const BOOL_T kbIsDynamicSlicingMode);
|
||||
#else
|
||||
int32_t FiredSliceThreads( SSliceThreadPrivateData *pPriData, WELS_EVENT **ppEventsList, SLayerBSInfo *pLayerBsInfo, const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx *pSliceCtx, const BOOL_T kbIsDynamicSlicingMode );
|
||||
int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** ppEventsList, SLayerBSInfo* pLayerBsInfo,
|
||||
const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx* pSliceCtx, const BOOL_T kbIsDynamicSlicingMode);
|
||||
#endif//WIN32
|
||||
|
||||
int32_t DynamicDetectCpuCores();
|
||||
|
@ -74,22 +74,29 @@ void WelsMdInterMb(void* pEncCtx, void* pWelsMd, SSlice *pSlice, SMB* pCurMb );
|
||||
//both used in BL and EL
|
||||
//void wels_md_inter_init ( SWelsMD* pMd, const uint8_t ref_idx, const bool_t is_highest_dlayer_flag );
|
||||
|
||||
bool_t WelsMdInterJudgeBGDPskip ( void* pEnc, void* pMd, SSlice *pSlice, SMB* pCurMb, SMbCache *pMbCache, BOOL_T* bKeepSkip );
|
||||
bool_t WelsMdInterJudgeBGDPskipFalse( void* pEnc, void* pMd, SSlice *pSlice, SMB* pCurMb, SMbCache *pMbCache, BOOL_T* bKeepSkip );
|
||||
bool_t WelsMdInterJudgeBGDPskip (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
|
||||
BOOL_T* bKeepSkip);
|
||||
bool_t WelsMdInterJudgeBGDPskipFalse (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
|
||||
BOOL_T* bKeepSkip);
|
||||
|
||||
void WelsMdInterUpdateBGDInfo ( SDqLayer* pCurLayer, SMB* pCurMb, const bool_t kbCollocatedPredFlag, const int32_t kiRefPictureType );
|
||||
void WelsMdInterUpdateBGDInfoNULL ( SDqLayer* pCurLayer, SMB* pCurMb, const bool_t kbCollocatedPredFlag, const int32_t kiRefPictureType );
|
||||
void WelsMdInterUpdateBGDInfo (SDqLayer* pCurLayer, SMB* pCurMb, const bool_t kbCollocatedPredFlag,
|
||||
const int32_t kiRefPictureType);
|
||||
void WelsMdInterUpdateBGDInfoNULL (SDqLayer* pCurLayer, SMB* pCurMb, const bool_t kbCollocatedPredFlag,
|
||||
const int32_t kiRefPictureType);
|
||||
|
||||
bool_t WelsMdInterJudgePskip( sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice *pSlice, SMB* pCurMb, SMbCache *pMbCache, BOOL_T bTrySkip );
|
||||
bool_t WelsMdInterJudgePskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
|
||||
BOOL_T bTrySkip);
|
||||
void WelsMdInterUpdatePskip (SDqLayer* pCurDqLayer, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache);
|
||||
void WelsMdInterDecidedPskip (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache);
|
||||
|
||||
void WelsMdInterDoubleCheckPskip (SMB* pCurMb, SMbCache* pMbCache);
|
||||
void WelsMdInterEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache);
|
||||
|
||||
void WelsMdInterSaveSadAndRefMbType( Mb_Type* pRefMbTypeList, SMbCache * pMbCache, const SMB* kpCurMb, const SWelsMD* kpMd );
|
||||
void WelsMdInterSaveSadAndRefMbType (Mb_Type* pRefMbTypeList, SMbCache* pMbCache, const SMB* kpCurMb,
|
||||
const SWelsMD* kpMd);
|
||||
|
||||
void WelsMdInterSecondaryModesEnc( sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice *pSlice, SMB* pCurMb, SMbCache *pMbCache, const BOOL_T kbSkip );
|
||||
void WelsMdInterSecondaryModesEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb,
|
||||
SMbCache* pMbCache, const BOOL_T kbSkip);
|
||||
void WelsMdIntraSecondaryModesEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache);
|
||||
//end of: both used in BL and EL
|
||||
|
||||
|
@ -64,7 +64,8 @@ typedef SDqLayer * pDqLayer;
|
||||
|
||||
typedef struct TagLayerInfo {
|
||||
SNalUnitHeaderExt sNalHeaderExt;
|
||||
SSlice *pSliceInLayer;// Here SSlice identify to Frame on concept, [iSliceIndex], need memory block external side for MT
|
||||
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
|
||||
|
@ -86,24 +86,18 @@ extern const uint32_t g_uiGolombUELength[256];
|
||||
/*
|
||||
* Get size of unsigned exp golomb codes
|
||||
*/
|
||||
static inline uint32_t BsSizeUE( const uint32_t kiValue )
|
||||
{
|
||||
if ( 256 > kiValue )
|
||||
{
|
||||
static inline uint32_t BsSizeUE (const uint32_t kiValue) {
|
||||
if (256 > kiValue) {
|
||||
return g_uiGolombUELength[kiValue];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
uint32_t n = 0;
|
||||
uint32_t iTmpValue = kiValue + 1;
|
||||
|
||||
if (iTmpValue & 0xffff0000)
|
||||
{
|
||||
if (iTmpValue & 0xffff0000) {
|
||||
iTmpValue >>= 16;
|
||||
n += 16;
|
||||
}
|
||||
if (iTmpValue & 0xff00)
|
||||
{
|
||||
if (iTmpValue & 0xff00) {
|
||||
iTmpValue >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
@ -118,20 +112,14 @@ static inline uint32_t BsSizeUE( const uint32_t kiValue )
|
||||
/*
|
||||
* Get size of signed exp golomb codes
|
||||
*/
|
||||
static inline uint32_t BsSizeSE( const int32_t kiValue )
|
||||
{
|
||||
static inline uint32_t BsSizeSE (const int32_t kiValue) {
|
||||
uint32_t iTmpValue;
|
||||
if ( 0 == kiValue )
|
||||
{
|
||||
if (0 == kiValue) {
|
||||
return 1;
|
||||
}
|
||||
else if ( 0 < kiValue )
|
||||
{
|
||||
} else if (0 < kiValue) {
|
||||
iTmpValue = (kiValue << 1) - 1;
|
||||
return BsSizeUE (iTmpValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iTmpValue = ((-kiValue) << 1);
|
||||
return BsSizeUE (iTmpValue);
|
||||
}
|
||||
@ -140,15 +128,13 @@ static inline uint32_t BsSizeSE( const int32_t kiValue )
|
||||
/*
|
||||
* Get size of truncated exp golomb codes
|
||||
*/
|
||||
static inline int32_t BsSizeTE( const int32_t kiX, const int32_t kiValue )
|
||||
{
|
||||
static inline int32_t BsSizeTE (const int32_t kiX, const int32_t kiValue) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline int32_t BsWriteBits( SBitStringAux *pBs, int32_t n, const uint32_t kuiValue )
|
||||
{
|
||||
static inline int32_t BsWriteBits (SBitStringAux* pBs, int32_t n, const uint32_t kuiValue) {
|
||||
if (n < pBs->iLeftBits) {
|
||||
pBs->uiCurBits = (pBs->uiCurBits << n) | kuiValue;
|
||||
pBs->iLeftBits -= n;
|
||||
@ -166,16 +152,14 @@ static inline int32_t BsWriteBits( SBitStringAux *pBs, int32_t n, const uint32_t
|
||||
/*
|
||||
* Write 1 bit
|
||||
*/
|
||||
static inline int32_t BsWriteOneBit( SBitStringAux *pBs, const uint32_t kuiValue )
|
||||
{
|
||||
static inline int32_t BsWriteOneBit (SBitStringAux* pBs, const uint32_t kuiValue) {
|
||||
BsWriteBits (pBs, 1, kuiValue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline void BsFlush(SBitStringAux * pBs)
|
||||
{
|
||||
static inline void BsFlush (SBitStringAux* pBs) {
|
||||
* (uint32_t*)pBs->pBufPtr = ENDIAN_FIX (pBs->uiCurBits << pBs->iLeftBits);
|
||||
pBs->pBufPtr += 4 - pBs->iLeftBits / 8;
|
||||
pBs->iLeftBits = 32;
|
||||
@ -185,23 +169,18 @@ static inline void BsFlush(SBitStringAux * pBs)
|
||||
/*
|
||||
* Write unsigned exp golomb codes
|
||||
*/
|
||||
static inline void BsWriteUE( SBitStringAux *pBs, const uint32_t kuiValue )
|
||||
{
|
||||
static inline void BsWriteUE (SBitStringAux* pBs, const uint32_t kuiValue) {
|
||||
if (256 > kuiValue) {
|
||||
BsWriteBits (pBs, g_uiGolombUELength[kuiValue], kuiValue + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
uint32_t n = 0;
|
||||
uint32_t iTmpValue = kuiValue + 1;
|
||||
|
||||
if (iTmpValue & 0xffff0000)
|
||||
{
|
||||
if (iTmpValue & 0xffff0000) {
|
||||
iTmpValue >>= 16;
|
||||
n += 16;
|
||||
}
|
||||
if (iTmpValue & 0xff00)
|
||||
{
|
||||
if (iTmpValue & 0xff00) {
|
||||
iTmpValue >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
@ -217,20 +196,14 @@ static inline void BsWriteUE( SBitStringAux *pBs, const uint32_t kuiValue )
|
||||
/*
|
||||
* Write signed exp golomb codes
|
||||
*/
|
||||
static inline void BsWriteSE( SBitStringAux *pBs, int32_t iValue )
|
||||
{
|
||||
static inline void BsWriteSE (SBitStringAux* pBs, int32_t iValue) {
|
||||
uint32_t iTmpValue;
|
||||
if ( 0 == iValue )
|
||||
{
|
||||
if (0 == iValue) {
|
||||
BsWriteOneBit (pBs, 1);
|
||||
}
|
||||
else if ( 0 < iValue )
|
||||
{
|
||||
} else if (0 < iValue) {
|
||||
iTmpValue = (iValue << 1) - 1;
|
||||
BsWriteUE (pBs, iTmpValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iTmpValue = ((-iValue) << 1);
|
||||
BsWriteUE (pBs, iTmpValue);
|
||||
}
|
||||
@ -240,14 +213,10 @@ static inline void BsWriteSE( SBitStringAux *pBs, int32_t iValue )
|
||||
/*
|
||||
* Write truncated exp golomb codes
|
||||
*/
|
||||
static inline void BsWriteTE( SBitStringAux *pBs, const int32_t kiX, const uint32_t kuiValue )
|
||||
{
|
||||
if ( 1 == kiX )
|
||||
{
|
||||
static inline void BsWriteTE (SBitStringAux* pBs, const int32_t kiX, const uint32_t kuiValue) {
|
||||
if (1 == kiX) {
|
||||
BsWriteOneBit (pBs, !kuiValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BsWriteUE (pBs, kuiValue);
|
||||
}
|
||||
}
|
||||
@ -256,21 +225,18 @@ static inline void BsWriteTE( SBitStringAux *pBs, const int32_t kiX, const uint3
|
||||
/*
|
||||
* Write RBSP trailing bits
|
||||
*/
|
||||
static inline void BsRbspTrailingBits( SBitStringAux *pBs )
|
||||
{
|
||||
static inline void BsRbspTrailingBits (SBitStringAux* pBs) {
|
||||
BsWriteOneBit (pBs, 1);
|
||||
BsFlush (pBs);
|
||||
}
|
||||
|
||||
|
||||
static inline BOOL_T BsCheckByteAlign( SBitStringAux * pBs)
|
||||
{
|
||||
static inline BOOL_T BsCheckByteAlign (SBitStringAux* pBs) {
|
||||
return ! (pBs->iLeftBits & 0x7);
|
||||
}
|
||||
|
||||
|
||||
static inline int32_t BsGetBitsPos( SBitStringAux *pBs )
|
||||
{
|
||||
static inline int32_t BsGetBitsPos (SBitStringAux* pBs) {
|
||||
return (((pBs->pBufPtr - pBs->pBuf) << 3) + 32 - pBs->iLeftBits);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,8 @@ typedef struct TagSliceArgument{
|
||||
} SSliceArgument;
|
||||
|
||||
typedef struct TagMulSliceOption { //interfaces about slicing from application layer
|
||||
SSliceArgument sSliceArgument; //according to uiSliceMode, decide which elements of this structure will actually takes effect
|
||||
SSliceArgument
|
||||
sSliceArgument; //according to uiSliceMode, decide which elements of this structure will actually takes effect
|
||||
SliceMode uiSliceMode;
|
||||
} SMulSliceOption;
|
||||
|
||||
|
@ -82,7 +82,8 @@ void WelsISliceMdEncDynamic( sWelsEncCtx* pEncCtx, SSlice *pSlice ); // for intr
|
||||
void WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
|
||||
void WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
|
||||
|
||||
void WelsCodeOneSlice( sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t/*EWelsNalUnitType*/ keNalType/*, bool_t bNewLayer*/ );
|
||||
void WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx,
|
||||
const int32_t/*EWelsNalUnitType*/ keNalType/*, bool_t bNewLayer*/);
|
||||
|
||||
void WelsInitSliceEncodingFuncs (uint32_t uiCpuFlag);
|
||||
|
||||
@ -90,11 +91,15 @@ void UpdateMbNeighbourInfoForNextSlice( SSliceCtx *pSliceCtx,
|
||||
SMB* pMbList,
|
||||
const int32_t kiNextSliceFirstMbIdx,
|
||||
const int32_t kiLastMbIdxInPartition);
|
||||
void AddSliceBoundary(sWelsEncCtx* pEncCtx, SSlice * pCurSlice, SSliceCtx *pSliceCtx, SMB* pCurMb, int32_t iNextSliceFirstMbIdx, const int32_t kiLastMbIdxInPartition );
|
||||
void WelsMdInterMbLoop( sWelsEncCtx* pEncCtx, SSlice *pSlice, void* pMd, const int32_t kiSliceFirstMbXY ); // for inter non-dynamic slice
|
||||
void WelsMdInterMbLoopOverDynamicSlice( sWelsEncCtx* pEncCtx, SSlice *pSlice, void* pMd, const int32_t kiSliceFirstMbXY ); // for inter dynamic slice
|
||||
void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
|
||||
int32_t iNextSliceFirstMbIdx, const int32_t kiLastMbIdxInPartition);
|
||||
void WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pMd,
|
||||
const int32_t kiSliceFirstMbXY); // for inter non-dynamic slice
|
||||
void WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pMd,
|
||||
const int32_t kiSliceFirstMbXY); // for inter dynamic slice
|
||||
|
||||
|
||||
BOOL_T DynSlcJudgeSliceBoundaryStepBack(void *pEncCtx, void *pSlice, SSliceCtx *pSliceCtx, SMB* pCurMb, SDynamicSlicingStack* pDss );
|
||||
BOOL_T DynSlcJudgeSliceBoundaryStepBack (void* pEncCtx, void* pSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
|
||||
SDynamicSlicingStack* pDss);
|
||||
}
|
||||
#endif //SVC_ENCODE_SLICE_H__
|
||||
|
@ -51,7 +51,8 @@ namespace WelsSVCEnc {
|
||||
///////////////////////
|
||||
|
||||
// NOILP ILFMD ENTRANCE
|
||||
void WelsMdSpatialelInterMbIlfmdNoilp( sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice *pSlice, SMB* pCurMb, const Mb_Type kuiRefMbType);
|
||||
void WelsMdSpatialelInterMbIlfmdNoilp (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb,
|
||||
const Mb_Type kuiRefMbType);
|
||||
void WelsMdInterMbEnhancelayer (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache);
|
||||
|
||||
SMB* GetRefMb (SDqLayer* pCurLayer, SMB* pCurMb);
|
||||
|
@ -112,7 +112,8 @@ void WelsMotionEstimateSearchSad(SWelsFuncPtrList *pFuncList, void* pLplayer, vo
|
||||
* \return NONE
|
||||
*/
|
||||
|
||||
void WelsMotionEstimateInitialPoint(SWelsFuncPtrList *pFuncList, SWelsME *pMe, SSlice *pSlice, const int32_t kiStrideEnc, const int32_t kiStrideRef );
|
||||
void WelsMotionEstimateInitialPoint (SWelsFuncPtrList* pFuncList, SWelsME* pMe, SSlice* pSlice,
|
||||
const int32_t kiStrideEnc, const int32_t kiStrideRef);
|
||||
|
||||
/*!
|
||||
* \brief mb iterative motion estimate search
|
||||
@ -123,9 +124,11 @@ void WelsMotionEstimateInitialPoint(SWelsFuncPtrList *pFuncList, SWelsME *pMe, S
|
||||
*
|
||||
* \return NONE
|
||||
*/
|
||||
void WelsMotionEstimateIterativeSearch( SWelsFuncPtrList *pFuncList, SWelsME *pMe, const int32_t kiStrideEnc, const int32_t kiStrideRef, uint8_t *pRef );
|
||||
void WelsMotionEstimateIterativeSearch (SWelsFuncPtrList* pFuncList, SWelsME* pMe, const int32_t kiStrideEnc,
|
||||
const int32_t kiStrideRef, uint8_t* pRef);
|
||||
|
||||
bool_t WelsMeSadCostSelect( int32_t *pSadCost, const uint16_t *kpMvdCost, int32_t *pBestCost, const int32_t kiDx, const int32_t kiDy, int32_t *pIx, int32_t *pIy);
|
||||
bool_t WelsMeSadCostSelect (int32_t* pSadCost, const uint16_t* kpMvdCost, int32_t* pBestCost, const int32_t kiDx,
|
||||
const int32_t kiDy, int32_t* pIx, int32_t* pIy);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -78,7 +78,8 @@ typedef real32_t (*PWelsPsnrFunc)( const void *kpTarPic,
|
||||
extern PWelsLogCallbackFunc wlog;
|
||||
|
||||
#ifdef __GNUC__
|
||||
extern void WelsLog(void *pCtx, int32_t iLevel, const str_t *kpFmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void WelsLog (void* pCtx, int32_t iLevel, const str_t* kpFmt, ...) __attribute__ ((__format__ (__printf__, 3,
|
||||
4)));
|
||||
#else
|
||||
extern void WelsLog (void* pCtx, int32_t iLevel, const str_t* kpFmt, ...);
|
||||
#endif
|
||||
|
@ -56,40 +56,36 @@ extern const ALIGNED_DECLARE(uint8_t, g_kuiEncNcMapTable[18], 16);
|
||||
|
||||
#define CHROMA_DC_NC_OFFSET 17
|
||||
|
||||
static inline int32_t WriteTotalCoeffTrailingones( SBitStringAux *pBs, uint8_t uiNc, uint8_t uiTotalCoeff, uint8_t uiTrailingOnes )
|
||||
{
|
||||
static inline int32_t WriteTotalCoeffTrailingones (SBitStringAux* pBs, uint8_t uiNc, uint8_t uiTotalCoeff,
|
||||
uint8_t uiTrailingOnes) {
|
||||
const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc];
|
||||
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0];
|
||||
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
|
||||
}
|
||||
|
||||
static inline int32_t WriteTotalcoeffTrailingonesChroma( SBitStringAux *pBs, uint8_t uiTotalCoeff, uint8_t uiTrailingOnes )
|
||||
{
|
||||
static inline int32_t WriteTotalcoeffTrailingonesChroma (SBitStringAux* pBs, uint8_t uiTotalCoeff,
|
||||
uint8_t uiTrailingOnes) {
|
||||
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
|
||||
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
|
||||
}
|
||||
|
||||
//kuiZeroCount = level_prefix;
|
||||
static inline int32_t WriteLevelPrefix( SBitStringAux *pBs, const uint32_t kuiZeroCount )
|
||||
{
|
||||
static inline int32_t WriteLevelPrefix (SBitStringAux* pBs, const uint32_t kuiZeroCount) {
|
||||
BsWriteBits (pBs, kuiZeroCount + 1, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int32_t WriteTotalZeros( SBitStringAux *pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros )
|
||||
{
|
||||
static inline int32_t WriteTotalZeros (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
|
||||
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
|
||||
return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]);
|
||||
}
|
||||
|
||||
static inline int32_t WriteTotalZerosChromaDc( SBitStringAux *pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros )
|
||||
{
|
||||
static inline int32_t WriteTotalZerosChromaDc (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
|
||||
const uint8_t* kpTotalZerosChromaDc = &g_kuiVlcTotalZerosChromaDc[uiTotalCoeff][uiTotalZeros][0];
|
||||
return BsWriteBits (pBs, kpTotalZerosChromaDc[1], kpTotalZerosChromaDc[0]);
|
||||
}
|
||||
|
||||
static inline int32_t WriteRunBefore( SBitStringAux *pBs, uint8_t uiZeroLeft, uint8_t uiRunBefore )
|
||||
{
|
||||
static inline int32_t WriteRunBefore (SBitStringAux* pBs, uint8_t uiZeroLeft, uint8_t uiRunBefore) {
|
||||
const uint8_t* kpRunBefore = &g_kuiVlcRunBefore[uiZeroLeft][uiRunBefore][0];
|
||||
return BsWriteBits (pBs, kpRunBefore[1], kpRunBefore[0]);
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ enum EProfileIdc{
|
||||
/*
|
||||
* NAL Unit Type (5 Bits)
|
||||
*/
|
||||
enum EWelsNalUnitType
|
||||
{
|
||||
enum EWelsNalUnitType {
|
||||
NAL_UNIT_UNSPEC_0 = 0,
|
||||
NAL_UNIT_CODED_SLICE = 1,
|
||||
NAL_UNIT_CODED_SLICE_DPA = 2,
|
||||
@ -105,8 +104,7 @@ enum EWelsNalUnitType
|
||||
* NAL Reference IDC (2 Bits)
|
||||
*/
|
||||
|
||||
enum EWelsNalRefIdc
|
||||
{
|
||||
enum EWelsNalRefIdc {
|
||||
NRI_PRI_LOWEST = 0,
|
||||
NRI_PRI_LOW = 1,
|
||||
NRI_PRI_HIGH = 2,
|
||||
@ -157,8 +155,7 @@ enum EFrameType{
|
||||
* meaning mapped version after eSliceType minus 4.
|
||||
*/
|
||||
|
||||
enum EWelsSliceType
|
||||
{
|
||||
enum EWelsSliceType {
|
||||
P_SLICE = 0,
|
||||
B_SLICE = 1,
|
||||
I_SLICE = 2,
|
||||
@ -186,8 +183,7 @@ struct SMVUnitXY{ // each 4 Bytes
|
||||
int16_t iMvX;
|
||||
int16_t iMvY;
|
||||
public:
|
||||
SMVUnitXY& sDeltaMv ( const SMVUnitXY& _v0, const SMVUnitXY& _v1 )
|
||||
{
|
||||
SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) {
|
||||
iMvX = _v0.iMvX - _v1.iMvX;
|
||||
iMvY = _v0.iMvY - _v1.iMvY;
|
||||
return (*this);
|
||||
@ -209,10 +205,13 @@ typedef struct TagParaSetOffsetVariable{
|
||||
|
||||
typedef struct TagParaSetOffset {
|
||||
//in PS0 design, "sParaSetOffsetVariable" record the previous paras before current IDR, AND NEED to be stacked and recover across IDR
|
||||
SParaSetOffsetVariable sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS
|
||||
SParaSetOffsetVariable
|
||||
sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS
|
||||
//in PSO design, "bPpsIdMappingIntoSubsetsps" uses the current para of current IDR period
|
||||
bool_t bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
|
||||
uint16_t uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR!! Can we just NOT put this into the SParaSetOffset structure?!!
|
||||
bool_t
|
||||
bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
|
||||
uint16_t
|
||||
uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR!! Can we just NOT put this into the SParaSetOffset structure?!!
|
||||
#if _DEBUG
|
||||
bool_t bEnableSpsPpsIdAddition;
|
||||
#endif
|
||||
@ -253,8 +252,7 @@ enum ETransType{
|
||||
T_PCM = 3
|
||||
};
|
||||
|
||||
enum EMbPosition
|
||||
{
|
||||
enum EMbPosition {
|
||||
LEFT_MB_POS = 0x01, // A
|
||||
TOP_MB_POS = 0x02, // B
|
||||
TOPRIGHT_MB_POS = 0x04, // C
|
||||
|
@ -65,14 +65,16 @@ typedef void (*PQuantizationFunc)(int16_t *pDct, int16_t* pFF, int16_t *pMF);
|
||||
typedef void (*PQuantizationMaxFunc) (int16_t* pDct, int16_t* pFF, int16_t* pMF, int16_t* pMax);
|
||||
typedef void (*PQuantizationDcFunc) (int16_t* pDct, int16_t iFF, int16_t iMF);
|
||||
typedef BOOL_T (*PQuantizationSkipFunc) (int16_t* pDct, int16_t iFF, int16_t iMF);
|
||||
typedef int32_t (*PQuantizationHadamardFunc)(int16_t *pRes, const int16_t kiFF, int16_t iMF, int16_t * pDct, int16_t * pBlock);
|
||||
typedef int32_t (*PQuantizationHadamardFunc) (int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct,
|
||||
int16_t* pBlock);
|
||||
|
||||
typedef void (*PWelsMcFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
SMVUnitXY mv, int32_t iWidth, int32_t iHeight);
|
||||
|
||||
typedef void (*PWelsLumaHalfpelMcFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iWidth, int32_t iHeight);
|
||||
typedef void (*PWelsLumaQuarpelMcFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight);
|
||||
typedef void (*PWelsLumaQuarpelMcFunc) (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||
int32_t iHeight);
|
||||
typedef void (*PWelsSampleAveragingFunc) (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t, int32_t);
|
||||
|
||||
typedef struct TagMcFunc {
|
||||
@ -87,8 +89,10 @@ typedef struct TagMcFunc{
|
||||
|
||||
typedef void (*PLumaDeblockingLT4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* iTc);
|
||||
typedef void (*PLumaDeblockingEQ4Func) (uint8_t* iSampleY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
|
||||
typedef void (*PChromaDeblockingLT4Func)( uint8_t *iSampleCb, uint8_t *iSampleCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc );
|
||||
typedef void (*PChromaDeblockingEQ4Func)( uint8_t *iSampleCb, uint8_t *iSampleCr, int32_t iStride, int32_t iAlpha, int32_t iBeta );
|
||||
typedef void (*PChromaDeblockingLT4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* iTc);
|
||||
typedef void (*PChromaDeblockingEQ4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr, int32_t iStride, int32_t iAlpha,
|
||||
int32_t iBeta);
|
||||
|
||||
typedef struct tagDeblockingFunc {
|
||||
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
|
||||
@ -108,21 +112,28 @@ typedef int32_t (*PIntraFineMdFunc)(void* pEncCtx, void * pWelsMd, SMB* pCurMb,
|
||||
typedef void (*PInterFineMdFunc) (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, int32_t bestCost);
|
||||
typedef BOOL_T (*PInterMdFirstIntraModeFunc) (void* pEncCtx, void* pWelsMd, SMB* pCurMb, SMbCache* pMbCache);
|
||||
|
||||
typedef void (*PMotionSearchFunc) ( SWelsFuncPtrList *pFuncList, void* pCurDqLayer, void* pMe, void* pSlice );// here after reset all function pointers, will set as right parameter type
|
||||
typedef void (*PMotionSearchFunc) (SWelsFuncPtrList* pFuncList, void* pCurDqLayer, void* pMe,
|
||||
void* pSlice); // here after reset all function pointers, will set as right parameter type
|
||||
typedef void (*PFillInterNeighborCacheFunc) (SMbCache* pMbCache, SMB* pCurMb, int32_t iMbWidth, int8_t* pVaaBgMbFlag);
|
||||
typedef void (*PAccumulateSadFunc) (uint32_t *pSumDiff, int32_t *pGomForegroundBlockNum, int32_t *iSad8x8, int8_t *pVaaBgMbFlag);//for RC
|
||||
typedef BOOL_T (*PDynamicSlicingStepBackFunc) ( void* pEncCtx, void* pSlice, SSliceCtx *pSliceCtx, SMB* pCurMb, SDynamicSlicingStack *pDynamicSlicingStack );// 2010.8.17
|
||||
typedef void (*PAccumulateSadFunc) (uint32_t* pSumDiff, int32_t* pGomForegroundBlockNum, int32_t* iSad8x8,
|
||||
int8_t* pVaaBgMbFlag);//for RC
|
||||
typedef BOOL_T (*PDynamicSlicingStepBackFunc) (void* pEncCtx, void* pSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
|
||||
SDynamicSlicingStack* pDynamicSlicingStack); // 2010.8.17
|
||||
|
||||
typedef bool_t (*PInterMdBackgroundDecisionFunc) ( void* pEncCtx, void* pWelsMd, SSlice *slice, SMB* pCurMb, SMbCache *pMbCache, BOOL_T* pKeepPskip );
|
||||
typedef void (*PInterMdBackgroundInfoUpdateFunc) ( SDqLayer* pCurLayer, SMB* pCurMb, const bool_t bFlag, const int32_t kiRefPictureType );
|
||||
typedef bool_t (*PInterMdBackgroundDecisionFunc) (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb,
|
||||
SMbCache* pMbCache, BOOL_T* pKeepPskip);
|
||||
typedef void (*PInterMdBackgroundInfoUpdateFunc) (SDqLayer* pCurLayer, SMB* pCurMb, const bool_t bFlag,
|
||||
const int32_t kiRefPictureType);
|
||||
|
||||
typedef void (*PInterMdFunc) (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache);
|
||||
|
||||
typedef int32_t (*PSampleSadSatdCostFunc) (uint8_t*, int32_t, uint8_t*, int32_t);
|
||||
typedef void (*PSample4SadCostFunc) (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*);
|
||||
typedef int32_t (*PIntraPred4x4Combined3Func)(uint8_t *, int32_t, uint8_t *, int32_t, uint8_t *, int32_t *, int32_t, int32_t, int32_t);
|
||||
typedef int32_t (*PIntraPred4x4Combined3Func) (uint8_t*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t*, int32_t,
|
||||
int32_t, int32_t);
|
||||
typedef int32_t (*PIntraPred16x16Combined3Func) (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*);
|
||||
typedef int32_t (*PIntraPred8x8Combined3Func)(uint8_t *, int32_t, uint8_t *, int32_t, int32_t*, int32_t, uint8_t*,uint8_t*,uint8_t*);
|
||||
typedef int32_t (*PIntraPred8x8Combined3Func) (uint8_t*, int32_t, uint8_t*, int32_t, int32_t*, int32_t, uint8_t*,
|
||||
uint8_t*, uint8_t*);
|
||||
#define MAX_BLOCK_TYPE 5 // prev 7
|
||||
typedef struct TagSampleDealingFunc {
|
||||
PSampleSadSatdCostFunc pfSampleSad[MAX_BLOCK_TYPE];
|
||||
@ -146,10 +157,10 @@ typedef int32_t (*PGetVarianceFromIntraVaaFunc)( uint8_t *pSampelY, const int32_
|
||||
typedef uint8_t (*PGetMbSignFromInterVaaFunc) (int32_t* pSad8x8);
|
||||
typedef void (*PUpdateMbMvFunc) (SMVUnitXY* pMvUnit, const SMVUnitXY ksMv);
|
||||
|
||||
struct TagWelsFuncPointerList
|
||||
{
|
||||
struct TagWelsFuncPointerList {
|
||||
PExpandPictureFunc pfExpandLumaPicture;
|
||||
PExpandPictureFunc pfExpandChromaPicture[2];// 0: for chroma unalignment && width_uv >= 16; 1: for chroma alignment && width_uv >= 16;
|
||||
PExpandPictureFunc
|
||||
pfExpandChromaPicture[2];// 0: for chroma unalignment && width_uv >= 16; 1: for chroma alignment && width_uv >= 16;
|
||||
|
||||
PFillInterNeighborCacheFunc pfFillInterNeighborCache;
|
||||
|
||||
@ -157,7 +168,8 @@ struct TagWelsFuncPointerList
|
||||
PGetMbSignFromInterVaaFunc pfGetMbSignFromInterVaa;
|
||||
PUpdateMbMvFunc pfUpdateMbMv;
|
||||
PInterMdFirstIntraModeFunc pfFirstIntraMode; //svc_encode_slice.c svc_mode_decision.c svc_base_layer_md.c
|
||||
PIntraFineMdFunc pfIntraFineMd; //svc_encode_slice.c svc_mode_decision.c svc_base_layer_md.c
|
||||
PIntraFineMdFunc
|
||||
pfIntraFineMd; //svc_encode_slice.c svc_mode_decision.c svc_base_layer_md.c
|
||||
PInterFineMdFunc pfInterFineMd; //svc_encode_slice.c svc_base_layer_md.c
|
||||
PInterMdFunc pfInterMd;
|
||||
|
||||
@ -169,7 +181,8 @@ struct TagWelsFuncPointerList
|
||||
PGetIntraPredFunc pfGetLumaI16x16Pred[I16_PRED_DC_A];
|
||||
PGetIntraPredFunc pfGetLumaI4x4Pred[I4_PRED_A];
|
||||
PGetIntraPredFunc pfGetChromaPred[C_PRED_A];
|
||||
PMotionSearchFunc pfMotionSearch; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c
|
||||
PMotionSearchFunc
|
||||
pfMotionSearch; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c
|
||||
|
||||
PCopyFunc pfCopy16x16Aligned; //svc_encode_slice.c svc_mode_decision.c svc_base_layer_md.c
|
||||
PCopyFunc pfCopy16x16NotAligned; //md.c
|
||||
|
@ -52,15 +52,13 @@
|
||||
|
||||
namespace WelsSVCEnc {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
SPicture* pScaledInputPicture;
|
||||
int32_t iScaledWidth[MAX_DEPENDENCY_LAYER];
|
||||
int32_t iScaledHeight[MAX_DEPENDENCY_LAYER];
|
||||
} Scaled_Picture;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
SVAACalcResult sVaaCalcInfo;
|
||||
SAdaptiveQuantizationParam sAdaptiveQuantParam;
|
||||
SComplexityAnalysisParam sComplexityAnalysisParam;
|
||||
@ -85,8 +83,7 @@ typedef struct
|
||||
bool_t bIdrPeriodFlag;
|
||||
} SVAAFrameInfo;
|
||||
|
||||
class CWelsLib
|
||||
{
|
||||
class CWelsLib {
|
||||
public:
|
||||
CWelsLib (void* pEncCtx);
|
||||
virtual ~CWelsLib();
|
||||
@ -102,8 +99,7 @@ private:
|
||||
void* m_pInterface[2];
|
||||
};
|
||||
|
||||
class CWelsPreProcess
|
||||
{
|
||||
class CWelsPreProcess {
|
||||
public:
|
||||
CWelsPreProcess (void* pEncCtx);
|
||||
virtual ~CWelsPreProcess();
|
||||
@ -127,16 +123,20 @@ private:
|
||||
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);
|
||||
|
||||
void VaaCalculation( SVAAFrameInfo *pVaaInfo, SPicture *pCurPicture, SPicture *pRefPicture, bool_t bCalculateSQDiff, bool_t bCalculateVar, bool_t bCalculateBGD );
|
||||
void VaaCalculation (SVAAFrameInfo* pVaaInfo, SPicture* pCurPicture, SPicture* pRefPicture, bool_t bCalculateSQDiff,
|
||||
bool_t bCalculateVar, bool_t bCalculateBGD);
|
||||
void BackgroundDetection (SVAAFrameInfo* pVaaInfo, SPicture* pCurPicture, SPicture* pRefPicture, bool_t bDetectFlag);
|
||||
void AdaptiveQuantCalculation (SVAAFrameInfo* pVaaInfo, SPicture* pCurPicture, SPicture* pRefPicture);
|
||||
void AnalyzePictureComplexity( void *pCtx, SPicture *pCurPicture, SPicture *pRefPicture, const int32_t kiDependencyId, const bool_t kbCalculateBGD );
|
||||
void AnalyzePictureComplexity (void* pCtx, SPicture* pCurPicture, SPicture* pRefPicture,
|
||||
const int32_t kiDependencyId, const bool_t kbCalculateBGD);
|
||||
void Padding (uint8_t* pSrcY, uint8_t* pSrcU, uint8_t* pSrcV, int32_t iStrideY, int32_t iStrideUV,
|
||||
int32_t iActualWidth, int32_t iPaddingWidth, int32_t iActualHeight, int32_t iPaddingHeight);
|
||||
void SetRefMbType (void* pCtx, uint32_t** pRefMbTypeArray, int32_t iRefPicType);
|
||||
|
||||
int32_t ColorspaceConvert( SWelsSvcCodingParam *pSvcParam, SPicture *pDstPic, const SSourcePicture *kpSrc, const int32_t kiWidth, const int32_t kiHeight );
|
||||
void WelsMoveMemoryWrapper(SWelsSvcCodingParam * pSvcParam, SPicture *pDstPic, const SSourcePicture *kpSrc, const int32_t kiWidth, const int32_t kiHeight );
|
||||
int32_t ColorspaceConvert (SWelsSvcCodingParam* pSvcParam, SPicture* pDstPic, const SSourcePicture* kpSrc,
|
||||
const int32_t kiWidth, const int32_t kiHeight);
|
||||
void WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SPicture* pDstPic, const SSourcePicture* kpSrc,
|
||||
const int32_t kiWidth, const int32_t kiHeight);
|
||||
|
||||
private:
|
||||
Scaled_Picture m_sScaledPicture;
|
||||
|
@ -43,8 +43,7 @@
|
||||
#include "au_set.h"
|
||||
#include "svc_enc_golomb.h"
|
||||
namespace WelsSVCEnc {
|
||||
static const uint32_t g_kuiMaxDPBx2AtLevel[52] = // *2 on the basic of Annex A, Table A-1, for int32_t type
|
||||
{
|
||||
static const uint32_t g_kuiMaxDPBx2AtLevel[52] = { // *2 on the basic of Annex A, Table A-1, for int32_t type
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0~9
|
||||
297, 675, 1782, 1782, 0, 0, 0, 0, 0, 0, //10, 11, 12, 13
|
||||
1782, 3564, 6075, 0, 0, 0, 0, 0, 0, 0, //20, 21, 22
|
||||
@ -56,8 +55,7 @@ static const uint32_t g_kuiMaxDPBx2AtLevel[52] = // *2 on the basic of Annex A,
|
||||
|
||||
#define LEVEL_NUMBER 16
|
||||
|
||||
typedef struct TagLevelLimit
|
||||
{
|
||||
typedef struct TagLevelLimit {
|
||||
uint8_t iLevelIdc;
|
||||
uint32_t uiMaxMbPS; // Max MBs processing speed
|
||||
uint32_t uiMaxFS; // Max Frame size
|
||||
@ -65,8 +63,7 @@ typedef struct TagLevelLimit
|
||||
uint32_t uiMaxBR; //Max Bitrate
|
||||
} SLevelLimit;
|
||||
|
||||
const SLevelLimit g_ksLevelLimit[LEVEL_NUMBER] =
|
||||
{
|
||||
const SLevelLimit g_ksLevelLimit[LEVEL_NUMBER] = {
|
||||
{ 10, 1485, 99, 396, 64 }, //10
|
||||
{ 9, 1485, 99, 396, 128 }, //9 (1b)
|
||||
{ 11, 3000, 396, 900, 192 }, //11
|
||||
@ -89,8 +86,8 @@ const SLevelLimit g_ksLevelLimit[LEVEL_NUMBER] =
|
||||
{ 51, 983040, 36864, 184320, 240000 } //51
|
||||
};
|
||||
|
||||
static inline int32_t WelsCheckLevelLimitation( const SWelsSPS* kpSps, const SLevelLimit *kpLevelLimit, float fFrameRate, int32_t iTargetBitRate )
|
||||
{
|
||||
static inline int32_t WelsCheckLevelLimitation (const SWelsSPS* kpSps, const SLevelLimit* kpLevelLimit,
|
||||
float fFrameRate, int32_t iTargetBitRate) {
|
||||
uint32_t uiPicWidthInMBs = kpSps->iMbWidth;
|
||||
uint32_t uiPicHeightInMBs = kpSps->iMbHeight;
|
||||
uint32_t uiPicInMBs = uiPicWidthInMBs * uiPicHeightInMBs;
|
||||
@ -106,7 +103,8 @@ static inline int32_t WelsCheckLevelLimitation( const SWelsSPS* kpSps, const SLe
|
||||
return 0;
|
||||
if (kpLevelLimit->uiMaxDPBMB < uiNumRefFrames * uiPicInMBs)
|
||||
return 0;
|
||||
if( iTargetBitRate && ( (int32_t) kpLevelLimit->uiMaxBR * 1200 ) < iTargetBitRate ) //RC enabled, considering bitrate constraint
|
||||
if (iTargetBitRate
|
||||
&& ((int32_t) kpLevelLimit->uiMaxBR * 1200) < iTargetBitRate) //RC enabled, considering bitrate constraint
|
||||
return 0;
|
||||
//add more checks here if needed in future
|
||||
|
||||
@ -114,13 +112,10 @@ static inline int32_t WelsCheckLevelLimitation( const SWelsSPS* kpSps, const SLe
|
||||
|
||||
}
|
||||
|
||||
static inline int32_t WelsGetLevelIdc( const SWelsSPS* kpSps, float fFrameRate, int32_t iTargetBitRate )
|
||||
{
|
||||
static inline int32_t WelsGetLevelIdc (const SWelsSPS* kpSps, float fFrameRate, int32_t iTargetBitRate) {
|
||||
int32_t iOrder;
|
||||
for( iOrder = 0; iOrder < LEVEL_NUMBER; iOrder++ )
|
||||
{
|
||||
if( WelsCheckLevelLimitation(kpSps, &(g_ksLevelLimit[iOrder]), fFrameRate, iTargetBitRate) )
|
||||
{
|
||||
for (iOrder = 0; iOrder < LEVEL_NUMBER; iOrder++) {
|
||||
if (WelsCheckLevelLimitation (kpSps, & (g_ksLevelLimit[iOrder]), fFrameRate, iTargetBitRate)) {
|
||||
return (int32_t) (g_ksLevelLimit[iOrder].iLevelIdc);
|
||||
}
|
||||
}
|
||||
@ -141,8 +136,7 @@ static inline int32_t WelsGetLevelIdc( const SWelsSPS* kpSps, float fFrameRate,
|
||||
* \note Call it in case EWelsNalUnitType is SPS.
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t WelsWriteSpsSyntax( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_t* pSpsIdDelta )
|
||||
{
|
||||
int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta) {
|
||||
SBitStringAux* pLocalBitStringAux = pBitStringAux;
|
||||
|
||||
assert (pSps != NULL && pBitStringAux != NULL);
|
||||
@ -160,8 +154,7 @@ int32_t WelsWriteSpsSyntax( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_
|
||||
if (PRO_SCALABLE_BASELINE == pSps->uiProfileIdc || PRO_SCALABLE_HIGH == pSps->uiProfileIdc ||
|
||||
PRO_HIGH == pSps->uiProfileIdc || PRO_HIGH10 == pSps->uiProfileIdc ||
|
||||
PRO_HIGH422 == pSps->uiProfileIdc || PRO_HIGH444 == pSps->uiProfileIdc ||
|
||||
PRO_CAVLC444 == pSps->uiProfileIdc || 44 == pSps->uiProfileIdc )
|
||||
{
|
||||
PRO_CAVLC444 == pSps->uiProfileIdc || 44 == pSps->uiProfileIdc) {
|
||||
BsWriteUE (pLocalBitStringAux, 1); //uiChromaFormatIdc, now should be 1
|
||||
BsWriteUE (pLocalBitStringAux, 0); //uiBitDepthLuma
|
||||
BsWriteUE (pLocalBitStringAux, 0); //uiBitDepthChroma
|
||||
@ -181,8 +174,7 @@ int32_t WelsWriteSpsSyntax( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_
|
||||
|
||||
BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bDirect8x8InferenceFlag*/); // direct_8x8_inference_flag
|
||||
BsWriteOneBit (pLocalBitStringAux, pSps->bFrameCroppingFlag); // bFrameCroppingFlag
|
||||
if ( pSps->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
|
||||
@ -195,8 +187,7 @@ int32_t WelsWriteSpsSyntax( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_
|
||||
}
|
||||
|
||||
|
||||
int32_t WelsWriteSpsNal( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_t* pSpsIdDelta)
|
||||
{
|
||||
int32_t WelsWriteSpsNal (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta) {
|
||||
WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta);
|
||||
|
||||
BsRbspTrailingBits (pBitStringAux);
|
||||
@ -220,8 +211,7 @@ int32_t WelsWriteSpsNal( SWelsSPS *pSps, SBitStringAux *pBitStringAux, int32_t*
|
||||
*************************************************************************************
|
||||
*/
|
||||
|
||||
int32_t WelsWriteSubsetSpsSyntax( SSubsetSps *pSubsetSps, SBitStringAux *pBitStringAux , int32_t* pSpsIdDelta )
|
||||
{
|
||||
int32_t WelsWriteSubsetSpsSyntax (SSubsetSps* pSubsetSps, SBitStringAux* pBitStringAux , int32_t* pSpsIdDelta) {
|
||||
SWelsSPS* pSps = &pSubsetSps->pSps;
|
||||
|
||||
WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta);
|
||||
@ -271,22 +261,24 @@ int32_t WelsWriteSubsetSpsSyntax( SSubsetSps *pSubsetSps, SBitStringAux *pBitStr
|
||||
* \note Call it in case EWelsNalUnitType is PPS.
|
||||
*************************************************************************************
|
||||
*/
|
||||
int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaSetOffset* sPSOVector )
|
||||
{
|
||||
int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaSetOffset* sPSOVector) {
|
||||
SBitStringAux* pLocalBitStringAux = pBitStringAux;
|
||||
|
||||
bool_t bUsedSubset = sPSOVector->bPpsIdMappingIntoSubsetsps[pPps->iPpsId];
|
||||
int32_t iParameterSetType = (bUsedSubset ? PARA_SET_TYPE_SUBSETSPS : PARA_SET_TYPE_AVCSPS);
|
||||
|
||||
BsWriteUE( pLocalBitStringAux, pPps->iPpsId + sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId] );
|
||||
BsWriteUE( pLocalBitStringAux, pPps->iSpsId + sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId] );
|
||||
BsWriteUE (pLocalBitStringAux, pPps->iPpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId]);
|
||||
BsWriteUE (pLocalBitStringAux, pPps->iSpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId]);
|
||||
|
||||
#if _DEBUG
|
||||
//SParaSetOffset use, 110421
|
||||
if ( sPSOVector->bEnableSpsPpsIdAddition )
|
||||
{
|
||||
const int32_t kiTmpSpsIdInBs = pPps->iSpsId + sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId];
|
||||
const int32_t tmp_pps_id_in_bs = pPps->iPpsId + sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId];
|
||||
if (sPSOVector->bEnableSpsPpsIdAddition) {
|
||||
const int32_t kiTmpSpsIdInBs = pPps->iSpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId];
|
||||
const int32_t tmp_pps_id_in_bs = pPps->iPpsId +
|
||||
sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId];
|
||||
assert (MAX_SPS_COUNT > kiTmpSpsIdInBs);
|
||||
assert (MAX_PPS_COUNT > tmp_pps_id_in_bs);
|
||||
assert (sPSOVector->sParaSetOffsetVariable[iParameterSetType].bUsedParaSetIdInBs[kiTmpSpsIdInBs]);
|
||||
@ -300,23 +292,19 @@ int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaS
|
||||
BsWriteUE (pLocalBitStringAux, 0/*pPps->uiNumSliceGroups - 1*/);
|
||||
#else
|
||||
BsWriteUE (pLocalBitStringAux, pPps->uiNumSliceGroups - 1);
|
||||
if ( pPps->uiNumSliceGroups > 1 )
|
||||
{
|
||||
if (pPps->uiNumSliceGroups > 1) {
|
||||
uint32_t i, uiNumBits;
|
||||
|
||||
BsWriteUE (pLocalBitStringAux, pPps->uiSliceGroupMapType);
|
||||
|
||||
switch ( pPps->uiSliceGroupMapType )
|
||||
{
|
||||
switch (pPps->uiSliceGroupMapType) {
|
||||
case 0:
|
||||
for ( i = 0; i < pPps->uiNumSliceGroups; i ++ )
|
||||
{
|
||||
for (i = 0; i < pPps->uiNumSliceGroups; i ++) {
|
||||
BsWriteUE (pLocalBitStringAux, pPps->uiRunLength[i] - 1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for ( i = 0; i < pPps->uiNumSliceGroups; i ++ )
|
||||
{
|
||||
for (i = 0; i < pPps->uiNumSliceGroups; i ++) {
|
||||
BsWriteUE (pLocalBitStringAux, pPps->uiTopLeft[i]);
|
||||
BsWriteUE (pLocalBitStringAux, pPps->uiBottomRight[i]);
|
||||
}
|
||||
@ -330,8 +318,7 @@ int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaS
|
||||
case 6:
|
||||
BsWriteUE (pLocalBitStringAux, pPps->uiPicSizeInMapUnits - 1);
|
||||
uiNumBits = 0;///////////////////WELS_CEILLOG2(pPps->uiPicSizeInMapUnits);
|
||||
for ( i = 0; i < pPps->uiPicSizeInMapUnits; i ++ )
|
||||
{
|
||||
for (i = 0; i < pPps->uiPicSizeInMapUnits; i ++) {
|
||||
BsWriteBits (pLocalBitStringAux, uiNumBits, pPps->uiSliceGroupId[i]);
|
||||
}
|
||||
break;
|
||||
@ -363,8 +350,8 @@ int32_t WelsWritePpsSyntax( SWelsPPS *pPps, SBitStringAux *pBitStringAux, SParaS
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool_t WelsGetPaddingOffset(int32_t iActualWidth, int32_t iActualHeight, int32_t iWidth, int32_t iHeight, SCropOffset &pOffset)
|
||||
{
|
||||
static inline bool_t WelsGetPaddingOffset (int32_t iActualWidth, int32_t iActualHeight, int32_t iWidth,
|
||||
int32_t iHeight, SCropOffset& pOffset) {
|
||||
if ((iWidth < iActualWidth) || (iHeight < iActualHeight))
|
||||
return false;
|
||||
|
||||
@ -380,22 +367,19 @@ static inline bool_t WelsGetPaddingOffset(int32_t iActualWidth, int32_t iActualH
|
||||
return (iWidth > iActualWidth) || (iHeight > iActualHeight);
|
||||
}
|
||||
|
||||
int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
const uint32_t kuiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc )
|
||||
{
|
||||
int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
|
||||
const int32_t kiNumRefFrame,
|
||||
const uint32_t kuiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc) {
|
||||
memset (pSps, 0, sizeof (SWelsSPS));
|
||||
|
||||
pSps->uiSpsId = kuiSpsId;
|
||||
pSps->iMbWidth = (pLayerParam->iFrameWidth + 15) >> 4;
|
||||
pSps->iMbHeight = (pLayerParam->iFrameHeight + 15) >> 4;
|
||||
|
||||
if ( 0 == kuiIntraPeriod )
|
||||
{
|
||||
if (0 == kuiIntraPeriod) {
|
||||
//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;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pSps->uiLog2MaxFrameNum = 4;
|
||||
while ((uint32_t) (1 << pSps->uiLog2MaxFrameNum) <= kuiIntraPeriod) {
|
||||
++ pSps->uiLog2MaxFrameNum;
|
||||
@ -405,13 +389,11 @@ int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t k
|
||||
|
||||
pSps->iNumRefFrames = kiNumRefFrame; /* min pRef size when fifo pRef operation*/
|
||||
|
||||
if ( kbEnableFrameCropping )
|
||||
{
|
||||
if (kbEnableFrameCropping) {
|
||||
// TODO: get frame_crop_left_offset, frame_crop_right_offset, frame_crop_top_offset, frame_crop_bottom_offset
|
||||
pSps->bFrameCroppingFlag = WelsGetPaddingOffset( pLayerParam->iActualWidth, pLayerParam->iActualHeight, pLayerParam->iFrameWidth, pLayerParam->iFrameHeight, pSps->sFrameCrop );
|
||||
}
|
||||
else
|
||||
{
|
||||
pSps->bFrameCroppingFlag = WelsGetPaddingOffset (pLayerParam->iActualWidth, pLayerParam->iActualHeight,
|
||||
pLayerParam->iFrameWidth, pLayerParam->iFrameHeight, pSps->sFrameCrop);
|
||||
} else {
|
||||
pSps->bFrameCroppingFlag = false;
|
||||
}
|
||||
|
||||
@ -420,22 +402,24 @@ int32_t WelsInitSps( SWelsSPS *pSps, SDLayerParam *pLayerParam, const uint32_t k
|
||||
if (bEnableRc) //fixed QP condition
|
||||
pSps->iLevelIdc = WelsGetLevelIdc (pSps, pLayerParam->fOutputFrameRate, pLayerParam->iSpatialBitrate);
|
||||
else
|
||||
pSps->iLevelIdc = WelsGetLevelIdc(pSps, pLayerParam->fOutputFrameRate, 0); // Set tar_br = 0 to remove the bitrate constraint; a better way is to set actual tar_br as 0
|
||||
pSps->iLevelIdc = WelsGetLevelIdc (pSps, pLayerParam->fOutputFrameRate,
|
||||
0); // Set tar_br = 0 to remove the bitrate constraint; a better way is to set actual tar_br as 0
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t WelsInitSubsetSps( SSubsetSps *pSubsetSps, SDLayerParam *pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
|
||||
const uint32_t kuiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc )
|
||||
{
|
||||
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
|
||||
const int32_t kiNumRefFrame,
|
||||
const uint32_t kuiSpsId, const bool_t kbEnableFrameCropping, bool_t bEnableRc) {
|
||||
SWelsSPS* pSps = &pSubsetSps->pSps;
|
||||
|
||||
memset (pSubsetSps, 0, sizeof (SSubsetSps));
|
||||
|
||||
WelsInitSps (pSps, pLayerParam, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping, bEnableRc);
|
||||
|
||||
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc : PRO_SCALABLE_BASELINE;
|
||||
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;
|
||||
@ -450,8 +434,7 @@ int32_t WelsInitPps( SWelsPPS *pPps,
|
||||
SSubsetSps* pSubsetSps,
|
||||
const uint32_t kuiPpsId,
|
||||
const bool_t kbDeblockingFilterPresentFlag,
|
||||
const bool_t kbUsingSubsetSps )
|
||||
{
|
||||
const bool_t kbUsingSubsetSps) {
|
||||
SWelsSPS* pUsedSps = NULL;
|
||||
if (pPps == NULL || (pSps == NULL && pSubsetSps == NULL))
|
||||
return 1;
|
||||
@ -460,8 +443,7 @@ int32_t WelsInitPps( SWelsPPS *pPps,
|
||||
if (NULL == pSps)
|
||||
return 1;
|
||||
pUsedSps = pSps;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
assert (pSubsetSps != NULL);
|
||||
if (NULL == pSubsetSps)
|
||||
return 1;
|
||||
@ -473,30 +455,22 @@ int32_t WelsInitPps( SWelsPPS *pPps,
|
||||
pPps->iSpsId = pUsedSps->uiSpsId;
|
||||
#if !defined(DISABLE_FMO_FEATURE)
|
||||
pPps->uiNumSliceGroups = 1; //param->qos_param.sliceGroupCount;
|
||||
if( pPps->uiNumSliceGroups > 1 )
|
||||
{
|
||||
if (pPps->uiNumSliceGroups > 1) {
|
||||
pPps->uiSliceGroupMapType = 0; //param->qos_param.sliceGroupType;
|
||||
if( pPps->uiSliceGroupMapType == 0 )
|
||||
{
|
||||
if (pPps->uiSliceGroupMapType == 0) {
|
||||
uint32_t uiGroup = 0;
|
||||
while (uiGroup < pPps->uiNumSliceGroups) {
|
||||
pPps->uiRunLength[uiGroup] = 25;
|
||||
++ uiGroup;
|
||||
}
|
||||
}
|
||||
else if( pPps->uiSliceGroupMapType == 2 )
|
||||
{
|
||||
} else if (pPps->uiSliceGroupMapType == 2) {
|
||||
memset (&pPps->uiTopLeft[0], 0, MAX_SLICEGROUP_IDS * sizeof (pPps->uiTopLeft[0]));
|
||||
memset (&pPps->uiBottomRight[0], 0, MAX_SLICEGROUP_IDS * sizeof (pPps->uiBottomRight[0]));
|
||||
}
|
||||
else if( pPps->uiSliceGroupMapType >= 3 &&
|
||||
pPps->uiSliceGroupMapType <= 5 )
|
||||
{
|
||||
} else if (pPps->uiSliceGroupMapType >= 3 &&
|
||||
pPps->uiSliceGroupMapType <= 5) {
|
||||
pPps->bSliceGroupChangeDirectionFlag = false;
|
||||
pPps->uiSliceGroupChangeRate = 0;
|
||||
}
|
||||
else if( pPps->uiSliceGroupMapType == 6 )
|
||||
{
|
||||
} else if (pPps->uiSliceGroupMapType == 6) {
|
||||
pPps->uiPicSizeInMapUnits = 1;
|
||||
memset (&pPps->uiSliceGroupId[0], 0, MAX_SLICEGROUP_IDS * sizeof (pPps->uiSliceGroupId[0]));
|
||||
}
|
||||
|
@ -52,58 +52,48 @@ namespace WelsSVCEnc {
|
||||
|
||||
#if defined(X86_ASM)
|
||||
|
||||
uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
{
|
||||
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||
uint32_t uiCPU = 0;
|
||||
uint32_t uiFeatureA = 0, uiFeatureB = 0, uiFeatureC = 0, uiFeatureD = 0;
|
||||
int32_t CacheLineSize = 0;
|
||||
int8_t chVenderName[16] = { 0 };
|
||||
|
||||
if( !WelsCPUIdVerify() )
|
||||
{
|
||||
if (!WelsCPUIdVerify()) {
|
||||
/* cpuid is not supported in cpu */
|
||||
return 0;
|
||||
}
|
||||
|
||||
WelsCPUId (0, &uiFeatureA, (uint32_t*)&chVenderName[0], (uint32_t*)&chVenderName[8], (uint32_t*)&chVenderName[4]);
|
||||
if( uiFeatureA == 0 )
|
||||
{
|
||||
if (uiFeatureA == 0) {
|
||||
/* maximum input value for basic cpuid information */
|
||||
return 0;
|
||||
}
|
||||
|
||||
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
if( (uiFeatureD & 0x00800000) == 0 )
|
||||
{
|
||||
if ((uiFeatureD & 0x00800000) == 0) {
|
||||
/* Basic MMX technology is not support in cpu, mean nothing for us so return here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
uiCPU = WELS_CPU_MMX;
|
||||
if( uiFeatureD & 0x02000000 )
|
||||
{
|
||||
if (uiFeatureD & 0x02000000) {
|
||||
/* SSE technology is identical to AMD MMX extensions */
|
||||
uiCPU |= WELS_CPU_MMXEXT | WELS_CPU_SSE;
|
||||
}
|
||||
if( uiFeatureD & 0x04000000 )
|
||||
{
|
||||
if (uiFeatureD & 0x04000000) {
|
||||
/* SSE2 support here */
|
||||
uiCPU |= WELS_CPU_SSE2;
|
||||
}
|
||||
if ( uiFeatureD & 0x00000001 )
|
||||
{
|
||||
if (uiFeatureD & 0x00000001) {
|
||||
/* x87 FPU on-chip checking */
|
||||
uiCPU |= WELS_CPU_FPU;
|
||||
}
|
||||
if ( uiFeatureD & 0x00008000 )
|
||||
{
|
||||
if (uiFeatureD & 0x00008000) {
|
||||
/* CMOV instruction checking */
|
||||
uiCPU |= WELS_CPU_CMOV;
|
||||
}
|
||||
if ( !strcmp((const str_t*)chVenderName,CPU_Vender_INTEL) ) // confirmed_safe_unsafe_usage
|
||||
{
|
||||
if ( uiFeatureD & 0x10000000 )
|
||||
{
|
||||
if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
|
||||
if (uiFeatureD & 0x10000000) {
|
||||
/* Multi-Threading checking: contains of multiple logic processors */
|
||||
uiCPU |= WELS_CPU_HTT;
|
||||
}
|
||||
@ -125,36 +115,32 @@ uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
/* SSE4.2 support here, next generation Nehalem processor */
|
||||
uiCPU |= WELS_CPU_SSE42;
|
||||
}
|
||||
if ( WelsCPUSupportAVX( uiFeatureA, uiFeatureC ) ) //
|
||||
{
|
||||
if (WelsCPUSupportAVX (uiFeatureA, uiFeatureC)) { //
|
||||
/* AVX supported */
|
||||
uiCPU |= WELS_CPU_AVX;
|
||||
}
|
||||
if ( WelsCPUSupportFMA( uiFeatureA, uiFeatureC ) ) //
|
||||
{
|
||||
if (WelsCPUSupportFMA (uiFeatureA, uiFeatureC)) { //
|
||||
/* AVX FMA supported */
|
||||
uiCPU |= WELS_CPU_FMA;
|
||||
}
|
||||
if ( uiFeatureC & 0x02000000 )
|
||||
{
|
||||
if (uiFeatureC & 0x02000000) {
|
||||
/* AES checking */
|
||||
uiCPU |= WELS_CPU_AES;
|
||||
}
|
||||
if ( uiFeatureC & 0x00400000 )
|
||||
{
|
||||
if (uiFeatureC & 0x00400000) {
|
||||
/* MOVBE checking */
|
||||
uiCPU |= WELS_CPU_MOVBE;
|
||||
}
|
||||
|
||||
if ( pNumberOfLogicProcessors != NULL )
|
||||
{
|
||||
if (pNumberOfLogicProcessors != NULL) {
|
||||
// HTT enabled on chip
|
||||
*pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
|
||||
}
|
||||
|
||||
WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
|
||||
if( (!strcmp((const str_t*)chVenderName,CPU_Vender_AMD)) && (uiFeatureA>=0x80000001) ){ // confirmed_safe_unsafe_usage
|
||||
if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_AMD))
|
||||
&& (uiFeatureA >= 0x80000001)) { // confirmed_safe_unsafe_usage
|
||||
WelsCPUId (0x80000001, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
if (uiFeatureD & 0x00400000) {
|
||||
uiCPU |= WELS_CPU_MMXEXT;
|
||||
@ -177,21 +163,20 @@ uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
}
|
||||
|
||||
// get cache line size
|
||||
if( (!strcmp((const str_t*)chVenderName,CPU_Vender_INTEL)) || !(strcmp((const str_t*)chVenderName,CPU_Vender_CYRIX)) ){ // confirmed_safe_unsafe_usage
|
||||
if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL))
|
||||
|| ! (strcmp ((const str_t*)chVenderName, CPU_Vender_CYRIX))) { // confirmed_safe_unsafe_usage
|
||||
WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
|
||||
CacheLineSize = (uiFeatureB&0xff00)>>5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
|
||||
CacheLineSize = (uiFeatureB & 0xff00) >>
|
||||
5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
|
||||
|
||||
if (CacheLineSize == 128) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_128;
|
||||
}
|
||||
else if( CacheLineSize == 64 ){
|
||||
} else if (CacheLineSize == 64) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_64;
|
||||
}
|
||||
else if( CacheLineSize == 32 ){
|
||||
} else if (CacheLineSize == 32) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_32;
|
||||
}
|
||||
else if( CacheLineSize == 16 ){
|
||||
} else if (CacheLineSize == 16) {
|
||||
uiCPU |= WELS_CPU_CACHELINE_16;
|
||||
}
|
||||
}
|
||||
@ -200,10 +185,8 @@ uint32_t WelsCPUFeatureDetect( int32_t *pNumberOfLogicProcessors )
|
||||
}
|
||||
|
||||
|
||||
void WelsCPURestore( const uint32_t kuiCPU )
|
||||
{
|
||||
if( kuiCPU & (WELS_CPU_MMX|WELS_CPU_MMXEXT|WELS_CPU_3DNOW|WELS_CPU_3DNOWEXT) )
|
||||
{
|
||||
void WelsCPURestore (const uint32_t kuiCPU) {
|
||||
if (kuiCPU & (WELS_CPU_MMX | WELS_CPU_MMXEXT | WELS_CPU_3DNOW | WELS_CPU_3DNOWEXT)) {
|
||||
WelsEmms();
|
||||
}
|
||||
}
|
||||
|
@ -105,38 +105,47 @@ static const int8_t g_kiTc0Table[52+12][4] = { //this table refers Table 8-17 in
|
||||
, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }
|
||||
};
|
||||
|
||||
static const uint8_t g_kuiTableBIdx[2][8] =
|
||||
static const uint8_t g_kuiTableBIdx[2][8] = {
|
||||
{
|
||||
{0, 4, 8, 12, // g_kuiTableBIdx
|
||||
3, 7, 11, 15}, // table_bn_idx
|
||||
0, 4, 8, 12, // g_kuiTableBIdx
|
||||
3, 7, 11, 15
|
||||
}, // table_bn_idx
|
||||
|
||||
{0, 1, 2, 3 , // g_kuiTableBIdx
|
||||
12, 13, 14, 15}, // table_bn_idx
|
||||
{
|
||||
0, 1, 2, 3 , // g_kuiTableBIdx
|
||||
12, 13, 14, 15
|
||||
}, // table_bn_idx
|
||||
};
|
||||
|
||||
static const ALIGNED_DECLARE(int32_t,g_kiTableBlock8x8Idx[2][4][4],16) =
|
||||
static const ALIGNED_DECLARE (int32_t, g_kiTableBlock8x8Idx[2][4][4], 16) = {
|
||||
{
|
||||
{0, 0, 2, 2,
|
||||
0, 0, 2, 2,
|
||||
0, 0, 2, 2,
|
||||
1, 1, 3, 3,
|
||||
1, 1, 3, 3},
|
||||
1, 1, 3, 3
|
||||
},
|
||||
|
||||
{0, 0, 1, 1,
|
||||
{
|
||||
0, 0, 1, 1,
|
||||
0, 0, 1, 1,
|
||||
2, 2, 3, 3,
|
||||
2, 2, 3, 3}
|
||||
2, 2, 3, 3
|
||||
}
|
||||
};
|
||||
static const ALIGNED_DECLARE(int32_t,g_kiTableBlock8x8NIdx[2][4][4],16) =
|
||||
static const ALIGNED_DECLARE (int32_t, g_kiTableBlock8x8NIdx[2][4][4], 16) = {
|
||||
{
|
||||
{1, 1, 3, 3,
|
||||
1, 1, 3, 3,
|
||||
0, 0, 2, 2,
|
||||
0, 0, 2, 2,
|
||||
1, 1, 3, 3},
|
||||
1, 1, 3, 3
|
||||
},
|
||||
|
||||
{2, 2, 3, 3,
|
||||
{
|
||||
2, 2, 3, 3,
|
||||
0, 0, 1, 1,
|
||||
0, 0, 1, 1,
|
||||
2, 2, 3, 3}
|
||||
2, 2, 3, 3
|
||||
}
|
||||
};
|
||||
|
||||
#define TC0_TBL_LOOKUP(iTc, iIdexA, pBS, bchroma) \
|
||||
@ -147,8 +156,7 @@ static const ALIGNED_DECLARE(int32_t,g_kiTableBlock8x8NIdx[2][4][4],16) =
|
||||
iTc[3] = g_kiTc0Table(iIdexA)[pBS[3]] + bchroma;\
|
||||
}
|
||||
|
||||
void inline DeblockingBSInsideMBAvsbase( int8_t* pNnzTab, uint8_t uiBS[2][4][4], int32_t iLShiftFactor )
|
||||
{
|
||||
void inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t uiBS[2][4][4], int32_t iLShiftFactor) {
|
||||
uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx3, 4, 4);
|
||||
|
||||
@ -182,8 +190,7 @@ void inline DeblockingBSInsideMBAvsbase( int8_t* pNnzTab, uint8_t uiBS[2][4][4],
|
||||
|
||||
}
|
||||
|
||||
void inline DeblockingBSInsideMBNormal( SMB* pCurMb, uint8_t uiBS[2][4][4], int8_t* pNnzTab )
|
||||
{
|
||||
void inline DeblockingBSInsideMBNormal (SMB* pCurMb, uint8_t uiBS[2][4][4], int8_t* pNnzTab) {
|
||||
uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4);
|
||||
|
||||
@ -232,22 +239,17 @@ void inline DeblockingBSInsideMBNormal( SMB* pCurMb, uint8_t uiBS[2][4][4], int8
|
||||
uiBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIdx, pCurMb->sMv, 15, 11);
|
||||
}
|
||||
|
||||
uint32_t DeblockingBSMarginalMBAvcbase( SMB* pCurMb, SMB* pNeighMb, int32_t iEdge)
|
||||
{
|
||||
uint32_t DeblockingBSMarginalMBAvcbase (SMB* pCurMb, SMB* pNeighMb, int32_t iEdge) {
|
||||
int32_t i;
|
||||
uint32_t uiBSx4;
|
||||
uint8_t* pBS = (uint8_t*) (&uiBSx4);
|
||||
uint32_t uiBIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][0]);
|
||||
uint32_t uiBnIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][4]);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
if (pCurMb->pNonZeroCount[uiBIdx&0xff] | pNeighMb->pNonZeroCount[uiBnIdx&0xff])
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (pCurMb->pNonZeroCount[uiBIdx & 0xff] | pNeighMb->pNonZeroCount[uiBnIdx & 0xff]) {
|
||||
pBS[i] = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pBS[i] =
|
||||
#ifndef SINGLE_REF_FRAME
|
||||
(pCurMb->uiRefIndex[g_kiTableBlock8x8Idx[1][iEdge][i]] - pNeighMb->uiRefIndex[g_kiTableBlock8x8NIdx[1][iEdge][i]]) ||
|
||||
@ -260,133 +262,132 @@ uint32_t DeblockingBSMarginalMBAvcbase( SMB* pCurMb, SMB* pNeighMb, int32_t iEdg
|
||||
return uiBSx4;
|
||||
}
|
||||
|
||||
void FilteringEdgeLumaH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeLumaH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 0);
|
||||
pfDeblocking->pfLumaDeblockingLT4Ver (pPix, iStride, iAlpha, iBeta, iTc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void FilteringEdgeLumaV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeLumaV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 0);
|
||||
pfDeblocking->pfLumaDeblockingLT4Hor (pPix, iStride, iAlpha, iBeta, iTc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FilteringEdgeLumaIntraH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeLumaIntraH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pfDeblocking->pfLumaDeblockingEQ4Ver (pPix, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FilteringEdgeLumaIntraV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,uint8_t* pBS)
|
||||
{
|
||||
void FilteringEdgeLumaIntraV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,
|
||||
uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pfDeblocking->pfLumaDeblockingEQ4Hor (pPix, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void FilteringEdgeChromaH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeChromaH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr,
|
||||
int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 1);
|
||||
pfDeblocking->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, iTc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void FilteringEdgeChromaV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeChromaV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr,
|
||||
int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 1);
|
||||
pfDeblocking->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, iTc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FilteringEdgeChromaIntraH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeChromaIntraH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb,
|
||||
uint8_t* pPixCr, int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pfDeblocking->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void FilteringEdgeChromaIntraV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )
|
||||
{
|
||||
void FilteringEdgeChromaIntraV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb,
|
||||
uint8_t* pPixCr, int32_t iStride, uint8_t* pBS) {
|
||||
int32_t iIdexA;
|
||||
int32_t iAlpha;
|
||||
int32_t iBeta;
|
||||
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pfDeblocking->pfChromaDeblockinEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void DeblockingInterMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter, uint8_t uiBS[2][4][4] )
|
||||
{
|
||||
void DeblockingInterMb (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter, uint8_t uiBS[2][4][4]) {
|
||||
int8_t iCurLumaQp = pCurMb->uiLumaQp;
|
||||
int8_t iCurChromaQp = pCurMb->uiChromaQp;
|
||||
int32_t iLineSize = pFilter->iCsStride[0];
|
||||
@ -407,20 +408,15 @@ void DeblockingInterMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFi
|
||||
pDestCb = pFilter->pCsData[1];
|
||||
pDestCr = pFilter->pCsData[2];
|
||||
|
||||
if (iLeftFlag)
|
||||
{
|
||||
if (iLeftFlag) {
|
||||
pFilter->uiLumaQP = (iCurLumaQp + (pCurMb - 1)->uiLumaQp + 1) >> 1;
|
||||
pFilter->uiChromaQP = (iCurChromaQp + (pCurMb - 1)->uiChromaQp + 1) >> 1;
|
||||
|
||||
if( uiBS[0][0][0] == 0x04 )
|
||||
{
|
||||
if (uiBS[0][0][0] == 0x04) {
|
||||
FilteringEdgeLumaIntraV (pfDeblocking, pFilter, pDestY, iLineSize , NULL);
|
||||
FilteringEdgeChromaIntraV (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*(uint32_t *)uiBS[0][0] != 0)
|
||||
{
|
||||
} else {
|
||||
if (* (uint32_t*)uiBS[0][0] != 0) {
|
||||
FilteringEdgeLumaV (pfDeblocking, pFilter, pDestY, iLineSize, uiBS[0][0]);
|
||||
FilteringEdgeChromaV (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, uiBS[0][0]);
|
||||
}
|
||||
@ -430,36 +426,28 @@ void DeblockingInterMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFi
|
||||
pFilter->uiLumaQP = iCurLumaQp;
|
||||
pFilter->uiChromaQP = iCurChromaQp;
|
||||
|
||||
if(*(uint32_t *)uiBS[0][1] != 0)
|
||||
{
|
||||
if (* (uint32_t*)uiBS[0][1] != 0) {
|
||||
FilteringEdgeLumaV (pfDeblocking, pFilter, &pDestY[1 << 2], iLineSize, uiBS[0][1]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)uiBS[0][2] != 0)
|
||||
{
|
||||
if (* (uint32_t*)uiBS[0][2] != 0) {
|
||||
FilteringEdgeLumaV (pfDeblocking, pFilter, &pDestY[2 << 2], iLineSize, uiBS[0][2]);
|
||||
FilteringEdgeChromaV (pfDeblocking, pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, uiBS[0][2]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)uiBS[0][3] != 0)
|
||||
{
|
||||
if (* (uint32_t*)uiBS[0][3] != 0) {
|
||||
FilteringEdgeLumaV (pfDeblocking, pFilter, &pDestY[3 << 2], iLineSize, uiBS[0][3]);
|
||||
}
|
||||
|
||||
if (iTopFlag)
|
||||
{
|
||||
if (iTopFlag) {
|
||||
pFilter->uiLumaQP = (iCurLumaQp + (pCurMb - iMbStride)->uiLumaQp + 1) >> 1;
|
||||
pFilter->uiChromaQP = (iCurChromaQp + (pCurMb - iMbStride)->uiChromaQp + 1) >> 1;
|
||||
|
||||
if(uiBS[1][0][0] == 0x04)
|
||||
{
|
||||
if (uiBS[1][0][0] == 0x04) {
|
||||
FilteringEdgeLumaIntraH (pfDeblocking, pFilter, pDestY, iLineSize , NULL);
|
||||
FilteringEdgeChromaIntraH (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*(uint32_t *)uiBS[1][0] != 0)
|
||||
{
|
||||
} else {
|
||||
if (* (uint32_t*)uiBS[1][0] != 0) {
|
||||
FilteringEdgeLumaH (pfDeblocking, pFilter, pDestY, iLineSize, uiBS[1][0]);
|
||||
FilteringEdgeChromaH (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, uiBS[1][0]);
|
||||
}
|
||||
@ -469,25 +457,22 @@ void DeblockingInterMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFi
|
||||
pFilter->uiLumaQP = iCurLumaQp;
|
||||
pFilter->uiChromaQP = iCurChromaQp;
|
||||
|
||||
if(*(uint32_t *)uiBS[1][1] != 0)
|
||||
{
|
||||
if (* (uint32_t*)uiBS[1][1] != 0) {
|
||||
FilteringEdgeLumaH (pfDeblocking, pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, uiBS[1][1]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)uiBS[1][2] != 0)
|
||||
{
|
||||
if (* (uint32_t*)uiBS[1][2] != 0) {
|
||||
FilteringEdgeLumaH (pfDeblocking, pFilter, &pDestY[ (2 << 2)*iLineSize], iLineSize, uiBS[1][2]);
|
||||
FilteringEdgeChromaH( pfDeblocking, pFilter, &pDestCb[(2<<1)*iLineSizeUV], &pDestCr[(2<<1)*iLineSizeUV], iLineSizeUV, uiBS[1][2] );
|
||||
FilteringEdgeChromaH (pfDeblocking, pFilter, &pDestCb[ (2 << 1)*iLineSizeUV], &pDestCr[ (2 << 1)*iLineSizeUV],
|
||||
iLineSizeUV, uiBS[1][2]);
|
||||
}
|
||||
|
||||
if(*(uint32_t *)uiBS[1][3] != 0)
|
||||
{
|
||||
if (* (uint32_t*)uiBS[1][3] != 0) {
|
||||
FilteringEdgeLumaH (pfDeblocking, pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, uiBS[1][3]);
|
||||
}
|
||||
}
|
||||
|
||||
void FilteringEdgeLumaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter )
|
||||
{
|
||||
void FilteringEdgeLumaHV (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter) {
|
||||
int32_t iLineSize = pFilter->iCsStride[0];
|
||||
int32_t iMbStride = pFilter->iMbStride;
|
||||
|
||||
@ -513,16 +498,15 @@ void FilteringEdgeLumaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblocking
|
||||
* (uint32_t*)uiBSx4 = 0x03030303;
|
||||
|
||||
// luma v
|
||||
if (iLeftFlag)
|
||||
{
|
||||
if (iLeftFlag) {
|
||||
pFilter->uiLumaQP = (iCurQp + (pCurMb - 1)->uiLumaQp + 1) >> 1;
|
||||
FilteringEdgeLumaIntraV (pfDeblocking, pFilter, pDestY, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->uiLumaQP = iCurQp;
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIdexA, uiBSx4, 0);
|
||||
pfDeblocking->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc);
|
||||
pfDeblocking->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc);
|
||||
@ -531,22 +515,19 @@ void FilteringEdgeLumaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblocking
|
||||
}
|
||||
|
||||
// luma h
|
||||
if (iTopFlag)
|
||||
{
|
||||
if (iTopFlag) {
|
||||
pFilter->uiLumaQP = (iCurQp + (pCurMb - iMbStride)->uiLumaQp + 1) >> 1;
|
||||
FilteringEdgeLumaIntraH (pfDeblocking, pFilter, pDestY, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->uiLumaQP = iCurQp;
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
if (iAlpha | iBeta) {
|
||||
pfDeblocking->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
|
||||
pfDeblocking->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
|
||||
pfDeblocking->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
|
||||
}
|
||||
}
|
||||
void FilteringEdgeChromaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter )
|
||||
{
|
||||
void FilteringEdgeChromaHV (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter) {
|
||||
int32_t iLineSize = pFilter->iCsStride[1];
|
||||
int32_t iMbStride = pFilter->iMbStride;
|
||||
|
||||
@ -572,43 +553,39 @@ void FilteringEdgeChromaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblocki
|
||||
* (uint32_t*)uiBSx4 = 0x03030303;
|
||||
|
||||
// chroma v
|
||||
if (iLeftFlag)
|
||||
{
|
||||
if (iLeftFlag) {
|
||||
pFilter->uiChromaQP = (iCurQp + (pCurMb - 1)->uiChromaQp + 1) >> 1;
|
||||
FilteringEdgeChromaIntraV (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->uiChromaQP = iCurQp;
|
||||
GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta);
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha,
|
||||
iBeta);
|
||||
if (iAlpha | iBeta) {
|
||||
TC0_TBL_LOOKUP (iTc, iIdexA, uiBSx4, 1);
|
||||
pfDeblocking->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc);
|
||||
}
|
||||
|
||||
// chroma h
|
||||
if (iTopFlag)
|
||||
{
|
||||
if (iTopFlag) {
|
||||
pFilter->uiChromaQP = (iCurQp + (pCurMb - iMbStride)->uiChromaQp + 1) >> 1;
|
||||
FilteringEdgeChromaIntraH (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSize, NULL);
|
||||
}
|
||||
|
||||
pFilter->uiChromaQP = iCurQp;
|
||||
if( iAlpha | iBeta )
|
||||
{
|
||||
pfDeblocking->pfChromaDeblockingLT4Ver( &pDestCb[(2<<1)*iLineSize], &pDestCr[(2<<1)*iLineSize], iLineSize, iAlpha, iBeta, iTc );
|
||||
if (iAlpha | iBeta) {
|
||||
pfDeblocking->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize, iAlpha,
|
||||
iBeta, iTc);
|
||||
}
|
||||
}
|
||||
|
||||
// merge h&v lookup table operation to save performance
|
||||
void DeblockingIntraMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter )
|
||||
{
|
||||
void DeblockingIntraMb (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter) {
|
||||
FilteringEdgeLumaHV (pfDeblocking, pCurMb, pFilter);
|
||||
FilteringEdgeChromaHV (pfDeblocking, pCurMb, pFilter);
|
||||
}
|
||||
|
||||
void DeblockingMbAvcbase( SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilter * pFilter )
|
||||
{
|
||||
void DeblockingMbAvcbase (SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilter* pFilter) {
|
||||
uint8_t uiBS[2][4][4] = { 0 };
|
||||
|
||||
Mb_Type uiCurMbType = pCurMb->uiMbType;
|
||||
@ -623,46 +600,35 @@ void DeblockingMbAvcbase( SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilte
|
||||
int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc];
|
||||
int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc];
|
||||
|
||||
switch( uiCurMbType )
|
||||
{
|
||||
switch (uiCurMbType) {
|
||||
case MB_TYPE_INTRA4x4:
|
||||
case MB_TYPE_INTRA16x16:
|
||||
case MB_TYPE_INTRA_PCM:
|
||||
DeblockingIntraMb (&pFunc->pfDeblocking, pCurMb, pFilter);
|
||||
break;
|
||||
default:
|
||||
if (iLeftFlag)
|
||||
{
|
||||
*(uint32_t*)uiBS[0][0] = IS_INTRA((pCurMb-1)->uiMbType)?0x04040404:DeblockingBSMarginalMBAvcbase( pCurMb, pCurMb-1, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iLeftFlag) {
|
||||
* (uint32_t*)uiBS[0][0] = IS_INTRA ((pCurMb - 1)->uiMbType) ? 0x04040404 : DeblockingBSMarginalMBAvcbase (pCurMb,
|
||||
pCurMb - 1, 0);
|
||||
} else {
|
||||
* (uint32_t*)uiBS[0][0] = 0;
|
||||
}
|
||||
if (iTopFlag)
|
||||
{
|
||||
*(uint32_t*)uiBS[1][0] = IS_INTRA((pCurMb-iMbStride)->uiMbType)?0x04040404:DeblockingBSMarginalMBAvcbase( pCurMb, (pCurMb-iMbStride), 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iTopFlag) {
|
||||
* (uint32_t*)uiBS[1][0] = IS_INTRA ((pCurMb - iMbStride)->uiMbType) ? 0x04040404 : DeblockingBSMarginalMBAvcbase (
|
||||
pCurMb, (pCurMb - iMbStride), 1);
|
||||
} else {
|
||||
* (uint32_t*)uiBS[1][0] = 0;
|
||||
}
|
||||
//SKIP MB_16x16 or others
|
||||
if( uiCurMbType != MB_TYPE_SKIP )
|
||||
{
|
||||
if (uiCurMbType != MB_TYPE_SKIP) {
|
||||
pFunc->pfSetNZCZero (pCurMb->pNonZeroCount); // set all none-zero nzc to 1; dbk can be opti!
|
||||
|
||||
if( uiCurMbType == MB_TYPE_16x16 )
|
||||
{
|
||||
if (uiCurMbType == MB_TYPE_16x16) {
|
||||
DeblockingBSInsideMBAvsbase (pCurMb->pNonZeroCount, uiBS, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DeblockingBSInsideMBNormal (pCurMb, uiBS, pCurMb->pNonZeroCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
* (uint32_t*)uiBS[0][1] = * (uint32_t*)uiBS[0][2] = * (uint32_t*)uiBS[0][3] =
|
||||
* (uint32_t*)uiBS[1][1] = * (uint32_t*)uiBS[1][2] = * (uint32_t*)uiBS[1][3] = 0;
|
||||
}
|
||||
@ -674,13 +640,10 @@ void DeblockingMbAvcbase( SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilte
|
||||
|
||||
// C code only
|
||||
|
||||
void DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc )
|
||||
{
|
||||
for( int32_t i = 0;i<16;i++)
|
||||
{
|
||||
void DeblockLumaLt4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t* pTc) {
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
int32_t iTc0 = pTc[i >> 2];
|
||||
if(iTc0>=0)
|
||||
{
|
||||
if (iTc0 >= 0) {
|
||||
int32_t p0 = pPix[-iStrideX];
|
||||
int32_t p1 = pPix[-2 * iStrideX];
|
||||
int32_t p2 = pPix[-3 * iStrideX];
|
||||
@ -691,17 +654,14 @@ void DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32_t
|
||||
bool_t bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bool_t bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
int32_t iTc = iTc0;
|
||||
if ( bDetaP0Q0&& bDetaP1P0 && bDetaQ1Q0 )
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta;
|
||||
bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta;
|
||||
if ( bDetaP2P0)
|
||||
{
|
||||
if (bDetaP2P0) {
|
||||
pPix[-2 * iStrideX] = p1 + WELS_CLIP3 ((p2 + ((p0 + q0 + 1) >> 1) - (p1 << 1)) >> 1, -iTc0, iTc0);
|
||||
iTc++;
|
||||
}
|
||||
if (bDetaQ2Q0)
|
||||
{
|
||||
if (bDetaQ2Q0) {
|
||||
pPix[iStrideX] = q1 + WELS_CLIP3 ((q2 + ((p0 + q0 + 1) >> 1) - (q1 << 1)) >> 1, -iTc0, iTc0);
|
||||
iTc++;
|
||||
}
|
||||
@ -715,13 +675,11 @@ void DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32_t
|
||||
}
|
||||
|
||||
|
||||
void DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void DeblockLumaEq4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta) {
|
||||
int32_t p0, p1, p2, q0, q1, q2;
|
||||
int32_t iDetaP0Q0;
|
||||
bool_t bDetaP1P0, bDetaQ1Q0;
|
||||
for (int32_t i = 0;i<16;i++)
|
||||
{
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
p0 = pPix[-iStrideX];
|
||||
p1 = pPix[-2 * iStrideX];
|
||||
p2 = pPix[-3 * iStrideX];
|
||||
@ -731,37 +689,27 @@ void DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int32_
|
||||
iDetaP0Q0 = WELS_ABS (p0 - q0);
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if ((iDetaP0Q0<iAlpha) && bDetaP1P0 &&bDetaQ1Q0)
|
||||
{
|
||||
if (iDetaP0Q0< (( iAlpha >> 2 ) + 2 ) )
|
||||
{
|
||||
if ((iDetaP0Q0 < iAlpha) && bDetaP1P0 && bDetaQ1Q0) {
|
||||
if (iDetaP0Q0 < ((iAlpha >> 2) + 2)) {
|
||||
bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta;
|
||||
bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta;
|
||||
if(bDetaP2P0)
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pPix[-1 * iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0
|
||||
}
|
||||
if (bDetaQ2Q0)
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pPix[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pPix[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0
|
||||
pPix[ 0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0
|
||||
}
|
||||
@ -769,32 +717,26 @@ void DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int32_
|
||||
pPix += iStrideY;
|
||||
}
|
||||
}
|
||||
void DeblockLumaLt4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc )
|
||||
{
|
||||
void DeblockLumaLt4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* iTc) {
|
||||
DeblockLumaLt4_c (pPix, iStride, 1, iAlpha, iBeta, iTc);
|
||||
}
|
||||
void DeblockLumaLt4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc )
|
||||
{
|
||||
void DeblockLumaLt4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* iTc) {
|
||||
DeblockLumaLt4_c (pPix, 1, iStride, iAlpha, iBeta, iTc);
|
||||
}
|
||||
void DeblockLumaEq4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void DeblockLumaEq4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockLumaEq4_c (pPix, iStride, 1, iAlpha, iBeta);
|
||||
}
|
||||
void DeblockLumaEq4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void DeblockLumaEq4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockLumaEq4_c (pPix, 1, iStride, iAlpha, iBeta);
|
||||
}
|
||||
void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc )
|
||||
{
|
||||
void DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta, int8_t* pTc) {
|
||||
int32_t p0, p1, q0, q1, iDeta;
|
||||
bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
|
||||
|
||||
for(int32_t i = 0;i<8;i++)
|
||||
{
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
int32_t iTc0 = pTc[i >> 1];
|
||||
if(iTc0 >0)
|
||||
{
|
||||
if (iTc0 > 0) {
|
||||
p0 = pPixCb[-iStrideX];
|
||||
p1 = pPixCb[-2 * iStrideX];
|
||||
q0 = pPixCb[0];
|
||||
@ -803,8 +745,7 @@ void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
|
||||
pPixCb[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
|
||||
pPixCb[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
|
||||
@ -820,8 +761,7 @@ void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
|
||||
if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
|
||||
pPixCr[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
|
||||
pPixCr[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
|
||||
@ -831,13 +771,12 @@ void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int
|
||||
pPixCr += iStrideY;
|
||||
}
|
||||
}
|
||||
void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
|
||||
int32_t iBeta) {
|
||||
int32_t i = 0, d = 0;
|
||||
int32_t p0, p1, q0, q1;
|
||||
bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
|
||||
for(int32_t i =0;i<8;i++)
|
||||
{
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
//cb
|
||||
p0 = pPixCb[-iStrideX];
|
||||
p1 = pPixCb[-2 * iStrideX];
|
||||
@ -846,8 +785,7 @@ void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
pPixCb[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
|
||||
pPixCb[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
|
||||
}
|
||||
@ -860,8 +798,7 @@ void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int
|
||||
bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
|
||||
bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
|
||||
bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
|
||||
if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0)
|
||||
{
|
||||
if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
|
||||
pPixCr[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
|
||||
pPixCr[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
|
||||
}
|
||||
@ -869,26 +806,23 @@ void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int
|
||||
pPixCb += iStrideY;
|
||||
}
|
||||
}
|
||||
void DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc )
|
||||
{
|
||||
void DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* iTc) {
|
||||
DeblockChromaLt4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, iTc);
|
||||
}
|
||||
void DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc )
|
||||
{
|
||||
void DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
|
||||
int8_t* iTc) {
|
||||
DeblockChromaLt4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, iTc);
|
||||
}
|
||||
void DeblockChromaEq4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockChromaEq4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta);
|
||||
}
|
||||
void DeblockChromaEq4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta )
|
||||
{
|
||||
void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
DeblockChromaEq4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta);
|
||||
}
|
||||
|
||||
|
||||
void DeblockingFilterFrameAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc )
|
||||
{
|
||||
void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) {
|
||||
int32_t i, j;
|
||||
const int32_t kiMbWidth = pCurDq->iMbWidth;
|
||||
const int32_t kiMbHeight = pCurDq->iMbHeight;
|
||||
@ -925,8 +859,7 @@ void DeblockingFilterFrameAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc )
|
||||
}
|
||||
}
|
||||
|
||||
void DeblockingFilterSliceAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc, const int32_t kiSliceIdx )
|
||||
{
|
||||
void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx) {
|
||||
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
|
||||
SMB* pMbList = pCurDq->sMbDataP;
|
||||
SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt;
|
||||
@ -953,58 +886,51 @@ void DeblockingFilterSliceAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc, co
|
||||
|
||||
iNextMbIdx = sSliceHeaderExt->sSliceHeader.iFirstMbInSlice;
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
for (; ;) {
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
pCurrentMbBlock = &pMbList[ iCurMbIdx ];
|
||||
|
||||
pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0]) << 4);
|
||||
pFilter.pCsData[1] = pCurDq->pDecPic->pData[1] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[1]) << 3);
|
||||
pFilter.pCsData[2] = pCurDq->pDecPic->pData[2] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[2]) << 3);
|
||||
pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0])
|
||||
<< 4);
|
||||
pFilter.pCsData[1] = pCurDq->pDecPic->pData[1] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[1])
|
||||
<< 3);
|
||||
pFilter.pCsData[2] = pCurDq->pDecPic->pData[2] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[2])
|
||||
<< 3);
|
||||
|
||||
DeblockingMbAvcbase (pFunc, pCurrentMbBlock, &pFilter);
|
||||
|
||||
++iNumMbFiltered;
|
||||
iNextMbIdx = WelsGetNextMbOfSlice (pSliceCtx, iCurMbIdx);
|
||||
//whether all of MB in current slice filtered or not
|
||||
if ( iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbFiltered >= kiTotalNumMb )
|
||||
{
|
||||
if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbFiltered >= kiTotalNumMb) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PerformDeblockingFilter( sWelsEncCtx *pEnc )
|
||||
{
|
||||
void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
|
||||
const int32_t kiCurDid = pEnc->uiDependencyId;
|
||||
SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam;
|
||||
SDLayerParam* pDlp = &pSvcParam->sDependencyLayers[kiCurDid];
|
||||
SDqLayer* pCurLayer = pEnc->pCurDqLayer;
|
||||
|
||||
if ( pCurLayer->iLoopFilterDisableIdc == 0 )
|
||||
{
|
||||
if (pCurLayer->iLoopFilterDisableIdc == 0) {
|
||||
DeblockingFilterFrameAvcbase (pCurLayer, pEnc->pFuncList);
|
||||
}
|
||||
else if ( pCurLayer->iLoopFilterDisableIdc == 2 )
|
||||
{
|
||||
} else if (pCurLayer->iLoopFilterDisableIdc == 2) {
|
||||
int32_t iSliceCount = 0;
|
||||
int32_t iSliceIdx = 0;
|
||||
|
||||
if ( SM_DYN_SLICE != pDlp->sMso.uiSliceMode )
|
||||
{
|
||||
if (SM_DYN_SLICE != pDlp->sMso.uiSliceMode) {
|
||||
iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx);
|
||||
do {
|
||||
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx);
|
||||
++ iSliceIdx;
|
||||
} while (iSliceIdx < iSliceCount);
|
||||
}
|
||||
else // for dynamic slicing mode
|
||||
{
|
||||
} else { // for dynamic slicing mode
|
||||
const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
|
||||
int32_t iPartitionIdx = 0;
|
||||
|
||||
while ( iPartitionIdx < kiNumPicPartition )
|
||||
{
|
||||
while (iPartitionIdx < kiNumPicPartition) {
|
||||
iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx];
|
||||
iSliceIdx = iPartitionIdx;
|
||||
do {
|
||||
@ -1017,8 +943,7 @@ void PerformDeblockingFilter( sWelsEncCtx *pEnc )
|
||||
}
|
||||
}
|
||||
|
||||
void WelsNonZeroCount_c(int8_t* pNonZeroCount)
|
||||
{
|
||||
void WelsNonZeroCount_c (int8_t* pNonZeroCount) {
|
||||
int32_t i;
|
||||
int32_t iIndex;
|
||||
|
||||
@ -1027,8 +952,7 @@ void WelsNonZeroCount_c(int8_t* pNonZeroCount)
|
||||
pNonZeroCount[iIndex] = !!pNonZeroCount[iIndex];
|
||||
}
|
||||
}
|
||||
void WelsBlockFuncInit( PSetNoneZeroCountZeroFunc *pfSetNZCZero, int32_t iCpu )
|
||||
{
|
||||
void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu) {
|
||||
*pfSetNZCZero = WelsNonZeroCount_c;
|
||||
}
|
||||
|
||||
@ -1036,8 +960,7 @@ void WelsBlockFuncInit( PSetNoneZeroCountZeroFunc *pfSetNZCZero, int32_t iCpu )
|
||||
#ifdef X86_ASM
|
||||
|
||||
extern "C" {
|
||||
void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc)
|
||||
{
|
||||
void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16);
|
||||
|
||||
DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]);
|
||||
@ -1045,8 +968,7 @@ void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32
|
||||
DeblockLumaTransposeV2H_sse2 (pPixY - 4, iStride, &uiBuf[0]);
|
||||
}
|
||||
|
||||
void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta)
|
||||
{
|
||||
void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
|
||||
ENFORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16);
|
||||
|
||||
DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]);
|
||||
@ -1059,8 +981,7 @@ void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32
|
||||
#endif
|
||||
|
||||
|
||||
void DeblockingInit( DeblockingFunc * pFunc, int32_t iCpu )
|
||||
{
|
||||
void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu) {
|
||||
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c;
|
||||
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c;
|
||||
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user