Squashed 'libretro-common/' changes from 377cef30fa..b1f9a44ebb

b1f9a44ebb Add missing headers

git-subtree-dir: libretro-common
git-subtree-split: b1f9a44ebbf488debc0f5ef2c817d9c4f72f7153
This commit is contained in:
twinaphex 2018-05-12 18:03:48 +02:00
parent ce9ce1d353
commit 37aad93a58
3 changed files with 141 additions and 1 deletions

View File

@ -122,4 +122,3 @@ uint32_t bitstream_flush(struct bitstream* bitstream)
bitstream->bits = bitstream->buffer = 0;
return bitstream->doffset;
}

View File

@ -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__ */

72
include/libchdr/lzma.h Normal file
View File

@ -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__ */