| 1 |
#ifndef LIBCHDR_CODEC_ZLIB_H |
| 2 |
#define LIBCHDR_CODEC_ZLIB_H |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
|
| 6 |
#if defined(__PS3__) || defined(__PSL1GHT__) |
| 7 |
#define __MACTYPES__ |
| 8 |
#endif |
| 9 |
#ifdef CHDR_SYSTEM_ZLIB |
| 10 |
#include <zlib.h> |
| 11 |
typedef uInt zlib_alloc_size; |
| 12 |
#else |
| 13 |
#include "../deps/miniz-3.1.1/miniz.h" |
| 14 |
typedef size_t zlib_alloc_size; |
| 15 |
#endif |
| 16 |
|
| 17 |
#include "../include/libchdr/chd.h" |
| 18 |
|
| 19 |
|
| 20 |
#define MAX_ZLIB_ALLOCS 64 |
| 21 |
|
| 22 |
typedef struct _zlib_allocator zlib_allocator; |
| 23 |
struct _zlib_allocator |
| 24 |
{ |
| 25 |
uint32_t * allocptr[MAX_ZLIB_ALLOCS]; |
| 26 |
uint32_t * allocptr2[MAX_ZLIB_ALLOCS]; |
| 27 |
}; |
| 28 |
|
| 29 |
typedef struct _zlib_codec_data zlib_codec_data; |
| 30 |
struct _zlib_codec_data |
| 31 |
{ |
| 32 |
z_stream inflater; |
| 33 |
zlib_allocator allocator; |
| 34 |
}; |
| 35 |
|
| 36 |
|
| 37 |
chd_error zlib_codec_init(void *codec, uint32_t hunkbytes); |
| 38 |
void zlib_codec_free(void *codec); |
| 39 |
chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen); |
| 40 |
|
| 41 |
#endif |