Soft-mode spectroscopy of the improper ferroelastics Hg2Cl2 and Hg2Br2