The cast is wrong, you should cast it like this,
(int)(uStartFrame - iFrameOffset) < 1
but this C-style cast is not really C++ style, in your case a static_cast
is preferable:
static_cast<int>(uStartFrame - iFrameOffset) < 1
static_cast<unsigned long>(uStartFrame - iFrameOffset) < 1
Apart from that, when you write int()(x)
you define a function that returns an integer and accepts no parameters, and then invoke it with uStartFrame - iFrameOffset as an argument. It shouldn't even compile, well at least gcc 4.8 rightfully complains about this.
Your compiler obviously does compile it and maybe even wrongly treats it as a function that returns an un-initialized integer, most likely 0, and that possible explains why your loop runs forever.