5. Given the quadratic function $f(x)$ satisfies $f(-2)=1$, $f(2)=2$, and $x \leqslant f(x) \leqslant \frac{1}{4}\left(x^{2}+4\right)$ for all real numbers $x$. Then the value of $f(4)$ is ( ).
(A) $\frac{17}{4}$
(B) $\frac{9}{2}$
(C) $\frac{19}{4}$
(D) 5
Let $f(x)=a x^{2}+b x+c(a \neq 0)$.
From the given information, we have
$$
\left\{\begin{array}{l}
f(-2)=4 a-2 b+c=1, \\
f(2)=4 a+2 b+c=2 .
\end{array}\right.
$$

Solving these, we get $b=\frac{1}{4}, c=\frac{3}{2}-4 a$.
Also, $x \leqslant f(x) \leqslant \frac{1}{4}\left(x^{2}+4\right)$ holds for all real numbers $x$, which implies
$$
a x^{2}+(b-1) x+c \geqslant 0
$$

and $\left(a-\frac{1}{4}\right) x^{2}+b x+(c-1) \leqslant 0$
hold for all real numbers $x$.
If $a=\frac{1}{4}$, then $c=\frac{1}{2}$, in which case, $\frac{1}{4} x-\frac{1}{2} \leqslant 0$ does not hold for all real numbers $x$. Therefore, $a \neq \frac{1}{4}$.
Thus, we have
$$
\left\{\begin{array}{l}
a>0, \\
(b-1)^{2}-4 a c \leqslant 0, \\
a-\frac{1}{4}<0, \\
b^{2}-4\left(a-\frac{1}{4}\right)(c-1) \leqslant 0 .
\end{array}\right.
$$
Considering $b=\frac{1}{4}, c=\frac{3}{2}-4 a$, solving the system of inequalities yields $a=\frac{3}{16}$.
When $b=\frac{1}{4}, a=\frac{3}{16}$, we have $c=\frac{3}{4}$.
Thus, $f(x)=\frac{3}{16} x^{2}+\frac{1}{4} x+\frac{3}{4}$.
Therefore, $f(4)=\frac{19}{4}$.