(RPNG optimizations)
- Use memcpy to inflate_buf into array - Some miscellaneous tweaks
This commit is contained in:
parent
8105688a99
commit
342d3da620
|
@ -566,35 +566,36 @@ static int png_reverse_filter_copy_line(uint32_t *data, const struct png_ihdr *i
|
||||||
memcpy(pngp->decoded_scanline, pngp->inflate_buf, pngp->pitch);
|
memcpy(pngp->decoded_scanline, pngp->inflate_buf, pngp->pitch);
|
||||||
break;
|
break;
|
||||||
case PNG_FILTER_SUB:
|
case PNG_FILTER_SUB:
|
||||||
for (i = 0; i < pngp->bpp; i++)
|
memcpy(pngp->decoded_scanline, pngp->inflate_buf, pngp->pitch);
|
||||||
pngp->decoded_scanline[i] = pngp->inflate_buf[i];
|
|
||||||
for (i = pngp->bpp; i < pngp->pitch; i++)
|
for (i = pngp->bpp; i < pngp->pitch; i++)
|
||||||
pngp->decoded_scanline[i] = pngp->decoded_scanline[i - pngp->bpp] + pngp->inflate_buf[i];
|
pngp->decoded_scanline[i] += pngp->decoded_scanline[i - pngp->bpp];
|
||||||
break;
|
break;
|
||||||
case PNG_FILTER_UP:
|
case PNG_FILTER_UP:
|
||||||
|
memcpy(pngp->decoded_scanline, pngp->inflate_buf, pngp->pitch);
|
||||||
for (i = 0; i < pngp->pitch; i++)
|
for (i = 0; i < pngp->pitch; i++)
|
||||||
pngp->decoded_scanline[i] = pngp->prev_scanline[i] + pngp->inflate_buf[i];
|
pngp->decoded_scanline[i] += pngp->prev_scanline[i];
|
||||||
break;
|
break;
|
||||||
case PNG_FILTER_AVERAGE:
|
case PNG_FILTER_AVERAGE:
|
||||||
|
memcpy(pngp->decoded_scanline, pngp->inflate_buf, pngp->pitch);
|
||||||
for (i = 0; i < pngp->bpp; i++)
|
for (i = 0; i < pngp->bpp; i++)
|
||||||
{
|
{
|
||||||
uint8_t avg = pngp->prev_scanline[i] >> 1;
|
uint8_t avg = pngp->prev_scanline[i] >> 1;
|
||||||
pngp->decoded_scanline[i] = avg + pngp->inflate_buf[i];
|
pngp->decoded_scanline[i] += avg;
|
||||||
}
|
}
|
||||||
for (i = pngp->bpp; i < pngp->pitch; i++)
|
for (i = pngp->bpp; i < pngp->pitch; i++)
|
||||||
{
|
{
|
||||||
uint8_t avg = (pngp->decoded_scanline[i - pngp->bpp] + pngp->prev_scanline[i]) >> 1;
|
uint8_t avg = (pngp->decoded_scanline[i - pngp->bpp] + pngp->prev_scanline[i]) >> 1;
|
||||||
pngp->decoded_scanline[i] = avg + pngp->inflate_buf[i];
|
pngp->decoded_scanline[i] += avg;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PNG_FILTER_PAETH:
|
case PNG_FILTER_PAETH:
|
||||||
|
memcpy(pngp->decoded_scanline, pngp->inflate_buf, pngp->pitch);
|
||||||
for (i = 0; i < pngp->bpp; i++)
|
for (i = 0; i < pngp->bpp; i++)
|
||||||
pngp->decoded_scanline[i] = pngp->prev_scanline[i] + pngp->inflate_buf[i];
|
pngp->decoded_scanline[i] += pngp->prev_scanline[i];
|
||||||
for (i = pngp->bpp; i < pngp->pitch; i++)
|
for (i = pngp->bpp; i < pngp->pitch; i++)
|
||||||
pngp->decoded_scanline[i] = paeth(pngp->decoded_scanline[i - pngp->bpp],
|
pngp->decoded_scanline[i] += paeth(pngp->decoded_scanline[i - pngp->bpp],
|
||||||
pngp->prev_scanline[i], pngp->prev_scanline[i - pngp->bpp]) + pngp->inflate_buf[i];
|
pngp->prev_scanline[i], pngp->prev_scanline[i - pngp->bpp]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return IMAGE_PROCESS_ERROR_END;
|
return IMAGE_PROCESS_ERROR_END;
|
||||||
}
|
}
|
||||||
|
@ -629,16 +630,16 @@ static int png_reverse_filter_regular_iterate(uint32_t **data, const struct png_
|
||||||
struct rpng_process *pngp)
|
struct rpng_process *pngp)
|
||||||
{
|
{
|
||||||
int ret = IMAGE_PROCESS_END;
|
int ret = IMAGE_PROCESS_END;
|
||||||
|
|
||||||
if (pngp->h < ihdr->height)
|
if (pngp->h < ihdr->height)
|
||||||
{
|
{
|
||||||
unsigned filter = *pngp->inflate_buf++;
|
unsigned filter = *pngp->inflate_buf++;
|
||||||
pngp->restore_buf_size += 1;
|
pngp->restore_buf_size += 1;
|
||||||
ret = png_reverse_filter_copy_line(*data,
|
ret = png_reverse_filter_copy_line(*data,
|
||||||
ihdr, pngp, filter);
|
ihdr, pngp, filter);
|
||||||
|
if (ret == IMAGE_PROCESS_END || ret == IMAGE_PROCESS_ERROR_END)
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (ret == IMAGE_PROCESS_END || ret == IMAGE_PROCESS_ERROR_END)
|
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
pngp->h++;
|
pngp->h++;
|
||||||
|
@ -670,11 +671,9 @@ static int png_reverse_filter_adam7_iterate(uint32_t **data_,
|
||||||
if (!to_next)
|
if (!to_next)
|
||||||
return IMAGE_PROCESS_END;
|
return IMAGE_PROCESS_END;
|
||||||
|
|
||||||
ret = png_reverse_filter_init(ihdr, pngp);
|
if ((ret = png_reverse_filter_init(ihdr, pngp)) == 1)
|
||||||
|
|
||||||
if (ret == 1)
|
|
||||||
return IMAGE_PROCESS_NEXT;
|
return IMAGE_PROCESS_NEXT;
|
||||||
if (ret == -1)
|
else if (ret == -1)
|
||||||
return IMAGE_PROCESS_ERROR_END;
|
return IMAGE_PROCESS_ERROR_END;
|
||||||
|
|
||||||
if (png_reverse_filter_init(&pngp->ihdr, pngp) == -1)
|
if (png_reverse_filter_init(&pngp->ihdr, pngp) == -1)
|
||||||
|
|
Loading…
Reference in New Issue