[libpng12] Removed WRITE_WEIGHTED_FILTERED code, reformatted LICENSE.
This commit is contained in:
parent
b9a5aee331
commit
d5b51a49a9
5
ANNOUNCE
5
ANNOUNCE
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.2.54beta01 - May 15, 2015
|
Libpng 1.2.54beta01 - July 13, 2015
|
||||||
|
|
||||||
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.
|
||||||
@ -43,12 +43,13 @@ Other information:
|
|||||||
|
|
||||||
Changes since the last public release (1.2.53):
|
Changes since the last public release (1.2.53):
|
||||||
|
|
||||||
version 1.2.54beta01 [May 15, 2015]
|
version 1.2.54beta01 [July 13, 2015]
|
||||||
Fix typecast in a png_debug2() statement in png_set_text_2() to
|
Fix typecast in a png_debug2() statement in png_set_text_2() to
|
||||||
avoid a compiler warning in PNG_DEBUG builds.
|
avoid a compiler warning in PNG_DEBUG builds.
|
||||||
Fixed printf formats in pngtest.c to avoid compiler warnings and a
|
Fixed printf formats in pngtest.c to avoid compiler warnings and a
|
||||||
Coverity warning in PNG_DEBUG builds.
|
Coverity warning in PNG_DEBUG builds.
|
||||||
Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds.
|
Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds.
|
||||||
|
Removed WRITE_WEIGHTED_FILTERED code.
|
||||||
|
|
||||||
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
|
||||||
|
6
CHANGES
6
CHANGES
@ -469,7 +469,7 @@ version 1.0.3d [September 4, 1999]
|
|||||||
Added new png_expand functions to scripts/pngdef.pas and pngos2.def
|
Added new png_expand functions to scripts/pngdef.pas and pngos2.def
|
||||||
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
|
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
|
||||||
|
|
||||||
version 1.0.4 [September 24, 1999]
|
Version 1.0.4 [September 24, 1999, not distributed publicly]
|
||||||
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
|
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
|
||||||
Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
|
Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
|
||||||
Made several minor corrections to pngtest.c
|
Made several minor corrections to pngtest.c
|
||||||
@ -493,6 +493,7 @@ version 1.0.4c [October 1, 1999]
|
|||||||
Added a "png_check_version" function in png.c and pngtest.c that will generate
|
Added a "png_check_version" function in png.c and pngtest.c that will generate
|
||||||
a helpful compiler error if an old png.h is found in the search path.
|
a helpful compiler error if an old png.h is found in the search path.
|
||||||
Changed type of png_user_transform_depth|channels from int to png_byte.
|
Changed type of png_user_transform_depth|channels from int to png_byte.
|
||||||
|
Added "Libpng is OSI Certified Open Source Software" statement to png.h
|
||||||
version 1.0.4d [October 6, 1999]
|
version 1.0.4d [October 6, 1999]
|
||||||
Changed 0.45 to 0.45455 in png_set_sRGB()
|
Changed 0.45 to 0.45455 in png_set_sRGB()
|
||||||
Removed unused PLTE entries from pngnow.png
|
Removed unused PLTE entries from pngnow.png
|
||||||
@ -2857,12 +2858,13 @@ version 1.2.53rc02 [February 21, 2015]
|
|||||||
versions 1.0.63 and 1.2.53 [February 26, 2015]
|
versions 1.0.63 and 1.2.53 [February 26, 2015]
|
||||||
No changes.
|
No changes.
|
||||||
|
|
||||||
version 1.2.54beta01 [May 15, 2015]
|
version 1.2.54beta01 [July 13, 2015]
|
||||||
Fixed typecast in a png_debug2() statement in png_set_text_2() to
|
Fixed typecast in a png_debug2() statement in png_set_text_2() to
|
||||||
avoid a compiler warning in PNG_DEBUG builds.
|
avoid a compiler warning in PNG_DEBUG builds.
|
||||||
Fixed printf formats in pngtest.c to avoid compiler warnings and a
|
Fixed printf formats in pngtest.c to avoid compiler warnings and a
|
||||||
Coverity warning in PNG_DEBUG builds.
|
Coverity warning in PNG_DEBUG builds.
|
||||||
Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds.
|
Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds.
|
||||||
|
Removed WRITE_WEIGHTED_FILTERED code.
|
||||||
|
|
||||||
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
|
||||||
|
46
LICENSE
46
LICENSE
@ -10,20 +10,14 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.2.6, August 15, 2004, through 1.2.54beta01, May 9, 2015, are
|
libpng versions 1.0.7, July 1, 2000, through 1.2.54beta01, July 13, 2015, are
|
||||||
Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
|
||||||
with the following individual added to the list of Contributing Authors
|
|
||||||
|
|
||||||
Cosmin Truta
|
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
|
||||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
|
||||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
with the following individuals added to the list of Contributing Authors
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
Simon-Pierre Cadieux
|
Simon-Pierre Cadieux
|
||||||
Eric S. Raymond
|
Eric S. Raymond
|
||||||
|
Cosmin Truta
|
||||||
Gilles Vollant
|
Gilles Vollant
|
||||||
|
|
||||||
and with the following additions to the disclaimer:
|
and with the following additions to the disclaimer:
|
||||||
@ -36,17 +30,17 @@ and with the following additions to the disclaimer:
|
|||||||
the user.
|
the user.
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||||
distributed according to the same disclaimer and license as libpng-0.96,
|
to the same disclaimer and license as libpng-0.96, with the following
|
||||||
with the following individuals added to the list of Contributing Authors:
|
individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
Tom Lane
|
Tom Lane
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
Willem van Schaik
|
Willem van Schaik
|
||||||
|
|
||||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
distributed according to the same disclaimer and license as libpng-0.88,
|
||||||
with the following individuals added to the list of Contributing Authors:
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
John Bowler
|
John Bowler
|
||||||
@ -57,7 +51,7 @@ with the following individuals added to the list of Contributing Authors:
|
|||||||
Tom Tanner
|
Tom Tanner
|
||||||
|
|
||||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
|
||||||
For the purposes of this copyright and license, "Contributing Authors"
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
is defined as the following set of individuals:
|
is defined as the following set of individuals:
|
||||||
@ -80,13 +74,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
|
|||||||
source code, or portions hereof, for any purpose, without fee, subject
|
source code, or portions hereof, for any purpose, without fee, subject
|
||||||
to the following restrictions:
|
to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this source code must not be misrepresented.
|
1. The origin of this source code must not be misrepresented.
|
||||||
|
|
||||||
2. Altered versions must be plainly marked as such and must not
|
2. Altered versions must be plainly marked as such and must not
|
||||||
be misrepresented as being the original source.
|
be misrepresented as being the original source.
|
||||||
|
|
||||||
3. This Copyright notice may not be removed or altered from any
|
3. This Copyright notice may not be removed or altered from any
|
||||||
source or altered source distribution.
|
source or altered source distribution.
|
||||||
|
|
||||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
fee, and encourage the use of this source code as a component to
|
fee, and encourage the use of this source code as a component to
|
||||||
@ -94,18 +88,18 @@ supporting the PNG file format in commercial products. If you use this
|
|||||||
source code in a product, acknowledgment is not required but would be
|
source code in a product, acknowledgment is not required but would be
|
||||||
appreciated.
|
appreciated.
|
||||||
|
|
||||||
|
|
||||||
A "png_get_copyright" function is available, for convenient use in "about"
|
A "png_get_copyright" function is available, for convenient use in "about"
|
||||||
boxes and the like:
|
boxes and the like:
|
||||||
|
|
||||||
printf("%s",png_get_copyright(NULL));
|
printf("%s", png_get_copyright(NULL));
|
||||||
|
|
||||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||||
|
|
||||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||||
certification mark of the Open Source Initiative.
|
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||||
|
the additional disclaimers inserted at version 1.0.7.
|
||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
May 9, 2015
|
July 13, 2015
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
libpng.txt - A description on how to use and modify libpng
|
libpng.txt - A description on how to use and modify libpng
|
||||||
|
|
||||||
libpng version 1.2.54beta01 - May 9, 2015
|
libpng version 1.2.54beta01 - July 13, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<glennrp at users.sourceforge.net>
|
<glennrp at users.sourceforge.net>
|
||||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||||
@ -11,7 +11,7 @@ libpng.txt - A description on how to use and modify libpng
|
|||||||
|
|
||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.2.54beta01 - May 9, 2015
|
libpng versions 0.97, January 1998, through 1.2.54beta01 - July 13, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||||
|
|
||||||
@ -2757,41 +2757,6 @@ is called for the first time.)
|
|||||||
same as the value of filter_method used
|
same as the value of filter_method used
|
||||||
in png_set_IHDR().
|
in png_set_IHDR().
|
||||||
|
|
||||||
It is also possible to influence how libpng chooses from among the
|
|
||||||
available filters. This is done in one or both of two ways - by
|
|
||||||
telling it how important it is to keep the same filter for successive
|
|
||||||
rows, and by telling it the relative computational costs of the filters.
|
|
||||||
|
|
||||||
double weights[3] = {1.5, 1.3, 1.1},
|
|
||||||
costs[PNG_FILTER_VALUE_LAST] =
|
|
||||||
{1.0, 1.3, 1.3, 1.5, 1.7};
|
|
||||||
|
|
||||||
png_set_filter_heuristics(png_ptr,
|
|
||||||
PNG_FILTER_HEURISTIC_WEIGHTED, 3,
|
|
||||||
weights, costs);
|
|
||||||
|
|
||||||
The weights are multiplying factors that indicate to libpng that the
|
|
||||||
row filter should be the same for successive rows unless another row filter
|
|
||||||
is that many times better than the previous filter. In the above example,
|
|
||||||
if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
|
|
||||||
"sum of absolute differences" 1.5 x 1.3 times higher than other filters
|
|
||||||
and still be chosen, while the NONE filter could have a sum 1.1 times
|
|
||||||
higher than other filters and still be chosen. Unspecified weights are
|
|
||||||
taken to be 1.0, and the specified weights should probably be declining
|
|
||||||
like those above in order to emphasize recent filters over older filters.
|
|
||||||
|
|
||||||
The filter costs specify for each filter type a relative decoding cost
|
|
||||||
to be considered when selecting row filters. This means that filters
|
|
||||||
with higher costs are less likely to be chosen over filters with lower
|
|
||||||
costs, unless their "sum of absolute differences" is that much smaller.
|
|
||||||
The costs do not necessarily reflect the exact computational speeds of
|
|
||||||
the various filters, since this would unduly influence the final image
|
|
||||||
size.
|
|
||||||
|
|
||||||
Note that the numbers above were invented purely for this example and
|
|
||||||
are given only to help explain the function usage. Little testing has
|
|
||||||
been done to find optimum values for either the costs or the weights.
|
|
||||||
|
|
||||||
Removing unwanted object code
|
Removing unwanted object code
|
||||||
|
|
||||||
There are a bunch of #define's in pngconf.h that control what parts of
|
There are a bunch of #define's in pngconf.h that control what parts of
|
||||||
@ -3183,7 +3148,7 @@ Other rules can be inferred by inspecting the libpng source.
|
|||||||
|
|
||||||
XIII. Y2K Compliance in libpng
|
XIII. Y2K Compliance in libpng
|
||||||
|
|
||||||
May 9, 2015
|
July 13, 2015
|
||||||
|
|
||||||
Since the PNG Development group is an ad-hoc body, we can't make
|
Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
an official declaration.
|
an official declaration.
|
||||||
|
147
libpng.3
147
libpng.3
@ -1,4 +1,4 @@
|
|||||||
.TH LIBPNG 3 "May 9, 2015"
|
.TH LIBPNG 3 "July 13, 2015"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.54beta01
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.54beta01
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -410,7 +410,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
|
|||||||
.SH LIBPNG.TXT
|
.SH LIBPNG.TXT
|
||||||
libpng.txt - A description on how to use and modify libpng
|
libpng.txt - A description on how to use and modify libpng
|
||||||
|
|
||||||
libpng version 1.2.54beta01 - May 9, 2015
|
libpng version 1.2.54beta01 - July 13, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<glennrp at users.sourceforge.net>
|
<glennrp at users.sourceforge.net>
|
||||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||||
@ -421,7 +421,7 @@ libpng.txt - A description on how to use and modify libpng
|
|||||||
|
|
||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.2.54beta01 - May 9, 2015
|
libpng versions 0.97, January 1998, through 1.2.54beta01 - July 13, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||||
|
|
||||||
@ -3167,41 +3167,6 @@ is called for the first time.)
|
|||||||
same as the value of filter_method used
|
same as the value of filter_method used
|
||||||
in png_set_IHDR().
|
in png_set_IHDR().
|
||||||
|
|
||||||
It is also possible to influence how libpng chooses from among the
|
|
||||||
available filters. This is done in one or both of two ways - by
|
|
||||||
telling it how important it is to keep the same filter for successive
|
|
||||||
rows, and by telling it the relative computational costs of the filters.
|
|
||||||
|
|
||||||
double weights[3] = {1.5, 1.3, 1.1},
|
|
||||||
costs[PNG_FILTER_VALUE_LAST] =
|
|
||||||
{1.0, 1.3, 1.3, 1.5, 1.7};
|
|
||||||
|
|
||||||
png_set_filter_heuristics(png_ptr,
|
|
||||||
PNG_FILTER_HEURISTIC_WEIGHTED, 3,
|
|
||||||
weights, costs);
|
|
||||||
|
|
||||||
The weights are multiplying factors that indicate to libpng that the
|
|
||||||
row filter should be the same for successive rows unless another row filter
|
|
||||||
is that many times better than the previous filter. In the above example,
|
|
||||||
if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
|
|
||||||
"sum of absolute differences" 1.5 x 1.3 times higher than other filters
|
|
||||||
and still be chosen, while the NONE filter could have a sum 1.1 times
|
|
||||||
higher than other filters and still be chosen. Unspecified weights are
|
|
||||||
taken to be 1.0, and the specified weights should probably be declining
|
|
||||||
like those above in order to emphasize recent filters over older filters.
|
|
||||||
|
|
||||||
The filter costs specify for each filter type a relative decoding cost
|
|
||||||
to be considered when selecting row filters. This means that filters
|
|
||||||
with higher costs are less likely to be chosen over filters with lower
|
|
||||||
costs, unless their "sum of absolute differences" is that much smaller.
|
|
||||||
The costs do not necessarily reflect the exact computational speeds of
|
|
||||||
the various filters, since this would unduly influence the final image
|
|
||||||
size.
|
|
||||||
|
|
||||||
Note that the numbers above were invented purely for this example and
|
|
||||||
are given only to help explain the function usage. Little testing has
|
|
||||||
been done to find optimum values for either the costs or the weights.
|
|
||||||
|
|
||||||
.SS Removing unwanted object code
|
.SS Removing unwanted object code
|
||||||
|
|
||||||
There are a bunch of #define's in pngconf.h that control what parts of
|
There are a bunch of #define's in pngconf.h that control what parts of
|
||||||
@ -3593,7 +3558,7 @@ Other rules can be inferred by inspecting the libpng source.
|
|||||||
|
|
||||||
.SH XIII. Y2K Compliance in libpng
|
.SH XIII. Y2K Compliance in libpng
|
||||||
|
|
||||||
May 9, 2015
|
July 13, 2015
|
||||||
|
|
||||||
Since the PNG Development group is an ad-hoc body, we can't make
|
Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
an official declaration.
|
an official declaration.
|
||||||
@ -3990,7 +3955,7 @@ possible without all of you.
|
|||||||
|
|
||||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||||
|
|
||||||
Libpng version 1.2.54beta01 - May 9, 2015:
|
Libpng version 1.2.54beta01 - July 13, 2015:
|
||||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||||
|
|
||||||
@ -4013,106 +3978,8 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.2.6, August 15, 2004, through 1.2.54beta01, May 9, 2015, are
|
libpng versions 1.0.7, July 1, 2000, through 1.2.54beta01, July 13, 2015, are
|
||||||
Copyright (c) 2004,2006-2015 Glenn Randers-Pehrson, and are
|
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
|
||||||
with the following individual added to the list of Contributing Authors
|
|
||||||
|
|
||||||
Cosmin Truta
|
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
|
||||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
|
||||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
with the following individuals added to the list of Contributing Authors
|
|
||||||
|
|
||||||
Simon-Pierre Cadieux
|
|
||||||
Eric S. Raymond
|
|
||||||
Gilles Vollant
|
|
||||||
|
|
||||||
and with the following additions to the disclaimer:
|
|
||||||
|
|
||||||
There is no warranty against interference with your
|
|
||||||
enjoyment of the library or against infringement.
|
|
||||||
There is no warranty that our efforts or the library
|
|
||||||
will fulfill any of your particular purposes or needs.
|
|
||||||
This library is provided with all faults, and the entire
|
|
||||||
risk of satisfactory quality, performance, accuracy, and
|
|
||||||
effort is with the user.
|
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
|
||||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
|
||||||
Distributed according to the same disclaimer and license as libpng-0.96,
|
|
||||||
with the following individuals added to the list of Contributing Authors:
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
Tom Lane
|
|
||||||
Glenn Randers-Pehrson
|
|
||||||
Willem van Schaik
|
|
||||||
|
|
||||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
|
||||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
|
||||||
with the following individuals added to the list of Contributing Authors:
|
|
||||||
|
|
||||||
John Bowler
|
|
||||||
Kevin Bracey
|
|
||||||
Sam Bushell
|
|
||||||
Magnus Holmgren
|
|
||||||
Greg Roelofs
|
|
||||||
Tom Tanner
|
|
||||||
|
|
||||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
|
||||||
|
|
||||||
For the purposes of this copyright and license, "Contributing Authors"
|
|
||||||
is defined as the following set of individuals:
|
|
||||||
|
|
||||||
Andreas Dilger
|
|
||||||
Dave Martindale
|
|
||||||
Guy Eric Schalnat
|
|
||||||
Paul Schmidt
|
|
||||||
Tim Wegner
|
|
||||||
|
|
||||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
|
||||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
|
||||||
including, without limitation, the warranties of merchantability and of
|
|
||||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
|
||||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
|
||||||
or consequential damages, which may result from the use of the PNG
|
|
||||||
Reference Library, even if advised of the possibility of such damage.
|
|
||||||
|
|
||||||
Permission is hereby granted to use, copy, modify, and distribute this
|
|
||||||
source code, or portions hereof, for any purpose, without fee, subject
|
|
||||||
to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this source code must not be misrepresented.
|
|
||||||
|
|
||||||
2. Altered versions must be plainly marked as such and
|
|
||||||
must not be misrepresented as being the original source.
|
|
||||||
|
|
||||||
3. This Copyright notice may not be removed or altered from
|
|
||||||
any source or altered source distribution.
|
|
||||||
|
|
||||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
|
||||||
fee, and encourage the use of this source code as a component to
|
|
||||||
supporting the PNG file format in commercial products. If you use this
|
|
||||||
source code in a product, acknowledgment is not required but would be
|
|
||||||
appreciated.
|
|
||||||
|
|
||||||
|
|
||||||
A "png_get_copyright" function is available, for convenient use in "about"
|
|
||||||
boxes and the like:
|
|
||||||
|
|
||||||
printf("%s",png_get_copyright(NULL));
|
|
||||||
|
|
||||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
|
||||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
|
||||||
|
|
||||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
|
||||||
certification mark of the Open Source Initiative.
|
|
||||||
|
|
||||||
Glenn Randers-Pehrson
|
|
||||||
glennrp at users.sourceforge.net
|
|
||||||
May 9, 2015
|
|
||||||
|
|
||||||
.\" end of man page
|
|
||||||
|
|
||||||
|
93
png.h
93
png.h
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.2.54beta01, May 9, 2015
|
* libpng version 1.2.54beta01, July 13, 2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@ -12,7 +12,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.2.54beta01, May 9, 2015: Glenn
|
* libpng versions 0.97, January 1998, through 1.2.54beta01, July 13, 2015: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
* Note about libpng version numbers:
|
* Note about libpng version numbers:
|
||||||
@ -330,20 +330,14 @@
|
|||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* libpng versions 1.2.6, August 15, 2004, through 1.2.54beta01, May 9, 2015, are
|
* libpng versions 1.0.7, July 1, 2000, through 1.2.54beta01, July 13, 2015, are
|
||||||
* Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
|
||||||
* with the following individual added to the list of Contributing Authors:
|
|
||||||
*
|
|
||||||
* Cosmin Truta
|
|
||||||
*
|
|
||||||
* libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
|
|
||||||
* Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
|
||||||
* distributed according to the same disclaimer and license as libpng-1.0.6
|
* distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
* with the following individuals added to the list of Contributing Authors:
|
* with the following individuals added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
* Simon-Pierre Cadieux
|
* Simon-Pierre Cadieux
|
||||||
* Eric S. Raymond
|
* Eric S. Raymond
|
||||||
|
* Cosmin Truta
|
||||||
* Gilles Vollant
|
* Gilles Vollant
|
||||||
*
|
*
|
||||||
* and with the following additions to the disclaimer:
|
* and with the following additions to the disclaimer:
|
||||||
@ -356,17 +350,17 @@
|
|||||||
* the user.
|
* the user.
|
||||||
*
|
*
|
||||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
|
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||||
* distributed according to the same disclaimer and license as libpng-0.96,
|
* to the same disclaimer and license as libpng-0.96, with the following
|
||||||
* with the following individuals added to the list of Contributing Authors:
|
* individuals added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
* Tom Lane
|
* Tom Lane
|
||||||
* Glenn Randers-Pehrson
|
* Glenn Randers-Pehrson
|
||||||
* Willem van Schaik
|
* Willem van Schaik
|
||||||
*
|
*
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||||
* Distributed according to the same disclaimer and license as libpng-0.88,
|
* distributed according to the same disclaimer and license as libpng-0.88,
|
||||||
* with the following individuals added to the list of Contributing Authors:
|
* with the following individuals added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
* John Bowler
|
* John Bowler
|
||||||
@ -377,7 +371,7 @@
|
|||||||
* Tom Tanner
|
* Tom Tanner
|
||||||
*
|
*
|
||||||
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
*
|
*
|
||||||
* For the purposes of this copyright and license, "Contributing Authors"
|
* For the purposes of this copyright and license, "Contributing Authors"
|
||||||
* is defined as the following set of individuals:
|
* is defined as the following set of individuals:
|
||||||
@ -400,13 +394,13 @@
|
|||||||
* source code, or portions hereof, for any purpose, without fee, subject
|
* source code, or portions hereof, for any purpose, without fee, subject
|
||||||
* to the following restrictions:
|
* to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this source code must not be misrepresented.
|
* 1. The origin of this source code must not be misrepresented.
|
||||||
*
|
*
|
||||||
* 2. Altered versions must be plainly marked as such and
|
* 2. Altered versions must be plainly marked as such and must not
|
||||||
* must not be misrepresented as being the original source.
|
* be misrepresented as being the original source.
|
||||||
*
|
*
|
||||||
* 3. This Copyright notice may not be removed or altered from
|
* 3. This Copyright notice may not be removed or altered from any
|
||||||
* any source or altered source distribution.
|
* source or altered source distribution.
|
||||||
*
|
*
|
||||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
* fee, and encourage the use of this source code as a component to
|
* fee, and encourage the use of this source code as a component to
|
||||||
@ -419,15 +413,16 @@
|
|||||||
* A "png_get_copyright" function is available, for convenient use in "about"
|
* A "png_get_copyright" function is available, for convenient use in "about"
|
||||||
* boxes and the like:
|
* boxes and the like:
|
||||||
*
|
*
|
||||||
* printf("%s",png_get_copyright(NULL));
|
* printf("%s", png_get_copyright(NULL));
|
||||||
*
|
*
|
||||||
* Also, the PNG logo (in PNG format, of course) is supplied in the
|
* Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||||
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Libpng is OSI Certified Open Source Software. OSI Certified is a
|
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||||
* certification mark of the Open Source Initiative.
|
* a certification mark of the Open Source Initiative. OSI has not addressed
|
||||||
|
* the additional disclaimers inserted at version 1.0.7.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -442,7 +437,7 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* May 9, 2015
|
* July 13, 2015
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
@ -506,7 +501,7 @@
|
|||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.2.54beta01"
|
#define PNG_LIBPNG_VER_STRING "1.2.54beta01"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.2.54beta01 - May 9, 2015\n"
|
" libpng version 1.2.54beta01 - July 13, 2015\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 0
|
#define PNG_LIBPNG_VER_SONUM 0
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 13
|
#define PNG_LIBPNG_VER_DLLNUM 13
|
||||||
@ -1460,16 +1455,6 @@ struct png_struct_def
|
|||||||
png_uint_16p hist PNG_DEPSTRUCT; /* histogram */
|
png_uint_16p hist PNG_DEPSTRUCT; /* histogram */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
png_byte heuristic_method PNG_DEPSTRUCT; /* heuristic for row filter selection */
|
|
||||||
png_byte num_prev_filters PNG_DEPSTRUCT; /* number of weights for previous rows */
|
|
||||||
png_bytep prev_filters PNG_DEPSTRUCT; /* filter type(s) of previous row(s) */
|
|
||||||
png_uint_16p filter_weights PNG_DEPSTRUCT; /* weight(s) for previous line(s) */
|
|
||||||
png_uint_16p inv_filter_weights PNG_DEPSTRUCT; /* 1/weight(s) for previous line(s) */
|
|
||||||
png_uint_16p filter_costs PNG_DEPSTRUCT; /* relative filter calculation cost */
|
|
||||||
png_uint_16p inv_filter_costs PNG_DEPSTRUCT; /* 1/relative filter calculation cost */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||||
png_charp time_buffer PNG_DEPSTRUCT; /* String to hold RFC 1123 time text */
|
png_charp time_buffer PNG_DEPSTRUCT; /* String to hold RFC 1123 time text */
|
||||||
#endif
|
#endif
|
||||||
@ -1985,35 +1970,7 @@ extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
|
|||||||
#define PNG_FILTER_VALUE_PAETH 4
|
#define PNG_FILTER_VALUE_PAETH 4
|
||||||
#define PNG_FILTER_VALUE_LAST 5
|
#define PNG_FILTER_VALUE_LAST 5
|
||||||
|
|
||||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
|
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* DEPRECATED */
|
||||||
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
|
|
||||||
* defines, either the default (minimum-sum-of-absolute-differences), or
|
|
||||||
* the experimental method (weighted-minimum-sum-of-absolute-differences).
|
|
||||||
*
|
|
||||||
* Weights are factors >= 1.0, indicating how important it is to keep the
|
|
||||||
* filter type consistent between rows. Larger numbers mean the current
|
|
||||||
* filter is that many times as likely to be the same as the "num_weights"
|
|
||||||
* previous filters. This is cumulative for each previous row with a weight.
|
|
||||||
* There needs to be "num_weights" values in "filter_weights", or it can be
|
|
||||||
* NULL if the weights aren't being specified. Weights have no influence on
|
|
||||||
* the selection of the first row filter. Well chosen weights can (in theory)
|
|
||||||
* improve the compression for a given image.
|
|
||||||
*
|
|
||||||
* Costs are factors >= 1.0 indicating the relative decoding costs of a
|
|
||||||
* filter type. Higher costs indicate more decoding expense, and are
|
|
||||||
* therefore less likely to be selected over a filter with lower computational
|
|
||||||
* costs. There needs to be a value in "filter_costs" for each valid filter
|
|
||||||
* type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
|
|
||||||
* setting the costs. Costs try to improve the speed of decompression without
|
|
||||||
* unduly increasing the compressed image size.
|
|
||||||
*
|
|
||||||
* A negative weight or cost indicates the default value is to be used, and
|
|
||||||
* values in the range [0.0, 1.0) indicate the value is to remain unchanged.
|
|
||||||
* The default values for both weights and costs are currently 1.0, but may
|
|
||||||
* change if good general weighting/cost heuristics can be found. If both
|
|
||||||
* the weights and costs are set to 1.0, this degenerates the WEIGHTED method
|
|
||||||
* to the UNWEIGHTED method, but with added encoding time/computation.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
|
||||||
int heuristic_method, int num_weights, png_doublep filter_weights,
|
int heuristic_method, int num_weights, png_doublep filter_weights,
|
||||||
@ -2021,9 +1978,7 @@ extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
|
|||||||
#endif
|
#endif
|
||||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||||
|
|
||||||
/* Heuristic used for row filter selection. These defines should NOT be
|
/* The following are no longer used and will be removed from libpng-1.7: */
|
||||||
* changed.
|
|
||||||
*/
|
|
||||||
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
|
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
|
||||||
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
|
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
|
||||||
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
||||||
|
133
pngwrite.c
133
pngwrite.c
@ -584,11 +584,6 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
|
png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
|
||||||
png_flush_ptr_NULL);
|
png_flush_ptr_NULL);
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
|
|
||||||
1, png_doublep_NULL, png_doublep_NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* Applications that neglect to set up their own setjmp() and then
|
/* Applications that neglect to set up their own setjmp() and then
|
||||||
* encounter a png_error() will longjmp here. Since the jmpbuf is
|
* encounter a png_error() will longjmp here. Since the jmpbuf is
|
||||||
@ -731,10 +726,6 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)png_ptr->zbuf_size);
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
|
|
||||||
1, png_doublep_NULL, png_doublep_NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a few rows of image data. If the image is interlaced,
|
/* Write a few rows of image data. If the image is interlaced,
|
||||||
@ -1150,14 +1141,6 @@ png_write_destroy(png_structp png_ptr)
|
|||||||
png_free(png_ptr, png_ptr->time_buffer);
|
png_free(png_ptr, png_ptr->time_buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
png_free(png_ptr, png_ptr->prev_filters);
|
|
||||||
png_free(png_ptr, png_ptr->filter_weights);
|
|
||||||
png_free(png_ptr, png_ptr->inv_filter_weights);
|
|
||||||
png_free(png_ptr, png_ptr->filter_costs);
|
|
||||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* Reset structure */
|
/* Reset structure */
|
||||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||||
@ -1310,117 +1293,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
|||||||
int num_weights, png_doublep filter_weights,
|
int num_weights, png_doublep filter_weights,
|
||||||
png_doublep filter_costs)
|
png_doublep filter_costs)
|
||||||
{
|
{
|
||||||
int i;
|
PNG_UNUSED(png_ptr)
|
||||||
|
PNG_UNUSED(heuristic_method)
|
||||||
png_debug(1, "in png_set_filter_heuristics");
|
PNG_UNUSED(num_weights)
|
||||||
|
PNG_UNUSED(filter_weights)
|
||||||
if (png_ptr == NULL)
|
PNG_UNUSED(filter_costs)
|
||||||
return;
|
|
||||||
if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST)
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Unknown filter heuristic method");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT)
|
|
||||||
{
|
|
||||||
heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_weights < 0 || filter_weights == NULL ||
|
|
||||||
heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED)
|
|
||||||
{
|
|
||||||
num_weights = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->num_prev_filters = (png_byte)num_weights;
|
|
||||||
png_ptr->heuristic_method = (png_byte)heuristic_method;
|
|
||||||
|
|
||||||
if (num_weights > 0)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters == NULL)
|
|
||||||
{
|
|
||||||
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)(png_sizeof(png_byte) * num_weights));
|
|
||||||
|
|
||||||
/* To make sure that the weighting starts out fairly */
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
png_ptr->prev_filters[i] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (png_ptr->filter_weights == NULL)
|
|
||||||
{
|
|
||||||
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)(png_sizeof(png_uint_16) * num_weights));
|
|
||||||
|
|
||||||
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)(png_sizeof(png_uint_16) * num_weights));
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
if (filter_weights[i] < 0.0)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
(png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5);
|
|
||||||
png_ptr->filter_weights[i] =
|
|
||||||
(png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If, in the future, there are other filter methods, this would
|
|
||||||
* need to be based on png_ptr->filter.
|
|
||||||
*/
|
|
||||||
if (png_ptr->filter_costs == NULL)
|
|
||||||
{
|
|
||||||
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
|
||||||
|
|
||||||
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
|
||||||
|
|
||||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_costs[i] =
|
|
||||||
png_ptr->filter_costs[i] = PNG_COST_FACTOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Here is where we set the relative costs of the different filters. We
|
|
||||||
* should take the desired compression level into account when setting
|
|
||||||
* the costs, so that Paeth, for instance, has a high relative cost at low
|
|
||||||
* compression levels, while it has a lower relative cost at higher
|
|
||||||
* compression settings. The filter types are in order of increasing
|
|
||||||
* relative cost, so it would be possible to do this with an algorithm.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
|
||||||
{
|
|
||||||
if (filter_costs == NULL || filter_costs[i] < 0.0)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_costs[i] =
|
|
||||||
png_ptr->filter_costs[i] = PNG_COST_FACTOR;
|
|
||||||
}
|
|
||||||
else if (filter_costs[i] >= 1.0)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_costs[i] =
|
|
||||||
(png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5);
|
|
||||||
png_ptr->filter_costs[i] =
|
|
||||||
(png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||||
|
|
||||||
|
314
pngwutil.c
314
pngwutil.c
@ -2156,20 +2156,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
png_uint_32 mins, bpp;
|
png_uint_32 mins, bpp;
|
||||||
png_byte filter_to_do = png_ptr->do_filter;
|
png_byte filter_to_do = png_ptr->do_filter;
|
||||||
png_uint_32 row_bytes = row_info->rowbytes;
|
png_uint_32 row_bytes = row_info->rowbytes;
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
int num_p_filters = (int)png_ptr->num_prev_filters;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
png_debug(1, "in png_write_find_filter");
|
png_debug(1, "in png_write_find_filter");
|
||||||
|
|
||||||
#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS)
|
|
||||||
{
|
|
||||||
/* These will never be selected so we need not test them. */
|
|
||||||
filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Find out how many bytes offset each pixel is */
|
/* Find out how many bytes offset each pixel is */
|
||||||
bpp = (row_info->pixel_depth + 7) >> 3;
|
bpp = (row_info->pixel_depth + 7) >> 3;
|
||||||
|
|
||||||
@ -2219,41 +2208,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
png_uint_32 sumhi, sumlo;
|
|
||||||
int j;
|
|
||||||
sumlo = sum & PNG_LOMASK;
|
|
||||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */
|
|
||||||
|
|
||||||
/* Reduce the sum if we match any of the previous rows */
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
|
|
||||||
{
|
|
||||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Factor in the cost of this filter (this is here for completeness,
|
|
||||||
* but it makes no sense to have a "cost" for the NONE filter, as
|
|
||||||
* it has the minimum possible computational cost - none).
|
|
||||||
*/
|
|
||||||
sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (sumhi > PNG_HIMASK)
|
|
||||||
sum = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
sum = (sumhi << PNG_HISHIFT) + sumlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
mins = sum;
|
mins = sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2283,41 +2237,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
/* We temporarily increase the "minimum sum" by the factor we
|
|
||||||
* would reduce the sum of this filter, so that we can do the
|
|
||||||
* early exit comparison without scaling the sum each time.
|
|
||||||
*/
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 lmhi, lmlo;
|
|
||||||
lmlo = lmins & PNG_LOMASK;
|
|
||||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
|
|
||||||
{
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (lmhi > PNG_HIMASK)
|
|
||||||
lmins = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
lmins = (lmhi << PNG_HISHIFT) + lmlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
|
for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
|
||||||
i++, rp++, dp++)
|
i++, rp++, dp++)
|
||||||
{
|
{
|
||||||
@ -2336,37 +2255,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 sumhi, sumlo;
|
|
||||||
sumlo = sum & PNG_LOMASK;
|
|
||||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
|
|
||||||
{
|
|
||||||
sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (sumhi > PNG_HIMASK)
|
|
||||||
sum = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
sum = (sumhi << PNG_HISHIFT) + sumlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sum < mins)
|
if (sum < mins)
|
||||||
{
|
{
|
||||||
mins = sum;
|
mins = sum;
|
||||||
@ -2396,38 +2284,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 lmhi, lmlo;
|
|
||||||
lmlo = lmins & PNG_LOMASK;
|
|
||||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
|
|
||||||
{
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (lmhi > PNG_HIMASK)
|
|
||||||
lmins = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
lmins = (lmhi << PNG_HISHIFT) + lmlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
|
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
|
||||||
pp = prev_row + 1; i < row_bytes; i++)
|
pp = prev_row + 1; i < row_bytes; i++)
|
||||||
{
|
{
|
||||||
@ -2439,37 +2295,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 sumhi, sumlo;
|
|
||||||
sumlo = sum & PNG_LOMASK;
|
|
||||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
|
|
||||||
{
|
|
||||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (sumhi > PNG_HIMASK)
|
|
||||||
sum = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
sum = (sumhi << PNG_HISHIFT) + sumlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sum < mins)
|
if (sum < mins)
|
||||||
{
|
{
|
||||||
mins = sum;
|
mins = sum;
|
||||||
@ -2502,37 +2327,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 lmhi, lmlo;
|
|
||||||
lmlo = lmins & PNG_LOMASK;
|
|
||||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)
|
|
||||||
{
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (lmhi > PNG_HIMASK)
|
|
||||||
lmins = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
lmins = (lmhi << PNG_HISHIFT) + lmlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
|
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
|
||||||
pp = prev_row + 1; i < bpp; i++)
|
pp = prev_row + 1; i < bpp; i++)
|
||||||
{
|
{
|
||||||
@ -2551,37 +2345,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 sumhi, sumlo;
|
|
||||||
sumlo = sum & PNG_LOMASK;
|
|
||||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
|
|
||||||
{
|
|
||||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (sumhi > PNG_HIMASK)
|
|
||||||
sum = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
sum = (sumhi << PNG_HISHIFT) + sumlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sum < mins)
|
if (sum < mins)
|
||||||
{
|
{
|
||||||
mins = sum;
|
mins = sum;
|
||||||
@ -2635,37 +2398,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 lmhi, lmlo;
|
|
||||||
lmlo = lmins & PNG_LOMASK;
|
|
||||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
|
|
||||||
{
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (lmhi > PNG_HIMASK)
|
|
||||||
lmins = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
lmins = (lmhi << PNG_HISHIFT) + lmlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
|
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
|
||||||
pp = prev_row + 1; i < bpp; i++)
|
pp = prev_row + 1; i < bpp; i++)
|
||||||
{
|
{
|
||||||
@ -2716,37 +2448,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
png_uint_32 sumhi, sumlo;
|
|
||||||
sumlo = sum & PNG_LOMASK;
|
|
||||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
|
||||||
|
|
||||||
for (j = 0; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
|
|
||||||
{
|
|
||||||
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
|
|
||||||
PNG_WEIGHT_SHIFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>
|
|
||||||
PNG_COST_SHIFT;
|
|
||||||
|
|
||||||
if (sumhi > PNG_HIMASK)
|
|
||||||
sum = PNG_MAXSUM;
|
|
||||||
else
|
|
||||||
sum = (sumhi << PNG_HISHIFT) + sumlo;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sum < mins)
|
if (sum < mins)
|
||||||
{
|
{
|
||||||
best_row = png_ptr->paeth_row;
|
best_row = png_ptr->paeth_row;
|
||||||
@ -2756,21 +2457,6 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
/* Do the actual writing of the filtered row data from the chosen filter. */
|
/* Do the actual writing of the filtered row data from the chosen filter. */
|
||||||
|
|
||||||
png_write_filtered_row(png_ptr, best_row);
|
png_write_filtered_row(png_ptr, best_row);
|
||||||
|
|
||||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
/* Save the type of filter we picked this time for future calculations */
|
|
||||||
if (png_ptr->num_prev_filters > 0)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
for (j = 1; j < num_p_filters; j++)
|
|
||||||
{
|
|
||||||
png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];
|
|
||||||
}
|
|
||||||
png_ptr->prev_filters[j] = best_row[0];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user