The magnification of stars crossing a caustic. I - Lenses with smooth potentials