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.
This commit is contained in:
Martin Storsjö
2014-12-16 11:08:19 +02:00
parent a9c2e1b431
commit 59fefbe7c7
3 changed files with 17 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ if (iNum==0) { \
iTc[0] = iTc[1] = iTc[2] = iTc[3] = 25; \
pBase[0] = pRef[0] = 128; \
for (int i = 1; i < iWidth*iWidth; i++) { \
pBase[i] = pRef[i] = WELS_CLIP3( pBase[i-1] -16 + rand()%32, 0, 255 ); \
pBase[i] = pRef[i] = WelsClip3( pBase[i-1] -16 + rand()%32, 0, 255 ); \
} \
} else if (iNum==1) { \
iAlpha = 4; \
@@ -34,7 +34,7 @@ if (iNum==0) { \
iTc[0] = iTc[1] = iTc[2] = iTc[3] = 9; \
pBase[0] = pRef[0] = 128; \
for (int i = 1; i < iWidth*iWidth; i++) { \
pBase[i] = pRef[i] = WELS_CLIP3( pBase[i-1] -4 + rand()%8, 0, 255 ); \
pBase[i] = pRef[i] = WelsClip3( pBase[i-1] -4 + rand()%8, 0, 255 ); \
} \
} else { \
iAlpha = rand() % 256; \