Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef LOOP_MACROS_INCLUDED
Toshihiro Shimizu 890ddd
#define LOOP_MACROS_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
	  assert ((0 <= xI) && (xI <= up->getLx() - 1) && \
Toshihiro Shimizu 890ddd
		  (0 <= yI) && (yI <= up->getLy() - 1)    ); \
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_FIRST                                                   \
Toshihiro Shimizu 890ddd
	xL += deltaXL;                                                                \
Toshihiro Shimizu 890ddd
	yL += deltaYL;                                                                \
Toshihiro Shimizu 890ddd
	xI = xL >> PADN;                                                              \
Toshihiro Shimizu 890ddd
	yI = yL >> PADN;                                                              \
Toshihiro Shimizu 890ddd
	upPix00 = upBasePix + (yI * upWrap + xI);                                     \
Toshihiro Shimizu 890ddd
	upPix10 = upPix00 + 1;                                                        \
Toshihiro Shimizu 890ddd
	upPix01 = upPix00 + upWrap;                                                   \
Toshihiro Shimizu 890ddd
	upPix11 = upPix00 + upWrap + 1;                                               \
Toshihiro Shimizu 890ddd
	xWeight1 = (xL & MASKN);                                                      \
Toshihiro Shimizu 890ddd
	xWeight0 = (1 << PADN) - xWeight1;                                            \
Toshihiro Shimizu 890ddd
	yWeight1 = (yL & MASKN);                                                      \
Toshihiro Shimizu 890ddd
	yWeight0 = (1 << PADN) - yWeight1;                                            \
Toshihiro Shimizu 890ddd
	c1 = MULT_2_X_16BIT(upPix00->r, upPix00->g, xWeight0);                        \
Toshihiro Shimizu 890ddd
	c3 = MULT_2_X_16BIT(upPix00->b, upPix01->r, xWeight0);                        \
Toshihiro Shimizu 890ddd
	c5 = MULT_2_X_16BIT(upPix01->g, upPix01->b, xWeight0);                        \
Toshihiro Shimizu 890ddd
	c2 = MULT_2_X_16BIT(upPix10->r, upPix10->g, xWeight1);                        \
Toshihiro Shimizu 890ddd
	c4 = MULT_2_X_16BIT(upPix10->b, upPix11->r, xWeight1);                        \
Toshihiro Shimizu 890ddd
	c6 = MULT_2_X_16BIT(upPix11->g, upPix11->b, xWeight1);                        \
Toshihiro Shimizu 890ddd
	s_gb = (c5 + c6) >> 16;                                                       \
Toshihiro Shimizu 890ddd
	gColUpTmp = s_gb >> 32;                                                       \
Toshihiro Shimizu 890ddd
	bColUpTmp = s_gb & 0x1FF;                                                     \
Toshihiro Shimizu 890ddd
	s_br = (c3 + c4) >> 16;                                                       \
Toshihiro Shimizu 890ddd
	bColDownTmp = s_br >> 32;                                                     \
Toshihiro Shimizu 890ddd
	rColUpTmp = s_br & 0x1FF;                                                     \
Toshihiro Shimizu 890ddd
	s_rg = (c1 + c2) >> 16;                                                       \
Toshihiro Shimizu 890ddd
	rColDownTmp = s_rg >> 32;                                                     \
Toshihiro Shimizu 890ddd
	gColDownTmp = s_rg & 0x1FF;                                                   \
Toshihiro Shimizu 890ddd
	rCol =                                                                        \
Toshihiro Shimizu 890ddd
		(unsigned char)((yWeight0 * rColDownTmp + yWeight1 * rColUpTmp) >> PADN); \
Toshihiro Shimizu 890ddd
	gCol =                                                                        \
Toshihiro Shimizu 890ddd
		(unsigned char)((yWeight0 * gColDownTmp + yWeight1 * gColUpTmp) >> PADN); \
Toshihiro Shimizu 890ddd
	bCol =                                                                        \
Toshihiro Shimizu 890ddd
		(unsigned char)((yWeight0 * bColDownTmp + yWeight1 * bColUpTmp) >> PADN); \
Toshihiro Shimizu 890ddd
	*dnPix = TPixel32(rCol, gCol, bCol, upPix00->m);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_FIRST_X_2 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST         \
