Re: [PNG] Meeting minutes - Jul 7th, 2025

>Integers must be updated to be more than 31-bit

The definition has been in the spec from the start.  Unfortunately it was
removed from PNG v3 even though signed integers are used in the
extensions.  Here's the definition from PNG v2:

Values are unsigned unless otherwise noted. Values explicitly noted as
> signed are represented in two's complement notation.
> PNG four-byte unsigned integers are limited to the range 0 to 231-1 to
> accommodate languages that have difficulty with unsigned four-byte values.
> Similarly PNG four-byte signed integers are limited to the range -(231-1)
> to 231-1 to accommodate languages that have difficulty with the value -231
> .


@CL: that text can be *massively *simplified:

Values shall be represented in 1, 2 or 4 bytes with the most significant
byte of the value first (MSB).  1 and 2 byte values encode 8 and 16 bit
unsigned integral values.  4 byte values shall be encoded as 2's complement
values limited to the range -(231-1) to 231-1; the encoded value 0x80000000
shall not be used.  Unless explicitly stated in the description of a chunk
value all 4 byte values shall be non-negative, i.e. in the range 0 to 231-1.

That will lead to much better implementations because implementors won't
make mistakes, like "ignoring" the top bit (which one PNG implementation
apparently does.)

In any case this should be an erratum to PNG v3; it was a mistake to remove
the definition of signed integers because it breaks the extensions document:

>
https://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html#DR.Integer-values

Also I do think teaching about byte-stream marshalling in the PNG spec is
out-of-place.  This is such a fundamental bit of computer science and
software engineering both.

John Bowler <jbowler@acm.org>

>

Received on Monday, 7 July 2025 21:48:21 UTC