shithub: openh264

Download patch

ref: eeb11578cad1f284eefd90ab203fac4b5b8c2f69
parent: 9bf4b592834d46704090c7ca2b323feb0d684281
parent: 15bd7dab57752e7a2ecbad766037c76e1a8a2190
author: ekr <[email protected]>
date: Thu Jan 9 13:07:57 EST 2014

Merge pull request #123 from licaiguo/update-vs2010-files

Update vs2010 files

--- a/codec/build/win32/dec/WelsDecCore_2010.vcxproj
+++ b/codec/build/win32/dec/WelsDecCore_2010.vcxproj
@@ -250,12 +250,14 @@
     </CustomBuild>
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\..\..\common\cpu.h" />
+    <ClInclude Include="..\..\..\common\cpu_core.h" />
     <ClInclude Include="..\..\..\common\logging.h" />
+    <ClInclude Include="..\..\..\common\macros.h" />
+    <ClInclude Include="..\..\..\common\typedefs.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\as264_common.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\au_parser.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\bit_stream.h" />
-    <ClInclude Include="..\..\..\decoder\core\inc\cpu.h" />
-    <ClInclude Include="..\..\..\decoder\core\inc\cpu_core.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\deblocking.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\decode_mb_aux.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\decoder.h" />
@@ -265,7 +267,6 @@
     <ClInclude Include="..\..\..\decoder\core\inc\fmo.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\get_intra_predictor.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\ls_defines.h" />
-    <ClInclude Include="..\..\..\decoder\core\inc\macros.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\manage_dec_ref.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\mb_cache.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\mc.h" />
@@ -285,7 +286,6 @@
     <ClInclude Include="..\..\..\decoder\core\inc\dec_frame.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\dec_golomb.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\decoder_core.h" />
-    <ClInclude Include="..\..\..\decoder\core\inc\typedefs.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\utils.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\vlc_decoder.h" />
     <ClInclude Include="..\..\..\decoder\core\inc\wels_common_basis.h" />
@@ -292,10 +292,11 @@
     <ClInclude Include="..\..\..\decoder\core\inc\wels_const.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\..\..\common\cpu.cpp" />
+    <ClCompile Include="..\..\..\common\deblocking_common.cpp" />
     <ClCompile Include="..\..\..\common\logging.cpp" />
     <ClCompile Include="..\..\..\decoder\core\src\au_parser.cpp" />
     <ClCompile Include="..\..\..\decoder\core\src\bit_stream.cpp" />
-    <ClCompile Include="..\..\..\decoder\core\src\cpu.cpp" />
     <ClCompile Include="..\..\..\decoder\core\src\deblocking.cpp" />
     <ClCompile Include="..\..\..\decoder\core\src\decode_mb_aux.cpp" />
     <ClCompile Include="..\..\..\decoder\core\src\decoder.cpp" />
--- a/codec/build/win32/dec/WelsDecCore_2010.vcxproj.filters
+++ b/codec/build/win32/dec/WelsDecCore_2010.vcxproj.filters
@@ -7,9 +7,6 @@
     <ClCompile Include="..\..\..\decoder\core\src\bit_stream.cpp">
       <Filter>sources</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\decoder\core\src\cpu.cpp">
-      <Filter>sources</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\..\decoder\core\src\deblocking.cpp">
       <Filter>sources</Filter>
     </ClCompile>
@@ -67,6 +64,12 @@
     <ClCompile Include="..\..\..\common\logging.cpp">
       <Filter>sources</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\common\cpu.cpp">
+      <Filter>sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\common\deblocking_common.cpp">
+      <Filter>sources</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\decoder\core\inc\as264_common.h">
@@ -81,12 +84,6 @@
     <ClInclude Include="..\..\..\decoder\core\inc\bit_stream.h">
       <Filter>headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\decoder\core\inc\cpu.h">
-      <Filter>headers</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\..\decoder\core\inc\cpu_core.h">
-      <Filter>headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\decoder\core\inc\deblocking.h">
       <Filter>headers</Filter>
     </ClInclude>
@@ -126,9 +123,6 @@
     <ClInclude Include="..\..\..\decoder\core\inc\ls_defines.h">
       <Filter>headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\decoder\core\inc\macros.h">
-      <Filter>headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\decoder\core\inc\manage_dec_ref.h">
       <Filter>headers</Filter>
     </ClInclude>
@@ -174,9 +168,6 @@
     <ClInclude Include="..\..\..\decoder\core\inc\slice.h">
       <Filter>headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\decoder\core\inc\typedefs.h">
-      <Filter>headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\decoder\core\inc\utils.h">
       <Filter>headers</Filter>
     </ClInclude>
@@ -187,6 +178,18 @@
       <Filter>headers</Filter>
     </ClInclude>
     <ClInclude Include="..\..\..\common\logging.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\cpu.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\cpu_core.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\typedefs.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\macros.h">
       <Filter>headers</Filter>
     </ClInclude>
   </ItemGroup>
--- a/codec/build/win32/enc/WelsEncCore_2010.vcxproj
+++ b/codec/build/win32/enc/WelsEncCore_2010.vcxproj
@@ -94,7 +94,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\common;..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;WELS_SVC;ENCODER_CORE;X86_ASM;HAVE_CACHE_LINE_ALIGN;MT_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -126,7 +126,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\common;..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN64;_DEBUG;X86_ASM;_LIB;WELS_SVC;ENCODER_CORE;HAVE_CACHE_LINE_ALIGN;MT_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -160,7 +160,7 @@
       <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\common;..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;WELS_SVC;ENCODER_CORE;X86_ASM;HAVE_CACHE_LINE_ALIGN;MT_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -196,7 +196,7 @@
       <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\common;..\..\..\encoder\core\inc;..\..\..\api\svc;..\..\..\WelsThreadLib\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN64;NDEBUG;X86_ASM;_LIB;WELS_SVC;ENCODER_CORE;HAVE_CACHE_LINE_ALIGN;MT_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -227,6 +227,8 @@
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\..\..\common\cpu.cpp" />
+    <ClCompile Include="..\..\..\common\deblocking_common.cpp" />
     <ClCompile Include="..\..\..\encoder\core\src\au_set.cpp">
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -237,16 +239,6 @@
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <ClCompile Include="..\..\..\encoder\core\src\cpu.cpp">
-      <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
     <ClCompile Include="..\..\..\encoder\core\src\deblocking.cpp">
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -504,12 +496,14 @@
     <ClCompile Include="..\..\..\encoder\core\src\wels_preprocess.cpp" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\..\..\common\cpu.h" />
