Maximum Huffman Tables in a Standard JPEG Header

A standard JPEG image can define a maximum of 8 Huffman tables within its file headers. These tables are specified using the Define Huffman Table (DHT) marker segment (0xFFC4) defined by the ISO/IEC 10918-1 standard (ITU-T T.81). The specification splits Huffman tables into two functional classes—DC tables and AC tables—and allows up to 4 distinct tables per class.

Breakdown of the 8-Table Limit

In the JPEG standard, Huffman tables are indexed by a 1-byte identifier located inside the DHT marker segment. This byte is divided into two 4-bit nibbles:

Because there are 2 valid classes and 4 valid identifiers per class, a decoder can store a maximum of:

Combined, this yields an absolute maximum of 8 Huffman tables active in a standard JPEG decoder at any given time.

Baseline vs. Extended JPEG Implementations

While the full standard permits 8 tables, constraints depend on the operating mode:

A JPEG file can contain multiple DHT markers or bundle multiple table definitions into a single DHT segment, but it cannot exceed the 4 DC and 4 AC identifier slots without violating the standard.