How many triplets $(p,q,r)$ of integers between $1$ and $1000$ satisfy $p^2\sin^2x+q\sin2x+r^2\cos^2x>1$, if $\sin x$ and $\cos x$ are non-zero? 
We have an inequality of the form 
  $$p^2\sin^2 x + q\sin2x + r^2\cos^2x > 1$$
  for integers $p$, $q$, $r$ with $1\leq p,q,r \leq 1000$, and such that $x$ cannot be any value that makes $\sin x$ or $\cos x$ equal to $0$.
How many triplets of the form $(p,q,r)$ satisfy the above inequality?   

Note. I actually need a pseudo code for this, but I was stuck in the mathematical approach itself so I came here.

My approach: 
I tried finding an upper bound by breaking $q\sin2x$ as $2q\sin x\cos x$ and clubbing it with the remaining two terms to get something of the form of
$$A\sin x + B\cos x > 1$$
The maximum value of LHS can $\sqrt{A^2+ B^2}$. 
But I haven't made any progress after this. 

Divide both sides by $\cos^2x$ and writing  $\tan x=t$ 
$$p^2t^2+2qt+r^2>1+t^2$$
$$t^2(p^2-1)+2qt+r^2-1>0$$
Now the roots of $$t^2(p^2-1)+2qt+r^2-1=0$$ are $t=\dfrac{-q\pm\sqrt{q^2-(p^2-1)(r^2-1)}}{p^2-1}$
So, either $t>$max $\left(\dfrac{-q+\sqrt{q^2-(p^2-1)(r^2-1)}}{p^2-1},\dfrac{-q-\sqrt{q^2-(p^2-1)(r^2-1)}}{p^2-1}\right)$
or either $t<$ min $\left(\dfrac{-q+\sqrt{q^2-(p^2-1)(r^2-1)}}{p^2-1},\dfrac{-q-\sqrt{q^2-(p^2-1)(r^2-1)}}{p^2-1}\right)$
As $\sin x\cos x\ne0,t$ must be non-zero and finite
