Revert "(RPNG) optimizations to copy_line_bw"

This reverts commit 9b29217564b567241ed47bdd52d978d9acdf4f9e.
This commit is contained in:
twinaphex 2020-08-19 18:15:08 +02:00
parent e3d77d7f28
commit 003ff126ce

View File

@ -266,24 +266,32 @@ static void png_reverse_filter_copy_line_rgba(uint32_t *data,
static void png_reverse_filter_copy_line_bw(uint32_t *data,
const uint8_t *decoded, unsigned width, unsigned depth)
{
unsigned i;
static const unsigned
mul_table[] = { 0, 0xff, 0x55, 0, 0x11, 0, 0, 0, 0x01 };
unsigned mul = mul_table[depth];
unsigned mask = (1 << depth) - 1;
unsigned bit = 0;
uint32_t *data_ptr = NULL;
unsigned i, bit;
static const unsigned mul_table[] = { 0, 0xff, 0x55, 0, 0x11, 0, 0, 0, 0x01 };
unsigned mul, mask;
for ( i = 0, data_ptr = &data[0]
; i < width
; i++, data_ptr++, bit += depth)
if (depth == 16)
{
for (i = 0; i < width; i++)
{
uint32_t val = decoded[i << 1];
data[i] = (val * 0x010101) | (0xffu << 24);
}
return;
}
mul = mul_table[depth];
mask = (1 << depth) - 1;
bit = 0;
for (i = 0; i < width; i++, bit += depth)
{
unsigned byte = bit >> 3;
unsigned val = decoded[byte] >> (8 - depth - (bit & 7));
val &= mask;
val *= mul;
*data_ptr = (val * 0x010101) | (0xffu << 24);
data[i] = (val * 0x010101) | (0xffu << 24);
}
}
@ -609,23 +617,7 @@ static int png_reverse_filter_copy_line(uint32_t *data, const struct png_ihdr *i
switch (ihdr->color_type)
{
case PNG_IHDR_COLOR_GRAY:
if (ihdr->depth == 16)
{
unsigned i;
const uint8_t *decoded = pngp->decoded_scanline;
unsigned width = ihdr->width;
uint32_t *data_ptr = NULL;
for ( i = 0, data_ptr = &data[0]
; i < width
; data_ptr++, i++)
{
uint32_t val = decoded[i << 1];
*data_ptr = (val * 0x010101) | (0xffu << 24);
}
}
else
png_reverse_filter_copy_line_bw(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
png_reverse_filter_copy_line_bw(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);
break;
case PNG_IHDR_COLOR_RGB:
png_reverse_filter_copy_line_rgb(data, pngp->decoded_scanline, ihdr->width, ihdr->depth);