mirror of https://github.com/status-im/leopard.git
Selectable fields
This commit is contained in:
parent
5cba1989ec
commit
b51a7219bc
|
@ -46,6 +46,8 @@
|
|||
+ Look into using FFT_m instead of FFT_n for decoder
|
||||
*/
|
||||
|
||||
#include "leopard.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
@ -72,6 +74,10 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Platform/Architecture
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID) || defined(IOS)
|
||||
#define LEO_TARGET_MOBILE
|
||||
#endif // ANDROID
|
||||
|
@ -172,10 +178,6 @@ extern bool CpuHasSSSE3;
|
|||
//------------------------------------------------------------------------------
|
||||
// Portable Intrinsics
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
// Returns highest bit index 0..31 where the first non-zero bit is found
|
||||
// Precondition: x != 0
|
||||
LEO_FORCE_INLINE unsigned LastNonzeroBit32(unsigned x)
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
|
||||
#include "LeopardFF16.h"
|
||||
|
||||
#ifdef LEO_HAS_FF16
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// Define this to enable the optimized version of FWHT()
|
||||
|
@ -1050,3 +1053,5 @@ bool Initialize()
|
|||
|
||||
|
||||
}} // namespace leopard::ff16
|
||||
|
||||
#endif // LEO_HAS_FF16
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "LeopardCommon.h"
|
||||
|
||||
#ifdef LEO_HAS_FF16
|
||||
|
||||
/*
|
||||
16-bit Finite Field Math
|
||||
|
||||
|
@ -156,3 +158,5 @@ bool Initialize();
|
|||
|
||||
|
||||
}} // namespace leopard::ff16
|
||||
|
||||
#endif // LEO_HAS_FF16
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
*/
|
||||
|
||||
#include "LeopardFF8.h"
|
||||
|
||||
#ifdef LEO_HAS_FF8
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// Define this to enable the optimized version of FWHT()
|
||||
|
@ -934,3 +937,5 @@ bool Initialize()
|
|||
|
||||
|
||||
}} // namespace leopard::ff8
|
||||
|
||||
#endif // LEO_HAS_FF8
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "LeopardCommon.h"
|
||||
|
||||
#ifdef LEO_HAS_FF8
|
||||
|
||||
/*
|
||||
8-bit Finite Field Math
|
||||
|
||||
|
@ -156,3 +158,5 @@ bool Initialize();
|
|||
|
||||
|
||||
}} // namespace leopard::ff8
|
||||
|
||||
#endif // LEO_HAS_FF8
|
||||
|
|
27
leopard.cpp
27
leopard.cpp
|
@ -27,8 +27,13 @@
|
|||
*/
|
||||
|
||||
#include "leopard.h"
|
||||
#include "LeopardFF8.h"
|
||||
#include "LeopardFF16.h"
|
||||
|
||||
#ifdef LEO_HAS_FF8
|
||||
#include "LeopardFF8.h"
|
||||
#endif // LEO_HAS_FF8
|
||||
#ifdef LEO_HAS_FF16
|
||||
#include "LeopardFF16.h"
|
||||
#endif // LEO_HAS_FF16
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -43,11 +48,15 @@ LEO_EXPORT int leo_init_(int version)
|
|||
if (version != LEO_VERSION)
|
||||
return Leopard_InvalidInput;
|
||||
|
||||
#ifdef LEO_HAS_FF8
|
||||
if (!leopard::ff8::Initialize())
|
||||
return Leopard_Platform;
|
||||
#endif // LEO_HAS_FF8
|
||||
|
||||
#ifdef LEO_HAS_FF16
|
||||
if (!leopard::ff16::Initialize())
|
||||
return Leopard_Platform;
|
||||
#endif // LEO_HAS_FF16
|
||||
|
||||
m_Initialized = true;
|
||||
return Leopard_Success;
|
||||
|
@ -90,6 +99,7 @@ LEO_EXPORT LeopardResult leo_encode(
|
|||
|
||||
const bool mt = (flags & LeopardFlags_Multithreaded) != 0;
|
||||
|
||||
#ifdef LEO_HAS_FF8
|
||||
if (n <= leopard::ff8::kOrder)
|
||||
{
|
||||
leopard::ff8::Encode(
|
||||
|
@ -100,7 +110,10 @@ LEO_EXPORT LeopardResult leo_encode(
|
|||
original_data,
|
||||
work_data);
|
||||
}
|
||||
else if (n <= leopard::ff16::kOrder)
|
||||
else
|
||||
#endif // LEO_HAS_FF8
|
||||
#ifdef LEO_HAS_FF16
|
||||
if (n <= leopard::ff16::kOrder)
|
||||
{
|
||||
leopard::ff16::Encode(
|
||||
buffer_bytes,
|
||||
|
@ -111,6 +124,7 @@ LEO_EXPORT LeopardResult leo_encode(
|
|||
work_data);
|
||||
}
|
||||
else
|
||||
#endif // LEO_HAS_FF16
|
||||
return Leopard_TooMuchData;
|
||||
|
||||
return Leopard_Success;
|
||||
|
@ -156,6 +170,7 @@ LEO_EXPORT LeopardResult leo_decode(
|
|||
|
||||
const bool mt = (flags & LeopardFlags_Multithreaded) != 0;
|
||||
|
||||
#ifdef LEO_HAS_FF8
|
||||
if (n <= leopard::ff8::kOrder)
|
||||
{
|
||||
leopard::ff8::Decode(
|
||||
|
@ -168,7 +183,10 @@ LEO_EXPORT LeopardResult leo_decode(
|
|||
recovery_data,
|
||||
work_data);
|
||||
}
|
||||
else if (n <= leopard::ff16::kOrder)
|
||||
else
|
||||
#endif // LEO_HAS_FF8
|
||||
#ifdef LEO_HAS_FF16
|
||||
if (n <= leopard::ff16::kOrder)
|
||||
{
|
||||
leopard::ff16::Decode(
|
||||
buffer_bytes,
|
||||
|
@ -181,6 +199,7 @@ LEO_EXPORT LeopardResult leo_decode(
|
|||
work_data);
|
||||
}
|
||||
else
|
||||
#endif // LEO_HAS_FF16
|
||||
return Leopard_TooMuchData;
|
||||
|
||||
return Leopard_Success;
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
// Library version
|
||||
#define LEO_VERSION 1
|
||||
|
||||
// Enable 8-bit or 16-bit fields
|
||||
#define LEO_HAS_FF8
|
||||
//#define LEO_HAS_FF16
|
||||
|
||||
// Tweak if the functions are exported or statically linked
|
||||
//#define LEO_DLL /* Defined when building/linking as DLL */
|
||||
//#define LEO_BUILDING /* Defined by the library makefile */
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="..\leopard.h" />
|
||||
<ClInclude Include="..\LeopardCommon.h" />
|
||||
<ClInclude Include="..\LeopardFF8.h" />
|
||||
<ClInclude Include="..\LeopardFF16.h" />
|
||||
<ClInclude Include="..\LeopardFF8.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\leopard.cpp" />
|
||||
<ClCompile Include="..\LeopardCommon.cpp" />
|
||||
<ClCompile Include="..\LeopardFF8.cpp" />
|
||||
<ClCompile Include="..\LeopardFF16.cpp" />
|
||||
<ClCompile Include="..\LeopardFF8.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{32176592-2F30-4BD5-B645-EB11C8D3453E}</ProjectGuid>
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
<ClInclude Include="..\LeopardCommon.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\LeopardFF16.h">
|
||||
<ClInclude Include="..\LeopardFF8.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\LeopardFF8.h">
|
||||
<ClInclude Include="..\LeopardFF16.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
@ -35,10 +35,10 @@
|
|||
<ClCompile Include="..\LeopardCommon.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\LeopardFF16.cpp">
|
||||
<ClCompile Include="..\LeopardFF8.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\LeopardFF8.cpp">
|
||||
<ClCompile Include="..\LeopardFF16.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* 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.
|
||||
* Neither the name of Leopard nor the names of its contributors may be
|
||||
* Neither the name of Leopard-RS nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* 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.
|
||||
* Neither the name of LHC-RS nor the names of its contributors may be
|
||||
* Neither the name of Leopard-RS nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
|
@ -67,8 +67,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Field
|
||||
|
||||
|
|
Loading…
Reference in New Issue