Raw file format

Home
Up
Jake's description
Paul's description

Here is my description of Minolta RAW file format. It's based on work of Paul K. Hansen and Jake. All this information is unconfirmed by Minolta and is just my guess based on experiments and hex editor so use it carefully. If you have any comments please let me know by e-mail.

Jake's description is here (or my mirror here)
Paul K. Hansen's work is here (or as a text file)
Thanks to Patrick Porlan for help

Version 1.02 published on 25.10.2002. Changes in: MRM, WBG, values > 3965.
Version 1.03 published on 30.7.2004. Changes: some info in A1,A2; new information in PRD block deciphered by Cliff Biffle.
Version 1.04 published on 1.6.2005. Changes: some info for A200; fixed typos in WBG block.

Basic structure of .mrw file is here:

MRM Block

PRD Block

Picture Raw Dimensions
Here is a file format version, size of the image in pixels.

TTW Block

Tiff Tags W???
This is a classic TIFF header with offset to IFDs containing the TIFF tags, EXIF tags, PIM info, thumbnails,...

WBG Block

White Balance Gains
Here are white balance coefficients measured when taking the picture.

RIF Block

Requested Image Format
This block contains instructions for DIVU about how to create a resulting image (sharpness, saturation, white balance, ...)

PAD Block

Zero PADding
Here are zeroes used to align the next block to 512 bytes boundary. Therefore the maximum length of this block should be 511 bytes with header.

 Image Data

 

Image Data
Here are the RAW image data read from CCD.
These are 16bit values of R, G, G' and B cells arranged in lines.
Odd rows are RGRGRGRG...
Even Rows are GBGBGBGB...

The A1 and A2 cameras do pack the image data. See below.
A200 uses different Bayer pattern (GBRG)

 

 

 

 

 

 

 

 

 

 

 

 

 


Every block in MRM (Minolta Raw M???) has this structure:

Block Name 4 bytes ex. 00 'M' 'R' 'M'
Block Length 4 bytes
big endian
(Mac style)
ex. 0x00007BF8
Block Data misc data see below

 

 

 

 

 

The length of whole block is then "Block Length" + 8.


0. MRM Block (Minolta Raw M???)

This superblock contains all the rest blocks (except image data)

Name

Offset

Size

Meaning

Block Name

0 4

Block name 00 'M' 'R' 'M'

Block Length

4 4

Length of the block
This is total length of all the rest blocks
Also this value + 8 is offset to RAW image data

Block Data

8  

Here are stored blocks PRD, TTW, WBG, RIF and PAD

 

 

 

 

 


1. PRD Block (Picture Raw Dimensions)

All numbers are stored in big endian format (Macintosh/Motorola style). Offset is counted from start of Block Data. This means that you have to add 8 to get offset from start of block. Size is in bytes.

Name

Offset

Size

Meaning

Version Number

0 8

This number describes camera which has taken the picture and therefore the version of raw file format.
27730001 for D5
27660001 for D7,D7u
27790001 for D7i
27780001 for D7Hi
27820001 for A1
27200001 for A2
27470002 for A200
21810002 for Dynax/Maxxum 7D

CCD Size Y

8 2

Height of the image sensor (number of lines in Image Data)
1544 for D5
1928 for D7xx, A1
2456 for A2

CCD Size X

10 2

Width of the image sensor (number of values in one line of Image Data)
2056 for D5
2568 for D7xx, A1
3272 for A2

Image Size Y

12 2

Height of the resulting image
1544 for D5 (probably a bug, it should be 1536)
1928 for D7 (probably a bug, it should be 1920)
1920 for D7u, D7i, D7Hi, A1
2448 for A2

Image Size X

14 2

Width of the resulting image
2048 for D5
2560 for D7xx, A1
3264 for A2

DataSize

16 1

16 - D5, D7xx - one pixel value (12 bits) is stored using 16 bits in the file
12 - A1, A2 - one pixel value (12 bits) is stored using 12 bits in the file

PixelSize

17 1

12 - all cameras - each pixel carries 12 bits of information

StorageMethod

18 1

0x52 - D5, D7xx - no packing
0x59 - A1,A2 - data is packed

Unknown1

19 1

0x00

Unknown2

20 2

0x0000

BayerPattern

22 2

0x0001 - RGGB
0x0004 - GBRG (A200)

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 


2. TTW Block (Tiff Tags W??)

This is a classic TIFF header as described in TIFF format specification ver. 6.0

Name

Offset

Size

Meaning

Byte order

0 2

MM is used in RAW (big endian, Macintosh/Motorola byte order)

Magic number

2 2

42 (You should know this number - "Life, Universe and Everything...")

Offset of the first IFD

4 4

8 (right next data is the first (and the only) ImageFileDirectory)

IFD - Number of entries

8 2

??? entries for D5
9 entries for D7
10 entries for D7u, D7i, D7Hi

IFD - Entry 1

10 12

Tag: Image Width (0x100)

IFD - Entry 2

22 12

Tag: Image Length (0x101)

IFD - Entry 3

34 12

Tag: Compression (0x103)

IFD - Entry 4

46 12

Tag: Image Description (0x10E)

IFD - Entry 5

58 12

Tag: Camera Make (0x10F)

