I'm no expert, but wouldn't demosaicing be done before any distortion corrections are applied?
That's my understanding. I believe that DNG files created by Adobe software (DNG convertor, LR, PS) store the main 'raw' image already demosaiced.
I don't think this is correct. A G7X CR2 converted to DNG with Adobe DNG converter is still bayer, and is uncorrected if I look at it in rawtherapee
Every possibility I've done something wrong and my analysis is incorrect
I've redone the earlier test on my G1X, attached are some resulting image comparisons (using Lightroom).
In each image the Canon .CR2 file is on the left, the CHDK DNG on the right.
In the first comparison (IMG_2704), there is no WarpRectilinear in the CHDK DNG file - you can see the distortion compared to the CR2 and the corner vignette.
In the second comparison I took the WarpRectilinear from a DNG converted from the CR2 using the Adobe DNG Convertor. I added this to the opcode list in the CHDK DNG file and took another image (IMG_2707). Using dng_validate I checked that the WarpRectilinear opcode is in the DNG file and has the expected values.
As you can see - the distortion is corrected; but i get funky colours.
Phil.