Toshihiro Shimizu 890ddd
	++dnPix;                        \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_FIRST_X_4 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_2     \
Toshihiro Shimizu 890ddd
	++dnPix;                        \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_2
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_FIRST_X_8 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_4     \
Toshihiro Shimizu 890ddd
	++dnPix;                        \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_4
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_FIRST_X_16 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_8      \
Toshihiro Shimizu 890ddd
	++dnPix;                         \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_8
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_FIRST_X_32 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_16     \
Toshihiro Shimizu 890ddd
	++dnPix;                         \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_FIRST_X_16
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_FIRST                                \
Toshihiro Shimizu 890ddd
	a = invAff * TPointD(xMin, y);                             \
Toshihiro Shimizu 890ddd
	xL0 = tround(a.x * (1 << PADN));                           \
Toshihiro Shimizu 890ddd
	yL0 = tround(a.y * (1 << PADN));                           \
Toshihiro Shimizu 890ddd
	kMinX = 0;                                                 \
Toshihiro Shimizu 890ddd
	kMaxX = xMax - xMin;                                       \
Toshihiro Shimizu 890ddd
	kMinY = 0;                                                 \
Toshihiro Shimizu 890ddd
	kMaxY = xMax - xMin;                                       \
Toshihiro Shimizu 890ddd
	if (deltaXL == 0) {                                        \
Toshihiro Shimizu 890ddd
		if ((xL0 < 0) || (lxPred < xL0))                       \
Toshihiro Shimizu 890ddd
			continue;                                          \
Toshihiro Shimizu 890ddd
	} else if (deltaXL > 0) {                                  \
Toshihiro Shimizu 890ddd
		if (lxPred < xL0)                                      \
Toshihiro Shimizu 890ddd
			continue;                                          \
Toshihiro Shimizu 890ddd
		kMaxX = (lxPred - xL0) / deltaXL;                      \
Toshihiro Shimizu 890ddd
		if (xL0 < 0) {                                         \
Toshihiro Shimizu 890ddd
			kMinX = ((-xL0) + deltaXL - 1) / deltaXL;          \
Toshihiro Shimizu 890ddd
		}                                                      \
Toshihiro Shimizu 890ddd
	} else {                                                   \
Toshihiro Shimizu 890ddd
		if (xL0 < 0)                                           \
Toshihiro Shimizu 890ddd
			continue;                                          \
Toshihiro Shimizu 890ddd
		kMaxX = xL0 / (-deltaXL);                              \
Toshihiro Shimizu 890ddd
		if (lxPred < xL0) {                                    \
Toshihiro Shimizu 890ddd
			kMinX = (xL0 - lxPred - deltaXL - 1) / (-deltaXL); \
Toshihiro Shimizu 890ddd
		}                                                      \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	if (deltaYL == 0) {                                        \
Toshihiro Shimizu 890ddd
		if ((yL0 < 0) || (lyPred < yL0))                       \
Toshihiro Shimizu 890ddd
			continue;                                          \
Toshihiro Shimizu 890ddd
	} else if (deltaYL > 0) {                                  \
Toshihiro Shimizu 890ddd
		if (lyPred < yL0)                                      \
Toshihiro Shimizu 890ddd
			continue;                                          \
Toshihiro Shimizu 890ddd
		kMaxY = (lyPred - yL0) / deltaYL;                      \
Toshihiro Shimizu 890ddd
		if (yL0 < 0) {                                         \
Toshihiro Shimizu 890ddd
			kMinY = ((-yL0) + deltaYL - 1) / deltaYL;          \
Toshihiro Shimizu 890ddd
		}                                                      \
Toshihiro Shimizu 890ddd
	} else {                                                   \
Toshihiro Shimizu 890ddd
		if (yL0 < 0)                                           \
Toshihiro Shimizu 890ddd
			continue;                                          \
Toshihiro Shimizu 890ddd
		kMaxY = yL0 / (-deltaYL);                              \
Toshihiro Shimizu 890ddd
		if (lyPred < yL0) {                                    \
Toshihiro Shimizu 890ddd
			kMinY = (yL0 - lyPred - deltaYL - 1) / (-deltaYL); \
Toshihiro Shimizu 890ddd
		}                                                      \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	kMin = tmax(kMinX, kMinY, (int)0);                         \
Toshihiro Shimizu 890ddd
	kMax = tmin(kMaxX, kMaxY, xMax - xMin);                    \
Toshihiro Shimizu 890ddd
	dnPix = dnRow + xMin + kMin;                               \
Toshihiro Shimizu 890ddd
	dnEndPix = dnRow + xMin + kMax + 1;                        \
Toshihiro Shimizu 890ddd
	xL = xL0 + (kMin - 1) * deltaXL;                           \
Toshihiro Shimizu 890ddd
	yL = yL0 + (kMin - 1) * deltaYL;                           \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 32; ++dnPix) {                   \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_FIRST_X_32;                          \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 16; ++dnPix) {                   \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_FIRST_X_16;                          \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 8; ++dnPix) {                    \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_FIRST_X_8;                           \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 4; ++dnPix) {                    \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_FIRST_X_4;                           \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 2; ++dnPix) {                    \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_FIRST_X_2;                           \
Toshihiro Shimizu 890ddd
	}                                                          \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix; ++dnPix) {                        \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_FIRST                                \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_FIRST_X_2 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST         \
Toshihiro Shimizu 890ddd
	++y;                            \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_FIRST_X_4 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_2     \
Toshihiro Shimizu 890ddd
	++y;                            \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_2
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_FIRST_X_8 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_4     \
Toshihiro Shimizu 890ddd
	++y;                            \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_4
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_FIRST_X_16 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_8      \
Toshihiro Shimizu 890ddd
	++y;                             \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_8
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_FIRST_X_32 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_16     \
Toshihiro Shimizu 890ddd
	++y;                             \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_FIRST_X_16
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
	  assert ((0 <= xI) && (xI <= up->getLx() - 1) &&  \
Toshihiro Shimizu 890ddd
		  (0 <= yI) && (yI <= up->getLy() - 1)    ); \
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_SECOND                                                  \
Toshihiro Shimizu 890ddd
	xL += deltaXL;                                                                \
Toshihiro Shimizu 890ddd
	xI = xL >> PADN;                                                              \
Toshihiro Shimizu 890ddd
	upPix00 = upBasePix + (yI * upWrap + xI);                                     \
Toshihiro Shimizu 890ddd
	upPix10 = upPix00 + 1;                                                        \
Toshihiro Shimizu 890ddd
	upPix01 = upPix00 + upWrap;                                                   \
Toshihiro Shimizu 890ddd
	upPix11 = upPix00 + upWrap + 1;                                               \
Toshihiro Shimizu 890ddd
	xWeight1 = (xL & MASKN);                                                      \
Toshihiro Shimizu 890ddd
	xWeight0 = (1 << PADN) - xWeight1;                                            \
Toshihiro Shimizu 890ddd
	c1 = MULT_2_X_16BIT(upPix00->r, upPix00->g, xWeight0);                        \
Toshihiro Shimizu 890ddd
	c3 = MULT_2_X_16BIT(upPix00->b, upPix01->r, xWeight0);                        \
Toshihiro Shimizu 890ddd
	c5 = MULT_2_X_16BIT(upPix01->g, upPix01->b, xWeight0);                        \
Toshihiro Shimizu 890ddd
	c2 = MULT_2_X_16BIT(upPix10->r, upPix10->g, xWeight1);                        \
Toshihiro Shimizu 890ddd
	c4 = MULT_2_X_16BIT(upPix10->b, upPix11->r, xWeight1);                        \
Toshihiro Shimizu 890ddd
	c6 = MULT_2_X_16BIT(upPix11->g, upPix11->b, xWeight1);                        \
Toshihiro Shimizu 890ddd
	s_gb = (c5 + c6) >> 16;                                                       \
Toshihiro Shimizu 890ddd
	gColUpTmp = s_gb >> 32;                                                       \
Toshihiro Shimizu 890ddd
	bColUpTmp = s_gb & 0x1FF;                                                     \
Toshihiro Shimizu 890ddd
	s_br = (c3 + c4) >> 16;                                                       \
Toshihiro Shimizu 890ddd
	bColDownTmp = s_br >> 32;                                                     \
Toshihiro Shimizu 890ddd
	rColUpTmp = s_br & 0x1FF;                                                     \
Toshihiro Shimizu 890ddd
	s_rg = (c1 + c2) >> 16;                                                       \
Toshihiro Shimizu 890ddd
	rColDownTmp = s_rg >> 32;                                                     \
Toshihiro Shimizu 890ddd
	gColDownTmp = s_rg & 0x1FF;                                                   \
Toshihiro Shimizu 890ddd
	rCol =                                                                        \
Toshihiro Shimizu 890ddd
		(unsigned char)((yWeight0 * rColDownTmp + yWeight1 * rColUpTmp) >> PADN); \
Toshihiro Shimizu 890ddd
	gCol =                                                                        \
Toshihiro Shimizu 890ddd
		(unsigned char)((yWeight0 * gColDownTmp + yWeight1 * gColUpTmp) >> PADN); \
Toshihiro Shimizu 890ddd
	bCol =                                                                        \
Toshihiro Shimizu 890ddd
		(unsigned char)((yWeight0 * bColDownTmp + yWeight1 * bColUpTmp) >> PADN); \
Toshihiro Shimizu 890ddd
	*dnPix = TPixel32(rCol, gCol, bCol, upPix00->m);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_SECOND_X_2 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND         \
Toshihiro Shimizu 890ddd
	++dnPix;                         \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_SECOND_X_4 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_2     \
Toshihiro Shimizu 890ddd
	++dnPix;                         \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_2
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_SECOND_X_8 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_4     \
Toshihiro Shimizu 890ddd
	++dnPix;                         \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_4
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_SECOND_X_16 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_8      \
Toshihiro Shimizu 890ddd
	++dnPix;                          \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_8
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INTERNAL_LOOP_THE_SECOND_X_32 \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_16     \
Toshihiro Shimizu 890ddd
	++dnPix;                          \
Toshihiro Shimizu 890ddd
	INTERNAL_LOOP_THE_SECOND_X_16
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_SECOND             \
Toshihiro Shimizu 890ddd
	xL = xL0 + (kMinX - 1) * deltaXL;        \
Toshihiro Shimizu 890ddd
	yL += deltaYL;                           \
Toshihiro Shimizu 890ddd
	yI = yL >> PADN;                         \
Toshihiro Shimizu 890ddd
	yWeight1 = (yL & MASKN);                 \
Toshihiro Shimizu 890ddd
	yWeight0 = (1 << PADN) - yWeight1;       \
Toshihiro Shimizu 890ddd
	dnPix = dnRow + xMin + kMinX;            \
Toshihiro Shimizu 890ddd
	dnEndPix = dnRow + xMin + kMaxX + 1;     \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 32; ++dnPix) { \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_SECOND_X_32;       \
Toshihiro Shimizu 890ddd
	}                                        \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 16; ++dnPix) { \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_SECOND_X_16;       \
Toshihiro Shimizu 890ddd
	}                                        \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 8; ++dnPix) {  \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_SECOND_X_8;        \
Toshihiro Shimizu 890ddd
	}                                        \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 4; ++dnPix) {  \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_SECOND_X_4;        \
Toshihiro Shimizu 890ddd
	}                                        \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix - 2; ++dnPix) {  \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_SECOND_X_2;        \
Toshihiro Shimizu 890ddd
	}                                        \
Toshihiro Shimizu 890ddd
	for (; dnPix < dnEndPix; ++dnPix) {      \
Toshihiro Shimizu 890ddd
		INTERNAL_LOOP_THE_SECOND             \
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_SECOND_X_2 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND         \
Toshihiro Shimizu 890ddd
	++kY;                            \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_SECOND_X_4 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_2     \
Toshihiro Shimizu 890ddd
	++kY;                            \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_2
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_SECOND_X_8 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_4     \
Toshihiro Shimizu 890ddd
	++kY;                            \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_4
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_SECOND_X_16 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_8      \
Toshihiro Shimizu 890ddd
	++kY;                             \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                  \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_8
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// -------------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define EXTERNAL_LOOP_THE_SECOND_X_32 \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_16     \
Toshihiro Shimizu 890ddd
	++kY;                             \
Toshihiro Shimizu 890ddd
	dnRow += dnWrap;                  \
Toshihiro Shimizu 890ddd
	EXTERNAL_LOOP_THE_SECOND_X_16
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif