History

Use the common WELS_CLIP3 macro instead of a custom reimplementation

Martin Storsjö committed 11 years ago

Commit a9c2e1b1 parent a4370b81 file · +19 −21Browse files

Showing the changes to test/decoder/DecUT_DeblockCommon.cpp (1 of 1 file). Show all

Unified · Split

test/decoder/DecUT_DeblockCommon.cpp+19−21
@@ -3,8 +3,6 @@ · 2 unmodified lines
33 #include "../../codec/decoder/core/inc/deblocking.h"
44 #include "../../codec/common/inc/deblocking_common.h"
55
6−#define CLIP3(MIN, MAX, VALUE) ((VALUE) < (MIN) ? (MIN) : ((VALUE) > (MAX) ? (MAX) : (VALUE)))
7−
86 using namespace WelsDec;
97
108 /* extern pure C functions */
@@ -28,7 +26,7 @@ if (iNum==0) { \ · 17 unmodified lines
2826 iTc[0] = iTc[1] = iTc[2] = iTc[3] = 25; \
2927 pBase[0] = pRef[0] = 128; \
3028 for (int i = 1; i < iWidth*iWidth; i++) { \
31− pBase[i] = pRef[i] = CLIP3( 0, 255, pBase[i-1] -16 + rand()%32 ); \
29+ pBase[i] = pRef[i] = WELS_CLIP3( pBase[i-1] -16 + rand()%32, 0, 255 ); \
3230 } \
3331 } else if (iNum==1) { \
3432 iAlpha = 4; \
@@ -36,7 +34,7 @@ if (iNum==0) { \ · 1 unmodified line
3634 iTc[0] = iTc[1] = iTc[2] = iTc[3] = 9; \
3735 pBase[0] = pRef[0] = 128; \
3836 for (int i = 1; i < iWidth*iWidth; i++) { \
39− pBase[i] = pRef[i] = CLIP3( 0, 255, pBase[i-1] -4 + rand()%8); \
37+ pBase[i] = pRef[i] = WELS_CLIP3( pBase[i-1] -4 + rand()%8, 0, 255 ); \
4038 } \
4139 } else { \
4240 iAlpha = rand() % 256; \
@@ -113,20 +111,20 @@ void anchor_DeblockingLumaNormal (uint8_t* pPix, int32_t iStrideX, int32_t iStri · 70 unmodified lines
113111 if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
114112 // 8-470
115113 if (abs (p[2] - p[0]) < iBeta) {
116− pPix[iStrideX * -2] = CLIP3 (0, 255, p[1] + CLIP3 (-1 * pTc[iIndexTc], pTc[iIndexTc],
117− ((p[2] + ((p[0] + q[0] + 1) >> 1) - (p[1] << 1)) >> 1)));
114+ pPix[iStrideX * -2] = WELS_CLIP3 (p[1] + WELS_CLIP3 (((p[2] + ((p[0] + q[0] + 1) >> 1) - (p[1] << 1)) >> 1),
115+ -1 * pTc[iIndexTc], pTc[iIndexTc]), 0, 255);
118116 iTc++;
119117 }
120118 // 8-472
121119 if (abs (q[2] - q[0]) < iBeta) {
122− pPix[iStrideX * 1] = CLIP3 (0, 255, q[1] + CLIP3 (-1 * pTc[iIndexTc], pTc[iIndexTc],
123− ((q[2] + ((p[0] + q[0] + 1) >> 1) - (q[1] << 1)) >> 1)));
120+ pPix[iStrideX * 1] = WELS_CLIP3 (q[1] + WELS_CLIP3 (((q[2] + ((p[0] + q[0] + 1) >> 1) - (q[1] << 1)) >> 1),
121+ -1 * pTc[iIndexTc], pTc[iIndexTc]), 0, 255);
124122 iTc++;
125123 }
126124 // 8-467,468,469
127− iDelta = CLIP3 (-1 * iTc, iTc, ((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3));
128− pPix[iStrideX * -1] = CLIP3 (0, 255, (p[0] + iDelta));
129− pPix[0] = CLIP3 (0, 255, (q[0] - iDelta));
125+ iDelta = WELS_CLIP3 (((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3), -1 * iTc, iTc);
126+ pPix[iStrideX * -1] = WELS_CLIP3 ((p[0] + iDelta), 0, 255);
127+ pPix[0] = WELS_CLIP3 ((q[0] - iDelta), 0, 255);
130128 }
131129
132130 // Next line
@@ -196,9 +194,9 @@ void anchor_DeblockingChromaNormal (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iS · 63 unmodified lines
196194 // filterSampleFlag, 8-460
197195 if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
198196 // 8-467, 468, 469
199− iDelta = CLIP3 (-1 * iTc, iTc, ((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3));
200− pPixCb[iStrideX * -1] = CLIP3 (0, 255, (p[0] + iDelta));
201− pPixCb[iStrideX * 0 ] = CLIP3 (0, 255, (q[0] - iDelta));
197+ iDelta = WELS_CLIP3 (((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3), -1 * iTc, iTc);
198+ pPixCb[iStrideX * -1] = WELS_CLIP3 ((p[0] + iDelta), 0, 255);
199+ pPixCb[iStrideX * 0 ] = WELS_CLIP3 ((q[0] - iDelta), 0, 255);
202200 }
203201 pPixCb += iStrideY;
204202
@@ -211,9 +209,9 @@ void anchor_DeblockingChromaNormal (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iS · 6 unmodified lines
211209 // filterSampleFlag, 8-460
212210 if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
213211 // 8-467, 468, 469
214− iDelta = CLIP3 (-1 * iTc, iTc, ((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3));
215− pPixCr[iStrideX * -1] = CLIP3 (0, 255, (p[0] + iDelta));
216− pPixCr[iStrideX * 0 ] = CLIP3 (0, 255, (q[0] - iDelta));
212+ iDelta = WELS_CLIP3 (((((q[0] - p[0]) << 2) + (p[1] - q[1]) + 4) >> 3), -1 * iTc, iTc);
213+ pPixCr[iStrideX * -1] = WELS_CLIP3 ((p[0] + iDelta), 0, 255);
214+ pPixCr[iStrideX * 0 ] = WELS_CLIP3 ((q[0] - iDelta), 0, 255);
217215 }
218216 pPixCr += iStrideY;
219217 }
@@ -235,8 +233,8 @@ void anchor_DeblockingChromaIntra (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iSt · 15 unmodified lines
235233 // filterSampleFlag, 8-460
236234 if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
237235 // 8-480, 487
238− pPixCb[iStrideX * -1] = CLIP3 (0, 255, (2 * p[1] + p[0] + q[1] + 2) >> 2);
239− pPixCb[iStrideX * 0 ] = CLIP3 (0, 255, (2 * q[1] + q[0] + p[1] + 2) >> 2);
236+ pPixCb[iStrideX * -1] = WELS_CLIP3 ((2 * p[1] + p[0] + q[1] + 2) >> 2, 0, 255);
237+ pPixCb[iStrideX * 0 ] = WELS_CLIP3 ((2 * q[1] + q[0] + p[1] + 2) >> 2, 0, 255);
240238 }
241239 pPixCb += iStrideY;
242240
@@ -249,8 +247,8 @@ void anchor_DeblockingChromaIntra (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iSt · 6 unmodified lines
249247 // filterSampleFlag, 8-460
250248 if (abs (p[0] - q[0]) < iAlpha && abs (p[1] - p[0]) < iBeta && abs (q[1] - q[0]) < iBeta) {
251249 // 8-480, 487
252− pPixCr[iStrideX * -1] = CLIP3 (0, 255, (2 * p[1] + p[0] + q[1] + 2) >> 2);
253− pPixCr[iStrideX * 0 ] = CLIP3 (0, 255, (2 * q[1] + q[0] + p[1] + 2) >> 2);
250+ pPixCr[iStrideX * -1] = WELS_CLIP3 ((2 * p[1] + p[0] + q[1] + 2) >> 2, 0, 255);
251+ pPixCr[iStrideX * 0 ] = WELS_CLIP3 ((2 * q[1] + q[0] + p[1] + 2) >> 2, 0, 255);
254252 }
255253 pPixCr += iStrideY;
256254 }

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