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