History

Use an inline function instead of a macro for clipping which contains rand()

When using a macro, the macro parameters get evaluated multiple times, which means that the rand() value compared actually isn't the same that is used as return value. This makes sure that clipping works as intended for the random tests.

Martin Storsjö committed 11 years ago

Commit 59fefbe1 parent a9c2e1b3 files · +17 −9Browse files

Showing the changes to test/api/encode_decode_api_test.cpp (1 of 3 files). Show all

Unified · Split

test/api/encode_decode_api_test.cpp+7−7
@@ -221,8 +221,8 @@ void EncodeDecodeTestAPI::InitialEncDec (int iWidth, int iHeight) { · 220 unmodified lines
221221
222222 void EncodeDecodeTestAPI::RandomParamExtCombination() {
223223
224− param_.iPicWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
225− param_.iPicHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
224+ param_.iPicWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
225+ param_.iPicHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
226226
227227 param_.fMaxFrameRate = rand() % FRAME_RATE_RANGE + 0.5f;
228228 param_.iUsageType = static_cast<EUsageType> (rand() % 2);
@@ -271,8 +271,8 @@ void EncodeDecodeTestAPI::RandomParamExtCombination() { · 42 unmodified lines
271271 //to do: profile and level id
272272 //pSpatialLayer->uiProfileIdc = 0;
273273 //pSpatialLayer->uiLevelIdc = 0;
274− pSpatialLayer->iVideoWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
275− pSpatialLayer->iVideoHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
274+ pSpatialLayer->iVideoWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
275+ pSpatialLayer->iVideoHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
276276 pSpatialLayer->fFrameRate = rand() % FRAME_RATE_RANGE + 0.5f;
277277 pSpatialLayer->iMaxSpatialBitrate = rand() % BIT_RATE_RANGE;
278278 pSpatialLayer->iSpatialBitrate = rand() % BIT_RATE_RANGE;
@@ -2057,10 +2057,10 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_P) { · 1778 unmodified lines
20572057 }
20582058
20592059 TEST_F (EncodeDecodeTestAPI, SetOptionEncParamExt) {
2060− int iWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
2061− int iHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
2060+ int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
2061+ int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
20622062 float fFrameRate = rand() + 0.5f;
2063− int iEncFrameNum = WELS_CLIP3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM);
2063+ int iEncFrameNum = WelsClip3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM);
20642064 int iSpatialLayerNum = 4;
20652065 int iSliceNum = 1;
20662066 encoder_->GetDefaultParams (&param_);

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