I apologize, I just noticed how old this thread is and what I think your actual question is. If you are trying to unpack a raw file, take a look at
github.com/jdhill-repo/indi-picamera/blo...er/indi_picamera.cpp
lines 870 to 900. I can't remember exactly where I got the format. Hope this helps.