Fixed bug with unaligned input on VSX filter_up

This commit is contained in:
Vadim Barkov 2017-01-16 19:45:17 +03:00
parent 91acd4baf8
commit ccef5edbfe

View File

@ -36,13 +36,24 @@ void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
png_size_t i;
png_size_t istop = row_info->rowbytes;
png_size_t unaligned_top = (png_size_t)row % 16;
png_size_t istop = row_info->rowbytes - unaligned_top;
png_bytep rp = row;
png_const_bytep pp = prev_row;
vector unsigned char rp_vec;
vector unsigned char pp_vec;
/* Altivec operations require 16-byte aligned data
* but input can be unaligned. So we calculate
* unaligned part as usual.
*/
for (i = 0; i < unaligned_top; i++)
{
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
rp++;
}
/* Using SIMD while we can */
while( istop >= 16 )
{
@ -69,9 +80,10 @@ void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row,
rp++;
}
}
}
void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
void png_read_filter_row_sub_vsx(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
const unsigned int bpp = 4;
@ -88,23 +100,6 @@ void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
}
}
void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
const unsigned int bpp = 4;
png_size_t i;
png_size_t istop = row_info->rowbytes;
png_bytep rp = row + bpp;
PNG_UNUSED(prev_row)
for (i = bpp; i < istop; i++)
{
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-3))) & 0xff);
rp++;
}
}
void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{