mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
(RPNG) Reimplement png_reverse_filter_loop
This commit is contained in:
parent
b7d73ebc93
commit
ebbefc41b2
@ -321,14 +321,6 @@ static const struct adam7_pass passes[] = {
|
||||
{ 0, 1, 1, 2 },
|
||||
};
|
||||
|
||||
enum png_process_code
|
||||
{
|
||||
PNG_PROCESS_ERROR = -2,
|
||||
PNG_PROCESS_ERROR_END = -1,
|
||||
PNG_PROCESS_NEXT = 0,
|
||||
PNG_PROCESS_END = 1,
|
||||
};
|
||||
|
||||
int png_reverse_filter_init(const struct png_ihdr *ihdr,
|
||||
struct rpng_process_t *pngp)
|
||||
{
|
||||
@ -465,7 +457,7 @@ static int png_reverse_filter_copy_line(uint32_t *data, const struct png_ihdr *i
|
||||
return PNG_PROCESS_NEXT;
|
||||
}
|
||||
|
||||
static int png_reverse_filter_iterate(uint32_t *data, const struct png_ihdr *ihdr,
|
||||
static int png_reverse_filter_regular_iterate(uint32_t *data, const struct png_ihdr *ihdr,
|
||||
struct rpng_process_t *pngp)
|
||||
{
|
||||
int ret = PNG_PROCESS_END;
|
||||
@ -494,7 +486,7 @@ static int png_reverse_filter_iterate(uint32_t *data, const struct png_ihdr *ihd
|
||||
int png_reverse_filter_regular_loop(uint32_t **data, const struct png_ihdr *ihdr,
|
||||
struct rpng_process_t *pngp)
|
||||
{
|
||||
int ret = png_reverse_filter_iterate(*data, ihdr, pngp);
|
||||
int ret = png_reverse_filter_regular_iterate(*data, ihdr, pngp);
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
@ -589,30 +581,16 @@ int png_reverse_filter_adam7(uint32_t **data_,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool png_reverse_filter_loop(struct rpng_t *rpng,
|
||||
int png_reverse_filter_iterate(struct rpng_t *rpng,
|
||||
uint32_t **data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!rpng)
|
||||
return false;
|
||||
|
||||
do
|
||||
{
|
||||
const struct png_ihdr *ihdr = &rpng->ihdr;
|
||||
struct rpng_process_t *pngp = &rpng->process;
|
||||
if (rpng->ihdr.interlace)
|
||||
return png_reverse_filter_adam7(data, &rpng->ihdr, &rpng->process);
|
||||
|
||||
if (ihdr->interlace)
|
||||
ret = png_reverse_filter_adam7(data, ihdr, pngp);
|
||||
else
|
||||
ret = png_reverse_filter_regular_loop(data,
|
||||
ihdr, pngp);
|
||||
}while(ret == PNG_PROCESS_NEXT);
|
||||
|
||||
if (ret == PNG_PROCESS_ERROR || ret == PNG_PROCESS_ERROR_END)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return png_reverse_filter_regular_loop(data, &rpng->ihdr, &rpng->process);
|
||||
}
|
||||
|
||||
bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
||||
|
@ -23,6 +23,14 @@
|
||||
#ifndef _RPNG_DECODE_H
|
||||
#define _RPNG_DECODE_H
|
||||
|
||||
enum png_process_code
|
||||
{
|
||||
PNG_PROCESS_ERROR = -2,
|
||||
PNG_PROCESS_ERROR_END = -1,
|
||||
PNG_PROCESS_NEXT = 0,
|
||||
PNG_PROCESS_END = 1,
|
||||
};
|
||||
|
||||
enum png_chunk_type png_chunk_type(const struct png_chunk *chunk);
|
||||
|
||||
void png_pass_geom(const struct png_ihdr *ihdr,
|
||||
@ -42,7 +50,7 @@ int png_reverse_filter_regular_loop(uint32_t **data,
|
||||
const struct png_ihdr *ihdr,
|
||||
struct rpng_process_t *pngp);
|
||||
|
||||
bool png_reverse_filter_loop(struct rpng_t *rpng,
|
||||
int png_reverse_filter_iterate(struct rpng_t *rpng,
|
||||
uint32_t **data);
|
||||
|
||||
bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
||||
|
@ -227,6 +227,7 @@ bool rpng_load_image_argb(const char *path, uint32_t **data,
|
||||
char header[8];
|
||||
struct rpng_t rpng = {{0}};
|
||||
bool ret = true;
|
||||
int retval = 0;
|
||||
|
||||
*data = NULL;
|
||||
*width = 0;
|
||||
@ -261,7 +262,11 @@ bool rpng_load_image_argb(const char *path, uint32_t **data,
|
||||
height))
|
||||
GOTO_END_ERROR();
|
||||
|
||||
if (!png_reverse_filter_loop(&rpng, data))
|
||||
do{
|
||||
retval = png_reverse_filter_iterate(&rpng, data);
|
||||
}while(retval == PNG_PROCESS_NEXT);
|
||||
|
||||
if (retval == PNG_PROCESS_ERROR || retval == PNG_PROCESS_ERROR_END)
|
||||
GOTO_END_ERROR();
|
||||
|
||||
end:
|
||||
|
@ -194,11 +194,17 @@ bool rpng_nbio_load_image_argb_iterate(uint8_t *buf, struct rpng_t *rpng)
|
||||
bool rpng_nbio_load_image_argb_process(struct rpng_t *rpng,
|
||||
uint32_t **data, unsigned *width, unsigned *height)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!rpng_load_image_argb_process_init(rpng, data, width,
|
||||
height))
|
||||
return false;
|
||||
|
||||
if (!png_reverse_filter_loop(rpng, data))
|
||||
do{
|
||||
retval = png_reverse_filter_iterate(rpng, data);
|
||||
}while(retval == PNG_PROCESS_NEXT);
|
||||
|
||||
if (retval == PNG_PROCESS_ERROR || retval == PNG_PROCESS_ERROR_END)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user