Merge commit '37aad93a58efba6c340e13aa1d83ddf2df762b3d'
This commit is contained in:
commit
9d5472cecf
|
@ -122,4 +122,3 @@ uint32_t bitstream_flush(struct bitstream* bitstream)
|
|||
bitstream->bits = bitstream->buffer = 0;
|
||||
return bitstream->doffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/* license:BSD-3-Clause
|
||||
* copyright-holders:Aaron Giles
|
||||
***************************************************************************
|
||||
|
||||
libchr_zlib.h
|
||||
|
||||
Zlib compression wrappers
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __LIBCHDR_ZLIB_H__
|
||||
#define __LIBCHDR_ZLIB_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <zlib.h>
|
||||
#include "coretypes.h"
|
||||
#include "chd.h"
|
||||
|
||||
#define MAX_ZLIB_ALLOCS 64
|
||||
|
||||
/* codec-private data for the ZLIB codec */
|
||||
|
||||
typedef struct _zlib_allocator zlib_allocator;
|
||||
struct _zlib_allocator
|
||||
{
|
||||
UINT32 * allocptr[MAX_ZLIB_ALLOCS];
|
||||
};
|
||||
|
||||
typedef struct _zlib_codec_data zlib_codec_data;
|
||||
struct _zlib_codec_data
|
||||
{
|
||||
z_stream inflater;
|
||||
zlib_allocator allocator;
|
||||
};
|
||||
|
||||
|
||||
/* codec-private data for the CDZL codec */
|
||||
typedef struct _cdzl_codec_data cdzl_codec_data;
|
||||
struct _cdzl_codec_data {
|
||||
/* internal state */
|
||||
zlib_codec_data base_decompressor;
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_data subcode_decompressor;
|
||||
#endif
|
||||
uint8_t* buffer;
|
||||
};
|
||||
|
||||
/* zlib compression codec */
|
||||
chd_error zlib_codec_init(void *codec, uint32_t hunkbytes);
|
||||
|
||||
void zlib_codec_free(void *codec);
|
||||
|
||||
chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
|
||||
|
||||
voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size);
|
||||
|
||||
void zlib_fast_free(voidpf opaque, voidpf address);
|
||||
|
||||
/* cdzl compression codec */
|
||||
chd_error cdzl_codec_init(void* codec, uint32_t hunkbytes);
|
||||
|
||||
void cdzl_codec_free(void* codec);
|
||||
|
||||
chd_error cdzl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
|
||||
|
||||
#endif /* __LIBCHDR_ZLIB_H__ */
|
|
@ -0,0 +1,72 @@
|
|||
/* license:BSD-3-Clause
|
||||
* copyright-holders:Aaron Giles
|
||||
***************************************************************************
|
||||
|
||||
lzma.h
|
||||
|
||||
LZMA compression wrappers
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __LIBCHDR_LZMA_H__
|
||||
#define __LIBCHDR_LZMA_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <LzmaEnc.h>
|
||||
#include <LzmaDec.h>
|
||||
|
||||
#include <libchdr/libchdr_zlib.h>
|
||||
|
||||
/* codec-private data for the LZMA codec */
|
||||
#define MAX_LZMA_ALLOCS 64
|
||||
|
||||
typedef struct _lzma_allocator lzma_allocator;
|
||||
struct _lzma_allocator
|
||||
{
|
||||
void *(*Alloc)(void *p, size_t size);
|
||||
void (*Free)(void *p, void *address); /* address can be 0 */
|
||||
void (*FreeSz)(void *p, void *address, size_t size); /* address can be 0 */
|
||||
uint32_t* allocptr[MAX_LZMA_ALLOCS];
|
||||
};
|
||||
|
||||
typedef struct _lzma_codec_data lzma_codec_data;
|
||||
struct _lzma_codec_data
|
||||
{
|
||||
CLzmaDec decoder;
|
||||
lzma_allocator allocator;
|
||||
};
|
||||
|
||||
/* codec-private data for the CDLZ codec */
|
||||
typedef struct _cdlz_codec_data cdlz_codec_data;
|
||||
struct _cdlz_codec_data {
|
||||
/* internal state */
|
||||
lzma_codec_data base_decompressor;
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_data subcode_decompressor;
|
||||
#endif
|
||||
uint8_t* buffer;
|
||||
};
|
||||
|
||||
chd_error lzma_codec_init(void* codec, uint32_t hunkbytes);
|
||||
|
||||
void lzma_codec_free(void* codec);
|
||||
|
||||
/*-------------------------------------------------
|
||||
* decompress - decompress data using the LZMA
|
||||
* codec
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
chd_error lzma_codec_decompress(void* codec, const uint8_t *src,
|
||||
uint32_t complen, uint8_t *dest, uint32_t destlen);
|
||||
|
||||
chd_error cdlz_codec_init(void* codec, uint32_t hunkbytes);
|
||||
|
||||
void cdlz_codec_free(void* codec);
|
||||
|
||||
chd_error cdlz_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
|
||||
|
||||
#endif /* __LIBCHDR_LZMA_H__ */
|
Loading…
Reference in New Issue