phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reference encoder not spec compliant: QOI_OP_RUN pixels not put into index array

exodustx0 opened this issue · comments

I'll demonstrate with an example. The image we're trying to encode has, in order:

  1. 1-62 black pixels
  2. 1 white pixel
  3. 1 black pixel

Encoding:

  1. Since black is the starting value for the previous pixel, the first data chunk is a QOI_OP_RUN no matter how many black pixels there are.
  2. All of RGB are -1 compared to black, so the second data chunk is a QOI_OP_DIFF of -1 for all of RGB.
  3. Since the first data chunk is a QOI_OP_RUN and thus its pixel is not put into the index array, and the starting value for the previous pixel isn't written to the index array before the encoding run starts, the third data chunk is a QOI_OP_DIFF, rather than a QOI_OP_INDEX.

Where exactly does the spec disagree with the encoders decision?

Just to be clear, a valid encoder only has to produce a valid QOI file. An encoder may just emit QOI_OP_RGBA chunks and nothing else and it will still be valid.

Where exactly does the spec disagree with the encoders decision?

"Each pixel that is seen by the encoder and decoder is put into [the index] array"
Which isn't the case.

Just to be clear, a valid encoder only has to produce a valid QOI file. An encoder may just emit QOI_OP_RGBA chunks and nothing else and it will still be valid.

Ah, I see. That makes sense, I suppose. My apologies for the misconception.