Sony has not published ARW. This page follows the open source decoders (dcraw and its successors) and ExifTool. An ARW file is a little-endian TIFF file.
Directories
| Directory | Content |
|---|---|
| IFD 0 | A JPEG preview, make and model, the Exif IFD (with Sony’s maker note), and the tags below. |
| IFD 1 | A small JPEG thumbnail. |
| Raw IFD | Reached through SubIFDs (0x014A) on most cameras: ImageWidth, ImageLength, BitsPerSample, Compression, CFA tags, StripOffsets or TileOffsets, and the tone curve 0x7010. |
| SR2 private data | Pointed to by DNGPrivateData (0xC634) in IFD 0: an IFD with the keys to the encrypted SR2 sub-IFD (below). |
SR2 private data
The private IFD holds three tags; the data they point to is encrypted and, once decrypted, is a further IFD with the black levels and white balance.
| Tag | Name | Meaning |
|---|---|---|
0x7200 | SR2SubIFDOffset | Offset of the encrypted sub-IFD |
0x7201 | SR2SubIFDLength | Its length in bytes |
0x7221 | SR2SubIFDKey | The 32-bit key |
0x7250 | MRWInfo | Minolta-style raw information, on some early models |
Decryption works on 32-bit big-endian words. A table of 128 words is seeded from the
key with key = key × 48828125 + 1 for the first four, then each further
word is (pad[p−4] ^ pad[p−2]) << 1 | (pad[p−3] ^ pad[p−1]) >> 31.
Each data word is XORed with pad[p] ^ pad[p+64] (indices modulo 128), and
that value replaces pad[p−1].
Compression
| Compression | Raw data |
|---|---|
| 1 | Uncompressed: 12 or 14-bit values stored in 16 bits each, row by row |
| 32767 | Sony compressed: the lossy 8-bits-per-pixel coding below on almost all cameras; a Huffman coding on the earliest ARW cameras such as the DSLR-A100 |
| 7 | Lossless compressed (newer cameras): tiled lossless JPEG |
Lossy compressed raw
Each row is cut into 32-column stretches. Within a stretch, the 16 pixels of one colour (every other column) are coded in one 16-byte block, then the 16 pixels of the other colour in the next block. A block is read as a little-endian bit string:
| Bits | Field |
|---|---|
| 0–10 | max: the largest value of the 16 |
| 11–21 | min: the smallest value |
| 22–25 | imax: which of the 16 pixels holds max |
| 26–29 | imin: which pixel holds min |
| 30–127 | 14 × 7 bits: the other pixels, in order |
A shift sh is the smallest value from 0 to 4 with
0x80 << sh > max − min. Each 7-bit value v becomes
(v << sh) + min, capped at 2047. The 11-bit results are then mapped
through the tone curve to linear values.
The curve comes from tag 0x7010: four knee points (each stored as a
short and shifted right by 2), between 0 and 4095 on the 12-bit scale. Between
successive knees the slope doubles: 1, 2, 4, 8, 16. dcraw applies it to twice the 11-bit
value.
Early Huffman coding
The earliest ARW cameras coded each column from right to left, even rows first and then odd rows, as lossless-JPEG-style Huffman differences from the previous value, using a fixed table of 18 codes. A running sum gives the 12-bit value.
Earlier formats
Sony’s first raw format, SRF, encrypts the image data itself with the same word cipher; ARW uses it only for the SR2 private data.