Parsing jpeg file, SOS marker
Asked Answered
G

1

7

I'm having problem with parsing jpeg file. When I hit SOS (start of scan) marker, there are few bytes which meaning I don't understand. In picture bellow, after SOS marker, there are 2 bytes for header length (Ls part on the picture). But what the rest of data on picture mean (for example Ns, Cs1 etc....), and where the pure data starts? SOS jpeg file header

Gauntry answered 14/12, 2011 at 20:39 Comment(0)
R
6

Cs1 is a components selection index, This refers back to the SOF section (where horizontal and vertical sampling factors are specified)

Td1 is the DC table selector for the current component (Cs1)

Ta1 is the AC table selector for the current component (Cs1)

Ss, Se and Ah,Al define the spectral selection for the current scan data (this is used in progressive bitmaps. In the first round of rendering, only lower frequencies are shown, in the final round, more detailed frequencies are shown)

The scan data starts after Al

In summary,

SOS (2 bytes)
Ls (2 Bytes)
Ns (1 byte)
Component Specific Parameters (Ns * 2 bytes)
Ss (1 byte)
Se (1 byte)
Ah,AL (1 byte)
... scan data ...
Recrement answered 14/12, 2011 at 21:41 Comment(4)
Thx for your answer, but except of Component-Specification parameters do I need any other bytes to make original picture (I have already generated Huffman table and codes, and read Quantization tables)Gauntry
For a simple jpeg, you'll need height, width, horizonatal and vertical sampling factors, huffman tables, quantization tables, restart marker (optional), Cs1, Cs2, Cs3 and of course the scan data itself. For a progressive jpg you'll have more than one frameRecrement
how do I know is it progressive and what is difference between simple jpeg and progressive jpeg?Gauntry
the spec you have will explain progressive jpegs much better than I can - in short, you have more than one scan section.Recrement

© 2022 - 2024 — McMap. All rights reserved.