Access demosaiced image with no processing

In our application we would like to access the original camera data.

We have a AVCapturePhoto photo for which isRawPhoto returns true.

If we instantiate a CIFilter with options = [ CIRAWFilterOption.boostAmount: 0.0, CIRAWFilterOption.boostShadowAmount: 0.0, CIRAWFilterOption.colorNoiseReductionAmount: 0.0, CIRAWFilterOption.disableGamutMap: true, CIRAWFilterOption.enableChromaticNoiseTracking: false, CIRAWFilterOption.enableSharpening: false, CIRAWFilterOption.luminanceNoiseReductionAmount: 0.0, CIRAWFilterOption.moireAmount: 0.0, CIRAWFilterOption.noiseReductionAmount: 0.0, CIRAWFilterOption.noiseReductionDetailAmount: 0.0, CIRAWFilterOption.noiseReductionContrastAmount: 0.0, CIRAWFilterOption.noiseReductionSharpnessAmount: 0.0, ] the output image is a non-linearly modified version.

photo.pixelBuffer appears to be in a format unlike any typical mosaic pattern (we have tried all four RGGB GRBG GBRG BGGR). Applying demosaic as per any of the patterns renders the repeated image in three vertical overlapping bands.

Is there any way of only applying demosaic to the image, or is there any documentation on the pixelBuffer format?
Edit: We have now been able to decode the pixelBuffer. However Apple's native demosaic code is faster than our own. Is there a way to get the image with only a demosaic applied? Even with all the options mentioned earlier, several non-linear changes are made.
Don't know if it's any help in your case but notice that you can insert a filter at the linear stage via the kCIInputLinearSpaceFilter
option
carstengp: I tried that but couldn't seem to extract the image from it. How would you do that?
Some more info: when disabling all processing options (eg. boostAmount = 0, boostShadowAmount = 0, disableGamutMap = true, colorNoiseReductionAmount = 0, etc.) resulting DNG in Raw Therapee has some modifications enabled such as "Clip out-of-gamut colours" and "Highlight reconstruction".
Access demosaiced image with no processing
 
 
Q