About the algorithm of decompressing Panasonic RW2

Hi all, I’m working on a library to decode RAW files.

I found two resources about decompression algorithms for panasonic rw2.

  1. from rawspeed
  2. from dcraw/libraw

But I just don’t know how they know the exact algorithm for decompressing raw bytes? I didn’t find any official documents or articles about Panasonic raw file encoding and compression details.

I would like to know where I can get this information instead of just copying the code from rawspeed/libraw to my library?

Thanks.

I don’t have a proper answer to your question, but maybe if the algorithm was reverse engineered a lot of smart guesses were involved.

The more important question that I am interested in: for what reason are you creating your own raw decoder?

2 Likes

A lot of smart guesses, and in many cases someone with a copy of the firmware or “official” manufacturer tools and a copy of IDA Pro along with the knowledge of how to use it.

(For example, the Nikon community likely has gotten quite a few useful bits from the NikonHacker crew, like leegong. leegong has poked at some Sony lens and body firmware products too that greatly helped some of my own lens protocol work - E-mount electronic protocol reverse engineering - Dyxum - Page 1 )

1 Like

For my raw culling software, posted here: I've created a new software to cull and pick raw photos.

I found libraw to be a bit slow, so I tried to create a faster library written in rust. In my test of the current version rendering some uncompressed raw files, it took only 1/3 - 1/2 of the time of libraw.

Thanks, that’s very helpful.

I dunno what @cytrinox did for dnglab, but check it here: https://github.com/dnglab/dnglab

1 Like

Here is an explanation of the panasonic raw compression algorithm, well at least one of 4:

https://www.dpreview.com/forums/post/40154581
https://www.dpreview.com/forums/post/37499126

Why 4? Because it says here
https://exiftool.org/TagNames/PanasonicRaw.html
that
0x000b Compression has 4 possible values.

Besides I just want to develop DC-S1 Raw files, and the missing bit is the lens correction. Would be thankful if your tool would accomplish this as first. I’m a big fan of Rust, although I cannot write it.

1 Like