The part that says "Pixels within a scanline are always packed into a sequence of bytes with no wasted bits between pixels" is incorrect, because for example, imagine IHDR.color_type == 0 and IHDR.bit_length == 4, and also imagine two pixels: 0b1111 (15) and 0b111 (7), the wording specifies this packing:
Pixel 1 = a
Pixel 2 = b
Pixel 3 = c
byte 0 = aaaabbbc
byte 1 = c[and-so-on]
The wording could be clearer, maybe something like "Pixels within a scanline are always packed into a sequence of bytes with no wasted bits between pixels (although you must take at least IHDR.bit_length number of bits to pack the pixels[or samples, the word "sample" can also be used here, I don't know which one is preferable]. For example, if you have a IHDR.bit_length of 4 and sample value of 7 (0b111), you must still pack the sample in 4 bits)".
You can argue that since the previous paragraph states "The size of each pixel is determined by the number of bits per pixel." then all the previous wording is not necessary, but from personal experience, I can say this is not the case, it is not that obvious, and there is room for an explicit explanation.
The other thing I consider unclear in this section is the format of the bit-stream of the samples. The specification states "These samples are packed into bytes with the leftmost sample in the high-order bits of a byte followed by the other samples for the scanline" and nothing else, meaning that the bit numbering is unspecified:
Which format is it?
Byte 0: aaaabbbb (32103210)
or
Byte 0: aaaabbbb (01230123)
For this, explaining the bit-stream format with a diagram, or more simply, the way I just did with only text (actually write "Byte 0: aaaabbbb (32103210)" in the specification to explain it) is far better than trying to do it with words, this is from personal experience with reading the unclear DEFLATE specification. Also, please don't argue that section "7.1 Integers and byte order" makes this "obvious" just because of the "The highest bit (value 128) of a byte is numbered bit 7; the lowest bit (value 1) is numbered bit 0" part...
The part that says "Pixels within a scanline are always packed into a sequence of bytes with no wasted bits between pixels" is incorrect, because for example, imagine
IHDR.color_type == 0andIHDR.bit_length == 4, and also imagine two pixels:0b1111 (15)and0b111 (7), the wording specifies this packing:The wording could be clearer, maybe something like "Pixels within a scanline are always packed into a sequence of bytes with no wasted bits between pixels (although you must take at least IHDR.bit_length number of bits to pack the pixels[or samples, the word "sample" can also be used here, I don't know which one is preferable]. For example, if you have a IHDR.bit_length of 4 and sample value of 7 (0b111), you must still pack the sample in 4 bits)".
You can argue that since the previous paragraph states "The size of each pixel is determined by the number of bits per pixel." then all the previous wording is not necessary, but from personal experience, I can say this is not the case, it is not that obvious, and there is room for an explicit explanation.
The other thing I consider unclear in this section is the format of the bit-stream of the samples. The specification states "These samples are packed into bytes with the leftmost sample in the high-order bits of a byte followed by the other samples for the scanline" and nothing else, meaning that the bit numbering is unspecified:
For this, explaining the bit-stream format with a diagram, or more simply, the way I just did with only text (actually write "Byte 0: aaaabbbb (32103210)" in the specification to explain it) is far better than trying to do it with words, this is from personal experience with reading the unclear DEFLATE specification. Also, please don't argue that section "7.1 Integers and byte order" makes this "obvious" just because of the "The highest bit (value 128) of a byte is numbered bit 7; the lowest bit (value 1) is numbered bit 0" part...