Quantitative Rotational to Librational Transition in Dense H₂ and D₂