mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Create zlib_deflate wrapper functions
This commit is contained in:
parent
3187e308a4
commit
4572a1c48d
@ -306,6 +306,14 @@ bool zlib_inflate_init2(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void zlib_deflate_init(void *data, int level)
|
||||
{
|
||||
z_stream *stream = (z_stream*)data;
|
||||
|
||||
if (stream)
|
||||
deflateInit(stream, level);
|
||||
}
|
||||
|
||||
bool zlib_inflate_init(void *data)
|
||||
{
|
||||
z_stream *stream = (z_stream*)data;
|
||||
@ -324,6 +332,13 @@ void zlib_stream_free(void *data)
|
||||
inflateEnd(ret);
|
||||
}
|
||||
|
||||
void zlib_stream_deflate_free(void *data)
|
||||
{
|
||||
z_stream *ret = (z_stream*)data;
|
||||
if (ret)
|
||||
deflateEnd(ret);
|
||||
}
|
||||
|
||||
bool zlib_inflate_data_to_file_init(
|
||||
zlib_file_handle_t *handle,
|
||||
const uint8_t *cdata, uint32_t csize, uint32_t size)
|
||||
@ -367,6 +382,22 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
int zlib_deflate_data_to_file(void *data)
|
||||
{
|
||||
int zstatus;
|
||||
z_stream *stream = (z_stream*)data;
|
||||
|
||||
if (!stream)
|
||||
return -1;
|
||||
|
||||
zstatus = deflate(stream, Z_FINISH);
|
||||
|
||||
if (zstatus == Z_STREAM_END)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zlib_inflate_data_to_file_iterate(void *data)
|
||||
{
|
||||
int zstatus;
|
||||
|
@ -315,13 +315,15 @@ static bool rpng_save_image(const char *path,
|
||||
encode_buf,
|
||||
deflate_buf + 8);
|
||||
|
||||
deflateInit(&stream, 9);
|
||||
if (deflate(&stream, Z_FINISH) != Z_STREAM_END)
|
||||
zlib_deflate_init(&stream, 9);
|
||||
|
||||
if (zlib_deflate_data_to_file(&stream) != 1)
|
||||
{
|
||||
deflateEnd(&stream);
|
||||
zlib_stream_deflate_free(&stream);
|
||||
GOTO_END_ERROR();
|
||||
}
|
||||
deflateEnd(&stream);
|
||||
|
||||
zlib_stream_deflate_free(&stream);
|
||||
|
||||
memcpy(deflate_buf + 4, "IDAT", 4);
|
||||
dword_write_be(deflate_buf + 0, zlib_stream_get_total_out(&stream));
|
||||
|
@ -117,6 +117,12 @@ void *zlib_stream_new(void);
|
||||
|
||||
void zlib_stream_free(void *data);
|
||||
|
||||
void zlib_deflate_init(void *data, int level);
|
||||
|
||||
int zlib_deflate_data_to_file(void *data);
|
||||
|
||||
void zlib_stream_deflate_free(void *data);
|
||||
|
||||
bool zlib_inflate_init(void *data);
|
||||
|
||||
bool zlib_inflate_init2(void *data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user