Quantum field theories in the infinite-momentum frame. I. Quantization of scalar and Dirac fields