[libpng16] Optimized absolute value calculation in filter selection, similar to
code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to use this.
This commit is contained in:
parent
ed5a01d922
commit
d9779744f9
7
ANNOUNCE
7
ANNOUNCE
@ -1,4 +1,4 @@
|
|||||||
Libpng 1.6.24beta03 - June 23, 2016
|
Libpng 1.6.24beta03 - June 30, 2016
|
||||||
|
|
||||||
This is not intended to be a public release. It will be replaced
|
This is not intended to be a public release. It will be replaced
|
||||||
within a few weeks by a public version or by another test version.
|
within a few weeks by a public version or by another test version.
|
||||||
@ -67,7 +67,10 @@ Version 1.6.24beta02 [June 23, 2016]
|
|||||||
structure padding is fixable, but it would be a signficant change (moving
|
structure padding is fixable, but it would be a signficant change (moving
|
||||||
structure members around).
|
structure members around).
|
||||||
|
|
||||||
Version 1.6.24beta03 [June 23, 2016]
|
Version 1.6.24beta03 [June 30, 2016]
|
||||||
|
Optimized absolute value calculation in filter selection, similar to
|
||||||
|
code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to
|
||||||
|
use this.
|
||||||
|
|
||||||
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
|
||||||
|
5
CHANGES
5
CHANGES
@ -5638,7 +5638,10 @@ Version 1.6.24beta02 [June 23, 2016]
|
|||||||
structure padding is fixable, but it would be a signficant change (moving
|
structure padding is fixable, but it would be a signficant change (moving
|
||||||
structure members around).
|
structure members around).
|
||||||
|
|
||||||
Version 1.6.24beta03 [June 23, 2016]
|
Version 1.6.24beta03 [June 30, 2016]
|
||||||
|
Optimized absolute value calculation in filter selection, similar to
|
||||||
|
code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to
|
||||||
|
use this.
|
||||||
|
|
||||||
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
|
||||||
|
32
pngwutil.c
32
pngwutil.c
@ -2262,14 +2262,22 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
i++, rp++, dp++)
|
i++, rp++, dp++)
|
||||||
{
|
{
|
||||||
v = *dp = *rp;
|
v = *dp = *rp;
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
||||||
i++, rp++, lp++, dp++)
|
i++, rp++, lp++, dp++)
|
||||||
{
|
{
|
||||||
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2294,7 +2302,11 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||||||
i++, rp++, pp++, dp++)
|
i++, rp++, pp++, dp++)
|
||||||
{
|
{
|
||||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2319,7 +2331,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
{
|
{
|
||||||
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
||||||
@ -2327,7 +2343,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||||
& 0xff);
|
& 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2352,7 +2372,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
{
|
{
|
||||||
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
||||||
@ -2381,7 +2405,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
|
|
||||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2465,7 +2493,11 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
||||||
{
|
{
|
||||||
v = *rp;
|
v = *rp;
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user