+    <ClInclude Include="..\..\..\common\cpu_core.h" />
+    <ClInclude Include="..\..\..\common\macros.h" />
+    <ClInclude Include="..\..\..\common\typedefs.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\array_stack_align.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\as264_common.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\au_set.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\bit_stream.h" />
-    <ClInclude Include="..\..\..\encoder\core\inc\cpu.h" />
-    <ClInclude Include="..\..\..\encoder\core\inc\cpu_core.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\deblocking.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\decode_mb_aux.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\dq_map.h" />
@@ -520,7 +514,6 @@
     <ClInclude Include="..\..\..\encoder\core\inc\extern.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\get_intra_predictor.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\ls_defines.h" />
-    <ClInclude Include="..\..\..\encoder\core\inc\macros.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\mb_cache.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\mc.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\md.h" />
@@ -554,7 +547,6 @@
     <ClInclude Include="..\..\..\encoder\core\inc\svc_motion_estimate.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\svc_set_mb_syn_cavlc.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\trace.h" />
-    <ClInclude Include="..\..\..\encoder\core\inc\typedefs.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\utils.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\vlc_encoder.h" />
     <ClInclude Include="..\..\..\encoder\core\inc\wels_common_basis.h" />
--- a/codec/build/win32/enc/WelsEncCore_2010.vcxproj.filters
+++ b/codec/build/win32/enc/WelsEncCore_2010.vcxproj.filters
@@ -7,9 +7,6 @@
     <ClCompile Include="..\..\..\encoder\core\src\au_set.cpp">
       <Filter>sources</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\encoder\core\src\cpu.cpp">
-      <Filter>sources</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\..\encoder\core\src\deblocking.cpp">
       <Filter>sources</Filter>
     </ClCompile>
@@ -97,6 +94,12 @@
     <ClCompile Include="..\..\..\encoder\core\src\wels_preprocess.cpp">
       <Filter>sources</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\common\cpu.cpp">
+      <Filter>sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\common\deblocking_common.cpp">
+      <Filter>sources</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\encoder\core\inc\array_stack_align.h">
@@ -111,12 +114,6 @@
     <ClInclude Include="..\..\..\encoder\core\inc\bit_stream.h">
       <Filter>headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\encoder\core\inc\cpu.h">
-      <Filter>headers</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\..\encoder\core\inc\cpu_core.h">
-      <Filter>headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\encoder\core\inc\deblocking.h">
       <Filter>headers</Filter>
     </ClInclude>
@@ -150,9 +147,6 @@
     <ClInclude Include="..\..\..\encoder\core\inc\ls_defines.h">
       <Filter>headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\encoder\core\inc\macros.h">
-      <Filter>headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\encoder\core\inc\mb_cache.h">
       <Filter>headers</Filter>
     </ClInclude>
@@ -252,9 +246,6 @@
     <ClInclude Include="..\..\..\encoder\core\inc\trace.h">
       <Filter>headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\encoder\core\inc\typedefs.h">
-      <Filter>headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\encoder\core\inc\utils.h">
       <Filter>headers</Filter>
     </ClInclude>
@@ -274,6 +265,18 @@
       <Filter>headers</Filter>
     </ClInclude>
     <ClInclude Include="..\..\..\WelsThreadLib\api\WelsThreadLib.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\cpu.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\cpu_core.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\typedefs.h">
+      <Filter>headers</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\common\macros.h">
       <Filter>headers</Filter>
     </ClInclude>
   </ItemGroup>
