[libpng16] Backed out previous optimization; the compiler should handle that.
This commit is contained in:
parent
29135161d7
commit
147dc568da
3
ANNOUNCE
3
ANNOUNCE
@ -45,9 +45,6 @@ Version 1.6.24beta02 [June 19, 2016]
|
|||||||
implemented in 1.7), however a simple safe fix here is to chose the lowest
|
implemented in 1.7), however a simple safe fix here is to chose the lowest
|
||||||
numbered filter in the list from png_set_filter (this only works if the
|
numbered filter in the list from png_set_filter (this only works if the
|
||||||
first problem is also fixed) (John Bowler).
|
first problem is also fixed) (John Bowler).
|
||||||
Avoid filter-selection heuristic sum calculations in cases where only one
|
|
||||||
filter is a candidate for selection. This trades off code size (added
|
|
||||||
png_setup_*_row_only() functions) for speed.
|
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
3
CHANGES
3
CHANGES
@ -5616,9 +5616,6 @@ Version 1.6.24beta02 [June 19, 2016]
|
|||||||
implemented in 1.7), however a simple safe fix here is to chose the lowest
|
implemented in 1.7), however a simple safe fix here is to chose the lowest
|
||||||
numbered filter in the list from png_set_filter (this only works if the
|
numbered filter in the list from png_set_filter (this only works if the
|
||||||
first problem is also fixed) (John Bowler).
|
first problem is also fixed) (John Bowler).
|
||||||
Avoid filter-selection heuristic sum calculations in cases where only one
|
|
||||||
filter is a candidate for selection. This trades off code size (added
|
|
||||||
png_setup_*_row_only() functions) for speed.
|
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
111
pngwutil.c
111
pngwutil.c
@ -2278,28 +2278,6 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void /* PRIVATE */
|
|
||||||
png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
|
||||||
const png_size_t row_bytes)
|
|
||||||
{
|
|
||||||
png_bytep rp, dp, lp;
|
|
||||||
png_size_t i;
|
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
|
|
||||||
|
|
||||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
|
|
||||||
i++, rp++, dp++)
|
|
||||||
{
|
|
||||||
*dp = *rp;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
|
||||||
i++, rp++, lp++, dp++)
|
|
||||||
{
|
|
||||||
*dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static png_size_t /* PRIVATE */
|
static png_size_t /* PRIVATE */
|
||||||
png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
||||||
const png_size_t lmins)
|
const png_size_t lmins)
|
||||||
@ -2324,21 +2302,6 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
static void /* PRIVATE */
|
|
||||||
png_setup_up_row_only(png_structrp png_ptr, const png_size_t row_bytes)
|
|
||||||
{
|
|
||||||
png_bytep rp, dp, pp;
|
|
||||||
png_size_t i;
|
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
|
|
||||||
|
|
||||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
|
||||||
pp = png_ptr->prev_row + 1; i < row_bytes;
|
|
||||||
i++, rp++, pp++, dp++)
|
|
||||||
{
|
|
||||||
*dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static png_size_t /* PRIVATE */
|
static png_size_t /* PRIVATE */
|
||||||
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
@ -2372,27 +2335,6 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
static void /* PRIVATE */
|
|
||||||
png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
|
||||||
const png_size_t row_bytes)
|
|
||||||
{
|
|
||||||
png_bytep rp, dp, pp, lp;
|
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
|
|
||||||
|
|
||||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
|
||||||
pp = png_ptr->prev_row + 1; i < bpp; i++)
|
|
||||||
{
|
|
||||||
*dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
|
||||||
{
|
|
||||||
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
|
||||||
& 0xff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static png_size_t /* PRIVATE */
|
static png_size_t /* PRIVATE */
|
||||||
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
@ -2447,48 +2389,6 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
static void /* PRIVATE */
|
|
||||||
png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
|
||||||
const png_size_t row_bytes)
|
|
||||||
{
|
|
||||||
png_bytep rp, dp, pp, cp, lp;
|
|
||||||
png_size_t i;
|
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
|
|
||||||
|
|
||||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
|
||||||
pp = png_ptr->prev_row + 1; i < bpp; i++)
|
|
||||||
{
|
|
||||||
*dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
|
||||||
i++)
|
|
||||||
{
|
|
||||||
int a, b, c, pa, pb, pc, p;
|
|
||||||
|
|
||||||
b = *pp++;
|
|
||||||
c = *cp++;
|
|
||||||
a = *lp++;
|
|
||||||
|
|
||||||
p = b - c;
|
|
||||||
pc = a - c;
|
|
||||||
|
|
||||||
#ifdef PNG_USE_ABS
|
|
||||||
pa = abs(p);
|
|
||||||
pb = abs(pc);
|
|
||||||
pc = abs(p + pc);
|
|
||||||
#else
|
|
||||||
pa = p < 0 ? -p : p;
|
|
||||||
pb = pc < 0 ? -pc : pc;
|
|
||||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
|
||||||
|
|
||||||
*dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* WRITE_FILTER */
|
#endif /* WRITE_FILTER */
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
@ -2576,7 +2476,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
if (filter_to_do == PNG_FILTER_SUB)
|
if (filter_to_do == PNG_FILTER_SUB)
|
||||||
/* It's the only filter so no testing is needed */
|
/* It's the only filter so no testing is needed */
|
||||||
{
|
{
|
||||||
png_setup_sub_row_only(png_ptr, bpp, row_bytes);
|
/* Passing PNG_SIZE_MAX here and below prevents the 'setup' function
|
||||||
|
* breaking out of the loop when lmins is exceeded.
|
||||||
|
*/
|
||||||
|
(void) png_setup_sub_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2602,7 +2505,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
/* Up filter */
|
/* Up filter */
|
||||||
if (filter_to_do == PNG_FILTER_UP)
|
if (filter_to_do == PNG_FILTER_UP)
|
||||||
{
|
{
|
||||||
png_setup_up_row_only(png_ptr, row_bytes);
|
(void) png_setup_up_row(png_ptr, row_bytes, PNG_SIZE_MAX);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2628,7 +2531,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
/* Avg filter */
|
/* Avg filter */
|
||||||
if (filter_to_do == PNG_FILTER_AVG)
|
if (filter_to_do == PNG_FILTER_AVG)
|
||||||
{
|
{
|
||||||
png_setup_avg_row_only(png_ptr, bpp, row_bytes);
|
(void) png_setup_avg_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2654,7 +2557,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
/* Paeth filter */
|
/* Paeth filter */
|
||||||
if ((filter_to_do == PNG_FILTER_PAETH) != 0)
|
if ((filter_to_do == PNG_FILTER_PAETH) != 0)
|
||||||
{
|
{
|
||||||
png_setup_paeth_row_only(png_ptr, bpp, row_bytes);
|
(void) png_setup_paeth_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user