Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / third_party / om-file-format-sys / c / include / vint.h

vint.h403 lines · 27.2 KiBRaw
1/**
2 Copyright (C) powturbo 2013-2019
3 GPL v2 License
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 - homepage : https://sites.google.com/site/powturbo/
20 - github : https://github.com/powturbo
21 - twitter : https://twitter.com/powturbo
22 - email : powturbo [_AT_] gmail [_DOT_] com
23**/
24// "Integer Compression" variable byte include header (scalar TurboVByte+ SIMD TurboByte)
25#ifndef _VINT_H_
26#define _VINT_H_
27
28#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34 #ifdef VINT_IN
35#include "conf.h"
36//----------------------------------- Variable byte: single value macros (low level) -----------------------------------------------
37//------------- 32 bits -------------
38extern unsigned char _vtab32_[];
39#define _vbxvlen32(_x_) _vtab32_[(unsigned char)(_x_)>>4] // (clz32((_x_) ^ 0xff) - 23) //
40#define _vbxlen32(_x_) ((bsr32(_x_|1)+6)/7)
41
42#define _vbxput32(_op_, _x_, _act_) {\
43 if(likely((_x_) < (1<< 7))) { *_op_++ = _x_; _act_;}\
44 else if(likely((_x_) < (1<<14))) { ctou16(_op_) = bswap16((_x_) | 0x8000u); _op_ += 2; _act_;}\
45 else if(likely((_x_) < (1<<21))) { *_op_++ = _x_ >> 16 | 0xc0u; ctou16(_op_) = _x_; _op_ += 2; _act_;}\
46 else if(likely((_x_) < (1<<28))) { ctou32(_op_) = bswap32((_x_) | 0xe0000000u); _op_ += 4; _act_;}\
47 else { *_op_++ = (unsigned long long)(_x_) >> 32 | 0xf0u; ctou32(_op_) = _x_; _op_ += 4; _act_;}\
48}
49
50#define _vbxget32(_ip_, _x_, _act_) do { _x_ = (unsigned)(*_ip_++);\
51 if(!(_x_ & 0x80u)) { _act_;}\
52 else if(!(_x_ & 0x40u)) { _x_ = bswap16(ctou16(_ip_ - 1) & 0xff3fu); _ip_++; _act_;}\
53 else if(!(_x_ & 0x20u)) { _x_ = (_x_ & 0x1f)<<16 | ctou16(_ip_); _ip_ += 2; _act_;}\
54 else if(!(_x_ & 0x10u)) { _x_ = bswap32(ctou32(_ip_-1) & 0xffffff0fu); _ip_ += 3; _act_;}\
55 else { _x_ = (unsigned long long)((_x_) & 0x07)<<32 | ctou32(_ip_); _ip_ += 4; _act_;}\
56} while(0)
57
58//------------- 64 bits -----------
59#define _vbxlen64(_x_) ((bsr64(_x_)+6)/7)
60#define _vbxvlen64(_x_) ((_x_)==0xff?9:clz32((_x_) ^ 0xff) - 23)
61
62#define _vbxput64(_op_, _x_, _act_) {\
63 if(likely(_x_ < (1<< 7))) { *_op_++ = _x_; _act_;}\
64 else if(likely(_x_ < (1<<14))) { ctou16(_op_) = bswap16(_x_| 0x8000); _op_ += 2; _act_;}\
65 else if(likely(_x_ < (1<<21))) { *_op_++ = _x_ >> 16 | 0xc0; ctou16(_op_) = _x_; _op_ += 2; _act_;}\
66 else if(likely(_x_ < (1<<28))) { ctou32(_op_) = bswap32(_x_| 0xe0000000); _op_ += 4; _act_;}\
67 else if( _x_ < 1ull<<35) { *_op_++ = _x_ >> 32 | 0xf0; ctou32(_op_) = _x_; _op_ += 4; _act_;}\
68 else if( _x_ < 1ull<<42) { ctou16(_op_) = bswap16(_x_ >> 32 | 0xf800); _op_ += 2; ctou32(_op_) = _x_; _op_ += 4; _act_;}\
69 else if( _x_ < 1ull<<49) { *_op_++ = _x_ >> 48 | 0xfc; ctou16(_op_) = _x_ >> 32; _op_ += 2; ctou32(_op_) = _x_; _op_ += 4; _act_;}\
70 else if( _x_ < 1ull<<56) { ctou64(_op_) = bswap64(_x_ | 0xfe00000000000000ull); _op_ += 8; _act_;}\
71 else { *_op_++ = 0xff; ctou64(_op_) = _x_; _op_ += 8; _act_;}\
72}
73
74#define _vbxget64(_ip_, _x_, _act_) do { _x_ = *_ip_++;\
75 if(!(_x_ & 0x80)) { _act_;}\
76 else if(!(_x_ & 0x40)) { _x_ = bswap16(ctou16(_ip_++-1) & 0xff3f); _act_;}\
77 else if(!(_x_ & 0x20)) { _x_ = (_x_ & 0x1f)<<16 | ctou16(_ip_); _ip_ += 2; _act_;}\
78 else if(!(_x_ & 0x10)) { _x_ = bswap32(ctou32(_ip_-1) & 0xffffff0f); _ip_ += 3; _act_;}\
79 else if(!(_x_ & 0x08)) { _x_ = (_x_ & 0x07)<<32 | ctou32(_ip_); _ip_ += 4; _act_;}\
80 else if(!(_x_ & 0x04)) { _x_ = (unsigned long long)(bswap16(ctou16(_ip_-1)) & 0x7ff) << 32 | ctou32(_ip_+1); _ip_ += 5; _act_;}\
81 else if(!(_x_ & 0x02)) { _x_ = (_x_ & 0x03)<<48 | (unsigned long long)ctou16(_ip_) << 32 | ctou32(_ip_+2); _ip_ += 6; _act_;}\
82 else if(!(_x_ & 0x01)) { _x_ = bswap64(ctou64(_ip_-1)) & 0x01ffffffffffffffull; _ip_ += 7; _act_;}\
83 else { _x_ = ctou64(_ip_); _ip_ += 8; _act_;}\
84} while(0)
85
86#define vbxput64(_op_, _x_) { unsigned long long _x = _x_; _vbxput64(_op_, _x, ;); }
87#define vbxput32(_op_, _x_) { register unsigned _x = _x_; _vbxput32(_op_, _x, ;); }
88#define vbxput16(_op_, _x_) vbxput32(_op_, _x_)
89#define vbxput8( _op_, _x_) (*_op_++ = _x_)
90
91#define vbxget64(_ip_, _x_) _vbxget64(_ip_, _x_, ;)
92#define vbxget32(_ip_, _x_) _vbxget32(_ip_, _x_, ;)
93#define vbxget16(_ip_, _x_) vbxget32(_ip_,_x_)
94#define vbxget8(_ip_, _x_) (_x_ = *_ip_++)
95//---------------------------------------------------------------------------
96#define VB_SIZE 64
97#define VB_MAX 254
98#define VB_B2 6
99#define VB_B3 3
100#define VB_BA3 (VB_MAX - (VB_SIZE/8 - 3))
101#define VB_BA2 (VB_BA3 - (1<<VB_B3))
102
103#define VB_OFS1 (VB_BA2 - (1<<VB_B2))
104#define VB_OFS2 (VB_OFS1 + (1 << (8+VB_B2)))
105#define VB_OFS3 (VB_OFS2 + (1 << (16+VB_B3)))
106
107#define _vblen32(_x_) ((_x_) < VB_OFS1?1:((_x_) < VB_OFS2?2:((_x_) < VB_OFS3)?3:(bsr32(_x_)+7)/8+1))
108#define _vbvlen32(_x_) ((_x_) < VB_OFS1?1:((_x_) < VB_BA2?2:((_x_) < VB_BA3)?3:(_x_-VB_BA3)))
109
110#define _vbput32(_op_, _x_, _act_) {\
111 if(likely((_x_) < VB_OFS1)){ *_op_++ = (_x_); _act_;}\
112 else if ((_x_) < VB_OFS2) { ctou16(_op_) = bswap16((VB_OFS1<<8)+((_x_)-VB_OFS1)); _op_ += 2; /*(_x_) -= VB_OFS1; *_op_++ = VB_OFS1 + ((_x_) >> 8); *_op_++ = (_x_);*/ _act_; }\
113 else if ((_x_) < VB_OFS3) { *_op_++ = VB_BA2 + (((_x_) -= VB_OFS2) >> 16); ctou16(_op_) = (_x_); _op_ += 2; _act_;}\
114 else { unsigned _b = (bsr32((_x_))+7)/8; *_op_++ = VB_BA3 + (_b - 3); ctou32(_op_) = (_x_); _op_ += _b; _act_;}\
115}
116
117#define _vbget32(_ip_, _x_, _act_) do { _x_ = *_ip_++;\
118 if(likely(_x_ < VB_OFS1)) { _act_ ;}\
119 else if(likely(_x_ < VB_BA2)) { _x_ = /*bswap16(ctou16(_ip_-1))*/ ((_x_<<8) + (*_ip_)) + (VB_OFS1 - (VB_OFS1 << 8)); _ip_++; _act_;} \
120 else if(likely(_x_ < VB_BA3)) { _x_ = ctou16(_ip_) + ((_x_ - VB_BA2 ) << 16) + VB_OFS2; _ip_ += 2; _act_;}\
121 else { unsigned _b = _x_-VB_BA3; _x_ = ctou32(_ip_) & ((1u << 8 * _b << 24) - 1); _ip_ += 3 + _b; _act_;}\
122} while(0)
123
124#define _vblen64(_x_) _vblen32(_x_)
125#define _vbvlen64(_x_) _vbvlen32(_x_)
126#define _vbput64(_op_, _x_, _act_) {\
127 if(likely((_x_) < VB_OFS1)){ *_op_++ = (_x_); _act_;}\
128 else if ((_x_) < VB_OFS2) { ctou16(_op_) = bswap16((VB_OFS1<<8)+((_x_)-VB_OFS1)); _op_ += 2; /*(_x_) -= VB_OFS1; *_op_++ = VB_OFS1 + ((_x_) >> 8); *_op_++ = (_x_);*/ _act_; }\
129 else if ((_x_) < VB_OFS3) { *_op_++ = VB_BA2 + (((_x_) -= VB_OFS2) >> 16); ctou16(_op_) = (_x_); _op_ += 2; _act_;}\
130 else { unsigned _b = (bsr64((_x_))+7)/8; *_op_++ = VB_BA3 + (_b - 3); ctou64(_op_) = (_x_); _op_ += _b; _act_;}\
131}
132
133#define _vbget64(_ip_, _x_, _act_) do { _x_ = *_ip_++;\
134 if(likely(_x_ < VB_OFS1)) { _act_ ;}\
135 else if(likely(_x_ < VB_BA2)) { _x_ = /*bswap16(ctou16(_ip_-1))*/ ((_x_<<8) + (*_ip_)) + (VB_OFS1 - (VB_OFS1 << 8)); _ip_++; _act_;} \
136 else if(likely(_x_ < VB_BA3)) { _x_ = ctou16(_ip_) + ((_x_ - VB_BA2 ) << 16) + VB_OFS2; _ip_ += 2; _act_;}\
137 else { unsigned _b = _x_-VB_BA3; _x_ = ctou64(_ip_) & ((1ull << 8 * _b << 24) - 1); _ip_ += 3 + _b; _act_;}\
138} while(0)
139
140#ifdef _WIN32
141//#define fgetc_unlocked(_f_) _fgetc_nolock(_f_)
142#define fputc_unlocked(_c_, _f_) fputc(_c_,_f_)
143#define fgetc_unlocked(_f_) fgetc(_f_)
144#else
145#define fputc_unlocked(_c_, _f_) fputc(_c_,_f_) //_IO_putc_unlocked(_c_,_f_)
146#define fgetc_unlocked(_f_) fgetc(_f_) //_IO_getc_unlocked(_f_)
147#endif
148
149#define leb128put(_op_, _x_) { uint64_t _x = _x_; while(_x > 0x7f) { *_op_++ = _x & 0x7f; _x >>= 7; } *_op_++ = _x | 0x80; }
150#define vbfput32(_f_, _x_) ({ uint64_t _x = _x_; while(_x > 0x7f) { fputc_unlocked(_x & 0x7f, _f_); _x >>= 7; } fputc_unlocked(_x | 0x80, _f_); })
151
152#define _leb128get(_ip_, _x_, _act_) { unsigned _sft=0; for(_x_=0;;_sft += 7) { unsigned _c = *_ip_++; _x_ += (_c & 0x7f) << _sft; if(_c >= 0x80) { _act_; break; } } }
153#define leb128get(_ip_, _x_) vbgetax(_ip_, _x_, ;)
154#define vbfget32(_f_ ) ({ unsigned _sft=0,_x=0; for(;;_sft += 7) { unsigned _c = fgetc_unlocked(_f_); if(_c != EOF) { _x += (_c & 0x7f) << _sft; if(_c & 0x80) break; } else { _x = EOF; break; } } _x; })
155
156//------------- 16 bits -----------
157#define _vblen16(_x_) _vblen32(_x_)
158#define _vbvlen16(_x_) _vbvlen32(_x_)
159
160#define _vbput16(_op_, _x_, _act_) _vbput32(_op_, _x_, _act_)
161#define _vbget16(_ip_, _x_, _act_) _vbget32(_ip_, _x_, _act_)
162
163#define _vblen8(_x_) 1
164#define _vbvlen8(_x_) 1
165#define _vbput8(_op_, _x_, _act_) { *_op_++ = _x_; _act_; }
166#define _vbget8(_ip_, _x_, _act_) { _x_ = *_ip_++; _act_; }
167//----------------------------------- Variable byte: single value functions -----------------------------------------------
168// ---- Variable byte length after compression
169static inline unsigned vblen16(unsigned short x) { return _vblen16(x); }
170static inline unsigned vblen32(unsigned x) { return _vblen32(x); }
171static inline unsigned vblen64(uint64_t x) { return _vblen64(x); }
172
173// ---- Length of compressed value. Input in is the first char of the compressed buffer start (Ex. vbvlen32(in[0]) )
174static inline unsigned vbvlen16(unsigned x) { return _vbvlen32(x); }
175static inline unsigned vbvlen32(unsigned x) { return _vbvlen32(x); }
176static inline unsigned vbvlen64(unsigned x) { return _vbvlen64(x); }
177
178//----- encode/decode 16/32/64 single value and advance output/input pointer
179#define vbput64(_op_, _x_) { unsigned long long _x = _x_; _vbput64(_op_, _x, ;); }
180#define vbput32(_op_, _x_) { register unsigned _x = _x_; _vbput32(_op_, _x, ;); }
181#define vbput16(_op_, _x_) vbput32(_op_, _x_)
182#define vbput8(_op_, _x_) (*_op_++ = _x_)
183
184#define vbget64(_ip_, _x_) _vbget64(_ip_, _x_, ;)
185#define vbget32(_ip_, _x_) _vbget32(_ip_, _x_, ;)
186#define vbget16(_ip_, _x_) vbget32(_ip_,_x_)
187#define vbget8(_ip_, _x_) (_x_ = *_ip_++)
188 #endif
189//----------------------------- TurboVByte 'vb':Variable byte + SIMD TurboByte 'v8': array functions ----------------------------------------
190// Encoding/DEcoding: Return value = end of compressed output/input buffer out/in
191
192//----------------------- Encoding/Decoding unsorted array with n integer values --------------------------
193unsigned char *vbenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out); //TurboVByte
194unsigned char *vbenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out);
195unsigned char *vbenc64( uint64_t *__restrict in, unsigned n, unsigned char *__restrict out);
196
197//-- Decode
198unsigned char *vbdec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out);
199unsigned char *vbdec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out);
200unsigned char *vbdec64( unsigned char *__restrict in, unsigned n, uint64_t *__restrict out);
201
202//-- Get value stored at index idx (idx:0...n-1)
203unsigned short vbgetx16( unsigned char *__restrict in, unsigned idx);
204unsigned vbgetx32( unsigned char *__restrict in, unsigned idx);
205uint64_t vbgetx64( unsigned char *__restrict in, unsigned idx);
206
207//-- Search and return index of next value equal to key or n when no key value found
208// ex. unsigned idx;unsigned char *ip; for(idx=0,ip=in;;) { if((idx = vgeteq32(&ip, idx, 4321))>=n) break; printf("found at %u ", idx); }
209unsigned vbgeteq16( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned short key);
210unsigned vbgeteq32( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned key);
211unsigned vbgeteq64( unsigned char **__restrict in, unsigned n, unsigned idx, uint64_t key);
212
213//---------------------- Delta encoding/decoding sorted array ---------------------------------------------
214//-- Increasing integer array. out[i] = out[i-1] + in[i]
215unsigned char *vbdenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
216unsigned char *vbdenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
217unsigned char *vbdenc64( uint64_t *__restrict in, unsigned n, unsigned char *__restrict out, uint64_t start);
218
219unsigned char *vbddec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
220unsigned char *vbddec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
221unsigned char *vbddec64( unsigned char *__restrict in, unsigned n, uint64_t *__restrict out, uint64_t start);
222
223//-- Get value stored at index idx (idx:0...n-1)
224unsigned short vbdgetx16( unsigned char *__restrict in, unsigned idx, unsigned short start);
225unsigned vbdgetx32( unsigned char *__restrict in, unsigned idx, unsigned start);
226uint64_t vbdgetx64( unsigned char *__restrict in, unsigned idx, uint64_t start);
227
228//-- Search and return index of next value equal to key or n when no key value found
229// ex. unsigned idx;unsigned char *ip; for(idx=0,ip=in;;) { if((idx = vgeteq32(&ip, idx, 4321))>=n) break; printf("found at %u ", idx); }
230unsigned vbdgetgeq16( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned short *key, unsigned short start);
231unsigned vbdgetgeq32( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned *key, unsigned start);
232unsigned vbdgetgeq64( unsigned char **__restrict in, unsigned n, unsigned idx, uint64_t *key, uint64_t start);
233
234//-- Strictly increasing (never remaining constant or decreasing) integer array. out[i] = out[i-1] + in[i] + 1
235unsigned char *vbd1enc16(unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
236unsigned char *vbd1enc32(unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
237unsigned char *vbd1enc64(uint64_t *__restrict in, unsigned n, unsigned char *__restrict out, uint64_t start);
238
239unsigned char *vbd1dec16(unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
240unsigned char *vbd1dec32(unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
241unsigned char *vbd1dec64(unsigned char *__restrict in, unsigned n, uint64_t *__restrict out, uint64_t start);
242
243
244//-- Get value stored at index idx (idx:0...n-1)
245unsigned short vbd1getx16( unsigned char *__restrict in, unsigned idx, unsigned short start);
246unsigned vbd1getx32( unsigned char *__restrict in, unsigned idx, unsigned start);
247uint64_t vbd1getx64( unsigned char *__restrict in, unsigned idx, uint64_t start);
248
249//-- Search and return index of next value equal to key or n when no key value found
250// ex. unsigned idx;unsigned char *ip; for(idx=0,ip=in;;) { if((idx = vgeteq32(&ip, idx, 4321))>=n) break; printf("found at %u ", idx); }
251unsigned vbd1getgeq16( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned short *key, unsigned short start);
252unsigned vbd1getgeq32( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned *key, unsigned start);
253unsigned vbd1getgeq64( unsigned char **__restrict in, unsigned n, unsigned idx, uint64_t *key, uint64_t start);
254
255//---------------------- Zigzag encoding/decoding for unsorted integer lists.
256unsigned char *vbzenc8( unsigned char *__restrict in, unsigned n, unsigned char *__restrict out, unsigned char start);
257unsigned char *vbzenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
258unsigned char *vbzenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
259unsigned char *vbzenc64( uint64_t *__restrict in, unsigned n, unsigned char *__restrict out, uint64_t start);
260
261unsigned char *vbzdec8( unsigned char *__restrict in, unsigned n, unsigned char *__restrict out, unsigned char start);
262unsigned char *vbzdec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
263unsigned char *vbzdec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
264unsigned char *vbzdec64( unsigned char *__restrict in, unsigned n, uint64_t *__restrict out, uint64_t start);
265
266//---------------------- XOR encoding/decoding for unsorted integer lists.
267unsigned char *vbxenc8( unsigned char *__restrict in, unsigned n, unsigned char *__restrict out, unsigned char start);
268unsigned char *vbxenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
269unsigned char *vbxenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
270unsigned char *vbxenc64( uint64_t *__restrict in, unsigned n, unsigned char *__restrict out, uint64_t start);
271
272unsigned char *vbxdec8( unsigned char *__restrict in, unsigned n, unsigned char *__restrict out, unsigned char start);
273unsigned char *vbxdec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
274unsigned char *vbxdec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
275unsigned char *vbxdec64( unsigned char *__restrict in, unsigned n, uint64_t *__restrict out, uint64_t start);
276
277//---------------------- Delta of delta encoding/decoding for unsorted integer lists.
278unsigned char *vbddenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
279unsigned char *vbddenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
280unsigned char *vbddenc64( uint64_t *__restrict in, unsigned n, unsigned char *__restrict out, uint64_t start);
281
282unsigned char *vbdddec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
283unsigned char *vbdddec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
284unsigned char *vbdddec64( unsigned char *__restrict in, unsigned n, uint64_t *__restrict out, uint64_t start);
285
286//-- Get value stored at index idx (idx:0...n-1)
287unsigned short vbzgetx16( unsigned char *__restrict in, unsigned idx, unsigned short start);
288unsigned vbzgetx32( unsigned char *__restrict in, unsigned idx, unsigned start);
289uint64_t vbzgetx64( unsigned char *__restrict in, unsigned idx, uint64_t start);
290
291//-- Search and return index of next value equal to key or n when no key value found
292// ex. unsigned idx;unsigned char *ip; for(idx=0,ip=in;;) { if((idx = vgeteq32(&ip, idx, 4321))>=n) break; printf("found at %u ", idx); }
293/*unsigned vbzgeteq15( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned short key, unsigned start);
294unsigned vbzgeteq16( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned short key, unsigned start);
295unsigned vbzgeteq32( unsigned char **__restrict in, unsigned n, unsigned idx, unsigned key, unsigned start);
296unsigned vbzgeteq64( unsigned char **__restrict in, unsigned n, unsigned idx, uint64_t key, unsigned start);*/
297
298//-------------------------- TurboByte (SIMD Group varint) --------------------------------------------------------------
299unsigned char *v8enc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out); //TurboByte
300unsigned char *v8enc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out);
301
302unsigned char *v8dec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out);
303unsigned char *v8dec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out);
304
305//------ delta ---------
306unsigned char *v8denc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
307unsigned char *v8denc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
308
309unsigned char *v8ddec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
310unsigned char *v8ddec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
311
312//------ delta 1 -------
313unsigned char *v8d1enc16(unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
314unsigned char *v8d1enc32(unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
315
316unsigned char *v8d1dec16(unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
317unsigned char *v8d1dec32(unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
318
319//------- zigzag -------
320unsigned char *v8zenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
321unsigned char *v8zenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
322
323unsigned char *v8zdec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
324unsigned char *v8zdec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
325
326//------- xor ----------
327unsigned char *v8xenc16( unsigned short *__restrict in, unsigned n, unsigned char *__restrict out, unsigned short start);
328unsigned char *v8xenc32( unsigned *__restrict in, unsigned n, unsigned char *__restrict out, unsigned start);
329
330unsigned char *v8xdec16( unsigned char *__restrict in, unsigned n, unsigned short *__restrict out, unsigned short start);
331unsigned char *v8xdec32( unsigned char *__restrict in, unsigned n, unsigned *__restrict out, unsigned start);
332//-------------------------- TurboByte Hybrid (SIMD Group varint) + Bitpacking -------------------------------------------
333size_t v8nenc16( uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
334size_t v8nenc32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
335
336size_t v8ndenc16( uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
337size_t v8ndenc32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
338
339size_t v8nd1enc16(uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
340size_t v8nd1enc32(uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
341
342size_t v8nzenc16( uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
343size_t v8nzenc32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
344
345size_t v8ndec16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
346size_t v8ndec32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
347
348size_t v8nddec16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
349size_t v8nddec32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
350
351size_t v8nd1dec16(unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
352size_t v8nd1dec32(unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
353
354size_t v8nzdec16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
355size_t v8nzdec32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
356
357size_t v8nxdec16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
358size_t v8nxdec32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
359//-------------
360size_t v8nenc128v16( uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
361size_t v8nenc128v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
362
363size_t v8ndenc128v16( uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
364size_t v8ndenc128v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
365
366size_t v8nd1enc128v16(uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
367size_t v8nd1enc128v32(uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
368
369size_t v8nzenc128v16( uint16_t *__restrict in, size_t n, unsigned char *__restrict out);
370size_t v8nzenc128v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
371
372size_t v8ndec128v16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
373size_t v8ndec128v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
374
375size_t v8nddec128v16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
376size_t v8nddec128v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
377
378size_t v8nd1dec128v16(unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
379size_t v8nd1dec128v32(unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
380
381size_t v8nzdec128v16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
382size_t v8nzdec128v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
383
384size_t v8nxdec128v16( unsigned char *__restrict in, size_t n, uint16_t *__restrict out);
385size_t v8nxdec128v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
386//-------------
387size_t v8nenc256v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
388size_t v8ndenc256v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
389size_t v8nd1enc256v32(uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
390size_t v8nzenc256v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
391size_t v8nxenc256v32( uint32_t *__restrict in, size_t n, unsigned char *__restrict out);
392
393size_t v8ndec256v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
394size_t v8nddec256v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
395size_t v8nd1dec256v32(unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
396size_t v8nzdec256v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
397size_t v8nxdec256v32( unsigned char *__restrict in, size_t n, uint32_t *__restrict out);
398
399#ifdef __cplusplus
400}
401#endif
402
403#endif