A study of the polarized structure function $g_1^{\rm p}(x,Q^2)$ and the polarized gluon distribution $\Delta g(x,Q^2)$ at HERA