This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstdafx.h
176 lines (135 loc) · 5 KB
/
stdafx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// stdafx.h : includefile for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#include <byteswap.h>
#include <cstdint>
#include <dlfcn.h>
#define __forceinline __attribute__((always_inline)) inline
#define COPY_64(d, s) {*(uint64_t*)(d) = *(uint64_t*)(s); }
#define COPY_64_BYTES(d, s) { \
_mm_storeu_si128((__m128i*)d + 0, _mm_loadu_si128((__m128i*)s + 0)); \
_mm_storeu_si128((__m128i*)d + 1, _mm_loadu_si128((__m128i*)s + 1)); \
_mm_storeu_si128((__m128i*)d + 2, _mm_loadu_si128((__m128i*)s + 2)); \
_mm_storeu_si128((__m128i*)d + 3, _mm_loadu_si128((__m128i*)s + 3)); \
}
#define COPY_64_ADD(d, s, t) _mm_storel_epi64((__m128i *)(d), _mm_add_epi8(_mm_loadl_epi64((__m128i *)(s)), _mm_loadl_epi64((__m128i *)(t))))
// include file for x86 SSE2 types
// compile with -msse2 (instructions available)
#ifdef __SSE2__
#include <emmintrin.h>
#else
#warning SSE2 support is not available.
#endif
//typedef int OodLZ_CompressFunc(int codec, uint8_t *src_buf, size_t src_len,
// uint8_t *dst_buf, int level, void *opts,
// size_t offs, size_t unused, void *scratch,
// size_t scratch_size);
//typedef int OodLZ_DecompressFunc(uint8_t *src_buf, int src_len, uint8_t *dst,
// size_t dst_size, int fuzz, int crc, int verbose,
// uint8_t *dst_base, size_t e, void *cb, void *cb_ctx,
// void *scratch, size_t scratch_size, int threadPhase);
typedef size_t (*OodleLZ_CompressFunc)(int codec, uint8_t *src_buf, size_t src_len,
uint8_t *dst_buf, int level, void *opts,
size_t offs, size_t unused, void *scratch,
size_t scratch_size
);
typedef size_t (*OodleLZ_DecompressFunc)(uint8_t* srcBuf, size_t srcLen,
uint8_t* dstBuf, size_t dstLen,
int64_t unk1, int64_t unk2, int64_t unk3,
int64_t unk4, int64_t unk5, int64_t unk6,
int64_t unk7, int64_t unk8, int64_t unk9,
int64_t unk10
);
// Linux typedefs
typedef __uint8_t byte;
typedef __uint8_t uint8;
typedef __uint32_t uint32;
typedef __uint64_t uint64;
typedef __int64_t int64;
typedef __int32_t int32;
typedef __uint16_t uint16;
typedef __int16_t int16;
// LARGE_INTEGER union which mimics MS' LARGE_INTEGER union
typedef uint8_t BYTE;
typedef uint32_t DWORD;
typedef int32_t LONG;
typedef int64_t LONGLONG;
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
};
struct {
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER;
struct HuffRevLut {
uint8 bits2len[2048];
uint8 bits2sym[2048];
};
typedef struct HuffReader {
// Array to hold the output of the huffman read array operation
byte *output;
byte *output_end;
// We decode three parallel streams, two forwards, |src| and |src_mid|
// while |src_end| is decoded backwards.
const byte *src;
const byte *src_mid;
const byte *src_end;
const byte *src_mid_org;
int src_bitpos;
int src_mid_bitpos;
int src_end_bitpos;
uint32_t src_bits;
uint32_t src_mid_bits;
uint32_t src_end_bits;
} HuffReader;
typedef struct BitReader {
// |p| holds the current byte and |p_end| the end of the buffer.
const byte *p;
const byte *p_end;
// Bits accumulated so far
uint32_t bits;
// Next byte will end up in the |bitpos| position in |bits|.
int bitpos;
} BitReader;
struct BitReader2 {
const uint8_t *p;
const uint8_t *p_end;
uint32_t bitpos;
};
// Header in front of each 256k block
typedef struct KrakenHeader {
// Type of decoder used, 6 means kraken
int decoder_type;
// Whether to restart the decoder
bool restart_decoder;
// Whether this block is uncompressed
bool uncompressed;
// Whether this block uses checksums.
bool use_checksums;
} KrakenHeader;
// Additional header in front of each 256k block ("quantum").
typedef struct KrakenQuantumHeader {
// The compressed size of this quantum. If this value is 0 it means
// the quantum is a special quantum such as memset.
uint32_t compressed_size;
// If checksums are enabled, holds the checksum.
uint32_t checksum;
// Two flags
uint8_t flag1;
uint8_t flag2;
// Whether the whole block matched a previous block
uint32_t whole_match_distance;
} KrakenQuantumHeader;