Reputation:
I'm in the process of writing a JPEG file decoder to learn about the workings of JPEG files. In working through ITU-T81, which specifies JPEG, I ran into the following regarding the DQT
segment for quantization tables:
In many of JPEG's segments, there is an n
parameter which you read from the segment, which then indicates how many iterations of the following item there are. However, in the DQT case, it just says "multiple", and its not defined how many multiples there are. One can possibly infer from Lq
, but the way this multiple is defined is a bit of an anomaly compared to the other segments.
For anyone who is familiar with this specification, what is the right way to determine how many multiples, or n
, of (Pq
, Tq
, Q0
..Q63
) there should be?
Upvotes: 1
Views: 374
Reputation: 1434
When reading the standard, I was also a bit confused.
If I understand the standard correctly, n
is not explicitly specified. Instead, you start by reading (Pq
, Tq
, Q0
..Q63
). If you are at the end of the segment, defined via Lq
, after reading those, there are no more tables. If you are not at the end of the segment, you read (Pq
, Tq
, Q0
..Q63
) again. Repeat this until you have finally reached the end of the segment.
Upvotes: 0
Reputation: 21647
Take the length field (LQ), subtract the length of the Pq/Tq field (one byte if I remember), and that is N.
Upvotes: 0