BinomialLLC / basis_universal

Basis Universal GPU Texture Codec
Apache License 2.0
2.73k stars 267 forks source link

Clarify handling of non-complete Huffman tables #263

Open lexaknyazev opened 3 years ago

lexaknyazev commented 3 years ago

Usually, Huffman tables are required to be complete, i.e., they fully cover all potential symbols within the maximum code length.

BasisU makes an exception for tables containing only one used symbol, thus leaving codes like 1.... undefined. https://github.com/BinomialLLC/basis_universal/blob/646a9f826131cb0b9e14b5e4740874808315f83a/transcoder/basisu_transcoder_internal.h#L163-L164

Even if the encoder never produces such invalid sequences, the bitstream documentation should address this.

richgel999 commented 3 years ago

Got it - will clarify.

richgel999 commented 1 year ago

I've added a note to the spec (section 6.0): https://github.com/BinomialLLC/basis_universal/wiki/.basis-File-Format-and-ETC1S-Texture-Video-Specification

Note: It's possible, just like in Deflate, for a Huffman table to be incomplete containing only a single symbol with a code length of 1 bit. In this case, this symbol will be assigned a code of "0".