-
Notifications
You must be signed in to change notification settings - Fork 2
/
spngt.h
99 lines (76 loc) · 1.89 KB
/
spngt.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
#ifndef SPNGT_H
#define SPNGT_H
#include <spng.h>
#include <string.h>
#include <inttypes.h>
#include <stdio.h>
#define SPNGT_DEFAULT_DECODE_RUNS 5
#define SPNGT_DEFAULT_ENCODE_RUNS 2
enum spngt_errno
{
SPNGT_OK = 0,
SPNGT_EINVAL = 1, /* invalid argument */
SPNGT_EMEM, /* out of memory */
SPNGT_ERROR, /* generic error */
SPNGT_ENOTSUPP, /* (operation) not supported */
};
enum spngt_zlib_strategy
{
SPNGT_Z_FILTERED = 1,
SPNGT_Z_HUFFMAN_ONLY = 2,
SPNGT_Z_RLE = 3,
SPNGT_Z_FIXED = 4,
SPNGT_Z_DEFAULT_STRATEGY = 0
};
struct spngt_params
{
void *image;
size_t image_size;
void *png;
size_t png_size;
/* Output format when decoding, input format when encoding */
enum spng_format fmt;
struct spng_ihdr ihdr;
struct spng_plte plte;
int decode_runs;
int encode_runs;
/* Applies to all options below */
int override_defaults;
/* zlib options */
int compression_level;
int window_bits;
int mem_level;
enum spngt_zlib_strategy strategy;
enum spng_filter_choice filter_choice;
};
struct spngt_buf_state
{
unsigned char *data;
size_t bytes_left;
int error;
};
#define SPNGT_LIBS(XX) \
XX(libpng) \
XX(spng) \
XX(stb) \
XX(lodepng) \
XX(wuffs)
enum spngt_library
{
#define XX(library) library,
SPNGT_LIBS(XX)
#undef XX
};
uint64_t spngt_time(void);
/* Calculate time elapsed and update *best if *best is larger */
void spngt_measure(uint64_t start, uint64_t end, uint64_t *best);
const char *spngt_strerror(enum spngt_errno err);
int spngt_prefetch_file(const char *path, struct spngt_params *params);
int spngt_exec_script(int argc, char **argv);
#define XX(lib) \
void spngt_print_version_##lib(void); \
int spngt_decode_##lib(struct spngt_params *params); \
int spngt_encode_##lib(struct spngt_params *params);
SPNGT_LIBS(XX)
#undef XX
#endif /* SPNGT_H */