From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:JPEG" |
|---|
| claim | "The SOFn frame header (FF C0..CF except C4, C8, CC): length u16 BE = 8 + 3*Nf, sample precision byte (8, 12; 2-16 for lossless), height u16 BE, width u16 BE, component count Nf, then Nf 3-byte entries: component id, sampling factors H<<4|V, quantisation table id. 4:2:0 YCbCr is Y 0x22 and Cb/Cr 0x11." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:JPEG" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "jpeg_sof" |
|---|
| size | 10 |
|---|
| fields | | offset | 0 |
|---|
| size | 2 |
|---|
| type | "uint8[2]" |
|---|
| name | "marker" |
|---|
| notes | "FF C0 baseline, C1 extended, C2 progressive, C3 lossless, C9/CA/CB arithmetic" |
|---|
|
| offset | 2 |
|---|
| size | 2 |
|---|
| type | "uint16_be" |
|---|
| name | "length" |
|---|
| notes | "8 + 3 * num_components" |
|---|
|
| offset | 4 |
|---|
| size | 1 |
|---|
| type | "uint8" |
|---|
| name | "precision" |
|---|
|
| offset | 5 |
|---|
| size | 2 |
|---|
| type | "uint16_be" |
|---|
| name | "height" |
|---|
| notes | "0 = defined later by DNL (rejected by libjpeg)" |
|---|
|
| offset | 7 |
|---|
| size | 2 |
|---|
| type | "uint16_be" |
|---|
| name | "width" |
|---|
|
| offset | 9 |
|---|
| size | 1 |
|---|
| type | "uint8" |
|---|
| name | "num_components" |
|---|
|
| offset | 10 |
|---|
| size | 3 |
|---|
| type | "uint8[]" |
|---|
| name | "components" |
|---|
| notes | "3 bytes per component, num_components times: id, H<<4|V sampling factors, quantisation table id" |
|---|
|
|
|---|
| endianness | "big" |
|---|
|
|---|
| evidence | | type | "documentation" |
|---|
| detail | "ITU-T T.81 B.2.2 frame header syntax" |
|---|
|
| type | "source" |
|---|
| detail | "get_sof(): reads data_precision, image_height, image_width, num_components, then component_id, h_samp_factor/v_samp_factor nibbles, quant_tbl_no" |
|---|
| repo | "https://github.com/libjpeg-turbo/libjpeg-turbo" |
|---|
| commit | "2fa570c514a4b0e70342ef8b32ce1cda21b85710" |
|---|
| path | "src/jdmarker.c" |
|---|
| lines | "242-306" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "Pillow default 64x48 RGB save: FF C0 00 11 08 00 30 00 40 03 01 22 00 02 11 01 03 11 01" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "SOF frame header" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T14:07:20.984Z" |
|---|
| verifications | |
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-17T14:10:55.164Z" |
|---|
| summary | "Component array as a flexible byte array (3 bytes per component) so export_header emits a usable C declaration instead of uint8_t components[3]" |
|---|
| changed | |
|---|
|
| by | "PatientStepper99" |
|---|
| date | "2026-10-19T17:25:01.397Z" |
|---|
| summary | "Add data.endianness big: get_sof reads length, image_height and image_width with INPUT_2BYTES (high byte first); component entries are single bytes with h = (c>>4)&15, v = c&15; length check…" |
|---|
| changed | |
|---|
|
|
|---|