Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panasonic Lumix DC GH6 RW2 raw format support #6469

Open
esby opened this issue Apr 30, 2022 · 9 comments · May be fixed by #7018 or #7020
Open

Panasonic Lumix DC GH6 RW2 raw format support #6469

esby opened this issue Apr 30, 2022 · 9 comments · May be fixed by #7018 or #7020
Labels
scope: file format Camera or image file formats type: enhancement Something could be better than it currently is
Milestone

Comments

@esby
Copy link

esby commented Apr 30, 2022

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
Copy link
Author

esby commented Apr 30, 2022

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)

@Thanatomanic Thanatomanic added type: enhancement Something could be better than it currently is scope: file format Camera or image file formats labels Apr 30, 2022
@Thanatomanic
Copy link
Contributor

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

@Thanatomanic
Copy link
Contributor

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...

@esby
Copy link
Author

esby commented May 3, 2022

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)

@SimonSegerblomRex
Copy link
Contributor

@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.

@cytrinox
Copy link

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.

@SimonSegerblomRex
Copy link
Contributor

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.

@esby
Copy link
Author

esby commented Jun 27, 2022

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

@seriousm4x
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: file format Camera or image file formats type: enhancement Something could be better than it currently is
Projects
None yet
6 participants