--- /dev/null
+++ b/codec/common/macros.h
@@ -1,0 +1,403 @@
+/*!
+ * \copy
+ *     Copyright (c)  2009-2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file	macros.h
+ *
+ * \brief	MACRO based tool utilization
+ *
+ * \date	3/13/2009 Created
+ *
+ *************************************************************************************
+ */
+#ifndef WELS_MACRO_UTILIZATIONS_H__
+#define WELS_MACRO_UTILIZATIONS_H__
+
+#include <math.h>
+#include <assert.h>
+#include "typedefs.h"
+
+/*
+* FORCE_STACK_ALIGN_1D: force 1 dimension local data aligned in stack
+* _tp: type
+* _nm: var name
+* _sz: size
+* _al: align bytes
+* auxiliary var: _nm ## _tEmP
+*/
+#define FORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
+	_tp _nm ## _tEmP[(_sz)+(_al)-1]; \
+	_tp *_nm = _nm ## _tEmP + ((_al)-1) - (((uintptr_t)(_nm ## _tEmP + ((_al)-1)) & ((_al)-1))/sizeof(_tp))
+
+
+#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
+	assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
+	_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
+	_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
+	_nm ## _tEmP_al -= (((uintptr_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
+	_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
+
+
+///////////// from encoder
+#if defined(_MSC_VER)
+
+#if(_MSC_VER < 1700)
+#define inline	__inline
+#endif
+
+#define __FASTCALL   __fastcall
+#define ALIGNED_DECLARE( type, var, n ) __declspec(align(n)) type var
+#define __align8(t,v) __declspec(align(8)) t v
+#define __align16(t,v) __declspec(align(16)) t v
+#elif defined(__GNUC__)
+#if !defined(MAC_POWERPC)
+#define __FASTCALL    __attribute__ ((fastcall))
+#else
+#define __FASTCALL	// mean NULL for mac ppc
+#endif//MAC_POWERPC
+#define ALIGNED_DECLARE( type, var, n ) type var __attribute__((aligned(n)))
+#define __align8(t,v) t v __attribute__ ((aligned (8)))
+#define __align16(t,v) t v __attribute__ ((aligned (16)))
+#endif//_MSC_VER
+
+#if defined(_MACH_PLATFORM) || defined(__GNUC__)
+#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
+	type name[(sizex)*(sizey)] __attribute__((aligned(alignment)))
+#else //_MSC_VER <= 1200
+#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
+__declspec(align(alignment)) type name[(sizex)*(sizey)]
+#endif//#if _MACH_PLATFORM
+
+#if defined(_MACH_PLATFORM) || defined(__GNUC__)
+#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
+	type name[size] __attribute__((aligned(alignment)))
+#else //_MSC_VER <= 1200
+#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
+	__declspec(align(alignment)) type name[(size)]
+#endif//#if _MACH_PLATFORM
+
+#if defined(_MSC_VER)
+#define inline	__inline
+#define __FASTCALL   __fastcall
+//	#define __align8(t,v) __declspec(align(8)) t v
+#define __align16(t,v) __declspec(align(16)) t v
+#elif defined(__GNUC__)
+#if !defined(MAC_POWERPC) && !defined(UNIX) && !defined(ANDROID_NDK) && !defined(APPLE_IOS)
+#define __FASTCALL    __attribute__ ((fastcall))// linux, centos, mac_x86 can be used
+#else
+#define __FASTCALL	// mean NULL for mac_ppc, solaris(sparc/x86)
+#endif//MAC_POWERPC
+//	#define __align8(t,v) t v __attribute__ ((aligned (8)))
+#define __align16(t,v) t v __attribute__ ((aligned (16)))
+
+#if defined(APPLE_IOS)
+#define inline  //For iOS platform
+#endif
+
+#endif//_MSC_VER
+
+
+#if !defined(SIZEOFRGB24)
+#define SIZEOFRGB24(cx, cy)	(3 * (cx) * (cy))
+#endif//SIZEOFRGB24
+
+#if !defined(SIZEOFRGB32)
+#define SIZEOFRGB32(cx, cy)	(4 * (cx) * (cy))
+#endif//SIZEOFRGB32
+#if 1
+#ifndef	WELS_ALIGN
+#define WELS_ALIGN(x, n)	(((x)+(n)-1)&~((n)-1))
+#endif//WELS_ALIGN
+
+#ifndef WELS_MAX
+#define WELS_MAX(x, y)	((x) > (y) ? (x) : (y))
+#endif//WELS_MAX
+
+#ifndef WELS_MIN
+#define WELS_MIN(x, y)	((x) < (y) ? (x) : (y))
+#endif//WELS_MIN
+#else
+
+#ifndef	WELS_ALIGN
+#define WELS_ALIGN(x, n)	(((x)+(n)-1)&~((n)-1))
+#endif//WELS_ALIGN
+
+#ifndef WELS_MAX
+#define WELS_MAX(x, y)	((x) - (((x)-(y))&(((x)-(y))>>31)))
+#endif//WELS_MAX
+
+#ifndef WELS_MIN
+#define WELS_MIN(x, y)	((y) + (((x)-(y))&(((x)-(y))>>31)))
+#endif//WELS_MIN
+
+#endif
+
+#ifndef WELS_CEIL
+#define WELS_CEIL(x)	ceil(x)	// FIXME: low complexity instead of math library used
+#endif//WELS_CEIL
+
+#ifndef WELS_FLOOR
+#define WELS_FLOOR(x)	floor(x)	// FIXME: low complexity instead of math library used
+#endif//WELS_FLOOR
+
+#ifndef WELS_ROUND
+#define WELS_ROUND(x)	((int32_t)(0.5f+(x)))
+#endif//WELS_ROUND
+
+#define WELS_NON_ZERO_COUNT_AVERAGE(nC,nA,nB) {		\
+    nC = nA + nB + 1;                      \
+	nC >>= (uint8_t)( nA != -1 && nB != -1);        \
+	nC += (uint8_t)(nA == -1 && nB == -1);           \
+}
+
+static __inline int32_t CeilLog2 (int32_t i) {
+int32_t s = 0;
+i--;
+while (i > 0) {
+  s++;
+  i >>= 1;
+}
+return s;
+}
+/*
+the second path will degrades the performance
+*/
+#if 1
+static inline int32_t WelsMedian (int32_t iX,  int32_t iY, int32_t iZ) {
+int32_t iMin = iX, iMax = iX;
+
+if (iY < iMin)
+  iMin	= iY;
+else
+  iMax = iY;
+
+if (iZ < iMin)
+  iMin	= iZ;
+else if (iZ > iMax)
+  iMax	= iZ;
+
+return (iX + iY + iZ) - (iMin + iMax);
+}
+#else
+static inline int32_t WelsMedian (int32_t iX,  int32_t iY, int32_t iZ) {
+int32_t iTmp = (iX - iY) & ((iX - iY) >> 31);
+iX -= iTmp;
+iY += iTmp;
+iY -= (iY - iZ) & ((iY - iZ) >> 31);
+iY += (iX - iY) & ((iX - iY) >> 31);
+return iY;
+}
+
+#endif
+
+#ifndef NEG_NUM
+//#define NEG_NUM( num ) (-num)
+#define NEG_NUM(iX) (1+(~(iX)))
+#endif// NEG_NUM
+
+#ifndef WELS_CLIP1
+//#define WELS_CLIP1(x) (x & ~255) ? (-x >> 31) : x
+#define WELS_CLIP1(iX) (((iX) & ~255) ? (-(iX) >> 31) : (iX)) //iX not only a value but also can be an expression
+#endif//WELS_CLIP1
+
+
+#ifndef WELS_SIGN
+#define WELS_SIGN(iX) ((int32_t)(iX) >> 31)
+#endif //WELS_SIGN
+#ifndef WELS_ABS
+#define WELS_ABS(iX) ((WELS_SIGN(iX) ^ (int32_t)(iX)) - WELS_SIGN(iX))
+#endif //WELS_ABS
+
+// WELS_CLIP3
+#ifndef WELS_CLIP3
+#define WELS_CLIP3(iX, iY, iZ) ((iX) < (iY) ? (iY) : ((iX) > (iZ) ? (iZ) : (iX)))
+#endif //WELS_CLIP3
+
+/*
+ * Description: to check variable validation and return the specified result
+ *	iResult:	value to be return
+ *	bCaseIf:	negative condition to be verified
+ */
+#ifndef WELS_VERIFY_RETURN_IF
+#define WELS_VERIFY_RETURN_IF(iResult, bCaseIf) \
+	if ( bCaseIf ){ \
+		return iResult; \
+	}
+#endif//#if WELS_VERIFY_RETURN_IF
+
+/*
+ *	Description: to check variable validation and return the specified result
+ *		with correspoinding process advance.
+ *	 result:	value to be return
+ *	 case_if:	negative condition to be verified
+ *	 proc:		process need perform
+ */
+#ifndef WELS_VERIFY_RETURN_PROC_IF
+#define WELS_VERIFY_RETURN_PROC_IF(iResult, bCaseIf, fProc) \
+	if ( bCaseIf ){ \
+		fProc;	\
+		return iResult;	\
+	}
+#endif//#if WELS_VERIFY_RETURN_PROC_IF
+
+/*
+ * Description:	to check variable validation and return
+ *	case_if:	negtive condition to be verified
+ *	return:		NONE
+ */
+#ifndef WELS_VERIFY_IF
+#define WELS_VERIFY_IF(bCaseIf) \
+	if ( bCaseIf ){ \
+		return; \
+	}
+#endif//#if WELS_VERIFY_IF
+
+/*
+ * Description:	to check variable validation and return with correspoinding process advance.
+ *	case_if:	negtive condition to be verified
+ *	proc:		process need preform
+ *	return:		NONE
+ */
+#ifndef WELS_VERIFY_PROC_IF
+#define WELS_VERIFY_PROC_IF(bCaseIf, fProc) \
+	if ( bCaseIf ){ \
+		fProc; \
+		return; \
+	}
+#endif//#if WELS_VERIFY_IF
+
+/*
+ * Description: to safe free a ptr with free function pointer
+ *  p:			pointer to be destroyed
+ *	free_fn:	free function pointer used
+ */
+#ifndef WELS_SAFE_FREE_P
+#define WELS_SAFE_FREE_P(pPtr, fFreeFunc) \
+	do{ \
+		if ( NULL != (pPtr) ){ \
+			fFreeFunc( (pPtr) ); \
+			(pPtr) = NULL; \
+		} \
+	}while( 0 );
+#endif//#if WELS_SAFE_FREE_P
+
+/*
+ * Description: to safe free an array ptr with free function pointer
+ *	arr:		pointer to an array, something like "**p";
+ *	num:		number of elements in array
+ *  free_fn:	free function pointer
+ */
+#ifndef WELS_SAFE_FREE_ARR
+#define WELS_SAFE_FREE_ARR(pArray, iNum, fFreeFunc) \
+	do{ \
+		if ( NULL != (pArray) ){ \
+			int32_t iIdx = 0; \
+			while( iIdx < iNum ){ \
+				if ( NULL != (pArray)[iIdx] ){ \
+					fFreeFunc( (pArray)[iIdx] ); \
+					(pArray)[iIdx] = NULL; \
+				} \
+				++ iIdx; \
+			} \
+			fFreeFunc((pArray)); \
+			(pArray) = NULL; \
+		} \
+	}while( 0 );
+#endif//#if WELS_SAFE_FREE_ARR
+static inline int32_t WELS_LOG2 (uint32_t v) {
+int32_t r = 0;
+while (v >>= 1) {
+  ++r;
+}
+return r;
+
+}
+
+#define CLIP3_QP_0_51(q)		WELS_CLIP3(q, 0, 51)	// ((q) < (0) ? (0) : ((q) > (51) ? (51) : (q)))
+#define   CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)
+#ifdef    WORDS_BIGENDIAN
+
+static inline uint32_t ENDIAN_FIX (uint32_t x) {
+return x;
+}
+
+#else
+
+
+#if defined(_MSC_VER) && defined(_M_IX86)
+static inline uint32_t ENDIAN_FIX (uint32_t x) {
+__asm {
+  mov   eax,  x
+  bswap   eax
+  mov   x,    eax
+}
+return x;
+}
+#else  // GCC
+static inline uint32_t ENDIAN_FIX (uint32_t x) {
+#ifdef X86_ARCH
+__asm__ __volatile__ ("bswap %0":"+r" (x));
+#else
+x = ((x & 0xff000000) >> 24) | ((x & 0xff0000) >> 8) |
+    ((x & 0xff00) << 8) | ((x & 0xff) << 24);
+#endif
+return x;
+}
+
+
+#endif
+
+#endif
+#ifndef BUTTERFLY1x2
+#define BUTTERFLY1x2(b) (((b)<<8) | (b))
+#endif//BUTTERFLY1x2
+
+#ifndef BUTTERFLY2x4
+#define BUTTERFLY2x4(wd) (((uint32_t)(wd)<<16) |(wd))
+#endif//BUTTERFLY2x4
+
+#ifndef BUTTERFLY4x8
+#define BUTTERFLY4x8(dw) (((uint64_t)(dw)<<32) | (dw))
+#endif//BUTTERFLY4x8
+
+static inline int32_t WELS_MEDIAN (int32_t x,  int32_t y, int32_t z) {
+int32_t t = (x - y) & ((x - y) >> 31);
+x -= t;
+y += t;
+y -= (y - z) & ((y - z) >> 31);
+y += (x - y) & ((x - y) >> 31);
+return y;
+}
+static inline BOOL_T WELS_POWER2_IF (uint32_t v) {
+return (v && ! (v & (v - 1)));
+}
+
+
+#endif//WELS_MACRO_UTILIZATIONS_H__
--- a/codec/decoder/core/inc/macros.h
+++ /dev/null
@@ -1,303 +1,0 @@
-/*!
- * \copy
- *     Copyright (c)  2009-2013, Cisco Systems
- *     All rights reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *        * Redistributions of source code must retain the above copyright
- *          notice, this list of conditions and the following disclaimer.
- *
- *        * Redistributions in binary form must reproduce the above copyright
- *          notice, this list of conditions and the following disclaimer in
- *          the documentation and/or other materials provided with the
- *          distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *     POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * \file	macros.h
- *
- * \brief	MACRO based tool utilization
- *
- * \date	3/13/2009 Created
- *
- *************************************************************************************
- */
-#ifndef WELS_MACRO_UTILIZATIONS_H__
-#define WELS_MACRO_UTILIZATIONS_H__
-
-#include <math.h>
-#include <assert.h>
-#include "typedefs.h"
-
-
-namespace WelsDec {
-
-/*
-* FORCE_STACK_ALIGN_1D: force 1 dimension local data aligned in stack
-* _tp: type
-* _nm: var name
-* _sz: size
-* _al: align bytes
-* auxiliary var: _nm ## _tEmP
-*/
-#define FORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
-	_tp _nm ## _tEmP[(_sz)+(_al)-1]; \
-	_tp *_nm = _nm ## _tEmP + ((_al)-1) - (((uintptr_t)(_nm ## _tEmP + ((_al)-1)) & ((_al)-1))/sizeof(_tp))
-
-
-#define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
-	assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
-	_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
-	_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
-	_nm ## _tEmP_al -= (((uintptr_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
-	_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
-
-
-///////////// from encoder
-#if defined(_MSC_VER)
-#define inline	__inline
-#define __FASTCALL   __fastcall
-//	#define __align8(t,v) __declspec(align(8)) t v
-#define __align16(t,v) __declspec(align(16)) t v
-#elif defined(__GNUC__)
-#if !defined(MAC_POWERPC) && !defined(UNIX) && !defined(ANDROID_NDK) && !defined(APPLE_IOS)
-#define __FASTCALL    __attribute__ ((fastcall))// linux, centos, mac_x86 can be used
-#else
-#define __FASTCALL	// mean NULL for mac_ppc, solaris(sparc/x86)
-#endif//MAC_POWERPC
-//	#define __align8(t,v) t v __attribute__ ((aligned (8)))
-#define __align16(t,v) t v __attribute__ ((aligned (16)))
-
-#if defined(APPLE_IOS)
-#define inline  //For iOS platform
-#endif
-
-#endif//_MSC_VER
-
-
-#if !defined(SIZEOFRGB24)
-#define SIZEOFRGB24(cx, cy)	(3 * (cx) * (cy))
-#endif//SIZEOFRGB24
-
-#if !defined(SIZEOFRGB32)
-#define SIZEOFRGB32(cx, cy)	(4 * (cx) * (cy))
-#endif//SIZEOFRGB32
-#if 1
-#ifndef	WELS_ALIGN
-#define WELS_ALIGN(x, n)	(((x)+(n)-1)&~((n)-1))
-#endif//WELS_ALIGN
-
-#ifndef WELS_MAX
-#define WELS_MAX(x, y)	((x) > (y) ? (x) : (y))
-#endif//WELS_MAX
-
-#ifndef WELS_MIN
-#define WELS_MIN(x, y)	((x) < (y) ? (x) : (y))
-#endif//WELS_MIN
-#else
-
-#ifndef	WELS_ALIGN
-#define WELS_ALIGN(x, n)	(((x)+(n)-1)&~((n)-1))
-#endif//WELS_ALIGN
-
-#ifndef WELS_MAX
-#define WELS_MAX(x, y)	((x) - (((x)-(y))&(((x)-(y))>>31)))
-#endif//WELS_MAX
-
-#ifndef WELS_MIN
-#define WELS_MIN(x, y)	((y) + (((x)-(y))&(((x)-(y))>>31)))
-#endif//WELS_MIN
-
-#endif
-
-#ifndef WELS_CEIL
-#define WELS_CEIL(x)	ceil(x)	// FIXME: low complexity instead of math library used
-#endif//WELS_CEIL
-
-#ifndef WELS_FLOOR
-#define WELS_FLOOR(x)	floor(x)	// FIXME: low complexity instead of math library used
-#endif//WELS_FLOOR
-
-#ifndef WELS_ROUND
-#define WELS_ROUND(x)	((int32_t)(0.5f+(x)))
-#endif//WELS_ROUND
-
-#define WELS_NON_ZERO_COUNT_AVERAGE(nC,nA,nB) {		\
-    nC = nA + nB + 1;                      \
-	nC >>= (uint8_t)( nA != -1 && nB != -1);        \
-	nC += (uint8_t)(nA == -1 && nB == -1);           \
-}
-
-static __inline int32_t CeilLog2 (int32_t i) {
-int32_t s = 0;
-i--;
-while (i > 0) {
-  s++;
-  i >>= 1;
-}
-return s;
-}
-/*
-the second path will degrades the performance
-*/
-#if 1
-static inline int32_t WelsMedian (int32_t iX,  int32_t iY, int32_t iZ) {
-int32_t iMin = iX, iMax = iX;
-
-if (iY < iMin)
-  iMin	= iY;
-else
-  iMax = iY;
-
-if (iZ < iMin)
-  iMin	= iZ;
-else if (iZ > iMax)
-  iMax	= iZ;
-
-return (iX + iY + iZ) - (iMin + iMax);
-}
-#else
-static inline int32_t WelsMedian (int32_t iX,  int32_t iY, int32_t iZ) {
-int32_t iTmp = (iX - iY) & ((iX - iY) >> 31);
-iX -= iTmp;
-iY += iTmp;
-iY -= (iY - iZ) & ((iY - iZ) >> 31);
-iY += (iX - iY) & ((iX - iY) >> 31);
-return iY;
-}
-
-#endif
-
-#ifndef NEG_NUM
-//#define NEG_NUM( num ) (-num)
-#define NEG_NUM(iX) (1+(~(iX)))
-#endif// NEG_NUM
-
-#ifndef WELS_CLIP1
-//#define WELS_CLIP1(x) (x & ~255) ? (-x >> 31) : x
-#define WELS_CLIP1(iX) (((iX) & ~255) ? (-(iX) >> 31) : (iX)) //iX not only a value but also can be an expression
-#endif//WELS_CLIP1
-
-
-#ifndef WELS_SIGN
-#define WELS_SIGN(iX) ((int32_t)(iX) >> 31)
-#endif //WELS_SIGN
-#ifndef WELS_ABS
-#define WELS_ABS(iX) ((WELS_SIGN(iX) ^ (int32_t)(iX)) - WELS_SIGN(iX))
-#endif //WELS_ABS
-
-// WELS_CLIP3
-#ifndef WELS_CLIP3
-#define WELS_CLIP3(iX, iY, iZ) ((iX) < (iY) ? (iY) : ((iX) > (iZ) ? (iZ) : (iX)))
-#endif //WELS_CLIP3
-
-/*
- * Description: to check variable validation and return the specified result
- *	iResult:	value to be return
- *	bCaseIf:	negative condition to be verified
- */
-#ifndef WELS_VERIFY_RETURN_IF
-#define WELS_VERIFY_RETURN_IF(iResult, bCaseIf) \
-	if ( bCaseIf ){ \
-		return iResult; \
-	}
-#endif//#if WELS_VERIFY_RETURN_IF
-
-/*
- *	Description: to check variable validation and return the specified result
- *		with correspoinding process advance.
- *	 result:	value to be return
- *	 case_if:	negative condition to be verified
- *	 proc:		process need perform
- */
-#ifndef WELS_VERIFY_RETURN_PROC_IF
-#define WELS_VERIFY_RETURN_PROC_IF(iResult, bCaseIf, fProc) \
-	if ( bCaseIf ){ \
-		fProc;	\
-		return iResult;	\
-	}
-#endif//#if WELS_VERIFY_RETURN_PROC_IF
-
-/*
- * Description:	to check variable validation and return
- *	case_if:	negtive condition to be verified
- *	return:		NONE
- */
-#ifndef WELS_VERIFY_IF
-#define WELS_VERIFY_IF(bCaseIf) \
-	if ( bCaseIf ){ \
-		return; \
-	}
-#endif//#if WELS_VERIFY_IF
-
-/*
- * Description:	to check variable validation and return with correspoinding process advance.
- *	case_if:	negtive condition to be verified
- *	proc:		process need preform
- *	return:		NONE
- */
-#ifndef WELS_VERIFY_PROC_IF
-#define WELS_VERIFY_PROC_IF(bCaseIf, fProc) \
-	if ( bCaseIf ){ \
-		fProc; \
-		return; \
-	}
-#endif//#if WELS_VERIFY_IF
-
-/*
- * Description: to safe free a ptr with free function pointer
- *  p:			pointer to be destroyed
- *	free_fn:	free function pointer used
- */
-#ifndef WELS_SAFE_FREE_P
-#define WELS_SAFE_FREE_P(pPtr, fFreeFunc) \
-	do{ \
-		if ( NULL != (pPtr) ){ \
-			fFreeFunc( (pPtr) ); \
-			(pPtr) = NULL; \
-		} \
-	}while( 0 );
-#endif//#if WELS_SAFE_FREE_P
-
-/*
- * Description: to safe free an array ptr with free function pointer
- *	arr:		pointer to an array, something like "**p";
- *	num:		number of elements in array
- *  free_fn:	free function pointer
- */
-#ifndef WELS_SAFE_FREE_ARR
-#define WELS_SAFE_FREE_ARR(pArray, iNum, fFreeFunc) \
-	do{ \
-		if ( NULL != (pArray) ){ \
-			int32_t iIdx = 0; \
-			while( iIdx < iNum ){ \
-				if ( NULL != (pArray)[iIdx] ){ \
-					fFreeFunc( (pArray)[iIdx] ); \
-					(pArray)[iIdx] = NULL; \
-				} \
-				++ iIdx; \
-			} \
-			fFreeFunc((pArray)); \
-			(pArray) = NULL; \
-		} \
-	}while( 0 );
-#endif//#if WELS_SAFE_FREE_ARR
-
-} // namespace WelsDec
-
-#endif//WELS_MACRO_UTILIZATIONS_H__
--- a/codec/decoder/core/inc/wels_const.h
+++ b/codec/decoder/core/inc/wels_const.h
@@ -92,7 +92,7 @@
 #define LAYER_NUM_EXCHANGEABLE	1
 
 #define MAX_NAL_UNIT_NUM_IN_AU	32	// predefined maximal number of NAL Units in an access unit
