I'm having difficulty understanding the ITU-T T.81 spec for the JPEG file format. Hopefully someone else here has tried to parse JPEG files and/or knows about the details of this file format.
The spec indiates that the ECS0 segment starts after the SOS segment but I can't find where in the spec it actually talks about the format of the ECS0 segment or how do detect its start. Simple JPEG implementations online are of limited help because they assume many things about the JPEGs they parse.
Can anyone point me in the right direction?
FYI: The JPEG file format spec is here.
When the standard talks about ECS, it doesn't refer to it as a segment type like SOS is, with a header and a size component; it is literally the raw Huffman-compressed bitstream representing the MCU's that comprise the image data. It is padded to fill an integral number of bytes, and can optionally be interleaved with RST headers (formally, RST headers are seperate to the ECS).
When the standard says ECS0, it means the 0th (first) ECS run, rather than a specific ECS type like how SOF0/SOF1/SOF2/etc are different types.
Example for baseline DCT :
FF DA // SOS header
00 08 // 8 bytes
01 // 1 channel
01 00 // channel 1 QT 0 HT 0
00 3F 00 // start/end spectral selector, successive approximation bit high/low
12 34 56 78 ... // Huffman-compressed MCU raw data
(sequence of Fuffman codes looked-up in AC/DC Huffman tables)
FF D9 // EOI
A handy free program for helping to explain the stucture of JFIF is JPEGsnoop ( http://www.impulseadventure.com/photo/jpeg-snoop.html ). There is a 'Full Decode' option in the menu which shows the raw Huffman bitstream, how it maps to Huffman symbols, gets de-quantized and then mapped into DCT components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With