mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 08:59:58 +00:00
Create zlib_set_stream
This commit is contained in:
parent
758d01b5da
commit
5d776f15b6
@ -349,10 +349,12 @@ bool zlib_inflate_data_to_file_init(
|
||||
if (!stream)
|
||||
goto error;
|
||||
|
||||
stream->next_in = (uint8_t*)cdata;
|
||||
stream->avail_in = csize;
|
||||
stream->next_out = handle->data;
|
||||
stream->avail_out = size;
|
||||
zlib_set_stream(stream,
|
||||
csize,
|
||||
size,
|
||||
(const uint8_t*)cdata,
|
||||
handle->data
|
||||
);
|
||||
|
||||
return true;
|
||||
|
||||
@ -778,3 +780,22 @@ bool zlib_perform_mode(const char *path, const char *valid_exts,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void zlib_set_stream(void *data,
|
||||
uint32_t avail_in,
|
||||
uint32_t avail_out,
|
||||
const uint8_t *next_in,
|
||||
uint8_t *next_out
|
||||
)
|
||||
{
|
||||
z_stream *stream = (z_stream*)data;
|
||||
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
stream->avail_in = avail_in;
|
||||
stream->avail_out = avail_out;
|
||||
|
||||
stream->next_in = (uint8_t*)next_in;
|
||||
stream->next_out = next_out;
|
||||
}
|
||||
|
@ -655,10 +655,12 @@ bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
||||
if (!rpng->process.inflate_buf)
|
||||
return false;
|
||||
|
||||
rpng->process.stream.next_in = rpng->idat_buf.data;
|
||||
rpng->process.stream.avail_in = rpng->idat_buf.size;
|
||||
rpng->process.stream.avail_out = rpng->process.inflate_buf_size;
|
||||
rpng->process.stream.next_out = rpng->process.inflate_buf;
|
||||
zlib_set_stream(
|
||||
&rpng->process.stream,
|
||||
rpng->idat_buf.size,
|
||||
rpng->process.inflate_buf_size,
|
||||
rpng->idat_buf.data,
|
||||
rpng->process.inflate_buf);
|
||||
|
||||
rpng->process.initialized = true;
|
||||
|
||||
|
@ -310,10 +310,12 @@ static bool rpng_save_image(const char *path,
|
||||
if (!deflate_buf)
|
||||
GOTO_END_ERROR();
|
||||
|
||||
stream.next_in = encode_buf;
|
||||
stream.avail_in = encode_buf_size;
|
||||
stream.next_out = deflate_buf + 8;
|
||||
stream.avail_out = encode_buf_size * 2;
|
||||
zlib_set_stream(
|
||||
&stream,
|
||||
encode_buf_size,
|
||||
encode_buf_size * 2,
|
||||
encode_buf,
|
||||
deflate_buf + 8);
|
||||
|
||||
deflateInit(&stream, 9);
|
||||
if (deflate(&stream, Z_FINISH) != Z_STREAM_END)
|
||||
|
@ -121,5 +121,12 @@ bool zlib_inflate_init(void *data);
|
||||
|
||||
bool zlib_inflate_init2(void *data);
|
||||
|
||||
void zlib_set_stream(void *data,
|
||||
uint32_t avail_in,
|
||||
uint32_t avail_out,
|
||||
const uint8_t *next_in,
|
||||
uint8_t *next_out
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user