I recently got a Pixel 4a and have been trying to figure out how to process the raw DNGs from the camera app.
The camera suffers from lens shading: vignetting that’s different for each color channel. The effect is noticeable - if I take a picture of a white surface, and white balance the center so that R=G=B at that point, then at the edges R < G and R < B. The radial vignetting model of lensfun doesn’t work to correct this - it has to be done before demosaic and it may also not be symmetrical if the optical image stabilization has moved the lens off center. It also varies with the focus distance.
The Android OS provides a lens shading map to correct it, which gets embedded in the DNG as GainMap opcodes within the OpcodeList2 tag.
Currently, ART is the only OSS raw converter that supports the GainMap. To enable it, in the Raw group turn on “Flat-Field” and select “Embedded in metadata”.
I’m experimenting with a quick and dirty workaround to process these files with the GainMap applied, in apps that do not support it yet. The raw2dng app compiles on Linux and includes the Adobe DNG SDK, so I used a fork of that as a starting point and added a new script dngpreprocess.
It takes a dng from the Google Camera app, loads it, applies the first few steps of processing, and writes it back out as a dng. It subtracts the black levels, converts from integer data to floating point scaled from 0 to 1, applies the GainMap, and writes it out as a floating point dng, still mosaiced. The resulting files seem to work with darktable, RawTherapee, rawproc, and Filmulator.
It doesn’t keep the preview image from the input dng. I couldn’t figure out a way to copy it from the input dng to the output dng, and when I tried to copy the code that generates the preview image from raw2dng it crashed.
There is also an option to replace the embedded camera profile with a dcp file. This may be useful with third party camera apps, which get a possibly questionable camera profile from the Android OS on the Pixel phone and write it to the dng, to replace it with the different profile used by the Google Camera app.