IFD - Entry 6

70 12

Tag: Camera Model (0x110)

IFD - Entry 7

82 12

Tag: Software (0x131)

IFD - Entry 8

94 12

Tag: Date and Time (0x132)

IFD - Entry 9

106 12

Tag: EXIF IFD offset (0x8769)

IFD - Entry 9

118 12

Tag: PIM IFD offset (0xC4A5)
only for D7u, D7i, D7Hi

Offset of the next IFD

130
(or 118)
4

0 (this was the last IFD)

Values of tags

134
(or 122)
?

Here are the values of the tags described above


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Description of EXIF tags can be found JEITA CP-3451 Standard

I do not know where to get a description of PIM tags. If you know it please let me know by e-mail.
Minolta MakerNote tag (part of EXIF) specification is not publicly available. I have decoded some parts of it and I will publish its structure some day on my website.


3. WBG Block (White Balance Gains)

Name

Offset

Size

Meaning

White Balance R denominator

0 1

Usually 2. Which means that you have to divide the white balance coefficient by 256.

Other values have this meaning:
0 - 64
1 - 128
2 - 256
3 - 512
4 - 1024

White Balance G denominator

1 1

White Balance G' denominator

2 1

White Balance B denominator

3 1

White Balance R nominator

4 2

White balance coefficient for channel R

White Balance G nominator

6 2

White balance coefficient for channel G

White Balance G' nominator

8 2

White balance coefficient for channel G'

White Balance B nominator

10 2

White balance coefficient for channel B

 

 

 

 

 

 

 

 


Usually those coefficient are the same as those in MakerNote in EXIF. This is when G=G'=1.
But there are some shots where G and G's is not equal to one. In this case the MakerNote has different white balance coefficients this time with G=1.
When user chooses in DIVU to use white balance as measured by camera the RAW image data are multiplied by these white balance coefficients.
The meaning of those coefficients depends on the Bayer pattern used by the camera. Usually it is RGGB, but A200 uses GBRG which does change the meaning of the WB coefficients above.


4. RIF Block (Requested Image Format)

Name

Offset

Size

Meaning

Unknown

0 1

???
0 for D7, D7u
1 for D7i, D7Hi

Saturation

1 1

Saturation setting from -3 to 3

Contrast

2 1

Contrast setting from -3 to 3

Sharpness

3 1

Sharpness setting:
-1 for soft
0 for normal
1 for hard

White Balance

4 1

White Balance setting:
0 for Camera Auto WB
1 for Daylight
2 for Cloudy
3 for Tungsten
4 for Fluorescent

Subject Program

5 1

Subject Program setting:
0 for None
1 for Portrait
2 for Text
3 for Night Portrait
4 for Sunset
5 for Sports Action

Film Speed

6 1

ISO speed value
This is a real ISO used by camera.
It is not limited to 100,200,400 and 800.
Here are the intermediate values like 109, 118, 154 too.
ISO = (2^((value/8.0)-1)*3.125)

Color Mode

7 1

Color Mode setting:
0 for Normal color
1 for black&white
2 for vivid color (D7i, D7Hi)
3 for solarization (D7i, D7Hi)
4 for AdobeRGB (D7Hi)

Color Filter

56 1

Color Filter setting from -3 to 3

B&W Filter

57 1

B&W Filter value from 0 to 10 (can be non-zero even when the picture was not taken in B&W mode)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Those values do not reflect camera setting when taking pictures. You can change them with DIVU when you choose different setting for RAW file and save back (works only with DIVU 1, DIVU 2 doesn't save values back to RAW file.).
There are much more values but I was able to decrypt only those in the table. My problem is that I have only a few raw files on my harddisk. If you have a large RAW collection and you are willing to help with the rest please let me know.


5. PAD Block (Padding)

Here are just zeroes used to create a gap so that Raw Image Data start at 512 bytes boundary.


Raw Image Data

The rest of the file are RAW image data read from CCD.
They are stored sequentially in lines.
Length of the line is defined in PRD block.
The number of lines is in PRD block also.
Odd lines are RGRGRG..., even lines are GBGBGB...
Values are 12bit numbers stored in two bytes in big endian byte order.
D5, D7xx: Two pixel values 0x123, 0x456 are stored as 01 23 04 56.
A1, A2: Image data are packed. Two pixel values 0x123, 0x456 are stored as 12 34 56. This method reduces the file size by cca 25%.

It may seem that the largest pixel value is is 0xF7D = 3965
but this in not true there are some pictures with full range of values up to 0xFFF = 4095.
According to latest information by Mark Horton the values >3965 appears only in
pictures taken with aperture f2.8. Because of a large aperture there is a vignetting
in the corners of the image. So the camera multiplies corner values to reduce
this effect. This could then result in values larger than 3965. Here is a picture which
roughly shows the affected areas:


This is a new vignetting compensation mask used in A1 and A2:

There are eight pixels extra in horizontal and vertical directions.
They are lost when interpolating Bayer pattern.
Nice description of Bayer interpolation algorithms by Ting Chen can be found here (here is my pdf mirror).
Very simple one is here and C source of conversion algorithm is here

Nice article about CCD sensors is here.
A site devoted to CCD technology is here.