This fixes running the tests when built with clang in debug mode.
This was accidentally broken in 6e815e708 when switched to using
ENFORCE_STACK_ALIGN_1D instead of manually aligning the buffers.
Previously the aligned pointer always had at least 16 bytes of
extra space in the stack before the pointer, so using [-1] was ok,
while now when using ENFORCE_STACK_ALIGN_1D, it's only guaranteed
that the pointer itself is aligned, but not that there's any extra
space before the pointer. Therefore, we need to manually offset
everything by one kiStride extra. (This already was accounted for
in the total number of bytes allocated for the array.)
This makes sure we don't accidentally return the same sequence
of random numbers multiple times within one test (which would
be very non-random).
Every time srand(time()) is called, the pseudo random number
generator is initialized to the same value (as long as time()
returned the same value).
By initializing the random number generator once and for all
before starting to run the unit tests, we are sure we don't
need to reinitialize it within all the tests and all the
functions that use random numbers.
This fixes occasional errors in MotionEstimateTest.
MotionEstimateTest was designed to allow the test to occasionally
not succeed - if it didn't succeed, it tried again, up to 100 times.
However, since the YUVPixelDataGenerator function reset the random
seed to time(), every attempt actually ran with the same random
data (as long as all 100 attempts ran within 1 second) - thus if
one attempt in MotionEstimateTest failed, all 100 of them would
fail. If the utility functions don't touch the random seed,
this is not an issue.