add Windows support for ADT-FSE alogrithm
This commit is contained in:
parent
0ca99ea9c9
commit
5a97cf9fc9
|
@ -17,6 +17,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int32_t BUILDIN_CLZ(uint32_t val);
|
||||||
|
#else
|
||||||
|
#define BUILDIN_CLZ(val) __builtin_clz(val)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dict = {
|
* dict = {
|
||||||
0: [0,0], 1:[1,0], 2:[2,0], 3:[3,0],
|
0: [0,0], 1:[1,0], 2:[2,0], 3:[3,0],
|
||||||
|
@ -53,10 +60,10 @@ MEM_STATIC int Int2code(int factor)
|
||||||
24, 24, 24, 24, 24, 24, 24, 24,
|
24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
24, 24, 24, 24, 24, 24, 24, 24 };
|
24, 24, 24, 24, 24, 24, 24, 24 };
|
||||||
if (factor >= 0)
|
if (factor >= 0)
|
||||||
return (factor > 63) ? 50 - __builtin_clz(factor) : Ft_Code[factor];
|
return (factor > 63) ? 50 - BUILDIN_CLZ(factor) : Ft_Code[factor];
|
||||||
else {
|
else {
|
||||||
factor = -factor;
|
factor = -factor;
|
||||||
return (factor > 63) ? 17 + __builtin_clz(factor) : 67 - Ft_Code[factor];
|
return (factor > 63) ? 17 + BUILDIN_CLZ(factor) : 67 - Ft_Code[factor];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,15 @@
|
||||||
#include "bitstream.h"
|
#include "bitstream.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int32_t BUILDIN_CLZ(uint32_t val) {
|
||||||
|
unsigned long r = 0;
|
||||||
|
_BitScanReverse(&r, val);
|
||||||
|
return (int)(31 - r);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform type array to FseCode & tranCodeBits
|
* @brief transform type array to FseCode & tranCodeBits
|
||||||
* [type] ---minus md---> [factor] ---transcode---> [tp_code] + [bitstream of diff]
|
* [type] ---minus md---> [factor] ---transcode---> [tp_code] + [bitstream of diff]
|
||||||
|
|
Loading…
Reference in New Issue