I am using LibRaw to decode raw images and modify the raw pixel values. I am comparing the raw pixels (no processing applied in my code) to the 'raw' pixels from the same image after conversion to DNG format using Adobe's DNG Converter. I am accessing the raw pixels by calling LibRaw::open_file() -> LibRaw::unpack() -> LibRaw::raw2image(), and then accessing the pixel values in the imgdata.image structure.
My problem is that sometimes they match with the DNG and sometimes they do not. (At least) one of the discrepancies is caused by the application of the embedded tone curve - it appears that for some cameras this is applied by default during LibRaw::unpack(), but for other cameras it is not (e.g. is for Canon, is not for Sony). Is this correct? If so, how can I determine when it is applied in unpack() and when it is not?
I am writing the raw pixel values back to dng (by modifying the DNG Converted image), and therefore I need to be able to match the pixel values by inverting the tone curve as required. Also, are there any other operations that are applied to the 'raw' pixel values during unpack() that I will need to invert?