mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 16:20:39 +00:00
(RPNG) Uncouple png_reverse_filter_init from png_reverse_filter_regular
This commit is contained in:
parent
676b6aaad5
commit
6506f6ce85
@ -395,9 +395,6 @@ static bool png_reverse_filter_regular(uint32_t *data, const struct png_ihdr *ih
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (png_reverse_filter_init(ihdr, pngp) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
do{
|
do{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
@ -451,13 +448,12 @@ static int png_reverse_filter_adam7(uint32_t *data,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (png_reverse_filter_init(&pngp->ihdr, pngp) == -1)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (!png_reverse_filter_regular(pngp->data,
|
if (!png_reverse_filter_regular(pngp->data,
|
||||||
&pngp->ihdr, pngp))
|
&pngp->ihdr, pngp))
|
||||||
{
|
goto error;
|
||||||
free(pngp->data);
|
|
||||||
ret = -1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
@ -482,15 +478,27 @@ end:
|
|||||||
pngp->adam7_restore_buf_size = 0;
|
pngp->adam7_restore_buf_size = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (pngp->data)
|
||||||
|
free(pngp->data);
|
||||||
|
pngp->inflate_buf -= pngp->adam7_restore_buf_size;
|
||||||
|
pngp->adam7_restore_buf_size = 0;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool png_reverse_filter_loop(struct rpng_t *rpng,
|
static bool png_reverse_filter_loop(struct rpng_t *rpng,
|
||||||
uint32_t **data)
|
uint32_t **data)
|
||||||
{
|
{
|
||||||
|
const struct png_ihdr *ihdr = NULL;
|
||||||
|
struct rpng_process_t *pngp = NULL;
|
||||||
rpng->process.adam7_restore_buf_size = 0;
|
rpng->process.adam7_restore_buf_size = 0;
|
||||||
rpng->process.restore_buf_size = 0;
|
rpng->process.restore_buf_size = 0;
|
||||||
rpng->process.palette = rpng->palette;
|
rpng->process.palette = rpng->palette;
|
||||||
|
|
||||||
|
ihdr = &rpng->ihdr;
|
||||||
|
pngp = &rpng->process;
|
||||||
|
|
||||||
if (rpng->ihdr.interlace == 1)
|
if (rpng->ihdr.interlace == 1)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -498,15 +506,20 @@ static bool png_reverse_filter_loop(struct rpng_t *rpng,
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = png_reverse_filter_adam7(*data,
|
ret = png_reverse_filter_adam7(*data,
|
||||||
&rpng->ihdr, &rpng->process);
|
ihdr, pngp);
|
||||||
}while(ret == 0);
|
}while(ret == 0);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!png_reverse_filter_regular(*data,
|
else
|
||||||
&rpng->ihdr, &rpng->process))
|
{
|
||||||
|
if (png_reverse_filter_init(ihdr, pngp) == -1)
|
||||||
return false;
|
return false;
|
||||||
|
if (!png_reverse_filter_regular(*data,
|
||||||
|
ihdr, pngp))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user