In a video track (handler vide), each entry of the
stsd atom is an image
description: the common sample description header, fixed video fields, an optional colour
table and then extension atoms. Offsets below count from the start of the entry.
Image description
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | uint32 | sample description size | Bytes in this entry, extensions included. |
| 4 | 4 | FourCC | data format | Compression type or uncompressed pixel format (tables below). |
| 8 | 6 | – | reserved | 0. |
| 14 | 2 | uint16 | data reference index | 1-based index into dref. |
| 16 | 2 | int16 | version | Version of the compressed data; 0 unless the compressor changed its format. |
| 18 | 2 | int16 | revision level | 0. |
| 20 | 4 | FourCC | vendor | Maker of the compressor, often appl. |
| 24 | 4 | uint32 | temporal quality | Degree of temporal compression, 0 to 1023. |
| 28 | 4 | uint32 | spatial quality | Degree of spatial compression, 0 to 1024. |
| 32 | 2 | uint16 | width | Width of the source image in pixels. |
| 34 | 2 | uint16 | height | Height in pixels. |
| 36 | 4 | 16.16 fixed | horizontal resolution | Pixels per inch, usually 72. |
| 40 | 4 | 16.16 fixed | vertical resolution | Pixels per inch. |
| 44 | 4 | uint32 | data size | 0. |
| 48 | 2 | uint16 | frame count | Frames of compressed data per sample, usually 1. |
| 50 | 32 | Pascal string | compressor name | A length byte and up to 31 characters, such as jpeg; the rest is padding. |
| 82 | 2 | int16 | depth | Pixel depth: 1, 2, 4, 8, 16, 24 or 32 for colour (32 only with alpha); 34, 36 and 40 for 2-, 4- and 8-bit greyscale. |
| 84 | 2 | int16 | color table ID | −1: the default colour table for the depth (a standard Macintosh table below 16 bits; none at 16, 24 and 32). 0: a colour table, in the ctab data layout, follows this field. |
| 86 | varies | atoms | extensions | Extension atoms, after the colour table if there is one. |
Some descriptions end with an optional 4-byte terminator of zeros, counted in the size. Anything other than 0 or 4 bytes left over after the last extension means the description is malformed.
Compression types
Apple’s list, which it says is not complete. More codes, including ProRes and the DV variants, are on Data types and codes.
| Code | Format |
|---|---|
cvid | Cinepak |
jpeg | JPEG |
smc | Graphics |
rle | Animation |
rpza | Apple Video (“road pizza”) |
kpcd | Kodak Photo CD |
png | Portable Network Graphics |
mjpa | Motion-JPEG format A |
mjpb | Motion-JPEG format B |
SVQ1 | Sorenson Video 1 |
SVQ3 | Sorenson Video 3 |
mp4v | MPEG-4 Part 2 video (needs esds) |
avc1 | H.264 (needs avcC) |
dvc | NTSC DV-25 |
dvcp | PAL DV-25 |
gif | CompuServe GIF |
h263 | H.263 |
tiff | TIFF |
raw | Uncompressed RGB |
2vuY | Uncompressed Y′CbCr 4:2:2, 8 bits per component |
yuv2 | Uncompressed Y′CbCr 4:2:2, 8 bits per component |
v308 | Uncompressed Y′CbCr 4:4:4, 8 bits per component |
v408 | Uncompressed Y′CbCr 4:4:4:4, 8 bits per component |
v216 | Uncompressed Y′CbCr 4:2:2, 10, 12, 14 or 16 bits per component |
v410 | Uncompressed Y′CbCr 4:4:4, 10 bits per component |
v210 | Uncompressed Y′CbCr 4:2:2, 10 bits per component |
Apple writes the 8-bit 4:2:2 code as 2vuY; files in practice use
2vuy (lower-case y), which is how FFmpeg and Apple’s own Core Video name it.
Extensions
| Atom | Meaning |
|---|---|
gama | 16.16 fixed gamma at which the image was captured. Superseded by colr; ignore it when colr is present. |
fiel | Field handling, two bytes (below). Required for every uncompressed Y′CbCr format. |
mjqt | Default quantisation table for a Motion-JPEG stream. |
mjht | Default Huffman table for a Motion-JPEG stream. |
esds | MPEG-4 elementary stream descriptor; required for mp4v. |
avcC | AVC decoder configuration record; required for avc1. |
pasp | Pixel aspect ratio; required when pixels are not square. |
colr | Colour parameters; required for uncompressed Y′CbCr. |
clap | Clean aperture; required for uncompressed Y′CbCr. |
fiel
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | field count | 1 progressive, 2 interlaced. |
| 9 | 1 | field ordering | When there are two fields, T being the field with the topmost line and B the other (table below). |
| Value | Displayed first | Stored first |
|---|---|---|
| 0 | Only one field. | |
| 1 | T | T |
| 6 | B | B |
| 9 | B | T |
| 14 | T | B |
With two fields, each sample holds two separately compressed images, one per field.
esds and avcC
esds: version (uint8, 0), flags (3 bytes, 0), then an MPEG-4 elementary
stream descriptor as defined in ISO/IEC 14496-1, with the limits of ISO/IEC 14496-14.
Present only with mp4v.
avcC: an AVCDecoderConfigurationRecord as defined in ISO/IEC
14496-15, the same as in MP4. Present only with avc1. Apple’s documentation
stops here; HEVC files use hvc1 or hev1 with hvcC,
also from ISO/IEC 14496-15.
pasp
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 4 | hSpacing | uint32 horizontal spacing of pixels. |
| 12 | 4 | vSpacing | uint32 vertical spacing of pixels. |
Only the ratio matters. Common values:
| Picture | hSpacing | vSpacing |
|---|---|---|
| 4:3 square pixels (composite NTSC or PAL) | 1 | 1 |
| 4:3 non-square 525 (NTSC) | 10 | 11 |
| 4:3 non-square 625 (PAL) | 59 | 54 |
| 16:9 analogue (composite NTSC or PAL) | 4 | 3 |
| 16:9 digital 525 (NTSC) | 40 | 33 |
| 16:9 digital 625 (PAL) | 118 | 81 |
| 1920 × 1035 HDTV (SMPTE 260M-1992) | 113 | 118 |
| 1920 × 1035 HDTV (SMPTE RP 187-1995) | 1018 | 1062 |
| 1920 × 1080 or 1280 × 720 HDTV | 1 | 1 |
colr
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 4 | colour parameter type | nclc for video; prof for print, followed by an ICC profile instead of the fields below. |
| 12 | 2 | primaries index | Chromaticities of the primaries and white point. |
| 14 | 2 | transfer function index | Transfer function between linear RGB and Y′CbCr. |
| 16 | 2 | matrix index | Matrix between R′G′B′ and Y′CbCr. |
| Primaries | Meaning |
|---|---|
| 0 | Reserved |
| 1 | ITU-R BT.709: white 0.3127, 0.3290 (D65); red 0.640, 0.330; green 0.300, 0.600; blue 0.150, 0.060 |
| 2 | Unknown |
| 3, 4 | Reserved |
| 5 | ITU-R BT.601 625-line: white D65; red 0.64, 0.33; green 0.29, 0.60; blue 0.15, 0.06 |
| 6 | ITU-R BT.601 525-line: white D65; red 0.630, 0.340; green 0.310, 0.595; blue 0.155, 0.070 |
| 7, 8 | Reserved |
| 9 | ITU-R BT.2020: white D65; red 0.708, 0.292; green 0.170, 0.797; blue 0.131, 0.046 |
| 10 | Reserved |
| 11 | SMPTE RP 431-2 (DCI P3): white 0.314, 0.351; red 0.680, 0.320; green 0.265, 0.690; blue 0.150, 0.060 |
| 12 | SMPTE EG 432-1 (P3 D65, Display P3): white D65; primaries as index 11 |
| 13 to 65535 | Reserved |
| Transfer function | Meaning |
|---|---|
| 0 | Reserved |
| 1 | ITU-R BT.709-2, SMPTE 274M-1995, 296M-1997, 293M-1996, 170M-1994 |
| 2 | Unknown |
| 3 to 6 | Reserved (MPEG-2’s code 6 is the same curve as 1; writers map 6 to 1) |
| 7 | SMPTE 240M-1995 and 274M-1995 |
| 8 to 16 | Reserved |
| 17 | SMPTE ST 428-1 (peak white normally 48 cd/m²) |
| 18 to 65535 | Reserved |
| Matrix | Meaning |
|---|---|
| 0 | Reserved |
| 1 | ITU-R BT.709-2 (1125/60/2:1 only), SMPTE 274M-1995, 296M-1997 |
| 2 | Unknown |
| 3 to 5 | Reserved |
| 6 | ITU-R BT.601-4 and BT.470-4 System B and G, SMPTE 170M-1994, 293M-1996 |
| 7 | SMPTE 240M-1995, 274M-1995 |
| 8 | Reserved |
| 9 | ITU-R BT.2020 non-constant luminance |
| 10 to 65535 | Reserved |
Apple defines two ways of storing Y′CbCr. Scheme A, wide range: Y′ unsigned over the full range (0 to 255 at 8 bits) and Cb, Cr two’s complement (−127 to +127). Scheme B, video range, as in ITU-R BT.601: Y′ 16 to 235 and Cb, Cr offset binary 16 to 240 at 8 bits; 64 to 940 and 64 to 960 at 10 bits (Apple’s text gives 65 as the lower chroma limit, which differs from BT.601’s 64). In scheme B the values 0 and 255 (8-bit), or 0 to 3 and 1020 to 1023 (10-bit), are reserved for synchronisation and never stored. Values just outside the nominal range carry filter overshoot and must be accepted.
clap
The clean aperture: the part of the stored picture meant to be shown, as a size and an offset of its centre from the picture centre. Each value is a fraction of two int32, a numerator then a denominator (1 for whole numbers).
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 4 | apertureWidth_N | Width in pixels, or its numerator. |
| 12 | 4 | apertureWidth_D | Denominator, or 1. |
| 16 | 4 | apertureHeight_N | Height in lines, or its numerator. |
| 20 | 4 | apertureHeight_D | Denominator, or 1. |
| 24 | 4 | horizOff_N | Horizontal offset of the aperture centre minus (width − 1) ÷ 2, usually 0; or its numerator. |
| 28 | 4 | horizOff_D | Denominator, or 1. |
| 32 | 4 | vertOff_N | Vertical offset of the aperture centre minus (height − 1) ÷ 2, usually 0; or its numerator. |
| 36 | 4 | vertOff_D | Denominator, or 1. |
Width and height must be positive; offsets may be negative.