-#define MAX_ACCESS_UINT_CAPACITY	1048576	// Maximal AU capacity in bytes: (1<<20) = 1024 KB predefined
+#define MAX_ACCESS_UNIT_CAPACITY	1048576	// Maximal AU capacity in bytes: (1<<20) = 1024 KB predefined
 
 enum {
   BASE_MB = 0,
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -303,13 +303,13 @@
   if (MemInitNalList (&pCtx->pAccessUnitList, MAX_NAL_UNIT_NUM_IN_AU) != 0)
     return ERR_INFO_OUT_OF_MEMORY;
 
-  if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMalloc (MAX_ACCESS_UINT_CAPACITY,
+  if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMalloc (MAX_ACCESS_UNIT_CAPACITY,
                               "pCtx->sRawData->pHead"))) == NULL) {
     return ERR_INFO_OUT_OF_MEMORY;
   }
   pCtx->sRawData.pStartPos               =
     pCtx->sRawData.pCurPos                 = pCtx->sRawData.pHead;
-  pCtx->sRawData.pEnd                     = pCtx->sRawData.pHead + MAX_ACCESS_UINT_CAPACITY;
+  pCtx->sRawData.pEnd                     = pCtx->sRawData.pHead + MAX_ACCESS_UNIT_CAPACITY;
 
   pCtx->uiTargetDqId			= (uint8_t) - 1;
   pCtx->bEndOfStreamFlag	= false;
