Panasonic has not published RW2. The tag names here are ExifTool’s and the decoding
follows dcraw. The file starts 49 49 55 00 (IIU), then the
offset of IFD 0 as in a little-endian TIFF file. IFD 0 mixes Panasonic’s own tags (low
numbers) with standard TIFF tags.
Panasonic tags in IFD 0
| Tag | Name | Type | Meaning |
|---|---|---|---|
0x0001 | PanasonicRawVersion | UNDEFINED | Version, as ASCII digits |
0x0002 | SensorWidth | SHORT | Width of the sensor data |
0x0003 | SensorHeight | SHORT | Height of the sensor data |
0x0004–0x0007 | SensorTopBorder, LeftBorder, BottomBorder, RightBorder | SHORT | The visible area within the sensor data |
0x0008 | SamplesPerPixel | SHORT | Samples per pixel |
0x0009 | CFAPattern | SHORT | 0 n/a, 1 RG/GB, 2 GR/BG, 3 GB/RG, 4 BG/GR |
0x000A | BitsPerSample | SHORT | Bits per value, such as 12 |
0x000B | Compression | SHORT | 34316 RAW 1, 34826 RAW 2, 34828 RAW 3, 34830 RAW 4 |
0x000E–0x0010 | LinearityLimitRed, Green, Blue | SHORT | Highest linear value of each colour |
0x0011, 0x0012 | RedBalance, BlueBalance | SHORT | White balance (early cameras such as the Digilux 2) |
0x0013 | WBInfo | – | White balance presets (below) |
0x0017 | ISO | SHORT | ISO speed |
0x0018–0x001A | HighISOMultiplierRed, Green, Blue | SHORT | Gains used at high ISO |
0x001B | NoiseReductionParams | UNDEFINED | A count, then for each entry an ISO and red, green and blue strengths |
0x001C–0x001E | BlackLevelRed, Green, Blue | SHORT | Black level of each colour |
0x0024–0x0026 | WBRedLevel, WBGreenLevel, WBBlueLevel | SHORT | White balance as shot |
0x0027 | WBInfo2 | – | White balance presets with green (below) |
0x002D | RawFormat | SHORT | Version of the raw data coding; values not documented |
0x002E | JpgFromRaw | UNDEFINED | A JPEG preview with its own complete Exif data |
0x002F–0x0032 | CropTop, CropLeft, CropBottom, CropRight | SHORT | Crop applied by the camera |
0x0037 | ISO | LONG | ISO speed in newer cameras |
0x0118 | RawDataOffset | LONG | Where the raw data starts |
0x0119 | DistortionInfo | – | Lens distortion correction (below) |
0x011C | Gamma | SHORT | Gamma |
0x0120 | CameraIFD | – | An IFD of camera settings (below) |
0x0121 | Multishot | LONG | 0 off, 65536 pixel shift |
0x0127 | JpgFromRaw2 | – | A second embedded JPEG |
Standard tags in IFD 0 include Make (0x010F), Model, StripOffsets
(0x0111), Orientation, RowsPerStrip, StripByteCounts, Artist, XMP
(0x02BC), Copyright, IPTC, and the Exif and GPS IFD pointers.
Sub-tables
- WBInfo (
0x0013): shorts. Index 0 is the number of entries; then up to seven pairs of a light source type (Exif LightSource codes) and red and blue levels. - WBInfo2 (
0x0027): the same, with red, green and blue levels for each entry. - DistortionInfo (
0x0119): signed shorts of distortion parameters and a scale; the low 4 bits of one field switch the correction off (0) or on (1). The model behind the parameters is not documented. - CameraIFD (
0x0120): an IFD with tags such as0x1201and0x1202(lens make and model),0x1301–0x1303(aperture, shutter speed, sensitivity),0x3200–0x3203(daylight white balance per CFA colour) and0x3300(white balance set: 0 auto up to 16).
Raw data
The sensor data starts at RawDataOffset (or StripOffsets). Older RW2 files are either unpacked or use the original Panasonic compression below, which dcraw decodes. Newer cameras use further coding versions (RawFormat values beyond the original), supported in LibRaw but not publicly specified; they are not described here.
The original compression reads the data in blocks of 16384 bytes. Each block is
stored rotated: to rebuild it, move its last 0x2008 bytes to the front. Bits are then
read with a position p that starts at 0 for each block and, for each read of n bits,
becomes (p − n) mod 0x20000; the bits are taken from the 16-bit
little-endian value at byte (p >> 3) XOR 0x3FF0, shifted right by
p mod 8. Each row is coded in groups of 14 pixels, with a predictor for
even and one for odd columns:
at the start of each 14-pixel group: pred[0] = pred[1] = nonz[0] = nonz[1] = 0
for each pixel, i = column mod 14, c = i mod 2:
if i mod 3 == 2: sh = 4 >> (3 - read 2 bits)
if nonz[c]:
j = read 8 bits
if j != 0:
pred[c] -= 0x80 << sh
if pred[c] < 0 or sh == 4: pred[c] &= (1 << sh) - 1
pred[c] += j << sh
else:
nonz[c] = read 8 bits
if nonz[c] != 0 or i > 11: pred[c] = nonz[c] << 4 | read 4 bits
value = pred[c]
Values are 12-bit. The pixels of each row are all coded, including any beyond the visible width.