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.
Showing the changes to test/api/encode_decode_api_test.cpp (1 of 3 files). Show all
Unified · Split
| @@ -221,8 +221,8 @@ void EncodeDecodeTestAPI::InitialEncDec (int iWidth, int iHeight) { · 220 unmodified lines | ||
| 221 | 221 | |
| 222 | 222 | void EncodeDecodeTestAPI::RandomParamExtCombination() { |
| 223 | 223 | |
| 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); | |
| 226 | 226 | |
| 227 | 227 | param_.fMaxFrameRate = rand() % FRAME_RATE_RANGE + 0.5f; |
| 228 | 228 | param_.iUsageType = static_cast<EUsageType> (rand() % 2); |
| @@ -271,8 +271,8 @@ void EncodeDecodeTestAPI::RandomParamExtCombination() { · 42 unmodified lines | ||
| 271 | 271 | //to do: profile and level id |
| 272 | 272 | //pSpatialLayer->uiProfileIdc = 0; |
| 273 | 273 | //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); | |
| 276 | 276 | pSpatialLayer->fFrameRate = rand() % FRAME_RATE_RANGE + 0.5f; |
| 277 | 277 | pSpatialLayer->iMaxSpatialBitrate = rand() % BIT_RATE_RANGE; |
| 278 | 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 | |
| 2059 | 2059 | 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); | |
| 2062 | 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 | 2064 | int iSpatialLayerNum = 4; |
| 2065 | 2065 | int iSliceNum = 1; |
| 2066 | 2066 | encoder_->GetDefaultParams (¶m_); |