ref: a9c2e1b431ed113da603855c7baf419fbe9c44e6
parent: a4370b8ca8d66eda8209c4e0f8c4cb2c126c8e2e
author: Martin Storsjö <[email protected]>
date: Tue Dec 16 06:03:57 EST 2014
Use the common WELS_CLIP3 macro instead of a custom reimplementation
--- a/test/decoder/DecUT_DeblockCommon.cpp
+++ b/test/decoder/DecUT_DeblockCommon.cpp
@@ -3,8 +3,6 @@
#include "../../codec/decoder/core/inc/deblocking.h"
#include "../../codec/common/inc/deblocking_common.h"
-#define CLIP3(MIN, MAX, VALUE) ((VALUE) < (MIN) ? (MIN) : ((VALUE) > (MAX) ? (MAX) : (VALUE)))
-
using namespace WelsDec;
/* extern pure C functions */
@@ -28,7 +26,7 @@
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] = CLIP3( 0, 255, pBase[i-1] -16 + rand()%32 ); \
+ pBase[i] = pRef[i] = WELS_CLIP3( pBase[i-1] -16 + rand()%32, 0, 255 ); \
} \
} else if (iNum==1) { \
iAlpha = 4; \
@@ -36,7 +34,7 @@
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] = CLIP3( 0, 255, pBase[i-1] -4 + rand()%8); \
+ pBase[i] = pRef[i] = WELS_CLIP3( pBase[i-1] -4 + rand()%8, 0, 255 ); \
} \
} else { \
iAlpha = rand() % 256; \
@@ -113,20 +111,20 @@
if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
// 8-470
if (abs (p[2] - p[0]) < iBeta) {
- pPix[iStrideX * -2] = CLIP3 (0, 255, p[1] + CLIP3 (-1 * pTc[iIndexTc], pTc[iIndexTc],
- ((p[2] + ((p[0] + q[0] + 1) >> 1) - (p[1] << 1)) >> 1)));
+ pPix[iStrideX * -2] = WELS_CLIP3 (p[1] + WELS_CLIP3 (((p[2] + ((p[0] + q[0] + 1) >> 1) - (p[1] << 1)) >> 1),
+ -1 * pTc[iIndexTc], pTc[iIndexTc]), 0, 255);
iTc++;
}
// 8-472
if (abs (q[2] - q[0]) < iBeta) {
- pPix[iStrideX * 1] = CLIP3 (0, 255, q[1] + CLIP3 (-1 * pTc[iIndexTc], pTc[iIndexTc],
- ((q[2] + ((p[0] + q[0] + 1) >> 1) - (q[1] << 1)) >> 1)));
+ pPix[iStrideX * 1] = WELS_CLIP3 (q[1] + WELS_CLIP3 (((q[2] + ((p[0] + q[0] + 1) >> 1) - (q[1] << 1)) >> 1),
+ -1 * pTc[iIndexTc], pTc[iIndexTc]), 0, 255);
iTc++;
}
// 8-467,468,469
- iDelta = CLIP3 (-1 * iTc, iTc, ((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3));
- pPix[iStrideX * -1] = CLIP3 (0, 255, (p[0] + iDelta));
- pPix[0] = CLIP3 (0, 255, (q[0] - iDelta));
+ iDelta = WELS_CLIP3 (((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3), -1 * iTc, iTc);
+ pPix[iStrideX * -1] = WELS_CLIP3 ((p[0] + iDelta), 0, 255);
+ pPix[0] = WELS_CLIP3 ((q[0] - iDelta), 0, 255);
}
// Next line
@@ -196,9 +194,9 @@
// filterSampleFlag, 8-460
if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
// 8-467, 468, 469
- iDelta = CLIP3 (-1 * iTc, iTc, ((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3));
- pPixCb[iStrideX * -1] = CLIP3 (0, 255, (p[0] + iDelta));
- pPixCb[iStrideX * 0 ] = CLIP3 (0, 255, (q[0] - iDelta));
+ iDelta = WELS_CLIP3 (((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3), -1 * iTc, iTc);
+ pPixCb[iStrideX * -1] = WELS_CLIP3 ((p[0] + iDelta), 0, 255);
+ pPixCb[iStrideX * 0 ] = WELS_CLIP3 ((q[0] - iDelta), 0, 255);
}
pPixCb += iStrideY;
@@ -211,9 +209,9 @@
// filterSampleFlag, 8-460
if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
// 8-467, 468, 469
- iDelta = CLIP3 (-1 * iTc, iTc, ((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3));
- pPixCr[iStrideX * -1] = CLIP3 (0, 255, (p[0] + iDelta));
- pPixCr[iStrideX * 0 ] = CLIP3 (0, 255, (q[0] - iDelta));
+ iDelta = WELS_CLIP3 (((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3), -1 * iTc, iTc);
+ pPixCr[iStrideX * -1] = WELS_CLIP3 ((p[0] + iDelta), 0, 255);
+ pPixCr[iStrideX * 0 ] = WELS_CLIP3 ((q[0] - iDelta), 0, 255);
}
pPixCr += iStrideY;
}
@@ -235,8 +233,8 @@
// filterSampleFlag, 8-460
if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
// 8-480, 487
- pPixCb[iStrideX * -1] = CLIP3 (0, 255, (2 * p[1] + p[0] + q[1] + 2) >> 2);
- pPixCb[iStrideX * 0 ] = CLIP3 (0, 255, (2 * q[1] + q[0] + p[1] + 2) >> 2);
+ pPixCb[iStrideX * -1] = WELS_CLIP3 ((2 * p[1] + p[0] + q[1] + 2) >> 2, 0, 255);
+ pPixCb[iStrideX * 0 ] = WELS_CLIP3 ((2 * q[1] + q[0] + p[1] + 2) >> 2, 0, 255);
}
pPixCb += iStrideY;
@@ -249,8 +247,8 @@
// filterSampleFlag, 8-460
if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
// 8-480, 487
- pPixCr[iStrideX * -1] = CLIP3 (0, 255, (2 * p[1] + p[0] + q[1] + 2) >> 2);
- pPixCr[iStrideX * 0 ] = CLIP3 (0, 255, (2 * q[1] + q[0] + p[1] + 2) >> 2);
+ pPixCr[iStrideX * -1] = WELS_CLIP3 ((2 * p[1] + p[0] + q[1] + 2) >> 2, 0, 255);
+ pPixCr[iStrideX * 0 ] = WELS_CLIP3 ((2 * q[1] + q[0] + p[1] + 2) >> 2, 0, 255);
}
pPixCr += iStrideY;
}