-
Notifications
You must be signed in to change notification settings - Fork 20
/
compress.h
66 lines (51 loc) · 1.4 KB
/
compress.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
#pragma once
#include <string>
#include <vector>
#include <functional>
#include <cstdint>
namespace maxcso {
static const char *VERSION = "1.5.0";
struct Task;
enum TaskStatus {
TASK_INPROGRESS,
TASK_SUCCESS,
TASK_BAD_INPUT,
TASK_BAD_OUTPUT,
TASK_INVALID_DATA,
TASK_CANNOT_WRITE,
TASK_INVALID_OPTION,
};
enum TaskFlags {
TASKFLAG_DEFAULT = 0,
// Disable certain compression algorithms.
TASKFLAG_NO_ZLIB = 0x03,
TASKFLAG_NO_ZLIB_DEFAULT = 0x01,
TASKFLAG_NO_ZLIB_BRUTE = 0x02,
TASKFLAG_NO_ZOPFLI = 0x04,
TASKFLAG_NO_7ZIP = 0x08,
// Disable heuristics and compress all sectors.
TASKFLAG_FORCE_ALL = 0x10,
// Flags for new formats.
TASKFLAG_FMT_ZSO = 0x20,
TASKFLAG_FMT_CSO_2 = 0x40,
TASKFLAG_NO_LZ4 = 0x380,
TASKFLAG_NO_LZ4_DEFAULT = 0x80,
TASKFLAG_NO_LZ4_HC = 0x100,
TASKFLAG_NO_LZ4_HC_BRUTE = 0x200,
TASKFLAG_NO_ALL = TASKFLAG_NO_ZLIB | TASKFLAG_NO_ZOPFLI | TASKFLAG_NO_7ZIP | TASKFLAG_NO_LZ4,
TASKFLAG_DECOMPRESS = 0x400,
};
typedef std::function<void (const Task *, TaskStatus status, int64_t pos, int64_t total, int64_t written)> ProgressCallback;
typedef std::function<void (const Task *, TaskStatus status, const char *reason)> ErrorCallback;
struct Task {
std::string input;
std::string output;
ProgressCallback progress;
ErrorCallback error;
uint32_t block_size;
uint32_t flags;
uint32_t orig_max_cost;
uint32_t lz4_max_cost;
};
void Compress(const std::vector<Task> &tasks);
};