@@ -1968,4 +1968,4 @@
   return ERR_NONE;
 }
 
-} // namespace WelsDec
\ No newline at end of file
+} // namespace WelsDec
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -344,6 +344,13 @@
     const int kiSrcLen,
     void_t** ppDst,
     SBufferInfo* pDstInfo) {
+  if (kiSrcLen > MAX_ACCESS_UNIT_CAPACITY) {
+    m_pDecContext->iErrorCode |= dsOutOfMemory;
+    IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO,
+      "max AU size exceeded. Allowed size = %d, current size = %d",
+      MAX_ACCESS_UNIT_CAPACITY, kiSrcLen);
+    return dsOutOfMemory;
+  }
   if (kiSrcLen > 0 && kpSrc != NULL) {
 #ifdef OUTPUT_BIT_STREAM
     if (m_pFBS) {
--- a/codec/encoder/core/inc/macros.h
+++ /dev/null
@@ -1,401 +1,0 @@
-/*!
- * \copy
- *     Copyright (c)  2009-2013, Cisco Systems
- *     All rights reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *        * Redistributions of source code must retain the above copyright
- *          notice, this list of conditions and the following disclaimer.
- *
- *        * Redistributions in binary form must reproduce the above copyright
- *          notice, this list of conditions and the following disclaimer in
- *          the documentation and/or other materials provided with the
- *          distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *     POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * \file	macros.h
- *
- * \brief	MACRO based tool utilization
- *
- * \date	3/13/2009 Created
- *
- *************************************************************************************
- */
-#ifndef WELS_MACRO_UTILIZATIONS_H__
-#define WELS_MACRO_UTILIZATIONS_H__
-
-//#include <math.h>
-#include "typedefs.h"
-
-namespace WelsSVCEnc {
-#if defined(_MSC_VER)
-#if _MSC_VER <= 1200
-#define ALLOC_ALLIGN_MEM(name,size,type,alignment) \
-			type name##_storage[size+(alignment)-1]; \
-			type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
-
-#define ALLOC_ALLIGN_MEM_2(name,sizex,sizey,type,alignment) \
-			type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
-			type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
-#else //_MSC_VER <= 1200
-#define ALLOC_ALLIGN_MEM(name,size,type,alignment) \
-			__declspec(align(alignment)) type name[size]
-
-#define ALLOC_ALLIGN_MEM_2(name,sizex,sizey,type,alignment) \
-		__declspec(align(alignment)) type name[(sizex)*(sizey)]
-#endif//_MSC_VER <= 1200
-
-#elif defined(__GNUC__)
-
-#define ALLOC_ALLIGN_MEM(name,size,type,alignment) \
-		type name[size] __attribute__((aligned(alignment)))
-#define ALLOC_ALLIGN_MEM_2(name,sizex,sizey,type,alignment) \
-		type name[(sizex)*(sizey)] __attribute__((aligned(alignment)))
-
-#endif//_MSC_VER
-
-
-#if defined(_MSC_VER)
-
-#if(_MSC_VER < 1700)
-#define inline	__inline
-#endif
-
-#define __FASTCALL   __fastcall
-#define ALIGNED_DECLARE( type, var, n ) __declspec(align(n)) type var
-#define __align8(t,v) __declspec(align(8)) t v
-#define __align16(t,v) __declspec(align(16)) t v
-#elif defined(__GNUC__)
-#if !defined(MAC_POWERPC)
-#define __FASTCALL    __attribute__ ((fastcall))
-#else
-#define __FASTCALL	// mean NULL for mac ppc
-#endif//MAC_POWERPC
-#define ALIGNED_DECLARE( type, var, n ) type var __attribute__((aligned(n)))
-#define __align8(t,v) t v __attribute__ ((aligned (8)))
-#define __align16(t,v) t v __attribute__ ((aligned (16)))
-#endif//_MSC_VER
-
-#if defined(_MACH_PLATFORM) || defined(__GNUC__)
-#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
-	type name[(sizex)*(sizey)] __attribute__((aligned(alignment)))
-#else //_MSC_VER <= 1200
-#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
-__declspec(align(alignment)) type name[(sizex)*(sizey)]
-#endif//#if _MACH_PLATFORM
-
-#if defined(_MACH_PLATFORM) || defined(__GNUC__)
-#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
-	type name[size] __attribute__((aligned(alignment)))
-#else //_MSC_VER <= 1200
-#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
-	__declspec(align(alignment)) type name[(size)]
-#endif//#if _MACH_PLATFORM
-
-//#if !defined(SIZEOFRGB24)
-//#define SIZEOFRGB24(cx, cy)	(3 * (cx) * (cy))
-//#endif//SIZEOFRGB24
-
-//#if !defined(SIZEOFRGB32)
-//#define SIZEOFRGB32(cx, cy)	(4 * (cx) * (cy))
-//#endif//SIZEOFRGB32
-
-#ifndef	WELS_ALIGN
-#define WELS_ALIGN(x, n)	(((x)+(n)-1)&~((n)-1))
-#endif//WELS_ALIGN
-
-#ifndef WELS_MAX
-//#define WELS_MAX(x, y)	((x) > (y) ? (x) : (y))
-//#define WELS_MAX(x, y)	((x) - (((x)-(y))&(((x)-(y))>>31)))
-#define WELS_MAX(x, y)	((x) ^ (((x)^(y))& -((x)<(y))))		// WELS_MAX(x, y)
-#endif//WELS_MAX
-
-#ifndef WELS_MIN
-//#define WELS_MIN(x, y)	((x) < (y) ? (x) : (y))
-//#define WELS_MIN(x, y)	((y) + (((x)-(y))&(((x)-(y))>>31)))
-#define WELS_MIN(x, y)	((y) ^ (((x)^(y))& -((x)<(y))))		// WELS_MIN(x, y)
-#endif//WELS_MIN
-
-#ifndef WELS_ROUND
-#define WELS_ROUND(x)	((int32_t)((x)+0.5f+EPSN))
-#endif//WELS_ROUND
-
-static inline int32_t WELS_CEIL (float v) {
-const int32_t n = (int32_t)v;	// floor value
-return ((v > EPSN + n) ? (1 + n) : n);	// (int32_t)ceil(v);
-}
-
-static inline int32_t WELS_FLOOR (float v) {
-return (int32_t)v;
-}
-
-
-#define WELS_NON_ZERO_COUNT_AVERAGE(iC,iA,iB) {	\
-    iC = iA + iB + 1;                           \
-	iC >>= (int32_t)( iA != -1 && iB != -1);    \
-	iC += (iA == -1 && iB == -1);               \
-}
-
-/*
- * log base 2 of v and ceil/floor extension
- */
-
-static inline int32_t WELS_CEILLOG2 (uint32_t v) {
-int32_t r = 0;
---v;
-while (v > 0) {
-  ++r;
-  v >>= 1;
-}
-return r;
-}
-
-static inline int32_t WELS_FLOORLOG2 (uint32_t v) {
-int32_t r = 0;
-while (v > 1) {
-  ++r;
-  v >>= 1;
-}
-return r;
-}
-
-static inline int32_t WELS_LOG2 (uint32_t v) {
-int32_t r = 0;
-while (v >>= 1) {
-  ++r;
-}
-return r;
-
-}
-
-static inline BOOL_T WELS_POWER2_IF (uint32_t v) {
-return (v && ! (v & (v - 1)));
-}
-
-static inline int32_t WELS_MEDIAN (int32_t x,  int32_t y, int32_t z) {
-int32_t t = (x - y) & ((x - y) >> 31);
-x -= t;
-y += t;
-y -= (y - z) & ((y - z) >> 31);
-y += (x - y) & ((x - y) >> 31);
-return y;
-}
-
-#ifndef BUTTERFLY1x2
-#define BUTTERFLY1x2(b) (((b)<<8) | (b))
-#endif//BUTTERFLY1x2
-
-#ifndef BUTTERFLY2x4
-#define BUTTERFLY2x4(wd) (((uint32_t)(wd)<<16) |(wd))
-#endif//BUTTERFLY2x4
-
-#ifndef BUTTERFLY4x8
-#define BUTTERFLY4x8(dw) (((uint64_t)(dw)<<32) | (dw))
-#endif//BUTTERFLY4x8
-
-//when RS accumulation, should clip rs among range of [-255, 255]
-#ifndef CLIP_RS
-#define CLIP_RS( value ) ( WELS_MAX( WELS_MIN( value, 255 ), -255 ) )
-#endif //CLIP_RS
-
-//#ifndef NEG_NUM
-//#define NEG_NUM( num ) (1+(~(num)))
-//#endif// NEG_NUM
-
-#ifndef WELS_CLIP1
-#define WELS_CLIP1(x) (((x) & ~255) ? (-(x) >> 31) : (x))
-#endif//WELS_CLIP1
-
-#ifndef WELS_SIGN
-#define WELS_SIGN(a) ((int32_t)(a) >> 31)	// General: (a)>>(sizeof(int)*CHAR_BIT-1), CHAR_BIT= the number of bits per byte (normally 8)
-#endif //WELS_SIGN
-
-static inline int32_t WELS_ABS (int32_t a) {
-const int32_t sign = WELS_SIGN (a);
-return ((a + sign) ^ sign);
-}
-
-// wels_tostring
-//#ifndef wels_tostring
-//#define wels_tostring(s)	#s
-//#endif //wels_tostring
-
-// WELS_CLIP3
-#ifndef WELS_CLIP3
-#define WELS_CLIP3(x, y, z)		((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
-#endif //WELS_CLIP3
-
-#define CLIP3_QP_0_51(q)		WELS_CLIP3(q, 0, 51)	// ((q) < (0) ? (0) : ((q) > (51) ? (51) : (q)))
-
-// Bitwise routines
-// n: ulong
-// b: bit order
-static inline bool_t BITWISE_ENABLED (const uint32_t n, const uint8_t b) {
-const uint8_t bit = (b & 0x1f);	// maximal bit position 31 for uint32_t 4 bytes
-#if defined(WORDS_BIGENDIAN)
-/*
- * 31 .. 24, 23 .. 16, 15 .. 8, 7 .. 0
- * 7 .. 0, 15 .. 8, 23 .. 16, 31 .. 24
- */
-const uint8_t map = 24 + ((bit & 7) << 1) - bit;	// BIG_ENDIAN map
-return (bool_t) ((n & (1 << map)) >> map);	// BIG_ENDIAN
-#else
-return ((n & (1 << bit)) >> bit) ? true : false;	// LITTLE_ENDIAN
-#endif//WORDS_BIGENDIAN
-}
-
-#define   CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)
-
-//////////////////////////////////////////////////////////
-
-#ifdef    WORDS_BIGENDIAN
-
-static inline uint32_t ENDIAN_FIX (uint32_t x) {
-return x;
-}
-
-#else
-
-
-#if defined(_MSC_VER) && defined(_M_IX86)
-static inline uint32_t ENDIAN_FIX (uint32_t x) {
-__asm {
-  mov   eax,  x
-  bswap   eax
-  mov   x,    eax
-}
-return x;
-}
-#else  // GCC
-static inline uint32_t ENDIAN_FIX (uint32_t x) {
-#ifdef X86_ARCH
-__asm__ __volatile__ ("bswap %0":"+r" (x));
-#else
-x = ((x & 0xff000000) >> 24) | ((x & 0xff0000) >> 8) |
-    ((x & 0xff00) << 8) | ((x & 0xff) << 24);
-#endif
-return x;
-}
-
-
-#endif
-
-#endif
-
-// wels_swap16
-
-// wels_swap32
-
-// sad, satd, avg might being in other header
-
-/*
- * Description: to check variable validation and return the specified result
- *	result:		value to be return
- *	case_if:	negative condition to be verified
- */
-#ifndef WELS_VERIFY_RETURN_IF
-#define WELS_VERIFY_RETURN_IF(result, case_if) \
-	if ( case_if ){ \
-		return result; \
-	}
-#endif//#if WELS_VERIFY_RETURN_IF
-
-/*
- *	Description: to check variable validation and return the specified result
- *		with correspoinding process advance.
- *	 result:	value to be return
- *	 case_if:	negative condition to be verified
- *	 proc:		process need perform
- */
-#ifndef WELS_VERIFY_RETURN_PROC_IF
-#define WELS_VERIFY_RETURN_PROC_IF(result, case_if, proc) \
-	if ( case_if ){ \
-		proc;	\
-		return result;	\
-	}
-#endif//#if WELS_VERIFY_RETURN_PROC_IF
-
-/*
- * Description:	to check variable validation and return
- *	case_if:	negtive condition to be verified
- *	return:		NONE
- */
-#ifndef WELS_VERIFY_IF
-#define WELS_VERIFY_IF(case_if) \
-	if ( case_if ){ \
-		return; \
-	}
-#endif//#if WELS_VERIFY_IF
-
-/*
- * Description:	to check variable validation and return with correspoinding process advance.
- *	case_if:	negtive condition to be verified
- *	proc:		process need preform
- *	return:		NONE
- */
-#ifndef WELS_VERIFY_PROC_IF
-#define WELS_VERIFY_PROC_IF(case_if, proc) \
-	if ( case_if ){ \
-		proc; \
-		return; \
-	}
-#endif//#if WELS_VERIFY_IF
-
-/*
- * Description: to safe free a ptr with free function pointer
- *  p:			pointer to be destroyed
- *	free_fn:	free function pointer used
- */
-#ifndef WELS_SAFE_FREE_P
-#define WELS_SAFE_FREE_P(p, free_fn) \
-	do{ \
-		if ( NULL != (p) ){ \
-			free_fn( (p) ); \
-			(p) = NULL; \
-		} \
-	}while( 0 );
-#endif//#if WELS_SAFE_FREE_P
-
-/*
- * Description: to safe free an array ptr with free function pointer
- *	arr:		pointer to an array, something like "**p";
- *	num:		number of elements in array
- *  free_fn:	free function pointer
- */
-#ifndef WELS_SAFE_FREE_ARR
-#define WELS_SAFE_FREE_ARR(arr, num, free_fn) \
-	do{ \
-		if ( NULL != (arr) ){ \
-			int32_t iidx = 0; \
-			while( iidx < num ){ \
-				if ( NULL != (arr)[iidx] ){ \
-					free_fn( (arr)[iidx] ); \
-					(arr)[iidx] = NULL; \
-				} \
-				++ iidx; \
-			} \
-			free_fn((arr)); \
-			(arr) = NULL; \
-		} \
-	}while( 0 );
-#endif//#if WELS_SAFE_FREE_ARR
-
-}
-
-#endif//WELS_MACRO_UTILIZATIONS_H__