RawTherapee icon indicating copy to clipboard operation
RawTherapee copied to clipboard

Panasonic Lumix DC GH6 RW2 raw format support

Open esby opened this issue 2 years ago • 8 comments

Heya, I got my hands on a GH6 by Panasonic.

The model is branded as "DC-GH6E" on the Panasonic Nomenclature. (don't ask me why it is "DC" and not "DMC", I don't know, the GH5 is also named "DC", GH2 GH3 and GH4 were labelled as DMC ...)

I believe any version of rawtherapee (dev or released) will fail at loading the raws created by it.

The typical error message will be: (filename).RW2: Corrupt data near 0x48c200

From what I looked, the file format changed, it is now using the following information: RT_pana_info.encoding= 8 RT_pana_info.bpp= 16

by looking at rtengine/panasonic_decoders.cc, I assume this new encoding version (8) is new and that there is a method needed that probably would be named as panasonicC8_load_raw() in rtengine/panasonic_decoders.cc

Now, this is not my field of expertise at all and I just don't know what is needed exactly.

The camera can also produce files having an enhanced resolution by merging several photos taken at the same time for a dimension up to 11560 by 8680 pixels, now the format data seems to be the same too (same version and bpp) for those files.

I am providing one raw of one photo.

https://filebin.net/1bh53vgllqhi2oy1/P1000265.RW2

I can also provide sets of white frames if needed, just give me the time to make these.

NB: mirror for the raw files - http://esby.free.fr/perso/GH6-RW2/

esby avatar Apr 30 '22 10:04 esby

set of white frames uploaded there F/5.6 - from 100 to 25600 isos - LENR off. https://filebin.net/w4w7wo1juux5n1sg

(filesize 360 mb)

Not sure I am must do the LENR On, it seems not triggering all the time (eg: it won't trigger for 5s and less than 400 isos, I am kinda lazy to do white frames of 30 seconds over 100 125 160 200 250 and 400 isos)

esby avatar Apr 30 '22 15:04 esby

Thanks @esby. I've downloaded the files and will take a look.

Thanatomanic avatar Apr 30 '22 19:04 Thanatomanic

Figuring out a new decoding algorithm is quite outside my field of expertise, so we must rely on the efforts of others to figure that out first...

Thanatomanic avatar Apr 30 '22 19:04 Thanatomanic

I am trying with various attempts, but for now I keep failing.

Assuming bpp = 16

That would mean that pixperblock = 8

And that for 16 bytes, for each of the 8th values, we get one byte + the other one shifted to the left by 8 (shl 8) in the array of 16 bytes.

But I am just getting garbage as output.

That should looks like:

                (...)
                if (RT_pana_info.bpp == 16) {
                    rowptr[col + 0] = bytes[0] + ((bytes[1] ) << 8);
                    rowptr[col + 1] = bytes[2] + ((bytes[3] ) << 8);
                    rowptr[col + 2] = bytes[4] + ((bytes[5] ) << 8);
                    rowptr[col + 3] = bytes[6] + ((bytes[7] ) << 8);
                    rowptr[col + 4] = bytes[8] + ((bytes[9] ) << 8);
                    rowptr[col + 5] = bytes[10] + ((bytes[11] ) << 8);
                    rowptr[col + 6] = bytes[12] + ((bytes[13] ) << 8);
                    rowptr[col + 7] = bytes[14] + ((bytes[15] ) << 8);
                }
                else
                if (RT_pana_info.bpp == 14) {
                (...)

As a workaround, people can use adobe dng decoder (which works under wine)

esby avatar May 03 '22 10:05 esby

@esby, the image file you uploaded (P1000258.RW2) contains 34 831 360 bytes used for the RAW image data with 5792x4352 pixels. On average that's just a little more than 11 bits per pixel value, so there's obviously some form of compression assuming it should be decoded as 16 bit values. There's no pattern every 16 bytes like with the old types of .RW2 files, so it seems like they came up with some completely new compression scheme. (Instead it looks like they divided the image into two components encoded separately, but I'm no expert.) Shame on Panasonic for not releasing any information about the new format.

SimonSegerblomRex avatar May 18 '22 17:05 SimonSegerblomRex

It's a huffman compression, some new tiff tags (0x0040 etc), contains the huffman tree, init values and more. Seems to be called CF2 codec but I've not found any information on it.

cytrinox avatar May 18 '22 17:05 cytrinox

It's a huffman compression, some new tiff tags (0x0040 etc), contains the huffman tree, init values and more. Seems to be called CF2 codec but I've not found any information on it.

Nice! Then it might not be so difficult to decode the image data after all if you just manage to decode the Huffman codes. The compression ratio is quite similar to what you get with the Lossless JPEG Huffman compression used in DNG.

SimonSegerblomRex avatar May 18 '22 18:05 SimonSegerblomRex

Other random question, even if we use a dng step with Adobe dng_decoder, do we need to adjust the camconst.json file ?

esby avatar Jun 27 '22 13:06 esby

Is there any progress on this? I'm a total noob on decoding images, but a quick google search gives instructions on how to decode huffman images.

seriousm4x avatar Nov 19 '22 14:11 seriousm4x