ref: 37423d414836f735a91d3dec17c1370607938401
parent: be8e62ff47c9d7967e9f402baabe34de1482ec86
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Dec 3 09:04:36 EST 2020
make the decoder compile and run with treason
--- a/codec/common/inc/WelsThreadLib.h
+++ b/codec/common/inc/WelsThreadLib.h
@@ -43,67 +43,15 @@
#include "typedefs.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(_WIN32) || defined(__CYGWIN__)
-
-#include <windows.h>
-
-typedef HANDLE WELS_THREAD_HANDLE;
-typedef LPTHREAD_START_ROUTINE LPWELS_THREAD_ROUTINE;
-
-typedef CRITICAL_SECTION WELS_MUTEX;
-typedef HANDLE WELS_EVENT;
-
-#define WELS_THREAD_ROUTINE_TYPE DWORD WINAPI
-#define WELS_THREAD_ROUTINE_RETURN(rc) return (DWORD)rc;
-
-#ifdef WINAPI_FAMILY
-#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-#define WP80
-
-#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
-#define GetSystemInfo(x) GetNativeSystemInfo(x)
-#define CreateEvent(attr, reset, init, name) CreateEventEx(attr, name, ((reset) ? CREATE_EVENT_MANUAL_RESET : 0) | ((init) ? CREATE_EVENT_INITIAL_SET : 0), EVENT_ALL_ACCESS)
-#define CreateSemaphore(a, b, c, d) CreateSemaphoreEx(a, b, c, d, 0, SEMAPHORE_ALL_ACCESS)
-#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
-#define WaitForMultipleObjects(a, b, c, d) WaitForMultipleObjectsEx(a, b, c, d, FALSE)
-#endif
-#endif
-
-#else // NON-WINDOWS
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-
-#include <sys/stat.h>
-#include <fcntl.h>
-
-typedef pthread_t WELS_THREAD_HANDLE;
+typedef int WELS_THREAD_HANDLE;
typedef void* (*LPWELS_THREAD_ROUTINE) (void*);
-typedef pthread_mutex_t WELS_MUTEX;
+typedef QLock WELS_MUTEX;
+typedef int WELS_EVENT;
-#ifdef __APPLE__
-typedef pthread_cond_t WELS_EVENT;
-#else
-typedef sem_t* WELS_EVENT;
-#endif
-
#define WELS_THREAD_ROUTINE_TYPE void *
#define WELS_THREAD_ROUTINE_RETURN(rc) return (void*)(intptr_t)rc;
-#endif//_WIN32
-
typedef int32_t WELS_THREAD_ERROR_CODE;
typedef int32_t WELS_THREAD_ATTR;
@@ -122,14 +70,14 @@
WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex);
WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex);
-WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name = NULL);
-WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name = NULL);
+WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name);
+WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name);
WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event,WELS_MUTEX *pMutex, int* iCondition);
-WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event,WELS_MUTEX *pMutex, int& iCondition);
-WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds,WELS_MUTEX *pMutex = NULL);
+WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event,WELS_MUTEX *pMutex, int iCondition);
+WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds,WELS_MUTEX *pMutex);
WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, WELS_EVENT* event_list,
- WELS_EVENT* master_event = NULL,WELS_MUTEX *pMutex = NULL);
+ WELS_EVENT* master_event,WELS_MUTEX *pMutex);
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
void* arg, WELS_THREAD_ATTR attr);
--- a/codec/common/inc/crt_util_safe_x.h
+++ b/codec/common/inc/crt_util_safe_x.h
@@ -40,24 +40,8 @@
#ifndef WELS_CRT_UTIL_SAFE_CROSS_PLATFORMS_H__
#define WELS_CRT_UTIL_SAFE_CROSS_PLATFORMS_H__
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <math.h>
-#include <time.h>
-
-#if defined(_WIN32)
-#include <windows.h>
-#include <sys/types.h>
-#include <sys/timeb.h>
-#else
-#include <sys/time.h>
#include "typedefs.h"
-#endif//_WIN32
-#include "typedefs.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,14 +52,10 @@
typedef FILE WelsFileHandle;
-#ifdef _WIN32
-typedef struct _timeb SWelsTime;
-#else
typedef struct TagWelsTime {
- time_t time;
+ long time;
unsigned short millitm;
} SWelsTime;
-#endif
int32_t WelsSnprintf (char* buffer, int32_t sizeOfBuffer, const char* format, ...);
char* WelsStrncpy (char* dest, int32_t sizeInBytes, const char* src);
--- a/codec/common/inc/expand_pic.h
+++ b/codec/common/inc/expand_pic.h
@@ -90,10 +90,10 @@
PExpandPictureFunc pfExpandChromaPicture[2];
} SExpandPicFunc;
-void PadMBLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH,
- const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight);
-void PadMBChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH,
- const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight);
+void PadMBLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH,
+ const int32_t kiMbX, const int32_t kiMbY, const int32_t kiMBWidth, const int32_t kiMBHeight);
+void PadMBChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH,
+ const int32_t kiMbX, const int32_t kiMbY, const int32_t kiMBWidth, const int32_t kiMBHeight);
void ExpandReferencingPicture (uint8_t* pData[3], int32_t iWidth, int32_t iHeight, int32_t iStride[3],
PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]);
--- a/codec/common/inc/golomb_common.h
+++ b/codec/common/inc/golomb_common.h
@@ -42,8 +42,6 @@
#include "typedefs.h"
-namespace WelsCommon {
-
#define WRITE_BE_32(ptr, val) do { \
(ptr)[0] = (val) >> 24; \
(ptr)[1] = (val) >> 16; \
@@ -162,5 +160,4 @@
return 0;
}
-}
#endif//EXPONENTIAL_GOLOMB_ENTROPY_CODING_COMMON_H__
--- a/codec/common/inc/intra_pred_common.h
+++ b/codec/common/inc/intra_pred_common.h
@@ -44,8 +44,8 @@
#include "typedefs.h"
-void WelsI16x16LumaPredV_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
-void WelsI16x16LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
+void WelsI16x16LumaPredV_c_ref (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
+void WelsI16x16LumaPredH_c_ref (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride);
#if defined(__cplusplus)
--- a/codec/common/inc/ls_defines.h
+++ b/codec/common/inc/ls_defines.h
@@ -33,20 +33,19 @@
#ifndef ___LD_ST_MACROS___
#define ___LD_ST_MACROS___
-#include <string.h>
#include "typedefs.h"
-#ifdef __GNUC__
-
+#pragma pack on
struct tagUnaligned_64 {
uint64_t l;
-} __attribute__ ((packed)) __attribute__ ((may_alias));
+};
struct tagUnaligned_32 {
uint32_t l;
-} __attribute__ ((packed)) __attribute__ ((may_alias));
+};
struct tagUnaligned_16 {
uint16_t l;
-} __attribute__ ((packed)) __attribute__ ((may_alias));
+};
+#pragma pack off
#define LD16(a) (((struct tagUnaligned_16 *) (a))->l)
#define LD32(a) (((struct tagUnaligned_32 *) (a))->l)
@@ -54,7 +53,7 @@
#define STRUCTA(size, align) struct tagUnaligned_##size##_##align {\
uint##size##_t l; \
-} __attribute__ ((aligned(align))) __attribute__ ((may_alias))
+}
STRUCTA (16, 2);
STRUCTA (32, 2);
STRUCTA (32, 4);
@@ -61,8 +60,7 @@
STRUCTA (64, 2);
STRUCTA (64, 4);
STRUCTA (64, 8);
-//#define _USE_STRUCT_INT_CVT
-//#ifdef _USE_STRUCT_INT_CVT
+
#define ST16(a, b) (((struct tagUnaligned_16 *) (a))->l) = (b)
#define ST32(a, b) (((struct tagUnaligned_32 *) (a))->l) = (b)
#define ST64(a, b) (((struct tagUnaligned_64 *) (a))->l) = (b)
@@ -81,39 +79,6 @@
#define ST64A2(a, b) STA(a, b, 64, 2)
#define ST64A4(a, b) STA(a, b, 64, 4)
#define ST64A8(a, b) STA(a, b, 64, 8)
-//#else
-//inline void __ST16(void *dst, uint16_t v) { memcpy(dst, &v, 2); }
-//inline void __ST32(void *dst, uint32_t v) { memcpy(dst, &v, 4); }
-//inline void __ST64(void *dst, uint64_t v) { memcpy(dst, &v, 8); }
-//#endif
-
-#else
-
-//#define INTD16(a) (*((int16_t*)(a)))
-//#define INTD32(a) (*((int32_t*)(a)))
-//#define INTD64(a) (*((int64_t*)(a)))
-
-#define LD16(a) (*((uint16_t*)(a)))
-#define LD32(a) (*((uint32_t*)(a)))
-#define LD64(a) (*((uint64_t*)(a)))
-
-#define ST16(a, b) *((uint16_t*)(a)) = (b)
-#define ST32(a, b) *((uint32_t*)(a)) = (b)
-#define ST64(a, b) *((uint64_t*)(a)) = (b)
-#define LD16A2 LD16
-#define LD32A2 LD32
-#define LD32A4 LD32
-#define LD64A2 LD64
-#define LD64A4 LD64
-#define LD64A8 LD64
-#define ST16A2 ST16
-#define ST32A2 ST32
-#define ST32A4 ST32
-#define ST64A2 ST64
-#define ST64A4 ST64
-#define ST64A8 ST64
-
-#endif /* !__GNUC__ */
#ifndef INTD16
#define INTD16 LD16
--- a/codec/common/inc/macros.h
+++ b/codec/common/inc/macros.h
@@ -40,9 +40,6 @@
#ifndef WELS_MACRO_UTILIZATIONS_H__
#define WELS_MACRO_UTILIZATIONS_H__
-#include <math.h>
-#include <assert.h>
-#include <string.h>
#include "typedefs.h"
@@ -204,14 +201,6 @@
#define WELS_CLIP3(iX, iY, iZ) ((iX) < (iY) ? (iY) : ((iX) > (iZ) ? (iZ) : (iX)))
#endif //WELS_CLIP3
-template<typename T> T WelsClip3(T iX, T iY, T iZ) {
- if (iX < iY)
- return iY;
- if (iX > iZ)
- return iZ;
- return iX;
-}
-
#define DISALLOW_COPY_AND_ASSIGN(cclass) \
private: \
cclass(const cclass &); \
@@ -293,7 +282,7 @@
#define WELS_GCC_UNUSED
#endif
-inline bool CheckInRangeCloseOpen (const int16_t kiCurrent, const int16_t kiMin, const int16_t kiMax) {
+static inline bool CheckInRangeCloseOpen (const int16_t kiCurrent, const int16_t kiMin, const int16_t kiMax) {
return ((kiCurrent >= kiMin) && (kiCurrent < kiMax));
}
@@ -309,20 +298,20 @@
}
}
-inline void WelsSetMemMultiplebytes_c (void* pDst, uint32_t iValue, int32_t iSizeOfData, int32_t iDataLengthOfData) {
+static inline void WelsSetMemMultiplebytes_c (void* pDst, uint32_t iValue, int32_t iSizeOfData, int32_t iDataLengthOfData) {
assert (4 == iDataLengthOfData || 2 == iDataLengthOfData || 1 == iDataLengthOfData);
// TODO: consider add assembly for these functions
if (0 != iValue) {
if (4 == iDataLengthOfData) {
- WelsSetMemUint32_c (static_cast<uint32_t*> (pDst), static_cast<uint32_t> (iValue), iSizeOfData);
+ WelsSetMemUint32_c ((uint32_t*) (pDst), (uint32_t) (iValue), iSizeOfData);
} else if (2 == iDataLengthOfData) {
- WelsSetMemUint16_c (static_cast<uint16_t*> (pDst), static_cast<uint16_t> (iValue), iSizeOfData);
+ WelsSetMemUint16_c ((uint16_t*) (pDst), (uint16_t) (iValue), iSizeOfData);
} else {
- memset (static_cast<uint8_t*> (pDst), static_cast<uint8_t> (iValue), iSizeOfData);
+ memset ((uint8_t*) (pDst), (uint8_t) (iValue), iSizeOfData);
}
} else {
- memset (static_cast<uint8_t*> (pDst), 0, iSizeOfData * iDataLengthOfData);
+ memset ((uint8_t*) (pDst), 0, iSizeOfData * iDataLengthOfData);
}
}
--- a/codec/common/inc/mc.h
+++ b/codec/common/inc/mc.h
@@ -53,11 +53,7 @@
PWelsSampleAveragingFunc pfSampleAveraging;
} SMcFunc;
-namespace WelsCommon {
-
void InitMcFunc (SMcFunc* pMcFunc, uint32_t iCpu);
-
-} // namespace WelsCommon
#if defined(__cplusplus)
--- a/codec/common/inc/memory_align.h
+++ b/codec/common/inc/memory_align.h
@@ -44,37 +44,22 @@
#endif//MEMORY_MONITOR
#endif//MEMORY_CHECK
+typedef struct CMemoryAlign {
+void* (*WelsMallocz) (const uint32_t kuiSize, const char* kpTag);
+void* (*WelsMalloc) (const uint32_t kuiSize, const char* kpTag);
+void (*WelsFree) (void* pPointer, const char* kpTag);
+const uint32_t (*WelsGetCacheLineSize)(void);
+const uint32_t (*WelsGetMemoryUsage)(void);
-#ifdef MEMORY_CHECK
-#include <stdio.h>
-#endif//MEMORY_CHECK
-
-namespace WelsCommon {
-
-class CMemoryAlign {
- public:
-CMemoryAlign (const uint32_t kuiCacheLineSize);
-virtual ~CMemoryAlign();
-
-void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
-void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
-void WelsFree (void* pPointer, const char* kpTag);
-const uint32_t WelsGetCacheLineSize() const;
-const uint32_t WelsGetMemoryUsage() const;
-
- private:
-// private copy & assign constructors adding to fix klocwork scan issues
-CMemoryAlign (const CMemoryAlign& kcMa);
-CMemoryAlign& operator= (const CMemoryAlign& kcMa);
-
- protected:
uint32_t m_nCacheLineSize;
#ifdef MEMORY_MONITOR
uint32_t m_nMemoryUsageInBytes;
-#endif//MEMORY_MONITOR
-};
+#endif
+}CMemoryAlign;
+extern CMemoryAlign cMemoryAlign;
+
/*!
*************************************************************************************
* \brief malloc with zero filled utilization in Wels
@@ -110,7 +95,5 @@
#define WELS_DELETE_OP(p) \
if(p) delete p; \
p = NULL;
-
-}
#endif//WELS_COMMON_MEMORY_ALIGN_H__
--- a/codec/common/inc/typedefs.h
+++ b/codec/common/inc/typedefs.h
@@ -34,47 +34,31 @@
#ifndef WELS_TYPE_DEFINES_H__
#define WELS_TYPE_DEFINES_H__
-#include <limits.h>
-#include <stddef.h>
+#include <u.h>
+#include <libc.h>
+#include <stdio.h>
-////////////////////////////////////////////////////////////////////////////
-// NOTICE : ALL internal implement MUST use the data type defined as below
-// ONLY except with the interface file !!!!!
-////////////////////////////////////////////////////////////////////////////
+#define __attribute__(...)
-#ifndef _MSC_VER
+typedef enum { false, true } bool;
+typedef s8int int8_t;
+typedef u8int uint8_t;
+typedef s16int int16_t;
+typedef u16int uint16_t;
+typedef s32int int32_t;
+typedef u32int uint32_t;
+typedef s64int int64_t;
+typedef u64int uint64_t;
+typedef uintptr uintptr_t;
-#define __STDC_FORMAT_MACROS
-#include <stdint.h>
-#include <inttypes.h>
+#define PRId64 "lldd"
-#ifdef __LP64__
+#ifdef __amd64__
typedef int64_t intX_t;
#else
typedef int32_t intX_t;
#endif
-#else
-
-// FIXME: all singed type should be declared explicit, for example, int8_t should be declared as signed char.
-typedef signed char int8_t ;
-typedef unsigned char uint8_t ;
-typedef short int16_t ;
-typedef unsigned short uint16_t;
-typedef int int32_t ;
-typedef unsigned int uint32_t;
-typedef __int64 int64_t ;
-typedef unsigned __int64 uint64_t;
-#define PRId64 "I64d"
-
-#ifdef _WIN64
-typedef int64_t intX_t;
-#else
-typedef int32_t intX_t;
-#endif
-
-#endif // _MSC_VER defined
-
// The 'float' type is portable and usable without any need for any extra typedefs.
#ifdef EPSN
@@ -83,4 +67,3 @@
#define EPSN (0.000001f) // (1e-6) // desired float precision
#endif //WELS_TYPE_DEFINES_H__
-
--- a/codec/common/inc/utils.h
+++ b/codec/common/inc/utils.h
@@ -39,7 +39,6 @@
#ifndef WELS_UTILS_H__
#define WELS_UTILS_H__
-#include <stdarg.h>
#include "typedefs.h"
#define MAX_LOG_SIZE 1024
--- a/codec/common/inc/wels_common_defs.h
+++ b/codec/common/inc/wels_common_defs.h
@@ -39,7 +39,6 @@
#include "codec_app_def.h"
-namespace WelsCommon {
/*common use table*/
#define CTX_NA 0
@@ -69,8 +68,8 @@
extern const uint8_t g_kuiDequantScaling4x4Default[2][16];
extern const uint8_t g_kuiDequantScaling8x8Default[2][64];
-extern const ALIGNED_DECLARE (uint16_t, g_kuiDequantCoeff[52][8], 16);
-extern const ALIGNED_DECLARE (uint16_t, g_kuiDequantCoeff8x8[52][64], 16);
+extern const uint16_t g_kuiDequantCoeff[52][8];
+extern const uint16_t g_kuiDequantCoeff8x8[52][64];
extern const uint8_t g_kuiChromaQpTable[52];
extern const uint8_t g_kuiCabacRangeLps[64][4];
@@ -80,7 +79,7 @@
/*
* NAL Unit Type (5 Bits)
*/
-enum EWelsNalUnitType {
+typedef enum EWelsNalUnitType {
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
@@ -113,7 +112,7 @@
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
-};
+}EWelsNalUnitType;
/*
* NAL Reference IDC (2 Bits)
@@ -130,11 +129,11 @@
* VCL TYPE
*/
-enum EVclType {
+typedef enum EVclType {
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
-};
+}EVclType;
/*
* vcl type map for given NAL unit type and corresponding H264 type (0: AVC; 1: SVC).
@@ -160,7 +159,7 @@
* meaning mapped version after eSliceType minus 4.
*/
-enum EWelsSliceType {
+typedef enum EWelsSliceType {
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
@@ -167,7 +166,7 @@
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
-};
+}EWelsSliceType;
/* SSlice Types in scalable extension */
enum ESliceTypeExt {
@@ -369,5 +368,5 @@
#define C_PRED_DC_T 5
#define C_PRED_DC_128 6
#define C_PRED_A 7
-}
+
#endif//WELS_COMMON_DEFS_H__
--- a/codec/common/src/common_tables.cpp
+++ b/codec/common/src/common_tables.cpp
@@ -32,7 +32,6 @@
#include "wels_common_defs.h"
-namespace WelsCommon {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////pNonZeroCount[16+8] mapping scan index
@@ -205,7 +204,7 @@
22, 24, 25, 27, 28, 30, 32, 33,
24, 25, 27, 28, 30, 32, 33, 35 }
};
-ALIGNED_DECLARE (const uint16_t, g_kuiDequantCoeff[52][8], 16) = {
+const uint16_t g_kuiDequantCoeff[52][8] = {
/* 0*/{ 10, 13, 10, 13, 13, 16, 13, 16 }, /* 1*/{ 11, 14, 11, 14, 14, 18, 14, 18 },
/* 2*/{ 13, 16, 13, 16, 16, 20, 16, 20 }, /* 3*/{ 14, 18, 14, 18, 18, 23, 18, 23 },
/* 4*/{ 16, 20, 16, 20, 20, 25, 20, 25 }, /* 5*/{ 18, 23, 18, 23, 23, 29, 23, 29 },
@@ -234,7 +233,7 @@
/*50*/{ 3328, 4096, 3328, 4096, 4096, 5120, 4096, 5120 }, /*51*/{ 3584, 4608, 3584, 4608, 4608, 5888, 4608, 5888 },
};
-ALIGNED_DECLARE (const uint16_t, g_kuiDequantCoeff8x8[52][64], 16) = {
+const uint16_t g_kuiDequantCoeff8x8[52][64] = {
/* QP == 0 */
{ 320, 304, 400, 304, 320, 304, 400, 304, 304, 288, 384, 288, 304, 288, 384, 288, 400, 384, 512, 384, 400, 384, 512, 384, 304, 288, 384, 288, 304, 288, 384, 288, 320, 304, 400, 304, 320, 304, 400, 304, 304, 288, 384, 288, 304, 288, 384, 288, 400, 384, 512, 384, 400, 384, 512, 384, 304, 288, 384, 288, 304, 288, 384, 288 },
/* QP == 1 */
@@ -903,4 +902,3 @@
17
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-}
--- a/codec/common/src/crt_util_safe_x.cpp
+++ b/codec/common/src/crt_util_safe_x.cpp
@@ -38,21 +38,6 @@
*************************************************************************************
*/
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#if defined(_WIN32)
-#include <windows.h>
-#include <sys/types.h>
-#include <sys/timeb.h>
-#ifndef _MSC_VER
-#include <sys/time.h>
-#endif //!_MSC_VER
-#else
-#include <sys/time.h>
-#endif //_WIN32
-
#include "macros.h"
#include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms
@@ -215,28 +200,19 @@
}
int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
- struct timeval sTv;
+ long t;
- if (gettimeofday (&sTv, NULL)) {
- return -1;
- }
+ t = time(nil);
- pTp->time = sTv.tv_sec;
- pTp->millitm = (uint16_t)sTv.tv_usec / 1000;
+ pTp->time = t;
+ pTp->millitm = 0;
return 0;
}
int32_t WelsStrftime (char* pBuffer, int32_t iSize, const char* kpFormat, const SWelsTime* kpTp) {
- struct tm* pTnow;
- int32_t iRc;
-
- pTnow = localtime (&kpTp->time);
-
- iRc = (int32_t) strftime (pBuffer, iSize, kpFormat, pTnow);
- if (iRc == 0)
- pBuffer[0] = '\0';
- return iRc;
+ USED(kpFormat); USED(kpTp);
+ return snprint(pBuffer, iSize, "%s", ctime(time(nil)));
}
#endif
--- a/codec/common/src/expand_pic.cpp
+++ b/codec/common/src/expand_pic.cpp
@@ -29,11 +29,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*
*/
-#include <string.h>
+
#include "expand_pic.h"
#include "cpu_core.h"
-static inline void MBPadTopLeftLuma_c (uint8_t*& pDst, const int32_t& kiStride) {
+static inline void MBPadTopLeftLuma_c (uint8_t* pDst, const int32_t kiStride) {
const uint8_t kuiTL = pDst[0];
int32_t i = 0;
uint8_t* pTopLeft = pDst;
@@ -45,7 +45,7 @@
} while (++i < PADDING_LENGTH);
}
-static inline void MBPadTopLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX) {
+static inline void MBPadTopLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbX) {
uint8_t* pTopLine = pDst + (kiMbX << 4);
int32_t i = 0;
uint8_t* pTop = pTopLine;
@@ -56,8 +56,8 @@
} while (++i < PADDING_LENGTH);
}
-static inline void MBPadBottomLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX,
- const int32_t& kiPicH) {
+static inline void MBPadBottomLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbX,
+ const int32_t kiPicH) {
uint8_t* pBottomLine = pDst + (kiPicH - 1) * kiStride + (kiMbX << 4);
int32_t i = 0;
uint8_t* pBottom = pBottomLine;
@@ -68,7 +68,7 @@
} while (++i < PADDING_LENGTH);
}
-static inline void MBPadTopRightLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW) {
+static inline void MBPadTopRightLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW) {
uint8_t* pTopRight = pDst + kiPicW;
const uint8_t kuiTR = pTopRight[-1];
int32_t i = 0;
@@ -81,7 +81,7 @@
} while (++i < PADDING_LENGTH);
}
-static inline void MBPadBottomLeftLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicH) {
+static inline void MBPadBottomLeftLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicH) {
uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride;
const uint8_t kuiBL = pDstLastLine[0];
int32_t i = 0;
@@ -94,8 +94,8 @@
} while (++i < PADDING_LENGTH);
}
-static inline void MBPadBottomRightLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW,
- const int32_t& kiPicH) {
+static inline void MBPadBottomRightLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW,
+ const int32_t kiPicH) {
uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride + kiPicW;
const uint8_t kuiBR = pDstLastLine[-1];
int32_t i = 0;
@@ -108,7 +108,7 @@
} while (++i < PADDING_LENGTH);
}
-static inline void MBPadLeftLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY) {
+static inline void MBPadLeftLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbY) {
uint8_t* pTmp = pDst + (kiMbY << 4) * kiStride;
for (int32_t i = 0; i < 16; ++i) {
// pad left
@@ -117,8 +117,8 @@
}
}
-static inline void MBPadRightLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY,
- const int32_t& kiPicW) {
+static inline void MBPadRightLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbY,
+ const int32_t kiPicW) {
uint8_t* pTmp = pDst + (kiMbY << 4) * kiStride + kiPicW;
for (int32_t i = 0; i < 16; ++i) {
// pad right
@@ -127,7 +127,7 @@
}
}
-static inline void MBPadTopChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX) {
+static inline void MBPadTopChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbX) {
uint8_t* pTopLine = pDst + (kiMbX << 3);
int32_t i = 0;
uint8_t* pTop = pTopLine;
@@ -138,8 +138,8 @@
} while (++i < CHROMA_PADDING_LENGTH);
}
-static inline void MBPadBottomChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbX,
- const int32_t& kiPicH) {
+static inline void MBPadBottomChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbX,
+ const int32_t kiPicH) {
uint8_t* pBottomLine = pDst + (kiPicH - 1) * kiStride + (kiMbX << 3);
int32_t i = 0;
uint8_t* pBottom = pBottomLine;
@@ -150,7 +150,7 @@
} while (++i < CHROMA_PADDING_LENGTH);
}
-static inline void MBPadTopLeftChroma_c (uint8_t*& pDst, const int32_t& kiStride) {
+static inline void MBPadTopLeftChroma_c (uint8_t* pDst, const int32_t kiStride) {
const uint8_t kuiTL = pDst[0];
int32_t i = 0;
uint8_t* pTopLeft = pDst;
@@ -162,7 +162,7 @@
} while (++i < CHROMA_PADDING_LENGTH);
}
-static inline void MBPadTopRightChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW) {
+static inline void MBPadTopRightChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW) {
uint8_t* pTopRight = pDst + kiPicW;
const uint8_t kuiTR = pTopRight[-1];
int32_t i = 0;
@@ -175,7 +175,7 @@
} while (++i < CHROMA_PADDING_LENGTH);
}
-static inline void MBPadBottomLeftChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicH) {
+static inline void MBPadBottomLeftChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicH) {
uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride;
const uint8_t kuiBL = pDstLastLine[0];
int32_t i = 0;
@@ -188,7 +188,7 @@
} while (++i < CHROMA_PADDING_LENGTH);
}
-static inline void MBPadBottomRightChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW,
+static inline void MBPadBottomRightChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW,
const int32_t kiPicH) {
uint8_t* pDstLastLine = pDst + (kiPicH - 1) * kiStride + kiPicW;
const uint8_t kuiBR = pDstLastLine[-1];
@@ -202,7 +202,7 @@
} while (++i < CHROMA_PADDING_LENGTH);
}
-static inline void MBPadLeftChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY) {
+static inline void MBPadLeftChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbY) {
uint8_t* pTmp = pDst + (kiMbY << 3) * kiStride;
for (int32_t i = 0; i < 8; ++i) {
// pad left
@@ -211,8 +211,8 @@
}
}
-static inline void MBPadRightChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiMbY,
- const int32_t& kiPicW) {
+static inline void MBPadRightChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiMbY,
+ const int32_t kiPicW) {
uint8_t* pTmp = pDst + (kiMbY << 3) * kiStride + kiPicW;
for (int32_t i = 0; i < 8; ++i) {
// pad right
@@ -221,8 +221,8 @@
}
}
-void PadMBLuma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH,
- const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight) {
+void PadMBLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH,
+ const int32_t kiMbX, const int32_t kiMbY, const int32_t kiMBWidth, const int32_t kiMBHeight) {
if (kiMbX == 0 && kiMbY == 0) {
MBPadTopLeftLuma_c (pDst, kiStride);
} else if (kiMbY == 0 && kiMbX == kiMBWidth - 1) {
@@ -244,8 +244,8 @@
}
}
-void PadMBChroma_c (uint8_t*& pDst, const int32_t& kiStride, const int32_t& kiPicW, const int32_t& kiPicH,
- const int32_t& kiMbX, const int32_t& kiMbY, const int32_t& kiMBWidth, const int32_t& kiMBHeight) {
+void PadMBChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH,
+ const int32_t kiMbX, const int32_t kiMbY, const int32_t kiMBWidth, const int32_t kiMBHeight) {
if (kiMbX == 0 && kiMbY == 0) {
MBPadTopLeftChroma_c (pDst, kiStride);
} else if (kiMbY == 0 && kiMbX == kiMBWidth - 1) {
@@ -349,6 +349,7 @@
}
void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCPUFlag) {
+ USED(kuiCPUFlag);
pExpandPicFunc->pfExpandLumaPicture = ExpandPictureLuma_c;
pExpandPicFunc->pfExpandChromaPicture[0] = ExpandPictureChroma_c;
pExpandPicFunc->pfExpandChromaPicture[1] = ExpandPictureChroma_c;
--- a/codec/common/src/intra_pred_common.cpp
+++ b/codec/common/src/intra_pred_common.cpp
@@ -44,7 +44,7 @@
#include "intra_pred_common.h"
-void WelsI16x16LumaPredV_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
+void WelsI16x16LumaPredV_c_ref (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
uint8_t i = 15;
const int8_t* kpSrc = (int8_t*)&pRef[-kiStride];
const uint64_t kuiT1 = LD64 (kpSrc);
@@ -58,7 +58,7 @@
} while (i-- > 0);
}
-void WelsI16x16LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
+void WelsI16x16LumaPredH_c_ref (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
int32_t iStridex15 = (kiStride << 4) - kiStride;
int32_t iPredStride = 16;
int32_t iPredStridex15 = 240; //(iPredStride<<4)-iPredStride;
--- a/codec/common/src/mc.cpp
+++ b/codec/common/src/mc.cpp
@@ -45,8 +45,6 @@
#include "macros.h"
#include "asmdefs_mmi.h"
-namespace {
-
typedef void (*PMcChromaWidthExtFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
const uint8_t* kpABCD, int32_t iHeight);
typedef void (*PWelsSampleWidthAveragingFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*,
@@ -4195,9 +4193,10 @@
kpfFuncs[iWidth >> 4] (pDst, iDstStride, pSrcA, iSrcAStride, pSrcB, iSrcBStride, iHeight);
}
#endif//HAVE_MMI
-} // anon ns.
-void WelsCommon::InitMcFunc (SMcFunc* pMcFuncs, uint32_t uiCpuFlag) {
+void InitMcFunc (SMcFunc* pMcFuncs, uint32_t uiCpuFlag) {
+ USED(uiCpuFlag);
+
pMcFuncs->pfLumaHalfpelHor = McHorVer20_c;
pMcFuncs->pfLumaHalfpelVer = McHorVer02_c;
pMcFuncs->pfLumaHalfpelCen = McHorVer22_c;
--- a/codec/common/src/sad_common.cpp
+++ b/codec/common/src/sad_common.cpp
@@ -43,7 +43,7 @@
int32_t WelsSampleSad4x4_c (uint8_t* pSample1, int32_t iStride1, uint8_t* pSample2, int32_t iStride2) {
int32_t iSadSum = 0;
- int32_t i = 0;
+ int32_t i;
uint8_t* pSrc1 = pSample1;
uint8_t* pSrc2 = pSample2;
for (i = 0; i < 4; i++) {
@@ -75,7 +75,7 @@
int32_t WelsSampleSad8x8_c (uint8_t* pSample1, int32_t iStride1, uint8_t* pSample2, int32_t iStride2) {
int32_t iSadSum = 0;
- int32_t i = 0;
+ int32_t i;
uint8_t* pSrc1 = pSample1;
uint8_t* pSrc2 = pSample2;
for (i = 0; i < 8; i++) {
--- a/codec/decoder/core/inc/au_parser.h
+++ b/codec/decoder/core/inc/au_parser.h
@@ -46,8 +46,6 @@
#include "parameter_sets.h"
#include "decoder_context.h"
-namespace WelsDec {
-
/*!
*************************************************************************************
* \brief Start Code Prefix (0x 00 00 00 01) detection
@@ -192,8 +190,6 @@
*************************************************************************************
*/
int32_t ResetFmoList (PWelsDecoderContext pCtx);
-
-} // namespace WelsDec
#endif//WELS_ACCESS_UNIT_PARSER_H__
--- a/codec/decoder/core/inc/bit_stream.h
+++ b/codec/decoder/core/inc/bit_stream.h
@@ -38,10 +38,6 @@
#include "wels_common_defs.h"
#include "golomb_common.h"
-using namespace WelsCommon;
-
-namespace WelsDec {
-
/*!
* \brief input bits for decoder or initialize bitstream writing in encoder
*
@@ -56,7 +52,5 @@
int32_t InitReadBits (PBitStringAux pBitString, intX_t iEndOffset);
void RBSP2EBSP (uint8_t* pDstBuf, uint8_t* pSrcBuf, const int32_t kiSize);
-
-} // namespace WelsDec
#endif//WELS_BIT_STREAM_H__
--- a/codec/decoder/core/inc/cabac_decoder.h
+++ b/codec/decoder/core/inc/cabac_decoder.h
@@ -42,7 +42,6 @@
#include "decoder_context.h"
#include "error_code.h"
#include "wels_common_defs.h"
-namespace WelsDec {
static const uint8_t g_kRenormTable256[256] = {
6, 6, 6, 6, 6, 6, 6, 6,
5, 5, 5, 5, 5, 5, 5, 5,
@@ -87,19 +86,19 @@
int32_t InitCabacDecEngineFromBS (PWelsCabacDecEngine pDecEngine, SBitStringAux* pBsAux);
void RestoreCabacDecEngineToBS (PWelsCabacDecEngine pDecEngine, SBitStringAux* pBsAux);
//3. actual decoding
-int32_t Read32BitsCabac (PWelsCabacDecEngine pDecEngine, uint32_t& uiValue, int32_t& iNumBitsRead);
-int32_t DecodeBinCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t& uiBit);
-int32_t DecodeBypassCabac (PWelsCabacDecEngine pDecEngine, uint32_t& uiBinVal);
-int32_t DecodeTerminateCabac (PWelsCabacDecEngine pDecEngine, uint32_t& uiBinVal);
+int32_t Read32BitsCabac (PWelsCabacDecEngine pDecEngine, uint32_t *uiValue, int32_t *iNumBitsRead);
+int32_t DecodeBinCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t *uiBit);
+int32_t DecodeBypassCabac (PWelsCabacDecEngine pDecEngine, uint32_t *uiBinVal);
+int32_t DecodeTerminateCabac (PWelsCabacDecEngine pDecEngine, uint32_t *uiBinVal);
//4. unary parsing
int32_t DecodeUnaryBinCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, int32_t iCtxOffset,
- uint32_t& uiSymVal);
+ uint32_t *uiSymVal);
//5. EXGk parsing
-int32_t DecodeExpBypassCabac (PWelsCabacDecEngine pDecEngine, int32_t iCount, uint32_t& uiSymVal);
-uint32_t DecodeUEGLevelCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t& uiBinVal);
-int32_t DecodeUEGMvCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t iMaxC, uint32_t& uiCode);
+int32_t DecodeExpBypassCabac (PWelsCabacDecEngine pDecEngine, int32_t iCount, uint32_t *uiSymVal);
+uint32_t DecodeUEGLevelCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t *uiBinVal);
+int32_t DecodeUEGMvCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t iMaxC, uint32_t *uiCode);
#define WELS_CABAC_HALF 0x01FE
#define WELS_CABAC_QUARTER 0x0100
@@ -106,6 +105,5 @@
#define WELS_CABAC_FALSE_RETURN(iErrorInfo) \
if(iErrorInfo) { \
return iErrorInfo; \
-}
}
#endif
--- a/codec/decoder/core/inc/deblocking.h
+++ b/codec/decoder/core/inc/deblocking.h
@@ -43,7 +43,6 @@
#include "decoder_context.h"
#include "deblocking_common.h"
-namespace WelsDec {
/*!
* \brief deblocking module initialize
@@ -74,7 +73,7 @@
*
* \return NONE
*/
-void WelsDeblockingInitFilter (PWelsDecoderContext pCtx, SDeblockingFilter& pFilter, int32_t& iFilterIdc);
+void WelsDeblockingInitFilter (PWelsDecoderContext pCtx, SDeblockingFilter *pFilter, int32_t *iFilterIdc);
/*!
* \brief AVC MB deblocking filtering target layer
@@ -83,7 +82,7 @@
*
* \return NONE
*/
-void WelsDeblockingFilterMB (PDqLayer pCurDqLayer, SDeblockingFilter& pFilter, int32_t& iFilterIdc,
+void WelsDeblockingFilterMB (PDqLayer pCurDqLayer, SDeblockingFilter *pFilter, int32_t *iFilterIdc,
PDeblockingFilterMbFunc pDeblockMb);
/*!
@@ -99,20 +98,18 @@
uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge,
int32_t iNeighMb, int32_t iMbXy);
-uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy);
+uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy);
int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc);
void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag);
-inline int8_t* GetPNzc (PDqLayer pCurDqLayer, int32_t iMbXy) {
+static inline int8_t* GetPNzc (PDqLayer pCurDqLayer, int32_t iMbXy) {
if (pCurDqLayer->pDec != NULL && pCurDqLayer->pDec->pNzc != NULL) {
return pCurDqLayer->pDec->pNzc[iMbXy];
}
return pCurDqLayer->pNzc[iMbXy];
}
-
-} // namespace WelsDec
#endif //WELS_DEBLOCKING_H__
--- a/codec/decoder/core/inc/dec_frame.h
+++ b/codec/decoder/core/inc/dec_frame.h
@@ -44,8 +44,6 @@
#include "bit_stream.h"
#include "fmo.h"
-namespace WelsDec {
-
///////////////////////////////////DQ Layer level///////////////////////////////////
typedef struct TagDqLayer SDqLayer;
typedef SDqLayer* PDqLayer;
@@ -148,9 +146,5 @@
int32_t iMbHeight; // MB height of this picture, equal to sSps.iMbHeight;
} SGpuAvcDqLayer, *PGpuAvcDqLayer;
-
-///////////////////////////////////////////////////////////////////////
-
-} // namespace WelsDec
#endif//WELS_DEC_FRAME_H__
--- a/codec/decoder/core/inc/dec_golomb.h
+++ b/codec/decoder/core/inc/dec_golomb.h
@@ -47,12 +47,12 @@
#include "ls_defines.h"
#include "error_code.h"
-namespace WelsDec {
-
#define WELS_READ_VERIFY(uiRet) do{ \
uint32_t uiRetTmp = (uint32_t)uiRet; \
- if( uiRetTmp != ERR_NONE ) \
+ if( uiRetTmp != ERR_NONE ) { \
+ fprint(2, "%s: error %d ( ../codec/%s:%d )\n", #uiRet, uiRetTmp, __FILE__, __LINE__); \
return uiRetTmp; \
+ } \
}while(0)
#define GET_WORD(iCurBits, pBufPtr, iLeftBits, iAllowedBytes, iReadBytes) { \
if (iReadBytes > iAllowedBytes+1) { \
@@ -338,7 +338,5 @@
#define MAX_MB_SIZE 36864
// for aspect_ratio_idc
#define EXTENDED_SAR 255
-
-} // namespace WelsDec
#endif//WELS_EXPONENTIAL_GOLOMB_ENTROPY_CODING_H__
--- a/codec/decoder/core/inc/decode_mb_aux.h
+++ b/codec/decoder/core/inc/decode_mb_aux.h
@@ -36,8 +36,6 @@
#include "typedefs.h"
#include "macros.h"
-namespace WelsDec {
-
void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
@@ -72,7 +70,5 @@
#endif//__cplusplus
void GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride);
-
-} // namespace WelsDec
#endif//WELS_DECODE_MB_AUX_H__
--- a/codec/decoder/core/inc/decode_slice.h
+++ b/codec/decoder/core/inc/decode_slice.h
@@ -35,25 +35,23 @@
#include "decoder_context.h"
-namespace WelsDec {
-
int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx);
-int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
+int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx);
-int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
+int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx);
-int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
+int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
-typedef int32_t (*PWelsDecMbFunc) (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
+typedef int32_t (*PWelsDecMbFunc) (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
-int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
-int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
-int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag);
-int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag);
-int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag);
-int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag);
+int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
+int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
+int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag);
+int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t *uiEosFlag);
+int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiEosFlag);
+int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiEosFlag);
int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx); //construction based on slice
@@ -96,8 +94,6 @@
void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu);
void WelsBlockZero16x16_c (int16_t* block, int32_t stride);
void WelsBlockZero8x8_c (int16_t* block, int32_t stride);
-
-} // namespace WelsDec
#endif //WELS_DECODE_SLICE_H__
--- a/codec/decoder/core/inc/decoder.h
+++ b/codec/decoder/core/inc/decoder.h
@@ -43,8 +43,6 @@
#include "typedefs.h"
#include "decoder_context.h"
-namespace WelsDec {
-
#ifdef __cplusplus
extern "C" {
#endif//__cplusplus
@@ -62,12 +60,12 @@
/*
* fill last decoded picture info
*/
-void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo);
+void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo *sLastDecPicInfo);
/*!
* \brief fill data fields in SPS and PPS default for decoder context
*/
-void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx);
+void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX *sSpsPpsCtx);
/*!
* \brief copy SpsPps from one Ctx to another ctx for threaded code
@@ -127,7 +125,7 @@
* request memory blocks for decoder avc part
*/
int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight,
- bool& bReallocFlag);
+ bool *bReallocFlag);
/*
@@ -175,12 +173,10 @@
void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa);
//reset picture reodering buffer list
void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo,
- const bool& bFullReset);
+ const bool *bFullReset);
#ifdef __cplusplus
}
#endif//__cplusplus
-
-} // namespace WelsDec
#endif//WELS_DECODER_SYSTEM_ARCHITECTURE_H__
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -58,7 +58,6 @@
#include "memory_align.h"
#include "wels_decoder_thread.h"
-namespace WelsDec {
#define MAX_PRED_MODE_ID_I16x16 3
#define MAX_PRED_MODE_ID_CHROMA 3
#define MAX_PRED_MODE_ID_I4x4 8
@@ -561,8 +560,8 @@
static inline int32_t GetPrevFrameNum (PWelsDecoderContext pCtx) {
if (pCtx->uiDecodingTimeStamp > 0) {
PWelsDecoderThreadCTX pThreadCtx = (PWelsDecoderThreadCTX)pCtx->pThreadCtx;
- int32_t iThreadCount = int32_t (pThreadCtx->sThreadInfo.uiThrMaxNum);
- int32_t uiThrNum = int32_t (pThreadCtx->sThreadInfo.uiThrNum);
+ int32_t iThreadCount = (int32_t) pThreadCtx->sThreadInfo.uiThrMaxNum;
+ int32_t uiThrNum = (int32_t) (pThreadCtx->sThreadInfo.uiThrNum);
for (int32_t i = 0; i < iThreadCount; ++i) {
int32_t id = i - uiThrNum;
if (id != 0 && pThreadCtx[id].pCtx->uiDecodingTimeStamp == pCtx->uiDecodingTimeStamp - 1) {
@@ -579,8 +578,5 @@
//#ifdef __cplusplus
//}
//#endif//__cplusplus
-
-
-} // namespace WelsDec
#endif//WELS_DECODER_FRAMEWORK_H__
--- a/codec/decoder/core/inc/decoder_core.h
+++ b/codec/decoder/core/inc/decoder_core.h
@@ -47,7 +47,6 @@
#include "codec_def.h"
-namespace WelsDec {
/*
* InitBsBuffer
* Memory allocation for Bitstream Buffer
@@ -199,7 +198,6 @@
bool CheckRefPicturesComplete (PWelsDecoderContext pCtx); // Check whether all ref pictures are complete
void ForceResetParaSetStatusAndAUList (PWelsDecoderContext pCtx);
-} // namespace WelsDec
#endif//WELS_DECODER_CORE_H__
--- a/codec/decoder/core/inc/error_code.h
+++ b/codec/decoder/core/inc/error_code.h
@@ -40,8 +40,6 @@
#ifndef WELS_ERROR_CODE_H__
#define WELS_ERROR_CODE_H__
-namespace WelsDec {
-
typedef enum TagWelsErr {
ERR_NONE = 0,
ERR_INVALID_PARAMETERS = 1,
@@ -214,8 +212,6 @@
ERR_INFO_PARSEONLY_ERROR,
};
//-----------------------------------------------------------------------------------------------------------
-
-} // namespace WelsDec
#endif//WELS_ERROR_CODE_H__
--- a/codec/decoder/core/inc/error_concealment.h
+++ b/codec/decoder/core/inc/error_concealment.h
@@ -42,7 +42,6 @@
#include "rec_mb.h"
#include "decoder_context.h"
-namespace WelsDec {
//Initialize error concealment
void InitErrorCon (PWelsDecoderContext pCtx);
//Do error concealment using frame copy method
@@ -61,8 +60,6 @@
// ImplementErrorConceal
// Do actual error concealment
void ImplementErrorCon (PWelsDecoderContext pCtx);
-
-} // namespace WelsDec
#endif//WELS_ERROR_CONCEALMENT_H__
--- a/codec/decoder/core/inc/fmo.h
+++ b/codec/decoder/core/inc/fmo.h
@@ -45,8 +45,6 @@
#include "parameter_sets.h"
#include "memory_align.h"
-namespace WelsDec {
-
#ifndef MB_XY_T
#define MB_XY_T int32_t
#endif//MB_XY_T
@@ -108,7 +106,5 @@
* \return iNextMb - successful; -1 - failed;
*/
MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy);
-
-} // namespace WelsDec
#endif//WELS_FLEXIBLE_MACROBLOCK_ORDERING_H__
--- a/codec/decoder/core/inc/get_intra_predictor.h
+++ b/codec/decoder/core/inc/get_intra_predictor.h
@@ -43,8 +43,6 @@
#include "typedefs.h"
-namespace WelsDec {
-
void WelsI4x4LumaPredV_c (uint8_t* pPred, const int32_t kiStride);
void WelsI4x4LumaPredH_c (uint8_t* pPred, const int32_t kiStride);
void WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride);
@@ -183,8 +181,6 @@
#if defined(__cplusplus)
}
#endif//__cplusplus
-
-} // namespace WelsDec
#endif //WELS_GET_INTRA_PREDICTOR_H__
--- a/codec/decoder/core/inc/manage_dec_ref.h
+++ b/codec/decoder/core/inc/manage_dec_ref.h
@@ -45,8 +45,6 @@
#include "typedefs.h"
#include "decoder_context.h"
-namespace WelsDec {
-
void WelsResetRefPic (PWelsDecoderContext pCtx);
void WelsResetRefPicWithoutUnRef (PWelsDecoderContext pCtx);
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc);
@@ -53,9 +51,7 @@
int32_t WelsInitBSliceRefList (PWelsDecoderContext pCtx, int32_t iPoc);
int32_t WelsReorderRefList (PWelsDecoderContext pCtx);
int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx);
-int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, PPicture pLastDec = NULL);
-
-} // namespace WelsDec
+int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, PPicture pLastDec);
#endif//WELS_MANAGE_DEC_REF_H__
--- a/codec/decoder/core/inc/mb_cache.h
+++ b/codec/decoder/core/inc/mb_cache.h
@@ -36,8 +36,6 @@
#include "typedefs.h"
-namespace WelsDec {
-
#define REF_NOT_AVAIL -2
#define REF_NOT_IN_LIST -1 //intra
@@ -74,7 +72,5 @@
int8_t iLeftCbp;
int8_t iDummy[2]; //for align
} SWelsNeighAvail, *PWelsNeighAvail;
-
-} // namespace WelsDec
#endif//WELS_MACROBLOCK_CACHE_H__
--- a/codec/decoder/core/inc/memmgr_nal_unit.h
+++ b/codec/decoder/core/inc/memmgr_nal_unit.h
@@ -46,8 +46,6 @@
#include "nalu.h"
#include "memory_align.h"
-namespace WelsDec {
-
int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize, CMemoryAlign* pMa);
int32_t MemFreeNalList (PAccessUnit* ppAu, CMemoryAlign* pMa);
@@ -58,8 +56,6 @@
* Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit
*/
PNalUnit MemGetNextNal (PAccessUnit* ppAu, CMemoryAlign* pMa);
-
-} // namespace WelsDec
#endif//WELS_MEMORY_MANAGER_NAL_UNIT_H__
--- a/codec/decoder/core/inc/mv_pred.h
+++ b/codec/decoder/core/inc/mv_pred.h
@@ -44,8 +44,6 @@
#include "dec_frame.h"
#include "decoder_context.h"
-namespace WelsDec {
-
/*!
* \brief update mv and ref_index cache for current MB, only for P_16x16 (SKIP inclusive)
* \param
@@ -98,8 +96,7 @@
* \param
* \param output iMvp[] and ref
*/
-int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A],
- SubMbType& subMbType);
+int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A], SubMbType *subMbType);
/*!
* \brief get Colocated MB for both Spatial and Temporal Direct Mode
@@ -106,13 +103,13 @@
* \param
* \param output MbType and SubMbType
*/
-int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType& mbType, SubMbType& subMbType);
+int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType *mbType, SubMbType *subMbType);
/*!
* \brief get the motion predictor for B-slice temporal direct mode 16x16
*/
int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A],
- SubMbType& subMbType);
+ SubMbType *subMbType);
/*!
* \brief get the motion params for B-slice spatial direct mode
@@ -149,8 +146,8 @@
* \param
* \param output motion vector cache and motion vector deviation cache
*/
-void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
- const SubMbType& subMbType, const bool& bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A],
+void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t iIdx8, const int8_t iPartCount, const int8_t iPartW,
+ const SubMbType subMbType, const bool bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A],
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]);
/*!
@@ -158,10 +155,7 @@
* \param
* \param output motion vector cache and motion vector deviation cache
*/
-void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount,
- const int8_t& iPartW,
- const SubMbType& subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2],
- int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]);
+void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t iIdx8, const int8_t iPartCount, const int8_t iPartW, const SubMbType subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2], int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]);
/*!
* \brief returns ref_index in List_0 from the colocated ref_index in LIST_0.
@@ -168,8 +162,8 @@
* \param
* returns ref_index in List_0 of ref picture LIST_0
*/
-int8_t MapColToList0 (PWelsDecoderContext& pCtx, const int8_t& colocRefIndexL0,
- const int32_t& ref0Count); //ISO/IEC 14496-10:2009(E) (8-193)
+int8_t MapColToList0 (PWelsDecoderContext pCtx, const int8_t colocRefIndexL0,
+ const int32_t ref0Count); //ISO/IEC 14496-10:2009(E) (8-193)
/*!
* \brief update ref_index cache for current MB, for 8x8
@@ -176,9 +170,9 @@
* \param
* \param
*/
-void Update8x8RefIdx (PDqLayer& pCurDqLayer, const int16_t& iPartIdx, const int32_t& listIdx, const int8_t& iRef);
+void Update8x8RefIdx (PDqLayer pCurDqLayer, const int16_t iPartIdx, const int32_t listIdx, const int8_t iRef);
-inline uint32_t* GetMbType (PDqLayer& pCurDqLayer) {
+static inline uint32_t* GetMbType (PDqLayer pCurDqLayer) {
if (pCurDqLayer->pDec != NULL) {
return pCurDqLayer->pDec->pMbType;
} else {
@@ -185,7 +179,5 @@
return pCurDqLayer->pMbType;
}
}
-
-} // namespace WelsDec
#endif//WELS_MV_PRED_H__
--- a/codec/decoder/core/inc/nal_prefix.h
+++ b/codec/decoder/core/inc/nal_prefix.h
@@ -38,8 +38,6 @@
#include "wels_common_basis.h"
#include "slice.h"
-namespace WelsDec {
-
///////////////////////////////////NAL Unit prefix/headers///////////////////////////////////
/* Prefix NAL Unix syntax, refer to Page 392 in JVT X201wcm */
@@ -50,7 +48,5 @@
bool bPrefixNalUnitExtFlag;
bool bPrefixNalCorrectFlag;
} SPrefixNalUnit, *PPrefixNalUnit;
-
-} // namespace WelsDec
#endif//WELS_NAL_UNIT_PREFIX_H__
--- a/codec/decoder/core/inc/nalu.h
+++ b/codec/decoder/core/inc/nalu.h
@@ -39,8 +39,6 @@
#include "nal_prefix.h"
#include "bit_stream.h"
-namespace WelsDec {
-
///////////////////////////////////NAL UNIT level///////////////////////////////////
/* NAL Unit Structure */
@@ -73,7 +71,5 @@
uint32_t uiEndPos;
bool bCompletedAuFlag; // Indicate whether it is a completed AU
} SAccessUnit, *PAccessUnit;
-
-} // namespace WelsDec
#endif//WELS_NAL_UNIT_H__
--- a/codec/decoder/core/inc/parameter_sets.h
+++ b/codec/decoder/core/inc/parameter_sets.h
@@ -37,7 +37,6 @@
#include "wels_const.h"
#include "wels_common_basis.h"
-namespace WelsDec {
/* VUI syntax in Sequence Parameter Set, refer to E.1 in Rec */
typedef struct TagVui {
bool bAspectRatioInfoPresentFlag;
@@ -211,7 +210,5 @@
int32_t iSecondChromaQPIndexOffset; //second_chroma_qp_index_offset
} SPps, *PPps;
-
-} // namespace WelsDec
#endif //WELS_PARAMETER_SETS_H__
--- a/codec/decoder/core/inc/parse_mb_syn_cabac.h
+++ b/codec/decoder/core/inc/parse_mb_syn_cabac.h
@@ -41,18 +41,18 @@
#include "decoder_context.h"
#include "cabac_decoder.h"
-namespace WelsDec {
-int32_t ParseEndOfSliceCabac (PWelsDecoderContext pCtx, uint32_t& uiBinVal);
-int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSkip);
-int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal);
-int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal);
-int32_t ParseMBTypeBSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal);
+
+int32_t ParseEndOfSliceCabac (PWelsDecoderContext pCtx, uint32_t *uiBinVal);
+int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiSkip);
+int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiBinVal);
+int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiBinVal);
+int32_t ParseMBTypeBSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiBinVal);
int32_t ParseTransformSize8x8FlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail,
- bool& bTransformSize8x8Flag);
-int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType);
-int32_t ParseBSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType);
-int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t& iBinVal);
-int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeighAvail, int32_t& iBinVal);
+ bool *bTransformSize8x8Flag);
+int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiSubMbType);
+int32_t ParseBSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiSubMbType);
+int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t *iBinVal);
+int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeighAvail, int32_t *iBinVal);
int32_t ParseInterPMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A], int8_t pRefIndex[LIST_A][30]);
int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
@@ -60,15 +60,15 @@
int8_t pDirect[30]);
int32_t ParseRefIdxCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* nzc,
int8_t ref_idx[LIST_A][30], int8_t direct[30],
- int32_t iListIdx, int32_t index, int32_t iActiveRefNum, int32_t b8mode, int8_t& iRefIdxVal);
+ int32_t iListIdx, int32_t index, int32_t iActiveRefNum, int32_t b8mode, int8_t *iRefIdxVal);
int32_t ParseMvdInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, int8_t pRefIndex[LIST_A][30],
- int16_t pMvdCache[LIST_A][30][2], int32_t index, int8_t iListIdx, int8_t iMvComp, int16_t& iMvdVal);
-int32_t ParseCbpInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal);
-int32_t ParseDeltaQpCabac (PWelsDecoderContext pCtx, int32_t& iQpDelta);
+ int16_t pMvdCache[LIST_A][30][2], int32_t index, int8_t iListIdx, int8_t iMvComp, int16_t *iMvdVal);
+int32_t ParseCbpInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiBinVal);
+int32_t ParseDeltaQpCabac (PWelsDecoderContext pCtx, int32_t *iQpDelta);
int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int32_t index, int32_t iResProperty,
- PWelsDecoderContext pCtx, uint32_t& uiCbpBit);
+ PWelsDecoderContext pCtx, uint32_t *uiCbpBit);
int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty, PWelsDecoderContext pCtx,
- uint32_t& uiBinVal);
+ uint32_t *uiBinVal);
int32_t ParseSignificantCoeffCabac (int32_t* significant, int32_t iResProperty, PWelsDecoderContext pCtx);
int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux,
int32_t index, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty, int16_t* sTCoeff, uint8_t uiQp,
@@ -82,8 +82,7 @@
const int8_t iListIdx);
void UpdateP8x8DirectCabac (PDqLayer pCurDqLayer, int32_t iPartIdx);
void UpdateP16x16DirectCabac (PDqLayer pCurDqLayer);
-void UpdateP8x8RefCacheIdxCabac (int8_t pRefIndex[LIST_A][30], const int16_t& iPartIdx, const int32_t& listIdx,
- const int8_t& iRef);
-}
+void UpdateP8x8RefCacheIdxCabac (int8_t pRefIndex[LIST_A][30], const int16_t iPartIdx, const int32_t listIdx,
+ const int8_t iRef);
//#pragma pack()
#endif
--- a/codec/decoder/core/inc/parse_mb_syn_cavlc.h
+++ b/codec/decoder/core/inc/parse_mb_syn_cavlc.h
@@ -47,10 +47,7 @@
#include "dec_frame.h"
#include "slice.h"
-namespace WelsDec {
-
-
void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurDqLayer);
void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurDqLayer);
void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
@@ -133,5 +130,5 @@
PBitStringAux pBs);
int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A],
int8_t iRefIdxArray[LIST_A][30], PBitStringAux pBs);
-} // namespace WelsDec
+
#endif//WELS_PARSE_MB_SYN_CAVLC_H__
--- a/codec/decoder/core/inc/pic_queue.h
+++ b/codec/decoder/core/inc/pic_queue.h
@@ -37,8 +37,6 @@
#include "picture.h"
-namespace WelsDec {
-
#define PICTURE_RESOLUTION_ALIGNMENT 32
@@ -55,8 +53,6 @@
PPicture PrefetchPic (PPicBuff pPicBuff); // To get current node applicable
PPicture PrefetchPicForThread (PPicBuff pPicBuff); // To get current node applicable in the case of threaded mode
PPicture PrefetchLastPicForThread (PPicBuff pPicBuff,
- const int32_t& iLast); // To get last node applicable in the case of threaded mode
-
-} // namespace WelsDec
+ const int32_t iLast); // To get last node applicable in the case of threaded mode
#endif//WELS_PICTURE_QUEUE_H__
--- a/codec/decoder/core/inc/picture.h
+++ b/codec/decoder/core/inc/picture.h
@@ -39,15 +39,13 @@
#include "wels_const_common.h"
#include "wels_decoder_thread.h"
-using namespace WelsCommon;
-
-namespace WelsDec {
-
/*
* Reconstructed Picture definition
* It is used to express reference picture, also consequent reconstruction picture for output
*/
+typedef struct SPicture SPicture;
+
struct SPicture {
/************************************payload data*********************************/
uint8_t* pBuffer[4]; // pointer to the first allocated byte, basical offset of buffer, dimension:
@@ -105,7 +103,5 @@
};// "Picture" declaration is comflict with Mac system
typedef struct SPicture* PPicture;
-
-} // namespace WelsDec
#endif//WELS_PICTURE_H__
--- a/codec/decoder/core/inc/rec_mb.h
+++ b/codec/decoder/core/inc/rec_mb.h
@@ -47,8 +47,6 @@
#include "decoder_context.h"
-namespace WelsDec {
-
#define WELS_B_MB_REC_VERIFY(uiRet) do{ \
uint32_t uiRetTmp = (uint32_t)uiRet; \
if( uiRetTmp != ERR_NONE ) \
@@ -74,7 +72,7 @@
int32_t iPicHeight;
} sMCRefMember;
-void BaseMC (PWelsDecoderContext pCtx, sMCRefMember* pMCRefMem, const int32_t& listIdx, const int8_t& iRefIdx,
+void BaseMC (PWelsDecoderContext pCtx, sMCRefMember* pMCRefMem, const int32_t listIdx, const int8_t iRefIdx,
int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]);
@@ -97,8 +95,6 @@
int32_t GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx);
int32_t GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWelsDecoderContext pCtx);
-
-} // namespace WelsDec
#endif //WELS_REC_MB_H__
--- a/codec/decoder/core/inc/slice.h
+++ b/codec/decoder/core/inc/slice.h
@@ -40,8 +40,6 @@
#include "picture.h"
#include "parameter_sets.h"
-namespace WelsDec {
-
/*
* Reference picture list reordering syntax, refer to page 64 in JVT X201wcm
*/
@@ -202,7 +200,5 @@
int32_t iLastDeltaQp;
int16_t iMvScale[LIST_A][MAX_DPB_COUNT]; //Moton vector scale For Temporal Direct Mode Type
} SSlice, *PSlice;
-
-} // namespace WelsDec
#endif//WELS_SLICE_H__
--- a/codec/decoder/core/inc/vlc_decoder.h
+++ b/codec/decoder/core/inc/vlc_decoder.h
@@ -36,8 +36,6 @@
#include "bit_stream.h"
#include "dec_golomb.h"
-namespace WelsDec {
-
typedef struct TagVlcTable {
const uint8_t (*kpCoeffTokenVlcTable[4][8])[2];
const uint8_t (*kpChromaCoeffTokenVlcTable)[2];
@@ -171,7 +169,5 @@
pVlcTable->kpTotalZerosTable[1][2] = g_kuiTotalZerosChromaTable2;
}
-
-} // namespace WelsDec
#endif//WELS_VLC_DECODER_H__
--- a/codec/decoder/core/inc/wels_common_basis.h
+++ b/codec/decoder/core/inc/wels_common_basis.h
@@ -39,10 +39,6 @@
#include "wels_common_defs.h"
-using namespace WelsCommon;
-
-namespace WelsDec {
-
/*common use table*/
extern const uint8_t g_kuiScan8[24];
extern const uint8_t g_kuiLumaDcZigzagScan[16];
@@ -310,8 +306,5 @@
{18, 11}, {15, 11}, {64, 33}, {160, 99}, { 4, 3}, //10~14
{ 3, 2}, { 2, 1} //15~16
};
-
-
-} // namespace WelsDec
#endif//WELS_COMMON_BASIS_H__
--- a/codec/decoder/core/inc/wels_decoder_thread.h
+++ b/codec/decoder/core/inc/wels_decoder_thread.h
@@ -43,40 +43,9 @@
#include "WelsThreadLib.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+typedef int WELS_MUTEX_ATTR;
-#define WELS_DEC_MAX_NUM_CPU 16
-#define WELS_DEC_MAX_THREAD_STACK_SIZE 4096
-#define WELS_DEC_THREAD_COMMAND_RUN 0
-#define WELS_DEC_THREAD_COMMAND_ABORT 1
-
-#if defined(_WIN32) || defined(__CYGWIN__)
typedef struct tagWelsDecSemphore {
- WELS_THREAD_HANDLE h;
-} SWelsDecSemphore;
-
-typedef struct tagWelsDecEvent {
- WELS_THREAD_HANDLE h;
- int isSignaled;
-} SWelsDecEvent;
-
-typedef struct tagWelsDecThread {
- WELS_THREAD_HANDLE h;
-} SWelsDecThread;
-
-#define WelsDecThreadFunc(fn,a) DWORD WINAPI fn(LPVOID a)
-#define WelsDecThreadFuncArg(a) LPWELS_THREAD_ROUTINE a
-#define WELS_DEC_THREAD_WAIT_TIMEDOUT WAIT_TIMEOUT
-#define WELS_DEC_THREAD_WAIT_SIGNALED WAIT_OBJECT_0
-#define WELS_DEC_THREAD_WAIT_INFINITE INFINITE
-
-#else // NON-WINDOWS
-
-typedef pthread_mutexattr_t WELS_MUTEX_ATTR;
-
-typedef struct tagWelsDecSemphore {
long max;
long v;
WELS_EVENT e;
@@ -86,7 +55,7 @@
typedef struct tagWelsDecEvent {
int manualReset;
int isSignaled;
- pthread_cond_t c;
+ int c;
WELS_MUTEX m;
} SWelsDecEvent;
@@ -101,8 +70,6 @@
#define WELS_DEC_THREAD_WAIT_SIGNALED EINTR
#define WELS_DEC_THREAD_WAIT_INFINITE -1
-#endif//_WIN32
-
#define WelsDecThreadReturn WELS_THREAD_ROUTINE_RETURN(0);
int32_t GetCPUCount();
@@ -162,9 +129,5 @@
#define WAIT_SEMAPHORE(ph,timeout) \
SemWait(ph,(int32_t)timeout)
-
-#ifdef __cplusplus
-}
-#endif
#endif
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -48,7 +48,6 @@
#define _PARSE_NALHRD_VCLHRD_PARAMS_ 1
-namespace WelsDec {
/*!
*************************************************************************************
* \brief Start Code Prefix (0x 00 00 00 01) detection
@@ -107,13 +106,13 @@
*/
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;
+ PNalUnit pCurNal;
uint8_t* pNal = pSrcRbsp;
int32_t iNalSize = iSrcRbspLen;
- PBitStringAux pBs = NULL;
+ PBitStringAux pBs;
bool bExtensionFlag = false;
- int32_t iErr = ERR_NONE;
- int32_t iBitSize = 0;
+ int32_t iErr;
+ int32_t iBitSize;
SDataBuffer* pSavedData = &pCtx->sSavedData;
SLogContext* pLogCtx = & (pCtx->sLogCtx);
pNalUnitHeader->eNalUnitType = NAL_UNIT_UNSPEC_0;//SHOULD init it. because pCtx->sCurNalHead is common variable.
@@ -121,7 +120,7 @@
//remove the consecutive ZERO at the end of current NAL in the reverse order.--2011.6.1
{
int32_t iIndex = iSrcRbspLen - 1;
- uint8_t uiBsZero = 0;
+ uint8_t uiBsZero;
while (iIndex >= 0) {
uiBsZero = pSrcRbsp[iIndex];
if (0 == uiBsZero) {
@@ -266,7 +265,7 @@
bExtensionFlag = true;
case NAL_UNIT_CODED_SLICE:
case NAL_UNIT_CODED_SLICE_IDR: {
- PAccessUnit pCurAu = NULL;
+ PAccessUnit pCurAu;
uint32_t uiAvailNalNum;
pCurNal = MemGetNextNal (&pCtx->pAccessUnitList, pCtx->pMemAlign);
if (NULL == pCurNal) {
@@ -574,11 +573,11 @@
*/
int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen, uint8_t* pSrcNal,
const int32_t kSrcNalLen) {
- PBitStringAux pBs = NULL;
- EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; // make initial value as unspecified
+ PBitStringAux pBs;
+ EWelsNalUnitType eNalType; // make initial value as unspecified
int32_t iPicWidth = 0;
int32_t iPicHeight = 0;
- int32_t iBitSize = 0;
+ int32_t iBitSize;
int32_t iErr = ERR_NONE;
if (kiSrcLen <= 0)
return iErr;
@@ -720,7 +719,7 @@
int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs) {
- PSpsSvcExt pExt = NULL;
+ PSpsSvcExt pExt;
uint32_t uiCode;
int32_t iCode;
@@ -832,7 +831,6 @@
default:
return NULL;
}
- return NULL;
}
bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
@@ -912,8 +910,8 @@
uint8_t* pSrcNal, const int32_t kSrcNalLen) {
PBitStringAux pBs = pBsAux;
SSubsetSps sTempSubsetSps;
- PSps pSps = NULL;
- PSubsetSps pSubsetSps = NULL;
+ PSps pSps;
+ PSubsetSps pSubsetSps;
SNalUnitHeader* pNalHead = &pCtx->sCurNalHead;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
@@ -920,7 +918,7 @@
int32_t iSpsId;
uint32_t uiCode;
int32_t iCode;
- int32_t iRet = ERR_NONE;
+ int32_t iRet;
bool bConstraintSetFlags[6] = { false };
const bool kbUseSubsetFlag = IS_SUBSET_SPS_NAL (pNalHead->eNalUnitType);
@@ -1185,7 +1183,7 @@
SBitStringAux sSubsetSpsBs;
CMemoryAlign* pMa = pCtx->pMemAlign;
- uint8_t* pBsBuf = static_cast<uint8_t*> (pMa->WelsMallocz (SPS_PPS_BS_SIZE + 4,
+ uint8_t* pBsBuf = (uint8_t*) (pMa->WelsMallocz (SPS_PPS_BS_SIZE + 4,
"Temp buffer for parse only usage.")); //to reserve 4 bytes for UVLC writing buffer
if (NULL == pBsBuf) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "sps buffer alloc failed for parse only!");
@@ -1258,7 +1256,7 @@
*pPicWidth = pSps->iMbWidth << 4;
*pPicHeight = pSps->iMbHeight << 4;
- PSps pTmpSps = NULL;
+ PSps pTmpSps;
if (kbUseSubsetFlag) {
pTmpSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId].sSps;
} else {
@@ -1325,10 +1323,10 @@
*/
int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, uint8_t* pSrcNal,
const int32_t kSrcNalLen) {
-
- PPps pPps = NULL;
+ USED(pPpsList);
+ PPps pPps;
SPps sTempPps;
- uint32_t uiPpsId = 0;
+ uint32_t uiPpsId;
uint32_t iTmp;
uint32_t uiCode;
int32_t iCode;
@@ -1545,7 +1543,7 @@
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //timing_info_present_flag
pVui->bTimingInfoPresentFlag = !!uiCode;
if (pVui->bTimingInfoPresentFlag) {
- uint32_t uiTmp = 0;
+ uint32_t uiTmp;
WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //num_units_in_tick
uiTmp = (uiCode << 16);
WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //num_units_in_tick
@@ -1657,7 +1655,8 @@
*/
int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type
-
+ USED(pSei);
+ USED(pBsAux);
return ERR_NONE;
}
/*
@@ -1783,5 +1782,3 @@
}
return iCountNum;
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/bit_stream.cpp
+++ b/codec/decoder/core/src/bit_stream.cpp
@@ -40,10 +40,8 @@
#include "bit_stream.h"
#include "error_code.h"
-namespace WelsDec {
-
inline uint32_t GetValue4Bytes (uint8_t* pDstNal) {
- uint32_t uiValue = 0;
+ uint32_t uiValue;
uiValue = (pDstNal[0] << 24) | (pDstNal[1] << 16) | (pDstNal[2] << 8) | (pDstNal[3]);
return uiValue;
}
@@ -105,6 +103,3 @@
*pDstPointer++ = *pSrcPointer++;
}
}
-
-} // namespace WelsDec
-
--- a/codec/decoder/core/src/cabac_decoder.cpp
+++ b/codec/decoder/core/src/cabac_decoder.cpp
@@ -31,7 +31,7 @@
* cabac_decoder.cpp: deals with cabac state transition and related functions
*/
#include "cabac_decoder.h"
-namespace WelsDec {
+
static const int16_t g_kMvdBinPos2Ctx [8] = {0, 1, 2, 3, 3, 3, 3, 3};
void WelsCabacGlobalInit (PWelsDecoderContext pCtx) {
@@ -41,8 +41,8 @@
int32_t m = g_kiCabacGlobalContextIdx[iIdx][iModel][0];
int32_t n = g_kiCabacGlobalContextIdx[iIdx][iModel][1];
int32_t iPreCtxState = WELS_CLIP3 ((((m * iQp) >> 4) + n), 1, 126);
- uint8_t uiValMps = 0;
- uint8_t uiStateIdx = 0;
+ uint8_t uiValMps;
+ uint8_t uiStateIdx;
if (iPreCtxState <= 63) {
uiStateIdx = 63 - iPreCtxState;
uiValMps = 0;
@@ -59,7 +59,8 @@
// ------------------- 1. context initialization
void WelsCabacContextInit (PWelsDecoderContext pCtx, uint8_t eSliceType, int32_t iCabacInitIdc, int32_t iQp) {
- int32_t iIdx = pCtx->eSliceType == WelsCommon::I_SLICE ? 0 : iCabacInitIdc + 1;
+ int32_t iIdx = pCtx->eSliceType == I_SLICE ? 0 : iCabacInitIdc + 1;
+ (void)eSliceType;
if (!pCtx->bCabacInited) {
WelsCabacGlobalInit (pCtx);
}
@@ -102,43 +103,43 @@
}
// ------------------- 3. actual decoding
-int32_t Read32BitsCabac (PWelsCabacDecEngine pDecEngine, uint32_t& uiValue, int32_t& iNumBitsRead) {
+int32_t Read32BitsCabac (PWelsCabacDecEngine pDecEngine, uint32_t *uiValue, int32_t *iNumBitsRead) {
intX_t iLeftBytes = pDecEngine->pBuffEnd - pDecEngine->pBuffCurr;
- iNumBitsRead = 0;
- uiValue = 0;
+ *iNumBitsRead = 0;
+ *uiValue = 0;
if (iLeftBytes <= 0) {
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_CABAC_NO_BS_TO_READ);
}
switch (iLeftBytes) {
case 3:
- uiValue = ((pDecEngine->pBuffCurr[0]) << 16 | (pDecEngine->pBuffCurr[1]) << 8 | (pDecEngine->pBuffCurr[2]));
+ *uiValue = ((pDecEngine->pBuffCurr[0]) << 16 | (pDecEngine->pBuffCurr[1]) << 8 | (pDecEngine->pBuffCurr[2]));
pDecEngine->pBuffCurr += 3;
- iNumBitsRead = 24;
+ *iNumBitsRead = 24;
break;
case 2:
- uiValue = ((pDecEngine->pBuffCurr[0]) << 8 | (pDecEngine->pBuffCurr[1]));
+ *uiValue = ((pDecEngine->pBuffCurr[0]) << 8 | (pDecEngine->pBuffCurr[1]));
pDecEngine->pBuffCurr += 2;
- iNumBitsRead = 16;
+ *iNumBitsRead = 16;
break;
case 1:
- uiValue = pDecEngine->pBuffCurr[0];
+ *uiValue = pDecEngine->pBuffCurr[0];
pDecEngine->pBuffCurr += 1;
- iNumBitsRead = 8;
+ *iNumBitsRead = 8;
break;
default:
- uiValue = ((pDecEngine->pBuffCurr[0] << 24) | (pDecEngine->pBuffCurr[1]) << 16 | (pDecEngine->pBuffCurr[2]) << 8 |
+ *uiValue = ((pDecEngine->pBuffCurr[0] << 24) | (pDecEngine->pBuffCurr[1]) << 16 | (pDecEngine->pBuffCurr[2]) << 8 |
(pDecEngine->pBuffCurr[3]));
pDecEngine->pBuffCurr += 4;
- iNumBitsRead = 32;
+ *iNumBitsRead = 32;
break;
}
return ERR_NONE;
}
-int32_t DecodeBinCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t& uiBinVal) {
- int32_t iErrorInfo = ERR_NONE;
+int32_t DecodeBinCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t *uiBinVal) {
+ int32_t iErrorInfo;
uint32_t uiState = pBinCtx->uiState;
- uiBinVal = pBinCtx->uiMPS;
+ *uiBinVal = pBinCtx->uiMPS;
uint64_t uiOffset = pDecEngine->uiOffset;
uint64_t uiRange = pDecEngine->uiRange;
@@ -147,7 +148,7 @@
uiRange -= uiRangeLPS;
if (uiOffset >= (uiRange << pDecEngine->iBitsLeft)) { //LPS
uiOffset -= (uiRange << pDecEngine->iBitsLeft);
- uiBinVal ^= 0x0001;
+ *uiBinVal ^= 0x0001;
if (!uiState)
pBinCtx->uiMPS ^= 0x01;
pBinCtx->uiState = g_kuiStateTransTable[uiState][0];
@@ -171,7 +172,7 @@
}
uint32_t uiVal = 0;
int32_t iNumBitsRead = 0;
- iErrorInfo = Read32BitsCabac (pDecEngine, uiVal, iNumBitsRead);
+ iErrorInfo = Read32BitsCabac (pDecEngine, &uiVal, &iNumBitsRead);
pDecEngine->uiOffset = (uiOffset << iNumBitsRead) | uiVal;
pDecEngine->iBitsLeft += iNumBitsRead;
if (iErrorInfo && pDecEngine->iBitsLeft < 0) {
@@ -180,8 +181,8 @@
return ERR_NONE;
}
-int32_t DecodeBypassCabac (PWelsCabacDecEngine pDecEngine, uint32_t& uiBinVal) {
- int32_t iErrorInfo = ERR_NONE;
+int32_t DecodeBypassCabac (PWelsCabacDecEngine pDecEngine, uint32_t *uiBinVal) {
+ int32_t iErrorInfo;
int32_t iBitsLeft = pDecEngine->iBitsLeft;
uint64_t uiOffset = pDecEngine->uiOffset;
uint64_t uiRangeValue;
@@ -190,7 +191,7 @@
if (iBitsLeft <= 0) {
uint32_t uiVal = 0;
int32_t iNumBitsRead = 0;
- iErrorInfo = Read32BitsCabac (pDecEngine, uiVal, iNumBitsRead);
+ iErrorInfo = Read32BitsCabac (pDecEngine, &uiVal, &iNumBitsRead);
uiOffset = (uiOffset << iNumBitsRead) | uiVal;
iBitsLeft = iNumBitsRead;
if (iErrorInfo && iBitsLeft == 0) {
@@ -202,24 +203,24 @@
if (uiOffset >= uiRangeValue) {
pDecEngine->iBitsLeft = iBitsLeft;
pDecEngine->uiOffset = uiOffset - uiRangeValue;
- uiBinVal = 1;
+ *uiBinVal = 1;
return ERR_NONE;
}
pDecEngine->iBitsLeft = iBitsLeft;
pDecEngine->uiOffset = uiOffset;
- uiBinVal = 0;
+ *uiBinVal = 0;
return ERR_NONE;
}
-int32_t DecodeTerminateCabac (PWelsCabacDecEngine pDecEngine, uint32_t& uiBinVal) {
+int32_t DecodeTerminateCabac (PWelsCabacDecEngine pDecEngine, uint32_t *uiBinVal) {
int32_t iErrorInfo = ERR_NONE;
uint64_t uiRange = pDecEngine->uiRange - 2;
uint64_t uiOffset = pDecEngine->uiOffset;
if (uiOffset >= (uiRange << pDecEngine->iBitsLeft)) {
- uiBinVal = 1;
+ *uiBinVal = 1;
} else {
- uiBinVal = 0;
+ *uiBinVal = 0;
// Renorm
if (uiRange < WELS_CABAC_QUARTER) {
int32_t iRenorm = g_kRenormTable256[uiRange];
@@ -228,7 +229,7 @@
if (pDecEngine->iBitsLeft < 0) {
uint32_t uiVal = 0;
int32_t iNumBitsRead = 0;
- iErrorInfo = Read32BitsCabac (pDecEngine, uiVal, iNumBitsRead);
+ iErrorInfo = Read32BitsCabac (pDecEngine, &uiVal, &iNumBitsRead);
pDecEngine->uiOffset = (pDecEngine->uiOffset << iNumBitsRead) | uiVal;
pDecEngine->iBitsLeft += iNumBitsRead;
}
@@ -245,30 +246,30 @@
}
int32_t DecodeUnaryBinCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, int32_t iCtxOffset,
- uint32_t& uiSymVal) {
- uiSymVal = 0;
+ uint32_t *uiSymVal) {
+ *uiSymVal = 0;
WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, uiSymVal));
- if (uiSymVal == 0) {
+ if (*uiSymVal == 0) {
return ERR_NONE;
} else {
uint32_t uiCode;
pBinCtx += iCtxOffset;
- uiSymVal = 0;
+ *uiSymVal = 0;
do {
- WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, uiCode));
- ++uiSymVal;
+ WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, &uiCode));
+ ++(*uiSymVal);
} while (uiCode != 0);
return ERR_NONE;
}
}
-int32_t DecodeExpBypassCabac (PWelsCabacDecEngine pDecEngine, int32_t iCount, uint32_t& uiSymVal) {
+int32_t DecodeExpBypassCabac (PWelsCabacDecEngine pDecEngine, int32_t iCount, uint32_t *uiSymVal) {
uint32_t uiCode;
int32_t iSymTmp = 0;
int32_t iSymTmp2 = 0;
- uiSymVal = 0;
+ *uiSymVal = 0;
do {
- WELS_READ_VERIFY (DecodeBypassCabac (pDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeBypassCabac (pDecEngine, &uiCode));
if (uiCode == 1) {
iSymTmp += (1 << iCount);
++iCount;
@@ -279,55 +280,54 @@
}
while (iCount--) {
- WELS_READ_VERIFY (DecodeBypassCabac (pDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeBypassCabac (pDecEngine, &uiCode));
if (uiCode == 1) {
iSymTmp2 |= (1 << iCount);
}
}
- uiSymVal = (uint32_t) (iSymTmp + iSymTmp2);
+ *uiSymVal = (uint32_t) (iSymTmp + iSymTmp2);
return ERR_NONE;
}
-uint32_t DecodeUEGLevelCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t& uiCode) {
- uiCode = 0;
+uint32_t DecodeUEGLevelCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t *uiCode) {
+ *uiCode = 0;
WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, uiCode));
- if (uiCode == 0)
+ if (*uiCode == 0)
return ERR_NONE;
else {
uint32_t uiTmp, uiCount = 1;
- uiCode = 0;
+ *uiCode = 0;
do {
- WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, uiTmp));
- ++uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, &uiTmp));
+ ++(*uiCode);
++uiCount;
} while (uiTmp != 0 && uiCount != 13);
if (uiTmp != 0) {
- WELS_READ_VERIFY (DecodeExpBypassCabac (pDecEngine, 0, uiTmp));
- uiCode += uiTmp + 1;
+ WELS_READ_VERIFY (DecodeExpBypassCabac (pDecEngine, 0, &uiTmp));
+ *uiCode += uiTmp + 1;
}
return ERR_NONE;
}
- return ERR_NONE;
}
-int32_t DecodeUEGMvCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t iMaxBin, uint32_t& uiCode) {
+int32_t DecodeUEGMvCabac (PWelsCabacDecEngine pDecEngine, PWelsCabacCtx pBinCtx, uint32_t iMaxBin, uint32_t *uiCode) {
+ USED(iMaxBin);
WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx + g_kMvdBinPos2Ctx[0], uiCode));
- if (uiCode == 0)
+ if (*uiCode == 0)
return ERR_NONE;
else {
uint32_t uiTmp, uiCount = 1;
- uiCode = 0;
+ *uiCode = 0;
do {
- WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx + g_kMvdBinPos2Ctx[uiCount++], uiTmp));
- uiCode++;
+ WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx + g_kMvdBinPos2Ctx[uiCount++], &uiTmp));
+ (*uiCode)++;
} while (uiTmp != 0 && uiCount != 8);
if (uiTmp != 0) {
- WELS_READ_VERIFY (DecodeExpBypassCabac (pDecEngine, 3, uiTmp));
- uiCode += (uiTmp + 1);
+ WELS_READ_VERIFY (DecodeExpBypassCabac (pDecEngine, 3, &uiTmp));
+ *uiCode += (uiTmp + 1);
}
return ERR_NONE;
}
-}
}
--- a/codec/decoder/core/src/deblocking.cpp
+++ b/codec/decoder/core/src/deblocking.cpp
@@ -42,8 +42,6 @@
#include "deblocking_common.h"
#include "cpu_core.h"
-namespace WelsDec {
-
#define NO_SUPPORTED_FILTER_IDX (-1)
#define LEFT_FLAG_BIT 0
#define TOP_FLAG_BIT 1
@@ -672,8 +670,8 @@
int32_t iMbY = pCurDqLayer->iMbY;
int32_t iMbX = pCurDqLayer->iMbX;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
- bool bLeftFlag = false;
- bool bTopFlag = false;
+ bool bLeftFlag;
+ bool bTopFlag;
if (2 == iFilterIdc) {
bLeftFlag = (iMbX > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - 1]);
@@ -720,6 +718,7 @@
void FilteringEdgeLumaIntraH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
+ USED(pBS);
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@@ -734,6 +733,7 @@
}
void FilteringEdgeLumaIntraV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
+ USED(pBS);
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@@ -748,6 +748,7 @@
}
void FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
+ USED(pBS);
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@@ -821,6 +822,7 @@
void FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
+ USED(pBS);
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@@ -851,6 +853,7 @@
void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
uint8_t* pBS) {
+ USED(pBS);
int32_t iIndexA;
int32_t iAlpha;
int32_t iBeta;
@@ -1221,7 +1224,7 @@
SDeblockingFilter pFilter;
memset (&pFilter, 0, sizeof (pFilter));
PFmo pFmo = pCtx->pFmo;
- int32_t iNextMbXyIndex = 0;
+ int32_t iNextMbXyIndex;
int32_t iTotalNumMb = pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice;
int32_t iCountNumMb = 0;
int32_t iBoundryFlag;
@@ -1285,30 +1288,30 @@
*
* \return NONE
*/
-void WelsDeblockingInitFilter (PWelsDecoderContext pCtx, SDeblockingFilter& pFilter, int32_t& iFilterIdc) {
+void WelsDeblockingInitFilter (PWelsDecoderContext pCtx, SDeblockingFilter *pFilter, int32_t *iFilterIdc) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;
- memset (&pFilter, 0, sizeof (pFilter));
+ memset (pFilter, 0, sizeof (*pFilter));
- iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc;
+ *iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc;
/* Step1: parameters set */
- pFilter.pCsData[0] = pCtx->pDec->pData[0];
- pFilter.pCsData[1] = pCtx->pDec->pData[1];
- pFilter.pCsData[2] = pCtx->pDec->pData[2];
+ pFilter->pCsData[0] = pCtx->pDec->pData[0];
+ pFilter->pCsData[1] = pCtx->pDec->pData[1];
+ pFilter->pCsData[2] = pCtx->pDec->pData[2];
- pFilter.iCsStride[0] = pCtx->pDec->iLinesize[0];
- pFilter.iCsStride[1] = pCtx->pDec->iLinesize[1];
+ pFilter->iCsStride[0] = pCtx->pDec->iLinesize[0];
+ pFilter->iCsStride[1] = pCtx->pDec->iLinesize[1];
- pFilter.eSliceType = (EWelsSliceType)pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType;
+ pFilter->eSliceType = (EWelsSliceType)pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType;
- pFilter.iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset;
- pFilter.iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset;
+ pFilter->iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset;
+ pFilter->iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset;
- pFilter.pLoopf = &pCtx->sDeblockingFunc;
- pFilter.pRefPics[0] = pCtx->sRefPic.pRefList[0];
- pFilter.pRefPics[1] = pCtx->sRefPic.pRefList[1];
+ pFilter->pLoopf = &pCtx->sDeblockingFunc;
+ pFilter->pRefPics[0] = pCtx->sRefPic.pRefList[0];
+ pFilter->pRefPics[1] = pCtx->sRefPic.pRefList[1];
}
/*!
@@ -1318,12 +1321,12 @@
*
* \return NONE
*/
-void WelsDeblockingFilterMB (PDqLayer pCurDqLayer, SDeblockingFilter& pFilter, int32_t& iFilterIdc,
+void WelsDeblockingFilterMB (PDqLayer pCurDqLayer, SDeblockingFilter *pFilter, int32_t *iFilterIdc,
PDeblockingFilterMbFunc pDeblockMb) {
/* macroblock deblocking */
- if (0 == iFilterIdc || 2 == iFilterIdc) {
- int32_t iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, iFilterIdc);
- pDeblockMb (pCurDqLayer, &pFilter, iBoundryFlag);
+ if (0 == *iFilterIdc || 2 == *iFilterIdc) {
+ int32_t iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, *iFilterIdc);
+ pDeblockMb (pCurDqLayer, pFilter, iBoundryFlag);
}
}
/*!
@@ -1336,6 +1339,8 @@
*/
void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) {
+ USED(iCpu);
+
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c;
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c;
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c;
@@ -1418,5 +1423,3 @@
}
#endif//HAVE_MSA
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/decode_mb_aux.cpp
+++ b/codec/decoder/core/src/decode_mb_aux.cpp
@@ -30,13 +30,9 @@
*
*/
-#include <string.h>
-
#include "decode_mb_aux.h"
#include "wels_common_basis.h"
-namespace WelsDec {
-
//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 IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
@@ -186,5 +182,3 @@
pOffset[20 + i] = ((kuiA & 0x07) + (kiUVStride/*>>1*/) * (kuiA >> 3)) << 2;
}
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -50,13 +50,11 @@
#include "cpu_core.h"
-namespace WelsDec {
-
extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);
-static bool CheckRefPics (const PWelsDecoderContext& pCtx) {
+static bool CheckRefPics (const PWelsDecoderContext pCtx) {
int32_t listCount = 1;
if (pCtx->eSliceType == B_SLICE) {
++listCount;
@@ -88,7 +86,7 @@
int32_t iCurLayerWidth = pCurDqLayer->iMbWidth << 4;
int32_t iCurLayerHeight = pCurDqLayer->iMbHeight << 4;
- int32_t iNextMbXyIndex = 0;
+ int32_t iNextMbXyIndex;
PFmo pFmo = pCtx->pFmo;
int32_t iTotalNumMb = pCurSlice->iTotalMbInCurSlice;
@@ -451,15 +449,15 @@
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t iFinalMode, i;
- uint8_t uiNeighAvail = 0;
+ uint8_t uiNeighAvail;
uint32_t uiCode;
int32_t iCode;
pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail);
uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]);
for (i = 0; i < 16; i++) {
- int32_t iPrevIntra4x4PredMode = 0;
+ int32_t iPrevIntra4x4PredMode;
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
- WELS_READ_VERIFY (ParseIntraPredModeLumaCabac (pCtx, iCode));
+ WELS_READ_VERIFY (ParseIntraPredModeLumaCabac (pCtx, &iCode));
iPrevIntra4x4PredMode = iCode;
} else {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
@@ -502,7 +500,7 @@
return ERR_NONE;
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
- WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
+ WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, &iCode));
if (iCode > MAX_PRED_MODE_ID_CHROMA) {
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
}
@@ -530,7 +528,7 @@
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t iFinalMode, i;
- uint8_t uiNeighAvail = 0;
+ uint8_t uiNeighAvail;
uint32_t uiCode;
int32_t iCode;
pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail);
@@ -540,9 +538,9 @@
pCurDqLayer->pIntraNxNAvailFlag[iMbXy] = uiNeighAvail;
for (i = 0; i < 4; i++) {
- int32_t iPrevIntra4x4PredMode = 0;
+ int32_t iPrevIntra4x4PredMode;
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
- WELS_READ_VERIFY (ParseIntraPredModeLumaCabac (pCtx, iCode));
+ WELS_READ_VERIFY (ParseIntraPredModeLumaCabac (pCtx, &iCode));
iPrevIntra4x4PredMode = iCode;
} else {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
@@ -586,7 +584,7 @@
return ERR_NONE;
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
- WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
+ WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, &iCode));
if (iCode > MAX_PRED_MODE_ID_CHROMA) {
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
}
@@ -623,7 +621,7 @@
return ERR_NONE;
if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
- WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
+ WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, &iCode));
if (iCode > MAX_PRED_MODE_ID_CHROMA) {
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
}
@@ -643,7 +641,7 @@
return ERR_NONE;
}
-int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t *uiEosFlag) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PBitStringAux pBsAux = pCurDqLayer->pBitStringAux;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -653,7 +651,7 @@
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t i;
- uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0;
+ uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma, uiCbpChroma;
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
@@ -663,7 +661,7 @@
pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer);
- WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, uiMbType));
+ WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, &uiMbType));
if (uiMbType > 25) {
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
} else if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17
@@ -674,7 +672,7 @@
WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
pSlice->iLastDeltaQp = 0;
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
- if (uiEosFlag) {
+ if (*uiEosFlag) {
RestoreCabacDecEngineToBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux);
}
return ERR_NONE;
@@ -683,7 +681,7 @@
pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
// Transform 8x8 cabac will be added soon
- WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, &sNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
+ WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, &sNeighAvail, &pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
}
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
@@ -694,7 +692,7 @@
WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
}
//get uiCbp for I4x4
- WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
+ WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, &uiCbp));
pCurDqLayer->pCbp[iMbXy] = uiCbp;
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? uiCbp >> 4 : 0;
@@ -730,7 +728,7 @@
if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0]));
int32_t iQpDelta, iId8x8, iId4x4;
- WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta));
+ WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, &iQpDelta));
if (iQpDelta > 25 || iQpDelta < -26) {//out of iQpDelta range
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
@@ -844,18 +842,19 @@
}
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
- if (uiEosFlag) {
+ if (*uiEosFlag) {
RestoreCabacDecEngineToBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux);
}
return ERR_NONE;
}
-int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag) {
+ USED(pNalCur);
WELS_READ_VERIFY (WelsDecodeMbCabacISliceBaseMode0 (pCtx, uiEosFlag));
return ERR_NONE;
}
-int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiEosFlag) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PBitStringAux pBsAux = pCurDqLayer->pBitStringAux;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -872,7 +871,7 @@
pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- WELS_READ_VERIFY (ParseMBTypePSliceCabac (pCtx, pNeighAvail, uiMbType));
+ WELS_READ_VERIFY (ParseMBTypePSliceCabac (pCtx, pNeighAvail, &uiMbType));
// uiMbType = 4 is not allowded.
if (uiMbType < 4) { //Inter mode
int16_t pMotionVector[LIST_A][30][MV_A];
@@ -894,7 +893,7 @@
WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
pSlice->iLastDeltaQp = 0;
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
- if (uiEosFlag) {
+ if (*uiEosFlag) {
RestoreCabacDecEngineToBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux);
}
return ERR_NONE;
@@ -903,7 +902,7 @@
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
- WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
+ WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, &pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
}
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
@@ -935,7 +934,7 @@
ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
- WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp));
+ WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, &uiCbp));
pCurDqLayer->pCbp[iMbXy] = uiCbp;
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
@@ -957,7 +956,7 @@
if (bNeedParseTransformSize8x8Flag) {
WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail,
- pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); //transform_size_8x8_flag
+ &pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); //transform_size_8x8_flag
}
}
@@ -965,7 +964,7 @@
int32_t iQpDelta, iId8x8, iId4x4;
- WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta));
+ WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, &iQpDelta));
if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
@@ -1085,7 +1084,7 @@
}
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
- if (uiEosFlag) {
+ if (*uiEosFlag) {
RestoreCabacDecEngineToBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux);
}
@@ -1092,7 +1091,7 @@
return ERR_NONE;
}
-int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiEosFlag) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PBitStringAux pBsAux = pCurDqLayer->pBitStringAux;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -1109,7 +1108,7 @@
pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- WELS_READ_VERIFY (ParseMBTypeBSliceCabac (pCtx, pNeighAvail, uiMbType));
+ WELS_READ_VERIFY (ParseMBTypeBSliceCabac (pCtx, pNeighAvail, &uiMbType));
if (uiMbType < 23) { //Inter B mode
int16_t pMotionVector[LIST_A][30][MV_A];
@@ -1134,7 +1133,7 @@
WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
pSlice->iLastDeltaQp = 0;
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
- if (uiEosFlag) {
+ if (*uiEosFlag) {
RestoreCabacDecEngineToBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux);
}
return ERR_NONE;
@@ -1143,7 +1142,7 @@
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
- WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
+ WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, &pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
}
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
@@ -1175,7 +1174,7 @@
ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
- WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp));
+ WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, &uiCbp));
pCurDqLayer->pCbp[iMbXy] = uiCbp;
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
@@ -1198,7 +1197,7 @@
if (bNeedParseTransformSize8x8Flag) {
WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail,
- pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); //transform_size_8x8_flag
+ &pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); //transform_size_8x8_flag
}
}
@@ -1206,7 +1205,7 @@
int32_t iQpDelta, iId8x8, iId4x4;
- WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta));
+ WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, &iQpDelta));
if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
@@ -1326,7 +1325,7 @@
}
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
- if (uiEosFlag) {
+ if (*uiEosFlag) {
RestoreCabacDecEngineToBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux);
}
@@ -1334,7 +1333,8 @@
}
-int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag) {
+ USED(pNalCur);
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
@@ -1351,8 +1351,7 @@
pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
GetNeighborAvailMbType (&uiNeighAvail, pCurDqLayer);
- WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
-
+ WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, &uiCode));
if (uiCode) {
int16_t pMv[2] = {0};
pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP;
@@ -1399,7 +1398,8 @@
}
-int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag) {
+ USED(pNalCur);
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
@@ -1417,7 +1417,7 @@
pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
GetNeighborAvailMbType (&uiNeighAvail, pCurDqLayer);
- WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
+ WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, &uiCode));
memset (pCurDqLayer->pDirect[iMbXy], 0, sizeof (int8_t) * 16);
@@ -1450,13 +1450,13 @@
if (pSliceHeader->iDirectSpatialMvPredFlag) {
//predict direct spatial mv
- int32_t ret = PredMvBDirectSpatial (pCtx, pMv, ref, subMbType);
+ int32_t ret = PredMvBDirectSpatial (pCtx, pMv, ref, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
} else {
//temporal direct mode
- int32_t ret = PredBDirectTemporal (pCtx, pMv, ref, subMbType);
+ int32_t ret = PredBDirectTemporal (pCtx, pMv, ref, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -1513,6 +1513,7 @@
}
int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNalUnit pNalCur) {
+ USED(bFirstSliceInLayer);
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PFmo pFmo = pCtx->pFmo;
int32_t iRet;
@@ -1523,7 +1524,7 @@
PSliceHeader pSliceHeader = &pSliceHeaderExt->sSliceHeader;
int32_t iMbX, iMbY;
const int32_t kiCountNumMb = pSliceHeader->pSps->uiTotalMbCount; //need to be correct when fmo or multi slice
- uint32_t uiEosFlag = 0;
+ uint32_t uiEosFlag;
PWelsDecMbFunc pDecMbFunc;
pSlice->iTotalMbInCurSlice = 0; //initialize at the starting of slice decoding.
@@ -1535,6 +1536,7 @@
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
"WelsDecodeSlice()::::ILP flag exist, not supported with CABAC enabled!");
pCtx->iErrorCode |= dsBitstreamError;
+ fprint(2, "dsBitstreamError\n");
return dsBitstreamError;
}
if (P_SLICE == pSliceHeader->eSliceType)
@@ -1586,6 +1588,7 @@
pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
do {
+ //fprint(2, "(-1 == %d) || (%d >= %d) → %d\n", iNextMbXyIndex, iNextMbXyIndex, kiCountNumMb, (-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb));
if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame
break;
}
@@ -1592,9 +1595,10 @@
pCurDqLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc;
pCtx->bMbRefConcealed = false;
- iRet = pDecMbFunc (pCtx, pNalCur, uiEosFlag);
+ iRet = pDecMbFunc (pCtx, pNalCur, &uiEosFlag);
pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed;
if (iRet != ERR_NONE) {
+ fprint(2, "pDecMbFunc %p %p %d\n", pDecMbFunc, WelsDecodeMbCabacPSlice, iRet);
return iRet;
}
@@ -1659,6 +1663,7 @@
pDecMbFunc = WelsDecodeMbCavlcISlice;
}
}
+ USED(pDecMbFunc);
if (pSliceHeader->pPps->bConstainedIntraPredFlag) {
pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN;
@@ -1697,7 +1702,7 @@
SDeblockingFilter pFilter;
int32_t iFilterIdc = 1;
if (pSliceHeader->uiDisableDeblockingFilterIdc != 1) {
- WelsDeblockingInitFilter (pCtx, pFilter, iFilterIdc);
+ WelsDeblockingInitFilter (pCtx, &pFilter, &iFilterIdc);
}
do {
@@ -1707,7 +1712,7 @@
pCurDqLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc;
pCtx->bMbRefConcealed = false;
- iRet = pDecMbFunc (pCtx, pNalCur, uiEosFlag);
+ iRet = pDecMbFunc (pCtx, pNalCur, &uiEosFlag);
pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed;
if (iRet != ERR_NONE) {
return iRet;
@@ -1724,7 +1729,7 @@
pCtx->sBlockFunc.pWelsSetNonZeroCountFunc (
pCtx->pDec->pNzc[pCurDqLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti!
}
- WelsDeblockingFilterMB (pCurDqLayer, pFilter, iFilterIdc, pDeblockMb);
+ WelsDeblockingFilterMB (pCurDqLayer, &pFilter, &iFilterIdc, pDeblockMb);
if (pCtx->uiNalRefIdc > 0) {
if (pCurDqLayer->iMbX == 0 || pCurDqLayer->iMbX == pCurDqLayer->iMbWidth - 1 || pCurDqLayer->iMbY == 0
|| pCurDqLayer->iMbY == pCurDqLayer->iMbHeight - 1) {
@@ -1799,8 +1804,8 @@
const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t i;
- int32_t iRet = ERR_NONE;
- uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
+ int32_t iRet;
+ uint32_t uiMbType, uiCbp, uiCbpL, uiCbpC;
uint32_t uiCode;
int32_t iCode;
@@ -1881,6 +1886,7 @@
pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ USED(uiMbType);
}
}
if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
@@ -2063,12 +2069,13 @@
return ERR_NONE;
}
-int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag) {
+ USED(pNalCur);
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PBitStringAux pBs = pCurDqLayer->pBitStringAux;
PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;
int32_t iBaseModeFlag;
- int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
+ int32_t iRet; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
intX_t iUsedBits;
if (pSliceHeaderExt->bAdaptiveBaseModeFlag == 1) {
@@ -2092,7 +2099,7 @@
iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits);
// sub 1, for stop bit
if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
- uiEosFlag = 1;
+ *uiEosFlag = 1;
}
if (iUsedBits > (pBs->iBits -
1)) { //When BS incomplete, as long as find it, SHOULD stop decoding to avoid mosaic or crash.
@@ -2120,8 +2127,8 @@
const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t i;
- int32_t iRet = ERR_NONE;
- uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
+ int32_t iRet;
+ uint32_t uiMbType, uiCbp, uiCbpL = 0, uiCbpC = 0;
uint32_t uiCode;
int32_t iCode;
int32_t iMbResProperty;
@@ -2230,6 +2237,7 @@
pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ USED(uiMbType);
}
}
if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
@@ -2440,7 +2448,7 @@
return ERR_NONE;
}
-int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PBitStringAux pBs = pCurDqLayer->pBitStringAux;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -2450,7 +2458,7 @@
const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t iBaseModeFlag, i;
- int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
+ int32_t iRet; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
@@ -2522,7 +2530,7 @@
iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits);
// sub 1, for stop bit
if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
- uiEosFlag = 1;
+ *uiEosFlag = 1;
}
if (iUsedBits > (pBs->iBits -
1)) { //When BS incomplete, as long as find it, SHOULD stop decoding to avoid mosaic or crash.
@@ -2534,7 +2542,7 @@
return ERR_NONE;
}
-int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
+int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t *uiEosFlag) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PBitStringAux pBs = pCurDqLayer->pBitStringAux;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -2545,7 +2553,7 @@
const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t iBaseModeFlag, i;
- int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
+ int32_t iRet; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
@@ -2587,13 +2595,13 @@
if (pSliceHeader->iDirectSpatialMvPredFlag) {
//predict direct spatial mv
- int32_t ret = PredMvBDirectSpatial (pCtx, iMv, ref, subMbType);
+ int32_t ret = PredMvBDirectSpatial (pCtx, iMv, ref, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
} else {
//temporal direct mode
- int32_t ret = PredBDirectTemporal (pCtx, iMv, ref, subMbType);
+ int32_t ret = PredBDirectTemporal (pCtx, iMv, ref, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -2636,7 +2644,7 @@
iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits);
// sub 1, for stop bit
if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
- uiEosFlag = 1;
+ *uiEosFlag = 1;
}
if (iUsedBits > (pBs->iBits -
1)) { //When BS incomplete, as long as find it, SHOULD stop decoding to avoid mosaic or crash.
@@ -2664,8 +2672,8 @@
const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t i;
- int32_t iRet = ERR_NONE;
- uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
+ int32_t iRet;
+ uint32_t uiMbType, uiCbp, uiCbpL = 0, uiCbpC = 0;
uint32_t uiCode;
int32_t iCode;
int32_t iMbResProperty;
@@ -2774,6 +2782,7 @@
pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ USED(uiMbType);
}
}
if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
@@ -2985,6 +2994,7 @@
}
void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {
+ USED(iCpu);
pFunc->pWelsSetNonZeroCountFunc = WelsNonZeroCount_c;
pFunc->pWelsBlockZero16x16Func = WelsBlockZero16x16_c;
pFunc->pWelsBlockZero8x8Func = WelsBlockZero8x8_c;
@@ -3061,4 +3071,3 @@
}
return true;
}
-} // namespace WelsDec
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -54,8 +54,6 @@
#include "memory_align.h"
#include "wels_decoder_thread.h"
-namespace WelsDec {
-
extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);
extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
@@ -64,7 +62,7 @@
const int32_t kiPicWidth, const int32_t kiPicHeight) {
PPicBuff pPicBuf = NULL;
- int32_t iPicIdx = 0;
+ int32_t iPicIdx;
if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
return ERR_INFO_INVALID_PARAM;
}
@@ -108,7 +106,7 @@
const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
PPicBuff pPicOldBuf = *ppPicBuf;
PPicBuff pPicNewBuf = NULL;
- int32_t iPicIdx = 0;
+ int32_t iPicIdx;
if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
return ERR_INFO_INVALID_PARAM;
}
@@ -162,7 +160,6 @@
pPicOldBuf->iCapacity = 0;
pPicOldBuf->iCurrentIdx = 0;
pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
- pPicOldBuf = NULL;
return ERR_NONE;
}
@@ -170,7 +167,7 @@
const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
PPicBuff pPicOldBuf = *ppPicBuf;
PPicBuff pPicNewBuf = NULL;
- int32_t iPicIdx = 0;
+ int32_t iPicIdx;
if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
return ERR_INFO_INVALID_PARAM;
}
@@ -193,7 +190,7 @@
ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false);
- int32_t iPrevPicIdx = -1;
+ int32_t iPrevPicIdx;
for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {
if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
break;
@@ -250,13 +247,12 @@
pPicOldBuf->iCapacity = 0;
pPicOldBuf->iCurrentIdx = 0;
pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
- pPicOldBuf = NULL;
return ERR_NONE;
}
void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa) {
- PPicBuff pPicBuf = NULL;
+ PPicBuff pPicBuf;
ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false);
@@ -271,7 +267,6 @@
if (pPic != NULL) {
FreePicture (pPic, pMa);
}
- pPic = NULL;
++ iPicIdx;
}
@@ -284,15 +279,14 @@
pMa->WelsFree (pPicBuf, "pPicBuf");
- pPicBuf = NULL;
*ppPicBuf = NULL;
}
//reset picture reodering buffer list
void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo,
- const bool& fullReset) {
+ const bool *fullReset) {
if (pPictReoderingStatus != NULL && pPictInfo != NULL) {
- int32_t pictInfoListCount = fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1);
+ int32_t pictInfoListCount = *fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1);
pPictReoderingStatus->iPictInfoIndex = 0;
pPictReoderingStatus->iMinPOC = IMinInt32;
pPictReoderingStatus->iNumOfPicts = 0;
@@ -367,33 +361,33 @@
/*
* fill data fields in SPS and PPS default for decoder context
*/
-void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx) {
- sSpsPpsCtx.bSpsExistAheadFlag = false;
- sSpsPpsCtx.bSubspsExistAheadFlag = false;
- sSpsPpsCtx.bPpsExistAheadFlag = false;
- sSpsPpsCtx.bAvcBasedFlag = true;
- sSpsPpsCtx.iSpsErrorIgnored = 0;
- sSpsPpsCtx.iSubSpsErrorIgnored = 0;
- sSpsPpsCtx.iPpsErrorIgnored = 0;
- sSpsPpsCtx.iPPSInvalidNum = 0;
- sSpsPpsCtx.iPPSLastInvalidId = -1;
- sSpsPpsCtx.iSPSInvalidNum = 0;
- sSpsPpsCtx.iSPSLastInvalidId = -1;
- sSpsPpsCtx.iSubSPSInvalidNum = 0;
- sSpsPpsCtx.iSubSPSLastInvalidId = -1;
- sSpsPpsCtx.iSeqId = -1;
+void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX *sSpsPpsCtx) {
+ sSpsPpsCtx->bSpsExistAheadFlag = false;
+ sSpsPpsCtx->bSubspsExistAheadFlag = false;
+ sSpsPpsCtx->bPpsExistAheadFlag = false;
+ sSpsPpsCtx->bAvcBasedFlag = true;
+ sSpsPpsCtx->iSpsErrorIgnored = 0;
+ sSpsPpsCtx->iSubSpsErrorIgnored = 0;
+ sSpsPpsCtx->iPpsErrorIgnored = 0;
+ sSpsPpsCtx->iPPSInvalidNum = 0;
+ sSpsPpsCtx->iPPSLastInvalidId = -1;
+ sSpsPpsCtx->iSPSInvalidNum = 0;
+ sSpsPpsCtx->iSPSLastInvalidId = -1;
+ sSpsPpsCtx->iSubSPSInvalidNum = 0;
+ sSpsPpsCtx->iSubSPSLastInvalidId = -1;
+ sSpsPpsCtx->iSeqId = -1;
}
/*
* fill last decoded picture info
*/
-void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) {
- sLastDecPicInfo.iPrevPicOrderCntMsb = 0;
- sLastDecPicInfo.iPrevPicOrderCntLsb = 0;
- sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;
- sLastDecPicInfo.iPrevFrameNum = -1;
- sLastDecPicInfo.bLastHasMmco5 = false;
- sLastDecPicInfo.uiDecodingTimeStamp = 0;
+void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo *sLastDecPicInfo) {
+ sLastDecPicInfo->iPrevPicOrderCntMsb = 0;
+ sLastDecPicInfo->iPrevPicOrderCntLsb = 0;
+ sLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
+ sLastDecPicInfo->iPrevFrameNum = -1;
+ sLastDecPicInfo->bLastHasMmco5 = false;
+ sLastDecPicInfo->uiDecodingTimeStamp = 0;
}
/*!
@@ -432,7 +426,7 @@
* get size of reference picture list in target layer incoming, = (iNumRefFrames
*/
static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) {
- int32_t iNumRefFrames = 0;
+ int32_t iNumRefFrames;
// +2 for EC MV Copy buffer exchange
if ((pCtx == NULL) || (pCtx->pSps == NULL)) {
iNumRefFrames = MAX_REF_PIC_COUNT + 2;
@@ -458,13 +452,13 @@
* request memory blocks for decoder avc part
*/
int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight,
- bool& bReallocFlag) {
+ bool *bReallocFlag) {
const int32_t kiPicWidth = kiMbWidth << 4;
const int32_t kiPicHeight = kiMbHeight << 4;
- int32_t iErr = ERR_NONE;
+ int32_t iErr;
- int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
- bReallocFlag = false;
+ int32_t iPicQueueSize; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
+ *bReallocFlag = false;
bool bNeedChangePicQueue = true;
CMemoryAlign* pMa = pCtx->pMemAlign;
@@ -537,7 +531,7 @@
pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine))
- bReallocFlag = true; // memory re-allocation successfully finished
+ *bReallocFlag = true; // memory re-allocation successfully finished
return ERR_NONE;
}
@@ -594,7 +588,7 @@
* \brief Open decoder
*/
int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
- int iRet = ERR_NONE;
+ int iRet;
// function pointers
InitDecFuncs (pCtx, pCtx->uiCpuFlag);
@@ -735,21 +729,22 @@
*/
int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen,
uint8_t** ppDst, SBufferInfo* pDstBufInfo, SParserBsInfo* pDstBsInfo) {
+ USED(pDstBsInfo);
if (!pCtx->bEndOfStreamFlag) {
SDataBuffer* pRawData = &pCtx->sRawData;
- SDataBuffer* pSavedData = NULL;
+ SDataBuffer* pSavedData;
int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs
int32_t iSrcConsumed = 0; // consumed bit count of source bs
int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal
- int32_t iSrcLength = 0; //the total size of current AU or NAL
+ int32_t iSrcLength; //the total size of current AU or NAL
int32_t iRet = 0;
int32_t iConsumedBytes = 0;
int32_t iOffset = 0;
- uint8_t* pSrcNal = NULL;
- uint8_t* pDstNal = NULL;
- uint8_t* pNalPayload = NULL;
+ uint8_t* pSrcNal;
+ uint8_t* pDstNal;
+ uint8_t* pNalPayload;
if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset,
@@ -758,7 +753,7 @@
return dsBitstreamError;
}
- pSrcNal = const_cast<uint8_t*> (kpBsBuf) + iOffset;
+ pSrcNal = (uint8_t*) (kpBsBuf) + iOffset;
iSrcLength = kiBsLen - iOffset;
if ((kiBsLen + 4) > (pRawData->pEnd - pRawData->pCurPos)) {
@@ -834,7 +829,6 @@
}
}
if (iRet) {
- iRet = 0;
if (dsNoParamSets & pCtx->iErrorCode) {
#ifdef LONG_TERM_REF
pCtx->bParamSetsLostFlag = true;
@@ -896,7 +890,6 @@
return pCtx->iErrorCode;
}
if (iRet) {
- iRet = 0;
if (dsNoParamSets & pCtx->iErrorCode) {
#ifdef LONG_TERM_REF
pCtx->bParamSetsLostFlag = true;
@@ -942,7 +935,7 @@
* \return 0 - successful; none 0 - something wrong
*/
int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) {
- int32_t iErr = ERR_NONE;
+ int32_t iErr;
const int32_t kiPicWidth = kiMbWidth << 4;
const int32_t kiPicHeight = kiMbHeight << 4;
//fix Bugzilla Bug1479656 reallocate temp dec picture
@@ -952,7 +945,7 @@
pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4);
}
bool bReallocFlag = false;
- iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, bReallocFlag); // common memory used
+ iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, &bReallocFlag); // common memory used
if (ERR_NONE != iErr) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
"SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure.");
@@ -969,7 +962,7 @@
#if defined(MEMORY_MONITOR)
if (bReallocFlag) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes",
- static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
+ (unsigned long long) (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
}
#endif//MEMORY_MONITOR
return iErr;
@@ -983,23 +976,21 @@
DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag);
}
-namespace {
-template<void pfIdctResAddPred (uint8_t* pPred, int32_t iStride, int16_t* pRs)>
+
void IdctFourResAddPred_ (uint8_t* pPred, int32_t iStride, int16_t* pRs, const int8_t* pNzc) {
if (pNzc[0] || pRs[0 * 16])
- pfIdctResAddPred (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16);
+ IdctResAddPred_c (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16);
if (pNzc[1] || pRs[1 * 16])
- pfIdctResAddPred (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16);
+ IdctResAddPred_c (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16);
if (pNzc[4] || pRs[2 * 16])
- pfIdctResAddPred (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16);
+ IdctResAddPred_c (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16);
if (pNzc[5] || pRs[3 * 16])
- pfIdctResAddPred (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16);
+ IdctResAddPred_c (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16);
}
-} // anon ns
-
void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) {
+ USED(uiCpuFlag);
pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c;
pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c;
pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c;
@@ -1047,7 +1038,7 @@
pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c;
pCtx->pIdctResAddPredFunc = IdctResAddPred_c;
- pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_c>;
+ pCtx->pIdctFourResAddPredFunc = (void*)IdctResAddPred_c;
pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c;
@@ -1243,6 +1234,3 @@
else if (kbOutput)
UpdateDecStatNoFreezingInfo (pCtx);
}
-
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -43,7 +43,6 @@
#include "memory_align.h"
#include "error_concealment.h"
-namespace WelsDec {
static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
PDqLayer pCurDq = pCtx->pCurDqLayer;
PPicture pPic = pCtx->pDec;
@@ -90,9 +89,9 @@
PAccessUnit pCurAu = pCtx->pAccessUnitList;
if (dsErrorFree == pCtx->iErrorCode) { //correct decoding, add to data buffer
SParserBsInfo* pParser = pCtx->pParserBsInfo;
- SNalUnit* pCurNal = NULL;
+ SNalUnit* pCurNal;
int32_t iTotalNalLen = 0;
- int32_t iNalLen = 0;
+ int32_t iNalLen;
int32_t iNum = 0;
while (iNum < pParser->iNalNum) {
iTotalNalLen += pParser->pNalLenInByte[iNum++];
@@ -100,7 +99,7 @@
uint8_t* pDstBuf = pParser->pDstBuff + iTotalNalLen;
int32_t iIdx = pCurAu->uiStartPos;
int32_t iEndIdx = pCurAu->uiEndPos;
- uint8_t* pNalBs = NULL;
+ uint8_t* pNalBs;
pParser->uiOutBsTimeStamp = (pCurAu->pNalUnitsList [iIdx]) ? pCurAu->pNalUnitsList [iIdx]->uiTimeStamp : 0;
//pParser->iNalNum = 0;
pParser->iSpsWidthInPixel = (pCtx->pSps->iMbWidth << 4) - ((pCtx->pSps->sFrameCrop.iLeftOffset +
@@ -117,8 +116,8 @@
WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, ExpandBsLenBuffer (pCtx, pParser->iNalNum + 2))
}
bool bSubSps = (NAL_UNIT_CODED_SLICE_EXT == pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.sNalUnitHeader.eNalUnitType);
- SSpsBsInfo* pSpsBs = NULL;
- SPpsBsInfo* pPpsBs = NULL;
+ SSpsBsInfo* pSpsBs;
+ SPpsBsInfo* pPpsBs;
int32_t iSpsId = pCtx->pSps->iSpsId;
int32_t iPpsId = pCtx->pPps->iPpsId;
pCtx->bParamSetsLostFlag = false;
@@ -323,12 +322,12 @@
int32_t iCode;
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
- WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "luma_log2_weight_denom",
+ WELS_CHECK_SE_BOTH_ERROR_NOLOG ((int)uiCode, 0, 7, "luma_log2_weight_denom",
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM));
pSh->sPredWeightTable.uiLumaLog2WeightDenom = uiCode;
if (pSh->pSps->uiChromaArrayType != 0) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
- WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "chroma_log2_weight_denom",
+ WELS_CHECK_SE_BOTH_ERROR_NOLOG ((int)uiCode, 0, 7, "chroma_log2_weight_denom",
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM));
pSh->sPredWeightTable.uiChromaLog2WeightDenom = uiCode;
}
@@ -544,7 +543,7 @@
bMmco4Exist = true;
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_long_term_frame_idx_plus1
int32_t iMaxLongTermFrameIdx = -1 + uiCode;
- if (iMaxLongTermFrameIdx > int32_t (pSps->uiLog2MaxFrameNum)) {
+ if (iMaxLongTermFrameIdx > (int32_t) (pSps->uiLog2MaxFrameNum)) {
//ISO/IEC 14496-10:2009(E) 7.4.3.3 Decoded reference picture marking semantics page 96
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_MARKING);
}
@@ -609,7 +608,7 @@
CMemoryAlign* pMa = pCtx->pMemAlign;
pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM;
- if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
+ if ((pCtx->sRawData.pHead = (uint8_t*) (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
"pCtx->sRawData.pHead"))) == NULL) {
return ERR_INFO_OUT_OF_MEMORY;
}
@@ -616,12 +615,12 @@
pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead;
pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte;
if (pCtx->pParam->bParseOnly) {
- pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (pMa->WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo"));
+ pCtx->pParserBsInfo = (SParserBsInfo*) (pMa->WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo"));
if (pCtx->pParserBsInfo == NULL) {
return ERR_INFO_OUT_OF_MEMORY;
}
memset (pCtx->pParserBsInfo, 0, sizeof (SParserBsInfo));
- pCtx->pParserBsInfo->pDstBuff = static_cast<uint8_t*> (pMa->WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t),
+ pCtx->pParserBsInfo->pDstBuff = (uint8_t*) (pMa->WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t),
"pCtx->pParserBsInfo->pDstBuff"));
if (pCtx->pParserBsInfo->pDstBuff == NULL) {
return ERR_INFO_OUT_OF_MEMORY;
@@ -628,7 +627,7 @@
}
memset (pCtx->pParserBsInfo->pDstBuff, 0, MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t));
- if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
+ if ((pCtx->sSavedData.pHead = (uint8_t*) (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
"pCtx->sSavedData.pHead"))) == NULL) {
return ERR_INFO_OUT_OF_MEMORY;
}
@@ -636,7 +635,7 @@
pCtx->sSavedData.pEnd = pCtx->sSavedData.pHead + pCtx->iMaxBsBufferSizeInByte;
pCtx->iMaxNalNum = MAX_NAL_UNITS_IN_LAYER + 2; //2 reserved for SPS+PPS
- pCtx->pParserBsInfo->pNalLenInByte = static_cast<int*> (pMa->WelsMallocz (pCtx->iMaxNalNum * sizeof (int),
+ pCtx->pParserBsInfo->pNalLenInByte = (int*) (pMa->WelsMallocz (pCtx->iMaxNalNum * sizeof (int),
"pCtx->pParserBsInfo->pNalLenInByte"));
if (pCtx->pParserBsInfo->pNalLenInByte == NULL) {
return ERR_INFO_OUT_OF_MEMORY;
@@ -654,7 +653,7 @@
CMemoryAlign* pMa = pCtx->pMemAlign;
//Realloc sRawData
- uint8_t* pNewBsBuff = static_cast<uint8_t*> (pMa->WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead"));
+ uint8_t* pNewBsBuff = (uint8_t*) (pMa->WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead"));
if (pNewBsBuff == NULL) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "ExpandBsBuffer() Failed for malloc pNewBsBuff (%d)", iNewBuffLen);
pCtx->iErrorCode |= dsOutOfMemory;
@@ -679,7 +678,7 @@
if (pCtx->pParam->bParseOnly) {
//Realloc sSavedData
- uint8_t* pNewSavedBsBuff = static_cast<uint8_t*> (pMa->WelsMallocz (iNewBuffLen, "pCtx->sSavedData.pHead"));
+ uint8_t* pNewSavedBsBuff = (uint8_t*) (pMa->WelsMallocz (iNewBuffLen, "pCtx->sSavedData.pHead"));
if (pNewSavedBsBuff == NULL) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "ExpandBsBuffer() Failed for malloc pNewSavedBsBuff (%d)", iNewBuffLen);
pCtx->iErrorCode |= dsOutOfMemory;
@@ -704,7 +703,7 @@
if (!pParser->pNalLenInByte)
return ERR_INFO_INVALID_ACCESS;
- int iNewLen = kiCurrLen;
+ int iNewLen;
if (kiCurrLen >= MAX_MB_SIZE + 2) { //exceeds the max MB number of level 5.2
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "Current nal num (%d) exceededs %d.", kiCurrLen, MAX_MB_SIZE);
pCtx->iErrorCode |= dsOutOfMemory;
@@ -715,7 +714,7 @@
}
CMemoryAlign* pMa = pCtx->pMemAlign;
- int* pNewLenBuffer = static_cast<int*> (pMa->WelsMallocz (iNewLen * sizeof (int),
+ int* pNewLenBuffer = (int*) (pMa->WelsMallocz (iNewLen * sizeof (int),
"pCtx->pParserBsInfo->pNalLenInByte"));
if (pNewLenBuffer == NULL) {
pCtx->iErrorCode |= dsOutOfMemory;
@@ -854,7 +853,7 @@
pDecoderStatistics->iCurrentActiveSpsId = pSps->iSpsId;
pDecoderStatistics->iCurrentActivePpsId = pPps->iPpsId;
- pDecoderStatistics->uiProfile = static_cast<unsigned int> (pSps->uiProfileIdc);
+ pDecoderStatistics->uiProfile = (unsigned int) (pSps->uiProfileIdc);
pDecoderStatistics->uiLevel = pSps->uiLevelIdc;
}
@@ -876,19 +875,19 @@
pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum -
1];
- PNalUnitHeaderExt pNalHeaderExt = NULL;
- PSliceHeader pSliceHead = NULL;
- PSliceHeaderExt pSliceHeadExt = NULL;
+ PNalUnitHeaderExt pNalHeaderExt;
+ PSliceHeader pSliceHead;
+ PSliceHeaderExt pSliceHeadExt;
PSubsetSps pSubsetSps = NULL;
- PSps pSps = NULL;
- PPps pPps = NULL;
- EWelsNalUnitType eNalType = static_cast<EWelsNalUnitType> (0);
- int32_t iPpsId = 0;
- int32_t iRet = ERR_NONE;
- uint8_t uiSliceType = 0;
+ PSps pSps;
+ PPps pPps;
+ EWelsNalUnitType eNalType;
+ int32_t iPpsId;
+ int32_t iRet;
+ uint8_t uiSliceType;
uint8_t uiQualityId = BASE_QUALITY_ID;
- bool bIdrFlag = false;
- bool bSgChangeCycleInvolved = false; // involved slice group change cycle ?
+ bool bIdrFlag;
+ bool bSgChangeCycleInvolved; // involved slice group change cycle ?
uint32_t uiCode;
int32_t iCode;
SLogContext* pLogCtx = & (pCtx->sLogCtx);
@@ -942,7 +941,7 @@
}
}
- pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType);
+ pSliceHead->eSliceType = (EWelsSliceType) (uiSliceType);
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id
WELS_CHECK_SE_UPPER_ERROR (uiCode, (MAX_PPS_COUNT - 1), "iPpsId out of range",
@@ -1253,7 +1252,7 @@
bSgChangeCycleInvolved = (bSgChangeCycleInvolved && (uiQualityId == BASE_QUALITY_ID));
if (bSgChangeCycleInvolved) {
if (pPps->uiSliceGroupChangeRate > 0) {
- const int32_t kiNumBits = (int32_t)WELS_CEIL (log (static_cast<double> (1 + pPps->uiPicSizeInMapUnits /
+ const int32_t kiNumBits = (int32_t)WELS_CEIL (log ((double) (1 + pPps->uiPicSizeInMapUnits /
pPps->uiSliceGroupChangeRate)));
WELS_READ_VERIFY (BsGetBits (pBs, kiNumBits, &uiCode)); //lice_group_change_cycle
pSliceHead->iSliceGroupChangeCycle = uiCode;
@@ -1392,11 +1391,11 @@
* ppDst: succeeded VCL NAL based AVC (I/P Slice)
*/
bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst, PNalUnit const kpSrc) {
- PNalUnitHeaderExt pNalHdrExtD = NULL, pNalHdrExtS = NULL;
- PSliceHeaderExt pShExtD = NULL;
- PPrefixNalUnit pPrefixS = NULL;
- PSps pSps = NULL;
- int32_t iIdx = 0;
+ PNalUnitHeaderExt pNalHdrExtD, pNalHdrExtS;
+ PSliceHeaderExt pShExtD ;
+ PPrefixNalUnit pPrefixS;
+ PSps pSps;
+ int32_t iIdx;
if (kppDst == NULL || kpSrc == NULL)
return false;
@@ -1792,7 +1791,6 @@
}
pMa->WelsFree (pDq, "pDq");
- pDq = NULL;
pCtx->pDqLayersList[i] = NULL;
++ i;
@@ -1880,7 +1878,7 @@
uint8_t uiLastNuDependencyId, uiLastNuLayerDqId;
uint8_t uiCurNuDependencyId, uiCurNuQualityId, uiCurNuLayerDqId, uiCurNuRefLayerDqId;
- int32_t iCurNalUnitIdx = 0;
+ int32_t iCurNalUnitIdx;
//check the continuity of pNalUnitsList forwards (from pIdxNoInterLayerPred to end_postion)
uiLastNuDependencyId = pCurAu->pNalUnitsList[iStartIdx]->sNalHeaderExt.uiDependencyId;//starting nal unit
@@ -2020,7 +2018,7 @@
} else { //P_SLICE
//step 1: search uiDependencyId equal to pCtx->cur_seq_interval_target_dependency_id
bool bGetDependId = false;
- int32_t iIdxDependId = 0;
+ int32_t iIdxDependId;
iIdxDependId = kiEndPos;
while (iIdxDependId >= 0) {
@@ -2256,7 +2254,7 @@
* 0 - success; otherwise returned error_no defined in error_no.h
*/
int32_t WelsDecodeInitAccessUnitStart (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo) {
- int32_t iErr = ERR_NONE;
+ int32_t iErr;
PAccessUnit pCurAu = pCtx->pAccessUnitList;
pCtx->bAuReadyFlag = false;
pCtx->pLastDecPicInfo->bLastHasMmco5 = false;
@@ -2313,7 +2311,7 @@
* 0 - success; otherwise returned error_no defined in error_no.h
*/
int32_t InitConstructAccessUnit (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo) {
- int32_t iErr = ERR_NONE;
+ int32_t iErr;
iErr = WelsDecodeInitAccessUnitStart (pCtx, pDstInfo);
if (ERR_NONE != iErr) {
@@ -2342,7 +2340,7 @@
* 0 - success; otherwise returned error_no defined in error_no.h
*/
int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
- int32_t iErr = ERR_NONE;
+ int32_t iErr;
if (GetThreadCount (pCtx) <= 1) {
iErr = InitConstructAccessUnit (pCtx, pDstInfo);
if (ERR_NONE != iErr) {
@@ -2425,7 +2423,8 @@
}
int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) {
- int32_t iRet = ERR_NONE;
+ USED(kuiNRi);
+ int32_t iRet;
if (pCtx->eSliceType == B_SLICE) {
iRet = WelsInitBSliceRefList (pCtx, iPoc);
CreateImplicitWeightTable (pCtx);
@@ -2480,8 +2479,9 @@
* Decode current access unit when current AU is completed.
*/
int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
- PNalUnit pNalCur = pCtx->pNalCur = NULL;
+ PNalUnit pNalCur;
PAccessUnit pCurAu = pCtx->pAccessUnitList;
+ pCtx->pNalCur = NULL;
int32_t iIdx = pCurAu->uiStartPos;
int32_t iEndIdx = pCurAu->uiEndPos;
@@ -2501,18 +2501,16 @@
}
}
int32_t iThreadCount = GetThreadCount (pCtx);
- int32_t iPpsId = 0;
- int32_t iRet = ERR_NONE;
-
+ int32_t iPpsId;
+ int32_t iRet;
bool bAllRefComplete = true; // Assume default all ref picutres are complete
const uint8_t kuiTargetLayerDqId = GetTargetDqId (pCtx->uiTargetDqId, pCtx->pParam);
const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4;
int16_t iLastIdD = -1, iLastIdQ = -1;
- int16_t iCurrIdD = 0, iCurrIdQ = 0;
+ int16_t iCurrIdD, iCurrIdQ;
pCtx->uiNalRefIdc = 0;
- bool bFreshSliceAvailable =
- true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008
+ bool bFreshSliceAvailable; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008
//update pCurDqLayer at the starting of AU decoding
if (pCtx->bInitialDqLayersMem || pCtx->pCurDqLayer == NULL) {
@@ -2525,7 +2523,7 @@
while (iIdx <= iEndIdx) {
PDqLayer dq_cur = pCtx->pCurDqLayer;
SLayerInfo pLayerInfo;
- PSliceHeaderExt pShExt = NULL;
+ PSliceHeaderExt pShExt;
PSliceHeader pSh = NULL;
bool isNewFrame = true;
if (iThreadCount > 1) {
@@ -2723,6 +2721,7 @@
SET_EVENT (&pThreadCtx->sSliceDecodeStart);
}
iRet = WelsDecodeAndConstructSlice (pCtx);
+fprint(2, "WelsDecodeAndConstructSlice %d\n", iRet);
} else {
iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur);
}
@@ -2834,7 +2833,7 @@
++i;
}
}
- iRet = WelsMarkAsRef (pCtx);
+ iRet = WelsMarkAsRef (pCtx, NULL);
if (iRet != ERR_NONE) {
if (iRet == ERR_INFO_DUPLICATE_FRAME_NUM)
pCtx->iErrorCode |= dsBitstreamError;
@@ -2997,4 +2996,3 @@
return bAllRefComplete;
}
-} // namespace WelsDec
--- a/codec/decoder/core/src/decoder_data_tables.cpp
+++ b/codec/decoder/core/src/decoder_data_tables.cpp
@@ -36,8 +36,6 @@
#include "mb_cache.h"
#include "vlc_decoder.h"
-namespace WelsDec {
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -564,5 +562,3 @@
const uint8_t g_kuiZeroLeftBitNumMap[16] = {
0, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/error_concealment.cpp
+++ b/codec/decoder/core/src/error_concealment.cpp
@@ -38,7 +38,6 @@
#include "error_concealment.h"
#include "cpu_core.h"
-namespace WelsDec {
//Init
void InitErrorCon (PWelsDecoderContext pCtx) {
if ((pCtx->pParam->eEcActiveIdc == ERROR_CON_SLICE_COPY)
@@ -170,7 +169,9 @@
//Do error concealment using slice MV copy method
void DoMbECMvCopy (PWelsDecoderContext pCtx, PPicture pDec, PPicture pRef, int32_t iMbXy, int32_t iMbX, int32_t iMbY,
- sMCRefMember* pMCRefMem) {
+ sMCRefMember* pMCRefMem, int32_t iCurrPoc) {
+ USED(iCurrPoc);
+ USED(iMbXy);
if (pDec == pRef) {
return; // for protection, shall never go into this logic, error info printed outside.
}
@@ -180,7 +181,7 @@
int32_t iScale0;
int32_t iScale1;
uint8_t* pDst[3];
- int32_t iCurrPoc = pDec->iFramePoc;
+ iCurrPoc = pDec->iFramePoc;
pDst[0] = pDec->pData[0] + iMbXInPix + iMbYInPix * pMCRefMem->iDstLineLuma;
pDst[1] = pDec->pData[1] + (iMbXInPix >> 1) + (iMbYInPix >> 1) * pMCRefMem->iDstLineChroma;
pDst[2] = pDec->pData[2] + (iMbXInPix >> 1) + (iMbYInPix >> 1) * pMCRefMem->iDstLineChroma;
@@ -402,7 +403,7 @@
if (!pMbCorrectlyDecodedFlag[iMbXyIndex]) {
pCtx->pDec->iMbEcedNum++;
if (pSrcPic != NULL) {
- DoMbECMvCopy (pCtx, pDstPic, pSrcPic, iMbXyIndex, iMbX, iMbY, &sMCRefMem);
+ DoMbECMvCopy (pCtx, pDstPic, pSrcPic, iMbXyIndex, iMbX, iMbY, &sMCRefMem, 0);
} else { //pSrcPic == NULL
//Y component
pDstData = pDstPic->pData[0] + iMbY * 16 * iDstStride + iMbX * 16;
@@ -431,7 +432,7 @@
//Mark erroneous frame as Ref Pic into DPB
int32_t MarkECFrameAsRef (PWelsDecoderContext pCtx) {
- int32_t iRet = WelsMarkAsRef (pCtx);
+ int32_t iRet = WelsMarkAsRef (pCtx, 0);
// Under EC mode, the ERR_INFO_DUPLICATE_FRAME_NUM does not need to be process
if (iRet != ERR_NONE) {
return iRet;
@@ -476,5 +477,3 @@
pCtx->iErrorCode |= dsDataErrorConcealed;
pCtx->pDec->bIsComplete = false; // Set complete flag to false after do EC.
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/fmo.cpp
+++ b/codec/decoder/core/src/fmo.cpp
@@ -42,8 +42,6 @@
#include "memory_align.h"
#include "error_code.h"
-namespace WelsDec {
-
/*!
* \brief Generate MB allocated map for interleaved slice group (TYPE 0)
*
@@ -53,8 +51,8 @@
* \return 0 - successful; none 0 - failed
*/
static inline int32_t FmoGenerateMbAllocMapType0 (PFmo pFmo, PPps pPps) {
- uint32_t uiNumSliceGroups = 0;
- int32_t iMbNum = 0;
+ uint32_t uiNumSliceGroups;
+ int32_t iMbNum;
int32_t i = 0;
WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pFmo || NULL == pPps))
@@ -90,8 +88,8 @@
* \return 0 - successful; none 0 - failed
*/
static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const int32_t kiMbWidth) {
- uint32_t uiNumSliceGroups = 0;
- int32_t iMbNum = 0;
+ uint32_t uiNumSliceGroups;
+ int32_t iMbNum;
int32_t i = 0;
WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pFmo || NULL == pPps))
uiNumSliceGroups = pPps->uiNumSliceGroups;
@@ -119,7 +117,7 @@
*/
static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth,
const int32_t kiMbHeight, CMemoryAlign* pMa) {
- int32_t iNumMb = 0;
+ int32_t iNumMb;
int32_t iErr = 0;
bool bResolutionChanged = false;
@@ -322,5 +320,3 @@
// -1: No further MB in this slice (could be end of picture)
return iNextMb;
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/get_intra_predictor.cpp
+++ b/codec/decoder/core/src/get_intra_predictor.cpp
@@ -39,14 +39,11 @@
*
*************************************************************************************
*/
-#include <string.h>
#include "macros.h"
#include "ls_defines.h"
#include "get_intra_predictor.h"
-namespace WelsDec {
-
#define I4x4_COUNT 4
#define I8x8_COUNT 8
#define I16x16_COUNT 16
@@ -409,6 +406,7 @@
}
void WelsI8x8LumaPredH_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
uint64_t uiLeft;
int32_t iStride[8];
uint8_t uiPixelFilterL[8];
@@ -472,6 +470,7 @@
}
void WelsI8x8LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
int32_t iStride[8];
uint8_t uiPixelFilterL[8];
uint16_t uiTotal = 0;
@@ -534,6 +533,8 @@
}
void WelsI8x8LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
+ USED(bTLAvail);
// for normal 8 bit depth, 8-94
const uint64_t kuiDC64 = 0x8080808080808080ULL;
@@ -548,6 +549,7 @@
/*down pLeft*/
void WelsI8x8LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
// Top and Top-right available
int32_t iStride[8];
uint8_t uiPixelFilterT[16];
@@ -577,6 +579,7 @@
/*down pLeft*/
void WelsI8x8LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
// Top available and Top-right unavailable
int32_t iStride[8];
uint8_t uiPixelFilterT[16];
@@ -610,6 +613,7 @@
/*down right*/
void WelsI8x8LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTLAvail);
// The TopLeft, Top, Left are all available under this mode
int32_t iStride[8];
uint8_t uiPixelFilterTL;
@@ -660,6 +664,7 @@
/*vertical pLeft*/
void WelsI8x8LumaPredVL_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
// Top and Top-right available
int32_t iStride[8];
uint8_t uiPixelFilterT[16];
@@ -692,6 +697,7 @@
/*vertical pLeft*/
void WelsI8x8LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
// Top available and Top-right unavailable
int32_t iStride[8];
uint8_t uiPixelFilterT[16];
@@ -728,6 +734,7 @@
/*vertical right*/
void WelsI8x8LumaPredVR_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTLAvail);
// The TopLeft, Top, Left are always available under this mode
int32_t iStride[8];
uint8_t uiPixelFilterTL;
@@ -786,6 +793,7 @@
/*horizontal up*/
void WelsI8x8LumaPredHU_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTRAvail);
int32_t iStride[8];
uint8_t uiPixelFilterL[8];
int32_t i, j;
@@ -824,6 +832,7 @@
/*horizontal down*/
void WelsI8x8LumaPredHD_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
+ USED(bTLAvail);
// The TopLeft, Top, Left are all available under this mode
int32_t iStride[8];
uint8_t uiPixelFilterTL;
@@ -912,7 +921,7 @@
void WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride) {
- int32_t a = 0, b = 0, c = 0, H = 0, V = 0;
+ int32_t a, b, c, H = 0, V = 0;
int32_t i, j;
uint8_t* pTop = &pPred[-kiStride];
uint8_t* pLeft = &pPred[-1];
@@ -1051,7 +1060,7 @@
}
void WelsI16x16LumaPredPlane_c (uint8_t* pPred, const int32_t kiStride) {
- int32_t a = 0, b = 0, c = 0, H = 0, V = 0;
+ int32_t a, b, c, H = 0, V = 0;
int32_t i, j;
uint8_t* pTop = &pPred[-kiStride];
uint8_t* pLeft = &pPred[-1];
@@ -1079,7 +1088,7 @@
int32_t iTmp = (kiStride << 4) - kiStride;
int32_t iSum = 0;
uint8_t i = 15;
- uint8_t uiMean = 0;
+ uint8_t uiMean;
/*caculate the kMean value*/
do {
@@ -1101,7 +1110,7 @@
int32_t iTmp = (kiStride << 4) - kiStride;
int32_t iSum = 0;
uint8_t i = 15;
- uint8_t uiMean = 0;
+ uint8_t uiMean;
/*caculate the kMean value*/
do {
@@ -1119,8 +1128,8 @@
void WelsI16x16LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
int32_t iTmp = (kiStride << 4) - kiStride;
int32_t iSum = 0;
- uint64_t uiMean64 = 0;
- uint8_t uiMean = 0;
+ uint64_t uiMean64;
+ uint8_t uiMean;
uint8_t i = 15;
/*caculate the kMean value*/
@@ -1153,5 +1162,3 @@
iTmp -= kiStride;
} while (i-- > 0);
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -44,8 +44,6 @@
#include "error_code.h"
#include "decoder.h"
-namespace WelsDec {
-
static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum);
static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum);
@@ -102,7 +100,7 @@
// 2.IDR NAL i.e. 1st layer in IDR AU
void WelsResetRefPic (PWelsDecoderContext pCtx) {
- int32_t i = 0;
+ int32_t i;
PRefPic pRefPic = &pCtx->sRefPic;
pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0;
@@ -127,7 +125,7 @@
}
void WelsResetRefPicWithoutUnRef (PWelsDecoderContext pCtx) {
- int32_t i = 0;
+ int32_t i;
PRefPic pRefPic = &pCtx->sRefPic;
pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0;
@@ -355,7 +353,7 @@
* fills the pRefPic.pRefList.
*/
int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) {
-
+ USED(iPoc);
int32_t err = WelsCheckAndRecoverForFutureDecoding (pCtx);
if (err != ERR_NONE) return err;
@@ -392,7 +390,7 @@
int32_t ListCount = 1;
if (pCtx->eSliceType == B_SLICE) ListCount = 2;
for (int32_t listIdx = 0; listIdx < ListCount; ++listIdx) {
- PPicture pPic = NULL;
+ PPicture pPic;
PPicture* ppRefList = pCtx->sRefPic.pRefList[listIdx];
int32_t iMaxRefIdx = pCtx->iPicQueueNumber;
if (iMaxRefIdx >= MAX_REF_PIC_COUNT) {
@@ -401,7 +399,7 @@
int32_t iRefCount = pSliceHeader->uiRefCount[listIdx];
int32_t iPredFrameNum = pSliceHeader->iFrameNum;
int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum;
- int32_t iAbsDiffPicNum = -1;
+ int32_t iAbsDiffPicNum;
int32_t iReorderingIndex = 0;
int32_t i = 0;
@@ -489,9 +487,9 @@
int32_t iShortRefCount = pCtx->sRefPic.uiShortRefCount[LIST_0];
PPicture* ppLongRefList = pCtx->sRefPic.pLongRefList[LIST_0];
int32_t iLongRefCount = pCtx->sRefPic.uiLongRefCount[LIST_0];
- int32_t i = 0;
- int32_t j = 0;
- int32_t k = 0;
+ int32_t i;
+ int32_t j;
+ int32_t k;
int32_t iMaxRefIdx = pCtx->pSps->iNumRefFrames;
const int32_t iCurFrameNum = pSliceHeader->iFrameNum;
const int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum;
@@ -501,7 +499,7 @@
PPicture* ppRefList = pCtx->sRefPic.pRefList[listIdx];
int32_t iCount = 0;
int32_t iRefCount = pSliceHeader->uiRefCount[listIdx];
- int32_t iAbsDiffPicNum = -1;
+ int32_t iAbsDiffPicNum;
if (pRefPicListReorderSyn->bRefPicListReorderingFlag[listIdx]) {
int32_t iPredFrameNum = iCurFrameNum;
@@ -658,8 +656,8 @@
static int32_t MMCO (PWelsDecoderContext pCtx, PRefPic pRefPic, PRefPicMarking pRefPicMarking) {
PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
- int32_t i = 0;
- int32_t iRet = ERR_NONE;
+ int32_t i;
+ int32_t iRet;
for (i = 0; i < MAX_MMCO_COUNT && pRefPicMarking->sMmcoRef[i].uiMmcoType != MMCO_END; i++) {
uint32_t uiMmcoType = pRefPicMarking->sMmcoRef[i].uiMmcoType;
int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicMarking->sMmcoRef[i].iDiffOfPicNum) & ((
@@ -684,8 +682,8 @@
}
static int32_t MMCOProcess (PWelsDecoderContext pCtx, PRefPic pRefPic, uint32_t uiMmcoType,
int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {
- PPicture pPic = NULL;
- int32_t i = 0;
+ PPicture pPic;
+ int32_t i;
int32_t iRet = ERR_NONE;
switch (uiMmcoType) {
@@ -756,8 +754,8 @@
}
static int32_t SlidingWindow (PWelsDecoderContext pCtx, PRefPic pRefPic) {
- PPicture pPic = NULL;
- int32_t i = 0;
+ PPicture pPic;
+ int32_t i;
if (pRefPic->uiShortRefCount[LIST_0] + pRefPic->uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {
if (pRefPic->uiShortRefCount[LIST_0] == 0) {
@@ -764,22 +762,18 @@
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "No reference picture in short term list when sliding window");
return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH;
}
- for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {
- pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum);
- if (pPic) {
- SetUnRef (pPic);
- break;
- } else {
- return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
- }
- }
+ i = pRefPic->uiShortRefCount[LIST_0] - 1;
+ pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum);
+ if (pPic == NULL)
+ return ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW;
+ SetUnRef (pPic);
}
return ERR_NONE;
}
static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) {
- int32_t i = 0;
- int32_t iMoveSize = 0;
+ int32_t i;
+ int32_t iMoveSize;
PPicture pPic = NULL;
for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {
@@ -809,8 +803,8 @@
}
static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
- PPicture pPic = NULL;
- int32_t i = 0;
+ PPicture pPic;
+ int32_t i;
for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
pPic = pRefPic->pLongRefList[LIST_0][i];
if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {
@@ -864,7 +858,7 @@
static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx,
uint32_t uiLongTermPicNum) {
- int32_t i = 0;
+ int32_t i;
pPic->bUsedAsRef = true;
pPic->bIsLongRef = true;
@@ -892,8 +886,8 @@
static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx,
uint32_t uiLongTermPicNum) {
- PPicture pPic = NULL;
- int32_t i = 0;
+ PPicture pPic;
+ int32_t i;
int32_t iRet = ERR_NONE;
WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
@@ -954,5 +948,3 @@
return iRet;
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/memmgr_nal_unit.cpp
+++ b/codec/decoder/core/src/memmgr_nal_unit.cpp
@@ -42,11 +42,9 @@
#include "memory_align.h"
#include "error_code.h"
-namespace WelsDec {
-
int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize, CMemoryAlign* pMa) {
uint32_t uiIdx = 0;
- uint8_t* pBase = NULL, *pPtr = NULL;
+ uint8_t* pBase, *pPtr;
const uint32_t kuiSizeAu = sizeof (SAccessUnit);
const uint32_t kuiSizeNalUnitPtr = kuiSize * sizeof (PNalUnit);
const uint32_t kuiSizeNalUnit = sizeof (SNalUnit);
@@ -101,7 +99,7 @@
else {
PAccessUnit pTmp = NULL;
int32_t iIdx = 0;
- int32_t iRet = ERR_NONE;
+ int32_t iRet;
if ((iRet = MemInitNalList (&pTmp, kiExpSize, pMa)) != ERR_NONE) // request new list with expanding
return iRet;
@@ -129,7 +127,7 @@
*/
PNalUnit MemGetNextNal (PAccessUnit* ppAu, CMemoryAlign* pMa) {
PAccessUnit pAu = *ppAu;
- PNalUnit pNu = NULL;
+ PNalUnit pNu;
if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list
const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU >> 1);
@@ -144,5 +142,3 @@
return pNu;
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/mv_pred.cpp
+++ b/codec/decoder/core/src/mv_pred.cpp
@@ -43,8 +43,6 @@
#include "mb_cache.h"
#include "parse_mb_syn_cabac.h"
-namespace WelsDec {
-
static inline void SetRectBlock (void* vp, int32_t w, const int32_t h, int32_t stride, const uint32_t val,
const int32_t size) {
uint8_t* p = (uint8_t*)vp;
@@ -160,7 +158,7 @@
int32_t iCurSliceIdc, iTopSliceIdc, iLeftTopSliceIdc, iRightTopSliceIdc, iLeftSliceIdc;
int32_t iLeftTopType, iRightTopType, iTopType, iLeftType;
- int32_t iCurX, iCurY, iCurXy, iLeftXy, iTopXy = 0, iLeftTopXy = 0, iRightTopXy = 0;
+ int32_t iCurX, iCurY, iCurXy, iLeftXy = 0, iTopXy = 0, iLeftTopXy = 0, iRightTopXy = 0;
int8_t iLeftRef;
int8_t iTopRef;
@@ -181,7 +179,6 @@
bLeftAvail = (iLeftSliceIdc == iCurSliceIdc);
} else {
bLeftAvail = 0;
- bLeftTopAvail = 0;
}
if (iCurY != 0) {
@@ -307,12 +304,12 @@
}
}
-int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType& mbType, SubMbType& subMbType) {
+int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType *mbType, SubMbType *subMbType) {
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
uint32_t is8x8 = IS_Inter_8x8 (GetMbType (pCurDqLayer)[iMbXy]);
- mbType = GetMbType (pCurDqLayer)[iMbXy];
+ *mbType = GetMbType (pCurDqLayer)[iMbXy];
PPicture colocPic = pCtx->sRefPic.pRefList[LIST_1][0];
if (GetThreadCount (pCtx) > 1) {
@@ -336,14 +333,14 @@
coloc_mbType |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0;
}
if (IS_Inter_8x8 (coloc_mbType) && !pCtx->pSps->bDirect8x8InferenceFlag) {
- subMbType = SUB_MB_TYPE_4x4 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT;
- mbType |= MB_TYPE_8x8 | MB_TYPE_L0 | MB_TYPE_L1;
+ *subMbType = SUB_MB_TYPE_4x4 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT;
+ *mbType |= MB_TYPE_8x8 | MB_TYPE_L0 | MB_TYPE_L1;
} else if (!is8x8 && (IS_INTER_16x16 (coloc_mbType) || IS_INTRA (coloc_mbType)/* || IS_SKIP(coloc_mbType)*/)) {
- subMbType = SUB_MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT;
- mbType |= MB_TYPE_16x16 | MB_TYPE_L0 | MB_TYPE_L1;
+ *subMbType = SUB_MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT;
+ *mbType |= MB_TYPE_16x16 | MB_TYPE_L0 | MB_TYPE_L1;
} else {
- subMbType = SUB_MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT;
- mbType |= MB_TYPE_8x8 | MB_TYPE_L0 | MB_TYPE_L1;
+ *subMbType = SUB_MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT;
+ *mbType |= MB_TYPE_8x8 | MB_TYPE_L0 | MB_TYPE_L1;
}
if (IS_INTRA (coloc_mbType)) {
@@ -352,7 +349,7 @@
}
SetRectBlock (pCurDqLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 0, sizeof (int8_t));
- if (IS_INTER_16x16 (mbType)) {
+ if (IS_INTER_16x16 (*mbType)) {
int16_t iMVZero[2] = { 0 };
int16_t* pMv = IS_TYPE_L1 (coloc_mbType) ? colocPic->pMv[LIST_1][iMbXy][0] : iMVZero;
ST32 (pCurDqLayer->iColocMv[LIST_0][0], LD32 (colocPic->pMv[LIST_0][iMbXy][0]));
@@ -390,15 +387,15 @@
}
int32_t PredMvBDirectSpatial (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A],
- SubMbType& subMbType) {
+ SubMbType *subMbType) {
- int32_t ret = ERR_NONE;
+ int32_t ret;
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
bool bSkipOrDirect = (IS_SKIP (GetMbType (pCurDqLayer)[iMbXy]) | IS_DIRECT (GetMbType (pCurDqLayer)[iMbXy])) > 0;
MbType mbType;
- ret = GetColocatedMb (pCtx, mbType, subMbType);
+ ret = GetColocatedMb (pCtx, &mbType, subMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -427,7 +424,6 @@
bLeftAvail = (iLeftSliceIdc == iCurSliceIdc);
} else {
bLeftAvail = 0;
- bLeftTopAvail = 0;
}
if (iCurY != 0) {
@@ -557,10 +553,10 @@
ref[LIST_0] = ref[LIST_1] = 0;
} else if (ref[LIST_1] < 0) {
mbType &= ~MB_TYPE_L1;
- subMbType &= ~MB_TYPE_L1;
+ *subMbType &= ~MB_TYPE_L1;
} else if (ref[LIST_0] < 0) {
mbType &= ~MB_TYPE_L0;
- subMbType &= ~MB_TYPE_L0;
+ *subMbType &= ~MB_TYPE_L0;
}
GetMbType (pCurDqLayer)[iMbXy] = mbType;
@@ -590,7 +586,7 @@
int8_t pSubPartCount[4], pPartW[4];
for (int32_t i = 0; i < 4; i++) { //Direct 8x8 Ref and mv
int16_t iIdx8 = i << 2;
- pCurDqLayer->pSubMbType[iMbXy][i] = subMbType;
+ pCurDqLayer->pSubMbType[iMbXy][i] = *subMbType;
int8_t pRefIndex[LIST_A][30];
UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1);
@@ -599,11 +595,11 @@
pSubPartCount[i] = g_ksInterBSubMbTypeInfo[0].iPartCount;
pPartW[i] = g_ksInterBSubMbTypeInfo[0].iPartWidth;
- if (IS_SUB_4x4 (subMbType)) {
+ if (IS_SUB_4x4 (*subMbType)) {
pSubPartCount[i] = 4;
pPartW[i] = 1;
}
- FillSpatialDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, bIsLongRef, iMvp, ref, NULL, NULL);
+ FillSpatialDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], *subMbType, bIsLongRef, iMvp, ref, NULL, NULL);
}
}
}
@@ -611,14 +607,14 @@
}
int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A],
- SubMbType& subMbType) {
- int32_t ret = ERR_NONE;
+ SubMbType *subMbType) {
+ int32_t ret;
PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
bool bSkipOrDirect = (IS_SKIP (GetMbType (pCurDqLayer)[iMbXy]) | IS_DIRECT (GetMbType (pCurDqLayer)[iMbXy])) > 0;
MbType mbType;
- ret = GetColocatedMb (pCtx, mbType, subMbType);
+ ret = GetColocatedMb (pCtx, &mbType, subMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -644,7 +640,7 @@
int16_t* mv = pCurDqLayer->iColocMv[LIST_0][0];
int8_t colocRefIndexL0 = pCurDqLayer->iColocRefIndex[LIST_0][0];
if (colocRefIndexL0 >= 0) {
- ref[LIST_0] = MapColToList0 (pCtx, colocRefIndexL0, ref0Count);
+ ref[LIST_0] = MapColToList0(pCtx, colocRefIndexL0, ref0Count);
} else {
mv = pCurDqLayer->iColocMv[LIST_1][0];
}
@@ -666,7 +662,7 @@
for (int32_t i = 0; i < 4; i++) {
int16_t iIdx8 = i << 2;
const uint8_t iScan4Idx = g_kuiScan4[iIdx8];
- pCurDqLayer->pSubMbType[iMbXy][i] = subMbType;
+ pCurDqLayer->pSubMbType[iMbXy][i] = *subMbType;
int16_t (*mvColoc)[2] = pCurDqLayer->iColocMv[LIST_0];
@@ -691,11 +687,11 @@
pSubPartCount[i] = g_ksInterBSubMbTypeInfo[0].iPartCount;
pPartW[i] = g_ksInterBSubMbTypeInfo[0].iPartWidth;
- if (IS_SUB_4x4 (subMbType)) {
+ if (IS_SUB_4x4 (*subMbType)) {
pSubPartCount[i] = 4;
pPartW[i] = 1;
}
- FillTemporalDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, ref, mvColoc, NULL, NULL);
+ FillTemporalDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], *subMbType, ref, mvColoc, NULL, NULL);
}
}
}
@@ -716,7 +712,7 @@
const int8_t kiLeftTopRef = iRefIndex[listIdx][ kuiLeftTopIdx];
int8_t iDiagonalRef = kiRightTopRef;
- int8_t iMatchRef = 0;
+ int8_t iMatchRef;
int16_t iAMV[2], iBMV[2], iCMV[2];
@@ -947,8 +943,8 @@
}
}
-void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
- const SubMbType& subMbType, const bool& bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A],
+void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t iIdx8, const int8_t iPartCount, const int8_t iPartW,
+ const SubMbType subMbType, const bool bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A],
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]) {
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
for (int32_t j = 0; j < iPartCount; j++) {
@@ -1074,9 +1070,9 @@
}
}
-void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount,
- const int8_t& iPartW,
- const SubMbType& subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2], int16_t pMotionVector[LIST_A][30][MV_A],
+void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t iIdx8, const int8_t iPartCount,
+ const int8_t iPartW,
+ const SubMbType subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2], int16_t pMotionVector[LIST_A][30][MV_A],
int16_t pMvdCache[LIST_A][30][MV_A]) {
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
@@ -1155,8 +1151,8 @@
}
}
}
-int8_t MapColToList0 (PWelsDecoderContext& pCtx, const int8_t& colocRefIndexL0,
- const int32_t& ref0Count) { //ISO/IEC 14496-10:2009(E) (8-193)
+int8_t MapColToList0 (PWelsDecoderContext pCtx, const int8_t colocRefIndexL0,
+ const int32_t ref0Count) { //ISO/IEC 14496-10:2009(E) (8-193)
//When reference is lost, this function must be skipped.
if ((pCtx->iErrorCode & dsRefLost) == dsRefLost) {
return 0;
@@ -1172,7 +1168,7 @@
}
return 0;
}
-void Update8x8RefIdx (PDqLayer& pCurDqLayer, const int16_t& iPartIdx, const int32_t& listIdx, const int8_t& iRef) {
+void Update8x8RefIdx (PDqLayer pCurDqLayer, const int16_t iPartIdx, const int32_t listIdx, const int8_t iRef) {
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
const uint8_t iScan4Idx = g_kuiScan4[iPartIdx];
pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx] = pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx + 1] =
@@ -1180,4 +1176,3 @@
5] = iRef;
}
-} // namespace WelsDec
--- a/codec/decoder/core/src/parse_mb_syn_cabac.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cabac.cpp
@@ -34,9 +34,7 @@
#include "decode_slice.h"
#include "mv_pred.h"
#include "error_code.h"
-#include <stdio.h>
-namespace WelsDec {
#define IDX_UNUSED -1
static const int16_t g_kMaxPos [] = {IDX_UNUSED, 15, 14, 15, 3, 14, 63, 3, 3, 14, 14};
@@ -70,33 +68,34 @@
};
static uint32_t DecodeCabacIntraMbType (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, int ctx_base) {
+ USED(pNeighAvail);
uint32_t uiCode;
- uint32_t uiMbType = 0;
+ uint32_t uiMbType;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + ctx_base;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx, &uiCode));
if (!uiCode) {
return 0; /* I4x4 */
}
- WELS_READ_VERIFY (DecodeTerminateCabac (pCabacDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeTerminateCabac (pCabacDecEngine, &uiCode));
if (uiCode) {
return 25; /* PCM */
}
uiMbType = 1; /* I16x16 */
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 1, uiCode)); /* cbp_luma != 0 */
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 1, &uiCode)); /* cbp_luma != 0 */
uiMbType += 12 * uiCode;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, &uiCode));
if (uiCode) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, &uiCode));
uiMbType += 4 + 4 * uiCode;
}
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
uiMbType += 2 * uiCode;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
uiMbType += 1 * uiCode;
return uiMbType;
}
@@ -140,6 +139,7 @@
void UpdateP8x8RefIdxCabac (PDqLayer pCurDqLayer, int8_t pRefIndex[LIST_A][30], int32_t iPartIdx, const int8_t iRef,
const int8_t iListIdx) {
+ USED(pRefIndex);
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
const uint8_t iScan4Idx = g_kuiScan4[iPartIdx];
pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx] = pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx + 1]
@@ -221,14 +221,14 @@
}
}
-int32_t ParseEndOfSliceCabac (PWelsDecoderContext pCtx, uint32_t& uiBinVal) {
- uiBinVal = 0;
+int32_t ParseEndOfSliceCabac (PWelsDecoderContext pCtx, uint32_t *uiBinVal) {
+ *uiBinVal = 0;
WELS_READ_VERIFY (DecodeTerminateCabac (pCtx->pCabacDecEngine, uiBinVal));
return ERR_NONE;
}
-int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSkip) {
- uiSkip = 0;
+int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiSkip) {
+ *uiSkip = 0;
int32_t iCtxInc = NEW_CTX_OFFSET_SKIP;
iCtxInc += (pNeighAvail->iLeftAvail && !IS_SKIP (pNeighAvail->iLeftType)) + (pNeighAvail->iTopAvail
&& !IS_SKIP (pNeighAvail->iTopType));
@@ -240,11 +240,11 @@
}
-int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal) {
+int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiBinVal) {
uint32_t uiCode;
- int32_t iIdxA = 0, iIdxB = 0;
+ int32_t iIdxA, iIdxB;
int32_t iCtxInc;
- uiBinVal = 0;
+ *uiBinVal = 0;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_MB_TYPE_I; //I mode in I slice
iIdxA = (pNeighAvail->iLeftAvail) && (pNeighAvail->iLeftType != MB_TYPE_INTRA4x4
@@ -252,28 +252,28 @@
iIdxB = (pNeighAvail->iTopAvail) && (pNeighAvail->iTopType != MB_TYPE_INTRA4x4
&& pNeighAvail->iTopType != MB_TYPE_INTRA8x8);
iCtxInc = iIdxA + iIdxB;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, uiCode));
- uiBinVal = uiCode;
- if (uiBinVal != 0) { //I16x16
- WELS_READ_VERIFY (DecodeTerminateCabac (pCabacDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, &uiCode));
+ *uiBinVal = uiCode;
+ if (*uiBinVal != 0) { //I16x16
+ WELS_READ_VERIFY (DecodeTerminateCabac (pCabacDecEngine, &uiCode));
if (uiCode == 1)
- uiBinVal = 25; //I_PCM
+ *uiBinVal = 25; //I_PCM
else {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
- uiBinVal = 1 + uiCode * 12;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
+ *uiBinVal = 1 + uiCode * 12;
//decoding of uiCbp:0,1,2
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 4, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 4, &uiCode));
if (uiCode != 0) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
- uiBinVal += 4;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
+ *uiBinVal += 4;
if (uiCode != 0)
- uiBinVal += 4;
+ *uiBinVal += 4;
}
//decoding of I pred-mode: 0,1,2,3
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 6, uiCode));
- uiBinVal += (uiCode << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 7, uiCode));
- uiBinVal += uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 6, &uiCode));
+ *uiBinVal += (uiCode << 1);
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 7, &uiCode));
+ *uiBinVal += uiCode;
}
}
//I4x4
@@ -280,66 +280,67 @@
return ERR_NONE;
}
-int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiMbType) {
+int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiMbType) {
+ USED(pNeighAvail);
uint32_t uiCode;
- uiMbType = 0;
+ *uiMbType = 0;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_SKIP;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
if (uiCode) {
// Intra MB
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 6, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 6, &uiCode));
if (uiCode) { // Intra 16x16
- WELS_READ_VERIFY (DecodeTerminateCabac (pCabacDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeTerminateCabac (pCabacDecEngine, &uiCode));
if (uiCode) {
- uiMbType = 30;
+ *uiMbType = 30;
return ERR_NONE;//MB_TYPE_INTRA_PCM;
}
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 7, uiCode));
- uiMbType = 6 + uiCode * 12;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 7, &uiCode));
+ *uiMbType = 6 + uiCode * 12;
//uiCbp: 0,1,2
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 8, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 8, &uiCode));
if (uiCode) {
- uiMbType += 4;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 8, uiCode));
+ *uiMbType += 4;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 8, &uiCode));
if (uiCode)
- uiMbType += 4;
+ *uiMbType += 4;
}
//IPredMode: 0,1,2,3
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 9, uiCode));
- uiMbType += (uiCode << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 9, uiCode));
- uiMbType += uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 9, &uiCode));
+ *uiMbType += (uiCode << 1);
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 9, &uiCode));
+ *uiMbType += uiCode;
} else
// Intra 4x4
- uiMbType = 5;
+ *uiMbType = 5;
} else { // P MB
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 4, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 4, &uiCode));
if (uiCode) { //second bit
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 6, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 6, &uiCode));
if (uiCode)
- uiMbType = 1;
+ *uiMbType = 1;
else
- uiMbType = 2;
+ *uiMbType = 2;
} else {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
if (uiCode)
- uiMbType = 3;
+ *uiMbType = 3;
else
- uiMbType = 0;
+ *uiMbType = 0;
}
}
return ERR_NONE;
}
-int32_t ParseMBTypeBSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiMbType) {
+int32_t ParseMBTypeBSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiMbType) {
uint32_t uiCode;
- uiMbType = 0;
- int32_t iIdxA = 0, iIdxB = 0;
+ *uiMbType = 0;
+ int32_t iIdxA, iIdxB;
int32_t iCtxInc;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
@@ -349,40 +350,40 @@
iIdxB = (pNeighAvail->iTopAvail) && !IS_DIRECT (pNeighAvail->iTopType);
iCtxInc = iIdxA + iIdxB;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, &uiCode));
if (!uiCode)
- uiMbType = 0; // Bi_Direct
+ *uiMbType = 0; // Bi_Direct
else {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
if (!uiCode) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
- uiMbType = 1 + uiCode; // 16x16 L0L1
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
+ *uiMbType = 1 + uiCode; // 16x16 L0L1
} else {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 4, uiCode));
- uiMbType = uiCode << 3;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
- uiMbType |= uiCode << 2;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
- uiMbType |= uiCode << 1;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
- uiMbType |= uiCode;
- if (uiMbType < 8) {
- uiMbType += 3;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 4, &uiCode));
+ *uiMbType = uiCode << 3;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
+ *uiMbType |= uiCode << 2;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
+ *uiMbType |= uiCode << 1;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
+ *uiMbType |= uiCode;
+ if (*uiMbType < 8) {
+ *uiMbType += 3;
return ERR_NONE;
- } else if (uiMbType == 13) {
- uiMbType = DecodeCabacIntraMbType (pCtx, pNeighAvail, 32) + 23;
+ } else if (*uiMbType == 13) {
+ *uiMbType = DecodeCabacIntraMbType (pCtx, pNeighAvail, 32) + 23;
return ERR_NONE;
- } else if (uiMbType == 14) {
- uiMbType = 11; // Bi8x16
+ } else if (*uiMbType == 14) {
+ *uiMbType = 11; // Bi8x16
return ERR_NONE;
- } else if (uiMbType == 15) {
- uiMbType = 22; // 8x8
+ } else if (*uiMbType == 15) {
+ *uiMbType = 22; // 8x8
return ERR_NONE;
}
- uiMbType <<= 1;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, uiCode));
- uiMbType |= uiCode;
- uiMbType -= 4;
+ *uiMbType <<= 1;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 5, &uiCode));
+ *uiMbType |= uiCode;
+ *uiMbType -= 4;
}
}
return ERR_NONE;
@@ -389,7 +390,7 @@
}
int32_t ParseTransformSize8x8FlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail,
- bool& bTransformSize8x8Flag) {
+ bool *bTransformSize8x8Flag) {
uint32_t uiCode;
int32_t iIdxA, iIdxB;
int32_t iCtxInc;
@@ -399,83 +400,85 @@
iIdxB = (pNeighAvail->iTopAvail)
&& (pCtx->pCurDqLayer->pTransformSize8x8Flag[pCtx->pCurDqLayer->iMbXyIndex - pCtx->pCurDqLayer->iMbWidth]);
iCtxInc = iIdxA + iIdxB;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, uiCode));
- bTransformSize8x8Flag = !!uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, &uiCode));
+ *bTransformSize8x8Flag = !!uiCode;
return ERR_NONE;
}
-int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType) {
+int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiSubMbType) {
+ USED(pNeighAvail);
uint32_t uiCode;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_SUBMB_TYPE;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx, &uiCode));
if (uiCode)
- uiSubMbType = 0;
+ *uiSubMbType = 0;
else {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 1, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 1, &uiCode));
if (uiCode) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, uiCode));
- uiSubMbType = 3 - uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, &uiCode));
+ *uiSubMbType = 3 - uiCode;
} else {
- uiSubMbType = 1;
+ *uiSubMbType = 1;
}
}
return ERR_NONE;
}
-int32_t ParseBSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType) {
+int32_t ParseBSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiSubMbType) {
+ USED(pNeighAvail);
uint32_t uiCode;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_B_SUBMB_TYPE;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx, &uiCode));
if (!uiCode) {
- uiSubMbType = 0; /* B_Direct_8x8 */
+ *uiSubMbType = 0; /* B_Direct_8x8 */
return ERR_NONE;
}
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 1, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 1, &uiCode));
if (!uiCode) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
- uiSubMbType = 1 + uiCode; /* B_L0_8x8, B_L1_8x8 */
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
+ *uiSubMbType = 1 + uiCode; /* B_L0_8x8, B_L1_8x8 */
return ERR_NONE;
}
- uiSubMbType = 3;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, uiCode));
+ *uiSubMbType = 3;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 2, &uiCode));
if (uiCode) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
if (uiCode) {
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
- uiSubMbType = 11 + uiCode; /* B_L1_4x4, B_Bi_4x4 */
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
+ *uiSubMbType = 11 + uiCode; /* B_L1_4x4, B_Bi_4x4 */
return ERR_NONE;
}
- uiSubMbType += 4;
+ *uiSubMbType += 4;
}
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
- uiSubMbType += 2 * uiCode;
- WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
- uiSubMbType += uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
+ *uiSubMbType += 2 * uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, &uiCode));
+ *uiSubMbType += uiCode;
return ERR_NONE;
}
-int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t& iBinVal) {
+int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t *iBinVal) {
uint32_t uiCode;
- iBinVal = 0;
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR, uiCode));
+ *iBinVal = 0;
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR, &uiCode));
if (uiCode == 1)
- iBinVal = -1;
+ *iBinVal = -1;
else {
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR + 1, uiCode));
- iBinVal |= uiCode;
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR + 1, uiCode));
- iBinVal |= (uiCode << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR + 1, uiCode));
- iBinVal |= (uiCode << 2);
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR + 1, &uiCode));
+ *iBinVal |= uiCode;
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR + 1, &uiCode));
+ *iBinVal |= (uiCode << 1);
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_IPR + 1, &uiCode));
+ *iBinVal |= (uiCode << 2);
}
return ERR_NONE;
}
-int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeighAvail, int32_t& iBinVal) {
+int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeighAvail, int32_t *iBinVal) {
uint32_t uiCode;
int32_t iIdxA, iIdxB, iCtxInc;
int8_t* pChromaPredMode = pCtx->pCurDqLayer->pChromaPredMode;
@@ -487,7 +490,7 @@
int32_t iMbXyTop = iMbXy - pCtx->pCurDqLayer->iMbWidth;
int32_t iMbXyLeft = iMbXy - 1;
- iBinVal = 0;
+ *iBinVal = 0;
iIdxB = iTopAvail && (pChromaPredMode[iMbXyTop] > 0 && pChromaPredMode[iMbXyTop] <= 3)
&& pMbType[iMbXyTop] != MB_TYPE_INTRA_PCM;
@@ -494,24 +497,24 @@
iIdxA = iLeftAvail && (pChromaPredMode[iMbXyLeft] > 0 && pChromaPredMode[iMbXyLeft] <= 3)
&& pMbType[iMbXyLeft] != MB_TYPE_INTRA_PCM;
iCtxInc = iIdxA + iIdxB;
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CIPR + iCtxInc, uiCode));
- iBinVal = uiCode;
- if (iBinVal != 0) {
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CIPR + iCtxInc, &uiCode));
+ *iBinVal = uiCode;
+ if (*iBinVal != 0) {
uint32_t iSym;
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CIPR + 3, iSym));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CIPR + 3, &iSym));
if (iSym == 0) {
- iBinVal = (iSym + 1);
+ *iBinVal = (iSym + 1);
return ERR_NONE;
}
iSym = 0;
do {
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CIPR + 3, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CIPR + 3, &uiCode));
++iSym;
} while ((uiCode != 0) && (iSym < 1));
if ((uiCode != 0) && (iSym == 1))
++ iSym;
- iBinVal = (iSym + 1);
+ *iBinVal = (iSym + 1);
return ERR_NONE;
}
return ERR_NONE;
@@ -541,7 +544,7 @@
case MB_TYPE_16x16: {
iPartIdx = 0;
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, 0, LIST_0, iPartIdx, pRefCount[0], 0,
- iRef[0]));
+ &iRef[0]));
if ((iRef[0] < 0) || (iRef[0] >= pRefCount[0]) || (ppRefPic[iRef[0]] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
@@ -554,8 +557,8 @@
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRef[0]]
&& (ppRefPic[iRef[0]]->bIsComplete || bIsPending));
PredMv (pMotionVector, pRefIndex, LIST_0, 0, 4, iRef[0], pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -567,7 +570,7 @@
for (i = 0; i < 2; i++) {
iPartIdx = i << 3;
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, 0, LIST_0, iPartIdx, pRefCount[0], 0,
- iRef[i]));
+ &iRef[i]));
if ((iRef[i] < 0) || (iRef[i] >= pRefCount[0]) || (ppRefPic[iRef[i]] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
@@ -584,8 +587,8 @@
for (i = 0; i < 2; i++) {
iPartIdx = i << 3;
PredInter16x8Mv (pMotionVector, pRefIndex, LIST_0, iPartIdx, iRef[i], pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -597,7 +600,7 @@
for (i = 0; i < 2; i++) {
iPartIdx = i << 2;
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, 0, LIST_0, iPartIdx, pRefCount[0], 0,
- iRef[i]));
+ &iRef[i]));
if ((iRef[i] < 0) || (iRef[i] >= pRefCount[0]) || (ppRefPic[iRef[i]] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
@@ -615,8 +618,8 @@
iPartIdx = i << 2;
PredInter8x16Mv (pMotionVector, pRefIndex, LIST_0, i << 2, iRef[i], pMv/*&mv[0], &mv[1]*/);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -630,7 +633,7 @@
uint32_t uiSubMbType;
//sub_mb_type, partition
for (i = 0; i < 4; i++) {
- WELS_READ_VERIFY (ParseSubMBTypeCabac (pCtx, pNeighAvail, uiSubMbType));
+ WELS_READ_VERIFY (ParseSubMBTypeCabac (pCtx, pNeighAvail, &uiSubMbType));
if (uiSubMbType >= 4) { //invalid sub_mb_type
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_SUB_MB_TYPE);
}
@@ -645,7 +648,7 @@
for (i = 0; i < 4; i++) {
int16_t iIdx8 = i << 2;
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, 0, LIST_0, iIdx8, pRefCount[0], 1,
- pRefIdx[i]));
+ &pRefIdx[i]));
if ((pRefIdx[i] < 0) || (pRefIdx[i] >= pRefCount[0]) || (ppRefPic[pRefIdx[i]] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
@@ -674,8 +677,8 @@
iScan4Idx = g_kuiScan4[iPartIdx];
iCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
PredMv (pMotionVector, pRefIndex, LIST_0, iPartIdx, iBlockW, pRefIdx[i], pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, LIST_0, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -749,13 +752,13 @@
SubMbType subMbType;
if (pSliceHeader->iDirectSpatialMvPredFlag) {
//predict direct spatial mv
- int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, subMbType);
+ int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
} else {
//temporal direct 16x16 mode
- int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, subMbType);
+ int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -767,7 +770,7 @@
if (IS_DIR (mbType, 0, listIdx)) {
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, pDirect, listIdx, iPartIdx,
pRefCount[listIdx], 0,
- iRef[listIdx]));
+ &iRef[listIdx]));
if ((iRef[listIdx] < 0) || (iRef[listIdx] >= pRefCount[listIdx])
|| (pCtx->sRefPic.pRefList[listIdx][iRef[listIdx]] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
@@ -785,8 +788,8 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (IS_DIR (mbType, 0, listIdx)) {
PredMv (pMotionVector, pRefIndex, listIdx, 0, 4, iRef[listIdx], pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -804,7 +807,7 @@
int8_t ref_idx = REF_NOT_IN_LIST;
if (IS_DIR (mbType, i, listIdx)) {
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, pDirect, listIdx, iPartIdx,
- pRefCount[listIdx], 0, ref_idx));
+ pRefCount[listIdx], 0, &ref_idx));
if ((ref_idx < 0) || (ref_idx >= pRefCount[listIdx])
|| (pCtx->sRefPic.pRefList[listIdx][ref_idx] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
@@ -828,8 +831,8 @@
int8_t ref_idx = ref_idx_list[listIdx][i];
if (IS_DIR (mbType, i, listIdx)) {
PredInter16x8Mv (pMotionVector, pRefIndex, listIdx, iPartIdx, ref_idx, pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -848,7 +851,7 @@
int8_t ref_idx = REF_NOT_IN_LIST;
if (IS_DIR (mbType, i, listIdx)) {
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, pDirect, listIdx, iPartIdx,
- pRefCount[listIdx], 0, ref_idx));
+ pRefCount[listIdx], 0, &ref_idx));
if ((ref_idx < 0) || (ref_idx >= pRefCount[listIdx])
|| (pCtx->sRefPic.pRefList[listIdx][ref_idx] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
@@ -872,8 +875,8 @@
int8_t ref_idx = ref_idx_list[listIdx][i];
if (IS_DIR (mbType, i, listIdx)) {
PredInter8x16Mv (pMotionVector, pRefIndex, listIdx, iPartIdx, ref_idx, pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -899,7 +902,7 @@
bool has_direct_called = false;
SubMbType directSubMbType = 0;
for (int32_t i = 0; i < 4; i++) {
- WELS_READ_VERIFY (ParseBSubMBTypeCabac (pCtx, pNeighAvail, uiSubMbType));
+ WELS_READ_VERIFY (ParseBSubMBTypeCabac (pCtx, pNeighAvail, &uiSubMbType));
if (uiSubMbType >= 13) { //invalid sub_mb_type
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_SUB_MB_TYPE);
}
@@ -914,7 +917,7 @@
if (IS_DIRECT (g_ksInterBSubMbTypeInfo[uiSubMbType].iType)) {
if (!has_direct_called) {
if (pSliceHeader->iDirectSpatialMvPredFlag) {
- int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, directSubMbType);
+ int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, &directSubMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -921,7 +924,7 @@
} else {
//temporal direct mode
- int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, directSubMbType);
+ int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, &directSubMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -983,7 +986,7 @@
if (IS_DIR (subMbType, 0, listIdx)) {
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, pDirect, listIdx, iIdx8,
pRefCount[listIdx], 1,
- iref));
+ &iref));
if ((iref < 0) || (iref >= pRefCount[listIdx]) || (pCtx->sRefPic.pRefList[listIdx][iref] == NULL)) { //error ref_idx
pCtx->bMbRefConcealed = true;
if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
@@ -1026,8 +1029,8 @@
iCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
if (is_dir) {
PredMv (pMotionVector, pRefIndex, listIdx, iPartIdx, iBlockW, iref, pMv);
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, pMvd[0]));
- WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, pMvd[1]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 0, &pMvd[0]));
+ WELS_READ_VERIFY (ParseMvdInfoCabac (pCtx, pNeighAvail, pRefIndex, pMvdCache, iPartIdx, listIdx, 1, &pMvd[1]));
pMv[0] += pMvd[0];
pMv[1] += pMvd[1];
WELS_CHECK_SE_BOTH_WARNING (pMv[1], iMinVmv, iMaxVmv, "vertical mv");
@@ -1076,13 +1079,14 @@
int32_t ParseRefIdxCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* nzc,
int8_t ref_idx[LIST_A][30], int8_t direct[30],
- int32_t iListIdx, int32_t iZOrderIdx, int32_t iActiveRefNum, int32_t b8mode, int8_t& iRefIdxVal) {
+ int32_t iListIdx, int32_t iZOrderIdx, int32_t iActiveRefNum, int32_t b8mode, int8_t *iRefIdxVal) {
+ USED(b8mode); USED(nzc);
if (iActiveRefNum == 1) {
- iRefIdxVal = 0;
+ *iRefIdxVal = 0;
return ERR_NONE;
}
uint32_t uiCode;
- int32_t iIdxA = 0, iIdxB = 0;
+ int32_t iIdxA, iIdxB;
int32_t iCtxInc = 0;
int8_t* pRefIdxInMB = pCtx->pCurDqLayer->pDec->pRefIndex[iListIdx][pCtx->pCurDqLayer->iMbXyIndex];
int8_t* pDirect = pCtx->pCurDqLayer->pDirect[pCtx->pCurDqLayer->iMbXyIndex];
@@ -1140,22 +1144,23 @@
iCtxInc = iIdxA + (iIdxB << 1);
}
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_REF_NO + iCtxInc, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_REF_NO + iCtxInc, &uiCode));
if (uiCode) {
- WELS_READ_VERIFY (DecodeUnaryBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_REF_NO + 4, 1, uiCode));
+ WELS_READ_VERIFY (DecodeUnaryBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_REF_NO + 4, 1, &uiCode));
++uiCode;
}
- iRefIdxVal = (int8_t) uiCode;
+ *iRefIdxVal = (int8_t) uiCode;
return ERR_NONE;
}
int32_t ParseMvdInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, int8_t pRefIndex[LIST_A][30],
- int16_t pMvdCache[LIST_A][30][2], int32_t index, int8_t iListIdx, int8_t iMvComp, int16_t& iMvdVal) {
+ int16_t pMvdCache[LIST_A][30][2], int32_t index, int8_t iListIdx, int8_t iMvComp, int16_t *iMvdVal) {
+ USED(pNeighAvail);
uint32_t uiCode;
int32_t iIdxA = 0;
//int32_t sym;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_MVD + iMvComp * CTX_NUM_MVD;
- iMvdVal = 0;
+ *iMvdVal = 0;
if (pRefIndex[iListIdx][g_kuiCache30ScanIdx[index] - 6] >= 0)
iIdxA = WELS_ABS (pMvdCache[iListIdx][g_kuiCache30ScanIdx[index] - 6][iMvComp]);
@@ -1166,23 +1171,23 @@
if (iIdxA >= 3)
iCtxInc = 1 + (iIdxA > 32);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pBinCtx + iCtxInc, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pBinCtx + iCtxInc, &uiCode));
if (uiCode) {
- WELS_READ_VERIFY (DecodeUEGMvCabac (pCtx->pCabacDecEngine, pBinCtx + 3, 3, uiCode));
- iMvdVal = (int16_t) (uiCode + 1);
- WELS_READ_VERIFY (DecodeBypassCabac (pCtx->pCabacDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeUEGMvCabac (pCtx->pCabacDecEngine, pBinCtx + 3, 3, &uiCode));
+ *iMvdVal = (int16_t) (uiCode + 1);
+ WELS_READ_VERIFY (DecodeBypassCabac (pCtx->pCabacDecEngine, &uiCode));
if (uiCode) {
- iMvdVal = -iMvdVal;
+ *iMvdVal = -*iMvdVal;
}
} else {
- iMvdVal = 0;
+ *iMvdVal = 0;
}
return ERR_NONE;
}
-int32_t ParseCbpInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiCbp) {
- int32_t iIdxA = 0, iIdxB = 0, pALeftMb[2], pBTopMb[2];
- uiCbp = 0;
+int32_t ParseCbpInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t *uiCbp) {
+ int32_t iIdxA, iIdxB, pALeftMb[2], pBTopMb[2];
+ *uiCbp = 0;
uint32_t pCbpBit[6];
int32_t iCtxInc;
@@ -1198,31 +1203,31 @@
//left_top 8x8 block
iCtxInc = pALeftMb[0] + (pBTopMb[0] << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, pCbpBit[0]));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, &pCbpBit[0]));
if (pCbpBit[0])
- uiCbp += 0x01;
+ *uiCbp += 0x01;
//right_top 8x8 block
iIdxA = !pCbpBit[0];
iCtxInc = iIdxA + (pBTopMb[1] << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, pCbpBit[1]));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, &pCbpBit[1]));
if (pCbpBit[1])
- uiCbp += 0x02;
+ *uiCbp += 0x02;
//left_bottom 8x8 block
iIdxB = !pCbpBit[0];
iCtxInc = pALeftMb[1] + (iIdxB << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, pCbpBit[2]));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, &pCbpBit[2]));
if (pCbpBit[2])
- uiCbp += 0x04;
+ *uiCbp += 0x04;
//right_bottom 8x8 block
iIdxB = !pCbpBit[1];
iIdxA = !pCbpBit[2];
iCtxInc = iIdxA + (iIdxB << 1);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, pCbpBit[3]));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + iCtxInc, &pCbpBit[3]));
if (pCbpBit[3])
- uiCbp += 0x08;
+ *uiCbp += 0x08;
if (pCtx->pSps->uiChromaFormatIdc == 0)//monochroma
return ERR_NONE;
@@ -1235,7 +1240,7 @@
//BitIdx = 0
iCtxInc = iIdxA + (iIdxB << 1);
WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + CTX_NUM_CBP + iCtxInc,
- pCbpBit[4]));
+ &pCbpBit[4]));
//BitIdx = 1
if (pCbpBit[4]) {
@@ -1244,8 +1249,8 @@
iCtxInc = iIdxA + (iIdxB << 1);
WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine,
pCtx->pCabacCtx + NEW_CTX_OFFSET_CBP + 2 * CTX_NUM_CBP + iCtxInc,
- pCbpBit[5]));
- uiCbp += 1 << (4 + pCbpBit[5]);
+ &pCbpBit[5]));
+ *uiCbp += 1 << (4 + pCbpBit[5]);
}
@@ -1252,26 +1257,26 @@
return ERR_NONE;
}
-int32_t ParseDeltaQpCabac (PWelsDecoderContext pCtx, int32_t& iQpDelta) {
+int32_t ParseDeltaQpCabac (PWelsDecoderContext pCtx, int32_t *iQpDelta) {
uint32_t uiCode;
PSlice pCurrSlice = & (pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer);
- iQpDelta = 0;
+ *iQpDelta = 0;
PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_DELTA_QP;
int32_t iCtxInc = (pCurrSlice->iLastDeltaQp != 0);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pBinCtx + iCtxInc, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pBinCtx + iCtxInc, &uiCode));
if (uiCode != 0) {
- WELS_READ_VERIFY (DecodeUnaryBinCabac (pCtx->pCabacDecEngine, pBinCtx + 2, 1, uiCode));
+ WELS_READ_VERIFY (DecodeUnaryBinCabac (pCtx->pCabacDecEngine, pBinCtx + 2, 1, &uiCode));
uiCode++;
- iQpDelta = (uiCode + 1) >> 1;
+ *iQpDelta = (uiCode + 1) >> 1;
if ((uiCode & 1) == 0)
- iQpDelta = - iQpDelta;
+ *iQpDelta = -*iQpDelta;
}
- pCurrSlice->iLastDeltaQp = iQpDelta;
+ pCurrSlice->iLastDeltaQp = *iQpDelta;
return ERR_NONE;
}
int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int32_t iZIndex, int32_t iResProperty,
- PWelsDecoderContext pCtx, uint32_t& uiCbfBit) {
+ PWelsDecoderContext pCtx, uint32_t *uiCbfBit) {
int8_t nA, nB/*, zigzag_idx = 0*/;
int32_t iCurrBlkXy = pCtx->pCurDqLayer->iMbXyIndex;
int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring
@@ -1279,7 +1284,7 @@
uint16_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc;
uint32_t* pMbType = pCtx->pCurDqLayer->pDec->pMbType;
int32_t iCtxInc;
- uiCbfBit = 0;
+ *uiCbfBit = 0;
nA = nB = (int8_t)!!IS_INTRA (pMbType[iCurrBlkXy]);
if (iResProperty == I16_LUMA_DC || iResProperty == CHROMA_DC_U || iResProperty == CHROMA_DC_V) { //DC
@@ -1290,7 +1295,7 @@
iCtxInc = nA + (nB << 1);
WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine,
pCtx->pCabacCtx + NEW_CTX_OFFSET_CBF + g_kBlockCat2CtxOffsetCBF[iResProperty] + iCtxInc, uiCbfBit));
- if (uiCbfBit)
+ if (*uiCbfBit)
pCbfDc[iCurrBlkXy] |= (1 << iResProperty);
} else { //AC
//for 4x4 blk, make sure blk-idx is correct
@@ -1313,7 +1318,7 @@
}
int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty, PWelsDecoderContext pCtx,
- uint32_t& uiCoeffNum) {
+ uint32_t *uiCoeffNum) {
uint32_t uiCode;
PWelsCabacCtx pMapCtx = pCtx->pCabacCtx + (iResProperty == LUMA_DC_AC_8 ? NEW_CTX_OFFSET_MAP_8x8 : NEW_CTX_OFFSET_MAP)
@@ -1323,7 +1328,7 @@
int32_t i;
- uiCoeffNum = 0;
+ *uiCoeffNum = 0;
int32_t i0 = 0;
int32_t i1 = g_kMaxPos[iResProperty];
@@ -1332,13 +1337,13 @@
for (i = i0; i < i1; ++i) {
iCtx = (iResProperty == LUMA_DC_AC_8 ? g_kuiIdx2CtxSignificantCoeffFlag8x8[i] : i);
//read significant
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pMapCtx + iCtx, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pMapCtx + iCtx, &uiCode));
if (uiCode) {
* (pSignificantMap++) = 1;
- ++ uiCoeffNum;
+ ++(*uiCoeffNum);
//read last significant
iCtx = (iResProperty == LUMA_DC_AC_8 ? g_kuiIdx2CtxLastSignificantCoeffFlag8x8[i] : i);
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pLastCtx + iCtx, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pLastCtx + iCtx, &uiCode));
if (uiCode) {
memset (pSignificantMap, 0, (i1 - i) * sizeof (int32_t));
return ERR_NONE;
@@ -1351,7 +1356,7 @@
//if(i < i1+1)
{
*pSignificantMap = 1;
- ++uiCoeffNum;
+ ++(*uiCoeffNum);
}
return ERR_NONE;
@@ -1371,10 +1376,10 @@
int32_t c2 = 0;
for (; i >= 0; --i) {
if (*pCoff != 0) {
- WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pOneCtx + c1, uiCode));
+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pOneCtx + c1, &uiCode));
*pCoff += uiCode;
if (*pCoff == 2) {
- WELS_READ_VERIFY (DecodeUEGLevelCabac (pCtx->pCabacDecEngine, pAbsCtx + c2, uiCode));
+ WELS_READ_VERIFY (DecodeUEGLevelCabac (pCtx->pCabacDecEngine, pAbsCtx + c2, &uiCode));
*pCoff += uiCode;
++c2;
c2 = WELS_MIN (c2, iMaxType);
@@ -1383,7 +1388,7 @@
++c1;
c1 = WELS_MIN (c1, 4);
}
- WELS_READ_VERIFY (DecodeBypassCabac (pCtx->pCabacDecEngine, uiCode));
+ WELS_READ_VERIFY (DecodeBypassCabac (pCtx->pCabacDecEngine, &uiCode));
if (uiCode)
*pCoff = - *pCoff;
}
@@ -1395,6 +1400,7 @@
int32_t ParseResidualBlockCabac8x8 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux,
int32_t iIndex, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty,
short* sTCoeff, /*int mb_mode*/ uint8_t uiQp, PWelsDecoderContext pCtx) {
+ USED(iMaxNumCoeff); USED(pBsAux); USED(pNeighAvail);
uint32_t uiTotalCoeffNum = 0;
uint32_t uiCbpBit;
int32_t pSignificantMap[64] = {0};
@@ -1406,7 +1412,7 @@
uiCbpBit = 1; // for 8x8, MaxNumCoeff == 64 && uiCbpBit == 1
if (uiCbpBit) { //has coeff
- WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, uiTotalCoeffNum));
+ WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, &uiTotalCoeffNum));
WELS_READ_VERIFY (ParseSignificantCoeffCabac (pSignificantMap, iResProperty, pCtx));
}
@@ -1436,6 +1442,7 @@
int32_t iIndex, int32_t iMaxNumCoeff,
const uint8_t* pScanTable, int32_t iResProperty, short* sTCoeff, /*int mb_mode*/ uint8_t uiQp,
PWelsDecoderContext pCtx) {
+ USED(iMaxNumCoeff); USED(pBsAux);
int32_t iCurNzCacheIdx;
uint32_t uiTotalCoeffNum = 0;
uint32_t uiCbpBit;
@@ -1446,9 +1453,9 @@
const uint16_t* pDeQuantMul = (pCtx->bUseScalingList) ? pCtx->pDequant_coeff4x4[iMbResProperty][uiQp] :
g_kuiDequantCoeff[uiQp];
- WELS_READ_VERIFY (ParseCbfInfoCabac (pNeighAvail, pNonZeroCountCache, iIndex, iResProperty, pCtx, uiCbpBit));
+ WELS_READ_VERIFY (ParseCbfInfoCabac (pNeighAvail, pNonZeroCountCache, iIndex, iResProperty, pCtx, &uiCbpBit));
if (uiCbpBit) { //has coeff
- WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, uiTotalCoeffNum));
+ WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, &uiTotalCoeffNum));
WELS_READ_VERIFY (ParseSignificantCoeffCabac (pSignificantMap, iResProperty, pCtx));
}
@@ -1552,10 +1559,9 @@
WELS_READ_VERIFY (InitCabacDecEngineFromBS (pCabacDecEngine, pBsAux));
return ERR_NONE;
}
-void UpdateP8x8RefCacheIdxCabac (int8_t pRefIndex[LIST_A][30], const int16_t& iPartIdx,
- const int32_t& listIdx, const int8_t& iRef) {
+void UpdateP8x8RefCacheIdxCabac (int8_t pRefIndex[LIST_A][30], const int16_t iPartIdx,
+ const int32_t listIdx, const int8_t iRef) {
const uint8_t uiCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
pRefIndex[listIdx][uiCacheIdx] = pRefIndex[listIdx][uiCacheIdx + 1] = pRefIndex[listIdx][uiCacheIdx + 6] =
pRefIndex[listIdx][uiCacheIdx + 7] = iRef;
-}
}
--- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
@@ -44,7 +44,6 @@
#include "error_code.h"
#include "mv_pred.h"
-namespace WelsDec {
#define MAX_LEVEL_PREFIX 15
typedef struct TagReadBitsCache {
@@ -680,8 +679,7 @@
// return: used bits
-static int32_t CavlcGetTrailingOnesAndTotalCoeff (uint8_t& uiTotalCoeff, uint8_t& uiTrailingOnes,
- SReadBitsCache* pBitsCache, SVlcTable* pVlcTable, bool bChromaDc, int8_t nC) {
+static int32_t CavlcGetTrailingOnesAndTotalCoeff (uint8_t *uiTotalCoeff, uint8_t *uiTrailingOnes, SReadBitsCache* pBitsCache, SVlcTable* pVlcTable, bool bChromaDc, int8_t nC) {
const uint8_t* kpVlcTableMoreBitsCountList[3] = {g_kuiVlcTableMoreBitsCount0, g_kuiVlcTableMoreBitsCount1, g_kuiVlcTableMoreBitsCount2};
int32_t iUsedBits = 0;
int32_t iIndexVlc, iIndexValue, iNcMapIdx;
@@ -694,8 +692,8 @@
uiCount = pVlcTable->kpChromaCoeffTokenVlcTable[uiValue][1];
POP_BUFFER (pBitsCache, uiCount);
iUsedBits += uiCount;
- uiTrailingOnes = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][0];
- uiTotalCoeff = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][1];
+ *uiTrailingOnes = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][0];
+ *uiTotalCoeff = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][1];
} else { //luma
iNcMapIdx = g_kuiNcMapTable[nC];
if (iNcMapIdx <= 2) {
@@ -712,6 +710,7 @@
iIndexVlc = pVlcTable->kpCoeffTokenVlcTable[0][iNcMapIdx][uiValue][0];
uiCount = pVlcTable->kpCoeffTokenVlcTable[0][iNcMapIdx][uiValue][1];
uiValue = pBitsCache->uiCache32Bit >> (32 - uiCount);
+ USED(uiValue);
POP_BUFFER (pBitsCache, uiCount);
iUsedBits += uiCount;
}
@@ -721,8 +720,8 @@
iUsedBits += 6;
iIndexVlc = pVlcTable->kpCoeffTokenVlcTable[0][3][uiValue][0]; //differ
}
- uiTrailingOnes = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][0];
- uiTotalCoeff = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][1];
+ *uiTrailingOnes = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][0];
+ *uiTotalCoeff = g_kuiVlcTrailingOneTotalCoeffTable[iIndexVlc][1];
}
return iUsedBits;
@@ -781,7 +780,7 @@
return iUsedBits;
}
-static int32_t CavlcGetTotalZeros (int32_t& iZerosLeft, SReadBitsCache* pBitsCache, uint8_t uiTotalCoeff,
+static int32_t CavlcGetTotalZeros (int32_t *iZerosLeft, SReadBitsCache* pBitsCache, uint8_t uiTotalCoeff,
SVlcTable* pVlcTable, bool bChromaDc) {
int32_t iCount, iUsedBits = 0;
const uint8_t* kpBitNumMap;
@@ -808,7 +807,7 @@
iCount = pVlcTable->kpTotalZerosTable[uiTableType][iTotalZeroVlcIdx - 1][uiValue][1];
POP_BUFFER (pBitsCache, iCount);
iUsedBits += iCount;
- iZerosLeft = pVlcTable->kpTotalZerosTable[uiTableType][iTotalZeroVlcIdx - 1][uiValue][0];
+ *iZerosLeft = pVlcTable->kpTotalZerosTable[uiTableType][iTotalZeroVlcIdx - 1][uiValue][0];
return iUsedBits;
}
@@ -898,7 +897,7 @@
WELS_NON_ZERO_COUNT_AVERAGE (nC, nA, nB);
- iUsedBits += CavlcGetTrailingOnesAndTotalCoeff (uiTotalCoeff, uiTrailingOnes, &sReadBitsCache, pVlcTable, bChromaDc,
+ iUsedBits += CavlcGetTrailingOnesAndTotalCoeff (&uiTotalCoeff, &uiTrailingOnes, &sReadBitsCache, pVlcTable, bChromaDc,
nC);
if (iResidualProperty != CHROMA_DC && iResidualProperty != I16_LUMA_DC) {
@@ -917,7 +916,7 @@
}
iUsedBits += i;
if (uiTotalCoeff < iMaxNumCoeff) {
- iUsedBits += CavlcGetTotalZeros (iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
+ iUsedBits += CavlcGetTotalZeros (&iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
} else {
iZerosLeft = 0;
}
@@ -1017,7 +1016,7 @@
WELS_NON_ZERO_COUNT_AVERAGE (nC, nA, nB);
- iUsedBits += CavlcGetTrailingOnesAndTotalCoeff (uiTotalCoeff, uiTrailingOnes, &sReadBitsCache, pVlcTable, bChromaDc,
+ iUsedBits += CavlcGetTrailingOnesAndTotalCoeff (&uiTotalCoeff, &uiTrailingOnes, &sReadBitsCache, pVlcTable, bChromaDc,
nC);
if (iResidualProperty != CHROMA_DC && iResidualProperty != I16_LUMA_DC) {
@@ -1036,7 +1035,7 @@
}
iUsedBits += i;
if (uiTotalCoeff < iMaxNumCoeff) {
- iUsedBits += CavlcGetTotalZeros (iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
+ iUsedBits += CavlcGetTotalZeros (&iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
} else {
iZerosLeft = 0;
}
@@ -1357,13 +1356,13 @@
SubMbType subMbType;
if (pSliceHeader->iDirectSpatialMvPredFlag) {
//predict direct spatial mv
- int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, subMbType);
+ int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
} else {
//temporal direct 16x16 mode
- int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, subMbType);
+ int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, &subMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -1562,7 +1561,7 @@
if (IS_DIRECT (g_ksInterBSubMbTypeInfo[uiSubMbType].iType)) {
if (!has_direct_called) {
if (pSliceHeader->iDirectSpatialMvPredFlag) {
- int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, directSubMbType);
+ int32_t ret = PredMvBDirectSpatial (pCtx, pMvDirect, iRef, &directSubMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -1569,7 +1568,7 @@
} else {
//temporal direct mode
- int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, directSubMbType);
+ int32_t ret = PredBDirectTemporal (pCtx, pMvDirect, iRef, &directSubMbType);
if (ret != ERR_NONE) {
return ret;
}
@@ -1722,4 +1721,3 @@
}
return ERR_NONE;
}
-} // namespace WelsDec
--- a/codec/decoder/core/src/pic_queue.cpp
+++ b/codec/decoder/core/src/pic_queue.cpp
@@ -42,8 +42,6 @@
#include "codec_def.h"
#include "memory_align.h"
-namespace WelsDec {
-
void FreePicture (PPicture pPic, CMemoryAlign* pMa);
@@ -60,14 +58,14 @@
PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight) {
- PPicture pPic = NULL;
- int32_t iPicWidth = 0;
- int32_t iPicHeight = 0;
+ PPicture pPic;
+ int32_t iPicWidth;
+ int32_t iPicHeight;
- int32_t iPicChromaWidth = 0;
- int32_t iPicChromaHeight = 0;
- int32_t iLumaSize = 0;
- int32_t iChromaSize = 0;
+ int32_t iPicChromaWidth;
+ int32_t iPicChromaHeight;
+ int32_t iLumaSize;
+ int32_t iChromaSize;
CMemoryAlign* pMa = pCtx->pMemAlign;
pPic = (PPicture) pMa->WelsMallocz (sizeof (SPicture), "PPicture");
@@ -89,7 +87,7 @@
pPic->iLinesize[0] = iPicWidth;
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
} else {
- pPic->pBuffer[0] = static_cast<uint8_t*> (pMa->WelsMallocz (iLumaSize /* luma */
+ pPic->pBuffer[0] = (uint8_t*) (pMa->WelsMallocz (iLumaSize /* luma */
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic, pMa));
@@ -177,11 +175,10 @@
pPic->pReadyEvent = NULL;
}
pMa->WelsFree (pPic, "pPic");
- pPic = NULL;
}
}
PPicture PrefetchPic (PPicBuff pPicBuf) {
- int32_t iPicIdx = 0;
+ int32_t iPicIdx;
PPicture pPic = NULL;
if (pPicBuf->iCapacity == 0) {
@@ -216,7 +213,7 @@
}
PPicture PrefetchPicForThread (PPicBuff pPicBuf) {
- PPicture pPic = NULL;
+ PPicture pPic;
if (pPicBuf->iCapacity == 0) {
return NULL;
@@ -229,7 +226,7 @@
return pPic;
}
-PPicture PrefetchLastPicForThread (PPicBuff pPicBuf, const int32_t& iLastPicBuffIdx) {
+PPicture PrefetchLastPicForThread (PPicBuff pPicBuf, const int32_t iLastPicBuffIdx) {
PPicture pPic = NULL;
if (pPicBuf->iCapacity == 0) {
@@ -240,5 +237,3 @@
}
return pPic;
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/rec_mb.cpp
+++ b/codec/decoder/core/src/rec_mb.cpp
@@ -42,8 +42,6 @@
#include "rec_mb.h"
#include "decode_slice.h"
-namespace WelsDec {
-
void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurDqLayer) {
PPicture pCurPic = pCtx->pDec;
int32_t iLumaStride = pCurPic->iLinesize[0];
@@ -82,7 +80,7 @@
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8;
/*************local variable********************/
- uint8_t i = 0;
+ uint8_t i;
bool bTLAvail[4], bTRAvail[4];
// Top-Right : Left : Top-Left : Top
bTLAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x02);
@@ -137,7 +135,7 @@
/*************local variable********************/
- uint8_t i = 0;
+ uint8_t i;
/*************real process*********************/
for (i = 0; i < 16; i++) {
@@ -214,7 +212,7 @@
//according to current 8*8 block ref_index to gain reference picture
-static inline int32_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, const int8_t& iRefIdx,
+static inline int32_t GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, const int8_t iRefIdx,
int32_t listIdx) {
PPicture pRefPic;
@@ -241,7 +239,7 @@
#ifndef MC_FLOW_SIMPLE_JUDGE
#define MC_FLOW_SIMPLE_JUDGE 1
#endif //MC_FLOW_SIMPLE_JUDGE
-void BaseMC (PWelsDecoderContext pCtx, sMCRefMember* pMCRefMem, const int32_t& listIdx, const int8_t& iRefIdx,
+void BaseMC (PWelsDecoderContext pCtx, sMCRefMember* pMCRefMem, const int32_t listIdx, const int8_t iRefIdx,
int32_t iXOffset, int32_t iYOffset,
SMcFunc* pMCFunc,
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
@@ -265,7 +263,7 @@
}
int32_t offset = (iFullMVy >> 2) + iBlkHeight + 3 + 16;
if (offset > pCtx->lastReadyHeightOffset[listIdx][iRefIdx]) {
- const int32_t down_line = WELS_MIN (offset >> 4, int32_t (pCtx->sMb.iMbHeight) - 1);
+ const int32_t down_line = WELS_MIN (offset >> 4, (int32_t) (pCtx->sMb.iMbHeight) - 1);
if (pRefPic->pReadyEvent[down_line].isSignaled != 1) {
WAIT_EVENT (&pRefPic->pReadyEvent[down_line], WELS_DEC_THREAD_WAIT_INFINITE);
}
@@ -302,7 +300,7 @@
int32_t iLog2denom, iWoc, iOoc;
int32_t iPredTemp, iLineStride;
- int32_t iPixel = 0;
+ int32_t iPixel;
uint8_t* pDst;
//luma
iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;
@@ -366,9 +364,9 @@
static void BiWeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, sMCRefMember* pTempMCRefMem,
int32_t iRefIdx1, int32_t iRefIdx2, bool bWeightedBipredIdcIs1, int32_t iBlkWidth,
int32_t iBlkHeight) {
- int32_t iWoc1 = 0, iOoc1 = 0, iWoc2 = 0, iOoc2 = 0;
+ int32_t iWoc1, iOoc1 = 0, iWoc2, iOoc2 = 0;
int32_t iPredTemp, iLineStride;
- int32_t iPixel = 0;
+ int32_t iPixel;
//luma
int32_t iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;
if (bWeightedBipredIdcIs1) {
@@ -424,8 +422,9 @@
static void BiPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, sMCRefMember* pTempMCRefMem, int32_t iBlkWidth,
int32_t iBlkHeight) {
+ USED(pCurDqLayer);
int32_t iPredTemp, iLineStride;
- int32_t iPixel = 0;
+ int32_t iPixel;
//luma
iLineStride = pMCRefMem->iDstLineLuma;
@@ -488,7 +487,7 @@
pMCRefMem.iDstLineLuma = iDstLineLuma;
pMCRefMem.iDstLineChroma = iDstLineChroma;
- int8_t iRefIndex = 0;
+ int8_t iRefIndex;
switch (iMBType) {
case MB_TYPE_SKIP:
@@ -701,7 +700,7 @@
int8_t iRefIndex0 = 0;
int8_t iRefIndex1 = 0;
- int8_t iRefIndex = 0;
+ int8_t iRefIndex;
bool bWeightedBipredIdcIs1 = pCurDqLayer->sLayerInfo.pPps->uiWeightedBipredIdc == 1;
@@ -1058,7 +1057,7 @@
int32_t iChromaStride = pCtx->pCurDqLayer->pDec->iLinesize[1];
PIdctFourResAddPredFunc pIdctFourResAddPredFunc = pCtx->pIdctFourResAddPredFunc;
- uint8_t i = 0;
+ uint8_t i;
uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4;
if (1 == uiCbpC || 2 == uiCbpC) {
@@ -1074,5 +1073,3 @@
return ERR_NONE;
}
-
-} // namespace WelsDec
--- a/codec/decoder/core/src/wels_decoder_thread.cpp
+++ b/codec/decoder/core/src/wels_decoder_thread.cpp
@@ -38,29 +38,7 @@
*************************************************************************************
*/
-
-#ifdef __linux__
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-#include <sched.h>
-#elif !defined(_WIN32) && !defined(__CYGWIN__)
-#include <sys/types.h>
-#include <sys/param.h>
-#include <unistd.h>
-#ifndef __Fuchsia__
-#include <sys/sysctl.h>
-#endif
-#ifdef __APPLE__
-#define HW_NCPU_NAME "hw.logicalcpu"
-#else
-#define HW_NCPU_NAME "hw.ncpu"
-#endif
-#endif
-
#include "wels_decoder_thread.h"
-#include <stdio.h>
-#include <stdlib.h>
int32_t GetCPUCount() {
WelsLogicalProcessInfo pInfo;
--- /dev/null
+++ b/codec/mkfile
@@ -1,0 +1,55 @@
+</$objtype/mkfile
+
+LIB=libopenh264.a
+
+CFLAGS=$CFLAGS -p -D__plan9__ -D__${objtype}__ -Iapi/svc -Icommon/inc -Idecoder/core/inc/
+
+OFILES=\
+ au_parser.$O\
+ bit_stream.$O\
+ cabac_decoder.$O\
+ deblocking.$O\
+ decode_mb_aux.$O\
+ decode_slice.$O\
+ decoder.$O\
+ decoder_core.$O\
+ decoder_data_tables.$O\
+ error_concealment.$O\
+ fmo.$O\
+ get_intra_predictor.$O\
+ manage_dec_ref.$O\
+ memmgr_nal_unit.$O\
+ mv_pred.$O\
+ parse_mb_syn_cabac.$O\
+ parse_mb_syn_cavlc.$O\
+ pic_queue.$O\
+ rec_mb.$O\
+ \
+ common_tables.$O\
+ copy_mb.$O\
+ crt_util_safe_x.$O\
+ deblocking_common.$O\
+ expand_pic.$O\
+ intra_pred_common.$O\
+ mc.$O\
+ sad_common.$O\
+ utils.$O\
+ \
+ plan9.$O\
+
+# wels_decoder_thread.$O\
+
+UPDATE=\
+ mkfile\
+ $HFILES\
+ ${OFILES:%.$O=%.c}\
+ ${TARG:%=%.c}\
+ ${LIB}\
+
+</sys/src/cmd/mklib
+
+%.$O: decoder/core/src/%.cpp
+ $CC $CFLAGS -o $target decoder/core/src/$stem.cpp
+
+%.$O: common/src/%.cpp
+ $CC $CFLAGS -o $target common/src/$stem.cpp
--- /dev/null
+++ b/codec/plan9.c
@@ -1,0 +1,92 @@
+#include "decoder.h"
+
+uint32_t
+WelsCPUFeatureDetect(int32_t *pNumberOfLogicProcessors)
+{
+ char *s;
+
+ s = getenv("NPROC");
+ *pNumberOfLogicProcessors = s ? atoi(s) : 0;
+
+ return 0;
+}
+
+void
+EventPost(SWelsDecEvent* e)
+{
+ USED(e);
+}
+
+int
+EventCreate(SWelsDecEvent *e, int manualReset, int initialState)
+{
+ USED(e, manualReset, initialState);
+ return 0;
+}
+
+int
+EventWait(SWelsDecEvent *e, int32_t timeout)
+{
+ USED(e, timeout);
+ return 0;
+}
+
+void
+EventDestroy(SWelsDecEvent *e)
+{
+ USED(e);
+}
+
+void
+EventReset(SWelsDecEvent *e)
+{
+ USED(e);
+}
+
+void *
+WelsMallocz(const uint32_t kuiSize, const char *kpTag)
+{
+ void *p;
+ USED(kpTag);
+ if((p = mallocalign(kuiSize, 16, 0, 0)) == nil)
+ return nil;
+ return memset(p, 0, kuiSize);
+}
+
+static void *
+WelsMalloc(const uint32_t kuiSize, const char *kpTag)
+{
+ USED(kpTag);
+ return mallocalign(kuiSize, 16, 0, 0);
+}
+
+void
+WelsFree(void *pPointer, const char *kpTag)
+{
+ USED(kpTag);
+ free(pPointer);
+}
+
+static uint32_t
+WelsGetCacheLineSize(void)
+{
+ return 16;
+}
+
+static uint32_t
+WelsGetMemoryUsage(void)
+{
+ return 0;
+}
+
+CMemoryAlign cMemoryAlign = {
+#ifdef MEMORY_MONITOR
+ .m_nMemoryUsageInBytes = 0,
+#endif
+ .m_nCacheLineSize = 16,
+ .WelsMallocz = WelsMallocz,
+ .WelsMalloc = WelsMalloc,
+ .WelsFree = WelsFree,
+ .WelsGetCacheLineSize = WelsGetCacheLineSize,
+ .WelsGetMemoryUsage = WelsGetMemoryUsage,
+};