I checked and roughly understood the JPEG encoding algorithm from the wiki page about it.
- Transform to YCbCr, downsample
- Split into 8x8 blocks
- Apply DCT on blocks
- Divide resulting matrices by quantization table entries
- Entropy encoding
I understand that the quantization table in a file depends on what created the image, e.g. a camera manufacturer likely has their own proprietary QT algorithms, photoshop etc have their own QTs, there are public ones, etc. Now, if one opens 'real' JPEG files they may contain several quantization tables. How can this be? I'd assume the decoding algorithm looks like this:
- Decode entropy encoding, receive blocks
- Multiply blocks by quantization table entries
- revert other operations
What does the second/third/... QT do/when is it used? Is there an upper limit on the number of QTs in a JPEG file? When does it happen that a second QT is added to a JPEG file?