lclevy / canon_cr3

Describing the Canon CR3 fileformat from Canon M50 / EOS R / SX70 HS / EOS RP...
GNU General Public License v3.0
276 stars 34 forks source link

CMP1 structure #7

Closed Alexey-Danilchenko closed 5 years ago

Alexey-Danilchenko commented 5 years ago

Correct structure of CMP1 tag (terminology and structure from internals of CRX decoder). In terms of CRX decoder this CMP1 is essentially image header for encoded image (exists for each image track). Decoder uses CMP1 data to decode image track.

CMP1

Offset type size content
0 long 1 size of this tag. 0x3c
4 char 4 "CMP1"
8 short 1 ? FF 00
10 short 1 0x30 - size of the image header to follow
12 short 1 version - always 0x100 for current CR3 (major.minor version in bytes?)
14 bytes 2 00 00
16 long 1 image width
20 long 1 image height
24 long 1 tile width
28 long 1 tile height
32 bytes 1 bits per sample - usually 0xE
33 bits 4 number of planes - 4 for RGGB
33+4bits bits 4 CFA layout (valid values 0..3) - only valid where number of planes > 1
34 bits 4 extra bits per sample - only 1 or 3
34+4bits bits 4 number of wavelet levels (set for wavelet compressed image)
35 bits 1 1 = image has more than one tile horisontally (set for wavelet compressed image)
35+1bit bits 1 1 = image has more than one tile vertically (set for wavelet compressed image)
35+2bit bits 6 unused in current version - always 0
36 long 1 mdat track header size (mdat bitstream data starts following that header)
40 long 1 0
44 bytes 16 ? 4 times "01 01 00 00"
lclevy commented 5 years ago

Thank you a lot!

lclevy commented 5 years ago

I have these values for bytes 33 and 34:

33 byte 1 raw small = 41, raw big = 40, craw small = 41, craw big = 40
34  byte  raw small = 00, raw big = 00, craw small = 03, craw big = 03

following values are 4 bits: at 33, number of plane is 4, OK at 33+4bits is always 1 for small, 0 for big. extra bits ? at 34 is always 0. CFA ? at 34+4bits 0 (raw) or 3 (craw). seems wavelets levels, yes

Alexey-Danilchenko commented 5 years ago

Just to make it clear the information I provided is not a guess from a data and is based on internals of CRX decoder.

33+4bits is CFA layout. It will be different for different type of raw cameras and images. The values are 0..3 (at least those are the ones that CRX decoder uses).

The meaning for 34 (first 4 bits) I already specified - they may not exist in raw files yet but they are there. They are used by decoder to calculate the sample size in bits (that may be larger than raw bits).

lclevy commented 5 years ago

ok. do you confirm structures of ff01, ff02 and ff03 headers ?