RAW file format - RAW Shooting and Processing - CHDK Forum supplierdeeply

RAW file format

  • 7 Replies
RAW file format
« on: 11 / July / 2008, 03:49:49 »
Hi group,
I poked around for a while within this forum and at lots of places elsewhere.
There are many stories how to or not read the CHDK raw files.

But I miss a very simple piece of information: what exactly is the spec of this
file format? Seems to be a 'real raw' format. So it should be possible to describe
this format in less than 10 sentences.

all the best,


Offline LjL

  • ****
  • 266
  • A720IS
Re: RAW file format
« Reply #1 on: 11 / July / 2008, 07:44:28 »
How about 10 words? (This is for the A720IS, and I hope it's correct)

10-bit depth, packed, little-endian, Bayer filter, 3336x2480


Offline BB

  • ***
  • 164
Re: RAW file format
« Reply #2 on: 11 / July / 2008, 11:39:06 »
Here is a website with open source software that reads just about every common RAW format out there...

Decoding raw digital photos in Linux

Dcraw decodes raw photos, not raw files. No digital camera generates raw files in normal usage, there's always a header with useful metadata. (For abnormal usage, see CHDK and DIAG RAW below)
There are dozens of raw photo formats: CRW, CR2, MRW, NEF, RAF, etc. "RAW Format" does not exist; it is an illusion created by dcraw's ability to read all raw formats.



Offline LjL

  • ****
  • 266
  • A720IS
Re: RAW file format
« Reply #3 on: 11 / July / 2008, 11:47:32 »
It's not that easy to understand the format's specification by looking at dcraw's source code.

Re: RAW file format
« Reply #4 on: 11 / July / 2008, 13:19:45 »
Hi group,

thanks for the help. It's indeed easy. The secret in in raw_merge.c  ;)
Needs a simple look into the CHDK source code.
Could have done that first and ask thereafter but this is how life goes.


Re: RAW file format
« Reply #5 on: 27 / July / 2008, 11:56:06 »
@walter42, i couldn't understand entirely the raw_merge.c.  when i open up the .crw files in pyhton, i get the following strings:


looks like series of hexadecimal numbers, but i couldn't see how it was written in the raw_merge.c

is it possible to tell me what i missed?

Re: RAW file format
« Reply #6 on: 28 / July / 2008, 01:55:06 »
this is at the heart of raw_merge:

for (i=0;i<CAM_RAW_ROWPIX;i++) row=0;
  for (nrow=0,j=0;nrow<CAM_RAW_ROWS;nrow++,j++){
  for (i=0,src=0; i<CAM_RAW_ROWPIX; i+=8, src+=10){
  row[i+0]+=((0x3fc&(((unsigned short)rawrow[src+1])<<2)) | (rawrow[src+0] >> 6));
  row[i+1]+=((0x3f0&(((unsigned short)rawrow[src+0])<<4)) | (rawrow[src+3] >> 4));
  row[i+2]+=((0x3c0&(((unsigned short)rawrow[src+3])<<6)) | (rawrow[src+2] >> 2));
  row[i+3]+=((0x300&(((unsigned short)rawrow[src+2])<<8)) | (rawrow[src+5]));
  row[i+4]+=((0x3fc&(((unsigned short)rawrow[src+4])<<2)) | (rawrow[src+7] >> 6));
  row[i+5]+=((0x3f0&(((unsigned short)rawrow[src+7])<<4)) | (rawrow[src+6] >> 4));
  row[i+6]+=((0x3c0&(((unsigned short)rawrow[src+6])<<6)) | (rawrow[src+9] >> 2));
  row[i+7]+=((0x300&(((unsigned short)rawrow[src+9])<<8)) | (rawrow[src+8]));
and it does what others have said here: packed 10 bit data. You need to know c
You can tell the Bayer matrix from a testshot or from the others posts here. Use a red green and blue piece of cardboard.

Regards, Walter


Re: RAW file format
« Reply #7 on: 28 / July / 2008, 05:30:38 »
i've been studying that series of codes. but my real problem is reading what it writes to chdk crw.  like what i've said, i was getting this (\xc1\x1f\x08...) and i don't know how to interpret them. seems to me they are not related at all.  thanks for the reply though.


Related Topics