Filter code change prep.

This commit moves code round and changes the filter write interfaces that took
png_uint_32 buffer pixel counts to unsigned int.  Also moves compression code
and definitions into pngwutil.c so that the compression code is isolated from
other definitions.

Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
John Bowler
2015-11-27 15:42:52 -08:00
parent 14d11b9f35
commit b3a18efebf
7 changed files with 268 additions and 243 deletions

24
png.c
View File

@@ -866,58 +866,58 @@ png_access_version_number(void)
* like Z_OK or Z_STREAM_END where the error code is apparently a success code.
*/
void /* PRIVATE */
png_zstream_error(png_structrp png_ptr, int ret)
png_zstream_error(z_stream *zstream, int ret)
{
/* Translate 'ret' into an appropriate error string, priority is given to the
* one in zstream if set. This always returns a string, even in cases like
* Z_OK or Z_STREAM_END where the error code is a success code.
*/
if (png_ptr->zstream.msg == NULL) switch (ret)
if (zstream->msg == NULL) switch (ret)
{
default:
case Z_OK:
png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return code");
zstream->msg = PNGZ_MSG_CAST("unexpected zlib return code");
break;
case Z_STREAM_END:
/* Normal exit */
png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected end of LZ stream");
zstream->msg = PNGZ_MSG_CAST("unexpected end of LZ stream");
break;
case Z_NEED_DICT:
/* This means the deflate stream did not have a dictionary; this
* indicates a bogus PNG.
*/
png_ptr->zstream.msg = PNGZ_MSG_CAST("missing LZ dictionary");
zstream->msg = PNGZ_MSG_CAST("missing LZ dictionary");
break;
case Z_ERRNO:
/* gz APIs only: should not happen */
png_ptr->zstream.msg = PNGZ_MSG_CAST("zlib IO error");
zstream->msg = PNGZ_MSG_CAST("zlib IO error");
break;
case Z_STREAM_ERROR:
/* internal libpng error */
png_ptr->zstream.msg = PNGZ_MSG_CAST("bad parameters to zlib");
zstream->msg = PNGZ_MSG_CAST("bad parameters to zlib");
break;
case Z_DATA_ERROR:
png_ptr->zstream.msg = PNGZ_MSG_CAST("damaged LZ stream");
zstream->msg = PNGZ_MSG_CAST("damaged LZ stream");
break;
case Z_MEM_ERROR:
png_ptr->zstream.msg = PNGZ_MSG_CAST("insufficient memory");
zstream->msg = PNGZ_MSG_CAST("insufficient memory");
break;
case Z_BUF_ERROR:
/* End of input or output; not a problem if the caller is doing
* incremental read or write.
*/
png_ptr->zstream.msg = PNGZ_MSG_CAST("truncated");
zstream->msg = PNGZ_MSG_CAST("truncated");
break;
case Z_VERSION_ERROR:
png_ptr->zstream.msg = PNGZ_MSG_CAST("unsupported zlib version");
zstream->msg = PNGZ_MSG_CAST("unsupported zlib version");
break;
case PNG_UNEXPECTED_ZLIB_RETURN:
@@ -926,7 +926,7 @@ png_zstream_error(png_structrp png_ptr, int ret)
* and change pngpriv.h. Note that this message is "... return",
* whereas the default/Z_OK one is "... return code".
*/
png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return");
zstream->msg = PNGZ_MSG_CAST("unexpected zlib return");
break;
}
}