Seems WB_RGGBLevelsMeasured will not work reliably but WB_RGGBLevelsAsShot seems to work also for auto white balance so why not run calculations only from those numbers.
Second change would be to run cr2hdr default set to grab WB_RGGBLevelsAsShot instead of as now a command line setting. This PR will need some more polishing and testing but right know it works applying CR2 white balance straight away without any command line adding.
Reverting back to original cr2hdr command line options. Too many other functions depending on gray_med and gray_max. Auto wb when using exiv_wb is still fixed though so if testing run CR2 files captured in AWB with --wb=exif command line option to see if white balance match CR2/DNG(remember about slight discrepancy since we still miss the fine tuning CameraCalibration tag)