Ok, silly me, I already found the answer myself. I am writing it up because it is a useful integral for applications. My derivation is a generalization of the answer given here: Evaluating the elliptic integral $\int_{-\pi}^\pi\frac{dx}{\sqrt{(t-2\cos x)^2-4}}$
Consider the integral
$$
I = \int_0^\pi \frac{dx}{\sqrt{(1+A \cos x)(1+B \cos x)}}
$$
of which the integral in my question is a special case $(A = -1/2, B = -1/4)$.
Define
$$
a = \dfrac{1+A}{1-A} \\
b = \dfrac{1+B}{1-B}
$$
and rewrite in the form
$$
I = \frac{ 1 }{\sqrt{(1-A)(1-B)}} \int_0^\pi \frac{dx}{\sqrt{\left(1+ \frac{a-1}{2} ( 1 + \cos x ) \right)\left(1+ \frac{b-1}{2} ( 1 + \cos x) \right)}}
$$
Now substitute $t = \tan \frac x 2$, $\frac 1 2 ( 1 + \cos x) = \cos^2 \frac x 2 = 1/(t^2+1)$. This gives:
$$
I = \frac{ 2 }{\sqrt{(1-A)(1-B)}} \int_0^\infty \frac{dt}{ \sqrt{t^2+a^2} \sqrt{t^2+b^2} }
$$
The integral here can be recognized as the arithmetic-geometric mean of $\sqrt a$ and $\sqrt b$. We can evaluate it by putting $t = b \tan y$. The result is:
$$\begin{align} I &= \frac{ 2 }{\sqrt{(1-A)(1-B)}} \int_0^{\pi/2} \frac{dt}{ \sqrt b \sqrt{1 - \left(1 - \frac a b \right) \cos^2 t} }
\\ &= \frac{2}{\sqrt{(1-A)(1+B)}}
K_M \left( \frac{2B -2A }{(1-A)(1+B)} \right)
\end{align}$$
Here
$$
K_M(m) \equiv \int_0^{\pi/2} \frac{dx}{\sqrt{1-m \sin^2 x}}
$$
is the elliptic integral according to Mathematica's convention.