From 9c04f57cabbf736e91b831858d0eeecca703eabf Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sun, 19 Jun 2016 18:01:33 -0500 Subject: [PATCH 1/5] [libpng15] Corrected filter heuristic overflow handling. --- ANNOUNCE | 19 +++++++++++++++++-- CHANGES | 17 ++++++++++++++++- pngwutil.c | 42 +++++++++++++++++++++--------------------- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6ff3d8414..da4eebe51 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -Libpng 1.6.24beta02 - June 11, 2016 +Libpng 1.6.24beta02 - June 19, 2016 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. @@ -29,7 +29,22 @@ Version 1.6.24beta01 [June 11, 2016] Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro is not used within libpng, but is used in some of the examples. -Version 1.6.24beta02 [June 11, 2016] +Version 1.6.24beta02 [June 19, 2016] + Correct filter heuristic overflow handling. This was broken when the + write filter code was moved out-of-line; if there is a single filter and + the heuristic sum overflows the calculation of the filtered line is not + completed. In versions prior to 1.6 the code was duplicated in-line + and the check not performed, so the filter operation completed; however, + in the multi-filter case where the sum is performed the 'none' filter would + be selected if all the sums overflowed, even if it wasn't in the filter + list. The fix to the first problem is simply to provide PNG_SIZE_MAX as + the current lmins sum value; this means the sum can never exceed it and + overflows silently. A reasonable compiler that does choose to inline + the code will simply eliminate the sum check. + The fix to the second problem is to use high precision arithmetic (this is + 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 + first problem is also fixed) (John Bowler). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 5143b5540..2fc0222c3 100644 --- a/CHANGES +++ b/CHANGES @@ -5600,7 +5600,22 @@ Version 1.6.24beta01 [June 11, 2016] Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro is not used within libpng, but is used in some of the examples. -Version 1.6.24beta02 [June 11, 2016] +Version 1.6.24beta02 [June 19, 2016] + Correct filter heuristic overflow handling. This was broken when the + write filter code was moved out-of-line; if there is a single filter and + the heuristic sum overflows the calculation of the filtered line is not + completed. In versions prior to 1.6 the code was duplicated in-line + and the check not performed, so the filter operation completed; however, + in the multi-filter case where the sum is performed the 'none' filter would + be selected if all the sums overflowed, even if it wasn't in the filter + list. The fix to the first problem is simply to provide PNG_SIZE_MAX as + the current lmins sum value; this means the sum can never exceed it and + overflows silently. A reasonable compiler that does choose to inline + the code will simply eliminate the sum check. + The fix to the second problem is to use high precision arithmetic (this is + 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 + first problem is also fixed) (John Bowler). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngwutil.c b/pngwutil.c index b47f119d2..2e4d1a567 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.6.22 [May 26, 2016] + * Last changed in libpng 1.6.24 [(PENDING RELEASE)] * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -2397,7 +2397,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) #ifndef PNG_WRITE_FILTER_SUPPORTED png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); #else - png_byte filter_to_do = png_ptr->do_filter; + unsigned int filter_to_do = png_ptr->do_filter; png_bytep row_buf; png_bytep best_row; png_uint_32 bpp; @@ -2443,27 +2443,24 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) */ best_row = png_ptr->row_buf; - - if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE) + if (PNG_SIZE_MAX/128 <= row_bytes) { + /* Overflow can occur in the calculation, just select the lowest set + * filter. + */ + filter_to_do &= -filter_to_do; + } + else if ((filter_to_do & PNG_FILTER_NONE) != 0 && + filter_to_do != PNG_FILTER_NONE) + { + /* Overflow not possible and multiple filters in the list, including the + * 'none' filter. + */ png_bytep rp; png_size_t sum = 0; png_size_t i; int v; - if (PNG_SIZE_MAX/128 <= row_bytes) - { - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - /* Check for overflow */ - if (sum > PNG_SIZE_MAX/128 - 256) - break; - - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - } - else /* Overflow is not possible */ { for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) { @@ -2479,7 +2476,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (filter_to_do == PNG_FILTER_SUB) /* It's the only filter so no testing is needed */ { - (void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins); + /* 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; } @@ -2505,7 +2505,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { - (void) png_setup_up_row(png_ptr, row_bytes, mins); + (void) png_setup_up_row(png_ptr, row_bytes, PNG_SIZE_MAX); best_row = png_ptr->try_row; } @@ -2531,7 +2531,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { - (void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins); + (void) png_setup_avg_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX); best_row = png_ptr->try_row; } @@ -2557,7 +2557,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Paeth filter */ if ((filter_to_do == PNG_FILTER_PAETH) != 0) { - (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins); + (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX); best_row = png_ptr->try_row; } From 29135161d74e5f6f640ec1fc2ab3ceebc34e339b Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 19 Jun 2016 18:43:35 -0500 Subject: [PATCH 2/5] [libpng16] 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. --- ANNOUNCE | 3 ++ CHANGES | 3 ++ pngwutil.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 110 insertions(+), 7 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index da4eebe51..f506c831b 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -45,6 +45,9 @@ Version 1.6.24beta02 [June 19, 2016] 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 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 (subscription required; visit diff --git a/CHANGES b/CHANGES index 2fc0222c3..ee7c0d518 100644 --- a/CHANGES +++ b/CHANGES @@ -5616,6 +5616,9 @@ Version 1.6.24beta02 [June 19, 2016] 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 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 (subscription required; visit diff --git a/pngwutil.c b/pngwutil.c index 2e4d1a567..30b0a9702 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -2278,6 +2278,28 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, 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 */ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, const png_size_t lmins) @@ -2302,6 +2324,21 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, 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 */ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, @@ -2335,6 +2372,27 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, 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 */ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, @@ -2389,6 +2447,48 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, 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 */ void /* PRIVATE */ @@ -2476,10 +2576,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (filter_to_do == PNG_FILTER_SUB) /* It's the only filter so no testing is needed */ { - /* 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); + png_setup_sub_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2505,7 +2602,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { - (void) png_setup_up_row(png_ptr, row_bytes, PNG_SIZE_MAX); + png_setup_up_row_only(png_ptr, row_bytes); best_row = png_ptr->try_row; } @@ -2531,7 +2628,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { - (void) png_setup_avg_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX); + png_setup_avg_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2557,7 +2654,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Paeth filter */ if ((filter_to_do == PNG_FILTER_PAETH) != 0) { - (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, PNG_SIZE_MAX); + png_setup_paeth_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } From 147dc568daf025f765749ae1919d7b6f613860a6 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 19 Jun 2016 22:20:52 -0500 Subject: [PATCH 3/5] [libpng16] Backed out previous optimization; the compiler should handle that. --- ANNOUNCE | 3 -- CHANGES | 3 -- pngwutil.c | 111 ++++------------------------------------------------- 3 files changed, 7 insertions(+), 110 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index f506c831b..da4eebe51 100644 --- a/ANNOUNCE +++ b/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 numbered filter in the list from png_set_filter (this only works if the 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 (subscription required; visit diff --git a/CHANGES b/CHANGES index ee7c0d518..2fc0222c3 100644 --- a/CHANGES +++ b/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 numbered filter in the list from png_set_filter (this only works if the 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 (subscription required; visit diff --git a/pngwutil.c b/pngwutil.c index 30b0a9702..2e4d1a567 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -2278,28 +2278,6 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, 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 */ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, 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); } -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 */ 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); } -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 */ 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); } -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 */ 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) /* 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; } @@ -2602,7 +2505,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Up filter */ 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; } @@ -2628,7 +2531,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Avg filter */ 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; } @@ -2654,7 +2557,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Paeth filter */ 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; } From 36762ac4b46ccea1e5be11dee336af099ecacf9c Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Mon, 20 Jun 2016 08:59:25 -0400 Subject: [PATCH 4/5] More efficient absolute value on SSE2 --- contrib/intel/filter_sse2_intrinsics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/intel/filter_sse2_intrinsics.c b/contrib/intel/filter_sse2_intrinsics.c index aea3f86af..8197c2dd9 100644 --- a/contrib/intel/filter_sse2_intrinsics.c +++ b/contrib/intel/filter_sse2_intrinsics.c @@ -208,7 +208,7 @@ static __m128i abs_i16(__m128i x) { x = _mm_xor_si128(x, is_negative); /* +1 to negative lanes, else +0. */ - x = _mm_add_epi16(x, _mm_srli_epi16(is_negative, 15)); + x = _mm_sub_epi16(x, is_negative); return x; #endif } From 6c7c5a04b8aa27e33e33746471811b840c1fa6d2 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Mon, 20 Jun 2016 08:28:34 -0500 Subject: [PATCH 5/5] [libpng16] More efficient absolute value calculation on SSE2 (Matthieu Darbois). --- ANNOUNCE | 5 +++-- CHANGES | 3 ++- contrib/intel/filter_sse2_intrinsics.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index da4eebe51..811ba1ba1 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -Libpng 1.6.24beta02 - June 19, 2016 +Libpng 1.6.24beta02 - June 20, 2016 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. @@ -29,7 +29,7 @@ Version 1.6.24beta01 [June 11, 2016] Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro is not used within libpng, but is used in some of the examples. -Version 1.6.24beta02 [June 19, 2016] +Version 1.6.24beta02 [June 20, 2016] Correct filter heuristic overflow handling. This was broken when the write filter code was moved out-of-line; if there is a single filter and the heuristic sum overflows the calculation of the filtered line is not @@ -45,6 +45,7 @@ Version 1.6.24beta02 [June 19, 2016] 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 first problem is also fixed) (John Bowler). + Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 2fc0222c3..32575c28e 100644 --- a/CHANGES +++ b/CHANGES @@ -5600,7 +5600,7 @@ Version 1.6.24beta01 [June 11, 2016] Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro is not used within libpng, but is used in some of the examples. -Version 1.6.24beta02 [June 19, 2016] +Version 1.6.24beta02 [June 20, 2016] Correct filter heuristic overflow handling. This was broken when the write filter code was moved out-of-line; if there is a single filter and the heuristic sum overflows the calculation of the filtered line is not @@ -5616,6 +5616,7 @@ Version 1.6.24beta02 [June 19, 2016] 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 first problem is also fixed) (John Bowler). + Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/intel/filter_sse2_intrinsics.c b/contrib/intel/filter_sse2_intrinsics.c index 8197c2dd9..d6557125b 100644 --- a/contrib/intel/filter_sse2_intrinsics.c +++ b/contrib/intel/filter_sse2_intrinsics.c @@ -6,7 +6,7 @@ * Derived from arm/filter_neon_intrinsics.c, which was * Copyright (c) 2014,2016 Glenn Randers-Pehrson * - * Last changed in libpng 1.6.22 [May 26, 2016] + * Last changed in libpng 1.6.24 [(PENDING RELEASE)] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer