title: Get RAW Bayer pixel data from CVPixelBufferRef
body: <p>I am using <code>AVCaptureSession</code> &amp; <code>AVCapturePhotoOutput</code> to capture RAW photo data from device's camera in the <code>kCVPixelFormatType_14Bayer_RGGB</code> format.</p>
  
  <p>I have got as far as getting the raw photo sample buffer in the <code>AVCapturePhotoCaptureDelegate</code> callback:</p>
  
  <pre><code>func capture(captureOutput: AVCapturePhotoOutput,
               didFinishProcessingRawPhotoSampleBuffer rawSampleBuffer: CMSampleBuffer?,
               previewPhotoSampleBuffer: CMSampleBuffer?,
               resolvedSettings: AVCaptureResolvedPhotoSettings,
               bracketSettings: AVCaptureBracketedStillImageSettings?,
               error: Error?) {
  
    guard let rawSampleBuffer = rawSampleBuffer else { return }
  
    guard let pixelBuffer = CMSampleBufferGetImageBuffer(rawSampleBuffer) else { return }
  }
  </code></pre>
  
  <p>I am now attempting to follow the answers to <a href="https://stackoverflow.com/questions/34569750/get-pixel-value-from-cvpixelbufferref-in-swift">this question</a> to obtain pixel values from the <code>CVPixelBufferRef</code> but I cannot work out how to do this when using the 14 bit Bayer RGGB pixel format as opposed to the 32 bit RGB format mentioned in the answers.</p>