1#ifndef __LIBDRAGON_ASSET_INTERNAL_H
2#define __LIBDRAGON_ASSET_INTERNAL_H
7#define ASSET_MAGIC "DCA"
8#define ASSET_FLAG_WINSIZE_MASK 0x0007
9#define ASSET_FLAG_WINSIZE_16K 0x0000
10#define ASSET_FLAG_WINSIZE_8K 0x0001
11#define ASSET_FLAG_WINSIZE_4K 0x0002
12#define ASSET_FLAG_WINSIZE_2K 0x0003
13#define ASSET_FLAG_WINSIZE_32K 0x0004
14#define ASSET_FLAG_WINSIZE_64K 0x0005
15#define ASSET_FLAG_WINSIZE_128K 0x0006
16#define ASSET_FLAG_WINSIZE_256K 0x0007
17#define ASSET_FLAG_INPLACE 0x0100
18#define ASSET_ALIGNMENT 32
21static inline int asset_winsize_from_flags(uint16_t flags) {
22 flags &= ASSET_FLAG_WINSIZE_MASK;
24 return (2*1024) << flags;
26 return (16*1024) >> flags;
30static int asset_winsize_to_flags(
int winsize) {
31 if (winsize == 16*1024)
return ASSET_FLAG_WINSIZE_16K;
32 if (winsize == 8*1024)
return ASSET_FLAG_WINSIZE_8K;
33 if (winsize == 4*1024)
return ASSET_FLAG_WINSIZE_4K;
34 if (winsize == 2*1024)
return ASSET_FLAG_WINSIZE_2K;
35 if (winsize == 32*1024)
return ASSET_FLAG_WINSIZE_32K;
36 if (winsize == 64*1024)
return ASSET_FLAG_WINSIZE_64K;
37 if (winsize == 128*1024)
return ASSET_FLAG_WINSIZE_128K;
38 if (winsize == 256*1024)
return ASSET_FLAG_WINSIZE_256K;
53_Static_assert(
sizeof(
asset_header_t) == 20,
"invalid sizeof(asset_header_t)");
60 void (*decompress_init)(
void *state,
int fd,
int winsize);
63 ssize_t (*decompress_read)(
void *state,
void *buf,
size_t len);
66 void (*decompress_reset)(
void *state);
69 void* (*decompress_full)(
const char *fn,
int fd,
size_t cmp_size,
size_t len);
72 int (*decompress_full_inplace)(
const uint8_t *in,
size_t cmp_size, uint8_t *out,
size_t len);
76FILE *must_fopen(
const char *fn);
A decompression algorithm used by the asset library.
Definition asset_internal.h:56
int state_size
Basic size of the decompression state (without ringbuffer)
Definition asset_internal.h:57