Skip to content

Commit

Permalink
api! Remove the stub functions png_set_filter_heuristics, etc.
Browse files Browse the repository at this point in the history
The old experiment with delta-filtering heuristics did not work out
as expected. Eventually, the functions `png_set_filter_heuristics`
and `png_set_filter_heuristics_fixed` became no-ops. We are removing
them from libpng-1.8.

Signed-off-by: Cosmin Truta <[email protected]>
  • Loading branch information
ctruta committed Sep 25, 2024
1 parent bd09503 commit d596351
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 67 deletions.
4 changes: 0 additions & 4 deletions manuals/libpng.3
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.44

\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP

\fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP

\fBvoid png_set_filter_heuristics_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_fixed_point_p \fP\fIfilter_weights\fP\fB, png_fixed_point_p \fIfilter_costs\fP\fB);\fP

\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP

\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP
Expand Down
24 changes: 8 additions & 16 deletions png.h
Original file line number Diff line number Diff line change
Expand Up @@ -1474,22 +1474,6 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
#define PNG_FILTER_VALUE_LAST 5

#ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
int heuristic_method, int num_weights, png_const_doublep filter_weights,
png_const_doublep filter_costs))
PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
(png_structrp png_ptr, int heuristic_method, int num_weights,
png_const_fixed_point_p filter_weights,
png_const_fixed_point_p filter_costs))
#endif /* WRITE_WEIGHTED_FILTER */

/* The following are no longer used and will be removed from libpng-1.7: */
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */

/* Set the library compression level. Currently, valid values range from
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9
* (0 - no compression, 9 - "maximal" compression). Note that tests have
Expand Down Expand Up @@ -1537,6 +1521,14 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits,
PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
int method));
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */

PNG_REMOVED(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
int heuristic_method, int num_weights, png_const_doublep filter_weights,
png_const_doublep filter_costs),PNG_DEPRECATED)
PNG_REMOVED(209, void, png_set_filter_heuristics_fixed,
(png_structrp png_ptr, int heuristic_method, int num_weights,
png_const_fixed_point_p filter_weights,
png_const_fixed_point_p filter_costs),PNG_DEPRECATED)
#endif /* WRITE */

/* These next functions are called for input/output, memory, and error
Expand Down
12 changes: 6 additions & 6 deletions pngtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,12 +1696,12 @@ test_one_file(const char *inname, const char *outname)
{
fprintf(STDERR,
" Was %s written with the same maximum IDAT"
" chunk size (%d bytes),",
" chunk size (%d bytes),\n",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
"\n filtering heuristic (libpng default), compression");
" compression level (zlib default),\n");
fprintf(STDERR,
" level (zlib default),\n and zlib version (%s)?\n\n",
" and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
Expand All @@ -1728,12 +1728,12 @@ test_one_file(const char *inname, const char *outname)
{
fprintf(STDERR,
" Was %s written with the same maximum"
" IDAT chunk size (%d bytes),",
" IDAT chunk size (%d bytes),\n",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
"\n filtering heuristic (libpng default), compression");
" compression level (zlib default),\n");
fprintf(STDERR,
" level (zlib default),\n and zlib version (%s)?\n\n",
" and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
Expand Down
31 changes: 0 additions & 31 deletions pngwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,37 +1137,6 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
png_error(png_ptr, "Unknown custom filter method");
}

#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
/* Provide floating and fixed point APIs */
#ifdef PNG_FLOATING_POINT_SUPPORTED
void PNGAPI
png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
int num_weights, png_const_doublep filter_weights,
png_const_doublep filter_costs)
{
PNG_UNUSED(png_ptr)
PNG_UNUSED(heuristic_method)
PNG_UNUSED(num_weights)
PNG_UNUSED(filter_weights)
PNG_UNUSED(filter_costs)
}
#endif /* FLOATING_POINT */

#ifdef PNG_FIXED_POINT_SUPPORTED
void PNGAPI
png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
int num_weights, png_const_fixed_point_p filter_weights,
png_const_fixed_point_p filter_costs)
{
PNG_UNUSED(png_ptr)
PNG_UNUSED(heuristic_method)
PNG_UNUSED(num_weights)
PNG_UNUSED(filter_weights)
PNG_UNUSED(filter_costs)
}
#endif /* FIXED_POINT */
#endif /* WRITE_WEIGHTED_FILTER */

#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
void PNGAPI
png_set_compression_level(png_structrp png_ptr, int level)
Expand Down
9 changes: 4 additions & 5 deletions pngwutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -2573,11 +2573,10 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
* from zero, using anything >= 128 as negative numbers. This is known
* as the "minimum sum of absolute differences" heuristic. Other
* heuristics are the "weighted minimum sum of absolute differences"
* (experimental and can in theory improve compression), and the "zlib
* predictive" method (not implemented yet), which does test compressions
* of lines using different filter methods, and then chooses the
* (series of) filter(s) that give minimum compressed data size (VERY
* computationally expensive).
* method (experimented, then abandoned), and the "zlib predictive" method
* (not implemented yet), which does test compression of lines using
* different filter methods, and then chooses the (series of) filter(s)
* that give minimum compressed data size (VERY computationally expensive).
*
* GRR 980525: consider also
*
Expand Down
2 changes: 0 additions & 2 deletions scripts/pnglibconf.dfa
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,6 @@ option WRITE_USER_TRANSFORM requires WRITE_TRANSFORMS
option WRITE_INTERLACING requires WRITE

# Deprecated, will be removed.
option WRITE_WEIGHTED_FILTER requires WRITE

option WRITE_FLUSH requires WRITE

# Note: these can be turned off explicitly if not required by the
Expand Down
1 change: 0 additions & 1 deletion scripts/pnglibconf.h.prebuilt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_eXIf_SUPPORTED
Expand Down
2 changes: 0 additions & 2 deletions scripts/symbols.def
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ EXPORTS
png_destroy_write_struct @65
png_set_crc_action @66
png_set_filter @67
png_set_filter_heuristics @68
png_set_compression_level @69
png_set_compression_mem_level @70
png_set_compression_strategy @71
Expand Down Expand Up @@ -211,7 +210,6 @@ EXPORTS
png_save_int_32 @206
png_save_uint_16 @207
png_set_gamma_fixed @208
png_set_filter_heuristics_fixed @209
png_get_pixel_aspect_ratio_fixed @210
png_get_x_offset_inches_fixed @211
png_get_y_offset_inches_fixed @212
Expand Down

0 comments on commit d596351

Please sign in to comment.