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
221 221
222void EncodeDecodeTestAPI::RandomParamExtCombination() {222void EncodeDecodeTestAPI::RandomParamExtCombination() {
223 223
224 param_.iPicWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);224 param_.iPicWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
225 param_.iPicHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);225 param_.iPicHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
226 226
227 param_.fMaxFrameRate = rand() % FRAME_RATE_RANGE + 0.5f;227 param_.fMaxFrameRate = rand() % FRAME_RATE_RANGE + 0.5f;
228 param_.iUsageType = static_cast<EUsageType> (rand() % 2);228 param_.iUsageType = static_cast<EUsageType> (rand() % 2);
@@ -271,8 +271,8 @@ void EncodeDecodeTestAPI::RandomParamExtCombination() { · 42 unmodified lines
271 //to do: profile and level id271 //to do: profile and level id
272 //pSpatialLayer->uiProfileIdc = 0;272 //pSpatialLayer->uiProfileIdc = 0;
273 //pSpatialLayer->uiLevelIdc = 0;273 //pSpatialLayer->uiLevelIdc = 0;
274 pSpatialLayer->iVideoWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);274 pSpatialLayer->iVideoWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
275 pSpatialLayer->iVideoHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);275 pSpatialLayer->iVideoHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
276 pSpatialLayer->fFrameRate = rand() % FRAME_RATE_RANGE + 0.5f;276 pSpatialLayer->fFrameRate = rand() % FRAME_RATE_RANGE + 0.5f;
277 pSpatialLayer->iMaxSpatialBitrate = rand() % BIT_RATE_RANGE;277 pSpatialLayer->iMaxSpatialBitrate = rand() % BIT_RATE_RANGE;
278 pSpatialLayer->iSpatialBitrate = rand() % BIT_RATE_RANGE;278 pSpatialLayer->iSpatialBitrate = rand() % BIT_RATE_RANGE;
@@ -2057,10 +2057,10 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_P) { · 1778 unmodified lines
2057}2057}
2058 2058
2059TEST_F (EncodeDecodeTestAPI, SetOptionEncParamExt) {2059TEST_F (EncodeDecodeTestAPI, SetOptionEncParamExt) {
2060 int iWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);2060 int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH);
2061 int iHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);2061 int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT);
2062 float fFrameRate = rand() + 0.5f;2062 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);
2064 int iSpatialLayerNum = 4;2064 int iSpatialLayerNum = 4;
2065 int iSliceNum = 1;2065 int iSliceNum = 1;
2066 encoder_->GetDefaultParams (&param_);2066 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