Jpeg Basic Format
I’m back at work and as such… have time to post? Now where to begin? For reference, everything beginning with 0x means that it is in Hexadecimal format. If you need to know what that is I can suggest some reading or a quick Google search will fill you in.
I have made progress on breaking down the basic JPEG format. Through reading the ISO standard and various sites online I have found that a JPEG file normally consists of the hex values 0xFFD8 followed by a number of JPEG “markers” until the marker 0xFFD9 which indicates an end of file.
Basically a JPEG Marker is the bytes 0xFF followed by a marker byte which signifies a different piece of the JPEG file. In addition, each JPEG Marker (except for one) follows this pattern…
- Header
- 2 bytes beginning with 0xFF
- Length of data (including length bytes)
- 2 bytes
- Data
- [Length] bytes
The view on disk would be as follows:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| #1 | #2 | #3 … | |||||||||||||
The data can then follow a variety of formats depending on what the marker was. For a breakdown of the major ones visit this site but there are also a variety of proprietary ones that can often tell you a lot about the tools used to create the pictures. For example.. many pictures will actually have the photoshop version and date the picture was edited. Have you ever wondered if a photo was edited? A quick look at the picture’s internals can often tell you a lot about the picture.
So, what is the one that breaks the pattern? 0xFFDA or the “Start of Scan” marker which is the beginning of the actual compressed image data. I will dive into much detail on this later but to start this field should contain no other markers except for possibly 0xFFD[1-7] or the reset marker. (This marker will make it possible to simultaneously decompress different parts of the image) Finally, the image is finished with the bytes 0xFFD9. An overall view would be as follows:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0xFF | 0xD8 | Various Markers | |||||||||||||
| Various Markers cont… | |||||||||||||||
| Various Markers cont… | |||||||||||||||
| 0xFF | 0xDA | Compressed Data | |||||||||||||
| Compressed Data cont… | |||||||||||||||
| Compressed Data cont… | |||||||||||||||
| Compressed Data cont… | 0xFF | 0xD9 | |||||||||||||
