mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
png_reverse_filter_wrapper - more refactoring
This commit is contained in:
parent
9e9dcc12ab
commit
4897aed9e0
@ -134,17 +134,7 @@ static int png_reverse_filter_wrapper(uint32_t *data, const struct png_ihdr *ihd
|
|||||||
const uint32_t *palette)
|
const uint32_t *palette)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
bool cont = true;
|
bool cont = pngp->h < ihdr->height;
|
||||||
|
|
||||||
if (!pngp)
|
|
||||||
return -1;
|
|
||||||
if (!pngp->pass_initialized)
|
|
||||||
{
|
|
||||||
if (!png_reverse_filter_init(data, ihdr, inflate_buf, pngp, palette))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cont = pngp->h < ihdr->height;
|
|
||||||
|
|
||||||
if (!cont)
|
if (!cont)
|
||||||
{
|
{
|
||||||
@ -152,7 +142,7 @@ static int png_reverse_filter_wrapper(uint32_t *data, const struct png_ihdr *ihd
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;; )
|
do
|
||||||
{
|
{
|
||||||
unsigned filter;
|
unsigned filter;
|
||||||
|
|
||||||
@ -205,25 +195,33 @@ static int png_reverse_filter_wrapper(uint32_t *data, const struct png_ihdr *ihd
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ihdr->color_type == 0)
|
switch (ihdr->color_type)
|
||||||
copy_line_bw(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
|
{
|
||||||
else if (ihdr->color_type == 2)
|
case 0:
|
||||||
copy_line_rgb(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
|
copy_line_bw(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
|
||||||
else if (ihdr->color_type == 3)
|
break;
|
||||||
copy_line_plt(data, pngp->decoded_scanline, ihdr->width,
|
case 2:
|
||||||
ihdr->depth, palette);
|
copy_line_rgb(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
|
||||||
else if (ihdr->color_type == 4)
|
break;
|
||||||
copy_line_gray_alpha(data, pngp->decoded_scanline, ihdr->width,
|
case 3:
|
||||||
ihdr->depth);
|
copy_line_plt(data, pngp->decoded_scanline, ihdr->width,
|
||||||
else if (ihdr->color_type == 6)
|
ihdr->depth, palette);
|
||||||
copy_line_rgba(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
|
break;
|
||||||
|
case 4:
|
||||||
|
copy_line_gray_alpha(data, pngp->decoded_scanline, ihdr->width,
|
||||||
|
ihdr->depth);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
copy_line_rgba(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(pngp->prev_scanline, pngp->decoded_scanline, pngp->pitch);
|
memcpy(pngp->prev_scanline, pngp->decoded_scanline, pngp->pitch);
|
||||||
|
|
||||||
pngp->h++;
|
pngp->h++;
|
||||||
inflate_buf += pngp->pitch;
|
inflate_buf += pngp->pitch;
|
||||||
data += ihdr->width;
|
data += ihdr->width;
|
||||||
}
|
}while(1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
error:
|
error:
|
||||||
@ -236,6 +234,15 @@ static bool png_reverse_filter(uint32_t *data, const struct png_ihdr *ihdr,
|
|||||||
const uint32_t *palette)
|
const uint32_t *palette)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!pngp)
|
||||||
|
return -1;
|
||||||
|
if (!pngp->pass_initialized)
|
||||||
|
{
|
||||||
|
if (!png_reverse_filter_init(data, ihdr, inflate_buf, pngp, palette))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
while((ret = png_reverse_filter_wrapper(data,
|
while((ret = png_reverse_filter_wrapper(data,
|
||||||
ihdr, inflate_buf, pngp, palette)) == 0);
|
ihdr, inflate_buf, pngp, palette)) == 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user