4. $x$ is a real number, the maximum value of the function $f(x)=4 \cos ^{3} x-3 \cos ^{2} x$ $-6 \cos x+5$ is ( ).
(A) 7
(B) $\frac{27}{4}$
(C) $\frac{25}{4}$
(D) 5
4.B.
$$
\begin{array}{l}
f(x)=(\cos x-1)\left(4 \cos ^{2} x+\cos x-5\right) \\
=(4 \cos x+5)(\cos x-1)^{2} \\
=2\left(2 \cos x+\frac{5}{2}\right)(1-\cos x)(1-\cos x) \\
\leqslant 2\left[\frac{\left(2 \cos x+\frac{5}{2}\right)+(1-\cos x)+(1-\cos x)}{3}\right]^{3} \\
=2\left(\frac{3}{2}\right)^{3}=\frac{27}{4},
\end{array}
$$

The equality holds if and only if $2 \cos x+\frac{5}{2}=1-\cos x$, i.e., $\cos x=$ $-\frac{1}{2}$.