mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Cleanups
This commit is contained in:
parent
cc2d6ea99d
commit
7c047ea3b3
@ -351,7 +351,7 @@ static int png_reverse_filter_init(const struct png_ihdr *ihdr,
|
|||||||
png_pass_geom(&pngp->ihdr, pngp->pass.width,
|
png_pass_geom(&pngp->ihdr, pngp->pass.width,
|
||||||
pngp->pass.height, NULL, NULL, &pngp->pass.size);
|
pngp->pass.height, NULL, NULL, &pngp->pass.size);
|
||||||
|
|
||||||
if (pngp->pass.size > zlib_stream_get_total_out(&pngp->stream))
|
if (pngp->pass.size > zlib_stream_get_total_out(pngp->stream))
|
||||||
{
|
{
|
||||||
free(pngp->data);
|
free(pngp->data);
|
||||||
return -1;
|
return -1;
|
||||||
@ -367,7 +367,7 @@ static int png_reverse_filter_init(const struct png_ihdr *ihdr,
|
|||||||
|
|
||||||
png_pass_geom(ihdr, ihdr->width, ihdr->height, &pngp->bpp, &pngp->pitch, &pass_size);
|
png_pass_geom(ihdr, ihdr->width, ihdr->height, &pngp->bpp, &pngp->pitch, &pass_size);
|
||||||
|
|
||||||
if (zlib_stream_get_total_out(&pngp->stream) < pass_size)
|
if (zlib_stream_get_total_out(pngp->stream) < pass_size)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pngp->restore_buf_size = 0;
|
pngp->restore_buf_size = 0;
|
||||||
@ -524,7 +524,7 @@ static int png_reverse_filter_adam7_iterate(uint32_t **data_,
|
|||||||
pngp->inflate_buf += pngp->pass.size;
|
pngp->inflate_buf += pngp->pass.size;
|
||||||
pngp->adam7_restore_buf_size += pngp->pass.size;
|
pngp->adam7_restore_buf_size += pngp->pass.size;
|
||||||
|
|
||||||
zlib_stream_decrement_total_out(&pngp->stream, pngp->pass.size);
|
zlib_stream_decrement_total_out(pngp->stream, pngp->pass.size);
|
||||||
|
|
||||||
png_reverse_filter_adam7_deinterlace_pass(data,
|
png_reverse_filter_adam7_deinterlace_pass(data,
|
||||||
ihdr, pngp->data, pngp->pass.width, pngp->pass.height, &passes[pngp->pass.pos]);
|
ihdr, pngp->data, pngp->pass.width, pngp->pass.height, &passes[pngp->pass.pos]);
|
||||||
@ -583,13 +583,13 @@ int rpng_load_image_argb_process_inflate_init(struct rpng_t *rpng,
|
|||||||
uint32_t **data, unsigned *width, unsigned *height)
|
uint32_t **data, unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
int zstatus;
|
int zstatus;
|
||||||
bool to_continue = (zlib_stream_get_avail_in(&rpng->process.stream) > 0
|
bool to_continue = (zlib_stream_get_avail_in(rpng->process.stream) > 0
|
||||||
&& zlib_stream_get_avail_out(&rpng->process.stream) > 0);
|
&& zlib_stream_get_avail_out(rpng->process.stream) > 0);
|
||||||
|
|
||||||
if (!to_continue)
|
if (!to_continue)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
zstatus = zlib_inflate_data_to_file_iterate(&rpng->process.stream);
|
zstatus = zlib_inflate_data_to_file_iterate(rpng->process.stream);
|
||||||
|
|
||||||
switch (zstatus)
|
switch (zstatus)
|
||||||
{
|
{
|
||||||
@ -604,7 +604,7 @@ int rpng_load_image_argb_process_inflate_init(struct rpng_t *rpng,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
zlib_stream_free(&rpng->process.stream);
|
zlib_stream_free(rpng->process.stream);
|
||||||
|
|
||||||
*width = rpng->ihdr.width;
|
*width = rpng->ihdr.width;
|
||||||
*height = rpng->ihdr.height;
|
*height = rpng->ihdr.height;
|
||||||
@ -631,7 +631,7 @@ end:
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
zlib_stream_free(&rpng->process.stream);
|
zlib_stream_free(rpng->process.stream);
|
||||||
|
|
||||||
false_end:
|
false_end:
|
||||||
rpng->process.inflate_initialized = false;
|
rpng->process.inflate_initialized = false;
|
||||||
@ -649,7 +649,12 @@ bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
|||||||
if (rpng->ihdr.interlace == 1) /* To be sure. */
|
if (rpng->ihdr.interlace == 1) /* To be sure. */
|
||||||
rpng->process.inflate_buf_size *= 2;
|
rpng->process.inflate_buf_size *= 2;
|
||||||
|
|
||||||
if (!zlib_inflate_init(&rpng->process.stream))
|
rpng->process.stream = zlib_stream_new();
|
||||||
|
|
||||||
|
if (!rpng->process.stream)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!zlib_inflate_init(rpng->process.stream))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
rpng->process.inflate_buf = (uint8_t*)malloc(rpng->process.inflate_buf_size);
|
rpng->process.inflate_buf = (uint8_t*)malloc(rpng->process.inflate_buf_size);
|
||||||
@ -657,7 +662,7 @@ bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
zlib_set_stream(
|
zlib_set_stream(
|
||||||
&rpng->process.stream,
|
rpng->process.stream,
|
||||||
rpng->idat_buf.size,
|
rpng->idat_buf.size,
|
||||||
rpng->process.inflate_buf_size,
|
rpng->process.inflate_buf_size,
|
||||||
rpng->idat_buf.data,
|
rpng->idat_buf.data,
|
||||||
|
@ -21,12 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <formats/rpng.h>
|
#include <formats/rpng.h>
|
||||||
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "rpng_common.h"
|
#include "rpng_common.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <zlib.h>
|
|
||||||
#include <file/file_extract.h>
|
#include <file/file_extract.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -84,7 +83,7 @@ struct rpng_process_t
|
|||||||
size_t size;
|
size_t size;
|
||||||
unsigned pos;
|
unsigned pos;
|
||||||
} pass;
|
} pass;
|
||||||
z_stream stream;
|
void *stream;
|
||||||
zlib_file_handle_t handle;
|
zlib_file_handle_t handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user