Pressure dependence of the direct optical gap and refractive index of Ge and GaAs