Images compressed with the JPEG progressive mode can have multiple scans. From what I understand, each scan can have its own Huffman table, as the default Huffman tables from the JPEG standard are not suitable, e.g. for the last scans, which commonly only carry the LSBs.
When I open a progressive JPEG in the hex editor, analyzing the JPEG segments, I still see a DHT segment, holding one or two, not standard Huffman tables.
My question is, what is this table used for? As each scan can have a different Huffman table, I will not be able to use this one to decode the data. Also, the Huffman tables of each scan are apparently to be found in the image data. How are they found by the decoder? JPEG usually uses FF markers with length annotations. Is this not the case for Huffman tables of scans in progressive images? Also, I am wondering if it is efficient to have a Huffman table for each scan separately. I can imagine that some scans would have similar tables.
Edit:
When I open a progressive JPEG in the hex editor, [...] I still see a DHT segment, holding one or two, not standard Huffman tables. [...] what is this table used for?
The table(s) stored in the first DHT segment of the JPEG file hold the table(s) used for the first scan. It usually holds the DC coefficients of all channels. Therefore there are commonly two tables for the first scan of color images (DC luminance, DC chrominance). After the DHT segment(s), a SOS segment follows, holding the image data contained in the first scan. The remainder of the image is an alternation of DHT, SOS segments, followed by the EOI marker.
JPEG usually uses FF markers with length annotations. Is this not the case for Huffman tables of scans in progressive images?
Yes, it is the case also for progressive images. However, many hex editors using patterns skip markers after the first SOS marker. For baseline images, there is only one single SOS segment per file.
I have not found out yet if it is efficient to have a Huffman table stored for each scan separately.