History

Don't reset the random number generator within the unit tests

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.

Martin Storsjö committed 12 years ago

Commit 4f594de1 parent 806e59f16 files · +12 −114Browse files

Showing the changes to test/encoder/EncUT_EncoderMb.cpp (1 of 16 files). Show all

Unified · Split

test/encoder/EncUT_EncoderMb.cpp+6−6
@@ -124,8 +124,8 @@ void TestQuant (uint32_t qp, uint8_t* pSrc, uint8_t* pPred, int16_t* pDct, · 123 unmodified lines
124124 const int16_t* pFfI = g_kiQuantInterFF[6 + qp];
125125 const int16_t* pFfP = g_kiQuantInterFF[qp];
126126 //quant4x4 Intra MB
127− RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth, 0);
128− RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth, rand());
127+ RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth);
128+ RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth);
129129
130130 for (int16_t i = 0; i < 16; i++) {
131131 pDct[i] = pSrc[i] - pPred[i];
@@ -142,8 +142,8 @@ void TestQuant (uint32_t qp, uint8_t* pSrc, uint8_t* pPred, int16_t* pDct, · 10 unmodified lines
142142 }
143143
144144 //quant4x4 DC
145− RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth, 0);
146− RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth, rand());
145+ RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth);
146+ RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth);
147147
148148 for (int16_t i = 0; i < 16; i++) {
149149 pDct[i] = pSrc[i] - pPred[i];
@@ -160,8 +160,8 @@ void TestQuant (uint32_t qp, uint8_t* pSrc, uint8_t* pPred, int16_t* pDct, · 10 unmodified lines
160160 }
161161
162162 //quant4x4 Inter MB
163− RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth, 0);
164− RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth, rand());
163+ RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth);
164+ RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth);
165165
166166 for (int16_t i = 0; i < 64; i++) {
167167 pDct[i] = pSrc[i] - pPred[i];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t