wire / wire-format / jpeg-markers

JPEG marker structure

A JPEG file is a sequence of segments, each starting with a marker: 0xFF followed by a non-zero, non-0xFF byte. Standalone markers (SOI 0xFFD8, EOI 0xFFD9, RSTn 0xFFD0-0xFFD7) have no length. All others carry a 2-byte big-endian length (including the length field itself) followed by that many bytes of payload. Common markers: SOF0 (0xFFC0 baseline DCT), DHT (0xFFC4 Huffman table), DQT (0xFFDB quantization table), SOS (0xFFDA start of scan), APP0 (0xFFE0 JFIF), APP1 (0xFFE1 Exif).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: JPEG marker structure

wire format

spec: ITU-T T.81 / ISO/IEC 10918-1

A JPEG file is a sequence of segments, each starting with a marker: 0xFF followed by a non-zero, non-0xFF byte. Standalone markers (SOI 0xFFD8, EOI 0xFFD9, RSTn 0xFFD0-0xFFD7) have no length. All others carry a 2-byte big-endian length (including the length field itself) followed by that many bytes of payload. Common markers: SOF0 (0xFFC0 baseline DCT), DHT (0xFFC4 Huffman table), DQT (0xFFDB quantization table), SOS (0xFFDA start of scan), APP0 (0xFFE0 JFIF), APP1 (0xFFE1 Exif).

fieldsizemeaning
Marker prefix1 byte0xFF.
Marker code1 byte0x00 (stuffed byte) or 0x01 (TEM) or 0xD0-0xD9 (standalone) or 0xC0-0xCF/0xDA-0xFE (with length).
Length2 bytesPayload length + 2, big-endian (only for markers with payload).
Payload= length - 2Marker-specific data (SOF dimensions, DQT tables, SOS component specs, APP metadata, ...).
Entropy-coded datavariableAfter SOS, the entropy-coded segment runs until the next 0xFF 0x00-stuffed or 0xFF (non-zero) marker; 0xFF 0x00 is a stuffed zero.

example:

ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00

SOI + APP0 (JFIF) + DQT (quantization table) start


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/jpeg-markers or /wire-format/jpeg-markers.json